drivers/scsi/bnx2fc/bnx2fc_io.c
Source file repositories/reference/linux-study-clean/drivers/scsi/bnx2fc/bnx2fc_io.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/bnx2fc/bnx2fc_io.c- Extension
.c- Size
- 58152 bytes
- Lines
- 2101
- 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
bnx2fc.h
Detected Declarations
function bnx2fc_cmd_timer_setfunction bnx2fc_cmd_timeoutfunction bnx2fc_scsi_donefunction bnx2fc_cmd_mgr_freefunction list_for_each_entry_safefunction bnx2fc_cmd_releasefunction bnx2fc_free_mp_rescfunction bnx2fc_init_mp_reqfunction bnx2fc_initiate_tmffunction bnx2fc_initiate_abtsfunction bnx2fc_initiate_seq_cleanupfunction bnx2fc_initiate_cleanupfunction bnx2fc_eh_target_resetfunction bnx2fc_eh_device_resetfunction bnx2fc_abts_cleanupfunction bnx2fc_eh_abortfunction functionsfunction bnx2fc_process_seq_cleanup_complfunction bnx2fc_process_cleanup_complfunction bnx2fc_process_abts_complfunction bnx2fc_lun_reset_cmplfunction bnx2fc_tgt_reset_cmplfunction bnx2fc_process_tm_complfunction bnx2fc_split_bdfunction bnx2fc_map_sgfunction bnx2fc_build_bd_list_from_sgfunction bnx2fc_unmap_sg_listfunction bnx2fc_build_fcp_cmndfunction bnx2fc_parse_fcp_rspfunction bnx2fc_queuecommandfunction bnx2fc_process_scsi_cmd_complfunction bnx2fc_post_io_req
Annotated Snippet
if (test_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags)) {
BNX2FC_IO_DBG(io_req, "ABTS for ELS timed out\n");
if (!test_and_set_bit(BNX2FC_FLAG_ABTS_DONE,
&io_req->req_flags)) {
kref_put(&io_req->refcount, bnx2fc_cmd_release);
spin_unlock_bh(&tgt->tgt_lock);
return;
}
} else {
/*
* Handle ELS timeout.
* tgt_lock is used to sync compl path and timeout
* path. If els compl path is processing this IO, we
* have nothing to do here, just release the timer hold
*/
BNX2FC_IO_DBG(io_req, "ELS timed out\n");
if (test_and_set_bit(BNX2FC_FLAG_ELS_DONE,
&io_req->req_flags))
goto done;
/* Indicate the cb_func that this ELS is timed out */
set_bit(BNX2FC_FLAG_ELS_TIMEOUT, &io_req->req_flags);
if ((io_req->cb_func) && (io_req->cb_arg)) {
io_req->cb_func(io_req->cb_arg);
io_req->cb_arg = NULL;
}
}
break;
default:
printk(KERN_ERR PFX "cmd_timeout: invalid cmd_type %d\n",
cmd_type);
break;
}
done:
/* release the cmd that was held when timer was set */
kref_put(&io_req->refcount, bnx2fc_cmd_release);
spin_unlock_bh(&tgt->tgt_lock);
}
static void bnx2fc_scsi_done(struct bnx2fc_cmd *io_req, int err_code)
{
/* Called with host lock held */
struct scsi_cmnd *sc_cmd = io_req->sc_cmd;
/*
* active_cmd_queue may have other command types as well,
* and during flush operation, we want to error back only
* scsi commands.
*/
if (io_req->cmd_type != BNX2FC_SCSI_CMD)
return;
BNX2FC_IO_DBG(io_req, "scsi_done. err_code = 0x%x\n", err_code);
if (test_bit(BNX2FC_FLAG_CMD_LOST, &io_req->req_flags)) {
/* Do not call scsi done for this IO */
return;
}
bnx2fc_unmap_sg_list(io_req);
io_req->sc_cmd = NULL;
/* Sanity checks before returning command to mid-layer */
if (!sc_cmd) {
printk(KERN_ERR PFX "scsi_done - sc_cmd NULL. "
"IO(0x%x) already cleaned up\n",
io_req->xid);
return;
}
if (!sc_cmd->device) {
pr_err(PFX "0x%x: sc_cmd->device is NULL.\n", io_req->xid);
return;
}
if (!sc_cmd->device->host) {
pr_err(PFX "0x%x: sc_cmd->device->host is NULL.\n",
io_req->xid);
return;
}
sc_cmd->result = err_code << 16;
BNX2FC_IO_DBG(io_req, "sc=%p, result=0x%x, retries=%d, allowed=%d\n",
sc_cmd, host_byte(sc_cmd->result), sc_cmd->retries,
sc_cmd->allowed);
scsi_set_resid(sc_cmd, scsi_bufflen(sc_cmd));
bnx2fc_priv(sc_cmd)->io_req = NULL;
scsi_done(sc_cmd);
Annotation
- Immediate include surface: `bnx2fc.h`.
- Detected declarations: `function bnx2fc_cmd_timer_set`, `function bnx2fc_cmd_timeout`, `function bnx2fc_scsi_done`, `function bnx2fc_cmd_mgr_free`, `function list_for_each_entry_safe`, `function bnx2fc_cmd_release`, `function bnx2fc_free_mp_resc`, `function bnx2fc_init_mp_req`, `function bnx2fc_initiate_tmf`, `function bnx2fc_initiate_abts`.
- 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.