drivers/scsi/elx/libefc/efc_nport.c
Source file repositories/reference/linux-study-clean/drivers/scsi/elx/libefc/efc_nport.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/elx/libefc/efc_nport.c- Extension
.c- Size
- 18743 bytes
- Lines
- 778
- 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.
- 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
efc.h
Detected Declarations
function Copyrightfunction efc_nport_find_wwnfunction _efc_nport_freefunction efc_nport_allocfunction efc_nport_freefunction efc_nport_findfunction efc_nport_attachfunction xa_for_eachfunction efc_nport_shutdownfunction xa_for_eachfunction efc_vport_link_downfunction __efc_nport_commonfunction __efc_nport_allocatedfunction __efc_nport_vport_initfunction __efc_nport_vport_wait_allocfunction __efc_nport_vport_allocatedfunction efc_vport_update_specfunction __efc_nport_attachedfunction __efc_nport_wait_shutdownfunction __efc_nport_wait_port_freefunction efc_vport_nport_allocfunction efc_vport_startfunction efc_nport_vport_newfunction efc_nport_vport_delfunction efc_vport_del_allfunction efc_vport_create_spec
Annotated Snippet
if (nport) {
efc_log_err(domain->efc,
"NPORT %016llX %016llX already allocated\n",
wwnn, wwpn);
return NULL;
}
}
nport = kzalloc_obj(*nport, GFP_ATOMIC);
if (!nport)
return nport;
/* initialize refcount */
kref_init(&nport->ref);
nport->release = _efc_nport_free;
nport->efc = domain->efc;
snprintf(nport->display_name, sizeof(nport->display_name), "------");
nport->domain = domain;
xa_init(&nport->lookup);
nport->instance_index = domain->nport_count++;
nport->sm.app = nport;
nport->enable_ini = enable_ini;
nport->enable_tgt = enable_tgt;
nport->enable_rscn = (nport->enable_ini ||
(nport->enable_tgt && enable_target_rscn(nport->efc)));
/* Copy service parameters from domain */
memcpy(nport->service_params, domain->service_params,
sizeof(struct fc_els_flogi));
/* Update requested fc_id */
nport->fc_id = fc_id;
/* Update the nport's service parameters for the new wwn's */
nport->wwpn = wwpn;
nport->wwnn = wwnn;
snprintf(nport->wwnn_str, sizeof(nport->wwnn_str), "%016llX",
(unsigned long long)wwnn);
/*
* if this is the "first" nport of the domain,
* then make it the "phys" nport
*/
if (list_empty(&domain->nport_list))
domain->nport = nport;
INIT_LIST_HEAD(&nport->list_entry);
list_add_tail(&nport->list_entry, &domain->nport_list);
kref_get(&domain->ref);
efc_log_debug(domain->efc, "New Nport [%s]\n", nport->display_name);
return nport;
}
void
efc_nport_free(struct efc_nport *nport)
{
struct efc_domain *domain;
if (!nport)
return;
domain = nport->domain;
efc_log_debug(domain->efc, "[%s] free nport\n", nport->display_name);
list_del(&nport->list_entry);
/*
* if this is the physical nport,
* then clear it out of the domain
*/
if (nport == domain->nport)
domain->nport = NULL;
xa_destroy(&nport->lookup);
xa_erase(&domain->lookup, nport->fc_id);
if (list_empty(&domain->nport_list))
efc_domain_post_event(domain, EFC_EVT_ALL_CHILD_NODES_FREE,
NULL);
kref_put(&domain->ref, domain->release);
kref_put(&nport->ref, nport->release);
}
struct efc_nport *
efc_nport_find(struct efc_domain *domain, u32 d_id)
{
struct efc_nport *nport;
Annotation
- Immediate include surface: `efc.h`.
- Detected declarations: `function Copyright`, `function efc_nport_find_wwn`, `function _efc_nport_free`, `function efc_nport_alloc`, `function efc_nport_free`, `function efc_nport_find`, `function efc_nport_attach`, `function xa_for_each`, `function efc_nport_shutdown`, `function xa_for_each`.
- 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.
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.