drivers/infiniband/hw/efa/efa_com.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/efa/efa_com.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/efa/efa_com.c- Extension
.c- Size
- 34962 bytes
- Lines
- 1295
- Domain
- Driver Families
- Bucket
- drivers/infiniband
- 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/crc16.hlinux/log2.hefa_com.hefa_regs_defs.h
Detected Declarations
struct efa_comp_ctxenum efa_cmd_statusfunction efa_com_set_dma_addrfunction efa_com_reg_read32function efa_com_admin_init_sqfunction efa_com_admin_init_cqfunction efa_com_admin_init_aenqfunction efa_com_alloc_ctx_idfunction efa_com_dealloc_ctx_idfunction efa_com_get_comp_ctx_idfunction efa_com_dealloc_comp_ctxfunction __efa_com_submit_admin_cmdfunction efa_com_init_comp_ctxtfunction efa_com_submit_admin_cmdfunction efa_com_cqe_checksum_validfunction efa_com_handle_single_admin_completionfunction efa_com_handle_admin_completionfunction efa_com_comp_status_to_errnofunction efa_com_wait_and_process_admin_cq_pollingfunction efa_com_wait_and_process_admin_cq_interruptsfunction efa_com_wait_and_process_admin_cqfunction efa_com_cmd_execfunction efa_com_admin_destroyfunction efa_com_set_admin_polling_modefunction efa_com_stats_initfunction efa_com_admin_initfunction efa_com_admin_q_comp_intr_handlerfunction efa_com_get_specific_aenq_cbfunction efa_com_aenq_intr_handlerfunction efa_com_mmio_reg_read_resp_addr_initfunction efa_com_mmio_reg_read_initfunction efa_com_mmio_reg_read_destroyfunction efa_com_validate_versionfunction efa_com_get_dma_widthfunction wait_for_reset_statefunction efa_com_dev_resetfunction efa_com_create_eqfunction efa_com_destroy_eqfunction efa_com_arm_eqfunction efa_com_eq_comp_intr_handlerfunction efa_com_eq_destroyfunction efa_com_eq_init
Annotated Snippet
struct efa_comp_ctx {
struct completion wait_event;
struct efa_admin_acq_entry *user_cqe;
u32 comp_size;
enum efa_cmd_status status;
u16 cmd_id;
u8 cmd_opcode;
};
static const char *efa_com_cmd_str(u8 cmd)
{
#define EFA_CMD_STR_CASE(_cmd) case EFA_ADMIN_##_cmd: return #_cmd
switch (cmd) {
EFA_CMD_STR_CASE(CREATE_QP);
EFA_CMD_STR_CASE(MODIFY_QP);
EFA_CMD_STR_CASE(QUERY_QP);
EFA_CMD_STR_CASE(DESTROY_QP);
EFA_CMD_STR_CASE(CREATE_AH);
EFA_CMD_STR_CASE(DESTROY_AH);
EFA_CMD_STR_CASE(REG_MR);
EFA_CMD_STR_CASE(DEREG_MR);
EFA_CMD_STR_CASE(CREATE_CQ);
EFA_CMD_STR_CASE(DESTROY_CQ);
EFA_CMD_STR_CASE(GET_FEATURE);
EFA_CMD_STR_CASE(SET_FEATURE);
EFA_CMD_STR_CASE(GET_STATS);
EFA_CMD_STR_CASE(ALLOC_PD);
EFA_CMD_STR_CASE(DEALLOC_PD);
EFA_CMD_STR_CASE(ALLOC_UAR);
EFA_CMD_STR_CASE(DEALLOC_UAR);
EFA_CMD_STR_CASE(CREATE_EQ);
EFA_CMD_STR_CASE(DESTROY_EQ);
default: return "unknown command opcode";
}
#undef EFA_CMD_STR_CASE
}
void efa_com_set_dma_addr(dma_addr_t addr, u32 *addr_high, u32 *addr_low)
{
*addr_low = lower_32_bits(addr);
*addr_high = upper_32_bits(addr);
}
static u32 efa_com_reg_read32(struct efa_com_dev *edev, u16 offset)
{
struct efa_com_mmio_read *mmio_read = &edev->mmio_read;
struct efa_admin_mmio_req_read_less_resp *read_resp;
unsigned long exp_time;
u32 mmio_read_reg = 0;
u32 err;
read_resp = mmio_read->read_resp;
spin_lock(&mmio_read->lock);
mmio_read->seq_num++;
/* trash DMA req_id to identify when hardware is done */
read_resp->req_id = mmio_read->seq_num + 0x9aL;
EFA_SET(&mmio_read_reg, EFA_REGS_MMIO_REG_READ_REG_OFF, offset);
EFA_SET(&mmio_read_reg, EFA_REGS_MMIO_REG_READ_REQ_ID,
mmio_read->seq_num);
writel(mmio_read_reg, edev->reg_bar + EFA_REGS_MMIO_REG_READ_OFF);
exp_time = jiffies + usecs_to_jiffies(mmio_read->mmio_read_timeout);
do {
if (READ_ONCE(read_resp->req_id) == mmio_read->seq_num)
break;
udelay(1);
} while (time_is_after_jiffies(exp_time));
if (read_resp->req_id != mmio_read->seq_num) {
ibdev_err_ratelimited(
edev->efa_dev,
"Reading register timed out. expected: req id[%u] offset[%#x] actual: req id[%u] offset[%#x]\n",
mmio_read->seq_num, offset, read_resp->req_id,
read_resp->reg_off);
err = EFA_MMIO_READ_INVALID;
goto out;
}
if (read_resp->reg_off != offset) {
ibdev_err_ratelimited(
edev->efa_dev,
"Reading register failed: wrong offset provided\n");
err = EFA_MMIO_READ_INVALID;
goto out;
}
Annotation
- Immediate include surface: `linux/crc16.h`, `linux/log2.h`, `efa_com.h`, `efa_regs_defs.h`.
- Detected declarations: `struct efa_comp_ctx`, `enum efa_cmd_status`, `function efa_com_set_dma_addr`, `function efa_com_reg_read32`, `function efa_com_admin_init_sq`, `function efa_com_admin_init_cq`, `function efa_com_admin_init_aenq`, `function efa_com_alloc_ctx_id`, `function efa_com_dealloc_ctx_id`, `function efa_com_get_comp_ctx_id`.
- Atlas domain: Driver Families / drivers/infiniband.
- 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.