OSDN Git Service

ath10k: get the legacy rate index to update the txrate table
authorAnilkumar Kolli <akolli@codeaurora.org>
Tue, 4 Sep 2018 06:45:13 +0000 (12:15 +0530)
committerKalle Valo <kvalo@codeaurora.org>
Thu, 6 Sep 2018 16:02:25 +0000 (19:02 +0300)
Get the legacy rate index to update the pkts/bytes counter
against each possible tx rate.

Signed-off-by: Anilkumar Kolli <akolli@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/ath/ath10k/htt_rx.c

index 4d1cd90..01eb4a7 100644 (file)
@@ -2488,7 +2488,7 @@ void ath10k_htt_htc_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb)
                dev_kfree_skb_any(skb);
 }
 
-static inline bool is_valid_legacy_rate(u8 rate)
+static inline int ath10k_get_legacy_rate_idx(struct ath10k *ar, u8 rate)
 {
        static const u8 legacy_rates[] = {1, 2, 5, 11, 6, 9, 12,
                                          18, 24, 36, 48, 54};
@@ -2496,10 +2496,11 @@ static inline bool is_valid_legacy_rate(u8 rate)
 
        for (i = 0; i < ARRAY_SIZE(legacy_rates); i++) {
                if (rate == legacy_rates[i])
-                       return true;
+                       return i;
        }
 
-       return false;
+       ath10k_warn(ar, "Invalid legacy rate %hhd peer stats", rate);
+       return -EINVAL;
 }
 
 static void
@@ -2508,7 +2509,7 @@ ath10k_update_per_peer_tx_stats(struct ath10k *ar,
                                struct ath10k_per_peer_tx_stats *peer_stats)
 {
        struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
-       u8 rate = 0, sgi;
+       u8 rate = 0, rate_idx = 0, sgi;
        struct rate_info txrate;
 
        lockdep_assert_held(&ar->data_lock);
@@ -2536,17 +2537,12 @@ ath10k_update_per_peer_tx_stats(struct ath10k *ar,
        if (txrate.flags == WMI_RATE_PREAMBLE_CCK ||
            txrate.flags == WMI_RATE_PREAMBLE_OFDM) {
                rate = ATH10K_HW_LEGACY_RATE(peer_stats->ratecode);
-
-               if (!is_valid_legacy_rate(rate)) {
-                       ath10k_warn(ar, "Invalid legacy rate %hhd peer stats",
-                                   rate);
-                       return;
-               }
-
                /* This is hacky, FW sends CCK rate 5.5Mbps as 6 */
-               rate *= 10;
-               if (rate == 60 && txrate.flags == WMI_RATE_PREAMBLE_CCK)
-                       rate = rate - 5;
+               if (rate == 6 && txrate.flags == WMI_RATE_PREAMBLE_CCK)
+                       rate = 5;
+               rate_idx = ath10k_get_legacy_rate_idx(ar, rate);
+               if (rate_idx < 0)
+                       return;
                arsta->txrate.legacy = rate;
        } else if (txrate.flags == WMI_RATE_PREAMBLE_HT) {
                arsta->txrate.flags = RATE_INFO_FLAGS_MCS;