drivers/scsi/snic/snic_scsi.c
Source file repositories/reference/linux-study-clean/drivers/scsi/snic/snic_scsi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/snic/snic_scsi.c- Extension
.c- Size
- 67201 bytes
- Lines
- 2638
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/mempool.hlinux/errno.hlinux/init.hlinux/workqueue.hlinux/pci.hlinux/spinlock.hlinux/delay.hlinux/gfp.hscsi/scsi.hscsi/scsi_host.hscsi/scsi_device.hscsi/scsi_cmnd.hscsi/scsi_tcq.hscsi/scsi_dbg.hsnic_io.hsnic.h
Detected Declarations
function snic_state_to_strfunction snic_io_status_to_strfunction snic_ioreq_state_to_strfunction snic_io_lock_hashfunction snic_io_lock_tagfunction snic_release_req_buffunction snic_queue_icmnd_reqfunction for_each_sgfunction snic_issue_scsi_reqfunction snic_queuecommandfunction snic_proc_tmreq_pending_statefunction snic_process_io_failed_statefunction snic_tmreq_pendingfunction snic_process_icmnd_cmpl_statusfunction snic_icmnd_cmpl_handlerfunction snic_proc_dr_cmpl_lockedfunction snic_update_abort_statsfunction snic_process_itmf_cmplfunction snic_itmf_cmpl_handlerfunction snic_hba_reset_scsi_cleanupfunction snic_hba_reset_cmpl_handlerfunction snic_msg_ack_handlerfunction snic_aen_handlerfunction entriesfunction snic_fwcq_cmpl_handlerfunction snic_queue_itmf_reqfunction snic_issue_tm_reqfunction snic_queue_abort_reqfunction snic_abort_finishfunction snic_send_abort_and_waitfunction snic_abort_cmdfunction snic_is_abts_pendingfunction snic_dr_clean_single_reqfunction snic_dr_clean_pending_reqfunction snic_dr_finishfunction snic_queue_dr_reqfunction snic_send_dr_and_waitfunction snic_dev_reset_supportedfunction snic_unlink_and_release_reqfunction snic_device_resetfunction snic_issue_hba_resetfunction snic_resetfunction snic_host_resetfunction snic_cmpl_pending_tmreqfunction snic_scsi_cleanupfunction snic_shutdown_scsi_cleanupfunction snic_internal_abort_iofunction snic_tgt_scsi_abort_io
Annotated Snippet
for_each_sg(scsi_sglist(sc), sg, sg_cnt, i) {
sgd->addr = cpu_to_le64(sg_dma_address(sg));
sgd->len = cpu_to_le32(sg_dma_len(sg));
sgd->_resvd = 0;
sgd++;
}
}
pa = dma_map_single(&snic->pdev->dev,
sc->sense_buffer,
SCSI_SENSE_BUFFERSIZE,
DMA_FROM_DEVICE);
if (dma_mapping_error(&snic->pdev->dev, pa)) {
SNIC_HOST_ERR(snic->shost,
"QIcmnd:PCI Map Failed for sns buf %p tag %x\n",
sc->sense_buffer, snic_cmd_tag(sc));
ret = -ENOMEM;
return ret;
}
int_to_scsilun(sc->device->lun, &lun);
if (sc->sc_data_direction == DMA_FROM_DEVICE)
flags |= SNIC_ICMND_RD;
if (sc->sc_data_direction == DMA_TO_DEVICE)
flags |= SNIC_ICMND_WR;
/* Initialize icmnd */
snic_icmnd_init(rqi->req,
snic_cmd_tag(sc),
snic->config.hid, /* hid */
(ulong) rqi,
flags, /* command flags */
rqi->tgt_id,
lun.scsi_lun,
sc->cmnd,
sc->cmd_len,
scsi_bufflen(sc),
sg_cnt,
(ulong) req_to_sgl(rqi->req),
pa, /* sense buffer pa */
SCSI_SENSE_BUFFERSIZE);
atomic64_inc(&snic->s_stats.io.active);
ret = snic_queue_wq_desc(snic, rqi->req, rqi->req_len);
if (ret) {
atomic64_dec(&snic->s_stats.io.active);
SNIC_HOST_ERR(snic->shost,
"QIcmnd: Queuing Icmnd Failed. ret = %d\n",
ret);
} else
snic_stats_update_active_ios(&snic->s_stats);
return ret;
} /* end of snic_queue_icmnd_req */
/*
* snic_issue_scsi_req : Prepares IO request and Issues to FW.
*/
static int
snic_issue_scsi_req(struct snic *snic,
struct snic_tgt *tgt,
struct scsi_cmnd *sc)
{
struct snic_req_info *rqi = NULL;
int sg_cnt = 0;
int ret = 0;
u32 tag = snic_cmd_tag(sc);
u64 cmd_trc = 0, cmd_st_flags = 0;
spinlock_t *io_lock = NULL;
unsigned long flags;
CMD_STATE(sc) = SNIC_IOREQ_NOT_INITED;
CMD_FLAGS(sc) = SNIC_NO_FLAGS;
sg_cnt = scsi_dma_map(sc);
if (sg_cnt < 0) {
SNIC_TRC((u16)snic->shost->host_no, tag, (ulong) sc, 0,
sc->cmnd[0], sg_cnt, CMD_STATE(sc));
SNIC_HOST_ERR(snic->shost, "issue_sc:Failed to map SG List.\n");
ret = -ENOMEM;
goto issue_sc_end;
}
rqi = snic_req_init(snic, sg_cnt);
if (!rqi) {
scsi_dma_unmap(sc);
ret = -ENOMEM;
Annotation
- Immediate include surface: `linux/mempool.h`, `linux/errno.h`, `linux/init.h`, `linux/workqueue.h`, `linux/pci.h`, `linux/spinlock.h`, `linux/delay.h`, `linux/gfp.h`.
- Detected declarations: `function snic_state_to_str`, `function snic_io_status_to_str`, `function snic_ioreq_state_to_str`, `function snic_io_lock_hash`, `function snic_io_lock_tag`, `function snic_release_req_buf`, `function snic_queue_icmnd_req`, `function for_each_sg`, `function snic_issue_scsi_req`, `function snic_queuecommand`.
- 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.