mac80211: add ieee80211_tx_status_noskb
authorFelix Fietkau <nbd@openwrt.org>
Wed, 19 Nov 2014 19:08:13 +0000 (20:08 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 28 Nov 2014 14:01:51 +0000 (15:01 +0100)
This can be used by drivers that cannot reliably map tx status
information onto specific skbs.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
include/net/mac80211.h
net/mac80211/rate.h
net/mac80211/status.c

index 01dfd22e45fdc4c185485ba3561dba71c7c09511..58d719ddaa60c93d2c6424765e96abf254cb4dc6 100644 (file)
@@ -3618,6 +3618,26 @@ void ieee80211_get_tx_rates(struct ieee80211_vif *vif,
 void ieee80211_tx_status(struct ieee80211_hw *hw,
                         struct sk_buff *skb);
 
+/**
+ * ieee80211_tx_status_noskb - transmit status callback without skb
+ *
+ * This function can be used as a replacement for ieee80211_tx_status
+ * in drivers that cannot reliably map tx status information back to
+ * specific skbs.
+ *
+ * Calls to this function for a single hardware must be synchronized
+ * against each other. Calls to this function, ieee80211_tx_status_ni()
+ * and ieee80211_tx_status_irqsafe() may not be mixed for a single hardware.
+ *
+ * @hw: the hardware the frame was transmitted by
+ * @sta: the receiver station to which this packet is sent
+ *     (NULL for multicast packets)
+ * @info: tx status information
+ */
+void ieee80211_tx_status_noskb(struct ieee80211_hw *hw,
+                              struct ieee80211_sta *sta,
+                              struct ieee80211_tx_info *info);
+
 /**
  * ieee80211_tx_status_ni - transmit status callback (in process context)
  *
index dd25964a300ad7b037d494ce4645a4c52f67e342..38652f09feaf250ec0517e23c8f147c8921f7499 100644 (file)
@@ -48,6 +48,24 @@ static inline void rate_control_tx_status(struct ieee80211_local *local,
                ref->ops->tx_status_noskb(ref->priv, sband, ista, priv_sta, info);
 }
 
+static inline void
+rate_control_tx_status_noskb(struct ieee80211_local *local,
+                            struct ieee80211_supported_band *sband,
+                            struct sta_info *sta,
+                            struct ieee80211_tx_info *info)
+{
+       struct rate_control_ref *ref = local->rate_ctrl;
+       struct ieee80211_sta *ista = &sta->sta;
+       void *priv_sta = sta->rate_ctrl_priv;
+
+       if (!ref || !test_sta_flag(sta, WLAN_STA_RATE_CONTROL))
+               return;
+
+       if (WARN_ON_ONCE(!ref->ops->tx_status_noskb))
+               return;
+
+       ref->ops->tx_status_noskb(ref->priv, sband, ista, priv_sta, info);
+}
 
 static inline void rate_control_rate_init(struct sta_info *sta)
 {
index fee9c5ee51ae5bcb4387be19947b821ea8f3f3ab..bb146f377ee457e66a2f85cc99c264746bcace81 100644 (file)
@@ -656,6 +656,60 @@ static int ieee80211_tx_get_rates(struct ieee80211_hw *hw,
        return rates_idx;
 }
 
+void ieee80211_tx_status_noskb(struct ieee80211_hw *hw,
+                              struct ieee80211_sta *pubsta,
+                              struct ieee80211_tx_info *info)
+{
+       struct ieee80211_local *local = hw_to_local(hw);
+       struct ieee80211_supported_band *sband;
+       int retry_count;
+       int rates_idx;
+       bool acked;
+
+       rates_idx = ieee80211_tx_get_rates(hw, info, &retry_count);
+
+       sband = hw->wiphy->bands[info->band];
+
+       acked = !!(info->flags & IEEE80211_TX_STAT_ACK);
+       if (pubsta) {
+               struct sta_info *sta;
+
+               sta = container_of(pubsta, struct sta_info, sta);
+
+               if (!acked)
+                       sta->tx_retry_failed++;
+               sta->tx_retry_count += retry_count;
+
+               if (acked) {
+                       sta->last_rx = jiffies;
+
+                       if (sta->lost_packets)
+                               sta->lost_packets = 0;
+
+                       /* Track when last TDLS packet was ACKed */
+                       if (test_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH))
+                               sta->last_tdls_pkt_time = jiffies;
+               } else {
+                       ieee80211_lost_packet(sta, info);
+               }
+
+               rate_control_tx_status_noskb(local, sband, sta, info);
+       }
+
+       if (acked) {
+                   local->dot11TransmittedFrameCount++;
+                   if (!pubsta)
+                           local->dot11MulticastTransmittedFrameCount++;
+                   if (retry_count > 0)
+                           local->dot11RetryCount++;
+                   if (retry_count > 1)
+                           local->dot11MultipleRetryCount++;
+       } else {
+               local->dot11FailedCount++;
+       }
+}
+EXPORT_SYMBOL(ieee80211_tx_status_noskb);
+
 void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
 {
        struct sk_buff *skb2;