From 6906ebbe00247d5fbabc9f887197b92da6d50d2b Mon Sep 17 00:00:00 2001 From: Jakub Kicinski Date: Thu, 4 Apr 2024 12:01:01 -0700 Subject: [PATCH] sync to upstream 1148c4098e91 ("Merge branch 'selftests-net-groundwork-for-ynl-based-tests'") Signed-off-by: Jakub Kicinski --- generated/ethtool-user.c | 14 + generated/team-user.c | 598 ++++++++++++++++++++++++++++++++ generated/team-user.h | 1 + include/linux/ethtool_netlink.h | 4 + include/ynl-c/ethtool.h | 1 + include/ynl-c/team.h | 281 +++++++++++++++ 6 files changed, 899 insertions(+) create mode 100644 generated/team-user.c create mode 120000 generated/team-user.h create mode 100644 include/ynl-c/team.h diff --git a/generated/ethtool-user.c b/generated/ethtool-user.c index 5b480a5..f3e0025 100644 --- a/generated/ethtool-user.c +++ b/generated/ethtool-user.c @@ -90,6 +90,20 @@ const char *ethtool_stringset_str(enum ethtool_stringset value) return ethtool_stringset_strmap[value]; } +static const char * const ethtool_header_flags_strmap[] = { + [0] = "compact-bitsets", + [1] = "omit-reply", + [2] = "stats", +}; + +const char *ethtool_header_flags_str(int value) +{ + value = ffs(value) - 1; + if (value < 0 || value >= (int)YNL_ARRAY_SIZE(ethtool_header_flags_strmap)) + return NULL; + return ethtool_header_flags_strmap[value]; +} + /* Policies */ struct ynl_policy_attr ethtool_header_policy[ETHTOOL_A_HEADER_MAX + 1] = { [ETHTOOL_A_HEADER_DEV_INDEX] = { .name = "dev-index", .type = YNL_PT_U32, }, diff --git a/generated/team-user.c b/generated/team-user.c new file mode 100644 index 0000000..644376c --- /dev/null +++ b/generated/team-user.c @@ -0,0 +1,598 @@ +// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) +/* Do not edit directly, auto-generated from: */ +/* Documentation/netlink/specs/team.yaml */ +/* YNL-GEN user source */ + +#include +#include +#include "team-user.h" +#include "ynl.h" +#include + +#include + +/* Enums */ +static const char * const team_op_strmap[] = { + [TEAM_CMD_OPTIONS_SET] = "options-set", + [TEAM_CMD_OPTIONS_GET] = "options-get", + [TEAM_CMD_PORT_LIST_GET] = "port-list-get", +}; + +const char *team_op_str(int op) +{ + if (op < 0 || op >= (int)YNL_ARRAY_SIZE(team_op_strmap)) + return NULL; + return team_op_strmap[op]; +} + +/* Policies */ +struct ynl_policy_attr team_attr_option_policy[TEAM_ATTR_OPTION_MAX + 1] = { + [TEAM_ATTR_OPTION_UNSPEC] = { .name = "unspec", .type = YNL_PT_REJECT, }, + [TEAM_ATTR_OPTION_NAME] = { .name = "name", .type = YNL_PT_NUL_STR, }, + [TEAM_ATTR_OPTION_CHANGED] = { .name = "changed", .type = YNL_PT_FLAG, }, + [TEAM_ATTR_OPTION_TYPE] = { .name = "type", .type = YNL_PT_U8, }, + [TEAM_ATTR_OPTION_DATA] = { .name = "data", .type = YNL_PT_BINARY,}, + [TEAM_ATTR_OPTION_REMOVED] = { .name = "removed", .type = YNL_PT_FLAG, }, + [TEAM_ATTR_OPTION_PORT_IFINDEX] = { .name = "port-ifindex", .type = YNL_PT_U32, }, + [TEAM_ATTR_OPTION_ARRAY_INDEX] = { .name = "array-index", .type = YNL_PT_U32, }, +}; + +struct ynl_policy_nest team_attr_option_nest = { + .max_attr = TEAM_ATTR_OPTION_MAX, + .table = team_attr_option_policy, +}; + +struct ynl_policy_attr team_attr_port_policy[TEAM_ATTR_PORT_MAX + 1] = { + [TEAM_ATTR_PORT_UNSPEC] = { .name = "unspec", .type = YNL_PT_REJECT, }, + [TEAM_ATTR_PORT_IFINDEX] = { .name = "ifindex", .type = YNL_PT_U32, }, + [TEAM_ATTR_PORT_CHANGED] = { .name = "changed", .type = YNL_PT_FLAG, }, + [TEAM_ATTR_PORT_LINKUP] = { .name = "linkup", .type = YNL_PT_FLAG, }, + [TEAM_ATTR_PORT_SPEED] = { .name = "speed", .type = YNL_PT_U32, }, + [TEAM_ATTR_PORT_DUPLEX] = { .name = "duplex", .type = YNL_PT_U8, }, + [TEAM_ATTR_PORT_REMOVED] = { .name = "removed", .type = YNL_PT_FLAG, }, +}; + +struct ynl_policy_nest team_attr_port_nest = { + .max_attr = TEAM_ATTR_PORT_MAX, + .table = team_attr_port_policy, +}; + +struct ynl_policy_attr team_item_option_policy[TEAM_ATTR_ITEM_OPTION_MAX + 1] = { + [TEAM_ATTR_ITEM_OPTION_UNSPEC] = { .name = "option-unspec", .type = YNL_PT_REJECT, }, + [TEAM_ATTR_ITEM_OPTION] = { .name = "option", .type = YNL_PT_NEST, .nest = &team_attr_option_nest, }, +}; + +struct ynl_policy_nest team_item_option_nest = { + .max_attr = TEAM_ATTR_ITEM_OPTION_MAX, + .table = team_item_option_policy, +}; + +struct ynl_policy_attr team_item_port_policy[TEAM_ATTR_ITEM_PORT_MAX + 1] = { + [TEAM_ATTR_ITEM_PORT_UNSPEC] = { .name = "port-unspec", .type = YNL_PT_REJECT, }, + [TEAM_ATTR_ITEM_PORT] = { .name = "port", .type = YNL_PT_NEST, .nest = &team_attr_port_nest, }, +}; + +struct ynl_policy_nest team_item_port_nest = { + .max_attr = TEAM_ATTR_ITEM_PORT_MAX, + .table = team_item_port_policy, +}; + +struct ynl_policy_attr team_policy[TEAM_ATTR_MAX + 1] = { + [TEAM_ATTR_UNSPEC] = { .name = "unspec", .type = YNL_PT_REJECT, }, + [TEAM_ATTR_TEAM_IFINDEX] = { .name = "team-ifindex", .type = YNL_PT_U32, }, + [TEAM_ATTR_LIST_OPTION] = { .name = "list-option", .type = YNL_PT_NEST, .nest = &team_item_option_nest, }, + [TEAM_ATTR_LIST_PORT] = { .name = "list-port", .type = YNL_PT_NEST, .nest = &team_item_port_nest, }, +}; + +struct ynl_policy_nest team_nest = { + .max_attr = TEAM_ATTR_MAX, + .table = team_policy, +}; + +/* Common nested types */ +void team_attr_option_free(struct team_attr_option *obj) +{ + free(obj->name); + free(obj->data); +} + +int team_attr_option_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct team_attr_option *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.name_len) + ynl_attr_put_str(nlh, TEAM_ATTR_OPTION_NAME, obj->name); + if (obj->_present.changed) + ynl_attr_put(nlh, TEAM_ATTR_OPTION_CHANGED, NULL, 0); + if (obj->_present.type) + ynl_attr_put_u8(nlh, TEAM_ATTR_OPTION_TYPE, obj->type); + if (obj->_present.data_len) + ynl_attr_put(nlh, TEAM_ATTR_OPTION_DATA, obj->data, obj->_present.data_len); + if (obj->_present.removed) + ynl_attr_put(nlh, TEAM_ATTR_OPTION_REMOVED, NULL, 0); + if (obj->_present.port_ifindex) + ynl_attr_put_u32(nlh, TEAM_ATTR_OPTION_PORT_IFINDEX, obj->port_ifindex); + if (obj->_present.array_index) + ynl_attr_put_u32(nlh, TEAM_ATTR_OPTION_ARRAY_INDEX, obj->array_index); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int team_attr_option_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct team_attr_option *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TEAM_ATTR_OPTION_NAME) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = strnlen(ynl_attr_get_str(attr), ynl_attr_data_len(attr)); + dst->_present.name_len = len; + dst->name = malloc(len + 1); + memcpy(dst->name, ynl_attr_get_str(attr), len); + dst->name[len] = 0; + } else if (type == TEAM_ATTR_OPTION_CHANGED) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.changed = 1; + } else if (type == TEAM_ATTR_OPTION_TYPE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.type = 1; + dst->type = ynl_attr_get_u8(attr); + } else if (type == TEAM_ATTR_OPTION_DATA) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_present.data_len = len; + dst->data = malloc(len); + memcpy(dst->data, ynl_attr_data(attr), len); + } else if (type == TEAM_ATTR_OPTION_REMOVED) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.removed = 1; + } else if (type == TEAM_ATTR_OPTION_PORT_IFINDEX) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.port_ifindex = 1; + dst->port_ifindex = ynl_attr_get_u32(attr); + } else if (type == TEAM_ATTR_OPTION_ARRAY_INDEX) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.array_index = 1; + dst->array_index = ynl_attr_get_u32(attr); + } + } + + return 0; +} + +void team_attr_port_free(struct team_attr_port *obj) +{ +} + +int team_attr_port_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct team_attr_port *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TEAM_ATTR_PORT_IFINDEX) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.ifindex = 1; + dst->ifindex = ynl_attr_get_u32(attr); + } else if (type == TEAM_ATTR_PORT_CHANGED) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.changed = 1; + } else if (type == TEAM_ATTR_PORT_LINKUP) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.linkup = 1; + } else if (type == TEAM_ATTR_PORT_SPEED) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.speed = 1; + dst->speed = ynl_attr_get_u32(attr); + } else if (type == TEAM_ATTR_PORT_DUPLEX) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.duplex = 1; + dst->duplex = ynl_attr_get_u8(attr); + } else if (type == TEAM_ATTR_PORT_REMOVED) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.removed = 1; + } + } + + return 0; +} + +void team_item_option_free(struct team_item_option *obj) +{ + team_attr_option_free(&obj->option); +} + +int team_item_option_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct team_item_option *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.option) + team_attr_option_put(nlh, TEAM_ATTR_ITEM_OPTION, &obj->option); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int team_item_option_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct team_item_option *dst = yarg->data; + const struct nlattr *attr; + struct ynl_parse_arg parg; + + parg.ys = yarg->ys; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TEAM_ATTR_ITEM_OPTION) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.option = 1; + + parg.rsp_policy = &team_attr_option_nest; + parg.data = &dst->option; + if (team_attr_option_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } + } + + return 0; +} + +void team_item_port_free(struct team_item_port *obj) +{ + team_attr_port_free(&obj->port); +} + +int team_item_port_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct team_item_port *dst = yarg->data; + const struct nlattr *attr; + struct ynl_parse_arg parg; + + parg.ys = yarg->ys; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TEAM_ATTR_ITEM_PORT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.port = 1; + + parg.rsp_policy = &team_attr_port_nest; + parg.data = &dst->port; + if (team_attr_port_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } + } + + return 0; +} + +/* ============== TEAM_CMD_NOOP ============== */ +/* TEAM_CMD_NOOP - do */ +void team_noop_rsp_free(struct team_noop_rsp *rsp) +{ + free(rsp); +} + +int team_noop_rsp_parse(const struct nlmsghdr *nlh, struct ynl_parse_arg *yarg) +{ + struct team_noop_rsp *dst; + const struct nlattr *attr; + + dst = yarg->data; + + ynl_attr_for_each(attr, nlh, yarg->ys->family->hdr_len) { + unsigned int type = ynl_attr_type(attr); + + if (type == TEAM_ATTR_TEAM_IFINDEX) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.team_ifindex = 1; + dst->team_ifindex = ynl_attr_get_u32(attr); + } + } + + return YNL_PARSE_CB_OK; +} + +struct team_noop_rsp *team_noop(struct ynl_sock *ys) +{ + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; + struct team_noop_rsp *rsp; + struct nlmsghdr *nlh; + int err; + + nlh = ynl_gemsg_start_req(ys, ys->family_id, TEAM_CMD_NOOP, 1); + ys->req_policy = &team_nest; + yrs.yarg.rsp_policy = &team_nest; + + rsp = calloc(1, sizeof(*rsp)); + yrs.yarg.data = rsp; + yrs.cb = team_noop_rsp_parse; + yrs.rsp_cmd = TEAM_CMD_NOOP; + + err = ynl_exec(ys, nlh, &yrs); + if (err < 0) + goto err_free; + + return rsp; + +err_free: + team_noop_rsp_free(rsp); + return NULL; +} + +/* ============== TEAM_CMD_OPTIONS_SET ============== */ +/* TEAM_CMD_OPTIONS_SET - do */ +void team_options_set_req_free(struct team_options_set_req *req) +{ + team_item_option_free(&req->list_option); + free(req); +} + +void team_options_set_rsp_free(struct team_options_set_rsp *rsp) +{ + team_item_option_free(&rsp->list_option); + free(rsp); +} + +int team_options_set_rsp_parse(const struct nlmsghdr *nlh, + struct ynl_parse_arg *yarg) +{ + struct team_options_set_rsp *dst; + const struct nlattr *attr; + struct ynl_parse_arg parg; + + dst = yarg->data; + parg.ys = yarg->ys; + + ynl_attr_for_each(attr, nlh, yarg->ys->family->hdr_len) { + unsigned int type = ynl_attr_type(attr); + + if (type == TEAM_ATTR_TEAM_IFINDEX) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.team_ifindex = 1; + dst->team_ifindex = ynl_attr_get_u32(attr); + } else if (type == TEAM_ATTR_LIST_OPTION) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.list_option = 1; + + parg.rsp_policy = &team_item_option_nest; + parg.data = &dst->list_option; + if (team_item_option_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } + } + + return YNL_PARSE_CB_OK; +} + +struct team_options_set_rsp * +team_options_set(struct ynl_sock *ys, struct team_options_set_req *req) +{ + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; + struct team_options_set_rsp *rsp; + struct nlmsghdr *nlh; + int err; + + nlh = ynl_gemsg_start_req(ys, ys->family_id, TEAM_CMD_OPTIONS_SET, 1); + ys->req_policy = &team_nest; + yrs.yarg.rsp_policy = &team_nest; + + if (req->_present.team_ifindex) + ynl_attr_put_u32(nlh, TEAM_ATTR_TEAM_IFINDEX, req->team_ifindex); + if (req->_present.list_option) + team_item_option_put(nlh, TEAM_ATTR_LIST_OPTION, &req->list_option); + + rsp = calloc(1, sizeof(*rsp)); + yrs.yarg.data = rsp; + yrs.cb = team_options_set_rsp_parse; + yrs.rsp_cmd = TEAM_CMD_OPTIONS_SET; + + err = ynl_exec(ys, nlh, &yrs); + if (err < 0) + goto err_free; + + return rsp; + +err_free: + team_options_set_rsp_free(rsp); + return NULL; +} + +/* ============== TEAM_CMD_OPTIONS_GET ============== */ +/* TEAM_CMD_OPTIONS_GET - do */ +void team_options_get_req_free(struct team_options_get_req *req) +{ + free(req); +} + +void team_options_get_rsp_free(struct team_options_get_rsp *rsp) +{ + team_item_option_free(&rsp->list_option); + free(rsp); +} + +int team_options_get_rsp_parse(const struct nlmsghdr *nlh, + struct ynl_parse_arg *yarg) +{ + struct team_options_get_rsp *dst; + const struct nlattr *attr; + struct ynl_parse_arg parg; + + dst = yarg->data; + parg.ys = yarg->ys; + + ynl_attr_for_each(attr, nlh, yarg->ys->family->hdr_len) { + unsigned int type = ynl_attr_type(attr); + + if (type == TEAM_ATTR_TEAM_IFINDEX) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.team_ifindex = 1; + dst->team_ifindex = ynl_attr_get_u32(attr); + } else if (type == TEAM_ATTR_LIST_OPTION) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.list_option = 1; + + parg.rsp_policy = &team_item_option_nest; + parg.data = &dst->list_option; + if (team_item_option_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } + } + + return YNL_PARSE_CB_OK; +} + +struct team_options_get_rsp * +team_options_get(struct ynl_sock *ys, struct team_options_get_req *req) +{ + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; + struct team_options_get_rsp *rsp; + struct nlmsghdr *nlh; + int err; + + nlh = ynl_gemsg_start_req(ys, ys->family_id, TEAM_CMD_OPTIONS_GET, 1); + ys->req_policy = &team_nest; + yrs.yarg.rsp_policy = &team_nest; + + if (req->_present.team_ifindex) + ynl_attr_put_u32(nlh, TEAM_ATTR_TEAM_IFINDEX, req->team_ifindex); + + rsp = calloc(1, sizeof(*rsp)); + yrs.yarg.data = rsp; + yrs.cb = team_options_get_rsp_parse; + yrs.rsp_cmd = TEAM_CMD_OPTIONS_GET; + + err = ynl_exec(ys, nlh, &yrs); + if (err < 0) + goto err_free; + + return rsp; + +err_free: + team_options_get_rsp_free(rsp); + return NULL; +} + +/* ============== TEAM_CMD_PORT_LIST_GET ============== */ +/* TEAM_CMD_PORT_LIST_GET - do */ +void team_port_list_get_req_free(struct team_port_list_get_req *req) +{ + free(req); +} + +void team_port_list_get_rsp_free(struct team_port_list_get_rsp *rsp) +{ + team_item_port_free(&rsp->list_port); + free(rsp); +} + +int team_port_list_get_rsp_parse(const struct nlmsghdr *nlh, + struct ynl_parse_arg *yarg) +{ + struct team_port_list_get_rsp *dst; + const struct nlattr *attr; + struct ynl_parse_arg parg; + + dst = yarg->data; + parg.ys = yarg->ys; + + ynl_attr_for_each(attr, nlh, yarg->ys->family->hdr_len) { + unsigned int type = ynl_attr_type(attr); + + if (type == TEAM_ATTR_TEAM_IFINDEX) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.team_ifindex = 1; + dst->team_ifindex = ynl_attr_get_u32(attr); + } else if (type == TEAM_ATTR_LIST_PORT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.list_port = 1; + + parg.rsp_policy = &team_item_port_nest; + parg.data = &dst->list_port; + if (team_item_port_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } + } + + return YNL_PARSE_CB_OK; +} + +struct team_port_list_get_rsp * +team_port_list_get(struct ynl_sock *ys, struct team_port_list_get_req *req) +{ + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; + struct team_port_list_get_rsp *rsp; + struct nlmsghdr *nlh; + int err; + + nlh = ynl_gemsg_start_req(ys, ys->family_id, TEAM_CMD_PORT_LIST_GET, 1); + ys->req_policy = &team_nest; + yrs.yarg.rsp_policy = &team_nest; + + if (req->_present.team_ifindex) + ynl_attr_put_u32(nlh, TEAM_ATTR_TEAM_IFINDEX, req->team_ifindex); + + rsp = calloc(1, sizeof(*rsp)); + yrs.yarg.data = rsp; + yrs.cb = team_port_list_get_rsp_parse; + yrs.rsp_cmd = TEAM_CMD_PORT_LIST_GET; + + err = ynl_exec(ys, nlh, &yrs); + if (err < 0) + goto err_free; + + return rsp; + +err_free: + team_port_list_get_rsp_free(rsp); + return NULL; +} + +const struct ynl_family ynl_team_family = { + .name = "team", + .hdr_len = sizeof(struct genlmsghdr), +}; diff --git a/generated/team-user.h b/generated/team-user.h new file mode 120000 index 0000000..3862967 --- /dev/null +++ b/generated/team-user.h @@ -0,0 +1 @@ +../include/ynl-c/team.h \ No newline at end of file diff --git a/include/linux/ethtool_netlink.h b/include/linux/ethtool_netlink.h index 3f89074..accbb1a 100644 --- a/include/linux/ethtool_netlink.h +++ b/include/linux/ethtool_netlink.h @@ -515,6 +515,10 @@ enum { ETHTOOL_A_CABLE_RESULT_CODE_OPEN, ETHTOOL_A_CABLE_RESULT_CODE_SAME_SHORT, ETHTOOL_A_CABLE_RESULT_CODE_CROSS_SHORT, + /* detected reflection caused by the impedance discontinuity between + * a regular 100 Ohm cable and a part with the abnormal impedance value + */ + ETHTOOL_A_CABLE_RESULT_CODE_IMPEDANCE_MISMATCH, }; enum { diff --git a/include/ynl-c/ethtool.h b/include/ynl-c/ethtool.h index 4342195..bfe0143 100644 --- a/include/ynl-c/ethtool.h +++ b/include/ynl-c/ethtool.h @@ -20,6 +20,7 @@ extern const struct ynl_family ynl_ethtool_family; const char *ethtool_op_str(int op); const char *ethtool_udp_tunnel_type_str(int value); const char *ethtool_stringset_str(enum ethtool_stringset value); +const char *ethtool_header_flags_str(int value); /* Common nested types */ struct ethtool_header { diff --git a/include/ynl-c/team.h b/include/ynl-c/team.h new file mode 100644 index 0000000..125efca --- /dev/null +++ b/include/ynl-c/team.h @@ -0,0 +1,281 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ +/* Do not edit directly, auto-generated from: */ +/* Documentation/netlink/specs/team.yaml */ +/* YNL-GEN user header */ + +#ifndef _LINUX_TEAM_GEN_H +#define _LINUX_TEAM_GEN_H + +#include +#include +#include +#include + +struct ynl_sock; + +extern const struct ynl_family ynl_team_family; + +/* Enums */ +const char *team_op_str(int op); + +/* Common nested types */ +struct team_attr_option { + struct { + __u32 name_len; + __u32 changed:1; + __u32 type:1; + __u32 data_len; + __u32 removed:1; + __u32 port_ifindex:1; + __u32 array_index:1; + } _present; + + char *name; + __u8 type; + void *data; + __u32 port_ifindex; + __u32 array_index; +}; + +struct team_attr_port { + struct { + __u32 ifindex:1; + __u32 changed:1; + __u32 linkup:1; + __u32 speed:1; + __u32 duplex:1; + __u32 removed:1; + } _present; + + __u32 ifindex; + __u32 speed; + __u8 duplex; +}; + +struct team_item_option { + struct { + __u32 option:1; + } _present; + + struct team_attr_option option; +}; + +struct team_item_port { + struct { + __u32 port:1; + } _present; + + struct team_attr_port port; +}; + +/* ============== TEAM_CMD_NOOP ============== */ +/* TEAM_CMD_NOOP - do */ + +struct team_noop_rsp { + struct { + __u32 team_ifindex:1; + } _present; + + __u32 team_ifindex; +}; + +void team_noop_rsp_free(struct team_noop_rsp *rsp); + +/* + * No operation + */ +struct team_noop_rsp *team_noop(struct ynl_sock *ys); + +/* ============== TEAM_CMD_OPTIONS_SET ============== */ +/* TEAM_CMD_OPTIONS_SET - do */ +struct team_options_set_req { + struct { + __u32 team_ifindex:1; + __u32 list_option:1; + } _present; + + __u32 team_ifindex; + struct team_item_option list_option; +}; + +static inline struct team_options_set_req *team_options_set_req_alloc(void) +{ + return calloc(1, sizeof(struct team_options_set_req)); +} +void team_options_set_req_free(struct team_options_set_req *req); + +static inline void +team_options_set_req_set_team_ifindex(struct team_options_set_req *req, + __u32 team_ifindex) +{ + req->_present.team_ifindex = 1; + req->team_ifindex = team_ifindex; +} +static inline void +team_options_set_req_set_list_option_option_name(struct team_options_set_req *req, + const char *name) +{ + req->_present.list_option = 1; + req->list_option._present.option = 1; + free(req->list_option.option.name); + req->list_option.option._present.name_len = strlen(name); + req->list_option.option.name = malloc(req->list_option.option._present.name_len + 1); + memcpy(req->list_option.option.name, name, req->list_option.option._present.name_len); + req->list_option.option.name[req->list_option.option._present.name_len] = 0; +} +static inline void +team_options_set_req_set_list_option_option_changed(struct team_options_set_req *req) +{ + req->_present.list_option = 1; + req->list_option._present.option = 1; + req->list_option.option._present.changed = 1; +} +static inline void +team_options_set_req_set_list_option_option_type(struct team_options_set_req *req, + __u8 type) +{ + req->_present.list_option = 1; + req->list_option._present.option = 1; + req->list_option.option._present.type = 1; + req->list_option.option.type = type; +} +static inline void +team_options_set_req_set_list_option_option_data(struct team_options_set_req *req, + const void *data, size_t len) +{ + req->_present.list_option = 1; + req->list_option._present.option = 1; + free(req->list_option.option.data); + req->list_option.option._present.data_len = len; + req->list_option.option.data = malloc(req->list_option.option._present.data_len); + memcpy(req->list_option.option.data, data, req->list_option.option._present.data_len); +} +static inline void +team_options_set_req_set_list_option_option_removed(struct team_options_set_req *req) +{ + req->_present.list_option = 1; + req->list_option._present.option = 1; + req->list_option.option._present.removed = 1; +} +static inline void +team_options_set_req_set_list_option_option_port_ifindex(struct team_options_set_req *req, + __u32 port_ifindex) +{ + req->_present.list_option = 1; + req->list_option._present.option = 1; + req->list_option.option._present.port_ifindex = 1; + req->list_option.option.port_ifindex = port_ifindex; +} +static inline void +team_options_set_req_set_list_option_option_array_index(struct team_options_set_req *req, + __u32 array_index) +{ + req->_present.list_option = 1; + req->list_option._present.option = 1; + req->list_option.option._present.array_index = 1; + req->list_option.option.array_index = array_index; +} + +struct team_options_set_rsp { + struct { + __u32 team_ifindex:1; + __u32 list_option:1; + } _present; + + __u32 team_ifindex; + struct team_item_option list_option; +}; + +void team_options_set_rsp_free(struct team_options_set_rsp *rsp); + +/* + * Set team options + */ +struct team_options_set_rsp * +team_options_set(struct ynl_sock *ys, struct team_options_set_req *req); + +/* ============== TEAM_CMD_OPTIONS_GET ============== */ +/* TEAM_CMD_OPTIONS_GET - do */ +struct team_options_get_req { + struct { + __u32 team_ifindex:1; + } _present; + + __u32 team_ifindex; +}; + +static inline struct team_options_get_req *team_options_get_req_alloc(void) +{ + return calloc(1, sizeof(struct team_options_get_req)); +} +void team_options_get_req_free(struct team_options_get_req *req); + +static inline void +team_options_get_req_set_team_ifindex(struct team_options_get_req *req, + __u32 team_ifindex) +{ + req->_present.team_ifindex = 1; + req->team_ifindex = team_ifindex; +} + +struct team_options_get_rsp { + struct { + __u32 team_ifindex:1; + __u32 list_option:1; + } _present; + + __u32 team_ifindex; + struct team_item_option list_option; +}; + +void team_options_get_rsp_free(struct team_options_get_rsp *rsp); + +/* + * Get team options info + */ +struct team_options_get_rsp * +team_options_get(struct ynl_sock *ys, struct team_options_get_req *req); + +/* ============== TEAM_CMD_PORT_LIST_GET ============== */ +/* TEAM_CMD_PORT_LIST_GET - do */ +struct team_port_list_get_req { + struct { + __u32 team_ifindex:1; + } _present; + + __u32 team_ifindex; +}; + +static inline struct team_port_list_get_req *team_port_list_get_req_alloc(void) +{ + return calloc(1, sizeof(struct team_port_list_get_req)); +} +void team_port_list_get_req_free(struct team_port_list_get_req *req); + +static inline void +team_port_list_get_req_set_team_ifindex(struct team_port_list_get_req *req, + __u32 team_ifindex) +{ + req->_present.team_ifindex = 1; + req->team_ifindex = team_ifindex; +} + +struct team_port_list_get_rsp { + struct { + __u32 team_ifindex:1; + __u32 list_port:1; + } _present; + + __u32 team_ifindex; + struct team_item_port list_port; +}; + +void team_port_list_get_rsp_free(struct team_port_list_get_rsp *rsp); + +/* + * Get team ports info + */ +struct team_port_list_get_rsp * +team_port_list_get(struct ynl_sock *ys, struct team_port_list_get_req *req); + +#endif /* _LINUX_TEAM_GEN_H */