cfg80211: improve warnings in VHT rate calculation
authorJohannes Berg <johannes.berg@intel.com>
Thu, 4 May 2017 05:52:10 +0000 (07:52 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 17 May 2017 13:57:58 +0000 (15:57 +0200)
Linus reported hitting the bandwidth warning, but it is indeed
pretty useless - improve it by printing the rate configuration
and make it only warn once, for both warnings here.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/wireless/util.c

index 7198373e29206a0f19f006578596fea78e82f66e..a10d5c7bdf6307617d26e8c2f7e7e2c3e5684657 100644 (file)
@@ -1217,8 +1217,8 @@ static u32 cfg80211_calculate_bitrate_vht(struct rate_info *rate)
        u32 bitrate;
        int idx;
 
-       if (WARN_ON_ONCE(rate->mcs > 9))
-               return 0;
+       if (rate->mcs > 9)
+               goto warn;
 
        switch (rate->bw) {
        case RATE_INFO_BW_160:
@@ -1233,8 +1233,7 @@ static u32 cfg80211_calculate_bitrate_vht(struct rate_info *rate)
        case RATE_INFO_BW_5:
        case RATE_INFO_BW_10:
        default:
-               WARN_ON(1);
-               /* fall through */
+               goto warn;
        case RATE_INFO_BW_20:
                idx = 0;
        }
@@ -1247,6 +1246,10 @@ static u32 cfg80211_calculate_bitrate_vht(struct rate_info *rate)
 
        /* do NOT round down here */
        return (bitrate + 50000) / 100000;
+ warn:
+       WARN_ONCE(1, "invalid rate bw=%d, mcs=%d, nss=%d\n",
+                 rate->bw, rate->mcs, rate->nss);
+       return 0;
 }
 
 u32 cfg80211_calculate_bitrate(struct rate_info *rate)