drivers/scsi/libfc/fc_lport.c
Source file repositories/reference/linux-study-clean/drivers/scsi/libfc/fc_lport.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/libfc/fc_lport.c- Extension
.c- Size
- 59451 bytes
- Lines
- 2201
- 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/timer.hlinux/delay.hlinux/module.hlinux/slab.hlinux/unaligned.hscsi/fc/fc_gs.hscsi/libfc.hlinux/scatterlist.hfc_encode.hfc_libfc.h
Detected Declarations
struct fc_bsg_infofunction fc_frame_dropfunction fc_lport_rport_callbackfunction fc_lport_statefunction fc_lport_ptp_setupfunction fc_get_host_port_statefunction fc_get_host_speedfunction fc_get_host_statsfunction for_each_possible_cpufunction fc_lport_flogi_fillfunction fc_lport_add_fc4_typefunction fc_lport_recv_rlir_reqfunction fc_lport_recv_echo_reqfunction fc_lport_recv_rnid_reqfunction fc_lport_recv_logo_reqfunction fc_fabric_loginfunction __fc_linkupfunction fc_linkupfunction __fc_linkdownfunction fc_linkdownfunction fc_fabric_logofffunction fc_lport_destroyfunction fc_set_mfsfunction fc_lport_disc_callbackfunction fc_lport_enter_readyfunction fc_lport_set_port_idfunction fc_lport_set_local_idfunction fc_lport_recv_flogi_reqfunction fc_lport_recv_els_reqfunction fc_lport_els_prlifunction fc_lport_recvfunction fc_lport_resetfunction fc_lport_reset_lockedfunction fc_lport_enter_resetfunction fc_lport_enter_disabledfunction fc_lport_errorfunction fc_lport_ns_respfunction fc_lport_ms_respfunction fc_lport_scr_respfunction fc_lport_enter_scrfunction fc_lport_enter_nsfunction fc_lport_enter_dnsfunction fc_lport_enter_msfunction fc_lport_enter_fdmifunction fc_lport_timeoutfunction fc_lport_logo_respfunction fc_lport_enter_logofunction fc_lport_flogi_resp
Annotated Snippet
struct fc_bsg_info {
struct bsg_job *job;
struct fc_lport *lport;
u16 rsp_code;
struct scatterlist *sg;
u32 nents;
size_t offset;
};
/**
* fc_frame_drop() - Dummy frame handler
* @lport: The local port the frame was received on
* @fp: The received frame
*/
static int fc_frame_drop(struct fc_lport *lport, struct fc_frame *fp)
{
fc_frame_free(fp);
return 0;
}
/**
* fc_lport_rport_callback() - Event handler for rport events
* @lport: The lport which is receiving the event
* @rdata: private remote port data
* @event: The event that occurred
*
* Locking Note: The rport lock should not be held when calling
* this function.
*/
static void fc_lport_rport_callback(struct fc_lport *lport,
struct fc_rport_priv *rdata,
enum fc_rport_event event)
{
FC_LPORT_DBG(lport, "Received a %d event for port (%6.6x)\n", event,
rdata->ids.port_id);
mutex_lock(&lport->lp_mutex);
switch (event) {
case RPORT_EV_READY:
if (lport->state == LPORT_ST_DNS) {
lport->dns_rdata = rdata;
fc_lport_enter_ns(lport, LPORT_ST_RNN_ID);
} else if (lport->state == LPORT_ST_FDMI) {
lport->ms_rdata = rdata;
fc_lport_enter_ms(lport, LPORT_ST_DHBA);
} else {
FC_LPORT_DBG(lport, "Received an READY event "
"on port (%6.6x) for the directory "
"server, but the lport is not "
"in the DNS or FDMI state, it's in the "
"%d state", rdata->ids.port_id,
lport->state);
fc_rport_logoff(rdata);
}
break;
case RPORT_EV_LOGO:
case RPORT_EV_FAILED:
case RPORT_EV_STOP:
if (rdata->ids.port_id == FC_FID_DIR_SERV)
lport->dns_rdata = NULL;
else if (rdata->ids.port_id == FC_FID_MGMT_SERV)
lport->ms_rdata = NULL;
break;
case RPORT_EV_NONE:
break;
}
mutex_unlock(&lport->lp_mutex);
}
/**
* fc_lport_state() - Return a string which represents the lport's state
* @lport: The lport whose state is to converted to a string
*/
static const char *fc_lport_state(struct fc_lport *lport)
{
const char *cp;
cp = fc_lport_state_names[lport->state];
if (!cp)
cp = "unknown";
return cp;
}
/**
* fc_lport_ptp_setup() - Create an rport for point-to-point mode
* @lport: The lport to attach the ptp rport to
* @remote_fid: The FID of the ptp rport
* @remote_wwpn: The WWPN of the ptp rport
* @remote_wwnn: The WWNN of the ptp rport
*/
Annotation
- Immediate include surface: `linux/timer.h`, `linux/delay.h`, `linux/module.h`, `linux/slab.h`, `linux/unaligned.h`, `scsi/fc/fc_gs.h`, `scsi/libfc.h`, `linux/scatterlist.h`.
- Detected declarations: `struct fc_bsg_info`, `function fc_frame_drop`, `function fc_lport_rport_callback`, `function fc_lport_state`, `function fc_lport_ptp_setup`, `function fc_get_host_port_state`, `function fc_get_host_speed`, `function fc_get_host_stats`, `function for_each_possible_cpu`, `function fc_lport_flogi_fill`.
- 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.