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);
119 if (adapter->flags & IXGBE_FLAG_DCB_ENABLED)
122 if (!(adapter->flags & IXGBE_FLAG_MSIX_ENABLED)) {
123 e_err(drv, "Enable failed, needs MSI-X\n");
128 adapter->flags |= IXGBE_FLAG_DCB_ENABLED;
130 switch (adapter->hw.mac.type) {
131 case ixgbe_mac_82598EB:
132 adapter->last_lfc_mode = adapter->hw.fc.current_mode;
133 adapter->hw.fc.requested_mode = ixgbe_fc_none;
135 case ixgbe_mac_82599EB:
137 adapter->flags &= ~IXGBE_FLAG_FDIR_HASH_CAPABLE;
143 ixgbe_setup_tc(netdev, MAX_TRAFFIC_CLASS);
146 if (!(adapter->flags & IXGBE_FLAG_DCB_ENABLED))
149 adapter->hw.fc.requested_mode = adapter->last_lfc_mode;
150 adapter->temp_dcb_cfg.pfc_mode_enable = false;
151 adapter->dcb_cfg.pfc_mode_enable = false;
152 adapter->flags &= ~IXGBE_FLAG_DCB_ENABLED;
153 switch (adapter->hw.mac.type) {
154 case ixgbe_mac_82599EB:
156 adapter->flags |= IXGBE_FLAG_FDIR_HASH_CAPABLE;
161 ixgbe_setup_tc(netdev, 0);
168 static void ixgbe_dcbnl_get_perm_hw_addr(struct net_device *netdev,
171 struct ixgbe_adapter *adapter = netdev_priv(netdev);
174 memset(perm_addr, 0xff, MAX_ADDR_LEN);
176 for (i = 0; i < netdev->addr_len; i++)
177 perm_addr[i] = adapter->hw.mac.perm_addr[i];
179 switch (adapter->hw.mac.type) {
180 case ixgbe_mac_82599EB:
182 for (j = 0; j < netdev->addr_len; j++, i++)
183 perm_addr[i] = adapter->hw.mac.san_addr[j];
190 static void ixgbe_dcbnl_set_pg_tc_cfg_tx(struct net_device *netdev, int tc,
191 u8 prio, u8 bwg_id, u8 bw_pct,
194 struct ixgbe_adapter *adapter = netdev_priv(netdev);
196 if (prio != DCB_ATTR_VALUE_UNDEFINED)
197 adapter->temp_dcb_cfg.tc_config[tc].path[0].prio_type = prio;
198 if (bwg_id != DCB_ATTR_VALUE_UNDEFINED)
199 adapter->temp_dcb_cfg.tc_config[tc].path[0].bwg_id = bwg_id;
200 if (bw_pct != DCB_ATTR_VALUE_UNDEFINED)
201 adapter->temp_dcb_cfg.tc_config[tc].path[0].bwg_percent =
203 if (up_map != DCB_ATTR_VALUE_UNDEFINED)
204 adapter->temp_dcb_cfg.tc_config[tc].path[0].up_to_tc_bitmap =
207 if ((adapter->temp_dcb_cfg.tc_config[tc].path[0].prio_type !=
208 adapter->dcb_cfg.tc_config[tc].path[0].prio_type) ||
209 (adapter->temp_dcb_cfg.tc_config[tc].path[0].bwg_id !=
210 adapter->dcb_cfg.tc_config[tc].path[0].bwg_id) ||
211 (adapter->temp_dcb_cfg.tc_config[tc].path[0].bwg_percent !=
212 adapter->dcb_cfg.tc_config[tc].path[0].bwg_percent) ||
213 (adapter->temp_dcb_cfg.tc_config[tc].path[0].up_to_tc_bitmap !=
214 adapter->dcb_cfg.tc_config[tc].path[0].up_to_tc_bitmap))
215 adapter->dcb_set_bitmap |= BIT_PG_TX;
218 static void ixgbe_dcbnl_set_pg_bwg_cfg_tx(struct net_device *netdev, int bwg_id,
221 struct ixgbe_adapter *adapter = netdev_priv(netdev);
223 adapter->temp_dcb_cfg.bw_percentage[0][bwg_id] = bw_pct;
225 if (adapter->temp_dcb_cfg.bw_percentage[0][bwg_id] !=
226 adapter->dcb_cfg.bw_percentage[0][bwg_id])
227 adapter->dcb_set_bitmap |= BIT_PG_TX;
230 static void ixgbe_dcbnl_set_pg_tc_cfg_rx(struct net_device *netdev, int tc,
231 u8 prio, u8 bwg_id, u8 bw_pct,
234 struct ixgbe_adapter *adapter = netdev_priv(netdev);
236 if (prio != DCB_ATTR_VALUE_UNDEFINED)
237 adapter->temp_dcb_cfg.tc_config[tc].path[1].prio_type = prio;
238 if (bwg_id != DCB_ATTR_VALUE_UNDEFINED)
239 adapter->temp_dcb_cfg.tc_config[tc].path[1].bwg_id = bwg_id;
240 if (bw_pct != DCB_ATTR_VALUE_UNDEFINED)
241 adapter->temp_dcb_cfg.tc_config[tc].path[1].bwg_percent =
243 if (up_map != DCB_ATTR_VALUE_UNDEFINED)
244 adapter->temp_dcb_cfg.tc_config[tc].path[1].up_to_tc_bitmap =
247 if ((adapter->temp_dcb_cfg.tc_config[tc].path[1].prio_type !=
248 adapter->dcb_cfg.tc_config[tc].path[1].prio_type) ||
249 (adapter->temp_dcb_cfg.tc_config[tc].path[1].bwg_id !=
250 adapter->dcb_cfg.tc_config[tc].path[1].bwg_id) ||
251 (adapter->temp_dcb_cfg.tc_config[tc].path[1].bwg_percent !=
252 adapter->dcb_cfg.tc_config[tc].path[1].bwg_percent) ||
253 (adapter->temp_dcb_cfg.tc_config[tc].path[1].up_to_tc_bitmap !=
254 adapter->dcb_cfg.tc_config[tc].path[1].up_to_tc_bitmap))
255 adapter->dcb_set_bitmap |= BIT_PG_RX;
258 static void ixgbe_dcbnl_set_pg_bwg_cfg_rx(struct net_device *netdev, int bwg_id,
261 struct ixgbe_adapter *adapter = netdev_priv(netdev);
263 adapter->temp_dcb_cfg.bw_percentage[1][bwg_id] = bw_pct;
265 if (adapter->temp_dcb_cfg.bw_percentage[1][bwg_id] !=
266 adapter->dcb_cfg.bw_percentage[1][bwg_id])
267 adapter->dcb_set_bitmap |= BIT_PG_RX;
270 static void ixgbe_dcbnl_get_pg_tc_cfg_tx(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[0].prio_type;
277 *bwg_id = adapter->dcb_cfg.tc_config[tc].path[0].bwg_id;
278 *bw_pct = adapter->dcb_cfg.tc_config[tc].path[0].bwg_percent;
279 *up_map = adapter->dcb_cfg.tc_config[tc].path[0].up_to_tc_bitmap;
282 static void ixgbe_dcbnl_get_pg_bwg_cfg_tx(struct net_device *netdev, int bwg_id,
285 struct ixgbe_adapter *adapter = netdev_priv(netdev);
287 *bw_pct = adapter->dcb_cfg.bw_percentage[0][bwg_id];
290 static void ixgbe_dcbnl_get_pg_tc_cfg_rx(struct net_device *netdev, int tc,
291 u8 *prio, u8 *bwg_id, u8 *bw_pct,
294 struct ixgbe_adapter *adapter = netdev_priv(netdev);
296 *prio = adapter->dcb_cfg.tc_config[tc].path[1].prio_type;
297 *bwg_id = adapter->dcb_cfg.tc_config[tc].path[1].bwg_id;
298 *bw_pct = adapter->dcb_cfg.tc_config[tc].path[1].bwg_percent;
299 *up_map = adapter->dcb_cfg.tc_config[tc].path[1].up_to_tc_bitmap;
302 static void ixgbe_dcbnl_get_pg_bwg_cfg_rx(struct net_device *netdev, int bwg_id,
305 struct ixgbe_adapter *adapter = netdev_priv(netdev);
307 *bw_pct = adapter->dcb_cfg.bw_percentage[1][bwg_id];
310 static void ixgbe_dcbnl_set_pfc_cfg(struct net_device *netdev, int priority,
313 struct ixgbe_adapter *adapter = netdev_priv(netdev);
315 adapter->temp_dcb_cfg.tc_config[priority].dcb_pfc = setting;
316 if (adapter->temp_dcb_cfg.tc_config[priority].dcb_pfc !=
317 adapter->dcb_cfg.tc_config[priority].dcb_pfc) {
318 adapter->dcb_set_bitmap |= BIT_PFC;
319 adapter->temp_dcb_cfg.pfc_mode_enable = true;
323 static void ixgbe_dcbnl_get_pfc_cfg(struct net_device *netdev, int priority,
326 struct ixgbe_adapter *adapter = netdev_priv(netdev);
328 *setting = adapter->dcb_cfg.tc_config[priority].dcb_pfc;
331 static u8 ixgbe_dcbnl_set_all(struct net_device *netdev)
333 struct ixgbe_adapter *adapter = netdev_priv(netdev);
334 struct dcb_app app = {
335 .selector = DCB_APP_IDTYPE_ETHTYPE,
336 .protocol = ETH_P_FCOE,
338 u8 up = dcb_getapp(netdev, &app);
341 ret = ixgbe_copy_dcb_cfg(&adapter->temp_dcb_cfg, &adapter->dcb_cfg,
344 return DCB_NO_HW_CHG;
346 /* In IEEE mode app data must be parsed into DCBX format for
349 if (adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE)
353 if (up && (up != (1 << adapter->fcoe.up)))
354 adapter->dcb_set_bitmap |= BIT_APP_UPCHG;
357 * Only take down the adapter if an app change occurred. FCoE
358 * may shuffle tx rings in this case and this can not be done
359 * without a reset currently.
361 if (adapter->dcb_set_bitmap & BIT_APP_UPCHG) {
362 while (test_and_set_bit(__IXGBE_RESETTING, &adapter->state))
363 usleep_range(1000, 2000);
365 ixgbe_fcoe_setapp(adapter, up);
367 if (netif_running(netdev))
368 netdev->netdev_ops->ndo_stop(netdev);
369 ixgbe_clear_interrupt_scheme(adapter);
373 if (adapter->dcb_cfg.pfc_mode_enable) {
374 switch (adapter->hw.mac.type) {
375 case ixgbe_mac_82599EB:
377 if (adapter->hw.fc.current_mode != ixgbe_fc_pfc)
378 adapter->last_lfc_mode =
379 adapter->hw.fc.current_mode;
384 adapter->hw.fc.requested_mode = ixgbe_fc_pfc;
386 switch (adapter->hw.mac.type) {
387 case ixgbe_mac_82598EB:
388 adapter->hw.fc.requested_mode = ixgbe_fc_none;
390 case ixgbe_mac_82599EB:
392 adapter->hw.fc.requested_mode = adapter->last_lfc_mode;
400 if (adapter->dcb_set_bitmap & BIT_APP_UPCHG) {
401 ixgbe_init_interrupt_scheme(adapter);
402 if (netif_running(netdev))
403 netdev->netdev_ops->ndo_open(netdev);
404 ret = DCB_HW_CHG_RST;
408 if (adapter->dcb_set_bitmap & BIT_PFC) {
410 ixgbe_dcb_unpack_pfc(&adapter->dcb_cfg, &pfc_en);
411 ixgbe_dcb_hw_pfc_config(&adapter->hw, pfc_en);
415 if (adapter->dcb_set_bitmap & (BIT_PG_TX|BIT_PG_RX)) {
416 u16 refill[MAX_TRAFFIC_CLASS], max[MAX_TRAFFIC_CLASS];
417 u8 bwg_id[MAX_TRAFFIC_CLASS], prio_type[MAX_TRAFFIC_CLASS];
418 /* Priority to TC mapping in CEE case default to 1:1 */
419 u8 prio_tc[MAX_TRAFFIC_CLASS] = {0, 1, 2, 3, 4, 5, 6, 7};
420 int max_frame = adapter->netdev->mtu + ETH_HLEN + ETH_FCS_LEN;
423 if (adapter->netdev->features & NETIF_F_FCOE_MTU)
424 max_frame = max(max_frame, IXGBE_FCOE_JUMBO_FRAME_SIZE);
427 ixgbe_dcb_calculate_tc_credits(&adapter->hw, &adapter->dcb_cfg,
428 max_frame, DCB_TX_CONFIG);
429 ixgbe_dcb_calculate_tc_credits(&adapter->hw, &adapter->dcb_cfg,
430 max_frame, DCB_RX_CONFIG);
432 ixgbe_dcb_unpack_refill(&adapter->dcb_cfg,
433 DCB_TX_CONFIG, refill);
434 ixgbe_dcb_unpack_max(&adapter->dcb_cfg, max);
435 ixgbe_dcb_unpack_bwgid(&adapter->dcb_cfg,
436 DCB_TX_CONFIG, bwg_id);
437 ixgbe_dcb_unpack_prio(&adapter->dcb_cfg,
438 DCB_TX_CONFIG, prio_type);
440 ixgbe_dcb_hw_ets_config(&adapter->hw, refill, max,
441 bwg_id, prio_type, prio_tc);
444 if (adapter->dcb_cfg.pfc_mode_enable)
445 adapter->hw.fc.current_mode = ixgbe_fc_pfc;
447 if (adapter->dcb_set_bitmap & BIT_APP_UPCHG)
448 clear_bit(__IXGBE_RESETTING, &adapter->state);
449 adapter->dcb_set_bitmap = 0x00;
453 static u8 ixgbe_dcbnl_getcap(struct net_device *netdev, int capid, u8 *cap)
455 struct ixgbe_adapter *adapter = netdev_priv(netdev);
458 case DCB_CAP_ATTR_PG:
461 case DCB_CAP_ATTR_PFC:
464 case DCB_CAP_ATTR_UP2TC:
467 case DCB_CAP_ATTR_PG_TCS:
470 case DCB_CAP_ATTR_PFC_TCS:
473 case DCB_CAP_ATTR_GSP:
476 case DCB_CAP_ATTR_BCN:
479 case DCB_CAP_ATTR_DCBX:
480 *cap = adapter->dcbx_cap;
490 static u8 ixgbe_dcbnl_getnumtcs(struct net_device *netdev, int tcid, u8 *num)
492 struct ixgbe_adapter *adapter = netdev_priv(netdev);
495 if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
497 case DCB_NUMTCS_ATTR_PG:
498 *num = MAX_TRAFFIC_CLASS;
500 case DCB_NUMTCS_ATTR_PFC:
501 *num = MAX_TRAFFIC_CLASS;
514 static u8 ixgbe_dcbnl_setnumtcs(struct net_device *netdev, int tcid, u8 num)
519 static u8 ixgbe_dcbnl_getpfcstate(struct net_device *netdev)
521 struct ixgbe_adapter *adapter = netdev_priv(netdev);
523 return adapter->dcb_cfg.pfc_mode_enable;
526 static void ixgbe_dcbnl_setpfcstate(struct net_device *netdev, u8 state)
528 struct ixgbe_adapter *adapter = netdev_priv(netdev);
530 adapter->temp_dcb_cfg.pfc_mode_enable = state;
531 if (adapter->temp_dcb_cfg.pfc_mode_enable !=
532 adapter->dcb_cfg.pfc_mode_enable)
533 adapter->dcb_set_bitmap |= BIT_PFC;
537 * ixgbe_dcbnl_getapp - retrieve the DCBX application user priority
538 * @netdev : the corresponding netdev
539 * @idtype : identifies the id as ether type or TCP/UDP port number
540 * @id: id is either ether type or TCP/UDP port number
542 * Returns : on success, returns a non-zero 802.1p user priority bitmap
543 * otherwise returns 0 as the invalid user priority bitmap to indicate an
546 static u8 ixgbe_dcbnl_getapp(struct net_device *netdev, u8 idtype, u16 id)
548 struct ixgbe_adapter *adapter = netdev_priv(netdev);
549 struct dcb_app app = {
554 if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_CEE))
557 return dcb_getapp(netdev, &app);
560 static int ixgbe_dcbnl_ieee_getets(struct net_device *dev,
561 struct ieee_ets *ets)
563 struct ixgbe_adapter *adapter = netdev_priv(dev);
564 struct ieee_ets *my_ets = adapter->ixgbe_ieee_ets;
566 /* No IEEE PFC settings available */
570 ets->ets_cap = MAX_TRAFFIC_CLASS;
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 __u16 refill[IEEE_8021QAZ_MAX_TCS], max[IEEE_8021QAZ_MAX_TCS];
584 __u8 prio_type[IEEE_8021QAZ_MAX_TCS];
585 int max_frame = dev->mtu + ETH_HLEN + ETH_FCS_LEN;
587 __u64 *p = (__u64 *) ets->prio_tc;
588 /* naively give each TC a bwg to map onto CEE hardware */
589 __u8 bwg_id[IEEE_8021QAZ_MAX_TCS] = {0, 1, 2, 3, 4, 5, 6, 7};
591 if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE))
594 if (!adapter->ixgbe_ieee_ets) {
595 adapter->ixgbe_ieee_ets = kmalloc(sizeof(struct ieee_ets),
597 if (!adapter->ixgbe_ieee_ets)
601 memcpy(adapter->ixgbe_ieee_ets, ets, sizeof(*adapter->ixgbe_ieee_ets));
603 /* Map TSA onto CEE prio type */
604 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
605 switch (ets->tc_tsa[i]) {
606 case IEEE_8021QAZ_TSA_STRICT:
609 case IEEE_8021QAZ_TSA_ETS:
613 /* Hardware only supports priority strict or
614 * ETS transmission selection algorithms if
615 * we receive some other value from dcbnl
623 ixgbe_dcbnl_set_state(dev, 1);
625 ixgbe_dcbnl_set_state(dev, 0);
627 ixgbe_ieee_credits(ets->tc_tx_bw, refill, max, max_frame);
628 err = ixgbe_dcb_hw_ets_config(&adapter->hw, refill, max,
629 bwg_id, prio_type, ets->prio_tc);
633 static int ixgbe_dcbnl_ieee_getpfc(struct net_device *dev,
634 struct ieee_pfc *pfc)
636 struct ixgbe_adapter *adapter = netdev_priv(dev);
637 struct ieee_pfc *my_pfc = adapter->ixgbe_ieee_pfc;
640 /* No IEEE PFC settings available */
644 pfc->pfc_cap = MAX_TRAFFIC_CLASS;
645 pfc->pfc_en = my_pfc->pfc_en;
646 pfc->mbc = my_pfc->mbc;
647 pfc->delay = my_pfc->delay;
649 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
650 pfc->requests[i] = adapter->stats.pxoffrxc[i];
651 pfc->indications[i] = adapter->stats.pxofftxc[i];
657 static int ixgbe_dcbnl_ieee_setpfc(struct net_device *dev,
658 struct ieee_pfc *pfc)
660 struct ixgbe_adapter *adapter = netdev_priv(dev);
663 if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE))
666 if (!adapter->ixgbe_ieee_pfc) {
667 adapter->ixgbe_ieee_pfc = kmalloc(sizeof(struct ieee_pfc),
669 if (!adapter->ixgbe_ieee_pfc)
673 memcpy(adapter->ixgbe_ieee_pfc, pfc, sizeof(*adapter->ixgbe_ieee_pfc));
674 err = ixgbe_dcb_hw_pfc_config(&adapter->hw, pfc->pfc_en);
678 static int ixgbe_dcbnl_ieee_setapp(struct net_device *dev,
681 struct ixgbe_adapter *adapter = netdev_priv(dev);
683 if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE))
686 dcb_setapp(dev, app);
689 if (app->selector == 1 && app->protocol == ETH_P_FCOE &&
690 adapter->fcoe.tc == app->priority)
691 ixgbe_dcbnl_set_all(dev);
696 static u8 ixgbe_dcbnl_getdcbx(struct net_device *dev)
698 struct ixgbe_adapter *adapter = netdev_priv(dev);
699 return adapter->dcbx_cap;
702 static u8 ixgbe_dcbnl_setdcbx(struct net_device *dev, u8 mode)
704 struct ixgbe_adapter *adapter = netdev_priv(dev);
705 struct ieee_ets ets = {0};
706 struct ieee_pfc pfc = {0};
708 /* no support for LLD_MANAGED modes or CEE+IEEE */
709 if ((mode & DCB_CAP_DCBX_LLD_MANAGED) ||
710 ((mode & DCB_CAP_DCBX_VER_IEEE) && (mode & DCB_CAP_DCBX_VER_CEE)) ||
711 !(mode & DCB_CAP_DCBX_HOST))
714 if (mode == adapter->dcbx_cap)
717 adapter->dcbx_cap = mode;
719 /* ETS and PFC defaults */
723 if (mode & DCB_CAP_DCBX_VER_IEEE) {
724 ixgbe_dcbnl_ieee_setets(dev, &ets);
725 ixgbe_dcbnl_ieee_setpfc(dev, &pfc);
726 } else if (mode & DCB_CAP_DCBX_VER_CEE) {
727 adapter->dcb_set_bitmap |= (BIT_PFC & BIT_PG_TX & BIT_PG_RX);
728 ixgbe_dcbnl_set_all(dev);
730 /* Drop into single TC mode strict priority as this
731 * indicates CEE and IEEE versions are disabled
733 ixgbe_dcbnl_ieee_setets(dev, &ets);
734 ixgbe_dcbnl_ieee_setpfc(dev, &pfc);
735 ixgbe_dcbnl_set_state(dev, 0);
741 const struct dcbnl_rtnl_ops dcbnl_ops = {
742 .ieee_getets = ixgbe_dcbnl_ieee_getets,
743 .ieee_setets = ixgbe_dcbnl_ieee_setets,
744 .ieee_getpfc = ixgbe_dcbnl_ieee_getpfc,
745 .ieee_setpfc = ixgbe_dcbnl_ieee_setpfc,
746 .ieee_setapp = ixgbe_dcbnl_ieee_setapp,
747 .getstate = ixgbe_dcbnl_get_state,
748 .setstate = ixgbe_dcbnl_set_state,
749 .getpermhwaddr = ixgbe_dcbnl_get_perm_hw_addr,
750 .setpgtccfgtx = ixgbe_dcbnl_set_pg_tc_cfg_tx,
751 .setpgbwgcfgtx = ixgbe_dcbnl_set_pg_bwg_cfg_tx,
752 .setpgtccfgrx = ixgbe_dcbnl_set_pg_tc_cfg_rx,
753 .setpgbwgcfgrx = ixgbe_dcbnl_set_pg_bwg_cfg_rx,
754 .getpgtccfgtx = ixgbe_dcbnl_get_pg_tc_cfg_tx,
755 .getpgbwgcfgtx = ixgbe_dcbnl_get_pg_bwg_cfg_tx,
756 .getpgtccfgrx = ixgbe_dcbnl_get_pg_tc_cfg_rx,
757 .getpgbwgcfgrx = ixgbe_dcbnl_get_pg_bwg_cfg_rx,
758 .setpfccfg = ixgbe_dcbnl_set_pfc_cfg,
759 .getpfccfg = ixgbe_dcbnl_get_pfc_cfg,
760 .setall = ixgbe_dcbnl_set_all,
761 .getcap = ixgbe_dcbnl_getcap,
762 .getnumtcs = ixgbe_dcbnl_getnumtcs,
763 .setnumtcs = ixgbe_dcbnl_setnumtcs,
764 .getpfcstate = ixgbe_dcbnl_getpfcstate,
765 .setpfcstate = ixgbe_dcbnl_setpfcstate,
766 .getapp = ixgbe_dcbnl_getapp,
767 .getdcbx = ixgbe_dcbnl_getdcbx,
768 .setdcbx = ixgbe_dcbnl_setdcbx,