]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
mac80211: add tx dequeue function for process context
authorErik Stromdahl <erik.stromdahl@gmail.com>
Mon, 17 Jun 2019 20:01:39 +0000 (22:01 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 26 Jul 2019 11:23:19 +0000 (13:23 +0200)
Since ieee80211_tx_dequeue() must not be called with softirqs enabled
(i.e. from process context without proper disable of bottom halves),
we add a wrapper that disables bottom halves before calling
ieee80211_tx_dequeue()

The new function is named ieee80211_tx_dequeue_ni() just as all other
from-process-context versions found in mac80211.

The documentation of ieee80211_tx_dequeue() is also updated so it
mentions that the function should not be called from process context.

Signed-off-by: Erik Stromdahl <erik.stromdahl@gmail.com>
Link: https://lore.kernel.org/r/20190617200140.6189-1-erik.stromdahl@gmail.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
include/net/mac80211.h
net/mac80211/tx.c

index 6cc5b25edf9dfe72a8dcdc28ebf3de50c3b14b20..fbe1c29e334910d298f3ecc717789264123d07d7 100644 (file)
@@ -6234,10 +6234,36 @@ void ieee80211_unreserve_tid(struct ieee80211_sta *sta, u8 tid);
  * but for the duration of the frame handling.
  * However, also note that while in the wake_tx_queue() method,
  * rcu_read_lock() is already held.
+ *
+ * softirqs must also be disabled when this function is called.
+ * In process context, use ieee80211_tx_dequeue_ni() instead.
  */
 struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,
                                     struct ieee80211_txq *txq);
 
+/**
+ * ieee80211_tx_dequeue_ni - dequeue a packet from a software tx queue
+ * (in process context)
+ *
+ * Like ieee80211_tx_dequeue() but can be called in process context
+ * (internally disables bottom halves).
+ *
+ * @hw: pointer as obtained from ieee80211_alloc_hw()
+ * @txq: pointer obtained from station or virtual interface, or from
+ *     ieee80211_next_txq()
+ */
+static inline struct sk_buff *ieee80211_tx_dequeue_ni(struct ieee80211_hw *hw,
+                                                     struct ieee80211_txq *txq)
+{
+       struct sk_buff *skb;
+
+       local_bh_disable();
+       skb = ieee80211_tx_dequeue(hw, txq);
+       local_bh_enable();
+
+       return skb;
+}
+
 /**
  * ieee80211_next_txq - get next tx queue to pull packets from
  *
index f13eb2f61ccfc7d53b85f8dc2ec4140e55b2afde..fb8870d9eba3b125c823e664d5f75fd15f48021f 100644 (file)
@@ -3546,6 +3546,8 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,
        ieee80211_tx_result r;
        struct ieee80211_vif *vif = txq->vif;
 
+       WARN_ON_ONCE(softirq_count() == 0);
+
 begin:
        spin_lock_bh(&fq->lock);