drivers/scsi/lpfc/lpfc_scsi.c
Source file repositories/reference/linux-study-clean/drivers/scsi/lpfc/lpfc_scsi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/lpfc/lpfc_scsi.c- Extension
.c- Size
- 202478 bytes
- Lines
- 6833
- 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/export.hlinux/delay.hlinux/unaligned.hlinux/t10-pi.hlinux/crc-t10dif.hlinux/blk-cgroup.hnet/checksum.hscsi/scsi.hscsi/scsi_device.hscsi/scsi_eh.hscsi/scsi_host.hscsi/scsi_tcq.hscsi/scsi_transport_fc.hlpfc_version.hlpfc_hw4.hlpfc_hw.hlpfc_sli.hlpfc_sli4.hlpfc_nl.hlpfc_disc.hlpfc.hlpfc_scsi.hlpfc_logmsg.hlpfc_crtn.hlpfc_vport.h
Detected Declarations
struct scsi_dif_tuplefunction lpfc_rport_data_from_scsi_devicefunction lpfc_sli4_set_rsp_sgl_lastfunction lpfc_rampdown_queue_depthfunction lpfc_ramp_down_queue_handlerfunction shost_for_each_devicefunction fc_remote_port_deletefunction shost_for_each_devicefunction lpfc_new_scsi_buf_s3function lpfc_sli4_vport_delete_fcp_xri_abortedfunction list_for_each_entry_safefunction lpfc_sli4_io_xri_abortedfunction lpfc_get_scsi_buf_s3function lpfc_get_scsi_buf_s4function lpfc_get_scsi_buffunction lpfc_release_scsi_buf_s3function lpfc_release_scsi_buf_s4function lpfc_release_scsi_buffunction lpfc_fcpcmd_to_iocbfunction lpfc_scsi_prep_dma_buf_s3function scsi_for_each_sgfunction lpfc_bg_err_injectfunction lpfc_sc_to_bg_opcodesfunction lpfc_bg_err_opcodesfunction streamfunction lpfc_bg_setup_bpl_protfunction streamfunction lpfc_bg_setup_sgl_protfunction lpfc_prot_group_typefunction lpfc_bg_scsi_adjust_dlfunction lpfc_scsi_prep_dma_buffunction lpfc_bg_crcfunction lpfc_bg_csumfunction lpfc_calc_bg_errfunction lpfc_parse_bg_errfunction lpfc_scsi_prep_dma_buf_s4function lpfc_scsi_prep_dma_buffunction lpfc_scsi_prep_dma_buffunction lpfc_bg_scsi_prep_dma_buffunction lpfc_scsi_prep_cmnd_buffunction lpfc_send_scsi_error_eventfunction lpfc_scsi_unprep_dma_buffunction lpfc_unblock_requestsfunction lpfc_block_requestsfunction lpfc_update_cmf_cmplfunction lpfc_update_cmf_cmdfunction for_each_present_cpufunction lpfc_handle_fcp_err
Annotated Snippet
struct scsi_dif_tuple {
__be16 guard_tag; /* Checksum */
__be16 app_tag; /* Opaque storage */
__be32 ref_tag; /* Target LBA or indirect LBA */
};
static struct lpfc_rport_data *
lpfc_rport_data_from_scsi_device(struct scsi_device *sdev)
{
struct lpfc_vport *vport = (struct lpfc_vport *)sdev->host->hostdata;
if (vport->phba->cfg_fof)
return ((struct lpfc_device_data *)sdev->hostdata)->rport_data;
else
return (struct lpfc_rport_data *)sdev->hostdata;
}
static void
lpfc_release_scsi_buf_s4(struct lpfc_hba *phba, struct lpfc_io_buf *psb);
static void
lpfc_release_scsi_buf_s3(struct lpfc_hba *phba, struct lpfc_io_buf *psb);
static int
lpfc_prot_group_type(struct lpfc_hba *phba, struct scsi_cmnd *sc);
/**
* lpfc_sli4_set_rsp_sgl_last - Set the last bit in the response sge.
* @phba: Pointer to HBA object.
* @lpfc_cmd: lpfc scsi command object pointer.
*
* This function is called from the lpfc_prep_task_mgmt_cmd function to
* set the last bit in the response sge entry.
**/
static void
lpfc_sli4_set_rsp_sgl_last(struct lpfc_hba *phba,
struct lpfc_io_buf *lpfc_cmd)
{
struct sli4_sge *sgl = (struct sli4_sge *)lpfc_cmd->dma_sgl;
if (sgl) {
sgl += 1;
sgl->word2 = le32_to_cpu(sgl->word2);
bf_set(lpfc_sli4_sge_last, sgl, 1);
sgl->word2 = cpu_to_le32(sgl->word2);
}
}
/**
* lpfc_rampdown_queue_depth - Post RAMP_DOWN_QUEUE event to worker thread
* @phba: The Hba for which this call is being executed.
*
* This routine is called when there is resource error in driver or firmware.
* This routine posts WORKER_RAMP_DOWN_QUEUE event for @phba. This routine
* posts at most 1 event each second. This routine wakes up worker thread of
* @phba to process WORKER_RAM_DOWN_EVENT event.
*
* This routine should be called with no lock held.
**/
void
lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
{
unsigned long flags;
uint32_t evt_posted;
unsigned long expires;
spin_lock_irqsave(&phba->hbalock, flags);
atomic_inc(&phba->num_rsrc_err);
phba->last_rsrc_error_time = jiffies;
expires = phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL;
if (time_after(expires, jiffies)) {
spin_unlock_irqrestore(&phba->hbalock, flags);
return;
}
phba->last_ramp_down_time = jiffies;
spin_unlock_irqrestore(&phba->hbalock, flags);
spin_lock_irqsave(&phba->pport->work_port_lock, flags);
evt_posted = phba->pport->work_port_events & WORKER_RAMP_DOWN_QUEUE;
if (!evt_posted)
phba->pport->work_port_events |= WORKER_RAMP_DOWN_QUEUE;
spin_unlock_irqrestore(&phba->pport->work_port_lock, flags);
if (!evt_posted)
lpfc_worker_wake_up(phba);
return;
}
/**
* lpfc_ramp_down_queue_handler - WORKER_RAMP_DOWN_QUEUE event handler
Annotation
- Immediate include surface: `linux/pci.h`, `linux/slab.h`, `linux/interrupt.h`, `linux/export.h`, `linux/delay.h`, `linux/unaligned.h`, `linux/t10-pi.h`, `linux/crc-t10dif.h`.
- Detected declarations: `struct scsi_dif_tuple`, `function lpfc_rport_data_from_scsi_device`, `function lpfc_sli4_set_rsp_sgl_last`, `function lpfc_rampdown_queue_depth`, `function lpfc_ramp_down_queue_handler`, `function shost_for_each_device`, `function fc_remote_port_delete`, `function shost_for_each_device`, `function lpfc_new_scsi_buf_s3`, `function lpfc_sli4_vport_delete_fcp_xri_aborted`.
- 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.