drivers/scsi/fcoe/fcoe_transport.c
Source file repositories/reference/linux-study-clean/drivers/scsi/fcoe/fcoe_transport.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/fcoe/fcoe_transport.c- Extension
.c- Size
- 27387 bytes
- Lines
- 1060
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/types.hlinux/module.hlinux/kernel.hlinux/list.hlinux/netdevice.hlinux/ethtool.hlinux/errno.hlinux/crc32.hscsi/libfcoe.hlibfcoe.h
Detected Declarations
function eth2fc_speedfunction fcoe_link_speed_updatefunction __fcoe_get_lesbfunction fcoe_get_lesbfunction fcoe_ctlr_get_lesbfunction fcoe_wwn_to_strfunction fcoe_validate_vport_createfunction fcoe_get_wwnfunction fcoe_fc_crcfunction fcoe_start_iofunction fcoe_clean_pending_queuefunction fcoe_check_wait_queuefunction fcoe_queue_timerfunction fcoe_get_paged_crc_eoffunction fcoe_transport_attachfunction fcoe_transport_detachfunction fcoe_transport_showfunction fcoe_transport_initfunction fcoe_transport_exitfunction fcoe_add_netdev_mappingfunction fcoe_del_netdev_mappingfunction fcoe_if_to_netdevfunction libfcoe_device_notificationfunction fcoe_ctlr_create_storefunction fcoe_ctlr_destroy_storefunction fcoe_transport_createfunction fcoe_transport_destroyfunction fcoe_transport_disablefunction fcoe_transport_enablefunction libfcoe_initfunction libfcoe_exitmodule init libfcoe_initexport fcoe_link_speed_updateexport __fcoe_get_lesbexport fcoe_get_lesbexport fcoe_ctlr_get_lesbexport fcoe_wwn_to_strexport fcoe_validate_vport_createexport fcoe_get_wwnexport fcoe_fc_crcexport fcoe_start_ioexport fcoe_clean_pending_queueexport fcoe_check_wait_queueexport fcoe_queue_timerexport fcoe_get_paged_crc_eofexport fcoe_transport_attachexport fcoe_transport_detach
Annotated Snippet
const struct net_device_ops *ops = netdev->netdev_ops;
if (ops->ndo_fcoe_get_wwn)
return ops->ndo_fcoe_get_wwn(netdev, wwn, type);
return -EINVAL;
}
EXPORT_SYMBOL_GPL(fcoe_get_wwn);
/**
* fcoe_fc_crc() - Calculates the CRC for a given frame
* @fp: The frame to be checksumed
*
* This uses crc32() routine to calculate the CRC for a frame
*
* Return: The 32 bit CRC value
*/
u32 fcoe_fc_crc(struct fc_frame *fp)
{
struct sk_buff *skb = fp_skb(fp);
skb_frag_t *frag;
unsigned char *data;
unsigned long off, len, clen;
u32 crc;
unsigned i;
crc = crc32(~0, skb->data, skb_headlen(skb));
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
frag = &skb_shinfo(skb)->frags[i];
off = skb_frag_off(frag);
len = skb_frag_size(frag);
while (len > 0) {
clen = min(len, PAGE_SIZE - (off & ~PAGE_MASK));
data = kmap_atomic(
skb_frag_page(frag) + (off >> PAGE_SHIFT));
crc = crc32(crc, data + (off & ~PAGE_MASK), clen);
kunmap_atomic(data);
off += clen;
len -= clen;
}
}
return crc;
}
EXPORT_SYMBOL_GPL(fcoe_fc_crc);
/**
* fcoe_start_io() - Start FCoE I/O
* @skb: The packet to be transmitted
*
* This routine is called from the net device to start transmitting
* FCoE packets.
*
* Returns: 0 for success
*/
int fcoe_start_io(struct sk_buff *skb)
{
struct sk_buff *nskb;
int rc;
nskb = skb_clone(skb, GFP_ATOMIC);
if (!nskb)
return -ENOMEM;
rc = dev_queue_xmit(nskb);
if (rc != 0)
return rc;
kfree_skb(skb);
return 0;
}
EXPORT_SYMBOL_GPL(fcoe_start_io);
/**
* fcoe_clean_pending_queue() - Dequeue a skb and free it
* @lport: The local port to dequeue a skb on
*/
void fcoe_clean_pending_queue(struct fc_lport *lport)
{
struct fcoe_port *port = lport_priv(lport);
struct sk_buff *skb;
spin_lock_bh(&port->fcoe_pending_queue.lock);
while ((skb = __skb_dequeue(&port->fcoe_pending_queue)) != NULL) {
spin_unlock_bh(&port->fcoe_pending_queue.lock);
kfree_skb(skb);
spin_lock_bh(&port->fcoe_pending_queue.lock);
}
spin_unlock_bh(&port->fcoe_pending_queue.lock);
}
EXPORT_SYMBOL_GPL(fcoe_clean_pending_queue);
Annotation
- Immediate include surface: `linux/types.h`, `linux/module.h`, `linux/kernel.h`, `linux/list.h`, `linux/netdevice.h`, `linux/ethtool.h`, `linux/errno.h`, `linux/crc32.h`.
- Detected declarations: `function eth2fc_speed`, `function fcoe_link_speed_update`, `function __fcoe_get_lesb`, `function fcoe_get_lesb`, `function fcoe_ctlr_get_lesb`, `function fcoe_wwn_to_str`, `function fcoe_validate_vport_create`, `function fcoe_get_wwn`, `function fcoe_fc_crc`, `function fcoe_start_io`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.