drivers/infiniband/hw/bnxt_re/qplib_sp.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/bnxt_re/qplib_sp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/bnxt_re/qplib_sp.c- Extension
.c- Size
- 39215 bytes
- Lines
- 1151
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/interrupt.hlinux/spinlock.hlinux/sched.hlinux/pci.hroce_hsi.hqplib_res.hqplib_rcfw.hqplib_sp.hqplib_tlv.h
Detected Declarations
function bnxt_qplib_is_atomic_capfunction bnxt_qplib_query_versionfunction bnxt_qplib_get_dev_attrfunction bnxt_qplib_set_func_resourcesfunction bnxt_qplib_get_sgidfunction bnxt_qplib_del_sgidfunction bnxt_qplib_add_sgidfunction bnxt_qplib_create_ahfunction bnxt_qplib_destroy_ahfunction bnxt_qplib_free_mrwfunction bnxt_qplib_alloc_mrwfunction bnxt_qplib_dereg_mrwfunction bnxt_qplib_reg_mrfunction bnxt_qplib_alloc_fast_reg_page_listfunction bnxt_qplib_free_fast_reg_page_listfunction bnxt_qplib_get_roce_statsfunction bnxt_qplib_qext_statfunction bnxt_qplib_fill_cc_gen1function bnxt_qplib_modify_ccfunction bnxt_qplib_read_contextfunction bnxt_qplib_read_cc_gen1function bnxt_qplib_query_cc_paramfunction bnxt_qplib_create_flowfunction bnxt_qplib_destroy_flow
Annotated Snippet
if (sgid_tbl->hw_id[index] == 0xFFFF) {
dev_err(&res->pdev->dev,
"GID entry contains an invalid HW id\n");
return -EINVAL;
}
req.gid_index = cpu_to_le16(sgid_tbl->hw_id[index]);
bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, NULL, sizeof(req),
sizeof(resp), 0);
rc = bnxt_qplib_rcfw_send_message(rcfw, &msg);
if (rc)
return rc;
}
memcpy(&sgid_tbl->tbl[index].gid, &bnxt_qplib_gid_zero,
sizeof(bnxt_qplib_gid_zero));
sgid_tbl->tbl[index].vlan_id = 0xFFFF;
sgid_tbl->vlan[index] = 0;
sgid_tbl->active--;
dev_dbg(&res->pdev->dev,
"SGID deleted hw_id[0x%x] = 0x%x active = 0x%x\n",
index, sgid_tbl->hw_id[index], sgid_tbl->active);
sgid_tbl->hw_id[index] = (u16)-1;
/* unlock */
return 0;
}
int bnxt_qplib_add_sgid(struct bnxt_qplib_sgid_tbl *sgid_tbl,
struct bnxt_qplib_gid *gid, const u8 *smac,
u16 vlan_id, bool update, u32 *index,
bool is_ugid, u32 stats_ctx_id)
{
struct bnxt_qplib_res *res = to_bnxt_qplib(sgid_tbl,
struct bnxt_qplib_res,
sgid_tbl);
struct bnxt_qplib_rcfw *rcfw = res->rcfw;
int i, free_idx;
/* Do we need a sgid_lock here? */
if (sgid_tbl->active == sgid_tbl->max) {
dev_err(&res->pdev->dev, "SGID table is full\n");
return -ENOMEM;
}
free_idx = sgid_tbl->max;
for (i = 0; i < sgid_tbl->max; i++) {
if (!memcmp(&sgid_tbl->tbl[i], gid, sizeof(*gid)) &&
sgid_tbl->tbl[i].vlan_id == vlan_id) {
dev_dbg(&res->pdev->dev,
"SGID entry already exist in entry %d!\n", i);
*index = i;
return -EALREADY;
} else if (!memcmp(&sgid_tbl->tbl[i], &bnxt_qplib_gid_zero,
sizeof(bnxt_qplib_gid_zero)) &&
free_idx == sgid_tbl->max) {
free_idx = i;
}
}
if (free_idx == sgid_tbl->max) {
dev_err(&res->pdev->dev,
"SGID table is FULL but count is not MAX??\n");
return -ENOMEM;
}
if (update) {
struct creq_add_gid_resp resp = {};
struct bnxt_qplib_cmdqmsg msg = {};
struct cmdq_add_gid req = {};
int rc;
bnxt_qplib_rcfw_cmd_prep((struct cmdq_base *)&req,
CMDQ_BASE_OPCODE_ADD_GID,
sizeof(req));
req.gid[0] = cpu_to_be32(((u32 *)gid->data)[3]);
req.gid[1] = cpu_to_be32(((u32 *)gid->data)[2]);
req.gid[2] = cpu_to_be32(((u32 *)gid->data)[1]);
req.gid[3] = cpu_to_be32(((u32 *)gid->data)[0]);
/*
* driver should ensure that all RoCE traffic is always VLAN
* tagged if RoCE traffic is running on non-zero VLAN ID or
* RoCE traffic is running on non-zero Priority.
*/
if ((vlan_id != 0xFFFF) || res->prio) {
if (vlan_id != 0xFFFF)
req.vlan = cpu_to_le16
(vlan_id & CMDQ_ADD_GID_VLAN_VLAN_ID_MASK);
req.vlan |= cpu_to_le16
(CMDQ_ADD_GID_VLAN_TPID_TPID_8100 |
CMDQ_ADD_GID_VLAN_VLAN_EN);
}
/* MAC in network format */
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/spinlock.h`, `linux/sched.h`, `linux/pci.h`, `roce_hsi.h`, `qplib_res.h`, `qplib_rcfw.h`, `qplib_sp.h`.
- Detected declarations: `function bnxt_qplib_is_atomic_cap`, `function bnxt_qplib_query_version`, `function bnxt_qplib_get_dev_attr`, `function bnxt_qplib_set_func_resources`, `function bnxt_qplib_get_sgid`, `function bnxt_qplib_del_sgid`, `function bnxt_qplib_add_sgid`, `function bnxt_qplib_create_ah`, `function bnxt_qplib_destroy_ah`, `function bnxt_qplib_free_mrw`.
- 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.