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 static int ixgbe_copy_dcb_cfg(struct ixgbe_adapter *adapter, int tc_max)
49 struct ixgbe_dcb_config *scfg = &adapter->temp_dcb_cfg;
50 struct ixgbe_dcb_config *dcfg = &adapter->dcb_cfg;
51 struct tc_configuration *src = NULL;
52 struct tc_configuration *dst = NULL;
54 int tx = DCB_TX_CONFIG;
55 int rx = DCB_RX_CONFIG;
58 struct dcb_app app = {
59 .selector = DCB_APP_IDTYPE_ETHTYPE,
60 .protocol = ETH_P_FCOE,
62 u8 up = dcb_getapp(adapter->netdev, &app);
64 if (up && !(up & (1 << adapter->fcoe.up)))
65 changes |= BIT_APP_UPCHG;
68 for (i = DCB_PG_ATTR_TC_0; i < tc_max + DCB_PG_ATTR_TC_0; i++) {
69 src = &scfg->tc_config[i - DCB_PG_ATTR_TC_0];
70 dst = &dcfg->tc_config[i - DCB_PG_ATTR_TC_0];
72 if (dst->path[tx].prio_type != src->path[tx].prio_type) {
73 dst->path[tx].prio_type = src->path[tx].prio_type;
77 if (dst->path[tx].bwg_id != src->path[tx].bwg_id) {
78 dst->path[tx].bwg_id = src->path[tx].bwg_id;
82 if (dst->path[tx].bwg_percent != src->path[tx].bwg_percent) {
83 dst->path[tx].bwg_percent = src->path[tx].bwg_percent;
87 if (dst->path[tx].up_to_tc_bitmap !=
88 src->path[tx].up_to_tc_bitmap) {
89 dst->path[tx].up_to_tc_bitmap =
90 src->path[tx].up_to_tc_bitmap;
91 changes |= (BIT_PG_TX | BIT_PFC | BIT_APP_UPCHG);
94 if (dst->path[rx].prio_type != src->path[rx].prio_type) {
95 dst->path[rx].prio_type = src->path[rx].prio_type;
99 if (dst->path[rx].bwg_id != src->path[rx].bwg_id) {
100 dst->path[rx].bwg_id = src->path[rx].bwg_id;
101 changes |= BIT_PG_RX;
104 if (dst->path[rx].bwg_percent != src->path[rx].bwg_percent) {
105 dst->path[rx].bwg_percent = src->path[rx].bwg_percent;
106 changes |= BIT_PG_RX;
109 if (dst->path[rx].up_to_tc_bitmap !=
110 src->path[rx].up_to_tc_bitmap) {
111 dst->path[rx].up_to_tc_bitmap =
112 src->path[rx].up_to_tc_bitmap;
113 changes |= (BIT_PG_RX | BIT_PFC | BIT_APP_UPCHG);
117 for (i = DCB_PG_ATTR_BW_ID_0; i < DCB_PG_ATTR_BW_ID_MAX; i++) {
118 j = i - DCB_PG_ATTR_BW_ID_0;
119 if (dcfg->bw_percentage[tx][j] != scfg->bw_percentage[tx][j]) {
120 dcfg->bw_percentage[tx][j] = scfg->bw_percentage[tx][j];
121 changes |= BIT_PG_TX;
123 if (dcfg->bw_percentage[rx][j] != scfg->bw_percentage[rx][j]) {
124 dcfg->bw_percentage[rx][j] = scfg->bw_percentage[rx][j];
125 changes |= BIT_PG_RX;
129 for (i = DCB_PFC_UP_ATTR_0; i < DCB_PFC_UP_ATTR_MAX; i++) {
130 j = i - DCB_PFC_UP_ATTR_0;
131 if (dcfg->tc_config[j].dcb_pfc != scfg->tc_config[j].dcb_pfc) {
132 dcfg->tc_config[j].dcb_pfc = scfg->tc_config[j].dcb_pfc;
137 if (dcfg->pfc_mode_enable != scfg->pfc_mode_enable) {
138 dcfg->pfc_mode_enable = scfg->pfc_mode_enable;
145 static u8 ixgbe_dcbnl_get_state(struct net_device *netdev)
147 struct ixgbe_adapter *adapter = netdev_priv(netdev);
149 return !!(adapter->flags & IXGBE_FLAG_DCB_ENABLED);
152 static u8 ixgbe_dcbnl_set_state(struct net_device *netdev, u8 state)
154 struct ixgbe_adapter *adapter = netdev_priv(netdev);
157 /* Fail command if not in CEE mode */
158 if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_CEE))
161 /* verify there is something to do, if not then exit */
162 if (!state == !(adapter->flags & IXGBE_FLAG_DCB_ENABLED))
165 err = ixgbe_setup_tc(netdev,
166 state ? adapter->dcb_cfg.num_tcs.pg_tcs : 0);
171 static void ixgbe_dcbnl_get_perm_hw_addr(struct net_device *netdev,
174 struct ixgbe_adapter *adapter = netdev_priv(netdev);
177 memset(perm_addr, 0xff, MAX_ADDR_LEN);
179 for (i = 0; i < netdev->addr_len; i++)
180 perm_addr[i] = adapter->hw.mac.perm_addr[i];
182 switch (adapter->hw.mac.type) {
183 case ixgbe_mac_82599EB:
185 for (j = 0; j < netdev->addr_len; j++, i++)
186 perm_addr[i] = adapter->hw.mac.san_addr[j];
193 static void ixgbe_dcbnl_set_pg_tc_cfg_tx(struct net_device *netdev, int tc,
194 u8 prio, u8 bwg_id, u8 bw_pct,
197 struct ixgbe_adapter *adapter = netdev_priv(netdev);
199 if (prio != DCB_ATTR_VALUE_UNDEFINED)
200 adapter->temp_dcb_cfg.tc_config[tc].path[0].prio_type = prio;
201 if (bwg_id != DCB_ATTR_VALUE_UNDEFINED)
202 adapter->temp_dcb_cfg.tc_config[tc].path[0].bwg_id = bwg_id;
203 if (bw_pct != DCB_ATTR_VALUE_UNDEFINED)
204 adapter->temp_dcb_cfg.tc_config[tc].path[0].bwg_percent =
206 if (up_map != DCB_ATTR_VALUE_UNDEFINED)
207 adapter->temp_dcb_cfg.tc_config[tc].path[0].up_to_tc_bitmap =
211 static void ixgbe_dcbnl_set_pg_bwg_cfg_tx(struct net_device *netdev, int bwg_id,
214 struct ixgbe_adapter *adapter = netdev_priv(netdev);
216 adapter->temp_dcb_cfg.bw_percentage[0][bwg_id] = bw_pct;
219 static void ixgbe_dcbnl_set_pg_tc_cfg_rx(struct net_device *netdev, int tc,
220 u8 prio, u8 bwg_id, u8 bw_pct,
223 struct ixgbe_adapter *adapter = netdev_priv(netdev);
225 if (prio != DCB_ATTR_VALUE_UNDEFINED)
226 adapter->temp_dcb_cfg.tc_config[tc].path[1].prio_type = prio;
227 if (bwg_id != DCB_ATTR_VALUE_UNDEFINED)
228 adapter->temp_dcb_cfg.tc_config[tc].path[1].bwg_id = bwg_id;
229 if (bw_pct != DCB_ATTR_VALUE_UNDEFINED)
230 adapter->temp_dcb_cfg.tc_config[tc].path[1].bwg_percent =
232 if (up_map != DCB_ATTR_VALUE_UNDEFINED)
233 adapter->temp_dcb_cfg.tc_config[tc].path[1].up_to_tc_bitmap =
237 static void ixgbe_dcbnl_set_pg_bwg_cfg_rx(struct net_device *netdev, int bwg_id,
240 struct ixgbe_adapter *adapter = netdev_priv(netdev);
242 adapter->temp_dcb_cfg.bw_percentage[1][bwg_id] = bw_pct;
245 static void ixgbe_dcbnl_get_pg_tc_cfg_tx(struct net_device *netdev, int tc,
246 u8 *prio, u8 *bwg_id, u8 *bw_pct,
249 struct ixgbe_adapter *adapter = netdev_priv(netdev);
251 *prio = adapter->dcb_cfg.tc_config[tc].path[0].prio_type;
252 *bwg_id = adapter->dcb_cfg.tc_config[tc].path[0].bwg_id;
253 *bw_pct = adapter->dcb_cfg.tc_config[tc].path[0].bwg_percent;
254 *up_map = adapter->dcb_cfg.tc_config[tc].path[0].up_to_tc_bitmap;
257 static void ixgbe_dcbnl_get_pg_bwg_cfg_tx(struct net_device *netdev, int bwg_id,
260 struct ixgbe_adapter *adapter = netdev_priv(netdev);
262 *bw_pct = adapter->dcb_cfg.bw_percentage[0][bwg_id];
265 static void ixgbe_dcbnl_get_pg_tc_cfg_rx(struct net_device *netdev, int tc,
266 u8 *prio, u8 *bwg_id, u8 *bw_pct,
269 struct ixgbe_adapter *adapter = netdev_priv(netdev);
271 *prio = adapter->dcb_cfg.tc_config[tc].path[1].prio_type;
272 *bwg_id = adapter->dcb_cfg.tc_config[tc].path[1].bwg_id;
273 *bw_pct = adapter->dcb_cfg.tc_config[tc].path[1].bwg_percent;
274 *up_map = adapter->dcb_cfg.tc_config[tc].path[1].up_to_tc_bitmap;
277 static void ixgbe_dcbnl_get_pg_bwg_cfg_rx(struct net_device *netdev, int bwg_id,
280 struct ixgbe_adapter *adapter = netdev_priv(netdev);
282 *bw_pct = adapter->dcb_cfg.bw_percentage[1][bwg_id];
285 static void ixgbe_dcbnl_set_pfc_cfg(struct net_device *netdev, int priority,
288 struct ixgbe_adapter *adapter = netdev_priv(netdev);
290 adapter->temp_dcb_cfg.tc_config[priority].dcb_pfc = setting;
291 if (adapter->temp_dcb_cfg.tc_config[priority].dcb_pfc !=
292 adapter->dcb_cfg.tc_config[priority].dcb_pfc)
293 adapter->temp_dcb_cfg.pfc_mode_enable = true;
296 static void ixgbe_dcbnl_get_pfc_cfg(struct net_device *netdev, int priority,
299 struct ixgbe_adapter *adapter = netdev_priv(netdev);
301 *setting = adapter->dcb_cfg.tc_config[priority].dcb_pfc;
305 static void ixgbe_dcbnl_devreset(struct net_device *dev)
307 struct ixgbe_adapter *adapter = netdev_priv(dev);
309 while (test_and_set_bit(__IXGBE_RESETTING, &adapter->state))
310 usleep_range(1000, 2000);
312 if (netif_running(dev))
313 dev->netdev_ops->ndo_stop(dev);
315 ixgbe_clear_interrupt_scheme(adapter);
316 ixgbe_init_interrupt_scheme(adapter);
318 if (netif_running(dev))
319 dev->netdev_ops->ndo_open(dev);
321 clear_bit(__IXGBE_RESETTING, &adapter->state);
325 static u8 ixgbe_dcbnl_set_all(struct net_device *netdev)
327 struct ixgbe_adapter *adapter = netdev_priv(netdev);
328 struct ixgbe_dcb_config *dcb_cfg = &adapter->dcb_cfg;
329 struct ixgbe_hw *hw = &adapter->hw;
330 int ret = DCB_NO_HW_CHG;
333 /* Fail command if not in CEE mode */
334 if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_CEE))
337 adapter->dcb_set_bitmap |= ixgbe_copy_dcb_cfg(adapter,
339 if (!adapter->dcb_set_bitmap)
342 if (adapter->dcb_set_bitmap & (BIT_PG_TX|BIT_PG_RX)) {
343 u16 refill[MAX_TRAFFIC_CLASS], max[MAX_TRAFFIC_CLASS];
344 u8 bwg_id[MAX_TRAFFIC_CLASS], prio_type[MAX_TRAFFIC_CLASS];
345 /* Priority to TC mapping in CEE case default to 1:1 */
346 u8 prio_tc[MAX_USER_PRIORITY];
347 int max_frame = adapter->netdev->mtu + ETH_HLEN + ETH_FCS_LEN;
350 if (adapter->netdev->features & NETIF_F_FCOE_MTU)
351 max_frame = max(max_frame, IXGBE_FCOE_JUMBO_FRAME_SIZE);
354 ixgbe_dcb_calculate_tc_credits(hw, dcb_cfg, max_frame,
356 ixgbe_dcb_calculate_tc_credits(hw, dcb_cfg, max_frame,
359 ixgbe_dcb_unpack_refill(dcb_cfg, DCB_TX_CONFIG, refill);
360 ixgbe_dcb_unpack_max(dcb_cfg, max);
361 ixgbe_dcb_unpack_bwgid(dcb_cfg, DCB_TX_CONFIG, bwg_id);
362 ixgbe_dcb_unpack_prio(dcb_cfg, DCB_TX_CONFIG, prio_type);
363 ixgbe_dcb_unpack_map(dcb_cfg, DCB_TX_CONFIG, prio_tc);
365 ixgbe_dcb_hw_ets_config(hw, refill, max, bwg_id,
368 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++)
369 netdev_set_prio_tc_map(netdev, i, prio_tc[i]);
371 ret = DCB_HW_CHG_RST;
374 if (adapter->dcb_set_bitmap & BIT_PFC) {
375 if (dcb_cfg->pfc_mode_enable) {
377 u8 prio_tc[MAX_USER_PRIORITY];
379 ixgbe_dcb_unpack_map(dcb_cfg, DCB_TX_CONFIG, prio_tc);
380 ixgbe_dcb_unpack_pfc(dcb_cfg, &pfc_en);
381 ixgbe_dcb_hw_pfc_config(hw, pfc_en, prio_tc);
383 hw->mac.ops.fc_enable(hw);
386 ixgbe_set_rx_drop_en(adapter);
392 /* Reprogam FCoE hardware offloads when the traffic class
393 * FCoE is using changes. This happens if the APP info
394 * changes or the up2tc mapping is updated.
396 if (adapter->dcb_set_bitmap & BIT_APP_UPCHG) {
397 struct dcb_app app = {
398 .selector = DCB_APP_IDTYPE_ETHTYPE,
399 .protocol = ETH_P_FCOE,
401 u8 up = dcb_getapp(netdev, &app);
403 adapter->fcoe.up = ffs(up) - 1;
404 ixgbe_dcbnl_devreset(netdev);
405 ret = DCB_HW_CHG_RST;
409 adapter->dcb_set_bitmap = 0x00;
413 static u8 ixgbe_dcbnl_getcap(struct net_device *netdev, int capid, u8 *cap)
415 struct ixgbe_adapter *adapter = netdev_priv(netdev);
418 case DCB_CAP_ATTR_PG:
421 case DCB_CAP_ATTR_PFC:
424 case DCB_CAP_ATTR_UP2TC:
427 case DCB_CAP_ATTR_PG_TCS:
430 case DCB_CAP_ATTR_PFC_TCS:
433 case DCB_CAP_ATTR_GSP:
436 case DCB_CAP_ATTR_BCN:
439 case DCB_CAP_ATTR_DCBX:
440 *cap = adapter->dcbx_cap;
450 static int ixgbe_dcbnl_getnumtcs(struct net_device *netdev, int tcid, u8 *num)
452 struct ixgbe_adapter *adapter = netdev_priv(netdev);
455 if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
457 case DCB_NUMTCS_ATTR_PG:
458 *num = adapter->dcb_cfg.num_tcs.pg_tcs;
460 case DCB_NUMTCS_ATTR_PFC:
461 *num = adapter->dcb_cfg.num_tcs.pfc_tcs;
474 static int ixgbe_dcbnl_setnumtcs(struct net_device *netdev, int tcid, u8 num)
479 static u8 ixgbe_dcbnl_getpfcstate(struct net_device *netdev)
481 struct ixgbe_adapter *adapter = netdev_priv(netdev);
483 return adapter->dcb_cfg.pfc_mode_enable;
486 static void ixgbe_dcbnl_setpfcstate(struct net_device *netdev, u8 state)
488 struct ixgbe_adapter *adapter = netdev_priv(netdev);
490 adapter->temp_dcb_cfg.pfc_mode_enable = state;
494 * ixgbe_dcbnl_getapp - retrieve the DCBX application user priority
495 * @netdev : the corresponding netdev
496 * @idtype : identifies the id as ether type or TCP/UDP port number
497 * @id: id is either ether type or TCP/UDP port number
499 * Returns : on success, returns a non-zero 802.1p user priority bitmap
500 * otherwise returns 0 as the invalid user priority bitmap to indicate an
503 static u8 ixgbe_dcbnl_getapp(struct net_device *netdev, u8 idtype, u16 id)
505 struct ixgbe_adapter *adapter = netdev_priv(netdev);
506 struct dcb_app app = {
511 if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_CEE))
514 return dcb_getapp(netdev, &app);
517 static int ixgbe_dcbnl_ieee_getets(struct net_device *dev,
518 struct ieee_ets *ets)
520 struct ixgbe_adapter *adapter = netdev_priv(dev);
521 struct ieee_ets *my_ets = adapter->ixgbe_ieee_ets;
523 ets->ets_cap = adapter->dcb_cfg.num_tcs.pg_tcs;
525 /* No IEEE PFC settings available */
529 ets->cbs = my_ets->cbs;
530 memcpy(ets->tc_tx_bw, my_ets->tc_tx_bw, sizeof(ets->tc_tx_bw));
531 memcpy(ets->tc_rx_bw, my_ets->tc_rx_bw, sizeof(ets->tc_rx_bw));
532 memcpy(ets->tc_tsa, my_ets->tc_tsa, sizeof(ets->tc_tsa));
533 memcpy(ets->prio_tc, my_ets->prio_tc, sizeof(ets->prio_tc));
537 static int ixgbe_dcbnl_ieee_setets(struct net_device *dev,
538 struct ieee_ets *ets)
540 struct ixgbe_adapter *adapter = netdev_priv(dev);
541 int max_frame = dev->mtu + ETH_HLEN + ETH_FCS_LEN;
545 if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE))
548 if (!adapter->ixgbe_ieee_ets) {
549 adapter->ixgbe_ieee_ets = kmalloc(sizeof(struct ieee_ets),
551 if (!adapter->ixgbe_ieee_ets)
555 memcpy(adapter->ixgbe_ieee_ets, ets, sizeof(*adapter->ixgbe_ieee_ets));
557 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
558 if (ets->prio_tc[i] > max_tc)
559 max_tc = ets->prio_tc[i];
565 if (max_tc > adapter->dcb_cfg.num_tcs.pg_tcs)
568 if (max_tc != netdev_get_num_tc(dev))
569 err = ixgbe_setup_tc(dev, max_tc);
574 err = ixgbe_dcb_hw_ets(&adapter->hw, ets, max_frame);
579 static int ixgbe_dcbnl_ieee_getpfc(struct net_device *dev,
580 struct ieee_pfc *pfc)
582 struct ixgbe_adapter *adapter = netdev_priv(dev);
583 struct ieee_pfc *my_pfc = adapter->ixgbe_ieee_pfc;
586 pfc->pfc_cap = adapter->dcb_cfg.num_tcs.pfc_tcs;
588 /* No IEEE PFC settings available */
592 pfc->pfc_en = my_pfc->pfc_en;
593 pfc->mbc = my_pfc->mbc;
594 pfc->delay = my_pfc->delay;
596 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
597 pfc->requests[i] = adapter->stats.pxoffrxc[i];
598 pfc->indications[i] = adapter->stats.pxofftxc[i];
604 static int ixgbe_dcbnl_ieee_setpfc(struct net_device *dev,
605 struct ieee_pfc *pfc)
607 struct ixgbe_adapter *adapter = netdev_priv(dev);
608 struct ixgbe_hw *hw = &adapter->hw;
612 if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE))
615 if (!adapter->ixgbe_ieee_pfc) {
616 adapter->ixgbe_ieee_pfc = kmalloc(sizeof(struct ieee_pfc),
618 if (!adapter->ixgbe_ieee_pfc)
622 prio_tc = adapter->ixgbe_ieee_ets->prio_tc;
623 memcpy(adapter->ixgbe_ieee_pfc, pfc, sizeof(*adapter->ixgbe_ieee_pfc));
625 /* Enable link flow control parameters if PFC is disabled */
627 err = ixgbe_dcb_hw_pfc_config(hw, pfc->pfc_en, prio_tc);
629 err = hw->mac.ops.fc_enable(hw);
631 ixgbe_set_rx_drop_en(adapter);
636 static int ixgbe_dcbnl_ieee_setapp(struct net_device *dev,
639 struct ixgbe_adapter *adapter = netdev_priv(dev);
642 if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE))
645 err = dcb_ieee_setapp(dev, app);
648 if (!err && app->selector == IEEE_8021QAZ_APP_SEL_ETHERTYPE &&
649 app->protocol == ETH_P_FCOE) {
650 u8 app_mask = dcb_ieee_getapp_mask(dev, app);
652 if (app_mask & (1 << adapter->fcoe.up))
655 adapter->fcoe.up = app->priority;
656 ixgbe_dcbnl_devreset(dev);
662 static int ixgbe_dcbnl_ieee_delapp(struct net_device *dev,
665 struct ixgbe_adapter *adapter = netdev_priv(dev);
668 if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE))
671 err = dcb_ieee_delapp(dev, app);
674 if (!err && app->selector == IEEE_8021QAZ_APP_SEL_ETHERTYPE &&
675 app->protocol == ETH_P_FCOE) {
676 u8 app_mask = dcb_ieee_getapp_mask(dev, app);
678 if (app_mask & (1 << adapter->fcoe.up))
681 adapter->fcoe.up = app_mask ?
682 ffs(app_mask) - 1 : IXGBE_FCOE_DEFTC;
683 ixgbe_dcbnl_devreset(dev);
689 static u8 ixgbe_dcbnl_getdcbx(struct net_device *dev)
691 struct ixgbe_adapter *adapter = netdev_priv(dev);
692 return adapter->dcbx_cap;
695 static u8 ixgbe_dcbnl_setdcbx(struct net_device *dev, u8 mode)
697 struct ixgbe_adapter *adapter = netdev_priv(dev);
698 struct ieee_ets ets = {0};
699 struct ieee_pfc pfc = {0};
702 /* no support for LLD_MANAGED modes or CEE+IEEE */
703 if ((mode & DCB_CAP_DCBX_LLD_MANAGED) ||
704 ((mode & DCB_CAP_DCBX_VER_IEEE) && (mode & DCB_CAP_DCBX_VER_CEE)) ||
705 !(mode & DCB_CAP_DCBX_HOST))
708 if (mode == adapter->dcbx_cap)
711 adapter->dcbx_cap = mode;
713 /* ETS and PFC defaults */
717 if (mode & DCB_CAP_DCBX_VER_IEEE) {
718 ixgbe_dcbnl_ieee_setets(dev, &ets);
719 ixgbe_dcbnl_ieee_setpfc(dev, &pfc);
720 } else if (mode & DCB_CAP_DCBX_VER_CEE) {
721 u8 mask = BIT_PFC | BIT_PG_TX | BIT_PG_RX | BIT_APP_UPCHG;
723 adapter->dcb_set_bitmap |= mask;
724 ixgbe_dcbnl_set_all(dev);
726 /* Drop into single TC mode strict priority as this
727 * indicates CEE and IEEE versions are disabled
729 ixgbe_dcbnl_ieee_setets(dev, &ets);
730 ixgbe_dcbnl_ieee_setpfc(dev, &pfc);
731 err = ixgbe_setup_tc(dev, 0);
737 const struct dcbnl_rtnl_ops dcbnl_ops = {
738 .ieee_getets = ixgbe_dcbnl_ieee_getets,
739 .ieee_setets = ixgbe_dcbnl_ieee_setets,
740 .ieee_getpfc = ixgbe_dcbnl_ieee_getpfc,
741 .ieee_setpfc = ixgbe_dcbnl_ieee_setpfc,
742 .ieee_setapp = ixgbe_dcbnl_ieee_setapp,
743 .ieee_delapp = ixgbe_dcbnl_ieee_delapp,
744 .getstate = ixgbe_dcbnl_get_state,
745 .setstate = ixgbe_dcbnl_set_state,
746 .getpermhwaddr = ixgbe_dcbnl_get_perm_hw_addr,
747 .setpgtccfgtx = ixgbe_dcbnl_set_pg_tc_cfg_tx,
748 .setpgbwgcfgtx = ixgbe_dcbnl_set_pg_bwg_cfg_tx,
749 .setpgtccfgrx = ixgbe_dcbnl_set_pg_tc_cfg_rx,
750 .setpgbwgcfgrx = ixgbe_dcbnl_set_pg_bwg_cfg_rx,
751 .getpgtccfgtx = ixgbe_dcbnl_get_pg_tc_cfg_tx,
752 .getpgbwgcfgtx = ixgbe_dcbnl_get_pg_bwg_cfg_tx,
753 .getpgtccfgrx = ixgbe_dcbnl_get_pg_tc_cfg_rx,
754 .getpgbwgcfgrx = ixgbe_dcbnl_get_pg_bwg_cfg_rx,
755 .setpfccfg = ixgbe_dcbnl_set_pfc_cfg,
756 .getpfccfg = ixgbe_dcbnl_get_pfc_cfg,
757 .setall = ixgbe_dcbnl_set_all,
758 .getcap = ixgbe_dcbnl_getcap,
759 .getnumtcs = ixgbe_dcbnl_getnumtcs,
760 .setnumtcs = ixgbe_dcbnl_setnumtcs,
761 .getpfcstate = ixgbe_dcbnl_getpfcstate,
762 .setpfcstate = ixgbe_dcbnl_setpfcstate,
763 .getapp = ixgbe_dcbnl_getapp,
764 .getdcbx = ixgbe_dcbnl_getdcbx,
765 .setdcbx = ixgbe_dcbnl_setdcbx,