From 9cc0ed982af46919370bada9c02f7be5360e5a69 Mon Sep 17 00:00:00 2001 From: Jeff Johnson Date: Thu, 29 Sep 2016 12:11:42 -0700 Subject: [PATCH] qcacld-3.0: Correctly report 20 MHz bandwidth in Linux 4.x Linux kernel 4.0 introduced a new way for drivers to report bandwidth information to userspace. Prior to this rate information was indicated by setting an appropriate BW flag in the struct rate_info flags field, and 20MHz bandwidth was assumed if no flag was set. Linux 4.0 introduced a new bw field to struct rate_info, and the driver was updated to set this field in all cases where previously a bandwidth-specific flag had been set. Unfortunately in the 20 MHz bandwidth case the driver was not previously setting a bandwidth-specific flag, and hence in the current case it is not setting the bw field. This manifests itself in the following warning emitted by the kernel when the device is associated to an Access Point with a 20MHz bandwidth: WARNING: at kernel/msm-4.4/net/wireless/util.c:1137 Modules linked in: wlan(O) PC is at cfg80211_calculate_bitrate+0xdc/0x1f0 LR is at nl80211_put_sta_rate+0x64/0x1dc Fix this issue by initializing the rate_info bw field to 20 MHz prior to calculating the bandwidth. If the bandwidth is anything other than 20 MHz then this default value will later be overwritten. Change-Id: I734b05e0e41c7a859939372fe4d8a3668a08c668 CRs-Fixed: 1072803 --- core/hdd/src/wlan_hdd_stats.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/hdd/src/wlan_hdd_stats.c b/core/hdd/src/wlan_hdd_stats.c index 1e786fbc9b83..662aa3a2f5b8 100644 --- a/core/hdd/src/wlan_hdd_stats.c +++ b/core/hdd/src/wlan_hdd_stats.c @@ -1736,6 +1736,11 @@ static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, (int)pCfg->linkSpeedRssiLow, (int)rate_flags, (int)pAdapter->hdd_stats.ClassA_stat.mcs_index); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) || defined(WITH_BACKPORTS) + /* assume basic BW. anything else will override this later */ + sinfo->txrate.bw = RATE_INFO_BW_20; +#endif + if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed) { /* we do not want to necessarily report the current speed */ if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) {