drivers/scsi/fnic/fnic_fcs.c
Source file repositories/reference/linux-study-clean/drivers/scsi/fnic/fnic_fcs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/fnic/fnic_fcs.c- Extension
.c- Size
- 35355 bytes
- Lines
- 1181
- Domain
- Driver Families
- Bucket
- drivers/scsi
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/errno.hlinux/pci.hlinux/slab.hlinux/skbuff.hlinux/interrupt.hlinux/spinlock.hlinux/if_ether.hlinux/if_vlan.hlinux/workqueue.hscsi/fc/fc_fip.hscsi/fc/fc_els.hscsi/fc_frame.hlinux/etherdevice.hscsi/scsi_transport_fc.hfnic_io.hfnic.hfnic_fdls.hfdls_fc.hcq_enet_desc.hcq_exch_desc.hfip.h
Detected Declarations
function fnic_fdls_set_fcoe_srcmacfunction fnic_fdls_set_fcoe_dstmacfunction fnic_get_host_port_statefunction fnic_fdls_link_status_changefunction ethhdrfunction fnic_fdls_initfunction fnic_handle_linkfunction fnic_handle_framefunction fnic_handle_fip_framefunction fnic_import_rq_eth_pktfunction fnic_update_mac_lockedfunction fnic_rq_cmpl_frame_recvfunction fnic_rq_cmpl_handler_contfunction fnic_rq_cmpl_handlerfunction fnic_alloc_rq_framefunction fnic_free_rq_buffunction fnic_send_framefunction fdls_send_fcoe_framefunction fnic_send_fcoe_framefunction fnic_send_fip_framefunction fnic_flush_txfunction list_for_each_entry_safefunction fnic_fdls_register_portidfunction fnic_free_txqfunction list_for_each_entry_safefunction fnic_free_rxqfunction list_for_each_entry_safefunction fnic_wq_complete_frame_sendfunction fnic_wq_cmpl_handler_contfunction fnic_wq_cmpl_handlerfunction fnic_free_wq_buffunction fnic_fdls_add_tportfunction fnic_fdls_remove_tportfunction fnic_delete_fcp_tportsfunction fnic_tport_event_handlerfunction fnic_flush_tport_event_listfunction fnic_reset_work_handlerfunction fnic_fcpio_reset
Annotated Snippet
if (iport->usefip) {
iport->state = FNIC_IPORT_STATE_FIP;
FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
"link up: %d, usefip: %d", linkup, iport->usefip);
fnic_fcoe_send_vlan_req(fnic);
} else {
iport->state = FNIC_IPORT_STATE_FABRIC_DISC;
FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
"iport->state: %d", iport->state);
fnic_fdls_disc_start(iport);
}
} else {
iport->state = FNIC_IPORT_STATE_LINK_WAIT;
if (!is_zero_ether_addr(iport->fpma))
vnic_dev_del_addr(fnic->vdev, iport->fpma);
fnic_common_fip_cleanup(fnic);
fnic_fdls_link_down(iport);
}
spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
}
/*
* FPMA can be either taken from ethhdr(dst_mac) or flogi resp
* or derive from FC_MAP and FCID combination. While it should be
* same, revisit this if there is any possibility of not-correct.
*/
void fnic_fdls_learn_fcoe_macs(struct fnic_iport_s *iport, void *rx_frame,
uint8_t *fcid)
{
struct fnic *fnic = iport->fnic;
struct ethhdr *ethhdr = (struct ethhdr *) rx_frame;
uint8_t fcmac[6] = { 0x0E, 0xFC, 0x00, 0x00, 0x00, 0x00 };
memcpy(&fcmac[3], fcid, 3);
FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
"learn fcoe: dst_mac: %02x:%02x:%02x:%02x:%02x:%02x",
ethhdr->h_dest[0], ethhdr->h_dest[1],
ethhdr->h_dest[2], ethhdr->h_dest[3],
ethhdr->h_dest[4], ethhdr->h_dest[5]);
FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
"learn fcoe: fc_mac: %02x:%02x:%02x:%02x:%02x:%02x",
fcmac[0], fcmac[1], fcmac[2], fcmac[3], fcmac[4],
fcmac[5]);
fnic_fdls_set_fcoe_srcmac(fnic, fcmac);
fnic_fdls_set_fcoe_dstmac(fnic, ethhdr->h_source);
}
void fnic_fdls_init(struct fnic *fnic, int usefip)
{
struct fnic_iport_s *iport = &fnic->iport;
/* Initialize iPort structure */
iport->state = FNIC_IPORT_STATE_INIT;
iport->fnic = fnic;
iport->usefip = usefip;
FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
"iportsrcmac: %02x:%02x:%02x:%02x:%02x:%02x",
iport->hwmac[0], iport->hwmac[1], iport->hwmac[2],
iport->hwmac[3], iport->hwmac[4], iport->hwmac[5]);
INIT_LIST_HEAD(&iport->tport_list);
INIT_LIST_HEAD(&iport->tport_list_pending_del);
fnic_fdls_disc_init(iport);
}
void fnic_handle_link(struct work_struct *work)
{
struct fnic *fnic = container_of(work, struct fnic, link_work);
int old_link_status;
u32 old_link_down_cnt;
int max_count = 0;
if (vnic_dev_get_intr_mode(fnic->vdev) != VNIC_DEV_INTR_MODE_MSI)
FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
"Interrupt mode is not MSI\n");
spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags);
if (fnic->stop_rx_link_events) {
spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
"Stop link rx events\n");
return;
Annotation
- Immediate include surface: `linux/errno.h`, `linux/pci.h`, `linux/slab.h`, `linux/skbuff.h`, `linux/interrupt.h`, `linux/spinlock.h`, `linux/if_ether.h`, `linux/if_vlan.h`.
- Detected declarations: `function fnic_fdls_set_fcoe_srcmac`, `function fnic_fdls_set_fcoe_dstmac`, `function fnic_get_host_port_state`, `function fnic_fdls_link_status_change`, `function ethhdr`, `function fnic_fdls_init`, `function fnic_handle_link`, `function fnic_handle_frame`, `function fnic_handle_fip_frame`, `function fnic_import_rq_eth_pkt`.
- Atlas domain: Driver Families / drivers/scsi.
- Implementation status: source 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.