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
12 12
13static int __counter_set_mode(struct rdma_port_counter *port_counter,13static int __counter_set_mode(struct rdma_port_counter *port_counter,
14 enum rdma_nl_counter_mode new_mode,14 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)
16{17{
17 if (new_mode == RDMA_COUNTER_MODE_AUTO) {18 if (new_mode == RDMA_COUNTER_MODE_AUTO) {
18 if (new_mask & (~ALL_AUTO_MODE_MASKS))19 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
23 24
24 port_counter->mode.mode = new_mode;25 port_counter->mode.mode = new_mode;
25 port_counter->mode.mask = new_mask;26 port_counter->mode.mask = new_mask;
27 port_counter->mode.bind_opcnt = bind_opcnt;
26 return 0;28 return 0;
27}29}
28 30
@@ -41,6 +43,7 @@ static int __counter_set_mode(struct rdma_port_counter *port_counter, · 12 unmodified lines
41 */43 */
42int rdma_counter_set_auto_mode(struct ib_device *dev, u32 port,44int rdma_counter_set_auto_mode(struct ib_device *dev, u32 port,
43 enum rdma_nl_counter_mask mask,45 enum rdma_nl_counter_mask mask,
46 bool bind_opcnt,
44 struct netlink_ext_ack *extack)47 struct netlink_ext_ack *extack)
45{48{
46 struct rdma_port_counter *port_counter;49 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
59 RDMA_COUNTER_MODE_NONE;62 RDMA_COUNTER_MODE_NONE;
60 63
61 if (port_counter->mode.mode == mode &&64 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) {
63 ret = 0;67 ret = 0;
64 goto out;68 goto out;
65 }69 }
66 70
67 ret = __counter_set_mode(port_counter, mode, mask);71 ret = __counter_set_mode(port_counter, mode, mask, bind_opcnt);
68 72
69out:73out:
70 mutex_unlock(&port_counter->lock);74 mutex_unlock(&port_counter->lock);
@@ -140,7 +144,8 @@ out: · 69 unmodified lines
140 144
141static struct rdma_counter *alloc_and_bind(struct ib_device *dev, u32 port,145static struct rdma_counter *alloc_and_bind(struct ib_device *dev, u32 port,
142 struct ib_qp *qp,146 struct ib_qp *qp,
143 enum rdma_nl_counter_mode mode)147 enum rdma_nl_counter_mode mode,
148 bool bind_opcnt)
144{149{
145 struct rdma_port_counter *port_counter;150 struct rdma_port_counter *port_counter;
146 struct rdma_counter *counter;151 struct rdma_counter *counter;
@@ -168,7 +173,7 @@ static struct rdma_counter *alloc_and_bind(struct ib_device *dev, u32 port, · 21 unmodified lines
168 switch (mode) {173 switch (mode) {
169 case RDMA_COUNTER_MODE_MANUAL:174 case RDMA_COUNTER_MODE_MANUAL:
170 ret = __counter_set_mode(port_counter, RDMA_COUNTER_MODE_MANUAL,175 ret = __counter_set_mode(port_counter, RDMA_COUNTER_MODE_MANUAL,
171 0);176 0, bind_opcnt);
172 if (ret) {177 if (ret) {
173 mutex_unlock(&port_counter->lock);178 mutex_unlock(&port_counter->lock);
174 goto err_mode;179 goto err_mode;
@@ -187,6 +192,7 @@ static struct rdma_counter *alloc_and_bind(struct ib_device *dev, u32 port, · 12 unmodified lines
187 mutex_unlock(&port_counter->lock);192 mutex_unlock(&port_counter->lock);
188 193
189 counter->mode.mode = mode;194 counter->mode.mode = mode;
195 counter->mode.bind_opcnt = bind_opcnt;
190 kref_init(&counter->kref);196 kref_init(&counter->kref);
191 mutex_init(&counter->lock);197 mutex_init(&counter->lock);
192 198
@@ -215,7 +221,8 @@ static void rdma_counter_free(struct rdma_counter *counter) · 22 unmodified lines
215 port_counter->num_counters--;221 port_counter->num_counters--;
216 if (!port_counter->num_counters &&222 if (!port_counter->num_counters &&
217 (port_counter->mode.mode == RDMA_COUNTER_MODE_MANUAL))223 (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);
219 226
220 mutex_unlock(&port_counter->lock);227 mutex_unlock(&port_counter->lock);
221 228
@@ -347,7 +354,8 @@ int rdma_counter_bind_qp_auto(struct ib_qp *qp, u32 port) · 125 unmodified lines
347 return ret;354 return ret;
348 }355 }
349 } else {356 } 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);
351 if (!counter)359 if (!counter)
352 return -ENOMEM;360 return -ENOMEM;
353 }361 }
@@ -560,7 +568,7 @@ int rdma_counter_bind_qpn_alloc(struct ib_device *dev, u32 port, · 206 unmodified lines
560 goto err;568 goto err;
561 }569 }
562 570
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);
564 if (!counter) {572 if (!counter) {
565 ret = -ENOMEM;573 ret = -ENOMEM;
566 goto err;574 goto err;
@@ -615,13 +623,15 @@ out: · 48 unmodified lines
615 623
616int rdma_counter_get_mode(struct ib_device *dev, u32 port,624int rdma_counter_get_mode(struct ib_device *dev, u32 port,
617 enum rdma_nl_counter_mode *mode,625 enum rdma_nl_counter_mode *mode,
618 enum rdma_nl_counter_mask *mask)626 enum rdma_nl_counter_mask *mask,
627 bool *opcnt)
619{628{
620 struct rdma_port_counter *port_counter;629 struct rdma_port_counter *port_counter;
621 630
622 port_counter = &dev->port_data[port].port_counter;631 port_counter = &dev->port_data[port].port_counter;
623 *mode = port_counter->mode.mode;632 *mode = port_counter->mode.mode;
624 *mask = port_counter->mode.mask;633 *mask = port_counter->mode.mask;
634 *opcnt = port_counter->mode.bind_opcnt;
625 635
626 return 0;636 return 0;
627}637}
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
171 [RDMA_NLDEV_ATTR_PARENT_NAME] = { .type = NLA_NUL_STRING },171 [RDMA_NLDEV_ATTR_PARENT_NAME] = { .type = NLA_NUL_STRING },
172 [RDMA_NLDEV_ATTR_NAME_ASSIGN_TYPE] = { .type = NLA_U8 },172 [RDMA_NLDEV_ATTR_NAME_ASSIGN_TYPE] = { .type = NLA_U8 },
173 [RDMA_NLDEV_ATTR_EVENT_TYPE] = { .type = NLA_U8 },173 [RDMA_NLDEV_ATTR_EVENT_TYPE] = { .type = NLA_U8 },
174 [RDMA_NLDEV_ATTR_STAT_OPCOUNTER_ENABLED] = { .type = NLA_U8 },
174};175};
175 176
176static int put_driver_name_print_type(struct sk_buff *msg, const char *name,177static 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
2028 struct ib_device *device, u32 port)2029 struct ib_device *device, u32 port)
2029{2030{
2030 u32 mode, mask = 0, qpn, cntn = 0;2031 u32 mode, mask = 0, qpn, cntn = 0;
2032 bool opcnt = false;
2031 int ret;2033 int ret;
2032 2034
2033 /* Currently only counter for QP is supported */2035 /* 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
2035 nla_get_u32(tb[RDMA_NLDEV_ATTR_STAT_RES]) != RDMA_NLDEV_ATTR_RES_QP)2037 nla_get_u32(tb[RDMA_NLDEV_ATTR_STAT_RES]) != RDMA_NLDEV_ATTR_RES_QP)
2036 return -EINVAL;2038 return -EINVAL;
2037 2039
2040 if (tb[RDMA_NLDEV_ATTR_STAT_OPCOUNTER_ENABLED])
2041 opcnt = !!nla_get_u8(
2042 tb[RDMA_NLDEV_ATTR_STAT_OPCOUNTER_ENABLED]);
2043
2038 mode = nla_get_u32(tb[RDMA_NLDEV_ATTR_STAT_MODE]);2044 mode = nla_get_u32(tb[RDMA_NLDEV_ATTR_STAT_MODE]);
2039 if (mode == RDMA_COUNTER_MODE_AUTO) {2045 if (mode == RDMA_COUNTER_MODE_AUTO) {
2040 if (tb[RDMA_NLDEV_ATTR_STAT_AUTO_MODE_MASK])2046 if (tb[RDMA_NLDEV_ATTR_STAT_AUTO_MODE_MASK])
2041 mask = nla_get_u32(2047 mask = nla_get_u32(
2042 tb[RDMA_NLDEV_ATTR_STAT_AUTO_MODE_MASK]);2048 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);
2044 }2051 }
2045 2052
2046 if (!tb[RDMA_NLDEV_ATTR_RES_LQPN])2053 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
2358 struct ib_device *device;2365 struct ib_device *device;
2359 struct sk_buff *msg;2366 struct sk_buff *msg;
2360 u32 index, port;2367 u32 index, port;
2368 bool opcnt;
2361 int ret;2369 int ret;
2362 2370
2363 if (tb[RDMA_NLDEV_ATTR_STAT_COUNTER_ID])2371 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
2393 goto err_msg;2401 goto err_msg;
2394 }2402 }
2395 2403
2396 ret = rdma_counter_get_mode(device, port, &mode, &mask);2404 ret = rdma_counter_get_mode(device, port, &mode, &mask, &opcnt);
2397 if (ret)2405 if (ret)
2398 goto err_msg;2406 goto err_msg;
2399 2407
@@ -2410,6 +2418,12 @@ static int stat_get_doit_qp(struct sk_buff *skb, struct nlmsghdr *nlh, · 10 unmodified lines
2410 goto err_msg;2418 goto err_msg;
2411 }2419 }
2412 2420
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
2413 nlmsg_end(msg, nlh);2427 nlmsg_end(msg, nlh);
2414 ib_device_put(device);2428 ib_device_put(device);
2415 return rdma_nl_unicast(sock_net(skb->sk), msg, NETLINK_CB(skb).portid);2429 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
23 enum rdma_nl_counter_mode mode;23 enum rdma_nl_counter_mode mode;
24 enum rdma_nl_counter_mask mask;24 enum rdma_nl_counter_mask mask;
25 struct auto_mode_param param;25 struct auto_mode_param param;
26 bool bind_opcnt;
26};27};
27 28
28struct rdma_port_counter {29struct rdma_port_counter {
@@ -47,6 +48,7 @@ void rdma_counter_init(struct ib_device *dev); · 18 unmodified lines
47void rdma_counter_release(struct ib_device *dev);48void rdma_counter_release(struct ib_device *dev);
48int rdma_counter_set_auto_mode(struct ib_device *dev, u32 port,49int rdma_counter_set_auto_mode(struct ib_device *dev, u32 port,
49 enum rdma_nl_counter_mask mask,50 enum rdma_nl_counter_mask mask,
51 bool bind_opcnt,
50 struct netlink_ext_ack *extack);52 struct netlink_ext_ack *extack);
51int rdma_counter_bind_qp_auto(struct ib_qp *qp, u32 port);53int rdma_counter_bind_qp_auto(struct ib_qp *qp, u32 port);
52int rdma_counter_unbind_qp(struct ib_qp *qp, bool force);54int 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
61 u32 qp_num, u32 counter_id);63 u32 qp_num, u32 counter_id);
62int rdma_counter_get_mode(struct ib_device *dev, u32 port,64int rdma_counter_get_mode(struct ib_device *dev, u32 port,
63 enum rdma_nl_counter_mode *mode,65 enum rdma_nl_counter_mode *mode,
64 enum rdma_nl_counter_mask *mask);66 enum rdma_nl_counter_mask *mask,
67 bool *opcnt);
65 68
66int rdma_counter_modify(struct ib_device *dev, u32 port,69int rdma_counter_modify(struct ib_device *dev, u32 port,
67 unsigned int index, bool enable);70 unsigned int index, bool enable);
include/uapi/rdma/rdma_netlink.h+2−0
@@ -580,6 +580,8 @@ enum rdma_nldev_attr { · 579 unmodified lines
580 RDMA_NLDEV_ATTR_EVENT_TYPE, /* u8 */580 RDMA_NLDEV_ATTR_EVENT_TYPE, /* u8 */
581 581
582 RDMA_NLDEV_SYS_ATTR_MONITOR_MODE, /* u8 */582 RDMA_NLDEV_SYS_ATTR_MONITOR_MODE, /* u8 */
583
584 RDMA_NLDEV_ATTR_STAT_OPCOUNTER_ENABLED, /* u8 */
583 /*585 /*
584 * Always the end586 * Always the end
585 */587 */

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