1 /*******************************************************************************
3 Intel 10 Gigabit PCI Express Linux driver
4 Copyright(c) 1999 - 2011 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 *src_dcb_cfg,
48 struct ixgbe_dcb_config *dst_dcb_cfg, int tc_max)
50 struct tc_configuration *src_tc_cfg = NULL;
51 struct tc_configuration *dst_tc_cfg = NULL;
54 if (!src_dcb_cfg || !dst_dcb_cfg)
57 for (i = DCB_PG_ATTR_TC_0; i < tc_max + DCB_PG_ATTR_TC_0; i++) {
58 src_tc_cfg = &src_dcb_cfg->tc_config[i - DCB_PG_ATTR_TC_0];
59 dst_tc_cfg = &dst_dcb_cfg->tc_config[i - DCB_PG_ATTR_TC_0];
61 dst_tc_cfg->path[DCB_TX_CONFIG].prio_type =
62 src_tc_cfg->path[DCB_TX_CONFIG].prio_type;
64 dst_tc_cfg->path[DCB_TX_CONFIG].bwg_id =
65 src_tc_cfg->path[DCB_TX_CONFIG].bwg_id;
67 dst_tc_cfg->path[DCB_TX_CONFIG].bwg_percent =
68 src_tc_cfg->path[DCB_TX_CONFIG].bwg_percent;
70 dst_tc_cfg->path[DCB_TX_CONFIG].up_to_tc_bitmap =
71 src_tc_cfg->path[DCB_TX_CONFIG].up_to_tc_bitmap;
73 dst_tc_cfg->path[DCB_RX_CONFIG].prio_type =
74 src_tc_cfg->path[DCB_RX_CONFIG].prio_type;
76 dst_tc_cfg->path[DCB_RX_CONFIG].bwg_id =
77 src_tc_cfg->path[DCB_RX_CONFIG].bwg_id;
79 dst_tc_cfg->path[DCB_RX_CONFIG].bwg_percent =
80 src_tc_cfg->path[DCB_RX_CONFIG].bwg_percent;
82 dst_tc_cfg->path[DCB_RX_CONFIG].up_to_tc_bitmap =
83 src_tc_cfg->path[DCB_RX_CONFIG].up_to_tc_bitmap;
86 for (i = DCB_PG_ATTR_BW_ID_0; i < DCB_PG_ATTR_BW_ID_MAX; i++) {
87 dst_dcb_cfg->bw_percentage[DCB_TX_CONFIG]
88 [i-DCB_PG_ATTR_BW_ID_0] = src_dcb_cfg->bw_percentage
89 [DCB_TX_CONFIG][i-DCB_PG_ATTR_BW_ID_0];
90 dst_dcb_cfg->bw_percentage[DCB_RX_CONFIG]
91 [i-DCB_PG_ATTR_BW_ID_0] = src_dcb_cfg->bw_percentage
92 [DCB_RX_CONFIG][i-DCB_PG_ATTR_BW_ID_0];
95 for (i = DCB_PFC_UP_ATTR_0; i < DCB_PFC_UP_ATTR_MAX; i++) {
96 dst_dcb_cfg->tc_config[i - DCB_PFC_UP_ATTR_0].dcb_pfc =
97 src_dcb_cfg->tc_config[i - DCB_PFC_UP_ATTR_0].dcb_pfc;
100 dst_dcb_cfg->pfc_mode_enable = src_dcb_cfg->pfc_mode_enable;
105 static u8 ixgbe_dcbnl_get_state(struct net_device *netdev)
107 struct ixgbe_adapter *adapter = netdev_priv(netdev);
109 return !!(adapter->flags & IXGBE_FLAG_DCB_ENABLED);
112 static u8 ixgbe_dcbnl_set_state(struct net_device *netdev, u8 state)
115 struct ixgbe_adapter *adapter = netdev_priv(netdev);
117 /* Fail command if not in CEE mode */
118 if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_CEE))
121 /* verify there is something to do, if not then exit */
122 if (!!state != !(adapter->flags & IXGBE_FLAG_DCB_ENABLED))
126 err = ixgbe_setup_tc(netdev, MAX_TRAFFIC_CLASS);
128 err = ixgbe_setup_tc(netdev, 0);
133 static void ixgbe_dcbnl_get_perm_hw_addr(struct net_device *netdev,
136 struct ixgbe_adapter *adapter = netdev_priv(netdev);
139 memset(perm_addr, 0xff, MAX_ADDR_LEN);
141 for (i = 0; i < netdev->addr_len; i++)
142 perm_addr[i] = adapter->hw.mac.perm_addr[i];
144 switch (adapter->hw.mac.type) {
145 case ixgbe_mac_82599EB:
147 for (j = 0; j < netdev->addr_len; j++, i++)
148 perm_addr[i] = adapter->hw.mac.san_addr[j];
155 static void ixgbe_dcbnl_set_pg_tc_cfg_tx(struct net_device *netdev, int tc,
156 u8 prio, u8 bwg_id, u8 bw_pct,
159 struct ixgbe_adapter *adapter = netdev_priv(netdev);
161 if (prio != DCB_ATTR_VALUE_UNDEFINED)
162 adapter->temp_dcb_cfg.tc_config[tc].path[0].prio_type = prio;
163 if (bwg_id != DCB_ATTR_VALUE_UNDEFINED)
164 adapter->temp_dcb_cfg.tc_config[tc].path[0].bwg_id = bwg_id;
165 if (bw_pct != DCB_ATTR_VALUE_UNDEFINED)
166 adapter->temp_dcb_cfg.tc_config[tc].path[0].bwg_percent =
168 if (up_map != DCB_ATTR_VALUE_UNDEFINED)
169 adapter->temp_dcb_cfg.tc_config[tc].path[0].up_to_tc_bitmap =
172 if ((adapter->temp_dcb_cfg.tc_config[tc].path[0].prio_type !=
173 adapter->dcb_cfg.tc_config[tc].path[0].prio_type) ||
174 (adapter->temp_dcb_cfg.tc_config[tc].path[0].bwg_id !=
175 adapter->dcb_cfg.tc_config[tc].path[0].bwg_id) ||
176 (adapter->temp_dcb_cfg.tc_config[tc].path[0].bwg_percent !=
177 adapter->dcb_cfg.tc_config[tc].path[0].bwg_percent) ||
178 (adapter->temp_dcb_cfg.tc_config[tc].path[0].up_to_tc_bitmap !=
179 adapter->dcb_cfg.tc_config[tc].path[0].up_to_tc_bitmap))
180 adapter->dcb_set_bitmap |= BIT_PG_TX;
183 static void ixgbe_dcbnl_set_pg_bwg_cfg_tx(struct net_device *netdev, int bwg_id,
186 struct ixgbe_adapter *adapter = netdev_priv(netdev);
188 adapter->temp_dcb_cfg.bw_percentage[0][bwg_id] = bw_pct;
190 if (adapter->temp_dcb_cfg.bw_percentage[0][bwg_id] !=
191 adapter->dcb_cfg.bw_percentage[0][bwg_id])
192 adapter->dcb_set_bitmap |= BIT_PG_TX;
195 static void ixgbe_dcbnl_set_pg_tc_cfg_rx(struct net_device *netdev, int tc,
196 u8 prio, u8 bwg_id, u8 bw_pct,
199 struct ixgbe_adapter *adapter = netdev_priv(netdev);
201 if (prio != DCB_ATTR_VALUE_UNDEFINED)
202 adapter->temp_dcb_cfg.tc_config[tc].path[1].prio_type = prio;
203 if (bwg_id != DCB_ATTR_VALUE_UNDEFINED)
204 adapter->temp_dcb_cfg.tc_config[tc].path[1].bwg_id = bwg_id;
205 if (bw_pct != DCB_ATTR_VALUE_UNDEFINED)
206 adapter->temp_dcb_cfg.tc_config[tc].path[1].bwg_percent =
208 if (up_map != DCB_ATTR_VALUE_UNDEFINED)
209 adapter->temp_dcb_cfg.tc_config[tc].path[1].up_to_tc_bitmap =
212 if ((adapter->temp_dcb_cfg.tc_config[tc].path[1].prio_type !=
213 adapter->dcb_cfg.tc_config[tc].path[1].prio_type) ||
214 (adapter->temp_dcb_cfg.tc_config[tc].path[1].bwg_id !=
215 adapter->dcb_cfg.tc_config[tc].path[1].bwg_id) ||
216 (adapter->temp_dcb_cfg.tc_config[tc].path[1].bwg_percent !=
217 adapter->dcb_cfg.tc_config[tc].path[1].bwg_percent) ||
218 (adapter->temp_dcb_cfg.tc_config[tc].path[1].up_to_tc_bitmap !=
219 adapter->dcb_cfg.tc_config[tc].path[1].up_to_tc_bitmap))
220 adapter->dcb_set_bitmap |= BIT_PG_RX;
223 static void ixgbe_dcbnl_set_pg_bwg_cfg_rx(struct net_device *netdev, int bwg_id,
226 struct ixgbe_adapter *adapter = netdev_priv(netdev);
228 adapter->temp_dcb_cfg.bw_percentage[1][bwg_id] = bw_pct;
230 if (adapter->temp_dcb_cfg.bw_percentage[1][bwg_id] !=
231 adapter->dcb_cfg.bw_percentage[1][bwg_id])
232 adapter->dcb_set_bitmap |= BIT_PG_RX;
235 static void ixgbe_dcbnl_get_pg_tc_cfg_tx(struct net_device *netdev, int tc,
236 u8 *prio, u8 *bwg_id, u8 *bw_pct,
239 struct ixgbe_adapter *adapter = netdev_priv(netdev);
241 *prio = adapter->dcb_cfg.tc_config[tc].path[0].prio_type;
242 *bwg_id = adapter->dcb_cfg.tc_config[tc].path[0].bwg_id;
243 *bw_pct = adapter->dcb_cfg.tc_config[tc].path[0].bwg_percent;
244 *up_map = adapter->dcb_cfg.tc_config[tc].path[0].up_to_tc_bitmap;
247 static void ixgbe_dcbnl_get_pg_bwg_cfg_tx(struct net_device *netdev, int bwg_id,
250 struct ixgbe_adapter *adapter = netdev_priv(netdev);
252 *bw_pct = adapter->dcb_cfg.bw_percentage[0][bwg_id];
255 static void ixgbe_dcbnl_get_pg_tc_cfg_rx(struct net_device *netdev, int tc,
256 u8 *prio, u8 *bwg_id, u8 *bw_pct,
259 struct ixgbe_adapter *adapter = netdev_priv(netdev);
261 *prio = adapter->dcb_cfg.tc_config[tc].path[1].prio_type;
262 *bwg_id = adapter->dcb_cfg.tc_config[tc].path[1].bwg_id;
263 *bw_pct = adapter->dcb_cfg.tc_config[tc].path[1].bwg_percent;
264 *up_map = adapter->dcb_cfg.tc_config[tc].path[1].up_to_tc_bitmap;
267 static void ixgbe_dcbnl_get_pg_bwg_cfg_rx(struct net_device *netdev, int bwg_id,
270 struct ixgbe_adapter *adapter = netdev_priv(netdev);
272 *bw_pct = adapter->dcb_cfg.bw_percentage[1][bwg_id];
275 static void ixgbe_dcbnl_set_pfc_cfg(struct net_device *netdev, int priority,
278 struct ixgbe_adapter *adapter = netdev_priv(netdev);
280 adapter->temp_dcb_cfg.tc_config[priority].dcb_pfc = setting;
281 if (adapter->temp_dcb_cfg.tc_config[priority].dcb_pfc !=
282 adapter->dcb_cfg.tc_config[priority].dcb_pfc) {
283 adapter->dcb_set_bitmap |= BIT_PFC;
284 adapter->temp_dcb_cfg.pfc_mode_enable = true;
288 static void ixgbe_dcbnl_get_pfc_cfg(struct net_device *netdev, int priority,
291 struct ixgbe_adapter *adapter = netdev_priv(netdev);
293 *setting = adapter->dcb_cfg.tc_config[priority].dcb_pfc;
296 static u8 ixgbe_dcbnl_set_all(struct net_device *netdev)
298 struct ixgbe_adapter *adapter = netdev_priv(netdev);
301 struct dcb_app app = {
302 .selector = DCB_APP_IDTYPE_ETHTYPE,
303 .protocol = ETH_P_FCOE,
305 u8 up = dcb_getapp(netdev, &app);
308 /* Fail command if not in CEE mode */
309 if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_CEE))
312 ret = ixgbe_copy_dcb_cfg(&adapter->temp_dcb_cfg, &adapter->dcb_cfg,
315 return DCB_NO_HW_CHG;
318 if (up && (up != (1 << adapter->fcoe.up)))
319 adapter->dcb_set_bitmap |= BIT_APP_UPCHG;
322 * Only take down the adapter if an app change occurred. FCoE
323 * may shuffle tx rings in this case and this can not be done
324 * without a reset currently.
326 if (adapter->dcb_set_bitmap & BIT_APP_UPCHG) {
327 while (test_and_set_bit(__IXGBE_RESETTING, &adapter->state))
328 usleep_range(1000, 2000);
330 adapter->fcoe.up = ffs(up) - 1;
332 if (netif_running(netdev))
333 netdev->netdev_ops->ndo_stop(netdev);
334 ixgbe_clear_interrupt_scheme(adapter);
338 if (adapter->dcb_cfg.pfc_mode_enable) {
339 switch (adapter->hw.mac.type) {
340 case ixgbe_mac_82599EB:
342 if (adapter->hw.fc.current_mode != ixgbe_fc_pfc)
343 adapter->last_lfc_mode =
344 adapter->hw.fc.current_mode;
349 adapter->hw.fc.requested_mode = ixgbe_fc_pfc;
351 switch (adapter->hw.mac.type) {
352 case ixgbe_mac_82598EB:
353 adapter->hw.fc.requested_mode = ixgbe_fc_none;
355 case ixgbe_mac_82599EB:
357 adapter->hw.fc.requested_mode = adapter->last_lfc_mode;
365 if (adapter->dcb_set_bitmap & BIT_APP_UPCHG) {
366 ixgbe_init_interrupt_scheme(adapter);
367 if (netif_running(netdev))
368 netdev->netdev_ops->ndo_open(netdev);
369 ret = DCB_HW_CHG_RST;
373 if (adapter->dcb_set_bitmap & BIT_PFC) {
375 ixgbe_dcb_unpack_pfc(&adapter->dcb_cfg, &pfc_en);
376 ixgbe_dcb_hw_pfc_config(&adapter->hw, pfc_en);
380 if (adapter->dcb_set_bitmap & (BIT_PG_TX|BIT_PG_RX)) {
381 u16 refill[MAX_TRAFFIC_CLASS], max[MAX_TRAFFIC_CLASS];
382 u8 bwg_id[MAX_TRAFFIC_CLASS], prio_type[MAX_TRAFFIC_CLASS];
383 /* Priority to TC mapping in CEE case default to 1:1 */
384 u8 prio_tc[MAX_TRAFFIC_CLASS] = {0, 1, 2, 3, 4, 5, 6, 7};
385 int max_frame = adapter->netdev->mtu + ETH_HLEN + ETH_FCS_LEN;
388 if (adapter->netdev->features & NETIF_F_FCOE_MTU)
389 max_frame = max(max_frame, IXGBE_FCOE_JUMBO_FRAME_SIZE);
392 ixgbe_dcb_calculate_tc_credits(&adapter->hw, &adapter->dcb_cfg,
393 max_frame, DCB_TX_CONFIG);
394 ixgbe_dcb_calculate_tc_credits(&adapter->hw, &adapter->dcb_cfg,
395 max_frame, DCB_RX_CONFIG);
397 ixgbe_dcb_unpack_refill(&adapter->dcb_cfg,
398 DCB_TX_CONFIG, refill);
399 ixgbe_dcb_unpack_max(&adapter->dcb_cfg, max);
400 ixgbe_dcb_unpack_bwgid(&adapter->dcb_cfg,
401 DCB_TX_CONFIG, bwg_id);
402 ixgbe_dcb_unpack_prio(&adapter->dcb_cfg,
403 DCB_TX_CONFIG, prio_type);
405 ixgbe_dcb_hw_ets_config(&adapter->hw, refill, max,
406 bwg_id, prio_type, prio_tc);
409 if (adapter->dcb_cfg.pfc_mode_enable)
410 adapter->hw.fc.current_mode = ixgbe_fc_pfc;
412 if (adapter->dcb_set_bitmap & BIT_APP_UPCHG)
413 clear_bit(__IXGBE_RESETTING, &adapter->state);
414 adapter->dcb_set_bitmap = 0x00;
418 static u8 ixgbe_dcbnl_getcap(struct net_device *netdev, int capid, u8 *cap)
420 struct ixgbe_adapter *adapter = netdev_priv(netdev);
423 case DCB_CAP_ATTR_PG:
426 case DCB_CAP_ATTR_PFC:
429 case DCB_CAP_ATTR_UP2TC:
432 case DCB_CAP_ATTR_PG_TCS:
435 case DCB_CAP_ATTR_PFC_TCS:
438 case DCB_CAP_ATTR_GSP:
441 case DCB_CAP_ATTR_BCN:
444 case DCB_CAP_ATTR_DCBX:
445 *cap = adapter->dcbx_cap;
455 static u8 ixgbe_dcbnl_getnumtcs(struct net_device *netdev, int tcid, u8 *num)
457 struct ixgbe_adapter *adapter = netdev_priv(netdev);
460 if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
462 case DCB_NUMTCS_ATTR_PG:
463 *num = MAX_TRAFFIC_CLASS;
465 case DCB_NUMTCS_ATTR_PFC:
466 *num = MAX_TRAFFIC_CLASS;
479 static u8 ixgbe_dcbnl_setnumtcs(struct net_device *netdev, int tcid, u8 num)
484 static u8 ixgbe_dcbnl_getpfcstate(struct net_device *netdev)
486 struct ixgbe_adapter *adapter = netdev_priv(netdev);
488 return adapter->dcb_cfg.pfc_mode_enable;
491 static void ixgbe_dcbnl_setpfcstate(struct net_device *netdev, u8 state)
493 struct ixgbe_adapter *adapter = netdev_priv(netdev);
495 adapter->temp_dcb_cfg.pfc_mode_enable = state;
496 if (adapter->temp_dcb_cfg.pfc_mode_enable !=
497 adapter->dcb_cfg.pfc_mode_enable)
498 adapter->dcb_set_bitmap |= BIT_PFC;
502 * ixgbe_dcbnl_getapp - retrieve the DCBX application user priority
503 * @netdev : the corresponding netdev
504 * @idtype : identifies the id as ether type or TCP/UDP port number
505 * @id: id is either ether type or TCP/UDP port number
507 * Returns : on success, returns a non-zero 802.1p user priority bitmap
508 * otherwise returns 0 as the invalid user priority bitmap to indicate an
511 static u8 ixgbe_dcbnl_getapp(struct net_device *netdev, u8 idtype, u16 id)
513 struct ixgbe_adapter *adapter = netdev_priv(netdev);
514 struct dcb_app app = {
519 if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_CEE))
522 return dcb_getapp(netdev, &app);
525 static int ixgbe_dcbnl_ieee_getets(struct net_device *dev,
526 struct ieee_ets *ets)
528 struct ixgbe_adapter *adapter = netdev_priv(dev);
529 struct ieee_ets *my_ets = adapter->ixgbe_ieee_ets;
531 /* No IEEE PFC settings available */
535 ets->ets_cap = MAX_TRAFFIC_CLASS;
536 ets->cbs = my_ets->cbs;
537 memcpy(ets->tc_tx_bw, my_ets->tc_tx_bw, sizeof(ets->tc_tx_bw));
538 memcpy(ets->tc_rx_bw, my_ets->tc_rx_bw, sizeof(ets->tc_rx_bw));
539 memcpy(ets->tc_tsa, my_ets->tc_tsa, sizeof(ets->tc_tsa));
540 memcpy(ets->prio_tc, my_ets->prio_tc, sizeof(ets->prio_tc));
544 static int ixgbe_dcbnl_ieee_setets(struct net_device *dev,
545 struct ieee_ets *ets)
547 struct ixgbe_adapter *adapter = netdev_priv(dev);
548 int max_frame = dev->mtu + ETH_HLEN + ETH_FCS_LEN;
552 if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE))
555 if (!adapter->ixgbe_ieee_ets) {
556 adapter->ixgbe_ieee_ets = kmalloc(sizeof(struct ieee_ets),
558 if (!adapter->ixgbe_ieee_ets)
562 memcpy(adapter->ixgbe_ieee_ets, ets, sizeof(*adapter->ixgbe_ieee_ets));
564 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
565 if (ets->prio_tc[i] > max_tc)
566 max_tc = ets->prio_tc[i];
572 if (max_tc != netdev_get_num_tc(dev))
573 ixgbe_setup_tc(dev, max_tc);
575 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++)
576 netdev_set_prio_tc_map(dev, i, ets->prio_tc[i]);
578 return ixgbe_dcb_hw_ets(&adapter->hw, ets, max_frame);
581 static int ixgbe_dcbnl_ieee_getpfc(struct net_device *dev,
582 struct ieee_pfc *pfc)
584 struct ixgbe_adapter *adapter = netdev_priv(dev);
585 struct ieee_pfc *my_pfc = adapter->ixgbe_ieee_pfc;
588 /* No IEEE PFC settings available */
592 pfc->pfc_cap = MAX_TRAFFIC_CLASS;
593 pfc->pfc_en = my_pfc->pfc_en;
594 pfc->mbc = my_pfc->mbc;
595 pfc->delay = my_pfc->delay;
597 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
598 pfc->requests[i] = adapter->stats.pxoffrxc[i];
599 pfc->indications[i] = adapter->stats.pxofftxc[i];
605 static int ixgbe_dcbnl_ieee_setpfc(struct net_device *dev,
606 struct ieee_pfc *pfc)
608 struct ixgbe_adapter *adapter = netdev_priv(dev);
610 if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE))
613 if (!adapter->ixgbe_ieee_pfc) {
614 adapter->ixgbe_ieee_pfc = kmalloc(sizeof(struct ieee_pfc),
616 if (!adapter->ixgbe_ieee_pfc)
620 memcpy(adapter->ixgbe_ieee_pfc, pfc, sizeof(*adapter->ixgbe_ieee_pfc));
621 return ixgbe_dcb_hw_pfc_config(&adapter->hw, pfc->pfc_en);
625 static void ixgbe_dcbnl_devreset(struct net_device *dev)
627 struct ixgbe_adapter *adapter = netdev_priv(dev);
629 if (netif_running(dev))
630 dev->netdev_ops->ndo_stop(dev);
632 ixgbe_clear_interrupt_scheme(adapter);
633 ixgbe_init_interrupt_scheme(adapter);
635 if (netif_running(dev))
636 dev->netdev_ops->ndo_open(dev);
640 static int ixgbe_dcbnl_ieee_setapp(struct net_device *dev,
643 struct ixgbe_adapter *adapter = netdev_priv(dev);
646 if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE))
649 err = dcb_ieee_setapp(dev, app);
652 if (!err && app->selector == IEEE_8021QAZ_APP_SEL_ETHERTYPE &&
653 app->protocol == ETH_P_FCOE) {
654 u8 app_mask = dcb_ieee_getapp_mask(dev, app);
656 if (app_mask & (1 << adapter->fcoe.up))
659 adapter->fcoe.up = app->priority;
660 ixgbe_dcbnl_devreset(dev);
666 static int ixgbe_dcbnl_ieee_delapp(struct net_device *dev,
669 struct ixgbe_adapter *adapter = netdev_priv(dev);
672 if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE))
675 err = dcb_ieee_delapp(dev, app);
678 if (!err && app->selector == IEEE_8021QAZ_APP_SEL_ETHERTYPE &&
679 app->protocol == ETH_P_FCOE) {
680 u8 app_mask = dcb_ieee_getapp_mask(dev, app);
682 if (app_mask & (1 << adapter->fcoe.up))
685 adapter->fcoe.up = app_mask ?
686 ffs(app_mask) - 1 : IXGBE_FCOE_DEFTC;
687 ixgbe_dcbnl_devreset(dev);
693 static u8 ixgbe_dcbnl_getdcbx(struct net_device *dev)
695 struct ixgbe_adapter *adapter = netdev_priv(dev);
696 return adapter->dcbx_cap;
699 static u8 ixgbe_dcbnl_setdcbx(struct net_device *dev, u8 mode)
701 struct ixgbe_adapter *adapter = netdev_priv(dev);
702 struct ieee_ets ets = {0};
703 struct ieee_pfc pfc = {0};
705 /* no support for LLD_MANAGED modes or CEE+IEEE */
706 if ((mode & DCB_CAP_DCBX_LLD_MANAGED) ||
707 ((mode & DCB_CAP_DCBX_VER_IEEE) && (mode & DCB_CAP_DCBX_VER_CEE)) ||
708 !(mode & DCB_CAP_DCBX_HOST))
711 if (mode == adapter->dcbx_cap)
714 adapter->dcbx_cap = mode;
716 /* ETS and PFC defaults */
720 if (mode & DCB_CAP_DCBX_VER_IEEE) {
721 ixgbe_dcbnl_ieee_setets(dev, &ets);
722 ixgbe_dcbnl_ieee_setpfc(dev, &pfc);
723 } else if (mode & DCB_CAP_DCBX_VER_CEE) {
724 adapter->dcb_set_bitmap |= (BIT_PFC & BIT_PG_TX & BIT_PG_RX);
725 ixgbe_dcbnl_set_all(dev);
727 /* Drop into single TC mode strict priority as this
728 * indicates CEE and IEEE versions are disabled
730 ixgbe_dcbnl_ieee_setets(dev, &ets);
731 ixgbe_dcbnl_ieee_setpfc(dev, &pfc);
732 ixgbe_setup_tc(dev, 0);
738 const struct dcbnl_rtnl_ops dcbnl_ops = {
739 .ieee_getets = ixgbe_dcbnl_ieee_getets,
740 .ieee_setets = ixgbe_dcbnl_ieee_setets,
741 .ieee_getpfc = ixgbe_dcbnl_ieee_getpfc,
742 .ieee_setpfc = ixgbe_dcbnl_ieee_setpfc,
743 .ieee_setapp = ixgbe_dcbnl_ieee_setapp,
744 .ieee_delapp = ixgbe_dcbnl_ieee_delapp,
745 .getstate = ixgbe_dcbnl_get_state,
746 .setstate = ixgbe_dcbnl_set_state,
747 .getpermhwaddr = ixgbe_dcbnl_get_perm_hw_addr,
748 .setpgtccfgtx = ixgbe_dcbnl_set_pg_tc_cfg_tx,
749 .setpgbwgcfgtx = ixgbe_dcbnl_set_pg_bwg_cfg_tx,
750 .setpgtccfgrx = ixgbe_dcbnl_set_pg_tc_cfg_rx,
751 .setpgbwgcfgrx = ixgbe_dcbnl_set_pg_bwg_cfg_rx,
752 .getpgtccfgtx = ixgbe_dcbnl_get_pg_tc_cfg_tx,
753 .getpgbwgcfgtx = ixgbe_dcbnl_get_pg_bwg_cfg_tx,
754 .getpgtccfgrx = ixgbe_dcbnl_get_pg_tc_cfg_rx,
755 .getpgbwgcfgrx = ixgbe_dcbnl_get_pg_bwg_cfg_rx,
756 .setpfccfg = ixgbe_dcbnl_set_pfc_cfg,
757 .getpfccfg = ixgbe_dcbnl_get_pfc_cfg,
758 .setall = ixgbe_dcbnl_set_all,
759 .getcap = ixgbe_dcbnl_getcap,
760 .getnumtcs = ixgbe_dcbnl_getnumtcs,
761 .setnumtcs = ixgbe_dcbnl_setnumtcs,
762 .getpfcstate = ixgbe_dcbnl_getpfcstate,
763 .setpfcstate = ixgbe_dcbnl_setpfcstate,
764 .getapp = ixgbe_dcbnl_getapp,
765 .getdcbx = ixgbe_dcbnl_getdcbx,
766 .setdcbx = ixgbe_dcbnl_setdcbx,