1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 1999 - 2018 Intel Corporation. */
5 #include <linux/dcbnl.h>
6 #include "ixgbe_dcb_82598.h"
7 #include "ixgbe_dcb_82599.h"
8 #include "ixgbe_sriov.h"
10 /* Callbacks for DCB netlink in the kernel */
12 #define BIT_PG_RX 0x04
13 #define BIT_PG_TX 0x08
14 #define BIT_APP_UPCHG 0x10
16 /* Responses for the DCB_C_SET_ALL command */
17 #define DCB_HW_CHG_RST 0 /* DCB configuration changed with reset */
18 #define DCB_NO_HW_CHG 1 /* DCB configuration did not change */
19 #define DCB_HW_CHG 2 /* DCB configuration changed, no reset */
21 static int ixgbe_copy_dcb_cfg(struct ixgbe_adapter
*adapter
, int tc_max
)
23 struct ixgbe_dcb_config
*scfg
= &adapter
->temp_dcb_cfg
;
24 struct ixgbe_dcb_config
*dcfg
= &adapter
->dcb_cfg
;
25 struct tc_configuration
*src
= NULL
;
26 struct tc_configuration
*dst
= NULL
;
28 int tx
= DCB_TX_CONFIG
;
29 int rx
= DCB_RX_CONFIG
;
32 struct dcb_app app
= {
33 .selector
= DCB_APP_IDTYPE_ETHTYPE
,
34 .protocol
= ETH_P_FCOE
,
36 u8 up
= dcb_getapp(adapter
->netdev
, &app
);
38 if (up
&& !(up
& BIT(adapter
->fcoe
.up
)))
39 changes
|= BIT_APP_UPCHG
;
42 for (i
= DCB_PG_ATTR_TC_0
; i
< tc_max
+ DCB_PG_ATTR_TC_0
; i
++) {
43 src
= &scfg
->tc_config
[i
- DCB_PG_ATTR_TC_0
];
44 dst
= &dcfg
->tc_config
[i
- DCB_PG_ATTR_TC_0
];
46 if (dst
->path
[tx
].prio_type
!= src
->path
[tx
].prio_type
) {
47 dst
->path
[tx
].prio_type
= src
->path
[tx
].prio_type
;
51 if (dst
->path
[tx
].bwg_id
!= src
->path
[tx
].bwg_id
) {
52 dst
->path
[tx
].bwg_id
= src
->path
[tx
].bwg_id
;
56 if (dst
->path
[tx
].bwg_percent
!= src
->path
[tx
].bwg_percent
) {
57 dst
->path
[tx
].bwg_percent
= src
->path
[tx
].bwg_percent
;
61 if (dst
->path
[tx
].up_to_tc_bitmap
!=
62 src
->path
[tx
].up_to_tc_bitmap
) {
63 dst
->path
[tx
].up_to_tc_bitmap
=
64 src
->path
[tx
].up_to_tc_bitmap
;
65 changes
|= (BIT_PG_TX
| BIT_PFC
| BIT_APP_UPCHG
);
68 if (dst
->path
[rx
].prio_type
!= src
->path
[rx
].prio_type
) {
69 dst
->path
[rx
].prio_type
= src
->path
[rx
].prio_type
;
73 if (dst
->path
[rx
].bwg_id
!= src
->path
[rx
].bwg_id
) {
74 dst
->path
[rx
].bwg_id
= src
->path
[rx
].bwg_id
;
78 if (dst
->path
[rx
].bwg_percent
!= src
->path
[rx
].bwg_percent
) {
79 dst
->path
[rx
].bwg_percent
= src
->path
[rx
].bwg_percent
;
83 if (dst
->path
[rx
].up_to_tc_bitmap
!=
84 src
->path
[rx
].up_to_tc_bitmap
) {
85 dst
->path
[rx
].up_to_tc_bitmap
=
86 src
->path
[rx
].up_to_tc_bitmap
;
87 changes
|= (BIT_PG_RX
| BIT_PFC
| BIT_APP_UPCHG
);
91 for (i
= DCB_PG_ATTR_BW_ID_0
; i
< DCB_PG_ATTR_BW_ID_MAX
; i
++) {
92 j
= i
- DCB_PG_ATTR_BW_ID_0
;
93 if (dcfg
->bw_percentage
[tx
][j
] != scfg
->bw_percentage
[tx
][j
]) {
94 dcfg
->bw_percentage
[tx
][j
] = scfg
->bw_percentage
[tx
][j
];
97 if (dcfg
->bw_percentage
[rx
][j
] != scfg
->bw_percentage
[rx
][j
]) {
98 dcfg
->bw_percentage
[rx
][j
] = scfg
->bw_percentage
[rx
][j
];
103 for (i
= DCB_PFC_UP_ATTR_0
; i
< DCB_PFC_UP_ATTR_MAX
; i
++) {
104 j
= i
- DCB_PFC_UP_ATTR_0
;
105 if (dcfg
->tc_config
[j
].dcb_pfc
!= scfg
->tc_config
[j
].dcb_pfc
) {
106 dcfg
->tc_config
[j
].dcb_pfc
= scfg
->tc_config
[j
].dcb_pfc
;
111 if (dcfg
->pfc_mode_enable
!= scfg
->pfc_mode_enable
) {
112 dcfg
->pfc_mode_enable
= scfg
->pfc_mode_enable
;
119 static u8
ixgbe_dcbnl_get_state(struct net_device
*netdev
)
121 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
123 return !!(adapter
->flags
& IXGBE_FLAG_DCB_ENABLED
);
126 static u8
ixgbe_dcbnl_set_state(struct net_device
*netdev
, u8 state
)
128 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
130 /* Fail command if not in CEE mode */
131 if (!(adapter
->dcbx_cap
& DCB_CAP_DCBX_VER_CEE
))
134 /* verify there is something to do, if not then exit */
135 if (!state
== !(adapter
->flags
& IXGBE_FLAG_DCB_ENABLED
))
138 return !!ixgbe_setup_tc(netdev
,
139 state
? adapter
->dcb_cfg
.num_tcs
.pg_tcs
: 0);
142 static void ixgbe_dcbnl_get_perm_hw_addr(struct net_device
*netdev
,
145 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
148 memset(perm_addr
, 0xff, MAX_ADDR_LEN
);
150 for (i
= 0; i
< netdev
->addr_len
; i
++)
151 perm_addr
[i
] = adapter
->hw
.mac
.perm_addr
[i
];
153 switch (adapter
->hw
.mac
.type
) {
154 case ixgbe_mac_82599EB
:
157 for (j
= 0; j
< netdev
->addr_len
; j
++, i
++)
158 perm_addr
[i
] = adapter
->hw
.mac
.san_addr
[j
];
165 static void ixgbe_dcbnl_set_pg_tc_cfg_tx(struct net_device
*netdev
, int tc
,
166 u8 prio
, u8 bwg_id
, u8 bw_pct
,
169 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
171 if (prio
!= DCB_ATTR_VALUE_UNDEFINED
)
172 adapter
->temp_dcb_cfg
.tc_config
[tc
].path
[0].prio_type
= prio
;
173 if (bwg_id
!= DCB_ATTR_VALUE_UNDEFINED
)
174 adapter
->temp_dcb_cfg
.tc_config
[tc
].path
[0].bwg_id
= bwg_id
;
175 if (bw_pct
!= DCB_ATTR_VALUE_UNDEFINED
)
176 adapter
->temp_dcb_cfg
.tc_config
[tc
].path
[0].bwg_percent
=
178 if (up_map
!= DCB_ATTR_VALUE_UNDEFINED
)
179 adapter
->temp_dcb_cfg
.tc_config
[tc
].path
[0].up_to_tc_bitmap
=
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
;
191 static void ixgbe_dcbnl_set_pg_tc_cfg_rx(struct net_device
*netdev
, int tc
,
192 u8 prio
, u8 bwg_id
, u8 bw_pct
,
195 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
197 if (prio
!= DCB_ATTR_VALUE_UNDEFINED
)
198 adapter
->temp_dcb_cfg
.tc_config
[tc
].path
[1].prio_type
= prio
;
199 if (bwg_id
!= DCB_ATTR_VALUE_UNDEFINED
)
200 adapter
->temp_dcb_cfg
.tc_config
[tc
].path
[1].bwg_id
= bwg_id
;
201 if (bw_pct
!= DCB_ATTR_VALUE_UNDEFINED
)
202 adapter
->temp_dcb_cfg
.tc_config
[tc
].path
[1].bwg_percent
=
204 if (up_map
!= DCB_ATTR_VALUE_UNDEFINED
)
205 adapter
->temp_dcb_cfg
.tc_config
[tc
].path
[1].up_to_tc_bitmap
=
209 static void ixgbe_dcbnl_set_pg_bwg_cfg_rx(struct net_device
*netdev
, int bwg_id
,
212 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
214 adapter
->temp_dcb_cfg
.bw_percentage
[1][bwg_id
] = bw_pct
;
217 static void ixgbe_dcbnl_get_pg_tc_cfg_tx(struct net_device
*netdev
, int tc
,
218 u8
*prio
, u8
*bwg_id
, u8
*bw_pct
,
221 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
223 *prio
= adapter
->dcb_cfg
.tc_config
[tc
].path
[0].prio_type
;
224 *bwg_id
= adapter
->dcb_cfg
.tc_config
[tc
].path
[0].bwg_id
;
225 *bw_pct
= adapter
->dcb_cfg
.tc_config
[tc
].path
[0].bwg_percent
;
226 *up_map
= adapter
->dcb_cfg
.tc_config
[tc
].path
[0].up_to_tc_bitmap
;
229 static void ixgbe_dcbnl_get_pg_bwg_cfg_tx(struct net_device
*netdev
, int bwg_id
,
232 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
234 *bw_pct
= adapter
->dcb_cfg
.bw_percentage
[0][bwg_id
];
237 static void ixgbe_dcbnl_get_pg_tc_cfg_rx(struct net_device
*netdev
, int tc
,
238 u8
*prio
, u8
*bwg_id
, u8
*bw_pct
,
241 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
243 *prio
= adapter
->dcb_cfg
.tc_config
[tc
].path
[1].prio_type
;
244 *bwg_id
= adapter
->dcb_cfg
.tc_config
[tc
].path
[1].bwg_id
;
245 *bw_pct
= adapter
->dcb_cfg
.tc_config
[tc
].path
[1].bwg_percent
;
246 *up_map
= adapter
->dcb_cfg
.tc_config
[tc
].path
[1].up_to_tc_bitmap
;
249 static void ixgbe_dcbnl_get_pg_bwg_cfg_rx(struct net_device
*netdev
, int bwg_id
,
252 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
254 *bw_pct
= adapter
->dcb_cfg
.bw_percentage
[1][bwg_id
];
257 static void ixgbe_dcbnl_set_pfc_cfg(struct net_device
*netdev
, int priority
,
260 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
262 adapter
->temp_dcb_cfg
.tc_config
[priority
].dcb_pfc
= setting
;
263 if (adapter
->temp_dcb_cfg
.tc_config
[priority
].dcb_pfc
!=
264 adapter
->dcb_cfg
.tc_config
[priority
].dcb_pfc
)
265 adapter
->temp_dcb_cfg
.pfc_mode_enable
= true;
268 static void ixgbe_dcbnl_get_pfc_cfg(struct net_device
*netdev
, int priority
,
271 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
273 *setting
= adapter
->dcb_cfg
.tc_config
[priority
].dcb_pfc
;
276 static void ixgbe_dcbnl_devreset(struct net_device
*dev
)
278 struct ixgbe_adapter
*adapter
= netdev_priv(dev
);
280 while (test_and_set_bit(__IXGBE_RESETTING
, &adapter
->state
))
281 usleep_range(1000, 2000);
283 if (netif_running(dev
))
284 dev
->netdev_ops
->ndo_stop(dev
);
286 ixgbe_clear_interrupt_scheme(adapter
);
287 ixgbe_init_interrupt_scheme(adapter
);
289 if (netif_running(dev
))
290 dev
->netdev_ops
->ndo_open(dev
);
292 clear_bit(__IXGBE_RESETTING
, &adapter
->state
);
295 static u8
ixgbe_dcbnl_set_all(struct net_device
*netdev
)
297 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
298 struct ixgbe_dcb_config
*dcb_cfg
= &adapter
->dcb_cfg
;
299 struct ixgbe_hw
*hw
= &adapter
->hw
;
300 int ret
= DCB_NO_HW_CHG
;
303 /* Fail command if not in CEE mode */
304 if (!(adapter
->dcbx_cap
& DCB_CAP_DCBX_VER_CEE
))
305 return DCB_NO_HW_CHG
;
307 adapter
->dcb_set_bitmap
|= ixgbe_copy_dcb_cfg(adapter
,
309 if (!adapter
->dcb_set_bitmap
)
310 return DCB_NO_HW_CHG
;
312 if (adapter
->dcb_set_bitmap
& (BIT_PG_TX
|BIT_PG_RX
)) {
313 u16 refill
[MAX_TRAFFIC_CLASS
], max
[MAX_TRAFFIC_CLASS
];
314 u8 bwg_id
[MAX_TRAFFIC_CLASS
], prio_type
[MAX_TRAFFIC_CLASS
];
315 /* Priority to TC mapping in CEE case default to 1:1 */
316 u8 prio_tc
[MAX_USER_PRIORITY
];
317 int max_frame
= adapter
->netdev
->mtu
+ ETH_HLEN
+ ETH_FCS_LEN
;
320 if (adapter
->netdev
->fcoe_mtu
)
321 max_frame
= max(max_frame
, IXGBE_FCOE_JUMBO_FRAME_SIZE
);
324 ixgbe_dcb_calculate_tc_credits(hw
, dcb_cfg
, max_frame
,
326 ixgbe_dcb_calculate_tc_credits(hw
, dcb_cfg
, max_frame
,
329 ixgbe_dcb_unpack_refill(dcb_cfg
, DCB_TX_CONFIG
, refill
);
330 ixgbe_dcb_unpack_max(dcb_cfg
, max
);
331 ixgbe_dcb_unpack_bwgid(dcb_cfg
, DCB_TX_CONFIG
, bwg_id
);
332 ixgbe_dcb_unpack_prio(dcb_cfg
, DCB_TX_CONFIG
, prio_type
);
333 ixgbe_dcb_unpack_map(dcb_cfg
, DCB_TX_CONFIG
, prio_tc
);
335 ixgbe_dcb_hw_ets_config(hw
, refill
, max
, bwg_id
,
338 for (i
= 0; i
< IEEE_8021QAZ_MAX_TCS
; i
++)
339 netdev_set_prio_tc_map(netdev
, i
, prio_tc
[i
]);
341 ret
= DCB_HW_CHG_RST
;
344 if (adapter
->dcb_set_bitmap
& BIT_PFC
) {
345 if (dcb_cfg
->pfc_mode_enable
) {
347 u8 prio_tc
[MAX_USER_PRIORITY
];
349 ixgbe_dcb_unpack_map(dcb_cfg
, DCB_TX_CONFIG
, prio_tc
);
350 ixgbe_dcb_unpack_pfc(dcb_cfg
, &pfc_en
);
351 ixgbe_dcb_hw_pfc_config(hw
, pfc_en
, prio_tc
);
353 hw
->mac
.ops
.fc_enable(hw
);
356 ixgbe_set_rx_drop_en(adapter
);
362 /* Reprogram FCoE hardware offloads when the traffic class
363 * FCoE is using changes. This happens if the APP info
364 * changes or the up2tc mapping is updated.
366 if (adapter
->dcb_set_bitmap
& BIT_APP_UPCHG
) {
367 struct dcb_app app
= {
368 .selector
= DCB_APP_IDTYPE_ETHTYPE
,
369 .protocol
= ETH_P_FCOE
,
371 u8 up
= dcb_getapp(netdev
, &app
);
373 adapter
->fcoe
.up
= ffs(up
) - 1;
374 ixgbe_dcbnl_devreset(netdev
);
375 ret
= DCB_HW_CHG_RST
;
379 adapter
->dcb_set_bitmap
= 0x00;
383 static u8
ixgbe_dcbnl_getcap(struct net_device
*netdev
, int capid
, u8
*cap
)
385 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
388 case DCB_CAP_ATTR_PG
:
391 case DCB_CAP_ATTR_PFC
:
394 case DCB_CAP_ATTR_UP2TC
:
397 case DCB_CAP_ATTR_PG_TCS
:
400 case DCB_CAP_ATTR_PFC_TCS
:
403 case DCB_CAP_ATTR_GSP
:
406 case DCB_CAP_ATTR_BCN
:
409 case DCB_CAP_ATTR_DCBX
:
410 *cap
= adapter
->dcbx_cap
;
420 static int ixgbe_dcbnl_getnumtcs(struct net_device
*netdev
, int tcid
, u8
*num
)
422 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
424 if (adapter
->flags
& IXGBE_FLAG_DCB_ENABLED
) {
426 case DCB_NUMTCS_ATTR_PG
:
427 *num
= adapter
->dcb_cfg
.num_tcs
.pg_tcs
;
429 case DCB_NUMTCS_ATTR_PFC
:
430 *num
= adapter
->dcb_cfg
.num_tcs
.pfc_tcs
;
442 static int ixgbe_dcbnl_setnumtcs(struct net_device
*netdev
, int tcid
, u8 num
)
447 static u8
ixgbe_dcbnl_getpfcstate(struct net_device
*netdev
)
449 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
451 return adapter
->dcb_cfg
.pfc_mode_enable
;
454 static void ixgbe_dcbnl_setpfcstate(struct net_device
*netdev
, u8 state
)
456 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
458 adapter
->temp_dcb_cfg
.pfc_mode_enable
= state
;
462 * ixgbe_dcbnl_getapp - retrieve the DCBX application user priority
463 * @netdev : the corresponding netdev
464 * @idtype : identifies the id as ether type or TCP/UDP port number
465 * @id: id is either ether type or TCP/UDP port number
467 * Returns : on success, returns a non-zero 802.1p user priority bitmap
468 * otherwise returns -EINVAL as the invalid user priority bitmap to indicate an
471 static int ixgbe_dcbnl_getapp(struct net_device
*netdev
, u8 idtype
, u16 id
)
473 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
474 struct dcb_app app
= {
479 if (!(adapter
->dcbx_cap
& DCB_CAP_DCBX_VER_CEE
))
482 return dcb_getapp(netdev
, &app
);
485 static int ixgbe_dcbnl_ieee_getets(struct net_device
*dev
,
486 struct ieee_ets
*ets
)
488 struct ixgbe_adapter
*adapter
= netdev_priv(dev
);
489 struct ieee_ets
*my_ets
= adapter
->ixgbe_ieee_ets
;
491 ets
->ets_cap
= adapter
->dcb_cfg
.num_tcs
.pg_tcs
;
493 /* No IEEE PFC settings available */
497 ets
->cbs
= my_ets
->cbs
;
498 memcpy(ets
->tc_tx_bw
, my_ets
->tc_tx_bw
, sizeof(ets
->tc_tx_bw
));
499 memcpy(ets
->tc_rx_bw
, my_ets
->tc_rx_bw
, sizeof(ets
->tc_rx_bw
));
500 memcpy(ets
->tc_tsa
, my_ets
->tc_tsa
, sizeof(ets
->tc_tsa
));
501 memcpy(ets
->prio_tc
, my_ets
->prio_tc
, sizeof(ets
->prio_tc
));
505 static int ixgbe_dcbnl_ieee_setets(struct net_device
*dev
,
506 struct ieee_ets
*ets
)
508 struct ixgbe_adapter
*adapter
= netdev_priv(dev
);
509 int max_frame
= dev
->mtu
+ ETH_HLEN
+ ETH_FCS_LEN
;
514 if (!(adapter
->dcbx_cap
& DCB_CAP_DCBX_VER_IEEE
))
517 if (!adapter
->ixgbe_ieee_ets
) {
518 adapter
->ixgbe_ieee_ets
= kmalloc(sizeof(struct ieee_ets
),
520 if (!adapter
->ixgbe_ieee_ets
)
523 /* initialize UP2TC mappings to invalid value */
524 for (i
= 0; i
< IEEE_8021QAZ_MAX_TCS
; i
++)
525 adapter
->ixgbe_ieee_ets
->prio_tc
[i
] =
526 IEEE_8021QAZ_MAX_TCS
;
527 /* if possible update UP2TC mappings from HW */
528 ixgbe_dcb_read_rtrup2tc(&adapter
->hw
,
529 adapter
->ixgbe_ieee_ets
->prio_tc
);
532 for (i
= 0; i
< IEEE_8021QAZ_MAX_TCS
; i
++) {
533 if (ets
->prio_tc
[i
] > max_tc
)
534 max_tc
= ets
->prio_tc
[i
];
535 if (ets
->prio_tc
[i
] != adapter
->ixgbe_ieee_ets
->prio_tc
[i
])
539 memcpy(adapter
->ixgbe_ieee_ets
, ets
, sizeof(*adapter
->ixgbe_ieee_ets
));
544 if (max_tc
> adapter
->dcb_cfg
.num_tcs
.pg_tcs
)
547 if (max_tc
!= adapter
->hw_tcs
) {
548 err
= ixgbe_setup_tc(dev
, max_tc
);
551 } else if (map_chg
) {
552 ixgbe_dcbnl_devreset(dev
);
555 return ixgbe_dcb_hw_ets(&adapter
->hw
, ets
, max_frame
);
558 static int ixgbe_dcbnl_ieee_getpfc(struct net_device
*dev
,
559 struct ieee_pfc
*pfc
)
561 struct ixgbe_adapter
*adapter
= netdev_priv(dev
);
562 struct ieee_pfc
*my_pfc
= adapter
->ixgbe_ieee_pfc
;
565 pfc
->pfc_cap
= adapter
->dcb_cfg
.num_tcs
.pfc_tcs
;
567 /* No IEEE PFC settings available */
571 pfc
->pfc_en
= my_pfc
->pfc_en
;
572 pfc
->mbc
= my_pfc
->mbc
;
573 pfc
->delay
= my_pfc
->delay
;
575 for (i
= 0; i
< MAX_TRAFFIC_CLASS
; i
++) {
576 pfc
->requests
[i
] = adapter
->stats
.pxoffrxc
[i
];
577 pfc
->indications
[i
] = adapter
->stats
.pxofftxc
[i
];
583 static int ixgbe_dcbnl_ieee_setpfc(struct net_device
*dev
,
584 struct ieee_pfc
*pfc
)
586 struct ixgbe_adapter
*adapter
= netdev_priv(dev
);
587 struct ixgbe_hw
*hw
= &adapter
->hw
;
591 if (!(adapter
->dcbx_cap
& DCB_CAP_DCBX_VER_IEEE
))
594 if (!adapter
->ixgbe_ieee_pfc
) {
595 adapter
->ixgbe_ieee_pfc
= kmalloc(sizeof(struct ieee_pfc
),
597 if (!adapter
->ixgbe_ieee_pfc
)
601 prio_tc
= adapter
->ixgbe_ieee_ets
->prio_tc
;
602 memcpy(adapter
->ixgbe_ieee_pfc
, pfc
, sizeof(*adapter
->ixgbe_ieee_pfc
));
604 /* Enable link flow control parameters if PFC is disabled */
606 err
= ixgbe_dcb_hw_pfc_config(hw
, pfc
->pfc_en
, prio_tc
);
608 err
= hw
->mac
.ops
.fc_enable(hw
);
610 ixgbe_set_rx_drop_en(adapter
);
615 static int ixgbe_dcbnl_ieee_setapp(struct net_device
*dev
,
618 struct ixgbe_adapter
*adapter
= netdev_priv(dev
);
621 if (!(adapter
->dcbx_cap
& DCB_CAP_DCBX_VER_IEEE
))
624 err
= dcb_ieee_setapp(dev
, app
);
629 if (app
->selector
== IEEE_8021QAZ_APP_SEL_ETHERTYPE
&&
630 app
->protocol
== ETH_P_FCOE
) {
631 u8 app_mask
= dcb_ieee_getapp_mask(dev
, app
);
633 if (app_mask
& BIT(adapter
->fcoe
.up
))
636 adapter
->fcoe
.up
= app
->priority
;
637 ixgbe_dcbnl_devreset(dev
);
641 /* VF devices should use default UP when available */
642 if (app
->selector
== IEEE_8021QAZ_APP_SEL_ETHERTYPE
&&
643 app
->protocol
== 0) {
646 adapter
->default_up
= app
->priority
;
648 for (vf
= 0; vf
< adapter
->num_vfs
; vf
++) {
649 struct vf_data_storage
*vfinfo
= &adapter
->vfinfo
[vf
];
652 ixgbe_set_vmvir(adapter
, vfinfo
->pf_vlan
,
660 static int ixgbe_dcbnl_ieee_delapp(struct net_device
*dev
,
663 struct ixgbe_adapter
*adapter
= netdev_priv(dev
);
666 if (!(adapter
->dcbx_cap
& DCB_CAP_DCBX_VER_IEEE
))
669 err
= dcb_ieee_delapp(dev
, app
);
672 if (!err
&& app
->selector
== IEEE_8021QAZ_APP_SEL_ETHERTYPE
&&
673 app
->protocol
== ETH_P_FCOE
) {
674 u8 app_mask
= dcb_ieee_getapp_mask(dev
, app
);
676 if (app_mask
& BIT(adapter
->fcoe
.up
))
679 adapter
->fcoe
.up
= app_mask
?
680 ffs(app_mask
) - 1 : IXGBE_FCOE_DEFTC
;
681 ixgbe_dcbnl_devreset(dev
);
684 /* IF default priority is being removed clear VF default UP */
685 if (app
->selector
== IEEE_8021QAZ_APP_SEL_ETHERTYPE
&&
686 app
->protocol
== 0 && adapter
->default_up
== app
->priority
) {
688 long unsigned int app_mask
= dcb_ieee_getapp_mask(dev
, app
);
689 int qos
= app_mask
? find_first_bit(&app_mask
, 8) : 0;
691 adapter
->default_up
= qos
;
693 for (vf
= 0; vf
< adapter
->num_vfs
; vf
++) {
694 struct vf_data_storage
*vfinfo
= &adapter
->vfinfo
[vf
];
697 ixgbe_set_vmvir(adapter
, vfinfo
->pf_vlan
,
705 static u8
ixgbe_dcbnl_getdcbx(struct net_device
*dev
)
707 struct ixgbe_adapter
*adapter
= netdev_priv(dev
);
708 return adapter
->dcbx_cap
;
711 static u8
ixgbe_dcbnl_setdcbx(struct net_device
*dev
, u8 mode
)
713 struct ixgbe_adapter
*adapter
= netdev_priv(dev
);
714 struct ieee_ets ets
= {0};
715 struct ieee_pfc pfc
= {0};
718 /* no support for LLD_MANAGED modes or CEE+IEEE */
719 if ((mode
& DCB_CAP_DCBX_LLD_MANAGED
) ||
720 ((mode
& DCB_CAP_DCBX_VER_IEEE
) && (mode
& DCB_CAP_DCBX_VER_CEE
)) ||
721 !(mode
& DCB_CAP_DCBX_HOST
))
724 if (mode
== adapter
->dcbx_cap
)
727 adapter
->dcbx_cap
= mode
;
729 /* ETS and PFC defaults */
733 if (mode
& DCB_CAP_DCBX_VER_IEEE
) {
734 ixgbe_dcbnl_ieee_setets(dev
, &ets
);
735 ixgbe_dcbnl_ieee_setpfc(dev
, &pfc
);
736 } else if (mode
& DCB_CAP_DCBX_VER_CEE
) {
737 u8 mask
= BIT_PFC
| BIT_PG_TX
| BIT_PG_RX
| BIT_APP_UPCHG
;
739 adapter
->dcb_set_bitmap
|= mask
;
740 ixgbe_dcbnl_set_all(dev
);
742 /* Drop into single TC mode strict priority as this
743 * indicates CEE and IEEE versions are disabled
745 ixgbe_dcbnl_ieee_setets(dev
, &ets
);
746 ixgbe_dcbnl_ieee_setpfc(dev
, &pfc
);
747 err
= ixgbe_setup_tc(dev
, 0);
753 const struct dcbnl_rtnl_ops ixgbe_dcbnl_ops
= {
754 .ieee_getets
= ixgbe_dcbnl_ieee_getets
,
755 .ieee_setets
= ixgbe_dcbnl_ieee_setets
,
756 .ieee_getpfc
= ixgbe_dcbnl_ieee_getpfc
,
757 .ieee_setpfc
= ixgbe_dcbnl_ieee_setpfc
,
758 .ieee_setapp
= ixgbe_dcbnl_ieee_setapp
,
759 .ieee_delapp
= ixgbe_dcbnl_ieee_delapp
,
760 .getstate
= ixgbe_dcbnl_get_state
,
761 .setstate
= ixgbe_dcbnl_set_state
,
762 .getpermhwaddr
= ixgbe_dcbnl_get_perm_hw_addr
,
763 .setpgtccfgtx
= ixgbe_dcbnl_set_pg_tc_cfg_tx
,
764 .setpgbwgcfgtx
= ixgbe_dcbnl_set_pg_bwg_cfg_tx
,
765 .setpgtccfgrx
= ixgbe_dcbnl_set_pg_tc_cfg_rx
,
766 .setpgbwgcfgrx
= ixgbe_dcbnl_set_pg_bwg_cfg_rx
,
767 .getpgtccfgtx
= ixgbe_dcbnl_get_pg_tc_cfg_tx
,
768 .getpgbwgcfgtx
= ixgbe_dcbnl_get_pg_bwg_cfg_tx
,
769 .getpgtccfgrx
= ixgbe_dcbnl_get_pg_tc_cfg_rx
,
770 .getpgbwgcfgrx
= ixgbe_dcbnl_get_pg_bwg_cfg_rx
,
771 .setpfccfg
= ixgbe_dcbnl_set_pfc_cfg
,
772 .getpfccfg
= ixgbe_dcbnl_get_pfc_cfg
,
773 .setall
= ixgbe_dcbnl_set_all
,
774 .getcap
= ixgbe_dcbnl_getcap
,
775 .getnumtcs
= ixgbe_dcbnl_getnumtcs
,
776 .setnumtcs
= ixgbe_dcbnl_setnumtcs
,
777 .getpfcstate
= ixgbe_dcbnl_getpfcstate
,
778 .setpfcstate
= ixgbe_dcbnl_setpfcstate
,
779 .getapp
= ixgbe_dcbnl_getapp
,
780 .getdcbx
= ixgbe_dcbnl_getdcbx
,
781 .setdcbx
= ixgbe_dcbnl_setdcbx
,