@@ -232,77 +232,73 @@ int devlink_nl_instance_iter_dumpit(struct sk_buff *msg,
return msg->len;
}
+#define __DEVL_NL_OP_DO(cmd_subname, doit_subname, pre_doit_suffix, _validate, \
+ _maxattr, _policy) \
+ { \
+ .cmd = DEVLINK_CMD_##cmd_subname, \
+ .pre_doit = devlink_nl_pre_doit_##pre_doit_suffix, \
+ .doit = devlink_nl_cmd_##doit_subname##_doit, \
+ .post_doit = devlink_nl_post_doit, \
+ .flags = GENL_CMD_CAP_DO, \
+ .validate = _validate, \
+ .maxattr = _maxattr, \
+ .policy = _policy, \
+ }
+
+#define __DEVL_NL_OP_DUMP(cmd_subname, _validate, _maxattr, _policy) \
+ { \
+ .cmd = DEVLINK_CMD_##cmd_subname, \
+ .dumpit = devlink_nl_instance_iter_dumpit, \
+ .flags = GENL_CMD_CAP_DUMP, \
+ .validate = _validate, \
+ .maxattr = _maxattr, \
+ .policy = _policy, \
+ }
+
+#define __DEVL_NL_OP_LEGACY_DO(cmd_subname, doit_subname, pre_doit_suffix, \
+ validate) \
+ __DEVL_NL_OP_DO(cmd_subname, doit_subname, pre_doit_suffix, validate, \
+ DEVLINK_ATTR_MAX, devlink_nl_policy)
+
+#define __DEVL_NL_OP_LEGACY_DUMP(cmd_subname, validate) \
+ __DEVL_NL_OP_DUMP(cmd_subname, validate, \
+ DEVLINK_ATTR_MAX, devlink_nl_policy)
+
+#define DEVL_NL_OP_LEGACY_DO(cmd_subname, doit_subname, pre_doit_suffix) \
+ __DEVL_NL_OP_LEGACY_DO(cmd_subname, doit_subname, pre_doit_suffix, \
+ GENL_DONT_VALIDATE_STRICT)
+
+#define DEVL_NL_OP_LEGACY_DUMP(cmd_subname) \
+ __DEVL_NL_OP_LEGACY_DUMP(cmd_subname, GENL_DONT_VALIDATE_DUMP_STRICT)
+
+#define DEVL_NL_OP_LEGACY_STRICT_DO(cmd_subname, doit_subname, pre_doit_suffix) \
+ __DEVL_NL_OP_LEGACY_DO(cmd_subname, doit_subname, pre_doit_suffix, 0)
+
+#define DEVL_NL_OP_LEGACY_STRICT_DUMP(cmd_subname) \
+ __DEVL_NL_OP_LEGACY_DUMP(cmd_subname, 0)
+
+#define DEVL_NL_OP_DO(cmd_subname, doit_subname, pre_doit_suffix, \
+ maxattr, policy) \
+ __DEVL_NL_OP_DO(cmd_subname, doit_subname, pre_doit_suffix, 0, \
+ maxattr, policy)
+
+#define DEVL_NL_OP_DUMP(cmd_subname, maxattr, policy) \
+ __DEVL_NL_OP_DUMP(cmd_subname, 0, maxattr, policy)
+
static const struct genl_split_ops devlink_nl_split_ops[] = {
- {
- .cmd = DEVLINK_CMD_PORT_GET,
- .pre_doit = devlink_nl_pre_doit_port,
- .doit = devlink_nl_cmd_port_get_doit,
- .post_doit = devlink_nl_post_doit,
- .flags = GENL_CMD_CAP_DO,
- .validate = GENL_DONT_VALIDATE_STRICT,
- .maxattr = DEVLINK_ATTR_MAX,
- .policy = devlink_nl_policy,
- },
- {
- .cmd = DEVLINK_CMD_PORT_GET,
- .dumpit = devlink_nl_instance_iter_dumpit,
- .flags = GENL_CMD_CAP_DUMP,
- .validate = GENL_DONT_VALIDATE_DUMP,
- .maxattr = DEVLINK_ATTR_MAX,
- .policy = devlink_nl_policy,
- },
- {
- .cmd = DEVLINK_CMD_PARAM_GET,
- .pre_doit = devlink_nl_pre_doit_simple,
- .doit = devlink_nl_cmd_param_get_doit,
- .post_doit = devlink_nl_post_doit,
- .flags = GENL_CMD_CAP_DO,
- .validate = GENL_DONT_VALIDATE_STRICT,
- .maxattr = DEVLINK_ATTR_MAX,
- .policy = devlink_nl_policy,
- },
- {
- .cmd = DEVLINK_CMD_PARAM_GET,
- .dumpit = devlink_nl_instance_iter_dumpit,
- .flags = GENL_CMD_CAP_DUMP,
- .validate = GENL_DONT_VALIDATE_DUMP,
- .maxattr = DEVLINK_ATTR_MAX,
- .policy = devlink_nl_policy,
- },
- {
- .cmd = DEVLINK_CMD_HEALTH_REPORTER_GET,
- .pre_doit = devlink_nl_pre_doit_port_optional,
- .doit = devlink_nl_cmd_health_reporter_get_doit,
- .post_doit = devlink_nl_post_doit,
- .flags = GENL_CMD_CAP_DO,
- .validate = GENL_DONT_VALIDATE_STRICT,
- .maxattr = DEVLINK_ATTR_MAX,
- .policy = devlink_nl_policy,
- },
- {
- .cmd = DEVLINK_CMD_HEALTH_REPORTER_GET,
- .dumpit = devlink_nl_instance_iter_dumpit,
- .flags = GENL_CMD_CAP_DUMP,
- .validate = GENL_DONT_VALIDATE_DUMP,
- .maxattr = DEVLINK_ATTR_MAX,
- .policy = devlink_nl_policy,
- },
- {
- .cmd = DEVLINK_CMD_TRAP_GET,
- .pre_doit = devlink_nl_pre_doit_simple,
- .doit = devlink_nl_cmd_trap_get_doit,
- .post_doit = devlink_nl_post_doit,
- .flags = GENL_CMD_CAP_DO,
- .maxattr = DEVLINK_ATTR_MAX,
- .policy = devlink_nl_policy,
- },
- {
- .cmd = DEVLINK_CMD_TRAP_GET,
- .dumpit = devlink_nl_instance_iter_dumpit,
- .flags = GENL_CMD_CAP_DUMP,
- .maxattr = DEVLINK_ATTR_MAX,
- .policy = devlink_nl_policy,
- },
+ DEVL_NL_OP_LEGACY_DO(PORT_GET, port_get, port),
+ DEVL_NL_OP_LEGACY_DUMP(PORT_GET),
+ DEVL_NL_OP_LEGACY_DO(PARAM_GET, param_get, simple),
+ DEVL_NL_OP_LEGACY_DUMP(PARAM_GET),
+ DEVL_NL_OP_LEGACY_DO(HEALTH_REPORTER_GET, health_reporter_get,
+ port_optional),
+ DEVL_NL_OP_LEGACY_DUMP(HEALTH_REPORTER_GET),
+ DEVL_NL_OP_LEGACY_STRICT_DO(TRAP_GET, trap_get, simple),
+ DEVL_NL_OP_LEGACY_STRICT_DUMP(TRAP_GET),
+ /* For every newly added command put above this line the set of macros
+ * DEVL_NL_OP_DO and DEVL_NL_OP_DUMP should be used. Note that
+ * there is an exception with non-iterator dump implementation.
+ */
};
struct genl_family devlink_nl_family __ro_after_init = {