commit 02f8a4ed97dbf076a61da0a0dde69e58e53c72d7
parent 823230a2193088959164a8fa94c969aff03a7589
Author: Broadcom SDK Release <sdk.releases@broadcom.com>
Date: Mon, 16 Dec 2019 19:55:17 -0800
SDK-169951: Switch control L3Max128BV6Entries and ALPM config properties spn_...
Devices: 56850_A0,56850_A1,56850_A2,56960_A0,56960_B0,56960_B1,56980_A0,56980_B0
Module: ALPM
Switch control L3Max128BV6Entries and ALPM config properties
spn_IPV6_LPM_128B_ENABLE & spn_NUM_IPV6_LPM_128B_ENTRIES are not
handling properly, which affect ALPM object counters. In theory the
these two config properties should be read only during BCM
initialization. The switch control L3Max128BV6Entries can change in run
time which resize the paired_DEFIP; Set to zero means V6_64B is going to
be used, set different than zero (even spn_IPV6_LPM_128B_ENABLE=0) means
V6_128B is enabled. This patch fixes switch control
bcmSwitchL3Max128BV6Entries handling issue and it's effect on ALPM
object counters. For freeRoutes problem (based on previous solution), we
fixed an obvious problem for V6_64_freeRoutes which should be zero. Also
when freeRoutes is negative, it will be forced to zero.
Diffstat:
6 files changed, 59 insertions(+), 56 deletions(-)
diff --git a/sdk-6.5.16/include/soc/drv.h b/sdk-6.5.16/include/soc/drv.h
@@ -2509,6 +2509,9 @@ extern int SOC_BLOCK_IN_LIST(int *blk, int type);
#define SOC_FP_TCAM_SCACHE_HANDLE(unit) \
SOC_CONTROL(unit)->fp_tcam_scache_ptr
+#define SOC_ALPM_128B_ENABLE(unit) \
+ (SOC_L3_DEFIP_MAX_128B_ENTRIES(unit) > 0 ? 1 : 0)
+
/* URPF on/off set/get macros */
#define SOC_L2X_GROUP_ENABLE_GET(_unit_) (SOC_CONTROL(_unit_)->l2x_group_enable)
#define SOC_L2X_GROUP_ENABLE_SET(_unit_, _status_) \
diff --git a/sdk-6.5.16/src/bcm/esw/alpm2/alpm.c b/sdk-6.5.16/src/bcm/esw/alpm2/alpm.c
@@ -4473,19 +4473,13 @@ bcm_esw_alpm_ctrl_init(int u)
ALPM_MODE_CHK(u, BCM_ALPM_MODE_TCAM_ALPM)) {
ALPM_TCAM_ZONED(u) = TRUE;
}
- ALPM_128B(u) = soc_property_get(u, spn_IPV6_LPM_128B_ENABLE, 1);
- /* 256 entries per TCAM, 2 TCAMs per block, 4 blocks in total.
- * by default we have 2 blocks paired. */
- if (ALPM_128B(u)) {
- pair_ent_cnt = soc_property_get(u, spn_NUM_IPV6_LPM_128B_ENTRIES,
- def_ipv6_128b_entries);
- if (pair_ent_cnt > (def_ipv6_128b_entries * 2)) {
- pair_ent_cnt = def_ipv6_128b_entries * 2;
- }
- if (pair_ent_cnt == 0) {
- ALPM_ERR(("ALPM wrong config! ipv6_lpm_128b_enable=1 "
- "with num_ipv6_lpm_128b_entries=0\n"));
- }
+
+ /* Due to swith control L3Max128BV6Entries, pair_ent_cnt
+ shouldn't come directly from spn_NUM_IPV6_LPM_128B_ENTRIES */
+ ALPM_128B(u) = SOC_ALPM_128B_ENABLE(u);
+ pair_ent_cnt = SOC_L3_DEFIP_MAX_128B_ENTRIES(u);
+ if (pair_ent_cnt > (def_ipv6_128b_entries * 2)) {
+ pair_ent_cnt = def_ipv6_128b_entries * 2;
}
ALPM_TCAM_PAIR_BLK_CNT(u) = (pair_ent_cnt + (tcam_depth - 1)) / tcam_depth;
diff --git a/sdk-6.5.16/src/bcm/esw/switch.c b/sdk-6.5.16/src/bcm/esw/switch.c
@@ -26753,6 +26753,8 @@ _bcm_esw_l3_route_info_get(int u, bcm_switch_object_t object, int *entries)
soc_property_get(u, spn_L3_ALPM_ENABLE, 0)) {
if (SOC_IS_TD2_TT2(u)){
int rv = BCM_E_NONE;
+ int alpm_128b_enable = SOC_ALPM_128B_ENABLE(u);
+
int (* soc_alpm_capacity_get)(int, int, int *, int *) = NULL;
#if defined(BCM_TOMAHAWK_SUPPORT) || defined(BCM_APACHE_SUPPORT)
#if defined(BCM_TOMAHAWK_SUPPORT)
@@ -26776,7 +26778,7 @@ _bcm_esw_l3_route_info_get(int u, bcm_switch_object_t object, int *entries)
break;
case bcmSwitchObjectL3RouteV6Routes64bMax:
- if (soc_property_get(u, spn_IPV6_LPM_128B_ENABLE, 1)) {
+ if (alpm_128b_enable) {
*entries = 0;
} else {
rv = (* soc_alpm_capacity_get)(u,
@@ -26786,7 +26788,7 @@ _bcm_esw_l3_route_info_get(int u, bcm_switch_object_t object, int *entries)
break;
case bcmSwitchObjectL3RouteV6Routes128bMax:
- if (soc_property_get(u, spn_IPV6_LPM_128B_ENABLE, 1)) {
+ if (alpm_128b_enable) {
rv = (* soc_alpm_capacity_get)(u,
L3_DEFIP_ALPM_IPV6_128m, entries, NULL);
} else {
@@ -26802,7 +26804,7 @@ _bcm_esw_l3_route_info_get(int u, bcm_switch_object_t object, int *entries)
break;
case bcmSwitchObjectL3RouteV6Routes64bMinGuaranteed :
- if (soc_property_get(u, spn_IPV6_LPM_128B_ENABLE, 1)) {
+ if (alpm_128b_enable) {
*entries = 0;
} else {
rv = (* soc_alpm_capacity_get)(u,
@@ -26812,7 +26814,7 @@ _bcm_esw_l3_route_info_get(int u, bcm_switch_object_t object, int *entries)
break;
case bcmSwitchObjectL3RouteV6Routes128bMinGuaranteed:
- if (soc_property_get(u, spn_IPV6_LPM_128B_ENABLE, 1)) {
+ if (alpm_128b_enable) {
rv = (* soc_alpm_capacity_get)(u,
L3_DEFIP_ALPM_IPV6_128m, NULL, entries);
} else {
@@ -26822,51 +26824,55 @@ _bcm_esw_l3_route_info_get(int u, bcm_switch_object_t object, int *entries)
break;
case bcmSwitchObjectL3RouteV4RoutesFree:
- if (!soc_property_get(u, spn_IPV6_LPM_128B_ENABLE, 1) ||
- !soc_property_get(u, spn_L3_ALPM_IPV6_128B_BKT_RSVD, 0)) {
- return BCM_E_UNAVAIL;
- }
-
- if (!SOC_IS_TOMAHAWKX(u)) {
- return BCM_E_UNAVAIL;
- }
+ if (alpm_128b_enable &&
+ soc_property_get(u, spn_L3_ALPM_IPV6_128B_BKT_RSVD, 0) &&
+ SOC_IS_TOMAHAWKX(u)) {
- rv = (* soc_alpm_capacity_get)(u,
+ rv = (* soc_alpm_capacity_get)(u,
L3_DEFIP_ALPM_IPV4m, NULL, entries);
- *entries -= BCM_XGS3_L3_DEFIP_IP4_CNT(u);
- return rv;
- break;
- case bcmSwitchObjectL3RouteV6Routes64bFree:
- if (!soc_property_get(u, spn_IPV6_LPM_128B_ENABLE, 1) ||
- !soc_property_get(u, spn_L3_ALPM_IPV6_128B_BKT_RSVD, 0)) {
+ /* Coarse estimate: FreeRoutes = MinGuraranteed - UsedRoutes;
+ Only applicable when V6_128B_RSVD is enabled and for TOMAHAWKX */
+ *entries -= BCM_XGS3_L3_DEFIP_IP4_CNT(u);
+ if (BCM_SUCCESS(rv) && *entries < 0) {
+ *entries = 0;
+ }
+ return rv;
+ } else {
return BCM_E_UNAVAIL;
}
+ break;
- if (!SOC_IS_TOMAHAWKX(u)) {
+ case bcmSwitchObjectL3RouteV6Routes64bFree:
+ if (alpm_128b_enable &&
+ soc_property_get(u, spn_L3_ALPM_IPV6_128B_BKT_RSVD, 0) &&
+ SOC_IS_TOMAHAWKX(u)) {
+
+ *entries = 0; /* no V6Routes64bFree in V6_128B mode */
+ return rv;
+ } else {
return BCM_E_UNAVAIL;
}
-
- rv = (* soc_alpm_capacity_get)(u,
- L3_DEFIP_ALPM_IPV6_64m, NULL, entries);
- *entries -= BCM_XGS3_L3_DEFIP_IP6_CNT(u);
- return rv;
break;
case bcmSwitchObjectL3RouteV6Routes128bFree:
- if (!soc_property_get(u, spn_IPV6_LPM_128B_ENABLE, 1) ||
- !soc_property_get(u, spn_L3_ALPM_IPV6_128B_BKT_RSVD, 0)) {
- return BCM_E_UNAVAIL;
- }
+ if (alpm_128b_enable &&
+ soc_property_get(u, spn_L3_ALPM_IPV6_128B_BKT_RSVD, 0) &&
+ SOC_IS_TOMAHAWKX(u)) {
- if (!SOC_IS_TOMAHAWKX(u)) {
+ rv = (* soc_alpm_capacity_get)(u,
+ L3_DEFIP_ALPM_IPV6_128m, NULL, entries);
+
+ /* Coarse estimate: FreeRoutes = MinGuraranteed - UsedRoutes;
+ Only applicable when V6_128B_RSVD is enabled and for TOMAHAWKX */
+ *entries -= BCM_XGS3_L3_DEFIP_IP6_CNT(u);
+ if (BCM_SUCCESS(rv) && *entries < 0) {
+ *entries = 0;
+ }
+ return rv;
+ } else {
return BCM_E_UNAVAIL;
}
-
- rv = (* soc_alpm_capacity_get)(u,
- L3_DEFIP_ALPM_IPV6_128m, NULL, entries);
- *entries -= BCM_XGS3_L3_DEFIP_IP6_CNT(u);
- return rv;
break;
case bcmSwitchObjectL3RouteV4RoutesUsed:
@@ -26874,7 +26880,7 @@ _bcm_esw_l3_route_info_get(int u, bcm_switch_object_t object, int *entries)
break;
case bcmSwitchObjectL3RouteV6Routes64bUsed:
- if (soc_property_get(u, spn_IPV6_LPM_128B_ENABLE, 1)) {
+ if (alpm_128b_enable) {
*entries = 0;
} else {
*entries = BCM_XGS3_L3_DEFIP_IP6_CNT(u);
@@ -26882,7 +26888,7 @@ _bcm_esw_l3_route_info_get(int u, bcm_switch_object_t object, int *entries)
break;
case bcmSwitchObjectL3RouteV6Routes128bUsed:
- if (soc_property_get(u, spn_IPV6_LPM_128B_ENABLE, 1)) {
+ if (alpm_128b_enable) {
*entries = BCM_XGS3_L3_DEFIP_IP6_CNT(u);
} else {
*entries = 0;
diff --git a/sdk-6.5.16/src/bcm/esw/tomahawk/alpm.c b/sdk-6.5.16/src/bcm/esw/tomahawk/alpm.c
@@ -1277,7 +1277,7 @@ th_alpm_key_sel_init(int u)
};
urpf_enb = !!SOC_URPF_STATUS_GET(u);
- lpm_128b = !!soc_property_get(u, spn_IPV6_LPM_128B_ENABLE, 1);
+ lpm_128b = !!SOC_ALPM_128B_ENABLE(u);
if (soc_reg_field_valid(u, kselr, KEY_SEL_CAM0_1f)) {
i = lpm_128b;
diff --git a/sdk-6.5.16/src/soc/esw/trident2/alpm.c b/sdk-6.5.16/src/soc/esw/trident2/alpm.c
@@ -8531,7 +8531,7 @@ soc_alpm_lpm_init(int u)
}
}
SOC_IF_ERROR_RETURN(WRITE_L3_DEFIP_ALPM_CFGr(u, rval));
- if (soc_property_get(u, spn_IPV6_LPM_128B_ENABLE, 1)) {
+ if (SOC_ALPM_128B_ENABLE(u)) {
uint32 defip_key_sel_val = 0;
SOC_IF_ERROR_RETURN(READ_L3_DEFIP_KEY_SELr(u, &defip_key_sel_val));
@@ -10404,7 +10404,7 @@ _soc_alpm_pivot_max_get(int u, alpm_vrf_counter_t *pvt_max)
pvt_max->v4 = soc_mem_index_count(u, L3_DEFIPm) * 2;
pvt_max->v6_128 = soc_mem_index_count(u, L3_DEFIP_PAIR_128m);
- if (soc_property_get(u, spn_IPV6_LPM_128B_ENABLE, 1)) {
+ if (SOC_ALPM_128B_ENABLE(u)) {
pvt_max->v6_64 = pvt_max->v6_128;
} else {
pvt_max->v6_64 = pvt_max->v4 >> 1;
diff --git a/sdk-6.5.16/src/soc/esw/trident2/alpm_th.c b/sdk-6.5.16/src/soc/esw/trident2/alpm_th.c
@@ -748,7 +748,7 @@ _soc_th_alpm_ctrl_init(int u)
ALPM_CTRL(u).fld.key_mode = MODEf;
ALPM_CTRL(u).fld.key_type = ENTRY_TYPEf;
}
- ALPM_CTRL(u)._alpm_128b = soc_property_get(u, spn_IPV6_LPM_128B_ENABLE, 1);
+ ALPM_CTRL(u)._alpm_128b = SOC_ALPM_128B_ENABLE(u);
if (ALPM_CTRL(u)._alpm_128b) {
ALPM_CTRL(u)._alpm_128b_bkt_rsvd =
soc_property_get(u, spn_L3_ALPM_IPV6_128B_BKT_RSVD, 0);
@@ -9651,7 +9651,7 @@ soc_alpm_key_sel_reg_init(int u)
};
urpf_enb = !!SOC_URPF_STATUS_GET(u);
- lpm_128b = !!soc_property_get(u, spn_IPV6_LPM_128B_ENABLE, 1);
+ lpm_128b = !!SOC_ALPM_128B_ENABLE(u);
if (soc_reg_field_valid(u, kselr, KEY_SEL_CAM0_1f)) {
i = lpm_128b;
@@ -11770,7 +11770,7 @@ _soc_th_alpm_pivot_max_get(int u, alpm_vrf_counter_t *pvt_max)
pvt_max->v4 = soc_mem_index_count(u, L3_DEFIPm) * 2;
pvt_max->v6_128 = soc_mem_index_count(u, L3_DEFIP_PAIR_128m);
- if (soc_property_get(u, spn_IPV6_LPM_128B_ENABLE, 1)) {
+ if (SOC_ALPM_128B_ENABLE(u)) {
pvt_max->v6_64 = pvt_max->v6_128;
} else {
pvt_max->v6_64 = pvt_max->v4 >> 1;