// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
/* Do not edit directly, auto-generated from: */
/* Documentation/netlink/specs/devlink.yaml */
/* YNL-GEN kernel source */
/* To regenerate run: tools/net/ynl/ynl-regen.sh */
#include <net/netlink.h>
#include <net/genetlink.h>
#include "netlink_gen.h"
#include <uapi/linux/devlink.h>
/* Integer value ranges */
static const struct netlink_range_validation devlink_attr_index_range = {
.max = U32_MAX,
};
/* Sparse enums validation callbacks */
static int
devlink_attr_param_type_validate(const struct nlattr *attr,
struct netlink_ext_ack *extack)
{
switch (nla_get_u8(attr)) {
case DEVLINK_VAR_ATTR_TYPE_U8:
fallthrough;
case DEVLINK_VAR_ATTR_TYPE_U16:
fallthrough;
case DEVLINK_VAR_ATTR_TYPE_U32:
fallthrough;
case DEVLINK_VAR_ATTR_TYPE_U64:
fallthrough;
case DEVLINK_VAR_ATTR_TYPE_STRING:
fallthrough;
case DEVLINK_VAR_ATTR_TYPE_FLAG:
fallthrough;
case DEVLINK_VAR_ATTR_TYPE_NUL_STRING:
fallthrough;
case DEVLINK_VAR_ATTR_TYPE_BINARY:
return 0;
}
NL_SET_ERR_MSG_ATTR(extack, attr, "invalid enum value");
return -EINVAL;
}
/* Common nested types */
const struct nla_policy devlink_dl_port_function_nl_policy[DEVLINK_PORT_FN_ATTR_CAPS + 1] = {
[DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR] = { .type = NLA_BINARY, },
[DEVLINK_PORT_FN_ATTR_STATE] = NLA_POLICY_MAX(NLA_U8, 1),
[DEVLINK_PORT_FN_ATTR_OPSTATE] = NLA_POLICY_MAX(NLA_U8, 1),
[DEVLINK_PORT_FN_ATTR_CAPS] = NLA_POLICY_BITFIELD32(15),
};
const struct nla_policy devlink_dl_rate_tc_bws_nl_policy[DEVLINK_RATE_TC_ATTR_BW + 1] = {
[DEVLINK_RATE_TC_ATTR_INDEX] = NLA_POLICY_MAX(NLA_U8, DEVLINK_RATE_TC_INDEX_MAX),
[DEVLINK_RATE_TC_ATTR_BW] = { .type = NLA_U32,