Commit 24c8e56d authored by Jiri Pirko's avatar Jiri Pirko Committed by Jakub Kicinski

devlink: introduce dumpit callbacks for split ops

Introduce dumpit callbacks for generated split ops. Have them
as a thin wrapper around iteration function and allow to pass dump_one()
function pointer directly without need to store in devlink_cmd structs.

Note that the function prototypes are temporary until the generated ones
will replace them in a follow-up patch.
Signed-off-by: default avatarJiri Pirko <jiri@nvidia.com>
Acked-by: default avatarJakub Kicinski <kuba@kernel.org>
Link: https://lore.kernel.org/r/20230811155714.1736405-6-jiri@resnulli.usSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 8fa995ad
...@@ -1229,10 +1229,9 @@ int devlink_nl_selftests_get_doit(struct sk_buff *skb, struct genl_info *info) ...@@ -1229,10 +1229,9 @@ int devlink_nl_selftests_get_doit(struct sk_buff *skb, struct genl_info *info)
return genlmsg_reply(msg, info); return genlmsg_reply(msg, info);
} }
static int static int devlink_nl_selftests_get_dump_one(struct sk_buff *msg,
devlink_nl_cmd_selftests_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
struct devlink *devlink, struct netlink_callback *cb)
struct netlink_callback *cb)
{ {
if (!devlink->ops->selftest_check) if (!devlink->ops->selftest_check)
return 0; return 0;
...@@ -1243,9 +1242,11 @@ devlink_nl_cmd_selftests_get_dump_one(struct sk_buff *msg, ...@@ -1243,9 +1242,11 @@ devlink_nl_cmd_selftests_get_dump_one(struct sk_buff *msg,
cb->extack); cb->extack);
} }
const struct devlink_cmd devl_cmd_selftests_get = { int devlink_nl_selftests_get_dumpit(struct sk_buff *skb,
.dump_one = devlink_nl_cmd_selftests_get_dump_one, struct netlink_callback *cb)
}; {
return devlink_nl_dumpit(skb, cb, devlink_nl_selftests_get_dump_one);
}
static int devlink_selftest_result_put(struct sk_buff *skb, unsigned int id, static int devlink_selftest_result_put(struct sk_buff *skb, unsigned int id,
enum devlink_selftest_status test_status) enum devlink_selftest_status test_status)
......
...@@ -117,10 +117,6 @@ typedef int devlink_nl_dump_one_func_t(struct sk_buff *msg, ...@@ -117,10 +117,6 @@ typedef int devlink_nl_dump_one_func_t(struct sk_buff *msg,
struct devlink *devlink, struct devlink *devlink,
struct netlink_callback *cb); struct netlink_callback *cb);
struct devlink_cmd {
devlink_nl_dump_one_func_t *dump_one;
};
extern const struct genl_small_ops devlink_nl_small_ops[54]; extern const struct genl_small_ops devlink_nl_small_ops[54];
struct devlink * struct devlink *
...@@ -131,7 +127,6 @@ void devlink_notify_register(struct devlink *devlink); ...@@ -131,7 +127,6 @@ void devlink_notify_register(struct devlink *devlink);
int devlink_nl_dumpit(struct sk_buff *msg, struct netlink_callback *cb, int devlink_nl_dumpit(struct sk_buff *msg, struct netlink_callback *cb,
devlink_nl_dump_one_func_t *dump_one); devlink_nl_dump_one_func_t *dump_one);
int devlink_nl_instance_iter_dumpit(struct sk_buff *msg, struct netlink_callback *cb);
static inline struct devlink_nl_dump_state * static inline struct devlink_nl_dump_state *
devlink_dump_state(struct netlink_callback *cb) devlink_dump_state(struct netlink_callback *cb)
...@@ -151,22 +146,6 @@ devlink_nl_put_handle(struct sk_buff *msg, struct devlink *devlink) ...@@ -151,22 +146,6 @@ devlink_nl_put_handle(struct sk_buff *msg, struct devlink *devlink)
return 0; return 0;
} }
/* Commands */
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_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;
/* Notify */ /* Notify */
void devlink_notify(struct devlink *devlink, enum devlink_command cmd); void devlink_notify(struct devlink *devlink, enum devlink_command cmd);
...@@ -215,21 +194,40 @@ int devlink_nl_cmd_eswitch_get_doit(struct sk_buff *skb, struct genl_info *info) ...@@ -215,21 +194,40 @@ int devlink_nl_cmd_eswitch_get_doit(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_cmd_eswitch_set_doit(struct sk_buff *skb, struct genl_info *info); int devlink_nl_cmd_eswitch_set_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_flash_update(struct sk_buff *skb, struct genl_info *info); int devlink_nl_cmd_flash_update(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_selftests_get_doit(struct sk_buff *skb, struct genl_info *info); int devlink_nl_selftests_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_selftests_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_cmd_selftests_run(struct sk_buff *skb, struct genl_info *info); int devlink_nl_cmd_selftests_run(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_port_get_doit(struct sk_buff *skb, struct genl_info *info); int devlink_nl_port_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_port_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb);
int devlink_nl_rate_get_doit(struct sk_buff *skb, struct genl_info *info); int devlink_nl_rate_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_rate_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb);
int devlink_nl_linecard_get_doit(struct sk_buff *skb, struct genl_info *info); int devlink_nl_linecard_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_linecard_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_sb_get_doit(struct sk_buff *skb, struct genl_info *info); int devlink_nl_sb_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_sb_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb);
int devlink_nl_sb_pool_get_doit(struct sk_buff *skb, struct genl_info *info); int devlink_nl_sb_pool_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_sb_pool_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_sb_port_pool_get_doit(struct sk_buff *skb, int devlink_nl_sb_port_pool_get_doit(struct sk_buff *skb,
struct genl_info *info); struct genl_info *info);
int devlink_nl_sb_port_pool_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_sb_tc_pool_bind_get_doit(struct sk_buff *skb, int devlink_nl_sb_tc_pool_bind_get_doit(struct sk_buff *skb,
struct genl_info *info); struct genl_info *info);
int devlink_nl_sb_tc_pool_bind_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_param_get_doit(struct sk_buff *skb, int devlink_nl_param_get_doit(struct sk_buff *skb,
struct genl_info *info); struct genl_info *info);
int devlink_nl_param_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_region_get_doit(struct sk_buff *skb, struct genl_info *info); int devlink_nl_region_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_region_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_health_reporter_get_doit(struct sk_buff *skb, int devlink_nl_health_reporter_get_doit(struct sk_buff *skb,
struct genl_info *info); struct genl_info *info);
int devlink_nl_health_reporter_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_cmd_health_reporter_set_doit(struct sk_buff *skb, int devlink_nl_cmd_health_reporter_set_doit(struct sk_buff *skb,
struct genl_info *info); struct genl_info *info);
int devlink_nl_cmd_health_reporter_recover_doit(struct sk_buff *skb, int devlink_nl_cmd_health_reporter_recover_doit(struct sk_buff *skb,
...@@ -243,6 +241,11 @@ int devlink_nl_cmd_health_reporter_dump_clear_doit(struct sk_buff *skb, ...@@ -243,6 +241,11 @@ int devlink_nl_cmd_health_reporter_dump_clear_doit(struct sk_buff *skb,
int devlink_nl_cmd_health_reporter_test_doit(struct sk_buff *skb, int devlink_nl_cmd_health_reporter_test_doit(struct sk_buff *skb,
struct genl_info *info); struct genl_info *info);
int devlink_nl_trap_get_doit(struct sk_buff *skb, struct genl_info *info); int devlink_nl_trap_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_trap_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb);
int devlink_nl_trap_group_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_trap_group_get_doit(struct sk_buff *skb, struct genl_info *info); int devlink_nl_trap_group_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_trap_policer_get_doit(struct sk_buff *skb, int devlink_nl_trap_policer_get_doit(struct sk_buff *skb,
struct genl_info *info); struct genl_info *info);
int devlink_nl_trap_policer_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
...@@ -384,10 +384,9 @@ int devlink_nl_health_reporter_get_doit(struct sk_buff *skb, ...@@ -384,10 +384,9 @@ int devlink_nl_health_reporter_get_doit(struct sk_buff *skb,
return genlmsg_reply(msg, info); return genlmsg_reply(msg, info);
} }
static int static int devlink_nl_health_reporter_get_dump_one(struct sk_buff *msg,
devlink_nl_cmd_health_reporter_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
struct devlink *devlink, struct netlink_callback *cb)
struct netlink_callback *cb)
{ {
struct devlink_nl_dump_state *state = devlink_dump_state(cb); struct devlink_nl_dump_state *state = devlink_dump_state(cb);
struct devlink_health_reporter *reporter; struct devlink_health_reporter *reporter;
...@@ -434,9 +433,12 @@ devlink_nl_cmd_health_reporter_get_dump_one(struct sk_buff *msg, ...@@ -434,9 +433,12 @@ devlink_nl_cmd_health_reporter_get_dump_one(struct sk_buff *msg,
return 0; return 0;
} }
const struct devlink_cmd devl_cmd_health_reporter_get = { int devlink_nl_health_reporter_get_dumpit(struct sk_buff *skb,
.dump_one = devlink_nl_cmd_health_reporter_get_dump_one, struct netlink_callback *cb)
}; {
return devlink_nl_dumpit(skb, cb,
devlink_nl_health_reporter_get_dump_one);
}
int devlink_nl_cmd_health_reporter_set_doit(struct sk_buff *skb, int devlink_nl_cmd_health_reporter_set_doit(struct sk_buff *skb,
struct genl_info *info) struct genl_info *info)
......
This diff is collapsed.
...@@ -170,23 +170,6 @@ void devlink_nl_post_doit(const struct genl_split_ops *ops, ...@@ -170,23 +170,6 @@ void devlink_nl_post_doit(const struct genl_split_ops *ops,
devlink_put(devlink); devlink_put(devlink);
} }
static const struct devlink_cmd *devl_cmds[] = {
[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_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_dumpit(struct sk_buff *msg, struct netlink_callback *cb, int devlink_nl_dumpit(struct sk_buff *msg, struct netlink_callback *cb,
devlink_nl_dump_one_func_t *dump_one) devlink_nl_dump_one_func_t *dump_one)
{ {
...@@ -220,15 +203,6 @@ int devlink_nl_dumpit(struct sk_buff *msg, struct netlink_callback *cb, ...@@ -220,15 +203,6 @@ int devlink_nl_dumpit(struct sk_buff *msg, struct netlink_callback *cb,
return msg->len; return msg->len;
} }
int devlink_nl_instance_iter_dumpit(struct sk_buff *msg,
struct netlink_callback *cb)
{
const struct genl_dumpit_info *info = genl_dumpit_info(cb);
const struct devlink_cmd *cmd = devl_cmds[info->op.cmd];
return devlink_nl_dumpit(msg, cb, cmd->dump_one);
}
struct genl_family devlink_nl_family __ro_after_init = { struct genl_family devlink_nl_family __ro_after_init = {
.name = DEVLINK_GENL_NAME, .name = DEVLINK_GENL_NAME,
.version = DEVLINK_GENL_VERSION, .version = DEVLINK_GENL_VERSION,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment