Skip to contentSkip to conversation

Series short description

PATCH Superseded John Fastabend 2 participants 12 messages Jun 17, 2011 – Jun 20, 2011

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Series short description

The following series implements improvements to the DCB netlink interface. This work was done to improve Application handling and support firmware based LLDP agents.

This adds a multicast group for DCB currently user space has trouble keeping in sync across multiple applications and with firmware agents making DCB attribute changes in the driver.

To help support the recently ratified IEEE802.1Qaz extension which supports multiple APP data entries for the same selector and protocol fields a series of ieee set and delete routines were improved and in the delete case added.

Finally the patches 5 and 6 are fixes to currently existing code.

Please consider for net-next-2.6 inclusion.

---

John Fastabend (7):
dcb: Add missing error check in dcb_ieee_set()
dcb: fix return type on dcb_setapp()
dcb: Add dcb_ieee_getapp_mask() for drivers to query APP settings
dcb: Add ieee_dcb_delapp() and dcb op to delete app entry
dcb: Add ieee_dcb_setapp() to be used for IEEE 802.1Qaz APP data
net: dcbnl, add multicast group for DCB
dcb: Add DCBX capabilities bitmask to the get_ieee response

 include/linux/dcbnl.h     |    2 
 include/linux/rtnetlink.h |    2 
 include/net/dcbnl.h       |    6 +
 net/dcb/dcbnl.c           |  414 +++++++++++++++++++++++++++++++++++----------
 4 files changed, 334 insertions(+), 90 deletions(-)
Signature · 1 line
Signature
#2 lore raw

PATCH 2/7 net: dcbnl, add multicast group for DCB

Now that dcbnl is being used in many cases by more than a single agent it is beneficial to be notified when some entity either driver or user space has changed the DCB attributes.

Today applications either end up polling the interface or relying on a user space database to maintain the DCB state and post events. Polling is a poor solution for obvious reasons. And relying on a user space database has its own downside. Namely it has created strange boot dependencies requiring the database be populated before any applications dependent on DCB attributes starts or the application goes into a polling loop. Populating the database requires negotiating link setting with the peer and can take anywhere from less than a second up to a few seconds depending on the switch implementation.

Perhaps more importantly if another application or an embedded agent sets a DCB link attribute the database has no way of knowing other than polling the kernel. This prevents applications from responding quickly to changes in link events which at least in the FCoE case and probably any other protocols expecting a lossless link may result in IO errors.

By adding a multicast group for DCB we have clean way to disseminate kernel DCB link attributes up to user space. Avoiding the need for user space to maintain a coherant database and disperse events that potentially do not reflect the current link state.

---

 include/linux/rtnetlink.h |    2 
 net/dcb/dcbnl.c           |  228 +++++++++++++++++++++++++++++----------------
 2 files changed, 147 insertions(+), 83 deletions(-)
include/linux/rtnetlink.h +2 -0
index bbad657..c81226a 100644
@@ -585,6 +585,8 @@ enum rtnetlink_groups {
 #define RTNLGRP_PHONET_IFADDR	RTNLGRP_PHONET_IFADDR
 	RTNLGRP_PHONET_ROUTE,
 #define RTNLGRP_PHONET_ROUTE	RTNLGRP_PHONET_ROUTE
+	RTNLGRP_DCB,
+#define RTNLGRP_DCB		RTNLGRP_DCB
 	__RTNLGRP_MAX
 };
 #define RTNLGRP_MAX	(__RTNLGRP_MAX - 1)
net/dcb/dcbnl.c +145 -83

255 lines not on this page · raw message

#1 lore raw

PATCH 1/7 dcb: Add DCBX capabilities bitmask to the get_ieee response

In reply to John Fastabend

Adding the capabilities bitmask to the get_ieee response allows user space to determine the current DCBX mode. Either CEE or IEEE this is useful with devices that support switching between modes where knowing the current state is relevant.

Derived from work by Mark Rustad

---

 net/dcb/dcbnl.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
net/dcb/dcbnl.c +12 -0
index ed1bb8c..3a6d97d 100644
@@ -1288,6 +1288,7 @@ static int dcbnl_ieee_get(struct net_device *netdev, struct nlattr **tb,
 	struct nlattr *ieee, *app;
 	struct dcb_app_type *itr;
 	const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops;
+	int dcbx;
 	int err;
 
 	if (!ops)
@@ -1338,6 +1339,12 @@ static int dcbnl_ieee_get(struct net_device *netdev, struct nlattr **tb,
 			}
 		}
 	}
+
+	if (netdev->dcbnl_ops->getdcbx)
+		dcbx = netdev->dcbnl_ops->getdcbx(netdev);
+	else
+		dcbx = -EOPNOTSUPP;
+
 	spin_unlock(&dcb_lock);
 	nla_nest_end(skb, app);
 
@@ -1366,6 +1373,11 @@ static int dcbnl_ieee_get(struct net_device *netdev, struct nlattr **tb,
 	}
 
 	nla_nest_end(skb, ieee);
+	if (dcbx >= 0) {
+		err = nla_put_u8(skb, DCB_ATTR_DCBX, dcbx);
+		if (err)
+			goto nla_put_failure;
+	}
 	nlmsg_end(skb, nlh);
 
 	return rtnl_unicast(skb, &init_net, pid);
#5 lore raw

PATCH 3/7 dcb: Add ieee_dcb_setapp() to be used for IEEE 802.1Qaz APP data

In reply to John Fastabend

This adds a setapp routine for IEEE802.1Qaz encoded APP data types. The IEEE 802.1Qaz spec encodes the priority bits differently and allows for multiple APP data entries of the same selector and protocol. Trying to force these to use the same set routines was becoming tedious. Furthermore, userspace could probably enforce the correct semantics, but expecting drivers to do this seems error prone in the firmware case.

For these reasons add ieee_dcb_setapp() that understands the IEEE 802.1Qaz encoded form.

---

 include/net/dcbnl.h |    1 +
 net/dcb/dcbnl.c     |   55 +++++++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 52 insertions(+), 4 deletions(-)
include/net/dcbnl.h +1 -0
index e5983c9..47a17d2 100644
@@ -30,6 +30,7 @@ struct dcb_app_type {
 
 u8 dcb_setapp(struct net_device *, struct dcb_app *);
 u8 dcb_getapp(struct net_device *, struct dcb_app *);
+int dcb_ieee_setapp(struct net_device *, struct dcb_app *);
 
 /*
  * Ops struct for the netlink callbacks.  Used by DCB-enabled drivers through
net/dcb/dcbnl.c +51 -4

74 lines not on this page · raw message

#6 lore raw

PATCH 4/7 dcb: Add ieee_dcb_delapp() and dcb op to delete app entry

In reply to John Fastabend

Now that we allow multiple IEEE App entries we need a way to remove specific entries. To do this add the ieee_dcb_delapp() routine.

Additionaly drivers may need to remove the APP entry from their firmware tables. Add dcb ops routine to handle this.

---

 include/linux/dcbnl.h |    2 +
 include/net/dcbnl.h   |    2 +
 net/dcb/dcbnl.c       |   90 ++++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 92 insertions(+), 2 deletions(-)
include/linux/dcbnl.h +2 -0
index c522800..66a6723 100644
@@ -203,6 +203,7 @@ struct dcbmsg {
  * @DCB_CMD_GFEATCFG: get DCBX features flags
  * @DCB_CMD_SFEATCFG: set DCBX features negotiation flags
  * @DCB_CMD_CEE_GET: get CEE aggregated configuration
+ * @DCB_CMD_IEEE_DEL: delete IEEE 802.1Qaz configuration
  */
 enum dcbnl_commands {
 	DCB_CMD_UNDEFINED,
@@ -246,6 +247,7 @@ enum dcbnl_commands {
 	DCB_CMD_SFEATCFG,
 
 	DCB_CMD_CEE_GET,
+	DCB_CMD_IEEE_DEL,
 
 	__DCB_CMD_ENUM_MAX,
 	DCB_CMD_MAX = __DCB_CMD_ENUM_MAX - 1,
include/net/dcbnl.h +2 -0
index 47a17d2..8c545b1 100644
@@ -31,6 +31,7 @@ struct dcb_app_type {
 u8 dcb_setapp(struct net_device *, struct dcb_app *);
 u8 dcb_getapp(struct net_device *, struct dcb_app *);
 int dcb_ieee_setapp(struct net_device *, struct dcb_app *);
+int dcb_ieee_delapp(struct net_device *, struct dcb_app *);
 
 /*
  * Ops struct for the netlink callbacks.  Used by DCB-enabled drivers through
@@ -44,6 +45,7 @@ struct dcbnl_rtnl_ops {
 	int (*ieee_setpfc) (struct net_device *, struct ieee_pfc *);
 	int (*ieee_getapp) (struct net_device *, struct dcb_app *);
 	int (*ieee_setapp) (struct net_device *, struct dcb_app *);
+	int (*ieee_delapp) (struct net_device *, struct dcb_app *);
 	int (*ieee_peer_getets) (struct net_device *, struct ieee_ets *);
 	int (*ieee_peer_getpfc) (struct net_device *, struct ieee_pfc *);
 
net/dcb/dcbnl.c +88 -2

111 lines not on this page · raw message

#7 lore raw

PATCH 5/7 dcb: Add dcb_ieee_getapp_mask() for drivers to query APP settings

In reply to John Fastabend

With multiple APP entries per selector and protocol drivers or stacks may want to pick a specific value or stripe traffic across many priorities. Also if an APP entry in use is deleted the stack/driver may want to choose from the existing APP entries.

To facilitate this and avoid having duplicate code to walk the APP ring provide a routine dcb_ieee_getapp_mask() to return a u8 bitmask of all priorities set for the specified selector and protocol. This routine and bitmask is a helper for DCB kernel users.

---

 include/net/dcbnl.h |    1 +
 net/dcb/dcbnl.c     |   26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 0 deletions(-)
include/net/dcbnl.h +1 -0
index 8c545b1..0a28788 100644
@@ -32,6 +32,7 @@ u8 dcb_setapp(struct net_device *, struct dcb_app *);
 u8 dcb_getapp(struct net_device *, struct dcb_app *);
 int dcb_ieee_setapp(struct net_device *, struct dcb_app *);
 int dcb_ieee_delapp(struct net_device *, struct dcb_app *);
+u8 dcb_ieee_getapp_mask(struct net_device *, struct dcb_app *);
 
 /*
  * Ops struct for the netlink callbacks.  Used by DCB-enabled drivers through
net/dcb/dcbnl.c +26 -0
index 233a6fc..87010ef 100644
@@ -1928,6 +1928,32 @@ out:
 EXPORT_SYMBOL(dcb_setapp);
 
 /**
+ * dcb_ieee_getapp_mask - retrieve the IEEE DCB application priority
+ *
+ * Helper routine which on success returns a non-zero 802.1Qaz user
+ * priority bitmap otherwise returns 0 to indicate the dcb_app was
+ * not found in APP list.
+ */
+u8 dcb_ieee_getapp_mask(struct net_device *dev, struct dcb_app *app)
+{
+	struct dcb_app_type *itr;
+	u8 prio = 0;
+
+	spin_lock(&dcb_lock);
+	list_for_each_entry(itr, &dcb_app_list, list) {
+		if (itr->app.selector == app->selector &&
+		    itr->app.protocol == app->protocol &&
+		    (strncmp(itr->name, dev->name, IFNAMSIZ) == 0)) {
+			prio |= 1 << itr->app.priority;
+		}
+	}
+	spin_unlock(&dcb_lock);
+
+	return prio;
+}
+EXPORT_SYMBOL(dcb_ieee_getapp_mask);
+
+/**
  * dcb_ieee_setapp - add IEEE dcb application data to app list
  *
  * This adds Application data to the list. Multiple application
#8 lore raw

PATCH 6/7 dcb: fix return type on dcb_setapp()

In reply to John Fastabend

Incorrect return type on dcb_setapp() this routine returns negative error codes. All call sites of dcb_setapp() assign the return value to an int already so no need to update drivers.

---

 include/net/dcbnl.h |    2 +-
 net/dcb/dcbnl.c     |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
include/net/dcbnl.h +1 -1
index 0a28788..f8c5505 100644
@@ -28,7 +28,7 @@ struct dcb_app_type {
 	struct list_head  list;
 };
 
-u8 dcb_setapp(struct net_device *, struct dcb_app *);
+int dcb_setapp(struct net_device *, struct dcb_app *);
 u8 dcb_getapp(struct net_device *, struct dcb_app *);
 int dcb_ieee_setapp(struct net_device *, struct dcb_app *);
 int dcb_ieee_delapp(struct net_device *, struct dcb_app *);
net/dcb/dcbnl.c +1 -1
index 87010ef..28fc386 100644
@@ -1884,7 +1884,7 @@ EXPORT_SYMBOL(dcb_getapp);
  * removes applications from the app list if the priority is
  * set to zero.
  */
-u8 dcb_setapp(struct net_device *dev, struct dcb_app *new)
+int dcb_setapp(struct net_device *dev, struct dcb_app *new)
 {
 	struct dcb_app_type *itr;
 	struct dcb_app_type event;
#9 lore raw

PATCH 7/7 dcb: Add missing error check in dcb_ieee_set()

In reply to John Fastabend

Missing error checking before nla_parse_nested().

---

 net/dcb/dcbnl.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
net/dcb/dcbnl.c +3 -0
index 28fc386..e48879f 100644
@@ -1367,6 +1367,9 @@ static int dcbnl_ieee_set(struct net_device *netdev, struct nlattr **tb,
 	if (!ops)
 		return err;
 
+	if (!tb[DCB_ATTR_IEEE])
+		return -EINVAL;
+
 	err = nla_parse_nested(ieee, DCB_ATTR_IEEE_MAX,
 			       tb[DCB_ATTR_IEEE], dcbnl_ieee_policy);
 	if (err)
#10 lore raw
In reply to John Fastabend
Quoted 8 lines · John Fastabend

The following series implements improvements to the DCB netlink interface. This work was done to improve Application handling and support firmware based LLDP agents.

This adds a multicast group for DCB currently user space has trouble keeping in sync across multiple applications and with firmware agents making DCB attribute changes in the driver.

I was working on something along the same lines and would like to add on top of these changes a notification for the CEE flavor.

#3 lore raw

Re: [PATCH 2/7] net: dcbnl, add multicast group for DCB

In reply to John Fastabend
Quoted 39 lines · John Fastabend

Now that dcbnl is being used in many cases by more than a single agent it is beneficial to be notified when some entity either driver or user space has changed the DCB attributes.

Today applications either end up polling the interface or relying on a user space database to maintain the DCB state and post events. Polling is a poor solution for obvious reasons. And relying on a user space database has its own downside. Namely it has created strange boot dependencies requiring the database be populated before any applications dependent on DCB attributes starts or the application goes into a polling loop. Populating the database requires negotiating link setting with the peer and can take anywhere from less than a second up to a few seconds depending on the switch implementation.

Perhaps more importantly if another application or an embedded agent sets a DCB link attribute the database has no way of knowing other than polling the kernel. This prevents applications from responding quickly to changes in link events which at least in the FCoE case and probably any other protocols expecting a lossless link may result in IO errors.

By adding a multicast group for DCB we have clean way to disseminate kernel DCB link attributes up to user space. Avoiding the need for user space to maintain a coherant database and disperse events that potentially do not reflect the current link state.

---

 include/linux/rtnetlink.h |    2 
 net/dcb/dcbnl.c           |  228 +++++++++++++++++++++++++++++----------------
 2 files changed, 147 insertions(+), 83 deletions(-)

[...]

net/dcb/dcbnl.c static int dcbnl_ieee_get(struct net_device *netdev, struct nlattr **tb, · line 1314

Quoted 2 lines
net/dcb/dcbnl.c +2 -0
+static int dcbnl_notify(struct net_device *dev, int event, int cmd,
+			u32 seq, u32 pid)

[...]
A driver supporting an embedded dcbx stack would want to directly invoke the notification routine, therefore it should be exported. I'd like also to add support for a CEE notification. Also when the driver invokes the notification shouldn't it use a new event type something like RTM_NEWDCB?

#11 lore raw
In reply to Shmulik Ravid
Quoted 6 lines · Shmulik Ravid
Quoted 4 lines · John Fastabend

The following series implements improvements to the DCB netlink interface. This work was done to improve Application handling and support firmware based LLDP agents.

Quoted 8 lines
Quoted 4 lines

This adds a multicast group for DCB currently user space has trouble keeping in sync across multiple applications and with firmware agents making DCB attribute changes in the driver.

I was working on something along the same lines and would like to add on top of these changes a notification for the CEE flavor.

Yes please do. This would be helpful I just haven't got to it yet. Anyways we will need something like this to support CEE based firmware implementations.

Thanks,
John

#4 lore raw

Re: [PATCH 2/7] net: dcbnl, add multicast group for DCB

In reply to Shmulik Ravid
Quoted 41 lines · Shmulik Ravid
Quoted 32 lines · John Fastabend

Now that dcbnl is being used in many cases by more than a single agent it is beneficial to be notified when some entity either driver or user space has changed the DCB attributes.

Today applications either end up polling the interface or relying on a user space database to maintain the DCB state and post events. Polling is a poor solution for obvious reasons. And relying on a user space database has its own downside. Namely it has created strange boot dependencies requiring the database be populated before any applications dependent on DCB attributes starts or the application goes into a polling loop. Populating the database requires negotiating link setting with the peer and can take anywhere from less than a second up to a few seconds depending on the switch implementation.

Perhaps more importantly if another application or an embedded agent sets a DCB link attribute the database has no way of knowing other than polling the kernel. This prevents applications from responding quickly to changes in link events which at least in the FCoE case and probably any other protocols expecting a lossless link may result in IO errors.

By adding a multicast group for DCB we have clean way to disseminate kernel DCB link attributes up to user space. Avoiding the need for user space to maintain a coherant database and disperse events that potentially do not reflect the current link state.

Quoted 7 lines

---

 include/linux/rtnetlink.h |    2 
 net/dcb/dcbnl.c           |  228 +++++++++++++++++++++++++++++----------------
 2 files changed, 147 insertions(+), 83 deletions(-)
Quoted 6 lines

[...]

net/dcb/dcbnl.c static int dcbnl_ieee_get(struct net_device *netdev, struct nlattr **tb, · line 1314

Quoted 2 lines
net/dcb/dcbnl.c +2 -0
+static int dcbnl_notify(struct net_device *dev, int event, int cmd,
+			u32 seq, u32 pid)

[...]
A driver supporting an embedded dcbx stack would want to directly invoke the notification routine, therefore it should be exported. I'd like also

We can export this function when we add support to the driver.

Quoted 4 lines

to add support for a CEE notification. Also when the driver invokes the notification shouldn't it use a new event type something like RTM_NEWDCB?

I'm not sure a RTM_NEWDCB event is needed. How would user space be expected to handle the two events? FCoE needs to know if the link is lossless or not it shouldn't care if a firmware agent is running or a user space LLDP agent. Other applications (multipathd, iscsid) probably just want to know the current DCB attributes.

Maybe I missed your point could you provide more details?

Thanks,
John