diff --git a/dp/wifi3.0/dp_main.c b/dp/wifi3.0/dp_main.c index 67dd9e11e1..69c4e42bbb 100644 --- a/dp/wifi3.0/dp_main.c +++ b/dp/wifi3.0/dp_main.c @@ -8375,6 +8375,8 @@ char *dp_srng_get_str_from_hal_ring_type(enum hal_ring_type ring_type) return "Rxdma_monitor_desc"; case RXDMA_MONITOR_STATUS: return "Rxdma_monitor_status"; + case WBM_IDLE_LINK: + return "WBM_hw_idle_link"; default: dp_err("Invalid ring type"); break; diff --git a/dp/wifi3.0/dp_stats.c b/dp/wifi3.0/dp_stats.c index 183ebf9619..1c76599dc3 100644 --- a/dp/wifi3.0/dp_stats.c +++ b/dp/wifi3.0/dp_stats.c @@ -4998,23 +4998,30 @@ dp_print_ring_stat_from_hal(struct dp_soc *soc, struct dp_srng *srng, uint32_t headp; int32_t hw_headp = -1; int32_t hw_tailp = -1; + uint32_t ring_usage; const char *ring_name; struct hal_soc *hal_soc; if (soc && srng && srng->hal_srng) { hal_soc = (struct hal_soc *)soc->hal_soc; ring_name = dp_srng_get_str_from_hal_ring_type(ring_type); - hal_get_sw_hptp(soc->hal_soc, srng->hal_srng, &tailp, &headp); + ring_usage = hal_get_ring_usage(srng->hal_srng, + ring_type, &headp, &tailp); - DP_PRINT_STATS("%s:SW:Head pointer = %d Tail Pointer = %d\n", - ring_name, headp, tailp); + DP_PRINT_STATS("%s:SW: Head = %d Tail = %d Ring Usage = %u", + ring_name, headp, tailp, ring_usage); hal_get_hw_hptp(soc->hal_soc, srng->hal_srng, &hw_headp, &hw_tailp, ring_type); - - DP_PRINT_STATS("%s:HW:Head pointer = %d Tail Pointer = %d\n", - ring_name, hw_headp, hw_tailp); + ring_usage = 0; + if (hw_headp >= 0 && tailp >= 0) + ring_usage = + hal_get_ring_usage( + srng->hal_srng, ring_type, + &hw_headp, &hw_tailp); + DP_PRINT_STATS("%s:HW: Head = %d Tail = %d Ring Usage = %u", + ring_name, hw_headp, hw_tailp, ring_usage); } } @@ -5113,6 +5120,9 @@ dp_print_ring_stats(struct dp_pdev *pdev) RTPM_ID_DP_PRINT_RING_STATS)) return; + dp_print_ring_stat_from_hal(pdev->soc, + &pdev->soc->wbm_idle_link_ring, + WBM_IDLE_LINK); dp_print_ring_stat_from_hal(pdev->soc, &pdev->soc->reo_exception_ring, REO_EXCEPTION); diff --git a/hal/wifi3.0/hal_api.h b/hal/wifi3.0/hal_api.h index e6179dc998..0172d12b40 100644 --- a/hal/wifi3.0/hal_api.h +++ b/hal/wifi3.0/hal_api.h @@ -2717,4 +2717,44 @@ void hal_flush_reg_write_work(hal_soc_handle_t hal_handle); static inline void hal_flush_reg_write_work(hal_soc_handle_t hal_handle) { } #endif +/** + * hal_get_ring_usage - Calculate the ring usage percentage + * @hal_ring_hdl: Ring pointer + * @ring_type: Ring type + * @headp: pointer to head value + * @tailp: pointer to tail value + * + * Calculate the ring usage percentage for src and dest rings + * + * Return: Ring usage percentage + */ +static inline +uint32_t hal_get_ring_usage( + hal_ring_handle_t hal_ring_hdl, + enum hal_ring_type ring_type, uint32_t *headp, uint32_t *tailp) +{ + struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl; + uint32_t num_avail, num_valid = 0; + uint32_t ring_usage; + + if (srng->ring_dir == HAL_SRNG_SRC_RING) { + if (*tailp > *headp) + num_avail = ((*tailp - *headp) / srng->entry_size) - 1; + else + num_avail = ((srng->ring_size - *headp + *tailp) / + srng->entry_size) - 1; + if (ring_type == WBM_IDLE_LINK) + num_valid = num_avail; + else + num_valid = srng->num_entries - num_avail; + } else { + if (*headp >= *tailp) + num_valid = ((*headp - *tailp) / srng->entry_size); + else + num_valid = ((srng->ring_size - *tailp + *headp) / + srng->entry_size); + } + ring_usage = (100 * num_valid) / srng->num_entries; + return ring_usage; +} #endif /* _HAL_APIH_ */