]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
mac80211: move store skb ack code to its own function
authorJohn Crispin <john@phrozen.org>
Tue, 29 Oct 2019 09:13:02 +0000 (10:13 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 8 Nov 2019 09:18:13 +0000 (10:18 +0100)
This patch moves the code handling SKBTX_WIFI_STATUS inside the TX path
into an extra function. This allows us to reuse it inside the 802.11 encap
offloading datapath.

Signed-off-by: John Crispin <john@phrozen.org>
Link: https://lore.kernel.org/r/20191029091304.7330-2-john@phrozen.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/tx.c

index 938c10f7955bcb4516d493df6e783518c8fb3ba6..a4c435abe15fd409eb2a68e509176ba3358804b6 100644 (file)
@@ -2417,6 +2417,33 @@ static int ieee80211_lookup_ra_sta(struct ieee80211_sub_if_data *sdata,
        return 0;
 }
 
+static int ieee80211_store_ack_skb(struct ieee80211_local *local,
+                                  struct sk_buff *skb,
+                                  u32 *info_flags)
+{
+       struct sk_buff *ack_skb = skb_clone_sk(skb);
+       u16 info_id = 0;
+
+       if (ack_skb) {
+               unsigned long flags;
+               int id;
+
+               spin_lock_irqsave(&local->ack_status_lock, flags);
+               id = idr_alloc(&local->ack_status_frames, ack_skb,
+                              1, 0x10000, GFP_ATOMIC);
+               spin_unlock_irqrestore(&local->ack_status_lock, flags);
+
+               if (id >= 0) {
+                       info_id = id;
+                       *info_flags |= IEEE80211_TX_CTL_REQ_TX_STATUS;
+               } else {
+                       kfree_skb(ack_skb);
+               }
+       }
+
+       return info_id;
+}
+
 /**
  * ieee80211_build_hdr - build 802.11 header in the given frame
  * @sdata: virtual interface to build the header for
@@ -2710,26 +2737,8 @@ static struct sk_buff *ieee80211_build_hdr(struct ieee80211_sub_if_data *sdata,
        }
 
        if (unlikely(!multicast && skb->sk &&
-                    skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS)) {
-               struct sk_buff *ack_skb = skb_clone_sk(skb);
-
-               if (ack_skb) {
-                       unsigned long flags;
-                       int id;
-
-                       spin_lock_irqsave(&local->ack_status_lock, flags);
-                       id = idr_alloc(&local->ack_status_frames, ack_skb,
-                                      1, 0x10000, GFP_ATOMIC);
-                       spin_unlock_irqrestore(&local->ack_status_lock, flags);
-
-                       if (id >= 0) {
-                               info_id = id;
-                               info_flags |= IEEE80211_TX_CTL_REQ_TX_STATUS;
-                       } else {
-                               kfree_skb(ack_skb);
-                       }
-               }
-       }
+                    skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS))
+               info_id = ieee80211_store_ack_skb(local, skb, &info_flags);
 
        /*
         * If the skb is shared we need to obtain our own copy.