mac80211: add an intermediate software queue implementation
PATCH v4 1/1 mac80211: add an intermediate software queue implementation
This allows drivers to request per-vif and per-sta-tid queues from which they can pull frames. This makes it easier to keep the hardware queues short, and to improve fairness between clients and vifs.
The task of scheduling packet transmission is left up to the driver - queueing is controlled by mac80211. Drivers can only dequeue packets by calling ieee80211_tx_dequeue. This makes it possible to add active queue management later without changing drivers using this code.
This can also be used as a starting point to implement A-MSDU aggregation in a way that does not add artificially induced latency.
--- include/net/mac80211.h | 78 ++++++++++++++++++++++++++++++ net/mac80211/agg-tx.c | 42 +++++++++++++++++ net/mac80211/driver-ops.h | 12 +++++ net/mac80211/ieee80211_i.h | 24 ++++++++++ net/mac80211/iface.c | 19 ++++++++ net/mac80211/main.c | 3 ++ net/mac80211/rx.c | 13 +++++ net/mac80211/sta_info.c | 78 ++++++++++++++++++++++++++---- net/mac80211/sta_info.h | 2 + net/mac80211/trace.h | 28 +++++++++++ net/mac80211/tx.c | 115 +++++++++++++++++++++++++++++++++++++++++---- net/mac80211/util.c | 38 +++++++++++++++ 12 files changed, 433 insertions(+), 19 deletions(-)
include/net/mac80211.h +78 -0
@@ -84,6 +84,34 @@* */ +/** +* DOC: mac80211 software tx queueing +* +* mac80211 provides an optional intermediate queueing implementation designed +* to allow the driver to keep hardware queues short and provide some fairness +* between different stations/interfaces. +* In this model, the driver pulls data frames from the mac80211 queue instead +* of letting mac80211 push them via drv_tx(). +* Other frames (e.g. control or management) are still pushed using drv_tx(). +* +* Intermediate queues (struct ieee80211_txq) are kept per-sta per-tid, with a +* single per-vif queue for multicast data frames. +* +* The driver is expected to initialize its private per-queue data for stations +* and interfaces in the .add_interface and .sta_add ops. +* +* The driver can not access the queue directly. To dequeue a frame, it calls +* ieee80211_tx_dequeue(). Whenever mac80211 adds a new frame to a queue, it +* calls the .wake_tx_queue driver op. +* +* For AP powersave TIM handling, the driver only needs to indicate if it has +* buffered packets in the driver specific data structures by calling +* ieee80211_sta_set_buffered(). For frames buffered in the ieee80211_txq +* struct, mac80211 sets TIM and calls .release_buffered_frames(). +* The driver is expected to release its own buffered frames and also call +* ieee80211_tx_dequeue() within that callback. +*/ +struct device ;/**
@@ -1257,6 +1285,8 @@ struct ieee80211_vif {u8 cab_queue;u8 hw_queue[IEEE80211_NUM_ACS ]; +struct ieee80211_txq *txq; +struct ieee80211_chanctx_conf __rcu *chanctx_conf;u32 driver_flags;
@@ -1519,6 +1549,8 @@ struct ieee80211_sta {bool tdls_initiator;bool mfp; +struct ieee80211_txq *txq[IEEE80211_NUM_TIDS ]; +/* must be last */ u8 drv_priv[0 ]__aligned(sizeof(void *)) ; };
@@ -1547,6 +1579,27 @@ struct ieee80211_tx_control { };/** +* struct ieee80211_txq - Software intermediate tx queue +* +* @vif: &struct ieee80211_vif pointer from the add_interface callback. +* @sta: station table entry, may be NULL for per-vif queue +* @tid: the TID for this queue (unused for per-vif queue) +* @ac: the AC for this queue +* +* The driver can obtain packets from this queue by calling +* ieee80211_tx_dequeue(). +*/ +struct ieee80211_txq { +struct ieee80211_vif *vif; +struct ieee80211_sta *sta; +u8 tid; +u8 ac; + +/* must be last */ +u8 drv_priv[0 ]__aligned(sizeof(void *)) ; +}; + +/** * enum ieee80211_hw_flags - hardware flags * * These flags are used to indicate hardware capabilities to
@@ -1770,6 +1823,8 @@ enum ieee80211_hw_flags {* within &struct ieee80211_sta. * @chanctx_data_size: size (in bytes) of the drv_priv data area * within &struct ieee80211_chanctx_conf. +* @txq_data_size: size (in bytes) of the drv_priv data area +* within @struct ieee80211_txq. * * @max_rates: maximum number of alternate rate retry stages the hw * can handle.
@@ -1818,6 +1873,9 @@ enum ieee80211_hw_flags {* @n_cipher_schemes: a size of an array of cipher schemes definitions. * @cipher_schemes: a pointer to an array of cipher scheme definitions * supported by HW. +* +* @txq_ac_max_pending: maximum number of frames per AC pending in all txq +* entries for a vif. */ struct ieee80211_hw {struct ieee80211_conf conf;
@@ -1830,6 +1888,7 @@ struct ieee80211_hw {int vif_data_size;int sta_data_size;int chanctx_data_size; +int txq_data_size;u16 queues;u16 max_listen_interval;s8 max_signal;
@@ -1846,6 +1905,7 @@ struct ieee80211_hw {u8 uapsd_max_sp_len;u8 n_cipher_schemes;const struct ieee80211_cipher_scheme *cipher_schemes; +int txq_ac_max_pending; };/**
@@ -3007,6 +3067,8 @@ enum ieee80211_reconfig_type {* response template is provided, together with the location of the * switch-timing IE within the template. The skb can only be used within * the function call. +* +* @wake_tx_queue: Called when new packets have been added to the queue. */ struct ieee80211_ops { void (*tx)(struct ieee80211_hw *hw,
@@ -3238,6 +3300,9 @@ struct ieee80211_ops {void (*tdls_recv_channel_switch)(struct ieee80211_hw *hw,struct ieee80211_vif *vif,struct ieee80211_tdls_ch_sw_params *params); + +void (*wake_tx_queue)(struct ieee80211_hw *hw, +struct ieee80211_txq *txq); };/**
@@ -5259,4 +5324,17 @@ void ieee80211_unreserve_tid(struct ieee80211_sta *sta, u8 tid);*/ size_t ieee80211_ie_split (const u8 *ies,size_t ielen,const u8 *ids,int n_ids,size_t offset); + +/** +* ieee80211_tx_dequeue - dequeue a packet from a software tx queue +* +* @hw: pointer as obtained from ieee80211_alloc_hw() +* @txq: pointer obtained from .add_tx_queue() call +* +* Returns the skb if successful, NULL if no frame was available. +*/ +struct sk_buff *ieee80211_tx_dequeue (struct ieee80211_hw *hw, +struct ieee80211_txq *txq); + +#endif /* MAC80211_H */
net/mac80211/agg-tx.c +42 -0
72 lines not on this page · raw message
net/mac80211/driver-ops.h +12 -0
@@ -1367,4 +1367,16 @@ drv_tdls_recv_channel_switch(struct ieee80211_local *local, trace_drv_return_void(local); } +static inline void drv_wake_tx_queue (struct ieee80211_local *local, +struct txq_info *txq) +{ +struct ieee80211_sub_if_data *sdata =vif_to_sdata (txq->txq.vif); + +if (!check_sdata_in_driver (sdata)) +return ; + +trace_drv_wake_tx_queue (local, sdata, txq->txq.sta, txq->txq.tid); + local->ops->wake_tx_queue (&local->hw, &txq->txq); +} +#endif /* __MAC80211_DRIVER_OPS */
net/mac80211/ieee80211_i.h +24 -0
@@ -809,6 +809,19 @@ struct mac80211_qos_map {struct rcu_head rcu_head; }; +enum txq_info_flags { +IEEE80211_TXQ_STOP , +IEEE80211_TXQ_AMPDU , +}; + +struct txq_info { +struct sk_buff_head queue; +unsigned long flags; + +/* keep last! */ +struct ieee80211_txq txq; +}; +struct ieee80211_sub_if_data {struct list_head list;
@@ -853,6 +866,7 @@ struct ieee80211_sub_if_data {bool control_port_no_encrypt;int encrypt_headroom; +atomic_t txqs_len[IEEE80211_NUM_ACS ];struct ieee80211_tx_queue_params tx_conf[IEEE80211_NUM_ACS ];struct mac80211_qos_map __rcu *qos_map;
@@ -1450,6 +1464,10 @@ static inline struct ieee80211_local *hw_to_local( return container_of(hw, struct ieee80211_local, hw); } +static inline struct txq_info *to_txq_info (struct ieee80211_txq *txq) +{ + return container_of(txq, struct txq_info, txq); +}static inline int ieee80211_bssid_match (const u8 *raddr,const u8 *addr) {
@@ -1902,6 +1920,12 @@ static inline bool ieee80211_can_run_worker(struct ieee80211_local *local)return true; } +void ieee80211_init_tx_queue (struct ieee80211_sub_if_data *sdata, +struct sta_info *sta, +struct txq_info *txq,int tid); +void ieee80211_flush_tx_queue (struct ieee80211_local *local, +struct ieee80211_txq *txq); + void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, u16 transaction, u16 auth_alg, u16 status, const u8 *extra, size_t extra_len, const u8 *bssid,
net/mac80211/iface.c +19 -0
@@ -969,6 +969,9 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, }spin_unlock_irqrestore (&local->queue_stop_reason_lock, flags); +if (sdata->vif.txq) +ieee80211_flush_tx_queue (local, sdata->vif.txq); +if (local->open_count ==0 )ieee80211_clear_tx_pending (local);
@@ -1753,6 +1756,15 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,ieee80211_setup_sdata (sdata, type);if (ndev) { +struct txq_info *txqi =NULL ; + +if (local->ops->wake_tx_queue) { + txqi =kzalloc (sizeof (*txqi) + + local->hw.txq_data_size,GFP_KERNEL ); +if (txqi) +ieee80211_init_tx_queue (sdata,NULL , txqi,0 ); + } +if (params) { ndev->ieee80211_ptr->use_4addr = params->use_4addr;if (type ==NL80211_IFTYPE_STATION )
@@ -1765,6 +1777,7 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name, ret =register_netdevice (ndev);if (ret) { +kfree (txqi);free_netdev (ndev);return ret; }
@@ -1790,6 +1803,9 @@ void ieee80211_if_remove(struct ieee80211_sub_if_data *sdata)synchronize_rcu (); +if (sdata->vif.txq) +kfree (to_txq_info (sdata->vif.txq)); +if (sdata->dev) {unregister_netdevice (sdata->dev); }else {
@@ -1831,6 +1847,9 @@ void ieee80211_remove_interfaces(struct ieee80211_local *local)list_for_each_entry_safe (sdata, tmp, &local->interfaces, list) {list_del (&sdata->list); +if (sdata->vif.txq) +kfree (to_txq_info (sdata->vif.txq)); +if (sdata->dev)unregister_netdevice_queue (sdata->dev, &unreg_list);else
net/mac80211/main.c +3 -0
@@ -1035,6 +1035,9 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) local->dynamic_ps_forced_timeout =-1 ; +if (!local->hw.txq_ac_max_pending) + local->hw.txq_ac_max_pending =64 ; + result =ieee80211_wep_init (local);if (result <0 ) wiphy_debug(local->hw.wiphy, "Failed to initialize wep: %d\n",
net/mac80211/rx.c +13 -0
@@ -1184,6 +1184,7 @@ static void sta_ps_start(struct sta_info *sta)struct ieee80211_sub_if_data *sdata = sta->sdata;struct ieee80211_local *local = sdata->local;struct ps_data *ps; +int tid;if (sta->sdata->vif.type ==NL80211_IFTYPE_AP || sta->sdata->vif.type ==NL80211_IFTYPE_AP_VLAN )
@@ -1197,6 +1198,18 @@ static void sta_ps_start(struct sta_info *sta)drv_sta_notify (local, sdata,STA_NOTIFY_SLEEP , &sta->sta);ps_dbg (sdata,"STA %pM aid %d enters power save mode\n" , sta->sta.addr, sta->sta.aid); + +if (!sta->sta.txq[0 ]) +return ; + +for (tid =0 ; tid <ARRAY_SIZE (sta->sta.txq); tid++) { +struct txq_info *txqi =to_txq_info (sta->sta.txq[tid]); + +if (!skb_queue_len (&txqi->queue)) +set_bit (tid, &sta->txq_buffered_tids); +else +clear_bit (tid, &sta->txq_buffered_tids); + } }static void sta_ps_end (struct sta_info *sta)
net/mac80211/sta_info.c +69 -9
168 lines not on this page · raw message
net/mac80211/sta_info.h +2 -0
@@ -274,6 +274,7 @@ struct sta_ampdu_mlme {* entered power saving state, these are also delivered to * the station when it leaves powersave or polls for frames * @driver_buffered_tids: bitmap of TIDs the driver has data buffered on +* @txq_buffered_tids: bitmap of TIDs that mac80211 has txq data buffered on * @rx_packets: Number of MSDUs received from this STA * @rx_bytes: Number of bytes received from this STA * @last_rx: time (in jiffies) when last frame was received from this STA
@@ -368,6 +369,7 @@ struct sta_info {struct sk_buff_head ps_tx_buf[IEEE80211_NUM_ACS ];struct sk_buff_head tx_filtered[IEEE80211_NUM_ACS ];unsigned long driver_buffered_tids; +unsigned long txq_buffered_tids;/* Updated from RX path only, no locking requirements */ unsigned long rx_packets;
net/mac80211/trace.h +28 -0
@@ -2312,6 +2312,34 @@ TRACE_EVENT(drv_tdls_recv_channel_switch, ) ); +TRACE_EVENT (drv_wake_tx_queue, + TP_PROTO(struct ieee80211_local *local, + struct ieee80211_sub_if_data *sdata, + struct ieee80211_sta *sta, + u8 tid), + +TP_ARGS (local, sdata, sta, tid), + +TP_STRUCT__entry ( + LOCAL_ENTRY + VIF_ENTRY + STA_ENTRY +__field (u8, tid) + ), + +TP_fast_assign ( + LOCAL_ASSIGN; + VIF_ASSIGN; + STA_ASSIGN; + __entry->tid = tid; + ), + +TP_printk ( + LOCAL_PR_FMT VIF_PR_FMT STA_PR_FMT " tid: 0x%x", +LOCAL_PR_ARG ,VIF_PR_ARG ,STA_PR_ARG , __entry->tid + ) +); +#ifdef CONFIG_MAC80211_MESSAGE_TRACING #undef TRACE_SYSTEM#define TRACE_SYSTEM mac80211_msg
net/mac80211/tx.c +105 -10
160 lines not on this page · raw message
net/mac80211/util.c +38 -0
@@ -308,6 +308,11 @@ void ieee80211_propagate_queue_wake(struct ieee80211_local *local, int queue)for (ac =0 ; ac < n_acs; ac++) {int ac_queue = sdata->vif.hw_queue[ac]; +if (local->ops->wake_tx_queue && + (atomic_read (&sdata->txqs_len[ac]) > + local->hw.txq_ac_max_pending)) +continue ; + if (ac_queue == queue || (sdata->vif.cab_queue == queue && local->queue_stop_reasons[ac_queue] == 0 &&
@@ -3307,3 +3312,36 @@ u8 *ieee80211_add_wmm_info_ie(u8 *buf, u8 qosinfo)return buf; } + +void ieee80211_init_tx_queue (struct ieee80211_sub_if_data *sdata, +struct sta_info *sta, +struct txq_info *txqi,int tid) +{ +skb_queue_head_init (&txqi->queue); + txqi->txq.vif = &sdata->vif; + +if (sta) { + txqi->txq.sta = &sta->sta; + sta->sta.txq[tid] = &txqi->txq; + txqi->txq.ac = ieee802_1d_to_ac[tid &7 ]; + }else { + sdata->vif.txq = &txqi->txq; + txqi->txq.ac =IEEE80211_AC_BE ; + } +} + +void ieee80211_flush_tx_queue (struct ieee80211_local *local, +struct ieee80211_txq *txq) +{ + struct txq_info *txqi = container_of(txq, struct txq_info, txq); +struct ieee80211_sub_if_data *sdata =vif_to_sdata (txq->vif); +struct sk_buff *skb; +int n =0 ; + +while ((skb =skb_dequeue (&txqi->queue)) !=NULL ) { + n++; +ieee80211_free_txskb (&local->hw, skb); + } + +atomic_sub (n, &sdata->txqs_len[txq->ac]); +}
Signature · 1 line
2.2.2
Johannes Berg
maintainerQuoted 5 lines
+ * For AP powersave TIM handling, the driver only needs to indicate if it has
+ * buffered packets in the driver specific data structures by calling
+ *ieee80211_sta_set_buffered(). For frames buffered in theieee80211_txq
+ * struct, mac80211 sets TIM and calls .release_buffered_frames().
could perhaps be elaborated to
[...] mac80211 sets the appropriate TIM PVB bits and calls [...]
but I don't really care
Quoted 2 lines
+ * The driver is expected to release its own buffered frames and also call
+ *ieee80211_tx_dequeue()within that callback.
Perhaps that should read
"The driver is expected to release its own buffered frames (if any) and request the remaining dequeued frames by calling ieee80211_tx_dequeue()."
I'm not really sure it needs to be within that callback? I see no particular reason for that.
Quoted 5 lines
/**
+ * structieee80211_txq- Software intermediate tx queue
+ *
+ * @vif: &structieee80211_vifpointer from theadd_interfacecallback.
+ * @sta: station table entry, may be NULL for per-vif queue
well, "may be" is a bit of an understatement ;-)
just say "%NULL for per-vif queue"?
(%NULL just causes different formatting in kernel-doc)
Quoted 2 lines
+ * @tid: the TID for this queue (unused for per-vif queue)
+ * @ac: the AC for this queue
AC is also unused for per-vif I guess?
Quoted 7 lines
+/**
+ *ieee80211_tx_dequeue- dequeue a packet from a software tx queue
+ *
+ * @hw: pointer as obtained fromieee80211_alloc_hw()
+ * @txq: pointer obtained from .add_tx_queue() call
+ *
+ * Returns the skb if successful, NULL if no frame was available.
Perhaps also use %NULL here. Not really important though.
Quoted 8 lines
+++
b/net/mac80211/agg-tx.cnet/mac80211/agg-tx.c +3
-0@@ -188,6 +188,41 @@ ieee80211_wake_queue_agg(struct ieee80211_sub_if_data *sdata, int tid)__release (agg_queue); } +static void +ieee80211_agg_stop_txq (struct sta_info *sta,int tid) +{
net/mac80211/agg-tx.c ieee80211_wake_queue_agg(struct ieee80211_sub_if_data *sdata, int tid) · line 203
Quoted 10 lines
net/mac80211/agg-tx.c +10
-0+struct ieee80211_txq *txq = sta->sta.txq[tid]; +struct txq_info *txqi; + +if (!txq) +return ; + + txqi =to_txq_info (txq); +spin_lock_bh (&txqi->queue.lock); +set_bit (IEEE80211_TXQ_STOP , &txqi->flags); +spin_unlock_bh (&txqi->queue.lock);
What's the point in locking here?
Quoted 7 lines
net/mac80211/agg-tx.c +7
-0+static void +ieee80211_agg_start_txq (struct sta_info *sta,int tid,bool enable) +{ +struct ieee80211_txq *txq = sta->sta.txq[tid]; +struct txq_info *txqi; + +if (!txq)
net/mac80211/agg-tx.c ieee80211_wake_queue_agg(struct ieee80211_sub_if_data *sdata, int tid) · line 222
Quoted 10 lines
net/mac80211/agg-tx.c +10
-0+return ; + + txqi =to_txq_info (txq); + +if (enable) +set_bit (IEEE80211_TXQ_AMPDU , &txqi->flags); +else +clear_bit (IEEE80211_TXQ_AMPDU , &txqi->flags); + +clear_bit (IEEE80211_TXQ_STOP , &txqi->flags);
here you don't either
net/mac80211/sta_info.c struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata, · line 343
Quoted 3 lines
net/mac80211/sta_info.c +3
-0+for (i =0 ; i <ARRAY_SIZE (sta->sta.txq); i++) { +struct txq_info *txq = txq_data + i * size; +ieee80211_init_tx_queue (sdata, sta, txq, i);
I'd prefer you left a blank line after the declaration
net/mac80211/tx.c ieee80211_tx_prepare(struct ieee80211_sub_if_data *sdata, · line 1253
Quoted 3 lines
net/mac80211/tx.c +3
-0+if (pubsta) { +u8 tid = skb->priority &IEEE80211_QOS_CTL_TID_MASK ; + txq = pubsta->txq[tid];
same here
net/mac80211/tx.c ieee80211_tx_prepare(struct ieee80211_sub_if_data *sdata, · line 1262
Quoted 9 lines
net/mac80211/tx.c +9
-0+ }else if (vif) { + txq = vif->txq; + } + +if (!txq) + goto tx_normal; + + ac = txq->ac; + txqi = container_of(txq, struct txq_info, txq);
to_txq_info()?
Quoted 4 lines
net/mac80211/tx.c +4
-0+struct sk_buff *ieee80211_tx_dequeue (struct ieee80211_hw *hw, +struct ieee80211_txq *txq) +{ +struct ieee80211_local *local =hw_to_local (hw);
net/mac80211/tx.c ieee80211_tx_prepare(struct ieee80211_sub_if_data *sdata, · line 1289
Quoted 10 lines
net/mac80211/tx.c +10
-0+struct ieee80211_sub_if_data *sdata =vif_to_sdata (txq->vif); + struct txq_info *txqi = container_of(txq, struct txq_info, txq); +struct ieee80211_hdr *hdr; +struct sk_buff *skb =NULL ; +u8 ac = txq->ac; + +spin_lock_bh (&txqi->queue.lock); + +if (test_bit (IEEE80211_TXQ_STOP , &txqi->flags)) + goto out;
I don't really see much point in this locking scheme.
Fundamentally, one of the places will win if they execute concurrently, and then it doesn't matter whether you're already past the stop check or not, so I think you can just do that unlocked, and leave just the dequeue itself locked?
net/mac80211/util.c u8 *ieee80211_add_wmm_info_ie(u8 *buf, u8 qosinfo) · line 3334
Quoted 2 lines
net/mac80211/util.c +2
-0+void ieee80211_flush_tx_queue (struct ieee80211_local *local, +struct ieee80211_txq *txq)
I think you should consider renaming this, it doesn't really flush anything out, it just frees the packets.
johannes
Quoted 10 lines · Johannes Berg
Quoted 2 lines
+ * The driver is expected to release its own buffered frames and also call
+ *ieee80211_tx_dequeue()within that callback.Perhaps that should read
"The driver is expected to release its own buffered frames (if any) and request the remaining dequeued frames by callingieee80211_tx_dequeue()."I'm not really sure it needs to be within that callback? I see no particular reason for that.
Releasing multiple packets works, even if there is only one packet buffered in the driver and the rest in the txq. It also keeps the code more consistent.
Now that I'm thinking about this some more, it might even make sense to skip the sta PS queue for txq-enabled drivers. That would allow all sta data frames to either go through driver scheduling or release_buffered_frames.
Quoted 4 lines
Quoted 2 lines
+ * @tid: the TID for this queue (unused for per-vif queue)
+ * @ac: the AC for this queueAC is also unused for per-vif I guess?
It's set to BE for per-vif to allow the driver to use it to pick the right tx queue.
Quoted 5 lines
Quoted 5 lines
+++
b/net/mac80211/agg-tx.cnet/mac80211/agg-tx.c +0
-0@@ -188,6 +188,41 @@ ieee80211_wake_queue_agg(struct ieee80211_sub_if_data *sdata, int tid)__release (agg_queue); }
Quoted 15 lines
net/mac80211/agg-tx.c ieee80211_wake_queue_agg(struct ieee80211_sub_if_data *sdata, int tid) · line 203
Quoted 13 lines
net/mac80211/agg-tx.c +13
-0+static void +ieee80211_agg_stop_txq (struct sta_info *sta,int tid) +{ +struct ieee80211_txq *txq = sta->sta.txq[tid]; +struct txq_info *txqi; + +if (!txq) +return ; + + txqi =to_txq_info (txq); +spin_lock_bh (&txqi->queue.lock); +set_bit (IEEE80211_TXQ_STOP , &txqi->flags); +spin_unlock_bh (&txqi->queue.lock);What's the point in locking here?
If I don't lock here, one last dequeue call might still be running on another CPU. This would produce a theoretical race in accessing the sequence number, which the caller of this function reads before setting up the BA request.
Dequeueing happens outside of the normal network stack tx context, so synchronize_net is not enough.
Quoted 11 lines
Quoted 11 lines
net/mac80211/agg-tx.c +11
-0+static void +ieee80211_agg_start_txq (struct sta_info *sta,int tid,bool enable) +{ +struct ieee80211_txq *txq = sta->sta.txq[tid]; +struct txq_info *txqi; + +if (!txq) +return ; + + txqi =to_txq_info (txq); +
Quoted 8 lines
net/mac80211/agg-tx.c ieee80211_wake_queue_agg(struct ieee80211_sub_if_data *sdata, int tid) · line 222
Quoted 6 lines
net/mac80211/agg-tx.c +6
-0+if (enable) +set_bit (IEEE80211_TXQ_AMPDU , &txqi->flags); +else +clear_bit (IEEE80211_TXQ_AMPDU , &txqi->flags); + +clear_bit (IEEE80211_TXQ_STOP , &txqi->flags);here you don't either
Here only the order of changing IEEE80211_TXQ_AMPDU vs clearing IEEE80211_TXQ_STOP matters.
- Felix
Johannes Berg
maintainerQuoted 9 lines · Felix Fietkau
Quoted 8 lines · Johannes Berg
Quoted 2 lines
+ * The driver is expected to release its own buffered frames and also call
+ *ieee80211_tx_dequeue()within that callback.Perhaps that should read
"The driver is expected to release its own buffered frames (if any) and request the remaining dequeued frames by callingieee80211_tx_dequeue()."
Quoted 5 lines
Quoted 2 lines
I'm not really sure it needs to be within that callback? I see no particular reason for that.
Releasing multiple packets works, even if there is only one packet buffered in the driver and the rest in the txq. It also keeps the code more consistent.
Right. I still phrased that badly. I meant that the "also" should be limited by the number of frames really needed, i.e. use driver-buffered first and fill up with any mac80211-buffered by dequeuing. That's probably obvious enough though.
Anyway - not sure it needs to be in the callback?
Quoted 4 lines
Now that I'm thinking about this some more, it might even make sense to skip the sta PS queue for txq-enabled drivers. That would allow all sta data frames to either go through driver scheduling or
release_buffered_frames.
Well, it's slightly more complicated due to the filtered queue. Not sure you want to 'pollute' the TXQ abstraction with that?
Quoted 6 lines
If I don't lock here, one last dequeue call might still be running on another CPU. This would produce a theoretical race in accessing the sequence number, which the caller of this function reads before setting up the BA request.
Dequeueing happens outside of the normal network stack tx context, sosynchronize_netis not enough.
Ah, makes sense, I didn't think of the seqno. Can you please put that in a comment somewhere? :)
johannes
Quoted 16 lines · Johannes Berg
Quoted 9 lines · Felix Fietkau
Quoted 8 lines · Johannes Berg
Quoted 2 lines
+ * The driver is expected to release its own buffered frames and also call
+ *ieee80211_tx_dequeue()within that callback.Perhaps that should read
"The driver is expected to release its own buffered frames (if any) and request the remaining dequeued frames by callingieee80211_tx_dequeue()."Quoted 5 lines
Quoted 2 lines
I'm not really sure it needs to be within that callback? I see no particular reason for that.
Releasing multiple packets works, even if there is only one packet buffered in the driver and the rest in the txq. It also keeps the code more consistent.
Quoted 6 lines
Right. I still phrased that badly. I meant that the "also" should be limited by the number of frames really needed, i.e. use driver-buffered first and fill up with any mac80211-buffered by dequeuing. That's probably obvious enough though.
Anyway - not sure it needs to be in the callback?
I think it makes things simpler this way. What would you prefer?
Quoted 9 lines
Quoted 6 lines
If I don't lock here, one last dequeue call might still be running on another CPU. This would produce a theoretical race in accessing the sequence number, which the caller of this function reads before setting up the BA request.
Dequeueing happens outside of the normal network stack tx context, sosynchronize_netis not enough.Ah, makes sense, I didn't think of the seqno. Can you please put that in a comment somewhere? :)
Sure.
- Felix
Johannes Berg
maintainerQuoted 2 lines · Felix Fietkau
Quoted 1 line
Anyway - not sure it needs to be in the callback?
I think it makes things simpler this way. What would you prefer?
It might for the driver, but I'm not sure it should be required and described in the docs?
johannes