diff options
author | John Fastabend <john.r.fastabend@intel.com> | 2011-06-21 03:34:42 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-06-21 19:06:11 -0400 |
commit | b6db2174c59ef1e72f7bd63e0f105b1a2d7f18d3 (patch) | |
tree | b8d08270d6d6158fd94a6fc6ccadc5978d51a673 | |
parent | 314b4778ed579f29b6d46ba90dbf31314c13805f (diff) |
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>
-rw-r--r-- | include/net/dcbnl.h | 1 | ||||
-rw-r--r-- | 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 b3cf10d9b828..c53a4e06a16a 100644 --- a/include/net/dcbnl.h +++ b/include/net/dcbnl.h | |||
@@ -30,6 +30,7 @@ struct dcb_app_type { | |||
30 | 30 | ||
31 | u8 dcb_setapp(struct net_device *, struct dcb_app *); | 31 | u8 dcb_setapp(struct net_device *, struct dcb_app *); |
32 | u8 dcb_getapp(struct net_device *, struct dcb_app *); | 32 | u8 dcb_getapp(struct net_device *, struct dcb_app *); |
33 | int dcb_ieee_setapp(struct net_device *, struct dcb_app *); | ||
33 | 34 | ||
34 | int dcbnl_notify(struct net_device *dev, int event, int cmd, u32 seq, u32 pid); | 35 | int dcbnl_notify(struct net_device *dev, int event, int cmd, u32 seq, u32 pid); |
35 | 36 | ||
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c index ffba32692bdb..3e3b51c4a84a 100644 --- a/net/dcb/dcbnl.c +++ b/net/dcb/dcbnl.c | |||
@@ -1399,7 +1399,7 @@ static int dcbnl_ieee_set(struct net_device *netdev, struct nlattr **tb, | |||
1399 | if (ops->ieee_setapp) | 1399 | if (ops->ieee_setapp) |
1400 | err = ops->ieee_setapp(netdev, app_data); | 1400 | err = ops->ieee_setapp(netdev, app_data); |
1401 | else | 1401 | else |
1402 | err = dcb_setapp(netdev, app_data); | 1402 | err = dcb_ieee_setapp(netdev, app_data); |
1403 | if (err) | 1403 | if (err) |
1404 | goto err; | 1404 | goto err; |
1405 | } | 1405 | } |
@@ -1829,10 +1829,11 @@ u8 dcb_getapp(struct net_device *dev, struct dcb_app *app) | |||
1829 | EXPORT_SYMBOL(dcb_getapp); | 1829 | EXPORT_SYMBOL(dcb_getapp); |
1830 | 1830 | ||
1831 | /** | 1831 | /** |
1832 | * ixgbe_dcbnl_setapp - add dcb application data to app list | 1832 | * dcb_setapp - add CEE dcb application data to app list |
1833 | * | 1833 | * |
1834 | * Priority 0 is the default priority this removes applications | 1834 | * Priority 0 is an invalid priority in CEE spec. This routine |
1835 | * from the app list if the priority is set to zero. | 1835 | * removes applications from the app list if the priority is |
1836 | * set to zero. | ||
1836 | */ | 1837 | */ |
1837 | u8 dcb_setapp(struct net_device *dev, struct dcb_app *new) | 1838 | u8 dcb_setapp(struct net_device *dev, struct dcb_app *new) |
1838 | { | 1839 | { |
@@ -1877,6 +1878,52 @@ out: | |||
1877 | } | 1878 | } |
1878 | EXPORT_SYMBOL(dcb_setapp); | 1879 | EXPORT_SYMBOL(dcb_setapp); |
1879 | 1880 | ||
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 | |||
1880 | static void dcb_flushapp(void) | 1927 | static void dcb_flushapp(void) |
1881 | { | 1928 | { |
1882 | struct dcb_app_type *app; | 1929 | struct dcb_app_type *app; |