Skip to contentSkip to conversation

dcb: Add DCBX capabilities bitmask to the get_ieee response

PATCH New John Fastabend 1 participant 7 messages Jun 21, 2011

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

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

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);
#1 lore raw

PATCH v2 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 
 include/net/dcbnl.h       |    2 
 net/dcb/dcbnl.c           |  229 +++++++++++++++++++++++++++++----------------
 3 files changed, 150 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)
include/net/dcbnl.h +2 -0
index e5983c9..b3cf10d 100644
@@ -31,6 +31,8 @@ struct dcb_app_type {
 u8 dcb_setapp(struct net_device *, struct dcb_app *);
 u8 dcb_getapp(struct net_device *, struct dcb_app *);
 
+int dcbnl_notify(struct net_device *dev, int event, int cmd, u32 seq, u32 pid);
+
 /*
  * Ops struct for the netlink callbacks.  Used by DCB-enabled drivers through
  * the netdevice struct.
net/dcb/dcbnl.c +146 -83

256 lines not on this page · raw message

#2 lore raw

PATCH v2 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 b3cf10d..c53a4e0 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 *);
 
 int dcbnl_notify(struct net_device *dev, int event, int cmd, u32 seq, u32 pid);
 
net/dcb/dcbnl.c +51 -4

74 lines not on this page · raw message

#3 lore raw

PATCH v2 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 c53a4e0..62a2685 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 *);
 
 int dcbnl_notify(struct net_device *dev, int event, int cmd, u32 seq, u32 pid);
 
@@ -46,6 +47,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

#4 lore raw

PATCH v2 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 62a2685..c14fd94 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 *);
 
 int dcbnl_notify(struct net_device *dev, int event, int cmd, u32 seq, u32 pid);
 
net/dcb/dcbnl.c +26 -0
index 196084f..b7d0be0 100644
@@ -1929,6 +1929,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
#5 lore raw

PATCH v2 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 c14fd94..d5bbb79 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 b7d0be0..f54c784 100644
@@ -1885,7 +1885,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;
#6 lore raw

PATCH v2 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 f54c784..e954d4c 100644
@@ -1368,6 +1368,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)