]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
rdma: Add rdma statistic counter per-port auto mode support
authorMark Zhang <markz@mellanox.com>
Wed, 17 Jul 2019 14:31:52 +0000 (17:31 +0300)
committerStephen Hemminger <stephen@networkplumber.org>
Fri, 19 Jul 2019 17:51:13 +0000 (10:51 -0700)
With per-QP statistic counter support, a user is allowed to monitor
specific QPs categories, which are bound to/unbound from counters
dynamically allocated/deallocated.

In per-port "auto" mode, QPs are bound to counters automatically
according to common criteria. For example a per "type"(qp type)
scheme, where in each process all QPs have same qp type are bind
automatically to a single counter.
Currently only "type" (qp type) is supported. Examples:

$ rdma statistic qp set link mlx5_2/1 auto type on
$ rdma statistic qp set link mlx5_2/1 auto off

Signed-off-by: Mark Zhang <markz@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
rdma/stat.c
rdma/utils.c

index 0c23985194aa88a94290692214906ee61d1de122..ad1cc063b90b25524d0b61ac1084324c35e0d4a1 100644 (file)
@@ -14,12 +14,17 @@ static int stat_help(struct rd *rd)
        pr_out("       %s statistic OBJECT show\n", rd->filename);
        pr_out("       %s statistic OBJECT show link [ DEV/PORT_INDEX ] [ FILTER-NAME FILTER-VALUE ]\n", rd->filename);
        pr_out("       %s statistic OBJECT mode\n", rd->filename);
+       pr_out("       %s statistic OBJECT set COUNTER_SCOPE [DEV/PORT_INDEX] auto {CRITERIA | off}\n", rd->filename);
        pr_out("where  OBJECT: = { qp }\n");
+       pr_out("       CRITERIA : = { type }\n");
+       pr_out("       COUNTER_SCOPE: = { link | dev }\n");
        pr_out("Examples:\n");
        pr_out("       %s statistic qp show\n", rd->filename);
        pr_out("       %s statistic qp show link mlx5_2/1\n", rd->filename);
        pr_out("       %s statistic qp mode\n", rd->filename);
        pr_out("       %s statistic qp mode link mlx5_0\n", rd->filename);
+       pr_out("       %s statistic qp set link mlx5_2/1 auto type on\n", rd->filename);
+       pr_out("       %s statistic qp set link mlx5_2/1 auto off\n", rd->filename);
 
        return 0;
 }
@@ -381,6 +386,87 @@ static int stat_qp_show(struct rd *rd)
        return rd_exec_cmd(rd, cmds, "parameter");
 }
 
+static int stat_qp_set_link_auto_sendmsg(struct rd *rd, uint32_t mask)
+{
+       uint32_t seq;
+
+       rd_prepare_msg(rd, RDMA_NLDEV_CMD_STAT_SET,
+                      &seq, (NLM_F_REQUEST | NLM_F_ACK));
+
+       mnl_attr_put_u32(rd->nlh, RDMA_NLDEV_ATTR_DEV_INDEX, rd->dev_idx);
+       mnl_attr_put_u32(rd->nlh, RDMA_NLDEV_ATTR_PORT_INDEX, rd->port_idx);
+       mnl_attr_put_u32(rd->nlh, RDMA_NLDEV_ATTR_STAT_RES, RDMA_NLDEV_ATTR_RES_QP);
+       mnl_attr_put_u32(rd->nlh, RDMA_NLDEV_ATTR_STAT_MODE,
+                        RDMA_COUNTER_MODE_AUTO);
+       mnl_attr_put_u32(rd->nlh, RDMA_NLDEV_ATTR_STAT_AUTO_MODE_MASK, mask);
+
+       return rd_sendrecv_msg(rd, seq);
+}
+
+static int stat_one_qp_set_link_auto_off(struct rd *rd)
+{
+       return stat_qp_set_link_auto_sendmsg(rd, 0);
+}
+
+static int stat_one_qp_set_auto_type_on(struct rd *rd)
+{
+       return stat_qp_set_link_auto_sendmsg(rd, RDMA_COUNTER_MASK_QP_TYPE);
+}
+
+static int stat_one_qp_set_link_auto_type(struct rd *rd)
+{
+       const struct rd_cmd cmds[] = {
+               { NULL,         stat_help },
+               { "on",         stat_one_qp_set_auto_type_on },
+               { 0 }
+       };
+
+       return rd_exec_cmd(rd, cmds, "parameter");
+}
+
+static int stat_one_qp_set_link_auto(struct rd *rd)
+{
+       const struct rd_cmd cmds[] = {
+               { NULL,         stat_one_qp_link_get_mode },
+               { "off",        stat_one_qp_set_link_auto_off },
+               { "type",       stat_one_qp_set_link_auto_type },
+               { 0 }
+       };
+
+       return rd_exec_cmd(rd, cmds, "parameter");
+}
+
+static int stat_one_qp_set_link(struct rd *rd)
+{
+       const struct rd_cmd cmds[] = {
+               { NULL,         stat_one_qp_link_get_mode },
+               { "auto",       stat_one_qp_set_link_auto },
+               { 0 }
+       };
+
+       if (!rd->port_idx)
+               return 0;
+
+       return rd_exec_cmd(rd, cmds, "parameter");
+}
+
+static int stat_qp_set_link(struct rd *rd)
+{
+       return rd_exec_link(rd, stat_one_qp_set_link, false);
+}
+
+static int stat_qp_set(struct rd *rd)
+{
+       const struct rd_cmd cmds[] = {
+               { NULL,         stat_help },
+               { "link",       stat_qp_set_link },
+               { "help",       stat_help },
+               { 0 }
+       };
+
+       return rd_exec_cmd(rd, cmds, "parameter");
+}
+
 static int stat_qp(struct rd *rd)
 {
        const struct rd_cmd cmds[] =  {
@@ -388,6 +474,7 @@ static int stat_qp(struct rd *rd)
                { "show",       stat_qp_show },
                { "list",       stat_qp_show },
                { "mode",       stat_qp_get_mode },
+               { "set",        stat_qp_set },
                { "help",       stat_help },
                { 0 }
        };
index 9c885ad7389fa073deb1a09207bef613ff82ea93..aed1a3d011570e1af9dca7b77952dde6eda88a81 100644 (file)
@@ -445,6 +445,7 @@ static const enum mnl_attr_data_type nldev_policy[RDMA_NLDEV_ATTR_MAX] = {
        [RDMA_NLDEV_ATTR_STAT_HWCOUNTER_ENTRY_VALUE] = MNL_TYPE_U64,
        [RDMA_NLDEV_ATTR_STAT_MODE] = MNL_TYPE_U32,
        [RDMA_NLDEV_ATTR_STAT_RES] = MNL_TYPE_U32,
+       [RDMA_NLDEV_ATTR_STAT_AUTO_MODE_MASK] = MNL_TYPE_U32,
 };
 
 int rd_attr_check(const struct nlattr *attr, int *typep)