drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c- Extension
.c- Size
- 39748 bytes
- Lines
- 1436
- Domain
- Driver Families
- Bucket
- drivers/net
- 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.
- 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
qlcnic.h
Detected Declarations
function qlcnic_get_cmd_signaturefunction qlcnic_82xx_alloc_mbx_argsfunction qlcnic_free_mbx_argsfunction qlcnic_poll_rspfunction qlcnic_82xx_issue_cmdfunction qlcnic_fw_cmd_set_drv_versionfunction qlcnic_fw_cmd_set_mtufunction qlcnic_82xx_fw_cmd_create_rx_ctxfunction qlcnic_82xx_fw_cmd_del_rx_ctxfunction qlcnic_82xx_fw_cmd_create_tx_ctxfunction qlcnic_82xx_fw_cmd_del_tx_ctxfunction qlcnic_fw_cmd_set_portfunction qlcnic_alloc_hw_resourcesfunction qlcnic_fw_create_ctxfunction qlcnic_fw_destroy_ctxfunction qlcnic_free_hw_resourcesfunction qlcnic_82xx_config_intrptfunction qlcnic_82xx_get_mac_addressfunction qlcnic_82xx_get_nic_infofunction qlcnic_82xx_set_nic_infofunction qlcnic_82xx_get_pci_infofunction qlcnic_config_port_mirroringfunction qlcnic_get_port_statsfunction qlcnic_get_mac_statsfunction qlcnic_get_eswitch_statsfunction qlcnic_clear_esw_statsfunction __qlcnic_get_eswitch_port_configfunction qlcnic_config_switch_portfunction qlcnic_get_eswitch_port_config
Annotated Snippet
if (type == mbx_tbl[i].cmd) {
mbx->req.num = mbx_tbl[i].in_args;
mbx->rsp.num = mbx_tbl[i].out_args;
mbx->req.arg = kcalloc(mbx->req.num,
sizeof(u32), GFP_ATOMIC);
if (!mbx->req.arg)
return -ENOMEM;
mbx->rsp.arg = kcalloc(mbx->rsp.num,
sizeof(u32), GFP_ATOMIC);
if (!mbx->rsp.arg) {
kfree(mbx->req.arg);
mbx->req.arg = NULL;
return -ENOMEM;
}
mbx->req.arg[0] = type;
break;
}
}
return 0;
}
/* Free up mailbox registers */
void qlcnic_free_mbx_args(struct qlcnic_cmd_args *cmd)
{
kfree(cmd->req.arg);
cmd->req.arg = NULL;
kfree(cmd->rsp.arg);
cmd->rsp.arg = NULL;
}
static u32
qlcnic_poll_rsp(struct qlcnic_adapter *adapter)
{
u32 rsp;
int timeout = 0, err = 0;
do {
/* give atleast 1ms for firmware to respond */
mdelay(1);
if (++timeout > QLCNIC_OS_CRB_RETRY_COUNT)
return QLCNIC_CDRP_RSP_TIMEOUT;
rsp = QLCRD32(adapter, QLCNIC_CDRP_CRB_OFFSET, &err);
} while (!QLCNIC_CDRP_IS_RSP(rsp));
return rsp;
}
int qlcnic_82xx_issue_cmd(struct qlcnic_adapter *adapter,
struct qlcnic_cmd_args *cmd)
{
int i, err = 0;
u32 rsp;
u32 signature;
struct pci_dev *pdev = adapter->pdev;
struct qlcnic_hardware_context *ahw = adapter->ahw;
const char *fmt;
signature = qlcnic_get_cmd_signature(ahw);
/* Acquire semaphore before accessing CRB */
if (qlcnic_api_lock(adapter)) {
cmd->rsp.arg[0] = QLCNIC_RCODE_TIMEOUT;
return cmd->rsp.arg[0];
}
QLCWR32(adapter, QLCNIC_SIGN_CRB_OFFSET, signature);
for (i = 1; i < cmd->req.num; i++)
QLCWR32(adapter, QLCNIC_CDRP_ARG(i), cmd->req.arg[i]);
QLCWR32(adapter, QLCNIC_CDRP_CRB_OFFSET,
QLCNIC_CDRP_FORM_CMD(cmd->req.arg[0]));
rsp = qlcnic_poll_rsp(adapter);
if (rsp == QLCNIC_CDRP_RSP_TIMEOUT) {
dev_err(&pdev->dev, "command timeout, response = 0x%x\n", rsp);
cmd->rsp.arg[0] = QLCNIC_RCODE_TIMEOUT;
} else if (rsp == QLCNIC_CDRP_RSP_FAIL) {
cmd->rsp.arg[0] = QLCRD32(adapter, QLCNIC_CDRP_ARG(1), &err);
switch (cmd->rsp.arg[0]) {
case QLCNIC_RCODE_INVALID_ARGS:
fmt = "CDRP invalid args: [%d]\n";
break;
case QLCNIC_RCODE_NOT_SUPPORTED:
case QLCNIC_RCODE_NOT_IMPL:
fmt = "CDRP command not supported: [%d]\n";
break;
case QLCNIC_RCODE_NOT_PERMITTED:
fmt = "CDRP requested action not permitted: [%d]\n";
break;
Annotation
- Immediate include surface: `qlcnic.h`.
- Detected declarations: `function qlcnic_get_cmd_signature`, `function qlcnic_82xx_alloc_mbx_args`, `function qlcnic_free_mbx_args`, `function qlcnic_poll_rsp`, `function qlcnic_82xx_issue_cmd`, `function qlcnic_fw_cmd_set_drv_version`, `function qlcnic_fw_cmd_set_mtu`, `function qlcnic_82xx_fw_cmd_create_rx_ctx`, `function qlcnic_82xx_fw_cmd_del_rx_ctx`, `function qlcnic_82xx_fw_cmd_create_tx_ctx`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- 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.