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
137137 [RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_NAME]= { .type = NLA_NUL_STRING,
138138 .len = RDMA_NLDEV_ATTR_EMPTY_STRING },
139139 [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 },
140142 [RDMA_NLDEV_ATTR_RES_UNSAFE_GLOBAL_RKEY]= { .type = NLA_U32 },
141143 [RDMA_NLDEV_ATTR_RES_USECNT] = { .type = NLA_U64 },
142144 [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
164166 [RDMA_NLDEV_ATTR_STAT_HWCOUNTER_INDEX] = { .type = NLA_U32 },
165167 [RDMA_NLDEV_ATTR_STAT_HWCOUNTER_DYNAMIC] = { .type = NLA_U8 },
166168 [RDMA_NLDEV_SYS_ATTR_PRIVILEGED_QKEY_MODE] = { .type = NLA_U8 },
169+ [RDMA_NLDEV_ATTR_DRIVER_DETAILS] = { .type = NLA_U8 },
167170 };
168171
169172 static int put_driver_name_print_type(struct sk_buff *msg, const char *name,
@@ -399,7 +402,8 @@ err: · 229 unmodified lines
399402 return -EMSGSIZE;
400403 }
401404
402−static int fill_res_info(struct sk_buff *msg, struct ib_device *device)
405+static int fill_res_info(struct sk_buff *msg, struct ib_device *device,
406+ bool show_details)
403407 {
404408 static const char * const names[RDMA_RESTRACK_MAX] = {
405409 [RDMA_RESTRACK_PD] = "pd",
@@ -424,7 +428,7 @@ static int fill_res_info(struct sk_buff *msg, struct ib_device *device) · 18 unmodified lines
424428 for (i = 0; i < RDMA_RESTRACK_MAX; i++) {
425429 if (!names[i])
426430 continue;
427− curr = rdma_restrack_count(device, i);
431+ curr = rdma_restrack_count(device, i, show_details);
428432 ret = fill_res_info_entry(msg, names[i], curr);
429433 if (ret)
430434 goto err;
@@ -1305,6 +1309,7 @@ static int nldev_res_get_doit(struct sk_buff *skb, struct nlmsghdr *nlh, · 874 unmodified lines
13051309 struct netlink_ext_ack *extack)
13061310 {
13071311 struct nlattr *tb[RDMA_NLDEV_ATTR_MAX];
1312+ bool show_details = false;
13081313 struct ib_device *device;
13091314 struct sk_buff *msg;
13101315 u32 index;
@@ -1320,6 +1325,9 @@ static int nldev_res_get_doit(struct sk_buff *skb, struct nlmsghdr *nlh, · 9 unmodified lines
13201325 if (!device)
13211326 return -EINVAL;
13221327
1328+ if (tb[RDMA_NLDEV_ATTR_DRIVER_DETAILS])
1329+ show_details = nla_get_u8(tb[RDMA_NLDEV_ATTR_DRIVER_DETAILS]);
1330+
13231331 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
13241332 if (!msg) {
13251333 ret = -ENOMEM;
@@ -1334,7 +1342,7 @@ static int nldev_res_get_doit(struct sk_buff *skb, struct nlmsghdr *nlh, · 8 unmodified lines
13341342 goto err_free;
13351343 }
13361344
1337− ret = fill_res_info(msg, device);
1345+ ret = fill_res_info(msg, device, show_details);
13381346 if (ret)
13391347 goto err_free;
13401348
@@ -1364,7 +1372,7 @@ static int _nldev_res_get_dumpit(struct ib_device *device, · 23 unmodified lines
13641372 RDMA_NL_GET_TYPE(RDMA_NL_NLDEV, RDMA_NLDEV_CMD_RES_GET),
13651373 0, NLM_F_MULTI);
13661374
1367− if (!nlh || fill_res_info(skb, device)) {
1375+ if (!nlh || fill_res_info(skb, device, false)) {
13681376 nlmsg_cancel(skb, nlh);
13691377 goto out;
13701378 }
@@ -1534,6 +1542,7 @@ static int res_get_common_dumpit(struct sk_buff *skb, · 163 unmodified lines
15341542 struct rdma_restrack_entry *res;
15351543 struct rdma_restrack_root *rt;
15361544 int err, ret = 0, idx = 0;
1545+ bool show_details = false;
15371546 struct nlattr *table_attr;
15381547 struct nlattr *entry_attr;
15391548 struct ib_device *device;
@@ -1562,6 +1571,9 @@ static int res_get_common_dumpit(struct sk_buff *skb, · 22 unmodified lines
15621571 if (!device)
15631572 return -EINVAL;
15641573
1574+ if (tb[RDMA_NLDEV_ATTR_DRIVER_DETAILS])
1575+ show_details = nla_get_u8(tb[RDMA_NLDEV_ATTR_DRIVER_DETAILS]);
1576+
15651577 /*
15661578 * If no PORT_INDEX is supplied, we will return all QPs from that device
15671579 */
@@ -1599,6 +1611,9 @@ static int res_get_common_dumpit(struct sk_buff *skb, · 31 unmodified lines
15991611 * objects.
16001612 */
16011613 xa_for_each(&rt->xa, id, res) {
1614+ if (xa_get_mark(&rt->xa, res->id, RESTRACK_DD) && !show_details)
1615+ goto next;
1616+
16021617 if (idx < start || !rdma_restrack_get(res))
16031618 goto next;
16041619
drivers/infiniband/core/restrack.c+10−2
@@ -59,8 +59,10 @@ void rdma_restrack_clean(struct ib_device *dev) · 58 unmodified lines
5959 * rdma_restrack_count() - the current usage of specific object
6060 * @dev: IB device
6161 * @type: actual type of object to operate
62+ * @show_details: count driver specific objects
6263 */
63−int rdma_restrack_count(struct ib_device *dev, enum rdma_restrack_type type)
64+int rdma_restrack_count(struct ib_device *dev, enum rdma_restrack_type type,
65+ bool show_details)
6466 {
6567 struct rdma_restrack_root *rt = &dev->res[type];
6668 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
6870 u32 cnt = 0;
6971
7072 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;
7276 cnt++;
77+ }
7378 xa_unlock(&rt->xa);
7479 return cnt;
7580 }
@@ -198,6 +203,9 @@ void rdma_restrack_add(struct rdma_restrack_entry *res) · 122 unmodified lines
198203 ret = xa_insert(&rt->xa, res->id, res, GFP_KERNEL);
199204 if (ret)
200205 res->id = 0;
206+
207+ if (qp->qp_type >= IB_QPT_DRIVER)
208+ xa_set_mark(&rt->xa, res->id, RESTRACK_DD);
201209 } else if (res->type == RDMA_RESTRACK_COUNTER) {
202210 /* Special case to ensure that cntn points to right counter */
203211 struct rdma_counter *counter;
include/rdma/restrack.h+5−2
@@ -14,6 +14,9 @@ · 13 unmodified lines
1414 #include <uapi/rdma/rdma_netlink.h>
1515 #include <linux/xarray.h>
1616
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+
1720 struct ib_device;
1821 struct sk_buff;
1922
@@ -116,8 +119,8 @@ struct rdma_restrack_entry { · 96 unmodified lines
116119 u32 id;
117120 };
118121
119−int rdma_restrack_count(struct ib_device *dev,
120− enum rdma_restrack_type type);
122+int rdma_restrack_count(struct ib_device *dev, enum rdma_restrack_type type,
123+ bool show_details);
121124 /**
122125 * rdma_is_kernel_res() - check the owner of resource
123126 * @res: resource entry
include/uapi/rdma/rdma_netlink.h+6−0
@@ -558,6 +558,12 @@ enum rdma_nldev_attr { · 557 unmodified lines
558558
559559 RDMA_NLDEV_SYS_ATTR_PRIVILEGED_QKEY_MODE, /* u8 */
560560
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+
561567 /*
562568 * Always the end
563569 */