Skip to content

Commit e198d65

Browse files
Wenpeng Liangrleon
authored andcommitted
RDMA/hns: Support QP's restrack ops for hns driver
The QP restrack attributes come from the queue information maintained by the driver. For example: $ rdma res show qp link hns_0 lqpn 41 -jp -dd [ { "ifindex": 4, "ifname": "hns_0", "port": 1, "lqpn": 41, "rqpn": 40, "type": "RC", "state": "RTR", "rq-psn": 12474738, "sq-psn": 0, "path-mig-state": "ARMED", "pdn": 9, "pid": 1523, "comm": "ib_send_bw" }, "drv_sq_wqe_cnt": 128, "drv_sq_max_gs": 1, "drv_rq_wqe_cnt": 512, "drv_rq_max_gs": 2, "drv_ext_sge_sge_cnt": 0 } Link: https://lore.kernel.org/r/20220822104455.2311053-5-liangwenpeng@huawei.com Signed-off-by: Wenpeng Liang <liangwenpeng@huawei.com> Signed-off-by: Leon Romanovsky <leon@kernel.org>
1 parent f2b070f commit e198d65

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

drivers/infiniband/hw/hns/hns_roce_device.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,7 @@ int hns_roce_init(struct hns_roce_dev *hr_dev);
12251225
void hns_roce_exit(struct hns_roce_dev *hr_dev);
12261226
int hns_roce_fill_res_cq_entry(struct sk_buff *msg, struct ib_cq *ib_cq);
12271227
int hns_roce_fill_res_cq_entry_raw(struct sk_buff *msg, struct ib_cq *ib_cq);
1228+
int hns_roce_fill_res_qp_entry(struct sk_buff *msg, struct ib_qp *ib_qp);
12281229
struct hns_user_mmap_entry *
12291230
hns_roce_user_mmap_entry_insert(struct ib_ucontext *ucontext, u64 address,
12301231
size_t length,

drivers/infiniband/hw/hns/hns_roce_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ static const struct ib_device_ops hns_roce_dev_xrcd_ops = {
568568
static const struct ib_device_ops hns_roce_dev_restrack_ops = {
569569
.fill_res_cq_entry = hns_roce_fill_res_cq_entry,
570570
.fill_res_cq_entry_raw = hns_roce_fill_res_cq_entry_raw,
571+
.fill_res_qp_entry = hns_roce_fill_res_qp_entry,
571572
};
572573

573574
static int hns_roce_register_device(struct hns_roce_dev *hr_dev)

drivers/infiniband/hw/hns/hns_roce_restrack.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,37 @@ int hns_roce_fill_res_cq_entry_raw(struct sk_buff *msg, struct ib_cq *ib_cq)
7878

7979
return ret;
8080
}
81+
82+
int hns_roce_fill_res_qp_entry(struct sk_buff *msg, struct ib_qp *ib_qp)
83+
{
84+
struct hns_roce_qp *hr_qp = to_hr_qp(ib_qp);
85+
struct nlattr *table_attr;
86+
87+
table_attr = nla_nest_start(msg, RDMA_NLDEV_ATTR_DRIVER);
88+
if (!table_attr)
89+
return -EMSGSIZE;
90+
91+
if (rdma_nl_put_driver_u32_hex(msg, "sq_wqe_cnt", hr_qp->sq.wqe_cnt))
92+
goto err;
93+
94+
if (rdma_nl_put_driver_u32_hex(msg, "sq_max_gs", hr_qp->sq.max_gs))
95+
goto err;
96+
97+
if (rdma_nl_put_driver_u32_hex(msg, "rq_wqe_cnt", hr_qp->rq.wqe_cnt))
98+
goto err;
99+
100+
if (rdma_nl_put_driver_u32_hex(msg, "rq_max_gs", hr_qp->rq.max_gs))
101+
goto err;
102+
103+
if (rdma_nl_put_driver_u32_hex(msg, "ext_sge_sge_cnt", hr_qp->sge.sge_cnt))
104+
goto err;
105+
106+
nla_nest_end(msg, table_attr);
107+
108+
return 0;
109+
110+
err:
111+
nla_nest_cancel(msg, table_attr);
112+
113+
return -EMSGSIZE;
114+
}

0 commit comments

Comments
 (0)