drivers/scsi/lpfc/lpfc_nvme.c
Source file repositories/reference/linux-study-clean/drivers/scsi/lpfc/lpfc_nvme.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/lpfc/lpfc_nvme.c- Extension
.c- Size
- 86395 bytes
- Lines
- 2918
- 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.
- 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/pci.hlinux/slab.hlinux/interrupt.hlinux/delay.hlinux/unaligned.hlinux/crc-t10dif.hnet/checksum.hscsi/scsi.hscsi/scsi_device.hscsi/scsi_eh.hscsi/scsi_host.hscsi/scsi_tcq.hscsi/scsi_transport_fc.hscsi/fc/fc_fs.hlpfc_version.hlpfc_hw4.hlpfc_hw.hlpfc_sli.hlpfc_sli4.hlpfc_nl.hlpfc_disc.hlpfc.hlpfc_nvme.hlpfc_scsi.hlpfc_logmsg.hlpfc_crtn.hlpfc_vport.hlpfc_debugfs.h
Detected Declarations
function mapsfunction lpfc_nvme_delete_queuefunction lpfc_nvme_localport_deletefunction lpfc_nvme_remoteport_deletefunction lpfc_nvme_handle_lsreqfunction donefunction lpfc_nvme_ls_req_cmpfunction lpfc_nvme_gen_reqfunction __lpfc_nvme_ls_reqfunction lpfc_nvme_ls_reqfunction __lpfc_nvme_ls_abortfunction lpfc_nvme_xmt_ls_rspfunction progressfunction lpfc_nvme_adj_fcp_sglsfunction lpfc_nvme_io_cmd_cmplfunction lpfc_nvme_prep_io_cmdfunction lpfc_nvme_prep_io_dmafunction lpfc_nvme_fcp_io_submitfunction lpfc_nvme_abort_fcreq_cmplfunction lpfc_nvme_fcp_abortfunction lpfc_get_nvme_buffunction lpfc_release_nvme_buffunction lpfc_nvme_create_localportfunction lpfc_nvme_lport_unreg_waitfunction lpfc_nvme_destroy_localportfunction lpfc_nvme_update_localportfunction lpfc_nvme_register_portfunction lpfc_nvme_rescan_portfunction lpfc_nvme_unregister_portfunction lpfc_sli4_nvme_pci_offline_abortedfunction lpfc_sli4_nvme_xri_abortedfunction lpfc_nvme_wait_for_io_drainfunction lpfc_nvme_cancel_iocbfunction lpfc_nvme_flush_abts_listfunction list_for_each_entry_safefunction list_for_each_entry_safefunction lpfc_nvmels_flush_cmd
Annotated Snippet
if (lport) {
atomic_inc(&lport->fc4NvmeLsCmpls);
if (status) {
if (bf_get(lpfc_wcqe_c_xb, wcqe))
atomic_inc(&lport->cmpl_ls_xb);
atomic_inc(&lport->cmpl_ls_err);
}
}
}
__lpfc_nvme_ls_req_cmp(phba, vport, cmdwqe, wcqe);
}
static int
lpfc_nvme_gen_req(struct lpfc_vport *vport, struct lpfc_dmabuf *bmp,
struct lpfc_dmabuf *inp,
struct nvmefc_ls_req *pnvme_lsreq,
void (*cmpl)(struct lpfc_hba *, struct lpfc_iocbq *,
struct lpfc_iocbq *),
struct lpfc_nodelist *ndlp, uint32_t num_entry,
uint32_t tmo, uint8_t retry)
{
struct lpfc_hba *phba = vport->phba;
union lpfc_wqe128 *wqe;
struct lpfc_iocbq *genwqe;
struct ulp_bde64 *bpl;
struct ulp_bde64 bde;
int i, rc, xmit_len, first_len;
/* Allocate buffer for command WQE */
genwqe = lpfc_sli_get_iocbq(phba);
if (genwqe == NULL)
return 1;
wqe = &genwqe->wqe;
/* Initialize only 64 bytes */
memset(wqe, 0, sizeof(union lpfc_wqe));
genwqe->bpl_dmabuf = bmp;
genwqe->cmd_flag |= LPFC_IO_NVME_LS;
/* Save for completion so we can release these resources */
genwqe->ndlp = lpfc_nlp_get(ndlp);
if (!genwqe->ndlp) {
dev_warn(&phba->pcidev->dev,
"Warning: Failed node ref, not sending LS_REQ\n");
lpfc_sli_release_iocbq(phba, genwqe);
return 1;
}
genwqe->context_un.nvme_lsreq = pnvme_lsreq;
/* Fill in payload, bp points to frame payload */
if (!tmo)
/* FC spec states we need 3 * ratov for CT requests */
tmo = (3 * phba->fc_ratov);
/* For this command calculate the xmit length of the request bde. */
xmit_len = 0;
first_len = 0;
bpl = (struct ulp_bde64 *)bmp->virt;
for (i = 0; i < num_entry; i++) {
bde.tus.w = bpl[i].tus.w;
if (bde.tus.f.bdeFlags != BUFF_TYPE_BDE_64)
break;
xmit_len += bde.tus.f.bdeSize;
if (i == 0)
first_len = xmit_len;
}
genwqe->num_bdes = num_entry;
genwqe->hba_wqidx = 0;
/* Words 0 - 2 */
wqe->generic.bde.tus.f.bdeFlags = BUFF_TYPE_BDE_64;
wqe->generic.bde.tus.f.bdeSize = first_len;
wqe->generic.bde.addrLow = bpl[0].addrLow;
wqe->generic.bde.addrHigh = bpl[0].addrHigh;
/* Word 3 */
wqe->gen_req.request_payload_len = first_len;
/* Word 4 */
/* Word 5 */
bf_set(wqe_dfctl, &wqe->gen_req.wge_ctl, 0);
bf_set(wqe_si, &wqe->gen_req.wge_ctl, 1);
bf_set(wqe_la, &wqe->gen_req.wge_ctl, 1);
bf_set(wqe_rctl, &wqe->gen_req.wge_ctl, FC_RCTL_ELS4_REQ);
bf_set(wqe_type, &wqe->gen_req.wge_ctl, FC_TYPE_NVME);
Annotation
- Immediate include surface: `linux/pci.h`, `linux/slab.h`, `linux/interrupt.h`, `linux/delay.h`, `linux/unaligned.h`, `linux/crc-t10dif.h`, `net/checksum.h`, `scsi/scsi.h`.
- Detected declarations: `function maps`, `function lpfc_nvme_delete_queue`, `function lpfc_nvme_localport_delete`, `function lpfc_nvme_remoteport_delete`, `function lpfc_nvme_handle_lsreq`, `function done`, `function lpfc_nvme_ls_req_cmp`, `function lpfc_nvme_gen_req`, `function __lpfc_nvme_ls_req`, `function lpfc_nvme_ls_req`.
- 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.