drivers/scsi/bnx2i/bnx2i_iscsi.c
Source file repositories/reference/linux-study-clean/drivers/scsi/bnx2i/bnx2i_iscsi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/bnx2i/bnx2i_iscsi.c- Extension
.c- Size
- 63089 bytes
- Lines
- 2307
- 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/slab.hscsi/scsi_tcq.hscsi/libiscsi.hbnx2i.h
Detected Declarations
function bnx2i_adapter_readyfunction bnx2i_get_write_cmd_bd_idxfunction bnx2i_setup_write_cmd_bd_infofunction bnx2i_map_scsi_sgfunction scsi_for_each_sgfunction bnx2i_iscsi_map_sg_listfunction bnx2i_iscsi_unmap_sg_listfunction bnx2i_setup_cmd_wqe_templatefunction bnx2i_bind_conn_to_iscsi_cidfunction bnx2i_alloc_iscsi_cidfunction bnx2i_free_iscsi_cidfunction bnx2i_setup_free_cid_quefunction bnx2i_release_free_cid_quefunction bnx2i_free_epfunction bnx2i_alloc_bdtfunction bnx2i_destroy_cmd_poolfunction bnx2i_setup_cmd_poolfunction pathfunction bnx2i_free_mp_bdtfunction bnx2i_drop_sessionfunction bnx2i_ep_destroy_list_addfunction bnx2i_ep_destroy_list_delfunction bnx2i_ep_ofld_list_addfunction bnx2i_ep_ofld_list_delfunction bnx2i_find_ep_in_ofld_listfunction bnx2i_find_ep_in_destroy_listfunction bnx2i_ep_active_list_addfunction bnx2i_ep_active_list_delfunction bnx2i_setup_host_queue_sizefunction bnx2i_free_hbafunction bnx2i_conn_free_login_resourcesfunction bnx2i_conn_alloc_login_resourcesfunction bnx2i_iscsi_prep_generic_pdu_bdfunction bnx2i_iscsi_send_generic_requestfunction bnx2i_cpy_scsi_cdbfunction bnx2i_cleanup_taskfunction bnx2i_mtask_xmitfunction bnx2i_task_xmitfunction bnx2i_session_createfunction bnx2i_session_destroyfunction bnx2i_conn_createfunction bnx2i_conn_bindfunction bnx2i_conn_destroyfunction list_for_each_entry_safefunction bnx2i_ep_get_paramfunction bnx2i_host_get_paramfunction bnx2i_conn_startfunction bnx2i_conn_get_stats
Annotated Snippet
while (buf_off >= (cur_offset + bd_tbl->buffer_length)) {
cur_offset += bd_tbl->buffer_length;
cur_bd_idx++;
bd_tbl++;
}
}
*start_bd_off = buf_off - cur_offset;
*start_bd_idx = cur_bd_idx;
}
/**
* bnx2i_setup_write_cmd_bd_info - sets up BD various information
* @task: transport layer's cmd struct pointer
*
* identifies & marks various bd info for scsi command's immediate data,
* unsolicited data and first solicited data seq which includes BD start
* index & BD buf off. his function takes into account iscsi parameter such
* as immediate data and unsolicited data is support on this connection.
*/
static void bnx2i_setup_write_cmd_bd_info(struct iscsi_task *task)
{
struct bnx2i_cmd *cmd = task->dd_data;
u32 start_bd_offset;
u32 start_bd_idx;
u32 buffer_offset = 0;
u32 cmd_len = cmd->req.total_data_transfer_length;
/* if ImmediateData is turned off & IntialR2T is turned on,
* there will be no immediate or unsolicited data, just return.
*/
if (!iscsi_task_has_unsol_data(task) && !task->imm_count)
return;
/* Immediate data */
buffer_offset += task->imm_count;
if (task->imm_count == cmd_len)
return;
if (iscsi_task_has_unsol_data(task)) {
bnx2i_get_write_cmd_bd_idx(cmd, buffer_offset,
&start_bd_offset, &start_bd_idx);
cmd->req.ud_buffer_offset = start_bd_offset;
cmd->req.ud_start_bd_index = start_bd_idx;
buffer_offset += task->unsol_r2t.data_length;
}
if (buffer_offset != cmd_len) {
bnx2i_get_write_cmd_bd_idx(cmd, buffer_offset,
&start_bd_offset, &start_bd_idx);
if ((start_bd_offset > task->conn->session->first_burst) ||
(start_bd_idx > scsi_sg_count(cmd->scsi_cmd))) {
int i = 0;
iscsi_conn_printk(KERN_ALERT, task->conn,
"bnx2i- error, buf offset 0x%x "
"bd_valid %d use_sg %d\n",
buffer_offset, cmd->io_tbl.bd_valid,
scsi_sg_count(cmd->scsi_cmd));
for (i = 0; i < cmd->io_tbl.bd_valid; i++)
iscsi_conn_printk(KERN_ALERT, task->conn,
"bnx2i err, bd[%d]: len %x\n",
i, cmd->io_tbl.bd_tbl[i].\
buffer_length);
}
cmd->req.sd_buffer_offset = start_bd_offset;
cmd->req.sd_start_bd_index = start_bd_idx;
}
}
/**
* bnx2i_map_scsi_sg - maps IO buffer and prepares the BD table
* @hba: adapter instance
* @cmd: iscsi cmd struct pointer
*
* map SG list
*/
static int bnx2i_map_scsi_sg(struct bnx2i_hba *hba, struct bnx2i_cmd *cmd)
{
struct scsi_cmnd *sc = cmd->scsi_cmd;
struct iscsi_bd *bd = cmd->io_tbl.bd_tbl;
struct scatterlist *sg;
int byte_count = 0;
int bd_count = 0;
int sg_count;
int sg_len;
u64 addr;
int i;
Annotation
- Immediate include surface: `linux/slab.h`, `scsi/scsi_tcq.h`, `scsi/libiscsi.h`, `bnx2i.h`.
- Detected declarations: `function bnx2i_adapter_ready`, `function bnx2i_get_write_cmd_bd_idx`, `function bnx2i_setup_write_cmd_bd_info`, `function bnx2i_map_scsi_sg`, `function scsi_for_each_sg`, `function bnx2i_iscsi_map_sg_list`, `function bnx2i_iscsi_unmap_sg_list`, `function bnx2i_setup_cmd_wqe_template`, `function bnx2i_bind_conn_to_iscsi_cid`, `function bnx2i_alloc_iscsi_cid`.
- 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.