drivers/scsi/libfc/fc_rport.c
Source file repositories/reference/linux-study-clean/drivers/scsi/libfc/fc_rport.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/libfc/fc_rport.c- Extension
.c- Size
- 61563 bytes
- Lines
- 2294
- 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/kernel.hlinux/spinlock.hlinux/interrupt.hlinux/slab.hlinux/rcupdate.hlinux/timer.hlinux/workqueue.hlinux/export.hlinux/rculist.hlinux/unaligned.hscsi/libfc.hfc_encode.hfc_libfc.h
Detected Declarations
function fc_rport_lookupfunction fc_rport_createfunction fc_rport_destroyfunction fc_rport_statefunction fc_set_rport_loss_tmofunction fc_plogi_get_maxframefunction fc_rport_state_enterfunction fc_rport_workfunction fc_rport_loginfunction fc_rport_enter_deletefunction fc_rport_logofffunction fc_rport_enter_readyfunction fc_rport_timeoutfunction fc_rport_errorfunction fc_rport_error_retryfunction fc_rport_login_completefunction fc_rport_flogi_respfunction fc_rport_enter_flogifunction fc_rport_recv_flogi_reqfunction fc_rport_plogi_respfunction fc_rport_compatible_rolesfunction fc_rport_enter_plogifunction fc_rport_prli_respfunction fc_rport_enter_prlifunction fc_rport_rtv_respfunction fc_rport_enter_rtvfunction fc_rport_recv_rtv_reqfunction fc_rport_logo_respfunction fc_rport_enter_logofunction fc_rport_adisc_respfunction ntoh24function fc_rport_enter_adiscfunction fc_rport_recv_adisc_reqfunction fc_rport_recv_rls_reqfunction fc_rport_recv_els_reqfunction fc_rport_recv_reqfunction fc_rport_recv_plogi_reqfunction fc_rport_recv_prli_reqfunction fc_rport_recv_prlo_reqfunction fc_rport_recv_logo_reqfunction fc_rport_flush_queuefunction fc_rport_fcp_prlifunction fc_rport_t0_prlifunction fc_setup_rportfunction fc_destroy_rportfunction fc_rport_terminate_ioexport fc_rport_lookupexport fc_rport_create
Annotated Snippet
kref_get_unless_zero(&tmp_rdata->kref)) {
rdata = tmp_rdata;
break;
}
rcu_read_unlock();
return rdata;
}
EXPORT_SYMBOL(fc_rport_lookup);
/**
* fc_rport_create() - Create a new remote port
* @lport: The local port this remote port will be associated with
* @port_id: The identifiers for the new remote port
*
* The remote port will start in the INIT state.
*/
struct fc_rport_priv *fc_rport_create(struct fc_lport *lport, u32 port_id)
{
struct fc_rport_priv *rdata;
size_t rport_priv_size = sizeof(*rdata);
lockdep_assert_held(&lport->disc.disc_mutex);
rdata = fc_rport_lookup(lport, port_id);
if (rdata) {
kref_put(&rdata->kref, fc_rport_destroy);
return rdata;
}
if (lport->rport_priv_size > 0)
rport_priv_size = lport->rport_priv_size;
rdata = kzalloc(rport_priv_size, GFP_KERNEL);
if (!rdata)
return NULL;
rdata->ids.node_name = -1;
rdata->ids.port_name = -1;
rdata->ids.port_id = port_id;
rdata->ids.roles = FC_RPORT_ROLE_UNKNOWN;
kref_init(&rdata->kref);
mutex_init(&rdata->rp_mutex);
rdata->local_port = lport;
rdata->rp_state = RPORT_ST_INIT;
rdata->event = RPORT_EV_NONE;
rdata->flags = FC_RP_FLAGS_REC_SUPPORTED;
rdata->e_d_tov = lport->e_d_tov;
rdata->r_a_tov = lport->r_a_tov;
rdata->maxframe_size = FC_MIN_MAX_PAYLOAD;
INIT_DELAYED_WORK(&rdata->retry_work, fc_rport_timeout);
INIT_WORK(&rdata->event_work, fc_rport_work);
if (port_id != FC_FID_DIR_SERV) {
rdata->lld_event_callback = lport->tt.rport_event_callback;
list_add_rcu(&rdata->peers, &lport->disc.rports);
}
return rdata;
}
EXPORT_SYMBOL(fc_rport_create);
/**
* fc_rport_destroy() - Free a remote port after last reference is released
* @kref: The remote port's kref
*/
void fc_rport_destroy(struct kref *kref)
{
struct fc_rport_priv *rdata;
rdata = container_of(kref, struct fc_rport_priv, kref);
kfree_rcu(rdata, rcu);
}
EXPORT_SYMBOL(fc_rport_destroy);
/**
* fc_rport_state() - Return a string identifying the remote port's state
* @rdata: The remote port
*/
static const char *fc_rport_state(struct fc_rport_priv *rdata)
{
const char *cp;
cp = fc_rport_state_names[rdata->rp_state];
if (!cp)
cp = "Unknown";
return cp;
}
/**
* fc_set_rport_loss_tmo() - Set the remote port loss timeout
* @rport: The remote port that gets a new timeout value
* @timeout: The new timeout value (in seconds)
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/spinlock.h`, `linux/interrupt.h`, `linux/slab.h`, `linux/rcupdate.h`, `linux/timer.h`, `linux/workqueue.h`, `linux/export.h`.
- Detected declarations: `function fc_rport_lookup`, `function fc_rport_create`, `function fc_rport_destroy`, `function fc_rport_state`, `function fc_set_rport_loss_tmo`, `function fc_plogi_get_maxframe`, `function fc_rport_state_enter`, `function fc_rport_work`, `function fc_rport_login`, `function fc_rport_enter_delete`.
- 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.