RDMA/hns: Support SRQ restrack ops for hns driver
The SRQ restrack attributes come from the context maintained by ROCEE. Example: $ rdma res show srq -jp -dd [ { "ifindex": 0, "ifname": "hns_0", "srqn": 0, "type": "BASIC", "lqpn": [ "14-15","22-23" ], "pdn": 2, "pid": 1224, "comm": "ib_send_bw",{ "drv_srqn": 0, "drv_wqe_cnt": 512, "drv_max_gs": 2, "drv_xrcdn": 0 } } ] $ rdma res show srq link hns_0 -jpr [ { "ifindex": 0, "ifname": "hns_0", "data": [ 149,0,0,0,0,0,0,0,0,0,0,0,119,101,120,99,0, 46,62,31,0,0,0,0,3,0,0,1,0,58,62,31,0,0,0,0, 30,159,15,0,0,0,64,5,0,0,0,0,0,0,0,0,0,0,0, 9,0,0,0,0,0,0,0,0 ] } ] Signed-off-by: wenglianfa <wenglianfa@huawei.com> Link: https://lore.kernel.org/r/20230918131110.3987498-4-huangjunxian6@hisilicon.com Signed-off-by: Leon Romanovsky <leon@kernel.org>
This commit is contained in:
parent
aebf8145e1
commit
58c49c097f
@ -908,6 +908,7 @@ struct hns_roce_hw {
|
||||
int (*query_cqc)(struct hns_roce_dev *hr_dev, u32 cqn, void *buffer);
|
||||
int (*query_qpc)(struct hns_roce_dev *hr_dev, u32 qpn, void *buffer);
|
||||
int (*query_mpt)(struct hns_roce_dev *hr_dev, u32 key, void *buffer);
|
||||
int (*query_srqc)(struct hns_roce_dev *hr_dev, u32 srqn, void *buffer);
|
||||
int (*query_hw_counter)(struct hns_roce_dev *hr_dev,
|
||||
u64 *stats, u32 port, int *hw_counters);
|
||||
const struct ib_device_ops *hns_roce_dev_ops;
|
||||
@ -1239,6 +1240,8 @@ int hns_roce_fill_res_qp_entry(struct sk_buff *msg, struct ib_qp *ib_qp);
|
||||
int hns_roce_fill_res_qp_entry_raw(struct sk_buff *msg, struct ib_qp *ib_qp);
|
||||
int hns_roce_fill_res_mr_entry(struct sk_buff *msg, struct ib_mr *ib_mr);
|
||||
int hns_roce_fill_res_mr_entry_raw(struct sk_buff *msg, struct ib_mr *ib_mr);
|
||||
int hns_roce_fill_res_srq_entry(struct sk_buff *msg, struct ib_srq *ib_srq);
|
||||
int hns_roce_fill_res_srq_entry_raw(struct sk_buff *msg, struct ib_srq *ib_srq);
|
||||
struct hns_user_mmap_entry *
|
||||
hns_roce_user_mmap_entry_insert(struct ib_ucontext *ucontext, u64 address,
|
||||
size_t length,
|
||||
|
@ -5272,6 +5272,30 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int hns_roce_v2_query_srqc(struct hns_roce_dev *hr_dev, u32 srqn,
|
||||
void *buffer)
|
||||
{
|
||||
struct hns_roce_srq_context *context;
|
||||
struct hns_roce_cmd_mailbox *mailbox;
|
||||
int ret;
|
||||
|
||||
mailbox = hns_roce_alloc_cmd_mailbox(hr_dev);
|
||||
if (IS_ERR(mailbox))
|
||||
return PTR_ERR(mailbox);
|
||||
|
||||
context = mailbox->buf;
|
||||
ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, HNS_ROCE_CMD_QUERY_SRQC,
|
||||
srqn);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
memcpy(buffer, context, sizeof(*context));
|
||||
|
||||
out:
|
||||
hns_roce_free_cmd_mailbox(hr_dev, mailbox);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static u8 get_qp_timeout_attr(struct hns_roce_dev *hr_dev,
|
||||
struct hns_roce_v2_qp_context *context)
|
||||
{
|
||||
@ -6632,6 +6656,7 @@ static const struct hns_roce_hw hns_roce_hw_v2 = {
|
||||
.query_cqc = hns_roce_v2_query_cqc,
|
||||
.query_qpc = hns_roce_v2_query_qpc,
|
||||
.query_mpt = hns_roce_v2_query_mpt,
|
||||
.query_srqc = hns_roce_v2_query_srqc,
|
||||
.query_hw_counter = hns_roce_hw_v2_query_counter,
|
||||
.hns_roce_dev_ops = &hns_roce_v2_dev_ops,
|
||||
.hns_roce_dev_srq_ops = &hns_roce_v2_dev_srq_ops,
|
||||
|
@ -681,6 +681,8 @@ static const struct ib_device_ops hns_roce_dev_restrack_ops = {
|
||||
.fill_res_qp_entry_raw = hns_roce_fill_res_qp_entry_raw,
|
||||
.fill_res_mr_entry = hns_roce_fill_res_mr_entry,
|
||||
.fill_res_mr_entry_raw = hns_roce_fill_res_mr_entry_raw,
|
||||
.fill_res_srq_entry = hns_roce_fill_res_srq_entry,
|
||||
.fill_res_srq_entry_raw = hns_roce_fill_res_srq_entry_raw,
|
||||
};
|
||||
|
||||
static int hns_roce_register_device(struct hns_roce_dev *hr_dev)
|
||||
|
@ -160,3 +160,52 @@ int hns_roce_fill_res_mr_entry_raw(struct sk_buff *msg, struct ib_mr *ib_mr)
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int hns_roce_fill_res_srq_entry(struct sk_buff *msg, struct ib_srq *ib_srq)
|
||||
{
|
||||
struct hns_roce_srq *hr_srq = to_hr_srq(ib_srq);
|
||||
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, "srqn", hr_srq->srqn))
|
||||
goto err;
|
||||
|
||||
if (rdma_nl_put_driver_u32_hex(msg, "wqe_cnt", hr_srq->wqe_cnt))
|
||||
goto err;
|
||||
|
||||
if (rdma_nl_put_driver_u32_hex(msg, "max_gs", hr_srq->max_gs))
|
||||
goto err;
|
||||
|
||||
if (rdma_nl_put_driver_u32_hex(msg, "xrcdn", hr_srq->xrcdn))
|
||||
goto err;
|
||||
|
||||
nla_nest_end(msg, table_attr);
|
||||
|
||||
return 0;
|
||||
|
||||
err:
|
||||
nla_nest_cancel(msg, table_attr);
|
||||
return -EMSGSIZE;
|
||||
}
|
||||
|
||||
int hns_roce_fill_res_srq_entry_raw(struct sk_buff *msg, struct ib_srq *ib_srq)
|
||||
{
|
||||
struct hns_roce_dev *hr_dev = to_hr_dev(ib_srq->device);
|
||||
struct hns_roce_srq *hr_srq = to_hr_srq(ib_srq);
|
||||
struct hns_roce_srq_context context;
|
||||
int ret;
|
||||
|
||||
if (!hr_dev->hw->query_srqc)
|
||||
return -EINVAL;
|
||||
|
||||
ret = hr_dev->hw->query_srqc(hr_dev, hr_srq->srqn, &context);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = nla_put(msg, RDMA_NLDEV_ATTR_RES_RAW, sizeof(context), &context);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user