Commit 4fb56e3e authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'devlink-finish-conversion-to-generated-split_ops'

Jiri Pirko says:

====================
devlink: finish conversion to generated split_ops

This patchset converts the remaining genetlink commands to generated
split_ops and removes the existing small_ops arrays entirely
alongside with shared netlink attribute policy.

Patches #1-#6 are just small preparations and small fixes on multiple
              places. Note that couple of patches contain the "Fixes"
              tag but no need to put them into -net tree.
Patch #7 is a simple rename preparation
Patch #8 is the main one in this set and adds actual definitions of cmds
         in to yaml file.
Patches #9-#10 finalize the change removing bits that are no longer in
               use.
====================

Link: https://lore.kernel.org/r/20231021112711.660606-1-jiri@resnulli.usSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 70b1aca3 cebe7306
......@@ -192,7 +192,7 @@ properties:
type: string
type: &attr-type
description: The netlink attribute type
enum: [ unused, pad, flag, binary,
enum: [ unused, pad, flag, binary, bitfield32,
uint, sint, u8, u16, u32, u64, s32, s64,
string, nest, array-nest, nest-type-value ]
doc:
......
This diff is collapsed.
......@@ -182,7 +182,7 @@ members
- ``name`` - The attribute name of the struct member
- ``type`` - One of the scalar types ``u8``, ``u16``, ``u32``, ``u64``, ``s8``,
``s16``, ``s32``, ``s64``, ``string`` or ``binary``.
``s16``, ``s32``, ``s64``, ``string``, ``binary`` or ``bitfield32``.
- ``byte-order`` - ``big-endian`` or ``little-endian``
- ``doc``, ``enum``, ``enum-as-flags``, ``display-hint`` - Same as for
:ref:`attribute definitions <attribute_properties>`
......
......@@ -265,7 +265,7 @@ enum {
* Documentation/networking/devlink/devlink-flash.rst
*
*/
enum {
enum devlink_flash_overwrite {
DEVLINK_FLASH_OVERWRITE_SETTINGS_BIT,
DEVLINK_FLASH_OVERWRITE_IDENTIFIERS_BIT,
......
......@@ -492,7 +492,7 @@ devlink_nl_reload_actions_performed_snd(struct devlink *devlink, u32 actions_per
return -EMSGSIZE;
}
int devlink_nl_cmd_reload(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_reload_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
enum devlink_reload_action action;
......@@ -658,7 +658,7 @@ static int devlink_nl_eswitch_fill(struct sk_buff *msg, struct devlink *devlink,
return err;
}
int devlink_nl_cmd_eswitch_get_doit(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_eswitch_get_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct sk_buff *msg;
......@@ -679,7 +679,7 @@ int devlink_nl_cmd_eswitch_get_doit(struct sk_buff *skb, struct genl_info *info)
return genlmsg_reply(msg, info);
}
int devlink_nl_cmd_eswitch_set_doit(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_eswitch_set_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
const struct devlink_ops *ops = devlink->ops;
......@@ -1108,7 +1108,7 @@ static int devlink_flash_component_get(struct devlink *devlink,
return 0;
}
int devlink_nl_cmd_flash_update(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_flash_update_doit(struct sk_buff *skb, struct genl_info *info)
{
struct nlattr *nla_overwrite_mask, *nla_file_name;
struct devlink_flash_update_params params = {};
......@@ -1351,7 +1351,7 @@ static const struct nla_policy devlink_selftest_nl_policy[DEVLINK_ATTR_SELFTEST_
[DEVLINK_ATTR_SELFTEST_ID_FLASH] = { .type = NLA_FLAG },
};
int devlink_nl_cmd_selftests_run(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_selftests_run_doit(struct sk_buff *skb, struct genl_info *info)
{
struct nlattr *tb[DEVLINK_ATTR_SELFTEST_ID_MAX + 1];
struct devlink *devlink = info->user_ptr[0];
......
......@@ -227,67 +227,3 @@ int devlink_rate_nodes_check(struct devlink *devlink, u16 mode,
/* Linecards */
unsigned int devlink_linecard_index(struct devlink_linecard *linecard);
/* Devlink nl cmds */
int devlink_nl_cmd_reload(struct sk_buff *skb, struct genl_info *info);
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_flash_update(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_cmd_port_set_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_port_split_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_port_unsplit_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_port_new_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_port_del_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_sb_pool_set_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_sb_port_pool_set_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_sb_tc_pool_bind_set_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_sb_occ_snapshot_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_sb_occ_max_clear_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_dpipe_table_get(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_dpipe_entries_get(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_dpipe_headers_get(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_dpipe_table_counters_set(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_resource_set(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_resource_dump(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_param_set_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_port_param_get_dumpit(struct sk_buff *msg,
struct netlink_callback *cb);
int devlink_nl_cmd_port_param_get_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_port_param_set_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_region_new(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_region_del(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_region_read_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_cmd_health_reporter_set_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_health_reporter_recover_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_health_reporter_diagnose_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_health_reporter_dump_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_cmd_health_reporter_dump_clear_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_health_reporter_test_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_trap_set_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_trap_group_set_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_trap_policer_set_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_rate_set_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_rate_new_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_rate_del_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_linecard_set_doit(struct sk_buff *skb,
struct genl_info *info);
......@@ -289,7 +289,7 @@ static int devlink_dpipe_tables_fill(struct genl_info *info,
return err;
}
int devlink_nl_cmd_dpipe_table_get(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_dpipe_table_get_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
const char *table_name = NULL;
......@@ -562,8 +562,8 @@ static int devlink_dpipe_entries_fill(struct genl_info *info,
return genlmsg_reply(dump_ctx.skb, info);
}
int devlink_nl_cmd_dpipe_entries_get(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_dpipe_entries_get_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct devlink_dpipe_table *table;
......@@ -712,8 +712,8 @@ static int devlink_dpipe_headers_fill(struct genl_info *info,
return err;
}
int devlink_nl_cmd_dpipe_headers_get(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_dpipe_headers_get_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
......@@ -746,8 +746,8 @@ static int devlink_dpipe_table_counters_set(struct devlink *devlink,
return 0;
}
int devlink_nl_cmd_dpipe_table_counters_set(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_dpipe_table_counters_set_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
const char *table_name;
......
......@@ -452,8 +452,8 @@ int devlink_nl_health_reporter_get_dumpit(struct sk_buff *skb,
devlink_nl_health_reporter_get_dump_one);
}
int devlink_nl_cmd_health_reporter_set_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_health_reporter_set_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct devlink_health_reporter *reporter;
......@@ -655,8 +655,8 @@ devlink_health_reporter_state_update(struct devlink_health_reporter *reporter,
}
EXPORT_SYMBOL_GPL(devlink_health_reporter_state_update);
int devlink_nl_cmd_health_reporter_recover_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_health_reporter_recover_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct devlink_health_reporter *reporter;
......@@ -1108,8 +1108,8 @@ static int devlink_fmsg_dumpit(struct devlink_fmsg *fmsg, struct sk_buff *skb,
return err;
}
int devlink_nl_cmd_health_reporter_diagnose_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_health_reporter_diagnose_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct devlink_health_reporter *reporter;
......@@ -1163,8 +1163,8 @@ devlink_health_reporter_get_from_cb_lock(struct netlink_callback *cb)
return reporter;
}
int devlink_nl_cmd_health_reporter_dump_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb)
int devlink_nl_health_reporter_dump_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb)
{
struct devlink_nl_dump_state *state = devlink_dump_state(cb);
struct devlink_health_reporter *reporter;
......@@ -1202,8 +1202,8 @@ int devlink_nl_cmd_health_reporter_dump_get_dumpit(struct sk_buff *skb,
return err;
}
int devlink_nl_cmd_health_reporter_dump_clear_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_health_reporter_dump_clear_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct devlink_health_reporter *reporter;
......@@ -1219,8 +1219,8 @@ int devlink_nl_cmd_health_reporter_dump_clear_doit(struct sk_buff *skb,
return 0;
}
int devlink_nl_cmd_health_reporter_test_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_health_reporter_test_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct devlink_health_reporter *reporter;
......
......@@ -369,8 +369,7 @@ static int devlink_linecard_type_unset(struct devlink_linecard *linecard,
return err;
}
int devlink_nl_cmd_linecard_set_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_linecard_set_doit(struct sk_buff *skb, struct genl_info *info)
{
struct netlink_ext_ack *extack = info->extack;
struct devlink *devlink = info->user_ptr[0];
......
This diff is collapsed.
This diff is collapsed.
......@@ -11,8 +11,12 @@
#include <uapi/linux/devlink.h>
/* Common nested types */
extern const struct nla_policy devlink_dl_port_function_nl_policy[DEVLINK_PORT_FN_ATTR_CAPS + 1];
extern const struct nla_policy devlink_dl_selftest_id_nl_policy[DEVLINK_ATTR_SELFTEST_ID_FLASH + 1];
/* Ops table for devlink */
extern const struct genl_split_ops devlink_nl_ops[32];
extern const struct genl_split_ops devlink_nl_ops[73];
int devlink_nl_pre_doit(const struct genl_split_ops *ops, struct sk_buff *skb,
struct genl_info *info);
......@@ -30,25 +34,61 @@ int devlink_nl_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb);
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_port_set_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_port_new_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_port_del_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_port_split_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_port_unsplit_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_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_sb_pool_set_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_sb_port_pool_get_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_sb_port_pool_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_sb_port_pool_set_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_sb_tc_pool_bind_get_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_sb_tc_pool_bind_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_sb_tc_pool_bind_set_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_sb_occ_snapshot_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_sb_occ_max_clear_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_eswitch_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_eswitch_set_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_dpipe_table_get_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_dpipe_entries_get_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_dpipe_headers_get_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_dpipe_table_counters_set_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_resource_set_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_resource_dump_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_reload_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_param_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_param_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_param_set_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_region_new_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_region_del_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_region_read_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_port_param_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_port_param_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_port_param_set_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_info_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_info_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
......@@ -56,24 +96,46 @@ int devlink_nl_health_reporter_get_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_health_reporter_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_health_reporter_set_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_health_reporter_recover_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_health_reporter_diagnose_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_health_reporter_dump_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_health_reporter_dump_clear_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_flash_update_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_set_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_group_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_trap_group_set_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_trap_policer_get_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_trap_policer_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_trap_policer_set_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_health_reporter_test_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_rate_set_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_rate_new_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_rate_del_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_linecard_set_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_selftests_run_doit(struct sk_buff *skb, struct genl_info *info);
#endif /* _LINUX_DEVLINK_GEN_H */
......@@ -581,7 +581,7 @@ static int __devlink_nl_cmd_param_set_doit(struct devlink *devlink,
return 0;
}
int devlink_nl_cmd_param_set_doit(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_param_set_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
......@@ -589,22 +589,22 @@ int devlink_nl_cmd_param_set_doit(struct sk_buff *skb, struct genl_info *info)
info, DEVLINK_CMD_PARAM_NEW);
}
int devlink_nl_cmd_port_param_get_dumpit(struct sk_buff *msg,
struct netlink_callback *cb)
int devlink_nl_port_param_get_dumpit(struct sk_buff *msg,
struct netlink_callback *cb)
{
NL_SET_ERR_MSG(cb->extack, "Port params are not supported");
return msg->len;
}
int devlink_nl_cmd_port_param_get_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_port_param_get_doit(struct sk_buff *skb,
struct genl_info *info)
{
NL_SET_ERR_MSG(info->extack, "Port params are not supported");
return -EINVAL;
}
int devlink_nl_cmd_port_param_set_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_port_param_set_doit(struct sk_buff *skb,
struct genl_info *info)
{
NL_SET_ERR_MSG(info->extack, "Port params are not supported");
return -EINVAL;
......
......@@ -772,7 +772,7 @@ static int devlink_port_function_set(struct devlink_port *port,
return err;
}
int devlink_nl_cmd_port_set_doit(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_port_set_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink_port *devlink_port = info->user_ptr[1];
int err;
......@@ -798,7 +798,7 @@ int devlink_nl_cmd_port_set_doit(struct sk_buff *skb, struct genl_info *info)
return 0;
}
int devlink_nl_cmd_port_split_doit(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_port_split_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink_port *devlink_port = info->user_ptr[1];
struct devlink *devlink = info->user_ptr[0];
......@@ -829,8 +829,7 @@ int devlink_nl_cmd_port_split_doit(struct sk_buff *skb, struct genl_info *info)
info->extack);
}
int devlink_nl_cmd_port_unsplit_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_port_unsplit_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink_port *devlink_port = info->user_ptr[1];
struct devlink *devlink = info->user_ptr[0];
......@@ -840,7 +839,7 @@ int devlink_nl_cmd_port_unsplit_doit(struct sk_buff *skb,
return devlink_port->ops->port_unsplit(devlink, devlink_port, info->extack);
}
int devlink_nl_cmd_port_new_doit(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_port_new_doit(struct sk_buff *skb, struct genl_info *info)
{
struct netlink_ext_ack *extack = info->extack;
struct devlink_port_new_attrs new_attrs = {};
......@@ -904,7 +903,7 @@ int devlink_nl_cmd_port_new_doit(struct sk_buff *skb, struct genl_info *info)
return err;
}
int devlink_nl_cmd_port_del_doit(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_port_del_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink_port *devlink_port = info->user_ptr[1];
struct netlink_ext_ack *extack = info->extack;
......
......@@ -458,7 +458,7 @@ static bool devlink_rate_set_ops_supported(const struct devlink_ops *ops,
return true;
}
int devlink_nl_cmd_rate_set_doit(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_rate_set_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct devlink_rate *devlink_rate;
......@@ -480,7 +480,7 @@ int devlink_nl_cmd_rate_set_doit(struct sk_buff *skb, struct genl_info *info)
return err;
}
int devlink_nl_cmd_rate_new_doit(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_rate_new_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct devlink_rate *rate_node;
......@@ -536,7 +536,7 @@ int devlink_nl_cmd_rate_new_doit(struct sk_buff *skb, struct genl_info *info)
return err;
}
int devlink_nl_cmd_rate_del_doit(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_rate_del_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct devlink_rate *rate_node;
......
......@@ -588,7 +588,7 @@ int devlink_nl_region_get_dumpit(struct sk_buff *skb,
return devlink_nl_dumpit(skb, cb, devlink_nl_region_get_dump_one);
}
int devlink_nl_cmd_region_del(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_region_del_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct devlink_snapshot *snapshot;
......@@ -633,7 +633,7 @@ int devlink_nl_cmd_region_del(struct sk_buff *skb, struct genl_info *info)
return 0;
}
int devlink_nl_cmd_region_new(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_region_new_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct devlink_snapshot *snapshot;
......@@ -863,8 +863,8 @@ devlink_region_direct_fill(void *cb_priv, u8 *chunk, u32 chunk_size,
curr_offset, chunk_size, chunk);
}
int devlink_nl_cmd_region_read_dumpit(struct sk_buff *skb,
struct netlink_callback *cb)
int devlink_nl_region_read_dumpit(struct sk_buff *skb,
struct netlink_callback *cb)
{
const struct genl_dumpit_info *info = genl_dumpit_info(cb);
struct devlink_nl_dump_state *state = devlink_dump_state(cb);
......
......@@ -105,7 +105,7 @@ devlink_resource_validate_size(struct devlink_resource *resource, u64 size,
return err;
}
int devlink_nl_cmd_resource_set(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_resource_set_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct devlink_resource *resource;
......@@ -285,7 +285,7 @@ static int devlink_resource_fill(struct genl_info *info,
return err;
}
int devlink_nl_cmd_resource_dump(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_resource_dump_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
......
......@@ -413,7 +413,7 @@ static int devlink_sb_pool_set(struct devlink *devlink, unsigned int sb_index,
return -EOPNOTSUPP;
}
int devlink_nl_cmd_sb_pool_set_doit(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_sb_pool_set_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
enum devlink_sb_threshold_type threshold_type;
......@@ -621,8 +621,8 @@ static int devlink_sb_port_pool_set(struct devlink_port *devlink_port,
return -EOPNOTSUPP;
}
int devlink_nl_cmd_sb_port_pool_set_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_sb_port_pool_set_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink_port *devlink_port = info->user_ptr[1];
struct devlink *devlink = info->user_ptr[0];
......@@ -861,8 +861,8 @@ static int devlink_sb_tc_pool_bind_set(struct devlink_port *devlink_port,
return -EOPNOTSUPP;
}
int devlink_nl_cmd_sb_tc_pool_bind_set_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_sb_tc_pool_bind_set_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink_port *devlink_port = info->user_ptr[1];
struct devlink *devlink = info->user_ptr[0];
......@@ -900,8 +900,7 @@ int devlink_nl_cmd_sb_tc_pool_bind_set_doit(struct sk_buff *skb,
pool_index, threshold, info->extack);
}
int devlink_nl_cmd_sb_occ_snapshot_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_sb_occ_snapshot_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
const struct devlink_ops *ops = devlink->ops;
......@@ -916,8 +915,8 @@ int devlink_nl_cmd_sb_occ_snapshot_doit(struct sk_buff *skb,
return -EOPNOTSUPP;
}
int devlink_nl_cmd_sb_occ_max_clear_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_sb_occ_max_clear_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
const struct devlink_ops *ops = devlink->ops;
......
......@@ -414,7 +414,7 @@ static int devlink_trap_action_set(struct devlink *devlink,
info->extack);
}
int devlink_nl_cmd_trap_set_doit(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_trap_set_doit(struct sk_buff *skb, struct genl_info *info)
{
struct netlink_ext_ack *extack = info->extack;
struct devlink *devlink = info->user_ptr[0];
......@@ -684,8 +684,7 @@ static int devlink_trap_group_set(struct devlink *devlink,
return 0;
}
int devlink_nl_cmd_trap_group_set_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_trap_group_set_doit(struct sk_buff *skb, struct genl_info *info)
{
struct netlink_ext_ack *extack = info->extack;
struct devlink *devlink = info->user_ptr[0];
......@@ -926,8 +925,8 @@ devlink_trap_policer_set(struct devlink *devlink,
return 0;
}
int devlink_nl_cmd_trap_policer_set_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_trap_policer_set_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink_trap_policer_item *policer_item;
struct netlink_ext_ack *extack = info->extack;
......
......@@ -225,7 +225,8 @@ static void genl_op_from_split(struct genl_op_iter *iter)
}
if (i + cnt < family->n_split_ops &&
family->split_ops[i + cnt].flags & GENL_CMD_CAP_DUMP) {
family->split_ops[i + cnt].flags & GENL_CMD_CAP_DUMP &&
(!cnt || family->split_ops[i + cnt].cmd == iter->doit.cmd)) {
iter->dumpit = family->split_ops[i + cnt];
genl_op_fill_in_reject_policy_split(family, &iter->dumpit);
cnt++;
......
This diff is collapsed.
This diff is collapsed.
......@@ -379,6 +379,12 @@ int ynl_attr_validate(struct ynl_parse_arg *yarg, const struct nlattr *attr)
yerr(yarg->ys, YNL_ERROR_ATTR_INVALID,
"Invalid attribute (string %s)", policy->name);
return -1;
case YNL_PT_BITFIELD32:
if (len == sizeof(struct nla_bitfield32))
break;
yerr(yarg->ys, YNL_ERROR_ATTR_INVALID,
"Invalid attribute (bitfield32 %s)", policy->name);
return -1;
default:
yerr(yarg->ys, YNL_ERROR_ATTR_INVALID,
"Invalid attribute (unknown %s)", policy->name);
......
......@@ -135,6 +135,7 @@ enum ynl_policy_type {
YNL_PT_U64,
YNL_PT_UINT,
YNL_PT_NUL_STR,
YNL_PT_BITFIELD32,
};
struct ynl_policy_attr {
......
......@@ -478,6 +478,8 @@ class YnlFamily(SpecFamily):
elif attr['type'] in NlAttr.type_formats:
format = NlAttr.get_format(attr['type'], attr.byte_order)
attr_payload = format.pack(int(value))
elif attr['type'] in "bitfield32":
attr_payload = struct.pack("II", int(value["value"]), int(value["selector"]))
else:
raise Exception(f'Unknown type at {space} {name} {value} {attr["type"]}')
......@@ -545,14 +547,19 @@ class YnlFamily(SpecFamily):
decoded = attr.as_auto_scalar(attr_spec['type'], attr_spec.byte_order)
elif attr_spec["type"] in NlAttr.type_formats:
decoded = attr.as_scalar(attr_spec['type'], attr_spec.byte_order)
if 'enum' in attr_spec:
decoded = self._decode_enum(decoded, attr_spec)
elif attr_spec["type"] == 'array-nest':
decoded = self._decode_array_nest(attr, attr_spec)
elif attr_spec["type"] == 'bitfield32':
value, selector = struct.unpack("II", attr.raw)
if 'enum' in attr_spec:
value = self._decode_enum(value, attr_spec)
selector = self._decode_enum(selector, attr_spec)
decoded = {"value": value, "selector": selector}
else:
raise Exception(f'Unknown {attr_spec["type"]} with name {attr_spec["name"]}')
if 'enum' in attr_spec:
decoded = self._decode_enum(decoded, attr_spec)
if not attr_spec.is_multi:
rsp[attr_spec['name']] = decoded
elif attr_spec.name in rsp:
......
......@@ -488,6 +488,31 @@ class TypeBinary(Type):
f'memcpy({member}, {self.c_name}, {presence}_len);']
class TypeBitfield32(Type):
def _complex_member_type(self, ri):
return "struct nla_bitfield32"
def _attr_typol(self):
return f'.type = YNL_PT_BITFIELD32, '
def _attr_policy(self, policy):
if not 'enum' in self.attr:
raise Exception('Enum required for bitfield32 attr')
enum = self.family.consts[self.attr['enum']]
mask = enum.get_mask(as_flags=True)
return f"NLA_POLICY_BITFIELD32({mask})"
def attr_put(self, ri, var):
line = f"mnl_attr_put(nlh, {self.enum_name}, sizeof(struct nla_bitfield32), &{var}->{self.c_name})"
self._attr_put_line(ri, var, line)
def _attr_get(self, ri, var):
return f"memcpy(&{var}->{self.c_name}, mnl_attr_get_payload(attr), sizeof(struct nla_bitfield32));", None, None
def _setter_lines(self, ri, member, presence):
return [f"memcpy(&{member}, {self.c_name}, sizeof(struct nla_bitfield32));"]
class TypeNest(Type):
def _complex_member_type(self, ri):
return self.nested_struct_type
......@@ -786,6 +811,8 @@ class AttrSet(SpecAttrSet):
t = TypeString(self.family, self, elem, value)
elif elem['type'] == 'binary':
t = TypeBinary(self.family, self, elem, value)
elif elem['type'] == 'bitfield32':
t = TypeBitfield32(self.family, self, elem, value)
elif elem['type'] == 'nest':
t = TypeNest(self.family, self, elem, value)
elif elem['type'] == 'array-nest':
......@@ -1085,10 +1112,13 @@ class RenderInfo:
# 'do' and 'dump' response parsing is identical
self.type_consistent = True
if op_mode != 'do' and 'dump' in op and 'do' in op:
if ('reply' in op['do']) != ('reply' in op["dump"]):
self.type_consistent = False
elif 'reply' in op['do'] and op["do"]["reply"] != op["dump"]["reply"]:
if op_mode != 'do' and 'dump' in op:
if 'do' in op:
if ('reply' in op['do']) != ('reply' in op["dump"]):
self.type_consistent = False
elif 'reply' in op['do'] and op["do"]["reply"] != op["dump"]["reply"]:
self.type_consistent = False
else:
self.type_consistent = False
self.attr_set = attr_set
......@@ -2414,6 +2444,16 @@ def render_user_family(family, cw, prototype):
cw.block_end(line=';')
def family_contains_bitfield32(family):
for _, attr_set in family.attr_sets.items():
if attr_set.subset_of:
continue
for _, attr in attr_set.items():
if attr.type == "bitfield32":
return True
return False
def find_kernel_root(full_path):
sub_path = ''
while True:
......@@ -2499,6 +2539,8 @@ def main():
cw.p('#include <string.h>')
if args.header:
cw.p('#include <linux/types.h>')
if family_contains_bitfield32(parsed):
cw.p('#include <linux/netlink.h>')
else:
cw.p(f'#include "{parsed.name}-user.h"')
cw.p('#include "ynl.h"')
......
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