mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH wireless-next 0/4] wifi: mac80211: TSO and SG for encap offload, and the TID of 802.3 RX frames
@ 2026-11-22 13:42 Julius Bairaktaris
  2026-11-22 13:42 ` [PATCH wireless-next 1/4] wifi: mac80211: advertise TSO and SG for encap offloaded frames Julius Bairaktaris
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Julius Bairaktaris @ 2026-11-22 13:42 UTC (permalink / raw)
  To: Johannes Berg
  Cc: linux-wireless, Jeff Johnson, Felix Fietkau,
	Toke Høiland-Jørgensen, ath11k, ath12k, linux-kernel

Patch 1 lets a driver offer TSO and scatter-gather on the netdevs that
send with 802.3 encap offload, without offering them on the 802.11
path. ath11k uses it on IPQ8074 in a series for ath-next that lets the
TCL segment TCP batches, which depends on this patch.

Patches 2 to 4 count frames received in 802.3 format on their TID: the
802.3 receive path counted all of them on TID 0. Patch 2 adds the field,
3 and 4 fill it in ath11k and ath12k.

Patches 1 to 3 ran on a Xiaomi AX3600 (IPQ8074 hw2.0, firmware
WLAN.HK.2.12-01460) as part of OpenWrt's 6.18 kernel with wireless
backports 7.2, as an AP with Ethernet encap and decap.

I used Claude (Anthropic) to help write these patches.
I have reviewed the commit messages and the cover letter myself and
edited them where needed.

Julius Bairaktaris (4):
  wifi: mac80211: advertise TSO and SG for encap offloaded frames
  wifi: mac80211: take the TID of an 802.3 frame from the driver
  wifi: ath11k: pass the TID of a received 802.3 frame to mac80211
  wifi: ath12k: pass the TID of a received 802.3 frame to mac80211

 drivers/net/wireless/ath/ath11k/dp_rx.c |  1 +
 drivers/net/wireless/ath/ath12k/dp_rx.c |  1 +
 include/net/mac80211.h                  | 19 +++++++++
 net/mac80211/iface.c                    | 14 +++++++
 net/mac80211/main.c                     |  3 +-
 net/mac80211/rx.c                       |  3 ++
 net/mac80211/tx.c                       | 53 ++++++++++++++++++++++++-
 7 files changed, 91 insertions(+), 3 deletions(-)


base-commit: e1dd8486807c1acf9551250b7f81e116a21e6ad6
-- 
2.53.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH wireless-next 1/4] wifi: mac80211: advertise TSO and SG for encap offloaded frames
  2026-11-22 13:42 [PATCH wireless-next 0/4] wifi: mac80211: TSO and SG for encap offload, and the TID of 802.3 RX frames Julius Bairaktaris
@ 2026-11-22 13:42 ` Julius Bairaktaris
  2026-11-22 13:42 ` [PATCH wireless-next 2/4] wifi: mac80211: take the TID of an 802.3 frame from the driver Julius Bairaktaris
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Julius Bairaktaris @ 2026-11-22 13:42 UTC (permalink / raw)
  To: Johannes Berg
  Cc: linux-wireless, Jeff Johnson, Felix Fietkau,
	Toke Høiland-Jørgensen, ath11k, ath12k, linux-kernel

A driver whose hardware segments TCP frames and takes frames with
fragments on its 802.3 encap path cannot say so. hw->netdev_features
applies to every netdev of the hw, so a feature set there also reaches
the frames that go out through the 802.11 path.

Add hw->encap_netdev_features and hw->encap_gso_max_segs. mac80211 sets
the features on the AP, AP_VLAN and station netdevs when the hw supports
encap offload, and ieee80211_8023_xmit() passes them to
ieee80211_tx_skb_fixup(), so a GSO frame reaches the driver whole. The
802.11 path keeps using the features of the vif, which do not include
them, and segments such a frame in software as before.

AQL charges a frame by tx_time_est, which ieee80211_info_set_tx_time_est()
caps at 4095 us. A whole GSO frame to a slow station can take longer and
would be charged less than its airtime. Segment such a frame in software
instead.

The tx statistics count a TCP GSO frame as gso_segs packets, with the
headers of every segment in its length.

Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
---
 include/net/mac80211.h | 15 ++++++++++++
 net/mac80211/iface.c   | 14 +++++++++++
 net/mac80211/main.c    |  3 ++-
 net/mac80211/tx.c      | 53 ++++++++++++++++++++++++++++++++++++++++--
 4 files changed, 82 insertions(+), 3 deletions(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index f768ef9184eb..8eac4d50d06c 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -3271,6 +3271,19 @@ enum ieee80211_hw_flags {
  * @netdev_features: netdev features to be set in each netdev created
  *	from this HW. Note that not all features are usable with mac80211,
  *	other features will be rejected during HW registration.
+ * @encap_netdev_features: netdev features, in addition to @netdev_features,
+ *	set in each AP, AP VLAN and station netdev created from this HW, for
+ *	the frames that are sent with 802.3 encapsulation offload (see
+ *	%IEEE80211_OFFLOAD_ENCAP_ENABLED). A driver sets scatter-gather and
+ *	segmentation offload here when the hardware takes such frames whole.
+ *	mac80211 hands a driver a frame with these features only with
+ *	%IEEE80211_TX_CTL_HW_80211_ENCAP, and segments or linearizes it in
+ *	software on every other path, and for a station when the airtime
+ *	estimate of the whole frame is more than AQL can account to one frame.
+ *	Such a frame starts with its 802.3 header; a GSO frame has at most
+ *	@encap_gso_max_segs segments.
+ * @encap_gso_max_segs: the most segments of a GSO frame the driver takes
+ *	whole, when @encap_netdev_features has a segmentation offload.
  *
  * @uapsd_queues: This bitmap is included in (re)association frame to indicate
  *	for each access category if it is uAPSD trigger-enabled and delivery-
@@ -3330,6 +3343,8 @@ struct ieee80211_hw {
 		s16 accuracy;
 	} radiotap_timestamp;
 	netdev_features_t netdev_features;
+	netdev_features_t encap_netdev_features;
+	u16 encap_gso_max_segs;
 	u8 uapsd_queues;
 	u8 uapsd_max_sp_len;
 	u8 max_nan_de_entries;
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index b6ed6541bc42..c3869dbfdab7 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -2407,6 +2407,20 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,
 			sdata->u.mgd.use_4addr = params->use_4addr;
 
 		ndev->features |= local->hw.netdev_features;
+		/* Only the netdevs that can use the encap offload offer its
+		 * features: every other path segments in software, with the
+		 * features of the vif.
+		 */
+		if (ieee80211_hw_check(&local->hw, SUPPORTS_TX_ENCAP_OFFLOAD) &&
+		    local->hw.encap_netdev_features &&
+		    (type == NL80211_IFTYPE_AP ||
+		     type == NL80211_IFTYPE_AP_VLAN ||
+		     type == NL80211_IFTYPE_STATION)) {
+			ndev->features |= local->hw.encap_netdev_features;
+			if (local->hw.encap_gso_max_segs)
+				netif_set_tso_max_segs(ndev,
+						       local->hw.encap_gso_max_segs);
+		}
 		ndev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
 		ndev->hw_features |= ndev->features &
 					MAC80211_SUPPORTED_FEATURES_TX;
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index e03c2dbf4fb8..2a49fe7ed367 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -1243,7 +1243,8 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
 	}
 
 	/* Only HW csum features are currently compatible with mac80211 */
-	if (WARN_ON(hw->netdev_features & ~MAC80211_SUPPORTED_FEATURES))
+	if (WARN_ON((hw->netdev_features | hw->encap_netdev_features) &
+		    ~MAC80211_SUPPORTED_FEATURES))
 		return -EINVAL;
 
 	if (hw->max_report_rates == 0)
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index cb9ecac25a9c..faf3e6b9e4f8 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -14,6 +14,7 @@
 #include <linux/slab.h>
 #include <linux/skbuff.h>
 #include <linux/if_vlan.h>
+#include <linux/tcp.h>
 #include <linux/etherdevice.h>
 #include <linux/bitmap.h>
 #include <linux/rcupdate.h>
@@ -4797,6 +4798,35 @@ static bool ieee80211_tx_8023(struct ieee80211_sub_if_data *sdata,
 	return ret;
 }
 
+/* A frame's airtime estimate has 10 bits, in units of 4 us. A GSO frame whose
+ * estimate would not fit is charged less than it takes and stays in the AQL
+ * limits for as long as it takes, so it is segmented in software instead.
+ */
+#define IEEE80211_TX_GSO_AIRTIME_MAX	4092
+
+static bool ieee80211_8023_gso_fits(struct ieee80211_sub_if_data *sdata,
+				    struct sta_info *sta, struct sk_buff *skb,
+				    u16 queue)
+{
+	struct ieee80211_local *local = sdata->local;
+	u32 airtime;
+
+	if (!sta || !wiphy_ext_feature_isset(local->hw.wiphy,
+					     NL80211_EXT_FEATURE_AQL))
+		return true;
+
+	/* AQL charges the vif of the AP, as ieee80211_tx_dequeue() does */
+	if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
+		sdata = container_of(sdata->bss, struct ieee80211_sub_if_data,
+				     u.ap);
+
+	airtime = ieee80211_calc_expected_tx_airtime(&local->hw, &sdata->vif,
+						     &sta->sta, skb->len,
+						     queue != IEEE80211_AC_VO);
+
+	return airtime <= IEEE80211_TX_GSO_AIRTIME_MAX;
+}
+
 static void ieee80211_8023_xmit(struct ieee80211_sub_if_data *sdata,
 				struct net_device *dev, struct sta_info *sta,
 				struct ieee80211_key *key, struct sk_buff *skb)
@@ -4807,6 +4837,7 @@ static void ieee80211_8023_xmit(struct ieee80211_sub_if_data *sdata,
 	struct tid_ampdu_tx *tid_tx = NULL;
 	struct sk_buff *seg, *next;
 	unsigned int skbs = 0, len = 0;
+	netdev_features_t features;
 	u16 queue;
 	u8 tid;
 
@@ -4835,7 +4866,12 @@ static void ieee80211_8023_xmit(struct ieee80211_sub_if_data *sdata,
 			tid_tx->last_tx = jiffies;
 	}
 
-	skb = ieee80211_tx_skb_fixup(skb, ieee80211_sdata_netdev_features(sdata));
+	features = ieee80211_sdata_netdev_features(sdata) |
+		   local->hw.encap_netdev_features;
+	if (skb_is_gso(skb) && !ieee80211_8023_gso_fits(sdata, sta, skb, queue))
+		features &= ~(NETIF_F_ALL_TSO | NETIF_F_SG);
+
+	skb = ieee80211_tx_skb_fixup(skb, features);
 	if (!skb)
 		return;
 
@@ -4865,8 +4901,21 @@ static void ieee80211_8023_xmit(struct ieee80211_sub_if_data *sdata,
 		info->control.hw_key = &key->conf;
 
 	skb_list_walk_safe(skb, seg, next) {
-		skbs++;
+		unsigned int segs = 1;
+
 		len += seg->len;
+		/* a GSO frame is one frame of the queues and of the airtime
+		 * estimate, and as many packets of the counters as it has
+		 * segments
+		 */
+		if (skb_is_gso(seg) &&
+		    (skb_shinfo(seg)->gso_type &
+		     (SKB_GSO_TCPV4 | SKB_GSO_TCPV6))) {
+			segs = max_t(unsigned int, skb_shinfo(seg)->gso_segs, 1);
+			len += (segs - 1) * (skb_transport_offset(seg) +
+					     tcp_hdrlen(seg));
+		}
+		skbs += segs;
 		if (seg != skb)
 			memcpy(IEEE80211_SKB_CB(seg), info, sizeof(*info));
 	}
-- 
2.53.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH wireless-next 2/4] wifi: mac80211: take the TID of an 802.3 frame from the driver
  2026-11-22 13:42 [PATCH wireless-next 0/4] wifi: mac80211: TSO and SG for encap offload, and the TID of 802.3 RX frames Julius Bairaktaris
  2026-11-22 13:42 ` [PATCH wireless-next 1/4] wifi: mac80211: advertise TSO and SG for encap offloaded frames Julius Bairaktaris
@ 2026-11-22 13:42 ` Julius Bairaktaris
  2026-11-22 13:42 ` [PATCH wireless-next 3/4] wifi: ath11k: pass the TID of a received 802.3 frame to mac80211 Julius Bairaktaris
  2026-11-22 13:42 ` [PATCH wireless-next 4/4] wifi: ath12k: " Julius Bairaktaris
  3 siblings, 0 replies; 5+ messages in thread
From: Julius Bairaktaris @ 2026-11-22 13:42 UTC (permalink / raw)
  To: Johannes Berg
  Cc: linux-wireless, Jeff Johnson, Felix Fietkau,
	Toke Høiland-Jørgensen, ath11k, ath12k, linux-kernel

__ieee80211_rx_handle_8023() clears struct ieee80211_rx_data and never
sets seqno_idx, so ieee80211_rx_8023() counts every frame received with
RX_FLAG_8023 in rx_stats.msdu[0], whatever its TID. The native path
takes the TID from the QoS header, which an 802.3 frame no longer has.

Add a tid field to struct ieee80211_rx_status for the driver to fill,
and use it as seqno_idx on the 802.3 path. A driver that does not set it
leaves it 0, which counts the frame on TID 0 as before.

Fixes: 80a915ec4427 ("mac80211: add rx decapsulation offload support")
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
---
 include/net/mac80211.h | 4 ++++
 net/mac80211/rx.c      | 3 +++
 2 files changed, 7 insertions(+)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 8eac4d50d06c..d601070810fb 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -1770,6 +1770,9 @@ enum mac80211_rx_encoding {
  * @ampdu_reference: A-MPDU reference number, must be a different value for
  *	each A-MPDU but the same for each subframe within one A-MPDU
  * @zero_length_psdu_type: radiotap type of the 0-length PSDU
+ * @tid: the TID of a frame received in 802.3 format (%RX_FLAG_8023), or
+ *	%IEEE80211_NUM_TIDS if it has none; counts the frame in the per-TID
+ *	statistics of its station. Not read for other frames.
  * @link_id: id of the link used to receive the packet. Set and used by
  *	mac80211 internally, it uses @freq set by the driver to identify the
  *	correct link per vif. Set to %IEEE80211_LINK_UNSPECIFIED for non-MLD
@@ -1813,6 +1816,7 @@ struct ieee80211_rx_status {
 	u8 chains;
 	s8 chain_signal[IEEE80211_MAX_CHAINS];
 	u8 zero_length_psdu_type;
+	u8 tid;
 	u8 link_id:4;
 };
 
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index a2356cd17691..9fabc9b5a976 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -5303,6 +5303,7 @@ static void __ieee80211_rx_handle_8023(struct ieee80211_hw *hw,
 				       struct sk_buff *skb,
 				       struct list_head *list)
 {
+	struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
 	struct ieee80211_local *local = hw_to_local(hw);
 	struct ieee80211_fast_rx *fast_rx;
 	struct ieee80211_rx_data rx;
@@ -5313,6 +5314,8 @@ static void __ieee80211_rx_handle_8023(struct ieee80211_hw *hw,
 	rx.skb = skb;
 	rx.local = local;
 	rx.list = list;
+	/* the MSDU count of the station is kept per TID */
+	rx.seqno_idx = min_t(u8, status->tid, IEEE80211_NUM_TIDS);
 
 	I802_DEBUG_INC(local->dot11ReceivedFragmentCount);
 
-- 
2.53.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH wireless-next 3/4] wifi: ath11k: pass the TID of a received 802.3 frame to mac80211
  2026-11-22 13:42 [PATCH wireless-next 0/4] wifi: mac80211: TSO and SG for encap offload, and the TID of 802.3 RX frames Julius Bairaktaris
  2026-11-22 13:42 ` [PATCH wireless-next 1/4] wifi: mac80211: advertise TSO and SG for encap offloaded frames Julius Bairaktaris
  2026-11-22 13:42 ` [PATCH wireless-next 2/4] wifi: mac80211: take the TID of an 802.3 frame from the driver Julius Bairaktaris
@ 2026-11-22 13:42 ` Julius Bairaktaris
  2026-11-22 13:42 ` [PATCH wireless-next 4/4] wifi: ath12k: " Julius Bairaktaris
  3 siblings, 0 replies; 5+ messages in thread
From: Julius Bairaktaris @ 2026-11-22 13:42 UTC (permalink / raw)
  To: Johannes Berg
  Cc: linux-wireless, Jeff Johnson, Felix Fietkau,
	Toke Høiland-Jørgensen, ath11k, ath12k, linux-kernel

ath11k_dp_rx_deliver_msdu() delivers frames with Ethernet decap as
RX_FLAG_8023, and mac80211 counted all of them on TID 0. Pass the TID
the driver already took from the REO or MPDU start descriptor into
rxcb->tid.

Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.12-01460-QCAHKSWPL_SILICONZ-1

Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
---
 drivers/net/wireless/ath/ath11k/dp_rx.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/ath/ath11k/dp_rx.c b/drivers/net/wireless/ath/ath11k/dp_rx.c
index 6d95f7b343a5..7235399c5b39 100644
--- a/drivers/net/wireless/ath/ath11k/dp_rx.c
+++ b/drivers/net/wireless/ath/ath11k/dp_rx.c
@@ -2493,6 +2493,7 @@ static void ath11k_dp_rx_deliver_msdu(struct ath11k *ar, struct napi_struct *nap
 
 	rx_status = IEEE80211_SKB_RXCB(msdu);
 	*rx_status = *status;
+	rx_status->tid = min_t(u8, rxcb->tid, IEEE80211_NUM_TIDS);
 
 	/* TODO: trace rx packet */
 
-- 
2.53.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH wireless-next 4/4] wifi: ath12k: pass the TID of a received 802.3 frame to mac80211
  2026-11-22 13:42 [PATCH wireless-next 0/4] wifi: mac80211: TSO and SG for encap offload, and the TID of 802.3 RX frames Julius Bairaktaris
                   ` (2 preceding siblings ...)
  2026-11-22 13:42 ` [PATCH wireless-next 3/4] wifi: ath11k: pass the TID of a received 802.3 frame to mac80211 Julius Bairaktaris
@ 2026-11-22 13:42 ` Julius Bairaktaris
  3 siblings, 0 replies; 5+ messages in thread
From: Julius Bairaktaris @ 2026-11-22 13:42 UTC (permalink / raw)
  To: Johannes Berg
  Cc: linux-wireless, Jeff Johnson, Felix Fietkau,
	Toke Høiland-Jørgensen, ath11k, ath12k, linux-kernel

ath12k_dp_rx_deliver_msdu() delivers frames with Ethernet decap as
RX_FLAG_8023, and mac80211 counted all of them on TID 0. Pass the TID
the driver already took from the receive descriptor into rxcb->tid.

Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
---
 drivers/net/wireless/ath/ath12k/dp_rx.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/ath/ath12k/dp_rx.c b/drivers/net/wireless/ath/ath12k/dp_rx.c
index 36be543b7c50..fc381945d163 100644
--- a/drivers/net/wireless/ath/ath12k/dp_rx.c
+++ b/drivers/net/wireless/ath/ath12k/dp_rx.c
@@ -1413,6 +1413,7 @@ void ath12k_dp_rx_deliver_msdu(struct ath12k_pdev_dp *dp_pdev, struct napi_struc
 
 	rx_status = IEEE80211_SKB_RXCB(msdu);
 	*rx_status = *status;
+	rx_status->tid = min_t(u8, rxcb->tid, IEEE80211_NUM_TIDS);
 
 	/* TODO: trace rx packet */
 
-- 
2.53.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-22 13:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-22 13:42 [PATCH wireless-next 0/4] wifi: mac80211: TSO and SG for encap offload, and the TID of 802.3 RX frames Julius Bairaktaris
2026-11-22 13:42 ` [PATCH wireless-next 1/4] wifi: mac80211: advertise TSO and SG for encap offloaded frames Julius Bairaktaris
2026-11-22 13:42 ` [PATCH wireless-next 2/4] wifi: mac80211: take the TID of an 802.3 frame from the driver Julius Bairaktaris
2026-11-22 13:42 ` [PATCH wireless-next 3/4] wifi: ath11k: pass the TID of a received 802.3 frame to mac80211 Julius Bairaktaris
2026-11-22 13:42 ` [PATCH wireless-next 4/4] wifi: ath12k: " Julius Bairaktaris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®