From patchwork Wed Dec 13 08:45:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13490555 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="a3SlKFaH" Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31334F3 for ; Wed, 13 Dec 2023 00:45:14 -0800 (PST) Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1d0b2752dc6so58832185ad.3 for ; Wed, 13 Dec 2023 00:45:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702457113; x=1703061913; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GtT/ElbQqdJwX418PMIMGHlJ/bgVex4PuuJXGBHr+A8=; b=a3SlKFaHC6M0eGdCs3tc8FhrxrlwYIE7DvL8UzBwN1y2cSAI6zs77OVUkJlsphlXF8 +vzVnbWspZzwY8bnbZQ+4vpxzpzlXyNc1QEsVsYLCQ7ljH296TmttiKtEp3dKbOt/JHB poK3v+rfl8TnvfUnkC2kkGt8yadudQWFGC1qZ7wmKxxeyZUQdQfAWxCmQUvlxFpu71kV PGFnd5dT8uw3TvdmUYMBEM04Foez8CoDcyvCy4L+2aB2eXsgsPPiI8PJ7HClXNdCgPx+ +JkLOVB6Nglu3/l3kmvzkVwCHrgF0uuk3izNUEOb9kWbP4jyKXRiy2tU0vmt7IQK4A/8 KAqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702457113; x=1703061913; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GtT/ElbQqdJwX418PMIMGHlJ/bgVex4PuuJXGBHr+A8=; b=ufFKPMDiR0TLIR3MtHwupHL1FdF8/Xf1DJXXm8/85BX91ng7Ae/xhwy7xfpf8l+qgn WX2w6bhKxEV/ahcc4lSNuVbwvsHe3p5xv9fuFogweU/YRKLlHBoxTfSd+TkewX11xmTU U8/KjMqdQKWb+Uf0zBHg9r0u4cDPWLoYPPkPufm2Wo4b+rwXot1OHvdPO0YYwewzIJN7 DipFqb8uGo5RGPkUjGQ8A96dws15Kudte4OZMYDLuRy7fiiOR6eznT7U8JFw6cF09EyR tG1vwbwqQLjTRDISNQzsQ6Bxdj7yRMdi/ioOR2sKEbD497gN9Oyuznnw6ZUQaquJ7QuS oN6g== X-Gm-Message-State: AOJu0YyAK6S1Qn2lf+idoBBQ4vz6RLJYl6+/FdmdHp2DCOHzb1eOPM8U yhK+Bwfwitl1I0lB9SFTywc+EPjYPcVQ6v9TWh0= X-Google-Smtp-Source: AGHT+IHKrzsBaA7lIeLCAVJ4Cuh8VMQ9vvphlogR263YMnrGwpYP3EgpMRgBj2ZhxAddaNNgYcMkuw== X-Received: by 2002:a17:902:f546:b0:1d0:c37a:9d05 with SMTP id h6-20020a170902f54600b001d0c37a9d05mr10013464plf.75.1702457112893; Wed, 13 Dec 2023 00:45:12 -0800 (PST) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id h2-20020a170902f54200b001cfc67d46efsm9897824plf.191.2023.12.13.00.45.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 00:45:12 -0800 (PST) From: Hangbin Liu To: netdev@vger.kernel.org Cc: Jiri Pirko , Jakub Kicinski , Paolo Abeni , Hangbin Liu Subject: [Draft PATCH net-next 1/3] Documentation: netlink: add a YAML spec for team Date: Wed, 13 Dec 2023 16:45:00 +0800 Message-ID: <20231213084502.4042718-2-liuhangbin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231213084502.4042718-1-liuhangbin@gmail.com> References: <20231213084502.4042718-1-liuhangbin@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Add a YAML specification for team. Signed-off-by: Hangbin Liu --- Documentation/netlink/specs/team.yaml | 205 ++++++++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 206 insertions(+) create mode 100644 Documentation/netlink/specs/team.yaml diff --git a/Documentation/netlink/specs/team.yaml b/Documentation/netlink/specs/team.yaml new file mode 100644 index 000000000000..5647068bf521 --- /dev/null +++ b/Documentation/netlink/specs/team.yaml @@ -0,0 +1,205 @@ +# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) + +name: team + +protocol: genetlink-legacy + +doc: | + Network team device driver. + +c-family-name: team-genl-name +c-version-name: team-genl-version +kernel-policy: global +uapi-header: linux/if_team.h + +definitions: + - + name: string-max-len + type: const + value: 32 + - + name: genl-change-event-mc-grp-name + type: const + value: change_event + +attribute-sets: + - + name: team + doc: + The team nested layout of get/set msg looks like + [TEAM_ATTR_LIST_OPTION] + [TEAM_ATTR_ITEM_OPTION] + [TEAM_ATTR_OPTION_*], ... + [TEAM_ATTR_ITEM_OPTION] + [TEAM_ATTR_OPTION_*], ... + ... + [TEAM_ATTR_LIST_PORT] + [TEAM_ATTR_ITEM_PORT] + [TEAM_ATTR_PORT_*], ... + [TEAM_ATTR_ITEM_PORT] + [TEAM_ATTR_PORT_*], ... + ... + name-prefix: team-attr- + attributes: + - + name: unspec + type: unused + value: 0 + - + name: team-ifindex + type: u32 + - + name: list-option + type: nest + nested-attributes: item-option + - + name: list-port + type: nest + nested-attributes: item-port + - + name: item-option + name-prefix: team-attr-item- + attr-cnt-name: __team-attr-item-option-max + attr-max-name: team-attr-item-option-max + attributes: + - + name: option-unspec + type: unused + value: 0 + - + name: option + type: nest + nested-attributes: attr-option + - + name: attr-option + name-prefix: team-attr-option- + attributes: + - + name: unspec + type: unused + value: 0 + - + name: name + type: string + checks: + # no unterminated-ok defination? + # do we have to hard code this? + max-len: 32 + - + name: changed + type: flag + - + name: type + type: u8 + - + name: data + type: binary + - + name: removed + type: flag + - + name: port-ifindex + type: u32 + doc: for per-port options + - + name: array-index + type: u32 + doc: for for array options + - + name: item-port + name-prefix: team-attr-item- + attr-cnt-name: __team-attr-item-port-max + attr-max-name: team-attr-item-port-max + attributes: + - + name: port-unspec + type: unused + value: 0 + - + name: port + type: nest + nested-attributes: attr-port + - + name: attr-port + name-prefix: team-attr-port- + attributes: + - + name: unspec + type: unused + value: 0 + - + name: ifindex + type: u32 + - + name: changed + type: flag + - + name: linkup + type: flag + - + name: speed + type: u32 + - + name: duplex + type: u8 + - + name: removed + type: flag + +operations: + list: + - + name: noop + doc: No operation + value: 0 + attribute-set: team + dont-validate: [ strict, dump ] + + do: + # Actually it only reply the team netlink family + reply: + attributes: + - team-ifindex + + - + name: options-set + doc: Set team options + attribute-set: team + dont-validate: [ strict, dump ] + flags: [ admin-perm ] + + do: + request: + attributes: + - team-ifindex + - list-option + + - + name: options-get + doc: Get team options info + attribute-set: team + dont-validate: [ strict, dump ] + flags: [ admin-perm ] + + do: + request: + attributes: + - team-ifindex + reply: + attributes: + - list-option + + - + name: port-list-get + doc: Get team ports info + attribute-set: team + dont-validate: [ strict, dump ] + flags: [ admin-perm ] + + do: + request: + attributes: + - team-ifindex + reply: + attributes: + - list-port diff --git a/MAINTAINERS b/MAINTAINERS index 7fb66210069b..b64e449f47f9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -21301,6 +21301,7 @@ F: drivers/net/team/ F: include/linux/if_team.h F: include/uapi/linux/if_team.h F: tools/testing/selftests/drivers/net/team/ +F: Documentation/netlink/specs/team.yaml TECHNICAL ADVISORY BOARD PROCESS DOCS M: "Theodore Ts'o" From patchwork Wed Dec 13 08:45:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13490556 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OsanOzwC" Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 818BDE8 for ; Wed, 13 Dec 2023 00:45:16 -0800 (PST) Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1d08a924fcfso61894165ad.2 for ; Wed, 13 Dec 2023 00:45:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702457115; x=1703061915; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=d85yTVONb8lD34AiJX86T2dIk0UVQ4CuE1b2GPXCMXM=; b=OsanOzwC1QtaT8t/naojyvg9rhNlwIUKtxIMqh/aZIeSu2UH1Cm5XGed4zo5Gsp2Lg SCMONcFQsuVZJnjY9FQpVkMwC+OFaMqo7BRdFpS/0n+goAaHHQvJgsYh2Z8gRp7yqEUB COyE2YBAzXJIAz+BvrruHG0WYhs9u1+43Rg/C21/sHVUlKniVmgRh1s83AEA+Eipu8F/ 5B+kptl/7zp/ETxM3TK8tksTBXUt696l92XaDNNFe+0HpEDbxC4ELSRsuAuSJpCvWPto bjKCw1SCYCyxR+M46QrU7wn6S40Xa0HUfzhUznO/lH/yg24+iejqhr/sVQvvwC2amDHk 2Myg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702457115; x=1703061915; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d85yTVONb8lD34AiJX86T2dIk0UVQ4CuE1b2GPXCMXM=; b=piLEiqV/kmwfW5wREl1u6Tm89ZWd4SUl6ux88o+oSwNW/mNkUc+pY/8eAXQyJ3KvUB /RWhLTshvMHujbnfEQt6ZDlLZsEbF8OVQxRLhedbzVS7xuIO2Yp56uOt0SiPUeu36Q+r xIwFfYJSStlKpKdhtR2fXIZH/aGpB2qojZgC2VrgOX7kmtKccciAkBe46mHAUVZmCgWX X1xAgHNilQA+UZf3kxhkZzOHcU3dz3VBq2egIjIHtlmb/nXnIk9MdPJ36MxoQHBZ7ZZ3 BWM8a1joX1cb/EDT5xD+V6rDy9INP9lhEgQlSgs0ySMwfAogxlHDB7rN4H3SY/oNiOOe AqBQ== X-Gm-Message-State: AOJu0YzImty/AC7a6dihC3WnwxKQqvtJFeZtu+U74i38crceLEtC9xPC l2aQBGhX0JHR7ZCmGwyFnDvt92V2A2NpMJbHtmI= X-Google-Smtp-Source: AGHT+IE+2Z7Hl6XJvdf28/J/4KyhxIIZMN8H+YfThePKHahiCYz5JtFm4oLgofcZY8UmbqnJmnNhUQ== X-Received: by 2002:a17:903:5c4:b0:1d0:83f6:7c6b with SMTP id kf4-20020a17090305c400b001d083f67c6bmr6936787plb.29.1702457115162; Wed, 13 Dec 2023 00:45:15 -0800 (PST) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id h2-20020a170902f54200b001cfc67d46efsm9897824plf.191.2023.12.13.00.45.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 00:45:14 -0800 (PST) From: Hangbin Liu To: netdev@vger.kernel.org Cc: Jiri Pirko , Jakub Kicinski , Paolo Abeni , Hangbin Liu Subject: [Draft PATCH net-next 2/3] net: team: use policy generated by YAML spec Date: Wed, 13 Dec 2023 16:45:01 +0800 Message-ID: <20231213084502.4042718-3-liuhangbin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231213084502.4042718-1-liuhangbin@gmail.com> References: <20231213084502.4042718-1-liuhangbin@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org generated with: $ ./tools/net/ynl/ynl-gen-c.py --mode kernel \ > --spec Documentation/netlink/specs/team.yaml --source \ > -o drivers/net/team/team_nl.c $ ./tools/net/ynl/ynl-gen-c.py --mode kernel \ > --spec Documentation/netlink/specs/team.yaml --header \ > -o drivers/net/team/team_nl.h The TEAM_ATTR_LIST_PORT in team_nl_policy is removed as it only in the port list reply attributes. Signed-off-by: Hangbin Liu --- drivers/net/team/Makefile | 2 +- drivers/net/team/team.c | 59 +++++--------------------------------- drivers/net/team/team_nl.c | 59 ++++++++++++++++++++++++++++++++++++++ drivers/net/team/team_nl.h | 29 +++++++++++++++++++ 4 files changed, 96 insertions(+), 53 deletions(-) create mode 100644 drivers/net/team/team_nl.c create mode 100644 drivers/net/team/team_nl.h diff --git a/drivers/net/team/Makefile b/drivers/net/team/Makefile index f582d81a5091..43ee154db26e 100644 --- a/drivers/net/team/Makefile +++ b/drivers/net/team/Makefile @@ -3,7 +3,7 @@ # Makefile for the network team driver # -obj-$(CONFIG_NET_TEAM) += team.o +obj-$(CONFIG_NET_TEAM) += team.o team_nl.o obj-$(CONFIG_NET_TEAM_MODE_BROADCAST) += team_mode_broadcast.o obj-$(CONFIG_NET_TEAM_MODE_ROUNDROBIN) += team_mode_roundrobin.o obj-$(CONFIG_NET_TEAM_MODE_RANDOM) += team_mode_random.o diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c index 508d9a392ab1..90e73665978a 100644 --- a/drivers/net/team/team.c +++ b/drivers/net/team/team.c @@ -28,6 +28,8 @@ #include #include +#include "team_nl.h" + #define DRV_NAME "team" @@ -2254,28 +2256,7 @@ static struct rtnl_link_ops team_link_ops __read_mostly = { static struct genl_family team_nl_family; -static const struct nla_policy team_nl_policy[TEAM_ATTR_MAX + 1] = { - [TEAM_ATTR_UNSPEC] = { .type = NLA_UNSPEC, }, - [TEAM_ATTR_TEAM_IFINDEX] = { .type = NLA_U32 }, - [TEAM_ATTR_LIST_OPTION] = { .type = NLA_NESTED }, - [TEAM_ATTR_LIST_PORT] = { .type = NLA_NESTED }, -}; - -static const struct nla_policy -team_nl_option_policy[TEAM_ATTR_OPTION_MAX + 1] = { - [TEAM_ATTR_OPTION_UNSPEC] = { .type = NLA_UNSPEC, }, - [TEAM_ATTR_OPTION_NAME] = { - .type = NLA_STRING, - .len = TEAM_STRING_MAX_LEN, - }, - [TEAM_ATTR_OPTION_CHANGED] = { .type = NLA_FLAG }, - [TEAM_ATTR_OPTION_TYPE] = { .type = NLA_U8 }, - [TEAM_ATTR_OPTION_DATA] = { .type = NLA_BINARY }, - [TEAM_ATTR_OPTION_PORT_IFINDEX] = { .type = NLA_U32 }, - [TEAM_ATTR_OPTION_ARRAY_INDEX] = { .type = NLA_U32 }, -}; - -static int team_nl_cmd_noop(struct sk_buff *skb, struct genl_info *info) +int team_nl_noop_doit(struct sk_buff *skb, struct genl_info *info) { struct sk_buff *msg; void *hdr; @@ -2513,7 +2494,7 @@ static int team_nl_send_options_get(struct team *team, u32 portid, u32 seq, return err; } -static int team_nl_cmd_options_get(struct sk_buff *skb, struct genl_info *info) +int team_nl_options_get_doit(struct sk_buff *skb, struct genl_info *info) { struct team *team; struct team_option_inst *opt_inst; @@ -2538,7 +2519,7 @@ static int team_nl_cmd_options_get(struct sk_buff *skb, struct genl_info *info) static int team_nl_send_event_options_get(struct team *team, struct list_head *sel_opt_inst_list); -static int team_nl_cmd_options_set(struct sk_buff *skb, struct genl_info *info) +int team_nl_options_set_doit(struct sk_buff *skb, struct genl_info *info) { struct team *team; int err = 0; @@ -2579,7 +2560,7 @@ static int team_nl_cmd_options_set(struct sk_buff *skb, struct genl_info *info) err = nla_parse_nested_deprecated(opt_attrs, TEAM_ATTR_OPTION_MAX, nl_option, - team_nl_option_policy, + team_attr_option_nl_policy, info->extack); if (err) goto team_put; @@ -2802,7 +2783,7 @@ static int team_nl_send_port_list_get(struct team *team, u32 portid, u32 seq, return err; } -static int team_nl_cmd_port_list_get(struct sk_buff *skb, +int team_nl_port_list_get_doit(struct sk_buff *skb, struct genl_info *info) { struct team *team; @@ -2820,32 +2801,6 @@ static int team_nl_cmd_port_list_get(struct sk_buff *skb, return err; } -static const struct genl_small_ops team_nl_ops[] = { - { - .cmd = TEAM_CMD_NOOP, - .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, - .doit = team_nl_cmd_noop, - }, - { - .cmd = TEAM_CMD_OPTIONS_SET, - .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, - .doit = team_nl_cmd_options_set, - .flags = GENL_ADMIN_PERM, - }, - { - .cmd = TEAM_CMD_OPTIONS_GET, - .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, - .doit = team_nl_cmd_options_get, - .flags = GENL_ADMIN_PERM, - }, - { - .cmd = TEAM_CMD_PORT_LIST_GET, - .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, - .doit = team_nl_cmd_port_list_get, - .flags = GENL_ADMIN_PERM, - }, -}; - static const struct genl_multicast_group team_nl_mcgrps[] = { { .name = TEAM_GENL_CHANGE_EVENT_MC_GRP_NAME, }, }; diff --git a/drivers/net/team/team_nl.c b/drivers/net/team/team_nl.c new file mode 100644 index 000000000000..c57bb3d4d7d5 --- /dev/null +++ b/drivers/net/team/team_nl.c @@ -0,0 +1,59 @@ +// 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 kernel source */ + +#include +#include + +#include "team_nl.h" + +#include + +/* Common nested types */ +const struct nla_policy team_attr_option_nl_policy[TEAM_ATTR_OPTION_ARRAY_INDEX + 1] = { + [TEAM_ATTR_OPTION_NAME] = { .type = NLA_NUL_STRING, .len = 32, }, + [TEAM_ATTR_OPTION_CHANGED] = { .type = NLA_FLAG, }, + [TEAM_ATTR_OPTION_TYPE] = { .type = NLA_U8, }, + [TEAM_ATTR_OPTION_DATA] = { .type = NLA_BINARY, }, + [TEAM_ATTR_OPTION_REMOVED] = { .type = NLA_FLAG, }, + [TEAM_ATTR_OPTION_PORT_IFINDEX] = { .type = NLA_U32, }, + [TEAM_ATTR_OPTION_ARRAY_INDEX] = { .type = NLA_U32, }, +}; + +const struct nla_policy team_item_option_nl_policy[TEAM_ATTR_ITEM_OPTION + 1] = { + [TEAM_ATTR_ITEM_OPTION] = NLA_POLICY_NESTED(team_attr_option_nl_policy), +}; + +/* Global operation policy for team */ +const struct nla_policy team_nl_policy[TEAM_ATTR_LIST_OPTION + 1] = { + [TEAM_ATTR_TEAM_IFINDEX] = { .type = NLA_U32, }, + [TEAM_ATTR_LIST_OPTION] = NLA_POLICY_NESTED(team_item_option_nl_policy), +}; + +/* Ops table for team */ +const struct genl_small_ops team_nl_ops[4] = { + { + .cmd = TEAM_CMD_NOOP, + .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, + .doit = team_nl_noop_doit, + }, + { + .cmd = TEAM_CMD_OPTIONS_SET, + .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, + .doit = team_nl_options_set_doit, + .flags = GENL_ADMIN_PERM, + }, + { + .cmd = TEAM_CMD_OPTIONS_GET, + .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, + .doit = team_nl_options_get_doit, + .flags = GENL_ADMIN_PERM, + }, + { + .cmd = TEAM_CMD_PORT_LIST_GET, + .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, + .doit = team_nl_port_list_get_doit, + .flags = GENL_ADMIN_PERM, + }, +}; diff --git a/drivers/net/team/team_nl.h b/drivers/net/team/team_nl.h new file mode 100644 index 000000000000..c9ec1b22ac4d --- /dev/null +++ b/drivers/net/team/team_nl.h @@ -0,0 +1,29 @@ +/* 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 kernel header */ + +#ifndef _LINUX_TEAM_GEN_H +#define _LINUX_TEAM_GEN_H + +#include +#include + +#include + +/* Common nested types */ +extern const struct nla_policy team_attr_option_nl_policy[TEAM_ATTR_OPTION_ARRAY_INDEX + 1]; +extern const struct nla_policy team_item_option_nl_policy[TEAM_ATTR_ITEM_OPTION + 1]; + +/* Global operation policy for team */ +extern const struct nla_policy team_nl_policy[TEAM_ATTR_LIST_OPTION + 1]; + +/* Ops table for team */ +extern const struct genl_small_ops team_nl_ops[4]; + +int team_nl_noop_doit(struct sk_buff *skb, struct genl_info *info); +int team_nl_options_set_doit(struct sk_buff *skb, struct genl_info *info); +int team_nl_options_get_doit(struct sk_buff *skb, struct genl_info *info); +int team_nl_port_list_get_doit(struct sk_buff *skb, struct genl_info *info); + +#endif /* _LINUX_TEAM_GEN_H */ From patchwork Wed Dec 13 08:45:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13490557 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PZPLHz1j" Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D84AF4 for ; Wed, 13 Dec 2023 00:45:18 -0800 (PST) Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-6ce94f62806so3672221b3a.1 for ; Wed, 13 Dec 2023 00:45:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702457117; x=1703061917; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rXt+e70s18vvmZvnfHoG/leNZ6ipUAeaM1qUbwNwWzI=; b=PZPLHz1jDIL6NfW9LJ3TtdlzVNpLN508/vfZD+/VwhE5GOLvIZx3HQyhe82ToSGE76 E27zwqHrGqwJZsC+be1L8Y+aCNGLALUJ3y11pAHX8HnX/29b3B6B0WpHKHp//UZ7qrNR l8r0GsQYdE1ij8MwULOvOkHENcbiJzy0R3B+seoQhRLOITyIZuLL5X2Cy7FIJWChUFyd NECRUNdBduD45AFONJ7ETlzXTri5yxTzX4Y9naJbyNev2f2SUnYYw0Hjw2fm2BbVhIOW Hk+Mbs30mFt/YrGw75eZgqaqUtxRYXN/bUBEbhfXQFXsA9l6t6YB1vXA69oRj5CIBPMn uscQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702457117; x=1703061917; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rXt+e70s18vvmZvnfHoG/leNZ6ipUAeaM1qUbwNwWzI=; b=QloznM/LCEmehxzWsZTGieWMXJjKHOBeb1Q8IE5tl8J7ADfU4ctvP7FmwPhcpMRwhr DRhGHayG0oFs+M6JXyWa6N/K62Jq7awxaxJMFbYZr+k/QGdO9G2Ynr+gZ10Sex9EKcyq zJY6fcrfj0E4YIMwHwgJo3DHuIbMm0p4V9qVYrZo5W/o/YixqV2oXsNVkT3O8MBhSDXK RJKyw+YckecmhXS6brdgvh3K9gbOSUoI9MZMCvb/VxBvLChRje7KfZYzhv2O/eCo4Rqq yFnTLzMIiWU+6PvEiihhHNVb3NBY8IIp6+tBqbVkh1W8+oHUvKwxa08Wpkf1D+wSi9N1 wDsw== X-Gm-Message-State: AOJu0YxQEKL/6Ew1Hlwc3fm3dxBaeNYW+wEaMspS01a5EBs84UbH46BV oDiRTMMkwXZC2mVNjGofUI62XwiQ9DPHTYaAfj8= X-Google-Smtp-Source: AGHT+IH5kP7AhrmVPo3RJ2iT//G/47RMdOIWxy+LKUxYWdfi9Iv3tfua4SNhPFM8N/4EKoElq2/46g== X-Received: by 2002:a05:6a20:a8a1:b0:18c:a8fe:42f3 with SMTP id ca33-20020a056a20a8a100b0018ca8fe42f3mr3423398pzb.19.1702457117397; Wed, 13 Dec 2023 00:45:17 -0800 (PST) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id h2-20020a170902f54200b001cfc67d46efsm9897824plf.191.2023.12.13.00.45.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 00:45:16 -0800 (PST) From: Hangbin Liu To: netdev@vger.kernel.org Cc: Jiri Pirko , Jakub Kicinski , Paolo Abeni , Hangbin Liu Subject: [Draft PATCH net-next 3/3] uapi: team: use header file generated from YAML spec Date: Wed, 13 Dec 2023 16:45:02 +0800 Message-ID: <20231213084502.4042718-4-liuhangbin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231213084502.4042718-1-liuhangbin@gmail.com> References: <20231213084502.4042718-1-liuhangbin@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org generated with: $ ./tools/net/ynl/ynl-gen-c.py --mode uapi \ > --spec Documentation/netlink/specs/team.yaml \ > --header -o include/uapi/linux/if_team.h Signed-off-by: Hangbin Liu --- include/uapi/linux/if_team.h | 116 +++++++++++++---------------------- 1 file changed, 43 insertions(+), 73 deletions(-) diff --git a/include/uapi/linux/if_team.h b/include/uapi/linux/if_team.h index 13c61fecb78b..a5c06243a435 100644 --- a/include/uapi/linux/if_team.h +++ b/include/uapi/linux/if_team.h @@ -1,108 +1,78 @@ -/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ -/* - * include/linux/if_team.h - Network team device driver header - * Copyright (c) 2011 Jiri Pirko - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ +/* 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 uapi header */ -#ifndef _UAPI_LINUX_IF_TEAM_H_ -#define _UAPI_LINUX_IF_TEAM_H_ +#ifndef _UAPI_LINUX_IF_TEAM_H +#define _UAPI_LINUX_IF_TEAM_H +#define TEAM_GENL_NAME "team" +#define TEAM_GENL_VERSION 1 -#define TEAM_STRING_MAX_LEN 32 - -/********************************** - * NETLINK_GENERIC netlink family. - **********************************/ - -enum { - TEAM_CMD_NOOP, - TEAM_CMD_OPTIONS_SET, - TEAM_CMD_OPTIONS_GET, - TEAM_CMD_PORT_LIST_GET, - - __TEAM_CMD_MAX, - TEAM_CMD_MAX = (__TEAM_CMD_MAX - 1), -}; +#define TEAM_STRING_MAX_LEN 32 +#define TEAM_GENL_CHANGE_EVENT_MC_GRP_NAME "change_event" enum { TEAM_ATTR_UNSPEC, - TEAM_ATTR_TEAM_IFINDEX, /* u32 */ - TEAM_ATTR_LIST_OPTION, /* nest */ - TEAM_ATTR_LIST_PORT, /* nest */ + TEAM_ATTR_TEAM_IFINDEX, + TEAM_ATTR_LIST_OPTION, + TEAM_ATTR_LIST_PORT, __TEAM_ATTR_MAX, - TEAM_ATTR_MAX = __TEAM_ATTR_MAX - 1, + TEAM_ATTR_MAX = (__TEAM_ATTR_MAX - 1) }; -/* Nested layout of get/set msg: - * - * [TEAM_ATTR_LIST_OPTION] - * [TEAM_ATTR_ITEM_OPTION] - * [TEAM_ATTR_OPTION_*], ... - * [TEAM_ATTR_ITEM_OPTION] - * [TEAM_ATTR_OPTION_*], ... - * ... - * [TEAM_ATTR_LIST_PORT] - * [TEAM_ATTR_ITEM_PORT] - * [TEAM_ATTR_PORT_*], ... - * [TEAM_ATTR_ITEM_PORT] - * [TEAM_ATTR_PORT_*], ... - * ... - */ - enum { TEAM_ATTR_ITEM_OPTION_UNSPEC, - TEAM_ATTR_ITEM_OPTION, /* nest */ + TEAM_ATTR_ITEM_OPTION, __TEAM_ATTR_ITEM_OPTION_MAX, - TEAM_ATTR_ITEM_OPTION_MAX = __TEAM_ATTR_ITEM_OPTION_MAX - 1, + TEAM_ATTR_ITEM_OPTION_MAX = (__TEAM_ATTR_ITEM_OPTION_MAX - 1) }; enum { TEAM_ATTR_OPTION_UNSPEC, - TEAM_ATTR_OPTION_NAME, /* string */ - TEAM_ATTR_OPTION_CHANGED, /* flag */ - TEAM_ATTR_OPTION_TYPE, /* u8 */ - TEAM_ATTR_OPTION_DATA, /* dynamic */ - TEAM_ATTR_OPTION_REMOVED, /* flag */ - TEAM_ATTR_OPTION_PORT_IFINDEX, /* u32 */ /* for per-port options */ - TEAM_ATTR_OPTION_ARRAY_INDEX, /* u32 */ /* for array options */ + TEAM_ATTR_OPTION_NAME, + TEAM_ATTR_OPTION_CHANGED, + TEAM_ATTR_OPTION_TYPE, + TEAM_ATTR_OPTION_DATA, + TEAM_ATTR_OPTION_REMOVED, + TEAM_ATTR_OPTION_PORT_IFINDEX, + TEAM_ATTR_OPTION_ARRAY_INDEX, __TEAM_ATTR_OPTION_MAX, - TEAM_ATTR_OPTION_MAX = __TEAM_ATTR_OPTION_MAX - 1, + TEAM_ATTR_OPTION_MAX = (__TEAM_ATTR_OPTION_MAX - 1) }; enum { TEAM_ATTR_ITEM_PORT_UNSPEC, - TEAM_ATTR_ITEM_PORT, /* nest */ + TEAM_ATTR_ITEM_PORT, __TEAM_ATTR_ITEM_PORT_MAX, - TEAM_ATTR_ITEM_PORT_MAX = __TEAM_ATTR_ITEM_PORT_MAX - 1, + TEAM_ATTR_ITEM_PORT_MAX = (__TEAM_ATTR_ITEM_PORT_MAX - 1) }; enum { TEAM_ATTR_PORT_UNSPEC, - TEAM_ATTR_PORT_IFINDEX, /* u32 */ - TEAM_ATTR_PORT_CHANGED, /* flag */ - TEAM_ATTR_PORT_LINKUP, /* flag */ - TEAM_ATTR_PORT_SPEED, /* u32 */ - TEAM_ATTR_PORT_DUPLEX, /* u8 */ - TEAM_ATTR_PORT_REMOVED, /* flag */ + TEAM_ATTR_PORT_IFINDEX, + TEAM_ATTR_PORT_CHANGED, + TEAM_ATTR_PORT_LINKUP, + TEAM_ATTR_PORT_SPEED, + TEAM_ATTR_PORT_DUPLEX, + TEAM_ATTR_PORT_REMOVED, __TEAM_ATTR_PORT_MAX, - TEAM_ATTR_PORT_MAX = __TEAM_ATTR_PORT_MAX - 1, + TEAM_ATTR_PORT_MAX = (__TEAM_ATTR_PORT_MAX - 1) }; -/* - * NETLINK_GENERIC related info - */ -#define TEAM_GENL_NAME "team" -#define TEAM_GENL_VERSION 0x1 -#define TEAM_GENL_CHANGE_EVENT_MC_GRP_NAME "change_event" +enum { + TEAM_CMD_NOOP, + TEAM_CMD_OPTIONS_SET, + TEAM_CMD_OPTIONS_GET, + TEAM_CMD_PORT_LIST_GET, + + __TEAM_CMD_MAX, + TEAM_CMD_MAX = (__TEAM_CMD_MAX - 1) +}; -#endif /* _UAPI_LINUX_IF_TEAM_H_ */ +#endif /* _UAPI_LINUX_IF_TEAM_H */