1 /* bnx2x_dcb.c: Broadcom Everest network driver.
3 * Copyright 2009-2012 Broadcom Corporation
5 * Unless you and Broadcom execute a separate written software license
6 * agreement governing use of this software, this software is licensed to you
7 * under the terms of the GNU General Public License version 2, available
8 * at http://www.gnu.org/licenses/old-licenses/gpl-2.0.html (the "GPL").
10 * Notwithstanding the above, under no circumstances may you combine this
11 * software in any way with any other Broadcom software provided under a
12 * license other than the GPL, without Broadcom's express prior written
15 * Maintained by: Eilon Greenstein <eilong@broadcom.com>
16 * Written by: Dmitry Kravkov
20 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
22 #include <linux/netdevice.h>
23 #include <linux/types.h>
24 #include <linux/errno.h>
25 #include <linux/rtnetlink.h>
26 #include <net/dcbnl.h>
29 #include "bnx2x_cmn.h"
30 #include "bnx2x_dcb.h"
32 /* forward declarations of dcbx related functions */
33 static int bnx2x_dcbx_stop_hw_tx(struct bnx2x
*bp
);
34 static void bnx2x_pfc_set_pfc(struct bnx2x
*bp
);
35 static void bnx2x_dcbx_update_ets_params(struct bnx2x
*bp
);
36 static int bnx2x_dcbx_resume_hw_tx(struct bnx2x
*bp
);
37 static void bnx2x_dcbx_get_ets_pri_pg_tbl(struct bnx2x
*bp
,
38 u32
*set_configuration_ets_pg
,
40 static void bnx2x_dcbx_get_num_pg_traf_type(struct bnx2x
*bp
,
41 u32
*pg_pri_orginal_spread
,
42 struct pg_help_data
*help_data
);
43 static void bnx2x_dcbx_fill_cos_params(struct bnx2x
*bp
,
44 struct pg_help_data
*help_data
,
45 struct dcbx_ets_feature
*ets
,
46 u32
*pg_pri_orginal_spread
);
47 static void bnx2x_dcbx_separate_pauseable_from_non(struct bnx2x
*bp
,
48 struct cos_help_data
*cos_data
,
49 u32
*pg_pri_orginal_spread
,
50 struct dcbx_ets_feature
*ets
);
51 static void bnx2x_dcbx_fw_struct(struct bnx2x
*bp
,
52 struct bnx2x_func_tx_start_params
*);
54 /* helpers: read/write len bytes from addr into buff by REG_RD/REG_WR */
55 static void bnx2x_read_data(struct bnx2x
*bp
, u32
*buff
,
59 for (i
= 0; i
< len
; i
+= 4, buff
++)
60 *buff
= REG_RD(bp
, addr
+ i
);
63 static void bnx2x_write_data(struct bnx2x
*bp
, u32
*buff
,
67 for (i
= 0; i
< len
; i
+= 4, buff
++)
68 REG_WR(bp
, addr
+ i
, *buff
);
71 static void bnx2x_pfc_set(struct bnx2x
*bp
)
73 struct bnx2x_nig_brb_pfc_port_params pfc_params
= {0};
77 pfc_params
.num_of_rx_cos_priority_mask
=
78 bp
->dcbx_port_params
.ets
.num_of_cos
;
80 /* Tx COS configuration */
81 for (i
= 0; i
< bp
->dcbx_port_params
.ets
.num_of_cos
; i
++)
83 * We configure only the pauseable bits (non pauseable aren't
84 * configured at all) it's done to avoid false pauses from
87 pfc_params
.rx_cos_priority_mask
[i
] =
88 bp
->dcbx_port_params
.ets
.cos_params
[i
].pri_bitmask
89 & DCBX_PFC_PRI_PAUSE_MASK(bp
);
92 * Rx COS configuration
93 * Changing PFC RX configuration .
94 * In RX COS0 will always be configured to lossy and COS1 to lossless
96 for (i
= 0 ; i
< MAX_PFC_PRIORITIES
; i
++) {
99 if (pri_bit
& DCBX_PFC_PRI_PAUSE_MASK(bp
))
103 pfc_params
.pkt_priority_to_cos
= val
;
106 pfc_params
.llfc_low_priority_classes
= 0;
108 pfc_params
.llfc_high_priority_classes
= DCBX_PFC_PRI_PAUSE_MASK(bp
);
110 /* BRB configuration */
111 pfc_params
.cos0_pauseable
= false;
112 pfc_params
.cos1_pauseable
= true;
114 bnx2x_acquire_phy_lock(bp
);
115 bp
->link_params
.feature_config_flags
|= FEATURE_CONFIG_PFC_ENABLED
;
116 bnx2x_update_pfc(&bp
->link_params
, &bp
->link_vars
, &pfc_params
);
117 bnx2x_release_phy_lock(bp
);
120 static void bnx2x_pfc_clear(struct bnx2x
*bp
)
122 struct bnx2x_nig_brb_pfc_port_params nig_params
= {0};
123 nig_params
.pause_enable
= 1;
124 bnx2x_acquire_phy_lock(bp
);
125 bp
->link_params
.feature_config_flags
&= ~FEATURE_CONFIG_PFC_ENABLED
;
126 bnx2x_update_pfc(&bp
->link_params
, &bp
->link_vars
, &nig_params
);
127 bnx2x_release_phy_lock(bp
);
130 static void bnx2x_dump_dcbx_drv_param(struct bnx2x
*bp
,
131 struct dcbx_features
*features
,
135 DP(NETIF_MSG_LINK
, "local_mib.error %x\n", error
);
139 "local_mib.features.ets.enabled %x\n", features
->ets
.enabled
);
140 for (i
= 0; i
< DCBX_MAX_NUM_PG_BW_ENTRIES
; i
++)
142 "local_mib.features.ets.pg_bw_tbl[%d] %d\n", i
,
143 DCBX_PG_BW_GET(features
->ets
.pg_bw_tbl
, i
));
144 for (i
= 0; i
< DCBX_MAX_NUM_PRI_PG_ENTRIES
; i
++)
146 "local_mib.features.ets.pri_pg_tbl[%d] %d\n", i
,
147 DCBX_PRI_PG_GET(features
->ets
.pri_pg_tbl
, i
));
150 DP(BNX2X_MSG_DCB
, "dcbx_features.pfc.pri_en_bitmap %x\n",
151 features
->pfc
.pri_en_bitmap
);
152 DP(BNX2X_MSG_DCB
, "dcbx_features.pfc.pfc_caps %x\n",
153 features
->pfc
.pfc_caps
);
154 DP(BNX2X_MSG_DCB
, "dcbx_features.pfc.enabled %x\n",
155 features
->pfc
.enabled
);
157 DP(BNX2X_MSG_DCB
, "dcbx_features.app.default_pri %x\n",
158 features
->app
.default_pri
);
159 DP(BNX2X_MSG_DCB
, "dcbx_features.app.tc_supported %x\n",
160 features
->app
.tc_supported
);
161 DP(BNX2X_MSG_DCB
, "dcbx_features.app.enabled %x\n",
162 features
->app
.enabled
);
163 for (i
= 0; i
< DCBX_MAX_APP_PROTOCOL
; i
++) {
165 "dcbx_features.app.app_pri_tbl[%x].app_id %x\n",
166 i
, features
->app
.app_pri_tbl
[i
].app_id
);
168 "dcbx_features.app.app_pri_tbl[%x].pri_bitmap %x\n",
169 i
, features
->app
.app_pri_tbl
[i
].pri_bitmap
);
171 "dcbx_features.app.app_pri_tbl[%x].appBitfield %x\n",
172 i
, features
->app
.app_pri_tbl
[i
].appBitfield
);
176 static void bnx2x_dcbx_get_ap_priority(struct bnx2x
*bp
,
180 u32 pri
= MAX_PFC_PRIORITIES
;
181 u32 index
= MAX_PFC_PRIORITIES
- 1;
183 u32
*ttp
= bp
->dcbx_port_params
.app
.traffic_type_priority
;
185 /* Choose the highest priority */
186 while ((MAX_PFC_PRIORITIES
== pri
) && (0 != index
)) {
187 pri_mask
= 1 << index
;
188 if (GET_FLAGS(pri_bitmap
, pri_mask
))
193 if (pri
< MAX_PFC_PRIORITIES
)
194 ttp
[llfc_traf_type
] = max_t(u32
, ttp
[llfc_traf_type
], pri
);
197 static void bnx2x_dcbx_get_ap_feature(struct bnx2x
*bp
,
198 struct dcbx_app_priority_feature
*app
,
201 u32
*ttp
= bp
->dcbx_port_params
.app
.traffic_type_priority
;
203 if (GET_FLAGS(error
, DCBX_LOCAL_APP_ERROR
))
204 DP(BNX2X_MSG_DCB
, "DCBX_LOCAL_APP_ERROR\n");
206 if (GET_FLAGS(error
, DCBX_LOCAL_APP_MISMATCH
))
207 DP(BNX2X_MSG_DCB
, "DCBX_LOCAL_APP_MISMATCH\n");
209 if (GET_FLAGS(error
, DCBX_REMOTE_APP_TLV_NOT_FOUND
))
210 DP(BNX2X_MSG_DCB
, "DCBX_REMOTE_APP_TLV_NOT_FOUND\n");
212 !GET_FLAGS(error
, DCBX_LOCAL_APP_ERROR
| DCBX_LOCAL_APP_MISMATCH
|
213 DCBX_REMOTE_APP_TLV_NOT_FOUND
)) {
215 bp
->dcbx_port_params
.app
.enabled
= true;
217 for (index
= 0 ; index
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
; index
++)
220 if (app
->default_pri
< MAX_PFC_PRIORITIES
)
221 ttp
[LLFC_TRAFFIC_TYPE_NW
] = app
->default_pri
;
223 for (index
= 0 ; index
< DCBX_MAX_APP_PROTOCOL
; index
++) {
224 struct dcbx_app_priority_entry
*entry
=
227 if (GET_FLAGS(entry
[index
].appBitfield
,
228 DCBX_APP_SF_ETH_TYPE
) &&
229 ETH_TYPE_FCOE
== entry
[index
].app_id
)
230 bnx2x_dcbx_get_ap_priority(bp
,
231 entry
[index
].pri_bitmap
,
232 LLFC_TRAFFIC_TYPE_FCOE
);
234 if (GET_FLAGS(entry
[index
].appBitfield
,
236 TCP_PORT_ISCSI
== entry
[index
].app_id
)
237 bnx2x_dcbx_get_ap_priority(bp
,
238 entry
[index
].pri_bitmap
,
239 LLFC_TRAFFIC_TYPE_ISCSI
);
242 DP(BNX2X_MSG_DCB
, "DCBX_LOCAL_APP_DISABLED\n");
243 bp
->dcbx_port_params
.app
.enabled
= false;
244 for (index
= 0 ; index
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
; index
++)
245 ttp
[index
] = INVALID_TRAFFIC_TYPE_PRIORITY
;
249 static void bnx2x_dcbx_get_ets_feature(struct bnx2x
*bp
,
250 struct dcbx_ets_feature
*ets
,
253 u32 pg_pri_orginal_spread
[DCBX_MAX_NUM_PG_BW_ENTRIES
] = {0};
254 struct pg_help_data pg_help_data
;
255 struct bnx2x_dcbx_cos_params
*cos_params
=
256 bp
->dcbx_port_params
.ets
.cos_params
;
258 memset(&pg_help_data
, 0, sizeof(struct pg_help_data
));
261 if (GET_FLAGS(error
, DCBX_LOCAL_ETS_ERROR
))
262 DP(BNX2X_MSG_DCB
, "DCBX_LOCAL_ETS_ERROR\n");
264 if (GET_FLAGS(error
, DCBX_REMOTE_ETS_TLV_NOT_FOUND
))
265 DP(BNX2X_MSG_DCB
, "DCBX_REMOTE_ETS_TLV_NOT_FOUND\n");
267 /* Clean up old settings of ets on COS */
268 for (i
= 0; i
< ARRAY_SIZE(bp
->dcbx_port_params
.ets
.cos_params
) ; i
++) {
269 cos_params
[i
].pauseable
= false;
270 cos_params
[i
].strict
= BNX2X_DCBX_STRICT_INVALID
;
271 cos_params
[i
].bw_tbl
= DCBX_INVALID_COS_BW
;
272 cos_params
[i
].pri_bitmask
= 0;
275 if (bp
->dcbx_port_params
.app
.enabled
&& ets
->enabled
&&
277 DCBX_LOCAL_ETS_ERROR
| DCBX_REMOTE_ETS_TLV_NOT_FOUND
)) {
278 DP(BNX2X_MSG_DCB
, "DCBX_LOCAL_ETS_ENABLE\n");
279 bp
->dcbx_port_params
.ets
.enabled
= true;
281 bnx2x_dcbx_get_ets_pri_pg_tbl(bp
,
282 pg_pri_orginal_spread
,
285 bnx2x_dcbx_get_num_pg_traf_type(bp
,
286 pg_pri_orginal_spread
,
289 bnx2x_dcbx_fill_cos_params(bp
, &pg_help_data
,
290 ets
, pg_pri_orginal_spread
);
293 DP(BNX2X_MSG_DCB
, "DCBX_LOCAL_ETS_DISABLED\n");
294 bp
->dcbx_port_params
.ets
.enabled
= false;
295 ets
->pri_pg_tbl
[0] = 0;
297 for (i
= 0; i
< DCBX_MAX_NUM_PRI_PG_ENTRIES
; i
++)
298 DCBX_PG_BW_SET(ets
->pg_bw_tbl
, i
, 1);
302 static void bnx2x_dcbx_get_pfc_feature(struct bnx2x
*bp
,
303 struct dcbx_pfc_feature
*pfc
, u32 error
)
306 if (GET_FLAGS(error
, DCBX_LOCAL_PFC_ERROR
))
307 DP(BNX2X_MSG_DCB
, "DCBX_LOCAL_PFC_ERROR\n");
309 if (GET_FLAGS(error
, DCBX_REMOTE_PFC_TLV_NOT_FOUND
))
310 DP(BNX2X_MSG_DCB
, "DCBX_REMOTE_PFC_TLV_NOT_FOUND\n");
311 if (bp
->dcbx_port_params
.app
.enabled
&& pfc
->enabled
&&
312 !GET_FLAGS(error
, DCBX_LOCAL_PFC_ERROR
| DCBX_LOCAL_PFC_MISMATCH
|
313 DCBX_REMOTE_PFC_TLV_NOT_FOUND
)) {
314 bp
->dcbx_port_params
.pfc
.enabled
= true;
315 bp
->dcbx_port_params
.pfc
.priority_non_pauseable_mask
=
316 ~(pfc
->pri_en_bitmap
);
318 DP(BNX2X_MSG_DCB
, "DCBX_LOCAL_PFC_DISABLED\n");
319 bp
->dcbx_port_params
.pfc
.enabled
= false;
320 bp
->dcbx_port_params
.pfc
.priority_non_pauseable_mask
= 0;
324 /* maps unmapped priorities to to the same COS as L2 */
325 static void bnx2x_dcbx_map_nw(struct bnx2x
*bp
)
328 u32 unmapped
= (1 << MAX_PFC_PRIORITIES
) - 1; /* all ones */
329 u32
*ttp
= bp
->dcbx_port_params
.app
.traffic_type_priority
;
330 u32 nw_prio
= 1 << ttp
[LLFC_TRAFFIC_TYPE_NW
];
331 struct bnx2x_dcbx_cos_params
*cos_params
=
332 bp
->dcbx_port_params
.ets
.cos_params
;
334 /* get unmapped priorities by clearing mapped bits */
335 for (i
= 0; i
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
; i
++)
336 unmapped
&= ~(1 << ttp
[i
]);
338 /* find cos for nw prio and extend it with unmapped */
339 for (i
= 0; i
< ARRAY_SIZE(bp
->dcbx_port_params
.ets
.cos_params
); i
++) {
340 if (cos_params
[i
].pri_bitmask
& nw_prio
) {
341 /* extend the bitmask with unmapped */
343 "cos %d extended with 0x%08x\n", i
, unmapped
);
344 cos_params
[i
].pri_bitmask
|= unmapped
;
350 static void bnx2x_get_dcbx_drv_param(struct bnx2x
*bp
,
351 struct dcbx_features
*features
,
354 bnx2x_dcbx_get_ap_feature(bp
, &features
->app
, error
);
356 bnx2x_dcbx_get_pfc_feature(bp
, &features
->pfc
, error
);
358 bnx2x_dcbx_get_ets_feature(bp
, &features
->ets
, error
);
360 bnx2x_dcbx_map_nw(bp
);
363 #define DCBX_LOCAL_MIB_MAX_TRY_READ (100)
364 static int bnx2x_dcbx_read_mib(struct bnx2x
*bp
,
369 int max_try_read
= 0;
370 u32 mib_size
, prefix_seq_num
, suffix_seq_num
;
371 struct lldp_remote_mib
*remote_mib
;
372 struct lldp_local_mib
*local_mib
;
375 switch (read_mib_type
) {
376 case DCBX_READ_LOCAL_MIB
:
377 mib_size
= sizeof(struct lldp_local_mib
);
379 case DCBX_READ_REMOTE_MIB
:
380 mib_size
= sizeof(struct lldp_remote_mib
);
386 offset
+= BP_PORT(bp
) * mib_size
;
389 bnx2x_read_data(bp
, base_mib_addr
, offset
, mib_size
);
393 switch (read_mib_type
) {
394 case DCBX_READ_LOCAL_MIB
:
395 local_mib
= (struct lldp_local_mib
*) base_mib_addr
;
396 prefix_seq_num
= local_mib
->prefix_seq_num
;
397 suffix_seq_num
= local_mib
->suffix_seq_num
;
399 case DCBX_READ_REMOTE_MIB
:
400 remote_mib
= (struct lldp_remote_mib
*) base_mib_addr
;
401 prefix_seq_num
= remote_mib
->prefix_seq_num
;
402 suffix_seq_num
= remote_mib
->suffix_seq_num
;
407 } while ((prefix_seq_num
!= suffix_seq_num
) &&
408 (max_try_read
< DCBX_LOCAL_MIB_MAX_TRY_READ
));
410 if (max_try_read
>= DCBX_LOCAL_MIB_MAX_TRY_READ
) {
411 BNX2X_ERR("MIB could not be read\n");
418 static void bnx2x_pfc_set_pfc(struct bnx2x
*bp
)
420 if (bp
->dcbx_port_params
.pfc
.enabled
&&
421 !(bp
->dcbx_error
& DCBX_REMOTE_MIB_ERROR
))
423 * 1. Fills up common PFC structures if required
424 * 2. Configure NIG, MAC and BRB via the elink
431 static int bnx2x_dcbx_stop_hw_tx(struct bnx2x
*bp
)
433 struct bnx2x_func_state_params func_params
= {NULL
};
435 func_params
.f_obj
= &bp
->func_obj
;
436 func_params
.cmd
= BNX2X_F_CMD_TX_STOP
;
438 DP(BNX2X_MSG_DCB
, "STOP TRAFFIC\n");
439 return bnx2x_func_state_change(bp
, &func_params
);
442 static int bnx2x_dcbx_resume_hw_tx(struct bnx2x
*bp
)
444 struct bnx2x_func_state_params func_params
= {NULL
};
445 struct bnx2x_func_tx_start_params
*tx_params
=
446 &func_params
.params
.tx_start
;
448 func_params
.f_obj
= &bp
->func_obj
;
449 func_params
.cmd
= BNX2X_F_CMD_TX_START
;
451 bnx2x_dcbx_fw_struct(bp
, tx_params
);
453 DP(BNX2X_MSG_DCB
, "START TRAFFIC\n");
454 return bnx2x_func_state_change(bp
, &func_params
);
457 static void bnx2x_dcbx_2cos_limit_update_ets_config(struct bnx2x
*bp
)
459 struct bnx2x_dcbx_pg_params
*ets
= &(bp
->dcbx_port_params
.ets
);
462 if (ets
->num_of_cos
== 0 || ets
->num_of_cos
> DCBX_COS_MAX_NUM_E2
) {
463 BNX2X_ERR("Illegal number of COSes %d\n", ets
->num_of_cos
);
467 /* valid COS entries */
468 if (ets
->num_of_cos
== 1) /* no ETS */
472 if (((BNX2X_DCBX_STRICT_INVALID
== ets
->cos_params
[0].strict
) &&
473 (DCBX_INVALID_COS_BW
== ets
->cos_params
[0].bw_tbl
)) ||
474 ((BNX2X_DCBX_STRICT_INVALID
== ets
->cos_params
[1].strict
) &&
475 (DCBX_INVALID_COS_BW
== ets
->cos_params
[1].bw_tbl
))) {
476 BNX2X_ERR("all COS should have at least bw_limit or strict"
477 "ets->cos_params[0].strict= %x"
478 "ets->cos_params[0].bw_tbl= %x"
479 "ets->cos_params[1].strict= %x"
480 "ets->cos_params[1].bw_tbl= %x",
481 ets
->cos_params
[0].strict
,
482 ets
->cos_params
[0].bw_tbl
,
483 ets
->cos_params
[1].strict
,
484 ets
->cos_params
[1].bw_tbl
);
487 /* If we join a group and there is bw_tbl and strict then bw rules */
488 if ((DCBX_INVALID_COS_BW
!= ets
->cos_params
[0].bw_tbl
) &&
489 (DCBX_INVALID_COS_BW
!= ets
->cos_params
[1].bw_tbl
)) {
490 u32 bw_tbl_0
= ets
->cos_params
[0].bw_tbl
;
491 u32 bw_tbl_1
= ets
->cos_params
[1].bw_tbl
;
492 /* Do not allow 0-100 configuration
493 * since PBF does not support it
499 } else if (bw_tbl_1
== 0) {
504 bnx2x_ets_bw_limit(&bp
->link_params
, bw_tbl_0
, bw_tbl_1
);
506 if (ets
->cos_params
[0].strict
== BNX2X_DCBX_STRICT_COS_HIGHEST
)
507 rc
= bnx2x_ets_strict(&bp
->link_params
, 0);
508 else if (ets
->cos_params
[1].strict
509 == BNX2X_DCBX_STRICT_COS_HIGHEST
)
510 rc
= bnx2x_ets_strict(&bp
->link_params
, 1);
512 BNX2X_ERR("update_ets_params failed\n");
517 * In E3B0 the configuration may have more than 2 COS.
519 static void bnx2x_dcbx_update_ets_config(struct bnx2x
*bp
)
521 struct bnx2x_dcbx_pg_params
*ets
= &(bp
->dcbx_port_params
.ets
);
522 struct bnx2x_ets_params ets_params
= { 0 };
525 ets_params
.num_of_cos
= ets
->num_of_cos
;
527 for (i
= 0; i
< ets
->num_of_cos
; i
++) {
529 if (ets
->cos_params
[i
].strict
!= BNX2X_DCBX_STRICT_INVALID
) {
530 if (ets
->cos_params
[i
].bw_tbl
!= DCBX_INVALID_COS_BW
) {
531 BNX2X_ERR("COS can't be not BW and not SP\n");
535 ets_params
.cos
[i
].state
= bnx2x_cos_state_strict
;
536 ets_params
.cos
[i
].params
.sp_params
.pri
=
537 ets
->cos_params
[i
].strict
;
538 } else { /* COS is BW */
539 if (ets
->cos_params
[i
].bw_tbl
== DCBX_INVALID_COS_BW
) {
540 BNX2X_ERR("COS can't be not BW and not SP\n");
543 ets_params
.cos
[i
].state
= bnx2x_cos_state_bw
;
544 ets_params
.cos
[i
].params
.bw_params
.bw
=
545 (u8
)ets
->cos_params
[i
].bw_tbl
;
549 /* Configure the ETS in HW */
550 if (bnx2x_ets_e3b0_config(&bp
->link_params
, &bp
->link_vars
,
552 BNX2X_ERR("bnx2x_ets_e3b0_config failed\n");
553 bnx2x_ets_disabled(&bp
->link_params
, &bp
->link_vars
);
557 static void bnx2x_dcbx_update_ets_params(struct bnx2x
*bp
)
559 bnx2x_ets_disabled(&bp
->link_params
, &bp
->link_vars
);
561 if (!bp
->dcbx_port_params
.ets
.enabled
||
562 (bp
->dcbx_error
& DCBX_REMOTE_MIB_ERROR
))
565 if (CHIP_IS_E3B0(bp
))
566 bnx2x_dcbx_update_ets_config(bp
);
568 bnx2x_dcbx_2cos_limit_update_ets_config(bp
);
572 static int bnx2x_dcbx_read_shmem_remote_mib(struct bnx2x
*bp
)
574 struct lldp_remote_mib remote_mib
= {0};
575 u32 dcbx_remote_mib_offset
= SHMEM2_RD(bp
, dcbx_remote_mib_offset
);
578 DP(BNX2X_MSG_DCB
, "dcbx_remote_mib_offset 0x%x\n",
579 dcbx_remote_mib_offset
);
581 if (SHMEM_DCBX_REMOTE_MIB_NONE
== dcbx_remote_mib_offset
) {
582 BNX2X_ERR("FW doesn't support dcbx_remote_mib_offset\n");
586 rc
= bnx2x_dcbx_read_mib(bp
, (u32
*)&remote_mib
, dcbx_remote_mib_offset
,
587 DCBX_READ_REMOTE_MIB
);
590 BNX2X_ERR("Faild to read remote mib from FW\n");
594 /* save features and flags */
595 bp
->dcbx_remote_feat
= remote_mib
.features
;
596 bp
->dcbx_remote_flags
= remote_mib
.flags
;
601 static int bnx2x_dcbx_read_shmem_neg_results(struct bnx2x
*bp
)
603 struct lldp_local_mib local_mib
= {0};
604 u32 dcbx_neg_res_offset
= SHMEM2_RD(bp
, dcbx_neg_res_offset
);
607 DP(BNX2X_MSG_DCB
, "dcbx_neg_res_offset 0x%x\n", dcbx_neg_res_offset
);
609 if (SHMEM_DCBX_NEG_RES_NONE
== dcbx_neg_res_offset
) {
610 BNX2X_ERR("FW doesn't support dcbx_neg_res_offset\n");
614 rc
= bnx2x_dcbx_read_mib(bp
, (u32
*)&local_mib
, dcbx_neg_res_offset
,
615 DCBX_READ_LOCAL_MIB
);
618 BNX2X_ERR("Faild to read local mib from FW\n");
622 /* save features and error */
623 bp
->dcbx_local_feat
= local_mib
.features
;
624 bp
->dcbx_error
= local_mib
.error
;
631 u8
bnx2x_dcbx_dcbnl_app_up(struct dcbx_app_priority_entry
*ent
)
635 /* Choose the highest priority */
636 for (pri
= MAX_PFC_PRIORITIES
- 1; pri
> 0; pri
--)
637 if (ent
->pri_bitmap
& (1 << pri
))
643 u8
bnx2x_dcbx_dcbnl_app_idtype(struct dcbx_app_priority_entry
*ent
)
645 return ((ent
->appBitfield
& DCBX_APP_ENTRY_SF_MASK
) ==
646 DCBX_APP_SF_PORT
) ? DCB_APP_IDTYPE_PORTNUM
:
647 DCB_APP_IDTYPE_ETHTYPE
;
650 int bnx2x_dcbnl_update_applist(struct bnx2x
*bp
, bool delall
)
654 for (i
= 0; i
< DCBX_MAX_APP_PROTOCOL
&& err
== 0; i
++) {
655 struct dcbx_app_priority_entry
*ent
=
656 &bp
->dcbx_local_feat
.app
.app_pri_tbl
[i
];
658 if (ent
->appBitfield
& DCBX_APP_ENTRY_VALID
) {
659 u8 up
= bnx2x_dcbx_dcbnl_app_up(ent
);
661 /* avoid invalid user-priority */
664 app
.selector
= bnx2x_dcbx_dcbnl_app_idtype(ent
);
665 app
.protocol
= ent
->app_id
;
666 app
.priority
= delall
? 0 : up
;
667 err
= dcb_setapp(bp
->dev
, &app
);
675 static inline void bnx2x_dcbx_update_tc_mapping(struct bnx2x
*bp
)
678 for (cos
= 0; cos
< bp
->dcbx_port_params
.ets
.num_of_cos
; cos
++) {
679 for (prio
= 0; prio
< BNX2X_MAX_PRIORITY
; prio
++) {
680 if (bp
->dcbx_port_params
.ets
.cos_params
[cos
].pri_bitmask
682 bp
->prio_to_cos
[prio
] = cos
;
684 "tx_mapping %d --> %d\n", prio
, cos
);
689 /* setup tc must be called under rtnl lock, but we can't take it here
690 * as we are handling an attetntion on a work queue which must be
691 * flushed at some rtnl-locked contexts (e.g. if down)
693 if (!test_and_set_bit(BNX2X_SP_RTNL_SETUP_TC
, &bp
->sp_rtnl_state
))
694 schedule_delayed_work(&bp
->sp_rtnl_task
, 0);
697 void bnx2x_dcbx_set_params(struct bnx2x
*bp
, u32 state
)
700 case BNX2X_DCBX_STATE_NEG_RECEIVED
:
702 DP(BNX2X_MSG_DCB
, "BNX2X_DCBX_STATE_NEG_RECEIVED\n");
705 * Delete app tlvs from dcbnl before reading new
706 * negotiation results
708 bnx2x_dcbnl_update_applist(bp
, true);
710 /* Read rmeote mib if dcbx is in the FW */
711 if (bnx2x_dcbx_read_shmem_remote_mib(bp
))
714 /* Read neg results if dcbx is in the FW */
715 if (bnx2x_dcbx_read_shmem_neg_results(bp
))
718 bnx2x_dump_dcbx_drv_param(bp
, &bp
->dcbx_local_feat
,
721 bnx2x_get_dcbx_drv_param(bp
, &bp
->dcbx_local_feat
,
724 /* mark DCBX result for PMF migration */
725 bnx2x_update_drv_flags(bp
,
726 1 << DRV_FLAGS_DCB_CONFIGURED
,
730 * Add new app tlvs to dcbnl
732 bnx2x_dcbnl_update_applist(bp
, false);
735 * reconfigure the netdevice with the results of the new
738 bnx2x_dcbx_update_tc_mapping(bp
);
741 * allow other funtions to update their netdevices
745 bnx2x_link_sync_notify(bp
);
747 bnx2x_dcbx_stop_hw_tx(bp
);
751 case BNX2X_DCBX_STATE_TX_PAUSED
:
752 DP(BNX2X_MSG_DCB
, "BNX2X_DCBX_STATE_TX_PAUSED\n");
753 bnx2x_pfc_set_pfc(bp
);
755 bnx2x_dcbx_update_ets_params(bp
);
756 bnx2x_dcbx_resume_hw_tx(bp
);
759 case BNX2X_DCBX_STATE_TX_RELEASED
:
760 DP(BNX2X_MSG_DCB
, "BNX2X_DCBX_STATE_TX_RELEASED\n");
761 bnx2x_fw_command(bp
, DRV_MSG_CODE_DCBX_PMF_DRV_OK
, 0);
764 * Send a notification for the new negotiated parameters
766 dcbnl_cee_notify(bp
->dev
, RTM_GETDCB
, DCB_CMD_CEE_GET
, 0, 0);
770 BNX2X_ERR("Unknown DCBX_STATE\n");
774 #define LLDP_ADMIN_MIB_OFFSET(bp) (PORT_MAX*sizeof(struct lldp_params) + \
775 BP_PORT(bp)*sizeof(struct lldp_admin_mib))
777 static void bnx2x_dcbx_admin_mib_updated_params(struct bnx2x
*bp
,
778 u32 dcbx_lldp_params_offset
)
780 struct lldp_admin_mib admin_mib
;
781 u32 i
, other_traf_type
= PREDEFINED_APP_IDX_MAX
, traf_type
= 0;
782 u32 offset
= dcbx_lldp_params_offset
+ LLDP_ADMIN_MIB_OFFSET(bp
);
785 struct dcbx_features
*af
= &admin_mib
.features
;
786 struct bnx2x_config_dcbx_params
*dp
= &bp
->dcbx_config_params
;
788 memset(&admin_mib
, 0, sizeof(struct lldp_admin_mib
));
790 /* Read the data first */
791 bnx2x_read_data(bp
, (u32
*)&admin_mib
, offset
,
792 sizeof(struct lldp_admin_mib
));
794 if (bp
->dcbx_enabled
== BNX2X_DCBX_ENABLED_ON_NEG_ON
)
795 SET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_DCBX_ENABLED
);
797 RESET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_DCBX_ENABLED
);
799 if (dp
->overwrite_settings
== BNX2X_DCBX_OVERWRITE_SETTINGS_ENABLE
) {
801 RESET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_CEE_VERSION_MASK
);
802 admin_mib
.ver_cfg_flags
|=
803 (dp
->admin_dcbx_version
<< DCBX_CEE_VERSION_SHIFT
) &
804 DCBX_CEE_VERSION_MASK
;
806 af
->ets
.enabled
= (u8
)dp
->admin_ets_enable
;
808 af
->pfc
.enabled
= (u8
)dp
->admin_pfc_enable
;
810 /* FOR IEEE dp->admin_tc_supported_tx_enable */
811 if (dp
->admin_ets_configuration_tx_enable
)
812 SET_FLAGS(admin_mib
.ver_cfg_flags
,
813 DCBX_ETS_CONFIG_TX_ENABLED
);
815 RESET_FLAGS(admin_mib
.ver_cfg_flags
,
816 DCBX_ETS_CONFIG_TX_ENABLED
);
817 /* For IEEE admin_ets_recommendation_tx_enable */
818 if (dp
->admin_pfc_tx_enable
)
819 SET_FLAGS(admin_mib
.ver_cfg_flags
,
820 DCBX_PFC_CONFIG_TX_ENABLED
);
822 RESET_FLAGS(admin_mib
.ver_cfg_flags
,
823 DCBX_PFC_CONFIG_TX_ENABLED
);
825 if (dp
->admin_application_priority_tx_enable
)
826 SET_FLAGS(admin_mib
.ver_cfg_flags
,
827 DCBX_APP_CONFIG_TX_ENABLED
);
829 RESET_FLAGS(admin_mib
.ver_cfg_flags
,
830 DCBX_APP_CONFIG_TX_ENABLED
);
832 if (dp
->admin_ets_willing
)
833 SET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_ETS_WILLING
);
835 RESET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_ETS_WILLING
);
836 /* For IEEE admin_ets_reco_valid */
837 if (dp
->admin_pfc_willing
)
838 SET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_PFC_WILLING
);
840 RESET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_PFC_WILLING
);
842 if (dp
->admin_app_priority_willing
)
843 SET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_APP_WILLING
);
845 RESET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_APP_WILLING
);
847 for (i
= 0 ; i
< DCBX_MAX_NUM_PG_BW_ENTRIES
; i
++) {
848 DCBX_PG_BW_SET(af
->ets
.pg_bw_tbl
, i
,
849 (u8
)dp
->admin_configuration_bw_precentage
[i
]);
851 DP(BNX2X_MSG_DCB
, "pg_bw_tbl[%d] = %02x\n",
852 i
, DCBX_PG_BW_GET(af
->ets
.pg_bw_tbl
, i
));
855 for (i
= 0; i
< DCBX_MAX_NUM_PRI_PG_ENTRIES
; i
++) {
856 DCBX_PRI_PG_SET(af
->ets
.pri_pg_tbl
, i
,
857 (u8
)dp
->admin_configuration_ets_pg
[i
]);
859 DP(BNX2X_MSG_DCB
, "pri_pg_tbl[%d] = %02x\n",
860 i
, DCBX_PRI_PG_GET(af
->ets
.pri_pg_tbl
, i
));
863 /*For IEEE admin_recommendation_bw_precentage
864 *For IEEE admin_recommendation_ets_pg */
865 af
->pfc
.pri_en_bitmap
= (u8
)dp
->admin_pfc_bitmap
;
866 for (i
= 0; i
< DCBX_CONFIG_MAX_APP_PROTOCOL
; i
++) {
867 if (dp
->admin_priority_app_table
[i
].valid
) {
868 struct bnx2x_admin_priority_app_table
*table
=
869 dp
->admin_priority_app_table
;
870 if ((ETH_TYPE_FCOE
== table
[i
].app_id
) &&
871 (TRAFFIC_TYPE_ETH
== table
[i
].traffic_type
))
872 traf_type
= FCOE_APP_IDX
;
873 else if ((TCP_PORT_ISCSI
== table
[i
].app_id
) &&
874 (TRAFFIC_TYPE_PORT
== table
[i
].traffic_type
))
875 traf_type
= ISCSI_APP_IDX
;
877 traf_type
= other_traf_type
++;
879 af
->app
.app_pri_tbl
[traf_type
].app_id
=
882 af
->app
.app_pri_tbl
[traf_type
].pri_bitmap
=
883 (u8
)(1 << table
[i
].priority
);
885 af
->app
.app_pri_tbl
[traf_type
].appBitfield
=
886 (DCBX_APP_ENTRY_VALID
);
888 af
->app
.app_pri_tbl
[traf_type
].appBitfield
|=
889 (TRAFFIC_TYPE_ETH
== table
[i
].traffic_type
) ?
890 DCBX_APP_SF_ETH_TYPE
: DCBX_APP_SF_PORT
;
894 af
->app
.default_pri
= (u8
)dp
->admin_default_priority
;
898 /* Write the data. */
899 bnx2x_write_data(bp
, (u32
*)&admin_mib
, offset
,
900 sizeof(struct lldp_admin_mib
));
904 void bnx2x_dcbx_set_state(struct bnx2x
*bp
, bool dcb_on
, u32 dcbx_enabled
)
906 if (!CHIP_IS_E1x(bp
)) {
907 bp
->dcb_state
= dcb_on
;
908 bp
->dcbx_enabled
= dcbx_enabled
;
910 bp
->dcb_state
= false;
911 bp
->dcbx_enabled
= BNX2X_DCBX_ENABLED_INVALID
;
913 DP(BNX2X_MSG_DCB
, "DCB state [%s:%s]\n",
914 dcb_on
? "ON" : "OFF",
915 dcbx_enabled
== BNX2X_DCBX_ENABLED_OFF
? "user-mode" :
916 dcbx_enabled
== BNX2X_DCBX_ENABLED_ON_NEG_OFF
? "on-chip static" :
917 dcbx_enabled
== BNX2X_DCBX_ENABLED_ON_NEG_ON
?
918 "on-chip with negotiation" : "invalid");
921 void bnx2x_dcbx_init_params(struct bnx2x
*bp
)
923 bp
->dcbx_config_params
.admin_dcbx_version
= 0x0; /* 0 - CEE; 1 - IEEE */
924 bp
->dcbx_config_params
.admin_ets_willing
= 1;
925 bp
->dcbx_config_params
.admin_pfc_willing
= 1;
926 bp
->dcbx_config_params
.overwrite_settings
= 1;
927 bp
->dcbx_config_params
.admin_ets_enable
= 1;
928 bp
->dcbx_config_params
.admin_pfc_enable
= 1;
929 bp
->dcbx_config_params
.admin_tc_supported_tx_enable
= 1;
930 bp
->dcbx_config_params
.admin_ets_configuration_tx_enable
= 1;
931 bp
->dcbx_config_params
.admin_pfc_tx_enable
= 1;
932 bp
->dcbx_config_params
.admin_application_priority_tx_enable
= 1;
933 bp
->dcbx_config_params
.admin_ets_reco_valid
= 1;
934 bp
->dcbx_config_params
.admin_app_priority_willing
= 1;
935 bp
->dcbx_config_params
.admin_configuration_bw_precentage
[0] = 100;
936 bp
->dcbx_config_params
.admin_configuration_bw_precentage
[1] = 0;
937 bp
->dcbx_config_params
.admin_configuration_bw_precentage
[2] = 0;
938 bp
->dcbx_config_params
.admin_configuration_bw_precentage
[3] = 0;
939 bp
->dcbx_config_params
.admin_configuration_bw_precentage
[4] = 0;
940 bp
->dcbx_config_params
.admin_configuration_bw_precentage
[5] = 0;
941 bp
->dcbx_config_params
.admin_configuration_bw_precentage
[6] = 0;
942 bp
->dcbx_config_params
.admin_configuration_bw_precentage
[7] = 0;
943 bp
->dcbx_config_params
.admin_configuration_ets_pg
[0] = 0;
944 bp
->dcbx_config_params
.admin_configuration_ets_pg
[1] = 0;
945 bp
->dcbx_config_params
.admin_configuration_ets_pg
[2] = 0;
946 bp
->dcbx_config_params
.admin_configuration_ets_pg
[3] = 0;
947 bp
->dcbx_config_params
.admin_configuration_ets_pg
[4] = 0;
948 bp
->dcbx_config_params
.admin_configuration_ets_pg
[5] = 0;
949 bp
->dcbx_config_params
.admin_configuration_ets_pg
[6] = 0;
950 bp
->dcbx_config_params
.admin_configuration_ets_pg
[7] = 0;
951 bp
->dcbx_config_params
.admin_recommendation_bw_precentage
[0] = 100;
952 bp
->dcbx_config_params
.admin_recommendation_bw_precentage
[1] = 0;
953 bp
->dcbx_config_params
.admin_recommendation_bw_precentage
[2] = 0;
954 bp
->dcbx_config_params
.admin_recommendation_bw_precentage
[3] = 0;
955 bp
->dcbx_config_params
.admin_recommendation_bw_precentage
[4] = 0;
956 bp
->dcbx_config_params
.admin_recommendation_bw_precentage
[5] = 0;
957 bp
->dcbx_config_params
.admin_recommendation_bw_precentage
[6] = 0;
958 bp
->dcbx_config_params
.admin_recommendation_bw_precentage
[7] = 0;
959 bp
->dcbx_config_params
.admin_recommendation_ets_pg
[0] = 0;
960 bp
->dcbx_config_params
.admin_recommendation_ets_pg
[1] = 1;
961 bp
->dcbx_config_params
.admin_recommendation_ets_pg
[2] = 2;
962 bp
->dcbx_config_params
.admin_recommendation_ets_pg
[3] = 3;
963 bp
->dcbx_config_params
.admin_recommendation_ets_pg
[4] = 4;
964 bp
->dcbx_config_params
.admin_recommendation_ets_pg
[5] = 5;
965 bp
->dcbx_config_params
.admin_recommendation_ets_pg
[6] = 6;
966 bp
->dcbx_config_params
.admin_recommendation_ets_pg
[7] = 7;
967 bp
->dcbx_config_params
.admin_pfc_bitmap
= 0x0;
968 bp
->dcbx_config_params
.admin_priority_app_table
[0].valid
= 0;
969 bp
->dcbx_config_params
.admin_priority_app_table
[1].valid
= 0;
970 bp
->dcbx_config_params
.admin_priority_app_table
[2].valid
= 0;
971 bp
->dcbx_config_params
.admin_priority_app_table
[3].valid
= 0;
972 bp
->dcbx_config_params
.admin_default_priority
= 0;
975 void bnx2x_dcbx_init(struct bnx2x
*bp
)
977 u32 dcbx_lldp_params_offset
= SHMEM_LLDP_DCBX_PARAMS_NONE
;
979 if (bp
->dcbx_enabled
<= 0)
983 * chip of good for dcbx version,
985 * the function is pmf
986 * shmem2 contains DCBX support fields
988 DP(BNX2X_MSG_DCB
, "dcb_state %d bp->port.pmf %d\n",
989 bp
->dcb_state
, bp
->port
.pmf
);
991 if (bp
->dcb_state
== BNX2X_DCB_STATE_ON
&& bp
->port
.pmf
&&
992 SHMEM2_HAS(bp
, dcbx_lldp_params_offset
)) {
993 dcbx_lldp_params_offset
=
994 SHMEM2_RD(bp
, dcbx_lldp_params_offset
);
996 DP(BNX2X_MSG_DCB
, "dcbx_lldp_params_offset 0x%x\n",
997 dcbx_lldp_params_offset
);
999 bnx2x_update_drv_flags(bp
, 1 << DRV_FLAGS_DCB_CONFIGURED
, 0);
1001 if (SHMEM_LLDP_DCBX_PARAMS_NONE
!= dcbx_lldp_params_offset
) {
1002 bnx2x_dcbx_admin_mib_updated_params(bp
,
1003 dcbx_lldp_params_offset
);
1005 /* Let HW start negotiation */
1006 bnx2x_fw_command(bp
,
1007 DRV_MSG_CODE_DCBX_ADMIN_PMF_MSG
, 0);
1012 bnx2x_dcbx_print_cos_params(struct bnx2x
*bp
,
1013 struct bnx2x_func_tx_start_params
*pfc_fw_cfg
)
1019 "pfc_fw_cfg->dcb_version %x\n", pfc_fw_cfg
->dcb_version
);
1021 "pdev->params.dcbx_port_params.pfc.priority_non_pauseable_mask %x\n",
1022 bp
->dcbx_port_params
.pfc
.priority_non_pauseable_mask
);
1024 for (cos
= 0 ; cos
< bp
->dcbx_port_params
.ets
.num_of_cos
; cos
++) {
1026 "pdev->params.dcbx_port_params.ets.cos_params[%d].pri_bitmask %x\n",
1027 cos
, bp
->dcbx_port_params
.ets
.cos_params
[cos
].pri_bitmask
);
1030 "pdev->params.dcbx_port_params.ets.cos_params[%d].bw_tbl %x\n",
1031 cos
, bp
->dcbx_port_params
.ets
.cos_params
[cos
].bw_tbl
);
1034 "pdev->params.dcbx_port_params.ets.cos_params[%d].strict %x\n",
1035 cos
, bp
->dcbx_port_params
.ets
.cos_params
[cos
].strict
);
1038 "pdev->params.dcbx_port_params.ets.cos_params[%d].pauseable %x\n",
1039 cos
, bp
->dcbx_port_params
.ets
.cos_params
[cos
].pauseable
);
1042 for (pri
= 0; pri
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
; pri
++) {
1044 "pfc_fw_cfg->traffic_type_to_priority_cos[%d].priority %x\n",
1045 pri
, pfc_fw_cfg
->traffic_type_to_priority_cos
[pri
].priority
);
1048 "pfc_fw_cfg->traffic_type_to_priority_cos[%d].cos %x\n",
1049 pri
, pfc_fw_cfg
->traffic_type_to_priority_cos
[pri
].cos
);
1053 /* fills help_data according to pg_info */
1054 static void bnx2x_dcbx_get_num_pg_traf_type(struct bnx2x
*bp
,
1055 u32
*pg_pri_orginal_spread
,
1056 struct pg_help_data
*help_data
)
1058 bool pg_found
= false;
1059 u32 i
, traf_type
, add_traf_type
, add_pg
;
1060 u32
*ttp
= bp
->dcbx_port_params
.app
.traffic_type_priority
;
1061 struct pg_entry_help_data
*data
= help_data
->data
; /*shotcut*/
1063 /* Set to invalid */
1064 for (i
= 0; i
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
; i
++)
1065 data
[i
].pg
= DCBX_ILLEGAL_PG
;
1067 for (add_traf_type
= 0;
1068 add_traf_type
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
; add_traf_type
++) {
1070 if (ttp
[add_traf_type
] < MAX_PFC_PRIORITIES
) {
1071 add_pg
= (u8
)pg_pri_orginal_spread
[ttp
[add_traf_type
]];
1073 traf_type
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
;
1075 if (data
[traf_type
].pg
== add_pg
) {
1076 if (!(data
[traf_type
].pg_priority
&
1077 (1 << ttp
[add_traf_type
])))
1080 data
[traf_type
].pg_priority
|=
1081 (1 << ttp
[add_traf_type
]);
1086 if (false == pg_found
) {
1087 data
[help_data
->num_of_pg
].pg
= add_pg
;
1088 data
[help_data
->num_of_pg
].pg_priority
=
1089 (1 << ttp
[add_traf_type
]);
1090 data
[help_data
->num_of_pg
].num_of_dif_pri
= 1;
1091 help_data
->num_of_pg
++;
1095 "add_traf_type %d pg_found %s num_of_pg %d\n",
1096 add_traf_type
, (false == pg_found
) ? "NO" : "YES",
1097 help_data
->num_of_pg
);
1101 static void bnx2x_dcbx_ets_disabled_entry_data(struct bnx2x
*bp
,
1102 struct cos_help_data
*cos_data
,
1105 /* Only one priority than only one COS */
1106 cos_data
->data
[0].pausable
=
1107 IS_DCBX_PFC_PRI_ONLY_PAUSE(bp
, pri_join_mask
);
1108 cos_data
->data
[0].pri_join_mask
= pri_join_mask
;
1109 cos_data
->data
[0].cos_bw
= 100;
1110 cos_data
->num_of_cos
= 1;
1113 static inline void bnx2x_dcbx_add_to_cos_bw(struct bnx2x
*bp
,
1114 struct cos_entry_help_data
*data
,
1117 if (data
->cos_bw
== DCBX_INVALID_COS_BW
)
1118 data
->cos_bw
= pg_bw
;
1120 data
->cos_bw
+= pg_bw
;
1123 static void bnx2x_dcbx_separate_pauseable_from_non(struct bnx2x
*bp
,
1124 struct cos_help_data
*cos_data
,
1125 u32
*pg_pri_orginal_spread
,
1126 struct dcbx_ets_feature
*ets
)
1132 u8 num_of_pri
= LLFC_DRIVER_TRAFFIC_TYPE_MAX
;
1134 cos_data
->data
[0].pausable
= true;
1135 cos_data
->data
[1].pausable
= false;
1136 cos_data
->data
[0].pri_join_mask
= cos_data
->data
[1].pri_join_mask
= 0;
1138 for (i
= 0 ; i
< num_of_pri
; i
++) {
1139 pri_tested
= 1 << bp
->dcbx_port_params
.
1140 app
.traffic_type_priority
[i
];
1142 if (pri_tested
& DCBX_PFC_PRI_NON_PAUSE_MASK(bp
)) {
1143 cos_data
->data
[1].pri_join_mask
|= pri_tested
;
1146 cos_data
->data
[0].pri_join_mask
|= pri_tested
;
1149 pg_entry
= (u8
)pg_pri_orginal_spread
[bp
->dcbx_port_params
.
1150 app
.traffic_type_priority
[i
]];
1151 /* There can be only one strict pg */
1152 if (pg_entry
< DCBX_MAX_NUM_PG_BW_ENTRIES
)
1153 bnx2x_dcbx_add_to_cos_bw(bp
, &cos_data
->data
[entry
],
1154 DCBX_PG_BW_GET(ets
->pg_bw_tbl
, pg_entry
));
1156 /* If we join a group and one is strict
1157 * than the bw rulls */
1158 cos_data
->data
[entry
].strict
=
1159 BNX2X_DCBX_STRICT_COS_HIGHEST
;
1161 if ((0 == cos_data
->data
[0].pri_join_mask
) &&
1162 (0 == cos_data
->data
[1].pri_join_mask
))
1163 BNX2X_ERR("dcbx error: Both groups must have priorities\n");
1168 #define POWER_OF_2(x) ((0 != x) && (0 == (x & (x-1))))
1171 static void bnx2x_dcbx_2cos_limit_cee_single_pg_to_cos_params(struct bnx2x
*bp
,
1172 struct pg_help_data
*pg_help_data
,
1173 struct cos_help_data
*cos_data
,
1179 u32 pri_mask_without_pri
= 0;
1180 u32
*ttp
= bp
->dcbx_port_params
.app
.traffic_type_priority
;
1182 if (num_of_dif_pri
== 1) {
1183 bnx2x_dcbx_ets_disabled_entry_data(bp
, cos_data
, pri_join_mask
);
1186 /* single priority group */
1187 if (pg_help_data
->data
[0].pg
< DCBX_MAX_NUM_PG_BW_ENTRIES
) {
1188 /* If there are both pauseable and non-pauseable priorities,
1189 * the pauseable priorities go to the first queue and
1190 * the non-pauseable priorities go to the second queue.
1192 if (IS_DCBX_PFC_PRI_MIX_PAUSE(bp
, pri_join_mask
)) {
1194 cos_data
->data
[0].pausable
= true;
1196 cos_data
->data
[1].pausable
= false;
1198 if (2 == num_of_dif_pri
) {
1199 cos_data
->data
[0].cos_bw
= 50;
1200 cos_data
->data
[1].cos_bw
= 50;
1203 if (3 == num_of_dif_pri
) {
1204 if (POWER_OF_2(DCBX_PFC_PRI_GET_PAUSE(bp
,
1206 cos_data
->data
[0].cos_bw
= 33;
1207 cos_data
->data
[1].cos_bw
= 67;
1209 cos_data
->data
[0].cos_bw
= 67;
1210 cos_data
->data
[1].cos_bw
= 33;
1214 } else if (IS_DCBX_PFC_PRI_ONLY_PAUSE(bp
, pri_join_mask
)) {
1215 /* If there are only pauseable priorities,
1216 * then one/two priorities go to the first queue
1217 * and one priority goes to the second queue.
1219 if (2 == num_of_dif_pri
) {
1220 cos_data
->data
[0].cos_bw
= 50;
1221 cos_data
->data
[1].cos_bw
= 50;
1223 cos_data
->data
[0].cos_bw
= 67;
1224 cos_data
->data
[1].cos_bw
= 33;
1226 cos_data
->data
[1].pausable
= true;
1227 cos_data
->data
[0].pausable
= true;
1228 /* All priorities except FCOE */
1229 cos_data
->data
[0].pri_join_mask
= (pri_join_mask
&
1230 ((u8
)~(1 << ttp
[LLFC_TRAFFIC_TYPE_FCOE
])));
1231 /* Only FCOE priority.*/
1232 cos_data
->data
[1].pri_join_mask
=
1233 (1 << ttp
[LLFC_TRAFFIC_TYPE_FCOE
]);
1235 /* If there are only non-pauseable priorities,
1236 * they will all go to the same queue.
1238 bnx2x_dcbx_ets_disabled_entry_data(bp
,
1239 cos_data
, pri_join_mask
);
1241 /* priority group which is not BW limited (PG#15):*/
1242 if (IS_DCBX_PFC_PRI_MIX_PAUSE(bp
, pri_join_mask
)) {
1243 /* If there are both pauseable and non-pauseable
1244 * priorities, the pauseable priorities go to the first
1245 * queue and the non-pauseable priorities
1246 * go to the second queue.
1248 if (DCBX_PFC_PRI_GET_PAUSE(bp
, pri_join_mask
) >
1249 DCBX_PFC_PRI_GET_NON_PAUSE(bp
, pri_join_mask
)) {
1250 cos_data
->data
[0].strict
=
1251 BNX2X_DCBX_STRICT_COS_HIGHEST
;
1252 cos_data
->data
[1].strict
=
1253 BNX2X_DCBX_STRICT_COS_NEXT_LOWER_PRI(
1254 BNX2X_DCBX_STRICT_COS_HIGHEST
);
1256 cos_data
->data
[0].strict
=
1257 BNX2X_DCBX_STRICT_COS_NEXT_LOWER_PRI(
1258 BNX2X_DCBX_STRICT_COS_HIGHEST
);
1259 cos_data
->data
[1].strict
=
1260 BNX2X_DCBX_STRICT_COS_HIGHEST
;
1263 cos_data
->data
[0].pausable
= true;
1264 /* Non pause-able.*/
1265 cos_data
->data
[1].pausable
= false;
1267 /* If there are only pauseable priorities or
1268 * only non-pauseable,* the lower priorities go
1269 * to the first queue and the higherpriorities go
1270 * to the second queue.
1272 cos_data
->data
[0].pausable
=
1273 cos_data
->data
[1].pausable
=
1274 IS_DCBX_PFC_PRI_ONLY_PAUSE(bp
, pri_join_mask
);
1276 for (i
= 0 ; i
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
; i
++) {
1277 pri_tested
= 1 << bp
->dcbx_port_params
.
1278 app
.traffic_type_priority
[i
];
1279 /* Remove priority tested */
1280 pri_mask_without_pri
=
1281 (pri_join_mask
& ((u8
)(~pri_tested
)));
1282 if (pri_mask_without_pri
< pri_tested
)
1286 if (i
== LLFC_DRIVER_TRAFFIC_TYPE_MAX
)
1287 BNX2X_ERR("Invalid value for pri_join_mask - could not find a priority\n");
1289 cos_data
->data
[0].pri_join_mask
= pri_mask_without_pri
;
1290 cos_data
->data
[1].pri_join_mask
= pri_tested
;
1291 /* Both queues are strict priority,
1292 * and that with the highest priority
1293 * gets the highest strict priority in the arbiter.
1295 cos_data
->data
[0].strict
=
1296 BNX2X_DCBX_STRICT_COS_NEXT_LOWER_PRI(
1297 BNX2X_DCBX_STRICT_COS_HIGHEST
);
1298 cos_data
->data
[1].strict
=
1299 BNX2X_DCBX_STRICT_COS_HIGHEST
;
1304 static void bnx2x_dcbx_2cos_limit_cee_two_pg_to_cos_params(
1306 struct pg_help_data
*pg_help_data
,
1307 struct dcbx_ets_feature
*ets
,
1308 struct cos_help_data
*cos_data
,
1309 u32
*pg_pri_orginal_spread
,
1314 u8 pg
[DCBX_COS_MAX_NUM_E2
] = { 0 };
1316 /* If there are both pauseable and non-pauseable priorities,
1317 * the pauseable priorities go to the first queue and
1318 * the non-pauseable priorities go to the second queue.
1320 if (IS_DCBX_PFC_PRI_MIX_PAUSE(bp
, pri_join_mask
)) {
1321 if (IS_DCBX_PFC_PRI_MIX_PAUSE(bp
,
1322 pg_help_data
->data
[0].pg_priority
) ||
1323 IS_DCBX_PFC_PRI_MIX_PAUSE(bp
,
1324 pg_help_data
->data
[1].pg_priority
)) {
1325 /* If one PG contains both pauseable and
1326 * non-pauseable priorities then ETS is disabled.
1328 bnx2x_dcbx_separate_pauseable_from_non(bp
, cos_data
,
1329 pg_pri_orginal_spread
, ets
);
1330 bp
->dcbx_port_params
.ets
.enabled
= false;
1335 cos_data
->data
[0].pausable
= true;
1336 /* Non pauseable. */
1337 cos_data
->data
[1].pausable
= false;
1338 if (IS_DCBX_PFC_PRI_ONLY_PAUSE(bp
,
1339 pg_help_data
->data
[0].pg_priority
)) {
1340 /* 0 is pauseable */
1341 cos_data
->data
[0].pri_join_mask
=
1342 pg_help_data
->data
[0].pg_priority
;
1343 pg
[0] = pg_help_data
->data
[0].pg
;
1344 cos_data
->data
[1].pri_join_mask
=
1345 pg_help_data
->data
[1].pg_priority
;
1346 pg
[1] = pg_help_data
->data
[1].pg
;
1347 } else {/* 1 is pauseable */
1348 cos_data
->data
[0].pri_join_mask
=
1349 pg_help_data
->data
[1].pg_priority
;
1350 pg
[0] = pg_help_data
->data
[1].pg
;
1351 cos_data
->data
[1].pri_join_mask
=
1352 pg_help_data
->data
[0].pg_priority
;
1353 pg
[1] = pg_help_data
->data
[0].pg
;
1356 /* If there are only pauseable priorities or
1357 * only non-pauseable, each PG goes to a queue.
1359 cos_data
->data
[0].pausable
= cos_data
->data
[1].pausable
=
1360 IS_DCBX_PFC_PRI_ONLY_PAUSE(bp
, pri_join_mask
);
1361 cos_data
->data
[0].pri_join_mask
=
1362 pg_help_data
->data
[0].pg_priority
;
1363 pg
[0] = pg_help_data
->data
[0].pg
;
1364 cos_data
->data
[1].pri_join_mask
=
1365 pg_help_data
->data
[1].pg_priority
;
1366 pg
[1] = pg_help_data
->data
[1].pg
;
1369 /* There can be only one strict pg */
1370 for (i
= 0 ; i
< ARRAY_SIZE(pg
); i
++) {
1371 if (pg
[i
] < DCBX_MAX_NUM_PG_BW_ENTRIES
)
1372 cos_data
->data
[i
].cos_bw
=
1373 DCBX_PG_BW_GET(ets
->pg_bw_tbl
, pg
[i
]);
1375 cos_data
->data
[i
].strict
=
1376 BNX2X_DCBX_STRICT_COS_HIGHEST
;
1380 static int bnx2x_dcbx_join_pgs(
1382 struct dcbx_ets_feature
*ets
,
1383 struct pg_help_data
*pg_help_data
,
1384 u8 required_num_of_pg
)
1386 u8 entry_joined
= pg_help_data
->num_of_pg
- 1;
1387 u8 entry_removed
= entry_joined
+ 1;
1390 if (required_num_of_pg
== 0 || ARRAY_SIZE(pg_help_data
->data
)
1391 <= pg_help_data
->num_of_pg
) {
1393 BNX2X_ERR("required_num_of_pg can't be zero\n");
1397 while (required_num_of_pg
< pg_help_data
->num_of_pg
) {
1398 entry_joined
= pg_help_data
->num_of_pg
- 2;
1399 entry_removed
= entry_joined
+ 1;
1401 entry_removed
%= ARRAY_SIZE(pg_help_data
->data
);
1403 pg_help_data
->data
[entry_joined
].pg_priority
|=
1404 pg_help_data
->data
[entry_removed
].pg_priority
;
1406 pg_help_data
->data
[entry_joined
].num_of_dif_pri
+=
1407 pg_help_data
->data
[entry_removed
].num_of_dif_pri
;
1409 if (pg_help_data
->data
[entry_joined
].pg
== DCBX_STRICT_PRI_PG
||
1410 pg_help_data
->data
[entry_removed
].pg
== DCBX_STRICT_PRI_PG
)
1411 /* Entries joined strict priority rules */
1412 pg_help_data
->data
[entry_joined
].pg
=
1415 /* Entries can be joined join BW */
1416 pg_joined
= DCBX_PG_BW_GET(ets
->pg_bw_tbl
,
1417 pg_help_data
->data
[entry_joined
].pg
) +
1418 DCBX_PG_BW_GET(ets
->pg_bw_tbl
,
1419 pg_help_data
->data
[entry_removed
].pg
);
1421 DCBX_PG_BW_SET(ets
->pg_bw_tbl
,
1422 pg_help_data
->data
[entry_joined
].pg
, pg_joined
);
1424 /* Joined the entries */
1425 pg_help_data
->num_of_pg
--;
1431 static void bnx2x_dcbx_2cos_limit_cee_three_pg_to_cos_params(
1433 struct pg_help_data
*pg_help_data
,
1434 struct dcbx_ets_feature
*ets
,
1435 struct cos_help_data
*cos_data
,
1436 u32
*pg_pri_orginal_spread
,
1444 bool b_found_strict
= false;
1445 u8 num_of_pri
= LLFC_DRIVER_TRAFFIC_TYPE_MAX
;
1447 cos_data
->data
[0].pri_join_mask
= cos_data
->data
[1].pri_join_mask
= 0;
1448 /* If there are both pauseable and non-pauseable priorities,
1449 * the pauseable priorities go to the first queue and the
1450 * non-pauseable priorities go to the second queue.
1452 if (IS_DCBX_PFC_PRI_MIX_PAUSE(bp
, pri_join_mask
))
1453 bnx2x_dcbx_separate_pauseable_from_non(bp
,
1454 cos_data
, pg_pri_orginal_spread
, ets
);
1456 /* If two BW-limited PG-s were combined to one queue,
1457 * the BW is their sum.
1459 * If there are only pauseable priorities or only non-pauseable,
1460 * and there are both BW-limited and non-BW-limited PG-s,
1461 * the BW-limited PG/s go to one queue and the non-BW-limited
1462 * PG/s go to the second queue.
1464 * If there are only pauseable priorities or only non-pauseable
1465 * and all are BW limited, then two priorities go to the first
1466 * queue and one priority goes to the second queue.
1468 * We will join this two cases:
1469 * if one is BW limited it will go to the secoend queue
1470 * otherwise the last priority will get it
1473 cos_data
->data
[0].pausable
= cos_data
->data
[1].pausable
=
1474 IS_DCBX_PFC_PRI_ONLY_PAUSE(bp
, pri_join_mask
);
1476 for (i
= 0 ; i
< num_of_pri
; i
++) {
1477 pri_tested
= 1 << bp
->dcbx_port_params
.
1478 app
.traffic_type_priority
[i
];
1479 pg_entry
= (u8
)pg_pri_orginal_spread
[bp
->
1480 dcbx_port_params
.app
.traffic_type_priority
[i
]];
1482 if (pg_entry
< DCBX_MAX_NUM_PG_BW_ENTRIES
) {
1485 if (i
== (num_of_pri
-1) &&
1486 false == b_found_strict
)
1487 /* last entry will be handled separately
1488 * If no priority is strict than last
1489 * enty goes to last queue.*/
1491 cos_data
->data
[entry
].pri_join_mask
|=
1493 bnx2x_dcbx_add_to_cos_bw(bp
,
1494 &cos_data
->data
[entry
],
1495 DCBX_PG_BW_GET(ets
->pg_bw_tbl
,
1498 b_found_strict
= true;
1499 cos_data
->data
[1].pri_join_mask
|= pri_tested
;
1500 /* If we join a group and one is strict
1501 * than the bw rulls */
1502 cos_data
->data
[1].strict
=
1503 BNX2X_DCBX_STRICT_COS_HIGHEST
;
1510 static void bnx2x_dcbx_2cos_limit_cee_fill_cos_params(struct bnx2x
*bp
,
1511 struct pg_help_data
*help_data
,
1512 struct dcbx_ets_feature
*ets
,
1513 struct cos_help_data
*cos_data
,
1514 u32
*pg_pri_orginal_spread
,
1519 /* default E2 settings */
1520 cos_data
->num_of_cos
= DCBX_COS_MAX_NUM_E2
;
1522 switch (help_data
->num_of_pg
) {
1524 bnx2x_dcbx_2cos_limit_cee_single_pg_to_cos_params(
1532 bnx2x_dcbx_2cos_limit_cee_two_pg_to_cos_params(
1537 pg_pri_orginal_spread
,
1543 bnx2x_dcbx_2cos_limit_cee_three_pg_to_cos_params(
1548 pg_pri_orginal_spread
,
1553 BNX2X_ERR("Wrong pg_help_data.num_of_pg\n");
1554 bnx2x_dcbx_ets_disabled_entry_data(bp
,
1555 cos_data
, pri_join_mask
);
1559 static int bnx2x_dcbx_spread_strict_pri(struct bnx2x
*bp
,
1560 struct cos_help_data
*cos_data
,
1562 u8 num_spread_of_entries
,
1565 u8 strict_pri
= BNX2X_DCBX_STRICT_COS_HIGHEST
;
1566 u8 num_of_app_pri
= MAX_PFC_PRIORITIES
;
1569 while (num_spread_of_entries
&& num_of_app_pri
> 0) {
1570 app_pri_bit
= 1 << (num_of_app_pri
- 1);
1571 if (app_pri_bit
& strict_app_pris
) {
1572 struct cos_entry_help_data
*data
= &cos_data
->
1574 num_spread_of_entries
--;
1575 if (num_spread_of_entries
== 0) {
1576 /* last entry needed put all the entries left */
1577 data
->cos_bw
= DCBX_INVALID_COS_BW
;
1578 data
->strict
= strict_pri
;
1579 data
->pri_join_mask
= strict_app_pris
;
1580 data
->pausable
= DCBX_IS_PFC_PRI_SOME_PAUSE(bp
,
1581 data
->pri_join_mask
);
1583 strict_app_pris
&= ~app_pri_bit
;
1585 data
->cos_bw
= DCBX_INVALID_COS_BW
;
1586 data
->strict
= strict_pri
;
1587 data
->pri_join_mask
= app_pri_bit
;
1588 data
->pausable
= DCBX_IS_PFC_PRI_SOME_PAUSE(bp
,
1589 data
->pri_join_mask
);
1593 BNX2X_DCBX_STRICT_COS_NEXT_LOWER_PRI(strict_pri
);
1600 if (num_spread_of_entries
) {
1601 BNX2X_ERR("Didn't succeed to spread strict priorities\n");
1608 static u8
bnx2x_dcbx_cee_fill_strict_pri(struct bnx2x
*bp
,
1609 struct cos_help_data
*cos_data
,
1611 u8 num_spread_of_entries
,
1615 if (bnx2x_dcbx_spread_strict_pri(bp
, cos_data
, entry
,
1616 num_spread_of_entries
,
1618 struct cos_entry_help_data
*data
= &cos_data
->
1621 data
->cos_bw
= DCBX_INVALID_COS_BW
;
1622 data
->strict
= BNX2X_DCBX_STRICT_COS_HIGHEST
;
1623 data
->pri_join_mask
= strict_app_pris
;
1624 data
->pausable
= DCBX_IS_PFC_PRI_SOME_PAUSE(bp
,
1625 data
->pri_join_mask
);
1629 return num_spread_of_entries
;
1632 static void bnx2x_dcbx_cee_fill_cos_params(struct bnx2x
*bp
,
1633 struct pg_help_data
*help_data
,
1634 struct dcbx_ets_feature
*ets
,
1635 struct cos_help_data
*cos_data
,
1639 u8 need_num_of_entries
= 0;
1644 * if the number of requested PG-s in CEE is greater than 3
1645 * then the results are not determined since this is a violation
1648 if (help_data
->num_of_pg
> DCBX_COS_MAX_NUM_E3B0
) {
1649 if (bnx2x_dcbx_join_pgs(bp
, ets
, help_data
,
1650 DCBX_COS_MAX_NUM_E3B0
)) {
1651 BNX2X_ERR("Unable to reduce the number of PGs - we will disables ETS\n");
1652 bnx2x_dcbx_ets_disabled_entry_data(bp
, cos_data
,
1658 for (i
= 0 ; i
< help_data
->num_of_pg
; i
++) {
1659 struct pg_entry_help_data
*pg
= &help_data
->data
[i
];
1660 if (pg
->pg
< DCBX_MAX_NUM_PG_BW_ENTRIES
) {
1661 struct cos_entry_help_data
*data
= &cos_data
->
1664 data
->cos_bw
= DCBX_PG_BW_GET(ets
->pg_bw_tbl
, pg
->pg
);
1665 data
->strict
= BNX2X_DCBX_STRICT_INVALID
;
1666 data
->pri_join_mask
= pg
->pg_priority
;
1667 data
->pausable
= DCBX_IS_PFC_PRI_SOME_PAUSE(bp
,
1668 data
->pri_join_mask
);
1672 need_num_of_entries
= min_t(u8
,
1673 (u8
)pg
->num_of_dif_pri
,
1674 (u8
)DCBX_COS_MAX_NUM_E3B0
-
1675 help_data
->num_of_pg
+ 1);
1677 * If there are still VOQ-s which have no associated PG,
1678 * then associate these VOQ-s to PG15. These PG-s will
1679 * be used for SP between priorities on PG15.
1681 entry
+= bnx2x_dcbx_cee_fill_strict_pri(bp
, cos_data
,
1682 entry
, need_num_of_entries
, pg
->pg_priority
);
1686 /* the entry will represent the number of COSes used */
1687 cos_data
->num_of_cos
= entry
;
1689 static void bnx2x_dcbx_fill_cos_params(struct bnx2x
*bp
,
1690 struct pg_help_data
*help_data
,
1691 struct dcbx_ets_feature
*ets
,
1692 u32
*pg_pri_orginal_spread
)
1694 struct cos_help_data cos_data
;
1696 u32 pri_join_mask
= 0;
1697 u8 num_of_dif_pri
= 0;
1699 memset(&cos_data
, 0, sizeof(cos_data
));
1701 /* Validate the pg value */
1702 for (i
= 0; i
< help_data
->num_of_pg
; i
++) {
1703 if (DCBX_STRICT_PRIORITY
!= help_data
->data
[i
].pg
&&
1704 DCBX_MAX_NUM_PG_BW_ENTRIES
<= help_data
->data
[i
].pg
)
1705 BNX2X_ERR("Invalid pg[%d] data %x\n", i
,
1706 help_data
->data
[i
].pg
);
1707 pri_join_mask
|= help_data
->data
[i
].pg_priority
;
1708 num_of_dif_pri
+= help_data
->data
[i
].num_of_dif_pri
;
1712 cos_data
.num_of_cos
= 1;
1713 for (i
= 0; i
< ARRAY_SIZE(cos_data
.data
); i
++) {
1714 cos_data
.data
[i
].pri_join_mask
= 0;
1715 cos_data
.data
[i
].pausable
= false;
1716 cos_data
.data
[i
].strict
= BNX2X_DCBX_STRICT_INVALID
;
1717 cos_data
.data
[i
].cos_bw
= DCBX_INVALID_COS_BW
;
1720 if (CHIP_IS_E3B0(bp
))
1721 bnx2x_dcbx_cee_fill_cos_params(bp
, help_data
, ets
,
1722 &cos_data
, pri_join_mask
);
1723 else /* E2 + E3A0 */
1724 bnx2x_dcbx_2cos_limit_cee_fill_cos_params(bp
,
1727 pg_pri_orginal_spread
,
1731 for (i
= 0; i
< cos_data
.num_of_cos
; i
++) {
1732 struct bnx2x_dcbx_cos_params
*p
=
1733 &bp
->dcbx_port_params
.ets
.cos_params
[i
];
1735 p
->strict
= cos_data
.data
[i
].strict
;
1736 p
->bw_tbl
= cos_data
.data
[i
].cos_bw
;
1737 p
->pri_bitmask
= cos_data
.data
[i
].pri_join_mask
;
1738 p
->pauseable
= cos_data
.data
[i
].pausable
;
1741 if (p
->bw_tbl
!= DCBX_INVALID_COS_BW
||
1742 p
->strict
!= BNX2X_DCBX_STRICT_INVALID
) {
1743 if (p
->pri_bitmask
== 0)
1744 BNX2X_ERR("Invalid pri_bitmask for %d\n", i
);
1746 if (CHIP_IS_E2(bp
) || CHIP_IS_E3A0(bp
)) {
1749 DCBX_PFC_PRI_GET_NON_PAUSE(bp
,
1750 p
->pri_bitmask
) != 0)
1751 BNX2X_ERR("Inconsistent config for pausable COS %d\n",
1754 if (!p
->pauseable
&&
1755 DCBX_PFC_PRI_GET_PAUSE(bp
,
1756 p
->pri_bitmask
) != 0)
1757 BNX2X_ERR("Inconsistent config for nonpausable COS %d\n",
1763 DP(BNX2X_MSG_DCB
, "COS %d PAUSABLE prijoinmask 0x%x\n",
1764 i
, cos_data
.data
[i
].pri_join_mask
);
1767 "COS %d NONPAUSABLE prijoinmask 0x%x\n",
1768 i
, cos_data
.data
[i
].pri_join_mask
);
1771 bp
->dcbx_port_params
.ets
.num_of_cos
= cos_data
.num_of_cos
;
1774 static void bnx2x_dcbx_get_ets_pri_pg_tbl(struct bnx2x
*bp
,
1775 u32
*set_configuration_ets_pg
,
1780 for (i
= 0; i
< DCBX_MAX_NUM_PRI_PG_ENTRIES
; i
++) {
1781 set_configuration_ets_pg
[i
] = DCBX_PRI_PG_GET(pri_pg_tbl
, i
);
1783 DP(BNX2X_MSG_DCB
, "set_configuration_ets_pg[%d] = 0x%x\n",
1784 i
, set_configuration_ets_pg
[i
]);
1788 static void bnx2x_dcbx_fw_struct(struct bnx2x
*bp
,
1789 struct bnx2x_func_tx_start_params
*pfc_fw_cfg
)
1792 u8 cos
= 0, pri
= 0;
1793 struct priority_cos
*tt2cos
;
1794 u32
*ttp
= bp
->dcbx_port_params
.app
.traffic_type_priority
;
1796 memset(pfc_fw_cfg
, 0, sizeof(*pfc_fw_cfg
));
1798 /* to disable DCB - the structure must be zeroed */
1799 if (bp
->dcbx_error
& DCBX_REMOTE_MIB_ERROR
)
1803 tt2cos
= pfc_fw_cfg
->traffic_type_to_priority_cos
;
1805 /* Fw version should be incremented each update */
1806 pfc_fw_cfg
->dcb_version
= ++bp
->dcb_version
;
1807 pfc_fw_cfg
->dcb_enabled
= 1;
1809 /* Fill priority parameters */
1810 for (pri
= 0; pri
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
; pri
++) {
1811 tt2cos
[pri
].priority
= ttp
[pri
];
1812 pri_bit
= 1 << tt2cos
[pri
].priority
;
1814 /* Fill COS parameters based on COS calculated to
1815 * make it more general for future use */
1816 for (cos
= 0; cos
< bp
->dcbx_port_params
.ets
.num_of_cos
; cos
++)
1817 if (bp
->dcbx_port_params
.ets
.cos_params
[cos
].
1818 pri_bitmask
& pri_bit
)
1819 tt2cos
[pri
].cos
= cos
;
1822 /* we never want the FW to add a 0 vlan tag */
1823 pfc_fw_cfg
->dont_add_pri_0_en
= 1;
1825 bnx2x_dcbx_print_cos_params(bp
, pfc_fw_cfg
);
1828 void bnx2x_dcbx_pmf_update(struct bnx2x
*bp
)
1830 /* if we need to syncronize DCBX result from prev PMF
1831 * read it from shmem and update bp and netdev accordingly
1833 if (SHMEM2_HAS(bp
, drv_flags
) &&
1834 GET_FLAGS(SHMEM2_RD(bp
, drv_flags
), 1 << DRV_FLAGS_DCB_CONFIGURED
)) {
1835 /* Read neg results if dcbx is in the FW */
1836 if (bnx2x_dcbx_read_shmem_neg_results(bp
))
1839 bnx2x_dump_dcbx_drv_param(bp
, &bp
->dcbx_local_feat
,
1841 bnx2x_get_dcbx_drv_param(bp
, &bp
->dcbx_local_feat
,
1845 * Add new app tlvs to dcbnl
1847 bnx2x_dcbnl_update_applist(bp
, false);
1849 * Send a notification for the new negotiated parameters
1851 dcbnl_cee_notify(bp
->dev
, RTM_GETDCB
, DCB_CMD_CEE_GET
, 0, 0);
1854 * reconfigure the netdevice with the results of the new
1857 bnx2x_dcbx_update_tc_mapping(bp
);
1865 #define BNX2X_DCBX_CAPS (DCB_CAP_DCBX_LLD_MANAGED | \
1866 DCB_CAP_DCBX_VER_CEE | DCB_CAP_DCBX_STATIC)
1868 static inline bool bnx2x_dcbnl_set_valid(struct bnx2x
*bp
)
1870 /* validate dcbnl call that may change HW state:
1871 * DCB is on and DCBX mode was SUCCESSFULLY set by the user.
1873 return bp
->dcb_state
&& bp
->dcbx_mode_uset
;
1876 static u8
bnx2x_dcbnl_get_state(struct net_device
*netdev
)
1878 struct bnx2x
*bp
= netdev_priv(netdev
);
1879 DP(BNX2X_MSG_DCB
, "state = %d\n", bp
->dcb_state
);
1880 return bp
->dcb_state
;
1883 static u8
bnx2x_dcbnl_set_state(struct net_device
*netdev
, u8 state
)
1885 struct bnx2x
*bp
= netdev_priv(netdev
);
1886 DP(BNX2X_MSG_DCB
, "state = %s\n", state
? "on" : "off");
1888 bnx2x_dcbx_set_state(bp
, (state
? true : false), bp
->dcbx_enabled
);
1892 static void bnx2x_dcbnl_get_perm_hw_addr(struct net_device
*netdev
,
1895 struct bnx2x
*bp
= netdev_priv(netdev
);
1896 DP(BNX2X_MSG_DCB
, "GET-PERM-ADDR\n");
1898 /* first the HW mac address */
1899 memcpy(perm_addr
, netdev
->dev_addr
, netdev
->addr_len
);
1902 /* second SAN address */
1903 memcpy(perm_addr
+netdev
->addr_len
, bp
->fip_mac
, netdev
->addr_len
);
1907 static void bnx2x_dcbnl_set_pg_tccfg_tx(struct net_device
*netdev
, int prio
,
1908 u8 prio_type
, u8 pgid
, u8 bw_pct
,
1911 struct bnx2x
*bp
= netdev_priv(netdev
);
1913 DP(BNX2X_MSG_DCB
, "prio[%d] = %d\n", prio
, pgid
);
1914 if (!bnx2x_dcbnl_set_valid(bp
) || prio
>= DCBX_MAX_NUM_PRI_PG_ENTRIES
)
1918 * bw_pct ingnored - band-width percentage devision between user
1919 * priorities within the same group is not
1920 * standard and hence not supported
1922 * prio_type igonred - priority levels within the same group are not
1923 * standard and hence are not supported. According
1924 * to the standard pgid 15 is dedicated to strict
1925 * prioirty traffic (on the port level).
1930 bp
->dcbx_config_params
.admin_configuration_ets_pg
[prio
] = pgid
;
1931 bp
->dcbx_config_params
.admin_ets_configuration_tx_enable
= 1;
1934 static void bnx2x_dcbnl_set_pg_bwgcfg_tx(struct net_device
*netdev
,
1935 int pgid
, u8 bw_pct
)
1937 struct bnx2x
*bp
= netdev_priv(netdev
);
1938 DP(BNX2X_MSG_DCB
, "pgid[%d] = %d\n", pgid
, bw_pct
);
1940 if (!bnx2x_dcbnl_set_valid(bp
) || pgid
>= DCBX_MAX_NUM_PG_BW_ENTRIES
)
1943 bp
->dcbx_config_params
.admin_configuration_bw_precentage
[pgid
] = bw_pct
;
1944 bp
->dcbx_config_params
.admin_ets_configuration_tx_enable
= 1;
1947 static void bnx2x_dcbnl_set_pg_tccfg_rx(struct net_device
*netdev
, int prio
,
1948 u8 prio_type
, u8 pgid
, u8 bw_pct
,
1951 struct bnx2x
*bp
= netdev_priv(netdev
);
1952 DP(BNX2X_MSG_DCB
, "Nothing to set; No RX support\n");
1955 static void bnx2x_dcbnl_set_pg_bwgcfg_rx(struct net_device
*netdev
,
1956 int pgid
, u8 bw_pct
)
1958 struct bnx2x
*bp
= netdev_priv(netdev
);
1959 DP(BNX2X_MSG_DCB
, "Nothing to set; No RX support\n");
1962 static void bnx2x_dcbnl_get_pg_tccfg_tx(struct net_device
*netdev
, int prio
,
1963 u8
*prio_type
, u8
*pgid
, u8
*bw_pct
,
1966 struct bnx2x
*bp
= netdev_priv(netdev
);
1967 DP(BNX2X_MSG_DCB
, "prio = %d\n", prio
);
1970 * bw_pct ingnored - band-width percentage devision between user
1971 * priorities within the same group is not
1972 * standard and hence not supported
1974 * prio_type igonred - priority levels within the same group are not
1975 * standard and hence are not supported. According
1976 * to the standard pgid 15 is dedicated to strict
1977 * prioirty traffic (on the port level).
1981 *up_map
= *bw_pct
= *prio_type
= *pgid
= 0;
1983 if (!bp
->dcb_state
|| prio
>= DCBX_MAX_NUM_PRI_PG_ENTRIES
)
1986 *pgid
= DCBX_PRI_PG_GET(bp
->dcbx_local_feat
.ets
.pri_pg_tbl
, prio
);
1989 static void bnx2x_dcbnl_get_pg_bwgcfg_tx(struct net_device
*netdev
,
1990 int pgid
, u8
*bw_pct
)
1992 struct bnx2x
*bp
= netdev_priv(netdev
);
1993 DP(BNX2X_MSG_DCB
, "pgid = %d\n", pgid
);
1997 if (!bp
->dcb_state
|| pgid
>= DCBX_MAX_NUM_PG_BW_ENTRIES
)
2000 *bw_pct
= DCBX_PG_BW_GET(bp
->dcbx_local_feat
.ets
.pg_bw_tbl
, pgid
);
2003 static void bnx2x_dcbnl_get_pg_tccfg_rx(struct net_device
*netdev
, int prio
,
2004 u8
*prio_type
, u8
*pgid
, u8
*bw_pct
,
2007 struct bnx2x
*bp
= netdev_priv(netdev
);
2008 DP(BNX2X_MSG_DCB
, "Nothing to get; No RX support\n");
2010 *prio_type
= *pgid
= *bw_pct
= *up_map
= 0;
2013 static void bnx2x_dcbnl_get_pg_bwgcfg_rx(struct net_device
*netdev
,
2014 int pgid
, u8
*bw_pct
)
2016 struct bnx2x
*bp
= netdev_priv(netdev
);
2017 DP(BNX2X_MSG_DCB
, "Nothing to get; No RX support\n");
2022 static void bnx2x_dcbnl_set_pfc_cfg(struct net_device
*netdev
, int prio
,
2025 struct bnx2x
*bp
= netdev_priv(netdev
);
2026 DP(BNX2X_MSG_DCB
, "prio[%d] = %d\n", prio
, setting
);
2028 if (!bnx2x_dcbnl_set_valid(bp
) || prio
>= MAX_PFC_PRIORITIES
)
2031 bp
->dcbx_config_params
.admin_pfc_bitmap
|= ((setting
? 1 : 0) << prio
);
2034 bp
->dcbx_config_params
.admin_pfc_tx_enable
= 1;
2037 static void bnx2x_dcbnl_get_pfc_cfg(struct net_device
*netdev
, int prio
,
2040 struct bnx2x
*bp
= netdev_priv(netdev
);
2041 DP(BNX2X_MSG_DCB
, "prio = %d\n", prio
);
2045 if (!bp
->dcb_state
|| prio
>= MAX_PFC_PRIORITIES
)
2048 *setting
= (bp
->dcbx_local_feat
.pfc
.pri_en_bitmap
>> prio
) & 0x1;
2051 static u8
bnx2x_dcbnl_set_all(struct net_device
*netdev
)
2053 struct bnx2x
*bp
= netdev_priv(netdev
);
2056 DP(BNX2X_MSG_DCB
, "SET-ALL\n");
2058 if (!bnx2x_dcbnl_set_valid(bp
))
2061 if (bp
->recovery_state
!= BNX2X_RECOVERY_DONE
) {
2063 "Handling parity error recovery. Try again later\n");
2066 if (netif_running(bp
->dev
)) {
2067 bnx2x_nic_unload(bp
, UNLOAD_NORMAL
);
2068 rc
= bnx2x_nic_load(bp
, LOAD_NORMAL
);
2070 DP(BNX2X_MSG_DCB
, "set_dcbx_params done (%d)\n", rc
);
2077 static u8
bnx2x_dcbnl_get_cap(struct net_device
*netdev
, int capid
, u8
*cap
)
2079 struct bnx2x
*bp
= netdev_priv(netdev
);
2082 if (bp
->dcb_state
) {
2084 case DCB_CAP_ATTR_PG
:
2087 case DCB_CAP_ATTR_PFC
:
2090 case DCB_CAP_ATTR_UP2TC
:
2093 case DCB_CAP_ATTR_PG_TCS
:
2094 *cap
= 0x80; /* 8 priorities for PGs */
2096 case DCB_CAP_ATTR_PFC_TCS
:
2097 *cap
= 0x80; /* 8 priorities for PFC */
2099 case DCB_CAP_ATTR_GSP
:
2102 case DCB_CAP_ATTR_BCN
:
2105 case DCB_CAP_ATTR_DCBX
:
2106 *cap
= BNX2X_DCBX_CAPS
;
2109 BNX2X_ERR("Non valid capability ID\n");
2114 DP(BNX2X_MSG_DCB
, "DCB disabled\n");
2118 DP(BNX2X_MSG_DCB
, "capid %d:%x\n", capid
, *cap
);
2122 static int bnx2x_dcbnl_get_numtcs(struct net_device
*netdev
, int tcid
, u8
*num
)
2124 struct bnx2x
*bp
= netdev_priv(netdev
);
2127 DP(BNX2X_MSG_DCB
, "tcid %d\n", tcid
);
2129 if (bp
->dcb_state
) {
2131 case DCB_NUMTCS_ATTR_PG
:
2132 *num
= CHIP_IS_E3B0(bp
) ? DCBX_COS_MAX_NUM_E3B0
:
2133 DCBX_COS_MAX_NUM_E2
;
2135 case DCB_NUMTCS_ATTR_PFC
:
2136 *num
= CHIP_IS_E3B0(bp
) ? DCBX_COS_MAX_NUM_E3B0
:
2137 DCBX_COS_MAX_NUM_E2
;
2140 BNX2X_ERR("Non valid TC-ID\n");
2145 DP(BNX2X_MSG_DCB
, "DCB disabled\n");
2152 static int bnx2x_dcbnl_set_numtcs(struct net_device
*netdev
, int tcid
, u8 num
)
2154 struct bnx2x
*bp
= netdev_priv(netdev
);
2155 DP(BNX2X_MSG_DCB
, "num tcs = %d; Not supported\n", num
);
2159 static u8
bnx2x_dcbnl_get_pfc_state(struct net_device
*netdev
)
2161 struct bnx2x
*bp
= netdev_priv(netdev
);
2162 DP(BNX2X_MSG_DCB
, "state = %d\n", bp
->dcbx_local_feat
.pfc
.enabled
);
2167 return bp
->dcbx_local_feat
.pfc
.enabled
;
2170 static void bnx2x_dcbnl_set_pfc_state(struct net_device
*netdev
, u8 state
)
2172 struct bnx2x
*bp
= netdev_priv(netdev
);
2173 DP(BNX2X_MSG_DCB
, "state = %s\n", state
? "on" : "off");
2175 if (!bnx2x_dcbnl_set_valid(bp
))
2178 bp
->dcbx_config_params
.admin_pfc_tx_enable
=
2179 bp
->dcbx_config_params
.admin_pfc_enable
= (state
? 1 : 0);
2182 static void bnx2x_admin_app_set_ent(
2183 struct bnx2x_admin_priority_app_table
*app_ent
,
2184 u8 idtype
, u16 idval
, u8 up
)
2189 case DCB_APP_IDTYPE_ETHTYPE
:
2190 app_ent
->traffic_type
= TRAFFIC_TYPE_ETH
;
2192 case DCB_APP_IDTYPE_PORTNUM
:
2193 app_ent
->traffic_type
= TRAFFIC_TYPE_PORT
;
2196 break; /* never gets here */
2198 app_ent
->app_id
= idval
;
2199 app_ent
->priority
= up
;
2202 static bool bnx2x_admin_app_is_equal(
2203 struct bnx2x_admin_priority_app_table
*app_ent
,
2204 u8 idtype
, u16 idval
)
2206 if (!app_ent
->valid
)
2210 case DCB_APP_IDTYPE_ETHTYPE
:
2211 if (app_ent
->traffic_type
!= TRAFFIC_TYPE_ETH
)
2214 case DCB_APP_IDTYPE_PORTNUM
:
2215 if (app_ent
->traffic_type
!= TRAFFIC_TYPE_PORT
)
2221 if (app_ent
->app_id
!= idval
)
2227 static int bnx2x_set_admin_app_up(struct bnx2x
*bp
, u8 idtype
, u16 idval
, u8 up
)
2231 /* iterate over the app entries looking for idtype and idval */
2232 for (i
= 0, ff
= -1; i
< DCBX_CONFIG_MAX_APP_PROTOCOL
; i
++) {
2233 struct bnx2x_admin_priority_app_table
*app_ent
=
2234 &bp
->dcbx_config_params
.admin_priority_app_table
[i
];
2235 if (bnx2x_admin_app_is_equal(app_ent
, idtype
, idval
))
2238 if (ff
< 0 && !app_ent
->valid
)
2241 if (i
< DCBX_CONFIG_MAX_APP_PROTOCOL
)
2242 /* if found overwrite up */
2243 bp
->dcbx_config_params
.
2244 admin_priority_app_table
[i
].priority
= up
;
2246 /* not found use first-free */
2247 bnx2x_admin_app_set_ent(
2248 &bp
->dcbx_config_params
.admin_priority_app_table
[ff
],
2251 /* app table is full */
2252 BNX2X_ERR("Application table is too large\n");
2256 /* up configured, if not 0 make sure feature is enabled */
2258 bp
->dcbx_config_params
.admin_application_priority_tx_enable
= 1;
2263 static u8
bnx2x_dcbnl_set_app_up(struct net_device
*netdev
, u8 idtype
,
2266 struct bnx2x
*bp
= netdev_priv(netdev
);
2268 DP(BNX2X_MSG_DCB
, "app_type %d, app_id %x, prio bitmap %d\n",
2271 if (!bnx2x_dcbnl_set_valid(bp
)) {
2272 DP(BNX2X_MSG_DCB
, "dcbnl call not valid\n");
2278 case DCB_APP_IDTYPE_ETHTYPE
:
2279 case DCB_APP_IDTYPE_PORTNUM
:
2282 DP(BNX2X_MSG_DCB
, "Wrong ID type\n");
2285 return bnx2x_set_admin_app_up(bp
, idtype
, idval
, up
);
2288 static u8
bnx2x_dcbnl_get_dcbx(struct net_device
*netdev
)
2290 struct bnx2x
*bp
= netdev_priv(netdev
);
2293 state
= DCB_CAP_DCBX_LLD_MANAGED
| DCB_CAP_DCBX_VER_CEE
;
2295 if (bp
->dcbx_enabled
== BNX2X_DCBX_ENABLED_ON_NEG_OFF
)
2296 state
|= DCB_CAP_DCBX_STATIC
;
2301 static u8
bnx2x_dcbnl_set_dcbx(struct net_device
*netdev
, u8 state
)
2303 struct bnx2x
*bp
= netdev_priv(netdev
);
2304 DP(BNX2X_MSG_DCB
, "state = %02x\n", state
);
2308 if ((state
& BNX2X_DCBX_CAPS
) != state
) {
2309 BNX2X_ERR("Requested DCBX mode %x is beyond advertised capabilities\n",
2314 if (bp
->dcb_state
!= BNX2X_DCB_STATE_ON
) {
2315 BNX2X_ERR("DCB turned off, DCBX configuration is invalid\n");
2319 if (state
& DCB_CAP_DCBX_STATIC
)
2320 bp
->dcbx_enabled
= BNX2X_DCBX_ENABLED_ON_NEG_OFF
;
2322 bp
->dcbx_enabled
= BNX2X_DCBX_ENABLED_ON_NEG_ON
;
2324 bp
->dcbx_mode_uset
= true;
2328 static u8
bnx2x_dcbnl_get_featcfg(struct net_device
*netdev
, int featid
,
2331 struct bnx2x
*bp
= netdev_priv(netdev
);
2334 DP(BNX2X_MSG_DCB
, "featid %d\n", featid
);
2336 if (bp
->dcb_state
) {
2339 case DCB_FEATCFG_ATTR_PG
:
2340 if (bp
->dcbx_local_feat
.ets
.enabled
)
2341 *flags
|= DCB_FEATCFG_ENABLE
;
2342 if (bp
->dcbx_error
& DCBX_LOCAL_ETS_ERROR
)
2343 *flags
|= DCB_FEATCFG_ERROR
;
2345 case DCB_FEATCFG_ATTR_PFC
:
2346 if (bp
->dcbx_local_feat
.pfc
.enabled
)
2347 *flags
|= DCB_FEATCFG_ENABLE
;
2348 if (bp
->dcbx_error
& (DCBX_LOCAL_PFC_ERROR
|
2349 DCBX_LOCAL_PFC_MISMATCH
))
2350 *flags
|= DCB_FEATCFG_ERROR
;
2352 case DCB_FEATCFG_ATTR_APP
:
2353 if (bp
->dcbx_local_feat
.app
.enabled
)
2354 *flags
|= DCB_FEATCFG_ENABLE
;
2355 if (bp
->dcbx_error
& (DCBX_LOCAL_APP_ERROR
|
2356 DCBX_LOCAL_APP_MISMATCH
))
2357 *flags
|= DCB_FEATCFG_ERROR
;
2360 BNX2X_ERR("Non valid featrue-ID\n");
2365 DP(BNX2X_MSG_DCB
, "DCB disabled\n");
2372 static u8
bnx2x_dcbnl_set_featcfg(struct net_device
*netdev
, int featid
,
2375 struct bnx2x
*bp
= netdev_priv(netdev
);
2378 DP(BNX2X_MSG_DCB
, "featid = %d flags = %02x\n", featid
, flags
);
2380 /* ignore the 'advertise' flag */
2381 if (bnx2x_dcbnl_set_valid(bp
)) {
2383 case DCB_FEATCFG_ATTR_PG
:
2384 bp
->dcbx_config_params
.admin_ets_enable
=
2385 flags
& DCB_FEATCFG_ENABLE
? 1 : 0;
2386 bp
->dcbx_config_params
.admin_ets_willing
=
2387 flags
& DCB_FEATCFG_WILLING
? 1 : 0;
2389 case DCB_FEATCFG_ATTR_PFC
:
2390 bp
->dcbx_config_params
.admin_pfc_enable
=
2391 flags
& DCB_FEATCFG_ENABLE
? 1 : 0;
2392 bp
->dcbx_config_params
.admin_pfc_willing
=
2393 flags
& DCB_FEATCFG_WILLING
? 1 : 0;
2395 case DCB_FEATCFG_ATTR_APP
:
2396 /* ignore enable, always enabled */
2397 bp
->dcbx_config_params
.admin_app_priority_willing
=
2398 flags
& DCB_FEATCFG_WILLING
? 1 : 0;
2401 BNX2X_ERR("Non valid featrue-ID\n");
2406 DP(BNX2X_MSG_DCB
, "dcbnl call not valid\n");
2413 static int bnx2x_peer_appinfo(struct net_device
*netdev
,
2414 struct dcb_peer_app_info
*info
, u16
* app_count
)
2417 struct bnx2x
*bp
= netdev_priv(netdev
);
2419 DP(BNX2X_MSG_DCB
, "APP-INFO\n");
2421 info
->willing
= (bp
->dcbx_remote_flags
& DCBX_APP_REM_WILLING
) ?: 0;
2422 info
->error
= (bp
->dcbx_remote_flags
& DCBX_APP_RX_ERROR
) ?: 0;
2425 for (i
= 0; i
< DCBX_MAX_APP_PROTOCOL
; i
++)
2426 if (bp
->dcbx_remote_feat
.app
.app_pri_tbl
[i
].appBitfield
&
2427 DCBX_APP_ENTRY_VALID
)
2432 static int bnx2x_peer_apptable(struct net_device
*netdev
,
2433 struct dcb_app
*table
)
2436 struct bnx2x
*bp
= netdev_priv(netdev
);
2438 DP(BNX2X_MSG_DCB
, "APP-TABLE\n");
2440 for (i
= 0, j
= 0; i
< DCBX_MAX_APP_PROTOCOL
; i
++) {
2441 struct dcbx_app_priority_entry
*ent
=
2442 &bp
->dcbx_remote_feat
.app
.app_pri_tbl
[i
];
2444 if (ent
->appBitfield
& DCBX_APP_ENTRY_VALID
) {
2445 table
[j
].selector
= bnx2x_dcbx_dcbnl_app_idtype(ent
);
2446 table
[j
].priority
= bnx2x_dcbx_dcbnl_app_up(ent
);
2447 table
[j
++].protocol
= ent
->app_id
;
2453 static int bnx2x_cee_peer_getpg(struct net_device
*netdev
, struct cee_pg
*pg
)
2456 struct bnx2x
*bp
= netdev_priv(netdev
);
2458 pg
->willing
= (bp
->dcbx_remote_flags
& DCBX_ETS_REM_WILLING
) ?: 0;
2460 for (i
= 0; i
< CEE_DCBX_MAX_PGS
; i
++) {
2462 DCBX_PG_BW_GET(bp
->dcbx_remote_feat
.ets
.pg_bw_tbl
, i
);
2464 DCBX_PRI_PG_GET(bp
->dcbx_remote_feat
.ets
.pri_pg_tbl
, i
);
2469 static int bnx2x_cee_peer_getpfc(struct net_device
*netdev
,
2470 struct cee_pfc
*pfc
)
2472 struct bnx2x
*bp
= netdev_priv(netdev
);
2473 pfc
->tcs_supported
= bp
->dcbx_remote_feat
.pfc
.pfc_caps
;
2474 pfc
->pfc_en
= bp
->dcbx_remote_feat
.pfc
.pri_en_bitmap
;
2478 const struct dcbnl_rtnl_ops bnx2x_dcbnl_ops
= {
2479 .getstate
= bnx2x_dcbnl_get_state
,
2480 .setstate
= bnx2x_dcbnl_set_state
,
2481 .getpermhwaddr
= bnx2x_dcbnl_get_perm_hw_addr
,
2482 .setpgtccfgtx
= bnx2x_dcbnl_set_pg_tccfg_tx
,
2483 .setpgbwgcfgtx
= bnx2x_dcbnl_set_pg_bwgcfg_tx
,
2484 .setpgtccfgrx
= bnx2x_dcbnl_set_pg_tccfg_rx
,
2485 .setpgbwgcfgrx
= bnx2x_dcbnl_set_pg_bwgcfg_rx
,
2486 .getpgtccfgtx
= bnx2x_dcbnl_get_pg_tccfg_tx
,
2487 .getpgbwgcfgtx
= bnx2x_dcbnl_get_pg_bwgcfg_tx
,
2488 .getpgtccfgrx
= bnx2x_dcbnl_get_pg_tccfg_rx
,
2489 .getpgbwgcfgrx
= bnx2x_dcbnl_get_pg_bwgcfg_rx
,
2490 .setpfccfg
= bnx2x_dcbnl_set_pfc_cfg
,
2491 .getpfccfg
= bnx2x_dcbnl_get_pfc_cfg
,
2492 .setall
= bnx2x_dcbnl_set_all
,
2493 .getcap
= bnx2x_dcbnl_get_cap
,
2494 .getnumtcs
= bnx2x_dcbnl_get_numtcs
,
2495 .setnumtcs
= bnx2x_dcbnl_set_numtcs
,
2496 .getpfcstate
= bnx2x_dcbnl_get_pfc_state
,
2497 .setpfcstate
= bnx2x_dcbnl_set_pfc_state
,
2498 .setapp
= bnx2x_dcbnl_set_app_up
,
2499 .getdcbx
= bnx2x_dcbnl_get_dcbx
,
2500 .setdcbx
= bnx2x_dcbnl_set_dcbx
,
2501 .getfeatcfg
= bnx2x_dcbnl_get_featcfg
,
2502 .setfeatcfg
= bnx2x_dcbnl_set_featcfg
,
2503 .peer_getappinfo
= bnx2x_peer_appinfo
,
2504 .peer_getapptable
= bnx2x_peer_apptable
,
2505 .cee_peer_getpg
= bnx2x_cee_peer_getpg
,
2506 .cee_peer_getpfc
= bnx2x_cee_peer_getpfc
,
2509 #endif /* BCM_DCBNL */