drivers/scsi/bnx2i/bnx2i_hwi.c
Source file repositories/reference/linux-study-clean/drivers/scsi/bnx2i/bnx2i_hwi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/bnx2i/bnx2i_hwi.c- Extension
.c- Size
- 84039 bytes
- Lines
- 2746
- 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/gfp.hscsi/scsi_tcq.hscsi/libiscsi.hbnx2i.h
Detected Declarations
function bnx2i_get_cid_numfunction bnx2i_adjust_qp_sizefunction bnx2i_get_link_statefunction bnx2i_iscsi_license_errorfunction bnx2i_arm_cq_event_coalescingfunction sharedfunction bnx2i_ring_577xx_doorbellfunction bnx2i_put_rq_buffunction bnx2i_ring_sq_dbellfunction bnx2i_ring_dbell_update_sq_paramsfunction bnx2i_send_iscsi_loginfunction bnx2i_send_iscsi_tmffunction bnx2i_send_iscsi_textfunction bnx2i_send_iscsi_scsicmdfunction bnx2i_send_iscsi_nopoutfunction bnx2i_send_iscsi_logoutfunction bnx2i_update_iscsi_connfunction bnx2i_ep_ofld_timerfunction bnx2i_power_of2function bnx2i_send_cmd_cleanup_reqfunction bnx2i_send_conn_destroyfunction bnx2i_570x_send_conn_ofld_reqfunction bnx2i_5771x_send_conn_ofld_reqfunction bnx2i_send_conn_ofld_reqfunction setup_qp_page_tablesfunction QPfunction bnx2i_free_qp_rescfunction bnx2i_send_fw_iscsi_init_msgfunction bnx2i_process_scsi_cmd_respfunction bnx2i_process_login_respfunction bnx2i_process_text_respfunction bnx2i_process_tmf_respfunction bnx2i_process_logout_respfunction bnx2i_process_nopin_local_cmplfunction bnx2i_unsol_pdu_adjust_rqfunction bnx2i_process_nopin_mesgfunction bnx2i_process_async_mesgfunction bnx2i_process_reject_mesgfunction bnx2i_process_cmd_cleanup_respfunction bnx2i_percpu_io_threadfunction list_for_each_entry_safefunction bnx2i_queue_scsi_cmd_respfunction bnx2i_process_new_cqesfunction bnx2i_fastpath_notificationfunction bnx2i_process_update_conn_cmplfunction bnx2i_recovery_que_add_connfunction bnx2i_process_tcp_errorfunction bnx2i_process_iscsi_error
Annotated Snippet
test_bit(BNX2I_NX2_DEV_5709, &hba->cnic_dev_type)) {
if (!is_power_of_2(hba->max_sqes))
hba->max_sqes = rounddown_pow_of_two(hba->max_sqes);
if (!is_power_of_2(hba->max_rqes))
hba->max_rqes = rounddown_pow_of_two(hba->max_rqes);
}
/* Adjust each queue size if the user selection does not
* yield integral num of page buffers
*/
/* adjust SQ */
num_elements_per_pg = CNIC_PAGE_SIZE / BNX2I_SQ_WQE_SIZE;
if (hba->max_sqes < num_elements_per_pg)
hba->max_sqes = num_elements_per_pg;
else if (hba->max_sqes % num_elements_per_pg)
hba->max_sqes = (hba->max_sqes + num_elements_per_pg - 1) &
~(num_elements_per_pg - 1);
/* adjust CQ */
num_elements_per_pg = CNIC_PAGE_SIZE / BNX2I_CQE_SIZE;
if (hba->max_cqes < num_elements_per_pg)
hba->max_cqes = num_elements_per_pg;
else if (hba->max_cqes % num_elements_per_pg)
hba->max_cqes = (hba->max_cqes + num_elements_per_pg - 1) &
~(num_elements_per_pg - 1);
/* adjust RQ */
num_elements_per_pg = CNIC_PAGE_SIZE / BNX2I_RQ_WQE_SIZE;
if (hba->max_rqes < num_elements_per_pg)
hba->max_rqes = num_elements_per_pg;
else if (hba->max_rqes % num_elements_per_pg)
hba->max_rqes = (hba->max_rqes + num_elements_per_pg - 1) &
~(num_elements_per_pg - 1);
}
/**
* bnx2i_get_link_state - get network interface link state
* @hba: adapter instance pointer
*
* updates adapter structure flag based on netdev state
*/
static void bnx2i_get_link_state(struct bnx2i_hba *hba)
{
if (test_bit(__LINK_STATE_NOCARRIER, &hba->netdev->state))
set_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state);
else
clear_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state);
}
/**
* bnx2i_iscsi_license_error - displays iscsi license related error message
* @hba: adapter instance pointer
* @error_code: error classification
*
* Puts out an error log when driver is unable to offload iscsi connection
* due to license restrictions
*/
static void bnx2i_iscsi_license_error(struct bnx2i_hba *hba, u32 error_code)
{
if (error_code == ISCSI_KCQE_COMPLETION_STATUS_ISCSI_NOT_SUPPORTED)
/* iSCSI offload not supported on this device */
printk(KERN_ERR "bnx2i: iSCSI not supported, dev=%s\n",
hba->netdev->name);
if (error_code == ISCSI_KCQE_COMPLETION_STATUS_LOM_ISCSI_NOT_ENABLED)
/* iSCSI offload not supported on this LOM device */
printk(KERN_ERR "bnx2i: LOM is not enable to "
"offload iSCSI connections, dev=%s\n",
hba->netdev->name);
set_bit(ADAPTER_STATE_INIT_FAILED, &hba->adapter_state);
}
/**
* bnx2i_arm_cq_event_coalescing - arms CQ to enable EQ notification
* @ep: endpoint (transport identifier) structure
* @action: action, ARM or DISARM. For now only ARM_CQE is used
*
* Arm'ing CQ will enable chip to generate global EQ events inorder to interrupt
* the driver. EQ event is generated CQ index is hit or at least 1 CQ is
* outstanding and on chip timer expires
*/
int bnx2i_arm_cq_event_coalescing(struct bnx2i_endpoint *ep, u8 action)
{
struct bnx2i_5771x_cq_db *cq_db;
u16 cq_index;
u16 next_index = 0;
u32 num_active_cmds;
Annotation
- Immediate include surface: `linux/gfp.h`, `scsi/scsi_tcq.h`, `scsi/libiscsi.h`, `bnx2i.h`.
- Detected declarations: `function bnx2i_get_cid_num`, `function bnx2i_adjust_qp_size`, `function bnx2i_get_link_state`, `function bnx2i_iscsi_license_error`, `function bnx2i_arm_cq_event_coalescing`, `function shared`, `function bnx2i_ring_577xx_doorbell`, `function bnx2i_put_rq_buf`, `function bnx2i_ring_sq_dbell`, `function bnx2i_ring_dbell_update_sq_params`.
- 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.