mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-06 00:39:48 +00:00
RDMA/nldev: Add QP numbers to SRQ information
Add QP numbers that are associated with the SRQ to the SRQ information. The QPs are displayed in a range form. Sample output: $ rdma res show srq dev ibp8s0f0 srqn 0 type BASIC pdn 3 comm [ib_ipoib] dev ibp8s0f0 srqn 4 type BASIC lqpn 125-128,130-140 pdn 9 pid 3581 comm ibv_srq_pingpon dev ibp8s0f0 srqn 5 type BASIC lqpn 141-156 pdn 10 pid 3584 comm ibv_srq_pingpon dev ibp8s0f0 srqn 6 type BASIC lqpn 157-172 pdn 11 pid 3590 comm ibv_srq_pingpon dev ibp8s0f1 srqn 0 type BASIC pdn 3 comm [ib_ipoib] dev ibp8s0f1 srqn 1 type BASIC lqpn 329-344 pdn 4 pid 3586 comm ibv_srq_pingpon $ rdma res show srq lqpn 126-141 dev ibp8s0f0 srqn 4 type BASIC lqpn 126-128,130-140 pdn 9 pid 3581 comm ibv_srq_pingpon dev ibp8s0f0 srqn 5 type BASIC lqpn 141 pdn 10 pid 3584 comm ibv_srq_pingpon $ rdma res show srq lqpn 127 dev ibp8s0f0 srqn 4 type BASIC lqpn 127 pdn 9 pid 3581 comm ibv_srq_pingpon Link: https://lore.kernel.org/r/79a4bd4caec2248fd9583cccc26786af8e4414fc.1618753110.git.leonro@nvidia.com Signed-off-by: Neta Ostrovsky <netao@nvidia.com> Reviewed-by: Mark Zhang <markzhang@nvidia.com> Signed-off-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
This commit is contained in:
parent
391c6bd5ac
commit
c6c11ad3ab
2 changed files with 93 additions and 0 deletions
|
@ -135,6 +135,8 @@ static const struct nla_policy nldev_policy[RDMA_NLDEV_ATTR_MAX] = {
|
||||||
[RDMA_NLDEV_ATTR_RES_SRQ] = { .type = NLA_NESTED },
|
[RDMA_NLDEV_ATTR_RES_SRQ] = { .type = NLA_NESTED },
|
||||||
[RDMA_NLDEV_ATTR_RES_SRQN] = { .type = NLA_U32 },
|
[RDMA_NLDEV_ATTR_RES_SRQN] = { .type = NLA_U32 },
|
||||||
[RDMA_NLDEV_ATTR_RES_SRQ_ENTRY] = { .type = NLA_NESTED },
|
[RDMA_NLDEV_ATTR_RES_SRQ_ENTRY] = { .type = NLA_NESTED },
|
||||||
|
[RDMA_NLDEV_ATTR_MIN_RANGE] = { .type = NLA_U32 },
|
||||||
|
[RDMA_NLDEV_ATTR_MAX_RANGE] = { .type = NLA_U32 },
|
||||||
[RDMA_NLDEV_ATTR_SM_LID] = { .type = NLA_U32 },
|
[RDMA_NLDEV_ATTR_SM_LID] = { .type = NLA_U32 },
|
||||||
[RDMA_NLDEV_ATTR_SUBNET_PREFIX] = { .type = NLA_U64 },
|
[RDMA_NLDEV_ATTR_SUBNET_PREFIX] = { .type = NLA_U64 },
|
||||||
[RDMA_NLDEV_ATTR_STAT_AUTO_MODE_MASK] = { .type = NLA_U32 },
|
[RDMA_NLDEV_ATTR_STAT_AUTO_MODE_MASK] = { .type = NLA_U32 },
|
||||||
|
@ -723,6 +725,92 @@ static int fill_res_ctx_entry(struct sk_buff *msg, bool has_cap_net_admin,
|
||||||
return fill_res_name_pid(msg, res);
|
return fill_res_name_pid(msg, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int fill_res_range_qp_entry(struct sk_buff *msg, uint32_t min_range,
|
||||||
|
uint32_t max_range)
|
||||||
|
{
|
||||||
|
struct nlattr *entry_attr;
|
||||||
|
|
||||||
|
if (!min_range)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
entry_attr = nla_nest_start(msg, RDMA_NLDEV_ATTR_RES_QP_ENTRY);
|
||||||
|
if (!entry_attr)
|
||||||
|
return -EMSGSIZE;
|
||||||
|
|
||||||
|
if (min_range == max_range) {
|
||||||
|
if (nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_LQPN, min_range))
|
||||||
|
goto err;
|
||||||
|
} else {
|
||||||
|
if (nla_put_u32(msg, RDMA_NLDEV_ATTR_MIN_RANGE, min_range))
|
||||||
|
goto err;
|
||||||
|
if (nla_put_u32(msg, RDMA_NLDEV_ATTR_MAX_RANGE, max_range))
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
nla_nest_end(msg, entry_attr);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
err:
|
||||||
|
nla_nest_cancel(msg, entry_attr);
|
||||||
|
return -EMSGSIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int fill_res_srq_qps(struct sk_buff *msg, struct ib_srq *srq)
|
||||||
|
{
|
||||||
|
uint32_t min_range = 0, prev = 0;
|
||||||
|
struct rdma_restrack_entry *res;
|
||||||
|
struct rdma_restrack_root *rt;
|
||||||
|
struct nlattr *table_attr;
|
||||||
|
struct ib_qp *qp = NULL;
|
||||||
|
unsigned long id = 0;
|
||||||
|
|
||||||
|
table_attr = nla_nest_start(msg, RDMA_NLDEV_ATTR_RES_QP);
|
||||||
|
if (!table_attr)
|
||||||
|
return -EMSGSIZE;
|
||||||
|
|
||||||
|
rt = &srq->device->res[RDMA_RESTRACK_QP];
|
||||||
|
xa_lock(&rt->xa);
|
||||||
|
xa_for_each(&rt->xa, id, res) {
|
||||||
|
if (!rdma_restrack_get(res))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
qp = container_of(res, struct ib_qp, res);
|
||||||
|
if (!qp->srq || (qp->srq->res.id != srq->res.id)) {
|
||||||
|
rdma_restrack_put(res);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (qp->qp_num < prev)
|
||||||
|
/* qp_num should be ascending */
|
||||||
|
goto err_loop;
|
||||||
|
|
||||||
|
if (min_range == 0) {
|
||||||
|
min_range = qp->qp_num;
|
||||||
|
} else if (qp->qp_num > (prev + 1)) {
|
||||||
|
if (fill_res_range_qp_entry(msg, min_range, prev))
|
||||||
|
goto err_loop;
|
||||||
|
|
||||||
|
min_range = qp->qp_num;
|
||||||
|
}
|
||||||
|
prev = qp->qp_num;
|
||||||
|
rdma_restrack_put(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
xa_unlock(&rt->xa);
|
||||||
|
|
||||||
|
if (fill_res_range_qp_entry(msg, min_range, prev))
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
nla_nest_end(msg, table_attr);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
err_loop:
|
||||||
|
rdma_restrack_put(res);
|
||||||
|
xa_unlock(&rt->xa);
|
||||||
|
err:
|
||||||
|
nla_nest_cancel(msg, table_attr);
|
||||||
|
return -EMSGSIZE;
|
||||||
|
}
|
||||||
|
|
||||||
static int fill_res_srq_entry(struct sk_buff *msg, bool has_cap_net_admin,
|
static int fill_res_srq_entry(struct sk_buff *msg, bool has_cap_net_admin,
|
||||||
struct rdma_restrack_entry *res, uint32_t port)
|
struct rdma_restrack_entry *res, uint32_t port)
|
||||||
{
|
{
|
||||||
|
@ -743,6 +831,9 @@ static int fill_res_srq_entry(struct sk_buff *msg, bool has_cap_net_admin,
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fill_res_srq_qps(msg, srq))
|
||||||
|
goto err;
|
||||||
|
|
||||||
return fill_res_name_pid(msg, res);
|
return fill_res_name_pid(msg, res);
|
||||||
|
|
||||||
err:
|
err:
|
||||||
|
|
|
@ -544,6 +544,8 @@ enum rdma_nldev_attr {
|
||||||
RDMA_NLDEV_ATTR_RES_SRQ_ENTRY, /* nested table */
|
RDMA_NLDEV_ATTR_RES_SRQ_ENTRY, /* nested table */
|
||||||
RDMA_NLDEV_ATTR_RES_SRQN, /* u32 */
|
RDMA_NLDEV_ATTR_RES_SRQN, /* u32 */
|
||||||
|
|
||||||
|
RDMA_NLDEV_ATTR_MIN_RANGE, /* u32 */
|
||||||
|
RDMA_NLDEV_ATTR_MAX_RANGE, /* u32 */
|
||||||
/*
|
/*
|
||||||
* Always the end
|
* Always the end
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue