drivers/infiniband/hw/irdma/virtchnl.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/irdma/virtchnl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/irdma/virtchnl.c- Extension
.c- Size
- 16330 bytes
- Lines
- 619
- 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
osdep.hhmc.hdefs.htype.hprotos.hvirtchnl.hws.hi40iw_hw.hig3rdma_hw.h
Detected Declarations
struct vchnl_reg_map_elemstruct vchnl_regfld_map_elemfunction irdma_vchnl_req_verify_respfunction irdma_free_vchnl_req_msgfunction irdma_alloc_vchnl_req_msgfunction irdma_vchnl_req_send_syncfunction irdma_vchnl_req_get_reg_layoutfunction irdma_vchnl_req_add_vportfunction irdma_vchnl_req_del_vportfunction irdma_vchnl_req_aeq_vec_mapfunction irdma_vchnl_req_ceq_vec_mapfunction irdma_vchnl_req_get_verfunction irdma_vchnl_req_get_hmc_fcnfunction irdma_vchnl_req_put_hmc_fcnfunction irdma_vchnl_req_get_capsfunction irdma_vchnl_req_get_resp
Annotated Snippet
struct vchnl_reg_map_elem {
u16 reg_id;
u16 reg_idx;
bool pg_rel;
};
struct vchnl_regfld_map_elem {
u16 regfld_id;
u16 regfld_idx;
};
static struct vchnl_reg_map_elem vchnl_reg_map[] = {
{IRDMA_VCHNL_REG_ID_CQPTAIL, IRDMA_CQPTAIL, false},
{IRDMA_VCHNL_REG_ID_CQPDB, IRDMA_CQPDB, false},
{IRDMA_VCHNL_REG_ID_CCQPSTATUS, IRDMA_CCQPSTATUS, false},
{IRDMA_VCHNL_REG_ID_CCQPHIGH, IRDMA_CCQPHIGH, false},
{IRDMA_VCHNL_REG_ID_CCQPLOW, IRDMA_CCQPLOW, false},
{IRDMA_VCHNL_REG_ID_CQARM, IRDMA_CQARM, false},
{IRDMA_VCHNL_REG_ID_CQACK, IRDMA_CQACK, false},
{IRDMA_VCHNL_REG_ID_AEQALLOC, IRDMA_AEQALLOC, false},
{IRDMA_VCHNL_REG_ID_CQPERRCODES, IRDMA_CQPERRCODES, false},
{IRDMA_VCHNL_REG_ID_WQEALLOC, IRDMA_WQEALLOC, false},
{IRDMA_VCHNL_REG_ID_DB_ADDR_OFFSET, IRDMA_DB_ADDR_OFFSET, false },
{IRDMA_VCHNL_REG_ID_DYN_CTL, IRDMA_GLINT_DYN_CTL, false },
{IRDMA_VCHNL_REG_INV_ID, IRDMA_VCHNL_REG_INV_ID, false }
};
static struct vchnl_regfld_map_elem vchnl_regfld_map[] = {
{IRDMA_VCHNL_REGFLD_ID_CCQPSTATUS_CQP_OP_ERR, IRDMA_CCQPSTATUS_CCQP_ERR_M},
{IRDMA_VCHNL_REGFLD_ID_CCQPSTATUS_CCQP_DONE, IRDMA_CCQPSTATUS_CCQP_DONE_M},
{IRDMA_VCHNL_REGFLD_ID_CQPSQ_STAG_PDID, IRDMA_CQPSQ_STAG_PDID_M},
{IRDMA_VCHNL_REGFLD_ID_CQPSQ_CQ_CEQID, IRDMA_CQPSQ_CQ_CEQID_M},
{IRDMA_VCHNL_REGFLD_ID_CQPSQ_CQ_CQID, IRDMA_CQPSQ_CQ_CQID_M},
{IRDMA_VCHNL_REGFLD_ID_COMMIT_FPM_CQCNT, IRDMA_COMMIT_FPM_CQCNT_M},
{IRDMA_VCHNL_REGFLD_ID_UPESD_HMCN_ID, IRDMA_CQPSQ_UPESD_HMCFNID_M},
{IRDMA_VCHNL_REGFLD_INV_ID, IRDMA_VCHNL_REGFLD_INV_ID}
};
#define IRDMA_VCHNL_REG_COUNT ARRAY_SIZE(vchnl_reg_map)
#define IRDMA_VCHNL_REGFLD_COUNT ARRAY_SIZE(vchnl_regfld_map)
#define IRDMA_VCHNL_REGFLD_BUF_SIZE \
(IRDMA_VCHNL_REG_COUNT * sizeof(struct irdma_vchnl_reg_info) + \
IRDMA_VCHNL_REGFLD_COUNT * sizeof(struct irdma_vchnl_reg_field_info))
#define IRDMA_REGMAP_RESP_BUF_SIZE (IRDMA_VCHNL_RESP_MIN_SIZE + IRDMA_VCHNL_REGFLD_BUF_SIZE)
/**
* irdma_sc_vchnl_init - Initialize dev virtchannel and get hw_rev
* @dev: dev structure to update
* @info: virtchannel info parameters to fill into the dev structure
*/
int irdma_sc_vchnl_init(struct irdma_sc_dev *dev,
struct irdma_vchnl_init_info *info)
{
dev->vchnl_up = true;
dev->privileged = info->privileged;
dev->is_pf = info->is_pf;
dev->hw_attrs.uk_attrs.hw_rev = info->hw_rev;
if (!dev->privileged) {
int ret = irdma_vchnl_req_get_ver(dev, IRDMA_VCHNL_CHNL_VER_MAX,
&dev->vchnl_ver);
ibdev_dbg(to_ibdev(dev),
"DEV: Get Channel version ret = %d, version is %u\n",
ret, dev->vchnl_ver);
if (ret)
return ret;
ret = irdma_vchnl_req_get_caps(dev);
if (ret)
return ret;
dev->hw_attrs.uk_attrs.hw_rev = dev->vc_caps.hw_rev;
}
return 0;
}
/**
* irdma_vchnl_req_verify_resp - Verify requested response size
* @vchnl_req: vchnl message requested
* @resp_len: response length sent from vchnl peer
*/
static int irdma_vchnl_req_verify_resp(struct irdma_vchnl_req *vchnl_req,
u16 resp_len)
{
switch (vchnl_req->vchnl_msg->op_code) {
case IRDMA_VCHNL_OP_GET_VER:
case IRDMA_VCHNL_OP_GET_HMC_FCN:
Annotation
- Immediate include surface: `osdep.h`, `hmc.h`, `defs.h`, `type.h`, `protos.h`, `virtchnl.h`, `ws.h`, `i40iw_hw.h`.
- Detected declarations: `struct vchnl_reg_map_elem`, `struct vchnl_regfld_map_elem`, `function irdma_vchnl_req_verify_resp`, `function irdma_free_vchnl_req_msg`, `function irdma_alloc_vchnl_req_msg`, `function irdma_vchnl_req_send_sync`, `function irdma_vchnl_req_get_reg_layout`, `function irdma_vchnl_req_add_vport`, `function irdma_vchnl_req_del_vport`, `function irdma_vchnl_req_aeq_vec_map`.
- 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.