drivers/scsi/scsi_transport_fc.c
Source file repositories/reference/linux-study-clean/drivers/scsi/scsi_transport_fc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/scsi_transport_fc.c- Extension
.c- Size
- 133982 bytes
- Lines
- 4415
- Domain
- Driver Families
- Bucket
- drivers/scsi
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/init.hlinux/slab.hlinux/delay.hlinux/hex.hlinux/kernel.hlinux/bsg-lib.hscsi/scsi_device.hscsi/scsi_host.hscsi/scsi_transport.hscsi/scsi_transport_fc.hscsi/scsi_cmnd.hnet/netlink.hscsi/scsi_netlink_fc.hscsi/scsi_bsg_fc.huapi/scsi/fc/fc_els.hscsi_priv.h
Detected Declarations
struct fc_internalfunction show_fc_fc4sfunction fc_target_setupfunction fc_host_setupfunction fc_host_removefunction fc_get_event_numberfunction fc_host_post_fc_eventfunction fc_host_post_eventfunction fc_host_post_vendor_eventfunction fc_find_rport_by_wwpnfunction list_for_each_entryfunction fc_li_stats_updatefunction fc_delivery_stats_updatefunction fc_cn_stats_updatefunction fc_fpin_pname_stats_updatefunction fc_fpin_li_stats_updatefunction fc_fpin_delivery_stats_updatefunction fc_fpin_peer_congn_stats_updatefunction fc_fpin_congn_stats_updatefunction fc_host_fpin_rcvfunction fc_transport_initfunction fc_transport_exitfunction show_fc_rport_supported_classesfunction fc_str_to_dev_lossfunction fc_rport_set_dev_loss_tmofunction store_fc_rport_dev_loss_tmofunction show_fc_rport_rolesfunction fc_rport_set_marginal_statefunction show_fc_rport_port_statefunction show_fc_rport_fast_io_fail_tmofunction store_fc_rport_fast_io_fail_tmofunction show_fc_vport_rolesfunction store_fc_vport_deletefunction store_fc_vport_disablefunction show_fc_host_supported_classesfunction show_fc_host_supported_fc4sfunction show_fc_host_supported_speedsfunction show_fc_host_active_fc4sfunction show_fc_host_speedfunction show_fc_private_host_tgtid_bind_typefunction store_fc_private_host_tgtid_bind_typefunction store_fc_private_host_issue_lipfunction store_fc_private_host_dev_loss_tmofunction fc_stat_showfunction fc_reset_statisticsfunction fc_parse_wwnfunction store_fc_host_vport_createfunction prefixes
Annotated Snippet
error = device_add(dev);
if (error) {
printk(KERN_ERR "FC Remote Port device_add failed\n");
goto delete_rport;
}
transport_add_device(dev);
transport_configure_device(dev);
fc_bsg_rportadd(shost, rport);
/* ignore any bsg add error - we just can't do sgio */
if (rport->roles & FC_PORT_ROLE_FCP_TARGET) {
/* initiate a scan of the target */
rport->flags |= FC_RPORT_SCAN_PENDING;
scsi_queue_work(shost, &rport->scan_work);
}
return rport;
delete_rport:
transport_destroy_device(dev);
spin_lock_irqsave(shost->host_lock, flags);
list_del(&rport->peers);
scsi_host_put(shost); /* for fc_host->rport list */
spin_unlock_irqrestore(shost->host_lock, flags);
put_device(dev->parent);
kfree(rport);
return NULL;
}
/**
* fc_remote_port_add - notify fc transport of the existence of a remote FC port.
* @shost: scsi host the remote port is connected to.
* @channel: Channel on shost port connected to.
* @ids: The world wide names, fc address, and FC4 port
* roles for the remote port.
*
* The LLDD calls this routine to notify the transport of the existence
* of a remote port. The LLDD provides the unique identifiers (wwpn,wwn)
* of the port, it's FC address (port_id), and the FC4 roles that are
* active for the port.
*
* For ports that are FCP targets (aka scsi targets), the FC transport
* maintains consistent target id bindings on behalf of the LLDD.
* A consistent target id binding is an assignment of a target id to
* a remote port identifier, which persists while the scsi host is
* attached. The remote port can disappear, then later reappear, and
* it's target id assignment remains the same. This allows for shifts
* in FC addressing (if binding by wwpn or wwnn) with no apparent
* changes to the scsi subsystem which is based on scsi host number and
* target id values. Bindings are only valid during the attachment of
* the scsi host. If the host detaches, then later re-attaches, target
* id bindings may change.
*
* This routine is responsible for returning a remote port structure.
* The routine will search the list of remote ports it maintains
* internally on behalf of consistent target id mappings. If found, the
* remote port structure will be reused. Otherwise, a new remote port
* structure will be allocated.
*
* Whenever a remote port is allocated, a new fc_remote_port class
* device is created.
*
* Should not be called from interrupt context.
*
* Notes:
* This routine assumes no locks are held on entry.
*/
struct fc_rport *
fc_remote_port_add(struct Scsi_Host *shost, int channel,
struct fc_rport_identifiers *ids)
{
struct fc_internal *fci = to_fc_internal(shost->transportt);
struct fc_host_attrs *fc_host = shost_to_fc_host(shost);
struct fc_rport *rport;
unsigned long flags;
int match = 0;
/* ensure any stgt delete functions are done */
fc_flush_work(shost);
/*
* Search the list of "active" rports, for an rport that has been
* deleted, but we've held off the real delete while the target
* is in a "blocked" state.
*/
spin_lock_irqsave(shost->host_lock, flags);
list_for_each_entry(rport, &fc_host->rports, peers) {
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/slab.h`, `linux/delay.h`, `linux/hex.h`, `linux/kernel.h`, `linux/bsg-lib.h`, `scsi/scsi_device.h`.
- Detected declarations: `struct fc_internal`, `function show_fc_fc4s`, `function fc_target_setup`, `function fc_host_setup`, `function fc_host_remove`, `function fc_get_event_number`, `function fc_host_post_fc_event`, `function fc_host_post_event`, `function fc_host_post_vendor_event`, `function fc_find_rport_by_wwpn`.
- Atlas domain: Driver Families / drivers/scsi.
- Implementation status: integration 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.