drivers/scsi/fcoe/fcoe.c
Source file repositories/reference/linux-study-clean/drivers/scsi/fcoe/fcoe.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/fcoe/fcoe.c- Extension
.c- Size
- 75031 bytes
- Lines
- 2807
- Domain
- Driver Families
- Bucket
- drivers/scsi
- 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/module.hlinux/spinlock.hlinux/netdevice.hlinux/etherdevice.hlinux/ethtool.hlinux/if_ether.hlinux/if_vlan.hlinux/crc32.hlinux/slab.hlinux/cpu.hlinux/fs.hlinux/sysfs.hlinux/ctype.hlinux/workqueue.hnet/dcbnl.hnet/dcbevent.hscsi/scsi_tcq.hscsi/scsicam.hscsi/scsi_transport.hscsi/scsi_transport_fc.hnet/netdev_lock.hnet/rtnetlink.hscsi/fc/fc_encaps.hscsi/fc/fc_fip.hscsi/fc/fc_fcoe.hscsi/libfc.hscsi/fc_frame.hscsi/libfcoe.hfcoe.h
Detected Declarations
struct fip_frameenum fcoe_create_link_statefunction fcoe_interface_setupfunction fcoe_interface_createfunction fcoe_interface_removefunction fcoe_interface_cleanupfunction fcoe_fip_recvfunction fcoe_fip_vlan_recvfunction fcoe_port_sendfunction fcoe_fip_sendfunction fcoe_update_src_macfunction fcoe_get_src_macfunction fcoe_lport_configfunction fcoe_netdev_features_changefunction fcoe_netdev_configfunction fcoe_shost_configfunction fcoe_fdmi_infofunction fcoe_oem_matchfunction fcoe_em_configfunction list_for_each_entryfunction fcoe_if_destroyfunction fcoe_ddp_setupfunction fcoe_ddp_targetfunction fcoe_ddp_donefunction fcoe_if_createfunction fcoe_if_initfunction fcoe_if_exitfunction fcoe_thread_cleanup_localfunction fcoe_rcvfunction fcoe_alloc_paged_crc_eoffunction fcoe_xmitfunction fcoe_filter_framesfunction ntoh24function fcoe_recv_framefunction fcoe_receive_workfunction fcoe_dev_setupfunction fcoe_dev_cleanupfunction fcoe_hostlist_lookup_realdev_portfunction list_for_each_entryfunction fcoe_dcb_app_notificationfunction fcoe_device_notificationfunction list_for_each_entryfunction fcoe_disablefunction fcoe_enablefunction fcoe_ctlr_enabledfunction fcoe_ctlr_modefunction fcoe_destroyfunction fcoe_destroy_work
Annotated Snippet
const struct net_device_ops *ops;
fcoe->netdev = netdev;
/* Let LLD initialize for FCoE */
ops = netdev->netdev_ops;
if (ops->ndo_fcoe_enable) {
if (ops->ndo_fcoe_enable(netdev))
FCOE_NETDEV_DBG(netdev, "Failed to enable FCoE"
" specific feature for LLD.\n");
}
/* Do not support for bonding device */
if (netif_is_bond_master(netdev)) {
FCOE_NETDEV_DBG(netdev, "Bonded interfaces not supported\n");
return -EOPNOTSUPP;
}
/* look for SAN MAC address, if multiple SAN MACs exist, only
* use the first one for SPMA */
real_dev = is_vlan_dev(netdev) ? vlan_dev_real_dev(netdev) : netdev;
fcoe->realdev = real_dev;
rcu_read_lock();
for_each_dev_addr(real_dev, ha) {
if ((ha->type == NETDEV_HW_ADDR_T_SAN) &&
(is_valid_ether_addr(ha->addr))) {
memcpy(fip->ctl_src_addr, ha->addr, ETH_ALEN);
fip->spma = 1;
break;
}
}
rcu_read_unlock();
/* setup Source Mac Address */
if (!fip->spma)
memcpy(fip->ctl_src_addr, netdev->dev_addr, netdev->addr_len);
/*
* Add FCoE MAC address as second unicast MAC address
* or enter promiscuous mode if not capable of listening
* for multiple unicast MACs.
*/
dev_uc_add(netdev, flogi_maddr);
if (fip->spma)
dev_uc_add(netdev, fip->ctl_src_addr);
if (fip->mode == FIP_MODE_VN2VN) {
dev_mc_add(netdev, FIP_ALL_VN2VN_MACS);
dev_mc_add(netdev, FIP_ALL_P2P_MACS);
} else
dev_mc_add(netdev, FIP_ALL_ENODE_MACS);
/*
* setup the receive function from ethernet driver
* on the ethertype for the given device
*/
fcoe->fcoe_packet_type.func = fcoe_rcv;
fcoe->fcoe_packet_type.type = htons(ETH_P_FCOE);
fcoe->fcoe_packet_type.dev = netdev;
dev_add_pack(&fcoe->fcoe_packet_type);
fcoe->fip_packet_type.func = fcoe_fip_recv;
fcoe->fip_packet_type.type = htons(ETH_P_FIP);
fcoe->fip_packet_type.dev = netdev;
dev_add_pack(&fcoe->fip_packet_type);
if (netdev != real_dev) {
fcoe->fip_vlan_packet_type.func = fcoe_fip_vlan_recv;
fcoe->fip_vlan_packet_type.type = htons(ETH_P_FIP);
fcoe->fip_vlan_packet_type.dev = real_dev;
dev_add_pack(&fcoe->fip_vlan_packet_type);
}
return 0;
}
/**
* fcoe_interface_create() - Create a FCoE interface on a net device
* @netdev: The net device to create the FCoE interface on
* @fip_mode: The mode to use for FIP
*
* Returns: pointer to a struct fcoe_interface or NULL on error
*/
static struct fcoe_interface *fcoe_interface_create(struct net_device *netdev,
enum fip_mode fip_mode)
{
struct fcoe_ctlr_device *ctlr_dev;
struct fcoe_ctlr *ctlr;
struct fcoe_interface *fcoe;
int size;
int err;
Annotation
- Immediate include surface: `linux/module.h`, `linux/spinlock.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/ethtool.h`, `linux/if_ether.h`, `linux/if_vlan.h`, `linux/crc32.h`.
- Detected declarations: `struct fip_frame`, `enum fcoe_create_link_state`, `function fcoe_interface_setup`, `function fcoe_interface_create`, `function fcoe_interface_remove`, `function fcoe_interface_cleanup`, `function fcoe_fip_recv`, `function fcoe_fip_vlan_recv`, `function fcoe_port_send`, `function fcoe_fip_send`.
- Atlas domain: Driver Families / drivers/scsi.
- 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.