History

RDMA/core: Add an option to display driver-specific QPs in the rdmatool

Utilize the -dd flag (driver-specific details) in the rdmatool to view driver-specific QPs which are not exposed yet. Add the netlink attribute to mark request to convey driver details and use it to return QP subtype as a string. $ rdma resource show qp link ibp8s0f1 link ibp8s0f1/1 lqpn 360 type UD state RTS sq-psn 0 comm [mlx5_ib] link ibp8s0f1/1 lqpn 0 type SMI state RTS sq-psn 0 comm [ib_core] link ibp8s0f1/1 lqpn 1 type GSI state RTS sq-psn 0 comm [ib_core] $ rdma resource show qp link ibp8s0f1 -dd link ibp8s0f1/1 lqpn 360 type UD state RTS sq-psn 0 comm [mlx5_ib] link ibp8s0f1/1 lqpn 465 type DRIVER subtype REG_UMR state RTS sq-psn 0 comm [mlx5_ib] link ibp8s0f1/1 lqpn 0 type SMI state RTS sq-psn 0 comm [ib_core] link ibp8s0f1/1 lqpn 1 type GSI state RTS sq-psn 0 comm [ib_core] $ rdma resource show 0: ibp8s0f0: pd 3 cq 4 qp 3 cm_id 0 mr 0 ctx 0 srq 2 1: ibp8s0f1: pd 3 cq 4 qp 3 cm_id 0 mr 0 ctx 0 srq 2 $ rdma resource show -dd 0: ibp8s0f0: pd 3 cq 4 qp 4 cm_id 0 mr 0 ctx 0 srq 2 1: ibp8s0f1: pd 3 cq 4 qp 4 cm_id 0 mr 0 ctx 0 srq 2

Chiara Meiohas committed 2 years ago

Commit e18fa0b1 parent f847e844 files · +40 −8Browse files

Unified · Split

4 files
  1. drivers/infiniband/core/nldev.c +19 −4
  2. drivers/infiniband/core/restrack.c +10 −2
  3. include/rdma/restrack.h +5 −2
  4. include/uapi/rdma/rdma_netlink.h +6 −0
drivers/infiniband/core/nldev.c+19−4
@@ -137,6 +137,8 @@ static const struct nla_policy nldev_policy[RDMA_NLDEV_ATTR_MAX] = { · 136 unmodified lines
137 [RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_NAME]= { .type = NLA_NUL_STRING,137 [RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_NAME]= { .type = NLA_NUL_STRING,
138 .len = RDMA_NLDEV_ATTR_EMPTY_STRING },138 .len = RDMA_NLDEV_ATTR_EMPTY_STRING },
139 [RDMA_NLDEV_ATTR_RES_TYPE] = { .type = NLA_U8 },139 [RDMA_NLDEV_ATTR_RES_TYPE] = { .type = NLA_U8 },
140 [RDMA_NLDEV_ATTR_RES_SUBTYPE] = { .type = NLA_NUL_STRING,
141 .len = RDMA_NLDEV_ATTR_EMPTY_STRING },
140 [RDMA_NLDEV_ATTR_RES_UNSAFE_GLOBAL_RKEY]= { .type = NLA_U32 },142 [RDMA_NLDEV_ATTR_RES_UNSAFE_GLOBAL_RKEY]= { .type = NLA_U32 },
141 [RDMA_NLDEV_ATTR_RES_USECNT] = { .type = NLA_U64 },143 [RDMA_NLDEV_ATTR_RES_USECNT] = { .type = NLA_U64 },
142 [RDMA_NLDEV_ATTR_RES_SRQ] = { .type = NLA_NESTED },144 [RDMA_NLDEV_ATTR_RES_SRQ] = { .type = NLA_NESTED },
@@ -164,6 +166,7 @@ static const struct nla_policy nldev_policy[RDMA_NLDEV_ATTR_MAX] = { · 21 unmodified lines
164 [RDMA_NLDEV_ATTR_STAT_HWCOUNTER_INDEX] = { .type = NLA_U32 },166 [RDMA_NLDEV_ATTR_STAT_HWCOUNTER_INDEX] = { .type = NLA_U32 },
165 [RDMA_NLDEV_ATTR_STAT_HWCOUNTER_DYNAMIC] = { .type = NLA_U8 },167 [RDMA_NLDEV_ATTR_STAT_HWCOUNTER_DYNAMIC] = { .type = NLA_U8 },
166 [RDMA_NLDEV_SYS_ATTR_PRIVILEGED_QKEY_MODE] = { .type = NLA_U8 },168 [RDMA_NLDEV_SYS_ATTR_PRIVILEGED_QKEY_MODE] = { .type = NLA_U8 },
169 [RDMA_NLDEV_ATTR_DRIVER_DETAILS] = { .type = NLA_U8 },
167};170};
168 171
169static int put_driver_name_print_type(struct sk_buff *msg, const char *name,172static int put_driver_name_print_type(struct sk_buff *msg, const char *name,
@@ -399,7 +402,8 @@ err: · 229 unmodified lines
399 return -EMSGSIZE;402 return -EMSGSIZE;
400}403}
401 404
402static int fill_res_info(struct sk_buff *msg, struct ib_device *device)405static int fill_res_info(struct sk_buff *msg, struct ib_device *device,
406 bool show_details)
403{407{
404 static const char * const names[RDMA_RESTRACK_MAX] = {408 static const char * const names[RDMA_RESTRACK_MAX] = {
405 [RDMA_RESTRACK_PD] = "pd",409 [RDMA_RESTRACK_PD] = "pd",
@@ -424,7 +428,7 @@ static int fill_res_info(struct sk_buff *msg, struct ib_device *device) · 18 unmodified lines
424 for (i = 0; i < RDMA_RESTRACK_MAX; i++) {428 for (i = 0; i < RDMA_RESTRACK_MAX; i++) {
425 if (!names[i])429 if (!names[i])
426 continue;430 continue;
427 curr = rdma_restrack_count(device, i);431 curr = rdma_restrack_count(device, i, show_details);
428 ret = fill_res_info_entry(msg, names[i], curr);432 ret = fill_res_info_entry(msg, names[i], curr);
429 if (ret)433 if (ret)
430 goto err;434 goto err;
@@ -1305,6 +1309,7 @@ static int nldev_res_get_doit(struct sk_buff *skb, struct nlmsghdr *nlh, · 874 unmodified lines
1305 struct netlink_ext_ack *extack)1309 struct netlink_ext_ack *extack)
1306{1310{
1307 struct nlattr *tb[RDMA_NLDEV_ATTR_MAX];1311 struct nlattr *tb[RDMA_NLDEV_ATTR_MAX];
1312 bool show_details = false;
1308 struct ib_device *device;1313 struct ib_device *device;
1309 struct sk_buff *msg;1314 struct sk_buff *msg;
1310 u32 index;1315 u32 index;
@@ -1320,6 +1325,9 @@ static int nldev_res_get_doit(struct sk_buff *skb, struct nlmsghdr *nlh, · 9 unmodified lines
1320 if (!device)1325 if (!device)
1321 return -EINVAL;1326 return -EINVAL;
1322 1327
1328 if (tb[RDMA_NLDEV_ATTR_DRIVER_DETAILS])
1329 show_details = nla_get_u8(tb[RDMA_NLDEV_ATTR_DRIVER_DETAILS]);
1330
1323 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);1331 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
1324 if (!msg) {1332 if (!msg) {
1325 ret = -ENOMEM;1333 ret = -ENOMEM;
@@ -1334,7 +1342,7 @@ static int nldev_res_get_doit(struct sk_buff *skb, struct nlmsghdr *nlh, · 8 unmodified lines
1334 goto err_free;1342 goto err_free;
1335 }1343 }
1336 1344
1337 ret = fill_res_info(msg, device);1345 ret = fill_res_info(msg, device, show_details);
1338 if (ret)1346 if (ret)
1339 goto err_free;1347 goto err_free;
1340 1348
@@ -1364,7 +1372,7 @@ static int _nldev_res_get_dumpit(struct ib_device *device, · 23 unmodified lines
1364 RDMA_NL_GET_TYPE(RDMA_NL_NLDEV, RDMA_NLDEV_CMD_RES_GET),1372 RDMA_NL_GET_TYPE(RDMA_NL_NLDEV, RDMA_NLDEV_CMD_RES_GET),
1365 0, NLM_F_MULTI);1373 0, NLM_F_MULTI);
1366 1374
1367 if (!nlh || fill_res_info(skb, device)) {1375 if (!nlh || fill_res_info(skb, device, false)) {
1368 nlmsg_cancel(skb, nlh);1376 nlmsg_cancel(skb, nlh);
1369 goto out;1377 goto out;
1370 }1378 }
@@ -1534,6 +1542,7 @@ static int res_get_common_dumpit(struct sk_buff *skb, · 163 unmodified lines
1534 struct rdma_restrack_entry *res;1542 struct rdma_restrack_entry *res;
1535 struct rdma_restrack_root *rt;1543 struct rdma_restrack_root *rt;
1536 int err, ret = 0, idx = 0;1544 int err, ret = 0, idx = 0;
1545 bool show_details = false;
1537 struct nlattr *table_attr;1546 struct nlattr *table_attr;
1538 struct nlattr *entry_attr;1547 struct nlattr *entry_attr;
1539 struct ib_device *device;1548 struct ib_device *device;
@@ -1562,6 +1571,9 @@ static int res_get_common_dumpit(struct sk_buff *skb, · 22 unmodified lines
1562 if (!device)1571 if (!device)
1563 return -EINVAL;1572 return -EINVAL;
1564 1573
1574 if (tb[RDMA_NLDEV_ATTR_DRIVER_DETAILS])
1575 show_details = nla_get_u8(tb[RDMA_NLDEV_ATTR_DRIVER_DETAILS]);
1576
1565 /*1577 /*
1566 * If no PORT_INDEX is supplied, we will return all QPs from that device1578 * If no PORT_INDEX is supplied, we will return all QPs from that device
1567 */1579 */
@@ -1599,6 +1611,9 @@ static int res_get_common_dumpit(struct sk_buff *skb, · 31 unmodified lines
1599 * objects.1611 * objects.
1600 */1612 */
1601 xa_for_each(&rt->xa, id, res) {1613 xa_for_each(&rt->xa, id, res) {
1614 if (xa_get_mark(&rt->xa, res->id, RESTRACK_DD) && !show_details)
1615 goto next;
1616
1602 if (idx < start || !rdma_restrack_get(res))1617 if (idx < start || !rdma_restrack_get(res))
1603 goto next;1618 goto next;
1604 1619
drivers/infiniband/core/restrack.c+10−2
@@ -59,8 +59,10 @@ void rdma_restrack_clean(struct ib_device *dev) · 58 unmodified lines
59 * rdma_restrack_count() - the current usage of specific object59 * rdma_restrack_count() - the current usage of specific object
60 * @dev: IB device60 * @dev: IB device
61 * @type: actual type of object to operate61 * @type: actual type of object to operate
62 * @show_details: count driver specific objects
62 */63 */
63int rdma_restrack_count(struct ib_device *dev, enum rdma_restrack_type type)64int rdma_restrack_count(struct ib_device *dev, enum rdma_restrack_type type,
65 bool show_details)
64{66{
65 struct rdma_restrack_root *rt = &dev->res[type];67 struct rdma_restrack_root *rt = &dev->res[type];
66 struct rdma_restrack_entry *e;68 struct rdma_restrack_entry *e;
@@ -68,8 +70,11 @@ int rdma_restrack_count(struct ib_device *dev, enum rdma_restrack_type type) · 1 unmodified line
68 u32 cnt = 0;70 u32 cnt = 0;
69 71
70 xa_lock(&rt->xa);72 xa_lock(&rt->xa);
71 xas_for_each(&xas, e, U32_MAX)73 xas_for_each(&xas, e, U32_MAX) {
74 if (xa_get_mark(&rt->xa, e->id, RESTRACK_DD) && !show_details)
75 continue;
72 cnt++;76 cnt++;
77 }
73 xa_unlock(&rt->xa);78 xa_unlock(&rt->xa);
74 return cnt;79 return cnt;
75}80}
@@ -198,6 +203,9 @@ void rdma_restrack_add(struct rdma_restrack_entry *res) · 122 unmodified lines
198 ret = xa_insert(&rt->xa, res->id, res, GFP_KERNEL);203 ret = xa_insert(&rt->xa, res->id, res, GFP_KERNEL);
199 if (ret)204 if (ret)
200 res->id = 0;205 res->id = 0;
206
207 if (qp->qp_type >= IB_QPT_DRIVER)
208 xa_set_mark(&rt->xa, res->id, RESTRACK_DD);
201 } else if (res->type == RDMA_RESTRACK_COUNTER) {209 } else if (res->type == RDMA_RESTRACK_COUNTER) {
202 /* Special case to ensure that cntn points to right counter */210 /* Special case to ensure that cntn points to right counter */
203 struct rdma_counter *counter;211 struct rdma_counter *counter;
include/rdma/restrack.h+5−2
@@ -14,6 +14,9 @@ · 13 unmodified lines
14#include <uapi/rdma/rdma_netlink.h>14#include <uapi/rdma/rdma_netlink.h>
15#include <linux/xarray.h>15#include <linux/xarray.h>
16 16
17/* Mark entry as containing driver specific details, it is used to provide QP subtype for now */
18#define RESTRACK_DD XA_MARK_1
19
17struct ib_device;20struct ib_device;
18struct sk_buff;21struct sk_buff;
19 22
@@ -116,8 +119,8 @@ struct rdma_restrack_entry { · 96 unmodified lines
116 u32 id;119 u32 id;
117};120};
118 121
119int rdma_restrack_count(struct ib_device *dev,122int rdma_restrack_count(struct ib_device *dev, enum rdma_restrack_type type,
120 enum rdma_restrack_type type);123 bool show_details);
121/**124/**
122 * rdma_is_kernel_res() - check the owner of resource125 * rdma_is_kernel_res() - check the owner of resource
123 * @res: resource entry126 * @res: resource entry
include/uapi/rdma/rdma_netlink.h+6−0
@@ -558,6 +558,12 @@ enum rdma_nldev_attr { · 557 unmodified lines
558 558
559 RDMA_NLDEV_SYS_ATTR_PRIVILEGED_QKEY_MODE, /* u8 */559 RDMA_NLDEV_SYS_ATTR_PRIVILEGED_QKEY_MODE, /* u8 */
560 560
561 RDMA_NLDEV_ATTR_DRIVER_DETAILS, /* u8 */
562 /*
563 * QP subtype string, used for driver QPs
564 */
565 RDMA_NLDEV_ATTR_RES_SUBTYPE, /* string */
566
561 /*567 /*
562 * Always the end568 * Always the end
563 */569 */