* [PATCH 0/7] Series short description
@ 2011-06-17 21:08 John Fastabend
0 siblings, 0 replies; 13+ messages in thread
From: John Fastabend @ 2011-06-17 21:08 UTC (permalink / raw)
To: davem; +Cc: netdev, shmulikr
The following series implements...
---
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
dcbnl: Add ieee_dcb_setapp() to be used for IEEE 802.1Qaz APP data
net: dcbnl, add multicast group for 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
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 0/7] Series short description
@ 2011-06-17 21:16 John Fastabend
2011-06-17 21:16 ` [PATCH 1/7] dcb: Add DCBX capabilities bitmask to the get_ieee response John Fastabend
` (7 more replies)
0 siblings, 8 replies; 13+ messages in thread
From: John Fastabend @ 2011-06-17 21:16 UTC (permalink / raw)
To: davem; +Cc: netdev, shmulikr
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
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 1/7] dcb: Add DCBX capabilities bitmask to the get_ieee response
2011-06-17 21:16 [PATCH 0/7] Series short description John Fastabend
@ 2011-06-17 21:16 ` John Fastabend
2011-06-17 21:16 ` [PATCH 2/7] net: dcbnl, add multicast group for DCB John Fastabend
` (6 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: John Fastabend @ 2011-06-17 21:16 UTC (permalink / raw)
To: davem; +Cc: netdev, shmulikr
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
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
---
net/dcb/dcbnl.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index ed1bb8c..3a6d97d 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -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);
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 2/7] net: dcbnl, add multicast group for DCB
2011-06-17 21:16 [PATCH 0/7] Series short description John Fastabend
2011-06-17 21:16 ` [PATCH 1/7] dcb: Add DCBX capabilities bitmask to the get_ieee response John Fastabend
@ 2011-06-17 21:16 ` John Fastabend
2011-06-19 18:14 ` Shmulik Ravid
2011-06-17 21:16 ` [PATCH 3/7] dcb: Add ieee_dcb_setapp() to be used for IEEE 802.1Qaz APP data John Fastabend
` (5 subsequent siblings)
7 siblings, 1 reply; 13+ messages in thread
From: John Fastabend @ 2011-06-17 21:16 UTC (permalink / raw)
To: davem; +Cc: netdev, shmulikr
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.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
---
include/linux/rtnetlink.h | 2
net/dcb/dcbnl.c | 228 +++++++++++++++++++++++++++++----------------
2 files changed, 147 insertions(+), 83 deletions(-)
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index bbad657..c81226a 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -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)
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index 3a6d97d..b514579 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -1166,64 +1166,6 @@ err:
return ret;
}
-/* Handle IEEE 802.1Qaz SET commands. If any requested operation can not
- * be completed the entire msg is aborted and error value is returned.
- * No attempt is made to reconcile the case where only part of the
- * cmd can be completed.
- */
-static int dcbnl_ieee_set(struct net_device *netdev, struct nlattr **tb,
- u32 pid, u32 seq, u16 flags)
-{
- const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops;
- struct nlattr *ieee[DCB_ATTR_IEEE_MAX + 1];
- int err = -EOPNOTSUPP;
-
- if (!ops)
- goto err;
-
- err = nla_parse_nested(ieee, DCB_ATTR_IEEE_MAX,
- tb[DCB_ATTR_IEEE], dcbnl_ieee_policy);
- if (err)
- goto err;
-
- if (ieee[DCB_ATTR_IEEE_ETS] && ops->ieee_setets) {
- struct ieee_ets *ets = nla_data(ieee[DCB_ATTR_IEEE_ETS]);
- err = ops->ieee_setets(netdev, ets);
- if (err)
- goto err;
- }
-
- if (ieee[DCB_ATTR_IEEE_PFC] && ops->ieee_setpfc) {
- struct ieee_pfc *pfc = nla_data(ieee[DCB_ATTR_IEEE_PFC]);
- err = ops->ieee_setpfc(netdev, pfc);
- if (err)
- goto err;
- }
-
- if (ieee[DCB_ATTR_IEEE_APP_TABLE]) {
- struct nlattr *attr;
- int rem;
-
- nla_for_each_nested(attr, ieee[DCB_ATTR_IEEE_APP_TABLE], rem) {
- struct dcb_app *app_data;
- if (nla_type(attr) != DCB_ATTR_IEEE_APP)
- continue;
- app_data = nla_data(attr);
- if (ops->ieee_setapp)
- err = ops->ieee_setapp(netdev, app_data);
- else
- err = dcb_setapp(netdev, app_data);
- if (err)
- goto err;
- }
- }
-
-err:
- dcbnl_reply(err, RTM_SETDCB, DCB_CMD_IEEE_SET, DCB_ATTR_IEEE,
- pid, seq, flags);
- return err;
-}
-
static int dcbnl_build_peer_app(struct net_device *netdev, struct sk_buff* skb,
int app_nested_type, int app_info_type,
int app_entry_type)
@@ -1279,30 +1221,13 @@ nla_put_failure:
}
/* Handle IEEE 802.1Qaz GET commands. */
-static int dcbnl_ieee_get(struct net_device *netdev, struct nlattr **tb,
- u32 pid, u32 seq, u16 flags)
+static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev)
{
- struct sk_buff *skb;
- struct nlmsghdr *nlh;
- struct dcbmsg *dcb;
struct nlattr *ieee, *app;
struct dcb_app_type *itr;
const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops;
int dcbx;
- int err;
-
- if (!ops)
- return -EOPNOTSUPP;
-
- skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
- if (!skb)
- return -ENOBUFS;
-
- nlh = NLMSG_NEW(skb, pid, seq, RTM_GETDCB, sizeof(*dcb), flags);
-
- dcb = NLMSG_DATA(nlh);
- dcb->dcb_family = AF_UNSPEC;
- dcb->cmd = DCB_CMD_IEEE_GET;
+ int err = -EMSGSIZE;
NLA_PUT_STRING(skb, DCB_ATTR_IFNAME, netdev->name);
@@ -1378,16 +1303,153 @@ static int dcbnl_ieee_get(struct net_device *netdev, struct nlattr **tb,
if (err)
goto nla_put_failure;
}
- nlmsg_end(skb, nlh);
- return rtnl_unicast(skb, &init_net, pid);
+ return 0;
+
nla_put_failure:
- nlmsg_cancel(skb, nlh);
-nlmsg_failure:
- kfree_skb(skb);
- return -1;
+ return err;
}
+static int dcbnl_notify(struct net_device *dev, int event, int cmd,
+ u32 seq, u32 pid)
+{
+ struct net *net = dev_net(dev);
+ struct sk_buff *skb;
+ struct nlmsghdr *nlh;
+ struct dcbmsg *dcb;
+ const struct dcbnl_rtnl_ops *ops = dev->dcbnl_ops;
+ int err;
+
+ if (!ops)
+ return -EOPNOTSUPP;
+
+ skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
+ if (!skb)
+ return -ENOBUFS;
+
+ nlh = nlmsg_put(skb, pid, 0, event, sizeof(*dcb), 0);
+ if (nlh == NULL) {
+ kfree(skb);
+ return -EMSGSIZE;
+ }
+
+ dcb = NLMSG_DATA(nlh);
+ dcb->dcb_family = AF_UNSPEC;
+ dcb->cmd = cmd;
+
+ err = dcbnl_ieee_fill(skb, dev);
+ if (err < 0) {
+ /* Report error to broadcast listeners */
+ nlmsg_cancel(skb, nlh);
+ kfree_skb(skb);
+ rtnl_set_sk_err(net, RTNLGRP_DCB, err);
+ } else {
+ /* End nlmsg and notify broadcast listeners */
+ nlmsg_end(skb, nlh);
+ rtnl_notify(skb, net, 0, RTNLGRP_DCB, NULL, GFP_KERNEL);
+ }
+
+ return err;
+}
+
+/* Handle IEEE 802.1Qaz SET commands. If any requested operation can not
+ * be completed the entire msg is aborted and error value is returned.
+ * No attempt is made to reconcile the case where only part of the
+ * cmd can be completed.
+ */
+static int dcbnl_ieee_set(struct net_device *netdev, struct nlattr **tb,
+ u32 pid, u32 seq, u16 flags)
+{
+ const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops;
+ struct nlattr *ieee[DCB_ATTR_IEEE_MAX + 1];
+ int err = -EOPNOTSUPP;
+
+ if (!ops)
+ return err;
+
+ err = nla_parse_nested(ieee, DCB_ATTR_IEEE_MAX,
+ tb[DCB_ATTR_IEEE], dcbnl_ieee_policy);
+ if (err)
+ return err;
+
+ if (ieee[DCB_ATTR_IEEE_ETS] && ops->ieee_setets) {
+ struct ieee_ets *ets = nla_data(ieee[DCB_ATTR_IEEE_ETS]);
+ err = ops->ieee_setets(netdev, ets);
+ if (err)
+ goto err;
+ }
+
+ if (ieee[DCB_ATTR_IEEE_PFC] && ops->ieee_setpfc) {
+ struct ieee_pfc *pfc = nla_data(ieee[DCB_ATTR_IEEE_PFC]);
+ err = ops->ieee_setpfc(netdev, pfc);
+ if (err)
+ goto err;
+ }
+
+ if (ieee[DCB_ATTR_IEEE_APP_TABLE]) {
+ struct nlattr *attr;
+ int rem;
+
+ nla_for_each_nested(attr, ieee[DCB_ATTR_IEEE_APP_TABLE], rem) {
+ struct dcb_app *app_data;
+ if (nla_type(attr) != DCB_ATTR_IEEE_APP)
+ continue;
+ app_data = nla_data(attr);
+ if (ops->ieee_setapp)
+ err = ops->ieee_setapp(netdev, app_data);
+ else
+ err = dcb_setapp(netdev, app_data);
+ if (err)
+ goto err;
+ }
+ }
+
+err:
+ dcbnl_reply(err, RTM_SETDCB, DCB_CMD_IEEE_SET, DCB_ATTR_IEEE,
+ pid, seq, flags);
+ dcbnl_notify(netdev, RTM_SETDCB, DCB_CMD_IEEE_SET, seq, 0);
+ return err;
+}
+
+static int dcbnl_ieee_get(struct net_device *netdev, struct nlattr **tb,
+ u32 pid, u32 seq, u16 flags)
+{
+ struct net *net = dev_net(netdev);
+ struct sk_buff *skb;
+ struct nlmsghdr *nlh;
+ struct dcbmsg *dcb;
+ const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops;
+ int err;
+
+ if (!ops)
+ return -EOPNOTSUPP;
+
+ skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
+ if (!skb)
+ return -ENOBUFS;
+
+ nlh = nlmsg_put(skb, pid, seq, RTM_GETDCB, sizeof(*dcb), flags);
+ if (nlh == NULL) {
+ kfree(skb);
+ return -EMSGSIZE;
+ }
+
+ dcb = NLMSG_DATA(nlh);
+ dcb->dcb_family = AF_UNSPEC;
+ dcb->cmd = DCB_CMD_IEEE_GET;
+
+ err = dcbnl_ieee_fill(skb, netdev);
+
+ if (err < 0) {
+ nlmsg_cancel(skb, nlh);
+ kfree_skb(skb);
+ } else {
+ nlmsg_end(skb, nlh);
+ err = rtnl_unicast(skb, net, pid);
+ }
+
+ return err;
+}
/* DCBX configuration */
static int dcbnl_getdcbx(struct net_device *netdev, struct nlattr **tb,
u32 pid, u32 seq, u16 flags)
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 3/7] dcb: Add ieee_dcb_setapp() to be used for IEEE 802.1Qaz APP data
2011-06-17 21:16 [PATCH 0/7] Series short description John Fastabend
2011-06-17 21:16 ` [PATCH 1/7] dcb: Add DCBX capabilities bitmask to the get_ieee response John Fastabend
2011-06-17 21:16 ` [PATCH 2/7] net: dcbnl, add multicast group for DCB John Fastabend
@ 2011-06-17 21:16 ` John Fastabend
2011-06-17 21:16 ` [PATCH 4/7] dcb: Add ieee_dcb_delapp() and dcb op to delete app entry John Fastabend
` (4 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: John Fastabend @ 2011-06-17 21:16 UTC (permalink / raw)
To: davem; +Cc: netdev, shmulikr
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.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
---
include/net/dcbnl.h | 1 +
net/dcb/dcbnl.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 52 insertions(+), 4 deletions(-)
diff --git a/include/net/dcbnl.h b/include/net/dcbnl.h
index e5983c9..47a17d2 100644
--- a/include/net/dcbnl.h
+++ b/include/net/dcbnl.h
@@ -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
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index b514579..4e77170 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -1398,7 +1398,7 @@ static int dcbnl_ieee_set(struct net_device *netdev, struct nlattr **tb,
if (ops->ieee_setapp)
err = ops->ieee_setapp(netdev, app_data);
else
- err = dcb_setapp(netdev, app_data);
+ err = dcb_ieee_setapp(netdev, app_data);
if (err)
goto err;
}
@@ -1828,10 +1828,11 @@ u8 dcb_getapp(struct net_device *dev, struct dcb_app *app)
EXPORT_SYMBOL(dcb_getapp);
/**
- * ixgbe_dcbnl_setapp - add dcb application data to app list
+ * dcb_setapp - add CEE dcb application data to app list
*
- * Priority 0 is the default priority this removes applications
- * from the app list if the priority is set to zero.
+ * Priority 0 is an invalid priority in CEE spec. This routine
+ * removes applications from the app list if the priority is
+ * set to zero.
*/
u8 dcb_setapp(struct net_device *dev, struct dcb_app *new)
{
@@ -1876,6 +1877,52 @@ out:
}
EXPORT_SYMBOL(dcb_setapp);
+/**
+ * dcb_ieee_setapp - add IEEE dcb application data to app list
+ *
+ * This adds Application data to the list. Multiple application
+ * entries may exists for the same selector and protocol as long
+ * as the priorities are different.
+ */
+int dcb_ieee_setapp(struct net_device *dev, struct dcb_app *new)
+{
+ struct dcb_app_type *itr, *entry;
+ struct dcb_app_type event;
+ int err = 0;
+
+ memcpy(&event.name, dev->name, sizeof(event.name));
+ memcpy(&event.app, new, sizeof(event.app));
+
+ spin_lock(&dcb_lock);
+ /* Search for existing match and abort if found */
+ list_for_each_entry(itr, &dcb_app_list, list) {
+ if (itr->app.selector == new->selector &&
+ itr->app.protocol == new->protocol &&
+ itr->app.priority == new->priority &&
+ (strncmp(itr->name, dev->name, IFNAMSIZ) == 0)) {
+ err = -EEXIST;
+ goto out;
+ }
+ }
+
+ /* App entry does not exist add new entry */
+ entry = kmalloc(sizeof(struct dcb_app_type), GFP_ATOMIC);
+ if (!entry) {
+ err = -ENOMEM;
+ goto out;
+ }
+
+ memcpy(&entry->app, new, sizeof(*new));
+ strncpy(entry->name, dev->name, IFNAMSIZ);
+ list_add(&entry->list, &dcb_app_list);
+out:
+ spin_unlock(&dcb_lock);
+ if (!err)
+ call_dcbevent_notifiers(DCB_APP_EVENT, &event);
+ return err;
+}
+EXPORT_SYMBOL(dcb_ieee_setapp);
+
static void dcb_flushapp(void)
{
struct dcb_app_type *app;
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 4/7] dcb: Add ieee_dcb_delapp() and dcb op to delete app entry
2011-06-17 21:16 [PATCH 0/7] Series short description John Fastabend
` (2 preceding siblings ...)
2011-06-17 21:16 ` [PATCH 3/7] dcb: Add ieee_dcb_setapp() to be used for IEEE 802.1Qaz APP data John Fastabend
@ 2011-06-17 21:16 ` John Fastabend
2011-06-17 21:16 ` [PATCH 5/7] dcb: Add dcb_ieee_getapp_mask() for drivers to query APP settings John Fastabend
` (3 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: John Fastabend @ 2011-06-17 21:16 UTC (permalink / raw)
To: davem; +Cc: netdev, shmulikr
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.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
---
include/linux/dcbnl.h | 2 +
include/net/dcbnl.h | 2 +
net/dcb/dcbnl.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 92 insertions(+), 2 deletions(-)
diff --git a/include/linux/dcbnl.h b/include/linux/dcbnl.h
index c522800..66a6723 100644
--- a/include/linux/dcbnl.h
+++ b/include/linux/dcbnl.h
@@ -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,
diff --git a/include/net/dcbnl.h b/include/net/dcbnl.h
index 47a17d2..8c545b1 100644
--- a/include/net/dcbnl.h
+++ b/include/net/dcbnl.h
@@ -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 *);
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index 4e77170..233a6fc 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -1450,6 +1450,52 @@ static int dcbnl_ieee_get(struct net_device *netdev, struct nlattr **tb,
return err;
}
+
+static int dcbnl_ieee_del(struct net_device *netdev, struct nlattr **tb,
+ u32 pid, u32 seq, u16 flags)
+{
+ const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops;
+ struct nlattr *ieee[DCB_ATTR_IEEE_MAX + 1];
+ int err = -EOPNOTSUPP;
+
+ if (!ops)
+ return -EOPNOTSUPP;
+
+ 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)
+ return err;
+
+ if (ieee[DCB_ATTR_IEEE_APP_TABLE]) {
+ struct nlattr *attr;
+ int rem;
+
+ nla_for_each_nested(attr, ieee[DCB_ATTR_IEEE_APP_TABLE], rem) {
+ struct dcb_app *app_data;
+
+ if (nla_type(attr) != DCB_ATTR_IEEE_APP)
+ continue;
+ app_data = nla_data(attr);
+ if (ops->ieee_delapp)
+ err = ops->ieee_delapp(netdev, app_data);
+ else
+ err = dcb_ieee_delapp(netdev, app_data);
+ if (err)
+ goto err;
+ }
+ }
+
+err:
+ dcbnl_reply(err, RTM_SETDCB, DCB_CMD_IEEE_DEL, DCB_ATTR_IEEE,
+ pid, seq, flags);
+ dcbnl_notify(netdev, RTM_SETDCB, DCB_CMD_IEEE_DEL, seq, 0);
+ return err;
+}
+
+
/* DCBX configuration */
static int dcbnl_getdcbx(struct net_device *netdev, struct nlattr **tb,
u32 pid, u32 seq, u16 flags)
@@ -1764,11 +1810,15 @@ static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
goto out;
case DCB_CMD_IEEE_SET:
ret = dcbnl_ieee_set(netdev, tb, pid, nlh->nlmsg_seq,
- nlh->nlmsg_flags);
+ nlh->nlmsg_flags);
goto out;
case DCB_CMD_IEEE_GET:
ret = dcbnl_ieee_get(netdev, tb, pid, nlh->nlmsg_seq,
- nlh->nlmsg_flags);
+ nlh->nlmsg_flags);
+ goto out;
+ case DCB_CMD_IEEE_DEL:
+ ret = dcbnl_ieee_del(netdev, tb, pid, nlh->nlmsg_seq,
+ nlh->nlmsg_flags);
goto out;
case DCB_CMD_GDCBX:
ret = dcbnl_getdcbx(netdev, tb, pid, nlh->nlmsg_seq,
@@ -1923,6 +1973,42 @@ out:
}
EXPORT_SYMBOL(dcb_ieee_setapp);
+/**
+ * dcb_ieee_delapp - delete IEEE dcb application data from list
+ *
+ * This removes a matching APP data from the APP list
+ */
+int dcb_ieee_delapp(struct net_device *dev, struct dcb_app *del)
+{
+ struct dcb_app_type *itr;
+ struct dcb_app_type event;
+ int err = -ENOENT;
+
+ memcpy(&event.name, dev->name, sizeof(event.name));
+ memcpy(&event.app, del, sizeof(event.app));
+
+ spin_lock(&dcb_lock);
+ /* Search for existing match and remove it. */
+ list_for_each_entry(itr, &dcb_app_list, list) {
+ if (itr->app.selector == del->selector &&
+ itr->app.protocol == del->protocol &&
+ itr->app.priority == del->priority &&
+ (strncmp(itr->name, dev->name, IFNAMSIZ) == 0)) {
+ list_del(&itr->list);
+ kfree(itr);
+ err = 0;
+ goto out;
+ }
+ }
+
+out:
+ spin_unlock(&dcb_lock);
+ if (!err)
+ call_dcbevent_notifiers(DCB_APP_EVENT, &event);
+ return err;
+}
+EXPORT_SYMBOL(dcb_ieee_delapp);
+
static void dcb_flushapp(void)
{
struct dcb_app_type *app;
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 5/7] dcb: Add dcb_ieee_getapp_mask() for drivers to query APP settings
2011-06-17 21:16 [PATCH 0/7] Series short description John Fastabend
` (3 preceding siblings ...)
2011-06-17 21:16 ` [PATCH 4/7] dcb: Add ieee_dcb_delapp() and dcb op to delete app entry John Fastabend
@ 2011-06-17 21:16 ` John Fastabend
2011-06-17 21:16 ` [PATCH 6/7] dcb: fix return type on dcb_setapp() John Fastabend
` (2 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: John Fastabend @ 2011-06-17 21:16 UTC (permalink / raw)
To: davem; +Cc: netdev, shmulikr
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.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
---
include/net/dcbnl.h | 1 +
net/dcb/dcbnl.c | 26 ++++++++++++++++++++++++++
2 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/include/net/dcbnl.h b/include/net/dcbnl.h
index 8c545b1..0a28788 100644
--- a/include/net/dcbnl.h
+++ b/include/net/dcbnl.h
@@ -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
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index 233a6fc..87010ef 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -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
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 6/7] dcb: fix return type on dcb_setapp()
2011-06-17 21:16 [PATCH 0/7] Series short description John Fastabend
` (4 preceding siblings ...)
2011-06-17 21:16 ` [PATCH 5/7] dcb: Add dcb_ieee_getapp_mask() for drivers to query APP settings John Fastabend
@ 2011-06-17 21:16 ` John Fastabend
2011-06-17 21:16 ` [PATCH 7/7] dcb: Add missing error check in dcb_ieee_set() John Fastabend
2011-06-19 17:58 ` [PATCH 0/7] Series short description Shmulik Ravid
7 siblings, 0 replies; 13+ messages in thread
From: John Fastabend @ 2011-06-17 21:16 UTC (permalink / raw)
To: davem; +Cc: netdev, shmulikr
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.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
---
include/net/dcbnl.h | 2 +-
net/dcb/dcbnl.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/net/dcbnl.h b/include/net/dcbnl.h
index 0a28788..f8c5505 100644
--- a/include/net/dcbnl.h
+++ b/include/net/dcbnl.h
@@ -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 *);
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index 87010ef..28fc386 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -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;
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 7/7] dcb: Add missing error check in dcb_ieee_set()
2011-06-17 21:16 [PATCH 0/7] Series short description John Fastabend
` (5 preceding siblings ...)
2011-06-17 21:16 ` [PATCH 6/7] dcb: fix return type on dcb_setapp() John Fastabend
@ 2011-06-17 21:16 ` John Fastabend
2011-06-19 17:58 ` [PATCH 0/7] Series short description Shmulik Ravid
7 siblings, 0 replies; 13+ messages in thread
From: John Fastabend @ 2011-06-17 21:16 UTC (permalink / raw)
To: davem; +Cc: netdev, shmulikr
Missing error checking before nla_parse_nested().
Reported-by: Mark Rustad <mark.d.rustad@intel.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
---
net/dcb/dcbnl.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index 28fc386..e48879f 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -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)
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 0/7] Series short description
2011-06-17 21:16 [PATCH 0/7] Series short description John Fastabend
` (6 preceding siblings ...)
2011-06-17 21:16 ` [PATCH 7/7] dcb: Add missing error check in dcb_ieee_set() John Fastabend
@ 2011-06-19 17:58 ` Shmulik Ravid
2011-06-20 16:05 ` John Fastabend
7 siblings, 1 reply; 13+ messages in thread
From: Shmulik Ravid @ 2011-06-19 17:58 UTC (permalink / raw)
To: John Fastabend; +Cc: davem@davemloft.net, netdev@vger.kernel.org
On Fri, 2011-06-17 at 14:16 -0700, John Fastabend wrote:
> 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.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/7] net: dcbnl, add multicast group for DCB
2011-06-17 21:16 ` [PATCH 2/7] net: dcbnl, add multicast group for DCB John Fastabend
@ 2011-06-19 18:14 ` Shmulik Ravid
2011-06-20 16:16 ` John Fastabend
0 siblings, 1 reply; 13+ messages in thread
From: Shmulik Ravid @ 2011-06-19 18:14 UTC (permalink / raw)
To: John Fastabend; +Cc: davem@davemloft.net, netdev@vger.kernel.org
On Fri, 2011-06-17 at 14:16 -0700, John Fastabend wrote:
> 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.
>
> Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
> ---
>
> include/linux/rtnetlink.h | 2
> net/dcb/dcbnl.c | 228 +++++++++++++++++++++++++++++----------------
> 2 files changed, 147 insertions(+), 83 deletions(-)
>
[...]
> +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?
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 0/7] Series short description
2011-06-19 17:58 ` [PATCH 0/7] Series short description Shmulik Ravid
@ 2011-06-20 16:05 ` John Fastabend
0 siblings, 0 replies; 13+ messages in thread
From: John Fastabend @ 2011-06-20 16:05 UTC (permalink / raw)
To: Shmulik Ravid; +Cc: davem@davemloft.net, netdev@vger.kernel.org
On 6/19/2011 10:58 AM, Shmulik Ravid wrote:
>
> On Fri, 2011-06-17 at 14:16 -0700, John Fastabend wrote:
>> 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.
>
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
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/7] net: dcbnl, add multicast group for DCB
2011-06-19 18:14 ` Shmulik Ravid
@ 2011-06-20 16:16 ` John Fastabend
0 siblings, 0 replies; 13+ messages in thread
From: John Fastabend @ 2011-06-20 16:16 UTC (permalink / raw)
To: Shmulik Ravid; +Cc: davem@davemloft.net, netdev@vger.kernel.org
On 6/19/2011 11:14 AM, Shmulik Ravid wrote:
>
> On Fri, 2011-06-17 at 14:16 -0700, John Fastabend wrote:
>> 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.
>>
>> Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
>> ---
>>
>> include/linux/rtnetlink.h | 2
>> net/dcb/dcbnl.c | 228 +++++++++++++++++++++++++++++----------------
>> 2 files changed, 147 insertions(+), 83 deletions(-)
>>
> [...]
>> +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.
> 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
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2011-06-20 16:16 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-17 21:16 [PATCH 0/7] Series short description John Fastabend
2011-06-17 21:16 ` [PATCH 1/7] dcb: Add DCBX capabilities bitmask to the get_ieee response John Fastabend
2011-06-17 21:16 ` [PATCH 2/7] net: dcbnl, add multicast group for DCB John Fastabend
2011-06-19 18:14 ` Shmulik Ravid
2011-06-20 16:16 ` John Fastabend
2011-06-17 21:16 ` [PATCH 3/7] dcb: Add ieee_dcb_setapp() to be used for IEEE 802.1Qaz APP data John Fastabend
2011-06-17 21:16 ` [PATCH 4/7] dcb: Add ieee_dcb_delapp() and dcb op to delete app entry John Fastabend
2011-06-17 21:16 ` [PATCH 5/7] dcb: Add dcb_ieee_getapp_mask() for drivers to query APP settings John Fastabend
2011-06-17 21:16 ` [PATCH 6/7] dcb: fix return type on dcb_setapp() John Fastabend
2011-06-17 21:16 ` [PATCH 7/7] dcb: Add missing error check in dcb_ieee_set() John Fastabend
2011-06-19 17:58 ` [PATCH 0/7] Series short description Shmulik Ravid
2011-06-20 16:05 ` John Fastabend
-- strict thread matches above, loose matches on Subject: below --
2011-06-17 21:08 John Fastabend
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).