Commit b6db2174 authored by John Fastabend's avatar John Fastabend Committed by David S. Miller

dcb: Add ieee_dcb_setapp() to be used for IEEE 802.1Qaz APP data

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: default avatarJohn Fastabend <john.r.fastabend@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 314b4778
...@@ -30,6 +30,7 @@ struct dcb_app_type { ...@@ -30,6 +30,7 @@ struct dcb_app_type {
u8 dcb_setapp(struct net_device *, struct dcb_app *); u8 dcb_setapp(struct net_device *, struct dcb_app *);
u8 dcb_getapp(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); int dcbnl_notify(struct net_device *dev, int event, int cmd, u32 seq, u32 pid);
......
...@@ -1399,7 +1399,7 @@ static int dcbnl_ieee_set(struct net_device *netdev, struct nlattr **tb, ...@@ -1399,7 +1399,7 @@ static int dcbnl_ieee_set(struct net_device *netdev, struct nlattr **tb,
if (ops->ieee_setapp) if (ops->ieee_setapp)
err = ops->ieee_setapp(netdev, app_data); err = ops->ieee_setapp(netdev, app_data);
else else
err = dcb_setapp(netdev, app_data); err = dcb_ieee_setapp(netdev, app_data);
if (err) if (err)
goto err; goto err;
} }
...@@ -1829,10 +1829,11 @@ u8 dcb_getapp(struct net_device *dev, struct dcb_app *app) ...@@ -1829,10 +1829,11 @@ u8 dcb_getapp(struct net_device *dev, struct dcb_app *app)
EXPORT_SYMBOL(dcb_getapp); 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 * Priority 0 is an invalid priority in CEE spec. This routine
* from the app list if the priority is set to zero. * removes applications from the app list if the priority is
* set to zero.
*/ */
u8 dcb_setapp(struct net_device *dev, struct dcb_app *new) u8 dcb_setapp(struct net_device *dev, struct dcb_app *new)
{ {
...@@ -1877,6 +1878,52 @@ u8 dcb_setapp(struct net_device *dev, struct dcb_app *new) ...@@ -1877,6 +1878,52 @@ u8 dcb_setapp(struct net_device *dev, struct dcb_app *new)
} }
EXPORT_SYMBOL(dcb_setapp); 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) static void dcb_flushapp(void)
{ {
struct dcb_app_type *app; struct dcb_app_type *app;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment