* What's in linux1394-2.6.git? @ 2009-06-14 10:46 Stefan Richter 2009-06-14 10:48 ` Stefan Richter 2009-06-17 17:44 ` What's in linux1394-2.6.git? -- Part II.0/3 Stefan Richter 0 siblings, 2 replies; 18+ messages in thread From: Stefan Richter @ 2009-06-14 10:46 UTC (permalink / raw) To: linux-kernel; +Cc: linux1394-devel There are two batches in the FireWire/ IEEE 1394 repo, one to be merged soon, and another one which I'm not entirely sure of yet. Both batches deal with the newer firewire drivers only, the older ieee1394 stack is left untouched this time. As usual, the updates can be fetched from git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6.git or browsed at http://git.kernel.org/?p=linux/kernel/git/ieee1394/linux1394-2.6.git I will send a pull request for the 1st batch in the next few days. Batch 1: origin..for-linus ========================== This contains (1.) a few small fixes, (2.) a small addition to firewire-core's sysfs ABI in order to considerably simplify udev rules to set /dev/fw* ownership and ACLs, and (3.) preparations to add more drivers. Of these preparations, the bigger functional enhancements were actually already merged in 2.6.30-rc1; the remaining ones are small functional additions and a total reorganization of files, as you can see in the diffstat. After the udev related change went into mainline, I will send the respective udev rules update to linux-hotplug for inclusion into mainline udev. Stefan Richter (14): firewire: core: improve check for local node firewire: core: check for missing struct update at build time, not run time firewire: core: add sysfs attribute for easier udev rules firewire: share device ID table type with ieee1394 firewire: also use vendor ID in root directory for driver matches firewire: ohci: access bus_seconds atomically firewire: clean up includes firewire: reorganize header files firewire: rename source files firewire: add parent-of-unit accessor firewire: core: include linux/uaccess.h instead of asm/uaccess.h firewire: core: prepare for non-core children of card devices firewire: core: don't update Broadcast_Channel if RFC 2734 conditions aren't met firewire: core: use more outbound tlabels drivers/firewire/Makefile | 8 +- drivers/firewire/{fw-card.c => core-card.c} | 25 +- drivers/firewire/{fw-cdev.c => core-cdev.c} | 13 +- drivers/firewire/{fw-device.c => core-device.c} | 154 ++++- drivers/firewire/{fw-iso.c => core-iso.c} | 6 +- .../firewire/{fw-topology.c => core-topology.c} | 24 +- .../{fw-transaction.c => core-transaction.c} | 36 +- drivers/firewire/core.h | 293 ++++++++ drivers/firewire/fw-device.h | 202 ----- drivers/firewire/fw-topology.h | 77 -- drivers/firewire/fw-transaction.h | 446 ------------ drivers/firewire/{fw-ohci.c => ohci.c} | 19 +- drivers/firewire/{fw-ohci.h => ohci.h} | 6 +- drivers/firewire/{fw-sbp2.c => sbp2.c} | 58 +- include/linux/firewire.h | 357 +++++++++ 15 files changed, 898 insertions(+), 826 deletions(-) rename drivers/firewire/{fw-card.c => core-card.c} (97%) rename drivers/firewire/{fw-cdev.c => core-cdev.c} (99%) rename drivers/firewire/{fw-device.c => core-device.c} (88%) rename drivers/firewire/{fw-iso.c => core-iso.c} (99%) rename drivers/firewire/{fw-topology.c => core-topology.c} (97%) rename drivers/firewire/{fw-transaction.c => core-transaction.c} (98%) create mode 100644 drivers/firewire/core.h delete mode 100644 drivers/firewire/fw-device.h delete mode 100644 drivers/firewire/fw-topology.h delete mode 100644 drivers/firewire/fw-transaction.h rename drivers/firewire/{fw-ohci.c => ohci.c} (99%) rename drivers/firewire/{fw-ohci.h => ohci.h} (98%) rename drivers/firewire/{fw-sbp2.c => sbp2.c} (97%) create mode 100644 include/linux/firewire.h Batch 2: for-linus..for-next ============================ This contains Jay Fenlason's IPv4-over-1394 driver, which is one of the last two or so bigger steps to make drivers/firewire/ a functional superset of drivers/ieee1394/. Alas, the code in here has not been seen on LKML yet, and I recently encountered some stability issues in stress tests of the driver. Jay Fenlason (1): firewire: add IPv4 support Stefan Richter (5): firewire: net: add Kconfig item, rename driver firewire: net: style changes firewire: net: allow for unordered unit discovery firewire: net: remove unused code firewire: net: adjust net_device ops drivers/firewire/Kconfig | 12 + drivers/firewire/Makefile | 4 +- drivers/firewire/core-card.c | 2 + drivers/firewire/core-iso.c | 7 + drivers/firewire/core.h | 87 -- drivers/firewire/net.c | 1655 ++++++++++++++++++++++++++++++++++ drivers/ieee1394/Kconfig | 2 +- include/linux/firewire.h | 87 ++ 8 files changed, 1767 insertions(+), 89 deletions(-) create mode 100644 drivers/firewire/net.c -- Stefan Richter -=====-==--= -==- -===- http://arcgraph.de/sr/ ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: What's in linux1394-2.6.git? 2009-06-14 10:46 What's in linux1394-2.6.git? Stefan Richter @ 2009-06-14 10:48 ` Stefan Richter 2009-06-17 17:44 ` What's in linux1394-2.6.git? -- Part II.0/3 Stefan Richter 1 sibling, 0 replies; 18+ messages in thread From: Stefan Richter @ 2009-06-14 10:48 UTC (permalink / raw) To: linux-kernel; +Cc: linux1394-devel I wrote: > Batch 2: for-linus..for-next > ============================ > > This contains Jay Fenlason's IPv4-over-1394 driver, A note to those who pulled linux1394-2.6.git's "net" branch in the last few days: I deleted this branch, and for-next is not an ancestor of it requeued the IPv4 patches to after the latest firewire-core updates. -- Stefan Richter -=====-==--= -==- -===- http://arcgraph.de/sr/ ^ permalink raw reply [flat|nested] 18+ messages in thread
* What's in linux1394-2.6.git? -- Part II.0/3 2009-06-14 10:46 What's in linux1394-2.6.git? Stefan Richter 2009-06-14 10:48 ` Stefan Richter @ 2009-06-17 17:44 ` Stefan Richter 2009-06-17 17:47 ` What's in linux1394-2.6.git? -- Part II.1/3 Stefan Richter 1 sibling, 1 reply; 18+ messages in thread From: Stefan Richter @ 2009-06-17 17:44 UTC (permalink / raw) To: linux-kernel; +Cc: linux1394-devel There is some more in linux1394's for-next branch for which I plan to send a pull request on Monday. There is Jay Fenlason's IPv4 over FireWire implementation for the newer firewire stack in it (May 18), trivial stylistic changes by me (June 07; sorry for being slow with integration), small fixes to the new driver and to newly discovered bugs of firewire-core (June 14..16). This code has not been seen on LKML yet, hence I will post the combined diff in replies to this message. Repo URL: git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6.git for-next Gitweb: http://git.kernel.org/?p=linux/kernel/git/ieee1394/linux1394-2.6.git Shortlog and diffstat: Jay Fenlason (1): firewire: add IPv4 support Stefan Richter (9): firewire: net: add Kconfig item, rename driver firewire: net: style changes firewire: net: allow for unordered unit discovery firewire: net: remove unused code firewire: net: adjust net_device ops firewire: core: fix DMA unmapping in iso buffer removal firewire: core: fix iso context shutdown on card removal firewire: net: fix card driver reloading firewire: net: better FIFO address range check and rcodes drivers/firewire/Kconfig | 12 + drivers/firewire/Makefile | 4 +- drivers/firewire/core-card.c | 20 +- drivers/firewire/core-iso.c | 11 +- drivers/firewire/core.h | 87 --- drivers/firewire/net.c | 1655 ++++++++++++++++++++++++++++++++++++++++++ drivers/ieee1394/Kconfig | 2 +- include/linux/firewire.h | 87 +++ 8 files changed, 1780 insertions(+), 98 deletions(-) create mode 100644 drivers/firewire/net.c -- Stefan Richter -=====-==--= -==- =---= http://arcgraph.de/sr/ ^ permalink raw reply [flat|nested] 18+ messages in thread
* What's in linux1394-2.6.git? -- Part II.1/3 2009-06-17 17:44 ` What's in linux1394-2.6.git? -- Part II.0/3 Stefan Richter @ 2009-06-17 17:47 ` Stefan Richter 2009-06-17 17:48 ` What's in linux1394-2.6.git? -- Part II.2/3 Stefan Richter 0 siblings, 1 reply; 18+ messages in thread From: Stefan Richter @ 2009-06-17 17:47 UTC (permalink / raw) To: linux-kernel; +Cc: linux1394-devel This is the part of linux1394-2.6.git's current for-linus..for-next combined diff which affects firewire-core: Bug fixes and preparation to add firewire-net. --- drivers/firewire/core-card.c | 20 +++++--- drivers/firewire/core-iso.c | 11 +++- drivers/firewire/core.h | 87 ----------------------------------- include/linux/firewire.h | 87 +++++++++++++++++++++++++++++++++++ 4 files changed, 109 insertions(+), 96 deletions(-) Index: b/drivers/firewire/core-card.c =================================================================== --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c @@ -176,6 +176,7 @@ int fw_core_add_descriptor(struct fw_des return 0; } +EXPORT_SYMBOL(fw_core_add_descriptor); void fw_core_remove_descriptor(struct fw_descriptor *desc) { @@ -189,6 +190,7 @@ void fw_core_remove_descriptor(struct fw mutex_unlock(&card_mutex); } +EXPORT_SYMBOL(fw_core_remove_descriptor); static void allocate_broadcast_channel(struct fw_card *card, int generation) { @@ -459,11 +461,11 @@ EXPORT_SYMBOL(fw_card_add); /* - * The next few functions implements a dummy driver that use once a - * card driver shuts down an fw_card. This allows the driver to - * cleanly unload, as all IO to the card will be handled by the dummy - * driver instead of calling into the (possibly) unloaded module. The - * dummy driver just fails all IO. + * The next few functions implement a dummy driver that is used once a card + * driver shuts down an fw_card. This allows the driver to cleanly unload, + * as all IO to the card will be handled (and failed) by the dummy driver + * instead of calling into the module. Only functions for iso context + * shutdown still need to be provided by the card driver. */ static int dummy_enable(struct fw_card *card, u32 *config_rom, size_t length) @@ -510,7 +512,7 @@ static int dummy_enable_phys_dma(struct return -ENODEV; } -static struct fw_card_driver dummy_driver = { +static const struct fw_card_driver dummy_driver_template = { .enable = dummy_enable, .update_phy_reg = dummy_update_phy_reg, .set_config_rom = dummy_set_config_rom, @@ -529,6 +531,8 @@ void fw_card_release(struct kref *kref) void fw_core_remove_card(struct fw_card *card) { + struct fw_card_driver dummy_driver = dummy_driver_template; + card->driver->update_phy_reg(card, 4, PHY_LINK_ACTIVE | PHY_CONTENDER, 0); fw_core_initiate_bus_reset(card, 1); @@ -537,7 +541,9 @@ void fw_core_remove_card(struct fw_card list_del_init(&card->link); mutex_unlock(&card_mutex); - /* Set up the dummy driver. */ + /* Switch off most of the card driver interface. */ + dummy_driver.free_iso_context = card->driver->free_iso_context; + dummy_driver.stop_iso = card->driver->stop_iso; card->driver = &dummy_driver; fw_destroy_nodes(card); Index: b/drivers/firewire/core-iso.c =================================================================== --- a/drivers/firewire/core-iso.c +++ b/drivers/firewire/core-iso.c @@ -71,7 +71,7 @@ int fw_iso_buffer_init(struct fw_iso_buf for (j = 0; j < i; j++) { address = page_private(buffer->pages[j]); dma_unmap_page(card->device, address, - PAGE_SIZE, DMA_TO_DEVICE); + PAGE_SIZE, direction); __free_page(buffer->pages[j]); } kfree(buffer->pages); @@ -80,6 +80,7 @@ int fw_iso_buffer_init(struct fw_iso_buf return -ENOMEM; } +EXPORT_SYMBOL(fw_iso_buffer_init); int fw_iso_buffer_map(struct fw_iso_buffer *buffer, struct vm_area_struct *vma) { @@ -107,13 +108,14 @@ void fw_iso_buffer_destroy(struct fw_iso for (i = 0; i < buffer->page_count; i++) { address = page_private(buffer->pages[i]); dma_unmap_page(card->device, address, - PAGE_SIZE, DMA_TO_DEVICE); + PAGE_SIZE, buffer->direction); __free_page(buffer->pages[i]); } kfree(buffer->pages); buffer->pages = NULL; } +EXPORT_SYMBOL(fw_iso_buffer_destroy); struct fw_iso_context *fw_iso_context_create(struct fw_card *card, int type, int channel, int speed, size_t header_size, @@ -136,6 +138,7 @@ struct fw_iso_context *fw_iso_context_cr return ctx; } +EXPORT_SYMBOL(fw_iso_context_create); void fw_iso_context_destroy(struct fw_iso_context *ctx) { @@ -143,12 +146,14 @@ void fw_iso_context_destroy(struct fw_is card->driver->free_iso_context(ctx); } +EXPORT_SYMBOL(fw_iso_context_destroy); int fw_iso_context_start(struct fw_iso_context *ctx, int cycle, int sync, int tags) { return ctx->card->driver->start_iso(ctx, cycle, sync, tags); } +EXPORT_SYMBOL(fw_iso_context_start); int fw_iso_context_queue(struct fw_iso_context *ctx, struct fw_iso_packet *packet, @@ -159,11 +164,13 @@ int fw_iso_context_queue(struct fw_iso_c return card->driver->queue_iso(ctx, packet, buffer, payload); } +EXPORT_SYMBOL(fw_iso_context_queue); int fw_iso_context_stop(struct fw_iso_context *ctx) { return ctx->card->driver->stop_iso(ctx); } +EXPORT_SYMBOL(fw_iso_context_stop); /* * Isochronous bus resource management (channels, bandwidth), client side Index: b/drivers/firewire/core.h =================================================================== --- a/drivers/firewire/core.h +++ b/drivers/firewire/core.h @@ -1,7 +1,6 @@ #ifndef _FIREWIRE_CORE_H #define _FIREWIRE_CORE_H -#include <linux/dma-mapping.h> #include <linux/fs.h> #include <linux/list.h> #include <linux/idr.h> @@ -97,17 +96,6 @@ int fw_core_initiate_bus_reset(struct fw int fw_compute_block_crc(u32 *block); void fw_schedule_bm_work(struct fw_card *card, unsigned long delay); -struct fw_descriptor { - struct list_head link; - size_t length; - u32 immediate; - u32 key; - const u32 *data; -}; - -int fw_core_add_descriptor(struct fw_descriptor *desc); -void fw_core_remove_descriptor(struct fw_descriptor *desc); - /* -cdev */ @@ -130,77 +118,7 @@ void fw_node_event(struct fw_card *card, /* -iso */ -/* - * The iso packet format allows for an immediate header/payload part - * stored in 'header' immediately after the packet info plus an - * indirect payload part that is pointer to by the 'payload' field. - * Applications can use one or the other or both to implement simple - * low-bandwidth streaming (e.g. audio) or more advanced - * scatter-gather streaming (e.g. assembling video frame automatically). - */ -struct fw_iso_packet { - u16 payload_length; /* Length of indirect payload. */ - u32 interrupt:1; /* Generate interrupt on this packet */ - u32 skip:1; /* Set to not send packet at all. */ - u32 tag:2; - u32 sy:4; - u32 header_length:8; /* Length of immediate header. */ - u32 header[0]; -}; - -#define FW_ISO_CONTEXT_TRANSMIT 0 -#define FW_ISO_CONTEXT_RECEIVE 1 - -#define FW_ISO_CONTEXT_MATCH_TAG0 1 -#define FW_ISO_CONTEXT_MATCH_TAG1 2 -#define FW_ISO_CONTEXT_MATCH_TAG2 4 -#define FW_ISO_CONTEXT_MATCH_TAG3 8 -#define FW_ISO_CONTEXT_MATCH_ALL_TAGS 15 - -/* - * An iso buffer is just a set of pages mapped for DMA in the - * specified direction. Since the pages are to be used for DMA, they - * are not mapped into the kernel virtual address space. We store the - * DMA address in the page private. The helper function - * fw_iso_buffer_map() will map the pages into a given vma. - */ -struct fw_iso_buffer { - enum dma_data_direction direction; - struct page **pages; - int page_count; -}; - -typedef void (*fw_iso_callback_t)(struct fw_iso_context *context, - u32 cycle, size_t header_length, - void *header, void *data); - -struct fw_iso_context { - struct fw_card *card; - int type; - int channel; - int speed; - size_t header_size; - fw_iso_callback_t callback; - void *callback_data; -}; - -int fw_iso_buffer_init(struct fw_iso_buffer *buffer, struct fw_card *card, - int page_count, enum dma_data_direction direction); int fw_iso_buffer_map(struct fw_iso_buffer *buffer, struct vm_area_struct *vma); -void fw_iso_buffer_destroy(struct fw_iso_buffer *buffer, struct fw_card *card); - -struct fw_iso_context *fw_iso_context_create(struct fw_card *card, - int type, int channel, int speed, size_t header_size, - fw_iso_callback_t callback, void *callback_data); -int fw_iso_context_queue(struct fw_iso_context *ctx, - struct fw_iso_packet *packet, - struct fw_iso_buffer *buffer, - unsigned long payload); -int fw_iso_context_start(struct fw_iso_context *ctx, - int cycle, int sync, int tags); -int fw_iso_context_stop(struct fw_iso_context *ctx); -void fw_iso_context_destroy(struct fw_iso_context *ctx); - void fw_iso_resource_manage(struct fw_card *card, int generation, u64 channels_mask, int *channel, int *bandwidth, bool allocate); @@ -285,9 +203,4 @@ void fw_flush_transactions(struct fw_car void fw_send_phy_config(struct fw_card *card, int node_id, int generation, int gap_count); -static inline int fw_stream_packet_destination_id(int tag, int channel, int sy) -{ - return tag << 14 | channel << 8 | sy; -} - #endif /* _FIREWIRE_CORE_H */ Index: b/include/linux/firewire.h =================================================================== --- a/include/linux/firewire.h +++ b/include/linux/firewire.h @@ -3,6 +3,7 @@ #include <linux/completion.h> #include <linux/device.h> +#include <linux/dma-mapping.h> #include <linux/kernel.h> #include <linux/kref.h> #include <linux/list.h> @@ -355,4 +356,90 @@ int fw_run_transaction(struct fw_card *c int generation, int speed, unsigned long long offset, void *payload, size_t length); +static inline int fw_stream_packet_destination_id(int tag, int channel, int sy) +{ + return tag << 14 | channel << 8 | sy; +} + +struct fw_descriptor { + struct list_head link; + size_t length; + u32 immediate; + u32 key; + const u32 *data; +}; + +int fw_core_add_descriptor(struct fw_descriptor *desc); +void fw_core_remove_descriptor(struct fw_descriptor *desc); + +/* + * The iso packet format allows for an immediate header/payload part + * stored in 'header' immediately after the packet info plus an + * indirect payload part that is pointer to by the 'payload' field. + * Applications can use one or the other or both to implement simple + * low-bandwidth streaming (e.g. audio) or more advanced + * scatter-gather streaming (e.g. assembling video frame automatically). + */ +struct fw_iso_packet { + u16 payload_length; /* Length of indirect payload. */ + u32 interrupt:1; /* Generate interrupt on this packet */ + u32 skip:1; /* Set to not send packet at all. */ + u32 tag:2; + u32 sy:4; + u32 header_length:8; /* Length of immediate header. */ + u32 header[0]; +}; + +#define FW_ISO_CONTEXT_TRANSMIT 0 +#define FW_ISO_CONTEXT_RECEIVE 1 + +#define FW_ISO_CONTEXT_MATCH_TAG0 1 +#define FW_ISO_CONTEXT_MATCH_TAG1 2 +#define FW_ISO_CONTEXT_MATCH_TAG2 4 +#define FW_ISO_CONTEXT_MATCH_TAG3 8 +#define FW_ISO_CONTEXT_MATCH_ALL_TAGS 15 + +/* + * An iso buffer is just a set of pages mapped for DMA in the + * specified direction. Since the pages are to be used for DMA, they + * are not mapped into the kernel virtual address space. We store the + * DMA address in the page private. The helper function + * fw_iso_buffer_map() will map the pages into a given vma. + */ +struct fw_iso_buffer { + enum dma_data_direction direction; + struct page **pages; + int page_count; +}; + +int fw_iso_buffer_init(struct fw_iso_buffer *buffer, struct fw_card *card, + int page_count, enum dma_data_direction direction); +void fw_iso_buffer_destroy(struct fw_iso_buffer *buffer, struct fw_card *card); + +struct fw_iso_context; +typedef void (*fw_iso_callback_t)(struct fw_iso_context *context, + u32 cycle, size_t header_length, + void *header, void *data); +struct fw_iso_context { + struct fw_card *card; + int type; + int channel; + int speed; + size_t header_size; + fw_iso_callback_t callback; + void *callback_data; +}; + +struct fw_iso_context *fw_iso_context_create(struct fw_card *card, + int type, int channel, int speed, size_t header_size, + fw_iso_callback_t callback, void *callback_data); +int fw_iso_context_queue(struct fw_iso_context *ctx, + struct fw_iso_packet *packet, + struct fw_iso_buffer *buffer, + unsigned long payload); +int fw_iso_context_start(struct fw_iso_context *ctx, + int cycle, int sync, int tags); +int fw_iso_context_stop(struct fw_iso_context *ctx); +void fw_iso_context_destroy(struct fw_iso_context *ctx); + #endif /* _LINUX_FIREWIRE_H */ -- Stefan Richter -=====-==--= -==- =---= http://arcgraph.de/sr/ ^ permalink raw reply [flat|nested] 18+ messages in thread
* What's in linux1394-2.6.git? -- Part II.2/3 2009-06-17 17:47 ` What's in linux1394-2.6.git? -- Part II.1/3 Stefan Richter @ 2009-06-17 17:48 ` Stefan Richter 2009-06-17 17:50 ` What's in linux1394-2.6.git? -- Part II.3/3 Stefan Richter 0 siblings, 1 reply; 18+ messages in thread From: Stefan Richter @ 2009-06-17 17:48 UTC (permalink / raw) To: linux-kernel; +Cc: linux1394-devel This part of linux1394-2.6.git's current for-linus..for-next combined diff adds firewire-net. --- drivers/firewire/Kconfig | 12 + drivers/firewire/Makefile | 4 + drivers/firewire/net.c | 1655 ++++++++++++++++++++++++++++++++++++++ drivers/ieee1394/Kconfig | 2 4 files changed, 1671 insertions(+), 2 deletions(-) Index: b/drivers/firewire/Kconfig =================================================================== --- a/drivers/firewire/Kconfig +++ b/drivers/firewire/Kconfig @@ -77,3 +77,15 @@ config FIREWIRE_SBP2 You should also enable support for disks, CD-ROMs, etc. in the SCSI configuration section. + +config FIREWIRE_NET + tristate "IP networking over 1394" + depends on FIREWIRE && INET + help + This enables IPv4 over IEEE 1394, providing IP connectivity with + other implementations of RFC 2734 as found on several operating + systems. Multicast support is currently limited. + + To compile this driver as a module, say M here: The module will be + called firewire-net. It replaces eth1394 of the classic IEEE 1394 + stack. Index: b/drivers/firewire/Makefile =================================================================== --- a/drivers/firewire/Makefile +++ b/drivers/firewire/Makefile @@ -6,7 +6,9 @@ firewire-core-y += core-card.o core-cdev core-iso.o core-topology.o core-transaction.o firewire-ohci-y += ohci.o firewire-sbp2-y += sbp2.o +firewire-net-y += net.o -obj-$(CONFIG_FIREWIRE) += firewire-core.o +obj-$(CONFIG_FIREWIRE) += firewire-core.o obj-$(CONFIG_FIREWIRE_OHCI) += firewire-ohci.o obj-$(CONFIG_FIREWIRE_SBP2) += firewire-sbp2.o +obj-$(CONFIG_FIREWIRE_NET) += firewire-net.o Index: b/drivers/firewire/net.c =================================================================== --- /dev/null +++ b/drivers/firewire/net.c @@ -0,0 +1,1655 @@ +/* + * IPv4 over IEEE 1394, per RFC 2734 + * + * Copyright (C) 2009 Jay Fenlason <fenlason@redhat.com> + * + * based on eth1394 by Ben Collins et al + */ + +#include <linux/bug.h> +#include <linux/device.h> +#include <linux/ethtool.h> +#include <linux/firewire.h> +#include <linux/firewire-constants.h> +#include <linux/highmem.h> +#include <linux/in.h> +#include <linux/ip.h> +#include <linux/jiffies.h> +#include <linux/mod_devicetable.h> +#include <linux/module.h> +#include <linux/moduleparam.h> +#include <linux/mutex.h> +#include <linux/netdevice.h> +#include <linux/skbuff.h> +#include <linux/spinlock.h> + +#include <asm/unaligned.h> +#include <net/arp.h> + +#define FWNET_MAX_FRAGMENTS 25 /* arbitrary limit */ +#define FWNET_ISO_PAGE_COUNT (PAGE_SIZE < 16 * 1024 ? 4 : 2) + +#define IEEE1394_BROADCAST_CHANNEL 31 +#define IEEE1394_ALL_NODES (0xffc0 | 0x003f) +#define IEEE1394_MAX_PAYLOAD_S100 512 +#define FWNET_NO_FIFO_ADDR (~0ULL) + +#define IANA_SPECIFIER_ID 0x00005eU +#define RFC2734_SW_VERSION 0x000001U + +#define IEEE1394_GASP_HDR_SIZE 8 + +#define RFC2374_UNFRAG_HDR_SIZE 4 +#define RFC2374_FRAG_HDR_SIZE 8 +#define RFC2374_FRAG_OVERHEAD 4 + +#define RFC2374_HDR_UNFRAG 0 /* unfragmented */ +#define RFC2374_HDR_FIRSTFRAG 1 /* first fragment */ +#define RFC2374_HDR_LASTFRAG 2 /* last fragment */ +#define RFC2374_HDR_INTFRAG 3 /* interior fragment */ + +#define RFC2734_HW_ADDR_LEN 16 + +struct rfc2734_arp { + __be16 hw_type; /* 0x0018 */ + __be16 proto_type; /* 0x0806 */ + u8 hw_addr_len; /* 16 */ + u8 ip_addr_len; /* 4 */ + __be16 opcode; /* ARP Opcode */ + /* Above is exactly the same format as struct arphdr */ + + __be64 s_uniq_id; /* Sender's 64bit EUI */ + u8 max_rec; /* Sender's max packet size */ + u8 sspd; /* Sender's max speed */ + __be16 fifo_hi; /* hi 16bits of sender's FIFO addr */ + __be32 fifo_lo; /* lo 32bits of sender's FIFO addr */ + __be32 sip; /* Sender's IP Address */ + __be32 tip; /* IP Address of requested hw addr */ +} __attribute__((packed)); + +/* This header format is specific to this driver implementation. */ +#define FWNET_ALEN 8 +#define FWNET_HLEN 10 +struct fwnet_header { + u8 h_dest[FWNET_ALEN]; /* destination address */ + __be16 h_proto; /* packet type ID field */ +} __attribute__((packed)); + +/* IPv4 and IPv6 encapsulation header */ +struct rfc2734_header { + u32 w0; + u32 w1; +}; + +#define fwnet_get_hdr_lf(h) (((h)->w0 & 0xc0000000) >> 30) +#define fwnet_get_hdr_ether_type(h) (((h)->w0 & 0x0000ffff)) +#define fwnet_get_hdr_dg_size(h) (((h)->w0 & 0x0fff0000) >> 16) +#define fwnet_get_hdr_fg_off(h) (((h)->w0 & 0x00000fff)) +#define fwnet_get_hdr_dgl(h) (((h)->w1 & 0xffff0000) >> 16) + +#define fwnet_set_hdr_lf(lf) ((lf) << 30) +#define fwnet_set_hdr_ether_type(et) (et) +#define fwnet_set_hdr_dg_size(dgs) ((dgs) << 16) +#define fwnet_set_hdr_fg_off(fgo) (fgo) + +#define fwnet_set_hdr_dgl(dgl) ((dgl) << 16) + +static inline void fwnet_make_uf_hdr(struct rfc2734_header *hdr, + unsigned ether_type) +{ + hdr->w0 = fwnet_set_hdr_lf(RFC2374_HDR_UNFRAG) + | fwnet_set_hdr_ether_type(ether_type); +} + +static inline void fwnet_make_ff_hdr(struct rfc2734_header *hdr, + unsigned ether_type, unsigned dg_size, unsigned dgl) +{ + hdr->w0 = fwnet_set_hdr_lf(RFC2374_HDR_FIRSTFRAG) + | fwnet_set_hdr_dg_size(dg_size) + | fwnet_set_hdr_ether_type(ether_type); + hdr->w1 = fwnet_set_hdr_dgl(dgl); +} + +static inline void fwnet_make_sf_hdr(struct rfc2734_header *hdr, + unsigned lf, unsigned dg_size, unsigned fg_off, unsigned dgl) +{ + hdr->w0 = fwnet_set_hdr_lf(lf) + | fwnet_set_hdr_dg_size(dg_size) + | fwnet_set_hdr_fg_off(fg_off); + hdr->w1 = fwnet_set_hdr_dgl(dgl); +} + +/* This list keeps track of what parts of the datagram have been filled in */ +struct fwnet_fragment_info { + struct list_head fi_link; + u16 offset; + u16 len; +}; + +struct fwnet_partial_datagram { + struct list_head pd_link; + struct list_head fi_list; + struct sk_buff *skb; + /* FIXME Why not use skb->data? */ + char *pbuf; + u16 datagram_label; + u16 ether_type; + u16 datagram_size; +}; + +static DEFINE_MUTEX(fwnet_device_mutex); +static LIST_HEAD(fwnet_device_list); + +struct fwnet_device { + struct list_head dev_link; + spinlock_t lock; + enum { + FWNET_BROADCAST_ERROR, + FWNET_BROADCAST_RUNNING, + FWNET_BROADCAST_STOPPED, + } broadcast_state; + struct fw_iso_context *broadcast_rcv_context; + struct fw_iso_buffer broadcast_rcv_buffer; + void **broadcast_rcv_buffer_ptrs; + unsigned broadcast_rcv_next_ptr; + unsigned num_broadcast_rcv_ptrs; + unsigned rcv_buffer_size; + /* + * This value is the maximum unfragmented datagram size that can be + * sent by the hardware. It already has the GASP overhead and the + * unfragmented datagram header overhead calculated into it. + */ + unsigned broadcast_xmt_max_payload; + u16 broadcast_xmt_datagramlabel; + + /* + * The CSR address that remote nodes must send datagrams to for us to + * receive them. + */ + struct fw_address_handler handler; + u64 local_fifo; + + /* List of packets to be sent */ + struct list_head packet_list; + /* + * List of packets that were broadcasted. When we get an ISO interrupt + * one of them has been sent + */ + struct list_head broadcasted_list; + /* List of packets that have been sent but not yet acked */ + struct list_head sent_list; + + struct list_head peer_list; + struct fw_card *card; + struct net_device *netdev; +}; + +struct fwnet_peer { + struct list_head peer_link; + struct fwnet_device *dev; + u64 guid; + u64 fifo; + + /* guarded by dev->lock */ + struct list_head pd_list; /* received partial datagrams */ + unsigned pdg_size; /* pd_list size */ + + u16 datagram_label; /* outgoing datagram label */ + unsigned max_payload; /* includes RFC2374_FRAG_HDR_SIZE overhead */ + int node_id; + int generation; + unsigned speed; +}; + +/* This is our task struct. It's used for the packet complete callback. */ +struct fwnet_packet_task { + /* + * ptask can actually be on dev->packet_list, dev->broadcasted_list, + * or dev->sent_list depending on its current state. + */ + struct list_head pt_link; + struct fw_transaction transaction; + struct rfc2734_header hdr; + struct sk_buff *skb; + struct fwnet_device *dev; + + int outstanding_pkts; + unsigned max_payload; + u64 fifo_addr; + u16 dest_node; + u8 generation; + u8 speed; +}; + +/* + * saddr == NULL means use device source address. + * daddr == NULL means leave destination address (eg unresolved arp). + */ +static int fwnet_header_create(struct sk_buff *skb, struct net_device *net, + unsigned short type, const void *daddr, + const void *saddr, unsigned len) +{ + struct fwnet_header *h; + + h = (struct fwnet_header *)skb_push(skb, sizeof(*h)); + put_unaligned_be16(type, &h->h_proto); + + if (net->flags & (IFF_LOOPBACK | IFF_NOARP)) { + memset(h->h_dest, 0, net->addr_len); + + return net->hard_header_len; + } + + if (daddr) { + memcpy(h->h_dest, daddr, net->addr_len); + + return net->hard_header_len; + } + + return -net->hard_header_len; +} + +static int fwnet_header_rebuild(struct sk_buff *skb) +{ + struct fwnet_header *h = (struct fwnet_header *)skb->data; + + if (get_unaligned_be16(&h->h_proto) == ETH_P_IP) + return arp_find((unsigned char *)&h->h_dest, skb); + + fw_notify("%s: unable to resolve type %04x addresses\n", + skb->dev->name, be16_to_cpu(h->h_proto)); + return 0; +} + +static int fwnet_header_cache(const struct neighbour *neigh, + struct hh_cache *hh) +{ + struct net_device *net; + struct fwnet_header *h; + + if (hh->hh_type == cpu_to_be16(ETH_P_802_3)) + return -1; + net = neigh->dev; + h = (struct fwnet_header *)((u8 *)hh->hh_data + 16 - sizeof(*h)); + h->h_proto = hh->hh_type; + memcpy(h->h_dest, neigh->ha, net->addr_len); + hh->hh_len = FWNET_HLEN; + + return 0; +} + +/* Called by Address Resolution module to notify changes in address. */ +static void fwnet_header_cache_update(struct hh_cache *hh, + const struct net_device *net, const unsigned char *haddr) +{ + memcpy((u8 *)hh->hh_data + 16 - FWNET_HLEN, haddr, net->addr_len); +} + +static int fwnet_header_parse(const struct sk_buff *skb, unsigned char *haddr) +{ + memcpy(haddr, skb->dev->dev_addr, FWNET_ALEN); + + return FWNET_ALEN; +} + +static const struct header_ops fwnet_header_ops = { + .create = fwnet_header_create, + .rebuild = fwnet_header_rebuild, + .cache = fwnet_header_cache, + .cache_update = fwnet_header_cache_update, + .parse = fwnet_header_parse, +}; + +/* FIXME: is this correct for all cases? */ +static bool fwnet_frag_overlap(struct fwnet_partial_datagram *pd, + unsigned offset, unsigned len) +{ + struct fwnet_fragment_info *fi; + unsigned end = offset + len; + + list_for_each_entry(fi, &pd->fi_list, fi_link) + if (offset < fi->offset + fi->len && end > fi->offset) + return true; + + return false; +} + +/* Assumes that new fragment does not overlap any existing fragments */ +static struct fwnet_fragment_info *fwnet_frag_new( + struct fwnet_partial_datagram *pd, unsigned offset, unsigned len) +{ + struct fwnet_fragment_info *fi, *fi2, *new; + struct list_head *list; + + list = &pd->fi_list; + list_for_each_entry(fi, &pd->fi_list, fi_link) { + if (fi->offset + fi->len == offset) { + /* The new fragment can be tacked on to the end */ + /* Did the new fragment plug a hole? */ + fi2 = list_entry(fi->fi_link.next, + struct fwnet_fragment_info, fi_link); + if (fi->offset + fi->len == fi2->offset) { + /* glue fragments together */ + fi->len += len + fi2->len; + list_del(&fi2->fi_link); + kfree(fi2); + } else { + fi->len += len; + } + + return fi; + } + if (offset + len == fi->offset) { + /* The new fragment can be tacked on to the beginning */ + /* Did the new fragment plug a hole? */ + fi2 = list_entry(fi->fi_link.prev, + struct fwnet_fragment_info, fi_link); + if (fi2->offset + fi2->len == fi->offset) { + /* glue fragments together */ + fi2->len += fi->len + len; + list_del(&fi->fi_link); + kfree(fi); + + return fi2; + } + fi->offset = offset; + fi->len += len; + + return fi; + } + if (offset > fi->offset + fi->len) { + list = &fi->fi_link; + break; + } + if (offset + len < fi->offset) { + list = fi->fi_link.prev; + break; + } + } + + new = kmalloc(sizeof(*new), GFP_ATOMIC); + if (!new) { + fw_error("out of memory\n"); + return NULL; + } + + new->offset = offset; + new->len = len; + list_add(&new->fi_link, list); + + return new; +} + +static struct fwnet_partial_datagram *fwnet_pd_new(struct net_device *net, + struct fwnet_peer *peer, u16 datagram_label, unsigned dg_size, + void *frag_buf, unsigned frag_off, unsigned frag_len) +{ + struct fwnet_partial_datagram *new; + struct fwnet_fragment_info *fi; + + new = kmalloc(sizeof(*new), GFP_ATOMIC); + if (!new) + goto fail; + + INIT_LIST_HEAD(&new->fi_list); + fi = fwnet_frag_new(new, frag_off, frag_len); + if (fi == NULL) + goto fail_w_new; + + new->datagram_label = datagram_label; + new->datagram_size = dg_size; + new->skb = dev_alloc_skb(dg_size + net->hard_header_len + 15); + if (new->skb == NULL) + goto fail_w_fi; + + skb_reserve(new->skb, (net->hard_header_len + 15) & ~15); + new->pbuf = skb_put(new->skb, dg_size); + memcpy(new->pbuf + frag_off, frag_buf, frag_len); + list_add_tail(&new->pd_link, &peer->pd_list); + + return new; + +fail_w_fi: + kfree(fi); +fail_w_new: + kfree(new); +fail: + fw_error("out of memory\n"); + + return NULL; +} + +static struct fwnet_partial_datagram *fwnet_pd_find(struct fwnet_peer *peer, + u16 datagram_label) +{ + struct fwnet_partial_datagram *pd; + + list_for_each_entry(pd, &peer->pd_list, pd_link) + if (pd->datagram_label == datagram_label) + return pd; + + return NULL; +} + + +static void fwnet_pd_delete(struct fwnet_partial_datagram *old) +{ + struct fwnet_fragment_info *fi, *n; + + list_for_each_entry_safe(fi, n, &old->fi_list, fi_link) + kfree(fi); + + list_del(&old->pd_link); + dev_kfree_skb_any(old->skb); + kfree(old); +} + +static bool fwnet_pd_update(struct fwnet_peer *peer, + struct fwnet_partial_datagram *pd, void *frag_buf, + unsigned frag_off, unsigned frag_len) +{ + if (fwnet_frag_new(pd, frag_off, frag_len) == NULL) + return false; + + memcpy(pd->pbuf + frag_off, frag_buf, frag_len); + + /* + * Move list entry to beginnig of list so that oldest partial + * datagrams percolate to the end of the list + */ + list_move_tail(&pd->pd_link, &peer->pd_list); + + return true; +} + +static bool fwnet_pd_is_complete(struct fwnet_partial_datagram *pd) +{ + struct fwnet_fragment_info *fi; + + fi = list_entry(pd->fi_list.next, struct fwnet_fragment_info, fi_link); + + return fi->len == pd->datagram_size; +} + +/* caller must hold dev->lock */ +static struct fwnet_peer *fwnet_peer_find_by_guid(struct fwnet_device *dev, + u64 guid) +{ + struct fwnet_peer *peer; + + list_for_each_entry(peer, &dev->peer_list, peer_link) + if (peer->guid == guid) + return peer; + + return NULL; +} + +/* caller must hold dev->lock */ +static struct fwnet_peer *fwnet_peer_find_by_node_id(struct fwnet_device *dev, + int node_id, int generation) +{ + struct fwnet_peer *peer; + + list_for_each_entry(peer, &dev->peer_list, peer_link) + if (peer->node_id == node_id && + peer->generation == generation) + return peer; + + return NULL; +} + +/* See IEEE 1394-2008 table 6-4, table 8-8, table 16-18. */ +static unsigned fwnet_max_payload(unsigned max_rec, unsigned speed) +{ + max_rec = min(max_rec, speed + 8); + max_rec = min(max_rec, 0xbU); /* <= 4096 */ + if (max_rec < 8) { + fw_notify("max_rec %x out of range\n", max_rec); + max_rec = 8; + } + + return (1 << (max_rec + 1)) - RFC2374_FRAG_HDR_SIZE; +} + + +static int fwnet_finish_incoming_packet(struct net_device *net, + struct sk_buff *skb, u16 source_node_id, + bool is_broadcast, u16 ether_type) +{ + struct fwnet_device *dev; + static const __be64 broadcast_hw = cpu_to_be64(~0ULL); + int status; + __be64 guid; + + dev = netdev_priv(net); + /* Write metadata, and then pass to the receive level */ + skb->dev = net; + skb->ip_summed = CHECKSUM_UNNECESSARY; /* don't check it */ + + /* + * Parse the encapsulation header. This actually does the job of + * converting to an ethernet frame header, as well as arp + * conversion if needed. ARP conversion is easier in this + * direction, since we are using ethernet as our backend. + */ + /* + * If this is an ARP packet, convert it. First, we want to make + * use of some of the fields, since they tell us a little bit + * about the sending machine. + */ + if (ether_type == ETH_P_ARP) { + struct rfc2734_arp *arp1394; + struct arphdr *arp; + unsigned char *arp_ptr; + u64 fifo_addr; + u64 peer_guid; + unsigned sspd; + u16 max_payload; + struct fwnet_peer *peer; + unsigned long flags; + + arp1394 = (struct rfc2734_arp *)skb->data; + arp = (struct arphdr *)skb->data; + arp_ptr = (unsigned char *)(arp + 1); + peer_guid = get_unaligned_be64(&arp1394->s_uniq_id); + fifo_addr = (u64)get_unaligned_be16(&arp1394->fifo_hi) << 32 + | get_unaligned_be32(&arp1394->fifo_lo); + + sspd = arp1394->sspd; + /* Sanity check. OS X 10.3 PPC reportedly sends 131. */ + if (sspd > SCODE_3200) { + fw_notify("sspd %x out of range\n", sspd); + sspd = SCODE_3200; + } + max_payload = fwnet_max_payload(arp1394->max_rec, sspd); + + spin_lock_irqsave(&dev->lock, flags); + peer = fwnet_peer_find_by_guid(dev, peer_guid); + if (peer) { + peer->fifo = fifo_addr; + + if (peer->speed > sspd) + peer->speed = sspd; + if (peer->max_payload > max_payload) + peer->max_payload = max_payload; + } + spin_unlock_irqrestore(&dev->lock, flags); + + if (!peer) { + fw_notify("No peer for ARP packet from %016llx\n", + (unsigned long long)peer_guid); + goto failed_proto; + } + + /* + * Now that we're done with the 1394 specific stuff, we'll + * need to alter some of the data. Believe it or not, all + * that needs to be done is sender_IP_address needs to be + * moved, the destination hardware address get stuffed + * in and the hardware address length set to 8. + * + * IMPORTANT: The code below overwrites 1394 specific data + * needed above so keep the munging of the data for the + * higher level IP stack last. + */ + + arp->ar_hln = 8; + /* skip over sender unique id */ + arp_ptr += arp->ar_hln; + /* move sender IP addr */ + put_unaligned(arp1394->sip, (u32 *)arp_ptr); + /* skip over sender IP addr */ + arp_ptr += arp->ar_pln; + + if (arp->ar_op == htons(ARPOP_REQUEST)) + memset(arp_ptr, 0, sizeof(u64)); + else + memcpy(arp_ptr, net->dev_addr, sizeof(u64)); + } + + /* Now add the ethernet header. */ + guid = cpu_to_be64(dev->card->guid); + if (dev_hard_header(skb, net, ether_type, + is_broadcast ? &broadcast_hw : &guid, + NULL, skb->len) >= 0) { + struct fwnet_header *eth; + u16 *rawp; + __be16 protocol; + + skb_reset_mac_header(skb); + skb_pull(skb, sizeof(*eth)); + eth = (struct fwnet_header *)skb_mac_header(skb); + if (*eth->h_dest & 1) { + if (memcmp(eth->h_dest, net->broadcast, + net->addr_len) == 0) + skb->pkt_type = PACKET_BROADCAST; +#if 0 + else + skb->pkt_type = PACKET_MULTICAST; +#endif + } else { + if (memcmp(eth->h_dest, net->dev_addr, net->addr_len)) + skb->pkt_type = PACKET_OTHERHOST; + } + if (ntohs(eth->h_proto) >= 1536) { + protocol = eth->h_proto; + } else { + rawp = (u16 *)skb->data; + if (*rawp == 0xffff) + protocol = htons(ETH_P_802_3); + else + protocol = htons(ETH_P_802_2); + } + skb->protocol = protocol; + } + status = netif_rx(skb); + if (status == NET_RX_DROP) { + net->stats.rx_errors++; + net->stats.rx_dropped++; + } else { + net->stats.rx_packets++; + net->stats.rx_bytes += skb->len; + } + if (netif_queue_stopped(net)) + netif_wake_queue(net); + + return 0; + + failed_proto: + net->stats.rx_errors++; + net->stats.rx_dropped++; + + dev_kfree_skb_any(skb); + if (netif_queue_stopped(net)) + netif_wake_queue(net); + + net->last_rx = jiffies; + + return 0; +} + +static int fwnet_incoming_packet(struct fwnet_device *dev, __be32 *buf, int len, + int source_node_id, int generation, + bool is_broadcast) +{ + struct sk_buff *skb; + struct net_device *net = dev->netdev; + struct rfc2734_header hdr; + unsigned lf; + unsigned long flags; + struct fwnet_peer *peer; + struct fwnet_partial_datagram *pd; + int fg_off; + int dg_size; + u16 datagram_label; + int retval; + u16 ether_type; + + hdr.w0 = be32_to_cpu(buf[0]); + lf = fwnet_get_hdr_lf(&hdr); + if (lf == RFC2374_HDR_UNFRAG) { + /* + * An unfragmented datagram has been received by the ieee1394 + * bus. Build an skbuff around it so we can pass it to the + * high level network layer. + */ + ether_type = fwnet_get_hdr_ether_type(&hdr); + buf++; + len -= RFC2374_UNFRAG_HDR_SIZE; + + skb = dev_alloc_skb(len + net->hard_header_len + 15); + if (unlikely(!skb)) { + fw_error("out of memory\n"); + net->stats.rx_dropped++; + + return -1; + } + skb_reserve(skb, (net->hard_header_len + 15) & ~15); + memcpy(skb_put(skb, len), buf, len); + + return fwnet_finish_incoming_packet(net, skb, source_node_id, + is_broadcast, ether_type); + } + /* A datagram fragment has been received, now the fun begins. */ + hdr.w1 = ntohl(buf[1]); + buf += 2; + len -= RFC2374_FRAG_HDR_SIZE; + if (lf == RFC2374_HDR_FIRSTFRAG) { + ether_type = fwnet_get_hdr_ether_type(&hdr); + fg_off = 0; + } else { + ether_type = 0; + fg_off = fwnet_get_hdr_fg_off(&hdr); + } + datagram_label = fwnet_get_hdr_dgl(&hdr); + dg_size = fwnet_get_hdr_dg_size(&hdr); /* ??? + 1 */ + + spin_lock_irqsave(&dev->lock, flags); + + peer = fwnet_peer_find_by_node_id(dev, source_node_id, generation); + if (!peer) + goto bad_proto; + + pd = fwnet_pd_find(peer, datagram_label); + if (pd == NULL) { + while (peer->pdg_size >= FWNET_MAX_FRAGMENTS) { + /* remove the oldest */ + fwnet_pd_delete(list_first_entry(&peer->pd_list, + struct fwnet_partial_datagram, pd_link)); + peer->pdg_size--; + } + pd = fwnet_pd_new(net, peer, datagram_label, + dg_size, buf, fg_off, len); + if (pd == NULL) { + retval = -ENOMEM; + goto bad_proto; + } + peer->pdg_size++; + } else { + if (fwnet_frag_overlap(pd, fg_off, len) || + pd->datagram_size != dg_size) { + /* + * Differing datagram sizes or overlapping fragments, + * discard old datagram and start a new one. + */ + fwnet_pd_delete(pd); + pd = fwnet_pd_new(net, peer, datagram_label, + dg_size, buf, fg_off, len); + if (pd == NULL) { + retval = -ENOMEM; + peer->pdg_size--; + goto bad_proto; + } + } else { + if (!fwnet_pd_update(peer, pd, buf, fg_off, len)) { + /* + * Couldn't save off fragment anyway + * so might as well obliterate the + * datagram now. + */ + fwnet_pd_delete(pd); + peer->pdg_size--; + goto bad_proto; + } + } + } /* new datagram or add to existing one */ + + if (lf == RFC2374_HDR_FIRSTFRAG) + pd->ether_type = ether_type; + + if (fwnet_pd_is_complete(pd)) { + ether_type = pd->ether_type; + peer->pdg_size--; + skb = skb_get(pd->skb); + fwnet_pd_delete(pd); + + spin_unlock_irqrestore(&dev->lock, flags); + + return fwnet_finish_incoming_packet(net, skb, source_node_id, + false, ether_type); + } + /* + * Datagram is not complete, we're done for the + * moment. + */ + spin_unlock_irqrestore(&dev->lock, flags); + + return 0; + + bad_proto: + spin_unlock_irqrestore(&dev->lock, flags); + + if (netif_queue_stopped(net)) + netif_wake_queue(net); + + return 0; +} + +static void fwnet_receive_packet(struct fw_card *card, struct fw_request *r, + int tcode, int destination, int source, int generation, + int speed, unsigned long long offset, void *payload, + size_t length, void *callback_data) +{ + struct fwnet_device *dev = callback_data; + int rcode; + + if (destination == IEEE1394_ALL_NODES) { + kfree(r); + + return; + } + + if (offset != dev->handler.offset) + rcode = RCODE_ADDRESS_ERROR; + else if (tcode != TCODE_WRITE_BLOCK_REQUEST) + rcode = RCODE_TYPE_ERROR; + else if (fwnet_incoming_packet(dev, payload, length, + source, generation, false) != 0) { + fw_error("Incoming packet failure\n"); + rcode = RCODE_CONFLICT_ERROR; + } else + rcode = RCODE_COMPLETE; + + fw_send_response(card, r, rcode); +} + +static void fwnet_receive_broadcast(struct fw_iso_context *context, + u32 cycle, size_t header_length, void *header, void *data) +{ + struct fwnet_device *dev; + struct fw_iso_packet packet; + struct fw_card *card; + __be16 *hdr_ptr; + __be32 *buf_ptr; + int retval; + u32 length; + u16 source_node_id; + u32 specifier_id; + u32 ver; + unsigned long offset; + unsigned long flags; + + dev = data; + card = dev->card; + hdr_ptr = header; + length = be16_to_cpup(hdr_ptr); + + spin_lock_irqsave(&dev->lock, flags); + + offset = dev->rcv_buffer_size * dev->broadcast_rcv_next_ptr; + buf_ptr = dev->broadcast_rcv_buffer_ptrs[dev->broadcast_rcv_next_ptr++]; + if (dev->broadcast_rcv_next_ptr == dev->num_broadcast_rcv_ptrs) + dev->broadcast_rcv_next_ptr = 0; + + spin_unlock_irqrestore(&dev->lock, flags); + + specifier_id = (be32_to_cpu(buf_ptr[0]) & 0xffff) << 8 + | (be32_to_cpu(buf_ptr[1]) & 0xff000000) >> 24; + ver = be32_to_cpu(buf_ptr[1]) & 0xffffff; + source_node_id = be32_to_cpu(buf_ptr[0]) >> 16; + + if (specifier_id == IANA_SPECIFIER_ID && ver == RFC2734_SW_VERSION) { + buf_ptr += 2; + length -= IEEE1394_GASP_HDR_SIZE; + fwnet_incoming_packet(dev, buf_ptr, length, + source_node_id, -1, true); + } + + packet.payload_length = dev->rcv_buffer_size; + packet.interrupt = 1; + packet.skip = 0; + packet.tag = 3; + packet.sy = 0; + packet.header_length = IEEE1394_GASP_HDR_SIZE; + + spin_lock_irqsave(&dev->lock, flags); + + retval = fw_iso_context_queue(dev->broadcast_rcv_context, &packet, + &dev->broadcast_rcv_buffer, offset); + + spin_unlock_irqrestore(&dev->lock, flags); + + if (retval < 0) + fw_error("requeue failed\n"); +} + +static struct kmem_cache *fwnet_packet_task_cache; + +static int fwnet_send_packet(struct fwnet_packet_task *ptask); + +static void fwnet_transmit_packet_done(struct fwnet_packet_task *ptask) +{ + struct fwnet_device *dev; + unsigned long flags; + + dev = ptask->dev; + + spin_lock_irqsave(&dev->lock, flags); + list_del(&ptask->pt_link); + spin_unlock_irqrestore(&dev->lock, flags); + + ptask->outstanding_pkts--; /* FIXME access inside lock */ + + if (ptask->outstanding_pkts > 0) { + u16 dg_size; + u16 fg_off; + u16 datagram_label; + u16 lf; + struct sk_buff *skb; + + /* Update the ptask to point to the next fragment and send it */ + lf = fwnet_get_hdr_lf(&ptask->hdr); + switch (lf) { + case RFC2374_HDR_LASTFRAG: + case RFC2374_HDR_UNFRAG: + default: + fw_error("Outstanding packet %x lf %x, header %x,%x\n", + ptask->outstanding_pkts, lf, ptask->hdr.w0, + ptask->hdr.w1); + BUG(); + + case RFC2374_HDR_FIRSTFRAG: + /* Set frag type here for future interior fragments */ + dg_size = fwnet_get_hdr_dg_size(&ptask->hdr); + fg_off = ptask->max_payload - RFC2374_FRAG_HDR_SIZE; + datagram_label = fwnet_get_hdr_dgl(&ptask->hdr); + break; + + case RFC2374_HDR_INTFRAG: + dg_size = fwnet_get_hdr_dg_size(&ptask->hdr); + fg_off = fwnet_get_hdr_fg_off(&ptask->hdr) + + ptask->max_payload - RFC2374_FRAG_HDR_SIZE; + datagram_label = fwnet_get_hdr_dgl(&ptask->hdr); + break; + } + skb = ptask->skb; + skb_pull(skb, ptask->max_payload); + if (ptask->outstanding_pkts > 1) { + fwnet_make_sf_hdr(&ptask->hdr, RFC2374_HDR_INTFRAG, + dg_size, fg_off, datagram_label); + } else { + fwnet_make_sf_hdr(&ptask->hdr, RFC2374_HDR_LASTFRAG, + dg_size, fg_off, datagram_label); + ptask->max_payload = skb->len + RFC2374_FRAG_HDR_SIZE; + } + fwnet_send_packet(ptask); + } else { + dev_kfree_skb_any(ptask->skb); + kmem_cache_free(fwnet_packet_task_cache, ptask); + } +} + +static void fwnet_write_complete(struct fw_card *card, int rcode, + void *payload, size_t length, void *data) +{ + struct fwnet_packet_task *ptask; + + ptask = data; + + if (rcode == RCODE_COMPLETE) + fwnet_transmit_packet_done(ptask); + else + fw_error("fwnet_write_complete: failed: %x\n", rcode); + /* ??? error recovery */ +} + +static int fwnet_send_packet(struct fwnet_packet_task *ptask) +{ + struct fwnet_device *dev; + unsigned tx_len; + struct rfc2734_header *bufhdr; + unsigned long flags; + + dev = ptask->dev; + tx_len = ptask->max_payload; + switch (fwnet_get_hdr_lf(&ptask->hdr)) { + case RFC2374_HDR_UNFRAG: + bufhdr = (struct rfc2734_header *) + skb_push(ptask->skb, RFC2374_UNFRAG_HDR_SIZE); + put_unaligned_be32(ptask->hdr.w0, &bufhdr->w0); + break; + + case RFC2374_HDR_FIRSTFRAG: + case RFC2374_HDR_INTFRAG: + case RFC2374_HDR_LASTFRAG: + bufhdr = (struct rfc2734_header *) + skb_push(ptask->skb, RFC2374_FRAG_HDR_SIZE); + put_unaligned_be32(ptask->hdr.w0, &bufhdr->w0); + put_unaligned_be32(ptask->hdr.w1, &bufhdr->w1); + break; + + default: + BUG(); + } + if (ptask->dest_node == IEEE1394_ALL_NODES) { + u8 *p; + int generation; + int node_id; + + /* ptask->generation may not have been set yet */ + generation = dev->card->generation; + smp_rmb(); + node_id = dev->card->node_id; + + p = skb_push(ptask->skb, 8); + put_unaligned_be32(node_id << 16 | IANA_SPECIFIER_ID >> 8, p); + put_unaligned_be32((IANA_SPECIFIER_ID & 0xff) << 24 + | RFC2734_SW_VERSION, &p[4]); + + /* We should not transmit if broadcast_channel.valid == 0. */ + fw_send_request(dev->card, &ptask->transaction, + TCODE_STREAM_DATA, + fw_stream_packet_destination_id(3, + IEEE1394_BROADCAST_CHANNEL, 0), + generation, SCODE_100, 0ULL, ptask->skb->data, + tx_len + 8, fwnet_write_complete, ptask); + + /* FIXME race? */ + spin_lock_irqsave(&dev->lock, flags); + list_add_tail(&ptask->pt_link, &dev->broadcasted_list); + spin_unlock_irqrestore(&dev->lock, flags); + + return 0; + } + + fw_send_request(dev->card, &ptask->transaction, + TCODE_WRITE_BLOCK_REQUEST, ptask->dest_node, + ptask->generation, ptask->speed, ptask->fifo_addr, + ptask->skb->data, tx_len, fwnet_write_complete, ptask); + + /* FIXME race? */ + spin_lock_irqsave(&dev->lock, flags); + list_add_tail(&ptask->pt_link, &dev->sent_list); + spin_unlock_irqrestore(&dev->lock, flags); + + dev->netdev->trans_start = jiffies; + + return 0; +} + +static int fwnet_broadcast_start(struct fwnet_device *dev) +{ + struct fw_iso_context *context; + int retval; + unsigned num_packets; + unsigned max_receive; + struct fw_iso_packet packet; + unsigned long offset; + unsigned u; + + if (dev->local_fifo == FWNET_NO_FIFO_ADDR) { + /* outside OHCI posted write area? */ + static const struct fw_address_region region = { + .start = 0xffff00000000ULL, + .end = CSR_REGISTER_BASE, + }; + + dev->handler.length = 4096; + dev->handler.address_callback = fwnet_receive_packet; + dev->handler.callback_data = dev; + + retval = fw_core_add_address_handler(&dev->handler, ®ion); + if (retval < 0) + goto failed_initial; + + dev->local_fifo = dev->handler.offset; + } + + max_receive = 1U << (dev->card->max_receive + 1); + num_packets = (FWNET_ISO_PAGE_COUNT * PAGE_SIZE) / max_receive; + + if (!dev->broadcast_rcv_context) { + void **ptrptr; + + context = fw_iso_context_create(dev->card, + FW_ISO_CONTEXT_RECEIVE, IEEE1394_BROADCAST_CHANNEL, + dev->card->link_speed, 8, fwnet_receive_broadcast, dev); + if (IS_ERR(context)) { + retval = PTR_ERR(context); + goto failed_context_create; + } + + retval = fw_iso_buffer_init(&dev->broadcast_rcv_buffer, + dev->card, FWNET_ISO_PAGE_COUNT, DMA_FROM_DEVICE); + if (retval < 0) + goto failed_buffer_init; + + ptrptr = kmalloc(sizeof(void *) * num_packets, GFP_KERNEL); + if (!ptrptr) { + retval = -ENOMEM; + goto failed_ptrs_alloc; + } + + dev->broadcast_rcv_buffer_ptrs = ptrptr; + for (u = 0; u < FWNET_ISO_PAGE_COUNT; u++) { + void *ptr; + unsigned v; + + ptr = kmap(dev->broadcast_rcv_buffer.pages[u]); + for (v = 0; v < num_packets / FWNET_ISO_PAGE_COUNT; v++) + *ptrptr++ = (void *) + ((char *)ptr + v * max_receive); + } + dev->broadcast_rcv_context = context; + } else { + context = dev->broadcast_rcv_context; + } + + packet.payload_length = max_receive; + packet.interrupt = 1; + packet.skip = 0; + packet.tag = 3; + packet.sy = 0; + packet.header_length = IEEE1394_GASP_HDR_SIZE; + offset = 0; + + for (u = 0; u < num_packets; u++) { + retval = fw_iso_context_queue(context, &packet, + &dev->broadcast_rcv_buffer, offset); + if (retval < 0) + goto failed_rcv_queue; + + offset += max_receive; + } + dev->num_broadcast_rcv_ptrs = num_packets; + dev->rcv_buffer_size = max_receive; + dev->broadcast_rcv_next_ptr = 0U; + retval = fw_iso_context_start(context, -1, 0, + FW_ISO_CONTEXT_MATCH_ALL_TAGS); /* ??? sync */ + if (retval < 0) + goto failed_rcv_queue; + + /* FIXME: adjust it according to the min. speed of all known peers? */ + dev->broadcast_xmt_max_payload = IEEE1394_MAX_PAYLOAD_S100 + - IEEE1394_GASP_HDR_SIZE - RFC2374_UNFRAG_HDR_SIZE; + dev->broadcast_state = FWNET_BROADCAST_RUNNING; + + return 0; + + failed_rcv_queue: + kfree(dev->broadcast_rcv_buffer_ptrs); + dev->broadcast_rcv_buffer_ptrs = NULL; + failed_ptrs_alloc: + fw_iso_buffer_destroy(&dev->broadcast_rcv_buffer, dev->card); + failed_buffer_init: + fw_iso_context_destroy(context); + dev->broadcast_rcv_context = NULL; + failed_context_create: + fw_core_remove_address_handler(&dev->handler); + failed_initial: + dev->local_fifo = FWNET_NO_FIFO_ADDR; + + return retval; +} + +/* ifup */ +static int fwnet_open(struct net_device *net) +{ + struct fwnet_device *dev = netdev_priv(net); + int ret; + + if (dev->broadcast_state == FWNET_BROADCAST_ERROR) { + ret = fwnet_broadcast_start(dev); + if (ret) + return ret; + } + netif_start_queue(net); + + return 0; +} + +/* ifdown */ +static int fwnet_stop(struct net_device *net) +{ + netif_stop_queue(net); + + /* Deallocate iso context for use by other applications? */ + + return 0; +} + +static int fwnet_tx(struct sk_buff *skb, struct net_device *net) +{ + struct fwnet_header hdr_buf; + struct fwnet_device *dev = netdev_priv(net); + __be16 proto; + u16 dest_node; + unsigned max_payload; + u16 dg_size; + u16 *datagram_label_ptr; + struct fwnet_packet_task *ptask; + struct fwnet_peer *peer; + unsigned long flags; + + ptask = kmem_cache_alloc(fwnet_packet_task_cache, GFP_ATOMIC); + if (ptask == NULL) + goto fail; + + skb = skb_share_check(skb, GFP_ATOMIC); + if (!skb) + goto fail; + + /* + * Make a copy of the driver-specific header. + * We might need to rebuild the header on tx failure. + */ + memcpy(&hdr_buf, skb->data, sizeof(hdr_buf)); + skb_pull(skb, sizeof(hdr_buf)); + + proto = hdr_buf.h_proto; + dg_size = skb->len; + + /* serialize access to peer, including peer->datagram_label */ + spin_lock_irqsave(&dev->lock, flags); + + /* + * Set the transmission type for the packet. ARP packets and IP + * broadcast packets are sent via GASP. + */ + if (memcmp(hdr_buf.h_dest, net->broadcast, FWNET_ALEN) == 0 + || proto == htons(ETH_P_ARP) + || (proto == htons(ETH_P_IP) + && IN_MULTICAST(ntohl(ip_hdr(skb)->daddr)))) { + max_payload = dev->broadcast_xmt_max_payload; + datagram_label_ptr = &dev->broadcast_xmt_datagramlabel; + + ptask->fifo_addr = FWNET_NO_FIFO_ADDR; + ptask->generation = 0; + ptask->dest_node = IEEE1394_ALL_NODES; + ptask->speed = SCODE_100; + } else { + __be64 guid = get_unaligned((__be64 *)hdr_buf.h_dest); + u8 generation; + + peer = fwnet_peer_find_by_guid(dev, be64_to_cpu(guid)); + if (!peer || peer->fifo == FWNET_NO_FIFO_ADDR) + goto fail_unlock; + + generation = peer->generation; + dest_node = peer->node_id; + max_payload = peer->max_payload; + datagram_label_ptr = &peer->datagram_label; + + ptask->fifo_addr = peer->fifo; + ptask->generation = generation; + ptask->dest_node = dest_node; + ptask->speed = peer->speed; + } + + /* If this is an ARP packet, convert it */ + if (proto == htons(ETH_P_ARP)) { + struct arphdr *arp = (struct arphdr *)skb->data; + unsigned char *arp_ptr = (unsigned char *)(arp + 1); + struct rfc2734_arp *arp1394 = (struct rfc2734_arp *)skb->data; + __be32 ipaddr; + + ipaddr = get_unaligned((__be32 *)(arp_ptr + FWNET_ALEN)); + + arp1394->hw_addr_len = RFC2734_HW_ADDR_LEN; + arp1394->max_rec = dev->card->max_receive; + arp1394->sspd = dev->card->link_speed; + + put_unaligned_be16(dev->local_fifo >> 32, + &arp1394->fifo_hi); + put_unaligned_be32(dev->local_fifo & 0xffffffff, + &arp1394->fifo_lo); + put_unaligned(ipaddr, &arp1394->sip); + } + + ptask->hdr.w0 = 0; + ptask->hdr.w1 = 0; + ptask->skb = skb; + ptask->dev = dev; + + /* Does it all fit in one packet? */ + if (dg_size <= max_payload) { + fwnet_make_uf_hdr(&ptask->hdr, ntohs(proto)); + ptask->outstanding_pkts = 1; + max_payload = dg_size + RFC2374_UNFRAG_HDR_SIZE; + } else { + u16 datagram_label; + + max_payload -= RFC2374_FRAG_OVERHEAD; + datagram_label = (*datagram_label_ptr)++; + fwnet_make_ff_hdr(&ptask->hdr, ntohs(proto), dg_size, + datagram_label); + ptask->outstanding_pkts = DIV_ROUND_UP(dg_size, max_payload); + max_payload += RFC2374_FRAG_HDR_SIZE; + } + + spin_unlock_irqrestore(&dev->lock, flags); + + ptask->max_payload = max_payload; + fwnet_send_packet(ptask); + + return NETDEV_TX_OK; + + fail_unlock: + spin_unlock_irqrestore(&dev->lock, flags); + fail: + if (ptask) + kmem_cache_free(fwnet_packet_task_cache, ptask); + + if (skb != NULL) + dev_kfree_skb(skb); + + net->stats.tx_dropped++; + net->stats.tx_errors++; + + /* + * FIXME: According to a patch from 2003-02-26, "returning non-zero + * causes serious problems" here, allegedly. Before that patch, + * -ERRNO was returned which is not appropriate under Linux 2.6. + * Perhaps more needs to be done? Stop the queue in serious + * conditions and restart it elsewhere? + */ + return NETDEV_TX_OK; +} + +static int fwnet_change_mtu(struct net_device *net, int new_mtu) +{ + if (new_mtu < 68) + return -EINVAL; + + net->mtu = new_mtu; + return 0; +} + +static void fwnet_get_drvinfo(struct net_device *net, + struct ethtool_drvinfo *info) +{ + strcpy(info->driver, KBUILD_MODNAME); + strcpy(info->bus_info, "ieee1394"); +} + +static struct ethtool_ops fwnet_ethtool_ops = { + .get_drvinfo = fwnet_get_drvinfo, +}; + +static const struct net_device_ops fwnet_netdev_ops = { + .ndo_open = fwnet_open, + .ndo_stop = fwnet_stop, + .ndo_start_xmit = fwnet_tx, + .ndo_change_mtu = fwnet_change_mtu, +}; + +static void fwnet_init_dev(struct net_device *net) +{ + net->header_ops = &fwnet_header_ops; + net->netdev_ops = &fwnet_netdev_ops; + net->watchdog_timeo = 2 * HZ; + net->flags = IFF_BROADCAST | IFF_MULTICAST; + net->features = NETIF_F_HIGHDMA; + net->addr_len = FWNET_ALEN; + net->hard_header_len = FWNET_HLEN; + net->type = ARPHRD_IEEE1394; + net->tx_queue_len = 10; + SET_ETHTOOL_OPS(net, &fwnet_ethtool_ops); +} + +/* caller must hold fwnet_device_mutex */ +static struct fwnet_device *fwnet_dev_find(struct fw_card *card) +{ + struct fwnet_device *dev; + + list_for_each_entry(dev, &fwnet_device_list, dev_link) + if (dev->card == card) + return dev; + + return NULL; +} + +static int fwnet_add_peer(struct fwnet_device *dev, + struct fw_unit *unit, struct fw_device *device) +{ + struct fwnet_peer *peer; + + peer = kmalloc(sizeof(*peer), GFP_KERNEL); + if (!peer) + return -ENOMEM; + + dev_set_drvdata(&unit->device, peer); + + peer->dev = dev; + peer->guid = (u64)device->config_rom[3] << 32 | device->config_rom[4]; + peer->fifo = FWNET_NO_FIFO_ADDR; + INIT_LIST_HEAD(&peer->pd_list); + peer->pdg_size = 0; + peer->datagram_label = 0; + peer->speed = device->max_speed; + peer->max_payload = fwnet_max_payload(device->max_rec, peer->speed); + + peer->generation = device->generation; + smp_rmb(); + peer->node_id = device->node_id; + + spin_lock_irq(&dev->lock); + list_add_tail(&peer->peer_link, &dev->peer_list); + spin_unlock_irq(&dev->lock); + + return 0; +} + +static int fwnet_probe(struct device *_dev) +{ + struct fw_unit *unit = fw_unit(_dev); + struct fw_device *device = fw_parent_device(unit); + struct fw_card *card = device->card; + struct net_device *net; + bool allocated_netdev = false; + struct fwnet_device *dev; + unsigned max_mtu; + int ret; + + mutex_lock(&fwnet_device_mutex); + + dev = fwnet_dev_find(card); + if (dev) { + net = dev->netdev; + goto have_dev; + } + + net = alloc_netdev(sizeof(*dev), "firewire%d", fwnet_init_dev); + if (net == NULL) { + ret = -ENOMEM; + goto out; + } + + allocated_netdev = true; + SET_NETDEV_DEV(net, card->device); + dev = netdev_priv(net); + + spin_lock_init(&dev->lock); + dev->broadcast_state = FWNET_BROADCAST_ERROR; + dev->broadcast_rcv_context = NULL; + dev->broadcast_xmt_max_payload = 0; + dev->broadcast_xmt_datagramlabel = 0; + + dev->local_fifo = FWNET_NO_FIFO_ADDR; + + INIT_LIST_HEAD(&dev->packet_list); + INIT_LIST_HEAD(&dev->broadcasted_list); + INIT_LIST_HEAD(&dev->sent_list); + INIT_LIST_HEAD(&dev->peer_list); + + dev->card = card; + dev->netdev = net; + + /* + * Use the RFC 2734 default 1500 octets or the maximum payload + * as initial MTU + */ + max_mtu = (1 << (card->max_receive + 1)) + - sizeof(struct rfc2734_header) - IEEE1394_GASP_HDR_SIZE; + net->mtu = min(1500U, max_mtu); + + /* Set our hardware address while we're at it */ + put_unaligned_be64(card->guid, net->dev_addr); + put_unaligned_be64(~0ULL, net->broadcast); + ret = register_netdev(net); + if (ret) { + fw_error("Cannot register the driver\n"); + goto out; + } + + list_add_tail(&dev->dev_link, &fwnet_device_list); + fw_notify("%s: IPv4 over FireWire on device %016llx\n", + net->name, (unsigned long long)card->guid); + have_dev: + ret = fwnet_add_peer(dev, unit, device); + if (ret && allocated_netdev) { + unregister_netdev(net); + list_del(&dev->dev_link); + } + out: + if (ret && allocated_netdev) + free_netdev(net); + + mutex_unlock(&fwnet_device_mutex); + + return ret; +} + +static void fwnet_remove_peer(struct fwnet_peer *peer) +{ + struct fwnet_partial_datagram *pd, *pd_next; + + spin_lock_irq(&peer->dev->lock); + list_del(&peer->peer_link); + spin_unlock_irq(&peer->dev->lock); + + list_for_each_entry_safe(pd, pd_next, &peer->pd_list, pd_link) + fwnet_pd_delete(pd); + + kfree(peer); +} + +static int fwnet_remove(struct device *_dev) +{ + struct fwnet_peer *peer = dev_get_drvdata(_dev); + struct fwnet_device *dev = peer->dev; + struct net_device *net; + struct fwnet_packet_task *ptask, *pt_next; + + mutex_lock(&fwnet_device_mutex); + + fwnet_remove_peer(peer); + + if (list_empty(&dev->peer_list)) { + net = dev->netdev; + unregister_netdev(net); + + if (dev->local_fifo != FWNET_NO_FIFO_ADDR) + fw_core_remove_address_handler(&dev->handler); + if (dev->broadcast_rcv_context) { + fw_iso_context_stop(dev->broadcast_rcv_context); + fw_iso_buffer_destroy(&dev->broadcast_rcv_buffer, + dev->card); + fw_iso_context_destroy(dev->broadcast_rcv_context); + } + list_for_each_entry_safe(ptask, pt_next, + &dev->packet_list, pt_link) { + dev_kfree_skb_any(ptask->skb); + kmem_cache_free(fwnet_packet_task_cache, ptask); + } + list_for_each_entry_safe(ptask, pt_next, + &dev->broadcasted_list, pt_link) { + dev_kfree_skb_any(ptask->skb); + kmem_cache_free(fwnet_packet_task_cache, ptask); + } + list_for_each_entry_safe(ptask, pt_next, + &dev->sent_list, pt_link) { + dev_kfree_skb_any(ptask->skb); + kmem_cache_free(fwnet_packet_task_cache, ptask); + } + list_del(&dev->dev_link); + + free_netdev(net); + } + + mutex_unlock(&fwnet_device_mutex); + + return 0; +} + +/* + * FIXME abort partially sent fragmented datagrams, + * discard partially received fragmented datagrams + */ +static void fwnet_update(struct fw_unit *unit) +{ + struct fw_device *device = fw_parent_device(unit); + struct fwnet_peer *peer = dev_get_drvdata(&unit->device); + int generation; + + generation = device->generation; + + spin_lock_irq(&peer->dev->lock); + peer->node_id = device->node_id; + peer->generation = generation; + spin_unlock_irq(&peer->dev->lock); +} + +static const struct ieee1394_device_id fwnet_id_table[] = { + { + .match_flags = IEEE1394_MATCH_SPECIFIER_ID | + IEEE1394_MATCH_VERSION, + .specifier_id = IANA_SPECIFIER_ID, + .version = RFC2734_SW_VERSION, + }, + { } +}; + +static struct fw_driver fwnet_driver = { + .driver = { + .owner = THIS_MODULE, + .name = "net", + .bus = &fw_bus_type, + .probe = fwnet_probe, + .remove = fwnet_remove, + }, + .update = fwnet_update, + .id_table = fwnet_id_table, +}; + +static const u32 rfc2374_unit_directory_data[] = { + 0x00040000, /* directory_length */ + 0x1200005e, /* unit_specifier_id: IANA */ + 0x81000003, /* textual descriptor offset */ + 0x13000001, /* unit_sw_version: RFC 2734 */ + 0x81000005, /* textual descriptor offset */ + 0x00030000, /* descriptor_length */ + 0x00000000, /* text */ + 0x00000000, /* minimal ASCII, en */ + 0x49414e41, /* I A N A */ + 0x00030000, /* descriptor_length */ + 0x00000000, /* text */ + 0x00000000, /* minimal ASCII, en */ + 0x49507634, /* I P v 4 */ +}; + +static struct fw_descriptor rfc2374_unit_directory = { + .length = ARRAY_SIZE(rfc2374_unit_directory_data), + .key = (CSR_DIRECTORY | CSR_UNIT) << 24, + .data = rfc2374_unit_directory_data +}; + +static int __init fwnet_init(void) +{ + int err; + + err = fw_core_add_descriptor(&rfc2374_unit_directory); + if (err) + return err; + + fwnet_packet_task_cache = kmem_cache_create("packet_task", + sizeof(struct fwnet_packet_task), 0, 0, NULL); + if (!fwnet_packet_task_cache) { + err = -ENOMEM; + goto out; + } + + err = driver_register(&fwnet_driver.driver); + if (!err) + return 0; + + kmem_cache_destroy(fwnet_packet_task_cache); +out: + fw_core_remove_descriptor(&rfc2374_unit_directory); + + return err; +} +module_init(fwnet_init); + +static void __exit fwnet_cleanup(void) +{ + driver_unregister(&fwnet_driver.driver); + kmem_cache_destroy(fwnet_packet_task_cache); + fw_core_remove_descriptor(&rfc2374_unit_directory); +} +module_exit(fwnet_cleanup); + +MODULE_AUTHOR("Jay Fenlason <fenlason@redhat.com>"); +MODULE_DESCRIPTION("IPv4 over IEEE1394 as per RFC 2734"); +MODULE_LICENSE("GPL"); +MODULE_DEVICE_TABLE(ieee1394, fwnet_id_table); Index: b/drivers/ieee1394/Kconfig =================================================================== --- a/drivers/ieee1394/Kconfig +++ b/drivers/ieee1394/Kconfig @@ -105,7 +105,7 @@ config IEEE1394_ETH1394_ROM_ENTRY default n config IEEE1394_ETH1394 - tristate "IP over 1394" + tristate "IP networking over 1394" depends on IEEE1394 && EXPERIMENTAL && INET select IEEE1394_ETH1394_ROM_ENTRY help -- Stefan Richter -=====-==--= -==- =---= http://arcgraph.de/sr/ ^ permalink raw reply [flat|nested] 18+ messages in thread
* What's in linux1394-2.6.git? -- Part II.3/3 2009-06-17 17:48 ` What's in linux1394-2.6.git? -- Part II.2/3 Stefan Richter @ 2009-06-17 17:50 ` Stefan Richter 0 siblings, 0 replies; 18+ messages in thread From: Stefan Richter @ 2009-06-17 17:50 UTC (permalink / raw) To: linux-kernel; +Cc: linux1394-devel The following patch was actually /not/ yet committed to linux1394-2.6.git but probably will be committed on Monday. Date: Tue, 16 Jun 2009 22:36:34 +0200 (CEST) From: Stefan Richter <stefanr@s5r6.in-berlin.de> Subject: firewire: new stack is no longer experimental The new stack is now recommended over the old one if used for industrial video (IIDC/DCAM) or for storage devices (SBP-2) due to better performance, improved compatibility, added features, and security. It should also be functionally on par with and is more secure than the old ieee1394 stack in the use case of consumer video devices. IP-over-1394 support for the new stack is currently emerging, and a backend of the firedtv DVB driver to the new stack should be available soon. The one remaining area where the old stack is still required are audio devices, as the new stack is not yet able to support the FFADO FireWire audio framework. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de> --- drivers/firewire/Kconfig | 52 ++++++++++++++++++--------------------- drivers/ieee1394/Kconfig | 19 ++++---------- 2 files changed, 30 insertions(+), 41 deletions(-) Index: b/drivers/firewire/Kconfig =================================================================== --- a/drivers/firewire/Kconfig +++ b/drivers/firewire/Kconfig @@ -1,28 +1,29 @@ -comment "A new alternative FireWire stack is available with EXPERIMENTAL=y" - depends on EXPERIMENTAL=n - -comment "Enable only one of the two stacks, unless you know what you are doing" - depends on EXPERIMENTAL +comment "You can enable one or both FireWire driver stacks." +comment "See the help texts for more information." config FIREWIRE - tristate "New FireWire stack, EXPERIMENTAL" - depends on EXPERIMENTAL + tristate "FireWire driver stack" select CRC_ITU_T help - This is the "Juju" FireWire stack, a new alternative implementation - designed for robustness and simplicity. You can build either this - stack, or the old stack (the ieee1394 driver, ohci1394 etc.) or both. - Please read http://ieee1394.wiki.kernel.org/index.php/Juju_Migration - before you enable the new stack. + This is the new-generation IEEE 1394 (FireWire) driver stack + a.k.a. Juju, a new implementation designed for robustness and + simplicity. + See http://ieee1394.wiki.kernel.org/index.php/Juju_Migration + for information about migration from the older Linux 1394 stack + to the new driver stack. To compile this driver as a module, say M here: the module will be called firewire-core. This module functionally replaces ieee1394, raw1394, and video1394. To access it from application programs, you generally need at least - libraw1394 version 2. IIDC/DCAM applications also need libdc1394 - version 2. No libraries are required to access storage devices - through the firewire-sbp2 driver. + libraw1394 v2. IIDC/DCAM applications need libdc1394 v2. + No libraries are required to access storage devices through the + firewire-sbp2 driver. + + NOTE: + FireWire audio devices currently require the old drivers (ieee1394, + ohci1394, raw1394). config FIREWIRE_OHCI tristate "OHCI-1394 controllers" @@ -37,11 +38,9 @@ config FIREWIRE_OHCI stack. NOTE: - - You should only build either firewire-ohci or the old ohci1394 driver, - but not both. If you nevertheless want to install both, you should - configure them only as modules and blacklist the driver(s) which you - don't want to have auto-loaded. Add either + If you want to install firewire-ohci and ohci1394 together, you + should configure them only as modules and blacklist the driver(s) + which you don't want to have auto-loaded. Add either blacklist firewire-ohci or @@ -50,12 +49,7 @@ config FIREWIRE_OHCI blacklist dv1394 to /etc/modprobe.conf or /etc/modprobe.d/* and update modprobe.conf - depending on your distribution. The latter two modules should be - blacklisted together with ohci1394 because they depend on ohci1394. - - If you have an old modprobe which doesn't implement the blacklist - directive, use "install modulename /bin/true" for the modules to be - blacklisted. + depending on your distribution. config FIREWIRE_OHCI_DEBUG bool @@ -79,13 +73,15 @@ config FIREWIRE_SBP2 configuration section. config FIREWIRE_NET - tristate "IP networking over 1394" - depends on FIREWIRE && INET + tristate "IP networking over 1394 (EXPERIMENTAL)" + depends on FIREWIRE && INET && EXPERIMENTAL help This enables IPv4 over IEEE 1394, providing IP connectivity with other implementations of RFC 2734 as found on several operating systems. Multicast support is currently limited. + NOTE, this driver is not stable yet! + To compile this driver as a module, say M here: The module will be called firewire-net. It replaces eth1394 of the classic IEEE 1394 stack. Index: b/drivers/ieee1394/Kconfig =================================================================== --- a/drivers/ieee1394/Kconfig +++ b/drivers/ieee1394/Kconfig @@ -4,7 +4,7 @@ menu "IEEE 1394 (FireWire) support" source "drivers/firewire/Kconfig" config IEEE1394 - tristate "Stable FireWire stack" + tristate "Legacy alternative FireWire driver stack" depends on PCI || BROKEN help IEEE 1394 describes a high performance serial bus, which is also @@ -33,11 +33,9 @@ config IEEE1394_OHCI1394 module will be called ohci1394. NOTE: - - You should only build either ohci1394 or the new firewire-ohci driver, - but not both. If you nevertheless want to install both, you should - configure them only as modules and blacklist the driver(s) which you - don't want to have auto-loaded. Add either + If you want to install firewire-ohci and ohci1394 together, you + should configure them only as modules and blacklist the driver(s) + which you don't want to have auto-loaded. Add either blacklist firewire-ohci or @@ -46,12 +44,7 @@ config IEEE1394_OHCI1394 blacklist dv1394 to /etc/modprobe.conf or /etc/modprobe.d/* and update modprobe.conf - depending on your distribution. The latter two modules should be - blacklisted together with ohci1394 because they depend on ohci1394. - - If you have an old modprobe which doesn't implement the blacklist - directive, use "install modulename /bin/true" for the modules to be - blacklisted. + depending on your distribution. comment "PCILynx controller requires I2C" depends on IEEE1394 && I2C=n @@ -105,7 +98,7 @@ config IEEE1394_ETH1394_ROM_ENTRY default n config IEEE1394_ETH1394 - tristate "IP networking over 1394" + tristate "IP networking over 1394 (experimental)" depends on IEEE1394 && EXPERIMENTAL && INET select IEEE1394_ETH1394_ROM_ENTRY help -- Stefan Richter -=====-==--= -==- =---= http://arcgraph.de/sr/ ^ permalink raw reply [flat|nested] 18+ messages in thread
* What's in linux1394-2.6.git? @ 2010-02-25 21:12 Stefan Richter 0 siblings, 0 replies; 18+ messages in thread From: Stefan Richter @ 2010-02-25 21:12 UTC (permalink / raw) To: linux1394-devel; +Cc: linux-kernel Hi all, if there are no objections, I will see to get the following pulled into the mainline early next week: - three cycle timer related enhancements (hence mostly audio related): hardware quirk fix for reliable cycle timer register access, "quirks" module parameter for firewire-ohci, choice of clock for local time in the read-cycle-timer ioctl, - a few fixes (minor ones as far as I can tell), - some refactoring like the config ROM text leaf accessor and dead code removal. Clemens Ladisch (2): firewire: add fw_csr_string() helper function firewire: ohci: work around cycle timer bugs on VIA controllers Németh Márton (1): firewire: make PCI device id constant Stefan Richter (21): firewire: core: fw_csr_string addendum firewire: qualify config ROM cache pointers as const pointers firewire: ohci: enable cycle timer fix on ALi and NEC controllers firewire: get_cycle_timer optimization and cleanup firewire: remove incomplete Bus_Time CSR support Merge tag 'v2.6.33' for its firewire changes since last branch point firewire: core: fix "giving up on config rom" with Panasonic AG-DV2500 firewire: core: don't fail device creation in case of too large config ROM blocks firewire: core: increase stack size of config ROM reader firewire: core: fix an information leak firewire: core: rename an internal function firewire: cdev: add more flexible cycle timer ioctl firewire: cdev: increment ABI version number firewire: core: change type of a data buffer firewire: core: combine a bit of repeated code firewire: ohci: remove unused dualbuffer IR code firewire: ohci: reorder struct fw_ohci for better cache efficiency firewire: ohci: use an ID table for quirks detection firewire: ohci: add module parameter to activate quirk fixes firewire: ohci: fix IR/IT context mask mixup firewire: ohci: extend initialization log message drivers/firewire/core-cdev.c | 368 +++++++++++++++---------------- drivers/firewire/core-device.c | 198 +++++++++++------ drivers/firewire/core-transaction.c | 17 +- drivers/firewire/core.h | 2 +- drivers/firewire/ohci.c | 364 ++++++++++-------------------- drivers/firewire/sbp2.c | 5 +- drivers/media/dvb/firewire/firedtv-fw.c | 39 +--- include/linux/firewire-cdev.h | 40 +++- include/linux/firewire.h | 11 +- include/linux/pci_ids.h | 1 - 10 files changed, 493 insertions(+), 552 deletions(-) -- Stefan Richter -=====-==-=- --=- ==--= http://arcgraph.de/sr/ ^ permalink raw reply [flat|nested] 18+ messages in thread
* What's in linux1394-2.6.git? @ 2009-11-24 17:34 Stefan Richter 0 siblings, 0 replies; 18+ messages in thread From: Stefan Richter @ 2009-11-24 17:34 UTC (permalink / raw) To: linux-kernel; +Cc: linux1394-devel Here is a summary of what is currently queued up in git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6.git and also visible in linux-next. Gitweb: http://git.kernel.org/?p=linux/kernel/git/ieee1394/linux1394-2.6.git fixes branch ============ These are two fixes which make the new firewire driver stack interoperable with FFADO, the userspace drivers for FireWire audio interfaces. I will ask Linus to pull this branch later this week, in hope to get these fixes released in 2.6.32. In addition to these two kernel fixes, there are also some updates to the firewire-core backend of libraw1394 necessary to make it work with FFADO. At the moment these proposed updates are queued up at the "testing" branch of git://git.kernel.org/pub/scm/libs/ieee1394/libraw1394.git testing Here is the shortlog and diffstat of the fixes branch; full log and diff follow at the end of this message: Jay Fenlason (2): firewire: ohci: Make cycleMatch ISO transmission work firewire: ohci: pass correct iso xmit timestamps to core drivers/firewire/ohci.c | 41 +++++++++++++++++++++++++++++++++----- 1 files changed, 35 insertions(+), 6 deletions(-) Many thanks to Jay for debugging and fixing these issues. Some more kernel work will be neessary for fully satisfactory support of FireWire audio interfaces: Multiplex FCP requests as necessary for multiple device support; implement variable split transaction time-out; longer-term: implement a kernelspace streaming component for FFADO (some groundwork has been done in a GSoC project). master branch ============= This is for the post 2.6.32 merge window. We have got minor fixes and tweaks, among them reduced stack usage in ioctls and and a considerable reduction of stack usage in the bus reset handler tasklet. Akinobu Mita (1): ieee1394: Use hweight32 Stefan Richter (9): firewire: cdev: fix memory leak in an error path firewire: normalize style of queue_work wrappers firewire: cdev: normalize variable names firewire: optimize config ROM creation firewire: core: clarify generate_config_rom usage firewire: core: optimize Topology Map creation firewire: core: WARN on wrong usage of core transaction functions firewire: ohci: 0 may be a valid DMA address firewire: cdev: reduce stack usage by ioctl_dispatch drivers/firewire/core-card.c | 75 ++++++++---------- drivers/firewire/core-cdev.c | 113 ++++++++++++++++----------- drivers/firewire/core-topology.c | 17 +++-- drivers/firewire/core-transaction.c | 19 ++--- drivers/firewire/core.h | 9 +- drivers/firewire/ohci.c | 39 ++++++---- drivers/firewire/sbp2.c | 9 ++- drivers/ieee1394/ohci1394.c | 8 +-- include/linux/firewire.h | 17 +---- 9 files changed, 159 insertions(+), 147 deletions(-) firedtv branch ============== This is only a temporary branch with updates of the FireDTV DVB driver. These updates are currently picked up by Mauro and will go into the mainline via the V4L-DVB tree. Most notably, the firedtv driver is now finally ported from the old ieee1394 stack to the new firewire stack. Depending on which one or two of the stacks are chosen in Kconfig, the firedtv driver is built with an interface to one or both of the stacks. Stefan Richter (11): firedtv: move remote control workqueue handling into rc source file firedtv: reform lock transaction backend call firedtv: add missing include, rename a constant firedtv: port to new firewire core firedtv: shrink buffer pointer table firedtv: packet requeuing is likely to succeed firedtv: remove an unnecessary function argument Merge tag 'v2.6.32-rc8' into firedtv firedtv: do not DMA-map stack addresses firedtv: remove check for interrupting signal firedtv: reduce memset()s drivers/media/dvb/firewire/Kconfig | 7 +- drivers/media/dvb/firewire/Makefile | 1 + drivers/media/dvb/firewire/firedtv-1394.c | 42 +- drivers/media/dvb/firewire/firedtv-avc.c | 566 +++++++++++---------- drivers/media/dvb/firewire/firedtv-dvb.c | 16 +- drivers/media/dvb/firewire/firedtv-fw.c | 376 ++++++++++++++ drivers/media/dvb/firewire/firedtv-rc.c | 2 + drivers/media/dvb/firewire/firedtv.h | 23 +- 8 files changed, 746 insertions(+), 287 deletions(-) create mode 100644 drivers/media/dvb/firewire/firedtv-fw.c And here are the two patches from the "fixes" branch because they weren't posted to LKML yet: commit 31769cef2e973544164aa7d0db2e2024660d5e21 Author: Jay Fenlason <fenlason@redhat.com> Date: Sat Nov 21 00:05:56 2009 +0100 firewire: ohci: pass correct iso xmit timestamps to core Here is the final set of patches I used to get ffado to work with the new firewire stack. With these patches, I was able to start ardour and record from and playback to my PreSonus Inspire1394 from a (mostly) Fedora 12 system. Signed-off-by: Jay Fenlason <fenlason@redhat.com> Until now, firewire-ohci exposed only the transmit cycle of the last transmitted packet at each isochronous transmit complete event. This made it impossible for FFADO (FireWire audio drivers in userspace) to synchronize audio-out streams. The fix is to store the timestamp of each packet in the iso xmit event. As a bonus, the transfer status is stored too. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de> diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index c07cfad..94260aa 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c @@ -1904,15 +1904,30 @@ static int handle_it_packet(struct context *context, { struct iso_context *ctx = container_of(context, struct iso_context, context); + int i; + struct descriptor *pd; - if (last->transfer_status == 0) - /* This descriptor isn't done yet, stop iteration. */ + for (pd = d; pd <= last; pd++) + if (pd->transfer_status) + break; + if (pd > last) + /* Descriptor(s) not done yet, stop iteration */ return 0; - if (le16_to_cpu(last->control) & DESCRIPTOR_IRQ_ALWAYS) + i = ctx->header_length; + if (i + 4 < PAGE_SIZE) { + /* Present this value as big-endian to match the receive code */ + *(__be32 *)(ctx->header + i) = cpu_to_be32( + ((u32)le16_to_cpu(pd->transfer_status) << 16) | + le16_to_cpu(pd->res_count)); + ctx->header_length += 4; + } + if (le16_to_cpu(last->control) & DESCRIPTOR_IRQ_ALWAYS) { ctx->base.callback(&ctx->base, le16_to_cpu(last->res_count), - 0, NULL, ctx->base.callback_data); - + ctx->header_length, ctx->header, + ctx->base.callback_data); + ctx->header_length = 0; + } return 1; } commit 5ed1f321a71b8549cc2eea26c94fe7943ed01d31 Author: Jay Fenlason <fenlason@redhat.com> Date: Tue Nov 17 12:29:17 2009 -0500 firewire: ohci: Make cycleMatch ISO transmission work Calling the START_ISO ioctl with a nonnegative cycle paramater has never worked. Last night I got around to figuring out why. Most of this patch is a big comment explaining why we enable an interrupt source then don't actually do anything when we get one. As the comment says, we should do more, but we don't have a way to tell userspace what happened. . . Signed-off-by: Jay Fenlason <fenlason@redhat.com> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de> (edited comment) diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index 5d52425..c07cfad 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c @@ -275,7 +275,7 @@ static void log_irqs(u32 evt) !(evt & OHCI1394_busReset)) return; - fw_notify("IRQ %08x%s%s%s%s%s%s%s%s%s%s%s%s%s\n", evt, + fw_notify("IRQ %08x%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", evt, evt & OHCI1394_selfIDComplete ? " selfID" : "", evt & OHCI1394_RQPkt ? " AR_req" : "", evt & OHCI1394_RSPkt ? " AR_resp" : "", @@ -286,6 +286,7 @@ static void log_irqs(u32 evt) evt & OHCI1394_postedWriteErr ? " postedWriteErr" : "", evt & OHCI1394_cycleTooLong ? " cycleTooLong" : "", evt & OHCI1394_cycle64Seconds ? " cycle64Seconds" : "", + evt & OHCI1394_cycleInconsistent ? " cycleInconsistent" : "", evt & OHCI1394_regAccessFail ? " regAccessFail" : "", evt & OHCI1394_busReset ? " busReset" : "", evt & ~(OHCI1394_selfIDComplete | OHCI1394_RQPkt | @@ -293,6 +294,7 @@ static void log_irqs(u32 evt) OHCI1394_respTxComplete | OHCI1394_isochRx | OHCI1394_isochTx | OHCI1394_postedWriteErr | OHCI1394_cycleTooLong | OHCI1394_cycle64Seconds | + OHCI1394_cycleInconsistent | OHCI1394_regAccessFail | OHCI1394_busReset) ? " ?" : ""); } @@ -1439,6 +1441,17 @@ static irqreturn_t irq_handler(int irq, void *data) OHCI1394_LinkControl_cycleMaster); } + if (unlikely(event & OHCI1394_cycleInconsistent)) { + /* + * We need to clear this event bit in order to make + * cycleMatch isochronous I/O work. In theory we should + * stop active cycleMatch iso contexts now and restart + * them at least two cycles later. (FIXME?) + */ + if (printk_ratelimit()) + fw_notify("isochronous cycle inconsistent\n"); + } + if (event & OHCI1394_cycle64Seconds) { cycle_time = reg_read(ohci, OHCI1394_IsochronousCycleTimer); if ((cycle_time & 0x80000000) == 0) @@ -1528,6 +1541,7 @@ static int ohci_enable(struct fw_card *card, u32 *config_rom, size_t length) OHCI1394_reqTxComplete | OHCI1394_respTxComplete | OHCI1394_isochRx | OHCI1394_isochTx | OHCI1394_postedWriteErr | OHCI1394_cycleTooLong | + OHCI1394_cycleInconsistent | OHCI1394_cycle64Seconds | OHCI1394_regAccessFail | OHCI1394_masterIntEnable); if (param_debug & OHCI_PARAM_DEBUG_BUSRESETS) -- Stefan Richter -=====-==--= =-== ==--- http://arcgraph.de/sr/ ^ permalink raw reply related [flat|nested] 18+ messages in thread
* What's in linux1394-2.6.git? @ 2009-03-17 21:11 Stefan Richter 0 siblings, 0 replies; 18+ messages in thread From: Stefan Richter @ 2009-03-17 21:11 UTC (permalink / raw) To: linux-kernel; +Cc: linux1394-devel The following list of firewire subsystem changes are planned to be included in the next pull request. We basically have a number of firewire-core feature extensions, primarily for userspace drivers, secondarily for kernelspace drivers. These extensions are essential for the firewire backend of libdc1394 and good-to-have for the firewire backend of libraw1394. With these changes, functionality of libdc1394 on the newer firewire driver stack not only catches up to libdc1394 on the classic ieee1394 stack but surpasses it. (On Linux, libdc1394 is the basic framework for IIDC based video acquisition in industrial and research settings.) Jay Fenlason deserves most of the credit for the queued-up work. He also implemented several of the firewire-cdev extensions first; I merely redid them based on his implementation. David Moore (1): firewire: Include iso timestamp in headers when header_size > 4 Jay Fenlason (4): firewire: add a client_list_lock firewire: cdev: use an idr rather than a linked list for resources firewire: implement asynchronous stream transmission firewire: broadcast channel support Jay Fenlason, Stefan Richter (2): firewire: cdev: add ioctls for isochronous resource management firewire: cdev: add ioctl for broadcast write requests Stefan Richter (44): firewire: convert client_list_lock to mutex firewire: cdev: documentation fixlet firewire: cdev: tcodes input validation firewire: cdev: fix race of fw_device_op_release with bus reset firewire: cdev: address handler input validation firewire: core: remove outdated comment firewire: core: remove obsolete assertions firewire: standardize a variable name firewire: remove line breaks before function names firewire: core: remove unused definitions firewire: cdev: use list_first_entry firewire: prevent creation of multiple IR DMA contexts for the same channel firewire: cdev: fix documentation of FW_CDEV_IOC_GET_INFO firewire: cdev: reference-count client instances firewire: cdev: unify names of struct types and of their instances firewire: cdev: sort includes firewire: core: topology header fix firewire: cdev: add ioctls for manual iso resource management firewire: cdev: add ioctl to query maximum transmission speed firewire: cdev: restrict broadcast write requests to Units Space firewire: cdev: extend transaction payload size check firewire: cdev: replace some spin_lock_irqsave by spin_lock_irq firewire: cdev: shut down iso context before freeing the buffer firewire: cdev: increment fw_cdev_version, update documentation firewire: cdev: add ioctls for iso resource management, amendment firewire: cdev: simplify a schedule_delayed_work wrapper firewire: core: clean up includes firewire: core: move some functions firewire: core: remove condition which is always false firewire: normalize a variable name firewire: core: normalize a function argument name firewire: cdev: amendment to "add ioctl to query maximum transmission speed" firewire: cdev: secure add_descriptor ioctl firewire: cdev: fix race of ioctl_send_request with bus reset firewire: cdev: simplify FW_CDEV_IOC_SEND_REQUEST return value firewire: cdev: add closure to async stream ioctl firewire: core: drop unused call parameters of close_transaction firewire: core: increase bus manager grace period firewire: core: simplify broadcast channel allocation firewire: core: optimize propagation of BROADCAST_CHANNEL ieee1394: sbp2: follow up on "ieee1394: inherit ud vendor_id from node vendor_id" ieee1394: raw1394: add sparse annotations to raw1394_compat_write ieee1394: constify device ID tables DVB: firedtv: fix printk format mismatch Tobias Klauser (1): ieee1394: Storage class should be before const qualifier drivers/firewire/fw-card.c | 149 +++-- drivers/firewire/fw-cdev.c | 1044 +++++++++++++++++++++--------- drivers/firewire/fw-device.c | 203 ++++--- drivers/firewire/fw-device.h | 23 +- drivers/firewire/fw-iso.c | 227 ++++++- drivers/firewire/fw-ohci.c | 260 ++++---- drivers/firewire/fw-sbp2.c | 57 +- drivers/firewire/fw-topology.c | 29 +- drivers/firewire/fw-topology.h | 19 +- drivers/firewire/fw-transaction.c | 185 +++--- drivers/firewire/fw-transaction.h | 138 ++--- drivers/ieee1394/csr.c | 8 +- drivers/ieee1394/dv1394.c | 2 +- drivers/ieee1394/eth1394.c | 4 +- drivers/ieee1394/highlevel.c | 2 +- drivers/ieee1394/nodemgr.c | 4 +- drivers/ieee1394/nodemgr.h | 2 +- drivers/ieee1394/raw1394.c | 14 +- drivers/ieee1394/sbp2.c | 9 +- drivers/ieee1394/video1394.c | 2 +- drivers/media/dvb/firewire/firedtv-avc.c | 4 +- include/linux/firewire-cdev.h | 218 ++++++- 22 files changed, 1679 insertions(+), 924 deletions(-) -- Stefan Richter -=====-==--= --== =---= http://arcgraph.de/sr/ ^ permalink raw reply [flat|nested] 18+ messages in thread
* What's in linux1394-2.6.git? @ 2008-12-22 20:59 Stefan Richter 0 siblings, 0 replies; 18+ messages in thread From: Stefan Richter @ 2008-12-22 20:59 UTC (permalink / raw) To: linux-kernel; +Cc: linux1394-devel Well, more interesting is what's /not/ yet in linux1394-2.6.git but will hopefully be ready for the post-2.6.28 merge window, and that's the following changes to the <linux/firewire-cdev.h> ABI: - Add ioctls for isochronous resource management, - add ioctl for broadcast write requests, - add ioctl for iso context removal, allow more than one iso context per fd. (This is the least important feature though.) Jay Fenlason has had implementations of all of these for a while now, I just need to bring them up-to-date with the latest fw-cdev changes, notably the client resource idr change. So, I hope to have some substantial additions ready soon, on top of what /is/ in linux1394-2.6.git at the moment: David Moore (1): firewire: Include iso timestamp in headers when header_size > 4 Frans Pop (1): ieee1394: ohci1394: don't leave interrupts enabled during suspend/resume Harvey Harrison (7): ieee1394: consolidate uses of IEEE1934_BUSID_MAGIC ieee1394: pcilynx: trivial endian annotation ieee1394: replace CSR_SET_BUS_INFO_GENERATION macro ieee1394: mark bus_info_data as a __be32 array ieee1394: eth1394: trivial sparse annotations ieee1394: dv1394 annotate frame input/output structs as little endian ieee1934: dv1394: interrupt enabling/disabling broken on big-endian Jay Fenlason (3): firewire: add a client_list_lock firewire: typo in comment firewire: improve refcounting of fw_card Stefan Richter (12): firewire: convert client_list_lock to mutex firewire: fw-sbp2: remove unnecessary locking firewire: fix small memory leak at module removal ieee1394: replace a GFP_ATOMIC by GFP_KERNEL allocation ieee1394: mark all hpsb_address_ops instances as const ieee1394: ohci1394: pass error codes from request_irq through ieee1394: ohci1394: flush MMIO writes before delay in initialization firewire: fix resetting of bus manager retry counter firewire: reorder struct fw_card for better cache efficiency firewire: cdev: documentation fixlet firewire: cdev: tcodes input validation ieee1394: ignore nonzero Bus_Info_Block.max_rom, fetch config ROM in quadlets drivers/firewire/fw-card.c | 20 ++++++-- drivers/firewire/fw-cdev.c | 63 ++++++++++++++++--------- drivers/firewire/fw-device.c | 11 +++-- drivers/firewire/fw-device.h | 6 ++ drivers/firewire/fw-ohci.c | 73 ++++++++++++++--------------- drivers/firewire/fw-sbp2.c | 21 ++------ drivers/firewire/fw-topology.c | 16 +++---- drivers/firewire/fw-transaction.c | 2 + drivers/firewire/fw-transaction.h | 13 ++--- drivers/ieee1394/csr.c | 12 ++-- drivers/ieee1394/csr.h | 10 ++-- drivers/ieee1394/csr1212.c | 45 ++++++------------ drivers/ieee1394/csr1212.h | 9 +--- drivers/ieee1394/dv1394-private.h | 44 +++++++++--------- drivers/ieee1394/dv1394.c | 12 ++-- drivers/ieee1394/eth1394.c | 28 ++++++------ drivers/ieee1394/eth1394.h | 16 +++--- drivers/ieee1394/highlevel.c | 9 ++-- drivers/ieee1394/highlevel.h | 7 ++- drivers/ieee1394/hosts.c | 6 +- drivers/ieee1394/hosts.h | 2 +- drivers/ieee1394/ieee1394.h | 3 + drivers/ieee1394/nodemgr.c | 20 ++------ drivers/ieee1394/nodemgr.h | 3 - drivers/ieee1394/ohci1394.c | 26 ++++++++--- drivers/ieee1394/pcilynx.c | 2 +- drivers/ieee1394/pcilynx.h | 2 +- drivers/ieee1394/raw1394.c | 2 +- drivers/ieee1394/sbp2.c | 4 +- include/linux/firewire-cdev.h | 2 +- 30 files changed, 246 insertions(+), 243 deletions(-) Some further notes: - We still need to increment the ABI version number due to David's patch, and document the change appropriately. - There is still an old fw-topology patch in #master which is not yet merge-ready, my "insist on successive self ID complete events". - I really should stop messing around with drivers/ieee1394 and instead concentrate on drivers/firewire now. But wait, there is one other thing sitting in linux1394-2.6.git: The firedtv driver which went from Greg's staging tree to linux1394-2.6.git before it was decided to put several staging drivers into 2.6.28 mainline --- and so it happened that firedtv is still out of the mainline. I still want to do some mostly trivial updates to it before I post a snapshot on LKML for review. I hope to get this done during the coming merge window, or slightly thereafter, and to get it finally into mainline for 2.6.29. There is one todo-item of this driver which is not trivial, and that's its adaptation from drivers/ieee1394 to drivers/firewire. But this should not block its mainline submission. Ben Backx (2): firesat: fix DVB-S2 device recognition firesat: add DVB-S support for DVB-S2 devices Greg Kroah-Hartman (1): DVB: add firesat driver Henrik Kurelid (5): firesat: update isochronous interface, add CI support firesat: avc resend firedtv: fix returned struct for ca_info firedtv: use length_field() of PMT as length firedtv: fix registration - adapter number could only be zero Stefan Richter (29): firesat: add missing copyright notes firesat: rename to firedtv firedtv: nicer registration message and some initialization fixes firedtv: some header cleanups firedtv: replace semaphore by mutex firedtv: move some code back to ieee1394 core firedtv: replace tasklet by workqueue job firedtv: fix remote control input ieee1394: use correct barrier types between accesses of nodeid and generation ieee1394: add hpsb_node_read() and hpsb_node_lock() ieee1394: inherit ud vendor_id from node vendor_id firedtv: use hpsb_node_read(), _write(), _lock() firedtv: add vendor_id and version to driver match table firedtv: remove unused dual subunit code from initialization firedtv: fix initialization of dvb_frontend.ops firedtv: remove unused struct members firedtv: fix string comparison and a few sparse warnings firedtv: register input device as child of a FireWire device firedtv: remove various debug code firedtv: remove AV/C debug code firedtv: remove CA debug code firedtv: trivial cleanups in firesat-ci firedtv: trivial cleanups in cmp firedtv: remove bitfield typedefs from cmp, fix for big endian CPUs firedtv: don't retry oPCR updates endlessly firedtv: trivial cleanups in avc_api firedtv: trivial reorganization in avc_api firedtv: replace mdelay by msleep firedtv: increase FCP frame length for DVB-S2 tune QSPK drivers/ieee1394/dma.h | 1 + drivers/ieee1394/ieee1394_core.c | 1 + drivers/ieee1394/ieee1394_transactions.c | 29 + drivers/ieee1394/ieee1394_transactions.h | 2 + drivers/ieee1394/iso.h | 1 + drivers/ieee1394/nodemgr.c | 10 +- drivers/ieee1394/nodemgr.h | 18 + drivers/media/dvb/Kconfig | 2 + drivers/media/dvb/Makefile | 2 + drivers/media/dvb/firesat/Kconfig | 12 + drivers/media/dvb/firesat/Makefile | 13 + drivers/media/dvb/firesat/avc_api.c | 1051 ++++++++++++++++++++++ drivers/media/dvb/firesat/avc_api.h | 432 +++++++++ drivers/media/dvb/firesat/cmp.c | 171 ++++ drivers/media/dvb/firesat/cmp.h | 9 + drivers/media/dvb/firesat/firesat-ci.c | 261 ++++++ drivers/media/dvb/firesat/firesat-ci.h | 9 + drivers/media/dvb/firesat/firesat-rc.c | 191 ++++ drivers/media/dvb/firesat/firesat-rc.h | 11 + drivers/media/dvb/firesat/firesat.h | 227 +++++ drivers/media/dvb/firesat/firesat_1394.c | 291 ++++++ drivers/media/dvb/firesat/firesat_dvb.c | 276 ++++++ drivers/media/dvb/firesat/firesat_fe.c | 245 +++++ drivers/media/dvb/firesat/firesat_iso.c | 111 +++ 24 files changed, 3373 insertions(+), 3 deletions(-) create mode 100644 drivers/media/dvb/firesat/Kconfig create mode 100644 drivers/media/dvb/firesat/Makefile create mode 100644 drivers/media/dvb/firesat/avc_api.c create mode 100644 drivers/media/dvb/firesat/avc_api.h create mode 100644 drivers/media/dvb/firesat/cmp.c create mode 100644 drivers/media/dvb/firesat/cmp.h create mode 100644 drivers/media/dvb/firesat/firesat-ci.c create mode 100644 drivers/media/dvb/firesat/firesat-ci.h create mode 100644 drivers/media/dvb/firesat/firesat-rc.c create mode 100644 drivers/media/dvb/firesat/firesat-rc.h create mode 100644 drivers/media/dvb/firesat/firesat.h create mode 100644 drivers/media/dvb/firesat/firesat_1394.c create mode 100644 drivers/media/dvb/firesat/firesat_dvb.c create mode 100644 drivers/media/dvb/firesat/firesat_fe.c create mode 100644 drivers/media/dvb/firesat/firesat_iso.c -- Stefan Richter -=====-==--- ==-- =-==- http://arcgraph.de/sr/ ^ permalink raw reply [flat|nested] 18+ messages in thread
* What's in linux1394-2.6.git? @ 2008-10-10 18:30 Stefan Richter 2008-10-13 12:18 ` Mauro Carvalho Chehab 0 siblings, 1 reply; 18+ messages in thread From: Stefan Richter @ 2008-10-10 18:30 UTC (permalink / raw) To: linux-kernel; +Cc: linux1394-devel, Mauro Carvalho Chehab The "misc" branch ================= essentially contains continuations of work in 2.6.27 on the old ieee1394 stack: - BKL removal (now complete in the IEEE 1394 subsystem), - more robustness against connection loss. All of this except for "firewire: time out in fw_core_remove_card" is merge-ready and will appear in a pull request mid of next week. There is nothing interesting for the new firewire stack in it, alas. Jay Fenlason (1): firewire: fw_send_request_sync() Julia Lawall (1): ieee1394: Use DIV_ROUND_UP Stefan Richter (12): ieee1394: sbp2: stricter dma_sync ieee1394: sbp2: check for DMA mapping failures ieee1394: sbp2: enforce s/g segment size limit firewire: fw-sbp2: enforce s/g segment size limit firewire: fw-sbp2: fix another small generation access bug ieee1394: raw1394: replace BKL by local mutex, make ioctl() and mmap() thread-safe ieee1394: raw1394: narrow down the state_mutex protected region ieee1394: raw1394: make write() thread-safe ieee1394: nodemgr clean up class iterators ieee1394: survive a few seconds connection loss ieee1394: dv1394, video1394: remove unnecessary expressions firewire: time out in fw_core_remove_card The "cdev" branch ================= contains updates to the firewire-core userspace interface which I think should be deferred to after 2.6.28 (for 2.6.29-rc1). I would like to add Jay Fenlason's other pending work on the userspace API (iso resource management, broadcast requests...) and some touch-ups. I wished I had all of this ready for the currently open merge window, but I simply d id not have the necessary time. Well, actually the two fixes and the documentation patch can and will already go in in next week's pull request. David Moore (1): firewire: Include iso timestamp in headers when header_size > 4 Jay Fenlason (3): firewire: fw_send_request_sync() firewire: Add more documentation to firewire-cdev.h firewire: add a client_list_lock Stefan Richter (2): firewire: fix setting tag and sy in iso transmission firewire: fix ioctl() return code The "master" branch =================== has stuff that is still not merge-ready even though it's half a year old. Stefan Richter (2): firewire: insist on successive self ID complete events firewire: unnecessary BM delay after generation rollover The "firedtv" branch ==================== has one new driver for some FireWire DVB devices. Well, it's actually an old driver which went through v4l-experimental and Greg's staging tree, and was taken into linux1394-2.6.git only for some mainline submission preparations. There are four things which would be nice to do before asking for this to be pulled into mainline: - rename the directory, files and some types and variables from firesat to firedtv, - replace bitfield accesses of on-the-wire data by opencoded shifting/ masking/ endian conversion macros, - trivial but possibly numerous stylistic touchups (whitespace, comment style...), - post a snapshot on LKML. These steps are all simple boring tasks. I hope to complete them still during the merge window. Furthermore, maybe I will collapse most of the commits which I authored into a single commit to condense less interesting history. I suppose I will ask Mauro instead of Linus to pull the driver, although the patch queue does not touch the DVB subsystem except for adding the driver to the Makefile and Kconfig. Ben Backx (2): firesat: fix DVB-S2 device recognition firesat: add DVB-S support for DVB-S2 devices Greg Kroah-Hartman (1): DVB: add firesat driver Henrik Kurelid (2): firesat: update isochronous interface, add CI support firesat: avc resend Stefan Richter (18): firesat: add missing copyright notes firesat: rename to firedtv firedtv: nicer registration message and some initialization fixes firedtv: some header cleanups firedtv: replace semaphore by mutex firedtv: move some code back to ieee1394 core firedtv: replace tasklet by workqueue job firedtv: fix remote control input ieee1394: use correct barrier types between accesses of nodeid and generation ieee1394: add hpsb_node_read() and hpsb_node_lock() ieee1394: inherit ud vendor_id from node vendor_id firedtv: use hpsb_node_read(), _write(), _lock() firedtv: add vendor_id and version to driver match table firedtv: remove unused dual subunit code from initialization firedtv: fix initialization of dvb_frontend.ops firedtv: remove unused struct members firedtv: fix string comparison and a few sparse warnings firedtv: register input device as child of a FireWire device -- Stefan Richter -=====-==--- =-=- -=-=- http://arcgraph.de/sr/ ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: What's in linux1394-2.6.git? 2008-10-10 18:30 Stefan Richter @ 2008-10-13 12:18 ` Mauro Carvalho Chehab 0 siblings, 0 replies; 18+ messages in thread From: Mauro Carvalho Chehab @ 2008-10-13 12:18 UTC (permalink / raw) To: Stefan Richter; +Cc: linux-kernel, linux1394-devel On Fri, 10 Oct 2008 20:30:35 +0200 (CEST) Stefan Richter <stefanr@s5r6.in-berlin.de> wrote: > I suppose I will ask Mauro instead of Linus to pull the driver, although > the patch queue does not touch the DVB subsystem except for adding the > driver to the Makefile and Kconfig. Seems fine for me. As we've added several new drivers for 2.6.28, this is also safer to avoid (trivial) conflicts. Cheers, Mauro ^ permalink raw reply [flat|nested] 18+ messages in thread
* What's in linux1394-2.6.git? @ 2008-07-14 11:42 ` Stefan Richter 0 siblings, 0 replies; 18+ messages in thread From: Stefan Richter @ 2008-07-14 11:42 UTC (permalink / raw) To: linux-kernel; +Cc: linux1394-devel, linux-scsi Hi all, I now rebased all linux1394-2.6.git branches onto v2.6.26. Here is how it looks like now and what I plan to get merged into mainline: branch for-linus (based on v2.6.26) =================================== Contains cleanups including bits of Big Kernel Lock related work and Philippe's patch to include IR/IT DMA buffers of raw1394, video1394, dv1394 in core dumps. All of these patches have been seen on lkml and linux1394-devel and have been in many -next kernels without problem. I will send a pull request to Linus soon, maybe still today. Alan Cox (1): ieee1394: raw1394: Push the BKL down into the driver ioctls Philippe De Muyter (1): ieee1394: dump mmapped iso buffers in core files Stefan Richter (7): ieee1394: reduce log noise about config ROM CRC errors ieee1394: video1394: reorder module init, prepare BKL removal firewire: implement broadcast_channel CSR for 1394a compliance firewire: remove unused struct members firewire: clean up some includes firewire: clean up fw_card reference counting firewire: don't respond to broadcast write requests drivers/firewire/fw-card.c | 32 +++++++++++++++++--------- drivers/firewire/fw-device.c | 5 +-- drivers/firewire/fw-device.h | 1 - drivers/firewire/fw-ohci.c | 1 - drivers/firewire/fw-transaction.c | 32 +++++++++++++++++++------- drivers/firewire/fw-transaction.h | 34 ++++++++++++++++++++++------ drivers/ieee1394/csr1212.c | 32 ++++++++++++++++++-------- drivers/ieee1394/dma.c | 2 +- drivers/ieee1394/highlevel.c | 4 +-- drivers/ieee1394/highlevel.h | 13 ++++++++++- drivers/ieee1394/raw1394.c | 20 ++++++++++++---- drivers/ieee1394/video1394.c | 2 + 12 files changed, 125 insertions(+), 53 deletions(-) branch sbp2-spindown (based on v2.6.26) ======================================= Contains a new device quirk handling in sd-mod and uses it for some buggy SBP-2 disks. Also changes the default setting of manage_start_stop of all SBP-2 HDDs from off to on. That is, disks will now per default spun down if the system is suspended or shut down or if sd-mod is unbound from a HDD. This change is only done if the SBP-2 driver has exclusively logged in to a HDD (also the default mode), i.e. the feature is not used in multiple initiator setups. The patches have been seen on lkml, lsml, and linux1394-devel and have been in many -next kernels without problem. James has been polled for ACK or NAK regarding the SCSI change a few times but I didn't get a response. I will nevertheless submit this for mainline merge ASAP but in a pull request separate from the other for-linus patches. Stefan Richter (5): scsi: sd: optionally set power condition in START STOP UNIT firewire: fw-sbp2: fix spindown for PL-3507 and TSB42AA9 firmwares ieee1394: sbp2: fix spindown for PL-3507 and TSB42AA9 firmwares firewire: fw-sbp2: spin disks down on suspend and shutdown ieee1394: sbp2: spin disks down on suspend and shutdown drivers/firewire/fw-sbp2.c | 25 +++++++++++++++++++++++-- drivers/ieee1394/sbp2.c | 22 ++++++++++++++++++++-- drivers/ieee1394/sbp2.h | 1 + drivers/scsi/sd.c | 5 +++++ include/scsi/scsi_device.h | 1 + 5 files changed, 50 insertions(+), 4 deletions(-) branch for-next (based on for-linus) ==================================== Contains new patches which have not yet been in -next. However, they look like they could be merged even before 2.6.27-rc1 gets out. Stefan Richter (5): firewire: fix race of bus reset with request transmission firewire: fully initialize fw_transaction before marking it pending firewire: small fw_fill_request cleanup firewire: warn on unfinished transactions during card removal Merge branch 'sbp2-spindown' into for-next drivers/firewire/fw-card.c | 2 +- drivers/firewire/fw-topology.c | 2 -- drivers/firewire/fw-transaction.c | 21 +++++++++------------ 3 files changed, 10 insertions(+), 15 deletions(-) branch master (based on for-next) ================================= Contains an already very old fix and a small optimization. The fix still needs follow-up work; it trades a fix for potential but rare kernel panic with not too rare but avoidable temporary connection loss. I need to implement something to let the connection survive the respective situations. Stefan Richter (2): firewire: insist on successive self ID complete events firewire: unnecessary BM delay after generation rollover drivers/firewire/fw-card.c | 2 +- drivers/firewire/fw-topology.c | 12 ++++++++++++ drivers/firewire/fw-transaction.h | 9 +++++++++ 3 files changed, 22 insertions(+), 1 deletions(-) -- Stefan Richter -=====-==--- -=== -===- http://arcgraph.de/sr/ ^ permalink raw reply [flat|nested] 18+ messages in thread
* What's in linux1394-2.6.git? @ 2008-07-14 11:42 ` Stefan Richter 0 siblings, 0 replies; 18+ messages in thread From: Stefan Richter @ 2008-07-14 11:42 UTC (permalink / raw) To: linux-kernel; +Cc: linux1394-devel, linux-scsi Hi all, I now rebased all linux1394-2.6.git branches onto v2.6.26. Here is how it looks like now and what I plan to get merged into mainline: branch for-linus (based on v2.6.26) =================================== Contains cleanups including bits of Big Kernel Lock related work and Philippe's patch to include IR/IT DMA buffers of raw1394, video1394, dv1394 in core dumps. All of these patches have been seen on lkml and linux1394-devel and have been in many -next kernels without problem. I will send a pull request to Linus soon, maybe still today. Alan Cox (1): ieee1394: raw1394: Push the BKL down into the driver ioctls Philippe De Muyter (1): ieee1394: dump mmapped iso buffers in core files Stefan Richter (7): ieee1394: reduce log noise about config ROM CRC errors ieee1394: video1394: reorder module init, prepare BKL removal firewire: implement broadcast_channel CSR for 1394a compliance firewire: remove unused struct members firewire: clean up some includes firewire: clean up fw_card reference counting firewire: don't respond to broadcast write requests drivers/firewire/fw-card.c | 32 +++++++++++++++++--------- drivers/firewire/fw-device.c | 5 +-- drivers/firewire/fw-device.h | 1 - drivers/firewire/fw-ohci.c | 1 - drivers/firewire/fw-transaction.c | 32 +++++++++++++++++++------- drivers/firewire/fw-transaction.h | 34 ++++++++++++++++++++++------ drivers/ieee1394/csr1212.c | 32 ++++++++++++++++++-------- drivers/ieee1394/dma.c | 2 +- drivers/ieee1394/highlevel.c | 4 +-- drivers/ieee1394/highlevel.h | 13 ++++++++++- drivers/ieee1394/raw1394.c | 20 ++++++++++++---- drivers/ieee1394/video1394.c | 2 + 12 files changed, 125 insertions(+), 53 deletions(-) branch sbp2-spindown (based on v2.6.26) ======================================= Contains a new device quirk handling in sd-mod and uses it for some buggy SBP-2 disks. Also changes the default setting of manage_start_stop of all SBP-2 HDDs from off to on. That is, disks will now per default spun down if the system is suspended or shut down or if sd-mod is unbound from a HDD. This change is only done if the SBP-2 driver has exclusively logged in to a HDD (also the default mode), i.e. the feature is not used in multiple initiator setups. The patches have been seen on lkml, lsml, and linux1394-devel and have been in many -next kernels without problem. James has been polled for ACK or NAK regarding the SCSI change a few times but I didn't get a response. I will nevertheless submit this for mainline merge ASAP but in a pull request separate from the other for-linus patches. Stefan Richter (5): scsi: sd: optionally set power condition in START STOP UNIT firewire: fw-sbp2: fix spindown for PL-3507 and TSB42AA9 firmwares ieee1394: sbp2: fix spindown for PL-3507 and TSB42AA9 firmwares firewire: fw-sbp2: spin disks down on suspend and shutdown ieee1394: sbp2: spin disks down on suspend and shutdown drivers/firewire/fw-sbp2.c | 25 +++++++++++++++++++++++-- drivers/ieee1394/sbp2.c | 22 ++++++++++++++++++++-- drivers/ieee1394/sbp2.h | 1 + drivers/scsi/sd.c | 5 +++++ include/scsi/scsi_device.h | 1 + 5 files changed, 50 insertions(+), 4 deletions(-) branch for-next (based on for-linus) ==================================== Contains new patches which have not yet been in -next. However, they look like they could be merged even before 2.6.27-rc1 gets out. Stefan Richter (5): firewire: fix race of bus reset with request transmission firewire: fully initialize fw_transaction before marking it pending firewire: small fw_fill_request cleanup firewire: warn on unfinished transactions during card removal Merge branch 'sbp2-spindown' into for-next drivers/firewire/fw-card.c | 2 +- drivers/firewire/fw-topology.c | 2 -- drivers/firewire/fw-transaction.c | 21 +++++++++------------ 3 files changed, 10 insertions(+), 15 deletions(-) branch master (based on for-next) ================================= Contains an already very old fix and a small optimization. The fix still needs follow-up work; it trades a fix for potential but rare kernel panic with not too rare but avoidable temporary connection loss. I need to implement something to let the connection survive the respective situations. Stefan Richter (2): firewire: insist on successive self ID complete events firewire: unnecessary BM delay after generation rollover drivers/firewire/fw-card.c | 2 +- drivers/firewire/fw-topology.c | 12 ++++++++++++ drivers/firewire/fw-transaction.h | 9 +++++++++ 3 files changed, 22 insertions(+), 1 deletions(-) -- Stefan Richter -=====-==--- -=== -===- http://arcgraph.de/sr/ ------------------------------------------------------------------------- Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08 ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: What's in linux1394-2.6.git? 2008-07-14 11:42 ` Stefan Richter @ 2008-07-14 12:37 ` Stefan Richter -1 siblings, 0 replies; 18+ messages in thread From: Stefan Richter @ 2008-07-14 12:37 UTC (permalink / raw) To: linux-kernel; +Cc: linux1394-devel, linux-scsi On 14 Jul, Stefan Richter wrote: > I now rebased all linux1394-2.6.git branches onto v2.6.26. Here is how > it looks like now and what I plan to get merged into mainline: PS, URLs for checkouts: git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6.git http://www.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6.git gitweb: http://git.kernel.org/?p=linux/kernel/git/ieee1394/linux1394-2.6.git -- Stefan Richter -=====-==--- -=== -===- http://arcgraph.de/sr/ ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: What's in linux1394-2.6.git? @ 2008-07-14 12:37 ` Stefan Richter 0 siblings, 0 replies; 18+ messages in thread From: Stefan Richter @ 2008-07-14 12:37 UTC (permalink / raw) To: linux-kernel; +Cc: linux1394-devel, linux-scsi On 14 Jul, Stefan Richter wrote: > I now rebased all linux1394-2.6.git branches onto v2.6.26. Here is how > it looks like now and what I plan to get merged into mainline: PS, URLs for checkouts: git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6.git http://www.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6.git gitweb: http://git.kernel.org/?p=linux/kernel/git/ieee1394/linux1394-2.6.git -- Stefan Richter -=====-==--- -=== -===- http://arcgraph.de/sr/ ------------------------------------------------------------------------- Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08 ^ permalink raw reply [flat|nested] 18+ messages in thread
* What's in linux1394-2.6.git? @ 2008-04-02 21:52 Stefan Richter 0 siblings, 0 replies; 18+ messages in thread From: Stefan Richter @ 2008-04-02 21:52 UTC (permalink / raw) To: linux-kernel; +Cc: linux1394-devel Well, nothing big. First of all, what's _not_ in linux1394-2.6.git: DV reception is still broken in drivers/firewire/ on OHCI 1.0 variants of VIA VT630x. IP over 1394 is still not ported from drivers/ieee1394/ to drivers/firewire/. Both issues are held up by of lack of manpower. These and a bunch of other miscellaneous issues with drivers/firewire/ still keep them labeled EXPERIMENTAL for the time to come, even though we made some good progress with what went in for 2.6.25. Before distributors consider to switch from the ieee1394 subsystem to the firewire subsystem, they should have a good look at the ToDo and migration pages at wiki.linux1394.org. Now, what do we actually have for 2.6.26: - raw1394, video1394, dv1394: [improvement] These drivers are no longer bound to unit directory devices. This has always been unnecessary and got in the way of more specialized out-of-tree drivers. - firewire-core: [fix] Recognize changes in the configuration ROM of devices while they are plugged in. - firewire-ohci: [feature] Logging of various events can be enabled at runtime by a module parameter. This helps debugging the drivers as well as devices. - firewire-ohci: [feature] Unfiltered remote DMA can be enabled at compile time via a new option in the kernel hacking menu. This enables remote debugging as with ohci1394. - all: A bunch of bug fixes which seemed to fit into .26 better than into .25. Small cleanups. Almost all patches have been seen on LKML (and all on linux1394-devel), hence I don't repost them this time. They have all been exposed to -mm and to -next. In the latter, linux1394-2.6.git is still involved in a trivial merge conflict due to the kernel hacking menu entry. Still pending work: My firewire-core reference counting changes had two comments from Kristian which I will address in an incremental update; perhaps I manage to do this in time for the merge. Also, Pieter Palmer's iso transmit patch for the ieee1394 stack may perhaps be ready then. Shortlog and diffstat: Adrian Bunk (1): firewire: cleanups Harvey Harrison (1): ieee1394: replace remaining __FUNCTION__ occurrences Jarod Wilson (3): firewire: fw-sbp2: set dual-phase cycle_limit firewire: replace more hex values with defined csr constants firewire: use bitwise and to get reg in handle_registers Marcin Slusarz (1): ieee1394: be*_add_cpu conversion Robert P. J. Day (2): ieee1394: Use shorter list_splice_init() for brevity. ieee1394: Remove superfluous calls to kobject_set_name(). Stefan Richter (30): ieee1394: sbp2: relax SCSI DMA alignment ieee1394: prevent device binding of raw1394, video1394, dv1394 ieee1394: ohci1394: switch on bus power after resume on PPC PMac ieee1394: ohci1394: refactor probe, remove, suspend, resume ieee1394: ohci1394: unroll a macro with return ieee1394: ohci1394: refactor some printk format strings ieee1394: ohci1394: missing PPC PMac feature calls in failure path firewire: fw-sbp2: relax SCSI DMA alignment firewire: remove superfluous reference counting firewire: fw-sbp2: fix reference counting firewire: refactor fw_unit reference counting firewire: fw-sbp2: remove usages of fw_memcpy_to_be32 firewire: fw-sbp2: simplify some macros firewire: fw-sbp2: remove unnecessary memset firewire: fw-sbp2: reduce log noise firewire: fw-ohci: add option for remote debugging firewire: fw-ohci: switch on bus power after resume on PPC PMac firewire: fw-ohci: refactor probe, remove, suspend, resume firewire: replace static ROM cache by allocated cache firewire: reread config ROM when device reset the bus firewire: remove unused struct member firewire: insist on successive self ID complete events firewire: fw-ohci: add self ID error check firewire: fw-ohci: catch self_id_count == 0 firewire: debug interrupt events firewire: fw-ohci: untangle a mixed unsigned/signed expression firewire: wait until PHY configuration packet was transmitted (fix bus reset loop) firewire: fw-ohci: missing PPC PMac feature calls in failure path firewire: unnecessary BM delay after generation rollover firewire: fix synchronization of gap counts Documentation/debugging-via-ohci1394.txt | 13 +- drivers/firewire/Kconfig | 5 + drivers/firewire/fw-card.c | 52 +--- drivers/firewire/fw-cdev.c | 13 +- drivers/firewire/fw-device.c | 263 +++++++++++++++---- drivers/firewire/fw-device.h | 38 ++- drivers/firewire/fw-iso.c | 5 - drivers/firewire/fw-ohci.c | 321 +++++++++++++++++----- drivers/firewire/fw-ohci.h | 1 + drivers/firewire/fw-sbp2.c | 150 +++++------ drivers/firewire/fw-topology.c | 22 ++- drivers/firewire/fw-topology.h | 11 +- drivers/firewire/fw-transaction.c | 75 +++--- drivers/firewire/fw-transaction.h | 17 +- drivers/ieee1394/csr.c | 6 +- drivers/ieee1394/dv1394.c | 4 +- drivers/ieee1394/highlevel.c | 6 +- drivers/ieee1394/ieee1394_core.c | 2 +- drivers/ieee1394/nodemgr.c | 6 +- drivers/ieee1394/ohci1394.c | 229 ++++++++-------- drivers/ieee1394/pcilynx.c | 15 +- drivers/ieee1394/raw1394.c | 2 - drivers/ieee1394/sbp2.c | 11 +- drivers/ieee1394/video1394.c | 4 +- lib/Kconfig.debug | 10 + 25 files changed, 820 insertions(+), 461 deletions(-) -- Stefan Richter -=====-==--- -=-- ---=- http://arcgraph.de/sr/ ^ permalink raw reply [flat|nested] 18+ messages in thread
* What's in linux1394-2.6.git? @ 2008-01-17 21:07 Stefan Richter 0 siblings, 0 replies; 18+ messages in thread From: Stefan Richter @ 2008-01-17 21:07 UTC (permalink / raw) To: linux-kernel; +Cc: linux1394-devel Not much, and all of it is meant to be merged post 2.6.24. The most notable updates are fixes to firewire-ohci which fundamentally improve isochronous reception via libdc1394 v2. After these fixes, the most notable remaining issues with drivers/firewire are: - difficulties to detect SBP-2 (storage) devices on some hosts (need to collect debug data for this ASAP), - DV reception broken on OHCI 1.0 variants of VIA VT630x, - IP over 1394 still not implemented/ ported. So, distributors of kernel packages, be advised that the firewire drivers are still not as functional as the classic ieee1394 driver stack. As always, more details on this are captured at wiki.linux1394.org. I will follow up to this post with two combo patches, reflecting the merge queue for drivers/ieee1394 and drivers/firewire respectively, because several of the patches have not been seen on lkml yet, only on linux1394-devel. All of the patches have been in -mm though (except for a refresh of two small patches which happened after -rc8-mm1). Shortlog and diffstat: David Moore (3): firewire: fw-ohci: Fix for dualbuffer three-or-more buffers firewire: fw-ohci: Bug fixes for packet-per-buffer support firewire: fw-ohci: Dynamically allocate buffers for DMA descriptors Jay Fenlason (1): firewire: fw-sbp2: quiet logout errors on device removal Joe Perches (1): ieee1394: Add missing "space" Nick Piggin (1): ieee1394: nopage Rabin Vincent (1): firewire: Fix extraction of source node id Stefan Richter (11): ieee1394: sbp2: prepare for s/g chaining ieee1394: sbp2: s/g list access cosmetics ieee1394: small cleanup after "nopage" ieee1394: remove unused code ieee1394: sbp2: raise default transfer size limit ieee1394: ohci1394: don't schedule IT tasklets on IR events firewire: fw-sbp2: refactor workq and kref handling firewire: fw-sbp2: prepare for s/g chaining firewire: fw-sbp2: remove unused misleading macro firewire: fw-ohci: CycleTooLong interrupt management firewire vs. ieee1394: clarify MAINTAINERS MAINTAINERS | 4 +- drivers/firewire/fw-ohci.c | 390 +++++++++++++--------- drivers/firewire/fw-sbp2.c | 84 +++-- drivers/firewire/fw-transaction.c | 2 +- drivers/ieee1394/dma.c | 39 +-- drivers/ieee1394/ieee1394_transactions.c | 68 ---- drivers/ieee1394/ohci1394.c | 12 +- drivers/ieee1394/raw1394.c | 4 +- drivers/ieee1394/sbp2.c | 52 ++-- drivers/ieee1394/sbp2.h | 1 - 10 files changed, 340 insertions(+), 316 deletions(-) -- Stefan Richter -=====-==--- ---= =---= http://arcgraph.de/sr/ ^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2010-02-25 21:12 UTC | newest] Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2009-06-14 10:46 What's in linux1394-2.6.git? Stefan Richter 2009-06-14 10:48 ` Stefan Richter 2009-06-17 17:44 ` What's in linux1394-2.6.git? -- Part II.0/3 Stefan Richter 2009-06-17 17:47 ` What's in linux1394-2.6.git? -- Part II.1/3 Stefan Richter 2009-06-17 17:48 ` What's in linux1394-2.6.git? -- Part II.2/3 Stefan Richter 2009-06-17 17:50 ` What's in linux1394-2.6.git? -- Part II.3/3 Stefan Richter -- strict thread matches above, loose matches on Subject: below -- 2010-02-25 21:12 What's in linux1394-2.6.git? Stefan Richter 2009-11-24 17:34 Stefan Richter 2009-03-17 21:11 Stefan Richter 2008-12-22 20:59 Stefan Richter 2008-10-10 18:30 Stefan Richter 2008-10-13 12:18 ` Mauro Carvalho Chehab 2008-07-14 11:42 Stefan Richter 2008-07-14 11:42 ` Stefan Richter 2008-07-14 12:37 ` Stefan Richter 2008-07-14 12:37 ` Stefan Richter 2008-04-02 21:52 Stefan Richter 2008-01-17 21:07 Stefan Richter
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.