Skip to contentSkip to conversation

NET: DCB generic netlink interface

PATCH In review PJ Waskiewicz 4 participants 23 messages May 27, 2008 – Jun 12, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NET: DCB generic netlink interface

This patchset adds the initial DCB generic netlink interface to the kernel. It adds the layer as a generic interface for any DCB-capable device through the netdevice.

This patchset also includes an implementation using this interface in the ixgbe driver. It adds the hardware-specific code to turn the interface on, and includes the netlink callbacks in the driver to perform the requested operations.

These patches are targeted at the net-next-2.6 tree, for 2.6.27. The patch series is as follows:

patch 1: DCB netlink interface in-kernel
patch 2: ixgbe DCB hardware-specific patches
patch 3: enable DCB in ixgbe

Thanks,

Signature · 1 line
PJ Waskiewicz <[email protected]>
#1 lore raw

PATCH 1/3 : Add DCB netlink interface definition

This patch adds the netlink interface definition for Data Center Bridging. This technology uses 802.1Qaz and 801.1Qbb for extending ethernet to converge different traffic types on a single link. E.g. Fibre Channel over Ethernet and regular LAN traffic. The goal is to use priority flow control to pause individual flows at the MAC/network level, without impacting other network flows.

---

 include/linux/dcbnl.h     |  241 +++++++++++++++
 include/linux/netdevice.h |    8 
 net/Kconfig               |    1 
 net/Makefile              |    3 
 net/dcb/Kconfig           |   12 +
 net/dcb/Makefile          |    1 
 net/dcb/dcbnl.c           |  722 +++++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 988 insertions(+), 0 deletions(-)
include/linux/dcbnl.h new file +241 -0
new file mode 100644
index 0000000..db50f6c
@@ -0,0 +1,241 @@
+#ifndef __LINUX_DCBNL_H__
+#define __LINUX_DCBNL_H__
+/*
+ * Data Center Bridging (DCB) netlink header
+ *
+ * Copyright 2008, Peter P. Waskiewicz Jr. <[email protected]>
+ */
+
+#define DCB_PROTO_VERSION 1
+
+/**
+ * enum dcbnl_commands - supported DCB commands
+ *
+ * @DCB_CMD_UNDEFINED: unspecified command to catch errors
+ * @DCB_CMD_GSTATE: request the state of DCB in the device
+ * @DCB_CMD_SSTATE: set the state of DCB in the device
+ * @DCB_CMD_PGTX_GCFG: request the priority group configuration for Tx
+ * @DCB_CMD_PGTX_SCFG: set the priority group configuration for Tx
+ * @DCB_CMD_PGRX_GCFG: request the priority group configuration for Rx
+ * @DCB_CMD_PGRX_SCFG: set the priority group configuration for Rx
+ * @DCB_CMD_PFC_GCFG: request the priority flow control configuration
+ * @DCB_CMD_PFC_SCFG: set the priority flow control configuration
+ * @DCB_CMD_SET_ALL: apply all changes to the underlying device
+ * @DCB_CMD_GPERM_HWADDR: get the permanent MAC address of the underlying
+ *                        device.  Only useful when using bonding.
+ */
+enum dcbnl_commands {
+	DCB_CMD_UNDEFINED,
+
+	DCB_CMD_GSTATE,
+	DCB_CMD_SSTATE,
+
+	DCB_CMD_PGTX_GCFG,
+	DCB_CMD_PGTX_SCFG,
+	DCB_CMD_PGRX_GCFG,
+	DCB_CMD_PGRX_SCFG,
+
+	DCB_CMD_PFC_GCFG,
+	DCB_CMD_PFC_SCFG,
+
+	DCB_CMD_SET_ALL,
+	DCB_CMD_GPERM_HWADDR,
+
+	__DCB_CMD_ENUM_MAX,
+	DCB_CMD_MAX = __DCB_CMD_ENUM_MAX - 1,
+};
+
+
+/**
+ * enum dcbnl_attrs - DCB top-level netlink attributes
+ *
+ * @DCB_ATTR_UNDEFINED: unspecified attribute to catch errors
+ * @DCB_ATTR_IFNAME: interface name of the underlying device (NLA_STRING)
+ * @DCB_ATTR_STATE: state of the DCB state machine in the device (NLA_U8)
+ * @DCB_ATTR_PFC_CFG: priority flow control configuration (NLA_NESTED)
+ * @DCB_ATTR_PG_CFG: priority group configuration (NLA_NESTED)
+ * @DCB_ATTR_SET_ALL: bool to commit changes to hardware or not (NLA_U8)
+ * @DCB_ATTR_PERM_HWADDR: MAC address of the physical device (NLA_NESTED)
+ */
+enum dcbnl_attrs {
+	DCB_ATTR_UNDEFINED,
+
+	DCB_ATTR_IFNAME,
+	DCB_ATTR_STATE,
+	DCB_ATTR_PFC_CFG,
+	DCB_ATTR_PG_CFG,
+	DCB_ATTR_SET_ALL,
+	DCB_ATTR_PERM_HWADDR,
+
+	__DCB_ATTR_ENUM_MAX,
+	DCB_ATTR_MAX = __DCB_ATTR_ENUM_MAX - 1,
+};
+
+
+/**
+ * enum dcbnl_perm_hwaddr_attrs - DCB Permanent HW Address nested attributes
+ *
+ * @DCB_PERM_HW_ATTR_UNDEFINED: unspecified attribute to catch errors
+ * @DCB_PERM_HW_ATTR_0: MAC address from receive address 0 (NLA_U8)
+ * @DCB_PERM_HW_ATTR_1: MAC address from receive address 1 (NLA_U8)
+ * @DCB_PERM_HW_ATTR_2: MAC address from receive address 2 (NLA_U8)
+ * @DCB_PERM_HW_ATTR_3: MAC address from receive address 3 (NLA_U8)
+ * @DCB_PERM_HW_ATTR_4: MAC address from receive address 4 (NLA_U8)
+ * @DCB_PERM_HW_ATTR_5: MAC address from receive address 5 (NLA_U8)
+ * @DCB_PERM_HW_ATTR_ALL: apply to all MAC addresses (NLA_FLAG)
+ *
+ * These attributes are used when bonding DCB interfaces together.
+ *
+ */
+enum dcbnl_perm_hwaddr_attrs {
+	DCB_PERM_HW_ATTR_UNDEFINED,
+
+	DCB_PERM_HW_ATTR_0,
+	DCB_PERM_HW_ATTR_1,
+	DCB_PERM_HW_ATTR_2,
+	DCB_PERM_HW_ATTR_3,
+	DCB_PERM_HW_ATTR_4,
+	DCB_PERM_HW_ATTR_5,
+	DCB_PERM_HW_ATTR_ALL,
+
+	__DCB_PERM_HW_ATTR_ENUM_MAX,
+	DCB_PERM_HW_ATTR_MAX = __DCB_PERM_HW_ATTR_ENUM_MAX - 1,
+};
+
+/**
+ * enum dcbnl_pfc_attrs - DCB Priority Flow Control user-priority nested attrs
+ *
+ * @DCB_PFC_UP_ATTR_UNDEFINED: unspecified attribute to catch errors
+ * @DCB_PFC_UP_ATTR_0: Priority Flow Control value for User Priority 0 (NLA_U8)
+ * @DCB_PFC_UP_ATTR_1: Priority Flow Control value for User Priority 1 (NLA_U8)
+ * @DCB_PFC_UP_ATTR_2: Priority Flow Control value for User Priority 2 (NLA_U8)
+ * @DCB_PFC_UP_ATTR_3: Priority Flow Control value for User Priority 3 (NLA_U8)
+ * @DCB_PFC_UP_ATTR_4: Priority Flow Control value for User Priority 4 (NLA_U8)
+ * @DCB_PFC_UP_ATTR_5: Priority Flow Control value for User Priority 5 (NLA_U8)
+ * @DCB_PFC_UP_ATTR_6: Priority Flow Control value for User Priority 6 (NLA_U8)
+ * @DCB_PFC_UP_ATTR_7: Priority Flow Control value for User Priority 7 (NLA_U8)
+ * @DCB_PFC_UP_ATTR_MAX: highest attribute number currently defined
+ * @DCB_PFC_UP_ATTR_ALL: apply to all priority flow control attrs (NLA_FLAG) 
+ *
+ */
+enum dcbnl_pfc_up_attrs {
+	DCB_PFC_UP_ATTR_UNDEFINED,
+
+	DCB_PFC_UP_ATTR_0,
+	DCB_PFC_UP_ATTR_1,
+	DCB_PFC_UP_ATTR_2,
+	DCB_PFC_UP_ATTR_3,
+	DCB_PFC_UP_ATTR_4,
+	DCB_PFC_UP_ATTR_5,
+	DCB_PFC_UP_ATTR_6,
+	DCB_PFC_UP_ATTR_7,
+	DCB_PFC_UP_ATTR_ALL,
+
+	__DCB_PFC_UP_ATTR_ENUM_MAX,
+	DCB_PFC_UP_ATTR_MAX = __DCB_PFC_UP_ATTR_ENUM_MAX - 1,
+};
+
+/**
+ * enum dcbnl_pg_attrs - DCB Priority Group attributes
+ *
+ * @DCB_PG_ATTR_UNDEFINED: unspecified attribute to catch errors
+ * @DCB_PG_ATTR_TC_0: Priority Group Traffic Class 0 configuration (NLA_NESTED)
+ * @DCB_PG_ATTR_TC_1: Priority Group Traffic Class 1 configuration (NLA_NESTED)
+ * @DCB_PG_ATTR_TC_2: Priority Group Traffic Class 2 configuration (NLA_NESTED)
+ * @DCB_PG_ATTR_TC_3: Priority Group Traffic Class 3 configuration (NLA_NESTED)
+ * @DCB_PG_ATTR_TC_4: Priority Group Traffic Class 4 configuration (NLA_NESTED)
+ * @DCB_PG_ATTR_TC_5: Priority Group Traffic Class 5 configuration (NLA_NESTED)
+ * @DCB_PG_ATTR_TC_6: Priority Group Traffic Class 6 configuration (NLA_NESTED)
+ * @DCB_PG_ATTR_TC_7: Priority Group Traffic Class 7 configuration (NLA_NESTED)
+ * @DCB_PG_ATTR_TC_MAX: highest attribute number currently defined
+ * @DCB_PG_ATTR_TC_ALL: apply to all traffic classes (NLA_NESTED)
+ * @DCB_PG_ATTR_BWG_0: Bandwidth group 0 configuration (NLA_U8)
+ * @DCB_PG_ATTR_BWG_1: Bandwidth group 1 configuration (NLA_U8)
+ * @DCB_PG_ATTR_BWG_2: Bandwidth group 2 configuration (NLA_U8)
+ * @DCB_PG_ATTR_BWG_3: Bandwidth group 3 configuration (NLA_U8)
+ * @DCB_PG_ATTR_BWG_4: Bandwidth group 4 configuration (NLA_U8)
+ * @DCB_PG_ATTR_BWG_5: Bandwidth group 5 configuration (NLA_U8)
+ * @DCB_PG_ATTR_BWG_6: Bandwidth group 6 configuration (NLA_U8)
+ * @DCB_PG_ATTR_BWG_7: Bandwidth group 7 configuration (NLA_U8)
+ * @DCB_PG_ATTR_BWG_MAX: highest attribute number currently defined
+ * @DCB_PG_ATTR_BWG_ALL: apply to all bandwidth groups (NLA_FLAG)
+ *
+ */
+enum dcbnl_pg_attrs {
+	DCB_PG_ATTR_UNDEFINED,
+
+	DCB_PG_ATTR_TC_0,
+	DCB_PG_ATTR_TC_1,
+	DCB_PG_ATTR_TC_2,
+	DCB_PG_ATTR_TC_3,
+	DCB_PG_ATTR_TC_4,
+	DCB_PG_ATTR_TC_5,
+	DCB_PG_ATTR_TC_6,
+	DCB_PG_ATTR_TC_7,
+	DCB_PG_ATTR_TC_MAX,
+	DCB_PG_ATTR_TC_ALL,
+
+	DCB_PG_ATTR_BWG_0,
+	DCB_PG_ATTR_BWG_1,
+	DCB_PG_ATTR_BWG_2,
+	DCB_PG_ATTR_BWG_3,
+	DCB_PG_ATTR_BWG_4,
+	DCB_PG_ATTR_BWG_5,
+	DCB_PG_ATTR_BWG_6,
+	DCB_PG_ATTR_BWG_7,
+	DCB_PG_ATTR_BWG_MAX,
+	DCB_PG_ATTR_BWG_ALL,
+
+	__DCB_PG_ATTR_ENUM_MAX,
+	DCB_PG_ATTR_MAX = __DCB_PG_ATTR_ENUM_MAX - 1,
+};
+
+/**
+ * enum dcbnl_tc_attrs - DCB Traffic Class attributes
+ *
+ * @DCB_TC_ATTR_PARAM_UNDEFINED: unspecified attribute to catch errors
+ * @DCB_TC_ATTR_PARAM_STRICT_PRIO: Type of strict bandwidth aggregration (link
+ *                                 strict or group strict) (NLA_U8)
+ * @DCB_TC_ATTR_PARAM_BW_GROUP_ID: Bandwidth group this traffic class belongs to
+ *                                 (NLA_U8)
+ * @DCB_TC_ATTR_PARAM_BW_PCT: Percentage of bandwidth in the bandwidth group
+ *                            this traffic class has (NLA_U8)
+ * @DCB_TC_ATTR_PARAM_UP_MAPPING: Traffic class to user priority map (NLA_U8)
+ * @DCB_TC_ATTR_PARAM_ALL: apply to all traffic class parameters (NLA_FLAG)
+ *
+ */
+enum dcbnl_tc_attrs {
+	DCB_TC_ATTR_PARAM_UNDEFINED,
+
+	DCB_TC_ATTR_PARAM_STRICT_PRIO,
+	DCB_TC_ATTR_PARAM_BW_GROUP_ID,
+	DCB_TC_ATTR_PARAM_BW_PCT,
+	DCB_TC_ATTR_PARAM_UP_MAPPING,
+	DCB_TC_ATTR_PARAM_ALL,
+
+	__DCB_TC_ATTR_PARAM_ENUM_MAX,
+	DCB_TC_ATTR_PARAM_MAX = __DCB_TC_ATTR_PARAM_ENUM_MAX - 1,
+};
+
+/* 
+ * Ops struct for the netlink callbacks.  Used by DCB-enabled drivers through
+ * the netdevice struct.
+ */
+struct dcbnl_genl_ops {
+	u8   (*getstate)(struct net_device *);
+	void (*setstate)(struct net_device *, u8);
+	void (*getpermhwaddr)(struct net_device *, u8 *);
+	void (*setpgtccfgtx)(struct net_device *, int, u8, u8, u8, u8);
+	void (*setpgbwgcfgtx)(struct net_device *, int, u8);
+	void (*setpgtccfgrx)(struct net_device *, int, u8, u8, u8, u8);
+	void (*setpgbwgcfgrx)(struct net_device *, int, u8);
+	void (*getpgtccfgtx)(struct net_device *, int, u8 *, u8 *, u8 *, u8 *);
+	void (*getpgbwgcfgtx)(struct net_device *, int, u8 *);
+	void (*getpgtccfgrx)(struct net_device *, int, u8 *, u8 *, u8 *, u8 *);
+	void (*getpgbwgcfgrx)(struct net_device *, int, u8 *);
+	void (*setpfccfg)(struct net_device *, int, u8);
+	void (*getpfccfg)(struct net_device *, int, u8 *);
+	u8   (*setall)(struct net_device *);
+};
+
+#endif /* __LINUX_DCBNL_H__ */
include/linux/netdevice.h +8 -0
index f27fd20..f28a1fa 100644
@@ -42,6 +42,9 @@
 #include <linux/workqueue.h>
 
 #include <net/net_namespace.h>
+#ifdef CONFIG_DCBNL
+#include <linux/dcbnl.h>
+#endif
 
 struct vlan_group;
 struct ethtool_ops;
@@ -752,6 +755,11 @@ struct net_device
 #define GSO_MAX_SIZE		65536
 	unsigned int		gso_max_size;
 
+#ifdef CONFIG_DCBNL
+	/* Data Center Bridging netlink ops */
+	struct dcbnl_genl_ops *dcbnl_ops;
+#endif
+
 	/* The TX queue control structures */
 	unsigned int			egress_subqueue_count;
 	struct net_device_subqueue	egress_subqueue[1];
net/Kconfig +1 -0
index acbf7c6..fc6b832 100644
@@ -192,6 +192,7 @@ source "net/lapb/Kconfig"
 source "net/econet/Kconfig"
 source "net/wanrouter/Kconfig"
 source "net/sched/Kconfig"
+source "net/dcb/Kconfig"
 
 menu "Network testing"
 
net/Makefile +3 -0
index b7a1364..bc43e77 100644
@@ -53,6 +53,9 @@ obj-$(CONFIG_NETLABEL)		+= netlabel/
 obj-$(CONFIG_IUCV)		+= iucv/
 obj-$(CONFIG_RFKILL)		+= rfkill/
 obj-$(CONFIG_NET_9P)		+= 9p/
+ifeq ($(CONFIG_DCBNL),y)
+obj-$(CONFIG_DCB)		+= dcb/
+endif
 
 ifeq ($(CONFIG_NET),y)
 obj-$(CONFIG_SYSCTL)		+= sysctl_net.o
net/dcb/Kconfig new file +12 -0
new file mode 100644
index 0000000..bdf3880
@@ -0,0 +1,12 @@
+config DCB
+        tristate "Data Center Bridging support"
+
+config DCBNL
+	bool "Data Center Bridging netlink interface support"
+	depends on DCB
+	default n
+	---help---
+	  This option turns on the netlink interface
+	  (dcbnl) for Data Center Bridging capable devices.
+
+	  If unsure, say N.
net/dcb/Makefile new file +1 -0
new file mode 100644
index 0000000..9930f4c
@@ -0,0 +1 @@
+obj-$(CONFIG_DCB) += dcbnl.o
net/dcb/dcbnl.c new file +722 -0

722 lines not on this page · raw message

#2 lore raw

Re: [PATCH 1/3] [NET-NEXT]: Add DCB netlink interface definition

* PJ Waskiewicz <[email protected]> 2008-05-27 07:13

Quoted 6 lines

This patch adds the netlink interface definition for Data Center Bridging. This technology uses 802.1Qaz and 801.1Qbb for extending ethernet to converge different traffic types on a single link. E.g. Fibre Channel over Ethernet and regular LAN traffic. The goal is to use priority flow control to pause individual flows at the MAC/network level, without impacting other network flows.

Is there a specific reason why you used a separate generic netlink interface instead of embedding this into the regular link message via either IFLA_DCB or by using the info API?

#3 lore raw

RE: [PATCH 1/3] [NET-NEXT]: Add DCB netlink interface definition

Quoted 3 lines

Is there a specific reason why you used a separate generic netlink interface instead of embedding this into the regular link message via either IFLA_DCB or by using the info API?

There are four reasons we decided to use a separate interface:

1. The netlink messages are generated via userspace when the connection is setup, plus they're generated from LLDP frames coming in off the wire. Those LLDP frames implement the DCBX protocol (Data Center Bridging Exchange), which is the negotiation protocol between a DCB device and its link partner. In most cases, it's a DCB-compliant switch, like a Cisco Nexus 5000. So the messages can come out of band depending on how the network gets configured, and if any events occur causing the bandwidth credits or priority mappings to change (think automated backups at night, wanting more bandwidth than during the day).

2. The DCBX protocol is being extended to contain more information, and second generation DCB devices have more configuration data for the network. So we wanted an interface that could be extended on its own to support the new DCB protocols as they're ratified and implemented in new equipment, without impacting existing infrastructure.

3. We wanted to use generic netlink, since that seems to be a more preferred method of netlink communication vs. rtnetlink. And I don't know anything about the info API, so I can't comment on why we didn't look at that for implementation. Can you suggest something for me to look at for the info API so I can see what that's all about?

4. We also developed the userspace utilities for the Linux OSVs, which should be having a pre-release "release" on Sourceforge in the next week or so, to support the DCBX protocol. They're implemented using the generic netlink interface, so obviously if we can keep it that way, it'd be preferred. :-)

Thanks Thomas. Other than that, is there anything in the netlink interface that you would suggest to change?

Cheers,
-PJ Waskiewicz

#4 lore raw

Re: [PATCH 1/3] [NET-NEXT]: Add DCB netlink interface definition

* Waskiewicz Jr, Peter P <[email protected]> 2008-05-28 09:03

Quoted 9 lines

1. The netlink messages are generated via userspace when the connection is setup, plus they're generated from LLDP frames coming in off the wire. Those LLDP frames implement the DCBX protocol (Data Center Bridging Exchange), which is the negotiation protocol between a DCB device and its link partner. In most cases, it's a DCB-compliant switch, like a Cisco Nexus 5000. So the messages can come out of band depending on how the network gets configured, and if any events occur causing the bandwidth credits or priority mappings to change (think automated backups at night, wanting more bandwidth than during the day).

There isn't much difference really, instead of using the separate interface you could simply add a new link attribute IFLA_DCB and issue a RTM_SETLINK/RTM_GETLINK and send the same information in the same format. However, I agree with you that a separate interface is better in this case as dcb requests are not directly connected to other link changes at all and the dcb message structure is pretty complex.

Quoted 5 lines

3. We wanted to use generic netlink, since that seems to be a more preferred method of netlink communication vs. rtnetlink. And I don't know anything about the info API, so I can't comment on why we didn't look at that for implementation. Can you suggest something for me to look at for the info API so I can see what that's all about?

A prominent user is the VLAN code in net/8021q/vlan_netlink.c

Quoted 2 lines

Thanks Thomas. Other than that, is there anything in the netlink interface that you would suggest to change?

Looks good from here, I didn't read it all line by line though.

#5 lore raw

RE: [PATCH 1/3] [NET-NEXT]: Add DCB netlink interface definition

Quoted 15 lines

There isn't much difference really, instead of using the separate interface you could simply add a new link attribute IFLA_DCB and issue a RTM_SETLINK/RTM_GETLINK and send the same information in the same format. However, I agree with you that a separate interface is better in this case as dcb requests are not directly connected to other link changes at all and the dcb message structure is pretty complex.

Quoted 2 lines

3. We wanted to use generic netlink, since that seems to be a more preferred method of netlink communication vs. rtnetlink.

And I don't

Quoted 1 line

know anything about the info API, so I can't comment on why

we didn't

Quoted 1 line

look at that for implementation. Can you suggest something

for me to

Quoted 8 lines
Quoted 1 line

look at for the info API so I can see what that's all about?

A prominent user is the VLAN code in net/8021q/vlan_netlink.c

Quoted 2 lines

Thanks Thomas. Other than that, is there anything in the netlink interface that you would suggest to change?

Looks good from here, I didn't read it all line by line though.

Thanks Thomas for the review and comments.

Dave and Jeff, have you two taken a peek at this by chance?

Thanks,
-PJ Waskiewicz

#6 lore raw

Re: [PATCH 1/3] [NET-NEXT]: Add DCB netlink interface definition

In reply to PJ Waskiewicz
Quoted 7 lines · PJ Waskiewicz

+/**
+ * enum dcbnl_perm_hwaddr_attrs - DCB Permanent HW Address nested attributes
+ *
+ * @DCB_PERM_HW_ATTR_UNDEFINED: unspecified attribute to catch errors
+ * @DCB_PERM_HW_ATTR_0: MAC address from receive address 0 (NLA_U8)
+ * @DCB_PERM_HW_ATTR_1: MAC address from receive address 1 (NLA_U8)
+ * @DCB_PERM_HW_ATTR_2: MAC address from receive address 2 (NLA_U8)

Quoted 8 lines

+ * @DCB_PERM_HW_ATTR_3: MAC address from receive address 3 (NLA_U8)
+ * @DCB_PERM_HW_ATTR_4: MAC address from receive address 4 (NLA_U8)
+ * @DCB_PERM_HW_ATTR_5: MAC address from receive address 5 (NLA_U8)
+ * @DCB_PERM_HW_ATTR_ALL: apply to all MAC addresses (NLA_FLAG)
+ *
+ * These attributes are used when bonding DCB interfaces together.
+ *
+ */

For these and the other numbered attributes: is the maximum number fixed and/or defined somewhere? If not, I'd suggest to use lists of attributes.

Quoted 16 lines

+/**
+ * enum dcbnl_pg_attrs - DCB Priority Group attributes
+ *
+ * @DCB_PG_ATTR_UNDEFINED: unspecified attribute to catch errors
+ * @DCB_PG_ATTR_TC_0: Priority Group Traffic Class 0 configuration (NLA_NESTED)
+ * @DCB_PG_ATTR_TC_1: Priority Group Traffic Class 1 configuration (NLA_NESTED)
+ * @DCB_PG_ATTR_TC_2: Priority Group Traffic Class 2 configuration (NLA_NESTED)
+ * @DCB_PG_ATTR_TC_3: Priority Group Traffic Class 3 configuration (NLA_NESTED)
+ * @DCB_PG_ATTR_TC_4: Priority Group Traffic Class 4 configuration (NLA_NESTED)
+ * @DCB_PG_ATTR_TC_5: Priority Group Traffic Class 5 configuration (NLA_NESTED)
+ * @DCB_PG_ATTR_TC_6: Priority Group Traffic Class 6 configuration (NLA_NESTED)
+ * @DCB_PG_ATTR_TC_7: Priority Group Traffic Class 7 configuration (NLA_NESTED)
+ * @DCB_PG_ATTR_TC_MAX: highest attribute number currently defined
+ * @DCB_PG_ATTR_TC_ALL: apply to all traffic classes (NLA_NESTED)
+ * @DCB_PG_ATTR_BWG_0: Bandwidth group 0 configuration (NLA_U8)
+ * @DCB_PG_ATTR_BWG_1: Bandwidth group 1 configuration (NLA_U8)

Quoted 8 lines

+ * @DCB_PG_ATTR_BWG_2: Bandwidth group 2 configuration (NLA_U8)
+ * @DCB_PG_ATTR_BWG_3: Bandwidth group 3 configuration (NLA_U8)
+ * @DCB_PG_ATTR_BWG_4: Bandwidth group 4 configuration (NLA_U8)
+ * @DCB_PG_ATTR_BWG_5: Bandwidth group 5 configuration (NLA_U8)
+ * @DCB_PG_ATTR_BWG_6: Bandwidth group 6 configuration (NLA_U8)
+ * @DCB_PG_ATTR_BWG_7: Bandwidth group 7 configuration (NLA_U8)
+ * @DCB_PG_ATTR_BWG_MAX: highest attribute number currently defined
+ * @DCB_PG_ATTR_BWG_ALL: apply to all bandwidth groups (NLA_FLAG)

And in this case lists of nested attributes consisting of Priority and Bandwidth, since they seem to belong together.

include/linux/dcbnl.h line 227

Quoted 4 lines
include/linux/dcbnl.h new file +4 -0
+struct dcbnl_genl_ops {
+	u8   (*getstate)(struct net_device *);
+	void (*setstate)(struct net_device *, u8);
+	void (*getpermhwaddr)(struct net_device *, u8 *);

"getpermhwaddr" doesn't seem to belong in this interface but in rtnetlink and/or ethtool instead.

net/dcb/dcbnl.c line 235

Quoted 9 lines
net/dcb/dcbnl.c new file +7 -0
+static int dcbnl_getperm_hwaddr(struct sk_buff *skb, struct genl_info *info)
+{
...
+	dcbnl_skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
+	if (!dcbnl_skb)
+		goto err_out;
...
+err:
+	kfree(dcbnl_skb);

^^^ kfree_skb

The same error is present multiple times

Quoted 4 lines
net/dcb/dcbnl.c new file +4 -0
+static int __dcbnl_pg_setcfg(struct genl_info *info, int dir)
+{
+	struct net_device *netdev = NULL;
+	struct nlattr *pg_tb[DCB_PG_ATTR_MAX + 1];

net/dcb/dcbnl.c line 254

Quoted 10 lines
net/dcb/dcbnl.c new file +10 -0
+	struct nlattr *param_tb[DCB_TC_ATTR_PARAM_MAX + 1];
+	int ret = -EINVAL;
+	int i;
+	u8 prio = 0, bwg_id = 0, bw_pct = 0, up_map = 0;
+
+	if (!info->attrs[DCB_ATTR_IFNAME] || !info->attrs[DCB_ATTR_PG_CFG])
+		return ret;
+
+	netdev = dev_get_by_name(&init_net,
+				 nla_data(info->attrs[DCB_ATTR_IFNAME]));

The fact that you do this in every handler makes me wonder whether rtnetlink wouldn't be the better choice, if only because it uses the rtnl_mutex and configuration changes are thus serialized with other networking configuration changes.

For example I don't see anything preventing concurrent changes to the DCB configuration while it is copied between the temporary configuration and the real one. In one cases its done in a path holding the rtnl_mutex, in another case its done with holding the genl_mutex in a genetlink callback.

#7 lore raw

RE: [PATCH 1/3] [NET-NEXT]: Add DCB netlink interface definition

Quoted 3 lines

For these and the other numbered attributes: is the maximum number fixed and/or defined somewhere? If not, I'd suggest to use lists of attributes.

I think we want to define a maximum number. I can fix that.

Quoted 3 lines

And in this case lists of nested attributes consisting of Priority and Bandwidth, since they seem to belong together.

I'll see what I can come up with when I move this implementation to rtnetlink.

Quoted 7 lines

include/linux/dcbnl.h line 227

Quoted 4 lines
include/linux/dcbnl.h new file +4 -0
+struct dcbnl_genl_ops {
+	u8   (*getstate)(struct net_device *);
+	void (*setstate)(struct net_device *, u8);
+	void (*getpermhwaddr)(struct net_device *, u8 *);

"getpermhwaddr" doesn't seem to belong in this interface but in rtnetlink and/or ethtool instead.

This was a feature in ethtool, but it was removed at some point. I can add it to rtnetlink though if people think it'll be useful to have.

Quoted 13 lines
Quoted 1 line

+static int dcbnl_getperm_hwaddr(struct sk_buff *skb,

struct genl_info

net/dcb/dcbnl.c line 235

Quoted 8 lines
net/dcb/dcbnl.c new file +6 -0
+*info) {
...
+	dcbnl_skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
+	if (!dcbnl_skb)
+		goto err_out;
...
+err:
+	kfree(dcbnl_skb);

^^^ kfree_skb

Quoted 1 line

The same error is present multiple times

Good catch. I'll fix that.

Quoted 22 lines

net/dcb/dcbnl.c

Quoted 9 lines
net/dcb/dcbnl.c new file +9 -0
+static int __dcbnl_pg_setcfg(struct genl_info *info, int dir) {
+	struct net_device *netdev = NULL;
+	struct nlattr *pg_tb[DCB_PG_ATTR_MAX + 1];
+	struct nlattr *param_tb[DCB_TC_ATTR_PARAM_MAX + 1];
+	int ret = -EINVAL;
+	int i;
+	u8 prio = 0, bwg_id = 0, bw_pct = 0, up_map = 0;
+
+	if (!info->attrs[DCB_ATTR_IFNAME] || 

!info->attrs[DCB_ATTR_PG_CFG])

net/dcb/dcbnl.c line 135

Quoted 4 lines
net/dcb/dcbnl.c new file +4 -0
+		return ret;
+
+	netdev = dev_get_by_name(&init_net,
+				 

nla_data(info->attrs[DCB_ATTR_IFNAME]));

The fact that you do this in every handler makes me wonder whether rtnetlink wouldn't be the better choice, if only because it uses the rtnl_mutex and configuration changes are thus serialized with other networking configuration changes.

Quoted 5 lines

For example I don't see anything preventing concurrent changes to the DCB configuration while it is copied between the temporary configuration and the real one. In one cases its done in a path holding the rtnl_mutex, in another case its done with holding the genl_mutex in a genetlink callback.

When we wrote this, we didn't know enough about rtnetlink to know what to choose. The general trend seemed to be moving towards genetlink for subsystem changes in the kernel, so we chose that. But this serialization issue is a nice catch, and I think we'll move this implementation to use rtnetlink.

Cheers,
-PJ Waskiewicz

#8 lore raw

Re: [PATCH 1/3] [NET-NEXT]: Add DCB netlink interface definition

Quoted 8 lines · Peter P
Quoted 5 lines

include/linux/dcbnl.h line 227

Quoted 4 lines
include/linux/dcbnl.h new file +4 -0
+struct dcbnl_genl_ops {
+	u8   (*getstate)(struct net_device *);
+	void (*setstate)(struct net_device *, u8);
+	void (*getpermhwaddr)(struct net_device *, u8 *);

"getpermhwaddr" doesn't seem to belong in this interface but in rtnetlink and/or ethtool instead.

This was a feature in ethtool, but it was removed at some point. I can add it to rtnetlink though if people think it'll be useful to have.

I think thats a better idea than to put it in a private driver interface.

#9 lore raw

PATCH 2/3 ixgbe: Add Data Center Bridging hardware initialization code

In reply to PJ Waskiewicz

This patch adds the necessary hardware initialization code for 82598 to support Data Center Bridging. The code takes care of bandwidth credit calculations for the hardware arbiters, priority grouping methods, and all the hardware accesses to enable the features in 82598.

This is based from the net-next-2.6 tree.

---

 drivers/net/ixgbe/ixgbe_dcb.c       |  330 +++++++++++++++++++++++++++++
 drivers/net/ixgbe/ixgbe_dcb.h       |  168 +++++++++++++++
 drivers/net/ixgbe/ixgbe_dcb_82598.c |  400 +++++++++++++++++++++++++++++++++++
 drivers/net/ixgbe/ixgbe_dcb_82598.h |   98 +++++++++
 4 files changed, 996 insertions(+), 0 deletions(-)
drivers/net/ixgbe/ixgbe_dcb.c new file +330 -0
new file mode 100644
index 0000000..11be2b8
@@ -0,0 +1,330 @@
+/*******************************************************************************
+
+  Intel 10 Gigabit PCI Express Linux driver
+  Copyright(c) 1999 - 2008 Intel Corporation.
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms and conditions of the GNU General Public License,
+  version 2, as published by the Free Software Foundation.
+
+  This program is distributed in the hope it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+  more details.
+
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc.,
+  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+
+  The full GNU General Public License is included in this distribution in
+  the file called "COPYING".
+
+  Contact Information:
+  Linux NICS <[email protected]>
+  e1000-devel Mailing List <[email protected]>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+*******************************************************************************/
+
+
+#include "ixgbe.h"
+#include "ixgbe_type.h"
+#include "ixgbe_dcb.h"
+#include "ixgbe_dcb_82598.h"
+
+/**
+ * ixgbe_dcb_config - Struct containing DCB settings.
+ * @dcb_config: Pointer to DCB config structure
+ *
+ * This function checks DCB rules for DCB settings.
+ * The following rules are checked:
+ * 1. The sum of bandwidth percentages of all Bandwidth Groups must total 100%.
+ * 2. The sum of bandwidth percentages of all Traffic Classes within a Bandwidth
+ *    Group must total 100.
+ * 3. A Traffic Class should not be set to both Link Strict Priority
+ *    and Group Strict Priority.
+ * 4. Link strict Bandwidth Groups can only have link strict traffic classes
+ *    with zero bandwidth.
+ */
+s32 ixgbe_dcb_check_config(struct ixgbe_dcb_config *dcb_config)
+{
+	struct tc_bw_alloc *p;
+	s32 ret_val = 0;
+	u8 i, j, bw = 0, bw_id;
+	u8 bw_sum[2][MAX_BW_GROUP];
+	bool link_strict[2][MAX_BW_GROUP];
+
+	memset(bw_sum, 0, sizeof(bw_sum));
+	memset(link_strict, 0, sizeof(link_strict));
+
+	/* First Tx, then Rx */
+	for (i = 0; i < 2; i++) {
+		/* Check each traffic class for rule violation */
+		for (j = 0; j < MAX_TRAFFIC_CLASS; j++) {
+			p = &dcb_config->tc_config[j].path[i];
+
+			bw = p->bwg_percent;
+			bw_id = p->bwg_id;
+
+			if (bw_id >= MAX_BW_GROUP) {
+				ret_val = DCB_ERR_CONFIG;
+				goto err_config;
+			}
+			if (p->prio_type == prio_link) {
+				link_strict[i][bw_id] = true;
+				/* Link strict should have zero bandwidth */
+				if (bw) {
+					ret_val = DCB_ERR_LS_BW_NONZERO;
+					goto err_config;
+				}
+			} else if (!bw) {
+				/*
+				 * Traffic classes without link strict
+				 * should have non-zero bandwidth.
+				 */
+				ret_val = DCB_ERR_TC_BW_ZERO;
+				goto err_config;
+			}
+			bw_sum[i][bw_id] += bw;
+		}
+
+		bw = 0;
+
+		/* Check each bandwidth group for rule violation */
+		for (j = 0; j < MAX_BW_GROUP; j++) {
+			bw += dcb_config->bw_percentage[i][j];
+			/*
+			 * Sum of bandwidth percentages of all traffic classes
+			 * within a Bandwidth Group must total 100 except for
+			 * link strict group (zero bandwidth).
+			 */
+			if (link_strict[i][j]) {
+				if (bw_sum[i][j]) {
+					/*
+					 * Link strict group should have zero
+					 * bandwidth.
+					 */
+					ret_val = DCB_ERR_LS_BWG_NONZERO;
+					goto err_config;
+				}
+			} else if (bw_sum[i][j] != BW_PERCENT &&
+			           bw_sum[i][j] != 0) {
+				ret_val = DCB_ERR_TC_BW;
+				goto err_config;
+			}
+		}
+
+		if (bw != BW_PERCENT) {
+			ret_val = DCB_ERR_BW_GROUP;
+			goto err_config;
+		}
+	}
+
+err_config:
+	return ret_val;
+}
+
+/**
+ * ixgbe_dcb_calculate_tc_credits - Calculates traffic class credits
+ * @ixgbe_dcb_config: Struct containing DCB settings.
+ * @direction: Configuring either Tx or Rx.
+ *
+ * This function calculates the credits allocated to each traffic class.
+ * It should be called only after the rules are checked by
+ * ixgbe_dcb_check_config().
+ */
+s32 ixgbe_dcb_calculate_tc_credits(struct ixgbe_dcb_config *dcb_config,
+                                   u8 direction)
+{
+	struct tc_bw_alloc *p;
+	s32 ret_val = 0;
+	/* Initialization values default for Tx settings */
+	u32 credit_refill       = 0;
+	u32 credit_max          = 0;
+	u16 link_percentage     = 0;
+	u8  bw_percent          = 0;
+	u8  i;
+
+	if (dcb_config == NULL) {
+		ret_val = DCB_ERR_CONFIG;
+		goto out;
+	}
+
+	/* Find out the link percentage for each TC first */
+	for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
+		p = &dcb_config->tc_config[i].path[direction];
+		bw_percent = dcb_config->bw_percentage[direction][p->bwg_id];
+
+		link_percentage = p->bwg_percent;
+		/* Must be careful of integer division for very small nums */
+		link_percentage = (link_percentage * bw_percent) / 100;
+		if (p->bwg_percent > 0 && link_percentage == 0)
+			link_percentage = 1;
+
+		/* Save link_percentage for reference */
+		p->link_percent = (u8)link_percentage;
+
+		/* Calculate credit refill and save it */
+		credit_refill = link_percentage * MINIMUM_CREDIT_REFILL;
+		p->data_credits_refill = (u16)credit_refill;
+
+		/* Calculate maximum credit for the TC */
+		credit_max = (link_percentage * MAX_CREDIT) / 100;
+
+		/*
+		 * Adjustment based on rule checking, if the percentage
+		 * of a TC is too small, the maximum credit may not be
+		 * enough to send out a jumbo frame in data plane arbitration.
+		 */
+		if (credit_max && credit_max < MINIMUM_CREDIT_FOR_JUMBO)
+			credit_max = MINIMUM_CREDIT_FOR_JUMBO;
+
+		if (direction == DCB_TX_CONFIG) {
+			/*
+			 * Adjustment based on rule checking, if the
+			 * percentage of a TC is too small, the maximum
+			 * credit may not be enough to send out a TSO
+			 * packet in descriptor plane arbitration.
+			 */
+			if (credit_max &&
+			    (credit_max < MINIMUM_CREDIT_FOR_TSO))
+				credit_max = MINIMUM_CREDIT_FOR_TSO;
+
+			dcb_config->tc_config[i].desc_credits_max = (u16)credit_max;
+		}
+
+		p->data_credits_max = (u16)credit_max;
+	}
+
+out:
+	return ret_val;
+}
+
+/**
+ * ixgbe_dcb_get_tc_stats - Returns status of each traffic class
+ * @hw: pointer to hardware structure
+ * @stats: pointer to statistics structure
+ * @tc_count:  Number of elements in bwg_array.
+ *
+ * This function returns the status data for each of the Traffic Classes in use.
+ */
+s32 ixgbe_dcb_get_tc_stats(struct ixgbe_hw *hw, struct ixgbe_hw_stats *stats,
+                           u8 tc_count)
+{
+	s32 ret = 0;
+	if (hw->mac.type == ixgbe_mac_82598EB)
+		ret = ixgbe_dcb_get_tc_stats_82598(hw, stats, tc_count);
+	return ret;
+}
+
+/**
+ * ixgbe_dcb_get_pfc_stats - Returns CBFC status of each traffic class
+ * hw - pointer to hardware structure
+ * stats - pointer to statistics structure
+ * tc_count -  Number of elements in bwg_array.
+ *
+ * This function returns the CBFC status data for each of the Traffic Classes.
+ */
+s32 ixgbe_dcb_get_pfc_stats(struct ixgbe_hw *hw, struct ixgbe_hw_stats *stats,
+                            u8 tc_count)
+{
+	s32 ret = 0;
+	if (hw->mac.type == ixgbe_mac_82598EB)
+		ret = ixgbe_dcb_get_pfc_stats_82598(hw, stats, tc_count);
+	return ret;
+}
+
+/**
+ * ixgbe_dcb_config_rx_arbiter - Config Rx arbiter
+ * @hw: pointer to hardware structure
+ * @dcb_config: pointer to ixgbe_dcb_config structure
+ *
+ * Configure Rx Data Arbiter and credits for each traffic class.
+ */
+s32 ixgbe_dcb_config_rx_arbiter(struct ixgbe_hw *hw,
+                                struct ixgbe_dcb_config *dcb_config)
+{
+	s32 ret = 0;
+	if (hw->mac.type == ixgbe_mac_82598EB)
+		ret = ixgbe_dcb_config_rx_arbiter_82598(hw, dcb_config);
+	return ret;
+}
+
+/**
+ * ixgbe_dcb_config_tx_desc_arbiter - Config Tx Desc arbiter
+ * @hw: pointer to hardware structure
+ * @dcb_config: pointer to ixgbe_dcb_config structure
+ *
+ * Configure Tx Descriptor Arbiter and credits for each traffic class.
+ */
+s32 ixgbe_dcb_config_tx_desc_arbiter(struct ixgbe_hw *hw,
+                                     struct ixgbe_dcb_config *dcb_config)
+{
+	s32 ret = 0;
+	if (hw->mac.type == ixgbe_mac_82598EB)
+		ret = ixgbe_dcb_config_tx_desc_arbiter_82598(hw, dcb_config);
+	return ret;
+}
+
+/**
+ * ixgbe_dcb_config_tx_data_arbiter - Config Tx data arbiter
+ * @hw: pointer to hardware structure
+ * @dcb_config: pointer to ixgbe_dcb_config structure
+ *
+ * Configure Tx Data Arbiter and credits for each traffic class.
+ */
+s32 ixgbe_dcb_config_tx_data_arbiter(struct ixgbe_hw *hw,
+                                     struct ixgbe_dcb_config *dcb_config)
+{
+	s32 ret = 0;
+	if (hw->mac.type == ixgbe_mac_82598EB)
+		ret = ixgbe_dcb_config_tx_data_arbiter_82598(hw, dcb_config);
+	return ret;
+}
+
+/**
+ * ixgbe_dcb_config_pfc - Config priority flow control
+ * @hw: pointer to hardware structure
+ * @dcb_config: pointer to ixgbe_dcb_config structure
+ *
+ * Configure Priority Flow Control for each traffic class.
+ */
+s32 ixgbe_dcb_config_pfc(struct ixgbe_hw *hw,
+                         struct ixgbe_dcb_config *dcb_config)
+{
+	s32 ret = 0;
+	if (hw->mac.type == ixgbe_mac_82598EB)
+		ret = ixgbe_dcb_config_pfc_82598(hw, dcb_config);
+	return ret;
+}
+
+/**
+ * ixgbe_dcb_config_tc_stats - Config traffic class statistics
+ * @hw: pointer to hardware structure
+ *
+ * Configure queue statistics registers, all queues belonging to same traffic
+ * class uses a single set of queue statistics counters.
+ */
+s32 ixgbe_dcb_config_tc_stats(struct ixgbe_hw *hw)
+{
+	s32 ret = 0;
+	if (hw->mac.type == ixgbe_mac_82598EB)
+		ret = ixgbe_dcb_config_tc_stats_82598(hw);
+	return ret;
+}
+
+/**
+ * ixgbe_dcb_hw_config - Config and enable DCB
+ * @hw: pointer to hardware structure
+ * @dcb_config: pointer to ixgbe_dcb_config structure
+ *
+ * Configure dcb settings and enable dcb mode.
+ */
+s32 ixgbe_dcb_hw_config(struct ixgbe_hw *hw,
+                        struct ixgbe_dcb_config *dcb_config)
+{
+	s32 ret = 0;
+	if (hw->mac.type == ixgbe_mac_82598EB)
+		ret = ixgbe_dcb_hw_config_82598(hw, dcb_config);
+	return ret;
+}
drivers/net/ixgbe/ixgbe_dcb.h new file +168 -0

168 lines not on this page · raw message

drivers/net/ixgbe/ixgbe_dcb_82598.c new file +400 -0

400 lines not on this page · raw message

drivers/net/ixgbe/ixgbe_dcb_82598.h new file +98 -0

98 lines not on this page · raw message

#10 lore raw

PATCH 3/3 ixgbe: Enable Data Center Bridging (DCB) support

In reply to PJ Waskiewicz

This patch enables DCB support for 82598. DCB is a technology using the 802.1Qaz and 802.1Qbb IEEE standards for priority grouping and priority flow control. This is useful when trying to allow different types of traffic on separate flows to be paused and handled with different priorities across the network without impacting other flows on the same links. A target traffic type for this technology is to provide flow control for Fibre Channel over Ethernet, while not impacting other LAN traffic flows on the link.

This is a respin of previous patches posted for this. These new patches now use the DCBNL netlink interface in the kernel to communicate with userspace. The userspace utilities to control this are in the process of being posted to SourceForge, and should be available in the very near future.

This is based from the net-next-2.6 tree.

---

 drivers/net/ixgbe/Makefile        |    2 
 drivers/net/ixgbe/ixgbe.h         |   22 +
 drivers/net/ixgbe/ixgbe_ethtool.c |   36 ++
 drivers/net/ixgbe/ixgbe_main.c    |  577 +++++++++++++++++++++++++++++++++----
 4 files changed, 576 insertions(+), 61 deletions(-)
drivers/net/ixgbe/Makefile +1 -1
index ccd83d9..20b37cc 100644
@@ -33,4 +33,4 @@
 obj-$(CONFIG_IXGBE) += ixgbe.o
 
 ixgbe-objs := ixgbe_main.o ixgbe_common.o ixgbe_ethtool.o \
-              ixgbe_82598.o ixgbe_phy.o
+              ixgbe_82598.o ixgbe_phy.o ixgbe_dcb.o ixgbe_dcb_82598.o
drivers/net/ixgbe/ixgbe.h +19 -3
index d981134..145421f 100644
@@ -35,6 +35,7 @@
 
 #include "ixgbe_type.h"
 #include "ixgbe_common.h"
+#include "ixgbe_dcb.h"
 
 #ifdef CONFIG_DCA
 #include <linux/dca.h>
@@ -98,6 +99,7 @@
 #define IXGBE_TX_FLAGS_TSO		(u32)(1 << 2)
 #define IXGBE_TX_FLAGS_IPV4		(u32)(1 << 3)
 #define IXGBE_TX_FLAGS_VLAN_MASK	0xffff0000
+#define IXGBE_TX_FLAGS_VLAN_PRIO_MASK	0x0000e000
 #define IXGBE_TX_FLAGS_VLAN_SHIFT	16
 
 /* wrapper around a pointer to a socket buffer,
@@ -144,7 +146,7 @@ struct ixgbe_ring {
 
 	u16 reg_idx; /* holds the special value that gets the hardware register
 		      * offset associated with this ring, which is different
-		      * for DCE and RSS modes */
+		      * for DCB and RSS modes */
 
 #ifdef CONFIG_DCA
 	/* cpu for tx queue */
@@ -162,8 +164,10 @@ struct ixgbe_ring {
 	u16 work_limit;                /* max work per interrupt */
 };
 
+#define RING_F_DCB  0
 #define RING_F_VMDQ 1
 #define RING_F_RSS  2
+#define IXGBE_MAX_DCB_INDICES   8
 #define IXGBE_MAX_RSS_INDICES  16
 #define IXGBE_MAX_VMDQ_INDICES 16
 struct ixgbe_ring_feature {
@@ -174,6 +178,10 @@ struct ixgbe_ring_feature {
 #define MAX_RX_QUEUES 64
 #define MAX_TX_QUEUES 32
 
+#define MAX_RX_PACKET_BUFFERS ((adapter->flags & IXGBE_FLAG_DCB_ENABLED) \
+                               ? 8 : 1)
+#define MAX_TX_PACKET_BUFFERS MAX_RX_PACKET_BUFFERS
+
 /* MAX_MSIX_Q_VECTORS of these are allocated,
  * but we only use one per queue-specific vector.
  */
@@ -226,6 +234,9 @@ struct ixgbe_adapter {
 	struct work_struct reset_task;
 	struct ixgbe_q_vector q_vector[MAX_MSIX_Q_VECTORS];
 	char name[MAX_MSIX_COUNT][IFNAMSIZ + 5];
+	struct ixgbe_dcb_config dcb_cfg;
+	struct ixgbe_dcb_config temp_dcb_cfg;
+	u8 dcb_set_bitmap;
 
 	/* Interrupt Throttle Rate */
 	u32 itr_setting;
@@ -234,6 +245,7 @@ struct ixgbe_adapter {
 
 	/* TX */
 	struct ixgbe_ring *tx_ring;	/* One per active queue */
+	int num_tx_queues;
 	u64 restart_queue;
 	u64 lsc_int;
 	u64 hw_tso_ctxt;
@@ -243,12 +255,11 @@ struct ixgbe_adapter {
 
 	/* RX */
 	struct ixgbe_ring *rx_ring;	/* One per active queue */
+	int num_rx_queues;
 	u64 hw_csum_tx_good;
 	u64 hw_csum_rx_error;
 	u64 hw_csum_rx_good;
 	u64 non_eop_descs;
-	int num_tx_queues;
-	int num_rx_queues;
 	int num_msix_vectors;
 	struct ixgbe_ring_feature ring_feature[3];
 	struct msix_entry *msix_entries;
@@ -270,6 +281,7 @@ struct ixgbe_adapter {
 #define IXGBE_FLAG_RSS_ENABLED                  (u32)(1 << 6)
 #define IXGBE_FLAG_VMDQ_ENABLED                 (u32)(1 << 7)
 #define IXGBE_FLAG_DCA_ENABLED                  (u32)(1 << 8)
+#define IXGBE_FLAG_DCB_ENABLED                  (u32)(1 << 9)
 
 	/* OS defined structs */
 	struct net_device *netdev;
@@ -314,5 +326,9 @@ extern int ixgbe_setup_rx_resources(struct ixgbe_adapter *adapter,
 				    struct ixgbe_ring *rxdr);
 extern int ixgbe_setup_tx_resources(struct ixgbe_adapter *adapter,
 				    struct ixgbe_ring *txdr);
+extern int ixgbe_close(struct net_device *netdev);
+extern void ixgbe_reset_interrupt_capability(struct ixgbe_adapter *adapter);
+extern int ixgbe_open(struct net_device *netdev);
+extern int ixgbe_init_interrupt_scheme(struct ixgbe_adapter *adapter);
 
 #endif /* _IXGBE_H_ */
drivers/net/ixgbe/ixgbe_ethtool.c +35 -1
index 4e46377..944f669 100644
@@ -97,7 +97,17 @@ static struct ixgbe_stats ixgbe_gstrings_stats[] = {
 		 ((struct ixgbe_adapter *)netdev->priv)->num_rx_queues) * \
 		 (sizeof(struct ixgbe_queue_stats) / sizeof(u64)))
 #define IXGBE_GLOBAL_STATS_LEN	ARRAY_SIZE(ixgbe_gstrings_stats)
-#define IXGBE_STATS_LEN (IXGBE_GLOBAL_STATS_LEN + IXGBE_QUEUE_STATS_LEN)
+#define IXGBE_PB_STATS_LEN ( \
+		(((struct ixgbe_adapter *)netdev->priv)->flags & \
+		 IXGBE_FLAG_DCB_ENABLED) ? \
+		 (sizeof(((struct ixgbe_adapter *)0)->stats.pxonrxc) + \
+		  sizeof(((struct ixgbe_adapter *)0)->stats.pxontxc) + \
+		  sizeof(((struct ixgbe_adapter *)0)->stats.pxoffrxc) + \
+		  sizeof(((struct ixgbe_adapter *)0)->stats.pxofftxc)) \
+		 / sizeof(u64) : 0)
+#define IXGBE_STATS_LEN (IXGBE_GLOBAL_STATS_LEN + \
+		IXGBE_PB_STATS_LEN + \
+		IXGBE_QUEUE_STATS_LEN)
 
 static int ixgbe_get_settings(struct net_device *netdev,
 			      struct ethtool_cmd *ecmd)
@@ -806,6 +816,16 @@ static void ixgbe_get_ethtool_stats(struct net_device *netdev,
 			data[i + k] = queue_stat[k];
 		i += k;
 	}
+	if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
+		for (j = 0; j < MAX_TX_PACKET_BUFFERS; j++) {
+			data[i++] = adapter->stats.pxontxc[j];
+			data[i++] = adapter->stats.pxofftxc[j];
+		}
+		for (j = 0; j < MAX_RX_PACKET_BUFFERS; j++) {
+			data[i++] = adapter->stats.pxonrxc[j];
+			data[i++] = adapter->stats.pxoffrxc[j];
+		}
+	}
 }
 
 static void ixgbe_get_strings(struct net_device *netdev, u32 stringset,
@@ -834,6 +854,20 @@ static void ixgbe_get_strings(struct net_device *netdev, u32 stringset,
 			sprintf(p, "rx_queue_%u_bytes", i);
 			p += ETH_GSTRING_LEN;
 		}
+		if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
+			for (i = 0; i < MAX_TX_PACKET_BUFFERS; i++) {
+				sprintf(p, "tx_pb_%u_pxon", i);
+				p += ETH_GSTRING_LEN;
+				sprintf(p, "tx_pb_%u_pxoff", i);
+				p += ETH_GSTRING_LEN;
+			}
+			for (i = 0; i < MAX_RX_PACKET_BUFFERS; i++) {
+				sprintf(p, "rx_pb_%u_pxon", i);
+				p += ETH_GSTRING_LEN;
+				sprintf(p, "rx_pb_%u_pxoff", i);
+				p += ETH_GSTRING_LEN;
+			}
+		}
 /*		BUG_ON(p - data != IXGBE_STATS_LEN * ETH_GSTRING_LEN); */
 		break;
 	}
drivers/net/ixgbe/ixgbe_main.c +521 -56

891 lines not on this page · raw message

maintainer
#11 lore raw
In reply to PJ Waskiewicz

From: PJ Waskiewicz <[email protected]>
Date: Tue, 27 May 2008 07:13:39 -0700

Quoted 9 lines

This patchset adds the initial DCB generic netlink interface to the kernel. It adds the layer as a generic interface for any DCB-capable device through the netdevice.

This patchset also includes an implementation using this interface in the ixgbe driver. It adds the hardware-specific code to turn the interface on, and includes the netlink callbacks in the driver to perform the requested operations.

Quoted 6 lines

These patches are targeted at the net-next-2.6 tree, for 2.6.27. The patch series is as follows:

patch 1: DCB netlink interface in-kernel
patch 2: ixgbe DCB hardware-specific patches
patch 3: enable DCB in ixgbe

Overall the changes look OK. In particular the netlink implementation looks clean.

However we need to think about how this stuff overlaps with existing 'tc' facilities. For example, what we really need to do here is define this generic DCB interface such that it normally just sits on top of a software scheduler layer implementation and therefore there are always non-NULL DCB ops to invoke.

If there is a device that can implement this in hardware, that's fine and we define some interface for invoking that.

Because of that, the netdevice is likely not the correct place for the ops (the only actual ugly part of the patches in my opinion).

I'm still very active travelling which is why I haven't responded to this earlier. I ask that you express some understanding about this as there is really nothing I can do to review these kinds of important changes properly when I am changing 10 timezones every other day.

Besides we're still in bug fix phase, so nothing I say will get this upstream into Linus's tree any faster, and we really need to get something like this right because it will be hard to undo this afterwards if we get it wrong.

#12 lore raw
Quoted 10 lines

From: David Miller [mailto:[email protected]]
Sent: Wednesday, June 04, 2008 11:45 AM
To: Waskiewicz Jr, Peter P
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] NET: DCB generic netlink interface

Overall the changes look OK. In particular the netlink implementation looks clean.

Quoted 6 lines

However we need to think about how this stuff overlaps with existing 'tc' facilities. For example, what we really need to do here is define this generic DCB interface such that it normally just sits on top of a software scheduler layer implementation and therefore there are always non-NULL DCB ops to invoke.

I'm not sure I follow this. DCB is a scheduling policy, but that scheduling policy is in the hardware. The configuration interface, which is what this is, happens out of band of any scheduling policies in the kernel. It's very analogous to the wireless configuration layer for mac80211 that uses generic netlink.

Quoted 6 lines

If there is a device that can implement this in hardware, that's fine and we define some interface for invoking that.

Because of that, the netdevice is likely not the correct place for the ops (the only actual ugly part of the patches in my opinion).

I agree that having this in the netdevice isn't great. But given the nature of how the hardware can be configured (via a user on the host, or via messages from a switch to the userspace utilities), I think it needs to be in there. It's also the only common place the userspace can enumerate an ethernet device from userspace; tc is another way, but the ethernet device is used, along with the qdisc, which is part of the netdevice. But I am certainly all ears for any suggestions to not have it in the netdevice if it can be done.

Quoted 5 lines

I'm still very active travelling which is why I haven't responded to this earlier. I ask that you express some understanding about this as there is really nothing I can do to review these kinds of important changes properly when I am changing 10 timezones every other day.

I can certainly sympathize; I've been travelling in Israel this past week, and will be getting back to Portland on Friday. Having a 10-hour difference from what your normal timezone is is certainly challenging.

Quoted 4 lines

Besides we're still in bug fix phase, so nothing I say will get this upstream into Linus's tree any faster, and we really need to get something like this right because it will be hard to undo this afterwards if we get it wrong.

Totally understood. My goal though is to make sure any feedback/suggestions can be digested prior to the merge window, since the chances of getting any good review during the merge window is next to impossible, given the amount of patches flying in that have already been queued. I just want to make sure I'm prepared for a good submission by the time the merge window opens.

Thanks Dave. Any guidance from you, or anyone else, as to how I can get this into better shape for acceptance, I'm all ears.

Cheers,
-PJ Waskiewicz

maintainer
#13 lore raw

From: "Waskiewicz Jr, Peter P" <[email protected]>
Date: Wed, 4 Jun 2008 23:23:00 -0700

Quoted 5 lines

I'm not sure I follow this. DCB is a scheduling policy, but that scheduling policy is in the hardware. The configuration interface, which is what this is, happens out of band of any scheduling policies in the kernel. It's very analogous to the wireless configuration layer for mac80211 that uses generic netlink.

And I'm saying we should have a equivalent software scheduler in the kernel that can implement this if the hardware offloaded version isn't present.

It overlaps existing functionality to a certain extent, and there is no real reason for that overlap to exist. The question is which (the existing facilities or the new one) subsumes which.

#14 lore raw

* David Miller <[email protected]> 2008-06-05 07:43

Quoted 9 lines

From: "Waskiewicz Jr, Peter P" <[email protected]>
Date: Wed, 4 Jun 2008 23:23:00 -0700

Quoted 5 lines

I'm not sure I follow this. DCB is a scheduling policy, but that scheduling policy is in the hardware. The configuration interface, which is what this is, happens out of band of any scheduling policies in the kernel. It's very analogous to the wireless configuration layer for mac80211 that uses generic netlink.

Quoted 3 lines

And I'm saying we should have a equivalent software scheduler in the kernel that can implement this if the hardware offloaded version isn't present.

I agree, I think we should make it possible to use DCB without the strict need for hardware support. Our current classful qdiscs htb and cbq already fullfil the requirements of priority grouping as specified in 802.1.qaz except that the configuration interface is different as it does not use percentage values.

There is also demand for a networking cgroup subsystem which requires exactly the same kind of priority grouping. It would be only logical to be able to use hardware support where possible.

Therefore I believe the way to go is to build a new or extend the current tc system. Like with the current default qdisc, it should be possible to automatically create qdiscs for DCB or cgroup while still allowing to overwrite the tc configuration with a custom tree for

As Patrick pointed out, this probably belongs in the rtnetlink family as it will be strictly attached to the net_device.

#15 lore raw
In reply to David Miller
Quoted 6 lines

From: "Waskiewicz Jr, Peter P" <[email protected]>
Date: Wed, 4 Jun 2008 23:23:00 -0700

Quoted 3 lines

I'm not sure I follow this. DCB is a scheduling policy, but that scheduling policy is in the hardware. The configuration interface, which is what this is, happens out of band of any

Quoted 8 lines

scheduling policies

Quoted 3 lines

in the kernel. It's very analogous to the wireless configuration layer for
mac80211 that uses generic netlink.

And I'm saying we should have a equivalent software scheduler in the kernel that can implement this if the hardware offloaded version isn't present.

I really don't think this is something that would work in software. I agree that having a bandwidth grouping like 802.1Qaz would be somewhat useful, but that's the only piece of DCB that would work in software. And you can achieve the same behavior using sch_prio with cbq or htb on the nodes, minus the full link aggregation.

The 802.1Qbb, per-priority pause (flow control), cannot work in a software implementation. This is a new flow control frame processed by the MAC for each priority on the link. Also, the Rx filtering can't be emulated in software either. The MAC filters on VLAN priority. I know that can be configured with vconfig and set_ingress_map, but the whole point of the technology is to have the Rx processing done in the hardware's packet buffers, much like RSS filtering.

This technology really is a hardware-based technology. The piece that we could effectively implement in software is the Tx priority grouping. But that's a small piece of the whole technology. All we're trying to do is provide the method of configuring the hardware for this technology, which is closely coupled with the FCoE work going on in the SCSI world. I don't think anyone would benefit trying to emulate it in software, since everything we can implement in the software can already be achieved using existing facilities.

Quoted 4 lines

It overlaps existing functionality to a certain extent, and there is no real reason for that overlap to exist. The question is which (the existing facilities or the new one) subsumes which.

The existing facilities for traffic shaping and bandwidth aggregation do overlap if you loaded those qdiscs with a DCB device. But I don't think the existing qdiscs should be removed or modified; the two technologies are too different, in my opinion, to be combined in software.

Thanks Dave,
-PJ Waskiewicz

maintainer
#16 lore raw

From: "Waskiewicz Jr, Peter P" <[email protected]>
Date: Tue, 10 Jun 2008 12:55:16 -0700

Quoted 2 lines

The 802.1Qbb, per-priority pause (flow control), cannot work in a software implementation.

Of course, I know that.

Quoted 5 lines

Also, the Rx filtering can't be emulated in software either. The MAC filters on VLAN priority. I know that can be configured with vconfig and set_ingress_map, but the whole point of the technology is to have the Rx processing done in the hardware's packet buffers, much like RSS filtering.

This is a scare crow, please don't use arguments like that.

Saying that it can't be done at all in software, but then saying "well, it sort of can be done, but the point is to do it in hardware" side-steps the very reason I want you to implement a software variant of the parts that can be done in software.

Quoted 1 line

This technology really is a hardware-based technology.

This sounds like another way of saying "having a software implementation of even some of this facility would compromise the value of our hardware implementation."

That's not the kind of decision making process we use when deciding how to implement things in the kernel.

#17 lore raw
In reply to Waskiewicz Jr, Peter P

* Waskiewicz Jr, Peter P <[email protected]> 2008-06-10 12:55

Quoted 6 lines

I really don't think this is something that would work in software. I agree that having a bandwidth grouping like 802.1Qaz would be somewhat useful, but that's the only piece of DCB that would work in software. And you can achieve the same behavior using sch_prio with cbq or htb on the nodes, minus the full link aggregation.

Quoted 7 lines

The 802.1Qbb, per-priority pause (flow control), cannot work in a software implementation. This is a new flow control frame processed by the MAC for each priority on the link. Also, the Rx filtering can't be emulated in software either. The MAC filters on VLAN priority. I know that can be configured with vconfig and set_ingress_map, but the whole point of the technology is to have the Rx processing done in the hardware's packet buffers, much like RSS filtering.

Everything is possible in software as long as the hardware doesn't hide the congestion information. It would be very useful to pass congestion information received by 802.1Qau frames to the kernel for use when selecting the nexthop or for the routing daemon to make decisions on. So far we could only react to link states, now we could actually react to link congestion on the routing layer.

There is no doubt that doing the prioritization in hardware is much preferred but we should try and integrate it with other tc techniques. F.e. it would be great if we could control DCB via skb->tc_index if that is possible. It would allow to define DCB traffic classes with the rich features of existing classifiers. I've seen there is a mapping functionality although I haven't found any documentation on how to use it exactly.

Another area of interest is sending congestion frames on our own. We could finally implement real ingress software shaping and turn every linux system into a DCB capable node.

#18 lore raw
Quoted 3 lines · Thomas Graf

Another area of interest is sending congestion frames on our own. We could finally implement real ingress software shaping and turn every linux system into a DCB capable node.

There was a qdisc submission for a scheduler called "pace" (IIRC) that did this. It needed some cleanups before merging, but nothing grave.

#19 lore raw

* Patrick McHardy <[email protected]> 2008-06-11 19:50

Quoted 8 lines
Quoted 3 lines · Thomas Graf

Another area of interest is sending congestion frames on our own. We could finally implement real ingress software shaping and turn every linux system into a DCB capable node.

There was a qdisc submission for a scheduler called "pace" (IIRC) that did this. It needed some cleanups before merging, but nothing grave.

Do you know if it used congestion notifcation on link level? I can't seem to find the posting.

#20 lore raw
Quoted 11 lines · Thomas Graf

* Patrick McHardy <[email protected]> 2008-06-11 19:50

Quoted 7 lines
Quoted 3 lines · Thomas Graf

Another area of interest is sending congestion frames on our own. We could finally implement real ingress software shaping and turn every linux system into a DCB capable node.

There was a qdisc submission for a scheduler called "pace" (IIRC) that did this. It needed some cleanups before merging, but nothing grave.

Do you know if it used congestion notifcation on link level? I can't seem to find the posting.

They're using PAUSE frames. The latest submission I could find is:

http://marc.info/?t=119625135300006&r=1&w=2

#21 lore raw
In reply to Thomas Graf
Quoted 1 line

Everything is possible in software as long as the hardware doesn't

hide

Quoted 4 lines

the congestion information. It would be very useful to pass congestion Information received by 802.1Qau frames to the kernel for use when selecting the nexthop or for the routing daemon to make decisions on. So far we could only react to link states, now we could actually react

to

Quoted 1 line

link congestion on the routing layer.

Congestion notification in 802.1Qau is certainly something we need to support somewhere in the stack. I was actually talking with one of our hardware architects while I was in Israel last week about that exact gap, since the BCN/QCN rate limiting will eventually drop packets if we don't have a way of telling the upper layers to "slow down." The notification mechanism is also needed for 802.1Qbb, since the whole point of the priority flow control is to provide a no-drop mechanism for things like FCoE. But if the upper layers (e.g. FCoE stack) don't know to pause when the network is too congested, frames will be dropped, which is bad.

802.1Qau is still being defined in IEEE unfortunately, and we and others have no hardware that supports it to test the congestion notification tag processing. But it is something on our radar that needs to be addressed.

Quoted 4 lines

There is no doubt that doing the prioritization in hardware is much preferred but we should try and integrate it with other tc techniques. F.e. it would be great if we could control DCB via skb->tc_index if that is possible. It would allow to define DCB traffic classes with

the

Quoted 3 lines

rich features of existing classifiers. I've seen there is a mapping functionality although I haven't found any documentation on how to use it exactly.

The prioritization is only one piece. The bandwidth aggregation, different modes of defining group strict vs. link strict priorities within a bandwidth group, etc., are all hardware modes. These modes need to be in sync with the link partner (switch, back to back NIC), and are kept in sync with the DCBX protocol via LLDP.

Quoted 3 lines

Another area of interest is sending congestion frames on our own. We could finally implement real ingress software shaping and turn every linux system into a DCB capable node.

Once 802.1Qau is defined, and IEEE decides to use BCN or QCN, I think this is a great direction to go in. Right now the congestion notification stuff is too up in the air to latch onto unfortunately.

Thanks for the comments Thomas,

-PJ Waskiewicz

#22 lore raw

* Waskiewicz Jr, Peter P <[email protected]> 2008-06-11 11:28

Quoted 5 lines

Congestion notification in 802.1Qau is certainly something we need to support somewhere in the stack. I was actually talking with one of our hardware architects while I was in Israel last week about that exact gap, since the BCN/QCN rate limiting will eventually drop packets if we don't have a way of telling the upper layers to "slow down."

That's already possible by calling netif_stop_queue() respectively netif_stop_subqueue(). Much more important for the upper layers to know is when a congestion is about to happen so it can be avoided with routing decisions.

Quoted 5 lines

The prioritization is only one piece. The bandwidth aggregation, different modes of defining group strict vs. link strict priorities within a bandwidth group, etc., are all hardware modes. These modes need to be in sync with the link partner (switch, back to back NIC), and are kept in sync with the DCBX protocol via LLDP.

Again, this piece of hardware basically implements a classful qdisc like htb or cbq except that it's limited to a flat tree. Yet, the capabilities of the hardware may not be sufficient, therefore it must be possible to combine hardware shaping with software qdiscs. It is therefore crucial to find common grounds to exchange traffic class information. Is your piece of hardware strictly limited to map VLANs to traffic classes or would it be possible to attach traffic class information to the packet in some way? (skb->tc_index) Could you elaborate on how classification works, especially the configurable mapping?

The most difficult part for me, an probably others as well, is that there are no public documents available yet which would describe the direction of where this is going, how complete the current implementation actually is. We're pretty much looking at a black box which doesn't work very well with the existing architecture and requires a completely separate configuration interface. If we merge a configuration interface for DCB now it will be pretty much written in stone, yet we have no idea what other vendors may need.