Add virtual port netlink support
Subsystems (2)
v9 cover Add virtual port netlink support
[rebase to sync with virtif changes]
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 v9 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 two new sub msgs called IFLA_VF_PORTS and IFLA_PORT_SELF (added to end of IFLA_cmd list). These are both nested atrtibutes using this layout:
[IFLA_NUM_VF]
[IFLA_VF_PORTS]
[IFLA_VF_PORT]
[IFLA_PORT_*], ...
[IFLA_VF_PORT]
[IFLA_PORT_*], ...
...
[IFLA_PORT_SELF]
[IFLA_PORT_*], ...These attributes are design to be set and get symmetrically. VF_PORTS is a list of VF_PORTs, one for each VF, when dealing with an SR-IOV device. PORT_SELF is for the PF of the SR-IOV device, in case it wants to also have a port-profile, or for the case where the VF==PF, like in enic patch 2/2 of this patch set.
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.
--- include/linux/if_link.h | 75 ++++++++++++++++++++ include/linux/netdevice.h | 8 ++ net/core/rtnetlink.c | 169 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 251 insertions(+), 1 deletions(-)
include/linux/if_link.h +75 -0
@@ -113,6 +113,8 @@ enum {IFLA_NUM_VF ,/* Number of VFs if device is SR-IOV PF */ IFLA_VFINFO_LIST ,IFLA_STATS64 , +IFLA_VF_PORTS , +IFLA_PORT_SELF , __IFLA_MAX };
@@ -274,4 +276,77 @@ struct ifla_vf_info {__u32 qos; __u32 tx_rate; }; + +/* VF ports management section +* +* Nested layout of set/get msg is: +* +* [IFLA_NUM_VF] +* [IFLA_VF_PORTS] +* [IFLA_VF_PORT] +* [IFLA_PORT_*], ... +* [IFLA_VF_PORT] +* [IFLA_PORT_*], ... +* ... +* [IFLA_PORT_SELF] +* [IFLA_PORT_*], ... +*/ + +enum { +IFLA_VF_PORT_UNSPEC , +IFLA_VF_PORT ,/* nest */ + __IFLA_VF_PORT_MAX, +}; + +#define IFLA_VF_PORT_MAX (__IFLA_VF_PORT_MAX - 1) + +enum { +IFLA_PORT_UNSPEC , +IFLA_PORT_VF ,/* __u32 */ +IFLA_PORT_PROFILE ,/* string */ +IFLA_PORT_VSI_TYPE ,/* 802.1Qbg (pre-)standard VDP */ +IFLA_PORT_INSTANCE_UUID ,/* binary UUID */ +IFLA_PORT_HOST_UUID ,/* binary UUID */ +IFLA_PORT_REQUEST ,/* __u8 */ +IFLA_PORT_RESPONSE ,/* __u16, output only */ + __IFLA_PORT_MAX, +}; + +#define IFLA_PORT_MAX (__IFLA_PORT_MAX - 1) + +#define PORT_PROFILE_MAX 40 +#define PORT_UUID_MAX 16 +#define PORT_SELF_VF -1 + +enum { +PORT_REQUEST_PREASSOCIATE =0 , +PORT_REQUEST_PREASSOCIATE_RR , +PORT_REQUEST_ASSOCIATE , +PORT_REQUEST_DISASSOCIATE , +}; + +enum { +PORT_VDP_RESPONSE_SUCCESS =0 , +PORT_VDP_RESPONSE_INVALID_FORMAT , +PORT_VDP_RESPONSE_INSUFFICIENT_RESOURCES , +PORT_VDP_RESPONSE_UNUSED_VTID , +PORT_VDP_RESPONSE_VTID_VIOLATION , +PORT_VDP_RESPONSE_VTID_VERSION_VIOALTION , +PORT_VDP_RESPONSE_OUT_OF_SYNC , +/* 0x08-0xFF reserved for future VDP use */ +PORT_PROFILE_RESPONSE_SUCCESS =0x100 , +PORT_PROFILE_RESPONSE_INPROGRESS , +PORT_PROFILE_RESPONSE_INVALID , +PORT_PROFILE_RESPONSE_BADSTATE , +PORT_PROFILE_RESPONSE_INSUFFICIENT_RESOURCES , +PORT_PROFILE_RESPONSE_ERROR , +}; + +struct ifla_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 +8 -0
@@ -686,6 +686,9 @@ 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 *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 +738,11 @@ 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 *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 +168 -1
220 lines not on this page · raw message
Re: [net-next-2.6 V9 PATCH 1/2] Add netlink support for virtual port management
From: Scott Feldman <[email protected]>
Date: Mon, 17 May 2010 22:48:35 -0700
...
Quoted 2 lines
Signed-off-by Scott Feldman <[email protected]>Signed-off-by Roopa Prabhu<[email protected]>
Applied.
Re: [net-next-2.6 V9 PATCH 1/2] Add netlink support for virtual port management (was iovnl)
In reply to Scott FeldmanQuoted 9 lines · Scott Feldman
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 two new sub msgs calledIFLA_VF_PORTSandIFLA_PORT_SELF(added to end ofIFLA_cmdlist). These are both nested atrtibutes using this layout:...
Appologies for the delay, my mailserver failed me once again :|
This version looks very good to me, just one question:
Quoted 13 lines
net/core/rtnetlink.c +13
-0+static int rtnl_vf_ports_fill (struct sk_buff *skb,struct net_device *dev) +{ +struct nlattr *vf_ports; +struct nlattr *vf_port; +int vf; +int err; + + vf_ports =nla_nest_start (skb,IFLA_VF_PORTS ); +if (!vf_ports) +return -EMSGSIZE ; + +for (vf =0 ; vf <dev_num_vf (dev->dev.parent); vf++) { + vf_port =nla_nest_start (skb,IFLA_VF_PORT );
net/core/rtnetlink.c static inline size_t if_nlmsg_size(const struct net_device *dev) · line 734
Quoted 10 lines
net/core/rtnetlink.c +10
-0+if (!vf_port) { +nla_nest_cancel (skb, vf_ports); +return -EMSGSIZE ; + } +NLA_PUT_U32 (skb,IFLA_PORT_VF , vf); + err = dev->netdev_ops->ndo_get_vf_port (dev, vf, skb); +if (err) { +nla_put_failure: +nla_nest_cancel (skb, vf_port); +continue ;
Are you sure you want to continue here? During a full dump this means that the last VF port fitting in the skb will most likely be incomplete since the higher layer code won't notice that the size was exceeded and the entry should be dumped into another skb.
Quoted 8 lines
net/core/rtnetlink.c +8
-0+ } +nla_nest_end (skb, vf_port); + } + +nla_nest_end (skb, vf_ports); + +return 0 ; +}
Re: [net-next-2.6 V9 PATCH 1/2] Add netlink support for virtual port management (was iovnl)
Quoted 22 lines · Patrick McHardy
Quoted 21 lines · Scott Feldman
net/core/rtnetlink.c +21
-0+static int rtnl_vf_ports_fill (struct sk_buff *skb,struct net_device *dev) +{ +struct nlattr *vf_ports; +struct nlattr *vf_port; +int vf; +int err; + + vf_ports =nla_nest_start (skb,IFLA_VF_PORTS ); +if (!vf_ports) +return -EMSGSIZE ; + +for (vf =0 ; vf <dev_num_vf (dev->dev.parent); vf++) { + vf_port =nla_nest_start (skb,IFLA_VF_PORT ); +if (!vf_port) { +nla_nest_cancel (skb, vf_ports); +return -EMSGSIZE ; + } +NLA_PUT_U32 (skb,IFLA_PORT_VF , vf); + err = dev->netdev_ops->ndo_get_vf_port (dev, vf, skb); +if (err) { +nla_put_failure:
Quoted 8 lines
net/core/rtnetlink.c static inline size_t if_nlmsg_size(const struct net_device *dev) · line 734
Quoted 2 lines
net/core/rtnetlink.c +2
-0+nla_nest_cancel (skb, vf_port); +continue ;Are you sure you want to continue here? During a full dump this means that the last VF port fitting in the skb will most likely be incomplete since the higher layer code won't notice that the size was exceeded and the entry should be dumped into another skb.
Drats, that's a bug. I'll get that fixed. Thanks Patrick for catching it.
-scott
PATCH v9 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 | 10 + drivers/net/enic/enic_main.c | 330 ++++++++++++++++++++++++++++++++++++++++-- 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, 521 insertions(+), 24 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 +9 -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,13 @@ struct enic_msix_entry {void *devid; }; +struct enic_port_profile { +u8 request; +char name[PORT_PROFILE_MAX ]; +u8 instance_uuid[PORT_UUID_MAX ]; +u8 host_uuid[PORT_UUID_MAX ]; +}; +/* Per-instance private data structure */ struct enic {struct net_device *netdev;
@@ -95,6 +102,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 +318 -12
413 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
David Miller
maintainerRe: [net-next-2.6 V9 PATCH 2/2] Add ndo_{set|get}_vf_port support for enic dynamic vnics
From: Scott Feldman <[email protected]>
Date: Mon, 17 May 2010 22:48:42 -0700
...
Quoted 2 lines
Signed-off-by Scott Feldman <[email protected]>Signed-off-by Roopa Prabhu<[email protected]>
Also applied, thanks for rebasing this Scott.