drivers/scsi/csiostor/csio_scsi.c
Source file repositories/reference/linux-study-clean/drivers/scsi/csiostor/csio_scsi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/csiostor/csio_scsi.c- Extension
.c- Size
- 68936 bytes
- Lines
- 2531
- 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/device.hlinux/delay.hlinux/ctype.hlinux/kernel.hlinux/slab.hlinux/string.hlinux/compiler.hlinux/export.hlinux/module.hlinux/unaligned.hasm/page.hscsi/scsi.hscsi/scsi_device.hscsi/scsi_transport_fc.hcsio_hw.hcsio_lnode.hcsio_rnode.hcsio_scsi.hcsio_init.h
Detected Declarations
function csio_scsi_match_iofunction csio_scsi_gather_active_iosfunction list_for_each_safefunction csio_scsi_itnexus_loss_errorfunction csio_scsi_fcp_cmndfunction csio_scsi_init_cmd_wrfunction ALIGNfunction csio_scsi_init_ultptx_dsglfunction scsi_for_each_sgfunction list_for_eachfunction csio_scsi_init_read_wrfunction csio_scsi_init_write_wrfunction csio_scsi_readfunction csio_scsi_writefunction csio_setup_ddpfunction scsi_for_each_sgfunction csio_scsi_init_abrt_cls_wrfunction csio_scsi_abrt_clsfunction csio_scsis_uninitfunction csio_scsis_io_activefunction csio_scsis_tm_activefunction csio_scsis_abortingfunction csio_scsis_closingfunction csio_scsis_shost_cmpl_awaitfunction cachefunction csio_scsi_cleanup_io_qfunction csio_abrt_clsfunction csio_scsi_abort_io_qfunction csio_scsim_cleanup_iofunction sleepfunction csio_show_hw_statefunction csio_device_resetfunction csio_disable_portfunction csio_show_dbg_levelfunction csio_store_dbg_levelfunction csio_show_num_reg_rnodesfunction csio_scsi_copy_to_sglfunction csio_scsi_err_handlerfunction csio_scsi_cbfnfunction csio_queuecommandfunction csio_do_abrt_clsfunction csio_eh_abort_handlerfunction csio_tm_cbfnfunction csio_eh_lun_reset_handlerfunction csio_sdev_initfunction csio_sdev_configurefunction csio_sdev_destroyfunction csio_scan_finished
Annotated Snippet
if (csio_scsi_match_io((struct csio_ioreq *)tmp, sld)) {
list_del_init(tmp);
list_add_tail(tmp, dest);
}
}
}
static inline bool
csio_scsi_itnexus_loss_error(uint16_t error)
{
switch (error) {
case FW_ERR_LINK_DOWN:
case FW_RDEV_NOT_READY:
case FW_ERR_RDEV_LOST:
case FW_ERR_RDEV_LOGO:
case FW_ERR_RDEV_IMPL_LOGO:
return true;
}
return false;
}
/*
* csio_scsi_fcp_cmnd - Frame the SCSI FCP command paylod.
* @req: IO req structure.
* @addr: DMA location to place the payload.
*
* This routine is shared between FCP_WRITE, FCP_READ and FCP_CMD requests.
*/
static inline void
csio_scsi_fcp_cmnd(struct csio_ioreq *req, void *addr)
{
struct fcp_cmnd *fcp_cmnd = (struct fcp_cmnd *)addr;
struct scsi_cmnd *scmnd = csio_scsi_cmnd(req);
/* Check for Task Management */
if (likely(csio_priv(scmnd)->fc_tm_flags == 0)) {
int_to_scsilun(scmnd->device->lun, &fcp_cmnd->fc_lun);
fcp_cmnd->fc_tm_flags = 0;
fcp_cmnd->fc_cmdref = 0;
memcpy(fcp_cmnd->fc_cdb, scmnd->cmnd, 16);
fcp_cmnd->fc_pri_ta = FCP_PTA_SIMPLE;
fcp_cmnd->fc_dl = cpu_to_be32(scsi_bufflen(scmnd));
if (req->nsge)
if (req->datadir == DMA_TO_DEVICE)
fcp_cmnd->fc_flags = FCP_CFL_WRDATA;
else
fcp_cmnd->fc_flags = FCP_CFL_RDDATA;
else
fcp_cmnd->fc_flags = 0;
} else {
memset(fcp_cmnd, 0, sizeof(*fcp_cmnd));
int_to_scsilun(scmnd->device->lun, &fcp_cmnd->fc_lun);
fcp_cmnd->fc_tm_flags = csio_priv(scmnd)->fc_tm_flags;
}
}
/*
* csio_scsi_init_cmd_wr - Initialize the SCSI CMD WR.
* @req: IO req structure.
* @addr: DMA location to place the payload.
* @size: Size of WR (including FW WR + immed data + rsp SG entry
*
* Wrapper for populating fw_scsi_cmd_wr.
*/
static inline void
csio_scsi_init_cmd_wr(struct csio_ioreq *req, void *addr, uint32_t size)
{
struct csio_hw *hw = req->lnode->hwp;
struct csio_rnode *rn = req->rnode;
struct fw_scsi_cmd_wr *wr = (struct fw_scsi_cmd_wr *)addr;
struct csio_dma_buf *dma_buf;
uint8_t imm = csio_hw_to_scsim(hw)->proto_cmd_len;
wr->op_immdlen = cpu_to_be32(FW_WR_OP_V(FW_SCSI_CMD_WR) |
FW_SCSI_CMD_WR_IMMDLEN(imm));
wr->flowid_len16 = cpu_to_be32(FW_WR_FLOWID_V(rn->flowid) |
FW_WR_LEN16_V(
DIV_ROUND_UP(size, 16)));
wr->cookie = (uintptr_t) req;
wr->iqid = cpu_to_be16(csio_q_physiqid(hw, req->iq_idx));
wr->tmo_val = (uint8_t) req->tmo;
wr->r3 = 0;
memset(&wr->r5, 0, 8);
/* Get RSP DMA buffer */
dma_buf = &req->dma_buf;
Annotation
- Immediate include surface: `linux/device.h`, `linux/delay.h`, `linux/ctype.h`, `linux/kernel.h`, `linux/slab.h`, `linux/string.h`, `linux/compiler.h`, `linux/export.h`.
- Detected declarations: `function csio_scsi_match_io`, `function csio_scsi_gather_active_ios`, `function list_for_each_safe`, `function csio_scsi_itnexus_loss_error`, `function csio_scsi_fcp_cmnd`, `function csio_scsi_init_cmd_wr`, `function ALIGN`, `function csio_scsi_init_ultptx_dsgl`, `function scsi_for_each_sg`, `function list_for_each`.
- 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.