mac0211: add a helper function for fixing up tx status rates
authorFelix Fietkau <nbd@openwrt.org>
Wed, 19 Nov 2014 19:08:12 +0000 (20:08 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 28 Nov 2014 14:01:50 +0000 (15:01 +0100)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/status.c

index 7d706d8..fee9c5e 100644 (file)
@@ -621,24 +621,13 @@ static void ieee80211_lost_packet(struct sta_info *sta,
        sta->lost_packets = 0;
 }
 
-void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
+static int ieee80211_tx_get_rates(struct ieee80211_hw *hw,
+                                 struct ieee80211_tx_info *info,
+                                 int *retry_count)
 {
-       struct sk_buff *skb2;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
-       struct ieee80211_local *local = hw_to_local(hw);
-       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
-       __le16 fc;
-       struct ieee80211_supported_band *sband;
-       struct ieee80211_sub_if_data *sdata;
-       struct net_device *prev_dev = NULL;
-       struct sta_info *sta, *tmp;
-       int retry_count = -1, i;
        int rates_idx = -1;
-       bool send_to_cooked;
-       bool acked;
-       struct ieee80211_bar *bar;
-       int rtap_len;
-       int shift = 0;
+       int count = -1;
+       int i;
 
        for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
                if ((info->flags & IEEE80211_TX_CTL_AMPDU) &&
@@ -656,12 +645,37 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
                        break;
                }
 
-               retry_count += info->status.rates[i].count;
+               count += info->status.rates[i].count;
        }
        rates_idx = i - 1;
 
-       if (retry_count < 0)
-               retry_count = 0;
+       if (count < 0)
+               count = 0;
+
+       *retry_count = count;
+       return rates_idx;
+}
+
+void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
+{
+       struct sk_buff *skb2;
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
+       struct ieee80211_local *local = hw_to_local(hw);
+       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
+       __le16 fc;
+       struct ieee80211_supported_band *sband;
+       struct ieee80211_sub_if_data *sdata;
+       struct net_device *prev_dev = NULL;
+       struct sta_info *sta, *tmp;
+       int retry_count;
+       int rates_idx;
+       bool send_to_cooked;
+       bool acked;
+       struct ieee80211_bar *bar;
+       int rtap_len;
+       int shift = 0;
+
+       rates_idx = ieee80211_tx_get_rates(hw, info, &retry_count);
 
        rcu_read_lock();