devlink: rename and reorder instances of struct devlink_cmd
authorJiri Pirko <jiri@nvidia.com>
Tue, 31 Jan 2023 09:06:13 +0000 (10:06 +0100)
committerJakub Kicinski <kuba@kernel.org>
Wed, 1 Feb 2023 18:57:01 +0000 (10:57 -0800)
In order to maintain naming consistency, rename and reorder all usages
of struct struct devlink_cmd in the following way:
1) Remove "gen" and replace it with "cmd" to match the struct name
2) Order devl_cmds[] and the header file to match the order
   of enum devlink_command
3) Move devl_cmd_rate_get among the peers
4) Remove "inst" for DEVLINK_CMD_GET
5) Add "_get" suffix to all to match DEVLINK_CMD_*_GET (only rate had it
   done correctly)

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/devlink/devl_internal.h
net/devlink/leftover.c
net/devlink/netlink.c

index 3910db5547fec855a7a11ec72d57773ee88a7a15..bdd7ad25c7e8713d337f1b1be872676f9ce8a26c 100644 (file)
@@ -140,21 +140,22 @@ devlink_dump_state(struct netlink_callback *cb)
 }
 
 /* Commands */
-extern const struct devlink_cmd devl_gen_inst;
-extern const struct devlink_cmd devl_gen_port;
-extern const struct devlink_cmd devl_gen_sb;
-extern const struct devlink_cmd devl_gen_sb_pool;
-extern const struct devlink_cmd devl_gen_sb_port_pool;
-extern const struct devlink_cmd devl_gen_sb_tc_pool_bind;
-extern const struct devlink_cmd devl_gen_selftests;
-extern const struct devlink_cmd devl_gen_param;
-extern const struct devlink_cmd devl_gen_region;
-extern const struct devlink_cmd devl_gen_info;
-extern const struct devlink_cmd devl_gen_health_reporter;
-extern const struct devlink_cmd devl_gen_trap;
-extern const struct devlink_cmd devl_gen_trap_group;
-extern const struct devlink_cmd devl_gen_trap_policer;
-extern const struct devlink_cmd devl_gen_linecard;
+extern const struct devlink_cmd devl_cmd_get;
+extern const struct devlink_cmd devl_cmd_port_get;
+extern const struct devlink_cmd devl_cmd_sb_get;
+extern const struct devlink_cmd devl_cmd_sb_pool_get;
+extern const struct devlink_cmd devl_cmd_sb_port_pool_get;
+extern const struct devlink_cmd devl_cmd_sb_tc_pool_bind_get;
+extern const struct devlink_cmd devl_cmd_param_get;
+extern const struct devlink_cmd devl_cmd_region_get;
+extern const struct devlink_cmd devl_cmd_info_get;
+extern const struct devlink_cmd devl_cmd_health_reporter_get;
+extern const struct devlink_cmd devl_cmd_trap_get;
+extern const struct devlink_cmd devl_cmd_trap_group_get;
+extern const struct devlink_cmd devl_cmd_trap_policer_get;
+extern const struct devlink_cmd devl_cmd_rate_get;
+extern const struct devlink_cmd devl_cmd_linecard_get;
+extern const struct devlink_cmd devl_cmd_selftests_get;
 
 /* Ports */
 int devlink_port_netdevice_event(struct notifier_block *nb,
@@ -182,8 +183,6 @@ struct devlink_linecard *
 devlink_linecard_get_from_info(struct devlink *devlink, struct genl_info *info);
 
 /* Rates */
-extern const struct devlink_cmd devl_gen_rate_get;
-
 struct devlink_rate *
 devlink_rate_get_from_info(struct devlink *devlink, struct genl_info *info);
 struct devlink_rate *
index 16cb5975de1af96564e15ab4d7a3e67e08299ee2..056d9ca14a3d7e2cd244ae685403e97d91c186ce 100644 (file)
@@ -1236,7 +1236,7 @@ devlink_nl_cmd_rate_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
        return err;
 }
 
-const struct devlink_cmd devl_gen_rate_get = {
+const struct devlink_cmd devl_cmd_rate_get = {
        .dump_one               = devlink_nl_cmd_rate_get_dump_one,
 };
 
@@ -1303,7 +1303,7 @@ devlink_nl_cmd_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
                               cb->nlh->nlmsg_seq, NLM_F_MULTI);
 }
 
-const struct devlink_cmd devl_gen_inst = {
+const struct devlink_cmd devl_cmd_get = {
        .dump_one               = devlink_nl_cmd_get_dump_one,
 };
 
@@ -1359,7 +1359,7 @@ devlink_nl_cmd_port_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
        return err;
 }
 
-const struct devlink_cmd devl_gen_port = {
+const struct devlink_cmd devl_cmd_port_get = {
        .dump_one               = devlink_nl_cmd_port_get_dump_one,
 };
 
@@ -2137,7 +2137,7 @@ static int devlink_nl_cmd_linecard_get_dump_one(struct sk_buff *msg,
        return err;
 }
 
-const struct devlink_cmd devl_gen_linecard = {
+const struct devlink_cmd devl_cmd_linecard_get = {
        .dump_one               = devlink_nl_cmd_linecard_get_dump_one,
 };
 
@@ -2392,7 +2392,7 @@ devlink_nl_cmd_sb_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
        return err;
 }
 
-const struct devlink_cmd devl_gen_sb = {
+const struct devlink_cmd devl_cmd_sb_get = {
        .dump_one               = devlink_nl_cmd_sb_get_dump_one,
 };
 
@@ -2530,7 +2530,7 @@ devlink_nl_cmd_sb_pool_get_dump_one(struct sk_buff *msg,
        return err;
 }
 
-const struct devlink_cmd devl_gen_sb_pool = {
+const struct devlink_cmd devl_cmd_sb_pool_get = {
        .dump_one               = devlink_nl_cmd_sb_pool_get_dump_one,
 };
 
@@ -2738,7 +2738,7 @@ devlink_nl_cmd_sb_port_pool_get_dump_one(struct sk_buff *msg,
        return err;
 }
 
-const struct devlink_cmd devl_gen_sb_port_pool = {
+const struct devlink_cmd devl_cmd_sb_port_pool_get = {
        .dump_one               = devlink_nl_cmd_sb_port_pool_get_dump_one,
 };
 
@@ -2973,7 +2973,7 @@ devlink_nl_cmd_sb_tc_pool_bind_get_dump_one(struct sk_buff *msg,
        return err;
 }
 
-const struct devlink_cmd devl_gen_sb_tc_pool_bind = {
+const struct devlink_cmd devl_cmd_sb_tc_pool_bind_get = {
        .dump_one               = devlink_nl_cmd_sb_tc_pool_bind_get_dump_one,
 };
 
@@ -4785,7 +4785,7 @@ devlink_nl_cmd_selftests_get_dump_one(struct sk_buff *msg,
                                         cb->extack);
 }
 
-const struct devlink_cmd devl_gen_selftests = {
+const struct devlink_cmd devl_cmd_selftests_get = {
        .dump_one               = devlink_nl_cmd_selftests_get_dump_one,
 };
 
@@ -5271,7 +5271,7 @@ devlink_nl_cmd_param_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
        return err;
 }
 
-const struct devlink_cmd devl_gen_param = {
+const struct devlink_cmd devl_cmd_param_get = {
        .dump_one               = devlink_nl_cmd_param_get_dump_one,
 };
 
@@ -5978,7 +5978,7 @@ devlink_nl_cmd_region_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
        return 0;
 }
 
-const struct devlink_cmd devl_gen_region = {
+const struct devlink_cmd devl_cmd_region_get = {
        .dump_one               = devlink_nl_cmd_region_get_dump_one,
 };
 
@@ -6625,7 +6625,7 @@ devlink_nl_cmd_info_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
        return err;
 }
 
-const struct devlink_cmd devl_gen_info = {
+const struct devlink_cmd devl_cmd_info_get = {
        .dump_one               = devlink_nl_cmd_info_get_dump_one,
 };
 
@@ -7793,7 +7793,7 @@ devlink_nl_cmd_health_reporter_get_dump_one(struct sk_buff *msg,
        return 0;
 }
 
-const struct devlink_cmd devl_gen_health_reporter = {
+const struct devlink_cmd devl_cmd_health_reporter_get = {
        .dump_one               = devlink_nl_cmd_health_reporter_get_dump_one,
 };
 
@@ -8311,7 +8311,7 @@ devlink_nl_cmd_trap_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
        return err;
 }
 
-const struct devlink_cmd devl_gen_trap = {
+const struct devlink_cmd devl_cmd_trap_get = {
        .dump_one               = devlink_nl_cmd_trap_get_dump_one,
 };
 
@@ -8524,7 +8524,7 @@ devlink_nl_cmd_trap_group_get_dump_one(struct sk_buff *msg,
        return err;
 }
 
-const struct devlink_cmd devl_gen_trap_group = {
+const struct devlink_cmd devl_cmd_trap_group_get = {
        .dump_one               = devlink_nl_cmd_trap_group_get_dump_one,
 };
 
@@ -8817,7 +8817,7 @@ devlink_nl_cmd_trap_policer_get_dump_one(struct sk_buff *msg,
        return err;
 }
 
-const struct devlink_cmd devl_gen_trap_policer = {
+const struct devlink_cmd devl_cmd_trap_policer_get = {
        .dump_one               = devlink_nl_cmd_trap_policer_get_dump_one,
 };
 
index 33ed3984f3cb4332e51400dd1b1c016e0e0b2ba8..7a332eb70f70335b9303ecee6f81d1e022023e0e 100644 (file)
@@ -177,23 +177,23 @@ static void devlink_nl_post_doit(const struct genl_split_ops *ops,
        devlink_put(devlink);
 }
 
-static const struct devlink_cmd *devl_gen_cmds[] = {
-       [DEVLINK_CMD_GET]               = &devl_gen_inst,
-       [DEVLINK_CMD_PORT_GET]          = &devl_gen_port,
-       [DEVLINK_CMD_SB_GET]            = &devl_gen_sb,
-       [DEVLINK_CMD_SB_POOL_GET]       = &devl_gen_sb_pool,
-       [DEVLINK_CMD_SB_PORT_POOL_GET]  = &devl_gen_sb_port_pool,
-       [DEVLINK_CMD_SB_TC_POOL_BIND_GET] = &devl_gen_sb_tc_pool_bind,
-       [DEVLINK_CMD_PARAM_GET]         = &devl_gen_param,
-       [DEVLINK_CMD_REGION_GET]        = &devl_gen_region,
-       [DEVLINK_CMD_INFO_GET]          = &devl_gen_info,
-       [DEVLINK_CMD_HEALTH_REPORTER_GET] = &devl_gen_health_reporter,
-       [DEVLINK_CMD_RATE_GET]          = &devl_gen_rate_get,
-       [DEVLINK_CMD_TRAP_GET]          = &devl_gen_trap,
-       [DEVLINK_CMD_TRAP_GROUP_GET]    = &devl_gen_trap_group,
-       [DEVLINK_CMD_TRAP_POLICER_GET]  = &devl_gen_trap_policer,
-       [DEVLINK_CMD_LINECARD_GET]      = &devl_gen_linecard,
-       [DEVLINK_CMD_SELFTESTS_GET]     = &devl_gen_selftests,
+static const struct devlink_cmd *devl_cmds[] = {
+       [DEVLINK_CMD_GET]               = &devl_cmd_get,
+       [DEVLINK_CMD_PORT_GET]          = &devl_cmd_port_get,
+       [DEVLINK_CMD_SB_GET]            = &devl_cmd_sb_get,
+       [DEVLINK_CMD_SB_POOL_GET]       = &devl_cmd_sb_pool_get,
+       [DEVLINK_CMD_SB_PORT_POOL_GET]  = &devl_cmd_sb_port_pool_get,
+       [DEVLINK_CMD_SB_TC_POOL_BIND_GET] = &devl_cmd_sb_tc_pool_bind_get,
+       [DEVLINK_CMD_PARAM_GET]         = &devl_cmd_param_get,
+       [DEVLINK_CMD_REGION_GET]        = &devl_cmd_region_get,
+       [DEVLINK_CMD_INFO_GET]          = &devl_cmd_info_get,
+       [DEVLINK_CMD_HEALTH_REPORTER_GET] = &devl_cmd_health_reporter_get,
+       [DEVLINK_CMD_TRAP_GET]          = &devl_cmd_trap_get,
+       [DEVLINK_CMD_TRAP_GROUP_GET]    = &devl_cmd_trap_group_get,
+       [DEVLINK_CMD_TRAP_POLICER_GET]  = &devl_cmd_trap_policer_get,
+       [DEVLINK_CMD_RATE_GET]          = &devl_cmd_rate_get,
+       [DEVLINK_CMD_LINECARD_GET]      = &devl_cmd_linecard_get,
+       [DEVLINK_CMD_SELFTESTS_GET]     = &devl_cmd_selftests_get,
 };
 
 int devlink_nl_instance_iter_dumpit(struct sk_buff *msg,
@@ -205,7 +205,7 @@ int devlink_nl_instance_iter_dumpit(struct sk_buff *msg,
        struct devlink *devlink;
        int err = 0;
 
-       cmd = devl_gen_cmds[info->op.cmd];
+       cmd = devl_cmds[info->op.cmd];
 
        while ((devlink = devlinks_xa_find_get(sock_net(msg->sk),
                                               &state->instance))) {