History

RDMA/core: Add support to optional-counters binding configuration

Whenever a new counter is created, save inside it the user requested configuration for optional-counters binding, for manual configuration it is requested directly by the user and for the automatic configuration it depends on if the automatic binding was enabled with or without optional-counters binding. This argument will later be used by the driver to determine if to bind the optional-counters as well or not when trying to bind this counter to a QP. It indicates that when binding counters to a QP we also want the currently enabled link optional-counters to be bound as well.

Patrisious Haddad committed 1 year ago

Commit da371101 parent 7e53b314 files · +41 −12Browse files

Unified · Split

4 files
  1. drivers/infiniband/core/counters.c +19 −9
  2. drivers/infiniband/core/nldev.c +16 −2
  3. include/rdma/rdma_counter.h +4 −1
  4. include/uapi/rdma/rdma_netlink.h +2 −0
drivers/infiniband/core/counters.c+19−9
@@ -12,7 +12,8 @@ · 11 unmodified lines
1212
1313 static int __counter_set_mode(struct rdma_port_counter *port_counter,
1414 enum rdma_nl_counter_mode new_mode,
15− enum rdma_nl_counter_mask new_mask)
15+ enum rdma_nl_counter_mask new_mask,
16+ bool bind_opcnt)
1617 {
1718 if (new_mode == RDMA_COUNTER_MODE_AUTO) {
1819 if (new_mask & (~ALL_AUTO_MODE_MASKS))
@@ -23,6 +24,7 @@ static int __counter_set_mode(struct rdma_port_counter *port_counter, · 4 unmodified lines
2324
2425 port_counter->mode.mode = new_mode;
2526 port_counter->mode.mask = new_mask;
27+ port_counter->mode.bind_opcnt = bind_opcnt;
2628 return 0;
2729 }
2830
@@ -41,6 +43,7 @@ static int __counter_set_mode(struct rdma_port_counter *port_counter, · 12 unmodified lines
4143 */
4244 int rdma_counter_set_auto_mode(struct ib_device *dev, u32 port,
4345 enum rdma_nl_counter_mask mask,
46+ bool bind_opcnt,
4447 struct netlink_ext_ack *extack)
4548 {
4649 struct rdma_port_counter *port_counter;
@@ -59,12 +62,13 @@ int rdma_counter_set_auto_mode(struct ib_device *dev, u32 port, · 12 unmodified lines
5962 RDMA_COUNTER_MODE_NONE;
6063
6164 if (port_counter->mode.mode == mode &&
62− port_counter->mode.mask == mask) {
65+ port_counter->mode.mask == mask &&
66+ port_counter->mode.bind_opcnt == bind_opcnt) {
6367 ret = 0;
6468 goto out;
6569 }
6670
67− ret = __counter_set_mode(port_counter, mode, mask);
71+ ret = __counter_set_mode(port_counter, mode, mask, bind_opcnt);
6872
6973 out:
7074 mutex_unlock(&port_counter->lock);
@@ -140,7 +144,8 @@ out: · 69 unmodified lines
140144
141145 static struct rdma_counter *alloc_and_bind(struct ib_device *dev, u32 port,
142146 struct ib_qp *qp,
143− enum rdma_nl_counter_mode mode)
147+ enum rdma_nl_counter_mode mode,
148+ bool bind_opcnt)
144149 {
145150 struct rdma_port_counter *port_counter;
146151 struct rdma_counter *counter;
@@ -168,7 +173,7 @@ static struct rdma_counter *alloc_and_bind(struct ib_device *dev, u32 port, · 21 unmodified lines
168173 switch (mode) {
169174 case RDMA_COUNTER_MODE_MANUAL:
170175 ret = __counter_set_mode(port_counter, RDMA_COUNTER_MODE_MANUAL,
171− 0);
176+ 0, bind_opcnt);
172177 if (ret) {
173178 mutex_unlock(&port_counter->lock);
174179 goto err_mode;
@@ -187,6 +192,7 @@ static struct rdma_counter *alloc_and_bind(struct ib_device *dev, u32 port, · 12 unmodified lines
187192 mutex_unlock(&port_counter->lock);
188193
189194 counter->mode.mode = mode;
195+ counter->mode.bind_opcnt = bind_opcnt;
190196 kref_init(&counter->kref);
191197 mutex_init(&counter->lock);
192198
@@ -215,7 +221,8 @@ static void rdma_counter_free(struct rdma_counter *counter) · 22 unmodified lines
215221 port_counter->num_counters--;
216222 if (!port_counter->num_counters &&
217223 (port_counter->mode.mode == RDMA_COUNTER_MODE_MANUAL))
218− __counter_set_mode(port_counter, RDMA_COUNTER_MODE_NONE, 0);
224+ __counter_set_mode(port_counter, RDMA_COUNTER_MODE_NONE, 0,
225+ false);
219226
220227 mutex_unlock(&port_counter->lock);
221228
@@ -347,7 +354,8 @@ int rdma_counter_bind_qp_auto(struct ib_qp *qp, u32 port) · 125 unmodified lines
347354 return ret;
348355 }
349356 } else {
350− counter = alloc_and_bind(dev, port, qp, RDMA_COUNTER_MODE_AUTO);
357+ counter = alloc_and_bind(dev, port, qp, RDMA_COUNTER_MODE_AUTO,
358+ port_counter->mode.bind_opcnt);
351359 if (!counter)
352360 return -ENOMEM;
353361 }
@@ -560,7 +568,7 @@ int rdma_counter_bind_qpn_alloc(struct ib_device *dev, u32 port, · 206 unmodified lines
560568 goto err;
561569 }
562570
563− counter = alloc_and_bind(dev, port, qp, RDMA_COUNTER_MODE_MANUAL);
571+ counter = alloc_and_bind(dev, port, qp, RDMA_COUNTER_MODE_MANUAL, true);
564572 if (!counter) {
565573 ret = -ENOMEM;
566574 goto err;
@@ -615,13 +623,15 @@ out: · 48 unmodified lines
615623
616624 int rdma_counter_get_mode(struct ib_device *dev, u32 port,
617625 enum rdma_nl_counter_mode *mode,
618− enum rdma_nl_counter_mask *mask)
626+ enum rdma_nl_counter_mask *mask,
627+ bool *opcnt)
619628 {
620629 struct rdma_port_counter *port_counter;
621630
622631 port_counter = &dev->port_data[port].port_counter;
623632 *mode = port_counter->mode.mode;
624633 *mask = port_counter->mode.mask;
634+ *opcnt = port_counter->mode.bind_opcnt;
625635
626636 return 0;
627637 }
drivers/infiniband/core/nldev.c+16−2
@@ -171,6 +171,7 @@ static const struct nla_policy nldev_policy[RDMA_NLDEV_ATTR_MAX] = { · 170 unmodified lines
171171 [RDMA_NLDEV_ATTR_PARENT_NAME] = { .type = NLA_NUL_STRING },
172172 [RDMA_NLDEV_ATTR_NAME_ASSIGN_TYPE] = { .type = NLA_U8 },
173173 [RDMA_NLDEV_ATTR_EVENT_TYPE] = { .type = NLA_U8 },
174+ [RDMA_NLDEV_ATTR_STAT_OPCOUNTER_ENABLED] = { .type = NLA_U8 },
174175 };
175176
176177 static int put_driver_name_print_type(struct sk_buff *msg, const char *name,
@@ -2028,6 +2029,7 @@ static int nldev_stat_set_mode_doit(struct sk_buff *msg, · 1851 unmodified lines
20282029 struct ib_device *device, u32 port)
20292030 {
20302031 u32 mode, mask = 0, qpn, cntn = 0;
2032+ bool opcnt = false;
20312033 int ret;
20322034
20332035 /* Currently only counter for QP is supported */
@@ -2035,12 +2037,17 @@ static int nldev_stat_set_mode_doit(struct sk_buff *msg, · 1 unmodified line
20352037 nla_get_u32(tb[RDMA_NLDEV_ATTR_STAT_RES]) != RDMA_NLDEV_ATTR_RES_QP)
20362038 return -EINVAL;
20372039
2040+ if (tb[RDMA_NLDEV_ATTR_STAT_OPCOUNTER_ENABLED])
2041+ opcnt = !!nla_get_u8(
2042+ tb[RDMA_NLDEV_ATTR_STAT_OPCOUNTER_ENABLED]);
2043+
20382044 mode = nla_get_u32(tb[RDMA_NLDEV_ATTR_STAT_MODE]);
20392045 if (mode == RDMA_COUNTER_MODE_AUTO) {
20402046 if (tb[RDMA_NLDEV_ATTR_STAT_AUTO_MODE_MASK])
20412047 mask = nla_get_u32(
20422048 tb[RDMA_NLDEV_ATTR_STAT_AUTO_MODE_MASK]);
2043− return rdma_counter_set_auto_mode(device, port, mask, extack);
2049+ return rdma_counter_set_auto_mode(device, port, mask, opcnt,
2050+ extack);
20442051 }
20452052
20462053 if (!tb[RDMA_NLDEV_ATTR_RES_LQPN])
@@ -2358,6 +2365,7 @@ static int stat_get_doit_qp(struct sk_buff *skb, struct nlmsghdr *nlh, · 311 unmodified lines
23582365 struct ib_device *device;
23592366 struct sk_buff *msg;
23602367 u32 index, port;
2368+ bool opcnt;
23612369 int ret;
23622370
23632371 if (tb[RDMA_NLDEV_ATTR_STAT_COUNTER_ID])
@@ -2393,7 +2401,7 @@ static int stat_get_doit_qp(struct sk_buff *skb, struct nlmsghdr *nlh, · 29 unmodified lines
23932401 goto err_msg;
23942402 }
23952403
2396− ret = rdma_counter_get_mode(device, port, &mode, &mask);
2404+ ret = rdma_counter_get_mode(device, port, &mode, &mask, &opcnt);
23972405 if (ret)
23982406 goto err_msg;
23992407
@@ -2410,6 +2418,12 @@ static int stat_get_doit_qp(struct sk_buff *skb, struct nlmsghdr *nlh, · 10 unmodified lines
24102418 goto err_msg;
24112419 }
24122420
2421+ if ((mode == RDMA_COUNTER_MODE_AUTO) &&
2422+ nla_put_u8(msg, RDMA_NLDEV_ATTR_STAT_OPCOUNTER_ENABLED, opcnt)) {
2423+ ret = -EMSGSIZE;
2424+ goto err_msg;
2425+ }
2426+
24132427 nlmsg_end(msg, nlh);
24142428 ib_device_put(device);
24152429 return rdma_nl_unicast(sock_net(skb->sk), msg, NETLINK_CB(skb).portid);
include/rdma/rdma_counter.h+4−1
@@ -23,6 +23,7 @@ struct rdma_counter_mode { · 22 unmodified lines
2323 enum rdma_nl_counter_mode mode;
2424 enum rdma_nl_counter_mask mask;
2525 struct auto_mode_param param;
26+ bool bind_opcnt;
2627 };
2728
2829 struct rdma_port_counter {
@@ -47,6 +48,7 @@ void rdma_counter_init(struct ib_device *dev); · 18 unmodified lines
4748 void rdma_counter_release(struct ib_device *dev);
4849 int rdma_counter_set_auto_mode(struct ib_device *dev, u32 port,
4950 enum rdma_nl_counter_mask mask,
51+ bool bind_opcnt,
5052 struct netlink_ext_ack *extack);
5153 int rdma_counter_bind_qp_auto(struct ib_qp *qp, u32 port);
5254 int rdma_counter_unbind_qp(struct ib_qp *qp, bool force);
@@ -61,7 +63,8 @@ int rdma_counter_unbind_qpn(struct ib_device *dev, u32 port, · 8 unmodified lines
6163 u32 qp_num, u32 counter_id);
6264 int rdma_counter_get_mode(struct ib_device *dev, u32 port,
6365 enum rdma_nl_counter_mode *mode,
64− enum rdma_nl_counter_mask *mask);
66+ enum rdma_nl_counter_mask *mask,
67+ bool *opcnt);
6568
6669 int rdma_counter_modify(struct ib_device *dev, u32 port,
6770 unsigned int index, bool enable);
include/uapi/rdma/rdma_netlink.h+2−0
@@ -580,6 +580,8 @@ enum rdma_nldev_attr { · 579 unmodified lines
580580 RDMA_NLDEV_ATTR_EVENT_TYPE, /* u8 */
581581
582582 RDMA_NLDEV_SYS_ATTR_MONITOR_MODE, /* u8 */
583+
584+ RDMA_NLDEV_ATTR_STAT_OPCOUNTER_ENABLED, /* u8 */
583585 /*
584586 * Always the end
585587 */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t