Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6
[sfrench/cifs-2.6.git] / drivers / net / ixgbe / ixgbe_dcb_nl.c
1 /*******************************************************************************
2
3   Intel 10 Gigabit PCI Express Linux driver
4   Copyright(c) 1999 - 2010 Intel Corporation.
5
6   This program is free software; you can redistribute it and/or modify it
7   under the terms and conditions of the GNU General Public License,
8   version 2, as published by the Free Software Foundation.
9
10   This program is distributed in the hope it will be useful, but WITHOUT
11   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13   more details.
14
15   You should have received a copy of the GNU General Public License along with
16   this program; if not, write to the Free Software Foundation, Inc.,
17   51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18
19   The full GNU General Public License is included in this distribution in
20   the file called "COPYING".
21
22   Contact Information:
23   Linux NICS <linux.nics@intel.com>
24   e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25   Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27 *******************************************************************************/
28
29 #include "ixgbe.h"
30 #include <linux/dcbnl.h>
31 #include "ixgbe_dcb_82598.h"
32 #include "ixgbe_dcb_82599.h"
33
34 /* Callbacks for DCB netlink in the kernel */
35 #define BIT_DCB_MODE    0x01
36 #define BIT_PFC         0x02
37 #define BIT_PG_RX       0x04
38 #define BIT_PG_TX       0x08
39 #define BIT_APP_UPCHG   0x10
40 #define BIT_RESETLINK   0x40
41 #define BIT_LINKSPEED   0x80
42
43 /* Responses for the DCB_C_SET_ALL command */
44 #define DCB_HW_CHG_RST  0  /* DCB configuration changed with reset */
45 #define DCB_NO_HW_CHG   1  /* DCB configuration did not change */
46 #define DCB_HW_CHG      2  /* DCB configuration changed, no reset */
47
48 int ixgbe_copy_dcb_cfg(struct ixgbe_dcb_config *src_dcb_cfg,
49                        struct ixgbe_dcb_config *dst_dcb_cfg, int tc_max)
50 {
51         struct tc_configuration *src_tc_cfg = NULL;
52         struct tc_configuration *dst_tc_cfg = NULL;
53         int i;
54
55         if (!src_dcb_cfg || !dst_dcb_cfg)
56                 return -EINVAL;
57
58         for (i = DCB_PG_ATTR_TC_0; i < tc_max + DCB_PG_ATTR_TC_0; i++) {
59                 src_tc_cfg = &src_dcb_cfg->tc_config[i - DCB_PG_ATTR_TC_0];
60                 dst_tc_cfg = &dst_dcb_cfg->tc_config[i - DCB_PG_ATTR_TC_0];
61
62                 dst_tc_cfg->path[DCB_TX_CONFIG].prio_type =
63                                 src_tc_cfg->path[DCB_TX_CONFIG].prio_type;
64
65                 dst_tc_cfg->path[DCB_TX_CONFIG].bwg_id =
66                                 src_tc_cfg->path[DCB_TX_CONFIG].bwg_id;
67
68                 dst_tc_cfg->path[DCB_TX_CONFIG].bwg_percent =
69                                 src_tc_cfg->path[DCB_TX_CONFIG].bwg_percent;
70
71                 dst_tc_cfg->path[DCB_TX_CONFIG].up_to_tc_bitmap =
72                                 src_tc_cfg->path[DCB_TX_CONFIG].up_to_tc_bitmap;
73
74                 dst_tc_cfg->path[DCB_RX_CONFIG].prio_type =
75                                 src_tc_cfg->path[DCB_RX_CONFIG].prio_type;
76
77                 dst_tc_cfg->path[DCB_RX_CONFIG].bwg_id =
78                                 src_tc_cfg->path[DCB_RX_CONFIG].bwg_id;
79
80                 dst_tc_cfg->path[DCB_RX_CONFIG].bwg_percent =
81                                 src_tc_cfg->path[DCB_RX_CONFIG].bwg_percent;
82
83                 dst_tc_cfg->path[DCB_RX_CONFIG].up_to_tc_bitmap =
84                                 src_tc_cfg->path[DCB_RX_CONFIG].up_to_tc_bitmap;
85         }
86
87         for (i = DCB_PG_ATTR_BW_ID_0; i < DCB_PG_ATTR_BW_ID_MAX; i++) {
88                 dst_dcb_cfg->bw_percentage[DCB_TX_CONFIG]
89                         [i-DCB_PG_ATTR_BW_ID_0] = src_dcb_cfg->bw_percentage
90                                 [DCB_TX_CONFIG][i-DCB_PG_ATTR_BW_ID_0];
91                 dst_dcb_cfg->bw_percentage[DCB_RX_CONFIG]
92                         [i-DCB_PG_ATTR_BW_ID_0] = src_dcb_cfg->bw_percentage
93                                 [DCB_RX_CONFIG][i-DCB_PG_ATTR_BW_ID_0];
94         }
95
96         for (i = DCB_PFC_UP_ATTR_0; i < DCB_PFC_UP_ATTR_MAX; i++) {
97                 dst_dcb_cfg->tc_config[i - DCB_PFC_UP_ATTR_0].dcb_pfc =
98                         src_dcb_cfg->tc_config[i - DCB_PFC_UP_ATTR_0].dcb_pfc;
99         }
100
101         dst_dcb_cfg->pfc_mode_enable = src_dcb_cfg->pfc_mode_enable;
102
103         return 0;
104 }
105
106 static u8 ixgbe_dcbnl_get_state(struct net_device *netdev)
107 {
108         struct ixgbe_adapter *adapter = netdev_priv(netdev);
109
110         return !!(adapter->flags & IXGBE_FLAG_DCB_ENABLED);
111 }
112
113 static u8 ixgbe_dcbnl_set_state(struct net_device *netdev, u8 state)
114 {
115         u8 err = 0;
116         struct ixgbe_adapter *adapter = netdev_priv(netdev);
117
118         if (state > 0) {
119                 /* Turn on DCB */
120                 if (adapter->flags & IXGBE_FLAG_DCB_ENABLED)
121                         goto out;
122
123                 if (!(adapter->flags & IXGBE_FLAG_MSIX_ENABLED)) {
124                         DPRINTK(DRV, ERR, "Enable failed, needs MSI-X\n");
125                         err = 1;
126                         goto out;
127                 }
128
129                 if (netif_running(netdev))
130                         netdev->netdev_ops->ndo_stop(netdev);
131                 ixgbe_clear_interrupt_scheme(adapter);
132
133                 if (adapter->hw.mac.type == ixgbe_mac_82598EB) {
134                         adapter->last_lfc_mode = adapter->hw.fc.current_mode;
135                         adapter->hw.fc.requested_mode = ixgbe_fc_none;
136                 }
137                 adapter->flags &= ~IXGBE_FLAG_RSS_ENABLED;
138                 if (adapter->hw.mac.type == ixgbe_mac_82599EB) {
139                         adapter->flags &= ~IXGBE_FLAG_FDIR_HASH_CAPABLE;
140                         adapter->flags &= ~IXGBE_FLAG_FDIR_PERFECT_CAPABLE;
141                 }
142                 adapter->flags |= IXGBE_FLAG_DCB_ENABLED;
143                 ixgbe_init_interrupt_scheme(adapter);
144                 if (netif_running(netdev))
145                         netdev->netdev_ops->ndo_open(netdev);
146         } else {
147                 /* Turn off DCB */
148                 if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
149                         if (netif_running(netdev))
150                                 netdev->netdev_ops->ndo_stop(netdev);
151                         ixgbe_clear_interrupt_scheme(adapter);
152
153                         adapter->hw.fc.requested_mode = adapter->last_lfc_mode;
154                         adapter->temp_dcb_cfg.pfc_mode_enable = false;
155                         adapter->dcb_cfg.pfc_mode_enable = false;
156                         adapter->flags &= ~IXGBE_FLAG_DCB_ENABLED;
157                         adapter->flags |= IXGBE_FLAG_RSS_ENABLED;
158                         if (adapter->hw.mac.type == ixgbe_mac_82599EB)
159                                 adapter->flags |= IXGBE_FLAG_FDIR_HASH_CAPABLE;
160
161                         ixgbe_init_interrupt_scheme(adapter);
162                         if (netif_running(netdev))
163                                 netdev->netdev_ops->ndo_open(netdev);
164                 }
165         }
166 out:
167         return err;
168 }
169
170 static void ixgbe_dcbnl_get_perm_hw_addr(struct net_device *netdev,
171                                          u8 *perm_addr)
172 {
173         struct ixgbe_adapter *adapter = netdev_priv(netdev);
174         int i, j;
175
176         memset(perm_addr, 0xff, MAX_ADDR_LEN);
177
178         for (i = 0; i < netdev->addr_len; i++)
179                 perm_addr[i] = adapter->hw.mac.perm_addr[i];
180
181         if (adapter->hw.mac.type == ixgbe_mac_82599EB) {
182                 for (j = 0; j < netdev->addr_len; j++, i++)
183                         perm_addr[i] = adapter->hw.mac.san_addr[j];
184         }
185 }
186
187 static void ixgbe_dcbnl_set_pg_tc_cfg_tx(struct net_device *netdev, int tc,
188                                          u8 prio, u8 bwg_id, u8 bw_pct,
189                                          u8 up_map)
190 {
191         struct ixgbe_adapter *adapter = netdev_priv(netdev);
192
193         if (prio != DCB_ATTR_VALUE_UNDEFINED)
194                 adapter->temp_dcb_cfg.tc_config[tc].path[0].prio_type = prio;
195         if (bwg_id != DCB_ATTR_VALUE_UNDEFINED)
196                 adapter->temp_dcb_cfg.tc_config[tc].path[0].bwg_id = bwg_id;
197         if (bw_pct != DCB_ATTR_VALUE_UNDEFINED)
198                 adapter->temp_dcb_cfg.tc_config[tc].path[0].bwg_percent =
199                         bw_pct;
200         if (up_map != DCB_ATTR_VALUE_UNDEFINED)
201                 adapter->temp_dcb_cfg.tc_config[tc].path[0].up_to_tc_bitmap =
202                         up_map;
203
204         if ((adapter->temp_dcb_cfg.tc_config[tc].path[0].prio_type !=
205              adapter->dcb_cfg.tc_config[tc].path[0].prio_type) ||
206             (adapter->temp_dcb_cfg.tc_config[tc].path[0].bwg_id !=
207              adapter->dcb_cfg.tc_config[tc].path[0].bwg_id) ||
208             (adapter->temp_dcb_cfg.tc_config[tc].path[0].bwg_percent !=
209              adapter->dcb_cfg.tc_config[tc].path[0].bwg_percent) ||
210             (adapter->temp_dcb_cfg.tc_config[tc].path[0].up_to_tc_bitmap !=
211              adapter->dcb_cfg.tc_config[tc].path[0].up_to_tc_bitmap)) {
212                 adapter->dcb_set_bitmap |= BIT_PG_TX;
213                 adapter->dcb_set_bitmap |= BIT_RESETLINK;
214         }
215 }
216
217 static void ixgbe_dcbnl_set_pg_bwg_cfg_tx(struct net_device *netdev, int bwg_id,
218                                           u8 bw_pct)
219 {
220         struct ixgbe_adapter *adapter = netdev_priv(netdev);
221
222         adapter->temp_dcb_cfg.bw_percentage[0][bwg_id] = bw_pct;
223
224         if (adapter->temp_dcb_cfg.bw_percentage[0][bwg_id] !=
225             adapter->dcb_cfg.bw_percentage[0][bwg_id]) {
226                 adapter->dcb_set_bitmap |= BIT_PG_RX;
227                 adapter->dcb_set_bitmap |= BIT_RESETLINK;
228         }
229 }
230
231 static void ixgbe_dcbnl_set_pg_tc_cfg_rx(struct net_device *netdev, int tc,
232                                          u8 prio, u8 bwg_id, u8 bw_pct,
233                                          u8 up_map)
234 {
235         struct ixgbe_adapter *adapter = netdev_priv(netdev);
236
237         if (prio != DCB_ATTR_VALUE_UNDEFINED)
238                 adapter->temp_dcb_cfg.tc_config[tc].path[1].prio_type = prio;
239         if (bwg_id != DCB_ATTR_VALUE_UNDEFINED)
240                 adapter->temp_dcb_cfg.tc_config[tc].path[1].bwg_id = bwg_id;
241         if (bw_pct != DCB_ATTR_VALUE_UNDEFINED)
242                 adapter->temp_dcb_cfg.tc_config[tc].path[1].bwg_percent =
243                         bw_pct;
244         if (up_map != DCB_ATTR_VALUE_UNDEFINED)
245                 adapter->temp_dcb_cfg.tc_config[tc].path[1].up_to_tc_bitmap =
246                         up_map;
247
248         if ((adapter->temp_dcb_cfg.tc_config[tc].path[1].prio_type !=
249              adapter->dcb_cfg.tc_config[tc].path[1].prio_type) ||
250             (adapter->temp_dcb_cfg.tc_config[tc].path[1].bwg_id !=
251              adapter->dcb_cfg.tc_config[tc].path[1].bwg_id) ||
252             (adapter->temp_dcb_cfg.tc_config[tc].path[1].bwg_percent !=
253              adapter->dcb_cfg.tc_config[tc].path[1].bwg_percent) ||
254             (adapter->temp_dcb_cfg.tc_config[tc].path[1].up_to_tc_bitmap !=
255              adapter->dcb_cfg.tc_config[tc].path[1].up_to_tc_bitmap)) {
256                 adapter->dcb_set_bitmap |= BIT_PG_RX;
257                 adapter->dcb_set_bitmap |= BIT_RESETLINK;
258         }
259 }
260
261 static void ixgbe_dcbnl_set_pg_bwg_cfg_rx(struct net_device *netdev, int bwg_id,
262                                           u8 bw_pct)
263 {
264         struct ixgbe_adapter *adapter = netdev_priv(netdev);
265
266         adapter->temp_dcb_cfg.bw_percentage[1][bwg_id] = bw_pct;
267
268         if (adapter->temp_dcb_cfg.bw_percentage[1][bwg_id] !=
269             adapter->dcb_cfg.bw_percentage[1][bwg_id]) {
270                 adapter->dcb_set_bitmap |= BIT_PG_RX;
271                 adapter->dcb_set_bitmap |= BIT_RESETLINK;
272         }
273 }
274
275 static void ixgbe_dcbnl_get_pg_tc_cfg_tx(struct net_device *netdev, int tc,
276                                          u8 *prio, u8 *bwg_id, u8 *bw_pct,
277                                          u8 *up_map)
278 {
279         struct ixgbe_adapter *adapter = netdev_priv(netdev);
280
281         *prio = adapter->dcb_cfg.tc_config[tc].path[0].prio_type;
282         *bwg_id = adapter->dcb_cfg.tc_config[tc].path[0].bwg_id;
283         *bw_pct = adapter->dcb_cfg.tc_config[tc].path[0].bwg_percent;
284         *up_map = adapter->dcb_cfg.tc_config[tc].path[0].up_to_tc_bitmap;
285 }
286
287 static void ixgbe_dcbnl_get_pg_bwg_cfg_tx(struct net_device *netdev, int bwg_id,
288                                           u8 *bw_pct)
289 {
290         struct ixgbe_adapter *adapter = netdev_priv(netdev);
291
292         *bw_pct = adapter->dcb_cfg.bw_percentage[0][bwg_id];
293 }
294
295 static void ixgbe_dcbnl_get_pg_tc_cfg_rx(struct net_device *netdev, int tc,
296                                          u8 *prio, u8 *bwg_id, u8 *bw_pct,
297                                          u8 *up_map)
298 {
299         struct ixgbe_adapter *adapter = netdev_priv(netdev);
300
301         *prio = adapter->dcb_cfg.tc_config[tc].path[1].prio_type;
302         *bwg_id = adapter->dcb_cfg.tc_config[tc].path[1].bwg_id;
303         *bw_pct = adapter->dcb_cfg.tc_config[tc].path[1].bwg_percent;
304         *up_map = adapter->dcb_cfg.tc_config[tc].path[1].up_to_tc_bitmap;
305 }
306
307 static void ixgbe_dcbnl_get_pg_bwg_cfg_rx(struct net_device *netdev, int bwg_id,
308                                           u8 *bw_pct)
309 {
310         struct ixgbe_adapter *adapter = netdev_priv(netdev);
311
312         *bw_pct = adapter->dcb_cfg.bw_percentage[1][bwg_id];
313 }
314
315 static void ixgbe_dcbnl_set_pfc_cfg(struct net_device *netdev, int priority,
316                                     u8 setting)
317 {
318         struct ixgbe_adapter *adapter = netdev_priv(netdev);
319
320         adapter->temp_dcb_cfg.tc_config[priority].dcb_pfc = setting;
321         if (adapter->temp_dcb_cfg.tc_config[priority].dcb_pfc !=
322             adapter->dcb_cfg.tc_config[priority].dcb_pfc) {
323                 adapter->dcb_set_bitmap |= BIT_PFC;
324                 adapter->temp_dcb_cfg.pfc_mode_enable = true;
325         }
326 }
327
328 static void ixgbe_dcbnl_get_pfc_cfg(struct net_device *netdev, int priority,
329                                     u8 *setting)
330 {
331         struct ixgbe_adapter *adapter = netdev_priv(netdev);
332
333         *setting = adapter->dcb_cfg.tc_config[priority].dcb_pfc;
334 }
335
336 static u8 ixgbe_dcbnl_set_all(struct net_device *netdev)
337 {
338         struct ixgbe_adapter *adapter = netdev_priv(netdev);
339         int ret;
340
341         if (!adapter->dcb_set_bitmap)
342                 return DCB_NO_HW_CHG;
343
344         /*
345          * Only take down the adapter if the configuration change
346          * requires a reset.
347          */
348         if (adapter->dcb_set_bitmap & BIT_RESETLINK) {
349                 while (test_and_set_bit(__IXGBE_RESETTING, &adapter->state))
350                         msleep(1);
351
352                 if (adapter->dcb_set_bitmap & BIT_APP_UPCHG) {
353                         if (netif_running(netdev))
354                                 netdev->netdev_ops->ndo_stop(netdev);
355                         ixgbe_clear_interrupt_scheme(adapter);
356                 } else {
357                         if (netif_running(netdev))
358                                 ixgbe_down(adapter);
359                 }
360         }
361
362         ret = ixgbe_copy_dcb_cfg(&adapter->temp_dcb_cfg, &adapter->dcb_cfg,
363                                  adapter->ring_feature[RING_F_DCB].indices);
364         if (ret) {
365                 if (adapter->dcb_set_bitmap & BIT_RESETLINK)
366                         clear_bit(__IXGBE_RESETTING, &adapter->state);
367                 return DCB_NO_HW_CHG;
368         }
369
370         if (adapter->dcb_cfg.pfc_mode_enable) {
371                 if ((adapter->hw.mac.type != ixgbe_mac_82598EB) &&
372                         (adapter->hw.fc.current_mode != ixgbe_fc_pfc))
373                         adapter->last_lfc_mode = adapter->hw.fc.current_mode;
374                 adapter->hw.fc.requested_mode = ixgbe_fc_pfc;
375         } else {
376                 if (adapter->hw.mac.type != ixgbe_mac_82598EB)
377                         adapter->hw.fc.requested_mode = adapter->last_lfc_mode;
378                 else
379                         adapter->hw.fc.requested_mode = ixgbe_fc_none;
380         }
381
382         if (adapter->dcb_set_bitmap & BIT_RESETLINK) {
383                 if (adapter->dcb_set_bitmap & BIT_APP_UPCHG) {
384                         ixgbe_init_interrupt_scheme(adapter);
385                         if (netif_running(netdev))
386                                 netdev->netdev_ops->ndo_open(netdev);
387                 } else {
388                         if (netif_running(netdev))
389                                 ixgbe_up(adapter);
390                 }
391                 ret = DCB_HW_CHG_RST;
392         } else if (adapter->dcb_set_bitmap & BIT_PFC) {
393                 if (adapter->hw.mac.type == ixgbe_mac_82598EB)
394                         ixgbe_dcb_config_pfc_82598(&adapter->hw,
395                                                    &adapter->dcb_cfg);
396                 else if (adapter->hw.mac.type == ixgbe_mac_82599EB)
397                         ixgbe_dcb_config_pfc_82599(&adapter->hw,
398                                                    &adapter->dcb_cfg);
399                 ret = DCB_HW_CHG;
400         }
401         if (adapter->dcb_cfg.pfc_mode_enable)
402                 adapter->hw.fc.current_mode = ixgbe_fc_pfc;
403
404         if (adapter->dcb_set_bitmap & BIT_RESETLINK)
405                 clear_bit(__IXGBE_RESETTING, &adapter->state);
406         adapter->dcb_set_bitmap = 0x00;
407         return ret;
408 }
409
410 static u8 ixgbe_dcbnl_getcap(struct net_device *netdev, int capid, u8 *cap)
411 {
412         struct ixgbe_adapter *adapter = netdev_priv(netdev);
413         u8 rval = 0;
414
415         if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
416                 switch (capid) {
417                 case DCB_CAP_ATTR_PG:
418                         *cap = true;
419                         break;
420                 case DCB_CAP_ATTR_PFC:
421                         *cap = true;
422                         break;
423                 case DCB_CAP_ATTR_UP2TC:
424                         *cap = false;
425                         break;
426                 case DCB_CAP_ATTR_PG_TCS:
427                         *cap = 0x80;
428                         break;
429                 case DCB_CAP_ATTR_PFC_TCS:
430                         *cap = 0x80;
431                         break;
432                 case DCB_CAP_ATTR_GSP:
433                         *cap = true;
434                         break;
435                 case DCB_CAP_ATTR_BCN:
436                         *cap = false;
437                         break;
438                 default:
439                         rval = -EINVAL;
440                         break;
441                 }
442         } else {
443                 rval = -EINVAL;
444         }
445
446         return rval;
447 }
448
449 static u8 ixgbe_dcbnl_getnumtcs(struct net_device *netdev, int tcid, u8 *num)
450 {
451         struct ixgbe_adapter *adapter = netdev_priv(netdev);
452         u8 rval = 0;
453
454         if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
455                 switch (tcid) {
456                 case DCB_NUMTCS_ATTR_PG:
457                         *num = MAX_TRAFFIC_CLASS;
458                         break;
459                 case DCB_NUMTCS_ATTR_PFC:
460                         *num = MAX_TRAFFIC_CLASS;
461                         break;
462                 default:
463                         rval = -EINVAL;
464                         break;
465                 }
466         } else {
467                 rval = -EINVAL;
468         }
469
470         return rval;
471 }
472
473 static u8 ixgbe_dcbnl_setnumtcs(struct net_device *netdev, int tcid, u8 num)
474 {
475         return -EINVAL;
476 }
477
478 static u8 ixgbe_dcbnl_getpfcstate(struct net_device *netdev)
479 {
480         struct ixgbe_adapter *adapter = netdev_priv(netdev);
481
482         return adapter->dcb_cfg.pfc_mode_enable;
483 }
484
485 static void ixgbe_dcbnl_setpfcstate(struct net_device *netdev, u8 state)
486 {
487         struct ixgbe_adapter *adapter = netdev_priv(netdev);
488
489         adapter->temp_dcb_cfg.pfc_mode_enable = state;
490         if (adapter->temp_dcb_cfg.pfc_mode_enable !=
491                 adapter->dcb_cfg.pfc_mode_enable)
492                 adapter->dcb_set_bitmap |= BIT_PFC;
493         return;
494 }
495
496 /**
497  * ixgbe_dcbnl_getapp - retrieve the DCBX application user priority
498  * @netdev : the corresponding netdev
499  * @idtype : identifies the id as ether type or TCP/UDP port number
500  * @id: id is either ether type or TCP/UDP port number
501  *
502  * Returns : on success, returns a non-zero 802.1p user priority bitmap
503  * otherwise returns 0 as the invalid user priority bitmap to indicate an
504  * error.
505  */
506 static u8 ixgbe_dcbnl_getapp(struct net_device *netdev, u8 idtype, u16 id)
507 {
508         u8 rval = 0;
509
510         switch (idtype) {
511         case DCB_APP_IDTYPE_ETHTYPE:
512 #ifdef IXGBE_FCOE
513                 if (id == ETH_P_FCOE)
514                         rval = ixgbe_fcoe_getapp(netdev_priv(netdev));
515 #endif
516                 break;
517         case DCB_APP_IDTYPE_PORTNUM:
518                 break;
519         default:
520                 break;
521         }
522         return rval;
523 }
524
525 /**
526  * ixgbe_dcbnl_setapp - set the DCBX application user priority
527  * @netdev : the corresponding netdev
528  * @idtype : identifies the id as ether type or TCP/UDP port number
529  * @id: id is either ether type or TCP/UDP port number
530  * @up: the 802.1p user priority bitmap
531  *
532  * Returns : 0 on success or 1 on error
533  */
534 static u8 ixgbe_dcbnl_setapp(struct net_device *netdev,
535                              u8 idtype, u16 id, u8 up)
536 {
537         u8 rval = 1;
538
539         switch (idtype) {
540         case DCB_APP_IDTYPE_ETHTYPE:
541 #ifdef IXGBE_FCOE
542                 if (id == ETH_P_FCOE) {
543                         u8 tc;
544                         struct ixgbe_adapter *adapter;
545
546                         adapter = netdev_priv(netdev);
547                         tc = adapter->fcoe.tc;
548                         rval = ixgbe_fcoe_setapp(adapter, up);
549                         if ((!rval) && (tc != adapter->fcoe.tc) &&
550                             (adapter->flags & IXGBE_FLAG_DCB_ENABLED) &&
551                             (adapter->flags & IXGBE_FLAG_FCOE_ENABLED)) {
552                                 adapter->dcb_set_bitmap |= BIT_APP_UPCHG;
553                                 adapter->dcb_set_bitmap |= BIT_RESETLINK;
554                         }
555                 }
556 #endif
557                 break;
558         case DCB_APP_IDTYPE_PORTNUM:
559                 break;
560         default:
561                 break;
562         }
563         return rval;
564 }
565
566 const struct dcbnl_rtnl_ops dcbnl_ops = {
567         .getstate       = ixgbe_dcbnl_get_state,
568         .setstate       = ixgbe_dcbnl_set_state,
569         .getpermhwaddr  = ixgbe_dcbnl_get_perm_hw_addr,
570         .setpgtccfgtx   = ixgbe_dcbnl_set_pg_tc_cfg_tx,
571         .setpgbwgcfgtx  = ixgbe_dcbnl_set_pg_bwg_cfg_tx,
572         .setpgtccfgrx   = ixgbe_dcbnl_set_pg_tc_cfg_rx,
573         .setpgbwgcfgrx  = ixgbe_dcbnl_set_pg_bwg_cfg_rx,
574         .getpgtccfgtx   = ixgbe_dcbnl_get_pg_tc_cfg_tx,
575         .getpgbwgcfgtx  = ixgbe_dcbnl_get_pg_bwg_cfg_tx,
576         .getpgtccfgrx   = ixgbe_dcbnl_get_pg_tc_cfg_rx,
577         .getpgbwgcfgrx  = ixgbe_dcbnl_get_pg_bwg_cfg_rx,
578         .setpfccfg      = ixgbe_dcbnl_set_pfc_cfg,
579         .getpfccfg      = ixgbe_dcbnl_get_pfc_cfg,
580         .setall         = ixgbe_dcbnl_set_all,
581         .getcap         = ixgbe_dcbnl_getcap,
582         .getnumtcs      = ixgbe_dcbnl_getnumtcs,
583         .setnumtcs      = ixgbe_dcbnl_setnumtcs,
584         .getpfcstate    = ixgbe_dcbnl_getpfcstate,
585         .setpfcstate    = ixgbe_dcbnl_setpfcstate,
586         .getapp         = ixgbe_dcbnl_getapp,
587         .setapp         = ixgbe_dcbnl_setapp,
588 };
589