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>
22 #include <linux/rtnetlink.h>
23 #include <net/dcbnl.h>
26 #include "bnx2x_cmn.h"
27 #include "bnx2x_dcb.h"
29 /* forward declarations of dcbx related functions */
30 static int bnx2x_dcbx_stop_hw_tx(struct bnx2x
*bp
);
31 static void bnx2x_pfc_set_pfc(struct bnx2x
*bp
);
32 static void bnx2x_dcbx_update_ets_params(struct bnx2x
*bp
);
33 static int bnx2x_dcbx_resume_hw_tx(struct bnx2x
*bp
);
34 static void bnx2x_dcbx_get_ets_pri_pg_tbl(struct bnx2x
*bp
,
35 u32
*set_configuration_ets_pg
,
37 static void bnx2x_dcbx_get_num_pg_traf_type(struct bnx2x
*bp
,
38 u32
*pg_pri_orginal_spread
,
39 struct pg_help_data
*help_data
);
40 static void bnx2x_dcbx_fill_cos_params(struct bnx2x
*bp
,
41 struct pg_help_data
*help_data
,
42 struct dcbx_ets_feature
*ets
,
43 u32
*pg_pri_orginal_spread
);
44 static void bnx2x_dcbx_separate_pauseable_from_non(struct bnx2x
*bp
,
45 struct cos_help_data
*cos_data
,
46 u32
*pg_pri_orginal_spread
,
47 struct dcbx_ets_feature
*ets
);
48 static void bnx2x_dcbx_fw_struct(struct bnx2x
*bp
,
49 struct bnx2x_func_tx_start_params
*);
51 /* helpers: read/write len bytes from addr into buff by REG_RD/REG_WR */
52 static void bnx2x_read_data(struct bnx2x
*bp
, u32
*buff
,
56 for (i
= 0; i
< len
; i
+= 4, buff
++)
57 *buff
= REG_RD(bp
, addr
+ i
);
60 static void bnx2x_write_data(struct bnx2x
*bp
, u32
*buff
,
64 for (i
= 0; i
< len
; i
+= 4, buff
++)
65 REG_WR(bp
, addr
+ i
, *buff
);
68 static void bnx2x_pfc_set(struct bnx2x
*bp
)
70 struct bnx2x_nig_brb_pfc_port_params pfc_params
= {0};
74 pfc_params
.num_of_rx_cos_priority_mask
=
75 bp
->dcbx_port_params
.ets
.num_of_cos
;
77 /* Tx COS configuration */
78 for (i
= 0; i
< bp
->dcbx_port_params
.ets
.num_of_cos
; i
++)
80 * We configure only the pauseable bits (non pauseable aren't
81 * configured at all) it's done to avoid false pauses from
84 pfc_params
.rx_cos_priority_mask
[i
] =
85 bp
->dcbx_port_params
.ets
.cos_params
[i
].pri_bitmask
86 & DCBX_PFC_PRI_PAUSE_MASK(bp
);
89 * Rx COS configuration
90 * Changing PFC RX configuration .
91 * In RX COS0 will always be configured to lossy and COS1 to lossless
93 for (i
= 0 ; i
< MAX_PFC_PRIORITIES
; i
++) {
96 if (pri_bit
& DCBX_PFC_PRI_PAUSE_MASK(bp
))
100 pfc_params
.pkt_priority_to_cos
= val
;
103 pfc_params
.llfc_low_priority_classes
= 0;
105 pfc_params
.llfc_high_priority_classes
= DCBX_PFC_PRI_PAUSE_MASK(bp
);
107 /* BRB configuration */
108 pfc_params
.cos0_pauseable
= false;
109 pfc_params
.cos1_pauseable
= true;
111 bnx2x_acquire_phy_lock(bp
);
112 bp
->link_params
.feature_config_flags
|= FEATURE_CONFIG_PFC_ENABLED
;
113 bnx2x_update_pfc(&bp
->link_params
, &bp
->link_vars
, &pfc_params
);
114 bnx2x_release_phy_lock(bp
);
117 static void bnx2x_pfc_clear(struct bnx2x
*bp
)
119 struct bnx2x_nig_brb_pfc_port_params nig_params
= {0};
120 nig_params
.pause_enable
= 1;
122 if (bp
->flags
& SAFC_TX_FLAG
) {
123 u32 high
= 0, low
= 0;
126 for (i
= 0; i
< BNX2X_MAX_PRIORITY
; i
++) {
127 if (bp
->pri_map
[i
] == 1)
129 if (bp
->pri_map
[i
] == 0)
133 nig_params
.llfc_low_priority_classes
= high
;
134 nig_params
.llfc_low_priority_classes
= low
;
136 nig_params
.pause_enable
= 0;
137 nig_params
.llfc_enable
= 1;
138 nig_params
.llfc_out_en
= 1;
140 #endif /* BNX2X_SAFC */
141 bnx2x_acquire_phy_lock(bp
);
142 bp
->link_params
.feature_config_flags
&= ~FEATURE_CONFIG_PFC_ENABLED
;
143 bnx2x_update_pfc(&bp
->link_params
, &bp
->link_vars
, &nig_params
);
144 bnx2x_release_phy_lock(bp
);
147 static void bnx2x_dump_dcbx_drv_param(struct bnx2x
*bp
,
148 struct dcbx_features
*features
,
152 DP(NETIF_MSG_LINK
, "local_mib.error %x\n", error
);
156 "local_mib.features.ets.enabled %x\n", features
->ets
.enabled
);
157 for (i
= 0; i
< DCBX_MAX_NUM_PG_BW_ENTRIES
; i
++)
159 "local_mib.features.ets.pg_bw_tbl[%d] %d\n", i
,
160 DCBX_PG_BW_GET(features
->ets
.pg_bw_tbl
, i
));
161 for (i
= 0; i
< DCBX_MAX_NUM_PRI_PG_ENTRIES
; i
++)
163 "local_mib.features.ets.pri_pg_tbl[%d] %d\n", i
,
164 DCBX_PRI_PG_GET(features
->ets
.pri_pg_tbl
, i
));
167 DP(NETIF_MSG_LINK
, "dcbx_features.pfc.pri_en_bitmap %x\n",
168 features
->pfc
.pri_en_bitmap
);
169 DP(NETIF_MSG_LINK
, "dcbx_features.pfc.pfc_caps %x\n",
170 features
->pfc
.pfc_caps
);
171 DP(NETIF_MSG_LINK
, "dcbx_features.pfc.enabled %x\n",
172 features
->pfc
.enabled
);
174 DP(NETIF_MSG_LINK
, "dcbx_features.app.default_pri %x\n",
175 features
->app
.default_pri
);
176 DP(NETIF_MSG_LINK
, "dcbx_features.app.tc_supported %x\n",
177 features
->app
.tc_supported
);
178 DP(NETIF_MSG_LINK
, "dcbx_features.app.enabled %x\n",
179 features
->app
.enabled
);
180 for (i
= 0; i
< DCBX_MAX_APP_PROTOCOL
; i
++) {
182 "dcbx_features.app.app_pri_tbl[%x].app_id %x\n",
183 i
, features
->app
.app_pri_tbl
[i
].app_id
);
185 "dcbx_features.app.app_pri_tbl[%x].pri_bitmap %x\n",
186 i
, features
->app
.app_pri_tbl
[i
].pri_bitmap
);
188 "dcbx_features.app.app_pri_tbl[%x].appBitfield %x\n",
189 i
, features
->app
.app_pri_tbl
[i
].appBitfield
);
193 static void bnx2x_dcbx_get_ap_priority(struct bnx2x
*bp
,
197 u32 pri
= MAX_PFC_PRIORITIES
;
198 u32 index
= MAX_PFC_PRIORITIES
- 1;
200 u32
*ttp
= bp
->dcbx_port_params
.app
.traffic_type_priority
;
202 /* Choose the highest priority */
203 while ((MAX_PFC_PRIORITIES
== pri
) && (0 != index
)) {
204 pri_mask
= 1 << index
;
205 if (GET_FLAGS(pri_bitmap
, pri_mask
))
210 if (pri
< MAX_PFC_PRIORITIES
)
211 ttp
[llfc_traf_type
] = max_t(u32
, ttp
[llfc_traf_type
], pri
);
214 static void bnx2x_dcbx_get_ap_feature(struct bnx2x
*bp
,
215 struct dcbx_app_priority_feature
*app
,
218 u32
*ttp
= bp
->dcbx_port_params
.app
.traffic_type_priority
;
220 if (GET_FLAGS(error
, DCBX_LOCAL_APP_ERROR
))
221 DP(NETIF_MSG_LINK
, "DCBX_LOCAL_APP_ERROR\n");
223 if (GET_FLAGS(error
, DCBX_LOCAL_APP_MISMATCH
))
224 DP(NETIF_MSG_LINK
, "DCBX_LOCAL_APP_MISMATCH\n");
227 !GET_FLAGS(error
, DCBX_LOCAL_APP_ERROR
| DCBX_LOCAL_APP_MISMATCH
)) {
229 bp
->dcbx_port_params
.app
.enabled
= true;
231 for (index
= 0 ; index
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
; index
++)
234 if (app
->default_pri
< MAX_PFC_PRIORITIES
)
235 ttp
[LLFC_TRAFFIC_TYPE_NW
] = app
->default_pri
;
237 for (index
= 0 ; index
< DCBX_MAX_APP_PROTOCOL
; index
++) {
238 struct dcbx_app_priority_entry
*entry
=
241 if (GET_FLAGS(entry
[index
].appBitfield
,
242 DCBX_APP_SF_ETH_TYPE
) &&
243 ETH_TYPE_FCOE
== entry
[index
].app_id
)
244 bnx2x_dcbx_get_ap_priority(bp
,
245 entry
[index
].pri_bitmap
,
246 LLFC_TRAFFIC_TYPE_FCOE
);
248 if (GET_FLAGS(entry
[index
].appBitfield
,
250 TCP_PORT_ISCSI
== entry
[index
].app_id
)
251 bnx2x_dcbx_get_ap_priority(bp
,
252 entry
[index
].pri_bitmap
,
253 LLFC_TRAFFIC_TYPE_ISCSI
);
256 DP(NETIF_MSG_LINK
, "DCBX_LOCAL_APP_DISABLED\n");
257 bp
->dcbx_port_params
.app
.enabled
= false;
258 for (index
= 0 ; index
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
; index
++)
259 ttp
[index
] = INVALID_TRAFFIC_TYPE_PRIORITY
;
263 static void bnx2x_dcbx_get_ets_feature(struct bnx2x
*bp
,
264 struct dcbx_ets_feature
*ets
,
267 u32 pg_pri_orginal_spread
[DCBX_MAX_NUM_PG_BW_ENTRIES
] = {0};
268 struct pg_help_data pg_help_data
;
269 struct bnx2x_dcbx_cos_params
*cos_params
=
270 bp
->dcbx_port_params
.ets
.cos_params
;
272 memset(&pg_help_data
, 0, sizeof(struct pg_help_data
));
275 if (GET_FLAGS(error
, DCBX_LOCAL_ETS_ERROR
))
276 DP(NETIF_MSG_LINK
, "DCBX_LOCAL_ETS_ERROR\n");
279 /* Clean up old settings of ets on COS */
280 for (i
= 0; i
< ARRAY_SIZE(bp
->dcbx_port_params
.ets
.cos_params
) ; i
++) {
281 cos_params
[i
].pauseable
= false;
282 cos_params
[i
].strict
= BNX2X_DCBX_STRICT_INVALID
;
283 cos_params
[i
].bw_tbl
= DCBX_INVALID_COS_BW
;
284 cos_params
[i
].pri_bitmask
= 0;
287 if (bp
->dcbx_port_params
.app
.enabled
&&
288 !GET_FLAGS(error
, DCBX_LOCAL_ETS_ERROR
) &&
290 DP(NETIF_MSG_LINK
, "DCBX_LOCAL_ETS_ENABLE\n");
291 bp
->dcbx_port_params
.ets
.enabled
= true;
293 bnx2x_dcbx_get_ets_pri_pg_tbl(bp
,
294 pg_pri_orginal_spread
,
297 bnx2x_dcbx_get_num_pg_traf_type(bp
,
298 pg_pri_orginal_spread
,
301 bnx2x_dcbx_fill_cos_params(bp
, &pg_help_data
,
302 ets
, pg_pri_orginal_spread
);
305 DP(NETIF_MSG_LINK
, "DCBX_LOCAL_ETS_DISABLED\n");
306 bp
->dcbx_port_params
.ets
.enabled
= false;
307 ets
->pri_pg_tbl
[0] = 0;
309 for (i
= 0; i
< DCBX_MAX_NUM_PRI_PG_ENTRIES
; i
++)
310 DCBX_PG_BW_SET(ets
->pg_bw_tbl
, i
, 1);
314 static void bnx2x_dcbx_get_pfc_feature(struct bnx2x
*bp
,
315 struct dcbx_pfc_feature
*pfc
, u32 error
)
318 if (GET_FLAGS(error
, DCBX_LOCAL_PFC_ERROR
))
319 DP(NETIF_MSG_LINK
, "DCBX_LOCAL_PFC_ERROR\n");
321 if (bp
->dcbx_port_params
.app
.enabled
&&
322 !GET_FLAGS(error
, DCBX_LOCAL_PFC_ERROR
| DCBX_LOCAL_PFC_MISMATCH
) &&
324 bp
->dcbx_port_params
.pfc
.enabled
= true;
325 bp
->dcbx_port_params
.pfc
.priority_non_pauseable_mask
=
326 ~(pfc
->pri_en_bitmap
);
328 DP(NETIF_MSG_LINK
, "DCBX_LOCAL_PFC_DISABLED\n");
329 bp
->dcbx_port_params
.pfc
.enabled
= false;
330 bp
->dcbx_port_params
.pfc
.priority_non_pauseable_mask
= 0;
334 /* maps unmapped priorities to to the same COS as L2 */
335 static void bnx2x_dcbx_map_nw(struct bnx2x
*bp
)
338 u32 unmapped
= (1 << MAX_PFC_PRIORITIES
) - 1; /* all ones */
339 u32
*ttp
= bp
->dcbx_port_params
.app
.traffic_type_priority
;
340 u32 nw_prio
= 1 << ttp
[LLFC_TRAFFIC_TYPE_NW
];
341 struct bnx2x_dcbx_cos_params
*cos_params
=
342 bp
->dcbx_port_params
.ets
.cos_params
;
344 /* get unmapped priorities by clearing mapped bits */
345 for (i
= 0; i
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
; i
++)
346 unmapped
&= ~(1 << ttp
[i
]);
348 /* find cos for nw prio and extend it with unmapped */
349 for (i
= 0; i
< ARRAY_SIZE(bp
->dcbx_port_params
.ets
.cos_params
); i
++) {
350 if (cos_params
[i
].pri_bitmask
& nw_prio
) {
351 /* extend the bitmask with unmapped */
353 "cos %d extended with 0x%08x", i
, unmapped
);
354 cos_params
[i
].pri_bitmask
|= unmapped
;
360 static void bnx2x_get_dcbx_drv_param(struct bnx2x
*bp
,
361 struct dcbx_features
*features
,
364 bnx2x_dcbx_get_ap_feature(bp
, &features
->app
, error
);
366 bnx2x_dcbx_get_pfc_feature(bp
, &features
->pfc
, error
);
368 bnx2x_dcbx_get_ets_feature(bp
, &features
->ets
, error
);
370 bnx2x_dcbx_map_nw(bp
);
373 #define DCBX_LOCAL_MIB_MAX_TRY_READ (100)
374 static int bnx2x_dcbx_read_mib(struct bnx2x
*bp
,
379 int max_try_read
= 0;
380 u32 mib_size
, prefix_seq_num
, suffix_seq_num
;
381 struct lldp_remote_mib
*remote_mib
;
382 struct lldp_local_mib
*local_mib
;
385 switch (read_mib_type
) {
386 case DCBX_READ_LOCAL_MIB
:
387 mib_size
= sizeof(struct lldp_local_mib
);
389 case DCBX_READ_REMOTE_MIB
:
390 mib_size
= sizeof(struct lldp_remote_mib
);
396 offset
+= BP_PORT(bp
) * mib_size
;
399 bnx2x_read_data(bp
, base_mib_addr
, offset
, mib_size
);
403 switch (read_mib_type
) {
404 case DCBX_READ_LOCAL_MIB
:
405 local_mib
= (struct lldp_local_mib
*) base_mib_addr
;
406 prefix_seq_num
= local_mib
->prefix_seq_num
;
407 suffix_seq_num
= local_mib
->suffix_seq_num
;
409 case DCBX_READ_REMOTE_MIB
:
410 remote_mib
= (struct lldp_remote_mib
*) base_mib_addr
;
411 prefix_seq_num
= remote_mib
->prefix_seq_num
;
412 suffix_seq_num
= remote_mib
->suffix_seq_num
;
417 } while ((prefix_seq_num
!= suffix_seq_num
) &&
418 (max_try_read
< DCBX_LOCAL_MIB_MAX_TRY_READ
));
420 if (max_try_read
>= DCBX_LOCAL_MIB_MAX_TRY_READ
) {
421 BNX2X_ERR("MIB could not be read\n");
428 static void bnx2x_pfc_set_pfc(struct bnx2x
*bp
)
430 if (bp
->dcbx_port_params
.pfc
.enabled
&&
431 !(bp
->dcbx_error
& DCBX_REMOTE_MIB_ERROR
))
433 * 1. Fills up common PFC structures if required
434 * 2. Configure NIG, MAC and BRB via the elink
441 static int bnx2x_dcbx_stop_hw_tx(struct bnx2x
*bp
)
443 struct bnx2x_func_state_params func_params
= {0};
445 func_params
.f_obj
= &bp
->func_obj
;
446 func_params
.cmd
= BNX2X_F_CMD_TX_STOP
;
448 DP(NETIF_MSG_LINK
, "STOP TRAFFIC\n");
449 return bnx2x_func_state_change(bp
, &func_params
);
452 static int bnx2x_dcbx_resume_hw_tx(struct bnx2x
*bp
)
454 struct bnx2x_func_state_params func_params
= {0};
455 struct bnx2x_func_tx_start_params
*tx_params
=
456 &func_params
.params
.tx_start
;
458 func_params
.f_obj
= &bp
->func_obj
;
459 func_params
.cmd
= BNX2X_F_CMD_TX_START
;
461 bnx2x_dcbx_fw_struct(bp
, tx_params
);
463 DP(NETIF_MSG_LINK
, "START TRAFFIC\n");
464 return bnx2x_func_state_change(bp
, &func_params
);
467 static void bnx2x_dcbx_2cos_limit_update_ets_config(struct bnx2x
*bp
)
469 struct bnx2x_dcbx_pg_params
*ets
= &(bp
->dcbx_port_params
.ets
);
472 if (ets
->num_of_cos
== 0 || ets
->num_of_cos
> DCBX_COS_MAX_NUM_E2
) {
473 BNX2X_ERR("Illegal number of COSes %d\n", ets
->num_of_cos
);
477 /* valid COS entries */
478 if (ets
->num_of_cos
== 1) /* no ETS */
482 if (((BNX2X_DCBX_STRICT_INVALID
== ets
->cos_params
[0].strict
) &&
483 (DCBX_INVALID_COS_BW
== ets
->cos_params
[0].bw_tbl
)) ||
484 ((BNX2X_DCBX_STRICT_INVALID
== ets
->cos_params
[1].strict
) &&
485 (DCBX_INVALID_COS_BW
== ets
->cos_params
[1].bw_tbl
))) {
486 BNX2X_ERR("all COS should have at least bw_limit or strict"
487 "ets->cos_params[0].strict= %x"
488 "ets->cos_params[0].bw_tbl= %x"
489 "ets->cos_params[1].strict= %x"
490 "ets->cos_params[1].bw_tbl= %x",
491 ets
->cos_params
[0].strict
,
492 ets
->cos_params
[0].bw_tbl
,
493 ets
->cos_params
[1].strict
,
494 ets
->cos_params
[1].bw_tbl
);
497 /* If we join a group and there is bw_tbl and strict then bw rules */
498 if ((DCBX_INVALID_COS_BW
!= ets
->cos_params
[0].bw_tbl
) &&
499 (DCBX_INVALID_COS_BW
!= ets
->cos_params
[1].bw_tbl
)) {
500 u32 bw_tbl_0
= ets
->cos_params
[0].bw_tbl
;
501 u32 bw_tbl_1
= ets
->cos_params
[1].bw_tbl
;
502 /* Do not allow 0-100 configuration
503 * since PBF does not support it
509 } else if (bw_tbl_1
== 0) {
514 bnx2x_ets_bw_limit(&bp
->link_params
, bw_tbl_0
, bw_tbl_1
);
516 if (ets
->cos_params
[0].strict
== BNX2X_DCBX_STRICT_COS_HIGHEST
)
517 rc
= bnx2x_ets_strict(&bp
->link_params
, 0);
518 else if (ets
->cos_params
[1].strict
519 == BNX2X_DCBX_STRICT_COS_HIGHEST
)
520 rc
= bnx2x_ets_strict(&bp
->link_params
, 1);
522 BNX2X_ERR("update_ets_params failed\n");
527 * In E3B0 the configuration may have more than 2 COS.
529 void bnx2x_dcbx_update_ets_config(struct bnx2x
*bp
)
531 struct bnx2x_dcbx_pg_params
*ets
= &(bp
->dcbx_port_params
.ets
);
532 struct bnx2x_ets_params ets_params
= { 0 };
535 ets_params
.num_of_cos
= ets
->num_of_cos
;
537 for (i
= 0; i
< ets
->num_of_cos
; i
++) {
539 if (ets
->cos_params
[i
].strict
!= BNX2X_DCBX_STRICT_INVALID
) {
540 if (ets
->cos_params
[i
].bw_tbl
!= DCBX_INVALID_COS_BW
) {
541 BNX2X_ERR("COS can't be not BW and not SP\n");
545 ets_params
.cos
[i
].state
= bnx2x_cos_state_strict
;
546 ets_params
.cos
[i
].params
.sp_params
.pri
=
547 ets
->cos_params
[i
].strict
;
548 } else { /* COS is BW */
549 if (ets
->cos_params
[i
].bw_tbl
== DCBX_INVALID_COS_BW
) {
550 BNX2X_ERR("COS can't be not BW and not SP\n");
553 ets_params
.cos
[i
].state
= bnx2x_cos_state_bw
;
554 ets_params
.cos
[i
].params
.bw_params
.bw
=
555 (u8
)ets
->cos_params
[i
].bw_tbl
;
559 /* Configure the ETS in HW */
560 if (bnx2x_ets_e3b0_config(&bp
->link_params
, &bp
->link_vars
,
562 BNX2X_ERR("bnx2x_ets_e3b0_config failed\n");
563 bnx2x_ets_disabled(&bp
->link_params
, &bp
->link_vars
);
567 static void bnx2x_dcbx_update_ets_params(struct bnx2x
*bp
)
569 bnx2x_ets_disabled(&bp
->link_params
, &bp
->link_vars
);
571 if (!bp
->dcbx_port_params
.ets
.enabled
||
572 (bp
->dcbx_error
& DCBX_REMOTE_MIB_ERROR
))
575 if (CHIP_IS_E3B0(bp
))
576 bnx2x_dcbx_update_ets_config(bp
);
578 bnx2x_dcbx_2cos_limit_update_ets_config(bp
);
582 static int bnx2x_dcbx_read_shmem_remote_mib(struct bnx2x
*bp
)
584 struct lldp_remote_mib remote_mib
= {0};
585 u32 dcbx_remote_mib_offset
= SHMEM2_RD(bp
, dcbx_remote_mib_offset
);
588 DP(NETIF_MSG_LINK
, "dcbx_remote_mib_offset 0x%x\n",
589 dcbx_remote_mib_offset
);
591 if (SHMEM_DCBX_REMOTE_MIB_NONE
== dcbx_remote_mib_offset
) {
592 BNX2X_ERR("FW doesn't support dcbx_remote_mib_offset\n");
596 rc
= bnx2x_dcbx_read_mib(bp
, (u32
*)&remote_mib
, dcbx_remote_mib_offset
,
597 DCBX_READ_REMOTE_MIB
);
600 BNX2X_ERR("Faild to read remote mib from FW\n");
604 /* save features and flags */
605 bp
->dcbx_remote_feat
= remote_mib
.features
;
606 bp
->dcbx_remote_flags
= remote_mib
.flags
;
611 static int bnx2x_dcbx_read_shmem_neg_results(struct bnx2x
*bp
)
613 struct lldp_local_mib local_mib
= {0};
614 u32 dcbx_neg_res_offset
= SHMEM2_RD(bp
, dcbx_neg_res_offset
);
617 DP(NETIF_MSG_LINK
, "dcbx_neg_res_offset 0x%x\n", dcbx_neg_res_offset
);
619 if (SHMEM_DCBX_NEG_RES_NONE
== dcbx_neg_res_offset
) {
620 BNX2X_ERR("FW doesn't support dcbx_neg_res_offset\n");
624 rc
= bnx2x_dcbx_read_mib(bp
, (u32
*)&local_mib
, dcbx_neg_res_offset
,
625 DCBX_READ_LOCAL_MIB
);
628 BNX2X_ERR("Faild to read local mib from FW\n");
632 /* save features and error */
633 bp
->dcbx_local_feat
= local_mib
.features
;
634 bp
->dcbx_error
= local_mib
.error
;
641 u8
bnx2x_dcbx_dcbnl_app_up(struct dcbx_app_priority_entry
*ent
)
645 /* Choose the highest priority */
646 for (pri
= MAX_PFC_PRIORITIES
- 1; pri
> 0; pri
--)
647 if (ent
->pri_bitmap
& (1 << pri
))
653 u8
bnx2x_dcbx_dcbnl_app_idtype(struct dcbx_app_priority_entry
*ent
)
655 return ((ent
->appBitfield
& DCBX_APP_ENTRY_SF_MASK
) ==
656 DCBX_APP_SF_PORT
) ? DCB_APP_IDTYPE_PORTNUM
:
657 DCB_APP_IDTYPE_ETHTYPE
;
660 int bnx2x_dcbnl_update_applist(struct bnx2x
*bp
, bool delall
)
664 for (i
= 0; i
< DCBX_MAX_APP_PROTOCOL
&& err
== 0; i
++) {
665 struct dcbx_app_priority_entry
*ent
=
666 &bp
->dcbx_local_feat
.app
.app_pri_tbl
[i
];
668 if (ent
->appBitfield
& DCBX_APP_ENTRY_VALID
) {
669 u8 up
= bnx2x_dcbx_dcbnl_app_up(ent
);
671 /* avoid invalid user-priority */
674 app
.selector
= bnx2x_dcbx_dcbnl_app_idtype(ent
);
675 app
.protocol
= ent
->app_id
;
676 app
.priority
= delall
? 0 : up
;
677 err
= dcb_setapp(bp
->dev
, &app
);
685 static inline void bnx2x_update_drv_flags(struct bnx2x
*bp
, u32 flags
, u32 set
)
687 if (SHMEM2_HAS(bp
, drv_flags
)) {
689 bnx2x_acquire_hw_lock(bp
, HW_LOCK_DRV_FLAGS
);
690 drv_flags
= SHMEM2_RD(bp
, drv_flags
);
693 SET_FLAGS(drv_flags
, flags
);
695 RESET_FLAGS(drv_flags
, flags
);
697 SHMEM2_WR(bp
, drv_flags
, drv_flags
);
698 DP(NETIF_MSG_HW
, "drv_flags 0x%08x\n", drv_flags
);
699 bnx2x_release_hw_lock(bp
, HW_LOCK_DRV_FLAGS
);
703 static inline void bnx2x_dcbx_update_tc_mapping(struct bnx2x
*bp
)
706 for (cos
= 0; cos
< bp
->dcbx_port_params
.ets
.num_of_cos
; cos
++) {
707 for (prio
= 0; prio
< BNX2X_MAX_PRIORITY
; prio
++) {
708 if (bp
->dcbx_port_params
.ets
.cos_params
[cos
].pri_bitmask
710 bp
->prio_to_cos
[prio
] = cos
;
712 "tx_mapping %d --> %d\n", prio
, cos
);
717 /* setup tc must be called under rtnl lock, but we can't take it here
718 * as we are handling an attetntion on a work queue which must be
719 * flushed at some rtnl-locked contexts (e.g. if down)
721 if (!test_and_set_bit(BNX2X_SP_RTNL_SETUP_TC
, &bp
->sp_rtnl_state
))
722 schedule_delayed_work(&bp
->sp_rtnl_task
, 0);
725 void bnx2x_dcbx_set_params(struct bnx2x
*bp
, u32 state
)
728 case BNX2X_DCBX_STATE_NEG_RECEIVED
:
730 DP(NETIF_MSG_LINK
, "BNX2X_DCBX_STATE_NEG_RECEIVED\n");
733 * Delete app tlvs from dcbnl before reading new
734 * negotiation results
736 bnx2x_dcbnl_update_applist(bp
, true);
738 /* Read rmeote mib if dcbx is in the FW */
739 if (bnx2x_dcbx_read_shmem_remote_mib(bp
))
742 /* Read neg results if dcbx is in the FW */
743 if (bnx2x_dcbx_read_shmem_neg_results(bp
))
746 bnx2x_dump_dcbx_drv_param(bp
, &bp
->dcbx_local_feat
,
749 bnx2x_get_dcbx_drv_param(bp
, &bp
->dcbx_local_feat
,
752 /* mark DCBX result for PMF migration */
753 bnx2x_update_drv_flags(bp
, DRV_FLAGS_DCB_CONFIGURED
, 1);
756 * Add new app tlvs to dcbnl
758 bnx2x_dcbnl_update_applist(bp
, false);
760 bnx2x_dcbx_stop_hw_tx(bp
);
762 /* reconfigure the netdevice with the results of the new
765 bnx2x_dcbx_update_tc_mapping(bp
);
769 case BNX2X_DCBX_STATE_TX_PAUSED
:
770 DP(NETIF_MSG_LINK
, "BNX2X_DCBX_STATE_TX_PAUSED\n");
771 bnx2x_pfc_set_pfc(bp
);
773 bnx2x_dcbx_update_ets_params(bp
);
774 bnx2x_dcbx_resume_hw_tx(bp
);
776 case BNX2X_DCBX_STATE_TX_RELEASED
:
777 DP(NETIF_MSG_LINK
, "BNX2X_DCBX_STATE_TX_RELEASED\n");
778 bnx2x_fw_command(bp
, DRV_MSG_CODE_DCBX_PMF_DRV_OK
, 0);
781 * Send a notification for the new negotiated parameters
783 dcbnl_cee_notify(bp
->dev
, RTM_GETDCB
, DCB_CMD_CEE_GET
, 0, 0);
787 BNX2X_ERR("Unknown DCBX_STATE\n");
791 #define LLDP_ADMIN_MIB_OFFSET(bp) (PORT_MAX*sizeof(struct lldp_params) + \
792 BP_PORT(bp)*sizeof(struct lldp_admin_mib))
794 static void bnx2x_dcbx_admin_mib_updated_params(struct bnx2x
*bp
,
795 u32 dcbx_lldp_params_offset
)
797 struct lldp_admin_mib admin_mib
;
798 u32 i
, other_traf_type
= PREDEFINED_APP_IDX_MAX
, traf_type
= 0;
799 u32 offset
= dcbx_lldp_params_offset
+ LLDP_ADMIN_MIB_OFFSET(bp
);
802 struct dcbx_features
*af
= &admin_mib
.features
;
803 struct bnx2x_config_dcbx_params
*dp
= &bp
->dcbx_config_params
;
805 memset(&admin_mib
, 0, sizeof(struct lldp_admin_mib
));
807 /* Read the data first */
808 bnx2x_read_data(bp
, (u32
*)&admin_mib
, offset
,
809 sizeof(struct lldp_admin_mib
));
811 if (bp
->dcbx_enabled
== BNX2X_DCBX_ENABLED_ON_NEG_ON
)
812 SET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_DCBX_ENABLED
);
814 RESET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_DCBX_ENABLED
);
816 if (dp
->overwrite_settings
== BNX2X_DCBX_OVERWRITE_SETTINGS_ENABLE
) {
818 RESET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_CEE_VERSION_MASK
);
819 admin_mib
.ver_cfg_flags
|=
820 (dp
->admin_dcbx_version
<< DCBX_CEE_VERSION_SHIFT
) &
821 DCBX_CEE_VERSION_MASK
;
823 af
->ets
.enabled
= (u8
)dp
->admin_ets_enable
;
825 af
->pfc
.enabled
= (u8
)dp
->admin_pfc_enable
;
827 /* FOR IEEE dp->admin_tc_supported_tx_enable */
828 if (dp
->admin_ets_configuration_tx_enable
)
829 SET_FLAGS(admin_mib
.ver_cfg_flags
,
830 DCBX_ETS_CONFIG_TX_ENABLED
);
832 RESET_FLAGS(admin_mib
.ver_cfg_flags
,
833 DCBX_ETS_CONFIG_TX_ENABLED
);
834 /* For IEEE admin_ets_recommendation_tx_enable */
835 if (dp
->admin_pfc_tx_enable
)
836 SET_FLAGS(admin_mib
.ver_cfg_flags
,
837 DCBX_PFC_CONFIG_TX_ENABLED
);
839 RESET_FLAGS(admin_mib
.ver_cfg_flags
,
840 DCBX_PFC_CONFIG_TX_ENABLED
);
842 if (dp
->admin_application_priority_tx_enable
)
843 SET_FLAGS(admin_mib
.ver_cfg_flags
,
844 DCBX_APP_CONFIG_TX_ENABLED
);
846 RESET_FLAGS(admin_mib
.ver_cfg_flags
,
847 DCBX_APP_CONFIG_TX_ENABLED
);
849 if (dp
->admin_ets_willing
)
850 SET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_ETS_WILLING
);
852 RESET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_ETS_WILLING
);
853 /* For IEEE admin_ets_reco_valid */
854 if (dp
->admin_pfc_willing
)
855 SET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_PFC_WILLING
);
857 RESET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_PFC_WILLING
);
859 if (dp
->admin_app_priority_willing
)
860 SET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_APP_WILLING
);
862 RESET_FLAGS(admin_mib
.ver_cfg_flags
, DCBX_APP_WILLING
);
864 for (i
= 0 ; i
< DCBX_MAX_NUM_PG_BW_ENTRIES
; i
++) {
865 DCBX_PG_BW_SET(af
->ets
.pg_bw_tbl
, i
,
866 (u8
)dp
->admin_configuration_bw_precentage
[i
]);
868 DP(NETIF_MSG_LINK
, "pg_bw_tbl[%d] = %02x\n",
869 i
, DCBX_PG_BW_GET(af
->ets
.pg_bw_tbl
, i
));
872 for (i
= 0; i
< DCBX_MAX_NUM_PRI_PG_ENTRIES
; i
++) {
873 DCBX_PRI_PG_SET(af
->ets
.pri_pg_tbl
, i
,
874 (u8
)dp
->admin_configuration_ets_pg
[i
]);
876 DP(NETIF_MSG_LINK
, "pri_pg_tbl[%d] = %02x\n",
877 i
, DCBX_PRI_PG_GET(af
->ets
.pri_pg_tbl
, i
));
880 /*For IEEE admin_recommendation_bw_precentage
881 *For IEEE admin_recommendation_ets_pg */
882 af
->pfc
.pri_en_bitmap
= (u8
)dp
->admin_pfc_bitmap
;
883 for (i
= 0; i
< 4; i
++) {
884 if (dp
->admin_priority_app_table
[i
].valid
) {
885 struct bnx2x_admin_priority_app_table
*table
=
886 dp
->admin_priority_app_table
;
887 if ((ETH_TYPE_FCOE
== table
[i
].app_id
) &&
888 (TRAFFIC_TYPE_ETH
== table
[i
].traffic_type
))
889 traf_type
= FCOE_APP_IDX
;
890 else if ((TCP_PORT_ISCSI
== table
[i
].app_id
) &&
891 (TRAFFIC_TYPE_PORT
== table
[i
].traffic_type
))
892 traf_type
= ISCSI_APP_IDX
;
894 traf_type
= other_traf_type
++;
896 af
->app
.app_pri_tbl
[traf_type
].app_id
=
899 af
->app
.app_pri_tbl
[traf_type
].pri_bitmap
=
900 (u8
)(1 << table
[i
].priority
);
902 af
->app
.app_pri_tbl
[traf_type
].appBitfield
=
903 (DCBX_APP_ENTRY_VALID
);
905 af
->app
.app_pri_tbl
[traf_type
].appBitfield
|=
906 (TRAFFIC_TYPE_ETH
== table
[i
].traffic_type
) ?
907 DCBX_APP_SF_ETH_TYPE
: DCBX_APP_SF_PORT
;
911 af
->app
.default_pri
= (u8
)dp
->admin_default_priority
;
915 /* Write the data. */
916 bnx2x_write_data(bp
, (u32
*)&admin_mib
, offset
,
917 sizeof(struct lldp_admin_mib
));
921 void bnx2x_dcbx_set_state(struct bnx2x
*bp
, bool dcb_on
, u32 dcbx_enabled
)
923 if (!CHIP_IS_E1x(bp
) && !CHIP_IS_E3(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_admin_mib_updated_params(bp
,
1033 dcbx_lldp_params_offset
);
1035 /* Let HW start negotiation */
1036 bnx2x_fw_command(bp
,
1037 DRV_MSG_CODE_DCBX_ADMIN_PMF_MSG
, 0);
1042 bnx2x_dcbx_print_cos_params(struct bnx2x
*bp
,
1043 struct bnx2x_func_tx_start_params
*pfc_fw_cfg
)
1049 "pfc_fw_cfg->dcb_version %x\n", pfc_fw_cfg
->dcb_version
);
1051 "pdev->params.dcbx_port_params.pfc."
1052 "priority_non_pauseable_mask %x\n",
1053 bp
->dcbx_port_params
.pfc
.priority_non_pauseable_mask
);
1055 for (cos
= 0 ; cos
< bp
->dcbx_port_params
.ets
.num_of_cos
; cos
++) {
1056 DP(NETIF_MSG_LINK
, "pdev->params.dcbx_port_params.ets."
1057 "cos_params[%d].pri_bitmask %x\n", cos
,
1058 bp
->dcbx_port_params
.ets
.cos_params
[cos
].pri_bitmask
);
1060 DP(NETIF_MSG_LINK
, "pdev->params.dcbx_port_params.ets."
1061 "cos_params[%d].bw_tbl %x\n", cos
,
1062 bp
->dcbx_port_params
.ets
.cos_params
[cos
].bw_tbl
);
1064 DP(NETIF_MSG_LINK
, "pdev->params.dcbx_port_params.ets."
1065 "cos_params[%d].strict %x\n", cos
,
1066 bp
->dcbx_port_params
.ets
.cos_params
[cos
].strict
);
1068 DP(NETIF_MSG_LINK
, "pdev->params.dcbx_port_params.ets."
1069 "cos_params[%d].pauseable %x\n", cos
,
1070 bp
->dcbx_port_params
.ets
.cos_params
[cos
].pauseable
);
1073 for (pri
= 0; pri
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
; pri
++) {
1075 "pfc_fw_cfg->traffic_type_to_priority_cos[%d]."
1076 "priority %x\n", pri
,
1077 pfc_fw_cfg
->traffic_type_to_priority_cos
[pri
].priority
);
1080 "pfc_fw_cfg->traffic_type_to_priority_cos[%d].cos %x\n",
1081 pri
, pfc_fw_cfg
->traffic_type_to_priority_cos
[pri
].cos
);
1085 /* fills help_data according to pg_info */
1086 static void bnx2x_dcbx_get_num_pg_traf_type(struct bnx2x
*bp
,
1087 u32
*pg_pri_orginal_spread
,
1088 struct pg_help_data
*help_data
)
1090 bool pg_found
= false;
1091 u32 i
, traf_type
, add_traf_type
, add_pg
;
1092 u32
*ttp
= bp
->dcbx_port_params
.app
.traffic_type_priority
;
1093 struct pg_entry_help_data
*data
= help_data
->data
; /*shotcut*/
1095 /* Set to invalid */
1096 for (i
= 0; i
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
; i
++)
1097 data
[i
].pg
= DCBX_ILLEGAL_PG
;
1099 for (add_traf_type
= 0;
1100 add_traf_type
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
; add_traf_type
++) {
1102 if (ttp
[add_traf_type
] < MAX_PFC_PRIORITIES
) {
1103 add_pg
= (u8
)pg_pri_orginal_spread
[ttp
[add_traf_type
]];
1105 traf_type
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
;
1107 if (data
[traf_type
].pg
== add_pg
) {
1108 if (!(data
[traf_type
].pg_priority
&
1109 (1 << ttp
[add_traf_type
])))
1112 data
[traf_type
].pg_priority
|=
1113 (1 << ttp
[add_traf_type
]);
1118 if (false == pg_found
) {
1119 data
[help_data
->num_of_pg
].pg
= add_pg
;
1120 data
[help_data
->num_of_pg
].pg_priority
=
1121 (1 << ttp
[add_traf_type
]);
1122 data
[help_data
->num_of_pg
].num_of_dif_pri
= 1;
1123 help_data
->num_of_pg
++;
1127 "add_traf_type %d pg_found %s num_of_pg %d\n",
1128 add_traf_type
, (false == pg_found
) ? "NO" : "YES",
1129 help_data
->num_of_pg
);
1133 static void bnx2x_dcbx_ets_disabled_entry_data(struct bnx2x
*bp
,
1134 struct cos_help_data
*cos_data
,
1137 /* Only one priority than only one COS */
1138 cos_data
->data
[0].pausable
=
1139 IS_DCBX_PFC_PRI_ONLY_PAUSE(bp
, pri_join_mask
);
1140 cos_data
->data
[0].pri_join_mask
= pri_join_mask
;
1141 cos_data
->data
[0].cos_bw
= 100;
1142 cos_data
->num_of_cos
= 1;
1145 static inline void bnx2x_dcbx_add_to_cos_bw(struct bnx2x
*bp
,
1146 struct cos_entry_help_data
*data
,
1149 if (data
->cos_bw
== DCBX_INVALID_COS_BW
)
1150 data
->cos_bw
= pg_bw
;
1152 data
->cos_bw
+= pg_bw
;
1155 static void bnx2x_dcbx_separate_pauseable_from_non(struct bnx2x
*bp
,
1156 struct cos_help_data
*cos_data
,
1157 u32
*pg_pri_orginal_spread
,
1158 struct dcbx_ets_feature
*ets
)
1164 u8 num_of_pri
= LLFC_DRIVER_TRAFFIC_TYPE_MAX
;
1166 cos_data
->data
[0].pausable
= true;
1167 cos_data
->data
[1].pausable
= false;
1168 cos_data
->data
[0].pri_join_mask
= cos_data
->data
[1].pri_join_mask
= 0;
1170 for (i
= 0 ; i
< num_of_pri
; i
++) {
1171 pri_tested
= 1 << bp
->dcbx_port_params
.
1172 app
.traffic_type_priority
[i
];
1174 if (pri_tested
& DCBX_PFC_PRI_NON_PAUSE_MASK(bp
)) {
1175 cos_data
->data
[1].pri_join_mask
|= pri_tested
;
1178 cos_data
->data
[0].pri_join_mask
|= pri_tested
;
1181 pg_entry
= (u8
)pg_pri_orginal_spread
[bp
->dcbx_port_params
.
1182 app
.traffic_type_priority
[i
]];
1183 /* There can be only one strict pg */
1184 if (pg_entry
< DCBX_MAX_NUM_PG_BW_ENTRIES
)
1185 bnx2x_dcbx_add_to_cos_bw(bp
, &cos_data
->data
[entry
],
1186 DCBX_PG_BW_GET(ets
->pg_bw_tbl
, pg_entry
));
1188 /* If we join a group and one is strict
1189 * than the bw rulls */
1190 cos_data
->data
[entry
].strict
=
1191 BNX2X_DCBX_STRICT_COS_HIGHEST
;
1193 if ((0 == cos_data
->data
[0].pri_join_mask
) &&
1194 (0 == cos_data
->data
[1].pri_join_mask
))
1195 BNX2X_ERR("dcbx error: Both groups must have priorities\n");
1200 #define POWER_OF_2(x) ((0 != x) && (0 == (x & (x-1))))
1203 static void bnx2x_dcbx_2cos_limit_cee_single_pg_to_cos_params(struct bnx2x
*bp
,
1204 struct pg_help_data
*pg_help_data
,
1205 struct cos_help_data
*cos_data
,
1211 u32 pri_mask_without_pri
= 0;
1212 u32
*ttp
= bp
->dcbx_port_params
.app
.traffic_type_priority
;
1214 if (num_of_dif_pri
== 1) {
1215 bnx2x_dcbx_ets_disabled_entry_data(bp
, cos_data
, pri_join_mask
);
1218 /* single priority group */
1219 if (pg_help_data
->data
[0].pg
< DCBX_MAX_NUM_PG_BW_ENTRIES
) {
1220 /* If there are both pauseable and non-pauseable priorities,
1221 * the pauseable priorities go to the first queue and
1222 * the non-pauseable priorities go to the second queue.
1224 if (IS_DCBX_PFC_PRI_MIX_PAUSE(bp
, pri_join_mask
)) {
1226 cos_data
->data
[0].pausable
= true;
1228 cos_data
->data
[1].pausable
= false;
1230 if (2 == num_of_dif_pri
) {
1231 cos_data
->data
[0].cos_bw
= 50;
1232 cos_data
->data
[1].cos_bw
= 50;
1235 if (3 == num_of_dif_pri
) {
1236 if (POWER_OF_2(DCBX_PFC_PRI_GET_PAUSE(bp
,
1238 cos_data
->data
[0].cos_bw
= 33;
1239 cos_data
->data
[1].cos_bw
= 67;
1241 cos_data
->data
[0].cos_bw
= 67;
1242 cos_data
->data
[1].cos_bw
= 33;
1246 } else if (IS_DCBX_PFC_PRI_ONLY_PAUSE(bp
, pri_join_mask
)) {
1247 /* If there are only pauseable priorities,
1248 * then one/two priorities go to the first queue
1249 * and one priority goes to the second queue.
1251 if (2 == num_of_dif_pri
) {
1252 cos_data
->data
[0].cos_bw
= 50;
1253 cos_data
->data
[1].cos_bw
= 50;
1255 cos_data
->data
[0].cos_bw
= 67;
1256 cos_data
->data
[1].cos_bw
= 33;
1258 cos_data
->data
[1].pausable
= true;
1259 cos_data
->data
[0].pausable
= true;
1260 /* All priorities except FCOE */
1261 cos_data
->data
[0].pri_join_mask
= (pri_join_mask
&
1262 ((u8
)~(1 << ttp
[LLFC_TRAFFIC_TYPE_FCOE
])));
1263 /* Only FCOE priority.*/
1264 cos_data
->data
[1].pri_join_mask
=
1265 (1 << ttp
[LLFC_TRAFFIC_TYPE_FCOE
]);
1267 /* If there are only non-pauseable priorities,
1268 * they will all go to the same queue.
1270 bnx2x_dcbx_ets_disabled_entry_data(bp
,
1271 cos_data
, pri_join_mask
);
1273 /* priority group which is not BW limited (PG#15):*/
1274 if (IS_DCBX_PFC_PRI_MIX_PAUSE(bp
, pri_join_mask
)) {
1275 /* If there are both pauseable and non-pauseable
1276 * priorities, the pauseable priorities go to the first
1277 * queue and the non-pauseable priorities
1278 * go to the second queue.
1280 if (DCBX_PFC_PRI_GET_PAUSE(bp
, pri_join_mask
) >
1281 DCBX_PFC_PRI_GET_NON_PAUSE(bp
, pri_join_mask
)) {
1282 cos_data
->data
[0].strict
=
1283 BNX2X_DCBX_STRICT_COS_HIGHEST
;
1284 cos_data
->data
[1].strict
=
1285 BNX2X_DCBX_STRICT_COS_NEXT_LOWER_PRI(
1286 BNX2X_DCBX_STRICT_COS_HIGHEST
);
1288 cos_data
->data
[0].strict
=
1289 BNX2X_DCBX_STRICT_COS_NEXT_LOWER_PRI(
1290 BNX2X_DCBX_STRICT_COS_HIGHEST
);
1291 cos_data
->data
[1].strict
=
1292 BNX2X_DCBX_STRICT_COS_HIGHEST
;
1295 cos_data
->data
[0].pausable
= true;
1296 /* Non pause-able.*/
1297 cos_data
->data
[1].pausable
= false;
1299 /* If there are only pauseable priorities or
1300 * only non-pauseable,* the lower priorities go
1301 * to the first queue and the higherpriorities go
1302 * to the second queue.
1304 cos_data
->data
[0].pausable
=
1305 cos_data
->data
[1].pausable
=
1306 IS_DCBX_PFC_PRI_ONLY_PAUSE(bp
, pri_join_mask
);
1308 for (i
= 0 ; i
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
; i
++) {
1309 pri_tested
= 1 << bp
->dcbx_port_params
.
1310 app
.traffic_type_priority
[i
];
1311 /* Remove priority tested */
1312 pri_mask_without_pri
=
1313 (pri_join_mask
& ((u8
)(~pri_tested
)));
1314 if (pri_mask_without_pri
< pri_tested
)
1318 if (i
== LLFC_DRIVER_TRAFFIC_TYPE_MAX
)
1319 BNX2X_ERR("Invalid value for pri_join_mask -"
1320 " could not find a priority\n");
1322 cos_data
->data
[0].pri_join_mask
= pri_mask_without_pri
;
1323 cos_data
->data
[1].pri_join_mask
= pri_tested
;
1324 /* Both queues are strict priority,
1325 * and that with the highest priority
1326 * gets the highest strict priority in the arbiter.
1328 cos_data
->data
[0].strict
=
1329 BNX2X_DCBX_STRICT_COS_NEXT_LOWER_PRI(
1330 BNX2X_DCBX_STRICT_COS_HIGHEST
);
1331 cos_data
->data
[1].strict
=
1332 BNX2X_DCBX_STRICT_COS_HIGHEST
;
1337 static void bnx2x_dcbx_2cos_limit_cee_two_pg_to_cos_params(
1339 struct pg_help_data
*pg_help_data
,
1340 struct dcbx_ets_feature
*ets
,
1341 struct cos_help_data
*cos_data
,
1342 u32
*pg_pri_orginal_spread
,
1347 u8 pg
[DCBX_COS_MAX_NUM_E2
] = { 0 };
1349 /* If there are both pauseable and non-pauseable priorities,
1350 * the pauseable priorities go to the first queue and
1351 * the non-pauseable priorities go to the second queue.
1353 if (IS_DCBX_PFC_PRI_MIX_PAUSE(bp
, pri_join_mask
)) {
1354 if (IS_DCBX_PFC_PRI_MIX_PAUSE(bp
,
1355 pg_help_data
->data
[0].pg_priority
) ||
1356 IS_DCBX_PFC_PRI_MIX_PAUSE(bp
,
1357 pg_help_data
->data
[1].pg_priority
)) {
1358 /* If one PG contains both pauseable and
1359 * non-pauseable priorities then ETS is disabled.
1361 bnx2x_dcbx_separate_pauseable_from_non(bp
, cos_data
,
1362 pg_pri_orginal_spread
, ets
);
1363 bp
->dcbx_port_params
.ets
.enabled
= false;
1368 cos_data
->data
[0].pausable
= true;
1369 /* Non pauseable. */
1370 cos_data
->data
[1].pausable
= false;
1371 if (IS_DCBX_PFC_PRI_ONLY_PAUSE(bp
,
1372 pg_help_data
->data
[0].pg_priority
)) {
1373 /* 0 is pauseable */
1374 cos_data
->data
[0].pri_join_mask
=
1375 pg_help_data
->data
[0].pg_priority
;
1376 pg
[0] = pg_help_data
->data
[0].pg
;
1377 cos_data
->data
[1].pri_join_mask
=
1378 pg_help_data
->data
[1].pg_priority
;
1379 pg
[1] = pg_help_data
->data
[1].pg
;
1380 } else {/* 1 is pauseable */
1381 cos_data
->data
[0].pri_join_mask
=
1382 pg_help_data
->data
[1].pg_priority
;
1383 pg
[0] = pg_help_data
->data
[1].pg
;
1384 cos_data
->data
[1].pri_join_mask
=
1385 pg_help_data
->data
[0].pg_priority
;
1386 pg
[1] = pg_help_data
->data
[0].pg
;
1389 /* If there are only pauseable priorities or
1390 * only non-pauseable, each PG goes to a queue.
1392 cos_data
->data
[0].pausable
= cos_data
->data
[1].pausable
=
1393 IS_DCBX_PFC_PRI_ONLY_PAUSE(bp
, pri_join_mask
);
1394 cos_data
->data
[0].pri_join_mask
=
1395 pg_help_data
->data
[0].pg_priority
;
1396 pg
[0] = pg_help_data
->data
[0].pg
;
1397 cos_data
->data
[1].pri_join_mask
=
1398 pg_help_data
->data
[1].pg_priority
;
1399 pg
[1] = pg_help_data
->data
[1].pg
;
1402 /* There can be only one strict pg */
1403 for (i
= 0 ; i
< ARRAY_SIZE(pg
); i
++) {
1404 if (pg
[i
] < DCBX_MAX_NUM_PG_BW_ENTRIES
)
1405 cos_data
->data
[i
].cos_bw
=
1406 DCBX_PG_BW_GET(ets
->pg_bw_tbl
, pg
[i
]);
1408 cos_data
->data
[i
].strict
=
1409 BNX2X_DCBX_STRICT_COS_HIGHEST
;
1413 static int bnx2x_dcbx_join_pgs(
1415 struct dcbx_ets_feature
*ets
,
1416 struct pg_help_data
*pg_help_data
,
1417 u8 required_num_of_pg
)
1419 u8 entry_joined
= pg_help_data
->num_of_pg
- 1;
1420 u8 entry_removed
= entry_joined
+ 1;
1423 if (required_num_of_pg
== 0 || ARRAY_SIZE(pg_help_data
->data
)
1424 <= pg_help_data
->num_of_pg
) {
1426 BNX2X_ERR("required_num_of_pg can't be zero\n");
1430 while (required_num_of_pg
< pg_help_data
->num_of_pg
) {
1431 entry_joined
= pg_help_data
->num_of_pg
- 2;
1432 entry_removed
= entry_joined
+ 1;
1434 entry_removed
%= ARRAY_SIZE(pg_help_data
->data
);
1436 pg_help_data
->data
[entry_joined
].pg_priority
|=
1437 pg_help_data
->data
[entry_removed
].pg_priority
;
1439 pg_help_data
->data
[entry_joined
].num_of_dif_pri
+=
1440 pg_help_data
->data
[entry_removed
].num_of_dif_pri
;
1442 if (pg_help_data
->data
[entry_joined
].pg
== DCBX_STRICT_PRI_PG
||
1443 pg_help_data
->data
[entry_removed
].pg
== DCBX_STRICT_PRI_PG
)
1444 /* Entries joined strict priority rules */
1445 pg_help_data
->data
[entry_joined
].pg
=
1448 /* Entries can be joined join BW */
1449 pg_joined
= DCBX_PG_BW_GET(ets
->pg_bw_tbl
,
1450 pg_help_data
->data
[entry_joined
].pg
) +
1451 DCBX_PG_BW_GET(ets
->pg_bw_tbl
,
1452 pg_help_data
->data
[entry_removed
].pg
);
1454 DCBX_PG_BW_SET(ets
->pg_bw_tbl
,
1455 pg_help_data
->data
[entry_joined
].pg
, pg_joined
);
1457 /* Joined the entries */
1458 pg_help_data
->num_of_pg
--;
1464 static void bnx2x_dcbx_2cos_limit_cee_three_pg_to_cos_params(
1466 struct pg_help_data
*pg_help_data
,
1467 struct dcbx_ets_feature
*ets
,
1468 struct cos_help_data
*cos_data
,
1469 u32
*pg_pri_orginal_spread
,
1477 bool b_found_strict
= false;
1478 u8 num_of_pri
= LLFC_DRIVER_TRAFFIC_TYPE_MAX
;
1480 cos_data
->data
[0].pri_join_mask
= cos_data
->data
[1].pri_join_mask
= 0;
1481 /* If there are both pauseable and non-pauseable priorities,
1482 * the pauseable priorities go to the first queue and the
1483 * non-pauseable priorities go to the second queue.
1485 if (IS_DCBX_PFC_PRI_MIX_PAUSE(bp
, pri_join_mask
))
1486 bnx2x_dcbx_separate_pauseable_from_non(bp
,
1487 cos_data
, pg_pri_orginal_spread
, ets
);
1489 /* If two BW-limited PG-s were combined to one queue,
1490 * the BW is their sum.
1492 * If there are only pauseable priorities or only non-pauseable,
1493 * and there are both BW-limited and non-BW-limited PG-s,
1494 * the BW-limited PG/s go to one queue and the non-BW-limited
1495 * PG/s go to the second queue.
1497 * If there are only pauseable priorities or only non-pauseable
1498 * and all are BW limited, then two priorities go to the first
1499 * queue and one priority goes to the second queue.
1501 * We will join this two cases:
1502 * if one is BW limited it will go to the secoend queue
1503 * otherwise the last priority will get it
1506 cos_data
->data
[0].pausable
= cos_data
->data
[1].pausable
=
1507 IS_DCBX_PFC_PRI_ONLY_PAUSE(bp
, pri_join_mask
);
1509 for (i
= 0 ; i
< num_of_pri
; i
++) {
1510 pri_tested
= 1 << bp
->dcbx_port_params
.
1511 app
.traffic_type_priority
[i
];
1512 pg_entry
= (u8
)pg_pri_orginal_spread
[bp
->
1513 dcbx_port_params
.app
.traffic_type_priority
[i
]];
1515 if (pg_entry
< DCBX_MAX_NUM_PG_BW_ENTRIES
) {
1518 if (i
== (num_of_pri
-1) &&
1519 false == b_found_strict
)
1520 /* last entry will be handled separately
1521 * If no priority is strict than last
1522 * enty goes to last queue.*/
1524 cos_data
->data
[entry
].pri_join_mask
|=
1526 bnx2x_dcbx_add_to_cos_bw(bp
,
1527 &cos_data
->data
[entry
],
1528 DCBX_PG_BW_GET(ets
->pg_bw_tbl
,
1531 b_found_strict
= true;
1532 cos_data
->data
[1].pri_join_mask
|= pri_tested
;
1533 /* If we join a group and one is strict
1534 * than the bw rulls */
1535 cos_data
->data
[1].strict
=
1536 BNX2X_DCBX_STRICT_COS_HIGHEST
;
1543 static void bnx2x_dcbx_2cos_limit_cee_fill_cos_params(struct bnx2x
*bp
,
1544 struct pg_help_data
*help_data
,
1545 struct dcbx_ets_feature
*ets
,
1546 struct cos_help_data
*cos_data
,
1547 u32
*pg_pri_orginal_spread
,
1552 /* default E2 settings */
1553 cos_data
->num_of_cos
= DCBX_COS_MAX_NUM_E2
;
1555 switch (help_data
->num_of_pg
) {
1557 bnx2x_dcbx_2cos_limit_cee_single_pg_to_cos_params(
1565 bnx2x_dcbx_2cos_limit_cee_two_pg_to_cos_params(
1570 pg_pri_orginal_spread
,
1576 bnx2x_dcbx_2cos_limit_cee_three_pg_to_cos_params(
1581 pg_pri_orginal_spread
,
1586 BNX2X_ERR("Wrong pg_help_data.num_of_pg\n");
1587 bnx2x_dcbx_ets_disabled_entry_data(bp
,
1588 cos_data
, pri_join_mask
);
1592 static int bnx2x_dcbx_spread_strict_pri(struct bnx2x
*bp
,
1593 struct cos_help_data
*cos_data
,
1595 u8 num_spread_of_entries
,
1598 u8 strict_pri
= BNX2X_DCBX_STRICT_COS_HIGHEST
;
1599 u8 num_of_app_pri
= MAX_PFC_PRIORITIES
;
1602 while (num_spread_of_entries
&& num_of_app_pri
> 0) {
1603 app_pri_bit
= 1 << (num_of_app_pri
- 1);
1604 if (app_pri_bit
& strict_app_pris
) {
1605 struct cos_entry_help_data
*data
= &cos_data
->
1607 num_spread_of_entries
--;
1608 if (num_spread_of_entries
== 0) {
1609 /* last entry needed put all the entries left */
1610 data
->cos_bw
= DCBX_INVALID_COS_BW
;
1611 data
->strict
= strict_pri
;
1612 data
->pri_join_mask
= strict_app_pris
;
1613 data
->pausable
= DCBX_IS_PFC_PRI_SOME_PAUSE(bp
,
1614 data
->pri_join_mask
);
1616 strict_app_pris
&= ~app_pri_bit
;
1618 data
->cos_bw
= DCBX_INVALID_COS_BW
;
1619 data
->strict
= strict_pri
;
1620 data
->pri_join_mask
= app_pri_bit
;
1621 data
->pausable
= DCBX_IS_PFC_PRI_SOME_PAUSE(bp
,
1622 data
->pri_join_mask
);
1626 BNX2X_DCBX_STRICT_COS_NEXT_LOWER_PRI(strict_pri
);
1633 if (num_spread_of_entries
)
1639 static u8
bnx2x_dcbx_cee_fill_strict_pri(struct bnx2x
*bp
,
1640 struct cos_help_data
*cos_data
,
1642 u8 num_spread_of_entries
,
1646 if (bnx2x_dcbx_spread_strict_pri(bp
, cos_data
, entry
,
1647 num_spread_of_entries
,
1649 struct cos_entry_help_data
*data
= &cos_data
->
1652 data
->cos_bw
= DCBX_INVALID_COS_BW
;
1653 data
->strict
= BNX2X_DCBX_STRICT_COS_HIGHEST
;
1654 data
->pri_join_mask
= strict_app_pris
;
1655 data
->pausable
= DCBX_IS_PFC_PRI_SOME_PAUSE(bp
,
1656 data
->pri_join_mask
);
1660 return num_spread_of_entries
;
1663 static void bnx2x_dcbx_cee_fill_cos_params(struct bnx2x
*bp
,
1664 struct pg_help_data
*help_data
,
1665 struct dcbx_ets_feature
*ets
,
1666 struct cos_help_data
*cos_data
,
1670 u8 need_num_of_entries
= 0;
1675 * if the number of requested PG-s in CEE is greater than 3
1676 * then the results are not determined since this is a violation
1679 if (help_data
->num_of_pg
> DCBX_COS_MAX_NUM_E3B0
) {
1680 if (bnx2x_dcbx_join_pgs(bp
, ets
, help_data
,
1681 DCBX_COS_MAX_NUM_E3B0
)) {
1682 BNX2X_ERR("Unable to reduce the number of PGs -"
1683 "we will disables ETS\n");
1684 bnx2x_dcbx_ets_disabled_entry_data(bp
, cos_data
,
1690 for (i
= 0 ; i
< help_data
->num_of_pg
; i
++) {
1691 struct pg_entry_help_data
*pg
= &help_data
->data
[i
];
1692 if (pg
->pg
< DCBX_MAX_NUM_PG_BW_ENTRIES
) {
1693 struct cos_entry_help_data
*data
= &cos_data
->
1696 data
->cos_bw
= DCBX_PG_BW_GET(ets
->pg_bw_tbl
, pg
->pg
);
1697 data
->strict
= BNX2X_DCBX_STRICT_INVALID
;
1698 data
->pri_join_mask
= pg
->pg_priority
;
1699 data
->pausable
= DCBX_IS_PFC_PRI_SOME_PAUSE(bp
,
1700 data
->pri_join_mask
);
1704 need_num_of_entries
= min_t(u8
,
1705 (u8
)pg
->num_of_dif_pri
,
1706 (u8
)DCBX_COS_MAX_NUM_E3B0
-
1707 help_data
->num_of_pg
+ 1);
1709 * If there are still VOQ-s which have no associated PG,
1710 * then associate these VOQ-s to PG15. These PG-s will
1711 * be used for SP between priorities on PG15.
1713 entry
+= bnx2x_dcbx_cee_fill_strict_pri(bp
, cos_data
,
1714 entry
, need_num_of_entries
, pg
->pg_priority
);
1718 /* the entry will represent the number of COSes used */
1719 cos_data
->num_of_cos
= entry
;
1721 static void bnx2x_dcbx_fill_cos_params(struct bnx2x
*bp
,
1722 struct pg_help_data
*help_data
,
1723 struct dcbx_ets_feature
*ets
,
1724 u32
*pg_pri_orginal_spread
)
1726 struct cos_help_data cos_data
;
1728 u32 pri_join_mask
= 0;
1729 u8 num_of_dif_pri
= 0;
1731 memset(&cos_data
, 0, sizeof(cos_data
));
1733 /* Validate the pg value */
1734 for (i
= 0; i
< help_data
->num_of_pg
; i
++) {
1735 if (DCBX_STRICT_PRIORITY
!= help_data
->data
[i
].pg
&&
1736 DCBX_MAX_NUM_PG_BW_ENTRIES
<= help_data
->data
[i
].pg
)
1737 BNX2X_ERR("Invalid pg[%d] data %x\n", i
,
1738 help_data
->data
[i
].pg
);
1739 pri_join_mask
|= help_data
->data
[i
].pg_priority
;
1740 num_of_dif_pri
+= help_data
->data
[i
].num_of_dif_pri
;
1744 cos_data
.num_of_cos
= 1;
1745 for (i
= 0; i
< ARRAY_SIZE(cos_data
.data
); i
++) {
1746 cos_data
.data
[i
].pri_join_mask
= 0;
1747 cos_data
.data
[i
].pausable
= false;
1748 cos_data
.data
[i
].strict
= BNX2X_DCBX_STRICT_INVALID
;
1749 cos_data
.data
[i
].cos_bw
= DCBX_INVALID_COS_BW
;
1752 if (CHIP_IS_E3B0(bp
))
1753 bnx2x_dcbx_cee_fill_cos_params(bp
, help_data
, ets
,
1754 &cos_data
, pri_join_mask
);
1755 else /* E2 + E3A0 */
1756 bnx2x_dcbx_2cos_limit_cee_fill_cos_params(bp
,
1759 pg_pri_orginal_spread
,
1763 for (i
= 0; i
< cos_data
.num_of_cos
; i
++) {
1764 struct bnx2x_dcbx_cos_params
*p
=
1765 &bp
->dcbx_port_params
.ets
.cos_params
[i
];
1767 p
->strict
= cos_data
.data
[i
].strict
;
1768 p
->bw_tbl
= cos_data
.data
[i
].cos_bw
;
1769 p
->pri_bitmask
= cos_data
.data
[i
].pri_join_mask
;
1770 p
->pauseable
= cos_data
.data
[i
].pausable
;
1773 if (p
->bw_tbl
!= DCBX_INVALID_COS_BW
||
1774 p
->strict
!= BNX2X_DCBX_STRICT_INVALID
) {
1775 if (p
->pri_bitmask
== 0)
1776 BNX2X_ERR("Invalid pri_bitmask for %d\n", i
);
1778 if (CHIP_IS_E2(bp
) || CHIP_IS_E3A0(bp
)) {
1781 DCBX_PFC_PRI_GET_NON_PAUSE(bp
,
1782 p
->pri_bitmask
) != 0)
1783 BNX2X_ERR("Inconsistent config for "
1784 "pausable COS %d\n", i
);
1786 if (!p
->pauseable
&&
1787 DCBX_PFC_PRI_GET_PAUSE(bp
,
1788 p
->pri_bitmask
) != 0)
1789 BNX2X_ERR("Inconsistent config for "
1790 "nonpausable COS %d\n", i
);
1795 DP(NETIF_MSG_LINK
, "COS %d PAUSABLE prijoinmask 0x%x\n",
1796 i
, cos_data
.data
[i
].pri_join_mask
);
1798 DP(NETIF_MSG_LINK
, "COS %d NONPAUSABLE prijoinmask "
1800 i
, cos_data
.data
[i
].pri_join_mask
);
1803 bp
->dcbx_port_params
.ets
.num_of_cos
= cos_data
.num_of_cos
;
1806 static void bnx2x_dcbx_get_ets_pri_pg_tbl(struct bnx2x
*bp
,
1807 u32
*set_configuration_ets_pg
,
1812 for (i
= 0; i
< DCBX_MAX_NUM_PRI_PG_ENTRIES
; i
++) {
1813 set_configuration_ets_pg
[i
] = DCBX_PRI_PG_GET(pri_pg_tbl
, i
);
1815 DP(NETIF_MSG_LINK
, "set_configuration_ets_pg[%d] = 0x%x\n",
1816 i
, set_configuration_ets_pg
[i
]);
1820 static void bnx2x_dcbx_fw_struct(struct bnx2x
*bp
,
1821 struct bnx2x_func_tx_start_params
*pfc_fw_cfg
)
1824 u8 cos
= 0, pri
= 0;
1825 struct priority_cos
*tt2cos
;
1826 u32
*ttp
= bp
->dcbx_port_params
.app
.traffic_type_priority
;
1828 memset(pfc_fw_cfg
, 0, sizeof(*pfc_fw_cfg
));
1830 /* to disable DCB - the structure must be zeroed */
1831 if (bp
->dcbx_error
& DCBX_REMOTE_MIB_ERROR
)
1835 tt2cos
= pfc_fw_cfg
->traffic_type_to_priority_cos
;
1837 /* Fw version should be incremented each update */
1838 pfc_fw_cfg
->dcb_version
= ++bp
->dcb_version
;
1839 pfc_fw_cfg
->dcb_enabled
= 1;
1841 /* Fill priority parameters */
1842 for (pri
= 0; pri
< LLFC_DRIVER_TRAFFIC_TYPE_MAX
; pri
++) {
1843 tt2cos
[pri
].priority
= ttp
[pri
];
1844 pri_bit
= 1 << tt2cos
[pri
].priority
;
1846 /* Fill COS parameters based on COS calculated to
1847 * make it more general for future use */
1848 for (cos
= 0; cos
< bp
->dcbx_port_params
.ets
.num_of_cos
; cos
++)
1849 if (bp
->dcbx_port_params
.ets
.cos_params
[cos
].
1850 pri_bitmask
& pri_bit
)
1851 tt2cos
[pri
].cos
= cos
;
1854 /* we never want the FW to add a 0 vlan tag */
1855 pfc_fw_cfg
->dont_add_pri_0_en
= 1;
1857 bnx2x_dcbx_print_cos_params(bp
, pfc_fw_cfg
);
1860 void bnx2x_dcbx_pmf_update(struct bnx2x
*bp
)
1862 /* if we need to syncronize DCBX result from prev PMF
1863 * read it from shmem and update bp accordingly
1865 if (SHMEM2_HAS(bp
, drv_flags
) &&
1866 GET_FLAGS(SHMEM2_RD(bp
, drv_flags
), DRV_FLAGS_DCB_CONFIGURED
)) {
1867 /* Read neg results if dcbx is in the FW */
1868 if (bnx2x_dcbx_read_shmem_neg_results(bp
))
1871 bnx2x_dump_dcbx_drv_param(bp
, &bp
->dcbx_local_feat
,
1873 bnx2x_get_dcbx_drv_param(bp
, &bp
->dcbx_local_feat
,
1881 #define BNX2X_DCBX_CAPS (DCB_CAP_DCBX_LLD_MANAGED | \
1882 DCB_CAP_DCBX_VER_CEE | DCB_CAP_DCBX_STATIC)
1884 static inline bool bnx2x_dcbnl_set_valid(struct bnx2x
*bp
)
1886 /* validate dcbnl call that may change HW state:
1887 * DCB is on and DCBX mode was SUCCESSFULLY set by the user.
1889 return bp
->dcb_state
&& bp
->dcbx_mode_uset
;
1892 static u8
bnx2x_dcbnl_get_state(struct net_device
*netdev
)
1894 struct bnx2x
*bp
= netdev_priv(netdev
);
1895 DP(NETIF_MSG_LINK
, "state = %d\n", bp
->dcb_state
);
1896 return bp
->dcb_state
;
1899 static u8
bnx2x_dcbnl_set_state(struct net_device
*netdev
, u8 state
)
1901 struct bnx2x
*bp
= netdev_priv(netdev
);
1902 DP(NETIF_MSG_LINK
, "state = %s\n", state
? "on" : "off");
1904 bnx2x_dcbx_set_state(bp
, (state
? true : false), bp
->dcbx_enabled
);
1908 static void bnx2x_dcbnl_get_perm_hw_addr(struct net_device
*netdev
,
1911 struct bnx2x
*bp
= netdev_priv(netdev
);
1912 DP(NETIF_MSG_LINK
, "GET-PERM-ADDR\n");
1914 /* first the HW mac address */
1915 memcpy(perm_addr
, netdev
->dev_addr
, netdev
->addr_len
);
1918 /* second SAN address */
1919 memcpy(perm_addr
+netdev
->addr_len
, bp
->fip_mac
, netdev
->addr_len
);
1923 static void bnx2x_dcbnl_set_pg_tccfg_tx(struct net_device
*netdev
, int prio
,
1924 u8 prio_type
, u8 pgid
, u8 bw_pct
,
1927 struct bnx2x
*bp
= netdev_priv(netdev
);
1929 DP(NETIF_MSG_LINK
, "prio[%d] = %d\n", prio
, pgid
);
1930 if (!bnx2x_dcbnl_set_valid(bp
) || prio
>= DCBX_MAX_NUM_PRI_PG_ENTRIES
)
1934 * bw_pct ingnored - band-width percentage devision between user
1935 * priorities within the same group is not
1936 * standard and hence not supported
1938 * prio_type igonred - priority levels within the same group are not
1939 * standard and hence are not supported. According
1940 * to the standard pgid 15 is dedicated to strict
1941 * prioirty traffic (on the port level).
1946 bp
->dcbx_config_params
.admin_configuration_ets_pg
[prio
] = pgid
;
1947 bp
->dcbx_config_params
.admin_ets_configuration_tx_enable
= 1;
1950 static void bnx2x_dcbnl_set_pg_bwgcfg_tx(struct net_device
*netdev
,
1951 int pgid
, u8 bw_pct
)
1953 struct bnx2x
*bp
= netdev_priv(netdev
);
1954 DP(NETIF_MSG_LINK
, "pgid[%d] = %d\n", pgid
, bw_pct
);
1956 if (!bnx2x_dcbnl_set_valid(bp
) || pgid
>= DCBX_MAX_NUM_PG_BW_ENTRIES
)
1959 bp
->dcbx_config_params
.admin_configuration_bw_precentage
[pgid
] = bw_pct
;
1960 bp
->dcbx_config_params
.admin_ets_configuration_tx_enable
= 1;
1963 static void bnx2x_dcbnl_set_pg_tccfg_rx(struct net_device
*netdev
, int prio
,
1964 u8 prio_type
, u8 pgid
, u8 bw_pct
,
1967 struct bnx2x
*bp
= netdev_priv(netdev
);
1968 DP(NETIF_MSG_LINK
, "Nothing to set; No RX support\n");
1971 static void bnx2x_dcbnl_set_pg_bwgcfg_rx(struct net_device
*netdev
,
1972 int pgid
, u8 bw_pct
)
1974 struct bnx2x
*bp
= netdev_priv(netdev
);
1975 DP(NETIF_MSG_LINK
, "Nothing to set; No RX support\n");
1978 static void bnx2x_dcbnl_get_pg_tccfg_tx(struct net_device
*netdev
, int prio
,
1979 u8
*prio_type
, u8
*pgid
, u8
*bw_pct
,
1982 struct bnx2x
*bp
= netdev_priv(netdev
);
1983 DP(NETIF_MSG_LINK
, "prio = %d\n", prio
);
1986 * bw_pct ingnored - band-width percentage devision between user
1987 * priorities within the same group is not
1988 * standard and hence not supported
1990 * prio_type igonred - priority levels within the same group are not
1991 * standard and hence are not supported. According
1992 * to the standard pgid 15 is dedicated to strict
1993 * prioirty traffic (on the port level).
1997 *up_map
= *bw_pct
= *prio_type
= *pgid
= 0;
1999 if (!bp
->dcb_state
|| prio
>= DCBX_MAX_NUM_PRI_PG_ENTRIES
)
2002 *pgid
= DCBX_PRI_PG_GET(bp
->dcbx_local_feat
.ets
.pri_pg_tbl
, prio
);
2005 static void bnx2x_dcbnl_get_pg_bwgcfg_tx(struct net_device
*netdev
,
2006 int pgid
, u8
*bw_pct
)
2008 struct bnx2x
*bp
= netdev_priv(netdev
);
2009 DP(NETIF_MSG_LINK
, "pgid = %d\n", pgid
);
2013 if (!bp
->dcb_state
|| pgid
>= DCBX_MAX_NUM_PG_BW_ENTRIES
)
2016 *bw_pct
= DCBX_PG_BW_GET(bp
->dcbx_local_feat
.ets
.pg_bw_tbl
, pgid
);
2019 static void bnx2x_dcbnl_get_pg_tccfg_rx(struct net_device
*netdev
, int prio
,
2020 u8
*prio_type
, u8
*pgid
, u8
*bw_pct
,
2023 struct bnx2x
*bp
= netdev_priv(netdev
);
2024 DP(NETIF_MSG_LINK
, "Nothing to get; No RX support\n");
2026 *prio_type
= *pgid
= *bw_pct
= *up_map
= 0;
2029 static void bnx2x_dcbnl_get_pg_bwgcfg_rx(struct net_device
*netdev
,
2030 int pgid
, u8
*bw_pct
)
2032 struct bnx2x
*bp
= netdev_priv(netdev
);
2033 DP(NETIF_MSG_LINK
, "Nothing to get; No RX support\n");
2038 static void bnx2x_dcbnl_set_pfc_cfg(struct net_device
*netdev
, int prio
,
2041 struct bnx2x
*bp
= netdev_priv(netdev
);
2042 DP(NETIF_MSG_LINK
, "prio[%d] = %d\n", prio
, setting
);
2044 if (!bnx2x_dcbnl_set_valid(bp
) || prio
>= MAX_PFC_PRIORITIES
)
2047 bp
->dcbx_config_params
.admin_pfc_bitmap
|= ((setting
? 1 : 0) << prio
);
2050 bp
->dcbx_config_params
.admin_pfc_tx_enable
= 1;
2053 static void bnx2x_dcbnl_get_pfc_cfg(struct net_device
*netdev
, int prio
,
2056 struct bnx2x
*bp
= netdev_priv(netdev
);
2057 DP(NETIF_MSG_LINK
, "prio = %d\n", prio
);
2061 if (!bp
->dcb_state
|| prio
>= MAX_PFC_PRIORITIES
)
2064 *setting
= (bp
->dcbx_local_feat
.pfc
.pri_en_bitmap
>> prio
) & 0x1;
2067 static u8
bnx2x_dcbnl_set_all(struct net_device
*netdev
)
2069 struct bnx2x
*bp
= netdev_priv(netdev
);
2072 DP(NETIF_MSG_LINK
, "SET-ALL\n");
2074 if (!bnx2x_dcbnl_set_valid(bp
))
2077 if (bp
->recovery_state
!= BNX2X_RECOVERY_DONE
) {
2078 netdev_err(bp
->dev
, "Handling parity error recovery. "
2079 "Try again later\n");
2082 if (netif_running(bp
->dev
)) {
2083 bnx2x_nic_unload(bp
, UNLOAD_NORMAL
);
2084 rc
= bnx2x_nic_load(bp
, LOAD_NORMAL
);
2086 DP(NETIF_MSG_LINK
, "set_dcbx_params done (%d)\n", rc
);
2093 static u8
bnx2x_dcbnl_get_cap(struct net_device
*netdev
, int capid
, u8
*cap
)
2095 struct bnx2x
*bp
= netdev_priv(netdev
);
2098 if (bp
->dcb_state
) {
2100 case DCB_CAP_ATTR_PG
:
2103 case DCB_CAP_ATTR_PFC
:
2106 case DCB_CAP_ATTR_UP2TC
:
2109 case DCB_CAP_ATTR_PG_TCS
:
2110 *cap
= 0x80; /* 8 priorities for PGs */
2112 case DCB_CAP_ATTR_PFC_TCS
:
2113 *cap
= 0x80; /* 8 priorities for PFC */
2115 case DCB_CAP_ATTR_GSP
:
2118 case DCB_CAP_ATTR_BCN
:
2121 case DCB_CAP_ATTR_DCBX
:
2122 *cap
= BNX2X_DCBX_CAPS
;
2130 DP(NETIF_MSG_LINK
, "capid %d:%x\n", capid
, *cap
);
2134 static u8
bnx2x_dcbnl_get_numtcs(struct net_device
*netdev
, int tcid
, u8
*num
)
2136 struct bnx2x
*bp
= netdev_priv(netdev
);
2139 DP(NETIF_MSG_LINK
, "tcid %d\n", tcid
);
2141 if (bp
->dcb_state
) {
2143 case DCB_NUMTCS_ATTR_PG
:
2144 *num
= CHIP_IS_E3B0(bp
) ? DCBX_COS_MAX_NUM_E3B0
:
2145 DCBX_COS_MAX_NUM_E2
;
2147 case DCB_NUMTCS_ATTR_PFC
:
2148 *num
= CHIP_IS_E3B0(bp
) ? DCBX_COS_MAX_NUM_E3B0
:
2149 DCBX_COS_MAX_NUM_E2
;
2161 static u8
bnx2x_dcbnl_set_numtcs(struct net_device
*netdev
, int tcid
, u8 num
)
2163 struct bnx2x
*bp
= netdev_priv(netdev
);
2164 DP(NETIF_MSG_LINK
, "num tcs = %d; Not supported\n", num
);
2168 static u8
bnx2x_dcbnl_get_pfc_state(struct net_device
*netdev
)
2170 struct bnx2x
*bp
= netdev_priv(netdev
);
2171 DP(NETIF_MSG_LINK
, "state = %d\n", bp
->dcbx_local_feat
.pfc
.enabled
);
2176 return bp
->dcbx_local_feat
.pfc
.enabled
;
2179 static void bnx2x_dcbnl_set_pfc_state(struct net_device
*netdev
, u8 state
)
2181 struct bnx2x
*bp
= netdev_priv(netdev
);
2182 DP(NETIF_MSG_LINK
, "state = %s\n", state
? "on" : "off");
2184 if (!bnx2x_dcbnl_set_valid(bp
))
2187 bp
->dcbx_config_params
.admin_pfc_tx_enable
=
2188 bp
->dcbx_config_params
.admin_pfc_enable
= (state
? 1 : 0);
2191 static void bnx2x_admin_app_set_ent(
2192 struct bnx2x_admin_priority_app_table
*app_ent
,
2193 u8 idtype
, u16 idval
, u8 up
)
2198 case DCB_APP_IDTYPE_ETHTYPE
:
2199 app_ent
->traffic_type
= TRAFFIC_TYPE_ETH
;
2201 case DCB_APP_IDTYPE_PORTNUM
:
2202 app_ent
->traffic_type
= TRAFFIC_TYPE_PORT
;
2205 break; /* never gets here */
2207 app_ent
->app_id
= idval
;
2208 app_ent
->priority
= up
;
2211 static bool bnx2x_admin_app_is_equal(
2212 struct bnx2x_admin_priority_app_table
*app_ent
,
2213 u8 idtype
, u16 idval
)
2215 if (!app_ent
->valid
)
2219 case DCB_APP_IDTYPE_ETHTYPE
:
2220 if (app_ent
->traffic_type
!= TRAFFIC_TYPE_ETH
)
2223 case DCB_APP_IDTYPE_PORTNUM
:
2224 if (app_ent
->traffic_type
!= TRAFFIC_TYPE_PORT
)
2230 if (app_ent
->app_id
!= idval
)
2236 static int bnx2x_set_admin_app_up(struct bnx2x
*bp
, u8 idtype
, u16 idval
, u8 up
)
2240 /* iterate over the app entries looking for idtype and idval */
2241 for (i
= 0, ff
= -1; i
< 4; i
++) {
2242 struct bnx2x_admin_priority_app_table
*app_ent
=
2243 &bp
->dcbx_config_params
.admin_priority_app_table
[i
];
2244 if (bnx2x_admin_app_is_equal(app_ent
, idtype
, idval
))
2247 if (ff
< 0 && !app_ent
->valid
)
2251 /* if found overwrite up */
2252 bp
->dcbx_config_params
.
2253 admin_priority_app_table
[i
].priority
= up
;
2255 /* not found use first-free */
2256 bnx2x_admin_app_set_ent(
2257 &bp
->dcbx_config_params
.admin_priority_app_table
[ff
],
2260 /* app table is full */
2263 /* up configured, if not 0 make sure feature is enabled */
2265 bp
->dcbx_config_params
.admin_application_priority_tx_enable
= 1;
2270 static u8
bnx2x_dcbnl_set_app_up(struct net_device
*netdev
, u8 idtype
,
2273 struct bnx2x
*bp
= netdev_priv(netdev
);
2275 DP(NETIF_MSG_LINK
, "app_type %d, app_id %x, prio bitmap %d\n",
2278 if (!bnx2x_dcbnl_set_valid(bp
))
2283 case DCB_APP_IDTYPE_ETHTYPE
:
2284 case DCB_APP_IDTYPE_PORTNUM
:
2289 return bnx2x_set_admin_app_up(bp
, idtype
, idval
, up
);
2292 static u8
bnx2x_dcbnl_get_dcbx(struct net_device
*netdev
)
2294 struct bnx2x
*bp
= netdev_priv(netdev
);
2297 state
= DCB_CAP_DCBX_LLD_MANAGED
| DCB_CAP_DCBX_VER_CEE
;
2299 if (bp
->dcbx_enabled
== BNX2X_DCBX_ENABLED_ON_NEG_OFF
)
2300 state
|= DCB_CAP_DCBX_STATIC
;
2305 static u8
bnx2x_dcbnl_set_dcbx(struct net_device
*netdev
, u8 state
)
2307 struct bnx2x
*bp
= netdev_priv(netdev
);
2308 DP(NETIF_MSG_LINK
, "state = %02x\n", state
);
2312 if ((state
& BNX2X_DCBX_CAPS
) != state
) {
2313 BNX2X_ERR("Requested DCBX mode %x is beyond advertised "
2314 "capabilities\n", state
);
2318 if (bp
->dcb_state
!= BNX2X_DCB_STATE_ON
) {
2319 BNX2X_ERR("DCB turned off, DCBX configuration is invalid\n");
2323 if (state
& DCB_CAP_DCBX_STATIC
)
2324 bp
->dcbx_enabled
= BNX2X_DCBX_ENABLED_ON_NEG_OFF
;
2326 bp
->dcbx_enabled
= BNX2X_DCBX_ENABLED_ON_NEG_ON
;
2328 bp
->dcbx_mode_uset
= true;
2332 static u8
bnx2x_dcbnl_get_featcfg(struct net_device
*netdev
, int featid
,
2335 struct bnx2x
*bp
= netdev_priv(netdev
);
2338 DP(NETIF_MSG_LINK
, "featid %d\n", featid
);
2340 if (bp
->dcb_state
) {
2343 case DCB_FEATCFG_ATTR_PG
:
2344 if (bp
->dcbx_local_feat
.ets
.enabled
)
2345 *flags
|= DCB_FEATCFG_ENABLE
;
2346 if (bp
->dcbx_error
& DCBX_LOCAL_ETS_ERROR
)
2347 *flags
|= DCB_FEATCFG_ERROR
;
2349 case DCB_FEATCFG_ATTR_PFC
:
2350 if (bp
->dcbx_local_feat
.pfc
.enabled
)
2351 *flags
|= DCB_FEATCFG_ENABLE
;
2352 if (bp
->dcbx_error
& (DCBX_LOCAL_PFC_ERROR
|
2353 DCBX_LOCAL_PFC_MISMATCH
))
2354 *flags
|= DCB_FEATCFG_ERROR
;
2356 case DCB_FEATCFG_ATTR_APP
:
2357 if (bp
->dcbx_local_feat
.app
.enabled
)
2358 *flags
|= DCB_FEATCFG_ENABLE
;
2359 if (bp
->dcbx_error
& (DCBX_LOCAL_APP_ERROR
|
2360 DCBX_LOCAL_APP_MISMATCH
))
2361 *flags
|= DCB_FEATCFG_ERROR
;
2373 static u8
bnx2x_dcbnl_set_featcfg(struct net_device
*netdev
, int featid
,
2376 struct bnx2x
*bp
= netdev_priv(netdev
);
2379 DP(NETIF_MSG_LINK
, "featid = %d flags = %02x\n", featid
, flags
);
2381 /* ignore the 'advertise' flag */
2382 if (bnx2x_dcbnl_set_valid(bp
)) {
2384 case DCB_FEATCFG_ATTR_PG
:
2385 bp
->dcbx_config_params
.admin_ets_enable
=
2386 flags
& DCB_FEATCFG_ENABLE
? 1 : 0;
2387 bp
->dcbx_config_params
.admin_ets_willing
=
2388 flags
& DCB_FEATCFG_WILLING
? 1 : 0;
2390 case DCB_FEATCFG_ATTR_PFC
:
2391 bp
->dcbx_config_params
.admin_pfc_enable
=
2392 flags
& DCB_FEATCFG_ENABLE
? 1 : 0;
2393 bp
->dcbx_config_params
.admin_pfc_willing
=
2394 flags
& DCB_FEATCFG_WILLING
? 1 : 0;
2396 case DCB_FEATCFG_ATTR_APP
:
2397 /* ignore enable, always enabled */
2398 bp
->dcbx_config_params
.admin_app_priority_willing
=
2399 flags
& DCB_FEATCFG_WILLING
? 1 : 0;
2411 static int bnx2x_peer_appinfo(struct net_device
*netdev
,
2412 struct dcb_peer_app_info
*info
, u16
* app_count
)
2415 struct bnx2x
*bp
= netdev_priv(netdev
);
2417 DP(NETIF_MSG_LINK
, "APP-INFO\n");
2419 info
->willing
= (bp
->dcbx_remote_flags
& DCBX_APP_REM_WILLING
) ?: 0;
2420 info
->error
= (bp
->dcbx_remote_flags
& DCBX_APP_RX_ERROR
) ?: 0;
2423 for (i
= 0; i
< DCBX_MAX_APP_PROTOCOL
; i
++)
2424 if (bp
->dcbx_remote_feat
.app
.app_pri_tbl
[i
].appBitfield
&
2425 DCBX_APP_ENTRY_VALID
)
2430 static int bnx2x_peer_apptable(struct net_device
*netdev
,
2431 struct dcb_app
*table
)
2434 struct bnx2x
*bp
= netdev_priv(netdev
);
2436 DP(NETIF_MSG_LINK
, "APP-TABLE\n");
2438 for (i
= 0, j
= 0; i
< DCBX_MAX_APP_PROTOCOL
; i
++) {
2439 struct dcbx_app_priority_entry
*ent
=
2440 &bp
->dcbx_remote_feat
.app
.app_pri_tbl
[i
];
2442 if (ent
->appBitfield
& DCBX_APP_ENTRY_VALID
) {
2443 table
[j
].selector
= bnx2x_dcbx_dcbnl_app_idtype(ent
);
2444 table
[j
].priority
= bnx2x_dcbx_dcbnl_app_up(ent
);
2445 table
[j
++].protocol
= ent
->app_id
;
2451 static int bnx2x_cee_peer_getpg(struct net_device
*netdev
, struct cee_pg
*pg
)
2454 struct bnx2x
*bp
= netdev_priv(netdev
);
2456 pg
->willing
= (bp
->dcbx_remote_flags
& DCBX_ETS_REM_WILLING
) ?: 0;
2458 for (i
= 0; i
< CEE_DCBX_MAX_PGS
; i
++) {
2460 DCBX_PG_BW_GET(bp
->dcbx_remote_feat
.ets
.pg_bw_tbl
, i
);
2462 DCBX_PRI_PG_GET(bp
->dcbx_remote_feat
.ets
.pri_pg_tbl
, i
);
2467 static int bnx2x_cee_peer_getpfc(struct net_device
*netdev
,
2468 struct cee_pfc
*pfc
)
2470 struct bnx2x
*bp
= netdev_priv(netdev
);
2471 pfc
->tcs_supported
= bp
->dcbx_remote_feat
.pfc
.pfc_caps
;
2472 pfc
->pfc_en
= bp
->dcbx_remote_feat
.pfc
.pri_en_bitmap
;
2476 const struct dcbnl_rtnl_ops bnx2x_dcbnl_ops
= {
2477 .getstate
= bnx2x_dcbnl_get_state
,
2478 .setstate
= bnx2x_dcbnl_set_state
,
2479 .getpermhwaddr
= bnx2x_dcbnl_get_perm_hw_addr
,
2480 .setpgtccfgtx
= bnx2x_dcbnl_set_pg_tccfg_tx
,
2481 .setpgbwgcfgtx
= bnx2x_dcbnl_set_pg_bwgcfg_tx
,
2482 .setpgtccfgrx
= bnx2x_dcbnl_set_pg_tccfg_rx
,
2483 .setpgbwgcfgrx
= bnx2x_dcbnl_set_pg_bwgcfg_rx
,
2484 .getpgtccfgtx
= bnx2x_dcbnl_get_pg_tccfg_tx
,
2485 .getpgbwgcfgtx
= bnx2x_dcbnl_get_pg_bwgcfg_tx
,
2486 .getpgtccfgrx
= bnx2x_dcbnl_get_pg_tccfg_rx
,
2487 .getpgbwgcfgrx
= bnx2x_dcbnl_get_pg_bwgcfg_rx
,
2488 .setpfccfg
= bnx2x_dcbnl_set_pfc_cfg
,
2489 .getpfccfg
= bnx2x_dcbnl_get_pfc_cfg
,
2490 .setall
= bnx2x_dcbnl_set_all
,
2491 .getcap
= bnx2x_dcbnl_get_cap
,
2492 .getnumtcs
= bnx2x_dcbnl_get_numtcs
,
2493 .setnumtcs
= bnx2x_dcbnl_set_numtcs
,
2494 .getpfcstate
= bnx2x_dcbnl_get_pfc_state
,
2495 .setpfcstate
= bnx2x_dcbnl_set_pfc_state
,
2496 .setapp
= bnx2x_dcbnl_set_app_up
,
2497 .getdcbx
= bnx2x_dcbnl_get_dcbx
,
2498 .setdcbx
= bnx2x_dcbnl_set_dcbx
,
2499 .getfeatcfg
= bnx2x_dcbnl_get_featcfg
,
2500 .setfeatcfg
= bnx2x_dcbnl_set_featcfg
,
2501 .peer_getappinfo
= bnx2x_peer_appinfo
,
2502 .peer_getapptable
= bnx2x_peer_apptable
,
2503 .cee_peer_getpg
= bnx2x_cee_peer_getpg
,
2504 .cee_peer_getpfc
= bnx2x_cee_peer_getpfc
,
2507 #endif /* BCM_DCBNL */