drivers/infiniband/hw/hns/hns_roce_restrack.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/hns/hns_roce_restrack.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/hns/hns_roce_restrack.c- Extension
.c- Size
- 5471 bytes
- Lines
- 235
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
rdma/rdma_cm.hrdma/restrack.huapi/rdma/rdma_netlink.hhns_roce_common.hhns_roce_device.hhns_roce_hw_v2.h
Detected Declarations
struct hns_roce_full_qp_ctxfunction hns_roce_fill_res_cq_entryfunction hns_roce_fill_res_cq_entry_rawfunction hns_roce_fill_res_qp_entryfunction hns_roce_fill_res_qp_entry_rawfunction hns_roce_fill_res_mr_entryfunction hns_roce_fill_res_mr_entry_rawfunction hns_roce_fill_res_srq_entryfunction hns_roce_fill_res_srq_entry_raw
Annotated Snippet
struct hns_roce_full_qp_ctx {
struct hns_roce_v2_qp_context qpc;
struct hns_roce_v2_scc_context sccc;
} context = {};
u32 sccn = hr_qp->qpn;
int ret;
if (!hr_dev->hw->query_qpc)
return -EINVAL;
ret = hr_dev->hw->query_qpc(hr_dev, hr_qp->qpn, &context.qpc);
if (ret)
return ret;
/* If SCC is disabled or the query fails, the queried SCCC will
* be all 0.
*/
if (!(hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_QP_FLOW_CTRL) ||
!hr_dev->hw->query_sccc)
goto out;
if (hr_qp->cong_type == CONG_TYPE_DIP) {
if (!hr_qp->dip)
goto out;
sccn = hr_qp->dip->dip_idx;
}
ret = hr_dev->hw->query_sccc(hr_dev, sccn, &context.sccc);
if (ret)
ibdev_warn_ratelimited(&hr_dev->ib_dev,
"failed to query SCCC, ret = %d.\n",
ret);
out:
ret = nla_put(msg, RDMA_NLDEV_ATTR_RES_RAW, sizeof(context), &context);
return ret;
}
int hns_roce_fill_res_mr_entry(struct sk_buff *msg, struct ib_mr *ib_mr)
{
struct hns_roce_mr *hr_mr = to_hr_mr(ib_mr);
struct nlattr *table_attr;
table_attr = nla_nest_start(msg, RDMA_NLDEV_ATTR_DRIVER);
if (!table_attr)
return -EMSGSIZE;
if (rdma_nl_put_driver_u32_hex(msg, "pbl_hop_num", hr_mr->pbl_hop_num))
goto err;
if (rdma_nl_put_driver_u32_hex(msg, "ba_pg_shift",
hr_mr->pbl_mtr.hem_cfg.ba_pg_shift))
goto err;
if (rdma_nl_put_driver_u32_hex(msg, "buf_pg_shift",
hr_mr->pbl_mtr.hem_cfg.buf_pg_shift))
goto err;
nla_nest_end(msg, table_attr);
return 0;
err:
nla_nest_cancel(msg, table_attr);
return -EMSGSIZE;
}
int hns_roce_fill_res_mr_entry_raw(struct sk_buff *msg, struct ib_mr *ib_mr)
{
struct hns_roce_dev *hr_dev = to_hr_dev(ib_mr->device);
struct hns_roce_mr *hr_mr = to_hr_mr(ib_mr);
struct hns_roce_v2_mpt_entry context;
int ret;
if (!hr_dev->hw->query_mpt)
return -EINVAL;
ret = hr_dev->hw->query_mpt(hr_dev, hr_mr->key, &context);
if (ret)
return ret;
ret = nla_put(msg, RDMA_NLDEV_ATTR_RES_RAW, sizeof(context), &context);
return ret;
}
int hns_roce_fill_res_srq_entry(struct sk_buff *msg, struct ib_srq *ib_srq)
{
Annotation
- Immediate include surface: `rdma/rdma_cm.h`, `rdma/restrack.h`, `uapi/rdma/rdma_netlink.h`, `hns_roce_common.h`, `hns_roce_device.h`, `hns_roce_hw_v2.h`.
- Detected declarations: `struct hns_roce_full_qp_ctx`, `function hns_roce_fill_res_cq_entry`, `function hns_roce_fill_res_cq_entry_raw`, `function hns_roce_fill_res_qp_entry`, `function hns_roce_fill_res_qp_entry_raw`, `function hns_roce_fill_res_mr_entry`, `function hns_roce_fill_res_mr_entry_raw`, `function hns_roce_fill_res_srq_entry`, `function hns_roce_fill_res_srq_entry_raw`.
- Atlas domain: Driver Families / drivers/infiniband.
- Implementation status: source implementation candidate.
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.