From 37e5a76c071036a1241bb7b07453cabad477452b Mon Sep 17 00:00:00 2001 From: Aman Mehta Date: Wed, 30 Aug 2023 18:07:19 +0530 Subject: [PATCH] qcacmn: Add ini to control rate filter for rx avg Adds ini field to control the filter for rx avg rate calculation. 0 : Filter Disabled 11000 : Max rate filter (in kbps) supported for filter Change-Id: I6ae88b7af3d4c1fae033101e77b308949e5b3d1e CRs-Fixed: 3628056 --- dp/wifi3.0/monitor/dp_rx_mon.c | 35 ++++++++++++++++++++++++++++++++-- wlan_cfg/cfg_dp.h | 15 ++++++++++++++- wlan_cfg/wlan_cfg.c | 5 ++++- wlan_cfg/wlan_cfg.h | 3 +++ 4 files changed, 54 insertions(+), 4 deletions(-) diff --git a/dp/wifi3.0/monitor/dp_rx_mon.c b/dp/wifi3.0/monitor/dp_rx_mon.c index 4827888551..ec1bb01541 100644 --- a/dp/wifi3.0/monitor/dp_rx_mon.c +++ b/dp/wifi3.0/monitor/dp_rx_mon.c @@ -661,6 +661,33 @@ end: dp_rx_populate_cfr_non_assoc_sta(pdev, ppdu_info, cdp_rx_ppdu); } +/* + * dp_mon_eval_avg_rate_filter() - Evaluates rate value against filter + * @peer: dp peer + * @ratekbps: last packet rate in kbps + * @avg_rate: average rate for which new rate is to be evaluated + * + * Return: true when average need to be evaluated else false + */ +static inline bool +dp_mon_eval_avg_rate_filter(struct dp_peer *peer, uint32_t ratekbps, + uint32_t avg_rate) { + uint16_t filter_val = 0; + + if (qdf_unlikely(!peer || !peer->vdev || + !peer->vdev->pdev->soc->wlan_cfg_ctx)) { + return true; + } + + filter_val = + peer->vdev->pdev->soc->wlan_cfg_ctx->avg_rate_stats_filter_val; + + if (!filter_val || avg_rate < filter_val || ratekbps > filter_val) { + return true; + } + return false; +} + /** * dp_rx_rate_stats_update() - Update per-peer rate statistics * @peer: Datapath peer handle @@ -736,8 +763,12 @@ static inline void dp_rx_rate_stats_update(struct dp_peer *peer, ppdu->rix = rix; ppdu_user->rix = rix; DP_STATS_UPD(mon_peer, rx.last_rx_rate, ratekbps); - mon_peer->stats.rx.avg_rx_rate = - dp_ath_rate_lpf(mon_peer->stats.rx.avg_rx_rate, ratekbps); + if (qdf_unlikely(dp_mon_eval_avg_rate_filter(peer, ratekbps, + mon_peer->stats.rx.avg_rx_rate))) { + mon_peer->stats.rx.avg_rx_rate = + dp_ath_rate_lpf(mon_peer->stats.rx.avg_rx_rate, + ratekbps); + } ppdu_rx_rate = dp_ath_rate_out(mon_peer->stats.rx.avg_rx_rate); DP_STATS_UPD(mon_peer, rx.rnd_avg_rx_rate, ppdu_rx_rate); ppdu->rx_ratekbps = ratekbps; diff --git a/wlan_cfg/cfg_dp.h b/wlan_cfg/cfg_dp.h index bbb459786d..82cfc7fc8b 100644 --- a/wlan_cfg/cfg_dp.h +++ b/wlan_cfg/cfg_dp.h @@ -565,6 +565,10 @@ #define WLAN_CFG_TX_CAPT_2_RBM_DEFAULT 2 #define WLAN_CFG_TX_CAPT_3_RBM_DEFAULT 3 +#define WLAN_CFG_DP_AVG_RATE_FILTER_MIN 0 +#define WLAN_CFG_DP_AVG_RATE_FILTER_MAX 11000 +#define WLAN_CFG_DP_AVG_RATE_FILTER_DEFAULT 0 + /* * * "dp_tx_capt_max_mem_mb"- maximum memory used by Tx capture @@ -1581,6 +1585,14 @@ WLAN_CFG_DP_NAPI_SCALE_FACTOR, \ CFG_VALUE_OR_DEFAULT, "NAPI scale factor for DP") +#define CFG_DP_STATS_AVG_RATE_FILTER \ + CFG_INI_UINT("dp_stats_avg_rate_filter_val", \ + WLAN_CFG_DP_AVG_RATE_FILTER_MIN,\ + WLAN_CFG_DP_AVG_RATE_FILTER_MAX, \ + WLAN_CFG_DP_AVG_RATE_FILTER_DEFAULT, \ + CFG_VALUE_OR_DEFAULT, \ + "Average Rate filter for stats") + /* * * legacy_mode_csum_disable - Disable csum offload for legacy 802.11abg modes @@ -2190,5 +2202,6 @@ CFG(CFG_DP_TX_CAPT_RADIO_2_RBM_ID) \ CFG(CFG_DP_TX_CAPT_RADIO_3_RBM_ID) \ CFG_DP_UMAC_RESET_BUFFER_WINDOW_CFG \ - CFG(CFG_DP_RX_BUFFER_SIZE) + CFG(CFG_DP_RX_BUFFER_SIZE) \ + CFG(CFG_DP_STATS_AVG_RATE_FILTER) #endif /* _CFG_DP_H_ */ diff --git a/wlan_cfg/wlan_cfg.c b/wlan_cfg/wlan_cfg.c index 7c6c5e7e21..9aa8104d80 100644 --- a/wlan_cfg/wlan_cfg.c +++ b/wlan_cfg/wlan_cfg.c @@ -4193,6 +4193,8 @@ wlan_cfg_soc_attach(struct cdp_ctrl_objmgr_psoc *psoc) wlan_soc_local_pkt_capture_cfg_attach(psoc, wlan_cfg_ctx); wlan_soc_umac_reset_cfg_attach(psoc, wlan_cfg_ctx); wlan_cfg_ctx->rx_buffer_size = cfg_get(psoc, CFG_DP_RX_BUFFER_SIZE); + wlan_cfg_ctx->avg_rate_stats_filter_val = + cfg_get(psoc, CFG_DP_STATS_AVG_RATE_FILTER); return wlan_cfg_ctx; } @@ -4447,7 +4449,8 @@ wlan_cfg_soc_attach(struct cdp_ctrl_objmgr_psoc *psoc) cfg_get(psoc, CFG_SPECIAL_FRAME_MSK); wlan_soc_umac_reset_cfg_attach(psoc, wlan_cfg_ctx); wlan_cfg_ctx->rx_buffer_size = cfg_get(psoc, CFG_DP_RX_BUFFER_SIZE); - + wlan_cfg_ctx->avg_rate_stats_filter_val = + cfg_get(psoc, CFG_DP_STATS_AVG_RATE_FILTER); return wlan_cfg_ctx; } #endif diff --git a/wlan_cfg/wlan_cfg.h b/wlan_cfg/wlan_cfg.h index 97a663b449..7841c8c495 100644 --- a/wlan_cfg/wlan_cfg.h +++ b/wlan_cfg/wlan_cfg.h @@ -352,6 +352,8 @@ struct wlan_srng_cfg { * during this window, configured time is in * milliseconds. * @fw_ast_indication_disable: Disable AST + * @avg_rate_stats_filter_val: Average rate filter value for stats. + * */ struct wlan_cfg_dp_soc_ctxt { int num_int_ctxts; @@ -566,6 +568,7 @@ struct wlan_cfg_dp_soc_ctxt { uint32_t umac_reset_buffer_window; #endif bool fw_ast_indication_disable; + uint16_t avg_rate_stats_filter_val; }; /**