1 /*******************************************************************************
3 Intel 10 Gigabit PCI Express Linux driver
4 Copyright(c) 1999 - 2010 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_RESETLINK 0x40
41 #define BIT_LINKSPEED 0x80
43 /* Responses for the DCB_C_SET_ALL command */
44 #define DCB_HW_CHG_RST 0 /* DCB configuration changed with reset */
45 #define DCB_NO_HW_CHG 1 /* DCB configuration did not change */
46 #define DCB_HW_CHG 2 /* DCB configuration changed, no reset */
48 int ixgbe_copy_dcb_cfg(struct ixgbe_dcb_config
*src_dcb_cfg
,
49 struct ixgbe_dcb_config
*dst_dcb_cfg
, int tc_max
)
51 struct tc_configuration
*src_tc_cfg
= NULL
;
52 struct tc_configuration
*dst_tc_cfg
= NULL
;
55 if (!src_dcb_cfg
|| !dst_dcb_cfg
)
58 for (i
= DCB_PG_ATTR_TC_0
; i
< tc_max
+ DCB_PG_ATTR_TC_0
; i
++) {
59 src_tc_cfg
= &src_dcb_cfg
->tc_config
[i
- DCB_PG_ATTR_TC_0
];
60 dst_tc_cfg
= &dst_dcb_cfg
->tc_config
[i
- DCB_PG_ATTR_TC_0
];
62 dst_tc_cfg
->path
[DCB_TX_CONFIG
].prio_type
=
63 src_tc_cfg
->path
[DCB_TX_CONFIG
].prio_type
;
65 dst_tc_cfg
->path
[DCB_TX_CONFIG
].bwg_id
=
66 src_tc_cfg
->path
[DCB_TX_CONFIG
].bwg_id
;
68 dst_tc_cfg
->path
[DCB_TX_CONFIG
].bwg_percent
=
69 src_tc_cfg
->path
[DCB_TX_CONFIG
].bwg_percent
;
71 dst_tc_cfg
->path
[DCB_TX_CONFIG
].up_to_tc_bitmap
=
72 src_tc_cfg
->path
[DCB_TX_CONFIG
].up_to_tc_bitmap
;
74 dst_tc_cfg
->path
[DCB_RX_CONFIG
].prio_type
=
75 src_tc_cfg
->path
[DCB_RX_CONFIG
].prio_type
;
77 dst_tc_cfg
->path
[DCB_RX_CONFIG
].bwg_id
=
78 src_tc_cfg
->path
[DCB_RX_CONFIG
].bwg_id
;
80 dst_tc_cfg
->path
[DCB_RX_CONFIG
].bwg_percent
=
81 src_tc_cfg
->path
[DCB_RX_CONFIG
].bwg_percent
;
83 dst_tc_cfg
->path
[DCB_RX_CONFIG
].up_to_tc_bitmap
=
84 src_tc_cfg
->path
[DCB_RX_CONFIG
].up_to_tc_bitmap
;
87 for (i
= DCB_PG_ATTR_BW_ID_0
; i
< DCB_PG_ATTR_BW_ID_MAX
; i
++) {
88 dst_dcb_cfg
->bw_percentage
[DCB_TX_CONFIG
]
89 [i
-DCB_PG_ATTR_BW_ID_0
] = src_dcb_cfg
->bw_percentage
90 [DCB_TX_CONFIG
][i
-DCB_PG_ATTR_BW_ID_0
];
91 dst_dcb_cfg
->bw_percentage
[DCB_RX_CONFIG
]
92 [i
-DCB_PG_ATTR_BW_ID_0
] = src_dcb_cfg
->bw_percentage
93 [DCB_RX_CONFIG
][i
-DCB_PG_ATTR_BW_ID_0
];
96 for (i
= DCB_PFC_UP_ATTR_0
; i
< DCB_PFC_UP_ATTR_MAX
; i
++) {
97 dst_dcb_cfg
->tc_config
[i
- DCB_PFC_UP_ATTR_0
].dcb_pfc
=
98 src_dcb_cfg
->tc_config
[i
- DCB_PFC_UP_ATTR_0
].dcb_pfc
;
101 dst_dcb_cfg
->pfc_mode_enable
= src_dcb_cfg
->pfc_mode_enable
;
106 static u8
ixgbe_dcbnl_get_state(struct net_device
*netdev
)
108 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
110 return !!(adapter
->flags
& IXGBE_FLAG_DCB_ENABLED
);
113 static u8
ixgbe_dcbnl_set_state(struct net_device
*netdev
, u8 state
)
116 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
120 if (adapter
->flags
& IXGBE_FLAG_DCB_ENABLED
)
123 if (!(adapter
->flags
& IXGBE_FLAG_MSIX_ENABLED
)) {
124 e_err(drv
, "Enable failed, needs MSI-X\n");
129 if (netif_running(netdev
))
130 netdev
->netdev_ops
->ndo_stop(netdev
);
131 ixgbe_clear_interrupt_scheme(adapter
);
133 adapter
->flags
&= ~IXGBE_FLAG_RSS_ENABLED
;
134 switch (adapter
->hw
.mac
.type
) {
135 case ixgbe_mac_82598EB
:
136 adapter
->last_lfc_mode
= adapter
->hw
.fc
.current_mode
;
137 adapter
->hw
.fc
.requested_mode
= ixgbe_fc_none
;
139 case ixgbe_mac_82599EB
:
141 adapter
->flags
&= ~IXGBE_FLAG_FDIR_HASH_CAPABLE
;
142 adapter
->flags
&= ~IXGBE_FLAG_FDIR_PERFECT_CAPABLE
;
148 adapter
->flags
|= IXGBE_FLAG_DCB_ENABLED
;
149 ixgbe_init_interrupt_scheme(adapter
);
150 if (netif_running(netdev
))
151 netdev
->netdev_ops
->ndo_open(netdev
);
154 if (adapter
->flags
& IXGBE_FLAG_DCB_ENABLED
) {
155 if (netif_running(netdev
))
156 netdev
->netdev_ops
->ndo_stop(netdev
);
157 ixgbe_clear_interrupt_scheme(adapter
);
159 adapter
->hw
.fc
.requested_mode
= adapter
->last_lfc_mode
;
160 adapter
->temp_dcb_cfg
.pfc_mode_enable
= false;
161 adapter
->dcb_cfg
.pfc_mode_enable
= false;
162 adapter
->flags
&= ~IXGBE_FLAG_DCB_ENABLED
;
163 adapter
->flags
|= IXGBE_FLAG_RSS_ENABLED
;
164 switch (adapter
->hw
.mac
.type
) {
165 case ixgbe_mac_82599EB
:
167 adapter
->flags
|= IXGBE_FLAG_FDIR_HASH_CAPABLE
;
173 ixgbe_init_interrupt_scheme(adapter
);
174 if (netif_running(netdev
))
175 netdev
->netdev_ops
->ndo_open(netdev
);
182 static void ixgbe_dcbnl_get_perm_hw_addr(struct net_device
*netdev
,
185 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
188 memset(perm_addr
, 0xff, MAX_ADDR_LEN
);
190 for (i
= 0; i
< netdev
->addr_len
; i
++)
191 perm_addr
[i
] = adapter
->hw
.mac
.perm_addr
[i
];
193 switch (adapter
->hw
.mac
.type
) {
194 case ixgbe_mac_82599EB
:
196 for (j
= 0; j
< netdev
->addr_len
; j
++, i
++)
197 perm_addr
[i
] = adapter
->hw
.mac
.san_addr
[j
];
204 static void ixgbe_dcbnl_set_pg_tc_cfg_tx(struct net_device
*netdev
, int tc
,
205 u8 prio
, u8 bwg_id
, u8 bw_pct
,
208 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
210 if (prio
!= DCB_ATTR_VALUE_UNDEFINED
)
211 adapter
->temp_dcb_cfg
.tc_config
[tc
].path
[0].prio_type
= prio
;
212 if (bwg_id
!= DCB_ATTR_VALUE_UNDEFINED
)
213 adapter
->temp_dcb_cfg
.tc_config
[tc
].path
[0].bwg_id
= bwg_id
;
214 if (bw_pct
!= DCB_ATTR_VALUE_UNDEFINED
)
215 adapter
->temp_dcb_cfg
.tc_config
[tc
].path
[0].bwg_percent
=
217 if (up_map
!= DCB_ATTR_VALUE_UNDEFINED
)
218 adapter
->temp_dcb_cfg
.tc_config
[tc
].path
[0].up_to_tc_bitmap
=
221 if ((adapter
->temp_dcb_cfg
.tc_config
[tc
].path
[0].prio_type
!=
222 adapter
->dcb_cfg
.tc_config
[tc
].path
[0].prio_type
) ||
223 (adapter
->temp_dcb_cfg
.tc_config
[tc
].path
[0].bwg_id
!=
224 adapter
->dcb_cfg
.tc_config
[tc
].path
[0].bwg_id
) ||
225 (adapter
->temp_dcb_cfg
.tc_config
[tc
].path
[0].bwg_percent
!=
226 adapter
->dcb_cfg
.tc_config
[tc
].path
[0].bwg_percent
) ||
227 (adapter
->temp_dcb_cfg
.tc_config
[tc
].path
[0].up_to_tc_bitmap
!=
228 adapter
->dcb_cfg
.tc_config
[tc
].path
[0].up_to_tc_bitmap
))
229 adapter
->dcb_set_bitmap
|= BIT_PG_TX
;
232 static void ixgbe_dcbnl_set_pg_bwg_cfg_tx(struct net_device
*netdev
, int bwg_id
,
235 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
237 adapter
->temp_dcb_cfg
.bw_percentage
[0][bwg_id
] = bw_pct
;
239 if (adapter
->temp_dcb_cfg
.bw_percentage
[0][bwg_id
] !=
240 adapter
->dcb_cfg
.bw_percentage
[0][bwg_id
])
241 adapter
->dcb_set_bitmap
|= BIT_PG_TX
;
244 static void ixgbe_dcbnl_set_pg_tc_cfg_rx(struct net_device
*netdev
, int tc
,
245 u8 prio
, u8 bwg_id
, u8 bw_pct
,
248 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
250 if (prio
!= DCB_ATTR_VALUE_UNDEFINED
)
251 adapter
->temp_dcb_cfg
.tc_config
[tc
].path
[1].prio_type
= prio
;
252 if (bwg_id
!= DCB_ATTR_VALUE_UNDEFINED
)
253 adapter
->temp_dcb_cfg
.tc_config
[tc
].path
[1].bwg_id
= bwg_id
;
254 if (bw_pct
!= DCB_ATTR_VALUE_UNDEFINED
)
255 adapter
->temp_dcb_cfg
.tc_config
[tc
].path
[1].bwg_percent
=
257 if (up_map
!= DCB_ATTR_VALUE_UNDEFINED
)
258 adapter
->temp_dcb_cfg
.tc_config
[tc
].path
[1].up_to_tc_bitmap
=
261 if ((adapter
->temp_dcb_cfg
.tc_config
[tc
].path
[1].prio_type
!=
262 adapter
->dcb_cfg
.tc_config
[tc
].path
[1].prio_type
) ||
263 (adapter
->temp_dcb_cfg
.tc_config
[tc
].path
[1].bwg_id
!=
264 adapter
->dcb_cfg
.tc_config
[tc
].path
[1].bwg_id
) ||
265 (adapter
->temp_dcb_cfg
.tc_config
[tc
].path
[1].bwg_percent
!=
266 adapter
->dcb_cfg
.tc_config
[tc
].path
[1].bwg_percent
) ||
267 (adapter
->temp_dcb_cfg
.tc_config
[tc
].path
[1].up_to_tc_bitmap
!=
268 adapter
->dcb_cfg
.tc_config
[tc
].path
[1].up_to_tc_bitmap
))
269 adapter
->dcb_set_bitmap
|= BIT_PG_RX
;
272 static void ixgbe_dcbnl_set_pg_bwg_cfg_rx(struct net_device
*netdev
, int bwg_id
,
275 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
277 adapter
->temp_dcb_cfg
.bw_percentage
[1][bwg_id
] = bw_pct
;
279 if (adapter
->temp_dcb_cfg
.bw_percentage
[1][bwg_id
] !=
280 adapter
->dcb_cfg
.bw_percentage
[1][bwg_id
])
281 adapter
->dcb_set_bitmap
|= BIT_PG_RX
;
284 static void ixgbe_dcbnl_get_pg_tc_cfg_tx(struct net_device
*netdev
, int tc
,
285 u8
*prio
, u8
*bwg_id
, u8
*bw_pct
,
288 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
290 *prio
= adapter
->dcb_cfg
.tc_config
[tc
].path
[0].prio_type
;
291 *bwg_id
= adapter
->dcb_cfg
.tc_config
[tc
].path
[0].bwg_id
;
292 *bw_pct
= adapter
->dcb_cfg
.tc_config
[tc
].path
[0].bwg_percent
;
293 *up_map
= adapter
->dcb_cfg
.tc_config
[tc
].path
[0].up_to_tc_bitmap
;
296 static void ixgbe_dcbnl_get_pg_bwg_cfg_tx(struct net_device
*netdev
, int bwg_id
,
299 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
301 *bw_pct
= adapter
->dcb_cfg
.bw_percentage
[0][bwg_id
];
304 static void ixgbe_dcbnl_get_pg_tc_cfg_rx(struct net_device
*netdev
, int tc
,
305 u8
*prio
, u8
*bwg_id
, u8
*bw_pct
,
308 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
310 *prio
= adapter
->dcb_cfg
.tc_config
[tc
].path
[1].prio_type
;
311 *bwg_id
= adapter
->dcb_cfg
.tc_config
[tc
].path
[1].bwg_id
;
312 *bw_pct
= adapter
->dcb_cfg
.tc_config
[tc
].path
[1].bwg_percent
;
313 *up_map
= adapter
->dcb_cfg
.tc_config
[tc
].path
[1].up_to_tc_bitmap
;
316 static void ixgbe_dcbnl_get_pg_bwg_cfg_rx(struct net_device
*netdev
, int bwg_id
,
319 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
321 *bw_pct
= adapter
->dcb_cfg
.bw_percentage
[1][bwg_id
];
324 static void ixgbe_dcbnl_set_pfc_cfg(struct net_device
*netdev
, int priority
,
327 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
329 adapter
->temp_dcb_cfg
.tc_config
[priority
].dcb_pfc
= setting
;
330 if (adapter
->temp_dcb_cfg
.tc_config
[priority
].dcb_pfc
!=
331 adapter
->dcb_cfg
.tc_config
[priority
].dcb_pfc
) {
332 adapter
->dcb_set_bitmap
|= BIT_PFC
;
333 adapter
->temp_dcb_cfg
.pfc_mode_enable
= true;
337 static void ixgbe_dcbnl_get_pfc_cfg(struct net_device
*netdev
, int priority
,
340 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
342 *setting
= adapter
->dcb_cfg
.tc_config
[priority
].dcb_pfc
;
345 static u8
ixgbe_dcbnl_set_all(struct net_device
*netdev
)
347 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
351 if (!adapter
->dcb_set_bitmap
)
352 return DCB_NO_HW_CHG
;
354 ret
= ixgbe_copy_dcb_cfg(&adapter
->temp_dcb_cfg
, &adapter
->dcb_cfg
,
355 adapter
->ring_feature
[RING_F_DCB
].indices
);
358 return DCB_NO_HW_CHG
;
361 * Only take down the adapter if the configuration change
364 do_reset
= adapter
->dcb_set_bitmap
& (BIT_RESETLINK
| BIT_APP_UPCHG
);
367 while (test_and_set_bit(__IXGBE_RESETTING
, &adapter
->state
))
370 if (adapter
->dcb_set_bitmap
& BIT_APP_UPCHG
) {
371 if (netif_running(netdev
))
372 netdev
->netdev_ops
->ndo_stop(netdev
);
373 ixgbe_clear_interrupt_scheme(adapter
);
375 if (netif_running(netdev
))
380 if (adapter
->dcb_cfg
.pfc_mode_enable
) {
381 switch (adapter
->hw
.mac
.type
) {
382 case ixgbe_mac_82599EB
:
384 if (adapter
->hw
.fc
.current_mode
!= ixgbe_fc_pfc
)
385 adapter
->last_lfc_mode
=
386 adapter
->hw
.fc
.current_mode
;
391 adapter
->hw
.fc
.requested_mode
= ixgbe_fc_pfc
;
393 switch (adapter
->hw
.mac
.type
) {
394 case ixgbe_mac_82598EB
:
395 adapter
->hw
.fc
.requested_mode
= ixgbe_fc_none
;
397 case ixgbe_mac_82599EB
:
399 adapter
->hw
.fc
.requested_mode
= adapter
->last_lfc_mode
;
407 if (adapter
->dcb_set_bitmap
& BIT_APP_UPCHG
) {
408 ixgbe_init_interrupt_scheme(adapter
);
409 if (netif_running(netdev
))
410 netdev
->netdev_ops
->ndo_open(netdev
);
412 if (netif_running(netdev
))
415 ret
= DCB_HW_CHG_RST
;
418 if (adapter
->dcb_set_bitmap
& BIT_PFC
) {
420 ixgbe_dcb_unpack_pfc(&adapter
->dcb_cfg
, &pfc_en
);
422 if (adapter
->hw
.mac
.type
== ixgbe_mac_82598EB
)
423 ixgbe_dcb_config_pfc_82598(&adapter
->hw
, pfc_en
);
424 else if (adapter
->hw
.mac
.type
== ixgbe_mac_82599EB
)
425 ixgbe_dcb_config_pfc_82599(&adapter
->hw
, pfc_en
);
429 if (adapter
->dcb_set_bitmap
& (BIT_PG_TX
|BIT_PG_RX
)) {
430 u16 refill
[MAX_TRAFFIC_CLASS
], max
[MAX_TRAFFIC_CLASS
];
431 u8 bwg_id
[MAX_TRAFFIC_CLASS
], prio_type
[MAX_TRAFFIC_CLASS
];
432 int max_frame
= adapter
->netdev
->mtu
+ ETH_HLEN
+ ETH_FCS_LEN
;
435 if (adapter
->netdev
->features
& NETIF_F_FCOE_MTU
)
436 max_frame
= max(max_frame
, IXGBE_FCOE_JUMBO_FRAME_SIZE
);
439 ixgbe_dcb_calculate_tc_credits(&adapter
->hw
, &adapter
->dcb_cfg
,
440 max_frame
, DCB_TX_CONFIG
);
441 ixgbe_dcb_calculate_tc_credits(&adapter
->hw
, &adapter
->dcb_cfg
,
442 max_frame
, DCB_RX_CONFIG
);
444 ixgbe_dcb_unpack_refill(&adapter
->dcb_cfg
,
445 DCB_TX_CONFIG
, refill
);
446 ixgbe_dcb_unpack_max(&adapter
->dcb_cfg
, max
);
447 ixgbe_dcb_unpack_bwgid(&adapter
->dcb_cfg
,
448 DCB_TX_CONFIG
, bwg_id
);
449 ixgbe_dcb_unpack_prio(&adapter
->dcb_cfg
,
450 DCB_TX_CONFIG
, prio_type
);
452 ixgbe_dcb_hw_ets_config(&adapter
->hw
, refill
, max
,
456 if (adapter
->dcb_cfg
.pfc_mode_enable
)
457 adapter
->hw
.fc
.current_mode
= ixgbe_fc_pfc
;
460 clear_bit(__IXGBE_RESETTING
, &adapter
->state
);
461 adapter
->dcb_set_bitmap
= 0x00;
465 static u8
ixgbe_dcbnl_getcap(struct net_device
*netdev
, int capid
, u8
*cap
)
467 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
470 if (adapter
->flags
& IXGBE_FLAG_DCB_ENABLED
) {
472 case DCB_CAP_ATTR_PG
:
475 case DCB_CAP_ATTR_PFC
:
478 case DCB_CAP_ATTR_UP2TC
:
481 case DCB_CAP_ATTR_PG_TCS
:
484 case DCB_CAP_ATTR_PFC_TCS
:
487 case DCB_CAP_ATTR_GSP
:
490 case DCB_CAP_ATTR_BCN
:
504 static u8
ixgbe_dcbnl_getnumtcs(struct net_device
*netdev
, int tcid
, u8
*num
)
506 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
509 if (adapter
->flags
& IXGBE_FLAG_DCB_ENABLED
) {
511 case DCB_NUMTCS_ATTR_PG
:
512 *num
= MAX_TRAFFIC_CLASS
;
514 case DCB_NUMTCS_ATTR_PFC
:
515 *num
= MAX_TRAFFIC_CLASS
;
528 static u8
ixgbe_dcbnl_setnumtcs(struct net_device
*netdev
, int tcid
, u8 num
)
533 static u8
ixgbe_dcbnl_getpfcstate(struct net_device
*netdev
)
535 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
537 return adapter
->dcb_cfg
.pfc_mode_enable
;
540 static void ixgbe_dcbnl_setpfcstate(struct net_device
*netdev
, u8 state
)
542 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
544 adapter
->temp_dcb_cfg
.pfc_mode_enable
= state
;
545 if (adapter
->temp_dcb_cfg
.pfc_mode_enable
!=
546 adapter
->dcb_cfg
.pfc_mode_enable
)
547 adapter
->dcb_set_bitmap
|= BIT_PFC
;
551 * ixgbe_dcbnl_getapp - retrieve the DCBX application user priority
552 * @netdev : the corresponding netdev
553 * @idtype : identifies the id as ether type or TCP/UDP port number
554 * @id: id is either ether type or TCP/UDP port number
556 * Returns : on success, returns a non-zero 802.1p user priority bitmap
557 * otherwise returns 0 as the invalid user priority bitmap to indicate an
560 static u8
ixgbe_dcbnl_getapp(struct net_device
*netdev
, u8 idtype
, u16 id
)
565 case DCB_APP_IDTYPE_ETHTYPE
:
567 if (id
== ETH_P_FCOE
)
568 rval
= ixgbe_fcoe_getapp(netdev_priv(netdev
));
571 case DCB_APP_IDTYPE_PORTNUM
:
580 * ixgbe_dcbnl_setapp - set the DCBX application user priority
581 * @netdev : the corresponding netdev
582 * @idtype : identifies the id as ether type or TCP/UDP port number
583 * @id: id is either ether type or TCP/UDP port number
584 * @up: the 802.1p user priority bitmap
586 * Returns : 0 on success or 1 on error
588 static u8
ixgbe_dcbnl_setapp(struct net_device
*netdev
,
589 u8 idtype
, u16 id
, u8 up
)
594 case DCB_APP_IDTYPE_ETHTYPE
:
596 if (id
== ETH_P_FCOE
) {
598 struct ixgbe_adapter
*adapter
= netdev_priv(netdev
);
600 /* Get current programmed tc */
601 old_tc
= adapter
->fcoe
.tc
;
602 rval
= ixgbe_fcoe_setapp(adapter
, up
);
605 !(adapter
->flags
& IXGBE_FLAG_DCB_ENABLED
) ||
606 !(adapter
->flags
& IXGBE_FLAG_FCOE_ENABLED
))
609 /* The FCoE application priority may be changed multiple
610 * times in quick sucession with switches that build up
611 * TLVs. To avoid creating uneeded device resets this
612 * checks the actual HW configuration and clears
613 * BIT_APP_UPCHG if a HW configuration change is not
616 if (old_tc
== adapter
->fcoe
.tc
)
617 adapter
->dcb_set_bitmap
&= ~BIT_APP_UPCHG
;
619 adapter
->dcb_set_bitmap
|= BIT_APP_UPCHG
;
623 case DCB_APP_IDTYPE_PORTNUM
:
631 static int ixgbe_dcbnl_ieee_getets(struct net_device
*dev
,
632 struct ieee_ets
*ets
)
634 struct ixgbe_adapter
*adapter
= netdev_priv(dev
);
635 struct ieee_ets
*my_ets
= adapter
->ixgbe_ieee_ets
;
637 /* No IEEE PFC settings available */
641 ets
->ets_cap
= MAX_TRAFFIC_CLASS
;
642 ets
->cbs
= my_ets
->cbs
;
643 memcpy(ets
->tc_tx_bw
, my_ets
->tc_tx_bw
, sizeof(ets
->tc_tx_bw
));
644 memcpy(ets
->tc_rx_bw
, my_ets
->tc_rx_bw
, sizeof(ets
->tc_rx_bw
));
645 memcpy(ets
->tc_tsa
, my_ets
->tc_tsa
, sizeof(ets
->tc_tsa
));
646 memcpy(ets
->prio_tc
, my_ets
->prio_tc
, sizeof(ets
->prio_tc
));
650 static int ixgbe_dcbnl_ieee_setets(struct net_device
*dev
,
651 struct ieee_ets
*ets
)
653 struct ixgbe_adapter
*adapter
= netdev_priv(dev
);
654 __u16 refill
[IEEE_8021QAZ_MAX_TCS
], max
[IEEE_8021QAZ_MAX_TCS
];
655 int max_frame
= dev
->mtu
+ ETH_HLEN
+ ETH_FCS_LEN
;
657 /* naively give each TC a bwg to map onto CEE hardware */
658 __u8 bwg_id
[IEEE_8021QAZ_MAX_TCS
] = {0, 1, 2, 3, 4, 5, 6, 7};
660 if (!adapter
->ixgbe_ieee_ets
) {
661 adapter
->ixgbe_ieee_ets
= kmalloc(sizeof(struct ieee_ets
),
663 if (!adapter
->ixgbe_ieee_ets
)
668 memcpy(adapter
->ixgbe_ieee_ets
, ets
, sizeof(*adapter
->ixgbe_ieee_ets
));
670 ixgbe_ieee_credits(ets
->tc_tx_bw
, refill
, max
, max_frame
);
671 err
= ixgbe_dcb_hw_ets_config(&adapter
->hw
, refill
, max
,
672 bwg_id
, ets
->tc_tsa
);
676 static int ixgbe_dcbnl_ieee_getpfc(struct net_device
*dev
,
677 struct ieee_pfc
*pfc
)
679 struct ixgbe_adapter
*adapter
= netdev_priv(dev
);
680 struct ieee_pfc
*my_pfc
= adapter
->ixgbe_ieee_pfc
;
683 /* No IEEE PFC settings available */
687 pfc
->pfc_cap
= MAX_TRAFFIC_CLASS
;
688 pfc
->pfc_en
= my_pfc
->pfc_en
;
689 pfc
->mbc
= my_pfc
->mbc
;
690 pfc
->delay
= my_pfc
->delay
;
692 for (i
= 0; i
< MAX_TRAFFIC_CLASS
; i
++) {
693 pfc
->requests
[i
] = adapter
->stats
.pxoffrxc
[i
];
694 pfc
->indications
[i
] = adapter
->stats
.pxofftxc
[i
];
700 static int ixgbe_dcbnl_ieee_setpfc(struct net_device
*dev
,
701 struct ieee_pfc
*pfc
)
703 struct ixgbe_adapter
*adapter
= netdev_priv(dev
);
706 if (!adapter
->ixgbe_ieee_pfc
) {
707 adapter
->ixgbe_ieee_pfc
= kmalloc(sizeof(struct ieee_pfc
),
709 if (!adapter
->ixgbe_ieee_pfc
)
713 memcpy(adapter
->ixgbe_ieee_pfc
, pfc
, sizeof(*adapter
->ixgbe_ieee_pfc
));
714 err
= ixgbe_dcb_hw_pfc_config(&adapter
->hw
, pfc
->pfc_en
);
718 const struct dcbnl_rtnl_ops dcbnl_ops
= {
719 .ieee_getets
= ixgbe_dcbnl_ieee_getets
,
720 .ieee_setets
= ixgbe_dcbnl_ieee_setets
,
721 .ieee_getpfc
= ixgbe_dcbnl_ieee_getpfc
,
722 .ieee_setpfc
= ixgbe_dcbnl_ieee_setpfc
,
723 .getstate
= ixgbe_dcbnl_get_state
,
724 .setstate
= ixgbe_dcbnl_set_state
,
725 .getpermhwaddr
= ixgbe_dcbnl_get_perm_hw_addr
,
726 .setpgtccfgtx
= ixgbe_dcbnl_set_pg_tc_cfg_tx
,
727 .setpgbwgcfgtx
= ixgbe_dcbnl_set_pg_bwg_cfg_tx
,
728 .setpgtccfgrx
= ixgbe_dcbnl_set_pg_tc_cfg_rx
,
729 .setpgbwgcfgrx
= ixgbe_dcbnl_set_pg_bwg_cfg_rx
,
730 .getpgtccfgtx
= ixgbe_dcbnl_get_pg_tc_cfg_tx
,
731 .getpgbwgcfgtx
= ixgbe_dcbnl_get_pg_bwg_cfg_tx
,
732 .getpgtccfgrx
= ixgbe_dcbnl_get_pg_tc_cfg_rx
,
733 .getpgbwgcfgrx
= ixgbe_dcbnl_get_pg_bwg_cfg_rx
,
734 .setpfccfg
= ixgbe_dcbnl_set_pfc_cfg
,
735 .getpfccfg
= ixgbe_dcbnl_get_pfc_cfg
,
736 .setall
= ixgbe_dcbnl_set_all
,
737 .getcap
= ixgbe_dcbnl_getcap
,
738 .getnumtcs
= ixgbe_dcbnl_getnumtcs
,
739 .setnumtcs
= ixgbe_dcbnl_setnumtcs
,
740 .getpfcstate
= ixgbe_dcbnl_getpfcstate
,
741 .setpfcstate
= ixgbe_dcbnl_setpfcstate
,
742 .getapp
= ixgbe_dcbnl_getapp
,
743 .setapp
= ixgbe_dcbnl_setapp
,