drivers/firewire/net.c
Source file repositories/reference/linux-study-clean/drivers/firewire/net.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/firewire/net.c- Extension
.c- Size
- 42746 bytes
- Lines
- 1710
- Domain
- Driver Families
- Bucket
- drivers/firewire
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bug.hlinux/compiler.hlinux/delay.hlinux/device.hlinux/ethtool.hlinux/firewire.hlinux/firewire-constants.hlinux/highmem.hlinux/in.hlinux/ip.hlinux/jiffies.hlinux/mod_devicetable.hlinux/module.hlinux/moduleparam.hlinux/mutex.hlinux/netdevice.hlinux/skbuff.hlinux/slab.hlinux/spinlock.hlinux/unaligned.hnet/arp.hnet/firewire.h
Detected Declarations
struct rfc2734_headerstruct fwnet_fragment_infostruct fwnet_partial_datagramstruct fwnet_devicestruct fwnet_peerstruct fwnet_packet_taskfunction Copyrightfunction fwnet_make_uf_hdrfunction fwnet_make_ff_hdrfunction fwnet_make_sf_hdrfunction fwnet_header_createfunction fwnet_header_cachefunction fwnet_header_cache_updatefunction fwnet_header_parsefunction fwnet_frag_overlapfunction fwnet_pd_deletefunction fwnet_pd_updatefunction fwnet_pd_is_completefunction fwnet_max_payloadfunction fwnet_finish_incoming_packetfunction fwnet_incoming_packetfunction fwnet_receive_packetfunction gasp_source_idfunction gasp_specifier_idfunction gasp_versionfunction fwnet_receive_broadcastfunction fwnet_free_ptaskfunction dec_queued_datagramsfunction fwnet_transmit_packet_donefunction fwnet_transmit_packet_failedfunction fwnet_write_completefunction fwnet_send_packetfunction fwnet_fifo_stopfunction fwnet_fifo_startfunction __fwnet_broadcast_stopfunction fwnet_broadcast_stopfunction fwnet_broadcast_startfunction set_carrier_statefunction fwnet_openfunction fwnet_stopfunction fwnet_txfunction fwnet_init_devfunction fwnet_add_peerfunction fwnet_probefunction fwnet_updatefunction fwnet_remove_peerfunction fwnet_removefunction fwnet_init
Annotated Snippet
static const struct net_device_ops fwnet_netdev_ops = {
.ndo_open = fwnet_open,
.ndo_stop = fwnet_stop,
.ndo_start_xmit = fwnet_tx,
};
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 = FWNET_TX_QUEUE_LEN;
net->ethtool_ops = &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_obj(*peer);
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];
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);
dev->peer_count++;
set_carrier_state(dev);
spin_unlock_irq(&dev->lock);
return 0;
}
static int fwnet_probe(struct fw_unit *unit,
const struct ieee1394_device_id *id)
{
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;
union fwnet_hwaddr ha;
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", NET_NAME_UNKNOWN,
fwnet_init_dev);
if (net == NULL) {
mutex_unlock(&fwnet_device_mutex);
return -ENOMEM;
}
Annotation
- Immediate include surface: `linux/bug.h`, `linux/compiler.h`, `linux/delay.h`, `linux/device.h`, `linux/ethtool.h`, `linux/firewire.h`, `linux/firewire-constants.h`, `linux/highmem.h`.
- Detected declarations: `struct rfc2734_header`, `struct fwnet_fragment_info`, `struct fwnet_partial_datagram`, `struct fwnet_device`, `struct fwnet_peer`, `struct fwnet_packet_task`, `function Copyright`, `function fwnet_make_uf_hdr`, `function fwnet_make_ff_hdr`, `function fwnet_make_sf_hdr`.
- Atlas domain: Driver Families / drivers/firewire.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.