drivers/scsi/lpfc/lpfc_sli.c
Source file repositories/reference/linux-study-clean/drivers/scsi/lpfc/lpfc_sli.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/lpfc/lpfc_sli.c- Extension
.c- Size
- 701133 bytes
- Lines
- 22829
- 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/blkdev.hlinux/pci.hlinux/interrupt.hlinux/delay.hlinux/slab.hlinux/lockdep.hlinux/dmi.hlinux/of.hscsi/scsi.hscsi/scsi_cmnd.hscsi/scsi_device.hscsi/scsi_host.hscsi/scsi_transport_fc.hscsi/fc/fc_fs.hlinux/crash_dump.hasm/set_memory.hlpfc_hw4.hlpfc_hw.hlpfc_sli.hlpfc_sli4.hlpfc_nl.hlpfc_disc.hlpfc.hlpfc_scsi.hlpfc_nvme.hlpfc_crtn.hlpfc_logmsg.hlpfc_compat.hlpfc_debugfs.hlpfc_vport.hlpfc_version.h
Detected Declarations
function lpfc_wqe_cmd_templatefunction lpfc_sli4_wq_putfunction lpfc_sli4_wq_releasefunction lpfc_sli4_mq_putfunction lpfc_sli4_mq_releasefunction Queuefunction lpfc_sli4_eq_clr_intrfunction lpfc_sli4_if6_eq_clr_intrfunction lpfc_sli4_write_eq_dbfunction lpfc_sli4_if6_write_eq_dbfunction __lpfc_sli4_consume_eqefunction lpfc_sli4_eqcq_flushfunction list_for_each_entryfunction lpfc_sli4_process_eqfunction Queuefunction __lpfc_sli4_consume_cqefunction lpfc_sli4_write_cq_dbfunction lpfc_sli4_if6_write_cq_dbfunction lpfc_sli4_rq_putfunction lpfc_sli4_rq_releasefunction lpfc_cmd_iocbfunction lpfc_resp_iocbfunction __lpfc_sli_get_iocbqfunction __lpfc_clear_active_sglqfunction __lpfc_get_active_sglqfunction lpfc_clr_rrq_activefunction stop_timefunction lpfc_get_active_rrqfunction lpfc_cleanup_vports_rrqsfunction list_for_each_entry_safefunction lpfc_test_rrq_activefunction lpfc_set_rrq_activefunction __lpfc_sli_get_els_sglqfunction __lpfc_sli_get_nvmet_sglqfunction lpfc_sli_get_iocbqfunction listfunction __lpfc_sli_release_iocbq_s3function __lpfc_sli_release_iocbqfunction lpfc_sli_release_iocbqfunction lpfc_sli_cancel_iocbsfunction lpfc_sli_iocb_cmd_typefunction lpfc_sli_ring_mapfunction lpfc_sli_ringtxcmpl_putfunction lpfc_sli_ringtx_getfunction lpfc_cmf_sync_cmplfunction congestionfunction lpfc_sli_next_iocb_slotfunction lpfc_sli_next_iotag
Annotated Snippet
if (q->dpp_enable && q->phba->cfg_enable_dpp) {
bf_set(lpfc_if6_wq_db_list_fm_num_posted, &doorbell, 1);
bf_set(lpfc_if6_wq_db_list_fm_dpp, &doorbell, 1);
bf_set(lpfc_if6_wq_db_list_fm_dpp_id, &doorbell,
q->dpp_id);
bf_set(lpfc_if6_wq_db_list_fm_id, &doorbell,
q->queue_id);
} else {
bf_set(lpfc_wq_db_list_fm_num_posted, &doorbell, 1);
bf_set(lpfc_wq_db_list_fm_id, &doorbell, q->queue_id);
/* Leave bits <23:16> clear for if_type 6 dpp */
if_type = bf_get(lpfc_sli_intf_if_type,
&q->phba->sli4_hba.sli_intf);
if (if_type != LPFC_SLI_INTF_IF_TYPE_6)
bf_set(lpfc_wq_db_list_fm_index, &doorbell,
host_index);
}
} else if (q->db_format == LPFC_DB_RING_FORMAT) {
bf_set(lpfc_wq_db_ring_fm_num_posted, &doorbell, 1);
bf_set(lpfc_wq_db_ring_fm_id, &doorbell, q->queue_id);
} else {
return -EINVAL;
}
writel(doorbell.word0, q->db_regaddr);
return 0;
}
/**
* lpfc_sli4_wq_release - Updates internal hba index for WQ
* @q: The Work Queue to operate on.
* @index: The index to advance the hba index to.
*
* This routine will update the HBA index of a queue to reflect consumption of
* Work Queue Entries by the HBA. When the HBA indicates that it has consumed
* an entry the host calls this function to update the queue's internal
* pointers.
**/
static void
lpfc_sli4_wq_release(struct lpfc_queue *q, uint32_t index)
{
/* sanity check on queue memory */
if (unlikely(!q))
return;
q->hba_index = index;
}
/**
* lpfc_sli4_mq_put - Put a Mailbox Queue Entry on an Mailbox Queue
* @q: The Mailbox Queue to operate on.
* @mqe: The Mailbox Queue Entry to put on the Work queue.
*
* This routine will copy the contents of @mqe to the next available entry on
* the @q. This function will then ring the Work Queue Doorbell to signal the
* HBA to start processing the Work Queue Entry. This function returns 0 if
* successful. If no entries are available on @q then this function will return
* -ENOMEM.
* The caller is expected to hold the hbalock when calling this routine.
**/
static uint32_t
lpfc_sli4_mq_put(struct lpfc_queue *q, struct lpfc_mqe *mqe)
{
struct lpfc_mqe *temp_mqe;
struct lpfc_register doorbell;
/* sanity check on queue memory */
if (unlikely(!q))
return -ENOMEM;
temp_mqe = lpfc_sli4_qe(q, q->host_index);
/* If the host has not yet processed the next entry then we are done */
if (((q->host_index + 1) % q->entry_count) == q->hba_index)
return -ENOMEM;
lpfc_sli4_pcimem_bcopy(mqe, temp_mqe, q->entry_size);
/* Save off the mailbox pointer for completion */
q->phba->mbox = (MAILBOX_t *)temp_mqe;
/* Update the host index before invoking device */
q->host_index = ((q->host_index + 1) % q->entry_count);
/* Ring Doorbell */
doorbell.word0 = 0;
bf_set(lpfc_mq_doorbell_num_posted, &doorbell, 1);
bf_set(lpfc_mq_doorbell_id, &doorbell, q->queue_id);
writel(doorbell.word0, q->phba->sli4_hba.MQDBregaddr);
return 0;
}
Annotation
- Immediate include surface: `linux/blkdev.h`, `linux/pci.h`, `linux/interrupt.h`, `linux/delay.h`, `linux/slab.h`, `linux/lockdep.h`, `linux/dmi.h`, `linux/of.h`.
- Detected declarations: `function lpfc_wqe_cmd_template`, `function lpfc_sli4_wq_put`, `function lpfc_sli4_wq_release`, `function lpfc_sli4_mq_put`, `function lpfc_sli4_mq_release`, `function Queue`, `function lpfc_sli4_eq_clr_intr`, `function lpfc_sli4_if6_eq_clr_intr`, `function lpfc_sli4_write_eq_db`, `function lpfc_sli4_if6_write_eq_db`.
- 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.