wifi: ath11k: hardware TSO and scatter-gather with Ethernet encapsulation
v2 cover wifi: ath11k: hardware TSO and scatter-gather with Ethernet encapsulation
With Ethernet encap, the TCL of IPQ8074 can send a TCP batch from MSDU extension descriptors: one descriptor per segment lists the shared headers and the segment's payload, and the TCL writes the IP length, IP ID, TCP sequence number, flags and checksums into each segment. This series uses that for TSO and scatter-gather.
Patches 1 to 4 rework the TX path the series builds on: completions freed and their peers looked up once per run, the TCL ring taken once per dequeue run, TXQs pushed from BH work after the receive poll, and the TX buffer ids kept in a table. Patch 5 sends TCP batches and frames with fragments from extension descriptors, patch 6 offers SG, TSO and TSO6 through the mac80211 encap features, and patch 7 takes batches of up to 64 segments, as GRO builds them on a forwarding path. Patches 8 and 9 take work out of each segment's completion.
Only IPQ8074 sets hw_params.tx_tso, the chip this ran on; Qualcomm's open-source WLAN host driver on CodeLinaro uses one layout of this descriptor for the whole hardware generation, and each further chip needs its own run before its flag is set. TSO and SG take effect only in Ethernet mode, frame_mode=2.
This depends on Jose Ignacio Tornos Martinez's TX flow control series [1], patches 1-3, on v7 of my airtime queue limits series [2], and on v2 of my mac80211 series [3], whose patch 4 adds the encap features patch 6 sets; base-commit and prerequisites below.
v1 was tested on a Xiaomi AX3600 (IPQ8074 hw2.0, firmware WLAN.HK.2.12-01460) as an AP with Ethernet encap, on OpenWrt's 6.18 kernel with wireless backports 7.2 and further ath11k receive changes, with routed and bridged TCP over IPv4 and IPv6 to one HE160 station, 3 runs per cell. Over a full run of the eight cells the TCL segmented 2,609,390 batches of 14,450,235 segments, and none was segmented in software. Forwarded UDP saw no loss, and the kernel log stayed clean.
I used Claude (Anthropic) to help write these patches.
Changes in v2:
- rebased onto ath-next 18d0bedbb5f0, airtime queue limits v7 [2] and mac80211 v2 [3]; v1 sat on a mac80211 patch that returned the airtime of a freed encap frame, which is withdrawn, and patch 2 of [2] does that in the driver instead
- patch 5: the frames it drops (a batch that cannot be segmented in software, a software segment ath11k_dp_tx() refuses, a frame with fragments that cannot be made linear) go back to mac80211 through ath11k_dp_tx_drop() with their station, as the other dropped encap frames do with [2]; ieee80211_free_txskb() kept their airtime charge with the station. Found while rebasing onto [2].
- patch 6: commit message: mac80211 v2 sets the encap features on every netdev and takes them away from frames sent without encap, and the AQL segmentation applies because [2] enables AQL
- patches 4 and 5: commit message paragraphs moved above the trailers
- v1: https://lore.kernel.org/all/[email protected]/
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
[3] https://lore.kernel.org/all/[email protected]/
Julius Bairaktaris (9):
wifi: ath11k: batch TX completion frees and peer lookups
wifi: ath11k: fill the TCL ring once per dequeue run
wifi: ath11k: push TXQs from BH work
wifi: ath11k: replace the TX buffer IDR with a table
wifi: ath11k: let the TCL segment TCP batches
wifi: ath11k: offer scatter-gather and TSO with Ethernet encap
wifi: ath11k: take TCP batches as long as GRO builds them
wifi: ath11k: give an extension descriptor the number of its buffer id
wifi: ath11k: count the segments of a TX batch without an atomic
drivers/net/wireless/ath/ath11k/core.c | 1 + drivers/net/wireless/ath/ath11k/core.h | 22 + drivers/net/wireless/ath/ath11k/debugfs.c | 7 + drivers/net/wireless/ath/ath11k/dp.c | 30 +- drivers/net/wireless/ath/ath11k/dp.h | 54 +- drivers/net/wireless/ath/ath11k/dp_tx.c | 981 +++++++++++++++++++-- drivers/net/wireless/ath/ath11k/dp_tx.h | 16 +- drivers/net/wireless/ath/ath11k/hal_desc.h | 46 + drivers/net/wireless/ath/ath11k/hw.h | 1 + drivers/net/wireless/ath/ath11k/mac.c | 157 +++- 10 files changed, 1167 insertions(+), 148 deletions(-)
base-commit: 18d0bedbb5f0538396cb7f763ed9cd1dd69c5b23
prerequisite-message-id: <[email protected]>
prerequisite-message-id: <[email protected]>
prerequisite-message-id: <[email protected]>
prerequisite-patch-id: ff44eb6f1d673e75bc013e3ffc870d7d30252c17
prerequisite-patch-id: 2cde5e2a788f79e4b8c858a60ec11cd120b1b97e
prerequisite-patch-id: c86d3c9047c851f45b5d46398850c9d810d82258
prerequisite-patch-id: c3c9a2d5971c3e294bbef307df3befb0ff6678fd
prerequisite-patch-id: 46edfde76690d68785bc79ce81641524dcfffb4b
prerequisite-patch-id: 013f4003b682991301e1f6e4c381b30ba7ef38c7
prerequisite-patch-id: a3d4787acbb5c0739313b5f098bfb19add947ba7
prerequisite-patch-id: 0118167889d6928ea3b7922b59cd92c629d8ee1a
prerequisite-patch-id: f04db5549c465332f7abd795b0b3ed0984ca3444
prerequisite-patch-id: e4fd4524faccfc5c605a649903acb239d6b0a1dd
prerequisite-patch-id: 46dda0c1aa2552cbd23ab02fc8478d76bc8c8e99
prerequisite-patch-id: 2119096a59fa9de3cb57d63d6175874715068121
prerequisite-patch-id: 9532ca6465e7ec842bfb9e1e515acfa1cc49e860
prerequisite-patch-id: 0be0cf33cd3fa94f694f568603c1c59a433add1b
prerequisite-patch-id: fdbf9387c4946c9c2ebcf955674e07650fcd2291
prerequisite-patch-id: 827f1fc874ddd87e0d3bd762edfad197dadf1789
prerequisite-patch-id: 8d56af8bc8c0fc1828bf58ef3f7960e448f95463
prerequisite-patch-id: 66bc7e41834694d916ce81abb35483d65edb7005
prerequisite-patch-id: fbf304f07f5939251fd931109bdc54f3990e12d5
prerequisite-patch-id: 74e497d16ff6eb7011fae616dc937b6bf8ee1687
Signature · 1 line
2.53.0
PATCH v2 1/9 wifi: ath11k: batch TX completion frees and peer lookups
The TX completion handler takes base_lock and searches the peer list for every frame, although consecutive completions mostly belong to one peer, and it frees each buffer on its own. Carry the peer's station and TX rate across one completion run and look them up again only when the peer ID changes. Collect the completed buffers on the status free list and free them with napi_consume_skb() at the end of the run.
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.12-01460-QCAHKSWPL_SILICONZ-1
---
v2: rebased onto airtime queue limits v7, whose patch 2 returns a frame whose peer is not found through ath11k_dp_tx_drop(); that call stays, now after the cached lookup.
drivers/net/wireless/ath/ath11k/dp_tx.c | 49 ++++++++++++++++++------- 1 file changed, 35 insertions(+), 14 deletions(-)
drivers/net/wireless/ath/ath11k/dp_tx.c +35 -14
@@ -701,9 +701,21 @@ void ath11k_dp_tx_update_txcompl(struct ath11k *ar, struct hal_tx_status *ts)spin_unlock_bh (&ab->base_lock); } +/* +* State carried across one completion run: consecutive frames mostly belong +* to one peer, and the statuses hand their buffers back to be freed in bulk. +*/ +struct ath11k_dp_tx_compl { +struct list_head free; +struct ieee80211_sta *sta; +struct rate_info rate; +u16 peer_id; +}; +static void ath11k_dp_tx_complete_msdu (struct ath11k *ar,struct sk_buff *msdu, -struct hal_tx_status *ts) +struct hal_tx_status *ts, +struct ath11k_dp_tx_compl *c) {struct ieee80211_tx_status status = {};struct ieee80211_rate_status status_rate = {};
@@ -711,8 +723,6 @@ static void ath11k_dp_tx_complete_msdu(struct ath11k *ar,struct ieee80211_tx_info *info;struct ath11k_skb_cb *skb_cb;struct ath11k_peer *peer; -struct ath11k_sta *arsta; -struct rate_info rate;struct ieee80211_vif *vif;u8 sta_addr[ETH_ALEN ];u8 flags;
@@ -787,31 +797,35 @@ static void ath11k_dp_tx_complete_msdu(struct ath11k *ar,ath11k_dp_tx_cache_peer_stats (ar, msdu, ts); } -spin_lock_bh (&ab->base_lock); - peer =ath11k_peer_find_by_id (ab, ts->peer_id); -if (!peer || !peer->sta) { +if (!c->sta || c->peer_id != ts->peer_id) { +spin_lock_bh (&ab->base_lock); + peer =ath11k_peer_find_by_id (ab, ts->peer_id); + c->sta = peer ? peer->sta :NULL ; + c->peer_id = ts->peer_id; +if (c->sta) + c->rate =ath11k_sta_to_arsta (c->sta)->last_txrate; +spin_unlock_bh (&ab->base_lock); + } + +if (!c->sta) {ath11k_dbg (ab,ATH11K_DBG_DATA ,"dp_tx: failed to find the peer with peer_id %d\n" , ts->peer_id); -spin_unlock_bh (&ab->base_lock);ath11k_dp_tx_drop (ar,ath11k_dp_tx_find_sta (vif, flags, sta_addr), msdu);return ; } - arsta =ath11k_sta_to_arsta (peer->sta); - status.sta = peer->sta; + status.sta = c->sta; status.skb = msdu; status.info = info; - rate = arsta->last_txrate; + status.free_list = &c->free; - status_rate.rate_idx = rate; + status_rate.rate_idx = c->rate; status_rate.try_count =1 ; status.rates = &status_rate; status.n_rates =1 ; -spin_unlock_bh (&ab->base_lock); -ieee80211_tx_status_ext (ar->hw, &status); }
@@ -856,6 +870,8 @@ int ath11k_dp_tx_completion_handler(struct ath11k_base *ab, int ring_id,struct sk_buff *msdu;struct hal_tx_status ts = {};struct dp_tx_ring *tx_ring = &dp->tx_ring[ring_id]; +struct ath11k_dp_tx_compl c = { .free =LIST_HEAD_INIT (c.free) }; +struct sk_buff *tmp;unsigned long push =0 ;int done =0 ;u32 *desc;
@@ -929,7 +945,12 @@ int ath11k_dp_tx_completion_handler(struct ath11k_base *ab, int ring_id,if (atomic_dec_and_test (&ar->dp.num_tx_pending))wake_up (&ar->dp.tx_empty_waitq); -ath11k_dp_tx_complete_msdu (ar, msdu, &ts); +ath11k_dp_tx_complete_msdu (ar, msdu, &ts, &c); + } + +list_for_each_entry_safe (msdu, tmp, &c.free, list) { +skb_list_del_init (msdu); +napi_consume_skb (msdu, budget); }/* A completion returns the airtime the frame was charged, which is
Signature · 1 line
2.53.0
PATCH v2 2/9 wifi: ath11k: fill the TCL ring once per dequeue run
In reply to Julius BairaktarisEach frame a TXQ hands over took the TCL ring lock twice, read the hardware tail pointer three times and wrote the head pointer once. Take the ring once for the whole dequeue run instead: read the free count at the start, queue the frames on that ring and write the head pointer after the last one. ath11k_dp_tx() takes the ring the caller holds and does not fall back to another ring while it is held.
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.12-01460-QCAHKSWPL_SILICONZ-1
---
v2: no change.
drivers/net/wireless/ath/ath11k/dp_tx.c | 37 ++++++++++---- drivers/net/wireless/ath/ath11k/dp_tx.h | 2 +- drivers/net/wireless/ath/ath11k/mac.c | 68 ++++++++++++++++--------- 3 files changed, 72 insertions(+), 35 deletions(-)
drivers/net/wireless/ath/ath11k/dp_tx.c +26 -11
@@ -108,8 +108,13 @@ bool ath11k_dp_tx_idr_has_room(struct dp_tx_ring *tx_ring)return atomic_read (&tx_ring->num_txbuf) <DP_TX_IDR_SIZE -1 ; } +/* +* A caller that passes @held_ring holds that TCL ring's lock with an access +* open, and ends the access itself once it has queued its last frame; the frame +* goes on that ring or not at all. +*/ int ath11k_dp_tx (struct ath11k *ar,struct ath11k_vif *arvif, -struct ath11k_sta *arsta,struct sk_buff *skb) +struct ath11k_sta *arsta,struct sk_buff *skb,int held_ring) {struct ath11k_base *ab = ar->ab;struct ath11k_dp *dp = &ab->dp;
@@ -137,7 +142,10 @@ int ath11k_dp_tx(struct ath11k *ar, struct ath11k_vif *arvif, pool_id =skb_get_queue_mapping (skb) & (ATH11K_HW_MAX_QUEUES -1 ); - ring_selector = ab->hw_params.hw_ops->get_ring_selector (skb_get_queue_mapping (skb)); +if (held_ring >=0 ) + ring_selector = held_ring; +else + ring_selector = ab->hw_params.hw_ops->get_ring_selector (skb_get_queue_mapping (skb)); tcl_ring_sel: tcl_ring_retry = false;
@@ -157,7 +165,7 @@ int ath11k_dp_tx(struct ath11k *ar, struct ath11k_vif *arvif,spin_unlock_bh (&tx_ring->tx_idr_lock);if (unlikely (ret <0 )) { -if (ring_map == (BIT (num_tx_rings) -1 ) || +if (held_ring >=0 || ring_map == (BIT (num_tx_rings) -1 ) || !ab->hw_params.tcl_ring_retry) {atomic_inc (&ab->soc_stats.tx_err.misc_fail);return -ENOSPC ;
@@ -256,11 +264,17 @@ int ath11k_dp_tx(struct ath11k *ar, struct ath11k_vif *arvif, hal_ring_id = tx_ring->tcl_data_ring.ring_id; tcl_ring = &ab->hal.srng_list[hal_ring_id]; -spin_lock_bh (&tcl_ring->lock); - -ath11k_hal_srng_access_begin (ab, tcl_ring); +if (held_ring <0 ) { +spin_lock_bh (&tcl_ring->lock); +ath11k_hal_srng_access_begin (ab, tcl_ring); + } hal_tcl_desc = (void *)ath11k_hal_srng_src_get_next_entry (ab, tcl_ring); +if (unlikely (!hal_tcl_desc && held_ring >=0 )) { + ab->soc_stats.tx_err.desc_na[ti.ring_id]++; + ret = -ENOSPC ; + goto fail_unmap_dma; + }if (unlikely (!hal_tcl_desc)) {/* NOTE: It is highly unlikely we'll be running out of tcl_ring * desc because the desc is directly enqueued onto hw queue.
@@ -287,11 +301,12 @@ int ath11k_dp_tx(struct ath11k *ar, struct ath11k_vif *arvif,ath11k_hal_tx_cmd_desc_setup (ab, hal_tcl_desc +sizeof (struct hal_tlv_hdr ), &ti); -ath11k_hal_srng_access_end (ab, tcl_ring); - -ath11k_dp_shadow_start_timer (ab, tcl_ring, &dp->tx_ring_timer[ti.ring_id]); - -spin_unlock_bh (&tcl_ring->lock); +if (held_ring <0 ) { +ath11k_hal_srng_access_end (ab, tcl_ring); +ath11k_dp_shadow_start_timer (ab, tcl_ring, + &dp->tx_ring_timer[ti.ring_id]); +spin_unlock_bh (&tcl_ring->lock); + }ath11k_dbg_dump (ab,ATH11K_DBG_DP_TX ,NULL ,"dp tx msdu: " , skb->data, skb->len);
drivers/net/wireless/ath/ath11k/dp_tx.h +1 -1
@@ -20,7 +20,7 @@ struct ath11k_dp_htt_wbm_tx_status {void ath11k_dp_tx_update_txcompl (struct ath11k *ar,struct hal_tx_status *ts);int ath11k_dp_tx_htt_h2t_ver_req_msg (struct ath11k_base *ab);int ath11k_dp_tx (struct ath11k *ar,struct ath11k_vif *arvif, -struct ath11k_sta *arsta,struct sk_buff *skb); +struct ath11k_sta *arsta,struct sk_buff *skb,int held_ring);bool ath11k_dp_tx_idr_has_room (struct dp_tx_ring *tx_ring);int ath11k_dp_tx_completion_handler (struct ath11k_base *ab,int ring_id,int budget);
drivers/net/wireless/ath/ath11k/mac.c +45 -23
111 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v2 3/9 wifi: ath11k: push TXQs from BH work
In reply to Julius BairaktarisEach frame that the network stack queues from a receive poll wakes its TXQ on its own, and the wake ran a scheduling round at once, so a round handed the hardware a single frame and paid for the ring access, the locks and the scheduler per frame. Record the woken access categories and run their rounds from BH work, which runs after the poll and takes every frame it queued in one round.
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.12-01460-QCAHKSWPL_SILICONZ-1
---
v2: no change.
drivers/net/wireless/ath/ath11k/core.h | 3 +++ drivers/net/wireless/ath/ath11k/mac.c | 24 +++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath11k/core.h +3 -0
@@ -717,6 +717,9 @@ struct ath11k {spinlock_t txq_lock[IEEE80211_NUM_ACS ];/* access categories whose round ended for lack of room */ unsigned long txq_starved; +/* access categories woken since txq_work last ran */ +unsigned long txq_woken; +struct work_struct txq_work;struct list_head arvifs;/* should never be NULL; needed for regular htt rx */
drivers/net/wireless/ath/ath11k/mac.c +23 -1
@@ -6794,6 +6794,7 @@ static void ath11k_mac_op_stop(struct ieee80211_hw *hw, bool suspend)cancel_work_sync (&ar->channel_update_work);cancel_work_sync (&ar->regd_update_work);cancel_work_sync (&ar->ab->update_11d_work); +cancel_work_sync (&ar->txq_work);if (ar->state_11d ==ATH11K_11D_PREPARING ) { ar->state_11d =ATH11K_11D_IDLE ;
@@ -10214,10 +10215,30 @@ static void ath11k_mac_schedule_txq(struct ath11k *ar, u8 ac)spin_unlock_bh (&ar->txq_lock[ac]); } +/* +* A frame queued from a receive poll wakes its TXQ on its own, so pushing +* from the wake would hand the hardware one frame per round. The rounds run +* from BH work instead, after the poll, and take every frame it queued. +*/ +static void ath11k_mac_txq_work (struct work_struct *work) +{ + struct ath11k *ar = container_of(work, struct ath11k, txq_work); +unsigned long woken =xchg (&ar->txq_woken,0 ); +u8 ac; + +rcu_read_lock (); +for_each_set_bit (ac, &woken,IEEE80211_NUM_ACS ) +ath11k_mac_schedule_txq (ar, ac); +rcu_read_unlock (); +} +static void ath11k_mac_op_wake_tx_queue (struct ieee80211_hw *hw,struct ieee80211_txq *txq) { -ath11k_mac_schedule_txq (hw->priv, txq->ac); +struct ath11k *ar = hw->priv; + +set_bit (txq->ac, &ar->txq_woken); +queue_work (system_bh_wq, &ar->txq_work); }void ath11k_mac_tx_push_pending (struct ath11k *ar,u8 ac)
@@ -10956,6 +10977,7 @@ int ath11k_mac_allocate(struct ath11k_base *ab)for (j =0 ; j <IEEE80211_NUM_ACS ; j++)spin_lock_init (&ar->txq_lock[j]); +INIT_WORK (&ar->txq_work, ath11k_mac_txq_work);INIT_LIST_HEAD (&ar->arvifs);INIT_LIST_HEAD (&ar->ppdu_stats_info);mutex_init (&ar->conf_mutex);
Signature · 1 line
2.53.0
PATCH v2 4/9 wifi: ath11k: replace the TX buffer IDR with a table
In reply to Julius BairaktarisEvery transmitted frame took a buffer id from an IDR when it was queued and gave it back on completion. Keep the ids of each TCL ring in a table indexed by id with a stack of the free ones, so both steps take constant time. The id range stays the one the IDR handed out. The recovery path that returns the frames a crashed firmware holds walks the table as well. ath11k_dp_tx_idr_has_room() now reads the count of free ids, and the num_txbuf counter it read until now goes away.
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.12-01460-QCAHKSWPL_SILICONZ-1
---
v2: commit message: the paragraph that followed Tested-on moved above it.
drivers/net/wireless/ath/ath11k/dp.c | 30 ++++--- drivers/net/wireless/ath/ath11k/dp.h | 11 ++- drivers/net/wireless/ath/ath11k/dp_tx.c | 104 ++++++++++++++++++------ drivers/net/wireless/ath/ath11k/dp_tx.h | 2 + drivers/net/wireless/ath/ath11k/mac.c | 20 +++-- 5 files changed, 115 insertions(+), 52 deletions(-)
drivers/net/wireless/ath/ath11k/dp.c +17 -13
@@ -1015,17 +1015,21 @@ void ath11k_dp_vdev_tx_attach(struct ath11k *ar, struct ath11k_vif *arvif)ath11k_dp_update_vdev_search (arvif); } -static int ath11k_dp_tx_pending_cleanup (int buf_id,void *skb,void *ctx) +static void ath11k_dp_tx_pending_cleanup (struct ath11k_base *ab, +struct dp_tx_ring *tx_ring) { -struct ath11k_base *ab = ctx; -struct sk_buff *msdu = skb; +struct sk_buff *msdu; +u32 id; -dma_unmap_single (ab->dev,ATH11K_SKB_CB (msdu)->paddr, msdu->len, -DMA_TO_DEVICE ); - -dev_kfree_skb_any (msdu); +for (id =0 ; tx_ring->bufs && id <DP_TX_IDR_SIZE -1 ; id++) { + msdu = tx_ring->bufs[id]; +if (!msdu) +continue ; -return 0 ; +dma_unmap_single (ab->dev,ATH11K_SKB_CB (msdu)->paddr, + msdu->len,DMA_TO_DEVICE ); +dev_kfree_skb_any (msdu); + } }void ath11k_dp_free (struct ath11k_base *ab)
@@ -1042,9 +1046,8 @@ void ath11k_dp_free(struct ath11k_base *ab)for (i =0 ; i < ab->hw_params.hal_params->num_tx_rings; i++) {spin_lock_bh (&dp->tx_ring[i].tx_idr_lock); -idr_for_each (&dp->tx_ring[i].txbuf_idr, - ath11k_dp_tx_pending_cleanup, ab); -idr_destroy (&dp->tx_ring[i].txbuf_idr); +ath11k_dp_tx_pending_cleanup (ab, &dp->tx_ring[i]); +ath11k_dp_tx_bufs_free (&dp->tx_ring[i]);spin_unlock_bh (&dp->tx_ring[i].tx_idr_lock);kfree (dp->tx_ring[i].tx_status); dp->tx_ring[i].tx_status =NULL ;
@@ -1093,8 +1096,9 @@ int ath11k_dp_alloc(struct ath11k_base *ab) size =sizeof (struct hal_wbm_release_ring ) *DP_TX_COMP_RING_SIZE ;for (i =0 ; i < ab->hw_params.hal_params->num_tx_rings; i++) { -idr_init (&dp->tx_ring[i].txbuf_idr); -atomic_set (&dp->tx_ring[i].num_txbuf,0 ); + ret =ath11k_dp_tx_bufs_init (&dp->tx_ring[i]); +if (ret) + goto fail_cmn_srng_cleanup;spin_lock_init (&dp->tx_ring[i].tx_idr_lock);spin_lock_init (&dp->tx_ring[i].wake_tx_lock); dp->tx_ring[i].tcl_data_ring_id = i;
drivers/net/wireless/ath/ath11k/dp.h +5 -6
@@ -84,13 +84,12 @@ struct dp_tx_ring {u8 tcl_data_ring_id;struct dp_srng tcl_data_ring;struct dp_srng tcl_comp_ring; -struct idr txbuf_idr; -/* Protects txbuf_idr; num_txbuf changes with it and is read without */ +/* Buffers by the id their descriptor carries, and the ids not in use */ +struct sk_buff **bufs; +u32 *free_ids; +u32 num_free; +/* Protects bufs and free_ids */ spinlock_t tx_idr_lock; -/* MSDU ids in use, one per frame between ath11k_dp_tx() and its -* completion -*/ -atomic_t num_txbuf;/* Serializes wake_tx_queue operations for this ring */ spinlock_t wake_tx_lock;struct hal_wbm_release_ring *tx_status;
drivers/net/wireless/ath/ath11k/dp_tx.c +79 -25
159 lines not on this page · raw message
drivers/net/wireless/ath/ath11k/dp_tx.h +2 -0
@@ -22,6 +22,8 @@ int ath11k_dp_tx_htt_h2t_ver_req_msg(struct ath11k_base *ab);int ath11k_dp_tx (struct ath11k *ar,struct ath11k_vif *arvif,struct ath11k_sta *arsta,struct sk_buff *skb,int held_ring);bool ath11k_dp_tx_idr_has_room (struct dp_tx_ring *tx_ring); +int ath11k_dp_tx_bufs_init (struct dp_tx_ring *tx_ring); +void ath11k_dp_tx_bufs_free (struct dp_tx_ring *tx_ring);int ath11k_dp_tx_completion_handler (struct ath11k_base *ab,int ring_id,int budget);void ath11k_dp_tx_free_pending (struct ath11k_base *ab);
drivers/net/wireless/ath/ath11k/mac.c +12 -8
@@ -7364,15 +7364,20 @@ static int ath11k_mac_op_add_interface(struct ieee80211_hw *hw,return ret; } -static int ath11k_mac_vif_unref (int buf_id,void *skb,void *ctx) +static void ath11k_mac_vif_unref (struct dp_tx_ring *tx_ring, +struct ieee80211_vif *vif) { -struct ieee80211_vif *vif = ctx; -struct ath11k_skb_cb *skb_cb =ATH11K_SKB_CB (skb); +struct ath11k_skb_cb *skb_cb; +u32 id; -if (skb_cb->vif == vif) - skb_cb->vif =NULL ; +for (id =0 ; id <DP_TX_IDR_SIZE -1 ; id++) { +if (!tx_ring->bufs[id]) +continue ; -return 0 ; + skb_cb =ATH11K_SKB_CB (tx_ring->bufs[id]); +if (skb_cb->vif == vif) + skb_cb->vif =NULL ; + } } static void ath11k_mac_op_remove_interface(struct ieee80211_hw *hw,
@@ -7437,8 +7442,7 @@ static void ath11k_mac_op_remove_interface(struct ieee80211_hw *hw,for (i =0 ; i < ab->hw_params.hal_params->num_tx_rings; i++) {spin_lock_bh (&ab->dp.tx_ring[i].tx_idr_lock); -idr_for_each (&ab->dp.tx_ring[i].txbuf_idr, - ath11k_mac_vif_unref, vif); +ath11k_mac_vif_unref (&ab->dp.tx_ring[i], vif);spin_unlock_bh (&ab->dp.tx_ring[i].tx_idr_lock); }
Signature · 1 line
2.53.0
PATCH v2 5/9 wifi: ath11k: let the TCL segment TCP batches
In reply to Julius Bairaktarismac80211 can hand the driver a TCP batch as one frame with the segments described by gso_size. Sending each segment as its own frame costs an allocation, a mapping and a free per segment on the CPU.
The TCL segments a batch itself. The layout of the MSDU extension descriptor, with its TSO fields and six buffer pointers, is that of the HAL_TX_MSDU_EXTENSION_* field offsets in hal/wifi3.0/hal_tx_hw_defines.h of Qualcomm's open-source WLAN host driver on CodeLinaro. A data command of type EXT_DESC points at an MSDU extension descriptor that lists the headers of the batch and the payload of one segment in up to six buffers, and carries the segment's IP length, IP ID, TCP sequence number and flags, which the TCL writes into the headers; it fills in the checksums the data command enables. Queue every segment of a batch that way, with one mapping of the headers and one of each payload piece, and report the batch to mac80211 when the completion of its last segment arrives. Each segment holds a reference on the batch and its own buffer id, so the completion paths release a segment and return the batch only for the last one.
Every segment completes on its own: its status counts in the station statistics as that of a frame of its length, and goes into the status of the batch. The batch is reported to mac80211 as acked only if all its segments were acked, with the most tries of any segment, as mac80211 reads the tries as those of one frame at one rate and their sum over the segments would overstate them by the number of segments. The tries now come from the completion for every frame, where mac80211 got a constant 1 before.
The ring entries, ids and descriptors of all segments are taken before the first is queued. A batch the TCL cannot take (no free descriptor, more than five payload pieces in a segment, a frame that is not sent with Ethernet encap, a protocol other than TCP, an IPv6 header followed by extension headers, which the descriptor has no length for) is segmented in software with skb_gso_segment(); the frames share the airtime charge of the batch by leaving it on the last one. A frame with fragments but no GSO is sent from one extension descriptor as a batch of one segment without segmentation, with its linear part and up to five fragments as the buffers, and is made linear only if that does not fit; ARP, EAPOL and DHCP frames always stay linear. The transmit loop of a vif with the encap offload takes a frame only while a batch of 16 segments fits in the TCL ring, which is the most the interface offers. Once the firmware crashed, no frame takes this path and the ring is not updated, as for the TXQ push.
A dequeue run now asks ath11k_dp_tx_idr_has_room() for as many MSDU ids as it reserves TCL entries, since a batch the TCL cannot take whole is segmented in software with an id per segment.
A batch, a frame of a batch segmented in software, or a frame with fragments that is not sent goes back to mac80211 through ath11k_dp_tx_drop() with the station mac80211 passed, as a frame ath11k_dp_tx() refuses does, so the airtime charged for it is returned.
The frames are built as the vendor host driver of the same TCL (Qualcomm's open-source WLAN host driver on CodeLinaro) builds its TSO frames. The buffer of the headers ends on an 8 byte boundary: that driver moves the headers down into the head room by the excess, with the header offsets, and maps the payload where it was (qdf_nbuf_adj_tso_frag() in qdf/linux/src/qdf_nbuf.c, built with FIX_TXDMA_LIMITATION). Here that is done for every frame sent from an extension descriptor, a frame with fragments too, and the head is copied first only when it lacks the room or is shared. The descriptors fill each 4096 byte block of their coherent memory and none crosses into the next, as in that driver's pool of descriptor pages (dp_tx_ext_desc_pool_alloc_by_id() in dp/wifi3.0/dp_tx_desc.c). A batch enables the IP, UDP and TCP checksums in the data command, as dp_tx_hw_enqueue_li() in dp/wifi3.0/li/dp_li_tx.c does for a TSO frame. On IPQ8074, frames built without these rules are not delivered at all, while built with them TCP batches and scatter-gather frames went out routed and bridged, over IPv4 and IPv6 (observed on the device).
The debugfs SOC statistics count the batches and segments, the batches that were segmented in software and the frames sent as scatter-gather.
---
v2:
- A batch skb_gso_segment() cannot segment, a software segment ath11k_dp_tx() refuses, and a frame with fragments skb_linearize() cannot make linear go back through ath11k_dp_tx_drop() with the station mac80211 passed, instead of ieee80211_free_txskb(), which finds no station for an encap frame and kept its airtime charge. ath11k_dp_tx_gso() takes the ieee80211_sta for that.
- Rebased onto airtime queue limits v7: the skb control block keeps the station address of its patch 2 beside tso_try and tso_bad.
- The comment on the unlocked read in ath11k_dp_tx_idr_has_room() says that a stale count can also cost the segments of a batch split in software.
- Commit message: the paragraph that followed Tested-on moved above the trailers, and a paragraph on the dropped frames.
drivers/net/wireless/ath/ath11k/core.c | 1 + drivers/net/wireless/ath/ath11k/core.h | 14 + drivers/net/wireless/ath/ath11k/debugfs.c | 7 + drivers/net/wireless/ath/ath11k/dp.c | 10 +- drivers/net/wireless/ath/ath11k/dp.h | 37 +- drivers/net/wireless/ath/ath11k/dp_tx.c | 827 +++++++++++++++++++-- drivers/net/wireless/ath/ath11k/dp_tx.h | 15 +- drivers/net/wireless/ath/ath11k/hal_desc.h | 46 ++ drivers/net/wireless/ath/ath11k/hw.h | 1 + drivers/net/wireless/ath/ath11k/mac.c | 43 +- 10 files changed, 919 insertions(+), 82 deletions(-)
drivers/net/wireless/ath/ath11k/core.c +1 -0
@@ -120,6 +120,7 @@ static const struct ath11k_hw_params ath11k_hw_params[] = { .sram_dump = {}, .tcl_ring_retry = true, + .tx_tso = true, .tx_ring_size = DP_TCL_DATA_RING_SIZE, .smp2p_wow_exit = false, .support_dual_stations = false,
drivers/net/wireless/ath/ath11k/core.h +14 -0
@@ -124,6 +124,12 @@ struct ath11k_skb_cb {struct ath11k *ar;struct ieee80211_vif *vif;u8 sta_addr[ETH_ALEN ]; +/* +* Of a frame sent from an MSDU extension descriptor: the most tries +* of its segments so far, and how many were not acked +*/ +u8 tso_try; +u8 tso_bad; } __packed;struct ath11k_skb_rxcb {
@@ -910,6 +916,14 @@ struct ath11k_soc_dp_stats {u32 rxdma_error[HAL_REO_ENTR_RING_RXDMA_ECODE_MAX ];u32 reo_error[HAL_REO_DEST_RING_ERROR_CODE_MAX ];u32 hal_reo_error[DP_REO_DST_RING_MAX ]; +/* +* TCP batches the TCL segments, their segments, and batches that +* were segmented in software instead +*/ +atomic_t tx_tso_batch; +atomic_t tx_tso_seg; +atomic_t tx_tso_sw; +atomic_t tx_sg;struct ath11k_soc_dp_tx_err_stats tx_err;struct ath11k_dp_ring_bp_stats bp_stats; };
drivers/net/wireless/ath/ath11k/debugfs.c +7 -0
@@ -703,6 +703,13 @@ static ssize_t ath11k_debugfs_dump_soc_dp_stats(struct file *file, soc_stats->hal_reo_error[2 ], soc_stats->hal_reo_error[3]); + len +=scnprintf (buf + len, size - len, +"TCP batches segmented by the TCL: %d, their segments: %d, segmented in software: %d, frames with fragments sent as scatter-gather: %d\n" , +atomic_read (&soc_stats->tx_tso_batch), +atomic_read (&soc_stats->tx_tso_seg), +atomic_read (&soc_stats->tx_tso_sw), +atomic_read (&soc_stats->tx_sg)); + len +=scnprintf (buf + len, size - len,"\nSOC TX STATS:\n" ); len +=scnprintf (buf + len, size - len,"\nTCL Ring Full Failures:\n" );
drivers/net/wireless/ath/ath11k/dp.c +6 -4
@@ -1022,12 +1022,14 @@ static void ath11k_dp_tx_pending_cleanup(struct ath11k_base *ab,u32 id;for (id =0 ; tx_ring->bufs && id <DP_TX_IDR_SIZE -1 ; id++) { - msdu = tx_ring->bufs[id]; +bool more; + + msdu =ath11k_dp_tx_buf_put_id (ab, tx_ring, id, &more,NULL );if (!msdu)continue ;dma_unmap_single (ab->dev,ATH11K_SKB_CB (msdu)->paddr, - msdu->len,DMA_TO_DEVICE ); +skb_headlen (msdu),DMA_TO_DEVICE );dev_kfree_skb_any (msdu); } }
@@ -1047,8 +1049,8 @@ void ath11k_dp_free(struct ath11k_base *ab)for (i =0 ; i < ab->hw_params.hal_params->num_tx_rings; i++) {spin_lock_bh (&dp->tx_ring[i].tx_idr_lock);ath11k_dp_tx_pending_cleanup (ab, &dp->tx_ring[i]); -ath11k_dp_tx_bufs_free (&dp->tx_ring[i]);spin_unlock_bh (&dp->tx_ring[i].tx_idr_lock); +ath11k_dp_tx_bufs_free (ab, &dp->tx_ring[i]);kfree (dp->tx_ring[i].tx_status); dp->tx_ring[i].tx_status =NULL ; }
@@ -1096,7 +1098,7 @@ int ath11k_dp_alloc(struct ath11k_base *ab) size =sizeof (struct hal_wbm_release_ring ) *DP_TX_COMP_RING_SIZE ;for (i =0 ; i < ab->hw_params.hal_params->num_tx_rings; i++) { - ret =ath11k_dp_tx_bufs_init (&dp->tx_ring[i]); + ret =ath11k_dp_tx_bufs_init (ab, &dp->tx_ring[i]);if (ret) goto fail_cmn_srng_cleanup;spin_lock_init (&dp->tx_ring[i].tx_idr_lock);
drivers/net/wireless/ath/ath11k/dp.h +36 -1
@@ -80,6 +80,29 @@ struct dp_rxdma_ring {#define ATH11K_TX_COMPL_NEXT (x) (((x) + 1) % DP_TX_COMP_RING_SIZE) +/* +* The most segments of a TCP batch the TCL takes whole, and the payload +* pieces of one segment past the headers +*/ +#define ATH11K_DP_TX_TSO_MAX_SEGS 16 +#define ATH11K_DP_TX_NO_EXT 0xffff + +struct ath11k_dp_tx_ext_map { +u32 dma[HAL_TX_MSDU_EXT_NUM_BUFS -1 ]; +u16 len[HAL_TX_MSDU_EXT_NUM_BUFS -1 ]; +/* the frame this descriptor makes, headers included */ +u16 seg_len; +u8 num; +}; + +/* What a buffer id held when it was released */ +struct ath11k_dp_tx_seg { +/* the frame, or the batch the segment belongs to */ +struct sk_buff *skb; +/* the length of the segment, or 0 for a frame sent as one buffer */ +u16 len; +}; +struct dp_tx_ring {u8 tcl_data_ring_id;struct dp_srng tcl_data_ring;
@@ -88,7 +111,18 @@ struct dp_tx_ring {struct sk_buff **bufs;u32 *free_ids;u32 num_free; -/* Protects bufs and free_ids */ +/* +* MSDU extension descriptors for TSO segments, placed by +* ath11k_dp_tx_ext_off(), the payload mappings of each, the +* descriptor each buffer id uses, and the ones not in use +*/ +struct hal_tx_msdu_ext *ext; +dma_addr_t ext_paddr; +struct ath11k_dp_tx_ext_map *ext_map; +u16 *ext_slot; +u16 *ext_free; +u32 ext_num_free; +/* Protects bufs, free_ids, ext_slot and ext_free */ spinlock_t tx_idr_lock;/* Serializes wake_tx_queue operations for this ring */ spinlock_t wake_tx_lock;
@@ -212,6 +246,7 @@ struct ath11k_pdev_dp {#define DP_TCL_DATA_RING_SIZE_WCN6750 2048#define DP_TX_COMP_RING_SIZE 32768#define DP_TX_IDR_SIZE DP_TX_COMP_RING_SIZE +#define DP_TX_EXT_DESC_NUM 2048#define DP_TCL_CMD_RING_SIZE 32#define DP_TCL_STATUS_RING_SIZE 32#define DP_REO_DST_RING_MAX 4
drivers/net/wireless/ath/ath11k/dp_tx.c +758 -69
1,078 lines not on this page · raw message
drivers/net/wireless/ath/ath11k/dp_tx.h +12 -3
@@ -21,9 +21,18 @@ void ath11k_dp_tx_update_txcompl(struct ath11k *ar, struct hal_tx_status *ts);int ath11k_dp_tx_htt_h2t_ver_req_msg (struct ath11k_base *ab);int ath11k_dp_tx (struct ath11k *ar,struct ath11k_vif *arvif,struct ath11k_sta *arsta,struct sk_buff *skb,int held_ring); -bool ath11k_dp_tx_idr_has_room (struct dp_tx_ring *tx_ring); -int ath11k_dp_tx_bufs_init (struct dp_tx_ring *tx_ring); -void ath11k_dp_tx_bufs_free (struct dp_tx_ring *tx_ring); +bool ath11k_dp_tx_idr_has_room (struct dp_tx_ring *tx_ring,int n); +int ath11k_dp_tx_gso (struct ath11k *ar,struct ath11k_vif *arvif, +struct ieee80211_sta *sta,struct sk_buff *skb, +int held_ring); +int ath11k_dp_tx_sg (struct ath11k *ar,struct ath11k_vif *arvif, +struct sk_buff *skb,int held_ring); +int ath11k_dp_tx_bufs_init (struct ath11k_base *ab,struct dp_tx_ring *tx_ring); +void ath11k_dp_tx_bufs_free (struct ath11k_base *ab,struct dp_tx_ring *tx_ring); +struct sk_buff *ath11k_dp_tx_buf_put_id (struct ath11k_base *ab, +struct dp_tx_ring *tx_ring,u32 id, +bool *more, +struct ath11k_dp_tx_seg *seg);int ath11k_dp_tx_completion_handler (struct ath11k_base *ab,int ring_id,int budget);void ath11k_dp_tx_free_pending (struct ath11k_base *ab);
drivers/net/wireless/ath/ath11k/hal_desc.h +46 -0
52 lines not on this page · raw message
drivers/net/wireless/ath/ath11k/hw.h +1 -0
@@ -223,6 +223,7 @@ struct ath11k_hw_params { } sram_dump;bool tcl_ring_retry; +bool tx_tso;u32 tx_ring_size;bool smp2p_wow_exit;bool support_fw_mac_sequence;
drivers/net/wireless/ath/ath11k/mac.c +38 -5
84 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v2 6/9 wifi: ath11k: offer scatter-gather and TSO with Ethernet encap
In reply to Julius BairaktarisTell mac80211 that the frames its netdevs send with Ethernet encap may be TCP batches with fragments (NETIF_F_SG, TSO and TSO6, up to 16 segments), on a device whose TCL takes them (IPQ8074). mac80211 segments them in software on every other path. As ath11k enables airtime queue limits, mac80211 also segments a batch whose airtime estimate is more than it can charge to one frame, or whose station has no known rate yet. A batch that is dropped returns its airtime charge to its station through ath11k_dp_tx_drop(), as the other dropped encap frames do.
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.12-01460-QCAHKSWPL_SILICONZ-1
---
v2: commit message: mac80211 v2 sets the encap features on every netdev and takes them away from frames sent without encap, so the message no longer names netdev types; it segments a batch for AQL because airtime queue limits v7 enables AQL in ath11k, and a dropped batch returns its charge through ath11k_dp_tx_drop().
drivers/net/wireless/ath/ath11k/dp_tx.c | 6 ++++++ drivers/net/wireless/ath/ath11k/dp_tx.h | 1 + drivers/net/wireless/ath/ath11k/mac.c | 12 ++++++++++++ 3 files changed, 19 insertions(+)
drivers/net/wireless/ath/ath11k/dp_tx.c +6 -0
@@ -15,6 +15,12 @@#include "peer.h" #include "mac.h" +/* Whether the netdevs of this device offer TSO and scatter-gather */ +bool ath11k_dp_tx_tso_wanted (struct ath11k_base *ab) +{ +return ab->hw_params.tx_tso; +} +static enum hal_tcl_encap_type ath11k_dp_tx_get_encap_type (struct ath11k_vif *arvif,struct sk_buff *skb) {
drivers/net/wireless/ath/ath11k/dp_tx.h +1 -0
@@ -22,6 +22,7 @@ int ath11k_dp_tx_htt_h2t_ver_req_msg(struct ath11k_base *ab);int ath11k_dp_tx (struct ath11k *ar,struct ath11k_vif *arvif,struct ath11k_sta *arsta,struct sk_buff *skb,int held_ring);bool ath11k_dp_tx_idr_has_room (struct dp_tx_ring *tx_ring,int n); +bool ath11k_dp_tx_tso_wanted (struct ath11k_base *ab);int ath11k_dp_tx_gso (struct ath11k *ar,struct ath11k_vif *arvif,struct ieee80211_sta *sta,struct sk_buff *skb,int held_ring);
drivers/net/wireless/ath/ath11k/mac.c +12 -0
@@ -10731,6 +10731,18 @@ static int __ath11k_mac_register(struct ath11k *ar)if (ath11k_frame_mode ==ATH11K_HW_TXRX_ETHERNET ) {ieee80211_hw_set (ar->hw,SUPPORTS_TX_ENCAP_OFFLOAD );ieee80211_hw_set (ar->hw,SUPPORTS_RX_DECAP_OFFLOAD ); + +/* +* The TCL takes a TCP batch whole, with its payload in +* fragments, when the frame goes out with Ethernet encap. +*/ +if (ath11k_dp_tx_tso_wanted (ab)) { + ar->hw->encap_netdev_features =NETIF_F_SG | +NETIF_F_TSO | +NETIF_F_TSO6 ; + ar->hw->encap_gso_max_segs = +ATH11K_DP_TX_TSO_MAX_SEGS ; + } }if (cap->nss_ratio_enabled)
Signature · 1 line
2.53.0
PATCH v2 7/9 wifi: ath11k: take TCP batches as long as GRO builds them
In reply to Julius BairaktarisThe netdevs offer ATH11K_DP_TX_TSO_MAX_SEGS (16) as their gso_max_segs, but a bridge or router hands them what GRO built on the ingress port: up to 64 KB (the default gro_max_size), and for a frame list up to 64 segments, where tcp_gro_receive() ends it. At an MSS of 1448 that is 45 segments. gso_features_check() clears the GSO features of every frame with more segments than gso_max_segs, so validate_xmit_skb() cut each such batch into one frame per segment before mac80211, and forwarded TCP downlink reached the TCL one segment at a time under load, when GRO batches are longest.
The 16 is no limit of the TCL: each segment of a batch is a ring entry and an MSDU extension descriptor of its own, and a ring has 2048 descriptors. Raise the bound to 64. The transmit loop then takes a frame while 64 of the 512 TCL ring entries are free, and a batch keeps 256 bytes of ids and descriptor slots on the stack. A batch whose airtime does not fit the estimate is still cut by mac80211 before it is queued.
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.12-01460-QCAHKSWPL_SILICONZ-1
---
v2: no change.
drivers/net/wireless/ath/ath11k/dp.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath11k/dp.h +6 -3
@@ -81,10 +81,13 @@ struct dp_rxdma_ring {#define ATH11K_TX_COMPL_NEXT (x) (((x) + 1) % DP_TX_COMP_RING_SIZE)/* -* The most segments of a TCP batch the TCL takes whole, and the payload -* pieces of one segment past the headers +* The most segments of a TCP batch the TCL takes whole: each segment is a +* ring entry and an extension descriptor of its own, so the bound is what the +* stack builds, the 64 segments at which TCP GRO ends a frame list aggregate +* and more than the 64 KB of any other GRO aggregate hold at an MSS of 1024 +* or more. */ -#define ATH11K_DP_TX_TSO_MAX_SEGS 16 +#define ATH11K_DP_TX_TSO_MAX_SEGS 64#define ATH11K_DP_TX_NO_EXT 0xffffstruct ath11k_dp_tx_ext_map {
Signature · 1 line
2.53.0
PATCH v2 8/9 wifi: ath11k: give an extension descriptor the number of its buffer id
In reply to Julius BairaktarisA TSO segment takes a buffer id from the id stack and an MSDU extension descriptor from a second stack, and a table indexed by id records which descriptor the id took. Its completion reads that table, then the payload map of the descriptor, a 36 byte entry that crosses into a second cache line for half of the descriptors. All of these were written when the batch was queued and are cold when its completions come: in a profile of bridged downlink at 900 Mbit/s (IPQ8074, one run), the instruction after the load of the segment length from the map in ath11k_dp_tx_buf_put_id() takes 1.05 % of all samples, the instructions around the load of the payload addresses 0.42 % and the comparison of the table entry 0.19 %.
Reserve the ids below DP_TX_EXT_DESC_NUM for the extension descriptors, id n for descriptor n, handed out from the descriptor stack, and the others for frames sent from one buffer. The id then names its descriptor: the table goes, together with its write at queue time and its read and reset at completion. End the payload pieces of a map at the first of length 0, which no mapped piece has, instead of a count, so the map is 32 bytes and, aligned to that, never crosses a cache line. Frames sent from one buffer keep 30719 ids, where they shared 32767 with the segments before.
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.12-01460-QCAHKSWPL_SILICONZ-1
---
v2: no change.
drivers/net/wireless/ath/ath11k/dp.h | 21 +++--- drivers/net/wireless/ath/ath11k/dp_tx.c | 95 ++++++++++++------------- 2 files changed, 60 insertions(+), 56 deletions(-)
drivers/net/wireless/ath/ath11k/dp.h +13 -8
@@ -88,15 +88,18 @@ struct dp_rxdma_ring {* or more. */ #define ATH11K_DP_TX_TSO_MAX_SEGS 64 -#define ATH11K_DP_TX_NO_EXT 0xffff +/* +* The payload mappings of an extension descriptor, which end at the first +* piece of length 0 or after the last one, and the frame the descriptor +* makes, headers included. 32 bytes, so that the map of a completion is one +* cache line. +*/ struct ath11k_dp_tx_ext_map {u32 dma[HAL_TX_MSDU_EXT_NUM_BUFS -1 ];u16 len[HAL_TX_MSDU_EXT_NUM_BUFS -1 ]; -/* the frame this descriptor makes, headers included */ u16 seg_len; -u8 num; -}; +}__aligned(32) ;/* What a buffer id held when it was released */ struct ath11k_dp_tx_seg {
@@ -116,16 +119,18 @@ struct dp_tx_ring {u32 num_free;/* * MSDU extension descriptors for TSO segments, placed by -* ath11k_dp_tx_ext_off(), the payload mappings of each, the -* descriptor each buffer id uses, and the ones not in use +* ath11k_dp_tx_ext_off(), and the payload mappings of each. The +* buffer ids below ext_ids are those of the extension descriptor of +* the same number and are handed out from ext_free, the others from +* free_ids. */ struct hal_tx_msdu_ext *ext;dma_addr_t ext_paddr;struct ath11k_dp_tx_ext_map *ext_map; -u16 *ext_slot;u16 *ext_free;u32 ext_num_free; -/* Protects bufs, free_ids, ext_slot and ext_free */ +u32 ext_ids; +/* Protects bufs, free_ids and ext_free */ spinlock_t tx_idr_lock;/* Serializes wake_tx_queue operations for this ring */ spinlock_t wake_tx_lock;
drivers/net/wireless/ath/ath11k/dp_tx.c +47 -48
226 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v2 9/9 wifi: ath11k: count the segments of a TX batch without an atomic
In reply to Julius BairaktarisA batch the TCL segments from extension descriptors holds one reference of its skb per segment, taken with refcount_add() when it is sent, and each segment's completion drops one with skb_unref() in ath11k_dp_tx_buf_put_id(). That is an atomic on the skb's reference count line, which nothing else of the completion reads: in a profile of routed downlink at 900 Mbit/s (IPQ8074, one run) the instruction after it takes 0.44 % of all samples.
Count the outstanding segments in the frame's control block instead, whose line the completion of the segment reads anyway. The send sets the count before the first descriptor is on the ring, with the frame held only by the driver (its reference count is 1 there), and every release of an id of the batch decrements it: the completion handler and the firmware release paths under the id lock, and the teardown, which runs alone. The send's failure path gives its ids back before any count exists, as it gave them back before any reference was taken. The release that takes the count to zero returns the frame, as skb_unref() did for the last reference, so the frames of a batch complete and are freed in the same order as before.
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.12-01460-QCAHKSWPL_SILICONZ-1
---
v2: no change.
drivers/net/wireless/ath/ath11k/core.h | 5 +++++ drivers/net/wireless/ath/ath11k/dp_tx.c | 17 +++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-)
drivers/net/wireless/ath/ath11k/core.h +5 -0
@@ -130,6 +130,11 @@ struct ath11k_skb_cb {*/ u8 tso_try;u8 tso_bad; +/* +* Of a batch whose segments are counted here instead of in the skb's +* reference count: the segments whose completion is still to come +*/ +u8 tso_left; } __packed;struct ath11k_skb_rxcb {
drivers/net/wireless/ath/ath11k/dp_tx.c +11 -6
@@ -245,7 +245,7 @@ struct sk_buff *ath11k_dp_tx_buf_put_id(struct ath11k_base *ab,ath11k_dp_tx_tso_unmap (ab->dev, map); tx_ring->ext_free[tx_ring->ext_num_free++] = id; -if (!skb_unref (skb)) { +if (--ATH11K_SKB_CB (skb)->tso_left) { *more = true;return NULL ; }
@@ -701,9 +701,9 @@ static void ath11k_dp_tx_ext_unpad(struct sk_buff *skb, unsigned int len,* its segments, and the payload in the fragments. A TCP batch has one * descriptor for each of its segments, which also gives the segment's IP * length, IP ID, TCP sequence number and flags for the TCL to write into the -* headers; every segment holds a reference on the batch, and the completion -* of the last one reports the batch to mac80211. A frame with fragments has -* one descriptor, and is a batch of one segment. +* headers; every segment holds a share of the batch's segment count, and the +* completion of the last one reports the batch to mac80211. A frame with +* fragments has one descriptor, and is a batch of one segment. * * Returns -EAGAIN, with the frame untouched, for one the TCL cannot take * whole. The ids, extension descriptors and ring entries of all segments are
@@ -892,7 +892,12 @@ static int ath11k_dp_tx_ext(struct ath11k *ar, struct ath11k_vif *arvif, skb_cb->ar = ar; skb_cb->tso_try =0 ; skb_cb->tso_bad =0 ; -refcount_add (n -1 , &skb->users); +/* +* Each segment's completion gives back one share of the frame, +* counted in the control block under the id lock every release of an +* id holds. +*/ + skb_cb->tso_left = n; ti.encap_type =HAL_TCL_ENCAP_TYPE_ETHERNET ; ti.meta_data_flags = arvif->tcl_metadata;
@@ -961,7 +966,7 @@ static int ath11k_dp_tx_ext(struct ath11k *ar, struct ath11k_vif *arvif,ath11k_dp_tx_ext_unpad (skb, hdr_len, pad);spin_lock_bh (&tx_ring->tx_idr_lock);for (j = n; j--;) { -/* no reference was taken yet: release the id only */ +/* no segment was counted yet: release the id only */ tx_ring->bufs[ids[j]] =NULL ; tx_ring->ext_free[tx_ring->ext_num_free++] = ids[j]; }
Signature · 1 line
2.53.0