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>
23 #include <linux/dcbnl.h>
27 #include "bnx2x_cmn.h"
28 #include "bnx2x_dcb.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_pfc_fw_struct_e2(struct bnx2x
*bp
);
53 static void bnx2x_pfc_set(struct bnx2x
*bp
)
55 struct bnx2x_nig_brb_pfc_port_params pfc_params
= {0};
60 /* Tx COS configuration */
61 for (i
= 0; i
< bp
->dcbx_port_params
.ets
.num_of_cos
; i
++)
62 if (bp
->dcbx_port_params
.ets
.cos_params
[i
].pauseable
)
63 pfc_params
.rx_cos_priority_mask
[i
] =
64 bp
->dcbx_port_params
.ets
.
65 cos_params
[i
].pri_bitmask
;
68 * Rx COS configuration
69 * Changing PFC RX configuration .
70 * In RX COS0 will always be configured to lossy and COS1 to lossless
72 for (pri
= 0 ; pri
< MAX_PFC_PRIORITIES
; pri
++) {
75 if (pri_bit
& DCBX_PFC_PRI_PAUSE_MASK(bp
))
76 val
|= 1 << (pri
* 4);
79 pfc_params
.pkt_priority_to_cos
= val
;
82 pfc_params
.llfc_low_priority_classes
= 0;
84 pfc_params
.llfc_high_priority_classes
= DCBX_PFC_PRI_PAUSE_MASK(bp
);
86 /* BRB configuration */
87 pfc_params
.cos0_pauseable
= false;
88 pfc_params
.cos1_pauseable
= true;
90 bnx2x_acquire_phy_lock(bp
);
91 bp
->link_params
.feature_config_flags
|= FEATURE_CONFIG_PFC_ENABLED
;
92 bnx2x_update_pfc(&bp
->link_params
, &bp
->link_vars
, &pfc_params
);
93 bnx2x_release_phy_lock(bp
);
96 static void bnx2x_pfc_clear(struct bnx2x
*bp
)
98 struct bnx2x_nig_brb_pfc_port_params nig_params
= {0};
99 nig_params
.pause_enable
= 1;
101 if (bp
->flags
& SAFC_TX_FLAG
) {
102 u32 high
= 0, low
= 0;
105 for (i
= 0; i
< BNX2X_MAX_PRIORITY
; i
++) {
106 if (bp
->pri_map
[i
] == 1)
108 if (bp
->pri_map
[i
] == 0)
112 nig_params
.llfc_low_priority_classes
= high
;
113 nig_params
.llfc_low_priority_classes
= low
;
115 nig_params
.pause_enable
= 0;
116 nig_params
.llfc_enable
= 1;
117 nig_params
.llfc_out_en
= 1;
119 #endif /* BNX2X_SAFC */
120 bnx2x_acquire_phy_lock(bp
);
121 bp
->link_params
.feature_config_flags
&= ~FEATURE_CONFIG_PFC_ENABLED
;
122 bnx2x_update_pfc(&bp
->link_params
, &bp
->link_vars
, &nig_params
);
123 bnx2x_release_phy_lock(bp
);
126 static void bnx2x_dump_dcbx_drv_param(struct bnx2x
*bp
,
127 struct dcbx_features
*features
,
131 DP(NETIF_MSG_LINK
, "local_mib.error %x\n", error
);
135 "local_mib.features.ets.enabled %x\n", features
->ets
.enabled
);
136 for (i
= 0; i
< DCBX_MAX_NUM_PG_BW_ENTRIES
; i
++)
138 "local_mib.features.ets.pg_bw_tbl[%d] %d\n", i
,
139 DCBX_PG_BW_GET(features
->ets
.pg_bw_tbl
, i
));
140 for (i
= 0; i
< DCBX_MAX_NUM_PRI_PG_ENTRIES
; i
++)
142 "local_mib.features.ets.pri_pg_tbl[%d] %d\n", i
,
143 DCBX_PRI_PG_GET(features
->ets
.pri_pg_tbl
, i
));
146 DP(NETIF_MSG_LINK
, "dcbx_features.pfc.pri_en_bitmap %x\n",
147 features
->pfc
.pri_en_bitmap
);
148 DP(NETIF_MSG_LINK
, "dcbx_features.pfc.pfc_caps %x\n",
149 features
->pfc
.pfc_caps
);
150 DP(NETIF_MSG_LINK
, "dcbx_features.pfc.enabled %x\n",
151 features
->pfc
.enabled
);
153 DP(NETIF_MSG_LINK
, "dcbx_features.app.default_pri %x\n",
154 features
->app
.default_pri
);
155 DP(NETIF_MSG_LINK
, "dcbx_features.app.tc_supported %x\n",
156 features
->app
.tc_supported
);
157 DP(NETIF_MSG_LINK
, "dcbx_features.app.enabled %x\n",
158 features
->app
.enabled
);
159 for (i
= 0; i
< DCBX_MAX_APP_PROTOCOL
; i
++) {
161 "dcbx_features.app.app_pri_tbl[%x].app_id %x\n",
162 i
, features
->app
.app_pri_tbl
[i
].app_id
);
164 "dcbx_features.app.app_pri_tbl[%x].pri_bitmap %x\n",
165 i
, features
->app
.app_pri_tbl
[i
].pri_bitmap
);
167 "dcbx_features.app.app_pri_tbl[%x].appBitfield %x\n",
168 i
, features
->app
.app_pri_tbl
[i
].appBitfield
);
172 static void bnx2x_dcbx_get_ap_priority(struct bnx2x
*bp
,
176 u32 pri
= MAX_PFC_PRIORITIES
;
177 u32 index
= MAX_PFC_PRIORITIES
- 1;
179 u32
*ttp
= bp
->dcbx_port_params
.app
.traffic_type_priority
;
181 /* Choose the highest priority */
182 while ((MAX_PFC_PRIORITIES
== pri
) && (0 != index
)) {
183 pri_mask
= 1 << index
;
184 if (GET_FLAGS(pri_bitmap
, pri_mask
))
189 if (pri
< MAX_PFC_PRIORITIES
)
190 ttp
[llfc_traf_type
] = max_t(u32
, ttp
[llfc_traf_type
], pri
);
193 static void bnx2x_dcbx_get_ap_feature(struct bnx2x
*bp
,
194 struct dcbx_app_priority_feature
*app
,
197 u32
*ttp
= bp
->dcbx_port_params
.app
.traffic_type_priority
;
199 if (GET_FLAGS(error
, DCBX_LOCAL_APP_ERROR
))
200 DP(NETIF_MSG_LINK
, "DCBX_LOCAL_APP_ERROR\n");
202 if (app
->enabled
&& !GET_FLAGS(error
, DCBX_LOCAL_APP_ERROR
)) {
204 bp
->dcbx_port_params
.app
.enabled
= true;
206 for (index
= 0 ; index
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
; index
++)
209 if (app
->default_pri
< MAX_PFC_PRIORITIES
)
210 ttp
[LLFC_TRAFFIC_TYPE_NW
] = app
->default_pri
;
212 for (index
= 0 ; index
< DCBX_MAX_APP_PROTOCOL
; index
++) {
213 struct dcbx_app_priority_entry
*entry
=
216 if (GET_FLAGS(entry
[index
].appBitfield
,
217 DCBX_APP_SF_ETH_TYPE
) &&
218 ETH_TYPE_FCOE
== entry
[index
].app_id
)
219 bnx2x_dcbx_get_ap_priority(bp
,
220 entry
[index
].pri_bitmap
,
221 LLFC_TRAFFIC_TYPE_FCOE
);
223 if (GET_FLAGS(entry
[index
].appBitfield
,
225 TCP_PORT_ISCSI
== entry
[index
].app_id
)
226 bnx2x_dcbx_get_ap_priority(bp
,
227 entry
[index
].pri_bitmap
,
228 LLFC_TRAFFIC_TYPE_ISCSI
);
231 DP(NETIF_MSG_LINK
, "DCBX_LOCAL_APP_DISABLED\n");
232 bp
->dcbx_port_params
.app
.enabled
= false;
233 for (index
= 0 ; index
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
; index
++)
234 ttp
[index
] = INVALID_TRAFFIC_TYPE_PRIORITY
;
238 static void bnx2x_dcbx_get_ets_feature(struct bnx2x
*bp
,
239 struct dcbx_ets_feature
*ets
,
242 u32 pg_pri_orginal_spread
[DCBX_MAX_NUM_PG_BW_ENTRIES
] = {0};
243 struct pg_help_data pg_help_data
;
244 struct bnx2x_dcbx_cos_params
*cos_params
=
245 bp
->dcbx_port_params
.ets
.cos_params
;
247 memset(&pg_help_data
, 0, sizeof(struct pg_help_data
));
250 if (GET_FLAGS(error
, DCBX_LOCAL_ETS_ERROR
))
251 DP(NETIF_MSG_LINK
, "DCBX_LOCAL_ETS_ERROR\n");
254 /* Clean up old settings of ets on COS */
255 for (i
= 0; i
< E2_NUM_OF_COS
; i
++) {
257 cos_params
[i
].pauseable
= false;
258 cos_params
[i
].strict
= BNX2X_DCBX_COS_NOT_STRICT
;
259 cos_params
[i
].bw_tbl
= DCBX_INVALID_COS_BW
;
260 cos_params
[i
].pri_bitmask
= DCBX_PFC_PRI_GET_NON_PAUSE(bp
, 0);
263 if (bp
->dcbx_port_params
.app
.enabled
&&
264 !GET_FLAGS(error
, DCBX_LOCAL_ETS_ERROR
) &&
266 DP(NETIF_MSG_LINK
, "DCBX_LOCAL_ETS_ENABLE\n");
267 bp
->dcbx_port_params
.ets
.enabled
= true;
269 bnx2x_dcbx_get_ets_pri_pg_tbl(bp
,
270 pg_pri_orginal_spread
,
273 bnx2x_dcbx_get_num_pg_traf_type(bp
,
274 pg_pri_orginal_spread
,
277 bnx2x_dcbx_fill_cos_params(bp
, &pg_help_data
,
278 ets
, pg_pri_orginal_spread
);
281 DP(NETIF_MSG_LINK
, "DCBX_LOCAL_ETS_DISABLED\n");
282 bp
->dcbx_port_params
.ets
.enabled
= false;
283 ets
->pri_pg_tbl
[0] = 0;
285 for (i
= 0; i
< DCBX_MAX_NUM_PRI_PG_ENTRIES
; i
++)
286 DCBX_PG_BW_SET(ets
->pg_bw_tbl
, i
, 1);
290 static void bnx2x_dcbx_get_pfc_feature(struct bnx2x
*bp
,
291 struct dcbx_pfc_feature
*pfc
, u32 error
)
294 if (GET_FLAGS(error
, DCBX_LOCAL_PFC_ERROR
))
295 DP(NETIF_MSG_LINK
, "DCBX_LOCAL_PFC_ERROR\n");
297 if (bp
->dcbx_port_params
.app
.enabled
&&
298 !GET_FLAGS(error
, DCBX_LOCAL_PFC_ERROR
) &&
300 bp
->dcbx_port_params
.pfc
.enabled
= true;
301 bp
->dcbx_port_params
.pfc
.priority_non_pauseable_mask
=
302 ~(pfc
->pri_en_bitmap
);
304 DP(NETIF_MSG_LINK
, "DCBX_LOCAL_PFC_DISABLED\n");
305 bp
->dcbx_port_params
.pfc
.enabled
= false;
306 bp
->dcbx_port_params
.pfc
.priority_non_pauseable_mask
= 0;
310 static void bnx2x_get_dcbx_drv_param(struct bnx2x
*bp
,
311 struct dcbx_features
*features
,
314 bnx2x_dcbx_get_ap_feature(bp
, &features
->app
, error
);
316 bnx2x_dcbx_get_pfc_feature(bp
, &features
->pfc
, error
);
318 bnx2x_dcbx_get_ets_feature(bp
, &features
->ets
, error
);
321 #define DCBX_LOCAL_MIB_MAX_TRY_READ (100)
322 static int bnx2x_dcbx_read_mib(struct bnx2x
*bp
,
327 int max_try_read
= 0, i
;
328 u32
*buff
, mib_size
, prefix_seq_num
, suffix_seq_num
;
329 struct lldp_remote_mib
*remote_mib
;
330 struct lldp_local_mib
*local_mib
;
333 switch (read_mib_type
) {
334 case DCBX_READ_LOCAL_MIB
:
335 mib_size
= sizeof(struct lldp_local_mib
);
337 case DCBX_READ_REMOTE_MIB
:
338 mib_size
= sizeof(struct lldp_remote_mib
);
344 offset
+= BP_PORT(bp
) * mib_size
;
347 buff
= base_mib_addr
;
348 for (i
= 0; i
< mib_size
; i
+= 4, buff
++)
349 *buff
= REG_RD(bp
, offset
+ i
);
353 switch (read_mib_type
) {
354 case DCBX_READ_LOCAL_MIB
:
355 local_mib
= (struct lldp_local_mib
*) base_mib_addr
;
356 prefix_seq_num
= local_mib
->prefix_seq_num
;
357 suffix_seq_num
= local_mib
->suffix_seq_num
;
359 case DCBX_READ_REMOTE_MIB
:
360 remote_mib
= (struct lldp_remote_mib
*) base_mib_addr
;
361 prefix_seq_num
= remote_mib
->prefix_seq_num
;
362 suffix_seq_num
= remote_mib
->suffix_seq_num
;
367 } while ((prefix_seq_num
!= suffix_seq_num
) &&
368 (max_try_read
< DCBX_LOCAL_MIB_MAX_TRY_READ
));
370 if (max_try_read
>= DCBX_LOCAL_MIB_MAX_TRY_READ
) {
371 BNX2X_ERR("MIB could not be read\n");
378 static void bnx2x_pfc_set_pfc(struct bnx2x
*bp
)
380 if (!CHIP_IS_E1x(bp
)) {
382 BNX2X_ERR("4 port mode is not supported");
386 if (bp
->dcbx_port_params
.pfc
.enabled
)
388 /* 1. Fills up common PFC structures if required.*/
389 /* 2. Configure NIG, MAC and BRB via the elink:
390 * elink must first check if BMAC is not in reset
391 * and only then configures the BMAC
392 * Or, configure EMAC.
401 static void bnx2x_dcbx_stop_hw_tx(struct bnx2x
*bp
)
403 DP(NETIF_MSG_LINK
, "sending STOP TRAFFIC\n");
404 bnx2x_sp_post(bp
, RAMROD_CMD_ID_COMMON_STOP_TRAFFIC
,
405 0 /* connectionless */,
406 0 /* dataHi is zero */,
407 0 /* dataLo is zero */,
408 NONE_CONNECTION_TYPE
);
411 static void bnx2x_dcbx_resume_hw_tx(struct bnx2x
*bp
)
413 bnx2x_pfc_fw_struct_e2(bp
);
414 DP(NETIF_MSG_LINK
, "sending START TRAFFIC\n");
415 bnx2x_sp_post(bp
, RAMROD_CMD_ID_COMMON_START_TRAFFIC
,
416 0, /* connectionless */
417 U64_HI(bnx2x_sp_mapping(bp
, pfc_config
)),
418 U64_LO(bnx2x_sp_mapping(bp
, pfc_config
)),
419 NONE_CONNECTION_TYPE
);
422 static void bnx2x_dcbx_update_ets_params(struct bnx2x
*bp
)
424 struct bnx2x_dcbx_pg_params
*ets
= &(bp
->dcbx_port_params
.ets
);
427 bnx2x_ets_disabled(&bp
->link_params
/*, &bp->link_vars*/);
432 if ((ets
->num_of_cos
== 0) || (ets
->num_of_cos
> E2_NUM_OF_COS
)) {
433 BNX2X_ERR("illegal num of cos= %x", ets
->num_of_cos
);
437 /* valid COS entries */
438 if (ets
->num_of_cos
== 1) /* no ETS */
442 if (((BNX2X_DCBX_COS_NOT_STRICT
== ets
->cos_params
[0].strict
) &&
443 (DCBX_INVALID_COS_BW
== ets
->cos_params
[0].bw_tbl
)) ||
444 ((BNX2X_DCBX_COS_NOT_STRICT
== ets
->cos_params
[1].strict
) &&
445 (DCBX_INVALID_COS_BW
== ets
->cos_params
[1].bw_tbl
))) {
446 BNX2X_ERR("all COS should have at least bw_limit or strict"
447 "ets->cos_params[0].strict= %x"
448 "ets->cos_params[0].bw_tbl= %x"
449 "ets->cos_params[1].strict= %x"
450 "ets->cos_params[1].bw_tbl= %x",
451 ets
->cos_params
[0].strict
,
452 ets
->cos_params
[0].bw_tbl
,
453 ets
->cos_params
[1].strict
,
454 ets
->cos_params
[1].bw_tbl
);
457 /* If we join a group and there is bw_tbl and strict then bw rules */
458 if ((DCBX_INVALID_COS_BW
!= ets
->cos_params
[0].bw_tbl
) &&
459 (DCBX_INVALID_COS_BW
!= ets
->cos_params
[1].bw_tbl
)) {
460 u32 bw_tbl_0
= ets
->cos_params
[0].bw_tbl
;
461 u32 bw_tbl_1
= ets
->cos_params
[1].bw_tbl
;
462 /* Do not allow 0-100 configuration
463 * since PBF does not support it
469 } else if (bw_tbl_1
== 0) {
474 bnx2x_ets_bw_limit(&bp
->link_params
, bw_tbl_0
, bw_tbl_1
);
476 if (ets
->cos_params
[0].strict
== BNX2X_DCBX_COS_HIGH_STRICT
)
477 status
= bnx2x_ets_strict(&bp
->link_params
, 0);
478 else if (ets
->cos_params
[1].strict
479 == BNX2X_DCBX_COS_HIGH_STRICT
)
480 status
= bnx2x_ets_strict(&bp
->link_params
, 1);
483 BNX2X_ERR("update_ets_params failed\n");
488 static int bnx2x_dcbx_read_shmem_remote_mib(struct bnx2x
*bp
)
490 struct lldp_remote_mib remote_mib
= {0};
491 u32 dcbx_remote_mib_offset
= SHMEM2_RD(bp
, dcbx_remote_mib_offset
);
494 DP(NETIF_MSG_LINK
, "dcbx_remote_mib_offset 0x%x\n",
495 dcbx_remote_mib_offset
);
497 if (SHMEM_DCBX_REMOTE_MIB_NONE
== dcbx_remote_mib_offset
) {
498 BNX2X_ERR("FW doesn't support dcbx_remote_mib_offset\n");
502 rc
= bnx2x_dcbx_read_mib(bp
, (u32
*)&remote_mib
, dcbx_remote_mib_offset
,
503 DCBX_READ_REMOTE_MIB
);
506 BNX2X_ERR("Faild to read remote mib from FW\n");
510 /* save features and flags */
511 bp
->dcbx_remote_feat
= remote_mib
.features
;
512 bp
->dcbx_remote_flags
= remote_mib
.flags
;
517 static int bnx2x_dcbx_read_shmem_neg_results(struct bnx2x
*bp
)
519 struct lldp_local_mib local_mib
= {0};
520 u32 dcbx_neg_res_offset
= SHMEM2_RD(bp
, dcbx_neg_res_offset
);
523 DP(NETIF_MSG_LINK
, "dcbx_neg_res_offset 0x%x\n", dcbx_neg_res_offset
);
525 if (SHMEM_DCBX_NEG_RES_NONE
== dcbx_neg_res_offset
) {
526 BNX2X_ERR("FW doesn't support dcbx_neg_res_offset\n");
530 rc
= bnx2x_dcbx_read_mib(bp
, (u32
*)&local_mib
, dcbx_neg_res_offset
,
531 DCBX_READ_LOCAL_MIB
);
534 BNX2X_ERR("Faild to read local mib from FW\n");
538 /* save features and error */
539 bp
->dcbx_local_feat
= local_mib
.features
;
540 bp
->dcbx_error
= local_mib
.error
;
547 u8
bnx2x_dcbx_dcbnl_app_up(struct dcbx_app_priority_entry
*ent
)
551 /* Choose the highest priority */
552 for (pri
= MAX_PFC_PRIORITIES
- 1; pri
> 0; pri
--)
553 if (ent
->pri_bitmap
& (1 << pri
))
559 u8
bnx2x_dcbx_dcbnl_app_idtype(struct dcbx_app_priority_entry
*ent
)
561 return ((ent
->appBitfield
& DCBX_APP_ENTRY_SF_MASK
) ==
562 DCBX_APP_SF_PORT
) ? DCB_APP_IDTYPE_PORTNUM
:
563 DCB_APP_IDTYPE_ETHTYPE
;
566 int bnx2x_dcbnl_update_applist(struct bnx2x
*bp
, bool delall
)
570 for (i
= 0; i
< DCBX_MAX_APP_PROTOCOL
&& err
== 0; i
++) {
571 struct dcbx_app_priority_entry
*ent
=
572 &bp
->dcbx_local_feat
.app
.app_pri_tbl
[i
];
574 if (ent
->appBitfield
& DCBX_APP_ENTRY_VALID
) {
575 u8 up
= bnx2x_dcbx_dcbnl_app_up(ent
);
577 /* avoid invalid user-priority */
580 app
.selector
= bnx2x_dcbx_dcbnl_app_idtype(ent
);
581 app
.protocol
= ent
->app_id
;
582 app
.priority
= delall
? 0 : up
;
583 err
= dcb_setapp(bp
->dev
, &app
);
591 static inline void bnx2x_update_drv_flags(struct bnx2x
*bp
, u32 flags
, u32 set
)
593 if (SHMEM2_HAS(bp
, drv_flags
)) {
595 bnx2x_acquire_hw_lock(bp
, HW_LOCK_DRV_FLAGS
);
596 drv_flags
= SHMEM2_RD(bp
, drv_flags
);
599 SET_FLAGS(drv_flags
, flags
);
601 RESET_FLAGS(drv_flags
, flags
);
603 SHMEM2_WR(bp
, drv_flags
, drv_flags
);
604 DP(NETIF_MSG_HW
, "drv_flags 0x%08x\n", drv_flags
);
605 bnx2x_release_hw_lock(bp
, HW_LOCK_DRV_FLAGS
);
609 void bnx2x_dcbx_set_params(struct bnx2x
*bp
, u32 state
)
612 case BNX2X_DCBX_STATE_NEG_RECEIVED
:
614 DP(NETIF_MSG_LINK
, "BNX2X_DCBX_STATE_NEG_RECEIVED\n");
617 * Delete app tlvs from dcbnl before reading new
618 * negotiation results
620 bnx2x_dcbnl_update_applist(bp
, true);
622 /* Read rmeote mib if dcbx is in the FW */
623 if (bnx2x_dcbx_read_shmem_remote_mib(bp
))
626 /* Read neg results if dcbx is in the FW */
627 if (bnx2x_dcbx_read_shmem_neg_results(bp
))
630 bnx2x_dump_dcbx_drv_param(bp
, &bp
->dcbx_local_feat
,
633 bnx2x_get_dcbx_drv_param(bp
, &bp
->dcbx_local_feat
,
636 /* mark DCBX result for PMF migration */
637 bnx2x_update_drv_flags(bp
, DRV_FLAGS_DCB_CONFIGURED
, 1);
640 * Add new app tlvs to dcbnl
642 bnx2x_dcbnl_update_applist(bp
, false);
644 bnx2x_dcbx_stop_hw_tx(bp
);
648 case BNX2X_DCBX_STATE_TX_PAUSED
:
649 DP(NETIF_MSG_LINK
, "BNX2X_DCBX_STATE_TX_PAUSED\n");
650 bnx2x_pfc_set_pfc(bp
);
652 bnx2x_dcbx_update_ets_params(bp
);
653 bnx2x_dcbx_resume_hw_tx(bp
);
655 case BNX2X_DCBX_STATE_TX_RELEASED
:
656 DP(NETIF_MSG_LINK
, "BNX2X_DCBX_STATE_TX_RELEASED\n");
657 bnx2x_fw_command(bp
, DRV_MSG_CODE_DCBX_PMF_DRV_OK
, 0);
660 BNX2X_ERR("Unknown DCBX_STATE\n");
665 #define LLDP_STATS_OFFSET(bp) (BP_PORT(bp)*\
666 sizeof(struct lldp_dcbx_stat))
668 /* calculate struct offset in array according to chip information */
669 #define LLDP_PARAMS_OFFSET(bp) (BP_PORT(bp)*sizeof(struct lldp_params))
671 #define LLDP_ADMIN_MIB_OFFSET(bp) (PORT_MAX*sizeof(struct lldp_params) + \
672 BP_PORT(bp)*sizeof(struct lldp_admin_mib))
674 static void bnx2x_dcbx_lldp_updated_params(struct bnx2x
*bp
,
675 u32 dcbx_lldp_params_offset
)
677 struct lldp_params lldp_params
= {0};
678 u32 i
= 0, *buff
= NULL
;
679 u32 offset
= dcbx_lldp_params_offset
+ LLDP_PARAMS_OFFSET(bp
);
681 DP(NETIF_MSG_LINK
, "lldp_offset 0x%x\n", offset
);
683 if ((bp
->lldp_config_params
.overwrite_settings
==
684 BNX2X_DCBX_OVERWRITE_SETTINGS_ENABLE
)) {
685 /* Read the data first */
686 buff
= (u32
*)&lldp_params
;
687 for (i
= 0; i
< sizeof(struct lldp_params
); i
+= 4, buff
++)
688 *buff
= REG_RD(bp
, (offset
+ i
));
690 lldp_params
.msg_tx_hold
=
691 (u8
)bp
->lldp_config_params
.msg_tx_hold
;
692 lldp_params
.msg_fast_tx_interval
=
693 (u8
)bp
->lldp_config_params
.msg_fast_tx
;
694 lldp_params
.tx_crd_max
=
695 (u8
)bp
->lldp_config_params
.tx_credit_max
;
696 lldp_params
.msg_tx_interval
=
697 (u8
)bp
->lldp_config_params
.msg_tx_interval
;
698 lldp_params
.tx_fast
=
699 (u8
)bp
->lldp_config_params
.tx_fast
;
702 buff
= (u32
*)&lldp_params
;
703 for (i
= 0; i
< sizeof(struct lldp_params
); i
+= 4, buff
++)
704 REG_WR(bp
, (offset
+ i
) , *buff
);
707 } else if (BNX2X_DCBX_OVERWRITE_SETTINGS_ENABLE
==
708 bp
->lldp_config_params
.overwrite_settings
)
709 bp
->lldp_config_params
.overwrite_settings
=
710 BNX2X_DCBX_OVERWRITE_SETTINGS_INVALID
;
713 static void bnx2x_dcbx_admin_mib_updated_params(struct bnx2x
*bp
,
714 u32 dcbx_lldp_params_offset
)
716 struct lldp_admin_mib admin_mib
;
717 u32 i
, other_traf_type
= PREDEFINED_APP_IDX_MAX
, traf_type
= 0;
719 u32 offset
= dcbx_lldp_params_offset
+ LLDP_ADMIN_MIB_OFFSET(bp
);
722 struct dcbx_features
*af
= &admin_mib
.features
;
723 struct bnx2x_config_dcbx_params
*dp
= &bp
->dcbx_config_params
;
725 memset(&admin_mib
, 0, sizeof(struct lldp_admin_mib
));
726 buff
= (u32
*)&admin_mib
;
727 /* Read the data first */
728 for (i
= 0; i
< sizeof(struct lldp_admin_mib
); i
+= 4, buff
++)
729 *buff
= REG_RD(bp
, (offset
+ i
));
731 if (bp
->dcbx_enabled
== BNX2X_DCBX_ENABLED_ON_NEG_ON
)
732 SET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_DCBX_ENABLED
);
734 RESET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_DCBX_ENABLED
);
736 if ((BNX2X_DCBX_OVERWRITE_SETTINGS_ENABLE
==
737 dp
->overwrite_settings
)) {
738 RESET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_CEE_VERSION_MASK
);
739 admin_mib
.ver_cfg_flags
|=
740 (dp
->admin_dcbx_version
<< DCBX_CEE_VERSION_SHIFT
) &
741 DCBX_CEE_VERSION_MASK
;
743 af
->ets
.enabled
= (u8
)dp
->admin_ets_enable
;
745 af
->pfc
.enabled
= (u8
)dp
->admin_pfc_enable
;
747 /* FOR IEEE dp->admin_tc_supported_tx_enable */
748 if (dp
->admin_ets_configuration_tx_enable
)
749 SET_FLAGS(admin_mib
.ver_cfg_flags
,
750 DCBX_ETS_CONFIG_TX_ENABLED
);
752 RESET_FLAGS(admin_mib
.ver_cfg_flags
,
753 DCBX_ETS_CONFIG_TX_ENABLED
);
754 /* For IEEE admin_ets_recommendation_tx_enable */
755 if (dp
->admin_pfc_tx_enable
)
756 SET_FLAGS(admin_mib
.ver_cfg_flags
,
757 DCBX_PFC_CONFIG_TX_ENABLED
);
759 RESET_FLAGS(admin_mib
.ver_cfg_flags
,
760 DCBX_PFC_CONFIG_TX_ENABLED
);
762 if (dp
->admin_application_priority_tx_enable
)
763 SET_FLAGS(admin_mib
.ver_cfg_flags
,
764 DCBX_APP_CONFIG_TX_ENABLED
);
766 RESET_FLAGS(admin_mib
.ver_cfg_flags
,
767 DCBX_APP_CONFIG_TX_ENABLED
);
769 if (dp
->admin_ets_willing
)
770 SET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_ETS_WILLING
);
772 RESET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_ETS_WILLING
);
773 /* For IEEE admin_ets_reco_valid */
774 if (dp
->admin_pfc_willing
)
775 SET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_PFC_WILLING
);
777 RESET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_PFC_WILLING
);
779 if (dp
->admin_app_priority_willing
)
780 SET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_APP_WILLING
);
782 RESET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_APP_WILLING
);
784 for (i
= 0 ; i
< DCBX_MAX_NUM_PG_BW_ENTRIES
; i
++) {
785 DCBX_PG_BW_SET(af
->ets
.pg_bw_tbl
, i
,
786 (u8
)dp
->admin_configuration_bw_precentage
[i
]);
788 DP(NETIF_MSG_LINK
, "pg_bw_tbl[%d] = %02x\n",
789 i
, DCBX_PG_BW_GET(af
->ets
.pg_bw_tbl
, i
));
792 for (i
= 0; i
< DCBX_MAX_NUM_PRI_PG_ENTRIES
; i
++) {
793 DCBX_PRI_PG_SET(af
->ets
.pri_pg_tbl
, i
,
794 (u8
)dp
->admin_configuration_ets_pg
[i
]);
796 DP(NETIF_MSG_LINK
, "pri_pg_tbl[%d] = %02x\n",
797 i
, DCBX_PRI_PG_GET(af
->ets
.pri_pg_tbl
, i
));
800 /*For IEEE admin_recommendation_bw_precentage
801 *For IEEE admin_recommendation_ets_pg */
802 af
->pfc
.pri_en_bitmap
= (u8
)dp
->admin_pfc_bitmap
;
803 for (i
= 0; i
< 4; i
++) {
804 if (dp
->admin_priority_app_table
[i
].valid
) {
805 struct bnx2x_admin_priority_app_table
*table
=
806 dp
->admin_priority_app_table
;
807 if ((ETH_TYPE_FCOE
== table
[i
].app_id
) &&
808 (TRAFFIC_TYPE_ETH
== table
[i
].traffic_type
))
809 traf_type
= FCOE_APP_IDX
;
810 else if ((TCP_PORT_ISCSI
== table
[i
].app_id
) &&
811 (TRAFFIC_TYPE_PORT
== table
[i
].traffic_type
))
812 traf_type
= ISCSI_APP_IDX
;
814 traf_type
= other_traf_type
++;
816 af
->app
.app_pri_tbl
[traf_type
].app_id
=
819 af
->app
.app_pri_tbl
[traf_type
].pri_bitmap
=
820 (u8
)(1 << table
[i
].priority
);
822 af
->app
.app_pri_tbl
[traf_type
].appBitfield
=
823 (DCBX_APP_ENTRY_VALID
);
825 af
->app
.app_pri_tbl
[traf_type
].appBitfield
|=
826 (TRAFFIC_TYPE_ETH
== table
[i
].traffic_type
) ?
827 DCBX_APP_SF_ETH_TYPE
: DCBX_APP_SF_PORT
;
831 af
->app
.default_pri
= (u8
)dp
->admin_default_priority
;
833 } else if (BNX2X_DCBX_OVERWRITE_SETTINGS_ENABLE
==
834 dp
->overwrite_settings
)
835 dp
->overwrite_settings
= BNX2X_DCBX_OVERWRITE_SETTINGS_INVALID
;
837 /* Write the data. */
838 buff
= (u32
*)&admin_mib
;
839 for (i
= 0; i
< sizeof(struct lldp_admin_mib
); i
+= 4, buff
++)
840 REG_WR(bp
, (offset
+ i
), *buff
);
843 void bnx2x_dcbx_set_state(struct bnx2x
*bp
, bool dcb_on
, u32 dcbx_enabled
)
845 if (!CHIP_IS_E1x(bp
) && !CHIP_MODE_IS_4_PORT(bp
)) {
846 bp
->dcb_state
= dcb_on
;
847 bp
->dcbx_enabled
= dcbx_enabled
;
849 bp
->dcb_state
= false;
850 bp
->dcbx_enabled
= BNX2X_DCBX_ENABLED_INVALID
;
852 DP(NETIF_MSG_LINK
, "DCB state [%s:%s]\n",
853 dcb_on
? "ON" : "OFF",
854 dcbx_enabled
== BNX2X_DCBX_ENABLED_OFF
? "user-mode" :
855 dcbx_enabled
== BNX2X_DCBX_ENABLED_ON_NEG_OFF
? "on-chip static" :
856 dcbx_enabled
== BNX2X_DCBX_ENABLED_ON_NEG_ON
?
857 "on-chip with negotiation" : "invalid");
860 void bnx2x_dcbx_init_params(struct bnx2x
*bp
)
862 bp
->dcbx_config_params
.admin_dcbx_version
= 0x0; /* 0 - CEE; 1 - IEEE */
863 bp
->dcbx_config_params
.admin_ets_willing
= 1;
864 bp
->dcbx_config_params
.admin_pfc_willing
= 1;
865 bp
->dcbx_config_params
.overwrite_settings
= 1;
866 bp
->dcbx_config_params
.admin_ets_enable
= 1;
867 bp
->dcbx_config_params
.admin_pfc_enable
= 1;
868 bp
->dcbx_config_params
.admin_tc_supported_tx_enable
= 1;
869 bp
->dcbx_config_params
.admin_ets_configuration_tx_enable
= 1;
870 bp
->dcbx_config_params
.admin_pfc_tx_enable
= 1;
871 bp
->dcbx_config_params
.admin_application_priority_tx_enable
= 1;
872 bp
->dcbx_config_params
.admin_ets_reco_valid
= 1;
873 bp
->dcbx_config_params
.admin_app_priority_willing
= 1;
874 bp
->dcbx_config_params
.admin_configuration_bw_precentage
[0] = 00;
875 bp
->dcbx_config_params
.admin_configuration_bw_precentage
[1] = 50;
876 bp
->dcbx_config_params
.admin_configuration_bw_precentage
[2] = 50;
877 bp
->dcbx_config_params
.admin_configuration_bw_precentage
[3] = 0;
878 bp
->dcbx_config_params
.admin_configuration_bw_precentage
[4] = 0;
879 bp
->dcbx_config_params
.admin_configuration_bw_precentage
[5] = 0;
880 bp
->dcbx_config_params
.admin_configuration_bw_precentage
[6] = 0;
881 bp
->dcbx_config_params
.admin_configuration_bw_precentage
[7] = 0;
882 bp
->dcbx_config_params
.admin_configuration_ets_pg
[0] = 1;
883 bp
->dcbx_config_params
.admin_configuration_ets_pg
[1] = 0;
884 bp
->dcbx_config_params
.admin_configuration_ets_pg
[2] = 0;
885 bp
->dcbx_config_params
.admin_configuration_ets_pg
[3] = 2;
886 bp
->dcbx_config_params
.admin_configuration_ets_pg
[4] = 0;
887 bp
->dcbx_config_params
.admin_configuration_ets_pg
[5] = 0;
888 bp
->dcbx_config_params
.admin_configuration_ets_pg
[6] = 0;
889 bp
->dcbx_config_params
.admin_configuration_ets_pg
[7] = 0;
890 bp
->dcbx_config_params
.admin_recommendation_bw_precentage
[0] = 0;
891 bp
->dcbx_config_params
.admin_recommendation_bw_precentage
[1] = 1;
892 bp
->dcbx_config_params
.admin_recommendation_bw_precentage
[2] = 2;
893 bp
->dcbx_config_params
.admin_recommendation_bw_precentage
[3] = 0;
894 bp
->dcbx_config_params
.admin_recommendation_bw_precentage
[4] = 7;
895 bp
->dcbx_config_params
.admin_recommendation_bw_precentage
[5] = 5;
896 bp
->dcbx_config_params
.admin_recommendation_bw_precentage
[6] = 6;
897 bp
->dcbx_config_params
.admin_recommendation_bw_precentage
[7] = 7;
898 bp
->dcbx_config_params
.admin_recommendation_ets_pg
[0] = 0;
899 bp
->dcbx_config_params
.admin_recommendation_ets_pg
[1] = 1;
900 bp
->dcbx_config_params
.admin_recommendation_ets_pg
[2] = 2;
901 bp
->dcbx_config_params
.admin_recommendation_ets_pg
[3] = 3;
902 bp
->dcbx_config_params
.admin_recommendation_ets_pg
[4] = 4;
903 bp
->dcbx_config_params
.admin_recommendation_ets_pg
[5] = 5;
904 bp
->dcbx_config_params
.admin_recommendation_ets_pg
[6] = 6;
905 bp
->dcbx_config_params
.admin_recommendation_ets_pg
[7] = 7;
906 bp
->dcbx_config_params
.admin_pfc_bitmap
= 0x8; /* FCoE(3) enable */
907 bp
->dcbx_config_params
.admin_priority_app_table
[0].valid
= 1;
908 bp
->dcbx_config_params
.admin_priority_app_table
[1].valid
= 1;
909 bp
->dcbx_config_params
.admin_priority_app_table
[2].valid
= 0;
910 bp
->dcbx_config_params
.admin_priority_app_table
[3].valid
= 0;
911 bp
->dcbx_config_params
.admin_priority_app_table
[0].priority
= 3;
912 bp
->dcbx_config_params
.admin_priority_app_table
[1].priority
= 0;
913 bp
->dcbx_config_params
.admin_priority_app_table
[2].priority
= 0;
914 bp
->dcbx_config_params
.admin_priority_app_table
[3].priority
= 0;
915 bp
->dcbx_config_params
.admin_priority_app_table
[0].traffic_type
= 0;
916 bp
->dcbx_config_params
.admin_priority_app_table
[1].traffic_type
= 1;
917 bp
->dcbx_config_params
.admin_priority_app_table
[2].traffic_type
= 0;
918 bp
->dcbx_config_params
.admin_priority_app_table
[3].traffic_type
= 0;
919 bp
->dcbx_config_params
.admin_priority_app_table
[0].app_id
= 0x8906;
920 bp
->dcbx_config_params
.admin_priority_app_table
[1].app_id
= 3260;
921 bp
->dcbx_config_params
.admin_priority_app_table
[2].app_id
= 0;
922 bp
->dcbx_config_params
.admin_priority_app_table
[3].app_id
= 0;
923 bp
->dcbx_config_params
.admin_default_priority
=
924 bp
->dcbx_config_params
.admin_priority_app_table
[1].priority
;
927 void bnx2x_dcbx_init(struct bnx2x
*bp
)
929 u32 dcbx_lldp_params_offset
= SHMEM_LLDP_DCBX_PARAMS_NONE
;
931 if (bp
->dcbx_enabled
<= 0)
935 * chip of good for dcbx version,
937 * the function is pmf
938 * shmem2 contains DCBX support fields
940 DP(NETIF_MSG_LINK
, "dcb_state %d bp->port.pmf %d\n",
941 bp
->dcb_state
, bp
->port
.pmf
);
943 if (bp
->dcb_state
== BNX2X_DCB_STATE_ON
&& bp
->port
.pmf
&&
944 SHMEM2_HAS(bp
, dcbx_lldp_params_offset
)) {
945 dcbx_lldp_params_offset
=
946 SHMEM2_RD(bp
, dcbx_lldp_params_offset
);
948 DP(NETIF_MSG_LINK
, "dcbx_lldp_params_offset 0x%x\n",
949 dcbx_lldp_params_offset
);
951 bnx2x_update_drv_flags(bp
, DRV_FLAGS_DCB_CONFIGURED
, 0);
953 if (SHMEM_LLDP_DCBX_PARAMS_NONE
!= dcbx_lldp_params_offset
) {
954 bnx2x_dcbx_lldp_updated_params(bp
,
955 dcbx_lldp_params_offset
);
957 bnx2x_dcbx_admin_mib_updated_params(bp
,
958 dcbx_lldp_params_offset
);
960 /* Let HW start negotiation */
962 DRV_MSG_CODE_DCBX_ADMIN_PMF_MSG
, 0);
967 bnx2x_dcbx_print_cos_params(struct bnx2x
*bp
,
968 struct flow_control_configuration
*pfc_fw_cfg
)
974 "pfc_fw_cfg->dcb_version %x\n", pfc_fw_cfg
->dcb_version
);
976 "pdev->params.dcbx_port_params.pfc."
977 "priority_non_pauseable_mask %x\n",
978 bp
->dcbx_port_params
.pfc
.priority_non_pauseable_mask
);
980 for (cos
= 0 ; cos
< bp
->dcbx_port_params
.ets
.num_of_cos
; cos
++) {
981 DP(NETIF_MSG_LINK
, "pdev->params.dcbx_port_params.ets."
982 "cos_params[%d].pri_bitmask %x\n", cos
,
983 bp
->dcbx_port_params
.ets
.cos_params
[cos
].pri_bitmask
);
985 DP(NETIF_MSG_LINK
, "pdev->params.dcbx_port_params.ets."
986 "cos_params[%d].bw_tbl %x\n", cos
,
987 bp
->dcbx_port_params
.ets
.cos_params
[cos
].bw_tbl
);
989 DP(NETIF_MSG_LINK
, "pdev->params.dcbx_port_params.ets."
990 "cos_params[%d].strict %x\n", cos
,
991 bp
->dcbx_port_params
.ets
.cos_params
[cos
].strict
);
993 DP(NETIF_MSG_LINK
, "pdev->params.dcbx_port_params.ets."
994 "cos_params[%d].pauseable %x\n", cos
,
995 bp
->dcbx_port_params
.ets
.cos_params
[cos
].pauseable
);
998 for (pri
= 0; pri
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
; pri
++) {
1000 "pfc_fw_cfg->traffic_type_to_priority_cos[%d]."
1001 "priority %x\n", pri
,
1002 pfc_fw_cfg
->traffic_type_to_priority_cos
[pri
].priority
);
1005 "pfc_fw_cfg->traffic_type_to_priority_cos[%d].cos %x\n",
1006 pri
, pfc_fw_cfg
->traffic_type_to_priority_cos
[pri
].cos
);
1010 /* fills help_data according to pg_info */
1011 static void bnx2x_dcbx_get_num_pg_traf_type(struct bnx2x
*bp
,
1012 u32
*pg_pri_orginal_spread
,
1013 struct pg_help_data
*help_data
)
1015 bool pg_found
= false;
1016 u32 i
, traf_type
, add_traf_type
, add_pg
;
1017 u32
*ttp
= bp
->dcbx_port_params
.app
.traffic_type_priority
;
1018 struct pg_entry_help_data
*data
= help_data
->data
; /*shotcut*/
1020 /* Set to invalid */
1021 for (i
= 0; i
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
; i
++)
1022 data
[i
].pg
= DCBX_ILLEGAL_PG
;
1024 for (add_traf_type
= 0;
1025 add_traf_type
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
; add_traf_type
++) {
1027 if (ttp
[add_traf_type
] < MAX_PFC_PRIORITIES
) {
1028 add_pg
= (u8
)pg_pri_orginal_spread
[ttp
[add_traf_type
]];
1030 traf_type
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
;
1032 if (data
[traf_type
].pg
== add_pg
) {
1033 if (!(data
[traf_type
].pg_priority
&
1034 (1 << ttp
[add_traf_type
])))
1037 data
[traf_type
].pg_priority
|=
1038 (1 << ttp
[add_traf_type
]);
1043 if (false == pg_found
) {
1044 data
[help_data
->num_of_pg
].pg
= add_pg
;
1045 data
[help_data
->num_of_pg
].pg_priority
=
1046 (1 << ttp
[add_traf_type
]);
1047 data
[help_data
->num_of_pg
].num_of_dif_pri
= 1;
1048 help_data
->num_of_pg
++;
1052 "add_traf_type %d pg_found %s num_of_pg %d\n",
1053 add_traf_type
, (false == pg_found
) ? "NO" : "YES",
1054 help_data
->num_of_pg
);
1058 static void bnx2x_dcbx_ets_disabled_entry_data(struct bnx2x
*bp
,
1059 struct cos_help_data
*cos_data
,
1062 /* Only one priority than only one COS */
1063 cos_data
->data
[0].pausable
=
1064 IS_DCBX_PFC_PRI_ONLY_PAUSE(bp
, pri_join_mask
);
1065 cos_data
->data
[0].pri_join_mask
= pri_join_mask
;
1066 cos_data
->data
[0].cos_bw
= 100;
1067 cos_data
->num_of_cos
= 1;
1070 static inline void bnx2x_dcbx_add_to_cos_bw(struct bnx2x
*bp
,
1071 struct cos_entry_help_data
*data
,
1074 if (data
->cos_bw
== DCBX_INVALID_COS_BW
)
1075 data
->cos_bw
= pg_bw
;
1077 data
->cos_bw
+= pg_bw
;
1080 static void bnx2x_dcbx_separate_pauseable_from_non(struct bnx2x
*bp
,
1081 struct cos_help_data
*cos_data
,
1082 u32
*pg_pri_orginal_spread
,
1083 struct dcbx_ets_feature
*ets
)
1089 u8 num_of_pri
= LLFC_DRIVER_TRAFFIC_TYPE_MAX
;
1091 cos_data
->data
[0].pausable
= true;
1092 cos_data
->data
[1].pausable
= false;
1093 cos_data
->data
[0].pri_join_mask
= cos_data
->data
[1].pri_join_mask
= 0;
1095 for (i
= 0 ; i
< num_of_pri
; i
++) {
1096 pri_tested
= 1 << bp
->dcbx_port_params
.
1097 app
.traffic_type_priority
[i
];
1099 if (pri_tested
& DCBX_PFC_PRI_NON_PAUSE_MASK(bp
)) {
1100 cos_data
->data
[1].pri_join_mask
|= pri_tested
;
1103 cos_data
->data
[0].pri_join_mask
|= pri_tested
;
1106 pg_entry
= (u8
)pg_pri_orginal_spread
[bp
->dcbx_port_params
.
1107 app
.traffic_type_priority
[i
]];
1108 /* There can be only one strict pg */
1109 if (pg_entry
< DCBX_MAX_NUM_PG_BW_ENTRIES
)
1110 bnx2x_dcbx_add_to_cos_bw(bp
, &cos_data
->data
[entry
],
1111 DCBX_PG_BW_GET(ets
->pg_bw_tbl
, pg_entry
));
1113 /* If we join a group and one is strict
1114 * than the bw rulls */
1115 cos_data
->data
[entry
].strict
=
1116 BNX2X_DCBX_COS_HIGH_STRICT
;
1118 if ((0 == cos_data
->data
[0].pri_join_mask
) &&
1119 (0 == cos_data
->data
[1].pri_join_mask
))
1120 BNX2X_ERR("dcbx error: Both groups must have priorities\n");
1125 #define POWER_OF_2(x) ((0 != x) && (0 == (x & (x-1))))
1128 static void bxn2x_dcbx_single_pg_to_cos_params(struct bnx2x
*bp
,
1129 struct pg_help_data
*pg_help_data
,
1130 struct cos_help_data
*cos_data
,
1136 u32 pri_mask_without_pri
= 0;
1137 u32
*ttp
= bp
->dcbx_port_params
.app
.traffic_type_priority
;
1139 if (num_of_dif_pri
== 1) {
1140 bnx2x_dcbx_ets_disabled_entry_data(bp
, cos_data
, pri_join_mask
);
1143 /* single priority group */
1144 if (pg_help_data
->data
[0].pg
< DCBX_MAX_NUM_PG_BW_ENTRIES
) {
1145 /* If there are both pauseable and non-pauseable priorities,
1146 * the pauseable priorities go to the first queue and
1147 * the non-pauseable priorities go to the second queue.
1149 if (IS_DCBX_PFC_PRI_MIX_PAUSE(bp
, pri_join_mask
)) {
1151 cos_data
->data
[0].pausable
= true;
1153 cos_data
->data
[1].pausable
= false;
1155 if (2 == num_of_dif_pri
) {
1156 cos_data
->data
[0].cos_bw
= 50;
1157 cos_data
->data
[1].cos_bw
= 50;
1160 if (3 == num_of_dif_pri
) {
1161 if (POWER_OF_2(DCBX_PFC_PRI_GET_PAUSE(bp
,
1163 cos_data
->data
[0].cos_bw
= 33;
1164 cos_data
->data
[1].cos_bw
= 67;
1166 cos_data
->data
[0].cos_bw
= 67;
1167 cos_data
->data
[1].cos_bw
= 33;
1171 } else if (IS_DCBX_PFC_PRI_ONLY_PAUSE(bp
, pri_join_mask
)) {
1172 /* If there are only pauseable priorities,
1173 * then one/two priorities go to the first queue
1174 * and one priority goes to the second queue.
1176 if (2 == num_of_dif_pri
) {
1177 cos_data
->data
[0].cos_bw
= 50;
1178 cos_data
->data
[1].cos_bw
= 50;
1180 cos_data
->data
[0].cos_bw
= 67;
1181 cos_data
->data
[1].cos_bw
= 33;
1183 cos_data
->data
[1].pausable
= true;
1184 cos_data
->data
[0].pausable
= true;
1185 /* All priorities except FCOE */
1186 cos_data
->data
[0].pri_join_mask
= (pri_join_mask
&
1187 ((u8
)~(1 << ttp
[LLFC_TRAFFIC_TYPE_FCOE
])));
1188 /* Only FCOE priority.*/
1189 cos_data
->data
[1].pri_join_mask
=
1190 (1 << ttp
[LLFC_TRAFFIC_TYPE_FCOE
]);
1192 /* If there are only non-pauseable priorities,
1193 * they will all go to the same queue.
1195 bnx2x_dcbx_ets_disabled_entry_data(bp
,
1196 cos_data
, pri_join_mask
);
1198 /* priority group which is not BW limited (PG#15):*/
1199 if (IS_DCBX_PFC_PRI_MIX_PAUSE(bp
, pri_join_mask
)) {
1200 /* If there are both pauseable and non-pauseable
1201 * priorities, the pauseable priorities go to the first
1202 * queue and the non-pauseable priorities
1203 * go to the second queue.
1205 if (DCBX_PFC_PRI_GET_PAUSE(bp
, pri_join_mask
) >
1206 DCBX_PFC_PRI_GET_NON_PAUSE(bp
, pri_join_mask
)) {
1207 cos_data
->data
[0].strict
=
1208 BNX2X_DCBX_COS_HIGH_STRICT
;
1209 cos_data
->data
[1].strict
=
1210 BNX2X_DCBX_COS_LOW_STRICT
;
1212 cos_data
->data
[0].strict
=
1213 BNX2X_DCBX_COS_LOW_STRICT
;
1214 cos_data
->data
[1].strict
=
1215 BNX2X_DCBX_COS_HIGH_STRICT
;
1218 cos_data
->data
[0].pausable
= true;
1219 /* Non pause-able.*/
1220 cos_data
->data
[1].pausable
= false;
1222 /* If there are only pauseable priorities or
1223 * only non-pauseable,* the lower priorities go
1224 * to the first queue and the higherpriorities go
1225 * to the second queue.
1227 cos_data
->data
[0].pausable
=
1228 cos_data
->data
[1].pausable
=
1229 IS_DCBX_PFC_PRI_ONLY_PAUSE(bp
, pri_join_mask
);
1231 for (i
= 0 ; i
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
; i
++) {
1232 pri_tested
= 1 << bp
->dcbx_port_params
.
1233 app
.traffic_type_priority
[i
];
1234 /* Remove priority tested */
1235 pri_mask_without_pri
=
1236 (pri_join_mask
& ((u8
)(~pri_tested
)));
1237 if (pri_mask_without_pri
< pri_tested
)
1241 if (i
== LLFC_DRIVER_TRAFFIC_TYPE_MAX
)
1242 BNX2X_ERR("Invalid value for pri_join_mask -"
1243 " could not find a priority\n");
1245 cos_data
->data
[0].pri_join_mask
= pri_mask_without_pri
;
1246 cos_data
->data
[1].pri_join_mask
= pri_tested
;
1247 /* Both queues are strict priority,
1248 * and that with the highest priority
1249 * gets the highest strict priority in the arbiter.
1251 cos_data
->data
[0].strict
= BNX2X_DCBX_COS_LOW_STRICT
;
1252 cos_data
->data
[1].strict
= BNX2X_DCBX_COS_HIGH_STRICT
;
1257 static void bnx2x_dcbx_two_pg_to_cos_params(
1259 struct pg_help_data
*pg_help_data
,
1260 struct dcbx_ets_feature
*ets
,
1261 struct cos_help_data
*cos_data
,
1262 u32
*pg_pri_orginal_spread
,
1267 u8 pg
[E2_NUM_OF_COS
] = {0};
1269 /* If there are both pauseable and non-pauseable priorities,
1270 * the pauseable priorities go to the first queue and
1271 * the non-pauseable priorities go to the second queue.
1273 if (IS_DCBX_PFC_PRI_MIX_PAUSE(bp
, pri_join_mask
)) {
1274 if (IS_DCBX_PFC_PRI_MIX_PAUSE(bp
,
1275 pg_help_data
->data
[0].pg_priority
) ||
1276 IS_DCBX_PFC_PRI_MIX_PAUSE(bp
,
1277 pg_help_data
->data
[1].pg_priority
)) {
1278 /* If one PG contains both pauseable and
1279 * non-pauseable priorities then ETS is disabled.
1281 bnx2x_dcbx_separate_pauseable_from_non(bp
, cos_data
,
1282 pg_pri_orginal_spread
, ets
);
1283 bp
->dcbx_port_params
.ets
.enabled
= false;
1288 cos_data
->data
[0].pausable
= true;
1289 /* Non pauseable. */
1290 cos_data
->data
[1].pausable
= false;
1291 if (IS_DCBX_PFC_PRI_ONLY_PAUSE(bp
,
1292 pg_help_data
->data
[0].pg_priority
)) {
1293 /* 0 is pauseable */
1294 cos_data
->data
[0].pri_join_mask
=
1295 pg_help_data
->data
[0].pg_priority
;
1296 pg
[0] = pg_help_data
->data
[0].pg
;
1297 cos_data
->data
[1].pri_join_mask
=
1298 pg_help_data
->data
[1].pg_priority
;
1299 pg
[1] = pg_help_data
->data
[1].pg
;
1300 } else {/* 1 is pauseable */
1301 cos_data
->data
[0].pri_join_mask
=
1302 pg_help_data
->data
[1].pg_priority
;
1303 pg
[0] = pg_help_data
->data
[1].pg
;
1304 cos_data
->data
[1].pri_join_mask
=
1305 pg_help_data
->data
[0].pg_priority
;
1306 pg
[1] = pg_help_data
->data
[0].pg
;
1309 /* If there are only pauseable priorities or
1310 * only non-pauseable, each PG goes to a queue.
1312 cos_data
->data
[0].pausable
= cos_data
->data
[1].pausable
=
1313 IS_DCBX_PFC_PRI_ONLY_PAUSE(bp
, pri_join_mask
);
1314 cos_data
->data
[0].pri_join_mask
=
1315 pg_help_data
->data
[0].pg_priority
;
1316 pg
[0] = pg_help_data
->data
[0].pg
;
1317 cos_data
->data
[1].pri_join_mask
=
1318 pg_help_data
->data
[1].pg_priority
;
1319 pg
[1] = pg_help_data
->data
[1].pg
;
1322 /* There can be only one strict pg */
1323 for (i
= 0 ; i
< E2_NUM_OF_COS
; i
++) {
1324 if (pg
[i
] < DCBX_MAX_NUM_PG_BW_ENTRIES
)
1325 cos_data
->data
[i
].cos_bw
=
1326 DCBX_PG_BW_GET(ets
->pg_bw_tbl
, pg
[i
]);
1328 cos_data
->data
[i
].strict
= BNX2X_DCBX_COS_HIGH_STRICT
;
1332 static void bnx2x_dcbx_three_pg_to_cos_params(
1334 struct pg_help_data
*pg_help_data
,
1335 struct dcbx_ets_feature
*ets
,
1336 struct cos_help_data
*cos_data
,
1337 u32
*pg_pri_orginal_spread
,
1345 bool b_found_strict
= false;
1346 u8 num_of_pri
= LLFC_DRIVER_TRAFFIC_TYPE_MAX
;
1348 cos_data
->data
[0].pri_join_mask
= cos_data
->data
[1].pri_join_mask
= 0;
1349 /* If there are both pauseable and non-pauseable priorities,
1350 * the pauseable priorities go to the first queue and the
1351 * non-pauseable priorities go to the second queue.
1353 if (IS_DCBX_PFC_PRI_MIX_PAUSE(bp
, pri_join_mask
))
1354 bnx2x_dcbx_separate_pauseable_from_non(bp
,
1355 cos_data
, pg_pri_orginal_spread
, ets
);
1357 /* If two BW-limited PG-s were combined to one queue,
1358 * the BW is their sum.
1360 * If there are only pauseable priorities or only non-pauseable,
1361 * and there are both BW-limited and non-BW-limited PG-s,
1362 * the BW-limited PG/s go to one queue and the non-BW-limited
1363 * PG/s go to the second queue.
1365 * If there are only pauseable priorities or only non-pauseable
1366 * and all are BW limited, then two priorities go to the first
1367 * queue and one priority goes to the second queue.
1369 * We will join this two cases:
1370 * if one is BW limited it will go to the secoend queue
1371 * otherwise the last priority will get it
1374 cos_data
->data
[0].pausable
= cos_data
->data
[1].pausable
=
1375 IS_DCBX_PFC_PRI_ONLY_PAUSE(bp
, pri_join_mask
);
1377 for (i
= 0 ; i
< num_of_pri
; i
++) {
1378 pri_tested
= 1 << bp
->dcbx_port_params
.
1379 app
.traffic_type_priority
[i
];
1380 pg_entry
= (u8
)pg_pri_orginal_spread
[bp
->
1381 dcbx_port_params
.app
.traffic_type_priority
[i
]];
1383 if (pg_entry
< DCBX_MAX_NUM_PG_BW_ENTRIES
) {
1386 if (i
== (num_of_pri
-1) &&
1387 false == b_found_strict
)
1388 /* last entry will be handled separately
1389 * If no priority is strict than last
1390 * enty goes to last queue.*/
1392 cos_data
->data
[entry
].pri_join_mask
|=
1394 bnx2x_dcbx_add_to_cos_bw(bp
,
1395 &cos_data
->data
[entry
],
1396 DCBX_PG_BW_GET(ets
->pg_bw_tbl
,
1399 b_found_strict
= true;
1400 cos_data
->data
[1].pri_join_mask
|= pri_tested
;
1401 /* If we join a group and one is strict
1402 * than the bw rulls */
1403 cos_data
->data
[1].strict
=
1404 BNX2X_DCBX_COS_HIGH_STRICT
;
1411 static void bnx2x_dcbx_fill_cos_params(struct bnx2x
*bp
,
1412 struct pg_help_data
*help_data
,
1413 struct dcbx_ets_feature
*ets
,
1414 u32
*pg_pri_orginal_spread
)
1416 struct cos_help_data cos_data
;
1418 u32 pri_join_mask
= 0;
1419 u8 num_of_dif_pri
= 0;
1421 memset(&cos_data
, 0, sizeof(cos_data
));
1422 /* Validate the pg value */
1423 for (i
= 0; i
< help_data
->num_of_pg
; i
++) {
1424 if (DCBX_STRICT_PRIORITY
!= help_data
->data
[i
].pg
&&
1425 DCBX_MAX_NUM_PG_BW_ENTRIES
<= help_data
->data
[i
].pg
)
1426 BNX2X_ERR("Invalid pg[%d] data %x\n", i
,
1427 help_data
->data
[i
].pg
);
1428 pri_join_mask
|= help_data
->data
[i
].pg_priority
;
1429 num_of_dif_pri
+= help_data
->data
[i
].num_of_dif_pri
;
1432 /* default settings */
1433 cos_data
.num_of_cos
= 2;
1434 for (i
= 0; i
< E2_NUM_OF_COS
; i
++) {
1435 cos_data
.data
[i
].pri_join_mask
= pri_join_mask
;
1436 cos_data
.data
[i
].pausable
= false;
1437 cos_data
.data
[i
].strict
= BNX2X_DCBX_COS_NOT_STRICT
;
1438 cos_data
.data
[i
].cos_bw
= DCBX_INVALID_COS_BW
;
1441 switch (help_data
->num_of_pg
) {
1444 bxn2x_dcbx_single_pg_to_cos_params(
1452 bnx2x_dcbx_two_pg_to_cos_params(
1457 pg_pri_orginal_spread
,
1463 bnx2x_dcbx_three_pg_to_cos_params(
1468 pg_pri_orginal_spread
,
1474 BNX2X_ERR("Wrong pg_help_data.num_of_pg\n");
1475 bnx2x_dcbx_ets_disabled_entry_data(bp
,
1476 &cos_data
, pri_join_mask
);
1479 for (i
= 0; i
< cos_data
.num_of_cos
; i
++) {
1480 struct bnx2x_dcbx_cos_params
*params
=
1481 &bp
->dcbx_port_params
.ets
.cos_params
[i
];
1483 params
->pauseable
= cos_data
.data
[i
].pausable
;
1484 params
->strict
= cos_data
.data
[i
].strict
;
1485 params
->bw_tbl
= cos_data
.data
[i
].cos_bw
;
1486 if (params
->pauseable
) {
1487 params
->pri_bitmask
=
1488 DCBX_PFC_PRI_GET_PAUSE(bp
,
1489 cos_data
.data
[i
].pri_join_mask
);
1490 DP(NETIF_MSG_LINK
, "COS %d PAUSABLE prijoinmask 0x%x\n",
1491 i
, cos_data
.data
[i
].pri_join_mask
);
1493 params
->pri_bitmask
=
1494 DCBX_PFC_PRI_GET_NON_PAUSE(bp
,
1495 cos_data
.data
[i
].pri_join_mask
);
1496 DP(NETIF_MSG_LINK
, "COS %d NONPAUSABLE prijoinmask "
1498 i
, cos_data
.data
[i
].pri_join_mask
);
1502 bp
->dcbx_port_params
.ets
.num_of_cos
= cos_data
.num_of_cos
;
1505 static void bnx2x_dcbx_get_ets_pri_pg_tbl(struct bnx2x
*bp
,
1506 u32
*set_configuration_ets_pg
,
1511 for (i
= 0; i
< DCBX_MAX_NUM_PRI_PG_ENTRIES
; i
++) {
1512 set_configuration_ets_pg
[i
] = DCBX_PRI_PG_GET(pri_pg_tbl
, i
);
1514 DP(NETIF_MSG_LINK
, "set_configuration_ets_pg[%d] = 0x%x\n",
1515 i
, set_configuration_ets_pg
[i
]);
1519 static void bnx2x_pfc_fw_struct_e2(struct bnx2x
*bp
)
1521 struct flow_control_configuration
*pfc_fw_cfg
= NULL
;
1523 u8 cos
= 0, pri
= 0;
1524 struct priority_cos
*tt2cos
;
1525 u32
*ttp
= bp
->dcbx_port_params
.app
.traffic_type_priority
;
1527 pfc_fw_cfg
= (struct flow_control_configuration
*)
1528 bnx2x_sp(bp
, pfc_config
);
1529 memset(pfc_fw_cfg
, 0, sizeof(struct flow_control_configuration
));
1532 tt2cos
= pfc_fw_cfg
->traffic_type_to_priority_cos
;
1534 /* Fw version should be incremented each update */
1535 pfc_fw_cfg
->dcb_version
= ++bp
->dcb_version
;
1536 pfc_fw_cfg
->dcb_enabled
= 1;
1538 /* Fill priority parameters */
1539 for (pri
= 0; pri
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
; pri
++) {
1540 tt2cos
[pri
].priority
= ttp
[pri
];
1541 pri_bit
= 1 << tt2cos
[pri
].priority
;
1543 /* Fill COS parameters based on COS calculated to
1544 * make it more general for future use */
1545 for (cos
= 0; cos
< bp
->dcbx_port_params
.ets
.num_of_cos
; cos
++)
1546 if (bp
->dcbx_port_params
.ets
.cos_params
[cos
].
1547 pri_bitmask
& pri_bit
)
1548 tt2cos
[pri
].cos
= cos
;
1551 /* we never want the FW to add a 0 vlan tag */
1552 pfc_fw_cfg
->dont_add_pri_0_en
= 1;
1554 bnx2x_dcbx_print_cos_params(bp
, pfc_fw_cfg
);
1557 void bnx2x_dcbx_pmf_update(struct bnx2x
*bp
)
1559 /* if we need to syncronize DCBX result from prev PMF
1560 * read it from shmem and update bp accordingly
1562 if (SHMEM2_HAS(bp
, drv_flags
) &&
1563 GET_FLAGS(SHMEM2_RD(bp
, drv_flags
), DRV_FLAGS_DCB_CONFIGURED
)) {
1564 /* Read neg results if dcbx is in the FW */
1565 if (bnx2x_dcbx_read_shmem_neg_results(bp
))
1568 bnx2x_dump_dcbx_drv_param(bp
, &bp
->dcbx_local_feat
,
1570 bnx2x_get_dcbx_drv_param(bp
, &bp
->dcbx_local_feat
,
1578 #define BNX2X_DCBX_CAPS (DCB_CAP_DCBX_LLD_MANAGED | \
1579 DCB_CAP_DCBX_VER_CEE | DCB_CAP_DCBX_STATIC)
1581 static inline bool bnx2x_dcbnl_set_valid(struct bnx2x
*bp
)
1583 /* validate dcbnl call that may change HW state:
1584 * DCB is on and DCBX mode was SUCCESSFULLY set by the user.
1586 return bp
->dcb_state
&& bp
->dcbx_mode_uset
;
1589 static u8
bnx2x_dcbnl_get_state(struct net_device
*netdev
)
1591 struct bnx2x
*bp
= netdev_priv(netdev
);
1592 DP(NETIF_MSG_LINK
, "state = %d\n", bp
->dcb_state
);
1593 return bp
->dcb_state
;
1596 static u8
bnx2x_dcbnl_set_state(struct net_device
*netdev
, u8 state
)
1598 struct bnx2x
*bp
= netdev_priv(netdev
);
1599 DP(NETIF_MSG_LINK
, "state = %s\n", state
? "on" : "off");
1601 bnx2x_dcbx_set_state(bp
, (state
? true : false), bp
->dcbx_enabled
);
1605 static void bnx2x_dcbnl_get_perm_hw_addr(struct net_device
*netdev
,
1608 struct bnx2x
*bp
= netdev_priv(netdev
);
1609 DP(NETIF_MSG_LINK
, "GET-PERM-ADDR\n");
1611 /* first the HW mac address */
1612 memcpy(perm_addr
, netdev
->dev_addr
, netdev
->addr_len
);
1615 /* second SAN address */
1616 memcpy(perm_addr
+netdev
->addr_len
, bp
->fip_mac
, netdev
->addr_len
);
1620 static void bnx2x_dcbnl_set_pg_tccfg_tx(struct net_device
*netdev
, int prio
,
1621 u8 prio_type
, u8 pgid
, u8 bw_pct
,
1624 struct bnx2x
*bp
= netdev_priv(netdev
);
1626 DP(NETIF_MSG_LINK
, "prio[%d] = %d\n", prio
, pgid
);
1627 if (!bnx2x_dcbnl_set_valid(bp
) || prio
>= DCBX_MAX_NUM_PRI_PG_ENTRIES
)
1631 * bw_pct ingnored - band-width percentage devision between user
1632 * priorities within the same group is not
1633 * standard and hence not supported
1635 * prio_type igonred - priority levels within the same group are not
1636 * standard and hence are not supported. According
1637 * to the standard pgid 15 is dedicated to strict
1638 * prioirty traffic (on the port level).
1643 bp
->dcbx_config_params
.admin_configuration_ets_pg
[prio
] = pgid
;
1644 bp
->dcbx_config_params
.admin_ets_configuration_tx_enable
= 1;
1647 static void bnx2x_dcbnl_set_pg_bwgcfg_tx(struct net_device
*netdev
,
1648 int pgid
, u8 bw_pct
)
1650 struct bnx2x
*bp
= netdev_priv(netdev
);
1651 DP(NETIF_MSG_LINK
, "pgid[%d] = %d\n", pgid
, bw_pct
);
1653 if (!bnx2x_dcbnl_set_valid(bp
) || pgid
>= DCBX_MAX_NUM_PG_BW_ENTRIES
)
1656 bp
->dcbx_config_params
.admin_configuration_bw_precentage
[pgid
] = bw_pct
;
1657 bp
->dcbx_config_params
.admin_ets_configuration_tx_enable
= 1;
1660 static void bnx2x_dcbnl_set_pg_tccfg_rx(struct net_device
*netdev
, int prio
,
1661 u8 prio_type
, u8 pgid
, u8 bw_pct
,
1664 struct bnx2x
*bp
= netdev_priv(netdev
);
1665 DP(NETIF_MSG_LINK
, "Nothing to set; No RX support\n");
1668 static void bnx2x_dcbnl_set_pg_bwgcfg_rx(struct net_device
*netdev
,
1669 int pgid
, u8 bw_pct
)
1671 struct bnx2x
*bp
= netdev_priv(netdev
);
1672 DP(NETIF_MSG_LINK
, "Nothing to set; No RX support\n");
1675 static void bnx2x_dcbnl_get_pg_tccfg_tx(struct net_device
*netdev
, int prio
,
1676 u8
*prio_type
, u8
*pgid
, u8
*bw_pct
,
1679 struct bnx2x
*bp
= netdev_priv(netdev
);
1680 DP(NETIF_MSG_LINK
, "prio = %d\n", prio
);
1683 * bw_pct ingnored - band-width percentage devision between user
1684 * priorities within the same group is not
1685 * standard and hence not supported
1687 * prio_type igonred - priority levels within the same group are not
1688 * standard and hence are not supported. According
1689 * to the standard pgid 15 is dedicated to strict
1690 * prioirty traffic (on the port level).
1694 *up_map
= *bw_pct
= *prio_type
= *pgid
= 0;
1696 if (!bp
->dcb_state
|| prio
>= DCBX_MAX_NUM_PRI_PG_ENTRIES
)
1699 *pgid
= DCBX_PRI_PG_GET(bp
->dcbx_local_feat
.ets
.pri_pg_tbl
, prio
);
1702 static void bnx2x_dcbnl_get_pg_bwgcfg_tx(struct net_device
*netdev
,
1703 int pgid
, u8
*bw_pct
)
1705 struct bnx2x
*bp
= netdev_priv(netdev
);
1706 DP(NETIF_MSG_LINK
, "pgid = %d\n", pgid
);
1710 if (!bp
->dcb_state
|| pgid
>= DCBX_MAX_NUM_PG_BW_ENTRIES
)
1713 *bw_pct
= DCBX_PG_BW_GET(bp
->dcbx_local_feat
.ets
.pg_bw_tbl
, pgid
);
1716 static void bnx2x_dcbnl_get_pg_tccfg_rx(struct net_device
*netdev
, int prio
,
1717 u8
*prio_type
, u8
*pgid
, u8
*bw_pct
,
1720 struct bnx2x
*bp
= netdev_priv(netdev
);
1721 DP(NETIF_MSG_LINK
, "Nothing to get; No RX support\n");
1723 *prio_type
= *pgid
= *bw_pct
= *up_map
= 0;
1726 static void bnx2x_dcbnl_get_pg_bwgcfg_rx(struct net_device
*netdev
,
1727 int pgid
, u8
*bw_pct
)
1729 struct bnx2x
*bp
= netdev_priv(netdev
);
1730 DP(NETIF_MSG_LINK
, "Nothing to get; No RX support\n");
1735 static void bnx2x_dcbnl_set_pfc_cfg(struct net_device
*netdev
, int prio
,
1738 struct bnx2x
*bp
= netdev_priv(netdev
);
1739 DP(NETIF_MSG_LINK
, "prio[%d] = %d\n", prio
, setting
);
1741 if (!bnx2x_dcbnl_set_valid(bp
) || prio
>= MAX_PFC_PRIORITIES
)
1744 bp
->dcbx_config_params
.admin_pfc_bitmap
|= ((setting
? 1 : 0) << prio
);
1747 bp
->dcbx_config_params
.admin_pfc_tx_enable
= 1;
1750 static void bnx2x_dcbnl_get_pfc_cfg(struct net_device
*netdev
, int prio
,
1753 struct bnx2x
*bp
= netdev_priv(netdev
);
1754 DP(NETIF_MSG_LINK
, "prio = %d\n", prio
);
1758 if (!bp
->dcb_state
|| prio
>= MAX_PFC_PRIORITIES
)
1761 *setting
= (bp
->dcbx_local_feat
.pfc
.pri_en_bitmap
>> prio
) & 0x1;
1764 static u8
bnx2x_dcbnl_set_all(struct net_device
*netdev
)
1766 struct bnx2x
*bp
= netdev_priv(netdev
);
1769 DP(NETIF_MSG_LINK
, "SET-ALL\n");
1771 if (!bnx2x_dcbnl_set_valid(bp
))
1774 if (bp
->recovery_state
!= BNX2X_RECOVERY_DONE
) {
1775 netdev_err(bp
->dev
, "Handling parity error recovery. "
1776 "Try again later\n");
1779 if (netif_running(bp
->dev
)) {
1780 bnx2x_nic_unload(bp
, UNLOAD_NORMAL
);
1781 rc
= bnx2x_nic_load(bp
, LOAD_NORMAL
);
1783 DP(NETIF_MSG_LINK
, "set_dcbx_params done (%d)\n", rc
);
1790 static u8
bnx2x_dcbnl_get_cap(struct net_device
*netdev
, int capid
, u8
*cap
)
1792 struct bnx2x
*bp
= netdev_priv(netdev
);
1795 if (bp
->dcb_state
) {
1797 case DCB_CAP_ATTR_PG
:
1800 case DCB_CAP_ATTR_PFC
:
1803 case DCB_CAP_ATTR_UP2TC
:
1806 case DCB_CAP_ATTR_PG_TCS
:
1807 *cap
= 0x80; /* 8 priorities for PGs */
1809 case DCB_CAP_ATTR_PFC_TCS
:
1810 *cap
= 0x80; /* 8 priorities for PFC */
1812 case DCB_CAP_ATTR_GSP
:
1815 case DCB_CAP_ATTR_BCN
:
1818 case DCB_CAP_ATTR_DCBX
:
1819 *cap
= BNX2X_DCBX_CAPS
;
1827 DP(NETIF_MSG_LINK
, "capid %d:%x\n", capid
, *cap
);
1831 static u8
bnx2x_dcbnl_get_numtcs(struct net_device
*netdev
, int tcid
, u8
*num
)
1833 struct bnx2x
*bp
= netdev_priv(netdev
);
1836 DP(NETIF_MSG_LINK
, "tcid %d\n", tcid
);
1838 if (bp
->dcb_state
) {
1840 case DCB_NUMTCS_ATTR_PG
:
1841 *num
= E2_NUM_OF_COS
;
1843 case DCB_NUMTCS_ATTR_PFC
:
1844 *num
= E2_NUM_OF_COS
;
1856 static u8
bnx2x_dcbnl_set_numtcs(struct net_device
*netdev
, int tcid
, u8 num
)
1858 struct bnx2x
*bp
= netdev_priv(netdev
);
1859 DP(NETIF_MSG_LINK
, "num tcs = %d; Not supported\n", num
);
1863 static u8
bnx2x_dcbnl_get_pfc_state(struct net_device
*netdev
)
1865 struct bnx2x
*bp
= netdev_priv(netdev
);
1866 DP(NETIF_MSG_LINK
, "state = %d\n", bp
->dcbx_local_feat
.pfc
.enabled
);
1871 return bp
->dcbx_local_feat
.pfc
.enabled
;
1874 static void bnx2x_dcbnl_set_pfc_state(struct net_device
*netdev
, u8 state
)
1876 struct bnx2x
*bp
= netdev_priv(netdev
);
1877 DP(NETIF_MSG_LINK
, "state = %s\n", state
? "on" : "off");
1879 if (!bnx2x_dcbnl_set_valid(bp
))
1882 bp
->dcbx_config_params
.admin_pfc_tx_enable
=
1883 bp
->dcbx_config_params
.admin_pfc_enable
= (state
? 1 : 0);
1886 static void bnx2x_admin_app_set_ent(
1887 struct bnx2x_admin_priority_app_table
*app_ent
,
1888 u8 idtype
, u16 idval
, u8 up
)
1893 case DCB_APP_IDTYPE_ETHTYPE
:
1894 app_ent
->traffic_type
= TRAFFIC_TYPE_ETH
;
1896 case DCB_APP_IDTYPE_PORTNUM
:
1897 app_ent
->traffic_type
= TRAFFIC_TYPE_PORT
;
1900 break; /* never gets here */
1902 app_ent
->app_id
= idval
;
1903 app_ent
->priority
= up
;
1906 static bool bnx2x_admin_app_is_equal(
1907 struct bnx2x_admin_priority_app_table
*app_ent
,
1908 u8 idtype
, u16 idval
)
1910 if (!app_ent
->valid
)
1914 case DCB_APP_IDTYPE_ETHTYPE
:
1915 if (app_ent
->traffic_type
!= TRAFFIC_TYPE_ETH
)
1918 case DCB_APP_IDTYPE_PORTNUM
:
1919 if (app_ent
->traffic_type
!= TRAFFIC_TYPE_PORT
)
1925 if (app_ent
->app_id
!= idval
)
1931 static int bnx2x_set_admin_app_up(struct bnx2x
*bp
, u8 idtype
, u16 idval
, u8 up
)
1935 /* iterate over the app entries looking for idtype and idval */
1936 for (i
= 0, ff
= -1; i
< 4; i
++) {
1937 struct bnx2x_admin_priority_app_table
*app_ent
=
1938 &bp
->dcbx_config_params
.admin_priority_app_table
[i
];
1939 if (bnx2x_admin_app_is_equal(app_ent
, idtype
, idval
))
1942 if (ff
< 0 && !app_ent
->valid
)
1946 /* if found overwrite up */
1947 bp
->dcbx_config_params
.
1948 admin_priority_app_table
[i
].priority
= up
;
1950 /* not found use first-free */
1951 bnx2x_admin_app_set_ent(
1952 &bp
->dcbx_config_params
.admin_priority_app_table
[ff
],
1955 /* app table is full */
1958 /* up configured, if not 0 make sure feature is enabled */
1960 bp
->dcbx_config_params
.admin_application_priority_tx_enable
= 1;
1965 static u8
bnx2x_dcbnl_set_app_up(struct net_device
*netdev
, u8 idtype
,
1968 struct bnx2x
*bp
= netdev_priv(netdev
);
1970 DP(NETIF_MSG_LINK
, "app_type %d, app_id %x, prio bitmap %d\n",
1973 if (!bnx2x_dcbnl_set_valid(bp
))
1978 case DCB_APP_IDTYPE_ETHTYPE
:
1979 case DCB_APP_IDTYPE_PORTNUM
:
1984 return bnx2x_set_admin_app_up(bp
, idtype
, idval
, up
);
1987 static u8
bnx2x_dcbnl_get_dcbx(struct net_device
*netdev
)
1989 struct bnx2x
*bp
= netdev_priv(netdev
);
1992 state
= DCB_CAP_DCBX_LLD_MANAGED
| DCB_CAP_DCBX_VER_CEE
;
1994 if (bp
->dcbx_enabled
== BNX2X_DCBX_ENABLED_ON_NEG_OFF
)
1995 state
|= DCB_CAP_DCBX_STATIC
;
2000 static u8
bnx2x_dcbnl_set_dcbx(struct net_device
*netdev
, u8 state
)
2002 struct bnx2x
*bp
= netdev_priv(netdev
);
2003 DP(NETIF_MSG_LINK
, "state = %02x\n", state
);
2007 if ((state
& BNX2X_DCBX_CAPS
) != state
) {
2008 BNX2X_ERR("Requested DCBX mode %x is beyond advertised "
2009 "capabilities\n", state
);
2013 if (bp
->dcb_state
!= BNX2X_DCB_STATE_ON
) {
2014 BNX2X_ERR("DCB turned off, DCBX configuration is invalid\n");
2018 if (state
& DCB_CAP_DCBX_STATIC
)
2019 bp
->dcbx_enabled
= BNX2X_DCBX_ENABLED_ON_NEG_OFF
;
2021 bp
->dcbx_enabled
= BNX2X_DCBX_ENABLED_ON_NEG_ON
;
2023 bp
->dcbx_mode_uset
= true;
2027 static u8
bnx2x_dcbnl_get_featcfg(struct net_device
*netdev
, int featid
,
2030 struct bnx2x
*bp
= netdev_priv(netdev
);
2033 DP(NETIF_MSG_LINK
, "featid %d\n", featid
);
2035 if (bp
->dcb_state
) {
2038 case DCB_FEATCFG_ATTR_PG
:
2039 if (bp
->dcbx_local_feat
.ets
.enabled
)
2040 *flags
|= DCB_FEATCFG_ENABLE
;
2041 if (bp
->dcbx_error
& DCBX_LOCAL_ETS_ERROR
)
2042 *flags
|= DCB_FEATCFG_ERROR
;
2044 case DCB_FEATCFG_ATTR_PFC
:
2045 if (bp
->dcbx_local_feat
.pfc
.enabled
)
2046 *flags
|= DCB_FEATCFG_ENABLE
;
2047 if (bp
->dcbx_error
& (DCBX_LOCAL_PFC_ERROR
|
2048 DCBX_LOCAL_PFC_MISMATCH
))
2049 *flags
|= DCB_FEATCFG_ERROR
;
2051 case DCB_FEATCFG_ATTR_APP
:
2052 if (bp
->dcbx_local_feat
.app
.enabled
)
2053 *flags
|= DCB_FEATCFG_ENABLE
;
2054 if (bp
->dcbx_error
& (DCBX_LOCAL_APP_ERROR
|
2055 DCBX_LOCAL_APP_MISMATCH
))
2056 *flags
|= DCB_FEATCFG_ERROR
;
2068 static u8
bnx2x_dcbnl_set_featcfg(struct net_device
*netdev
, int featid
,
2071 struct bnx2x
*bp
= netdev_priv(netdev
);
2074 DP(NETIF_MSG_LINK
, "featid = %d flags = %02x\n", featid
, flags
);
2076 /* ignore the 'advertise' flag */
2077 if (bnx2x_dcbnl_set_valid(bp
)) {
2079 case DCB_FEATCFG_ATTR_PG
:
2080 bp
->dcbx_config_params
.admin_ets_enable
=
2081 flags
& DCB_FEATCFG_ENABLE
? 1 : 0;
2082 bp
->dcbx_config_params
.admin_ets_willing
=
2083 flags
& DCB_FEATCFG_WILLING
? 1 : 0;
2085 case DCB_FEATCFG_ATTR_PFC
:
2086 bp
->dcbx_config_params
.admin_pfc_enable
=
2087 flags
& DCB_FEATCFG_ENABLE
? 1 : 0;
2088 bp
->dcbx_config_params
.admin_pfc_willing
=
2089 flags
& DCB_FEATCFG_WILLING
? 1 : 0;
2091 case DCB_FEATCFG_ATTR_APP
:
2092 /* ignore enable, always enabled */
2093 bp
->dcbx_config_params
.admin_app_priority_willing
=
2094 flags
& DCB_FEATCFG_WILLING
? 1 : 0;
2106 static int bnx2x_peer_appinfo(struct net_device
*netdev
,
2107 struct dcb_peer_app_info
*info
, u16
* app_count
)
2110 struct bnx2x
*bp
= netdev_priv(netdev
);
2112 DP(NETIF_MSG_LINK
, "APP-INFO\n");
2114 info
->willing
= (bp
->dcbx_remote_flags
& DCBX_APP_REM_WILLING
) ?: 0;
2115 info
->error
= (bp
->dcbx_remote_flags
& DCBX_APP_RX_ERROR
) ?: 0;
2118 for (i
= 0; i
< DCBX_MAX_APP_PROTOCOL
; i
++)
2119 if (bp
->dcbx_remote_feat
.app
.app_pri_tbl
[i
].appBitfield
&
2120 DCBX_APP_ENTRY_VALID
)
2125 static int bnx2x_peer_apptable(struct net_device
*netdev
,
2126 struct dcb_app
*table
)
2129 struct bnx2x
*bp
= netdev_priv(netdev
);
2131 DP(NETIF_MSG_LINK
, "APP-TABLE\n");
2133 for (i
= 0, j
= 0; i
< DCBX_MAX_APP_PROTOCOL
; i
++) {
2134 struct dcbx_app_priority_entry
*ent
=
2135 &bp
->dcbx_remote_feat
.app
.app_pri_tbl
[i
];
2137 if (ent
->appBitfield
& DCBX_APP_ENTRY_VALID
) {
2138 table
[j
].selector
= bnx2x_dcbx_dcbnl_app_idtype(ent
);
2139 table
[j
].priority
= bnx2x_dcbx_dcbnl_app_up(ent
);
2140 table
[j
++].protocol
= ent
->app_id
;
2146 static int bnx2x_cee_peer_getpg(struct net_device
*netdev
, struct cee_pg
*pg
)
2149 struct bnx2x
*bp
= netdev_priv(netdev
);
2151 pg
->willing
= (bp
->dcbx_remote_flags
& DCBX_ETS_REM_WILLING
) ?: 0;
2153 for (i
= 0; i
< CEE_DCBX_MAX_PGS
; i
++) {
2155 DCBX_PG_BW_GET(bp
->dcbx_remote_feat
.ets
.pg_bw_tbl
, i
);
2157 DCBX_PRI_PG_GET(bp
->dcbx_remote_feat
.ets
.pri_pg_tbl
, i
);
2162 static int bnx2x_cee_peer_getpfc(struct net_device
*netdev
,
2163 struct cee_pfc
*pfc
)
2165 struct bnx2x
*bp
= netdev_priv(netdev
);
2166 pfc
->tcs_supported
= bp
->dcbx_remote_feat
.pfc
.pfc_caps
;
2167 pfc
->pfc_en
= bp
->dcbx_remote_feat
.pfc
.pri_en_bitmap
;
2171 const struct dcbnl_rtnl_ops bnx2x_dcbnl_ops
= {
2172 .getstate
= bnx2x_dcbnl_get_state
,
2173 .setstate
= bnx2x_dcbnl_set_state
,
2174 .getpermhwaddr
= bnx2x_dcbnl_get_perm_hw_addr
,
2175 .setpgtccfgtx
= bnx2x_dcbnl_set_pg_tccfg_tx
,
2176 .setpgbwgcfgtx
= bnx2x_dcbnl_set_pg_bwgcfg_tx
,
2177 .setpgtccfgrx
= bnx2x_dcbnl_set_pg_tccfg_rx
,
2178 .setpgbwgcfgrx
= bnx2x_dcbnl_set_pg_bwgcfg_rx
,
2179 .getpgtccfgtx
= bnx2x_dcbnl_get_pg_tccfg_tx
,
2180 .getpgbwgcfgtx
= bnx2x_dcbnl_get_pg_bwgcfg_tx
,
2181 .getpgtccfgrx
= bnx2x_dcbnl_get_pg_tccfg_rx
,
2182 .getpgbwgcfgrx
= bnx2x_dcbnl_get_pg_bwgcfg_rx
,
2183 .setpfccfg
= bnx2x_dcbnl_set_pfc_cfg
,
2184 .getpfccfg
= bnx2x_dcbnl_get_pfc_cfg
,
2185 .setall
= bnx2x_dcbnl_set_all
,
2186 .getcap
= bnx2x_dcbnl_get_cap
,
2187 .getnumtcs
= bnx2x_dcbnl_get_numtcs
,
2188 .setnumtcs
= bnx2x_dcbnl_set_numtcs
,
2189 .getpfcstate
= bnx2x_dcbnl_get_pfc_state
,
2190 .setpfcstate
= bnx2x_dcbnl_set_pfc_state
,
2191 .setapp
= bnx2x_dcbnl_set_app_up
,
2192 .getdcbx
= bnx2x_dcbnl_get_dcbx
,
2193 .setdcbx
= bnx2x_dcbnl_set_dcbx
,
2194 .getfeatcfg
= bnx2x_dcbnl_get_featcfg
,
2195 .setfeatcfg
= bnx2x_dcbnl_set_featcfg
,
2196 .peer_getappinfo
= bnx2x_peer_appinfo
,
2197 .peer_getapptable
= bnx2x_peer_apptable
,
2198 .cee_peer_getpg
= bnx2x_cee_peer_getpg
,
2199 .cee_peer_getpfc
= bnx2x_cee_peer_getpfc
,
2202 #endif /* BCM_DCBNL */