From: Christian Benvenuti <benve@cisco.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org
Subject: [RFC][net-next-2.6 PATCH 1/2] Add new protocol nested IFLA_PORT_PROTO_* attr
Date: Tue, 07 Dec 2010 20:31:01 -0800 [thread overview]
Message-ID: <20101208042953.16856.38217.stgit@savbu-pc100.cisco.com> (raw)
In-Reply-To: <20101208042925.16856.89232.stgit@savbu-pc100.cisco.com>
From: Christian Benvenuti <benve@cisco.com>
Signed-off-by: Christian Benvenuti <benve@cisco.com>
Signed-off-by: Roopa Prabhu <roprabhu@cisco.com>
Signed-off-by: David Wang <dwang2@cisco.com>
---
include/linux/if_link.h | 31 +++++++++++++++++++++++++++++--
include/net/rtnetlink.h | 3 +++
net/core/rtnetlink.c | 45 ++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 76 insertions(+), 3 deletions(-)
diff --git a/include/linux/if_link.h b/include/linux/if_link.h
index 6485d2a..6f331aa 100644
--- a/include/linux/if_link.h
+++ b/include/linux/if_link.h
@@ -332,12 +332,14 @@ enum {
enum {
IFLA_PORT_UNSPEC,
IFLA_PORT_VF, /* __u32 */
- IFLA_PORT_PROFILE, /* string */
- IFLA_PORT_VSI_TYPE, /* 802.1Qbg (pre-)standard VDP */
+ IFLA_PORT_PROFILE, /* (deprecated) */
+ IFLA_PORT_VSI_TYPE, /* (deprecated) */
IFLA_PORT_INSTANCE_UUID, /* binary UUID */
IFLA_PORT_HOST_UUID, /* binary UUID */
IFLA_PORT_REQUEST, /* __u8 */
IFLA_PORT_RESPONSE, /* __u16, output only */
+ IFLA_PORT_PROTO_8021QBH,
+ IFLA_PORT_PROTO_8021QBG,
__IFLA_PORT_MAX,
};
@@ -378,4 +380,29 @@ struct ifla_port_vsi {
__u8 pad[3];
};
+enum port_proto {
+ PORT_PROTO_UNSPEC,
+ PORT_PROTO_8021QBH,
+ PORT_PROTO_8021QBG,
+ __PORT_PROTO_MAX,
+};
+
+#define PORT_PROTO_MAX (__PORT_PROTO_MAX - 1)
+
+enum {
+ IFLA_PORT_8021QBG_UNSPEC,
+ IFLA_PORT_8021QBG_VSI_TYPE, /* (pre-)standard VDP */
+ __IFLA_PORT_8021QBG_MAX,
+};
+
+#define IFLA_PORT_8021QBG_MAX (__IFLA_PORT_8021QBG_MAX - 1)
+
+enum {
+ IFLA_PORT_8021QBH_UNSPEC,
+ IFLA_PORT_8021QBH_PROFILE,
+ __IFLA_PORT_8021QBH_MAX,
+};
+
+#define IFLA_PORT_8021QBH_MAX (__IFLA_PORT_8021QBH_MAX - 1)
+
#endif /* _LINUX_IF_LINK_H */
diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
index 4093ca7..bea154c 100644
--- a/include/net/rtnetlink.h
+++ b/include/net/rtnetlink.h
@@ -118,6 +118,9 @@ extern int rtnl_af_register(struct rtnl_af_ops *ops);
extern void rtnl_af_unregister(struct rtnl_af_ops *ops);
+extern int rtnl_link_parse_port_proto(enum port_proto proto,
+ struct nlattr *proto_attr,
+ struct nlattr *tb[]);
extern struct net *rtnl_link_get_net(struct net *src_net, struct nlattr *tb[]);
extern struct net_device *rtnl_create_link(struct net *src_net, struct net *net,
char *ifname, const struct rtnl_link_ops *ops, struct nlattr *tb[]);
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 750db57..7390b60 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -723,7 +723,15 @@ static size_t rtnl_port_size(const struct net_device *dev)
+ nla_total_size(PORT_UUID_MAX) /* PORT_INSTANCE_UUID */
+ nla_total_size(PORT_UUID_MAX) /* PORT_HOST_UUID */
+ nla_total_size(1) /* PROT_VDP_REQUEST */
- + nla_total_size(2); /* PORT_VDP_RESPONSE */
+ + nla_total_size(2) /* PORT_VDP_RESPONSE */
+
+ + nla_total_size(0) /* PROTO_8021QBH */
+ + nla_total_size(PORT_PROFILE_MAX) /* 8021QBH_PROFILE */
+
+ + nla_total_size(0) /* PROTO_8021QBG */
+ + nla_total_size(sizeof(struct ifla_port_vsi));
+ /* 8021QBG_VSI */
+
size_t vf_ports_size = nla_total_size(sizeof(struct nlattr));
size_t vf_port_size = nla_total_size(sizeof(struct nlattr))
+ port_size;
@@ -1067,6 +1075,18 @@ static const struct nla_policy ifla_vf_policy[IFLA_VF_MAX+1] = {
.len = sizeof(struct ifla_vf_tx_rate) },
};
+static
+const struct nla_policy ifla_port_8021qbh_policy[IFLA_PORT_8021QBH_MAX+1] = {
+ [IFLA_PORT_8021QBH_PROFILE] = { .type = NLA_STRING,
+ .len = PORT_PROFILE_MAX },
+};
+
+static
+const struct nla_policy ifla_port_8021qbg_policy[IFLA_PORT_8021QBG_MAX+1] = {
+ [IFLA_PORT_8021QBG_VSI_TYPE] = { .type = NLA_BINARY,
+ .len = sizeof(struct ifla_port_vsi)},
+};
+
static const struct nla_policy ifla_port_policy[IFLA_PORT_MAX+1] = {
[IFLA_PORT_VF] = { .type = NLA_U32 },
[IFLA_PORT_PROFILE] = { .type = NLA_STRING,
@@ -1079,8 +1099,31 @@ static const struct nla_policy ifla_port_policy[IFLA_PORT_MAX+1] = {
.len = PORT_UUID_MAX },
[IFLA_PORT_REQUEST] = { .type = NLA_U8, },
[IFLA_PORT_RESPONSE] = { .type = NLA_U16, },
+ [IFLA_PORT_PROTO_8021QBH] = { .type = NLA_NESTED },
+ [IFLA_PORT_PROTO_8021QBG] = { .type = NLA_NESTED },
};
+int rtnl_link_parse_port_proto(enum port_proto proto, struct nlattr *proto_attr,
+ struct nlattr *tb[])
+{
+ if ((proto > PORT_PROTO_MAX) || (proto_attr == NULL) || (tb == NULL))
+ return -EINVAL;
+
+ switch (proto) {
+ case PORT_PROTO_UNSPEC:
+ return -EINVAL;
+ case PORT_PROTO_8021QBH:
+ return nla_parse_nested(tb, IFLA_PORT_8021QBH_MAX,
+ proto_attr, ifla_port_8021qbh_policy);
+ case PORT_PROTO_8021QBG:
+ return nla_parse_nested(tb, IFLA_PORT_8021QBG_MAX,
+ proto_attr, ifla_port_8021qbg_policy);
+ default:
+ return -ENOTSUPP;
+ }
+}
+EXPORT_SYMBOL(rtnl_link_parse_port_proto);
+
struct net *rtnl_link_get_net(struct net *src_net, struct nlattr *tb[])
{
struct net *net;
next prev parent reply other threads:[~2010-12-08 4:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-08 4:29 [RFC][net-next-2.6 PATCH 0/2] rtnetlink: New IFLA_PORT_PROTO_* attr Christian Benvenuti
2010-12-08 4:31 ` Christian Benvenuti [this message]
2010-12-08 4:32 ` [RFC][net-next-2.6 PATCH 2/2] Update enic drv to support IFLA_PORT_PROTO_* attributes Christian Benvenuti
2010-12-09 13:33 ` [RFC][net-next-2.6 PATCH 0/2] rtnetlink: New IFLA_PORT_PROTO_* attr Stefan Berger
2010-12-12 0:53 ` Christian Benvenuti (benve)
2010-12-12 3:16 ` Stefan Berger
2010-12-14 15:47 ` Arnd Bergmann
2010-12-14 22:59 ` Christian Benvenuti (benve)
2010-12-15 13:33 ` Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101208042953.16856.38217.stgit@savbu-pc100.cisco.com \
--to=benve@cisco.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox