Vladislav Zolotarov | e4901dd | 2010-12-13 05:44:18 +0000 | [diff] [blame^] | 1 | /* bnx2x_dcb.c: Broadcom Everest network driver. |
| 2 | * |
| 3 | * Copyright 2009-2010 Broadcom Corporation |
| 4 | * |
| 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"). |
| 9 | * |
| 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 |
| 13 | * consent. |
| 14 | * |
| 15 | * Maintained by: Eilon Greenstein <eilong@broadcom.com> |
| 16 | * Written by: Dmitry Kravkov |
| 17 | * |
| 18 | */ |
| 19 | #include <linux/netdevice.h> |
| 20 | #include <linux/types.h> |
| 21 | #include <linux/errno.h> |
| 22 | |
| 23 | #include "bnx2x.h" |
| 24 | #include "bnx2x_cmn.h" |
| 25 | #include "bnx2x_dcb.h" |
| 26 | |
| 27 | |
| 28 | /* forward declarations of dcbx related functions */ |
| 29 | static void bnx2x_dcbx_stop_hw_tx(struct bnx2x *bp); |
| 30 | static void bnx2x_pfc_set_pfc(struct bnx2x *bp); |
| 31 | static void bnx2x_dcbx_update_ets_params(struct bnx2x *bp); |
| 32 | static void bnx2x_dcbx_resume_hw_tx(struct bnx2x *bp); |
| 33 | static void bnx2x_dcbx_get_ets_pri_pg_tbl(struct bnx2x *bp, |
| 34 | u32 *set_configuration_ets_pg, |
| 35 | u32 *pri_pg_tbl); |
| 36 | static void bnx2x_dcbx_get_num_pg_traf_type(struct bnx2x *bp, |
| 37 | u32 *pg_pri_orginal_spread, |
| 38 | struct pg_help_data *help_data); |
| 39 | static void bnx2x_dcbx_fill_cos_params(struct bnx2x *bp, |
| 40 | struct pg_help_data *help_data, |
| 41 | struct dcbx_ets_feature *ets, |
| 42 | u32 *pg_pri_orginal_spread); |
| 43 | static void bnx2x_dcbx_separate_pauseable_from_non(struct bnx2x *bp, |
| 44 | struct cos_help_data *cos_data, |
| 45 | u32 *pg_pri_orginal_spread, |
| 46 | struct dcbx_ets_feature *ets); |
| 47 | static void bnx2x_pfc_fw_struct_e2(struct bnx2x *bp); |
| 48 | |
| 49 | |
| 50 | static void bnx2x_pfc_set(struct bnx2x *bp) |
| 51 | { |
| 52 | struct bnx2x_nig_brb_pfc_port_params pfc_params = {0}; |
| 53 | u32 pri_bit, val = 0; |
| 54 | u8 pri; |
| 55 | |
| 56 | /* Tx COS configuration */ |
| 57 | if (bp->dcbx_port_params.ets.cos_params[0].pauseable) |
| 58 | pfc_params.rx_cos0_priority_mask = |
| 59 | bp->dcbx_port_params.ets.cos_params[0].pri_bitmask; |
| 60 | if (bp->dcbx_port_params.ets.cos_params[1].pauseable) |
| 61 | pfc_params.rx_cos1_priority_mask = |
| 62 | bp->dcbx_port_params.ets.cos_params[1].pri_bitmask; |
| 63 | |
| 64 | |
| 65 | /** |
| 66 | * Rx COS configuration |
| 67 | * Changing PFC RX configuration . |
| 68 | * In RX COS0 will always be configured to lossy and COS1 to lossless |
| 69 | */ |
| 70 | for (pri = 0 ; pri < MAX_PFC_PRIORITIES ; pri++) { |
| 71 | pri_bit = 1 << pri; |
| 72 | |
| 73 | if (pri_bit & DCBX_PFC_PRI_PAUSE_MASK(bp)) |
| 74 | val |= 1 << (pri * 4); |
| 75 | } |
| 76 | |
| 77 | pfc_params.pkt_priority_to_cos = val; |
| 78 | |
| 79 | /* RX COS0 */ |
| 80 | pfc_params.llfc_low_priority_classes = 0; |
| 81 | /* RX COS1 */ |
| 82 | pfc_params.llfc_high_priority_classes = DCBX_PFC_PRI_PAUSE_MASK(bp); |
| 83 | |
| 84 | /* BRB configuration */ |
| 85 | pfc_params.cos0_pauseable = false; |
| 86 | pfc_params.cos1_pauseable = true; |
| 87 | |
| 88 | bnx2x_acquire_phy_lock(bp); |
| 89 | bp->link_params.feature_config_flags |= FEATURE_CONFIG_PFC_ENABLED; |
| 90 | bnx2x_update_pfc(&bp->link_params, &bp->link_vars, &pfc_params); |
| 91 | bnx2x_release_phy_lock(bp); |
| 92 | } |
| 93 | |
| 94 | static void bnx2x_pfc_clear(struct bnx2x *bp) |
| 95 | { |
| 96 | struct bnx2x_nig_brb_pfc_port_params nig_params = {0}; |
| 97 | nig_params.pause_enable = 1; |
| 98 | #ifdef BNX2X_SAFC |
| 99 | if (bp->flags & SAFC_TX_FLAG) { |
| 100 | u32 high = 0, low = 0; |
| 101 | int i; |
| 102 | |
| 103 | for (i = 0; i < BNX2X_MAX_PRIORITY; i++) { |
| 104 | if (bp->pri_map[i] == 1) |
| 105 | high |= (1 << i); |
| 106 | if (bp->pri_map[i] == 0) |
| 107 | low |= (1 << i); |
| 108 | } |
| 109 | |
| 110 | nig_params.llfc_low_priority_classes = high; |
| 111 | nig_params.llfc_low_priority_classes = low; |
| 112 | |
| 113 | nig_params.pause_enable = 0; |
| 114 | nig_params.llfc_enable = 1; |
| 115 | nig_params.llfc_out_en = 1; |
| 116 | } |
| 117 | #endif /* BNX2X_SAFC */ |
| 118 | bnx2x_acquire_phy_lock(bp); |
| 119 | bp->link_params.feature_config_flags &= ~FEATURE_CONFIG_PFC_ENABLED; |
| 120 | bnx2x_update_pfc(&bp->link_params, &bp->link_vars, &nig_params); |
| 121 | bnx2x_release_phy_lock(bp); |
| 122 | } |
| 123 | |
| 124 | static void bnx2x_dump_dcbx_drv_param(struct bnx2x *bp, |
| 125 | struct dcbx_features *features, |
| 126 | u32 error) |
| 127 | { |
| 128 | u8 i = 0; |
| 129 | DP(NETIF_MSG_LINK, "local_mib.error %x\n", error); |
| 130 | |
| 131 | /* PG */ |
| 132 | DP(NETIF_MSG_LINK, |
| 133 | "local_mib.features.ets.enabled %x\n", features->ets.enabled); |
| 134 | for (i = 0; i < DCBX_MAX_NUM_PG_BW_ENTRIES; i++) |
| 135 | DP(NETIF_MSG_LINK, |
| 136 | "local_mib.features.ets.pg_bw_tbl[%d] %d\n", i, |
| 137 | DCBX_PG_BW_GET(features->ets.pg_bw_tbl, i)); |
| 138 | for (i = 0; i < DCBX_MAX_NUM_PRI_PG_ENTRIES; i++) |
| 139 | DP(NETIF_MSG_LINK, |
| 140 | "local_mib.features.ets.pri_pg_tbl[%d] %d\n", i, |
| 141 | DCBX_PRI_PG_GET(features->ets.pri_pg_tbl, i)); |
| 142 | |
| 143 | /* pfc */ |
| 144 | DP(NETIF_MSG_LINK, "dcbx_features.pfc.pri_en_bitmap %x\n", |
| 145 | features->pfc.pri_en_bitmap); |
| 146 | DP(NETIF_MSG_LINK, "dcbx_features.pfc.pfc_caps %x\n", |
| 147 | features->pfc.pfc_caps); |
| 148 | DP(NETIF_MSG_LINK, "dcbx_features.pfc.enabled %x\n", |
| 149 | features->pfc.enabled); |
| 150 | |
| 151 | DP(NETIF_MSG_LINK, "dcbx_features.app.default_pri %x\n", |
| 152 | features->app.default_pri); |
| 153 | DP(NETIF_MSG_LINK, "dcbx_features.app.tc_supported %x\n", |
| 154 | features->app.tc_supported); |
| 155 | DP(NETIF_MSG_LINK, "dcbx_features.app.enabled %x\n", |
| 156 | features->app.enabled); |
| 157 | for (i = 0; i < DCBX_MAX_APP_PROTOCOL; i++) { |
| 158 | DP(NETIF_MSG_LINK, |
| 159 | "dcbx_features.app.app_pri_tbl[%x].app_id %x\n", |
| 160 | i, features->app.app_pri_tbl[i].app_id); |
| 161 | DP(NETIF_MSG_LINK, |
| 162 | "dcbx_features.app.app_pri_tbl[%x].pri_bitmap %x\n", |
| 163 | i, features->app.app_pri_tbl[i].pri_bitmap); |
| 164 | DP(NETIF_MSG_LINK, |
| 165 | "dcbx_features.app.app_pri_tbl[%x].appBitfield %x\n", |
| 166 | i, features->app.app_pri_tbl[i].appBitfield); |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | static void bnx2x_dcbx_get_ap_priority(struct bnx2x *bp, |
| 171 | u8 pri_bitmap, |
| 172 | u8 llfc_traf_type) |
| 173 | { |
| 174 | u32 pri = MAX_PFC_PRIORITIES; |
| 175 | u32 index = MAX_PFC_PRIORITIES - 1; |
| 176 | u32 pri_mask; |
| 177 | u32 *ttp = bp->dcbx_port_params.app.traffic_type_priority; |
| 178 | |
| 179 | /* Choose the highest priority */ |
| 180 | while ((MAX_PFC_PRIORITIES == pri) && (0 != index)) { |
| 181 | pri_mask = 1 << index; |
| 182 | if (GET_FLAGS(pri_bitmap, pri_mask)) |
| 183 | pri = index ; |
| 184 | index--; |
| 185 | } |
| 186 | |
| 187 | if (pri < MAX_PFC_PRIORITIES) |
| 188 | ttp[llfc_traf_type] = max_t(u32, ttp[llfc_traf_type], pri); |
| 189 | } |
| 190 | |
| 191 | static void bnx2x_dcbx_get_ap_feature(struct bnx2x *bp, |
| 192 | struct dcbx_app_priority_feature *app, |
| 193 | u32 error) { |
| 194 | u8 index; |
| 195 | u32 *ttp = bp->dcbx_port_params.app.traffic_type_priority; |
| 196 | |
| 197 | if (GET_FLAGS(error, DCBX_LOCAL_APP_ERROR)) |
| 198 | DP(NETIF_MSG_LINK, "DCBX_LOCAL_APP_ERROR\n"); |
| 199 | |
| 200 | if (app->enabled && !GET_FLAGS(error, DCBX_LOCAL_APP_ERROR)) { |
| 201 | |
| 202 | bp->dcbx_port_params.app.enabled = true; |
| 203 | |
| 204 | for (index = 0 ; index < LLFC_DRIVER_TRAFFIC_TYPE_MAX; index++) |
| 205 | ttp[index] = 0; |
| 206 | |
| 207 | if (app->default_pri < MAX_PFC_PRIORITIES) |
| 208 | ttp[LLFC_TRAFFIC_TYPE_NW] = app->default_pri; |
| 209 | |
| 210 | for (index = 0 ; index < DCBX_MAX_APP_PROTOCOL; index++) { |
| 211 | struct dcbx_app_priority_entry *entry = |
| 212 | app->app_pri_tbl; |
| 213 | |
| 214 | if (GET_FLAGS(entry[index].appBitfield, |
| 215 | DCBX_APP_SF_ETH_TYPE) && |
| 216 | ETH_TYPE_FCOE == entry[index].app_id) |
| 217 | bnx2x_dcbx_get_ap_priority(bp, |
| 218 | entry[index].pri_bitmap, |
| 219 | LLFC_TRAFFIC_TYPE_FCOE); |
| 220 | |
| 221 | if (GET_FLAGS(entry[index].appBitfield, |
| 222 | DCBX_APP_SF_PORT) && |
| 223 | TCP_PORT_ISCSI == entry[index].app_id) |
| 224 | bnx2x_dcbx_get_ap_priority(bp, |
| 225 | entry[index].pri_bitmap, |
| 226 | LLFC_TRAFFIC_TYPE_ISCSI); |
| 227 | } |
| 228 | } else { |
| 229 | DP(NETIF_MSG_LINK, "DCBX_LOCAL_APP_DISABLED\n"); |
| 230 | bp->dcbx_port_params.app.enabled = false; |
| 231 | for (index = 0 ; index < LLFC_DRIVER_TRAFFIC_TYPE_MAX; index++) |
| 232 | ttp[index] = INVALID_TRAFFIC_TYPE_PRIORITY; |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | static void bnx2x_dcbx_get_ets_feature(struct bnx2x *bp, |
| 237 | struct dcbx_ets_feature *ets, |
| 238 | u32 error) { |
| 239 | int i = 0; |
| 240 | u32 pg_pri_orginal_spread[DCBX_MAX_NUM_PG_BW_ENTRIES] = {0}; |
| 241 | struct pg_help_data pg_help_data; |
| 242 | struct bnx2x_dcbx_cos_params *cos_params = |
| 243 | bp->dcbx_port_params.ets.cos_params; |
| 244 | |
| 245 | memset(&pg_help_data, 0, sizeof(struct pg_help_data)); |
| 246 | |
| 247 | |
| 248 | if (GET_FLAGS(error, DCBX_LOCAL_ETS_ERROR)) |
| 249 | DP(NETIF_MSG_LINK, "DCBX_LOCAL_ETS_ERROR\n"); |
| 250 | |
| 251 | |
| 252 | /* Clean up old settings of ets on COS */ |
| 253 | for (i = 0; i < E2_NUM_OF_COS ; i++) { |
| 254 | |
| 255 | cos_params[i].pauseable = false; |
| 256 | cos_params[i].strict = BNX2X_DCBX_COS_NOT_STRICT; |
| 257 | cos_params[i].bw_tbl = DCBX_INVALID_COS_BW; |
| 258 | cos_params[i].pri_bitmask = DCBX_PFC_PRI_GET_NON_PAUSE(bp, 0); |
| 259 | } |
| 260 | |
| 261 | if (bp->dcbx_port_params.app.enabled && |
| 262 | !GET_FLAGS(error, DCBX_LOCAL_ETS_ERROR) && |
| 263 | ets->enabled) { |
| 264 | DP(NETIF_MSG_LINK, "DCBX_LOCAL_ETS_ENABLE\n"); |
| 265 | bp->dcbx_port_params.ets.enabled = true; |
| 266 | |
| 267 | bnx2x_dcbx_get_ets_pri_pg_tbl(bp, |
| 268 | pg_pri_orginal_spread, |
| 269 | ets->pri_pg_tbl); |
| 270 | |
| 271 | bnx2x_dcbx_get_num_pg_traf_type(bp, |
| 272 | pg_pri_orginal_spread, |
| 273 | &pg_help_data); |
| 274 | |
| 275 | bnx2x_dcbx_fill_cos_params(bp, &pg_help_data, |
| 276 | ets, pg_pri_orginal_spread); |
| 277 | |
| 278 | } else { |
| 279 | DP(NETIF_MSG_LINK, "DCBX_LOCAL_ETS_DISABLED\n"); |
| 280 | bp->dcbx_port_params.ets.enabled = false; |
| 281 | ets->pri_pg_tbl[0] = 0; |
| 282 | |
| 283 | for (i = 0; i < DCBX_MAX_NUM_PRI_PG_ENTRIES ; i++) |
| 284 | DCBX_PG_BW_SET(ets->pg_bw_tbl, i, 1); |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | static void bnx2x_dcbx_get_pfc_feature(struct bnx2x *bp, |
| 289 | struct dcbx_pfc_feature *pfc, u32 error) |
| 290 | { |
| 291 | |
| 292 | if (GET_FLAGS(error, DCBX_LOCAL_PFC_ERROR)) |
| 293 | DP(NETIF_MSG_LINK, "DCBX_LOCAL_PFC_ERROR\n"); |
| 294 | |
| 295 | if (bp->dcbx_port_params.app.enabled && |
| 296 | !GET_FLAGS(error, DCBX_LOCAL_PFC_ERROR) && |
| 297 | pfc->enabled) { |
| 298 | bp->dcbx_port_params.pfc.enabled = true; |
| 299 | bp->dcbx_port_params.pfc.priority_non_pauseable_mask = |
| 300 | ~(pfc->pri_en_bitmap); |
| 301 | } else { |
| 302 | DP(NETIF_MSG_LINK, "DCBX_LOCAL_PFC_DISABLED\n"); |
| 303 | bp->dcbx_port_params.pfc.enabled = false; |
| 304 | bp->dcbx_port_params.pfc.priority_non_pauseable_mask = 0; |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | static void bnx2x_get_dcbx_drv_param(struct bnx2x *bp, |
| 309 | struct dcbx_features *features, |
| 310 | u32 error) |
| 311 | { |
| 312 | bnx2x_dcbx_get_ap_feature(bp, &features->app, error); |
| 313 | |
| 314 | bnx2x_dcbx_get_pfc_feature(bp, &features->pfc, error); |
| 315 | |
| 316 | bnx2x_dcbx_get_ets_feature(bp, &features->ets, error); |
| 317 | } |
| 318 | |
| 319 | #define DCBX_LOCAL_MIB_MAX_TRY_READ (100) |
| 320 | static int bnx2x_dcbx_read_mib(struct bnx2x *bp, |
| 321 | u32 *base_mib_addr, |
| 322 | u32 offset, |
| 323 | int read_mib_type) |
| 324 | { |
| 325 | int max_try_read = 0, i; |
| 326 | u32 *buff, mib_size, prefix_seq_num, suffix_seq_num; |
| 327 | struct lldp_remote_mib *remote_mib ; |
| 328 | struct lldp_local_mib *local_mib; |
| 329 | |
| 330 | |
| 331 | switch (read_mib_type) { |
| 332 | case DCBX_READ_LOCAL_MIB: |
| 333 | mib_size = sizeof(struct lldp_local_mib); |
| 334 | break; |
| 335 | case DCBX_READ_REMOTE_MIB: |
| 336 | mib_size = sizeof(struct lldp_remote_mib); |
| 337 | break; |
| 338 | default: |
| 339 | return 1; /*error*/ |
| 340 | } |
| 341 | |
| 342 | offset += BP_PORT(bp) * mib_size; |
| 343 | |
| 344 | do { |
| 345 | buff = base_mib_addr; |
| 346 | for (i = 0; i < mib_size; i += 4, buff++) |
| 347 | *buff = REG_RD(bp, offset + i); |
| 348 | |
| 349 | max_try_read++; |
| 350 | |
| 351 | switch (read_mib_type) { |
| 352 | case DCBX_READ_LOCAL_MIB: |
| 353 | local_mib = (struct lldp_local_mib *) base_mib_addr; |
| 354 | prefix_seq_num = local_mib->prefix_seq_num; |
| 355 | suffix_seq_num = local_mib->suffix_seq_num; |
| 356 | break; |
| 357 | case DCBX_READ_REMOTE_MIB: |
| 358 | remote_mib = (struct lldp_remote_mib *) base_mib_addr; |
| 359 | prefix_seq_num = remote_mib->prefix_seq_num; |
| 360 | suffix_seq_num = remote_mib->suffix_seq_num; |
| 361 | break; |
| 362 | default: |
| 363 | return 1; /*error*/ |
| 364 | } |
| 365 | } while ((prefix_seq_num != suffix_seq_num) && |
| 366 | (max_try_read < DCBX_LOCAL_MIB_MAX_TRY_READ)); |
| 367 | |
| 368 | if (max_try_read >= DCBX_LOCAL_MIB_MAX_TRY_READ) { |
| 369 | BNX2X_ERR("MIB could not be read\n"); |
| 370 | return 1; |
| 371 | } |
| 372 | |
| 373 | return 0; |
| 374 | } |
| 375 | |
| 376 | static void bnx2x_pfc_set_pfc(struct bnx2x *bp) |
| 377 | { |
| 378 | if (CHIP_IS_E2(bp)) { |
| 379 | if (BP_PORT(bp)) { |
| 380 | BNX2X_ERR("4 port mode is not supported"); |
| 381 | return; |
| 382 | } |
| 383 | |
| 384 | if (bp->dcbx_port_params.pfc.enabled) |
| 385 | |
| 386 | /* 1. Fills up common PFC structures if required.*/ |
| 387 | /* 2. Configure NIG, MAC and BRB via the elink: |
| 388 | * elink must first check if BMAC is not in reset |
| 389 | * and only then configures the BMAC |
| 390 | * Or, configure EMAC. |
| 391 | */ |
| 392 | bnx2x_pfc_set(bp); |
| 393 | |
| 394 | else |
| 395 | bnx2x_pfc_clear(bp); |
| 396 | } |
| 397 | } |
| 398 | |
| 399 | static void bnx2x_dcbx_stop_hw_tx(struct bnx2x *bp) |
| 400 | { |
| 401 | DP(NETIF_MSG_LINK, "sending STOP TRAFFIC\n"); |
| 402 | bnx2x_sp_post(bp, RAMROD_CMD_ID_COMMON_STOP_TRAFFIC, |
| 403 | 0 /* connectionless */, |
| 404 | 0 /* dataHi is zero */, |
| 405 | 0 /* dataLo is zero */, |
| 406 | 1 /* common */); |
| 407 | } |
| 408 | |
| 409 | static void bnx2x_dcbx_resume_hw_tx(struct bnx2x *bp) |
| 410 | { |
| 411 | bnx2x_pfc_fw_struct_e2(bp); |
| 412 | DP(NETIF_MSG_LINK, "sending START TRAFFIC\n"); |
| 413 | bnx2x_sp_post(bp, RAMROD_CMD_ID_COMMON_START_TRAFFIC, |
| 414 | 0, /* connectionless */ |
| 415 | U64_HI(bnx2x_sp_mapping(bp, pfc_config)), |
| 416 | U64_LO(bnx2x_sp_mapping(bp, pfc_config)), |
| 417 | 1 /* commmon */); |
| 418 | } |
| 419 | |
| 420 | static void bnx2x_dcbx_update_ets_params(struct bnx2x *bp) |
| 421 | { |
| 422 | struct bnx2x_dcbx_pg_params *ets = &(bp->dcbx_port_params.ets); |
| 423 | u8 status = 0; |
| 424 | |
| 425 | bnx2x_ets_disabled(&bp->link_params); |
| 426 | |
| 427 | if (!ets->enabled) |
| 428 | return; |
| 429 | |
| 430 | if ((ets->num_of_cos == 0) || (ets->num_of_cos > E2_NUM_OF_COS)) { |
| 431 | BNX2X_ERR("illegal num of cos= %x", ets->num_of_cos); |
| 432 | return; |
| 433 | } |
| 434 | |
| 435 | /* valid COS entries */ |
| 436 | if (ets->num_of_cos == 1) /* no ETS */ |
| 437 | return; |
| 438 | |
| 439 | /* sanity */ |
| 440 | if (((BNX2X_DCBX_COS_NOT_STRICT == ets->cos_params[0].strict) && |
| 441 | (DCBX_INVALID_COS_BW == ets->cos_params[0].bw_tbl)) || |
| 442 | ((BNX2X_DCBX_COS_NOT_STRICT == ets->cos_params[1].strict) && |
| 443 | (DCBX_INVALID_COS_BW == ets->cos_params[1].bw_tbl))) { |
| 444 | BNX2X_ERR("all COS should have at least bw_limit or strict" |
| 445 | "ets->cos_params[0].strict= %x" |
| 446 | "ets->cos_params[0].bw_tbl= %x" |
| 447 | "ets->cos_params[1].strict= %x" |
| 448 | "ets->cos_params[1].bw_tbl= %x", |
| 449 | ets->cos_params[0].strict, |
| 450 | ets->cos_params[0].bw_tbl, |
| 451 | ets->cos_params[1].strict, |
| 452 | ets->cos_params[1].bw_tbl); |
| 453 | return; |
| 454 | } |
| 455 | /* If we join a group and there is bw_tbl and strict then bw rules */ |
| 456 | if ((DCBX_INVALID_COS_BW != ets->cos_params[0].bw_tbl) && |
| 457 | (DCBX_INVALID_COS_BW != ets->cos_params[1].bw_tbl)) { |
| 458 | u32 bw_tbl_0 = ets->cos_params[0].bw_tbl; |
| 459 | u32 bw_tbl_1 = ets->cos_params[1].bw_tbl; |
| 460 | /* Do not allow 0-100 configuration |
| 461 | * since PBF does not support it |
| 462 | * force 1-99 instead |
| 463 | */ |
| 464 | if (bw_tbl_0 == 0) { |
| 465 | bw_tbl_0 = 1; |
| 466 | bw_tbl_1 = 99; |
| 467 | } else if (bw_tbl_1 == 0) { |
| 468 | bw_tbl_1 = 1; |
| 469 | bw_tbl_0 = 99; |
| 470 | } |
| 471 | |
| 472 | bnx2x_ets_bw_limit(&bp->link_params, bw_tbl_0, bw_tbl_1); |
| 473 | } else { |
| 474 | if (ets->cos_params[0].strict == BNX2X_DCBX_COS_HIGH_STRICT) |
| 475 | status = bnx2x_ets_strict(&bp->link_params, 0); |
| 476 | else if (ets->cos_params[1].strict |
| 477 | == BNX2X_DCBX_COS_HIGH_STRICT) |
| 478 | status = bnx2x_ets_strict(&bp->link_params, 1); |
| 479 | |
| 480 | if (status) |
| 481 | BNX2X_ERR("update_ets_params failed\n"); |
| 482 | } |
| 483 | } |
| 484 | |
| 485 | static int bnx2x_dcbx_read_shmem_neg_results(struct bnx2x *bp) |
| 486 | { |
| 487 | struct lldp_local_mib local_mib = {0}; |
| 488 | u32 dcbx_neg_res_offset = SHMEM2_RD(bp, dcbx_neg_res_offset); |
| 489 | int rc; |
| 490 | |
| 491 | DP(NETIF_MSG_LINK, "dcbx_neg_res_offset 0x%x\n", dcbx_neg_res_offset); |
| 492 | |
| 493 | if (SHMEM_DCBX_NEG_RES_NONE == dcbx_neg_res_offset) { |
| 494 | BNX2X_ERR("FW doesn't support dcbx_neg_res_offset\n"); |
| 495 | return -EINVAL; |
| 496 | } |
| 497 | rc = bnx2x_dcbx_read_mib(bp, (u32 *)&local_mib, dcbx_neg_res_offset, |
| 498 | DCBX_READ_LOCAL_MIB); |
| 499 | |
| 500 | if (rc) { |
| 501 | BNX2X_ERR("Faild to read local mib from FW\n"); |
| 502 | return rc; |
| 503 | } |
| 504 | |
| 505 | /* save features and error */ |
| 506 | bp->dcbx_local_feat = local_mib.features; |
| 507 | bp->dcbx_error = local_mib.error; |
| 508 | return 0; |
| 509 | } |
| 510 | |
| 511 | void bnx2x_dcbx_set_params(struct bnx2x *bp, u32 state) |
| 512 | { |
| 513 | switch (state) { |
| 514 | case BNX2X_DCBX_STATE_NEG_RECEIVED: |
| 515 | { |
| 516 | DP(NETIF_MSG_LINK, "BNX2X_DCBX_STATE_NEG_RECEIVED\n"); |
| 517 | |
| 518 | /* Read neg results if dcbx is in the FW */ |
| 519 | if (bnx2x_dcbx_read_shmem_neg_results(bp)) |
| 520 | return; |
| 521 | |
| 522 | bnx2x_dump_dcbx_drv_param(bp, &bp->dcbx_local_feat, |
| 523 | bp->dcbx_error); |
| 524 | |
| 525 | bnx2x_get_dcbx_drv_param(bp, &bp->dcbx_local_feat, |
| 526 | bp->dcbx_error); |
| 527 | |
| 528 | if (bp->state != BNX2X_STATE_OPENING_WAIT4_LOAD) { |
| 529 | bnx2x_dcbx_stop_hw_tx(bp); |
| 530 | return; |
| 531 | } |
| 532 | /* fall through */ |
| 533 | } |
| 534 | case BNX2X_DCBX_STATE_TX_PAUSED: |
| 535 | DP(NETIF_MSG_LINK, "BNX2X_DCBX_STATE_TX_PAUSED\n"); |
| 536 | bnx2x_pfc_set_pfc(bp); |
| 537 | |
| 538 | bnx2x_dcbx_update_ets_params(bp); |
| 539 | if (bp->state != BNX2X_STATE_OPENING_WAIT4_LOAD) { |
| 540 | bnx2x_dcbx_resume_hw_tx(bp); |
| 541 | return; |
| 542 | } |
| 543 | /* fall through */ |
| 544 | case BNX2X_DCBX_STATE_TX_RELEASED: |
| 545 | DP(NETIF_MSG_LINK, "BNX2X_DCBX_STATE_TX_RELEASED\n"); |
| 546 | if (bp->state != BNX2X_STATE_OPENING_WAIT4_LOAD) |
| 547 | bnx2x_fw_command(bp, DRV_MSG_CODE_DCBX_PMF_DRV_OK, 0); |
| 548 | |
| 549 | return; |
| 550 | default: |
| 551 | BNX2X_ERR("Unknown DCBX_STATE\n"); |
| 552 | } |
| 553 | } |
| 554 | |
| 555 | |
| 556 | #define LLDP_STATS_OFFSET(bp) (BP_PORT(bp)*\ |
| 557 | sizeof(struct lldp_dcbx_stat)) |
| 558 | |
| 559 | /* calculate struct offset in array according to chip information */ |
| 560 | #define LLDP_PARAMS_OFFSET(bp) (BP_PORT(bp)*sizeof(struct lldp_params)) |
| 561 | |
| 562 | #define LLDP_ADMIN_MIB_OFFSET(bp) (PORT_MAX*sizeof(struct lldp_params) + \ |
| 563 | BP_PORT(bp)*sizeof(struct lldp_admin_mib)) |
| 564 | |
| 565 | static void bnx2x_dcbx_lldp_updated_params(struct bnx2x *bp, |
| 566 | u32 dcbx_lldp_params_offset) |
| 567 | { |
| 568 | struct lldp_params lldp_params = {0}; |
| 569 | u32 i = 0, *buff = NULL; |
| 570 | u32 offset = dcbx_lldp_params_offset + LLDP_PARAMS_OFFSET(bp); |
| 571 | |
| 572 | DP(NETIF_MSG_LINK, "lldp_offset 0x%x\n", offset); |
| 573 | |
| 574 | if ((bp->lldp_config_params.overwrite_settings == |
| 575 | BNX2X_DCBX_OVERWRITE_SETTINGS_ENABLE)) { |
| 576 | /* Read the data first */ |
| 577 | buff = (u32 *)&lldp_params; |
| 578 | for (i = 0; i < sizeof(struct lldp_params); i += 4, buff++) |
| 579 | *buff = REG_RD(bp, (offset + i)); |
| 580 | |
| 581 | lldp_params.msg_tx_hold = |
| 582 | (u8)bp->lldp_config_params.msg_tx_hold; |
| 583 | lldp_params.msg_fast_tx_interval = |
| 584 | (u8)bp->lldp_config_params.msg_fast_tx; |
| 585 | lldp_params.tx_crd_max = |
| 586 | (u8)bp->lldp_config_params.tx_credit_max; |
| 587 | lldp_params.msg_tx_interval = |
| 588 | (u8)bp->lldp_config_params.msg_tx_interval; |
| 589 | lldp_params.tx_fast = |
| 590 | (u8)bp->lldp_config_params.tx_fast; |
| 591 | |
| 592 | /* Write the data.*/ |
| 593 | buff = (u32 *)&lldp_params; |
| 594 | for (i = 0; i < sizeof(struct lldp_params); i += 4, buff++) |
| 595 | REG_WR(bp, (offset + i) , *buff); |
| 596 | |
| 597 | |
| 598 | } else if (BNX2X_DCBX_OVERWRITE_SETTINGS_ENABLE == |
| 599 | bp->lldp_config_params.overwrite_settings) |
| 600 | bp->lldp_config_params.overwrite_settings = |
| 601 | BNX2X_DCBX_OVERWRITE_SETTINGS_INVALID; |
| 602 | } |
| 603 | |
| 604 | static void bnx2x_dcbx_admin_mib_updated_params(struct bnx2x *bp, |
| 605 | u32 dcbx_lldp_params_offset) |
| 606 | { |
| 607 | struct lldp_admin_mib admin_mib; |
| 608 | u32 i, other_traf_type = PREDEFINED_APP_IDX_MAX, traf_type = 0; |
| 609 | u32 *buff; |
| 610 | u32 offset = dcbx_lldp_params_offset + LLDP_ADMIN_MIB_OFFSET(bp); |
| 611 | |
| 612 | /*shortcuts*/ |
| 613 | struct dcbx_features *af = &admin_mib.features; |
| 614 | struct bnx2x_config_dcbx_params *dp = &bp->dcbx_config_params; |
| 615 | |
| 616 | memset(&admin_mib, 0, sizeof(struct lldp_admin_mib)); |
| 617 | buff = (u32 *)&admin_mib; |
| 618 | /* Read the data first */ |
| 619 | for (i = 0; i < sizeof(struct lldp_admin_mib); i += 4, buff++) |
| 620 | *buff = REG_RD(bp, (offset + i)); |
| 621 | |
| 622 | |
| 623 | if (BNX2X_DCBX_CONFIG_INV_VALUE != dp->admin_dcbx_enable) { |
| 624 | if (dp->admin_dcbx_enable) |
| 625 | SET_FLAGS(admin_mib.ver_cfg_flags, DCBX_DCBX_ENABLED); |
| 626 | else |
| 627 | RESET_FLAGS(admin_mib.ver_cfg_flags, DCBX_DCBX_ENABLED); |
| 628 | } |
| 629 | |
| 630 | if ((BNX2X_DCBX_OVERWRITE_SETTINGS_ENABLE == |
| 631 | dp->overwrite_settings)) { |
| 632 | RESET_FLAGS(admin_mib.ver_cfg_flags, DCBX_CEE_VERSION_MASK); |
| 633 | admin_mib.ver_cfg_flags |= |
| 634 | (dp->admin_dcbx_version << DCBX_CEE_VERSION_SHIFT) & |
| 635 | DCBX_CEE_VERSION_MASK; |
| 636 | |
| 637 | af->ets.enabled = (u8)dp->admin_ets_enable; |
| 638 | |
| 639 | af->pfc.enabled = (u8)dp->admin_pfc_enable; |
| 640 | |
| 641 | /* FOR IEEE dp->admin_tc_supported_tx_enable */ |
| 642 | if (dp->admin_ets_configuration_tx_enable) |
| 643 | SET_FLAGS(admin_mib.ver_cfg_flags, |
| 644 | DCBX_ETS_CONFIG_TX_ENABLED); |
| 645 | else |
| 646 | RESET_FLAGS(admin_mib.ver_cfg_flags, |
| 647 | DCBX_ETS_CONFIG_TX_ENABLED); |
| 648 | /* For IEEE admin_ets_recommendation_tx_enable */ |
| 649 | if (dp->admin_pfc_tx_enable) |
| 650 | SET_FLAGS(admin_mib.ver_cfg_flags, |
| 651 | DCBX_PFC_CONFIG_TX_ENABLED); |
| 652 | else |
| 653 | RESET_FLAGS(admin_mib.ver_cfg_flags, |
| 654 | DCBX_PFC_CONFIG_TX_ENABLED); |
| 655 | |
| 656 | if (dp->admin_application_priority_tx_enable) |
| 657 | SET_FLAGS(admin_mib.ver_cfg_flags, |
| 658 | DCBX_APP_CONFIG_TX_ENABLED); |
| 659 | else |
| 660 | RESET_FLAGS(admin_mib.ver_cfg_flags, |
| 661 | DCBX_APP_CONFIG_TX_ENABLED); |
| 662 | |
| 663 | if (dp->admin_ets_willing) |
| 664 | SET_FLAGS(admin_mib.ver_cfg_flags, DCBX_ETS_WILLING); |
| 665 | else |
| 666 | RESET_FLAGS(admin_mib.ver_cfg_flags, DCBX_ETS_WILLING); |
| 667 | /* For IEEE admin_ets_reco_valid */ |
| 668 | if (dp->admin_pfc_willing) |
| 669 | SET_FLAGS(admin_mib.ver_cfg_flags, DCBX_PFC_WILLING); |
| 670 | else |
| 671 | RESET_FLAGS(admin_mib.ver_cfg_flags, DCBX_PFC_WILLING); |
| 672 | |
| 673 | if (dp->admin_app_priority_willing) |
| 674 | SET_FLAGS(admin_mib.ver_cfg_flags, DCBX_APP_WILLING); |
| 675 | else |
| 676 | RESET_FLAGS(admin_mib.ver_cfg_flags, DCBX_APP_WILLING); |
| 677 | |
| 678 | for (i = 0 ; i < DCBX_MAX_NUM_PG_BW_ENTRIES; i++) { |
| 679 | DCBX_PG_BW_SET(af->ets.pg_bw_tbl, i, |
| 680 | (u8)dp->admin_configuration_bw_precentage[i]); |
| 681 | |
| 682 | DP(NETIF_MSG_LINK, "pg_bw_tbl[%d] = %02x\n", |
| 683 | i, DCBX_PG_BW_GET(af->ets.pg_bw_tbl, i)); |
| 684 | } |
| 685 | |
| 686 | for (i = 0; i < DCBX_MAX_NUM_PRI_PG_ENTRIES; i++) { |
| 687 | DCBX_PRI_PG_SET(af->ets.pri_pg_tbl, i, |
| 688 | (u8)dp->admin_configuration_ets_pg[i]); |
| 689 | |
| 690 | DP(NETIF_MSG_LINK, "pri_pg_tbl[%d] = %02x\n", |
| 691 | i, DCBX_PRI_PG_GET(af->ets.pri_pg_tbl, i)); |
| 692 | } |
| 693 | |
| 694 | /*For IEEE admin_recommendation_bw_precentage |
| 695 | *For IEEE admin_recommendation_ets_pg */ |
| 696 | af->pfc.pri_en_bitmap = (u8)dp->admin_pfc_bitmap; |
| 697 | for (i = 0; i < 4; i++) { |
| 698 | if (dp->admin_priority_app_table[i].valid) { |
| 699 | struct bnx2x_admin_priority_app_table *table = |
| 700 | dp->admin_priority_app_table; |
| 701 | if ((ETH_TYPE_FCOE == table[i].app_id) && |
| 702 | (TRAFFIC_TYPE_ETH == table[i].traffic_type)) |
| 703 | traf_type = FCOE_APP_IDX; |
| 704 | else if ((TCP_PORT_ISCSI == table[i].app_id) && |
| 705 | (TRAFFIC_TYPE_PORT == table[i].traffic_type)) |
| 706 | traf_type = ISCSI_APP_IDX; |
| 707 | else |
| 708 | traf_type = other_traf_type++; |
| 709 | |
| 710 | af->app.app_pri_tbl[traf_type].app_id = |
| 711 | table[i].app_id; |
| 712 | |
| 713 | af->app.app_pri_tbl[traf_type].pri_bitmap = |
| 714 | (u8)(1 << table[i].priority); |
| 715 | |
| 716 | af->app.app_pri_tbl[traf_type].appBitfield = |
| 717 | (DCBX_APP_ENTRY_VALID); |
| 718 | |
| 719 | af->app.app_pri_tbl[traf_type].appBitfield |= |
| 720 | (TRAFFIC_TYPE_ETH == table[i].traffic_type) ? |
| 721 | DCBX_APP_SF_ETH_TYPE : DCBX_APP_SF_PORT; |
| 722 | } |
| 723 | } |
| 724 | |
| 725 | af->app.default_pri = (u8)dp->admin_default_priority; |
| 726 | |
| 727 | } else if (BNX2X_DCBX_OVERWRITE_SETTINGS_ENABLE == |
| 728 | dp->overwrite_settings) |
| 729 | dp->overwrite_settings = BNX2X_DCBX_OVERWRITE_SETTINGS_INVALID; |
| 730 | |
| 731 | /* Write the data. */ |
| 732 | buff = (u32 *)&admin_mib; |
| 733 | for (i = 0; i < sizeof(struct lldp_admin_mib); i += 4, buff++) |
| 734 | REG_WR(bp, (offset + i), *buff); |
| 735 | } |
| 736 | |
| 737 | /* default */ |
| 738 | void bnx2x_dcbx_init_params(struct bnx2x *bp) |
| 739 | { |
| 740 | bp->dcbx_config_params.admin_dcbx_version = 0x0; /* 0 - CEE; 1 - IEEE */ |
| 741 | bp->dcbx_config_params.dcb_enable = 1; |
| 742 | bp->dcbx_config_params.admin_dcbx_enable = 1; |
| 743 | bp->dcbx_config_params.admin_ets_willing = 1; |
| 744 | bp->dcbx_config_params.admin_pfc_willing = 1; |
| 745 | bp->dcbx_config_params.overwrite_settings = 1; |
| 746 | bp->dcbx_config_params.admin_ets_enable = 1; |
| 747 | bp->dcbx_config_params.admin_pfc_enable = 1; |
| 748 | bp->dcbx_config_params.admin_tc_supported_tx_enable = 1; |
| 749 | bp->dcbx_config_params.admin_ets_configuration_tx_enable = 1; |
| 750 | bp->dcbx_config_params.admin_pfc_tx_enable = 1; |
| 751 | bp->dcbx_config_params.admin_application_priority_tx_enable = 1; |
| 752 | bp->dcbx_config_params.admin_ets_reco_valid = 1; |
| 753 | bp->dcbx_config_params.admin_app_priority_willing = 1; |
| 754 | bp->dcbx_config_params.admin_configuration_bw_precentage[0] = 00; |
| 755 | bp->dcbx_config_params.admin_configuration_bw_precentage[1] = 50; |
| 756 | bp->dcbx_config_params.admin_configuration_bw_precentage[2] = 50; |
| 757 | bp->dcbx_config_params.admin_configuration_bw_precentage[3] = 0; |
| 758 | bp->dcbx_config_params.admin_configuration_bw_precentage[4] = 0; |
| 759 | bp->dcbx_config_params.admin_configuration_bw_precentage[5] = 0; |
| 760 | bp->dcbx_config_params.admin_configuration_bw_precentage[6] = 0; |
| 761 | bp->dcbx_config_params.admin_configuration_bw_precentage[7] = 0; |
| 762 | bp->dcbx_config_params.admin_configuration_ets_pg[0] = 1; |
| 763 | bp->dcbx_config_params.admin_configuration_ets_pg[1] = 0; |
| 764 | bp->dcbx_config_params.admin_configuration_ets_pg[2] = 0; |
| 765 | bp->dcbx_config_params.admin_configuration_ets_pg[3] = 2; |
| 766 | bp->dcbx_config_params.admin_configuration_ets_pg[4] = 0; |
| 767 | bp->dcbx_config_params.admin_configuration_ets_pg[5] = 0; |
| 768 | bp->dcbx_config_params.admin_configuration_ets_pg[6] = 0; |
| 769 | bp->dcbx_config_params.admin_configuration_ets_pg[7] = 0; |
| 770 | bp->dcbx_config_params.admin_recommendation_bw_precentage[0] = 0; |
| 771 | bp->dcbx_config_params.admin_recommendation_bw_precentage[1] = 1; |
| 772 | bp->dcbx_config_params.admin_recommendation_bw_precentage[2] = 2; |
| 773 | bp->dcbx_config_params.admin_recommendation_bw_precentage[3] = 0; |
| 774 | bp->dcbx_config_params.admin_recommendation_bw_precentage[4] = 7; |
| 775 | bp->dcbx_config_params.admin_recommendation_bw_precentage[5] = 5; |
| 776 | bp->dcbx_config_params.admin_recommendation_bw_precentage[6] = 6; |
| 777 | bp->dcbx_config_params.admin_recommendation_bw_precentage[7] = 7; |
| 778 | bp->dcbx_config_params.admin_recommendation_ets_pg[0] = 0; |
| 779 | bp->dcbx_config_params.admin_recommendation_ets_pg[1] = 1; |
| 780 | bp->dcbx_config_params.admin_recommendation_ets_pg[2] = 2; |
| 781 | bp->dcbx_config_params.admin_recommendation_ets_pg[3] = 3; |
| 782 | bp->dcbx_config_params.admin_recommendation_ets_pg[4] = 4; |
| 783 | bp->dcbx_config_params.admin_recommendation_ets_pg[5] = 5; |
| 784 | bp->dcbx_config_params.admin_recommendation_ets_pg[6] = 6; |
| 785 | bp->dcbx_config_params.admin_recommendation_ets_pg[7] = 7; |
| 786 | bp->dcbx_config_params.admin_pfc_bitmap = 0x8; /* FCoE(3) enable */ |
| 787 | bp->dcbx_config_params.admin_priority_app_table[0].valid = 1; |
| 788 | bp->dcbx_config_params.admin_priority_app_table[1].valid = 1; |
| 789 | bp->dcbx_config_params.admin_priority_app_table[2].valid = 0; |
| 790 | bp->dcbx_config_params.admin_priority_app_table[3].valid = 0; |
| 791 | bp->dcbx_config_params.admin_priority_app_table[0].priority = 3; |
| 792 | bp->dcbx_config_params.admin_priority_app_table[1].priority = 0; |
| 793 | bp->dcbx_config_params.admin_priority_app_table[2].priority = 0; |
| 794 | bp->dcbx_config_params.admin_priority_app_table[3].priority = 0; |
| 795 | bp->dcbx_config_params.admin_priority_app_table[0].traffic_type = 0; |
| 796 | bp->dcbx_config_params.admin_priority_app_table[1].traffic_type = 1; |
| 797 | bp->dcbx_config_params.admin_priority_app_table[2].traffic_type = 0; |
| 798 | bp->dcbx_config_params.admin_priority_app_table[3].traffic_type = 0; |
| 799 | bp->dcbx_config_params.admin_priority_app_table[0].app_id = 0x8906; |
| 800 | bp->dcbx_config_params.admin_priority_app_table[1].app_id = 3260; |
| 801 | bp->dcbx_config_params.admin_priority_app_table[2].app_id = 0; |
| 802 | bp->dcbx_config_params.admin_priority_app_table[3].app_id = 0; |
| 803 | bp->dcbx_config_params.admin_default_priority = |
| 804 | bp->dcbx_config_params.admin_priority_app_table[1].priority; |
| 805 | } |
| 806 | |
| 807 | void bnx2x_dcbx_init(struct bnx2x *bp) |
| 808 | { |
| 809 | u32 dcbx_lldp_params_offset = SHMEM_LLDP_DCBX_PARAMS_NONE; |
| 810 | /* validate: |
| 811 | * chip of good for dcbx version, |
| 812 | * dcb is wanted |
| 813 | * the function is pmf |
| 814 | * shmem2 contains DCBX support fields |
| 815 | */ |
| 816 | DP(NETIF_MSG_LINK, "dcb_enable %d bp->port.pmf %d\n", |
| 817 | bp->dcbx_config_params.dcb_enable, bp->port.pmf); |
| 818 | |
| 819 | if (CHIP_IS_E2(bp) && !CHIP_MODE_IS_4_PORT(bp) && |
| 820 | bp->dcbx_config_params.dcb_enable && |
| 821 | bp->port.pmf && |
| 822 | SHMEM2_HAS(bp, dcbx_lldp_params_offset)) { |
| 823 | dcbx_lldp_params_offset = SHMEM2_RD(bp, |
| 824 | dcbx_lldp_params_offset); |
| 825 | DP(NETIF_MSG_LINK, "dcbx_lldp_params_offset 0x%x\n", |
| 826 | dcbx_lldp_params_offset); |
| 827 | if (SHMEM_LLDP_DCBX_PARAMS_NONE != dcbx_lldp_params_offset) { |
| 828 | bnx2x_dcbx_lldp_updated_params(bp, |
| 829 | dcbx_lldp_params_offset); |
| 830 | |
| 831 | bnx2x_dcbx_admin_mib_updated_params(bp, |
| 832 | dcbx_lldp_params_offset); |
| 833 | |
| 834 | /* set default configuration BC has */ |
| 835 | bnx2x_dcbx_set_params(bp, |
| 836 | BNX2X_DCBX_STATE_NEG_RECEIVED); |
| 837 | |
| 838 | bnx2x_fw_command(bp, |
| 839 | DRV_MSG_CODE_DCBX_ADMIN_PMF_MSG, 0); |
| 840 | } |
| 841 | } |
| 842 | } |
| 843 | |
| 844 | void bnx2x_dcb_init_intmem_pfc(struct bnx2x *bp) |
| 845 | { |
| 846 | struct priority_cos pricos[MAX_PFC_TRAFFIC_TYPES]; |
| 847 | u32 i = 0, addr; |
| 848 | memset(pricos, 0, sizeof(pricos)); |
| 849 | /* Default initialization */ |
| 850 | for (i = 0; i < MAX_PFC_TRAFFIC_TYPES; i++) |
| 851 | pricos[i].priority = LLFC_TRAFFIC_TYPE_TO_PRIORITY_UNMAPPED; |
| 852 | |
| 853 | /* Store per port struct to internal memory */ |
| 854 | addr = BAR_XSTRORM_INTMEM + |
| 855 | XSTORM_CMNG_PER_PORT_VARS_OFFSET(BP_PORT(bp)) + |
| 856 | offsetof(struct cmng_struct_per_port, |
| 857 | traffic_type_to_priority_cos); |
| 858 | __storm_memset_struct(bp, addr, sizeof(pricos), (u32 *)pricos); |
| 859 | |
| 860 | |
| 861 | /* LLFC disabled.*/ |
| 862 | REG_WR8(bp , BAR_XSTRORM_INTMEM + |
| 863 | XSTORM_CMNG_PER_PORT_VARS_OFFSET(BP_PORT(bp)) + |
| 864 | offsetof(struct cmng_struct_per_port, llfc_mode), |
| 865 | LLFC_MODE_NONE); |
| 866 | |
| 867 | /* DCBX disabled.*/ |
| 868 | REG_WR8(bp , BAR_XSTRORM_INTMEM + |
| 869 | XSTORM_CMNG_PER_PORT_VARS_OFFSET(BP_PORT(bp)) + |
| 870 | offsetof(struct cmng_struct_per_port, dcb_enabled), |
| 871 | DCB_DISABLED); |
| 872 | } |
| 873 | |
| 874 | static void |
| 875 | bnx2x_dcbx_print_cos_params(struct bnx2x *bp, |
| 876 | struct flow_control_configuration *pfc_fw_cfg) |
| 877 | { |
| 878 | u8 pri = 0; |
| 879 | u8 cos = 0; |
| 880 | |
| 881 | DP(NETIF_MSG_LINK, |
| 882 | "pfc_fw_cfg->dcb_version %x\n", pfc_fw_cfg->dcb_version); |
| 883 | DP(NETIF_MSG_LINK, |
| 884 | "pdev->params.dcbx_port_params.pfc." |
| 885 | "priority_non_pauseable_mask %x\n", |
| 886 | bp->dcbx_port_params.pfc.priority_non_pauseable_mask); |
| 887 | |
| 888 | for (cos = 0 ; cos < bp->dcbx_port_params.ets.num_of_cos ; cos++) { |
| 889 | DP(NETIF_MSG_LINK, "pdev->params.dcbx_port_params.ets." |
| 890 | "cos_params[%d].pri_bitmask %x\n", cos, |
| 891 | bp->dcbx_port_params.ets.cos_params[cos].pri_bitmask); |
| 892 | |
| 893 | DP(NETIF_MSG_LINK, "pdev->params.dcbx_port_params.ets." |
| 894 | "cos_params[%d].bw_tbl %x\n", cos, |
| 895 | bp->dcbx_port_params.ets.cos_params[cos].bw_tbl); |
| 896 | |
| 897 | DP(NETIF_MSG_LINK, "pdev->params.dcbx_port_params.ets." |
| 898 | "cos_params[%d].strict %x\n", cos, |
| 899 | bp->dcbx_port_params.ets.cos_params[cos].strict); |
| 900 | |
| 901 | DP(NETIF_MSG_LINK, "pdev->params.dcbx_port_params.ets." |
| 902 | "cos_params[%d].pauseable %x\n", cos, |
| 903 | bp->dcbx_port_params.ets.cos_params[cos].pauseable); |
| 904 | } |
| 905 | |
| 906 | for (pri = 0; pri < LLFC_DRIVER_TRAFFIC_TYPE_MAX; pri++) { |
| 907 | DP(NETIF_MSG_LINK, |
| 908 | "pfc_fw_cfg->traffic_type_to_priority_cos[%d]." |
| 909 | "priority %x\n", pri, |
| 910 | pfc_fw_cfg->traffic_type_to_priority_cos[pri].priority); |
| 911 | |
| 912 | DP(NETIF_MSG_LINK, |
| 913 | "pfc_fw_cfg->traffic_type_to_priority_cos[%d].cos %x\n", |
| 914 | pri, pfc_fw_cfg->traffic_type_to_priority_cos[pri].cos); |
| 915 | } |
| 916 | } |
| 917 | |
| 918 | /* fills help_data according to pg_info */ |
| 919 | static void bnx2x_dcbx_get_num_pg_traf_type(struct bnx2x *bp, |
| 920 | u32 *pg_pri_orginal_spread, |
| 921 | struct pg_help_data *help_data) |
| 922 | { |
| 923 | bool pg_found = false; |
| 924 | u32 i, traf_type, add_traf_type, add_pg; |
| 925 | u32 *ttp = bp->dcbx_port_params.app.traffic_type_priority; |
| 926 | struct pg_entry_help_data *data = help_data->data; /*shotcut*/ |
| 927 | |
| 928 | /* Set to invalid */ |
| 929 | for (i = 0; i < LLFC_DRIVER_TRAFFIC_TYPE_MAX; i++) |
| 930 | data[i].pg = DCBX_ILLEGAL_PG; |
| 931 | |
| 932 | for (add_traf_type = 0; |
| 933 | add_traf_type < LLFC_DRIVER_TRAFFIC_TYPE_MAX; add_traf_type++) { |
| 934 | pg_found = false; |
| 935 | if (ttp[add_traf_type] < MAX_PFC_PRIORITIES) { |
| 936 | add_pg = (u8)pg_pri_orginal_spread[ttp[add_traf_type]]; |
| 937 | for (traf_type = 0; |
| 938 | traf_type < LLFC_DRIVER_TRAFFIC_TYPE_MAX; |
| 939 | traf_type++) { |
| 940 | if (data[traf_type].pg == add_pg) { |
| 941 | if (!(data[traf_type].pg_priority & |
| 942 | (1 << ttp[add_traf_type]))) |
| 943 | data[traf_type]. |
| 944 | num_of_dif_pri++; |
| 945 | data[traf_type].pg_priority |= |
| 946 | (1 << ttp[add_traf_type]); |
| 947 | pg_found = true; |
| 948 | break; |
| 949 | } |
| 950 | } |
| 951 | if (false == pg_found) { |
| 952 | data[help_data->num_of_pg].pg = add_pg; |
| 953 | data[help_data->num_of_pg].pg_priority = |
| 954 | (1 << ttp[add_traf_type]); |
| 955 | data[help_data->num_of_pg].num_of_dif_pri = 1; |
| 956 | help_data->num_of_pg++; |
| 957 | } |
| 958 | } |
| 959 | DP(NETIF_MSG_LINK, |
| 960 | "add_traf_type %d pg_found %s num_of_pg %d\n", |
| 961 | add_traf_type, (false == pg_found) ? "NO" : "YES", |
| 962 | help_data->num_of_pg); |
| 963 | } |
| 964 | } |
| 965 | |
| 966 | |
| 967 | /******************************************************************************* |
| 968 | * Description: single priority group |
| 969 | * |
| 970 | * Return: |
| 971 | ******************************************************************************/ |
| 972 | static void bnx2x_dcbx_ets_disabled_entry_data(struct bnx2x *bp, |
| 973 | struct cos_help_data *cos_data, |
| 974 | u32 pri_join_mask) |
| 975 | { |
| 976 | /* Only one priority than only one COS */ |
| 977 | cos_data->data[0].pausable = |
| 978 | IS_DCBX_PFC_PRI_ONLY_PAUSE(bp, pri_join_mask); |
| 979 | cos_data->data[0].pri_join_mask = pri_join_mask; |
| 980 | cos_data->data[0].cos_bw = 100; |
| 981 | cos_data->num_of_cos = 1; |
| 982 | } |
| 983 | |
| 984 | /******************************************************************************* |
| 985 | * Description: updating the cos bw |
| 986 | * |
| 987 | * Return: |
| 988 | ******************************************************************************/ |
| 989 | static inline void bnx2x_dcbx_add_to_cos_bw(struct bnx2x *bp, |
| 990 | struct cos_entry_help_data *data, |
| 991 | u8 pg_bw) |
| 992 | { |
| 993 | if (data->cos_bw == DCBX_INVALID_COS_BW) |
| 994 | data->cos_bw = pg_bw; |
| 995 | else |
| 996 | data->cos_bw += pg_bw; |
| 997 | } |
| 998 | |
| 999 | /******************************************************************************* |
| 1000 | * Description: single priority group |
| 1001 | * |
| 1002 | * Return: |
| 1003 | ******************************************************************************/ |
| 1004 | static void bnx2x_dcbx_separate_pauseable_from_non(struct bnx2x *bp, |
| 1005 | struct cos_help_data *cos_data, |
| 1006 | u32 *pg_pri_orginal_spread, |
| 1007 | struct dcbx_ets_feature *ets) |
| 1008 | { |
| 1009 | u32 pri_tested = 0; |
| 1010 | u8 i = 0; |
| 1011 | u8 entry = 0; |
| 1012 | u8 pg_entry = 0; |
| 1013 | u8 num_of_pri = LLFC_DRIVER_TRAFFIC_TYPE_MAX; |
| 1014 | |
| 1015 | cos_data->data[0].pausable = true; |
| 1016 | cos_data->data[1].pausable = false; |
| 1017 | cos_data->data[0].pri_join_mask = cos_data->data[1].pri_join_mask = 0; |
| 1018 | |
| 1019 | for (i = 0 ; i < num_of_pri ; i++) { |
| 1020 | pri_tested = 1 << bp->dcbx_port_params. |
| 1021 | app.traffic_type_priority[i]; |
| 1022 | |
| 1023 | if (pri_tested & DCBX_PFC_PRI_NON_PAUSE_MASK(bp)) { |
| 1024 | cos_data->data[1].pri_join_mask |= pri_tested; |
| 1025 | entry = 1; |
| 1026 | } else { |
| 1027 | cos_data->data[0].pri_join_mask |= pri_tested; |
| 1028 | entry = 0; |
| 1029 | } |
| 1030 | pg_entry = (u8)pg_pri_orginal_spread[bp->dcbx_port_params. |
| 1031 | app.traffic_type_priority[i]]; |
| 1032 | /* There can be only one strict pg */ |
| 1033 | if (pg_entry < DCBX_MAX_NUM_PG_BW_ENTRIES) |
| 1034 | bnx2x_dcbx_add_to_cos_bw(bp, &cos_data->data[entry], |
| 1035 | DCBX_PG_BW_GET(ets->pg_bw_tbl, pg_entry)); |
| 1036 | else |
| 1037 | /* If we join a group and one is strict |
| 1038 | * than the bw rulls */ |
| 1039 | cos_data->data[entry].strict = |
| 1040 | BNX2X_DCBX_COS_HIGH_STRICT; |
| 1041 | } |
| 1042 | if ((0 == cos_data->data[0].pri_join_mask) && |
| 1043 | (0 == cos_data->data[1].pri_join_mask)) |
| 1044 | BNX2X_ERR("dcbx error: Both groups must have priorities\n"); |
| 1045 | } |
| 1046 | |
| 1047 | |
| 1048 | #ifndef POWER_OF_2 |
| 1049 | #define POWER_OF_2(x) ((0 != x) && (0 == (x & (x-1)))) |
| 1050 | #endif |
| 1051 | |
| 1052 | static void bxn2x_dcbx_single_pg_to_cos_params(struct bnx2x *bp, |
| 1053 | struct pg_help_data *pg_help_data, |
| 1054 | struct cos_help_data *cos_data, |
| 1055 | u32 pri_join_mask, |
| 1056 | u8 num_of_dif_pri) |
| 1057 | { |
| 1058 | u8 i = 0; |
| 1059 | u32 pri_tested = 0; |
| 1060 | u32 pri_mask_without_pri = 0; |
| 1061 | u32 *ttp = bp->dcbx_port_params.app.traffic_type_priority; |
| 1062 | /*debug*/ |
| 1063 | if (num_of_dif_pri == 1) { |
| 1064 | bnx2x_dcbx_ets_disabled_entry_data(bp, cos_data, pri_join_mask); |
| 1065 | return; |
| 1066 | } |
| 1067 | /* single priority group */ |
| 1068 | if (pg_help_data->data[0].pg < DCBX_MAX_NUM_PG_BW_ENTRIES) { |
| 1069 | /* If there are both pauseable and non-pauseable priorities, |
| 1070 | * the pauseable priorities go to the first queue and |
| 1071 | * the non-pauseable priorities go to the second queue. |
| 1072 | */ |
| 1073 | if (IS_DCBX_PFC_PRI_MIX_PAUSE(bp, pri_join_mask)) { |
| 1074 | /* Pauseable */ |
| 1075 | cos_data->data[0].pausable = true; |
| 1076 | /* Non pauseable.*/ |
| 1077 | cos_data->data[1].pausable = false; |
| 1078 | |
| 1079 | if (2 == num_of_dif_pri) { |
| 1080 | cos_data->data[0].cos_bw = 50; |
| 1081 | cos_data->data[1].cos_bw = 50; |
| 1082 | } |
| 1083 | |
| 1084 | if (3 == num_of_dif_pri) { |
| 1085 | if (POWER_OF_2(DCBX_PFC_PRI_GET_PAUSE(bp, |
| 1086 | pri_join_mask))) { |
| 1087 | cos_data->data[0].cos_bw = 33; |
| 1088 | cos_data->data[1].cos_bw = 67; |
| 1089 | } else { |
| 1090 | cos_data->data[0].cos_bw = 67; |
| 1091 | cos_data->data[1].cos_bw = 33; |
| 1092 | } |
| 1093 | } |
| 1094 | |
| 1095 | } else if (IS_DCBX_PFC_PRI_ONLY_PAUSE(bp, pri_join_mask)) { |
| 1096 | /* If there are only pauseable priorities, |
| 1097 | * then one/two priorities go to the first queue |
| 1098 | * and one priority goes to the second queue. |
| 1099 | */ |
| 1100 | if (2 == num_of_dif_pri) { |
| 1101 | cos_data->data[0].cos_bw = 50; |
| 1102 | cos_data->data[1].cos_bw = 50; |
| 1103 | } else { |
| 1104 | cos_data->data[0].cos_bw = 67; |
| 1105 | cos_data->data[1].cos_bw = 33; |
| 1106 | } |
| 1107 | cos_data->data[1].pausable = true; |
| 1108 | cos_data->data[0].pausable = true; |
| 1109 | /* All priorities except FCOE */ |
| 1110 | cos_data->data[0].pri_join_mask = (pri_join_mask & |
| 1111 | ((u8)~(1 << ttp[LLFC_TRAFFIC_TYPE_FCOE]))); |
| 1112 | /* Only FCOE priority.*/ |
| 1113 | cos_data->data[1].pri_join_mask = |
| 1114 | (1 << ttp[LLFC_TRAFFIC_TYPE_FCOE]); |
| 1115 | } else |
| 1116 | /* If there are only non-pauseable priorities, |
| 1117 | * they will all go to the same queue. |
| 1118 | */ |
| 1119 | bnx2x_dcbx_ets_disabled_entry_data(bp, |
| 1120 | cos_data, pri_join_mask); |
| 1121 | } else { |
| 1122 | /* priority group which is not BW limited (PG#15):*/ |
| 1123 | if (IS_DCBX_PFC_PRI_MIX_PAUSE(bp, pri_join_mask)) { |
| 1124 | /* If there are both pauseable and non-pauseable |
| 1125 | * priorities, the pauseable priorities go to the first |
| 1126 | * queue and the non-pauseable priorities |
| 1127 | * go to the second queue. |
| 1128 | */ |
| 1129 | if (DCBX_PFC_PRI_GET_PAUSE(bp, pri_join_mask) > |
| 1130 | DCBX_PFC_PRI_GET_NON_PAUSE(bp, pri_join_mask)) { |
| 1131 | cos_data->data[0].strict = |
| 1132 | BNX2X_DCBX_COS_HIGH_STRICT; |
| 1133 | cos_data->data[1].strict = |
| 1134 | BNX2X_DCBX_COS_LOW_STRICT; |
| 1135 | } else { |
| 1136 | cos_data->data[0].strict = |
| 1137 | BNX2X_DCBX_COS_LOW_STRICT; |
| 1138 | cos_data->data[1].strict = |
| 1139 | BNX2X_DCBX_COS_HIGH_STRICT; |
| 1140 | } |
| 1141 | /* Pauseable */ |
| 1142 | cos_data->data[0].pausable = true; |
| 1143 | /* Non pause-able.*/ |
| 1144 | cos_data->data[1].pausable = false; |
| 1145 | } else { |
| 1146 | /* If there are only pauseable priorities or |
| 1147 | * only non-pauseable,* the lower priorities go |
| 1148 | * to the first queue and the higherpriorities go |
| 1149 | * to the second queue. |
| 1150 | */ |
| 1151 | cos_data->data[0].pausable = |
| 1152 | cos_data->data[1].pausable = |
| 1153 | IS_DCBX_PFC_PRI_ONLY_PAUSE(bp, pri_join_mask); |
| 1154 | |
| 1155 | for (i = 0 ; i < LLFC_DRIVER_TRAFFIC_TYPE_MAX; i++) { |
| 1156 | pri_tested = 1 << bp->dcbx_port_params. |
| 1157 | app.traffic_type_priority[i]; |
| 1158 | /* Remove priority tested */ |
| 1159 | pri_mask_without_pri = |
| 1160 | (pri_join_mask & ((u8)(~pri_tested))); |
| 1161 | if (pri_mask_without_pri < pri_tested) |
| 1162 | break; |
| 1163 | } |
| 1164 | |
| 1165 | if (i == LLFC_DRIVER_TRAFFIC_TYPE_MAX) |
| 1166 | BNX2X_ERR("Invalid value for pri_join_mask -" |
| 1167 | " could not find a priority\n"); |
| 1168 | |
| 1169 | cos_data->data[0].pri_join_mask = pri_mask_without_pri; |
| 1170 | cos_data->data[1].pri_join_mask = pri_tested; |
| 1171 | /* Both queues are strict priority, |
| 1172 | * and that with the highest priority |
| 1173 | * gets the highest strict priority in the arbiter. |
| 1174 | */ |
| 1175 | cos_data->data[0].strict = BNX2X_DCBX_COS_LOW_STRICT; |
| 1176 | cos_data->data[1].strict = BNX2X_DCBX_COS_HIGH_STRICT; |
| 1177 | } |
| 1178 | } |
| 1179 | } |
| 1180 | |
| 1181 | static void bnx2x_dcbx_two_pg_to_cos_params( |
| 1182 | struct bnx2x *bp, |
| 1183 | struct pg_help_data *pg_help_data, |
| 1184 | struct dcbx_ets_feature *ets, |
| 1185 | struct cos_help_data *cos_data, |
| 1186 | u32 *pg_pri_orginal_spread, |
| 1187 | u32 pri_join_mask, |
| 1188 | u8 num_of_dif_pri) |
| 1189 | { |
| 1190 | u8 i = 0; |
| 1191 | u8 pg[E2_NUM_OF_COS] = {0}; |
| 1192 | |
| 1193 | /* If there are both pauseable and non-pauseable priorities, |
| 1194 | * the pauseable priorities go to the first queue and |
| 1195 | * the non-pauseable priorities go to the second queue. |
| 1196 | */ |
| 1197 | if (IS_DCBX_PFC_PRI_MIX_PAUSE(bp, pri_join_mask)) { |
| 1198 | if (IS_DCBX_PFC_PRI_MIX_PAUSE(bp, |
| 1199 | pg_help_data->data[0].pg_priority) || |
| 1200 | IS_DCBX_PFC_PRI_MIX_PAUSE(bp, |
| 1201 | pg_help_data->data[1].pg_priority)) { |
| 1202 | /* If one PG contains both pauseable and |
| 1203 | * non-pauseable priorities then ETS is disabled. |
| 1204 | */ |
| 1205 | bnx2x_dcbx_separate_pauseable_from_non(bp, cos_data, |
| 1206 | pg_pri_orginal_spread, ets); |
| 1207 | bp->dcbx_port_params.ets.enabled = false; |
| 1208 | return; |
| 1209 | } |
| 1210 | |
| 1211 | /* Pauseable */ |
| 1212 | cos_data->data[0].pausable = true; |
| 1213 | /* Non pauseable. */ |
| 1214 | cos_data->data[1].pausable = false; |
| 1215 | if (IS_DCBX_PFC_PRI_ONLY_PAUSE(bp, |
| 1216 | pg_help_data->data[0].pg_priority)) { |
| 1217 | /* 0 is pauseable */ |
| 1218 | cos_data->data[0].pri_join_mask = |
| 1219 | pg_help_data->data[0].pg_priority; |
| 1220 | pg[0] = pg_help_data->data[0].pg; |
| 1221 | cos_data->data[1].pri_join_mask = |
| 1222 | pg_help_data->data[1].pg_priority; |
| 1223 | pg[1] = pg_help_data->data[1].pg; |
| 1224 | } else {/* 1 is pauseable */ |
| 1225 | cos_data->data[0].pri_join_mask = |
| 1226 | pg_help_data->data[1].pg_priority; |
| 1227 | pg[0] = pg_help_data->data[1].pg; |
| 1228 | cos_data->data[1].pri_join_mask = |
| 1229 | pg_help_data->data[0].pg_priority; |
| 1230 | pg[1] = pg_help_data->data[0].pg; |
| 1231 | } |
| 1232 | } else { |
| 1233 | /* If there are only pauseable priorities or |
| 1234 | * only non-pauseable, each PG goes to a queue. |
| 1235 | */ |
| 1236 | cos_data->data[0].pausable = cos_data->data[1].pausable = |
| 1237 | IS_DCBX_PFC_PRI_ONLY_PAUSE(bp, pri_join_mask); |
| 1238 | cos_data->data[0].pri_join_mask = |
| 1239 | pg_help_data->data[0].pg_priority; |
| 1240 | pg[0] = pg_help_data->data[0].pg; |
| 1241 | cos_data->data[1].pri_join_mask = |
| 1242 | pg_help_data->data[1].pg_priority; |
| 1243 | pg[1] = pg_help_data->data[1].pg; |
| 1244 | } |
| 1245 | |
| 1246 | /* There can be only one strict pg */ |
| 1247 | for (i = 0 ; i < E2_NUM_OF_COS; i++) { |
| 1248 | if (pg[i] < DCBX_MAX_NUM_PG_BW_ENTRIES) |
| 1249 | cos_data->data[i].cos_bw = |
| 1250 | DCBX_PG_BW_GET(ets->pg_bw_tbl, pg[i]); |
| 1251 | else |
| 1252 | cos_data->data[i].strict = BNX2X_DCBX_COS_HIGH_STRICT; |
| 1253 | } |
| 1254 | } |
| 1255 | |
| 1256 | /******************************************************************************* |
| 1257 | * Description: Still |
| 1258 | * |
| 1259 | * Return: |
| 1260 | ******************************************************************************/ |
| 1261 | static void bnx2x_dcbx_three_pg_to_cos_params( |
| 1262 | struct bnx2x *bp, |
| 1263 | struct pg_help_data *pg_help_data, |
| 1264 | struct dcbx_ets_feature *ets, |
| 1265 | struct cos_help_data *cos_data, |
| 1266 | u32 *pg_pri_orginal_spread, |
| 1267 | u32 pri_join_mask, |
| 1268 | u8 num_of_dif_pri) |
| 1269 | { |
| 1270 | u8 i = 0; |
| 1271 | u32 pri_tested = 0; |
| 1272 | u8 entry = 0; |
| 1273 | u8 pg_entry = 0; |
| 1274 | bool b_found_strict = false; |
| 1275 | u8 num_of_pri = LLFC_DRIVER_TRAFFIC_TYPE_MAX; |
| 1276 | |
| 1277 | cos_data->data[0].pri_join_mask = cos_data->data[1].pri_join_mask = 0; |
| 1278 | /* If there are both pauseable and non-pauseable priorities, |
| 1279 | * the pauseable priorities go to the first queue and the |
| 1280 | * non-pauseable priorities go to the second queue. |
| 1281 | */ |
| 1282 | if (IS_DCBX_PFC_PRI_MIX_PAUSE(bp, pri_join_mask)) |
| 1283 | bnx2x_dcbx_separate_pauseable_from_non(bp, |
| 1284 | cos_data, pg_pri_orginal_spread, ets); |
| 1285 | else { |
| 1286 | /* If two BW-limited PG-s were combined to one queue, |
| 1287 | * the BW is their sum. |
| 1288 | * |
| 1289 | * If there are only pauseable priorities or only non-pauseable, |
| 1290 | * and there are both BW-limited and non-BW-limited PG-s, |
| 1291 | * the BW-limited PG/s go to one queue and the non-BW-limited |
| 1292 | * PG/s go to the second queue. |
| 1293 | * |
| 1294 | * If there are only pauseable priorities or only non-pauseable |
| 1295 | * and all are BW limited, then two priorities go to the first |
| 1296 | * queue and one priority goes to the second queue. |
| 1297 | * |
| 1298 | * We will join this two cases: |
| 1299 | * if one is BW limited it will go to the secoend queue |
| 1300 | * otherwise the last priority will get it |
| 1301 | */ |
| 1302 | |
| 1303 | cos_data->data[0].pausable = cos_data->data[1].pausable = |
| 1304 | IS_DCBX_PFC_PRI_ONLY_PAUSE(bp, pri_join_mask); |
| 1305 | |
| 1306 | for (i = 0 ; i < num_of_pri; i++) { |
| 1307 | pri_tested = 1 << bp->dcbx_port_params. |
| 1308 | app.traffic_type_priority[i]; |
| 1309 | pg_entry = (u8)pg_pri_orginal_spread[bp-> |
| 1310 | dcbx_port_params.app.traffic_type_priority[i]]; |
| 1311 | |
| 1312 | if (pg_entry < DCBX_MAX_NUM_PG_BW_ENTRIES) { |
| 1313 | entry = 0; |
| 1314 | |
| 1315 | if (i == (num_of_pri-1) && |
| 1316 | false == b_found_strict) |
| 1317 | /* last entry will be handled separately |
| 1318 | * If no priority is strict than last |
| 1319 | * enty goes to last queue.*/ |
| 1320 | entry = 1; |
| 1321 | cos_data->data[entry].pri_join_mask |= |
| 1322 | pri_tested; |
| 1323 | bnx2x_dcbx_add_to_cos_bw(bp, |
| 1324 | &cos_data->data[entry], |
| 1325 | DCBX_PG_BW_GET(ets->pg_bw_tbl, |
| 1326 | pg_entry)); |
| 1327 | } else { |
| 1328 | b_found_strict = true; |
| 1329 | cos_data->data[1].pri_join_mask |= pri_tested; |
| 1330 | /* If we join a group and one is strict |
| 1331 | * than the bw rulls */ |
| 1332 | cos_data->data[1].strict = |
| 1333 | BNX2X_DCBX_COS_HIGH_STRICT; |
| 1334 | } |
| 1335 | } |
| 1336 | } |
| 1337 | } |
| 1338 | |
| 1339 | |
| 1340 | static void bnx2x_dcbx_fill_cos_params(struct bnx2x *bp, |
| 1341 | struct pg_help_data *help_data, |
| 1342 | struct dcbx_ets_feature *ets, |
| 1343 | u32 *pg_pri_orginal_spread) |
| 1344 | { |
| 1345 | struct cos_help_data cos_data ; |
| 1346 | u8 i = 0; |
| 1347 | u32 pri_join_mask = 0; |
| 1348 | u8 num_of_dif_pri = 0; |
| 1349 | |
| 1350 | memset(&cos_data, 0, sizeof(cos_data)); |
| 1351 | /* Validate the pg value */ |
| 1352 | for (i = 0; i < help_data->num_of_pg ; i++) { |
| 1353 | if (DCBX_STRICT_PRIORITY != help_data->data[i].pg && |
| 1354 | DCBX_MAX_NUM_PG_BW_ENTRIES <= help_data->data[i].pg) |
| 1355 | BNX2X_ERR("Invalid pg[%d] data %x\n", i, |
| 1356 | help_data->data[i].pg); |
| 1357 | pri_join_mask |= help_data->data[i].pg_priority; |
| 1358 | num_of_dif_pri += help_data->data[i].num_of_dif_pri; |
| 1359 | } |
| 1360 | |
| 1361 | /* default settings */ |
| 1362 | cos_data.num_of_cos = 2; |
| 1363 | for (i = 0; i < E2_NUM_OF_COS ; i++) { |
| 1364 | cos_data.data[i].pri_join_mask = pri_join_mask; |
| 1365 | cos_data.data[i].pausable = false; |
| 1366 | cos_data.data[i].strict = BNX2X_DCBX_COS_NOT_STRICT; |
| 1367 | cos_data.data[i].cos_bw = DCBX_INVALID_COS_BW; |
| 1368 | } |
| 1369 | |
| 1370 | switch (help_data->num_of_pg) { |
| 1371 | case 1: |
| 1372 | |
| 1373 | bxn2x_dcbx_single_pg_to_cos_params( |
| 1374 | bp, |
| 1375 | help_data, |
| 1376 | &cos_data, |
| 1377 | pri_join_mask, |
| 1378 | num_of_dif_pri); |
| 1379 | break; |
| 1380 | case 2: |
| 1381 | bnx2x_dcbx_two_pg_to_cos_params( |
| 1382 | bp, |
| 1383 | help_data, |
| 1384 | ets, |
| 1385 | &cos_data, |
| 1386 | pg_pri_orginal_spread, |
| 1387 | pri_join_mask, |
| 1388 | num_of_dif_pri); |
| 1389 | break; |
| 1390 | |
| 1391 | case 3: |
| 1392 | bnx2x_dcbx_three_pg_to_cos_params( |
| 1393 | bp, |
| 1394 | help_data, |
| 1395 | ets, |
| 1396 | &cos_data, |
| 1397 | pg_pri_orginal_spread, |
| 1398 | pri_join_mask, |
| 1399 | num_of_dif_pri); |
| 1400 | |
| 1401 | break; |
| 1402 | default: |
| 1403 | BNX2X_ERR("Wrong pg_help_data.num_of_pg\n"); |
| 1404 | bnx2x_dcbx_ets_disabled_entry_data(bp, |
| 1405 | &cos_data, pri_join_mask); |
| 1406 | } |
| 1407 | |
| 1408 | for (i = 0; i < cos_data.num_of_cos ; i++) { |
| 1409 | struct bnx2x_dcbx_cos_params *params = |
| 1410 | &bp->dcbx_port_params.ets.cos_params[i]; |
| 1411 | |
| 1412 | params->pauseable = cos_data.data[i].pausable; |
| 1413 | params->strict = cos_data.data[i].strict; |
| 1414 | params->bw_tbl = cos_data.data[i].cos_bw; |
| 1415 | if (params->pauseable) { |
| 1416 | params->pri_bitmask = |
| 1417 | DCBX_PFC_PRI_GET_PAUSE(bp, |
| 1418 | cos_data.data[i].pri_join_mask); |
| 1419 | DP(NETIF_MSG_LINK, "COS %d PAUSABLE prijoinmask 0x%x\n", |
| 1420 | i, cos_data.data[i].pri_join_mask); |
| 1421 | } else { |
| 1422 | params->pri_bitmask = |
| 1423 | DCBX_PFC_PRI_GET_NON_PAUSE(bp, |
| 1424 | cos_data.data[i].pri_join_mask); |
| 1425 | DP(NETIF_MSG_LINK, "COS %d NONPAUSABLE prijoinmask " |
| 1426 | "0x%x\n", |
| 1427 | i, cos_data.data[i].pri_join_mask); |
| 1428 | } |
| 1429 | } |
| 1430 | |
| 1431 | bp->dcbx_port_params.ets.num_of_cos = cos_data.num_of_cos ; |
| 1432 | } |
| 1433 | |
| 1434 | static void bnx2x_dcbx_get_ets_pri_pg_tbl(struct bnx2x *bp, |
| 1435 | u32 *set_configuration_ets_pg, |
| 1436 | u32 *pri_pg_tbl) |
| 1437 | { |
| 1438 | int i; |
| 1439 | |
| 1440 | for (i = 0; i < DCBX_MAX_NUM_PRI_PG_ENTRIES; i++) { |
| 1441 | set_configuration_ets_pg[i] = DCBX_PRI_PG_GET(pri_pg_tbl, i); |
| 1442 | |
| 1443 | DP(NETIF_MSG_LINK, "set_configuration_ets_pg[%d] = 0x%x\n", |
| 1444 | i, set_configuration_ets_pg[i]); |
| 1445 | } |
| 1446 | } |
| 1447 | |
| 1448 | /******************************************************************************* |
| 1449 | * Description: Fill pfc_config struct that will be sent in DCBX start ramrod |
| 1450 | * |
| 1451 | * Return: |
| 1452 | ******************************************************************************/ |
| 1453 | static void bnx2x_pfc_fw_struct_e2(struct bnx2x *bp) |
| 1454 | { |
| 1455 | struct flow_control_configuration *pfc_fw_cfg = 0; |
| 1456 | u16 pri_bit = 0; |
| 1457 | u8 cos = 0, pri = 0; |
| 1458 | struct priority_cos *tt2cos; |
| 1459 | u32 *ttp = bp->dcbx_port_params.app.traffic_type_priority; |
| 1460 | |
| 1461 | pfc_fw_cfg = (struct flow_control_configuration *) |
| 1462 | bnx2x_sp(bp, pfc_config); |
| 1463 | memset(pfc_fw_cfg, 0, sizeof(struct flow_control_configuration)); |
| 1464 | |
| 1465 | /*shortcut*/ |
| 1466 | tt2cos = pfc_fw_cfg->traffic_type_to_priority_cos; |
| 1467 | |
| 1468 | /* Fw version should be incremented each update */ |
| 1469 | pfc_fw_cfg->dcb_version = ++bp->dcb_version; |
| 1470 | pfc_fw_cfg->dcb_enabled = DCB_ENABLED; |
| 1471 | |
| 1472 | /* Default initialization */ |
| 1473 | for (pri = 0; pri < MAX_PFC_TRAFFIC_TYPES ; pri++) { |
| 1474 | tt2cos[pri].priority = LLFC_TRAFFIC_TYPE_TO_PRIORITY_UNMAPPED; |
| 1475 | tt2cos[pri].cos = 0; |
| 1476 | } |
| 1477 | |
| 1478 | /* Fill priority parameters */ |
| 1479 | for (pri = 0; pri < LLFC_DRIVER_TRAFFIC_TYPE_MAX; pri++) { |
| 1480 | tt2cos[pri].priority = ttp[pri]; |
| 1481 | pri_bit = 1 << tt2cos[pri].priority; |
| 1482 | |
| 1483 | /* Fill COS parameters based on COS calculated to |
| 1484 | * make it more generally for future use */ |
| 1485 | for (cos = 0; cos < bp->dcbx_port_params.ets.num_of_cos; cos++) |
| 1486 | if (bp->dcbx_port_params.ets.cos_params[cos]. |
| 1487 | pri_bitmask & pri_bit) |
| 1488 | tt2cos[pri].cos = cos; |
| 1489 | } |
| 1490 | bnx2x_dcbx_print_cos_params(bp, pfc_fw_cfg); |
| 1491 | } |