commit b0dfbe8efbf25730cc29dc05c073502120465836
parent 820187ce35586936a552a60a368b4e1effe71855
Author: Broadcom SDK Release <sdk.releases@broadcom.com>
Date: Mon, 13 Jan 2020 12:42:34 -0800
SDK-175989: Fixed shared limit resolution code to update shared limits during...
Devices: 56980_A0
Module: MMU
Symptom:
SDK was incorrectly updating shared limit for all pools when PG limit
was changed instead of just the pool to which the PG maps to
Fixed shared limit resolution code to update shared limits during min
limit change only for relevant pools instead of all pools based on PG or
Queue to Service Pool mapping
Diffstat:
3 files changed, 110 insertions(+), 72 deletions(-)
diff --git a/sdk-6.5.16/include/soc/tomahawk3.h b/sdk-6.5.16/include/soc/tomahawk3.h
@@ -174,8 +174,8 @@ extern int soc_th3_mmu_get_shared_size(int unit, int *thd_shared);
extern int soc_th3_mmu_config_shared_buf_recalc(int unit, int res, int ing_shd,
int egr_db_shd, int egr_qe_shd,
int flags);
-extern int soc_th3_mmu_config_res_limits_update(int unit, int* shared_limit,
- int post_update);
+extern int soc_th3_mmu_config_res_limits_update(int unit, int* delta,
+ int pool, int post_update);
extern int soc_th3_cal_egress_rsvd_limit(int unit, int* total_egr_rsvd_limit);
extern int soc_th3_mmu_config_flex_thresholds(int unit, int port, int shared_limit);
extern int _soc_th3_mmu_config_shared_limit_chk_set(int unit,
diff --git a/sdk-6.5.16/src/bcm/tomahawk3/cosq.c b/sdk-6.5.16/src/bcm/tomahawk3/cosq.c
@@ -5028,7 +5028,7 @@ _bcm_th3_cosq_ing_res_set(int unit, bcm_gport_t gport, bcm_cos_queue_t cosq,
if (update) {
/* Decrease shared limits */
BCM_IF_ERROR_RETURN
- (soc_th3_mmu_config_res_limits_update(unit, shd_size, 1));
+ (soc_th3_mmu_config_res_limits_update(unit, delta, pool, 1));
}
/* set new guarantee */
@@ -5048,7 +5048,7 @@ _bcm_th3_cosq_ing_res_set(int unit, bcm_gport_t gport, bcm_cos_queue_t cosq,
if (update) {
/* Increase shared limits */
BCM_IF_ERROR_RETURN
- (soc_th3_mmu_config_res_limits_update(unit, shd_size, 0));
+ (soc_th3_mmu_config_res_limits_update(unit, delta, pool, 0));
}
sal_memcpy(_BCM_TH3_MMU_INFO(unit)->shared_limit, shd_size,
sizeof(shd_size));
@@ -5244,8 +5244,10 @@ _bcm_th3_cosq_egr_queue_set(int unit, bcm_gport_t gport, bcm_cos_queue_t cosq,
(type == bcmCosqControlEgressMCQueueMinLimitBytes)) {
int itm, itm_map;
int delta[_TH3_ITMS_PER_DEV] = {0}, update;
-
+ int pool;
itm_map = SOC_INFO(unit).itm_map;
+ BCM_IF_ERROR_RETURN(_bcm_th3_cosq_egr_pool_get(unit, gport,
+ cosq, -1, bcmCosqControlEgressPool,&pool));
cur_val = soc_mem_field32_get(unit, mem, entry, fld_limit);
sal_memcpy(shd_size, _BCM_TH3_MMU_INFO(unit)->shared_limit,
@@ -5273,7 +5275,7 @@ _bcm_th3_cosq_egr_queue_set(int unit, bcm_gport_t gport, bcm_cos_queue_t cosq,
}
if (update) {
BCM_IF_ERROR_RETURN
- (soc_th3_mmu_config_res_limits_update(unit, shd_size, 1));
+ (soc_th3_mmu_config_res_limits_update(unit, delta, pool, 1));
}
/* set new guarantee */
@@ -5296,7 +5298,7 @@ _bcm_th3_cosq_egr_queue_set(int unit, bcm_gport_t gport, bcm_cos_queue_t cosq,
}
if (update) {
BCM_IF_ERROR_RETURN
- (soc_th3_mmu_config_res_limits_update(unit, shd_size, 0));
+ (soc_th3_mmu_config_res_limits_update(unit, delta, pool, 0));
}
sal_memcpy(_BCM_TH3_MMU_INFO(unit)->shared_limit, shd_size,
@@ -5546,8 +5548,10 @@ _bcm_th3_cosq_qgroup_limit_enables_set(int unit, bcm_gport_t gport,
soc_field_t field = INVALIDf;
soc_field_t field2 = INVALIDf;
int old_qmin_limit[_TH3_ITMS_PER_DEV], new_qmin_limit[_TH3_ITMS_PER_DEV], shd_size[_TH3_ITMS_PER_DEV];
+ int delta[_TH3_ITMS_PER_DEV];
int rv;
int itm;
+ int pool;
if (arg < 0) {
return BCM_E_PARAM;
@@ -5630,6 +5634,10 @@ _bcm_th3_cosq_qgroup_limit_enables_set(int unit, bcm_gport_t gport,
*/
if ((type == bcmCosqControlEgressUCQueueGroupMinEnable) ||
(type == bcmCosqControlEgressMCQueueGroupMinEnable)) {
+
+ BCM_IF_ERROR_RETURN(_bcm_th3_cosq_egr_pool_get(unit, gport,
+ cosq, -1, bcmCosqControlEgressPool,&pool));
+
BCM_IF_ERROR_RETURN(soc_th3_cal_egress_rsvd_limit(unit, new_qmin_limit));
sal_memcpy(shd_size, _BCM_TH3_MMU_INFO(unit)->shared_limit,
sizeof(shd_size));
@@ -5637,10 +5645,11 @@ _bcm_th3_cosq_qgroup_limit_enables_set(int unit, bcm_gport_t gport,
/*Calculate the new value of shared limit*/
for (itm = 0; itm < _TH3_ITMS_PER_DEV; itm++) {
shd_size[itm] = shd_size[itm] + old_qmin_limit[itm] - new_qmin_limit[itm];
+ delta[itm] = old_qmin_limit[itm] - new_qmin_limit[itm];
}
/*Passing the modified values to the funtion to re-adjust shared limits*/
- rv = soc_th3_mmu_config_res_limits_update(unit, shd_size, 1);
+ rv = soc_th3_mmu_config_res_limits_update(unit, delta, pool, 1);
if (rv < 0) {
return rv;
}
@@ -5802,6 +5811,7 @@ _bcm_th3_cosq_qgroup_limit_set(int unit, bcm_gport_t gport, bcm_cos_t cosq,
if ((type == bcmCosqControlEgressUCQueueGroupMinLimitBytes) ||
(type == bcmCosqControlEgressMCQueueGroupMinLimitBytes)) {
+ int pool;
if (type == bcmCosqControlEgressUCQueueGroupMinLimitBytes) {
mem = MMU_THDO_CONFIG_UC_QGROUP0m;
}
@@ -5813,6 +5823,8 @@ _bcm_th3_cosq_qgroup_limit_set(int unit, bcm_gport_t gport, bcm_cos_t cosq,
field = MIN_LIMITf;
granularity =1;
/* Recalculate Shared Values if Min Changed */
+ BCM_IF_ERROR_RETURN(_bcm_th3_cosq_egr_pool_get(unit, gport,
+ cosq, -1, bcmCosqControlEgressPool,&pool));
sal_memcpy(shd_size, _BCM_TH3_MMU_INFO(unit)->shared_limit,
sizeof(shd_size));
@@ -5835,7 +5847,7 @@ _bcm_th3_cosq_qgroup_limit_set(int unit, bcm_gport_t gport, bcm_cos_t cosq,
}
}
- rv = soc_th3_mmu_config_res_limits_update(unit, shd_size, 1);
+ rv = soc_th3_mmu_config_res_limits_update(unit, delta, pool, 1);
if (rv < 0) {
return rv;
diff --git a/sdk-6.5.16/src/soc/esw/tomahawk3/traffic_manager/traffic_manager_thresholds.c b/sdk-6.5.16/src/soc/esw/tomahawk3/traffic_manager/traffic_manager_thresholds.c
@@ -2876,97 +2876,123 @@ _soc_th3_mmu_config_shared_limit_chk_set(int unit,
}
-int soc_th3_mmu_config_res_limits_update(int unit, int *shared_limit,
- int post_update)
+int soc_th3_mmu_config_res_limits_update(int unit, int *delta,
+ int pool, int post_update)
{
soc_info_t *si;
soc_reg_t reg;
soc_field_t field;
- int limit[_TH3_MMU_NUM_POOL] = {0}, itm;
- int idx;
+ int limit[_TH3_ITMS_PER_DEV] = {0};
+ int new_limit, itm;
int resume_limit, pool_resume;
+ uint32 rval;
+ int cur_val;
si = &SOC_INFO(unit);
pool_resume = 2 * _TH3_MMU_JUMBO_PACKET_SIZE;
-
- /* Get the min of the 2 itm limits */
- for (idx = 0; idx < _TH3_MMU_NUM_POOL; idx++) {
- limit[idx] = _TH3_MMU_TOTAL_CELLS_PER_ITM;
- for (itm = 0; itm < _TH3_ITMS_PER_DEV; itm ++) {
+ /* THDI: Per pool shared settings */
+ for (itm = 0; itm < _TH3_ITMS_PER_DEV; itm ++) {
+ limit[itm] = _TH3_MMU_TOTAL_CELLS_PER_ITM;
+ if (delta[itm] != 0) {
if (si->itm_map & (1 << itm)) {
- if (shared_limit[itm] < limit[idx]) {
- limit[idx] = shared_limit[itm];
+ reg = MMU_THDI_BUFFER_CELL_LIMIT_SPr;
+ field = LIMITf;
+ rval = 0;
+ SOC_IF_ERROR_RETURN
+ (soc_tomahawk3_itm_reg32_get(unit, reg, itm, -1, pool, &rval));
+
+ cur_val = soc_reg_field_get(unit, reg, rval, field);
+ limit[itm] = cur_val - delta[itm];
+ if (limit[itm] < 0) {
+ return SOC_E_RESOURCE;
}
}
}
}
- /* THDI: Per pool shared settings */
+ /* Get the min of the 2 itm limits */
+ new_limit = MIN(limit[0], limit[1]);
+
for (itm = 0; itm < _TH3_ITMS_PER_DEV; itm ++) {
if (si->itm_map & (1 << itm)) {
- for (idx = 0; idx < _TH3_MMU_NUM_POOL; idx++) {
- reg = MMU_THDI_BUFFER_CELL_LIMIT_SPr;
- field = LIMITf;
- SOC_IF_ERROR_RETURN
- (_soc_th3_mmu_config_shared_limit_chk_set
- (unit, reg, INVALIDm, field, idx, itm, limit[idx],
- post_update, 1));
- } /* for (idx */
+ reg = MMU_THDI_BUFFER_CELL_LIMIT_SPr;
+ field = LIMITf;
+ SOC_IF_ERROR_RETURN
+ (_soc_th3_mmu_config_shared_limit_chk_set
+ (unit, reg, INVALIDm, field, pool, itm, new_limit,
+ post_update, 1));
}
- } /* for (itm */
+ }
/* THDO - Shared settings per Pool */
- for (idx = 0; idx < _TH3_MMU_NUM_POOL; idx++) {
- if ((limit[idx] != 0) && (limit[idx] > pool_resume)) {
- resume_limit = limit[idx] - pool_resume;
- } else {
- resume_limit = 0;
+ for (itm = 0; itm < _TH3_ITMS_PER_DEV; itm ++) {
+ limit[itm] = _TH3_MMU_TOTAL_CELLS_PER_ITM;
+ if (delta[itm] != 0) {
+ reg = MMU_THDO_SHARED_DB_POOL_SHARED_LIMITr;
+ field = SHARED_LIMITf;
+ rval = 0;
+ SOC_IF_ERROR_RETURN
+ (soc_tomahawk3_itm_reg32_get(unit, reg, itm, -1, pool, &rval));
+ cur_val = soc_reg_field_get(unit, reg, rval, field);
+ limit[itm] = cur_val - delta[itm];
+ if (limit[itm] < 0) {
+ return SOC_E_RESOURCE;
+ }
}
+ }
- reg = MMU_THDO_SHARED_DB_POOL_SHARED_LIMITr;
- field = SHARED_LIMITf;
- SOC_IF_ERROR_RETURN
- (_soc_th3_mmu_config_shared_limit_chk_set
- (unit, reg, INVALIDm, field, idx, -1, limit[idx],
- post_update, 1));
-
- reg = MMU_THDO_SHARED_DB_POOL_YELLOW_SHARED_LIMITr;
- field = YELLOW_SHARED_LIMITf;
- SOC_IF_ERROR_RETURN
- (_soc_th3_mmu_config_shared_limit_chk_set
- (unit, reg, INVALIDm, field, idx, -1, limit[idx]/8,
- post_update, 1));
+ /* Get the min of the 2 itm limits */
+ new_limit = MIN(limit[0], limit[1]);
- reg = MMU_THDO_SHARED_DB_POOL_RED_SHARED_LIMITr;
- field = RED_SHARED_LIMITf;
- SOC_IF_ERROR_RETURN
- (_soc_th3_mmu_config_shared_limit_chk_set
- (unit, reg, INVALIDm, field, idx, -1, limit[idx]/8,
- post_update, 1));
+ reg = MMU_THDO_SHARED_DB_POOL_SHARED_LIMITr;
+ field = SHARED_LIMITf;
+ SOC_IF_ERROR_RETURN
+ (_soc_th3_mmu_config_shared_limit_chk_set
+ (unit, reg, INVALIDm, field, pool, -1, new_limit,
+ post_update, 1));
- reg = MMU_THDO_SHARED_DB_POOL_RESUME_LIMITr;
- field = RESUME_LIMITf;
- SOC_IF_ERROR_RETURN
- (_soc_th3_mmu_config_shared_limit_chk_set
- (unit, reg, INVALIDm, field, idx, -1, resume_limit/8,
- post_update, 1));
+ reg = MMU_THDO_SHARED_DB_POOL_YELLOW_SHARED_LIMITr;
+ field = YELLOW_SHARED_LIMITf;
+ SOC_IF_ERROR_RETURN
+ (_soc_th3_mmu_config_shared_limit_chk_set
+ (unit, reg, INVALIDm, field, pool, -1, new_limit/8,
+ post_update, 1));
- reg = MMU_THDO_SHARED_DB_POOL_YELLOW_RESUME_LIMITr;
- field = YELLOW_RESUME_LIMITf;
- SOC_IF_ERROR_RETURN
- (_soc_th3_mmu_config_shared_limit_chk_set
- (unit, reg, INVALIDm, field, idx, -1, resume_limit/8,
- post_update, 1));
+ reg = MMU_THDO_SHARED_DB_POOL_RED_SHARED_LIMITr;
+ field = RED_SHARED_LIMITf;
+ SOC_IF_ERROR_RETURN
+ (_soc_th3_mmu_config_shared_limit_chk_set
+ (unit, reg, INVALIDm, field, pool, -1, new_limit/8,
+ post_update, 1));
- reg = MMU_THDO_SHARED_DB_POOL_RED_RESUME_LIMITr;
- field = RED_RESUME_LIMITf;
- SOC_IF_ERROR_RETURN
- (_soc_th3_mmu_config_shared_limit_chk_set
- (unit, reg, INVALIDm, field, idx, -1, resume_limit/8,
- post_update, 1));
+ if ((new_limit != 0) && (new_limit > pool_resume)) {
+ resume_limit = new_limit - pool_resume;
+ } else {
+ resume_limit = 0;
}
+ reg = MMU_THDO_SHARED_DB_POOL_RESUME_LIMITr;
+ field = RESUME_LIMITf;
+ SOC_IF_ERROR_RETURN
+ (_soc_th3_mmu_config_shared_limit_chk_set
+ (unit, reg, INVALIDm, field, pool, -1, resume_limit/8,
+ post_update, 1));
+
+ reg = MMU_THDO_SHARED_DB_POOL_YELLOW_RESUME_LIMITr;
+ field = YELLOW_RESUME_LIMITf;
+ SOC_IF_ERROR_RETURN
+ (_soc_th3_mmu_config_shared_limit_chk_set
+ (unit, reg, INVALIDm, field, pool, -1, resume_limit/8,
+ post_update, 1));
+
+ reg = MMU_THDO_SHARED_DB_POOL_RED_RESUME_LIMITr;
+ field = RED_RESUME_LIMITf;
+ SOC_IF_ERROR_RETURN
+ (_soc_th3_mmu_config_shared_limit_chk_set
+ (unit, reg, INVALIDm, field, pool, -1, resume_limit/8,
+ post_update, 1));
+
return SOC_E_NONE;
}