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.

Dependency Surface

Detected Declarations

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

Implementation Notes