From de9833414f7cb3e48bc43a477fc1ef51570ebaa1 Mon Sep 17 00:00:00 2001 From: Sourav Mohapatra Date: Wed, 4 Dec 2019 08:59:50 +0530 Subject: [PATCH] qcacld-3.0: Report correct max NSS in case of DBS Currently in the driver, the NSS reported to the userspace in case of max rate reporting doesn't take into account if the hardware mode is DBS or not. This causes the NSS to remain 2 even if the connection has changed to 1x1. Add a check if the current mode is DBS or not and update the NSS accordingly. Change-Id: I66ea830c7c6483c7ce957e1276b4ac5a535b17df CRs-Fixed: 2579182 --- core/hdd/src/wlan_hdd_stats.c | 66 ++++++++++++++++++++++++----------- 1 file changed, 45 insertions(+), 21 deletions(-) diff --git a/core/hdd/src/wlan_hdd_stats.c b/core/hdd/src/wlan_hdd_stats.c index e753add4b3c3..da2ea512a7a1 100644 --- a/core/hdd/src/wlan_hdd_stats.c +++ b/core/hdd/src/wlan_hdd_stats.c @@ -4408,6 +4408,36 @@ static void hdd_fill_fcs_and_mpdu_count(struct hdd_adapter *adapter, } #endif +/** + * hdd_check_and_update_nss() - Check and update NSS as per DBS capability + * @hdd_ctx: HDD Context pointer + * @tx_nss: pointer to variable storing the tx_nss + * @rx_nss: pointer to variable storing the rx_nss + * + * The parameters include the NSS obtained from the FW or static NSS. This NSS + * could be invalid in the case the current HW mode is DBS where the connection + * are 1x1. Rectify these NSS values as per the current HW mode. + * + * Return: none + */ +static void hdd_check_and_update_nss(struct hdd_context *hdd_ctx, + uint8_t *tx_nss, uint8_t *rx_nss) +{ + if ((*tx_nss > 1) && + policy_mgr_is_current_hwmode_dbs(hdd_ctx->psoc) && + !policy_mgr_is_hw_dbs_2x2_capable(hdd_ctx->psoc)) { + hdd_debug("Hw mode is DBS, Reduce tx nss(%d) to 1", *tx_nss); + (*tx_nss)--; + } + + if ((*rx_nss > 1) && + policy_mgr_is_current_hwmode_dbs(hdd_ctx->psoc) && + !policy_mgr_is_hw_dbs_2x2_capable(hdd_ctx->psoc)) { + hdd_debug("Hw mode is DBS, Reduce tx nss(%d) to 1", *rx_nss); + (*rx_nss)--; + } +} + /** * wlan_hdd_get_sta_stats() - get aggregate STA stats * @wiphy: wireless phy @@ -4523,21 +4553,7 @@ static int wlan_hdd_get_sta_stats(struct wiphy *wiphy, tx_nss = adapter->hdd_stats.class_a_stat.tx_nss; rx_nss = adapter->hdd_stats.class_a_stat.rx_nss; - if ((tx_nss > 1) && - policy_mgr_is_current_hwmode_dbs(hdd_ctx->psoc) && - !policy_mgr_is_hw_dbs_2x2_capable(hdd_ctx->psoc)) { - hdd_debug("Hw mode is DBS, Reduce nss(%d) to 1", - tx_nss); - tx_nss--; - } - - if ((rx_nss > 1) && - policy_mgr_is_current_hwmode_dbs(hdd_ctx->psoc) && - !policy_mgr_is_hw_dbs_2x2_capable(hdd_ctx->psoc)) { - hdd_debug("Hw mode is DBS, Reduce nss(%d) to 1", - rx_nss); - rx_nss--; - } + hdd_check_and_update_nss(hdd_ctx, &tx_nss, &rx_nss); if (ucfg_mlme_stats_is_link_speed_report_actual( hdd_ctx->psoc)) { @@ -4576,24 +4592,32 @@ static int wlan_hdd_get_sta_stats(struct wiphy *wiphy, hdd_debug("guard interval: TX: %d, RX: %d", (int)tx_gi, (int)rx_gi); if (!ucfg_mlme_stats_is_link_speed_report_actual(hdd_ctx->psoc)) { - bool tx_rate_calc; - bool rx_rate_calc; + bool tx_rate_calc, rx_rate_calc; + uint8_t tx_nss_max, rx_nss_max; + + /* + * Take static NSS for reporting max rates. NSS from the FW + * is not reliable as it changes as per the environment + * quality. + */ + tx_nss_max = wlan_vdev_mlme_get_nss(adapter->vdev); + rx_nss_max = wlan_vdev_mlme_get_nss(adapter->vdev); + + hdd_check_and_update_nss(hdd_ctx, &tx_nss_max, &rx_nss_max); tx_rate_calc = hdd_report_max_rate(mac_handle, &sinfo->txrate, sinfo->signal, tx_rate_flags, tx_mcs_index, my_tx_rate, - wlan_vdev_mlme_get_nss( - adapter->vdev)); + tx_nss_max); rx_rate_calc = hdd_report_max_rate(mac_handle, &sinfo->rxrate, sinfo->signal, rx_rate_flags, rx_mcs_index, my_rx_rate, - wlan_vdev_mlme_get_nss( - adapter->vdev)); + rx_nss_max); if (!tx_rate_calc || !rx_rate_calc) /* Keep GUI happy */