1 /* bnx2x_dcb.c: Broadcom Everest network driver.
3 * Copyright 2009-2011 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
19 #include <linux/netdevice.h>
20 #include <linux/types.h>
21 #include <linux/errno.h>
24 #include "bnx2x_cmn.h"
25 #include "bnx2x_dcb.h"
28 #include <linux/rtnetlink.h>
31 /* forward declarations of dcbx related functions */
32 static void bnx2x_dcbx_stop_hw_tx(struct bnx2x
*bp
);
33 static void bnx2x_pfc_set_pfc(struct bnx2x
*bp
);
34 static void bnx2x_dcbx_update_ets_params(struct bnx2x
*bp
);
35 static void bnx2x_dcbx_resume_hw_tx(struct bnx2x
*bp
);
36 static void bnx2x_dcbx_get_ets_pri_pg_tbl(struct bnx2x
*bp
,
37 u32
*set_configuration_ets_pg
,
39 static void bnx2x_dcbx_get_num_pg_traf_type(struct bnx2x
*bp
,
40 u32
*pg_pri_orginal_spread
,
41 struct pg_help_data
*help_data
);
42 static void bnx2x_dcbx_fill_cos_params(struct bnx2x
*bp
,
43 struct pg_help_data
*help_data
,
44 struct dcbx_ets_feature
*ets
,
45 u32
*pg_pri_orginal_spread
);
46 static void bnx2x_dcbx_separate_pauseable_from_non(struct bnx2x
*bp
,
47 struct cos_help_data
*cos_data
,
48 u32
*pg_pri_orginal_spread
,
49 struct dcbx_ets_feature
*ets
);
50 static void bnx2x_dcbx_fw_struct(struct bnx2x
*bp
);
53 static void bnx2x_pfc_set(struct bnx2x
*bp
)
55 struct bnx2x_nig_brb_pfc_port_params pfc_params
= {0};
59 pfc_params
.num_of_rx_cos_priority_mask
=
60 bp
->dcbx_port_params
.ets
.num_of_cos
;
62 /* Tx COS configuration */
63 for (i
= 0; i
< bp
->dcbx_port_params
.ets
.num_of_cos
; i
++)
65 * We configure only the pauseable bits (non pauseable aren't
66 * configured at all) it's done to avoid false pauses from
69 pfc_params
.rx_cos_priority_mask
[i
] =
70 bp
->dcbx_port_params
.ets
.cos_params
[i
].pri_bitmask
71 & DCBX_PFC_PRI_PAUSE_MASK(bp
);
74 * Rx COS configuration
75 * Changing PFC RX configuration .
76 * In RX COS0 will always be configured to lossy and COS1 to lossless
78 for (i
= 0 ; i
< MAX_PFC_PRIORITIES
; i
++) {
81 if (pri_bit
& DCBX_PFC_PRI_PAUSE_MASK(bp
))
85 pfc_params
.pkt_priority_to_cos
= val
;
88 pfc_params
.llfc_low_priority_classes
= 0;
90 pfc_params
.llfc_high_priority_classes
= DCBX_PFC_PRI_PAUSE_MASK(bp
);
92 /* BRB configuration */
93 pfc_params
.cos0_pauseable
= false;
94 pfc_params
.cos1_pauseable
= true;
96 bnx2x_acquire_phy_lock(bp
);
97 bp
->link_params
.feature_config_flags
|= FEATURE_CONFIG_PFC_ENABLED
;
98 bnx2x_update_pfc(&bp
->link_params
, &bp
->link_vars
, &pfc_params
);
99 bnx2x_release_phy_lock(bp
);
102 static void bnx2x_pfc_clear(struct bnx2x
*bp
)
104 struct bnx2x_nig_brb_pfc_port_params nig_params
= {0};
105 nig_params
.pause_enable
= 1;
107 if (bp
->flags
& SAFC_TX_FLAG
) {
108 u32 high
= 0, low
= 0;
111 for (i
= 0; i
< BNX2X_MAX_PRIORITY
; i
++) {
112 if (bp
->pri_map
[i
] == 1)
114 if (bp
->pri_map
[i
] == 0)
118 nig_params
.llfc_low_priority_classes
= high
;
119 nig_params
.llfc_low_priority_classes
= low
;
121 nig_params
.pause_enable
= 0;
122 nig_params
.llfc_enable
= 1;
123 nig_params
.llfc_out_en
= 1;
125 #endif /* BNX2X_SAFC */
126 bnx2x_acquire_phy_lock(bp
);
127 bp
->link_params
.feature_config_flags
&= ~FEATURE_CONFIG_PFC_ENABLED
;
128 bnx2x_update_pfc(&bp
->link_params
, &bp
->link_vars
, &nig_params
);
129 bnx2x_release_phy_lock(bp
);
132 static void bnx2x_dump_dcbx_drv_param(struct bnx2x
*bp
,
133 struct dcbx_features
*features
,
137 DP(NETIF_MSG_LINK
, "local_mib.error %x\n", error
);
141 "local_mib.features.ets.enabled %x\n", features
->ets
.enabled
);
142 for (i
= 0; i
< DCBX_MAX_NUM_PG_BW_ENTRIES
; i
++)
144 "local_mib.features.ets.pg_bw_tbl[%d] %d\n", i
,
145 DCBX_PG_BW_GET(features
->ets
.pg_bw_tbl
, i
));
146 for (i
= 0; i
< DCBX_MAX_NUM_PRI_PG_ENTRIES
; i
++)
148 "local_mib.features.ets.pri_pg_tbl[%d] %d\n", i
,
149 DCBX_PRI_PG_GET(features
->ets
.pri_pg_tbl
, i
));
152 DP(NETIF_MSG_LINK
, "dcbx_features.pfc.pri_en_bitmap %x\n",
153 features
->pfc
.pri_en_bitmap
);
154 DP(NETIF_MSG_LINK
, "dcbx_features.pfc.pfc_caps %x\n",
155 features
->pfc
.pfc_caps
);
156 DP(NETIF_MSG_LINK
, "dcbx_features.pfc.enabled %x\n",
157 features
->pfc
.enabled
);
159 DP(NETIF_MSG_LINK
, "dcbx_features.app.default_pri %x\n",
160 features
->app
.default_pri
);
161 DP(NETIF_MSG_LINK
, "dcbx_features.app.tc_supported %x\n",
162 features
->app
.tc_supported
);
163 DP(NETIF_MSG_LINK
, "dcbx_features.app.enabled %x\n",
164 features
->app
.enabled
);
165 for (i
= 0; i
< DCBX_MAX_APP_PROTOCOL
; i
++) {
167 "dcbx_features.app.app_pri_tbl[%x].app_id %x\n",
168 i
, features
->app
.app_pri_tbl
[i
].app_id
);
170 "dcbx_features.app.app_pri_tbl[%x].pri_bitmap %x\n",
171 i
, features
->app
.app_pri_tbl
[i
].pri_bitmap
);
173 "dcbx_features.app.app_pri_tbl[%x].appBitfield %x\n",
174 i
, features
->app
.app_pri_tbl
[i
].appBitfield
);
178 static void bnx2x_dcbx_get_ap_priority(struct bnx2x
*bp
,
182 u32 pri
= MAX_PFC_PRIORITIES
;
183 u32 index
= MAX_PFC_PRIORITIES
- 1;
185 u32
*ttp
= bp
->dcbx_port_params
.app
.traffic_type_priority
;
187 /* Choose the highest priority */
188 while ((MAX_PFC_PRIORITIES
== pri
) && (0 != index
)) {
189 pri_mask
= 1 << index
;
190 if (GET_FLAGS(pri_bitmap
, pri_mask
))
195 if (pri
< MAX_PFC_PRIORITIES
)
196 ttp
[llfc_traf_type
] = max_t(u32
, ttp
[llfc_traf_type
], pri
);
199 static void bnx2x_dcbx_get_ap_feature(struct bnx2x
*bp
,
200 struct dcbx_app_priority_feature
*app
,
203 u32
*ttp
= bp
->dcbx_port_params
.app
.traffic_type_priority
;
205 if (GET_FLAGS(error
, DCBX_LOCAL_APP_ERROR
))
206 DP(NETIF_MSG_LINK
, "DCBX_LOCAL_APP_ERROR\n");
208 if (app
->enabled
&& !GET_FLAGS(error
, DCBX_LOCAL_APP_ERROR
)) {
210 bp
->dcbx_port_params
.app
.enabled
= true;
212 for (index
= 0 ; index
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
; index
++)
215 if (app
->default_pri
< MAX_PFC_PRIORITIES
)
216 ttp
[LLFC_TRAFFIC_TYPE_NW
] = app
->default_pri
;
218 for (index
= 0 ; index
< DCBX_MAX_APP_PROTOCOL
; index
++) {
219 struct dcbx_app_priority_entry
*entry
=
222 if (GET_FLAGS(entry
[index
].appBitfield
,
223 DCBX_APP_SF_ETH_TYPE
) &&
224 ETH_TYPE_FCOE
== entry
[index
].app_id
)
225 bnx2x_dcbx_get_ap_priority(bp
,
226 entry
[index
].pri_bitmap
,
227 LLFC_TRAFFIC_TYPE_FCOE
);
229 if (GET_FLAGS(entry
[index
].appBitfield
,
231 TCP_PORT_ISCSI
== entry
[index
].app_id
)
232 bnx2x_dcbx_get_ap_priority(bp
,
233 entry
[index
].pri_bitmap
,
234 LLFC_TRAFFIC_TYPE_ISCSI
);
237 DP(NETIF_MSG_LINK
, "DCBX_LOCAL_APP_DISABLED\n");
238 bp
->dcbx_port_params
.app
.enabled
= false;
239 for (index
= 0 ; index
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
; index
++)
240 ttp
[index
] = INVALID_TRAFFIC_TYPE_PRIORITY
;
244 static void bnx2x_dcbx_get_ets_feature(struct bnx2x
*bp
,
245 struct dcbx_ets_feature
*ets
,
248 u32 pg_pri_orginal_spread
[DCBX_MAX_NUM_PG_BW_ENTRIES
] = {0};
249 struct pg_help_data pg_help_data
;
250 struct bnx2x_dcbx_cos_params
*cos_params
=
251 bp
->dcbx_port_params
.ets
.cos_params
;
253 memset(&pg_help_data
, 0, sizeof(struct pg_help_data
));
256 if (GET_FLAGS(error
, DCBX_LOCAL_ETS_ERROR
))
257 DP(NETIF_MSG_LINK
, "DCBX_LOCAL_ETS_ERROR\n");
260 /* Clean up old settings of ets on COS */
261 for (i
= 0; i
< ARRAY_SIZE(bp
->dcbx_port_params
.ets
.cos_params
) ; i
++) {
262 cos_params
[i
].pauseable
= false;
263 cos_params
[i
].strict
= BNX2X_DCBX_STRICT_INVALID
;
264 cos_params
[i
].bw_tbl
= DCBX_INVALID_COS_BW
;
265 cos_params
[i
].pri_bitmask
= 0;
268 if (bp
->dcbx_port_params
.app
.enabled
&&
269 !GET_FLAGS(error
, DCBX_LOCAL_ETS_ERROR
) &&
271 DP(NETIF_MSG_LINK
, "DCBX_LOCAL_ETS_ENABLE\n");
272 bp
->dcbx_port_params
.ets
.enabled
= true;
274 bnx2x_dcbx_get_ets_pri_pg_tbl(bp
,
275 pg_pri_orginal_spread
,
278 bnx2x_dcbx_get_num_pg_traf_type(bp
,
279 pg_pri_orginal_spread
,
282 bnx2x_dcbx_fill_cos_params(bp
, &pg_help_data
,
283 ets
, pg_pri_orginal_spread
);
286 DP(NETIF_MSG_LINK
, "DCBX_LOCAL_ETS_DISABLED\n");
287 bp
->dcbx_port_params
.ets
.enabled
= false;
288 ets
->pri_pg_tbl
[0] = 0;
290 for (i
= 0; i
< DCBX_MAX_NUM_PRI_PG_ENTRIES
; i
++)
291 DCBX_PG_BW_SET(ets
->pg_bw_tbl
, i
, 1);
295 static void bnx2x_dcbx_get_pfc_feature(struct bnx2x
*bp
,
296 struct dcbx_pfc_feature
*pfc
, u32 error
)
299 if (GET_FLAGS(error
, DCBX_LOCAL_PFC_ERROR
))
300 DP(NETIF_MSG_LINK
, "DCBX_LOCAL_PFC_ERROR\n");
302 if (bp
->dcbx_port_params
.app
.enabled
&&
303 !GET_FLAGS(error
, DCBX_LOCAL_PFC_ERROR
) &&
305 bp
->dcbx_port_params
.pfc
.enabled
= true;
306 bp
->dcbx_port_params
.pfc
.priority_non_pauseable_mask
=
307 ~(pfc
->pri_en_bitmap
);
309 DP(NETIF_MSG_LINK
, "DCBX_LOCAL_PFC_DISABLED\n");
310 bp
->dcbx_port_params
.pfc
.enabled
= false;
311 bp
->dcbx_port_params
.pfc
.priority_non_pauseable_mask
= 0;
315 static void bnx2x_get_dcbx_drv_param(struct bnx2x
*bp
,
316 struct dcbx_features
*features
,
319 bnx2x_dcbx_get_ap_feature(bp
, &features
->app
, error
);
321 bnx2x_dcbx_get_pfc_feature(bp
, &features
->pfc
, error
);
323 bnx2x_dcbx_get_ets_feature(bp
, &features
->ets
, error
);
326 #define DCBX_LOCAL_MIB_MAX_TRY_READ (100)
327 static int bnx2x_dcbx_read_mib(struct bnx2x
*bp
,
332 int max_try_read
= 0, i
;
333 u32
*buff
, mib_size
, prefix_seq_num
, suffix_seq_num
;
334 struct lldp_remote_mib
*remote_mib
;
335 struct lldp_local_mib
*local_mib
;
338 switch (read_mib_type
) {
339 case DCBX_READ_LOCAL_MIB
:
340 mib_size
= sizeof(struct lldp_local_mib
);
342 case DCBX_READ_REMOTE_MIB
:
343 mib_size
= sizeof(struct lldp_remote_mib
);
349 offset
+= BP_PORT(bp
) * mib_size
;
352 buff
= base_mib_addr
;
353 for (i
= 0; i
< mib_size
; i
+= 4, buff
++)
354 *buff
= REG_RD(bp
, offset
+ i
);
358 switch (read_mib_type
) {
359 case DCBX_READ_LOCAL_MIB
:
360 local_mib
= (struct lldp_local_mib
*) base_mib_addr
;
361 prefix_seq_num
= local_mib
->prefix_seq_num
;
362 suffix_seq_num
= local_mib
->suffix_seq_num
;
364 case DCBX_READ_REMOTE_MIB
:
365 remote_mib
= (struct lldp_remote_mib
*) base_mib_addr
;
366 prefix_seq_num
= remote_mib
->prefix_seq_num
;
367 suffix_seq_num
= remote_mib
->suffix_seq_num
;
372 } while ((prefix_seq_num
!= suffix_seq_num
) &&
373 (max_try_read
< DCBX_LOCAL_MIB_MAX_TRY_READ
));
375 if (max_try_read
>= DCBX_LOCAL_MIB_MAX_TRY_READ
) {
376 BNX2X_ERR("MIB could not be read\n");
383 static void bnx2x_pfc_set_pfc(struct bnx2x
*bp
)
386 BNX2X_ERR("4 port mode is not supported");
390 if (bp
->dcbx_port_params
.pfc
.enabled
)
392 * 1. Fills up common PFC structures if required
393 * 2. Configure NIG, MAC and BRB via the elink
400 static void bnx2x_dcbx_stop_hw_tx(struct bnx2x
*bp
)
402 DP(NETIF_MSG_LINK
, "sending STOP TRAFFIC\n");
403 bnx2x_sp_post(bp
, RAMROD_CMD_ID_COMMON_STOP_TRAFFIC
,
404 0 /* connectionless */,
405 0 /* dataHi is zero */,
406 0 /* dataLo is zero */,
407 NONE_CONNECTION_TYPE
);
410 static void bnx2x_dcbx_resume_hw_tx(struct bnx2x
*bp
)
412 bnx2x_dcbx_fw_struct(bp
);
413 DP(NETIF_MSG_LINK
, "sending START TRAFFIC\n");
414 bnx2x_sp_post(bp
, RAMROD_CMD_ID_COMMON_START_TRAFFIC
,
415 0, /* connectionless */
416 U64_HI(bnx2x_sp_mapping(bp
, pfc_config
)),
417 U64_LO(bnx2x_sp_mapping(bp
, pfc_config
)),
418 NONE_CONNECTION_TYPE
);
421 static void bnx2x_dcbx_2cos_limit_update_ets_config(struct bnx2x
*bp
)
423 struct bnx2x_dcbx_pg_params
*ets
= &(bp
->dcbx_port_params
.ets
);
426 if (ets
->num_of_cos
== 0 || ets
->num_of_cos
> DCBX_COS_MAX_NUM_E2
) {
427 BNX2X_ERR("Illegal number of COSes %d\n", ets
->num_of_cos
);
431 /* valid COS entries */
432 if (ets
->num_of_cos
== 1) /* no ETS */
436 if (((BNX2X_DCBX_STRICT_INVALID
== ets
->cos_params
[0].strict
) &&
437 (DCBX_INVALID_COS_BW
== ets
->cos_params
[0].bw_tbl
)) ||
438 ((BNX2X_DCBX_STRICT_INVALID
== ets
->cos_params
[1].strict
) &&
439 (DCBX_INVALID_COS_BW
== ets
->cos_params
[1].bw_tbl
))) {
440 BNX2X_ERR("all COS should have at least bw_limit or strict"
441 "ets->cos_params[0].strict= %x"
442 "ets->cos_params[0].bw_tbl= %x"
443 "ets->cos_params[1].strict= %x"
444 "ets->cos_params[1].bw_tbl= %x",
445 ets
->cos_params
[0].strict
,
446 ets
->cos_params
[0].bw_tbl
,
447 ets
->cos_params
[1].strict
,
448 ets
->cos_params
[1].bw_tbl
);
451 /* If we join a group and there is bw_tbl and strict then bw rules */
452 if ((DCBX_INVALID_COS_BW
!= ets
->cos_params
[0].bw_tbl
) &&
453 (DCBX_INVALID_COS_BW
!= ets
->cos_params
[1].bw_tbl
)) {
454 u32 bw_tbl_0
= ets
->cos_params
[0].bw_tbl
;
455 u32 bw_tbl_1
= ets
->cos_params
[1].bw_tbl
;
456 /* Do not allow 0-100 configuration
457 * since PBF does not support it
463 } else if (bw_tbl_1
== 0) {
468 bnx2x_ets_bw_limit(&bp
->link_params
, bw_tbl_0
, bw_tbl_1
);
470 if (ets
->cos_params
[0].strict
== BNX2X_DCBX_STRICT_COS_HIGHEST
)
471 rc
= bnx2x_ets_strict(&bp
->link_params
, 0);
472 else if (ets
->cos_params
[1].strict
473 == BNX2X_DCBX_STRICT_COS_HIGHEST
)
474 rc
= bnx2x_ets_strict(&bp
->link_params
, 1);
476 BNX2X_ERR("update_ets_params failed\n");
481 * In E3B0 the configuration may have more than 2 COS.
483 void bnx2x_dcbx_update_ets_config(struct bnx2x
*bp
)
485 struct bnx2x_dcbx_pg_params
*ets
= &(bp
->dcbx_port_params
.ets
);
486 struct bnx2x_ets_params ets_params
= { 0 };
489 ets_params
.num_of_cos
= ets
->num_of_cos
;
491 for (i
= 0; i
< ets
->num_of_cos
; i
++) {
493 if (ets
->cos_params
[i
].strict
!= BNX2X_DCBX_STRICT_INVALID
) {
494 if (ets
->cos_params
[i
].bw_tbl
!= DCBX_INVALID_COS_BW
) {
495 BNX2X_ERR("COS can't be not BW and not SP\n");
499 ets_params
.cos
[i
].state
= bnx2x_cos_state_strict
;
500 ets_params
.cos
[i
].params
.sp_params
.pri
=
501 ets
->cos_params
[i
].strict
;
502 } else { /* COS is BW */
503 if (ets
->cos_params
[i
].bw_tbl
== DCBX_INVALID_COS_BW
) {
504 BNX2X_ERR("COS can't be not BW and not SP\n");
507 ets_params
.cos
[i
].state
= bnx2x_cos_state_bw
;
508 ets_params
.cos
[i
].params
.bw_params
.bw
=
509 (u8
)ets
->cos_params
[i
].bw_tbl
;
513 /* Configure the ETS in HW */
514 if (bnx2x_ets_e3b0_config(&bp
->link_params
, &bp
->link_vars
,
516 BNX2X_ERR("bnx2x_ets_e3b0_config failed\n");
517 bnx2x_ets_disabled(&bp
->link_params
, &bp
->link_vars
);
521 static void bnx2x_dcbx_update_ets_params(struct bnx2x
*bp
)
523 bnx2x_ets_disabled(&bp
->link_params
, &bp
->link_vars
);
525 if (!bp
->dcbx_port_params
.ets
.enabled
)
528 if (CHIP_IS_E3B0(bp
))
529 bnx2x_dcbx_update_ets_config(bp
);
531 bnx2x_dcbx_2cos_limit_update_ets_config(bp
);
535 static int bnx2x_dcbx_read_shmem_remote_mib(struct bnx2x
*bp
)
537 struct lldp_remote_mib remote_mib
= {0};
538 u32 dcbx_remote_mib_offset
= SHMEM2_RD(bp
, dcbx_remote_mib_offset
);
541 DP(NETIF_MSG_LINK
, "dcbx_remote_mib_offset 0x%x\n",
542 dcbx_remote_mib_offset
);
544 if (SHMEM_DCBX_REMOTE_MIB_NONE
== dcbx_remote_mib_offset
) {
545 BNX2X_ERR("FW doesn't support dcbx_remote_mib_offset\n");
549 rc
= bnx2x_dcbx_read_mib(bp
, (u32
*)&remote_mib
, dcbx_remote_mib_offset
,
550 DCBX_READ_REMOTE_MIB
);
553 BNX2X_ERR("Faild to read remote mib from FW\n");
557 /* save features and flags */
558 bp
->dcbx_remote_feat
= remote_mib
.features
;
559 bp
->dcbx_remote_flags
= remote_mib
.flags
;
564 static int bnx2x_dcbx_read_shmem_neg_results(struct bnx2x
*bp
)
566 struct lldp_local_mib local_mib
= {0};
567 u32 dcbx_neg_res_offset
= SHMEM2_RD(bp
, dcbx_neg_res_offset
);
570 DP(NETIF_MSG_LINK
, "dcbx_neg_res_offset 0x%x\n", dcbx_neg_res_offset
);
572 if (SHMEM_DCBX_NEG_RES_NONE
== dcbx_neg_res_offset
) {
573 BNX2X_ERR("FW doesn't support dcbx_neg_res_offset\n");
577 rc
= bnx2x_dcbx_read_mib(bp
, (u32
*)&local_mib
, dcbx_neg_res_offset
,
578 DCBX_READ_LOCAL_MIB
);
581 BNX2X_ERR("Faild to read local mib from FW\n");
585 /* save features and error */
586 bp
->dcbx_local_feat
= local_mib
.features
;
587 bp
->dcbx_error
= local_mib
.error
;
594 u8
bnx2x_dcbx_dcbnl_app_up(struct dcbx_app_priority_entry
*ent
)
598 /* Choose the highest priority */
599 for (pri
= MAX_PFC_PRIORITIES
- 1; pri
> 0; pri
--)
600 if (ent
->pri_bitmap
& (1 << pri
))
606 u8
bnx2x_dcbx_dcbnl_app_idtype(struct dcbx_app_priority_entry
*ent
)
608 return ((ent
->appBitfield
& DCBX_APP_ENTRY_SF_MASK
) ==
609 DCBX_APP_SF_PORT
) ? DCB_APP_IDTYPE_PORTNUM
:
610 DCB_APP_IDTYPE_ETHTYPE
;
613 int bnx2x_dcbnl_update_applist(struct bnx2x
*bp
, bool delall
)
617 for (i
= 0; i
< DCBX_MAX_APP_PROTOCOL
&& err
== 0; i
++) {
618 struct dcbx_app_priority_entry
*ent
=
619 &bp
->dcbx_local_feat
.app
.app_pri_tbl
[i
];
621 if (ent
->appBitfield
& DCBX_APP_ENTRY_VALID
) {
622 u8 up
= bnx2x_dcbx_dcbnl_app_up(ent
);
624 /* avoid invalid user-priority */
627 app
.selector
= bnx2x_dcbx_dcbnl_app_idtype(ent
);
628 app
.protocol
= ent
->app_id
;
629 app
.priority
= delall
? 0 : up
;
630 err
= dcb_setapp(bp
->dev
, &app
);
638 static inline void bnx2x_update_drv_flags(struct bnx2x
*bp
, u32 flags
, u32 set
)
640 if (SHMEM2_HAS(bp
, drv_flags
)) {
642 bnx2x_acquire_hw_lock(bp
, HW_LOCK_DRV_FLAGS
);
643 drv_flags
= SHMEM2_RD(bp
, drv_flags
);
646 SET_FLAGS(drv_flags
, flags
);
648 RESET_FLAGS(drv_flags
, flags
);
650 SHMEM2_WR(bp
, drv_flags
, drv_flags
);
651 DP(NETIF_MSG_HW
, "drv_flags 0x%08x\n", drv_flags
);
652 bnx2x_release_hw_lock(bp
, HW_LOCK_DRV_FLAGS
);
656 static inline void bnx2x_dcbx_update_tc_mapping(struct bnx2x
*bp
)
659 for (cos
= 0; cos
< bp
->dcbx_port_params
.ets
.num_of_cos
; cos
++) {
660 for (prio
= 0; prio
< BNX2X_MAX_PRIORITY
; prio
++) {
661 if (bp
->dcbx_port_params
.ets
.cos_params
[cos
].pri_bitmask
663 bp
->prio_to_cos
[prio
] = cos
;
668 /* setup tc must be called under rtnl lock, but we can't take it here
669 * as we are handling an attetntion on a work queue which must be
670 * flushed at some rtnl-locked contexts (e.g. if down)
672 if (!test_and_set_bit(BNX2X_SP_RTNL_SETUP_TC
, &bp
->sp_rtnl_state
))
673 schedule_delayed_work(&bp
->sp_rtnl_task
, 0);
676 void bnx2x_dcbx_set_params(struct bnx2x
*bp
, u32 state
)
679 case BNX2X_DCBX_STATE_NEG_RECEIVED
:
681 DP(NETIF_MSG_LINK
, "BNX2X_DCBX_STATE_NEG_RECEIVED\n");
684 * Delete app tlvs from dcbnl before reading new
685 * negotiation results
687 bnx2x_dcbnl_update_applist(bp
, true);
689 /* Read rmeote mib if dcbx is in the FW */
690 if (bnx2x_dcbx_read_shmem_remote_mib(bp
))
693 /* Read neg results if dcbx is in the FW */
694 if (bnx2x_dcbx_read_shmem_neg_results(bp
))
697 bnx2x_dump_dcbx_drv_param(bp
, &bp
->dcbx_local_feat
,
700 bnx2x_get_dcbx_drv_param(bp
, &bp
->dcbx_local_feat
,
703 /* mark DCBX result for PMF migration */
704 bnx2x_update_drv_flags(bp
, DRV_FLAGS_DCB_CONFIGURED
, 1);
707 * Add new app tlvs to dcbnl
709 bnx2x_dcbnl_update_applist(bp
, false);
711 bnx2x_dcbx_stop_hw_tx(bp
);
713 /* reconfigure the netdevice with the results of the new
716 bnx2x_dcbx_update_tc_mapping(bp
);
720 case BNX2X_DCBX_STATE_TX_PAUSED
:
721 DP(NETIF_MSG_LINK
, "BNX2X_DCBX_STATE_TX_PAUSED\n");
722 bnx2x_pfc_set_pfc(bp
);
724 bnx2x_dcbx_update_ets_params(bp
);
725 bnx2x_dcbx_resume_hw_tx(bp
);
727 case BNX2X_DCBX_STATE_TX_RELEASED
:
728 DP(NETIF_MSG_LINK
, "BNX2X_DCBX_STATE_TX_RELEASED\n");
729 bnx2x_fw_command(bp
, DRV_MSG_CODE_DCBX_PMF_DRV_OK
, 0);
732 * Send a notification for the new negotiated parameters
734 dcbnl_cee_notify(bp
->dev
, RTM_GETDCB
, DCB_CMD_CEE_GET
, 0, 0);
738 BNX2X_ERR("Unknown DCBX_STATE\n");
743 #define LLDP_STATS_OFFSET(bp) (BP_PORT(bp)*\
744 sizeof(struct lldp_dcbx_stat))
746 /* calculate struct offset in array according to chip information */
747 #define LLDP_PARAMS_OFFSET(bp) (BP_PORT(bp)*sizeof(struct lldp_params))
749 #define LLDP_ADMIN_MIB_OFFSET(bp) (PORT_MAX*sizeof(struct lldp_params) + \
750 BP_PORT(bp)*sizeof(struct lldp_admin_mib))
752 static void bnx2x_dcbx_lldp_updated_params(struct bnx2x
*bp
,
753 u32 dcbx_lldp_params_offset
)
755 struct lldp_params lldp_params
= {0};
756 u32 i
= 0, *buff
= NULL
;
757 u32 offset
= dcbx_lldp_params_offset
+ LLDP_PARAMS_OFFSET(bp
);
759 DP(NETIF_MSG_LINK
, "lldp_offset 0x%x\n", offset
);
761 if ((bp
->lldp_config_params
.overwrite_settings
==
762 BNX2X_DCBX_OVERWRITE_SETTINGS_ENABLE
)) {
763 /* Read the data first */
764 buff
= (u32
*)&lldp_params
;
765 for (i
= 0; i
< sizeof(struct lldp_params
); i
+= 4, buff
++)
766 *buff
= REG_RD(bp
, (offset
+ i
));
768 lldp_params
.msg_tx_hold
=
769 (u8
)bp
->lldp_config_params
.msg_tx_hold
;
770 lldp_params
.msg_fast_tx_interval
=
771 (u8
)bp
->lldp_config_params
.msg_fast_tx
;
772 lldp_params
.tx_crd_max
=
773 (u8
)bp
->lldp_config_params
.tx_credit_max
;
774 lldp_params
.msg_tx_interval
=
775 (u8
)bp
->lldp_config_params
.msg_tx_interval
;
776 lldp_params
.tx_fast
=
777 (u8
)bp
->lldp_config_params
.tx_fast
;
780 buff
= (u32
*)&lldp_params
;
781 for (i
= 0; i
< sizeof(struct lldp_params
); i
+= 4, buff
++)
782 REG_WR(bp
, (offset
+ i
) , *buff
);
785 } else if (BNX2X_DCBX_OVERWRITE_SETTINGS_ENABLE
==
786 bp
->lldp_config_params
.overwrite_settings
)
787 bp
->lldp_config_params
.overwrite_settings
=
788 BNX2X_DCBX_OVERWRITE_SETTINGS_INVALID
;
791 static void bnx2x_dcbx_admin_mib_updated_params(struct bnx2x
*bp
,
792 u32 dcbx_lldp_params_offset
)
794 struct lldp_admin_mib admin_mib
;
795 u32 i
, other_traf_type
= PREDEFINED_APP_IDX_MAX
, traf_type
= 0;
797 u32 offset
= dcbx_lldp_params_offset
+ LLDP_ADMIN_MIB_OFFSET(bp
);
800 struct dcbx_features
*af
= &admin_mib
.features
;
801 struct bnx2x_config_dcbx_params
*dp
= &bp
->dcbx_config_params
;
803 memset(&admin_mib
, 0, sizeof(struct lldp_admin_mib
));
804 buff
= (u32
*)&admin_mib
;
805 /* Read the data first */
806 for (i
= 0; i
< sizeof(struct lldp_admin_mib
); i
+= 4, buff
++)
807 *buff
= REG_RD(bp
, (offset
+ i
));
809 if (bp
->dcbx_enabled
== BNX2X_DCBX_ENABLED_ON_NEG_ON
)
810 SET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_DCBX_ENABLED
);
812 RESET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_DCBX_ENABLED
);
814 if ((BNX2X_DCBX_OVERWRITE_SETTINGS_ENABLE
==
815 dp
->overwrite_settings
)) {
816 RESET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_CEE_VERSION_MASK
);
817 admin_mib
.ver_cfg_flags
|=
818 (dp
->admin_dcbx_version
<< DCBX_CEE_VERSION_SHIFT
) &
819 DCBX_CEE_VERSION_MASK
;
821 af
->ets
.enabled
= (u8
)dp
->admin_ets_enable
;
823 af
->pfc
.enabled
= (u8
)dp
->admin_pfc_enable
;
825 /* FOR IEEE dp->admin_tc_supported_tx_enable */
826 if (dp
->admin_ets_configuration_tx_enable
)
827 SET_FLAGS(admin_mib
.ver_cfg_flags
,
828 DCBX_ETS_CONFIG_TX_ENABLED
);
830 RESET_FLAGS(admin_mib
.ver_cfg_flags
,
831 DCBX_ETS_CONFIG_TX_ENABLED
);
832 /* For IEEE admin_ets_recommendation_tx_enable */
833 if (dp
->admin_pfc_tx_enable
)
834 SET_FLAGS(admin_mib
.ver_cfg_flags
,
835 DCBX_PFC_CONFIG_TX_ENABLED
);
837 RESET_FLAGS(admin_mib
.ver_cfg_flags
,
838 DCBX_PFC_CONFIG_TX_ENABLED
);
840 if (dp
->admin_application_priority_tx_enable
)
841 SET_FLAGS(admin_mib
.ver_cfg_flags
,
842 DCBX_APP_CONFIG_TX_ENABLED
);
844 RESET_FLAGS(admin_mib
.ver_cfg_flags
,
845 DCBX_APP_CONFIG_TX_ENABLED
);
847 if (dp
->admin_ets_willing
)
848 SET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_ETS_WILLING
);
850 RESET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_ETS_WILLING
);
851 /* For IEEE admin_ets_reco_valid */
852 if (dp
->admin_pfc_willing
)
853 SET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_PFC_WILLING
);
855 RESET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_PFC_WILLING
);
857 if (dp
->admin_app_priority_willing
)
858 SET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_APP_WILLING
);
860 RESET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_APP_WILLING
);
862 for (i
= 0 ; i
< DCBX_MAX_NUM_PG_BW_ENTRIES
; i
++) {
863 DCBX_PG_BW_SET(af
->ets
.pg_bw_tbl
, i
,
864 (u8
)dp
->admin_configuration_bw_precentage
[i
]);
866 DP(NETIF_MSG_LINK
, "pg_bw_tbl[%d] = %02x\n",
867 i
, DCBX_PG_BW_GET(af
->ets
.pg_bw_tbl
, i
));
870 for (i
= 0; i
< DCBX_MAX_NUM_PRI_PG_ENTRIES
; i
++) {
871 DCBX_PRI_PG_SET(af
->ets
.pri_pg_tbl
, i
,
872 (u8
)dp
->admin_configuration_ets_pg
[i
]);
874 DP(NETIF_MSG_LINK
, "pri_pg_tbl[%d] = %02x\n",
875 i
, DCBX_PRI_PG_GET(af
->ets
.pri_pg_tbl
, i
));
878 /*For IEEE admin_recommendation_bw_precentage
879 *For IEEE admin_recommendation_ets_pg */
880 af
->pfc
.pri_en_bitmap
= (u8
)dp
->admin_pfc_bitmap
;
881 for (i
= 0; i
< 4; i
++) {
882 if (dp
->admin_priority_app_table
[i
].valid
) {
883 struct bnx2x_admin_priority_app_table
*table
=
884 dp
->admin_priority_app_table
;
885 if ((ETH_TYPE_FCOE
== table
[i
].app_id
) &&
886 (TRAFFIC_TYPE_ETH
== table
[i
].traffic_type
))
887 traf_type
= FCOE_APP_IDX
;
888 else if ((TCP_PORT_ISCSI
== table
[i
].app_id
) &&
889 (TRAFFIC_TYPE_PORT
== table
[i
].traffic_type
))
890 traf_type
= ISCSI_APP_IDX
;
892 traf_type
= other_traf_type
++;
894 af
->app
.app_pri_tbl
[traf_type
].app_id
=
897 af
->app
.app_pri_tbl
[traf_type
].pri_bitmap
=
898 (u8
)(1 << table
[i
].priority
);
900 af
->app
.app_pri_tbl
[traf_type
].appBitfield
=
901 (DCBX_APP_ENTRY_VALID
);
903 af
->app
.app_pri_tbl
[traf_type
].appBitfield
|=
904 (TRAFFIC_TYPE_ETH
== table
[i
].traffic_type
) ?
905 DCBX_APP_SF_ETH_TYPE
: DCBX_APP_SF_PORT
;
909 af
->app
.default_pri
= (u8
)dp
->admin_default_priority
;
911 } else if (BNX2X_DCBX_OVERWRITE_SETTINGS_ENABLE
==
912 dp
->overwrite_settings
)
913 dp
->overwrite_settings
= BNX2X_DCBX_OVERWRITE_SETTINGS_INVALID
;
915 /* Write the data. */
916 buff
= (u32
*)&admin_mib
;
917 for (i
= 0; i
< sizeof(struct lldp_admin_mib
); i
+= 4, buff
++)
918 REG_WR(bp
, (offset
+ i
), *buff
);
921 void bnx2x_dcbx_set_state(struct bnx2x
*bp
, bool dcb_on
, u32 dcbx_enabled
)
923 if (!CHIP_IS_E1x(bp
) && !CHIP_MODE_IS_4_PORT(bp
)) {
924 bp
->dcb_state
= dcb_on
;
925 bp
->dcbx_enabled
= dcbx_enabled
;
927 bp
->dcb_state
= false;
928 bp
->dcbx_enabled
= BNX2X_DCBX_ENABLED_INVALID
;
930 DP(NETIF_MSG_LINK
, "DCB state [%s:%s]\n",
931 dcb_on
? "ON" : "OFF",
932 dcbx_enabled
== BNX2X_DCBX_ENABLED_OFF
? "user-mode" :
933 dcbx_enabled
== BNX2X_DCBX_ENABLED_ON_NEG_OFF
? "on-chip static" :
934 dcbx_enabled
== BNX2X_DCBX_ENABLED_ON_NEG_ON
?
935 "on-chip with negotiation" : "invalid");
938 void bnx2x_dcbx_init_params(struct bnx2x
*bp
)
940 bp
->dcbx_config_params
.admin_dcbx_version
= 0x0; /* 0 - CEE; 1 - IEEE */
941 bp
->dcbx_config_params
.admin_ets_willing
= 1;
942 bp
->dcbx_config_params
.admin_pfc_willing
= 1;
943 bp
->dcbx_config_params
.overwrite_settings
= 1;
944 bp
->dcbx_config_params
.admin_ets_enable
= 1;
945 bp
->dcbx_config_params
.admin_pfc_enable
= 1;
946 bp
->dcbx_config_params
.admin_tc_supported_tx_enable
= 1;
947 bp
->dcbx_config_params
.admin_ets_configuration_tx_enable
= 1;
948 bp
->dcbx_config_params
.admin_pfc_tx_enable
= 1;
949 bp
->dcbx_config_params
.admin_application_priority_tx_enable
= 1;
950 bp
->dcbx_config_params
.admin_ets_reco_valid
= 1;
951 bp
->dcbx_config_params
.admin_app_priority_willing
= 1;
952 bp
->dcbx_config_params
.admin_configuration_bw_precentage
[0] = 00;
953 bp
->dcbx_config_params
.admin_configuration_bw_precentage
[1] = 50;
954 bp
->dcbx_config_params
.admin_configuration_bw_precentage
[2] = 50;
955 bp
->dcbx_config_params
.admin_configuration_bw_precentage
[3] = 0;
956 bp
->dcbx_config_params
.admin_configuration_bw_precentage
[4] = 0;
957 bp
->dcbx_config_params
.admin_configuration_bw_precentage
[5] = 0;
958 bp
->dcbx_config_params
.admin_configuration_bw_precentage
[6] = 0;
959 bp
->dcbx_config_params
.admin_configuration_bw_precentage
[7] = 0;
960 bp
->dcbx_config_params
.admin_configuration_ets_pg
[0] = 1;
961 bp
->dcbx_config_params
.admin_configuration_ets_pg
[1] = 0;
962 bp
->dcbx_config_params
.admin_configuration_ets_pg
[2] = 0;
963 bp
->dcbx_config_params
.admin_configuration_ets_pg
[3] = 2;
964 bp
->dcbx_config_params
.admin_configuration_ets_pg
[4] = 0;
965 bp
->dcbx_config_params
.admin_configuration_ets_pg
[5] = 0;
966 bp
->dcbx_config_params
.admin_configuration_ets_pg
[6] = 0;
967 bp
->dcbx_config_params
.admin_configuration_ets_pg
[7] = 0;
968 bp
->dcbx_config_params
.admin_recommendation_bw_precentage
[0] = 0;
969 bp
->dcbx_config_params
.admin_recommendation_bw_precentage
[1] = 1;
970 bp
->dcbx_config_params
.admin_recommendation_bw_precentage
[2] = 2;
971 bp
->dcbx_config_params
.admin_recommendation_bw_precentage
[3] = 0;
972 bp
->dcbx_config_params
.admin_recommendation_bw_precentage
[4] = 7;
973 bp
->dcbx_config_params
.admin_recommendation_bw_precentage
[5] = 5;
974 bp
->dcbx_config_params
.admin_recommendation_bw_precentage
[6] = 6;
975 bp
->dcbx_config_params
.admin_recommendation_bw_precentage
[7] = 7;
976 bp
->dcbx_config_params
.admin_recommendation_ets_pg
[0] = 0;
977 bp
->dcbx_config_params
.admin_recommendation_ets_pg
[1] = 1;
978 bp
->dcbx_config_params
.admin_recommendation_ets_pg
[2] = 2;
979 bp
->dcbx_config_params
.admin_recommendation_ets_pg
[3] = 3;
980 bp
->dcbx_config_params
.admin_recommendation_ets_pg
[4] = 4;
981 bp
->dcbx_config_params
.admin_recommendation_ets_pg
[5] = 5;
982 bp
->dcbx_config_params
.admin_recommendation_ets_pg
[6] = 6;
983 bp
->dcbx_config_params
.admin_recommendation_ets_pg
[7] = 7;
984 bp
->dcbx_config_params
.admin_pfc_bitmap
= 0x8; /* FCoE(3) enable */
985 bp
->dcbx_config_params
.admin_priority_app_table
[0].valid
= 1;
986 bp
->dcbx_config_params
.admin_priority_app_table
[1].valid
= 1;
987 bp
->dcbx_config_params
.admin_priority_app_table
[2].valid
= 0;
988 bp
->dcbx_config_params
.admin_priority_app_table
[3].valid
= 0;
989 bp
->dcbx_config_params
.admin_priority_app_table
[0].priority
= 3;
990 bp
->dcbx_config_params
.admin_priority_app_table
[1].priority
= 0;
991 bp
->dcbx_config_params
.admin_priority_app_table
[2].priority
= 0;
992 bp
->dcbx_config_params
.admin_priority_app_table
[3].priority
= 0;
993 bp
->dcbx_config_params
.admin_priority_app_table
[0].traffic_type
= 0;
994 bp
->dcbx_config_params
.admin_priority_app_table
[1].traffic_type
= 1;
995 bp
->dcbx_config_params
.admin_priority_app_table
[2].traffic_type
= 0;
996 bp
->dcbx_config_params
.admin_priority_app_table
[3].traffic_type
= 0;
997 bp
->dcbx_config_params
.admin_priority_app_table
[0].app_id
= 0x8906;
998 bp
->dcbx_config_params
.admin_priority_app_table
[1].app_id
= 3260;
999 bp
->dcbx_config_params
.admin_priority_app_table
[2].app_id
= 0;
1000 bp
->dcbx_config_params
.admin_priority_app_table
[3].app_id
= 0;
1001 bp
->dcbx_config_params
.admin_default_priority
=
1002 bp
->dcbx_config_params
.admin_priority_app_table
[1].priority
;
1005 void bnx2x_dcbx_init(struct bnx2x
*bp
)
1007 u32 dcbx_lldp_params_offset
= SHMEM_LLDP_DCBX_PARAMS_NONE
;
1009 if (bp
->dcbx_enabled
<= 0)
1013 * chip of good for dcbx version,
1015 * the function is pmf
1016 * shmem2 contains DCBX support fields
1018 DP(NETIF_MSG_LINK
, "dcb_state %d bp->port.pmf %d\n",
1019 bp
->dcb_state
, bp
->port
.pmf
);
1021 if (bp
->dcb_state
== BNX2X_DCB_STATE_ON
&& bp
->port
.pmf
&&
1022 SHMEM2_HAS(bp
, dcbx_lldp_params_offset
)) {
1023 dcbx_lldp_params_offset
=
1024 SHMEM2_RD(bp
, dcbx_lldp_params_offset
);
1026 DP(NETIF_MSG_LINK
, "dcbx_lldp_params_offset 0x%x\n",
1027 dcbx_lldp_params_offset
);
1029 bnx2x_update_drv_flags(bp
, DRV_FLAGS_DCB_CONFIGURED
, 0);
1031 if (SHMEM_LLDP_DCBX_PARAMS_NONE
!= dcbx_lldp_params_offset
) {
1032 bnx2x_dcbx_lldp_updated_params(bp
,
1033 dcbx_lldp_params_offset
);
1035 bnx2x_dcbx_admin_mib_updated_params(bp
,
1036 dcbx_lldp_params_offset
);
1038 /* Let HW start negotiation */
1039 bnx2x_fw_command(bp
,
1040 DRV_MSG_CODE_DCBX_ADMIN_PMF_MSG
, 0);
1045 bnx2x_dcbx_print_cos_params(struct bnx2x
*bp
,
1046 struct flow_control_configuration
*pfc_fw_cfg
)
1052 "pfc_fw_cfg->dcb_version %x\n", pfc_fw_cfg
->dcb_version
);
1054 "pdev->params.dcbx_port_params.pfc."
1055 "priority_non_pauseable_mask %x\n",
1056 bp
->dcbx_port_params
.pfc
.priority_non_pauseable_mask
);
1058 for (cos
= 0 ; cos
< bp
->dcbx_port_params
.ets
.num_of_cos
; cos
++) {
1059 DP(NETIF_MSG_LINK
, "pdev->params.dcbx_port_params.ets."
1060 "cos_params[%d].pri_bitmask %x\n", cos
,
1061 bp
->dcbx_port_params
.ets
.cos_params
[cos
].pri_bitmask
);
1063 DP(NETIF_MSG_LINK
, "pdev->params.dcbx_port_params.ets."
1064 "cos_params[%d].bw_tbl %x\n", cos
,
1065 bp
->dcbx_port_params
.ets
.cos_params
[cos
].bw_tbl
);
1067 DP(NETIF_MSG_LINK
, "pdev->params.dcbx_port_params.ets."
1068 "cos_params[%d].strict %x\n", cos
,
1069 bp
->dcbx_port_params
.ets
.cos_params
[cos
].strict
);
1071 DP(NETIF_MSG_LINK
, "pdev->params.dcbx_port_params.ets."
1072 "cos_params[%d].pauseable %x\n", cos
,
1073 bp
->dcbx_port_params
.ets
.cos_params
[cos
].pauseable
);
1076 for (pri
= 0; pri
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
; pri
++) {
1078 "pfc_fw_cfg->traffic_type_to_priority_cos[%d]."
1079 "priority %x\n", pri
,
1080 pfc_fw_cfg
->traffic_type_to_priority_cos
[pri
].priority
);
1083 "pfc_fw_cfg->traffic_type_to_priority_cos[%d].cos %x\n",
1084 pri
, pfc_fw_cfg
->traffic_type_to_priority_cos
[pri
].cos
);
1088 /* fills help_data according to pg_info */
1089 static void bnx2x_dcbx_get_num_pg_traf_type(struct bnx2x
*bp
,
1090 u32
*pg_pri_orginal_spread
,
1091 struct pg_help_data
*help_data
)
1093 bool pg_found
= false;
1094 u32 i
, traf_type
, add_traf_type
, add_pg
;
1095 u32
*ttp
= bp
->dcbx_port_params
.app
.traffic_type_priority
;
1096 struct pg_entry_help_data
*data
= help_data
->data
; /*shotcut*/
1098 /* Set to invalid */
1099 for (i
= 0; i
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
; i
++)
1100 data
[i
].pg
= DCBX_ILLEGAL_PG
;
1102 for (add_traf_type
= 0;
1103 add_traf_type
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
; add_traf_type
++) {
1105 if (ttp
[add_traf_type
] < MAX_PFC_PRIORITIES
) {
1106 add_pg
= (u8
)pg_pri_orginal_spread
[ttp
[add_traf_type
]];
1108 traf_type
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
;
1110 if (data
[traf_type
].pg
== add_pg
) {
1111 if (!(data
[traf_type
].pg_priority
&
1112 (1 << ttp
[add_traf_type
])))
1115 data
[traf_type
].pg_priority
|=
1116 (1 << ttp
[add_traf_type
]);
1121 if (false == pg_found
) {
1122 data
[help_data
->num_of_pg
].pg
= add_pg
;
1123 data
[help_data
->num_of_pg
].pg_priority
=
1124 (1 << ttp
[add_traf_type
]);
1125 data
[help_data
->num_of_pg
].num_of_dif_pri
= 1;
1126 help_data
->num_of_pg
++;
1130 "add_traf_type %d pg_found %s num_of_pg %d\n",
1131 add_traf_type
, (false == pg_found
) ? "NO" : "YES",
1132 help_data
->num_of_pg
);
1136 static void bnx2x_dcbx_ets_disabled_entry_data(struct bnx2x
*bp
,
1137 struct cos_help_data
*cos_data
,
1140 /* Only one priority than only one COS */
1141 cos_data
->data
[0].pausable
=
1142 IS_DCBX_PFC_PRI_ONLY_PAUSE(bp
, pri_join_mask
);
1143 cos_data
->data
[0].pri_join_mask
= pri_join_mask
;
1144 cos_data
->data
[0].cos_bw
= 100;
1145 cos_data
->num_of_cos
= 1;
1148 static inline void bnx2x_dcbx_add_to_cos_bw(struct bnx2x
*bp
,
1149 struct cos_entry_help_data
*data
,
1152 if (data
->cos_bw
== DCBX_INVALID_COS_BW
)
1153 data
->cos_bw
= pg_bw
;
1155 data
->cos_bw
+= pg_bw
;
1158 static void bnx2x_dcbx_separate_pauseable_from_non(struct bnx2x
*bp
,
1159 struct cos_help_data
*cos_data
,
1160 u32
*pg_pri_orginal_spread
,
1161 struct dcbx_ets_feature
*ets
)
1167 u8 num_of_pri
= LLFC_DRIVER_TRAFFIC_TYPE_MAX
;
1169 cos_data
->data
[0].pausable
= true;
1170 cos_data
->data
[1].pausable
= false;
1171 cos_data
->data
[0].pri_join_mask
= cos_data
->data
[1].pri_join_mask
= 0;
1173 for (i
= 0 ; i
< num_of_pri
; i
++) {
1174 pri_tested
= 1 << bp
->dcbx_port_params
.
1175 app
.traffic_type_priority
[i
];
1177 if (pri_tested
& DCBX_PFC_PRI_NON_PAUSE_MASK(bp
)) {
1178 cos_data
->data
[1].pri_join_mask
|= pri_tested
;
1181 cos_data
->data
[0].pri_join_mask
|= pri_tested
;
1184 pg_entry
= (u8
)pg_pri_orginal_spread
[bp
->dcbx_port_params
.
1185 app
.traffic_type_priority
[i
]];
1186 /* There can be only one strict pg */
1187 if (pg_entry
< DCBX_MAX_NUM_PG_BW_ENTRIES
)
1188 bnx2x_dcbx_add_to_cos_bw(bp
, &cos_data
->data
[entry
],
1189 DCBX_PG_BW_GET(ets
->pg_bw_tbl
, pg_entry
));
1191 /* If we join a group and one is strict
1192 * than the bw rulls */
1193 cos_data
->data
[entry
].strict
=
1194 BNX2X_DCBX_STRICT_COS_HIGHEST
;
1196 if ((0 == cos_data
->data
[0].pri_join_mask
) &&
1197 (0 == cos_data
->data
[1].pri_join_mask
))
1198 BNX2X_ERR("dcbx error: Both groups must have priorities\n");
1203 #define POWER_OF_2(x) ((0 != x) && (0 == (x & (x-1))))
1206 static void bnx2x_dcbx_2cos_limit_cee_single_pg_to_cos_params(struct bnx2x
*bp
,
1207 struct pg_help_data
*pg_help_data
,
1208 struct cos_help_data
*cos_data
,
1214 u32 pri_mask_without_pri
= 0;
1215 u32
*ttp
= bp
->dcbx_port_params
.app
.traffic_type_priority
;
1217 if (num_of_dif_pri
== 1) {
1218 bnx2x_dcbx_ets_disabled_entry_data(bp
, cos_data
, pri_join_mask
);
1221 /* single priority group */
1222 if (pg_help_data
->data
[0].pg
< DCBX_MAX_NUM_PG_BW_ENTRIES
) {
1223 /* If there are both pauseable and non-pauseable priorities,
1224 * the pauseable priorities go to the first queue and
1225 * the non-pauseable priorities go to the second queue.
1227 if (IS_DCBX_PFC_PRI_MIX_PAUSE(bp
, pri_join_mask
)) {
1229 cos_data
->data
[0].pausable
= true;
1231 cos_data
->data
[1].pausable
= false;
1233 if (2 == num_of_dif_pri
) {
1234 cos_data
->data
[0].cos_bw
= 50;
1235 cos_data
->data
[1].cos_bw
= 50;
1238 if (3 == num_of_dif_pri
) {
1239 if (POWER_OF_2(DCBX_PFC_PRI_GET_PAUSE(bp
,
1241 cos_data
->data
[0].cos_bw
= 33;
1242 cos_data
->data
[1].cos_bw
= 67;
1244 cos_data
->data
[0].cos_bw
= 67;
1245 cos_data
->data
[1].cos_bw
= 33;
1249 } else if (IS_DCBX_PFC_PRI_ONLY_PAUSE(bp
, pri_join_mask
)) {
1250 /* If there are only pauseable priorities,
1251 * then one/two priorities go to the first queue
1252 * and one priority goes to the second queue.
1254 if (2 == num_of_dif_pri
) {
1255 cos_data
->data
[0].cos_bw
= 50;
1256 cos_data
->data
[1].cos_bw
= 50;
1258 cos_data
->data
[0].cos_bw
= 67;
1259 cos_data
->data
[1].cos_bw
= 33;
1261 cos_data
->data
[1].pausable
= true;
1262 cos_data
->data
[0].pausable
= true;
1263 /* All priorities except FCOE */
1264 cos_data
->data
[0].pri_join_mask
= (pri_join_mask
&
1265 ((u8
)~(1 << ttp
[LLFC_TRAFFIC_TYPE_FCOE
])));
1266 /* Only FCOE priority.*/
1267 cos_data
->data
[1].pri_join_mask
=
1268 (1 << ttp
[LLFC_TRAFFIC_TYPE_FCOE
]);
1270 /* If there are only non-pauseable priorities,
1271 * they will all go to the same queue.
1273 bnx2x_dcbx_ets_disabled_entry_data(bp
,
1274 cos_data
, pri_join_mask
);
1276 /* priority group which is not BW limited (PG#15):*/
1277 if (IS_DCBX_PFC_PRI_MIX_PAUSE(bp
, pri_join_mask
)) {
1278 /* If there are both pauseable and non-pauseable
1279 * priorities, the pauseable priorities go to the first
1280 * queue and the non-pauseable priorities
1281 * go to the second queue.
1283 if (DCBX_PFC_PRI_GET_PAUSE(bp
, pri_join_mask
) >
1284 DCBX_PFC_PRI_GET_NON_PAUSE(bp
, pri_join_mask
)) {
1285 cos_data
->data
[0].strict
=
1286 BNX2X_DCBX_STRICT_COS_HIGHEST
;
1287 cos_data
->data
[1].strict
=
1288 BNX2X_DCBX_STRICT_COS_NEXT_LOWER_PRI(
1289 BNX2X_DCBX_STRICT_COS_HIGHEST
);
1291 cos_data
->data
[0].strict
=
1292 BNX2X_DCBX_STRICT_COS_NEXT_LOWER_PRI(
1293 BNX2X_DCBX_STRICT_COS_HIGHEST
);
1294 cos_data
->data
[1].strict
=
1295 BNX2X_DCBX_STRICT_COS_HIGHEST
;
1298 cos_data
->data
[0].pausable
= true;
1299 /* Non pause-able.*/
1300 cos_data
->data
[1].pausable
= false;
1302 /* If there are only pauseable priorities or
1303 * only non-pauseable,* the lower priorities go
1304 * to the first queue and the higherpriorities go
1305 * to the second queue.
1307 cos_data
->data
[0].pausable
=
1308 cos_data
->data
[1].pausable
=
1309 IS_DCBX_PFC_PRI_ONLY_PAUSE(bp
, pri_join_mask
);
1311 for (i
= 0 ; i
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
; i
++) {
1312 pri_tested
= 1 << bp
->dcbx_port_params
.
1313 app
.traffic_type_priority
[i
];
1314 /* Remove priority tested */
1315 pri_mask_without_pri
=
1316 (pri_join_mask
& ((u8
)(~pri_tested
)));
1317 if (pri_mask_without_pri
< pri_tested
)
1321 if (i
== LLFC_DRIVER_TRAFFIC_TYPE_MAX
)
1322 BNX2X_ERR("Invalid value for pri_join_mask -"
1323 " could not find a priority\n");
1325 cos_data
->data
[0].pri_join_mask
= pri_mask_without_pri
;
1326 cos_data
->data
[1].pri_join_mask
= pri_tested
;
1327 /* Both queues are strict priority,
1328 * and that with the highest priority
1329 * gets the highest strict priority in the arbiter.
1331 cos_data
->data
[0].strict
=
1332 BNX2X_DCBX_STRICT_COS_NEXT_LOWER_PRI(
1333 BNX2X_DCBX_STRICT_COS_HIGHEST
);
1334 cos_data
->data
[1].strict
=
1335 BNX2X_DCBX_STRICT_COS_HIGHEST
;
1340 static void bnx2x_dcbx_2cos_limit_cee_two_pg_to_cos_params(
1342 struct pg_help_data
*pg_help_data
,
1343 struct dcbx_ets_feature
*ets
,
1344 struct cos_help_data
*cos_data
,
1345 u32
*pg_pri_orginal_spread
,
1350 u8 pg
[DCBX_COS_MAX_NUM_E2
] = { 0 };
1352 /* If there are both pauseable and non-pauseable priorities,
1353 * the pauseable priorities go to the first queue and
1354 * the non-pauseable priorities go to the second queue.
1356 if (IS_DCBX_PFC_PRI_MIX_PAUSE(bp
, pri_join_mask
)) {
1357 if (IS_DCBX_PFC_PRI_MIX_PAUSE(bp
,
1358 pg_help_data
->data
[0].pg_priority
) ||
1359 IS_DCBX_PFC_PRI_MIX_PAUSE(bp
,
1360 pg_help_data
->data
[1].pg_priority
)) {
1361 /* If one PG contains both pauseable and
1362 * non-pauseable priorities then ETS is disabled.
1364 bnx2x_dcbx_separate_pauseable_from_non(bp
, cos_data
,
1365 pg_pri_orginal_spread
, ets
);
1366 bp
->dcbx_port_params
.ets
.enabled
= false;
1371 cos_data
->data
[0].pausable
= true;
1372 /* Non pauseable. */
1373 cos_data
->data
[1].pausable
= false;
1374 if (IS_DCBX_PFC_PRI_ONLY_PAUSE(bp
,
1375 pg_help_data
->data
[0].pg_priority
)) {
1376 /* 0 is pauseable */
1377 cos_data
->data
[0].pri_join_mask
=
1378 pg_help_data
->data
[0].pg_priority
;
1379 pg
[0] = pg_help_data
->data
[0].pg
;
1380 cos_data
->data
[1].pri_join_mask
=
1381 pg_help_data
->data
[1].pg_priority
;
1382 pg
[1] = pg_help_data
->data
[1].pg
;
1383 } else {/* 1 is pauseable */
1384 cos_data
->data
[0].pri_join_mask
=
1385 pg_help_data
->data
[1].pg_priority
;
1386 pg
[0] = pg_help_data
->data
[1].pg
;
1387 cos_data
->data
[1].pri_join_mask
=
1388 pg_help_data
->data
[0].pg_priority
;
1389 pg
[1] = pg_help_data
->data
[0].pg
;
1392 /* If there are only pauseable priorities or
1393 * only non-pauseable, each PG goes to a queue.
1395 cos_data
->data
[0].pausable
= cos_data
->data
[1].pausable
=
1396 IS_DCBX_PFC_PRI_ONLY_PAUSE(bp
, pri_join_mask
);
1397 cos_data
->data
[0].pri_join_mask
=
1398 pg_help_data
->data
[0].pg_priority
;
1399 pg
[0] = pg_help_data
->data
[0].pg
;
1400 cos_data
->data
[1].pri_join_mask
=
1401 pg_help_data
->data
[1].pg_priority
;
1402 pg
[1] = pg_help_data
->data
[1].pg
;
1405 /* There can be only one strict pg */
1406 for (i
= 0 ; i
< ARRAY_SIZE(pg
); i
++) {
1407 if (pg
[i
] < DCBX_MAX_NUM_PG_BW_ENTRIES
)
1408 cos_data
->data
[i
].cos_bw
=
1409 DCBX_PG_BW_GET(ets
->pg_bw_tbl
, pg
[i
]);
1411 cos_data
->data
[i
].strict
=
1412 BNX2X_DCBX_STRICT_COS_HIGHEST
;
1416 static int bnx2x_dcbx_join_pgs(
1418 struct dcbx_ets_feature
*ets
,
1419 struct pg_help_data
*pg_help_data
,
1420 u8 required_num_of_pg
)
1422 u8 entry_joined
= pg_help_data
->num_of_pg
- 1;
1423 u8 entry_removed
= entry_joined
+ 1;
1426 if (required_num_of_pg
== 0 || ARRAY_SIZE(pg_help_data
->data
)
1427 <= pg_help_data
->num_of_pg
) {
1429 BNX2X_ERR("required_num_of_pg can't be zero\n");
1433 while (required_num_of_pg
< pg_help_data
->num_of_pg
) {
1434 entry_joined
= pg_help_data
->num_of_pg
- 2;
1435 entry_removed
= entry_joined
+ 1;
1437 entry_removed
%= ARRAY_SIZE(pg_help_data
->data
);
1439 pg_help_data
->data
[entry_joined
].pg_priority
|=
1440 pg_help_data
->data
[entry_removed
].pg_priority
;
1442 pg_help_data
->data
[entry_joined
].num_of_dif_pri
+=
1443 pg_help_data
->data
[entry_removed
].num_of_dif_pri
;
1445 if (pg_help_data
->data
[entry_joined
].pg
== DCBX_STRICT_PRI_PG
||
1446 pg_help_data
->data
[entry_removed
].pg
== DCBX_STRICT_PRI_PG
)
1447 /* Entries joined strict priority rules */
1448 pg_help_data
->data
[entry_joined
].pg
=
1451 /* Entries can be joined join BW */
1452 pg_joined
= DCBX_PG_BW_GET(ets
->pg_bw_tbl
,
1453 pg_help_data
->data
[entry_joined
].pg
) +
1454 DCBX_PG_BW_GET(ets
->pg_bw_tbl
,
1455 pg_help_data
->data
[entry_removed
].pg
);
1457 DCBX_PG_BW_SET(ets
->pg_bw_tbl
,
1458 pg_help_data
->data
[entry_joined
].pg
, pg_joined
);
1460 /* Joined the entries */
1461 pg_help_data
->num_of_pg
--;
1467 static void bnx2x_dcbx_2cos_limit_cee_three_pg_to_cos_params(
1469 struct pg_help_data
*pg_help_data
,
1470 struct dcbx_ets_feature
*ets
,
1471 struct cos_help_data
*cos_data
,
1472 u32
*pg_pri_orginal_spread
,
1480 bool b_found_strict
= false;
1481 u8 num_of_pri
= LLFC_DRIVER_TRAFFIC_TYPE_MAX
;
1483 cos_data
->data
[0].pri_join_mask
= cos_data
->data
[1].pri_join_mask
= 0;
1484 /* If there are both pauseable and non-pauseable priorities,
1485 * the pauseable priorities go to the first queue and the
1486 * non-pauseable priorities go to the second queue.
1488 if (IS_DCBX_PFC_PRI_MIX_PAUSE(bp
, pri_join_mask
))
1489 bnx2x_dcbx_separate_pauseable_from_non(bp
,
1490 cos_data
, pg_pri_orginal_spread
, ets
);
1492 /* If two BW-limited PG-s were combined to one queue,
1493 * the BW is their sum.
1495 * If there are only pauseable priorities or only non-pauseable,
1496 * and there are both BW-limited and non-BW-limited PG-s,
1497 * the BW-limited PG/s go to one queue and the non-BW-limited
1498 * PG/s go to the second queue.
1500 * If there are only pauseable priorities or only non-pauseable
1501 * and all are BW limited, then two priorities go to the first
1502 * queue and one priority goes to the second queue.
1504 * We will join this two cases:
1505 * if one is BW limited it will go to the secoend queue
1506 * otherwise the last priority will get it
1509 cos_data
->data
[0].pausable
= cos_data
->data
[1].pausable
=
1510 IS_DCBX_PFC_PRI_ONLY_PAUSE(bp
, pri_join_mask
);
1512 for (i
= 0 ; i
< num_of_pri
; i
++) {
1513 pri_tested
= 1 << bp
->dcbx_port_params
.
1514 app
.traffic_type_priority
[i
];
1515 pg_entry
= (u8
)pg_pri_orginal_spread
[bp
->
1516 dcbx_port_params
.app
.traffic_type_priority
[i
]];
1518 if (pg_entry
< DCBX_MAX_NUM_PG_BW_ENTRIES
) {
1521 if (i
== (num_of_pri
-1) &&
1522 false == b_found_strict
)
1523 /* last entry will be handled separately
1524 * If no priority is strict than last
1525 * enty goes to last queue.*/
1527 cos_data
->data
[entry
].pri_join_mask
|=
1529 bnx2x_dcbx_add_to_cos_bw(bp
,
1530 &cos_data
->data
[entry
],
1531 DCBX_PG_BW_GET(ets
->pg_bw_tbl
,
1534 b_found_strict
= true;
1535 cos_data
->data
[1].pri_join_mask
|= pri_tested
;
1536 /* If we join a group and one is strict
1537 * than the bw rulls */
1538 cos_data
->data
[1].strict
=
1539 BNX2X_DCBX_STRICT_COS_HIGHEST
;
1546 static void bnx2x_dcbx_2cos_limit_cee_fill_cos_params(struct bnx2x
*bp
,
1547 struct pg_help_data
*help_data
,
1548 struct dcbx_ets_feature
*ets
,
1549 struct cos_help_data
*cos_data
,
1550 u32
*pg_pri_orginal_spread
,
1555 /* default E2 settings */
1556 cos_data
->num_of_cos
= DCBX_COS_MAX_NUM_E2
;
1558 switch (help_data
->num_of_pg
) {
1560 bnx2x_dcbx_2cos_limit_cee_single_pg_to_cos_params(
1568 bnx2x_dcbx_2cos_limit_cee_two_pg_to_cos_params(
1573 pg_pri_orginal_spread
,
1579 bnx2x_dcbx_2cos_limit_cee_three_pg_to_cos_params(
1584 pg_pri_orginal_spread
,
1589 BNX2X_ERR("Wrong pg_help_data.num_of_pg\n");
1590 bnx2x_dcbx_ets_disabled_entry_data(bp
,
1591 cos_data
, pri_join_mask
);
1595 static int bnx2x_dcbx_spread_strict_pri(struct bnx2x
*bp
,
1596 struct cos_help_data
*cos_data
,
1598 u8 num_spread_of_entries
,
1601 u8 strict_pri
= BNX2X_DCBX_STRICT_COS_HIGHEST
;
1602 u8 num_of_app_pri
= MAX_PFC_PRIORITIES
;
1605 while (num_spread_of_entries
&& num_of_app_pri
> 0) {
1606 app_pri_bit
= 1 << (num_of_app_pri
- 1);
1607 if (app_pri_bit
& strict_app_pris
) {
1608 struct cos_entry_help_data
*data
= &cos_data
->
1610 num_spread_of_entries
--;
1611 if (num_spread_of_entries
== 0) {
1612 /* last entry needed put all the entries left */
1613 data
->cos_bw
= DCBX_INVALID_COS_BW
;
1614 data
->strict
= strict_pri
;
1615 data
->pri_join_mask
= strict_app_pris
;
1616 data
->pausable
= DCBX_IS_PFC_PRI_SOME_PAUSE(bp
,
1617 data
->pri_join_mask
);
1619 strict_app_pris
&= ~app_pri_bit
;
1621 data
->cos_bw
= DCBX_INVALID_COS_BW
;
1622 data
->strict
= strict_pri
;
1623 data
->pri_join_mask
= app_pri_bit
;
1624 data
->pausable
= DCBX_IS_PFC_PRI_SOME_PAUSE(bp
,
1625 data
->pri_join_mask
);
1629 BNX2X_DCBX_STRICT_COS_NEXT_LOWER_PRI(strict_pri
);
1636 if (num_spread_of_entries
)
1642 static u8
bnx2x_dcbx_cee_fill_strict_pri(struct bnx2x
*bp
,
1643 struct cos_help_data
*cos_data
,
1645 u8 num_spread_of_entries
,
1649 if (bnx2x_dcbx_spread_strict_pri(bp
, cos_data
, entry
,
1650 num_spread_of_entries
,
1652 struct cos_entry_help_data
*data
= &cos_data
->
1655 data
->cos_bw
= DCBX_INVALID_COS_BW
;
1656 data
->strict
= BNX2X_DCBX_STRICT_COS_HIGHEST
;
1657 data
->pri_join_mask
= strict_app_pris
;
1658 data
->pausable
= DCBX_IS_PFC_PRI_SOME_PAUSE(bp
,
1659 data
->pri_join_mask
);
1663 return num_spread_of_entries
;
1666 static void bnx2x_dcbx_cee_fill_cos_params(struct bnx2x
*bp
,
1667 struct pg_help_data
*help_data
,
1668 struct dcbx_ets_feature
*ets
,
1669 struct cos_help_data
*cos_data
,
1673 u8 need_num_of_entries
= 0;
1678 * if the number of requested PG-s in CEE is greater than 3
1679 * then the results are not determined since this is a violation
1682 if (help_data
->num_of_pg
> DCBX_COS_MAX_NUM_E3B0
) {
1683 if (bnx2x_dcbx_join_pgs(bp
, ets
, help_data
,
1684 DCBX_COS_MAX_NUM_E3B0
)) {
1685 BNX2X_ERR("Unable to reduce the number of PGs -"
1686 "we will disables ETS\n");
1687 bnx2x_dcbx_ets_disabled_entry_data(bp
, cos_data
,
1693 for (i
= 0 ; i
< help_data
->num_of_pg
; i
++) {
1694 struct pg_entry_help_data
*pg
= &help_data
->data
[i
];
1695 if (pg
->pg
< DCBX_MAX_NUM_PG_BW_ENTRIES
) {
1696 struct cos_entry_help_data
*data
= &cos_data
->
1699 data
->cos_bw
= DCBX_PG_BW_GET(ets
->pg_bw_tbl
, pg
->pg
);
1700 data
->strict
= BNX2X_DCBX_STRICT_INVALID
;
1701 data
->pri_join_mask
= pg
->pg_priority
;
1702 data
->pausable
= DCBX_IS_PFC_PRI_SOME_PAUSE(bp
,
1703 data
->pri_join_mask
);
1707 need_num_of_entries
= min_t(u8
,
1708 (u8
)pg
->num_of_dif_pri
,
1709 (u8
)DCBX_COS_MAX_NUM_E3B0
-
1710 help_data
->num_of_pg
+ 1);
1712 * If there are still VOQ-s which have no associated PG,
1713 * then associate these VOQ-s to PG15. These PG-s will
1714 * be used for SP between priorities on PG15.
1716 entry
+= bnx2x_dcbx_cee_fill_strict_pri(bp
, cos_data
,
1717 entry
, need_num_of_entries
, pg
->pg_priority
);
1721 /* the entry will represent the number of COSes used */
1722 cos_data
->num_of_cos
= entry
;
1724 static void bnx2x_dcbx_fill_cos_params(struct bnx2x
*bp
,
1725 struct pg_help_data
*help_data
,
1726 struct dcbx_ets_feature
*ets
,
1727 u32
*pg_pri_orginal_spread
)
1729 struct cos_help_data cos_data
;
1731 u32 pri_join_mask
= 0;
1732 u8 num_of_dif_pri
= 0;
1734 memset(&cos_data
, 0, sizeof(cos_data
));
1736 /* Validate the pg value */
1737 for (i
= 0; i
< help_data
->num_of_pg
; i
++) {
1738 if (DCBX_STRICT_PRIORITY
!= help_data
->data
[i
].pg
&&
1739 DCBX_MAX_NUM_PG_BW_ENTRIES
<= help_data
->data
[i
].pg
)
1740 BNX2X_ERR("Invalid pg[%d] data %x\n", i
,
1741 help_data
->data
[i
].pg
);
1742 pri_join_mask
|= help_data
->data
[i
].pg_priority
;
1743 num_of_dif_pri
+= help_data
->data
[i
].num_of_dif_pri
;
1747 cos_data
.num_of_cos
= 1;
1748 for (i
= 0; i
< ARRAY_SIZE(cos_data
.data
); i
++) {
1749 cos_data
.data
[i
].pri_join_mask
= 0;
1750 cos_data
.data
[i
].pausable
= false;
1751 cos_data
.data
[i
].strict
= BNX2X_DCBX_STRICT_INVALID
;
1752 cos_data
.data
[i
].cos_bw
= DCBX_INVALID_COS_BW
;
1755 if (CHIP_IS_E3B0(bp
))
1756 bnx2x_dcbx_cee_fill_cos_params(bp
, help_data
, ets
,
1757 &cos_data
, pri_join_mask
);
1758 else /* E2 + E3A0 */
1759 bnx2x_dcbx_2cos_limit_cee_fill_cos_params(bp
,
1762 pg_pri_orginal_spread
,
1767 for (i
= 0; i
< cos_data
.num_of_cos
; i
++) {
1768 struct bnx2x_dcbx_cos_params
*p
=
1769 &bp
->dcbx_port_params
.ets
.cos_params
[i
];
1771 p
->strict
= cos_data
.data
[i
].strict
;
1772 p
->bw_tbl
= cos_data
.data
[i
].cos_bw
;
1773 p
->pri_bitmask
= cos_data
.data
[i
].pri_join_mask
;
1774 p
->pauseable
= cos_data
.data
[i
].pausable
;
1777 if (p
->bw_tbl
!= DCBX_INVALID_COS_BW
||
1778 p
->strict
!= BNX2X_DCBX_STRICT_INVALID
) {
1779 if (p
->pri_bitmask
== 0)
1780 BNX2X_ERR("Invalid pri_bitmask for %d\n", i
);
1782 if (CHIP_IS_E2(bp
) || CHIP_IS_E3A0(bp
)) {
1785 DCBX_PFC_PRI_GET_NON_PAUSE(bp
,
1786 p
->pri_bitmask
) != 0)
1787 BNX2X_ERR("Inconsistent config for "
1788 "pausable COS %d\n", i
);
1790 if (!p
->pauseable
&&
1791 DCBX_PFC_PRI_GET_PAUSE(bp
,
1792 p
->pri_bitmask
) != 0)
1793 BNX2X_ERR("Inconsistent config for "
1794 "nonpausable COS %d\n", i
);
1799 DP(NETIF_MSG_LINK
, "COS %d PAUSABLE prijoinmask 0x%x\n",
1800 i
, cos_data
.data
[i
].pri_join_mask
);
1802 DP(NETIF_MSG_LINK
, "COS %d NONPAUSABLE prijoinmask "
1804 i
, cos_data
.data
[i
].pri_join_mask
);
1807 bp
->dcbx_port_params
.ets
.num_of_cos
= cos_data
.num_of_cos
;
1810 static void bnx2x_dcbx_get_ets_pri_pg_tbl(struct bnx2x
*bp
,
1811 u32
*set_configuration_ets_pg
,
1816 for (i
= 0; i
< DCBX_MAX_NUM_PRI_PG_ENTRIES
; i
++) {
1817 set_configuration_ets_pg
[i
] = DCBX_PRI_PG_GET(pri_pg_tbl
, i
);
1819 DP(NETIF_MSG_LINK
, "set_configuration_ets_pg[%d] = 0x%x\n",
1820 i
, set_configuration_ets_pg
[i
]);
1824 static void bnx2x_dcbx_fw_struct(struct bnx2x
*bp
)
1826 struct flow_control_configuration
*pfc_fw_cfg
= NULL
;
1828 u8 cos
= 0, pri
= 0;
1829 struct priority_cos
*tt2cos
;
1830 u32
*ttp
= bp
->dcbx_port_params
.app
.traffic_type_priority
;
1832 pfc_fw_cfg
= (struct flow_control_configuration
*)
1833 bnx2x_sp(bp
, pfc_config
);
1834 memset(pfc_fw_cfg
, 0, sizeof(struct flow_control_configuration
));
1837 tt2cos
= pfc_fw_cfg
->traffic_type_to_priority_cos
;
1839 /* Fw version should be incremented each update */
1840 pfc_fw_cfg
->dcb_version
= ++bp
->dcb_version
;
1841 pfc_fw_cfg
->dcb_enabled
= 1;
1843 /* Fill priority parameters */
1844 for (pri
= 0; pri
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
; pri
++) {
1845 tt2cos
[pri
].priority
= ttp
[pri
];
1846 pri_bit
= 1 << tt2cos
[pri
].priority
;
1848 /* Fill COS parameters based on COS calculated to
1849 * make it more general for future use */
1850 for (cos
= 0; cos
< bp
->dcbx_port_params
.ets
.num_of_cos
; cos
++)
1851 if (bp
->dcbx_port_params
.ets
.cos_params
[cos
].
1852 pri_bitmask
& pri_bit
)
1853 tt2cos
[pri
].cos
= cos
;
1856 /* we never want the FW to add a 0 vlan tag */
1857 pfc_fw_cfg
->dont_add_pri_0_en
= 1;
1859 bnx2x_dcbx_print_cos_params(bp
, pfc_fw_cfg
);
1862 void bnx2x_dcbx_pmf_update(struct bnx2x
*bp
)
1864 /* if we need to syncronize DCBX result from prev PMF
1865 * read it from shmem and update bp accordingly
1867 if (SHMEM2_HAS(bp
, drv_flags
) &&
1868 GET_FLAGS(SHMEM2_RD(bp
, drv_flags
), DRV_FLAGS_DCB_CONFIGURED
)) {
1869 /* Read neg results if dcbx is in the FW */
1870 if (bnx2x_dcbx_read_shmem_neg_results(bp
))
1873 bnx2x_dump_dcbx_drv_param(bp
, &bp
->dcbx_local_feat
,
1875 bnx2x_get_dcbx_drv_param(bp
, &bp
->dcbx_local_feat
,
1883 #define BNX2X_DCBX_CAPS (DCB_CAP_DCBX_LLD_MANAGED | \
1884 DCB_CAP_DCBX_VER_CEE | DCB_CAP_DCBX_STATIC)
1886 static inline bool bnx2x_dcbnl_set_valid(struct bnx2x
*bp
)
1888 /* validate dcbnl call that may change HW state:
1889 * DCB is on and DCBX mode was SUCCESSFULLY set by the user.
1891 return bp
->dcb_state
&& bp
->dcbx_mode_uset
;
1894 static u8
bnx2x_dcbnl_get_state(struct net_device
*netdev
)
1896 struct bnx2x
*bp
= netdev_priv(netdev
);
1897 DP(NETIF_MSG_LINK
, "state = %d\n", bp
->dcb_state
);
1898 return bp
->dcb_state
;
1901 static u8
bnx2x_dcbnl_set_state(struct net_device
*netdev
, u8 state
)
1903 struct bnx2x
*bp
= netdev_priv(netdev
);
1904 DP(NETIF_MSG_LINK
, "state = %s\n", state
? "on" : "off");
1906 bnx2x_dcbx_set_state(bp
, (state
? true : false), bp
->dcbx_enabled
);
1910 static void bnx2x_dcbnl_get_perm_hw_addr(struct net_device
*netdev
,
1913 struct bnx2x
*bp
= netdev_priv(netdev
);
1914 DP(NETIF_MSG_LINK
, "GET-PERM-ADDR\n");
1916 /* first the HW mac address */
1917 memcpy(perm_addr
, netdev
->dev_addr
, netdev
->addr_len
);
1920 /* second SAN address */
1921 memcpy(perm_addr
+netdev
->addr_len
, bp
->fip_mac
, netdev
->addr_len
);
1925 static void bnx2x_dcbnl_set_pg_tccfg_tx(struct net_device
*netdev
, int prio
,
1926 u8 prio_type
, u8 pgid
, u8 bw_pct
,
1929 struct bnx2x
*bp
= netdev_priv(netdev
);
1931 DP(NETIF_MSG_LINK
, "prio[%d] = %d\n", prio
, pgid
);
1932 if (!bnx2x_dcbnl_set_valid(bp
) || prio
>= DCBX_MAX_NUM_PRI_PG_ENTRIES
)
1936 * bw_pct ingnored - band-width percentage devision between user
1937 * priorities within the same group is not
1938 * standard and hence not supported
1940 * prio_type igonred - priority levels within the same group are not
1941 * standard and hence are not supported. According
1942 * to the standard pgid 15 is dedicated to strict
1943 * prioirty traffic (on the port level).
1948 bp
->dcbx_config_params
.admin_configuration_ets_pg
[prio
] = pgid
;
1949 bp
->dcbx_config_params
.admin_ets_configuration_tx_enable
= 1;
1952 static void bnx2x_dcbnl_set_pg_bwgcfg_tx(struct net_device
*netdev
,
1953 int pgid
, u8 bw_pct
)
1955 struct bnx2x
*bp
= netdev_priv(netdev
);
1956 DP(NETIF_MSG_LINK
, "pgid[%d] = %d\n", pgid
, bw_pct
);
1958 if (!bnx2x_dcbnl_set_valid(bp
) || pgid
>= DCBX_MAX_NUM_PG_BW_ENTRIES
)
1961 bp
->dcbx_config_params
.admin_configuration_bw_precentage
[pgid
] = bw_pct
;
1962 bp
->dcbx_config_params
.admin_ets_configuration_tx_enable
= 1;
1965 static void bnx2x_dcbnl_set_pg_tccfg_rx(struct net_device
*netdev
, int prio
,
1966 u8 prio_type
, u8 pgid
, u8 bw_pct
,
1969 struct bnx2x
*bp
= netdev_priv(netdev
);
1970 DP(NETIF_MSG_LINK
, "Nothing to set; No RX support\n");
1973 static void bnx2x_dcbnl_set_pg_bwgcfg_rx(struct net_device
*netdev
,
1974 int pgid
, u8 bw_pct
)
1976 struct bnx2x
*bp
= netdev_priv(netdev
);
1977 DP(NETIF_MSG_LINK
, "Nothing to set; No RX support\n");
1980 static void bnx2x_dcbnl_get_pg_tccfg_tx(struct net_device
*netdev
, int prio
,
1981 u8
*prio_type
, u8
*pgid
, u8
*bw_pct
,
1984 struct bnx2x
*bp
= netdev_priv(netdev
);
1985 DP(NETIF_MSG_LINK
, "prio = %d\n", prio
);
1988 * bw_pct ingnored - band-width percentage devision between user
1989 * priorities within the same group is not
1990 * standard and hence not supported
1992 * prio_type igonred - priority levels within the same group are not
1993 * standard and hence are not supported. According
1994 * to the standard pgid 15 is dedicated to strict
1995 * prioirty traffic (on the port level).
1999 *up_map
= *bw_pct
= *prio_type
= *pgid
= 0;
2001 if (!bp
->dcb_state
|| prio
>= DCBX_MAX_NUM_PRI_PG_ENTRIES
)
2004 *pgid
= DCBX_PRI_PG_GET(bp
->dcbx_local_feat
.ets
.pri_pg_tbl
, prio
);
2007 static void bnx2x_dcbnl_get_pg_bwgcfg_tx(struct net_device
*netdev
,
2008 int pgid
, u8
*bw_pct
)
2010 struct bnx2x
*bp
= netdev_priv(netdev
);
2011 DP(NETIF_MSG_LINK
, "pgid = %d\n", pgid
);
2015 if (!bp
->dcb_state
|| pgid
>= DCBX_MAX_NUM_PG_BW_ENTRIES
)
2018 *bw_pct
= DCBX_PG_BW_GET(bp
->dcbx_local_feat
.ets
.pg_bw_tbl
, pgid
);
2021 static void bnx2x_dcbnl_get_pg_tccfg_rx(struct net_device
*netdev
, int prio
,
2022 u8
*prio_type
, u8
*pgid
, u8
*bw_pct
,
2025 struct bnx2x
*bp
= netdev_priv(netdev
);
2026 DP(NETIF_MSG_LINK
, "Nothing to get; No RX support\n");
2028 *prio_type
= *pgid
= *bw_pct
= *up_map
= 0;
2031 static void bnx2x_dcbnl_get_pg_bwgcfg_rx(struct net_device
*netdev
,
2032 int pgid
, u8
*bw_pct
)
2034 struct bnx2x
*bp
= netdev_priv(netdev
);
2035 DP(NETIF_MSG_LINK
, "Nothing to get; No RX support\n");
2040 static void bnx2x_dcbnl_set_pfc_cfg(struct net_device
*netdev
, int prio
,
2043 struct bnx2x
*bp
= netdev_priv(netdev
);
2044 DP(NETIF_MSG_LINK
, "prio[%d] = %d\n", prio
, setting
);
2046 if (!bnx2x_dcbnl_set_valid(bp
) || prio
>= MAX_PFC_PRIORITIES
)
2049 bp
->dcbx_config_params
.admin_pfc_bitmap
|= ((setting
? 1 : 0) << prio
);
2052 bp
->dcbx_config_params
.admin_pfc_tx_enable
= 1;
2055 static void bnx2x_dcbnl_get_pfc_cfg(struct net_device
*netdev
, int prio
,
2058 struct bnx2x
*bp
= netdev_priv(netdev
);
2059 DP(NETIF_MSG_LINK
, "prio = %d\n", prio
);
2063 if (!bp
->dcb_state
|| prio
>= MAX_PFC_PRIORITIES
)
2066 *setting
= (bp
->dcbx_local_feat
.pfc
.pri_en_bitmap
>> prio
) & 0x1;
2069 static u8
bnx2x_dcbnl_set_all(struct net_device
*netdev
)
2071 struct bnx2x
*bp
= netdev_priv(netdev
);
2074 DP(NETIF_MSG_LINK
, "SET-ALL\n");
2076 if (!bnx2x_dcbnl_set_valid(bp
))
2079 if (bp
->recovery_state
!= BNX2X_RECOVERY_DONE
) {
2080 netdev_err(bp
->dev
, "Handling parity error recovery. "
2081 "Try again later\n");
2084 if (netif_running(bp
->dev
)) {
2085 bnx2x_nic_unload(bp
, UNLOAD_NORMAL
);
2086 rc
= bnx2x_nic_load(bp
, LOAD_NORMAL
);
2088 DP(NETIF_MSG_LINK
, "set_dcbx_params done (%d)\n", rc
);
2095 static u8
bnx2x_dcbnl_get_cap(struct net_device
*netdev
, int capid
, u8
*cap
)
2097 struct bnx2x
*bp
= netdev_priv(netdev
);
2100 if (bp
->dcb_state
) {
2102 case DCB_CAP_ATTR_PG
:
2105 case DCB_CAP_ATTR_PFC
:
2108 case DCB_CAP_ATTR_UP2TC
:
2111 case DCB_CAP_ATTR_PG_TCS
:
2112 *cap
= 0x80; /* 8 priorities for PGs */
2114 case DCB_CAP_ATTR_PFC_TCS
:
2115 *cap
= 0x80; /* 8 priorities for PFC */
2117 case DCB_CAP_ATTR_GSP
:
2120 case DCB_CAP_ATTR_BCN
:
2123 case DCB_CAP_ATTR_DCBX
:
2124 *cap
= BNX2X_DCBX_CAPS
;
2132 DP(NETIF_MSG_LINK
, "capid %d:%x\n", capid
, *cap
);
2136 static u8
bnx2x_dcbnl_get_numtcs(struct net_device
*netdev
, int tcid
, u8
*num
)
2138 struct bnx2x
*bp
= netdev_priv(netdev
);
2141 DP(NETIF_MSG_LINK
, "tcid %d\n", tcid
);
2143 if (bp
->dcb_state
) {
2145 case DCB_NUMTCS_ATTR_PG
:
2146 *num
= CHIP_IS_E3B0(bp
) ? DCBX_COS_MAX_NUM_E3B0
:
2147 DCBX_COS_MAX_NUM_E2
;
2149 case DCB_NUMTCS_ATTR_PFC
:
2150 *num
= CHIP_IS_E3B0(bp
) ? DCBX_COS_MAX_NUM_E3B0
:
2151 DCBX_COS_MAX_NUM_E2
;
2163 static u8
bnx2x_dcbnl_set_numtcs(struct net_device
*netdev
, int tcid
, u8 num
)
2165 struct bnx2x
*bp
= netdev_priv(netdev
);
2166 DP(NETIF_MSG_LINK
, "num tcs = %d; Not supported\n", num
);
2170 static u8
bnx2x_dcbnl_get_pfc_state(struct net_device
*netdev
)
2172 struct bnx2x
*bp
= netdev_priv(netdev
);
2173 DP(NETIF_MSG_LINK
, "state = %d\n", bp
->dcbx_local_feat
.pfc
.enabled
);
2178 return bp
->dcbx_local_feat
.pfc
.enabled
;
2181 static void bnx2x_dcbnl_set_pfc_state(struct net_device
*netdev
, u8 state
)
2183 struct bnx2x
*bp
= netdev_priv(netdev
);
2184 DP(NETIF_MSG_LINK
, "state = %s\n", state
? "on" : "off");
2186 if (!bnx2x_dcbnl_set_valid(bp
))
2189 bp
->dcbx_config_params
.admin_pfc_tx_enable
=
2190 bp
->dcbx_config_params
.admin_pfc_enable
= (state
? 1 : 0);
2193 static void bnx2x_admin_app_set_ent(
2194 struct bnx2x_admin_priority_app_table
*app_ent
,
2195 u8 idtype
, u16 idval
, u8 up
)
2200 case DCB_APP_IDTYPE_ETHTYPE
:
2201 app_ent
->traffic_type
= TRAFFIC_TYPE_ETH
;
2203 case DCB_APP_IDTYPE_PORTNUM
:
2204 app_ent
->traffic_type
= TRAFFIC_TYPE_PORT
;
2207 break; /* never gets here */
2209 app_ent
->app_id
= idval
;
2210 app_ent
->priority
= up
;
2213 static bool bnx2x_admin_app_is_equal(
2214 struct bnx2x_admin_priority_app_table
*app_ent
,
2215 u8 idtype
, u16 idval
)
2217 if (!app_ent
->valid
)
2221 case DCB_APP_IDTYPE_ETHTYPE
:
2222 if (app_ent
->traffic_type
!= TRAFFIC_TYPE_ETH
)
2225 case DCB_APP_IDTYPE_PORTNUM
:
2226 if (app_ent
->traffic_type
!= TRAFFIC_TYPE_PORT
)
2232 if (app_ent
->app_id
!= idval
)
2238 static int bnx2x_set_admin_app_up(struct bnx2x
*bp
, u8 idtype
, u16 idval
, u8 up
)
2242 /* iterate over the app entries looking for idtype and idval */
2243 for (i
= 0, ff
= -1; i
< 4; i
++) {
2244 struct bnx2x_admin_priority_app_table
*app_ent
=
2245 &bp
->dcbx_config_params
.admin_priority_app_table
[i
];
2246 if (bnx2x_admin_app_is_equal(app_ent
, idtype
, idval
))
2249 if (ff
< 0 && !app_ent
->valid
)
2253 /* if found overwrite up */
2254 bp
->dcbx_config_params
.
2255 admin_priority_app_table
[i
].priority
= up
;
2257 /* not found use first-free */
2258 bnx2x_admin_app_set_ent(
2259 &bp
->dcbx_config_params
.admin_priority_app_table
[ff
],
2262 /* app table is full */
2265 /* up configured, if not 0 make sure feature is enabled */
2267 bp
->dcbx_config_params
.admin_application_priority_tx_enable
= 1;
2272 static u8
bnx2x_dcbnl_set_app_up(struct net_device
*netdev
, u8 idtype
,
2275 struct bnx2x
*bp
= netdev_priv(netdev
);
2277 DP(NETIF_MSG_LINK
, "app_type %d, app_id %x, prio bitmap %d\n",
2280 if (!bnx2x_dcbnl_set_valid(bp
))
2285 case DCB_APP_IDTYPE_ETHTYPE
:
2286 case DCB_APP_IDTYPE_PORTNUM
:
2291 return bnx2x_set_admin_app_up(bp
, idtype
, idval
, up
);
2294 static u8
bnx2x_dcbnl_get_dcbx(struct net_device
*netdev
)
2296 struct bnx2x
*bp
= netdev_priv(netdev
);
2299 state
= DCB_CAP_DCBX_LLD_MANAGED
| DCB_CAP_DCBX_VER_CEE
;
2301 if (bp
->dcbx_enabled
== BNX2X_DCBX_ENABLED_ON_NEG_OFF
)
2302 state
|= DCB_CAP_DCBX_STATIC
;
2307 static u8
bnx2x_dcbnl_set_dcbx(struct net_device
*netdev
, u8 state
)
2309 struct bnx2x
*bp
= netdev_priv(netdev
);
2310 DP(NETIF_MSG_LINK
, "state = %02x\n", state
);
2314 if ((state
& BNX2X_DCBX_CAPS
) != state
) {
2315 BNX2X_ERR("Requested DCBX mode %x is beyond advertised "
2316 "capabilities\n", state
);
2320 if (bp
->dcb_state
!= BNX2X_DCB_STATE_ON
) {
2321 BNX2X_ERR("DCB turned off, DCBX configuration is invalid\n");
2325 if (state
& DCB_CAP_DCBX_STATIC
)
2326 bp
->dcbx_enabled
= BNX2X_DCBX_ENABLED_ON_NEG_OFF
;
2328 bp
->dcbx_enabled
= BNX2X_DCBX_ENABLED_ON_NEG_ON
;
2330 bp
->dcbx_mode_uset
= true;
2334 static u8
bnx2x_dcbnl_get_featcfg(struct net_device
*netdev
, int featid
,
2337 struct bnx2x
*bp
= netdev_priv(netdev
);
2340 DP(NETIF_MSG_LINK
, "featid %d\n", featid
);
2342 if (bp
->dcb_state
) {
2345 case DCB_FEATCFG_ATTR_PG
:
2346 if (bp
->dcbx_local_feat
.ets
.enabled
)
2347 *flags
|= DCB_FEATCFG_ENABLE
;
2348 if (bp
->dcbx_error
& DCBX_LOCAL_ETS_ERROR
)
2349 *flags
|= DCB_FEATCFG_ERROR
;
2351 case DCB_FEATCFG_ATTR_PFC
:
2352 if (bp
->dcbx_local_feat
.pfc
.enabled
)
2353 *flags
|= DCB_FEATCFG_ENABLE
;
2354 if (bp
->dcbx_error
& (DCBX_LOCAL_PFC_ERROR
|
2355 DCBX_LOCAL_PFC_MISMATCH
))
2356 *flags
|= DCB_FEATCFG_ERROR
;
2358 case DCB_FEATCFG_ATTR_APP
:
2359 if (bp
->dcbx_local_feat
.app
.enabled
)
2360 *flags
|= DCB_FEATCFG_ENABLE
;
2361 if (bp
->dcbx_error
& (DCBX_LOCAL_APP_ERROR
|
2362 DCBX_LOCAL_APP_MISMATCH
))
2363 *flags
|= DCB_FEATCFG_ERROR
;
2375 static u8
bnx2x_dcbnl_set_featcfg(struct net_device
*netdev
, int featid
,
2378 struct bnx2x
*bp
= netdev_priv(netdev
);
2381 DP(NETIF_MSG_LINK
, "featid = %d flags = %02x\n", featid
, flags
);
2383 /* ignore the 'advertise' flag */
2384 if (bnx2x_dcbnl_set_valid(bp
)) {
2386 case DCB_FEATCFG_ATTR_PG
:
2387 bp
->dcbx_config_params
.admin_ets_enable
=
2388 flags
& DCB_FEATCFG_ENABLE
? 1 : 0;
2389 bp
->dcbx_config_params
.admin_ets_willing
=
2390 flags
& DCB_FEATCFG_WILLING
? 1 : 0;
2392 case DCB_FEATCFG_ATTR_PFC
:
2393 bp
->dcbx_config_params
.admin_pfc_enable
=
2394 flags
& DCB_FEATCFG_ENABLE
? 1 : 0;
2395 bp
->dcbx_config_params
.admin_pfc_willing
=
2396 flags
& DCB_FEATCFG_WILLING
? 1 : 0;
2398 case DCB_FEATCFG_ATTR_APP
:
2399 /* ignore enable, always enabled */
2400 bp
->dcbx_config_params
.admin_app_priority_willing
=
2401 flags
& DCB_FEATCFG_WILLING
? 1 : 0;
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(NETIF_MSG_LINK
, "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(NETIF_MSG_LINK
, "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 */