net: Add ndo_fcoe_enable/ndo_fcoe_disable to net_device_ops
Subsystems (2)
PATCH 1/8 net: Add ndo_fcoe_enable/ndo_fcoe_disable to net_device_ops
From: Yi Zou <[email protected]>
Add ndo_fcoe_enable/_disable to net_device_ops so the corresponding HW can initialize itself for FCoE traffic or clean up after FCoE traffic is done. This is expected to be called by the kernel FCoE stack upon receiving a request for creating an FCoE instance on the corresponding netdev interface. When implemented by the actual HW, the HW driver check the op code to perform corresponding initialization or clean up for FCoE. The initialization normally includes allocating extra queues for FCoE, setting corresponding HW registers for FCoE, indicating FCoE offload features via netdev, etc. The clean-up would include releasing the resources allocated for FCoE.
---
include/linux/netdevice.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
include/linux/netdevice.h +2 -0
@@ -623,6 +623,8 @@ struct net_device_ops {void (*ndo_poll_controller)(struct net_device *dev);#endif #if defined(CONFIG_FCOE ) || defined(CONFIG_FCOE_MODULE ) +int (*ndo_fcoe_enable)(struct net_device *dev); +int (*ndo_fcoe_disable)(struct net_device *dev); int (*ndo_fcoe_ddp_setup)(struct net_device *dev, u16 xid, struct scatterlist *sgl,
PATCH 2/8 vlan: Add support for net_devices_ops.ndo_fcoe_enable/_disable to VLAN
From: Yi Zou <[email protected]>
This adds implementation of the net_devices_ops.ndo_fcoe_enable/_disable to the VLAN driver. It checks if the real_dev has support for ndo_fcoe_enable/ ndo_fcoe_disable and if so, passes on to call the associated real_dev.
---
net/8021q/vlan_dev.c | 26 ++++++++++++++++++++++++++ 1 files changed, 26 insertions(+), 0 deletions(-)
net/8021q/vlan_dev.c +26 -0
@@ -586,6 +586,28 @@ static int vlan_dev_fcoe_ddp_done(struct net_device *dev, u16 xid)return len; } + +static int vlan_dev_fcoe_enable (struct net_device *dev) +{ +struct net_device *real_dev =vlan_dev_info (dev)->real_dev; +const struct net_device_ops *ops = real_dev->netdev_ops; +int rc = -EINVAL ; + +if (ops->ndo_fcoe_enable) + rc = ops->ndo_fcoe_enable (real_dev); +return rc; +} + +static int vlan_dev_fcoe_disable (struct net_device *dev) +{ +struct net_device *real_dev =vlan_dev_info (dev)->real_dev; +const struct net_device_ops *ops = real_dev->netdev_ops; +int rc = -EINVAL ; + +if (ops->ndo_fcoe_disable) + rc = ops->ndo_fcoe_disable (real_dev); +return rc; +}#endif static void vlan_dev_change_rx_flags (struct net_device *dev,int change)
@@ -749,6 +771,8 @@ static const struct net_device_ops vlan_netdev_ops = {#if defined(CONFIG_FCOE ) || defined(CONFIG_FCOE_MODULE ) .ndo_fcoe_ddp_setup = vlan_dev_fcoe_ddp_setup, .ndo_fcoe_ddp_done = vlan_dev_fcoe_ddp_done, + .ndo_fcoe_enable = vlan_dev_fcoe_enable, + .ndo_fcoe_disable = vlan_dev_fcoe_disable,#endif };
@@ -769,6 +793,8 @@ static const struct net_device_ops vlan_netdev_accel_ops = {#if defined(CONFIG_FCOE ) || defined(CONFIG_FCOE_MODULE ) .ndo_fcoe_ddp_setup = vlan_dev_fcoe_ddp_setup, .ndo_fcoe_ddp_done = vlan_dev_fcoe_ddp_done, + .ndo_fcoe_enable = vlan_dev_fcoe_enable, + .ndo_fcoe_disable = vlan_dev_fcoe_disable,#endif };
PATCH 3/8 ixgbe: Add support for the net_device_ops.ndo_fcoe_enable/disable to 82599
In reply to Jeff KirsherFrom: Yi Zou <[email protected]>
This adds support to the net_device_ops.ndo_fcoe_enable/disable for 82599. This consequently allows us to dynamically turn FCoE offload feature on or off upon incoming calls to ndo_fcoe_enable/disable. When this happens, FCoE offload features are enabled/disabled accordingly, and this is regardless of whether DCB being turned on or not.
---
drivers/net/ixgbe/ixgbe.h | 2 + drivers/net/ixgbe/ixgbe_dcb_nl.c | 33 ------------- drivers/net/ixgbe/ixgbe_fcoe.c | 94 ++++++++++++++++++++++++++++++++++++++ drivers/net/ixgbe/ixgbe_main.c | 2 + 4 files changed, 98 insertions(+), 33 deletions(-)
drivers/net/ixgbe/ixgbe.h +2 -0
@@ -450,6 +450,8 @@ extern int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter,extern int ixgbe_fcoe_ddp_get (struct net_device *netdev,u16 xid,struct scatterlist *sgl,unsigned int sgc);extern int ixgbe_fcoe_ddp_put (struct net_device *netdev,u16 xid); +extern int ixgbe_fcoe_enable (struct net_device *netdev); +extern int ixgbe_fcoe_disable (struct net_device *netdev);#endif /* IXGBE_FCOE */ #endif /* _IXGBE_H_ */
drivers/net/ixgbe/ixgbe_dcb_nl.c +0 -33
@@ -139,23 +139,6 @@ static u8 ixgbe_dcbnl_set_state(struct net_device *netdev, u8 state) adapter->flags &= ~IXGBE_FLAG_FDIR_PERFECT_CAPABLE ; } adapter->flags |=IXGBE_FLAG_DCB_ENABLED ; -#ifdef IXGBE_FCOE -/* Turn on FCoE offload */ -if ((adapter->flags &IXGBE_FLAG_FCOE_CAPABLE ) && - (!(adapter->flags &IXGBE_FLAG_FCOE_ENABLED ))) { - adapter->flags |=IXGBE_FLAG_FCOE_ENABLED ; - adapter->ring_feature[RING_F_FCOE ].indices = -IXGBE_FCRETA_SIZE ; - netdev->features |=NETIF_F_FCOE_CRC ; - netdev->features |=NETIF_F_FSO ; - netdev->features |=NETIF_F_FCOE_MTU ; - netdev->vlan_features |=NETIF_F_FCOE_CRC ; - netdev->vlan_features |=NETIF_F_FSO ; - netdev->vlan_features |=NETIF_F_FCOE_MTU ; - netdev->fcoe_ddp_xid =IXGBE_FCOE_DDP_MAX -1 ; -netdev_features_change (netdev); - } -#endif /* IXGBE_FCOE */ ixgbe_init_interrupt_scheme (adapter);if (netif_running (netdev)) netdev->netdev_ops->ndo_open (netdev);
@@ -174,22 +157,6 @@ static u8 ixgbe_dcbnl_set_state(struct net_device *netdev, u8 state)if (adapter->hw.mac.type == ixgbe_mac_82599EB) adapter->flags |=IXGBE_FLAG_FDIR_HASH_CAPABLE ; -#ifdef IXGBE_FCOE -/* Turn off FCoE offload */ -if (adapter->flags & (IXGBE_FLAG_FCOE_CAPABLE | -IXGBE_FLAG_FCOE_ENABLED )) { - adapter->flags &= ~IXGBE_FLAG_FCOE_ENABLED ; - adapter->ring_feature[RING_F_FCOE ].indices =0 ; - netdev->features &= ~NETIF_F_FCOE_CRC ; - netdev->features &= ~NETIF_F_FSO ; - netdev->features &= ~NETIF_F_FCOE_MTU ; - netdev->vlan_features &= ~NETIF_F_FCOE_CRC ; - netdev->vlan_features &= ~NETIF_F_FSO ; - netdev->vlan_features &= ~NETIF_F_FCOE_MTU ; - netdev->fcoe_ddp_xid =0 ; -netdev_features_change (netdev); - } -#endif /* IXGBE_FCOE */ ixgbe_init_interrupt_scheme (adapter);if (netif_running (netdev)) netdev->netdev_ops->ndo_open (netdev);
drivers/net/ixgbe/ixgbe_fcoe.c +94 -0
97 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_main.c +2 -0
@@ -5376,6 +5376,8 @@ static const struct net_device_ops ixgbe_netdev_ops = {#ifdef IXGBE_FCOE .ndo_fcoe_ddp_setup = ixgbe_fcoe_ddp_get, .ndo_fcoe_ddp_done = ixgbe_fcoe_ddp_put, + .ndo_fcoe_enable = ixgbe_fcoe_enable, + .ndo_fcoe_disable = ixgbe_fcoe_disable,#endif /* IXGBE_FCOE */ };
PATCH 4/8 dcbnl: Add support for setapp/getapp commands to dcbnl
In reply to Jeff KirsherFrom: Yi Zou <[email protected]>
This patch adds dcbnl command definitions to support setapp/getapp functionality from the IEEE 802.1Qaz Data Center Bridging Capability Exchange protocol (DCBX) specification. Section 3.3 defines the application protocol and its 802.1p user priority in DCBX, which is implemented here as a pair of setapp/getapp commands in the kernel dcbnl for setting and retrieving the user priority for an given application protocol. The protocol is identified by the combination of an id and an idtype. Currently, when idtype is 0, the corresponding id gives the ether type of this protocol, e.g., for FCoE, it will be 0x8906; when idtype is 1, then the corresponding id gives the TCP or UDP port number.
For more information regarding DCBX spec., please refer to the following:
http://www.ieee802.org/1/files/public/docs2008/
az-wadekar-dcbx-capability-exchange-discovery-protocol-1108-v1.01.pdf
---
include/linux/dcbnl.h | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-)
include/linux/dcbnl.h +18 -0
@@ -50,6 +50,8 @@ struct dcbmsg {* @DCB_CMD_SNUMTCS: set the number of traffic classes * @DCB_CMD_GBCN: set backward congestion notification configuration * @DCB_CMD_SBCN: get backward congestion notification configration. +* @DCB_CMD_GAPP: get application protocol configuration +* @DCB_CMD_SAPP: set application protocol configuration */ enum dcbnl_commands {DCB_CMD_UNDEFINED ,
@@ -80,6 +82,9 @@ enum dcbnl_commands {DCB_CMD_BCN_GCFG ,DCB_CMD_BCN_SCFG , +DCB_CMD_GAPP , +DCB_CMD_SAPP , + __DCB_CMD_ENUM_MAX, DCB_CMD_MAX = __DCB_CMD_ENUM_MAX - 1, };
@@ -114,6 +119,7 @@ enum dcbnl_attrs {DCB_ATTR_CAP ,DCB_ATTR_NUMTCS ,DCB_ATTR_BCN , +DCB_ATTR_APP , __DCB_ATTR_ENUM_MAX, DCB_ATTR_MAX = __DCB_ATTR_ENUM_MAX - 1,
@@ -338,5 +344,17 @@ enum dcb_general_attr_values {DCB_ATTR_VALUE_UNDEFINED =0xff }; +#define DCB_APP_IDTYPE_ETHTYPE 0x00 +#define DCB_APP_IDTYPE_PORTNUM 0x01 +enum dcbnl_app_attrs { +DCB_APP_ATTR_UNDEFINED , + +DCB_APP_ATTR_IDTYPE , +DCB_APP_ATTR_ID , +DCB_APP_ATTR_PRIORITY , + + __DCB_APP_ATTR_ENUM_MAX, +DCB_APP_ATTR_MAX = __DCB_APP_ATTR_ENUM_MAX -1 , +};#endif /* __LINUX_DCBNL_H__ */
PATCH 5/8 dcbnl: Add support for setapp/getapp to netdev dcbnl_rtnl_ops
In reply to Jeff KirsherFrom: Yi Zou <[email protected]>
Adds support of dcbnl setapp/getapp to dcbnl_rtnl_ops in netdev to allow LLDs to implement their corresponding dcbnl setapp/getapp ops to support the IEEE 802.1Q DCBX setapp/getapp commands.
---
include/net/dcbnl.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
include/net/dcbnl.h +2 -0
@@ -48,6 +48,8 @@ struct dcbnl_rtnl_ops {void (*setbcncfg)(struct net_device *,int ,u32 );void (*getbcnrp)(struct net_device *,int ,u8 *);void (*setbcnrp)(struct net_device *,int ,u8 ); +u8 (*setapp)(struct net_device *,u8 ,u16 ,u8 ); + u8 (*getapp)(struct net_device *, u8, u16); };#endif /* __NET_DCBNL_H__ */
PATCH 6/8 dcbnl: Add netlink attributes for setapp/getapp to dcbnl
In reply to Jeff KirsherFrom: Yi Zou <[email protected]>
Add defines for dcbnl netlink attributes to support netlink message passing of setapp/getapp in dcbnl.
---
net/dcb/dcbnl.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
net/dcb/dcbnl.c +8 -0
@@ -64,6 +64,7 @@ static struct nla_policy dcbnl_rtnl_policy[DCB_ATTR_MAX + 1] = { [DCB_ATTR_CAP] = {.type = NLA_NESTED}, [DCB_ATTR_PFC_STATE] = {.type = NLA_U8}, [DCB_ATTR_BCN] = {.type = NLA_NESTED}, + [DCB_ATTR_APP] = {.type = NLA_NESTED}, };/* DCB priority flow control to User Priority nested attributes */
@@ -158,6 +159,13 @@ static struct nla_policy dcbnl_bcn_nest[DCB_BCN_ATTR_MAX + 1] = { [DCB_BCN_ATTR_ALL] = {.type = NLA_FLAG}, }; +/* DCB APP nested attributes. */ +static struct nla_policy dcbnl_app_nest[DCB_APP_ATTR_MAX +1 ] = { + [DCB_APP_ATTR_IDTYPE ] = {.type =NLA_U8 }, + [DCB_APP_ATTR_ID ] = {.type =NLA_U16 }, + [DCB_APP_ATTR_PRIORITY ] = {.type =NLA_U8 }, +}; +/* standard netlink reply call */ static int dcbnl_reply (u8 value,u8 event,u8 cmd,u8 attr,u32 pid,u32 seq,u16 flags)
PATCH 7/8 dcbnl: Add implementations of dcbnl setapp/getapp commands
In reply to Jeff KirsherFrom: Yi Zou <[email protected]>
Implements the dcbnl netlink setapp/getapp pair. When a setapp/getapp is received, dcbnl would just pass on to dcbnl_rtnl_op.setapp/getapp that are supposed to be implemented by the low level drivers.
---
net/dcb/dcbnl.c | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 122 insertions(+), 0 deletions(-)
net/dcb/dcbnl.c +122 -0
@@ -544,6 +544,120 @@ static int dcbnl_setpfcstate(struct net_device *netdev, struct nlattr **tb,return ret; } +static int dcbnl_getapp (struct net_device *netdev,struct nlattr **tb, +u32 pid,u32 seq,u16 flags) +{ +struct sk_buff *dcbnl_skb; +struct nlmsghdr *nlh; +struct dcbmsg *dcb; +struct nlattr *app_nest; +struct nlattr *app_tb[DCB_APP_ATTR_MAX +1 ]; +u16 id; +u8 up, idtype; +int ret = -EINVAL ; + +if (!tb[DCB_ATTR_APP ] || !netdev->dcbnl_ops->getapp) + goto out; + + ret =nla_parse_nested (app_tb,DCB_APP_ATTR_MAX , tb[DCB_ATTR_APP ], + dcbnl_app_nest); +if (ret) + goto out; + + ret = -EINVAL ; +/* all must be non-null */ +if ((!app_tb[DCB_APP_ATTR_IDTYPE ]) || + (!app_tb[DCB_APP_ATTR_ID ])) + goto out; + +/* either by eth type or by socket number */ + idtype =nla_get_u8 (app_tb[DCB_APP_ATTR_IDTYPE ]); +if ((idtype !=DCB_APP_IDTYPE_ETHTYPE ) && + (idtype !=DCB_APP_IDTYPE_PORTNUM )) + goto out; + + id =nla_get_u16 (app_tb[DCB_APP_ATTR_ID ]); + up = netdev->dcbnl_ops->getapp (netdev, idtype, id); + +/* send this back */ + dcbnl_skb =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_KERNEL ); +if (!dcbnl_skb) + goto out; + + nlh =NLMSG_NEW (dcbnl_skb, pid, seq,RTM_GETDCB ,sizeof (*dcb), flags); + dcb =NLMSG_DATA (nlh); + dcb->dcb_family =AF_UNSPEC ; + dcb->cmd =DCB_CMD_GAPP ; + + app_nest =nla_nest_start (dcbnl_skb,DCB_ATTR_APP ); + ret =nla_put_u8 (dcbnl_skb,DCB_APP_ATTR_IDTYPE , idtype); +if (ret) + goto out_cancel; + + ret =nla_put_u16 (dcbnl_skb,DCB_APP_ATTR_ID , id); +if (ret) + goto out_cancel; + + ret =nla_put_u8 (dcbnl_skb,DCB_APP_ATTR_PRIORITY , up); +if (ret) + goto out_cancel; + +nla_nest_end (dcbnl_skb, app_nest); +nlmsg_end (dcbnl_skb, nlh); + + ret =rtnl_unicast (dcbnl_skb, &init_net, pid); +if (ret) + goto nlmsg_failure; + + goto out; + +out_cancel: +nla_nest_cancel (dcbnl_skb, app_nest); +nlmsg_failure: +kfree_skb (dcbnl_skb); +out: +return ret; +} + +static int dcbnl_setapp (struct net_device *netdev,struct nlattr **tb, +u32 pid,u32 seq,u16 flags) +{ +int ret = -EINVAL ; +u16 id; +u8 up, idtype; +struct nlattr *app_tb[DCB_APP_ATTR_MAX +1 ]; + +if (!tb[DCB_ATTR_APP ] || !netdev->dcbnl_ops->setapp) + goto out; + + ret =nla_parse_nested (app_tb,DCB_APP_ATTR_MAX , tb[DCB_ATTR_APP ], + dcbnl_app_nest); +if (ret) + goto out; + + ret = -EINVAL ; +/* all must be non-null */ +if ((!app_tb[DCB_APP_ATTR_IDTYPE ]) || + (!app_tb[DCB_APP_ATTR_ID ]) || + (!app_tb[DCB_APP_ATTR_PRIORITY ])) + goto out; + +/* either by eth type or by socket number */ + idtype =nla_get_u8 (app_tb[DCB_APP_ATTR_IDTYPE ]); +if ((idtype !=DCB_APP_IDTYPE_ETHTYPE ) && + (idtype !=DCB_APP_IDTYPE_PORTNUM )) + goto out; + + id =nla_get_u16 (app_tb[DCB_APP_ATTR_ID ]); + up =nla_get_u8 (app_tb[DCB_APP_ATTR_PRIORITY ]); + + ret =dcbnl_reply (netdev->dcbnl_ops->setapp (netdev, idtype, id, up), +RTM_SETDCB ,DCB_CMD_SAPP ,DCB_ATTR_APP , + pid, seq, flags); +out: +return ret; +} +static int __dcbnl_pg_getcfg (struct net_device *netdev,struct nlattr **tb,u32 pid,u32 seq,u16 flags,int dir) {
@@ -1101,6 +1215,14 @@ static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) ret =dcbnl_bcn_setcfg (netdev, tb, pid, nlh->nlmsg_seq, nlh->nlmsg_flags); goto out; +case DCB_CMD_GAPP : + ret =dcbnl_getapp (netdev, tb, pid, nlh->nlmsg_seq, + nlh->nlmsg_flags); + goto out; +case DCB_CMD_SAPP : + ret =dcbnl_setapp (netdev, tb, pid, nlh->nlmsg_seq, + nlh->nlmsg_flags); + goto out;default : goto errout; }
PATCH 8/8 ixgbe: Add support for dcbnl_rtnl_ops.setapp/getapp
In reply to Jeff KirsherFrom: Yi Zou <[email protected]>
Add support for dcbnl_rtnl_ops.setapp/getapp to set or get the current user priority bitmap for the given application protocol. Currently, 82599 only supports setapp/getapp for Fiber Channel over Ethernet (FCoE) protocol.
---
drivers/net/ixgbe/ixgbe.h | 4 ++ drivers/net/ixgbe/ixgbe_dcb_nl.c | 60 ++++++++++++++++++++++++++++++++++++ drivers/net/ixgbe/ixgbe_fcoe.c | 64 ++++++++++++++++++++++++++++++++++++++ drivers/net/ixgbe/ixgbe_fcoe.h | 4 ++ drivers/net/ixgbe/ixgbe_main.c | 2 + 5 files changed, 134 insertions(+), 0 deletions(-)
drivers/net/ixgbe/ixgbe.h +4 -0
@@ -452,6 +452,10 @@ extern int ixgbe_fcoe_ddp_get(struct net_device *netdev, u16 xid,extern int ixgbe_fcoe_ddp_put (struct net_device *netdev,u16 xid);extern int ixgbe_fcoe_enable (struct net_device *netdev);extern int ixgbe_fcoe_disable (struct net_device *netdev); +#ifdef CONFIG_IXGBE_DCB +extern u8 ixgbe_fcoe_getapp (struct ixgbe_adapter *adapter); +extern u8 ixgbe_fcoe_setapp (struct ixgbe_adapter *adapter,u8 up); +#endif /* CONFIG_IXGBE_DCB */ #endif /* IXGBE_FCOE */ #endif /* _IXGBE_H_ */
drivers/net/ixgbe/ixgbe_dcb_nl.c +60 -0
71 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_fcoe.c +64 -0
73 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_fcoe.h +4 -0
@@ -46,6 +46,9 @@#define IXGBE_FCBUFF_MIN 4096/* 4KB min */ #define IXGBE_FCOE_DDP_MAX 512/* 9 bits xid */ +/* Default traffic class to use for FCoE */ +#define IXGBE_FCOE_DEFTC 3 +/* fcerr */ #define IXGBE_FCERR_BADCRC 0x00100000
@@ -59,6 +62,7 @@ struct ixgbe_fcoe_ddp { };struct ixgbe_fcoe { +u8 tc;spinlock_t lock;struct pci_pool *pool;struct ixgbe_fcoe_ddp ddp[IXGBE_FCOE_DDP_MAX ];
drivers/net/ixgbe/ixgbe_main.c +2 -0
@@ -3801,6 +3801,8 @@ static int __devinit ixgbe_sw_init(struct ixgbe_adapter *adapter) adapter->flags |=IXGBE_FLAG_FCOE_CAPABLE ; adapter->flags &= ~IXGBE_FLAG_FCOE_ENABLED ; adapter->ring_feature[RING_F_FCOE ].indices =0 ; +/* Default traffic class to use for FCoE */ + adapter->fcoe.tc =IXGBE_FCOE_DEFTC ;#endif /* IXGBE_FCOE */ }
David Miller
maintainerThis patch series looks fine, all applied to net-next-2.6
Thanks!