1 /*******************************************************************************
3 Intel 10 Gigabit PCI Express Linux driver
4 Copyright(c) 1999 - 2012 Intel Corporation.
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.
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
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.
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
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
27 *******************************************************************************/
30 #include <linux/dcbnl.h>
31 #include "ixgbe_dcb_82598.h"
32 #include "ixgbe_dcb_82599.h"
34 /* Callbacks for DCB netlink in the kernel */
35 #define BIT_DCB_MODE 0x01
37 #define BIT_PG_RX 0x04
38 #define BIT_PG_TX 0x08
39 #define BIT_APP_UPCHG 0x10
40 #define BIT_LINKSPEED 0x80
42 /* Responses for the DCB_C_SET_ALL command */
43 #define DCB_HW_CHG_RST 0 /* DCB configuration changed with reset */
44 #define DCB_NO_HW_CHG 1 /* DCB configuration did not change */
45 #define DCB_HW_CHG 2 /* DCB configuration changed, no reset */
47 int ixgbe_copy_dcb_cfg(struct ixgbe_dcb_config *scfg,
48 struct ixgbe_dcb_config *dcfg, int tc_max)
50 struct tc_configuration *src = NULL;
51 struct tc_configuration *dst = NULL;
53 int tx = DCB_TX_CONFIG;
54 int rx = DCB_RX_CONFIG;
60 for (i = DCB_PG_ATTR_TC_0; i < tc_max + DCB_PG_ATTR_TC_0; i++) {
61 src = &scfg->tc_config[i - DCB_PG_ATTR_TC_0];
62 dst = &dcfg->tc_config[i - DCB_PG_ATTR_TC_0];
64 if (dst->path[tx].prio_type != src->path[tx].prio_type) {
65 dst->path[tx].prio_type = src->path[tx].prio_type;
69 if (dst->path[tx].bwg_id != src->path[tx].bwg_id) {
70 dst->path[tx].bwg_id = src->path[tx].bwg_id;
74 if (dst->path[tx].bwg_percent != src->path[tx].bwg_percent) {
75 dst->path[tx].bwg_percent = src->path[tx].bwg_percent;
79 if (dst->path[tx].up_to_tc_bitmap !=
80 src->path[tx].up_to_tc_bitmap) {
81 dst->path[tx].up_to_tc_bitmap =
82 src->path[tx].up_to_tc_bitmap;
83 changes |= (BIT_PG_TX | BIT_PFC | BIT_APP_UPCHG);
86 if (dst->path[rx].prio_type != src->path[rx].prio_type) {
87 dst->path[rx].prio_type = src->path[rx].prio_type;
91 if (dst->path[rx].bwg_id != src->path[rx].bwg_id) {
92 dst->path[rx].bwg_id = src->path[rx].bwg_id;
96 if (dst->path[rx].bwg_percent != src->path[rx].bwg_percent) {
97 dst->path[rx].bwg_percent = src->path[rx].bwg_percent;
101 if (dst->path[rx].up_to_tc_bitmap !=
102 src->path[rx].up_to_tc_bitmap) {
103 dst->path[rx].up_to_tc_bitmap =
104 src->path[rx].up_to_tc_bitmap;
105 changes |= (BIT_PG_RX | BIT_PFC | BIT_APP_UPCHG);
109 for (i = DCB_PG_ATTR_BW_ID_0; i < DCB_PG_ATTR_BW_ID_MAX; i++) {
110 j = i - DCB_PG_ATTR_BW_ID_0;
111 if (dcfg->bw_percentage[tx][j] != scfg->bw_percentage[tx][j]) {
112 dcfg->bw_percentage[tx][j] = scfg->bw_percentage[tx][j];
113 changes |= BIT_PG_TX;
115 if (dcfg->bw_percentage[rx][j] != scfg->bw_percentage[rx][j]) {
116 dcfg->bw_percentage[rx][j] = scfg->bw_percentage[rx][j];
117 changes |= BIT_PG_RX;
121 for (i = DCB_PFC_UP_ATTR_0; i < DCB_PFC_UP_ATTR_MAX; i++) {
122 j = i - DCB_PFC_UP_ATTR_0;
123 if (dcfg->tc_config[j].dcb_pfc != scfg->tc_config[j].dcb_pfc) {
124 dcfg->tc_config[j].dcb_pfc = scfg->tc_config[j].dcb_pfc;
129 if (dcfg->pfc_mode_enable != scfg->pfc_mode_enable) {
130 dcfg->pfc_mode_enable = scfg->pfc_mode_enable;
137 static u8 ixgbe_dcbnl_get_state(struct net_device *netdev)
139 struct ixgbe_adapter *adapter = netdev_priv(netdev);
141 return !!(adapter->flags & IXGBE_FLAG_DCB_ENABLED);
144 static u8 ixgbe_dcbnl_set_state(struct net_device *netdev, u8 state)
147 u8 prio_tc[MAX_USER_PRIORITY] = {0};
149 struct ixgbe_adapter *adapter = netdev_priv(netdev);
151 /* Fail command if not in CEE mode */
152 if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_CEE))
155 /* verify there is something to do, if not then exit */
156 if (!!state != !(adapter->flags & IXGBE_FLAG_DCB_ENABLED))
160 err = ixgbe_setup_tc(netdev, adapter->dcb_cfg.num_tcs.pg_tcs);
161 ixgbe_dcb_unpack_map(&adapter->dcb_cfg, DCB_TX_CONFIG, prio_tc);
163 err = ixgbe_setup_tc(netdev, 0);
169 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++)
170 netdev_set_prio_tc_map(netdev, i, prio_tc[i]);
176 static void ixgbe_dcbnl_get_perm_hw_addr(struct net_device *netdev,
179 struct ixgbe_adapter *adapter = netdev_priv(netdev);
182 memset(perm_addr, 0xff, MAX_ADDR_LEN);
184 for (i = 0; i < netdev->addr_len; i++)
185 perm_addr[i] = adapter->hw.mac.perm_addr[i];
187 switch (adapter->hw.mac.type) {
188 case ixgbe_mac_82599EB:
190 for (j = 0; j < netdev->addr_len; j++, i++)
191 perm_addr[i] = adapter->hw.mac.san_addr[j];
198 static void ixgbe_dcbnl_set_pg_tc_cfg_tx(struct net_device *netdev, int tc,
199 u8 prio, u8 bwg_id, u8 bw_pct,
202 struct ixgbe_adapter *adapter = netdev_priv(netdev);
204 if (prio != DCB_ATTR_VALUE_UNDEFINED)
205 adapter->temp_dcb_cfg.tc_config[tc].path[0].prio_type = prio;
206 if (bwg_id != DCB_ATTR_VALUE_UNDEFINED)
207 adapter->temp_dcb_cfg.tc_config[tc].path[0].bwg_id = bwg_id;
208 if (bw_pct != DCB_ATTR_VALUE_UNDEFINED)
209 adapter->temp_dcb_cfg.tc_config[tc].path[0].bwg_percent =
211 if (up_map != DCB_ATTR_VALUE_UNDEFINED)
212 adapter->temp_dcb_cfg.tc_config[tc].path[0].up_to_tc_bitmap =
216 static void ixgbe_dcbnl_set_pg_bwg_cfg_tx(struct net_device *netdev, int bwg_id,
219 struct ixgbe_adapter *adapter = netdev_priv(netdev);
221 adapter->temp_dcb_cfg.bw_percentage[0][bwg_id] = bw_pct;
224 static void ixgbe_dcbnl_set_pg_tc_cfg_rx(struct net_device *netdev, int tc,
225 u8 prio, u8 bwg_id, u8 bw_pct,
228 struct ixgbe_adapter *adapter = netdev_priv(netdev);
230 if (prio != DCB_ATTR_VALUE_UNDEFINED)
231 adapter->temp_dcb_cfg.tc_config[tc].path[1].prio_type = prio;
232 if (bwg_id != DCB_ATTR_VALUE_UNDEFINED)
233 adapter->temp_dcb_cfg.tc_config[tc].path[1].bwg_id = bwg_id;
234 if (bw_pct != DCB_ATTR_VALUE_UNDEFINED)
235 adapter->temp_dcb_cfg.tc_config[tc].path[1].bwg_percent =
237 if (up_map != DCB_ATTR_VALUE_UNDEFINED)
238 adapter->temp_dcb_cfg.tc_config[tc].path[1].up_to_tc_bitmap =
242 static void ixgbe_dcbnl_set_pg_bwg_cfg_rx(struct net_device *netdev, int bwg_id,
245 struct ixgbe_adapter *adapter = netdev_priv(netdev);
247 adapter->temp_dcb_cfg.bw_percentage[1][bwg_id] = bw_pct;
250 static void ixgbe_dcbnl_get_pg_tc_cfg_tx(struct net_device *netdev, int tc,
251 u8 *prio, u8 *bwg_id, u8 *bw_pct,
254 struct ixgbe_adapter *adapter = netdev_priv(netdev);
256 *prio = adapter->dcb_cfg.tc_config[tc].path[0].prio_type;
257 *bwg_id = adapter->dcb_cfg.tc_config[tc].path[0].bwg_id;
258 *bw_pct = adapter->dcb_cfg.tc_config[tc].path[0].bwg_percent;
259 *up_map = adapter->dcb_cfg.tc_config[tc].path[0].up_to_tc_bitmap;
262 static void ixgbe_dcbnl_get_pg_bwg_cfg_tx(struct net_device *netdev, int bwg_id,
265 struct ixgbe_adapter *adapter = netdev_priv(netdev);
267 *bw_pct = adapter->dcb_cfg.bw_percentage[0][bwg_id];
270 static void ixgbe_dcbnl_get_pg_tc_cfg_rx(struct net_device *netdev, int tc,
271 u8 *prio, u8 *bwg_id, u8 *bw_pct,
274 struct ixgbe_adapter *adapter = netdev_priv(netdev);
276 *prio = adapter->dcb_cfg.tc_config[tc].path[1].prio_type;
277 *bwg_id = adapter->dcb_cfg.tc_config[tc].path[1].bwg_id;
278 *bw_pct = adapter->dcb_cfg.tc_config[tc].path[1].bwg_percent;
279 *up_map = adapter->dcb_cfg.tc_config[tc].path[1].up_to_tc_bitmap;
282 static void ixgbe_dcbnl_get_pg_bwg_cfg_rx(struct net_device *netdev, int bwg_id,
285 struct ixgbe_adapter *adapter = netdev_priv(netdev);
287 *bw_pct = adapter->dcb_cfg.bw_percentage[1][bwg_id];
290 static void ixgbe_dcbnl_set_pfc_cfg(struct net_device *netdev, int priority,
293 struct ixgbe_adapter *adapter = netdev_priv(netdev);
295 adapter->temp_dcb_cfg.tc_config[priority].dcb_pfc = setting;
296 if (adapter->temp_dcb_cfg.tc_config[priority].dcb_pfc !=
297 adapter->dcb_cfg.tc_config[priority].dcb_pfc)
298 adapter->temp_dcb_cfg.pfc_mode_enable = true;
301 static void ixgbe_dcbnl_get_pfc_cfg(struct net_device *netdev, int priority,
304 struct ixgbe_adapter *adapter = netdev_priv(netdev);
306 *setting = adapter->dcb_cfg.tc_config[priority].dcb_pfc;
310 static void ixgbe_dcbnl_devreset(struct net_device *dev)
312 struct ixgbe_adapter *adapter = netdev_priv(dev);
314 while (test_and_set_bit(__IXGBE_RESETTING, &adapter->state))
315 usleep_range(1000, 2000);
317 if (netif_running(dev))
318 dev->netdev_ops->ndo_stop(dev);
320 ixgbe_clear_interrupt_scheme(adapter);
321 ixgbe_init_interrupt_scheme(adapter);
323 if (netif_running(dev))
324 dev->netdev_ops->ndo_open(dev);
326 clear_bit(__IXGBE_RESETTING, &adapter->state);
330 static u8 ixgbe_dcbnl_set_all(struct net_device *netdev)
332 struct ixgbe_adapter *adapter = netdev_priv(netdev);
333 int ret = DCB_NO_HW_CHG;
336 struct dcb_app app = {
337 .selector = DCB_APP_IDTYPE_ETHTYPE,
338 .protocol = ETH_P_FCOE,
342 /* In IEEE mode, use the IEEE Ethertype selector value */
343 if (adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE) {
344 app.selector = IEEE_8021QAZ_APP_SEL_ETHERTYPE;
345 up = dcb_ieee_getapp_mask(netdev, &app);
347 up = dcb_getapp(netdev, &app);
351 /* Fail command if not in CEE mode */
352 if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_CEE))
355 adapter->dcb_set_bitmap |= ixgbe_copy_dcb_cfg(&adapter->temp_dcb_cfg,
358 if (!adapter->dcb_set_bitmap)
361 if (adapter->dcb_cfg.pfc_mode_enable) {
362 switch (adapter->hw.mac.type) {
363 case ixgbe_mac_82599EB:
365 if (adapter->hw.fc.current_mode != ixgbe_fc_pfc)
366 adapter->last_lfc_mode =
367 adapter->hw.fc.current_mode;
372 adapter->hw.fc.requested_mode = ixgbe_fc_pfc;
374 switch (adapter->hw.mac.type) {
375 case ixgbe_mac_82598EB:
376 adapter->hw.fc.requested_mode = ixgbe_fc_none;
378 case ixgbe_mac_82599EB:
380 adapter->hw.fc.requested_mode = adapter->last_lfc_mode;
387 if (adapter->dcb_set_bitmap & (BIT_PG_TX|BIT_PG_RX)) {
388 u16 refill[MAX_TRAFFIC_CLASS], max[MAX_TRAFFIC_CLASS];
389 u8 bwg_id[MAX_TRAFFIC_CLASS], prio_type[MAX_TRAFFIC_CLASS];
390 /* Priority to TC mapping in CEE case default to 1:1 */
391 u8 prio_tc[MAX_USER_PRIORITY];
392 int max_frame = adapter->netdev->mtu + ETH_HLEN + ETH_FCS_LEN;
395 if (adapter->netdev->features & NETIF_F_FCOE_MTU)
396 max_frame = max(max_frame, IXGBE_FCOE_JUMBO_FRAME_SIZE);
399 ixgbe_dcb_calculate_tc_credits(&adapter->hw, &adapter->dcb_cfg,
400 max_frame, DCB_TX_CONFIG);
401 ixgbe_dcb_calculate_tc_credits(&adapter->hw, &adapter->dcb_cfg,
402 max_frame, DCB_RX_CONFIG);
404 ixgbe_dcb_unpack_refill(&adapter->dcb_cfg,
405 DCB_TX_CONFIG, refill);
406 ixgbe_dcb_unpack_max(&adapter->dcb_cfg, max);
407 ixgbe_dcb_unpack_bwgid(&adapter->dcb_cfg,
408 DCB_TX_CONFIG, bwg_id);
409 ixgbe_dcb_unpack_prio(&adapter->dcb_cfg,
410 DCB_TX_CONFIG, prio_type);
411 ixgbe_dcb_unpack_map(&adapter->dcb_cfg,
412 DCB_TX_CONFIG, prio_tc);
414 ixgbe_dcb_hw_ets_config(&adapter->hw, refill, max,
415 bwg_id, prio_type, prio_tc);
417 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++)
418 netdev_set_prio_tc_map(netdev, i, prio_tc[i]);
420 ret = DCB_HW_CHG_RST;
423 if (adapter->dcb_set_bitmap & BIT_PFC) {
425 u8 prio_tc[MAX_USER_PRIORITY];
427 ixgbe_dcb_unpack_map(&adapter->dcb_cfg,
428 DCB_TX_CONFIG, prio_tc);
429 ixgbe_dcb_unpack_pfc(&adapter->dcb_cfg, &pfc_en);
430 ixgbe_dcb_hw_pfc_config(&adapter->hw, pfc_en, prio_tc);
431 if (ret != DCB_HW_CHG_RST)
435 if (adapter->dcb_cfg.pfc_mode_enable)
436 adapter->hw.fc.current_mode = ixgbe_fc_pfc;
439 /* Reprogam FCoE hardware offloads when the traffic class
440 * FCoE is using changes. This happens if the APP info
441 * changes or the up2tc mapping is updated.
443 if ((up && !(up & (1 << adapter->fcoe.up))) ||
444 (adapter->dcb_set_bitmap & BIT_APP_UPCHG)) {
445 adapter->fcoe.up = ffs(up) - 1;
446 ixgbe_dcbnl_devreset(netdev);
447 ret = DCB_HW_CHG_RST;
451 adapter->dcb_set_bitmap = 0x00;
455 static u8 ixgbe_dcbnl_getcap(struct net_device *netdev, int capid, u8 *cap)
457 struct ixgbe_adapter *adapter = netdev_priv(netdev);
460 case DCB_CAP_ATTR_PG:
463 case DCB_CAP_ATTR_PFC:
466 case DCB_CAP_ATTR_UP2TC:
469 case DCB_CAP_ATTR_PG_TCS:
472 case DCB_CAP_ATTR_PFC_TCS:
475 case DCB_CAP_ATTR_GSP:
478 case DCB_CAP_ATTR_BCN:
481 case DCB_CAP_ATTR_DCBX:
482 *cap = adapter->dcbx_cap;
492 static int ixgbe_dcbnl_getnumtcs(struct net_device *netdev, int tcid, u8 *num)
494 struct ixgbe_adapter *adapter = netdev_priv(netdev);
497 if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
499 case DCB_NUMTCS_ATTR_PG:
500 *num = adapter->dcb_cfg.num_tcs.pg_tcs;
502 case DCB_NUMTCS_ATTR_PFC:
503 *num = adapter->dcb_cfg.num_tcs.pfc_tcs;
516 static int ixgbe_dcbnl_setnumtcs(struct net_device *netdev, int tcid, u8 num)
521 static u8 ixgbe_dcbnl_getpfcstate(struct net_device *netdev)
523 struct ixgbe_adapter *adapter = netdev_priv(netdev);
525 return adapter->dcb_cfg.pfc_mode_enable;
528 static void ixgbe_dcbnl_setpfcstate(struct net_device *netdev, u8 state)
530 struct ixgbe_adapter *adapter = netdev_priv(netdev);
532 adapter->temp_dcb_cfg.pfc_mode_enable = state;
536 * ixgbe_dcbnl_getapp - retrieve the DCBX application user priority
537 * @netdev : the corresponding netdev
538 * @idtype : identifies the id as ether type or TCP/UDP port number
539 * @id: id is either ether type or TCP/UDP port number
541 * Returns : on success, returns a non-zero 802.1p user priority bitmap
542 * otherwise returns 0 as the invalid user priority bitmap to indicate an
545 static u8 ixgbe_dcbnl_getapp(struct net_device *netdev, u8 idtype, u16 id)
547 struct ixgbe_adapter *adapter = netdev_priv(netdev);
548 struct dcb_app app = {
553 if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_CEE))
556 return dcb_getapp(netdev, &app);
559 static int ixgbe_dcbnl_ieee_getets(struct net_device *dev,
560 struct ieee_ets *ets)
562 struct ixgbe_adapter *adapter = netdev_priv(dev);
563 struct ieee_ets *my_ets = adapter->ixgbe_ieee_ets;
565 ets->ets_cap = adapter->dcb_cfg.num_tcs.pg_tcs;
567 /* No IEEE PFC settings available */
571 ets->cbs = my_ets->cbs;
572 memcpy(ets->tc_tx_bw, my_ets->tc_tx_bw, sizeof(ets->tc_tx_bw));
573 memcpy(ets->tc_rx_bw, my_ets->tc_rx_bw, sizeof(ets->tc_rx_bw));
574 memcpy(ets->tc_tsa, my_ets->tc_tsa, sizeof(ets->tc_tsa));
575 memcpy(ets->prio_tc, my_ets->prio_tc, sizeof(ets->prio_tc));
579 static int ixgbe_dcbnl_ieee_setets(struct net_device *dev,
580 struct ieee_ets *ets)
582 struct ixgbe_adapter *adapter = netdev_priv(dev);
583 int max_frame = dev->mtu + ETH_HLEN + ETH_FCS_LEN;
587 if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE))
590 if (!adapter->ixgbe_ieee_ets) {
591 adapter->ixgbe_ieee_ets = kmalloc(sizeof(struct ieee_ets),
593 if (!adapter->ixgbe_ieee_ets)
597 memcpy(adapter->ixgbe_ieee_ets, ets, sizeof(*adapter->ixgbe_ieee_ets));
599 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
600 if (ets->prio_tc[i] > max_tc)
601 max_tc = ets->prio_tc[i];
607 if (max_tc > adapter->dcb_cfg.num_tcs.pg_tcs)
610 if (max_tc != netdev_get_num_tc(dev))
611 err = ixgbe_setup_tc(dev, max_tc);
616 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++)
617 netdev_set_prio_tc_map(dev, i, ets->prio_tc[i]);
619 err = ixgbe_dcb_hw_ets(&adapter->hw, ets, max_frame);
624 static int ixgbe_dcbnl_ieee_getpfc(struct net_device *dev,
625 struct ieee_pfc *pfc)
627 struct ixgbe_adapter *adapter = netdev_priv(dev);
628 struct ieee_pfc *my_pfc = adapter->ixgbe_ieee_pfc;
631 pfc->pfc_cap = adapter->dcb_cfg.num_tcs.pfc_tcs;
633 /* No IEEE PFC settings available */
637 pfc->pfc_en = my_pfc->pfc_en;
638 pfc->mbc = my_pfc->mbc;
639 pfc->delay = my_pfc->delay;
641 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
642 pfc->requests[i] = adapter->stats.pxoffrxc[i];
643 pfc->indications[i] = adapter->stats.pxofftxc[i];
649 static int ixgbe_dcbnl_ieee_setpfc(struct net_device *dev,
650 struct ieee_pfc *pfc)
652 struct ixgbe_adapter *adapter = netdev_priv(dev);
655 if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE))
658 if (!adapter->ixgbe_ieee_pfc) {
659 adapter->ixgbe_ieee_pfc = kmalloc(sizeof(struct ieee_pfc),
661 if (!adapter->ixgbe_ieee_pfc)
665 prio_tc = adapter->ixgbe_ieee_ets->prio_tc;
666 memcpy(adapter->ixgbe_ieee_pfc, pfc, sizeof(*adapter->ixgbe_ieee_pfc));
667 return ixgbe_dcb_hw_pfc_config(&adapter->hw, pfc->pfc_en, prio_tc);
670 static int ixgbe_dcbnl_ieee_setapp(struct net_device *dev,
673 struct ixgbe_adapter *adapter = netdev_priv(dev);
676 if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE))
679 err = dcb_ieee_setapp(dev, app);
682 if (!err && app->selector == IEEE_8021QAZ_APP_SEL_ETHERTYPE &&
683 app->protocol == ETH_P_FCOE) {
684 u8 app_mask = dcb_ieee_getapp_mask(dev, app);
686 if (app_mask & (1 << adapter->fcoe.up))
689 adapter->fcoe.up = app->priority;
690 ixgbe_dcbnl_devreset(dev);
696 static int ixgbe_dcbnl_ieee_delapp(struct net_device *dev,
699 struct ixgbe_adapter *adapter = netdev_priv(dev);
702 if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE))
705 err = dcb_ieee_delapp(dev, app);
708 if (!err && app->selector == IEEE_8021QAZ_APP_SEL_ETHERTYPE &&
709 app->protocol == ETH_P_FCOE) {
710 u8 app_mask = dcb_ieee_getapp_mask(dev, app);
712 if (app_mask & (1 << adapter->fcoe.up))
715 adapter->fcoe.up = app_mask ?
716 ffs(app_mask) - 1 : IXGBE_FCOE_DEFTC;
717 ixgbe_dcbnl_devreset(dev);
723 static u8 ixgbe_dcbnl_getdcbx(struct net_device *dev)
725 struct ixgbe_adapter *adapter = netdev_priv(dev);
726 return adapter->dcbx_cap;
729 static u8 ixgbe_dcbnl_setdcbx(struct net_device *dev, u8 mode)
731 struct ixgbe_adapter *adapter = netdev_priv(dev);
732 struct ieee_ets ets = {0};
733 struct ieee_pfc pfc = {0};
736 /* no support for LLD_MANAGED modes or CEE+IEEE */
737 if ((mode & DCB_CAP_DCBX_LLD_MANAGED) ||
738 ((mode & DCB_CAP_DCBX_VER_IEEE) && (mode & DCB_CAP_DCBX_VER_CEE)) ||
739 !(mode & DCB_CAP_DCBX_HOST))
742 if (mode == adapter->dcbx_cap)
745 adapter->dcbx_cap = mode;
747 /* ETS and PFC defaults */
751 if (mode & DCB_CAP_DCBX_VER_IEEE) {
752 ixgbe_dcbnl_ieee_setets(dev, &ets);
753 ixgbe_dcbnl_ieee_setpfc(dev, &pfc);
754 } else if (mode & DCB_CAP_DCBX_VER_CEE) {
755 u8 mask = BIT_PFC | BIT_PG_TX | BIT_PG_RX | BIT_APP_UPCHG;
757 adapter->dcb_set_bitmap |= mask;
758 ixgbe_dcbnl_set_all(dev);
760 /* Drop into single TC mode strict priority as this
761 * indicates CEE and IEEE versions are disabled
763 ixgbe_dcbnl_ieee_setets(dev, &ets);
764 ixgbe_dcbnl_ieee_setpfc(dev, &pfc);
765 err = ixgbe_setup_tc(dev, 0);
771 const struct dcbnl_rtnl_ops dcbnl_ops = {
772 .ieee_getets = ixgbe_dcbnl_ieee_getets,
773 .ieee_setets = ixgbe_dcbnl_ieee_setets,
774 .ieee_getpfc = ixgbe_dcbnl_ieee_getpfc,
775 .ieee_setpfc = ixgbe_dcbnl_ieee_setpfc,
776 .ieee_setapp = ixgbe_dcbnl_ieee_setapp,
777 .ieee_delapp = ixgbe_dcbnl_ieee_delapp,
778 .getstate = ixgbe_dcbnl_get_state,
779 .setstate = ixgbe_dcbnl_set_state,
780 .getpermhwaddr = ixgbe_dcbnl_get_perm_hw_addr,
781 .setpgtccfgtx = ixgbe_dcbnl_set_pg_tc_cfg_tx,
782 .setpgbwgcfgtx = ixgbe_dcbnl_set_pg_bwg_cfg_tx,
783 .setpgtccfgrx = ixgbe_dcbnl_set_pg_tc_cfg_rx,
784 .setpgbwgcfgrx = ixgbe_dcbnl_set_pg_bwg_cfg_rx,
785 .getpgtccfgtx = ixgbe_dcbnl_get_pg_tc_cfg_tx,
786 .getpgbwgcfgtx = ixgbe_dcbnl_get_pg_bwg_cfg_tx,
787 .getpgtccfgrx = ixgbe_dcbnl_get_pg_tc_cfg_rx,
788 .getpgbwgcfgrx = ixgbe_dcbnl_get_pg_bwg_cfg_rx,
789 .setpfccfg = ixgbe_dcbnl_set_pfc_cfg,
790 .getpfccfg = ixgbe_dcbnl_get_pfc_cfg,
791 .setall = ixgbe_dcbnl_set_all,
792 .getcap = ixgbe_dcbnl_getcap,
793 .getnumtcs = ixgbe_dcbnl_getnumtcs,
794 .setnumtcs = ixgbe_dcbnl_setnumtcs,
795 .getpfcstate = ixgbe_dcbnl_getpfcstate,
796 .setpfcstate = ixgbe_dcbnl_setpfcstate,
797 .getapp = ixgbe_dcbnl_getapp,
798 .getdcbx = ixgbe_dcbnl_getdcbx,
799 .setdcbx = ixgbe_dcbnl_setdcbx,