Add virtual port netlink support
Subsystems (2)
v6 cover Add virtual port netlink support
The following series adds virtual port netlink support and adds an implementation to Cisco's enic netdev driver:
1/2: Adds virtual netlink RTM_SETLINK/RTM_GETLINK support, and
adds matching netdev ops net_{set|get}_vf_port.
2/2: Adds enic support for net_{set|get}_vf_port for enic
dynamic devices.
PATCH v6 1/2 Add netlink support for virtual port management (was iovnl)
From: Scott Feldman <[email protected]>
Add new netdev ops ndo_{set|get}_vf_port to allow setting of port-profile on a netdev interface. Extends netlink socket RTM_SETLINK/ RTM_GETLINK with new sub cmd called IFLA_VF_PORT (added to end of IFLA_cmd list).
A port-profile is used to configure/enable the external switch virtual port backing the netdev interface, not to configure the host-facing side of the netdev. A port-profile is an identifier known to the switch. How port- profiles are installed on the switch or how available port-profiles are made know to the host is outside the scope of this patch.
There are two types of port-profiles specs in the netlink msg. The first spec is for 802.1Qbg (pre-)standard, VDP protocol. The second spec is for devices that run a similar protocol as VDP but in firmware, thus hiding the protocol details. In either case, the specs have much in common and makes sense to define the netlink msg as the union of the two specs. For example, both specs have a notition of associating/deassociating a port-profile. And both specs require some information from the hypervisor manager, such as client port instance ID.
The general flow is the port-profile is applied to a host netdev interface using RTM_SETLINK, the receiver of the RTM_SETLINK msg communicates with the switch, and the switch virtual port backing the host netdev interface is configured/enabled based on the settings defined by the port-profile. What those settings comprise, and how those settings are managed is again outside the scope of this patch, since this patch only deals with the first step in the flow.
There is a RTM_GETLINK cmd to to return port-profile setting of an interface and to also return the status of the last port-profile association.
IFLA_VF_PORT is modeled after the existing IFLA_VF_* cmd where a VF number is passed in to identify the virtual function (VF) of an SR-IOV- capable device. In this case, the target of IFLA_VF_PORT msg is the netdev physical function (PF) device. The PF will apply the port-profile to the VF. IFLA_VF_PORT can also be used for devices that don't adhere to SR-IOV and can apply the port-profile directly to the netdev target. In this case, the VF number is ignored.
Passing in a NULL port-profile is used to delete the port-profile association.
--- include/linux/if_link.h | 52 +++++++++++++++++++ include/linux/netdevice.h | 10 ++++ net/core/rtnetlink.c | 122 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 183 insertions(+), 1 deletions(-)
include/linux/if_link.h +52 -0
@@ -116,6 +116,7 @@ enum {IFLA_VF_TX_RATE ,/* TX Bandwidth Allocation */ IFLA_VFINFO ,IFLA_STATS64 , +IFLA_VF_PORT , __IFLA_MAX };
@@ -259,4 +260,55 @@ struct ifla_vf_info {__u32 qos; __u32 tx_rate; }; + +/* VF Port management section */ + +enum { +IFLA_VF_PORT_UNSPEC , +IFLA_VF_PORT_VF ,/* __u32 */ +IFLA_VF_PORT_PROFILE ,/* string */ +IFLA_VF_PORT_VSI_TYPE ,/* 802.1Qbg (pre-)standard VDP */ +IFLA_VF_PORT_INSTANCE_UUID ,/* binary UUID */ +IFLA_VF_PORT_HOST_UUID ,/* binary UUID */ +IFLA_VF_PORT_REQUEST ,/* __u8 */ +IFLA_VF_PORT_RESPONSE ,/* __u16, output only */ + __IFLA_VF_PORT_MAX, +}; + +#define IFLA_VF_PORT_MAX (__IFLA_VF_PORT_MAX - 1) + +#define VF_PORT_PROFILE_MAX 40 +#define VF_PORT_UUID_MAX 16 + +enum { +VF_PORT_REQUEST_PREASSOCIATE =0 , +VF_PORT_REQUEST_PREASSOCIATE_RR , +VF_PORT_REQUEST_ASSOCIATE , +VF_PORT_REQUEST_DISASSOCIATE , +}; + +enum { +VF_PORT_VDP_RESPONSE_SUCCESS =0 , +VF_PORT_VDP_RESPONSE_INVALID_FORMAT , +VF_PORT_VDP_RESPONSE_INSUFFICIENT_RESOURCES , +VF_PORT_VDP_RESPONSE_UNUSED_VTID , +VF_PORT_VDP_RESPONSE_VTID_VIOLATION , +VF_PORT_VDP_RESPONSE_VTID_VERSION_VIOALTION , +VF_PORT_VDP_RESPONSE_OUT_OF_SYNC , +/* 0x08-0xFF reserved for future VDP use */ +VF_PORT_PROFILE_RESPONSE_SUCCESS =0x100 , +VF_PORT_PROFILE_RESPONSE_INPROGRESS , +VF_PORT_PROFILE_RESPONSE_INVALID , +VF_PORT_PROFILE_RESPONSE_BADSTATE , +VF_PORT_PROFILE_RESPONSE_INSUFFICIENT_RESOURCES , +VF_PORT_PROFILE_RESPONSE_ERROR , +}; + +struct ifla_vf_port_vsi { +__u8 vsi_mgr_id; +__u8 vsi_type_id[3 ]; +__u8 vsi_type_version; +__u8 pad[3 ]; +}; +#endif /* _LINUX_IF_LINK_H */
include/linux/netdevice.h +10 -0
@@ -686,6 +686,10 @@ struct netdev_rx_queue {* int (*ndo_set_vf_tx_rate)(struct net_device *dev, int vf, int rate); * int (*ndo_get_vf_config)(struct net_device *dev, * int vf, struct ifla_vf_info *ivf); +* int (*ndo_set_vf_port)(struct net_device *dev, int vf, +* struct nlattr *vf_port[]); +* int (*ndo_get_vf_port)(struct net_device *dev, int vf, +* struct sk_buff *skb); */ #define HAVE_NET_DEVICE_OPS struct net_device_ops {
@@ -735,6 +739,12 @@ struct net_device_ops {int (*ndo_get_vf_config)(struct net_device *dev,int vf,struct ifla_vf_info *ivf); +int (*ndo_set_vf_port)(struct net_device *dev, +int vf, +struct nlattr *vf_port[]); +int (*ndo_get_vf_port)(struct net_device *dev, +int vf, +struct sk_buff *skb);#if defined(CONFIG_FCOE ) || defined(CONFIG_FCOE_MODULE )int (*ndo_fcoe_enable)(struct net_device *dev);int (*ndo_fcoe_disable)(struct net_device *dev);
net/core/rtnetlink.c +121 -1
171 lines not on this page · raw message
Re: [net-next-2.6 V6 PATCH 1/2] Add netlink support for virtual port management (was iovnl)
Quoted 42 lines · * Scott Feldman ([email protected]) wrote:
From: Scott Feldman <[email protected]>
Add new netdev ops ndo_{set|get}_vf_port to allow setting of port-profile on a netdev interface. Extends netlink socket RTM_SETLINK/
RTM_GETLINKwith new sub cmd calledIFLA_VF_PORT(added to end ofIFLA_cmdlist).A port-profile is used to configure/enable the external switch virtual port backing the netdev interface, not to configure the host-facing side of the netdev. A port-profile is an identifier known to the switch. How port- profiles are installed on the switch or how available port-profiles are made know to the host is outside the scope of this patch.
There are two types of port-profiles specs in the netlink msg. The first spec is for 802.1Qbg (pre-)standard, VDP protocol. The second spec is for devices that run a similar protocol as VDP but in firmware, thus hiding the protocol details. In either case, the specs have much in common and makes sense to define the netlink msg as the union of the two specs. For example, both specs have a notition of associating/deassociating a port-profile. And both specs require some information from the hypervisor manager, such as client port instance ID.
The general flow is the port-profile is applied to a host netdev interface using
RTM_SETLINK, the receiver of theRTM_SETLINKmsg communicates with the switch, and the switch virtual port backing the host netdev interface is configured/enabled based on the settings defined by the port-profile. What those settings comprise, and how those settings are managed is again outside the scope of this patch, since this patch only deals with the first step in the flow.There is a
RTM_GETLINKcmd to to return port-profile setting of an interface and to also return the status of the last port-profile association.
IFLA_VF_PORTis modeled after the existing IFLA_VF_* cmd where a VF number is passed in to identify the virtual function (VF) of an SR-IOV- capable device. In this case, the target ofIFLA_VF_PORTmsg is the netdev physical function (PF) device. The PF will apply the port-profile to the VF.IFLA_VF_PORTcan also be used for devices that don't adhere to SR-IOV and can apply the port-profile directly to the netdev target. In this case, the VF number is ignored.
Quoted 5 lines
Passing in a NULL port-profile is used to delete the port-profile association.
Acked-by Arnd Bergmann <[email protected]>Signed-off-by Scott Feldman <[email protected]>Signed-off-by Roopa Prabhu<[email protected]>
Nice, this looks good to me.
Re: [net-next-2.6 V6 PATCH 1/2] Add netlink support for virtual port management (was iovnl)
In reply to Scott Feldmaninclude/linux/if_link.h struct ifla_vf_info { · line 312
Quoted 6 lines · Scott Feldman
include/linux/if_link.h +6
-0+struct ifla_vf_port_vsi { +__u8 vsi_mgr_id; +__u8 vsi_type_id[3 ]; +__u8 vsi_type_version; +__u8 pad[3 ]; +};
Where is this actually used? The only use I could find is in the size calculation.
net/core/rtnetlink.c static inline size_t if_nlmsg_size(const struct net_device *dev) · line 701
Quoted 6 lines
net/core/rtnetlink.c +2
-0+static int rtnl_vf_port_fill_nest (struct sk_buff *skb,struct net_device *dev, +int vf)
Please keep the style used in that file consistent and align arguments to the beginning of the opening '('.
Quoted 8 lines
net/core/rtnetlink.c +8
-0+{ +struct nlattr *data; +int err; + + data =nla_nest_start (skb,IFLA_VF_PORT ); +if (!data) +return -EMSGSIZE ; +
net/core/rtnetlink.c static inline size_t if_nlmsg_size(const struct net_device *dev) · line 719
Quoted 10 lines
net/core/rtnetlink.c +10
-0+if (vf >=0 ) +nla_put_u32 (skb,IFLA_VF_PORT_VF , vf); + + err = dev->netdev_ops->ndo_get_vf_port (dev, vf, skb); +if (err == -EMSGSIZE ) { +nla_nest_cancel (skb, data); +return -EMSGSIZE ; + }else if (err) { +nla_nest_cancel (skb, data); +return 0 ;
Why is the error not returned in this case?
Quoted 17 lines
net/core/rtnetlink.c +17
-0+ } + +nla_nest_end (skb, data); + +return 0 ; +} + +static int rtnl_vf_port_fill (struct sk_buff *skb,struct net_device *dev) +{ +int num_vf; +int err; + +if (!dev->netdev_ops->ndo_get_vf_port || !dev->dev.parent) +return 0 ; + + num_vf =dev_num_vf (dev->dev.parent); +
net/core/rtnetlink.c static inline size_t if_nlmsg_size(const struct net_device *dev) · line 746
Quoted 10 lines
net/core/rtnetlink.c +10
-0+if (num_vf) { +int i; + +for (i =0 ; i < num_vf; i++) { + err =rtnl_vf_port_fill_nest (skb, dev, i); +if (err) + goto nla_put_failure; + } + }else { + err =rtnl_vf_port_fill_nest (skb, dev,-1 );
What does -1 mean?
Quoted 14 lines
net/core/rtnetlink.c +10
-0+if (err) + goto nla_put_failure; + } + +return 0 ; + +nla_put_failure: +return -EMSGSIZE ; +} +static int rtnl_fill_ifinfo (struct sk_buff *skb,struct net_device *dev,int type,u32 pid,u32 seq,u32 change,unsigned int flags)
net/core/rtnetlink.c static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev, · line 829
Quoted 5 lines
net/core/rtnetlink.c +2
-0@@ -747,17 +825,23 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev, goto nla_put_failure;copy_rtnl_link_stats64 (nla_data (attr), stats); +if (dev->dev.parent) +NLA_PUT_U32 (skb,IFLA_NUM_VF ,dev_num_vf (dev->dev.parent));
Should this attribute really be included even if the number is zero?
Quoted 28 lines
net/core/rtnetlink.c +6
-1+if (dev->netdev_ops->ndo_get_vf_config && dev->dev.parent) {int i;struct ifla_vf_info ivi; -NLA_PUT_U32 (skb,IFLA_NUM_VF ,dev_num_vf (dev->dev.parent));for (i =0 ; i <dev_num_vf (dev->dev.parent); i++) {if (dev->netdev_ops->ndo_get_vf_config (dev, i, &ivi))break ;NLA_PUT (skb,IFLA_VFINFO ,sizeof (ivi), &ivi); } } + +if (rtnl_vf_port_fill (skb, dev)) + goto nla_put_failure; +if (dev->rtnl_link_ops) {if (rtnl_link_fill (skb, dev) <0 ) goto nla_put_failure;@@ -824,6 +908,7 @@ const struct nla_policy ifla_policy[IFLA_MAX+1] = { .len = sizeof(struct ifla_vf_vlan) }, [IFLA_VF_TX_RATE] = { .type = NLA_BINARY, .len = sizeof(struct ifla_vf_tx_rate) }, + [IFLA_VF_PORT] = { .type = NLA_NESTED }, };EXPORT_SYMBOL (ifla_policy);
net/core/rtnetlink.c static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = { · line 923
Quoted 7 lines
net/core/rtnetlink.c +4
-0@@ -832,6 +917,20 @@ static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = { [IFLA_INFO_DATA] = { .type = NLA_NESTED }, }; +static const struct nla_policy ifla_vf_port_policy[IFLA_VF_PORT_MAX +1 ] = { + [IFLA_VF_PORT_VF ] = { .type =NLA_U32 }, + [IFLA_VF_PORT_PROFILE ] = { .type =NLA_STRING , + .len =VF_PORT_PROFILE_MAX },
This is oddly indented, please align .len to .type as in the existing attributes.
Quoted 21 lines
net/core/rtnetlink.c +14
-0+ [IFLA_VF_PORT_VSI_TYPE ] = { .type =NLA_BINARY , + .len = sizeof(struct ifla_vf_port_vsi)}, + [IFLA_VF_PORT_INSTANCE_UUID ] = { .type =NLA_BINARY , + .len = VF_PORT_UUID_MAX }, + [IFLA_VF_PORT_HOST_UUID ] = { .type =NLA_STRING , + .len = VF_PORT_UUID_MAX }, + [IFLA_VF_PORT_REQUEST] = { .type = NLA_U8, }, + [IFLA_VF_PORT_RESPONSE] = { .type = NLA_U16, }, +}; +struct net *rtnl_link_get_net (struct net *src_net,struct nlattr *tb[]) {struct net *net;@@ -1028,6 +1127,27 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm, } err =0 ; +if (tb[IFLA_VF_PORT ]) { +struct nlattr *vf_port[IFLA_VF_PORT_MAX +1 ]; +int vf =-1 ; +
net/core/rtnetlink.c static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm, · line 1143
Quoted 10 lines
net/core/rtnetlink.c +10
-0+ err =nla_parse_nested (vf_port,IFLA_VF_PORT_MAX , + tb[IFLA_VF_PORT ], ifla_vf_port_policy); +if (err <0 ) + goto errout; + +if (vf_port[IFLA_VF_PORT_VF ]) + vf =nla_get_u32 (vf_port[IFLA_VF_PORT_VF ]); + err = -EOPNOTSUPP ; +if (ops->ndo_set_vf_port) + err = ops->ndo_set_vf_port (dev, vf, vf_port);
This appears to be addressing a single VF to issue commands. I already explained this during the last set of VF patches, messages are supposed to by symetrical, since you're dumping state for all existing VFs, you also need to accept configuration for multiple VFs. Basically, the kernel must be able to receive a message it created during a dump and fully recreate the state.
Re: [net-next-2.6 V6 PATCH 1/2] Add netlink support for virtual port management (was iovnl)
Quoted 4 lines · * Patrick McHardy ([email protected]) wrote:
net/core/rtnetlink.c static inline size_t if_nlmsg_size(const struct net_device *dev) · line 746
Quoted 2 lines
net/core/rtnetlink.c +2
-0+ }else { + err =rtnl_vf_port_fill_nest (skb, dev,-1 );What does -1 mean?
It means no VFs. Could be made a macro/enum constant
thanks,
-chris
Re: [net-next-2.6 V6 PATCH 1/2] Add netlink support for virtual port management (was iovnl)
Quoted 6 lines · Chris Wright
Quoted 3 lines · * Patrick McHardy ([email protected]) wrote:
net/core/rtnetlink.c static inline size_t if_nlmsg_size(const struct net_device *dev) · line 746
Quoted 2 lines
net/core/rtnetlink.c +2
-0+ }else { + err =rtnl_vf_port_fill_nest (skb, dev,-1 );What does -1 mean?
It means no VFs. Could be made a macro/enum constant
Why call rtnl_vg_port_fill_nest at all in that case? It even calls the ndo_get_vf_port() callback.
Re: [net-next-2.6 V6 PATCH 1/2] Add netlink support for virtual port management (was iovnl)
Quoted 10 lines · * Patrick McHardy ([email protected]) wrote:
Quoted 6 lines · Chris Wright
Quoted 3 lines · * Patrick McHardy ([email protected]) wrote:
net/core/rtnetlink.c static inline size_t if_nlmsg_size(const struct net_device *dev) · line 746
Quoted 2 lines
net/core/rtnetlink.c +2
-0+ }else { + err =rtnl_vf_port_fill_nest (skb, dev,-1 );What does -1 mean?
It means no VFs. Could be made a macro/enum constant
Why call
rtnl_vg_port_fill_nestat all in that case? It even calls thendo_get_vf_port()callback.
For the case where port profile is set on net dev that does not have VFs (e.g. the enic case in 2/2).
thanks,
-chris
Re: [net-next-2.6 V6 PATCH 1/2] Add netlink support for virtual port management (was iovnl)
Quoted 6 lines · Chris Wright
Quoted 5 lines · * Patrick McHardy ([email protected]) wrote:
Quoted 4 lines · Chris Wright
Quoted 3 lines · * Patrick McHardy ([email protected]) wrote:
net/core/rtnetlink.c static inline size_t if_nlmsg_size(const struct net_device *dev) · line 746
Quoted 2 lines
net/core/rtnetlink.c +2
-0+ }else { + err =rtnl_vf_port_fill_nest (skb, dev,-1 );What does -1 mean?
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
It means no VFs. Could be made a macro/enum constant
Why call
rtnl_vg_port_fill_nestat all in that case? It even calls thendo_get_vf_port()callback.For the case where port profile is set on net dev that does not have VFs (e.g. the enic case in 2/2).
Thanks for the explanation. I guess a enum constant would be nice to have. But the bigger problem is the asymetrical message parsing/construction.
BTW:
include/linux/if_link.h struct ifla_vf_info { · line 288
Quoted 6 lines
include/linux/if_link.h +6
-0+enum { +VF_PORT_REQUEST_PREASSOCIATE =0 , +VF_PORT_REQUEST_PREASSOCIATE_RR , +VF_PORT_REQUEST_ASSOCIATE , +VF_PORT_REQUEST_DISASSOCIATE , +};
Do multiple of these commands have to be issued in order to reach "associated" state? That also wouldn't fit into the rtnetlink design, which contains state, not commands.
Re: [net-next-2.6 V6 PATCH 1/2] Add netlink support for virtual port management (was iovnl)
Quoted 11 lines · * Patrick McHardy ([email protected]) wrote:
Quoted 10 lines · Chris Wright
Quoted 8 lines · * Patrick McHardy ([email protected]) wrote:
Quoted 5 lines · Chris Wright
Quoted 3 lines · * Patrick McHardy ([email protected]) wrote:
net/core/rtnetlink.c static inline size_t if_nlmsg_size(const struct net_device *dev) · line 746
Quoted 2 lines
net/core/rtnetlink.c +2
-0+ }else { + err =rtnl_vf_port_fill_nest (skb, dev,-1 );What does -1 mean?
It means no VFs. Could be made a macro/enum constant
Why call
rtnl_vg_port_fill_nestat all in that case? It even calls thendo_get_vf_port()callback.
Quoted 6 lines
Quoted 2 lines
For the case where port profile is set on net dev that does not have VFs (e.g. the enic case in 2/2).
Thanks for the explanation. I guess a enum constant would be nice to have. But the bigger problem is the asymetrical message parsing/construction.
Yeah, what would you like to do there? I think we have to keep the existing, just break out symmtetic set/get?
Quoted 12 lines
BTW:
include/linux/if_link.h struct ifla_vf_info { · line 288
Quoted 6 lines
include/linux/if_link.h +6
-0+enum { +VF_PORT_REQUEST_PREASSOCIATE =0 , +VF_PORT_REQUEST_PREASSOCIATE_RR , +VF_PORT_REQUEST_ASSOCIATE , +VF_PORT_REQUEST_DISASSOCIATE , +};Do multiple of these commands have to be issued in order to reach "associated" state? That also wouldn't fit into the rtnetlink design, which contains state, not commands.
It's optional. At the very least, you need 1 associate/disassociate for each logical link up/down.
For VM migration or (perhaps failover modes) you can optionally issue a preassociate. Preassociate has 2 flavors. One which is purely advisory, another which will reserve resources on the switch. These all reprsent state transitions in the switch, but only associate should allow final logical link up and traffic to flow.
thanks,
-chris
Re: [net-next-2.6 V6 PATCH 1/2] Add netlink support for virtual port management (was iovnl)
Quoted 11 lines · Chris Wright
Quoted 10 lines · * Patrick McHardy ([email protected]) wrote:
Quoted 9 lines · Chris Wright
Quoted 8 lines · * Patrick McHardy ([email protected]) wrote:
Quoted 5 lines · Chris Wright
Quoted 3 lines · * Patrick McHardy ([email protected]) wrote:
Review
Quoted 2 lines
(quoted diff) +2
-0+ } else { + err = rtnl_vf_port_fill_nest(skb, dev, -1);What does -1 mean?
It means no VFs. Could be made a macro/enum constant
Why call
rtnl_vg_port_fill_nestat all in that case? It even calls thendo_get_vf_port()callback.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
For the case where port profile is set on net dev that does not have VFs (e.g. the enic case in 2/2).
Thanks for the explanation. I guess a enum constant would be nice to have. But the bigger problem is the asymetrical message parsing/construction.
Yeah, what would you like to do there? I think we have to keep the existing, just break out symmtetic set/get?
Sure, that would be fine. I'll have a closer look at the exact message layout tommorrow, its getting late here.
Quoted 12 lines
Quoted 11 lines
BTW:
Review
Quoted 6 lines
(quoted diff) +6
-0+enum { + VF_PORT_REQUEST_PREASSOCIATE = 0, + VF_PORT_REQUEST_PREASSOCIATE_RR, + VF_PORT_REQUEST_ASSOCIATE, + VF_PORT_REQUEST_DISASSOCIATE, +};Do multiple of these commands have to be issued in order to reach "associated" state? That also wouldn't fit into the rtnetlink design, which contains state, not commands.
Quoted 8 lines
It's optional. At the very least, you need 1 associate/disassociate for each logical link up/down.
For VM migration or (perhaps failover modes) you can optionally issue a preassociate. Preassociate has 2 flavors. One which is purely advisory, another which will reserve resources on the switch. These all reprsent state transitions in the switch, but only associate should allow final logical link up and traffic to flow.
I see, thanks. That seems fine.
Re: [net-next-2.6 V6 PATCH 1/2] Add netlink support for virtual port management (was iovnl)
In reply to Patrick McHardyQuoted 10 lines · Patrick McHardy
include/linux/if_link.h struct ifla_vf_info { · line 288
Quoted 6 lines
include/linux/if_link.h +6
-0+enum { +VF_PORT_REQUEST_PREASSOCIATE =0 , +VF_PORT_REQUEST_PREASSOCIATE_RR , +VF_PORT_REQUEST_ASSOCIATE , +VF_PORT_REQUEST_DISASSOCIATE , +};Do multiple of these commands have to be issued in order to reach "associated" state? That also wouldn't fit into the rtnetlink design, which contains state, not commands.
In 802.1Qbg (see http://www.ieee802.org/1/files/public/docs2010/bg-joint-evb-0410v1.pdf)
they are defined both as state and as commands. I suggested
using the same definition so that we can use the exact values
when forming or receiving a TLV for the VDP protocol. We can change
freely between the first three during guest migration, but the port (identified by the UUID) can only be in associate state on one
machine, and the switches would use that information to redirect
the data flow to the target of the migration.
The disassociate state is a bit strange in netlink because it essentially means that the other information is now invalid, but I'm not sure if there is a good alternative. If the switch tells us that it is setting the link into disassociate state, that should still be visible in netlink.
Arnd
Re: [net-next-2.6 V6 PATCH 1/2] Add netlink support for virtual port management (was iovnl)
In reply to Patrick McHardyQuoted 10 lines · Patrick McHardy
include/linux/if_link.h struct ifla_vf_info { · line 312
Quoted 6 lines · Scott Feldman
include/linux/if_link.h +6
-0+struct ifla_vf_port_vsi { +__u8 vsi_mgr_id; +__u8 vsi_type_id[3 ]; +__u8 vsi_type_version; +__u8 pad[3 ]; +};Where is this actually used? The only use I could find is in the size calculation.
This is provisioned for VDP use. The enic implementation (patch 2/2) doesn't use these members.
Quoted 2 lines
Please keep the style used in that file consistent and align arguments to the beginning of the opening '('.
I'll fix.
Quoted 12 lines
Quoted 12 lines
net/core/rtnetlink.c +12
-0+{ +struct nlattr *data; +int err; + + data =nla_nest_start (skb,IFLA_VF_PORT ); +if (!data) +return -EMSGSIZE ; + +if (vf >=0 ) +nla_put_u32 (skb,IFLA_VF_PORT_VF , vf); + + err = dev->netdev_ops->ndo_get_vf_port (dev, vf, skb);
Quoted 8 lines
net/core/rtnetlink.c static inline size_t if_nlmsg_size(const struct net_device *dev) · line 719
Quoted 6 lines
+ if (err ==
-EMSGSIZE) {net/core/rtnetlink.c +5
-0+nla_nest_cancel (skb, data); +return -EMSGSIZE ; + }else if (err) { +nla_nest_cancel (skb, data); +return 0 ;Why is the error not returned in this case?
I was think the netdev could fail the call if the operation wasn't supported. I better choice would be to not set the netdev->op in the first place. Let me fix this.
Quoted 18 lines
Quoted 18 lines
net/core/rtnetlink.c +10
-0+if (err) + goto nla_put_failure; + } + +return 0 ; + +nla_put_failure: +return -EMSGSIZE ; +} +static int rtnl_fill_ifinfo (struct sk_buff *skb,struct net_device *dev,int type,u32 pid,u32 seq,u32 change,unsigned int flags)@@ -747,17 +825,23 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, structnet_device *dev, goto nla_put_failure;copy_rtnl_link_stats64 (nla_data (attr), stats);
Quoted 4 lines
net/core/rtnetlink.c static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev, · line 829
Quoted 2 lines
net/core/rtnetlink.c +2
-0+if (dev->dev.parent) +NLA_PUT_U32 (skb,IFLA_NUM_VF ,dev_num_vf (dev->dev.parent));Should this attribute really be included even if the number is zero?
The previous code would write zero also. I moved it out of the get_vf_config check so it could be used for get_vf_port as well.
Quoted 2 lines
This is oddly indented, please align .len to .type as in the existing attributes.
I'll fix, but bumping into 80 char issues...
Quoted 31 lines
Quoted 31 lines
net/core/rtnetlink.c +23
-0+ [IFLA_VF_PORT_VSI_TYPE ] = { .type =NLA_BINARY , + .len = sizeof(struct ifla_vf_port_vsi)}, + [IFLA_VF_PORT_INSTANCE_UUID ] = { .type =NLA_BINARY , + .len = VF_PORT_UUID_MAX }, + [IFLA_VF_PORT_HOST_UUID ] = { .type =NLA_STRING , + .len = VF_PORT_UUID_MAX }, + [IFLA_VF_PORT_REQUEST] = { .type = NLA_U8, }, + [IFLA_VF_PORT_RESPONSE] = { .type = NLA_U16, }, +}; +struct net *rtnl_link_get_net (struct net *src_net,struct nlattr *tb[]) {struct net *net;@@ -1028,6 +1127,27 @@ static int do_setlink(struct net_device *dev, structifinfomsg *ifm, } err =0 ; +if (tb[IFLA_VF_PORT ]) { +struct nlattr *vf_port[IFLA_VF_PORT_MAX +1 ]; +int vf =-1 ; + + err =nla_parse_nested (vf_port,IFLA_VF_PORT_MAX , + tb[IFLA_VF_PORT ], ifla_vf_port_policy); +if (err <0 ) + goto errout; + +if (vf_port[IFLA_VF_PORT_VF ]) + vf =nla_get_u32 (vf_port[IFLA_VF_PORT_VF ]); + err = -EOPNOTSUPP ; +if (ops->ndo_set_vf_port)
Quoted 8 lines
net/core/rtnetlink.c static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm, · line 1144
Quoted 1 line
net/core/rtnetlink.c +1
-0+ err = ops->ndo_set_vf_port (dev, vf, vf_port);This appears to be addressing a single VF to issue commands. I already explained this during the last set of VF patches, messages are supposed to by symetrical, since you're dumping state for all existing VFs, you also need to accept configuration for multiple VFs. Basically, the kernel must be able to receive a message it created during a dump and fully recreate the state.
This was modeled same as existing IFLA_VF_ cmd where single VF is addressed on set, but all VFs for PF are dumped on get.
Re: [net-next-2.6 V6 PATCH 1/2] Add netlink support for virtual port management (was iovnl)
Quoted 14 lines · Scott Feldman
Quoted 11 lines · Patrick McHardy
net/core/rtnetlink.c static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm, · line 1144
Quoted 5 lines
net/core/rtnetlink.c +5
-0+if (vf_port[IFLA_VF_PORT_VF ]) + vf =nla_get_u32 (vf_port[IFLA_VF_PORT_VF ]); + err = -EOPNOTSUPP ; +if (ops->ndo_set_vf_port) + err = ops->ndo_set_vf_port (dev, vf, vf_port);This appears to be addressing a single VF to issue commands. I already explained this during the last set of VF patches, messages are supposed to by symetrical, since you're dumping state for all existing VFs, you also need to accept configuration for multiple VFs. Basically, the kernel must be able to receive a message it created during a dump and fully recreate the state.
Quoted 2 lines
This was modeled same as existing
IFLA_VF_cmd where single VF is addressed on set, but all VFs for PF are dumped on get.
Yes, that one should have been done differently as well, unfortunately my comments were ignored. So far rtnetlink had two properties that are now broken:
- messages sent by the kernel could be sent back to the kernel to re-create an object in the same state
- the same parsing functions could be used in userspace for messages sent by the kernel and netlink error messages, which contain the original userspace message
I know at least one program I've written a few years ago which relies on the second property. Anyways, this is easily fixable by encapsulating all top-level VF attributes in a list and invoking the ndo_set_vf_port() callback for each VF configuration.
PATCH v6 2/2 Add ndo_{set|get}_vf_port support for enic dynamic vnics
In reply to Scott FeldmanFrom: Scott Feldman <[email protected]>
Add enic ndo_{set|get}_vf_port ops to support setting/getting port-profile for enic dynamic devices. Enic dynamic devices are just like normal enic eth devices except dynamic enics require an extra configuration step to assign a port-profile identifier to the interface before the interface is useable. Once a port-profile is assigned, link comes up on the interface and is ready for I/O. The port-profile is used to configure the network port assigned to the interface. The network port configuration includes VLAN membership, QoS policies, and port security settings typical of a data center network.
A dynamic enic initially has a zero-mac address. Before a port-profile is assigned, a valid non-zero unicast mac address should be assign to the dynamic enic interface.
--- drivers/net/enic/Makefile | 2 drivers/net/enic/enic.h | 9 + drivers/net/enic/enic_main.c | 321 +++++++++++++++++++++++++++++++++++++++--- drivers/net/enic/enic_res.c | 5 - drivers/net/enic/enic_res.h | 1 drivers/net/enic/vnic_dev.c | 58 +++++++- drivers/net/enic/vnic_dev.h | 7 + drivers/net/enic/vnic_vic.c | 73 ++++++++++ drivers/net/enic/vnic_vic.h | 59 ++++++++ 9 files changed, 500 insertions(+), 35 deletions(-)
drivers/net/enic/Makefile +1 -1
@@ -1,5 +1,5 @@ obj-$(CONFIG_ENIC) := enic.o enic-y := enic_main.o vnic_cq.o vnic_intr.o vnic_wq.o \ - enic_res.o vnic_dev.o vnic_rq.o + enic_res.o vnic_dev.o vnic_rq.o vnic_vic.o
drivers/net/enic/enic.h +8 -1
@@ -34,7 +34,7 @@#define DRV_NAME "enic"#define DRV_DESCRIPTION "Cisco VIC Ethernet NIC Driver" -#define DRV_VERSION "1.3.1.1" +#define DRV_VERSION "1.3.1.1-pp"#define DRV_COPYRIGHT "Copyright 2008-2009 Cisco Systems, Inc"#define PFX DRV_NAME ": "
@@ -74,6 +74,12 @@ struct enic_msix_entry {void *devid; }; +struct enic_port_profile { +char name[VF_PORT_PROFILE_MAX ]; +u8 instance_uuid[VF_PORT_UUID_MAX ]; +u8 host_uuid[VF_PORT_UUID_MAX ]; +}; +/* Per-instance private data structure */ struct enic {struct net_device *netdev;
@@ -95,6 +101,7 @@ struct enic {u32 port_mtu;u32 rx_coalesce_usecs;u32 tx_coalesce_usecs; +struct enic_port_profile pp;/* work queue cache line section */ ____cacheline_aligned struct vnic_wq wq[ENIC_WQ_MAX ];
drivers/net/enic/enic_main.c +298 -23
392 lines not on this page · raw message
drivers/net/enic/enic_res.c +0 -5
@@ -103,11 +103,6 @@ int enic_get_vnic_config(struct enic *enic)return 0 ; } -void enic_add_station_addr (struct enic *enic) -{ -vnic_dev_add_addr (enic->vdev, enic->mac_addr); -} -void enic_add_multicast_addr (struct enic *enic,u8 *addr) {vnic_dev_add_addr (enic->vdev, addr);
drivers/net/enic/enic_res.h +0 -1
@@ -131,7 +131,6 @@ static inline void enic_queue_rq_desc(struct vnic_rq *rq,struct enic ;int enic_get_vnic_config (struct enic *); -void enic_add_station_addr (struct enic *enic);void enic_add_multicast_addr (struct enic *enic,u8 *addr);void enic_del_multicast_addr (struct enic *enic,u8 *addr);void enic_add_vlan (struct enic *enic,u16 vlanid);
drivers/net/enic/vnic_dev.c +56 -2
84 lines not on this page · raw message
drivers/net/enic/vnic_dev.h +5 -2
@@ -103,8 +103,8 @@ int vnic_dev_stats_dump(struct vnic_dev *vdev, struct vnic_stats **stats);int vnic_dev_hang_notify (struct vnic_dev *vdev);void vnic_dev_packet_filter (struct vnic_dev *vdev,int directed,int multicast,int broadcast,int promisc,int allmulti); -void vnic_dev_add_addr (struct vnic_dev *vdev,u8 *addr); -void vnic_dev_del_addr (struct vnic_dev *vdev,u8 *addr); +int vnic_dev_add_addr (struct vnic_dev *vdev,u8 *addr); +int vnic_dev_del_addr (struct vnic_dev *vdev,u8 *addr);int vnic_dev_mac_addr (struct vnic_dev *vdev,u8 *mac_addr);int vnic_dev_raise_intr (struct vnic_dev *vdev,u16 intr); int vnic_dev_notify_setcmd(struct vnic_dev *vdev,
@@ -124,6 +124,9 @@ int vnic_dev_disable(struct vnic_dev *vdev);int vnic_dev_open (struct vnic_dev *vdev,int arg);int vnic_dev_open_done (struct vnic_dev *vdev,int *done);int vnic_dev_init (struct vnic_dev *vdev,int arg); +int vnic_dev_init_done (struct vnic_dev *vdev,int *done,int *err); +int vnic_dev_init_prov (struct vnic_dev *vdev,u8 *buf,u32 len); +int vnic_dev_deinit (struct vnic_dev *vdev);int vnic_dev_soft_reset (struct vnic_dev *vdev,int arg);int vnic_dev_soft_reset_done (struct vnic_dev *vdev,int *done); void vnic_dev_set_intr_mode(struct vnic_dev *vdev,
drivers/net/enic/vnic_vic.c new file +73 -0
73 lines not on this page · raw message
drivers/net/enic/vnic_vic.h new file +59 -0
59 lines not on this page · raw message