drivers/scsi/lpfc/lpfc_nvmet.c
Source file repositories/reference/linux-study-clean/drivers/scsi/lpfc/lpfc_nvmet.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/lpfc/lpfc_nvmet.c- Extension
.c- Size
- 110064 bytes
- Lines
- 3628
- 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_scsi.hlpfc_nvme.hlpfc_logmsg.hlpfc_crtn.hlpfc_vport.hlpfc_debugfs.h
Detected Declarations
function lpfc_nvmet_cmd_templatefunction lpfc_nvmet_get_ctx_for_xrifunction lpfc_nvmet_get_ctx_for_oxidfunction lpfc_nvmet_defer_releasefunction __lpfc_nvme_xmt_ls_rsp_cmpfunction lpfc_nvmet_xmt_ls_rsp_cmpfunction lpfc_nvmet_ctxbuf_postfunction lpfc_nvmet_ktimefunction lpfc_nvmet_xmt_fcp_op_cmpfunction __lpfc_nvme_xmt_ls_rspfunction lpfc_nvmet_xmt_ls_rspfunction lpfc_nvmet_xmt_fcp_opfunction lpfc_nvmet_targetport_deletefunction lpfc_nvmet_xmt_fcp_abortfunction lpfc_nvmet_xmt_fcp_releasefunction lpfc_nvmet_defer_rcvfunction lpfc_nvmet_ls_req_cmpfunction lpfc_nvmet_ls_reqfunction progressfunction lpfc_nvmet_host_traddrfunction lpfc_nvmet_host_releasefunction lpfc_nvmet_discovery_eventfunction __lpfc_nvmet_clean_io_for_cpufunction lpfc_nvmet_cleanup_io_contextfunction for_each_present_cpufunction lpfc_nvmet_setup_io_contextfunction indexfunction for_each_present_cpufunction lpfc_nvmet_create_targetportfunction lpfc_nvmet_update_targetportfunction lpfc_sli4_nvmet_xri_abortedfunction lpfc_nvmet_rcv_unsol_abortfunction list_for_each_entryfunction lpfc_nvmet_wqfull_flushfunction lpfc_nvmet_wqfull_processfunction lpfc_nvmet_destroy_targetportfunction lpfc_nvmet_handle_lsreqfunction lpfc_nvmet_process_rcv_fcp_reqfunction lpfc_nvmet_fcp_rqst_defer_workfunction lpfc_nvmet_replenish_contextfunction lpfc_nvmet_unsol_fcp_bufferfunction lpfc_nvmet_unsol_fcp_bufferfunction Servicefunction lpfc_nvmet_prep_fcp_wqefunction for_each_sgfunction lpfc_nvmet_sol_fcp_abort_cmpfunction lpfc_nvmet_unsol_fcp_abort_cmpfunction lpfc_nvmet_xmt_ls_abort_cmp
Annotated Snippet
if (status) {
atomic_inc(&tgtp->xmt_ls_rsp_error);
if (result == IOERR_ABORT_REQUESTED)
atomic_inc(&tgtp->xmt_ls_rsp_aborted);
if (bf_get(lpfc_wcqe_c_xb, wcqe))
atomic_inc(&tgtp->xmt_ls_rsp_xb_set);
} else {
atomic_inc(&tgtp->xmt_ls_rsp_cmpl);
}
}
finish:
__lpfc_nvme_xmt_ls_rsp_cmp(phba, cmdwqe, rspwqe);
}
/**
* lpfc_nvmet_ctxbuf_post - Repost a NVMET RQ DMA buffer and clean up context
* @phba: HBA buffer is associated with
* @ctx_buf: ctx buffer context
*
* Description: Frees the given DMA buffer in the appropriate way given by
* reposting it to its associated RQ so it can be reused.
*
* Notes: Takes phba->hbalock. Can be called with or without other locks held.
*
* Returns: None
**/
void
lpfc_nvmet_ctxbuf_post(struct lpfc_hba *phba, struct lpfc_nvmet_ctxbuf *ctx_buf)
{
#if (IS_ENABLED(CONFIG_NVME_TARGET_FC))
struct lpfc_async_xchg_ctx *ctxp = ctx_buf->context;
struct lpfc_nvmet_tgtport *tgtp;
struct fc_frame_header *fc_hdr;
struct rqb_dmabuf *nvmebuf;
struct lpfc_nvmet_ctx_info *infop;
uint32_t size, oxid, sid;
int cpu;
unsigned long iflag;
if (ctxp->state == LPFC_NVME_STE_FREE) {
lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
"6411 NVMET free, already free IO x%x: %d %d\n",
ctxp->oxid, ctxp->state, ctxp->entry_cnt);
}
if (ctxp->rqb_buffer) {
spin_lock_irqsave(&ctxp->ctxlock, iflag);
nvmebuf = ctxp->rqb_buffer;
/* check if freed in another path whilst acquiring lock */
if (nvmebuf) {
ctxp->rqb_buffer = NULL;
if (ctxp->flag & LPFC_NVME_CTX_REUSE_WQ) {
ctxp->flag &= ~LPFC_NVME_CTX_REUSE_WQ;
spin_unlock_irqrestore(&ctxp->ctxlock, iflag);
nvmebuf->hrq->rqbp->rqb_free_buffer(phba,
nvmebuf);
} else {
spin_unlock_irqrestore(&ctxp->ctxlock, iflag);
/* repost */
lpfc_rq_buf_free(phba, &nvmebuf->hbuf);
}
} else {
spin_unlock_irqrestore(&ctxp->ctxlock, iflag);
}
}
ctxp->state = LPFC_NVME_STE_FREE;
spin_lock_irqsave(&phba->sli4_hba.nvmet_io_wait_lock, iflag);
if (phba->sli4_hba.nvmet_io_wait_cnt) {
list_remove_head(&phba->sli4_hba.lpfc_nvmet_io_wait_list,
nvmebuf, struct rqb_dmabuf,
hbuf.list);
phba->sli4_hba.nvmet_io_wait_cnt--;
spin_unlock_irqrestore(&phba->sli4_hba.nvmet_io_wait_lock,
iflag);
fc_hdr = (struct fc_frame_header *)(nvmebuf->hbuf.virt);
oxid = be16_to_cpu(fc_hdr->fh_ox_id);
tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private;
size = nvmebuf->bytes_recv;
sid = sli4_sid_from_fc_hdr(fc_hdr);
ctxp = (struct lpfc_async_xchg_ctx *)ctx_buf->context;
ctxp->wqeq = NULL;
ctxp->offset = 0;
ctxp->phba = phba;
ctxp->size = size;
ctxp->oxid = oxid;
ctxp->sid = sid;
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 lpfc_nvmet_cmd_template`, `function lpfc_nvmet_get_ctx_for_xri`, `function lpfc_nvmet_get_ctx_for_oxid`, `function lpfc_nvmet_defer_release`, `function __lpfc_nvme_xmt_ls_rsp_cmp`, `function lpfc_nvmet_xmt_ls_rsp_cmp`, `function lpfc_nvmet_ctxbuf_post`, `function lpfc_nvmet_ktime`, `function lpfc_nvmet_xmt_fcp_op_cmp`, `function __lpfc_nvme_xmt_ls_rsp`.
- 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.