drivers/infiniband/hw/bnxt_re/ib_verbs.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/bnxt_re/ib_verbs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/bnxt_re/ib_verbs.c- Extension
.c- Size
- 140394 bytes
- Lines
- 5057
- 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/interrupt.hlinux/types.hlinux/pci.hlinux/netdevice.hlinux/if_ether.hnet/addrconf.hrdma/ib_verbs.hrdma/ib_user_verbs.hrdma/ib_umem.hrdma/ib_addr.hrdma/ib_mad.hrdma/ib_cache.hrdma/ib_pma.hrdma/uverbs_ioctl.hlinux/hashtable.hroce_hsi.hqplib_res.hqplib_sp.hqplib_fp.hqplib_rcfw.hbnxt_re.hib_verbs.hdebugfs.hrdma/uverbs_types.hrdma/uverbs_std_types.hrdma/ib_user_ioctl_cmds.hrdma/uverbs_named_ioctl.hrdma/bnxt_re-abi.h
Detected Declarations
function __from_ib_access_flagsfunction __to_ib_access_flagsfunction __qp_access_flags_from_ibfunction __qp_access_flags_to_ibfunction bnxt_re_check_and_set_relaxed_orderingfunction bnxt_re_build_sglfunction bnxt_re_query_devicefunction bnxt_re_modify_devicefunction bnxt_re_query_portfunction bnxt_re_get_port_immutablefunction bnxt_re_query_fw_strfunction bnxt_re_query_pkeyfunction bnxt_re_query_gidfunction bnxt_re_del_gidfunction bnxt_re_add_gidfunction bnxt_re_get_link_layerfunction bnxt_re_create_fence_wqefunction bnxt_re_bind_fence_mwfunction bnxt_re_destroy_fence_mrfunction bnxt_re_create_fence_mrfunction bnxt_re_mmap_entry_insertfunction bnxt_re_dealloc_pdfunction bnxt_re_alloc_pdfunction bnxt_re_destroy_ahfunction bnxt_re_stack_to_dev_nw_typefunction bnxt_re_create_ahfunction bnxt_re_query_ahfunction bnxt_re_lock_cqsfunction bnxt_re_unlock_cqsfunction bnxt_re_destroy_gsi_sqpfunction bnxt_re_del_unique_gidfunction bnxt_re_qp_free_umemfunction bnxt_re_destroy_qpfunction __from_ib_qp_typefunction bnxt_re_setup_rwqe_sizefunction bnxt_re_get_wqe_sizefunction bnxt_re_setup_swqe_sizefunction bnxt_re_setup_sginfofunction bnxt_re_get_psn_bytesfunction bnxt_re_init_user_qpfunction bnxt_re_qp_alloc_init_xrrqfunction bnxt_re_setup_qp_hwqsfunction bnxt_re_init_rq_attrfunction bnxt_re_adjust_gsi_rq_attrfunction bnxt_re_init_sq_attrfunction bnxt_re_adjust_gsi_sq_attrfunction bnxt_re_init_qp_typefunction bnxt_re_qp_calculate_msn_psn_size
Annotated Snippet
if (!ctx->refcnt) {
rc = bnxt_qplib_del_sgid(sgid_tbl, gid_to_del,
vlan_id, true);
if (rc) {
ibdev_err(&rdev->ibdev,
"Failed to remove GID: %#x", rc);
} else {
ctx_tbl = sgid_tbl->ctx;
ctx_tbl[ctx->idx] = NULL;
kfree(ctx);
}
}
} else {
return -EINVAL;
}
return rc;
}
int bnxt_re_add_gid(const struct ib_gid_attr *attr, void **context)
{
int rc;
u32 tbl_idx = 0;
u16 vlan_id = 0xFFFF;
struct bnxt_re_gid_ctx *ctx, **ctx_tbl;
struct bnxt_re_dev *rdev = to_bnxt_re_dev(attr->device, ibdev);
struct bnxt_qplib_sgid_tbl *sgid_tbl = &rdev->qplib_res.sgid_tbl;
rc = rdma_read_gid_l2_fields(attr, &vlan_id, NULL);
if (rc)
return rc;
rc = bnxt_qplib_add_sgid(sgid_tbl, (struct bnxt_qplib_gid *)&attr->gid,
rdev->qplib_res.netdev->dev_addr,
vlan_id, true, &tbl_idx, false, 0);
if (rc == -EALREADY) {
ctx_tbl = sgid_tbl->ctx;
ctx_tbl[tbl_idx]->refcnt++;
*context = ctx_tbl[tbl_idx];
return 0;
}
if (rc < 0) {
ibdev_err(&rdev->ibdev, "Failed to add GID: %#x", rc);
return rc;
}
ctx = kmalloc_obj(*ctx);
if (!ctx)
return -ENOMEM;
ctx_tbl = sgid_tbl->ctx;
ctx->idx = tbl_idx;
ctx->refcnt = 1;
ctx_tbl[tbl_idx] = ctx;
*context = ctx;
return rc;
}
enum rdma_link_layer bnxt_re_get_link_layer(struct ib_device *ibdev,
u32 port_num)
{
return IB_LINK_LAYER_ETHERNET;
}
#define BNXT_RE_FENCE_PBL_SIZE DIV_ROUND_UP(BNXT_RE_FENCE_BYTES, PAGE_SIZE)
static void bnxt_re_create_fence_wqe(struct bnxt_re_pd *pd)
{
struct bnxt_re_fence_data *fence = &pd->fence;
struct ib_mr *ib_mr = &fence->mr->ib_mr;
struct bnxt_qplib_swqe *wqe = &fence->bind_wqe;
struct bnxt_re_dev *rdev = pd->rdev;
if (bnxt_qplib_is_chip_gen_p5_p7(rdev->chip_ctx))
return;
memset(wqe, 0, sizeof(*wqe));
wqe->type = BNXT_QPLIB_SWQE_TYPE_BIND_MW;
wqe->wr_id = BNXT_QPLIB_FENCE_WRID;
wqe->flags |= BNXT_QPLIB_SWQE_FLAGS_SIGNAL_COMP;
wqe->flags |= BNXT_QPLIB_SWQE_FLAGS_UC_FENCE;
wqe->bind.zero_based = false;
wqe->bind.parent_l_key = ib_mr->lkey;
wqe->bind.va = (u64)(unsigned long)fence->va;
wqe->bind.length = fence->size;
wqe->bind.access_cntl = __from_ib_access_flags(IB_ACCESS_REMOTE_READ);
wqe->bind.mw_type = SQ_BIND_MW_TYPE_TYPE1;
/* Save the initial rkey in fence structure for now;
* wqe->bind.r_key will be set at (re)bind time.
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/types.h`, `linux/pci.h`, `linux/netdevice.h`, `linux/if_ether.h`, `net/addrconf.h`, `rdma/ib_verbs.h`, `rdma/ib_user_verbs.h`.
- Detected declarations: `function __from_ib_access_flags`, `function __to_ib_access_flags`, `function __qp_access_flags_from_ib`, `function __qp_access_flags_to_ib`, `function bnxt_re_check_and_set_relaxed_ordering`, `function bnxt_re_build_sgl`, `function bnxt_re_query_device`, `function bnxt_re_modify_device`, `function bnxt_re_query_port`, `function bnxt_re_get_port_immutable`.
- 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.