Skip to content

Commit b6db217

Browse files
John Fastabenddavem330
authored andcommitted
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: John Fastabend <john.r.fastabend@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 314b477 commit b6db217

2 files changed

Lines changed: 52 additions & 4 deletions

File tree

‎include/net/dcbnl.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ struct dcb_app_type {
3030

3131
u8 dcb_setapp(struct net_device *, struct dcb_app *);
3232
u8 dcb_getapp(struct net_device *, struct dcb_app *);
33+
int dcb_ieee_setapp(struct net_device *, struct dcb_app *);
3334

3435
int dcbnl_notify(struct net_device *dev, int event, int cmd, u32 seq, u32 pid);
3536

‎net/dcb/dcbnl.c‎

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,7 +1399,7 @@ static int dcbnl_ieee_set(struct net_device *netdev, struct nlattr **tb,
13991399
if (ops->ieee_setapp)
14001400
err = ops->ieee_setapp(netdev, app_data);
14011401
else
1402-
err = dcb_setapp(netdev, app_data);
1402+
err = dcb_ieee_setapp(netdev, app_data);
14031403
if (err)
14041404
goto err;
14051405
}
@@ -1829,10 +1829,11 @@ u8 dcb_getapp(struct net_device *dev, struct dcb_app *app)
18291829
EXPORT_SYMBOL(dcb_getapp);
18301830

18311831
/**
1832-
* ixgbe_dcbnl_setapp - add dcb application data to app list
1832+
* dcb_setapp - add CEE dcb application data to app list
18331833
*
1834-
* Priority 0 is the default priority this removes applications
1835-
* from the app list if the priority is set to zero.
1834+
* Priority 0 is an invalid priority in CEE spec. This routine
1835+
* removes applications from the app list if the priority is
1836+
* set to zero.
18361837
*/
18371838
u8 dcb_setapp(struct net_device *dev, struct dcb_app *new)
18381839
{
@@ -1877,6 +1878,52 @@ u8 dcb_setapp(struct net_device *dev, struct dcb_app *new)
18771878
}
18781879
EXPORT_SYMBOL(dcb_setapp);
18791880

1881+
/**
1882+
* dcb_ieee_setapp - add IEEE dcb application data to app list
1883+
*
1884+
* This adds Application data to the list. Multiple application
1885+
* entries may exists for the same selector and protocol as long
1886+
* as the priorities are different.
1887+
*/
1888+
int dcb_ieee_setapp(struct net_device *dev, struct dcb_app *new)
1889+
{
1890+
struct dcb_app_type *itr, *entry;
1891+
struct dcb_app_type event;
1892+
int err = 0;
1893+
1894+
memcpy(&event.name, dev->name, sizeof(event.name));
1895+
memcpy(&event.app, new, sizeof(event.app));
1896+
1897+
spin_lock(&dcb_lock);
1898+
/* Search for existing match and abort if found */
1899+
list_for_each_entry(itr, &dcb_app_list, list) {
1900+
if (itr->app.selector == new->selector &&
1901+
itr->app.protocol == new->protocol &&
1902+
itr->app.priority == new->priority &&
1903+
(strncmp(itr->name, dev->name, IFNAMSIZ) == 0)) {
1904+
err = -EEXIST;
1905+
goto out;
1906+
}
1907+
}
1908+
1909+
/* App entry does not exist add new entry */
1910+
entry = kmalloc(sizeof(struct dcb_app_type), GFP_ATOMIC);
1911+
if (!entry) {
1912+
err = -ENOMEM;
1913+
goto out;
1914+
}
1915+
1916+
memcpy(&entry->app, new, sizeof(*new));
1917+
strncpy(entry->name, dev->name, IFNAMSIZ);
1918+
list_add(&entry->list, &dcb_app_list);
1919+
out:
1920+
spin_unlock(&dcb_lock);
1921+
if (!err)
1922+
call_dcbevent_notifiers(DCB_APP_EVENT, &event);
1923+
return err;
1924+
}
1925+
EXPORT_SYMBOL(dcb_ieee_setapp);
1926+
18801927
static void dcb_flushapp(void)
18811928
{
18821929
struct dcb_app_type *app;

0 commit comments

Comments
 (0)