From nobody Tue Nov 24 11:44:06 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.208.46 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795371137; b=xiwcmdftyrE/7MVvuvFoJ+so8FyyInB9O5Miok9uMVP3CqpCuN8p9qmlYsF5tlj1AcFU 0u8TurLRhwcTKQYe0yWf91cipd4qvXfH1RnAd2+hgl7uIeHEBbB2VUTto9QUeEL9qdZkW cEvS3HAKY/oojs7ulLmuFl2JnPlTUrWzoxnmHprqqqXz8VkM01CUm1Zf56wSouVQ1fTkl EWIaIrwnyt5xEwV2fOJoLahK3z7S/s+xIncqAl+4C79xL/QzXdZZeNwDRBRZ6HDnGQqn4 wUhIXjGwdJJ9iWyRZzmcFdHf46bYxzpVga2bNsYz4VlbcSqKzPJfZTFC4LgcxBZ/u8g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795371137; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=TXtQuQYdk/h+VPS19Qx8ZxnBKtguIQfQlp5+pm4QqHk=; b=YGR3M+1d6zfsaMBEaj+cUkgtAe7UpiUATNEKHUQseNzbU4y4wVlQy/+FP2I3trOmsGmF VJ2574UuCoPINFigCxwZnJ+/jRSCstrXhjZ1o7UfQKWiYizeMNf8djkUrVOXBn04WSyqY oNz9BP8kXJ4a/JnMxfhks867uMGCA6ttIUX/kUBflgHpC0rigytaDm18H/OoirHQUROnK OjVb6KFK1qohl/LPamX3srQow5rP7hJiVKOLg1sX3oW+HaTeSVz0GX1RPch/VrkXQYZYD vBP5C5aQVfR/QozFOvjtUcl/GF8+Vp/bTpPXLKYNUju1GjPMmJgbzAdDk3d+lMWSk4A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=bairaktaris.de; spf=pass smtp.mailfrom=bairaktaris.de; dkim=pass header.d=bairaktaris.de header.i=@bairaktaris.de header.a=rsa-sha256 header.s=google header.b="kIMH/Jl5"; arc=none smtp.remote-ip=209.85.208.46 Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD69E606A338 for ; Sun, 22 Nov 2026 18:12:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CD69E606A338 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bairaktaris.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bairaktaris.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bairaktaris.de header.i=@bairaktaris.de header.a=rsa-sha256 header.s=google header.b=kIMH/Jl5 Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-6b8a1f59d5eso3064069a12.3 for ; Sun, 22 Nov 2026 10:12:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bairaktaris.de; s=google; t=1795371135; x=1795975935; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=TXtQuQYdk/h+VPS19Qx8ZxnBKtguIQfQlp5+pm4QqHk=; b=kIMH/Jl5Dp5VIFfR5zjYr099IESRRuCWJPtK3fToWAqJCN3js3bQUy4xPFrrAkXy13 cfOcaUHqeGDbEr2ddy73PhDoPXs6KdggKISW4O7UxMasl5yKx4JjnLywTcGd5IlFGOUs jPE1jXwj5mVjefTP1q+7wnCvpljMoCIFLVBc2bfbQta6w/MCCckHOLil0zwWytdJGNEf KqEDRK3IDcFr5aXpFBiSEfR06jk2znzDbSGnVKCJd9GO28RFxpgR7yIFJHulc7RTfTqk pYcyIoZOWoZKBz3B8Zm+iMI88yBAARpxkydI+S6vS9RyZD7fWlFAzqq3+v5lgZBqcFVo Vy2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795371135; x=1795975935; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=TXtQuQYdk/h+VPS19Qx8ZxnBKtguIQfQlp5+pm4QqHk=; b=Rso/QmuP4h1y13A0M8rS7ESn9PAneexYbO71zfhd3BrN9sDVT6Cux15TL6oc1L4hPm 7lrbQOrixhRiIXXs+QwcvrQMGzSZAY0fMkw5qBwnDn/zx5QcHWZ4jxXXbrW37MgETCTz aQkbQB/+yr7pOjrdo/qBrYxhF2Q3of4GMS2Giev/+mE5sfqzcZp8jlTQah1DP9cf+ICd tlqwt/OW3ZBNhi9GdeRfO8QxC3Pcp0b0aXFEi9/7LATYKJUHWahFm7f7rQn4Fy9Im25h LK5YbptljA8wnTVxVj3s4h0FXzSCHh168vvY0+3D0g/QoBJkKd10uaual2KpY26tySEp wjxw== X-Forwarded-Encrypted: i=1; AL+hErFYKpDey8XBzvDFHnOpz1+AOUUazcEbC5xvg8nk+95MECPEaJfYfAacgIKpkkNR5m7uSRUkxgwZJt3D8E8=@vger.kernel.org X-Gm-Message-State: APuU4Z/Qym6ibvILXjGw8NTffwhKNKU7AhVOG6+4d15OPC/fSjdzycn/ NFFu+KU1gi76w8Rxy02RMyYTE87mwuAUZtDB2mu5m9Sk1wMtEg3mVAeq2zEdfr1gww== X-Gm-Gg: AZFdTZdUNB0fuICzom10P/iLX0tL4WlredyhlDyisOWcL+Z/7tR/9el8a0tP8qd0GTa DMUMhP1yWHB9CCwExE7Gc12CTbykILmIFZcJFlJ3kx/5cvA3OrEqJscI4iEJxXPU1YBqPqTl0SG JSOsBv4Fffap7Yv34pc/9htxdNB5VKiOj8/8qSxMsEA+o4iy+HR7wbT8FnF1uS6GPq6D1iY6oz3 SlNqnukqFiewP8LMVVA+vk+odHIuiGzuPnPj1KcZIlnrcEYvt2qpnE3jRLjSbvoUYvc4mDzZLC2 aYblfsAcE29MS7OsSXT5gFXJLA/mJ/Z8BEWDJDk2YC++HvHeqI0/jggoR82s92vGhhEFU/K34Ky QSYdaC6OXFqrXH7/8VlZRj6aT1rqxNG23sRfM1TlJrtdiPbdxjQw76RYpEjaZe3PcdOazDBp0qL 9OE0GYYTfZCFouahi3nXSWl30zx9UaKFBjFL3/LN6wd9XU5M2BmDgF4lR2GidwKYqNeGlHJGvLO C2CVbR7yAJrx7PNv0ZQ4T97olPzytqp1XxhsiILRi9WYpnY1XkK8EH7HFekr6cDkB6N+HYFweHS vXPIO+w3NmS71wrvdSNPuo7qhOehTyDqlokzryxUTYrDLWpSL+QOFREFnD0+mqGmZoEBqwJnBaV OXCiSPP/hHTmLS5XsNd8Z2sVh0n6ogx/6TvmpVB5fqiX3AJZcSkvNlxz971EChxvacwYErqIf8U YA8ycTASAu/UuXMQdV6mYmaALW5seA8DzgMI2xWxCenyaRyNcQGlGnMbWLMKTJJ8vn8CtmdSXwY L7V/9ZRzfZzilTKuE7uo3MInqMP6k7Hp9LTJJrp7ADJTA/DaHqMaLhmcq6RcAYymOBuSpSvm/BO 3+5Oa8OyqbJft7hCh21s5Cy7hcLViqbys81ozu/skbdV2M+cufVEvjFIyvJgCn+KINECPXTf X-Received: by 2002:aa7:d592:0:b0:6b6:efc4:9eb2 with SMTP id 4fb4d7f45d1cf-6ba37acf02amr4637287a12.0.1795371135166; Sun, 22 Nov 2026 10:12:15 -0800 (PST) Received: from Desktop.tail070c67.ts.net (p200300f24713a700f1770d5b08d979ed.dip0.t-ipconnect.de. [2003:f2:4713:a700:f177:d5b:8d9:79ed]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6ba370cc257sm4052567a12.13.2026.11.22.10.12.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Nov 2026 10:12:14 -0800 (PST) From: Julius Bairaktaris To: Jeff Johnson Cc: ath11k@lists.infradead.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Baochen Qiang , Jose Ignacio Tornos Martinez , Johannes Berg Subject: [PATCH ath-next 1/9] wifi: ath11k: batch TX completion frees and peer lookups Date: Sun, 22 Nov 2026 19:12:05 +0100 Message-ID: <20261122181213.1016590-2-julius@bairaktaris.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261122181213.1016590-1-julius@bairaktaris.de> References: <20261122181213.1016590-1-julius@bairaktaris.de> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Julius Bairaktaris --- drivers/net/wireless/ath/ath11k/dp_tx.c | 49 ++++++++++++++++++------- 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/dp_tx.c b/drivers/net/wireless= /ath/ath11k/dp_tx.c index 5c3ddc8aad41..4f509771d60a 100644 --- a/drivers/net/wireless/ath/ath11k/dp_tx.c +++ b/drivers/net/wireless/ath/ath11k/dp_tx.c @@ -629,9 +629,21 @@ void ath11k_dp_tx_update_txcompl(struct ath11k *ar, st= ruct hal_tx_status *ts) spin_unlock_bh(&ab->base_lock); } =20 +/* + * State carried across one completion run: consecutive frames mostly belo= ng + * to one peer, and the statuses hand their buffers back to be freed in bu= lk. + */ +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 =3D {}; struct ieee80211_rate_status status_rate =3D {}; @@ -639,8 +651,6 @@ static void ath11k_dp_tx_complete_msdu(struct ath11k *a= r, struct ieee80211_tx_info *info; struct ath11k_skb_cb *skb_cb; struct ath11k_peer *peer; - struct ath11k_sta *arsta; - struct rate_info rate; =20 if (WARN_ON_ONCE(ts->buf_rel_source !=3D HAL_WBM_REL_SRC_MODULE_TQM)) { /* Must not happen */ @@ -707,30 +717,34 @@ static void ath11k_dp_tx_complete_msdu(struct ath11k = *ar, ath11k_dp_tx_cache_peer_stats(ar, msdu, ts); } =20 - spin_lock_bh(&ab->base_lock); - peer =3D ath11k_peer_find_by_id(ab, ts->peer_id); - if (!peer || !peer->sta) { + if (!c->sta || c->peer_id !=3D ts->peer_id) { + spin_lock_bh(&ab->base_lock); + peer =3D ath11k_peer_find_by_id(ab, ts->peer_id); + c->sta =3D peer ? peer->sta : NULL; + c->peer_id =3D ts->peer_id; + if (c->sta) + c->rate =3D 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); ieee80211_free_txskb(ar->hw, msdu); return; } - arsta =3D ath11k_sta_to_arsta(peer->sta); - status.sta =3D peer->sta; + status.sta =3D c->sta; status.skb =3D msdu; status.info =3D info; - rate =3D arsta->last_txrate; + status.free_list =3D &c->free; =20 - status_rate.rate_idx =3D rate; + status_rate.rate_idx =3D c->rate; status_rate.try_count =3D 1; =20 status.rates =3D &status_rate; status.n_rates =3D 1; =20 - spin_unlock_bh(&ab->base_lock); - ieee80211_tx_status_ext(ar->hw, &status); } =20 @@ -775,6 +789,8 @@ int ath11k_dp_tx_completion_handler(struct ath11k_base = *ab, int ring_id, struct sk_buff *msdu; struct hal_tx_status ts =3D {}; struct dp_tx_ring *tx_ring =3D &dp->tx_ring[ring_id]; + struct ath11k_dp_tx_compl c =3D { .free =3D LIST_HEAD_INIT(c.free) }; + struct sk_buff *tmp; unsigned long push =3D 0; int done =3D 0; u32 *desc; @@ -848,7 +864,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); =20 - 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); } =20 /* A completion returns the airtime the frame was charged, which is --=20 2.53.0 From nobody Tue Nov 24 11:44:06 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.208.47 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795371138; b=ehHtiZJastGxxzvdYDI4uwJVRVg8RWysfsrNZ2Ph7vmktFdoYRpQsvuyEQ9/GShQ9NzN 6vwdSIlg0H6KavHATXCT1eolOZxRTEA+sZrHebUEIHp2VzZA5vDxwpNxqhqRkeBoIS8BY yKhGNbVoQA0Ei9NXlQ1qtooT43INnPs4z4o7UMS0nj8B+7Xze58+SweY0jUw1SU59SwUK INMfcg0pcvNMMqg12IqdPKWZPfPlFS0eBYE+w2xsCyF3D+Xgrnb0YlvAO4MfWCJfUs/Gl L0tu0fiiVSl/YdMV/MdPIOZ9EnkNazLtRPcA5F0tw3a2Qr6f+or5WI+rkDER3NOe3wg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795371138; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=eil5Or1kTjxXApsN+46KoMKUA0/qV6GEUo9vYFMijv4=; b=DaYM+e/Z7kW3BWnAECx2bXW1uu8E6oD4N9nw6qbCCzV2Wmzf3kRFr2Qcv6zZ7Lg/oMIA /S3DCEdkq5GDyEShqXWLhQ2xU8cS/eyR58azpJpKeUQcfIZS1WWdluzVAmmQ7qHE7fx4k IyvT3d0YOCgT69nDfdG1nmYXdaJz/pwVFTvxmKwCLfHIylH2p+2brQ0xwShMSYsiTHnAH XL6Zej0RWapeIfpU4aKSQeyaq3ovsnumC7JpBJy+CBg0AeQkweceYlcvglQ5xJorP/KP0 diR7k0+3rrDsHolvSK/ouqFbC3eMKehQEV7m7nTPg/KGE6vFnhCzkjaE5QVFn1WQUzw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=bairaktaris.de; spf=pass smtp.mailfrom=bairaktaris.de; dkim=pass header.d=bairaktaris.de header.i=@bairaktaris.de header.a=rsa-sha256 header.s=google header.b=mRpfeKOK; arc=none smtp.remote-ip=209.85.208.47 Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 534E3606A33F for ; Sun, 22 Nov 2026 18:12:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 534E3606A33F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bairaktaris.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bairaktaris.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bairaktaris.de header.i=@bairaktaris.de header.a=rsa-sha256 header.s=google header.b=mRpfeKOK Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-6ba380cd8dbso3237444a12.3 for ; Sun, 22 Nov 2026 10:12:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bairaktaris.de; s=google; t=1795371137; x=1795975937; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=eil5Or1kTjxXApsN+46KoMKUA0/qV6GEUo9vYFMijv4=; b=mRpfeKOKXxANjPT0/9tD/ZIzFDfKfQQ+c08Okc8EnLW2u5M44uzf99kMj1ll2FK5Qp VbRZahUBrv+umkCTGl2MV/3VN1/jwu16aIcg8SqMkpF1p/TL48SiaAhH4QjAuFYb0sNY QocUG99J0MfzfgEu1RL3qRqs/qP02YQDib3bMvAim6j+DEXOJCa6M5FDyfFOY7SDPIp6 L3UJGGNgGaFstQ6oTJbe2FKNik4N1c7eMFSTONvTkH8fLF4vaRNM6LKMIfsCwXkHSLtE LdFFxSn4FWZI9WiBg2humstQ9vg/hUTzfw6tNGQNU49JL1UEm67PdzDdgX4noGrxIYDs AK1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795371137; x=1795975937; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=eil5Or1kTjxXApsN+46KoMKUA0/qV6GEUo9vYFMijv4=; b=jN0xmQkecMlvp83nHDNriU3r8c8TcbLhDEgu9izLWNbFsIjXzFjpGTvkckgaG7z9cj YreXtvyZP7mwjP/CzV9ddYsTtZwJ4pt9l273PzGCtmaGx6xEixHq/8/XHPaozhuqiOc2 I3w6UGFQAPqqZ75c8VlOxA5w+C9O4nXU/BBn0FNFmXXBPiwCeIbLVHFXN3p6GLEy092D CHdCcaaIPOM9zIeZfzw9+uETjbb7dCbqRPCS2YAIjhnW8XzFYpYZxQadX7WAN3kjUdCW 3sD72qtJWRKeAb99wYL0J/fkjZll5LwsEte+glID5QzPuqc2a4HX404+3fR6fdMBSRKP IYCg== X-Forwarded-Encrypted: i=1; AL+hErHig6ziTR76tjlD0qCq2cxrwdzUQkpUfNvOCs2fwYrNp6T4lbt8k6zZoNBM3UBsFafl5ifq3HAmULsB8lk=@vger.kernel.org X-Gm-Message-State: APuU4Z+3BoVgVUTa09JvAJ2gyqk7guEbNM2SdUtU0klgse9yXrnotxUN gQhtU5Z+uc5JGT5FJpDWTwkPyU8KDDPeygNjU0Z6be5BTGM+S8NTEkDjYPalcza7iQ== X-Gm-Gg: AZFdTZd0dwlpjwaoDgNJgYcDP4R4lDqmsQ/1JEJG6FzLIMpvxqGj+U1xSYf+hjapBWA Xm4mspO9RBkPZkyphvb4ntBmg9I2u5KQiGw0jRLiIj9QIOHEhdgJmR3kQu9Xl8HEESj9Qj+ZFfK iR7QRHO20yYQU0fvYgrle45NbzoPJETgKDzrP0xrxREXv27N3bltG1LZiUmKxqfNL1kkYqgkYoC wfeMMad0IGqI4JH55F7jiEO4q4nL8kI9P787mwme7m8CVITIZOOK6R+zm9Fe5syN+myFfGmjtJz /l3UHDb7trnuLZj9BJIkywu7B+wHv5IdDQSCQQykjPs0hF8RDRec47xP74jSILd4q9v20inZXa2 fBXlUfX88WnGAHA+4lgt3M6ypSLSgXWB6M/Q7lU9w/xN9bASi0cZUOFTxDE+K7S6LgGFBQ9Xiuz gvwe9wfT1un0osy/jubX729M/DXY+f49zIQh1Ah2MdJoX9pKgU/9WiByBeEhakvpzV67q9bv4N1 qhPRdjp0g0NutQn6YvwFUa/STPyX/9VWJlcittOlF5pPrSYyMl4AjSpmHE0hJVJMjyvWYvw9ztM +azluwwNFaw6LjHCw7B1GZfBrhNo8nq1X9r4Jr5AopBU3m09qeLeJwC5iKAWDcoRsFoeh7q2Zv+ 5IxhY9sPFNuTwGxhLf+aDdXuv1eyhEl/78T1S3ST2qqJmOFjzUIQXhrmGXcuzwVi3v/haW09DTC sukKL8XmIXgvJIi9O8QxhLpnQQHK4/JocueXKC60syW+l3TYZcHk98FKQFWodzzoy/GONELRx6j QbCwtme5mnoAmfBpAxeMDvQORQJGH9SSqC+6sWCn0HN6iieYGOuTSkYY5e9nZoeNjfeaMaRGCeW LnBSm8nX/aAqH8YQWCX4U0GvnZEm4Tav0Tjw0kyOKfnMxoRiYeykzMZjp4fe4fu4dP38XqobczL VJV45cd1pADJcLOwKO7o= X-Received: by 2002:aa7:c148:0:b0:6b7:8444:a44e with SMTP id 4fb4d7f45d1cf-6ba37cc0b7cmr4557133a12.4.1795371136615; Sun, 22 Nov 2026 10:12:16 -0800 (PST) Received: from Desktop.tail070c67.ts.net (p200300f24713a700f1770d5b08d979ed.dip0.t-ipconnect.de. [2003:f2:4713:a700:f177:d5b:8d9:79ed]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6ba370cc257sm4052567a12.13.2026.11.22.10.12.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Nov 2026 10:12:15 -0800 (PST) From: Julius Bairaktaris To: Jeff Johnson Cc: ath11k@lists.infradead.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Baochen Qiang , Jose Ignacio Tornos Martinez , Johannes Berg Subject: [PATCH ath-next 2/9] wifi: ath11k: fill the TCL ring once per dequeue run Date: Sun, 22 Nov 2026 19:12:06 +0100 Message-ID: <20261122181213.1016590-3-julius@bairaktaris.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261122181213.1016590-1-julius@bairaktaris.de> References: <20261122181213.1016590-1-julius@bairaktaris.de> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Each 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 Signed-off-by: Julius Bairaktaris --- 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(-) diff --git a/drivers/net/wireless/ath/ath11k/dp_tx.c b/drivers/net/wireless= /ath/ath11k/dp_tx.c index 4f509771d60a..bd5edab32a1f 100644 --- a/drivers/net/wireless/ath/ath11k/dp_tx.c +++ b/drivers/net/wireless/ath/ath11k/dp_tx.c @@ -108,8 +108,13 @@ bool ath11k_dp_tx_idr_has_room(struct dp_tx_ring *tx_r= ing) return atomic_read(&tx_ring->num_txbuf) < DP_TX_IDR_SIZE - 1; } =20 +/* + * A caller that passes @held_ring holds that TCL ring's lock with an acce= ss + * 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 =3D ar->ab; struct ath11k_dp *dp =3D &ab->dp; @@ -137,7 +142,10 @@ int ath11k_dp_tx(struct ath11k *ar, struct ath11k_vif = *arvif, =20 pool_id =3D skb_get_queue_mapping(skb) & (ATH11K_HW_MAX_QUEUES - 1); =20 - ring_selector =3D ab->hw_params.hw_ops->get_ring_selector(skb_get_queue_m= apping(skb)); + if (held_ring >=3D 0) + ring_selector =3D held_ring; + else + ring_selector =3D ab->hw_params.hw_ops->get_ring_selector(skb_get_queue_= mapping(skb)); =20 tcl_ring_sel: tcl_ring_retry =3D false; @@ -157,7 +165,7 @@ int ath11k_dp_tx(struct ath11k *ar, struct ath11k_vif *= arvif, spin_unlock_bh(&tx_ring->tx_idr_lock); =20 if (unlikely(ret < 0)) { - if (ring_map =3D=3D (BIT(num_tx_rings) - 1) || + if (held_ring >=3D 0 || ring_map =3D=3D (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 =3D tx_ring->tcl_data_ring.ring_id; tcl_ring =3D &ab->hal.srng_list[hal_ring_id]; =20 - 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); + } =20 hal_tcl_desc =3D (void *)ath11k_hal_srng_src_get_next_entry(ab, tcl_ring); + if (unlikely(!hal_tcl_desc && held_ring >=3D 0)) { + ab->soc_stats.tx_err.desc_na[ti.ring_id]++; + ret =3D -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); =20 - 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); + } =20 ath11k_dbg_dump(ab, ATH11K_DBG_DP_TX, NULL, "dp tx msdu: ", skb->data, skb->len); diff --git a/drivers/net/wireless/ath/ath11k/dp_tx.h b/drivers/net/wireless= /ath/ath11k/dp_tx.h index 760251c68b93..380e35e354f5 100644 --- a/drivers/net/wireless/ath/ath11k/dp_tx.h +++ b/drivers/net/wireless/ath/ath11k/dp_tx.h @@ -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); diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/a= th/ath11k/mac.c index a0f1451a8faf..090df2f1cadf 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -6521,7 +6521,7 @@ static int ath11k_mac_mgmt_tx(struct ath11k *ar, stru= ct sk_buff *skb, =20 static int ath11k_mac_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control, - struct sk_buff *skb) + struct sk_buff *skb, int held_ring) { struct ath11k_skb_cb *skb_cb =3D ATH11K_SKB_CB(skb); struct ath11k *ar =3D hw->priv; @@ -6559,7 +6559,7 @@ static int ath11k_mac_tx(struct ieee80211_hw *hw, if (control->sta) arsta =3D ath11k_sta_to_arsta(control->sta); =20 - ret =3D ath11k_dp_tx(ar, arvif, arsta, skb); + ret =3D ath11k_dp_tx(ar, arvif, arsta, skb, held_ring); if (unlikely(ret)) { ath11k_warn(ar->ab, "failed to transmit frame %d\n", ret); ieee80211_free_txskb(ar->hw, skb); @@ -6572,7 +6572,7 @@ static void ath11k_mac_op_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control, struct sk_buff *skb) { - ath11k_mac_tx(hw, control, skb); + ath11k_mac_tx(hw, control, skb, -1); } =20 void ath11k_mac_drain_tx(struct ath11k *ar) @@ -10118,7 +10118,7 @@ static int ath11k_mac_tx_push_txq(struct ath11k *ar= , struct ieee80211_txq *txq) struct hal_srng *tcl_ring; struct sk_buff *skb; u32 ring_selector; - int num_free; + int num_free, avail; int ret; u8 ring_id; =20 @@ -10132,38 +10132,60 @@ static int ath11k_mac_tx_push_txq(struct ath11k *= ar, struct ieee80211_txq *txq) * TCL ring or MSDU idr ends the whole round before a frame is taken * from the queue, and so does a frame the hardware refuses anyway, * as long as a frame in flight will restart it. + * + * The run holds the TCL ring for its whole length: the free count is + * read once and the head pointer written once, after the last frame, + * rather than per frame. The head pointer is a device register, which + * is not written while the firmware restarts or when no frame was + * added. */ - while (1) { +again: + if (unlikely(test_bit(ATH11K_FLAG_CRASH_FLUSH, &ar->ab->dev_flags))) + return -ESHUTDOWN; + + spin_lock_bh(&tx_ring->wake_tx_lock); + spin_lock_bh(&tcl_ring->lock); + ath11k_hal_srng_access_begin(ar->ab, tcl_ring); + num_free =3D ath11k_hal_srng_src_num_free(ar->ab, tcl_ring, false); + avail =3D num_free; + + ret =3D 0; + while (num_free) { if (unlikely(test_bit(ATH11K_FLAG_CRASH_FLUSH, &ar->ab->dev_flags))) break; =20 - spin_lock_bh(&tx_ring->wake_tx_lock); - - spin_lock_bh(&tcl_ring->lock); - num_free =3D ath11k_hal_srng_src_num_free(ar->ab, tcl_ring, true); - spin_unlock_bh(&tcl_ring->lock); - - if (num_free =3D=3D 0 || !ath11k_dp_tx_idr_has_room(tx_ring)) { - spin_unlock_bh(&tx_ring->wake_tx_lock); - if (ath11k_mac_mark_txq_starved(ar, txq->ac)) - return -ENOSPC; - continue; + if (!ath11k_dp_tx_idr_has_room(tx_ring)) { + ret =3D -ENOSPC; + break; } =20 skb =3D ieee80211_tx_dequeue(hw, txq); - if (!skb) { - spin_unlock_bh(&tx_ring->wake_tx_lock); + if (!skb) break; - } =20 - ret =3D ath11k_mac_tx(hw, &control, skb); + ret =3D ath11k_mac_tx(hw, &control, skb, ring_id); + if (unlikely(ret =3D=3D -ENOSPC || ret =3D=3D -ENOMEM)) + break; + ret =3D 0; + num_free--; + } =20 - spin_unlock_bh(&tx_ring->wake_tx_lock); + if (num_free !=3D avail && + likely(!test_bit(ATH11K_FLAG_CRASH_FLUSH, &ar->ab->dev_flags))) { + ath11k_hal_srng_access_end(ar->ab, tcl_ring); + ath11k_dp_shadow_start_timer(ar->ab, tcl_ring, + &ar->ab->dp.tx_ring_timer[ring_id]); + } + spin_unlock_bh(&tcl_ring->lock); + spin_unlock_bh(&tx_ring->wake_tx_lock); =20 - if (unlikely(ret =3D=3D -ENOSPC || ret =3D=3D -ENOMEM) && - ath11k_mac_mark_txq_starved(ar, txq->ac)) + if (!num_free) + ret =3D -ENOSPC; + if (unlikely(ret =3D=3D -ENOSPC || ret =3D=3D -ENOMEM)) { + if (ath11k_mac_mark_txq_starved(ar, txq->ac)) return ret; + goto again; } =20 return 0; --=20 2.53.0 From nobody Tue Nov 24 11:44:06 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.208.41 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795371140; b=KoHD4QmEO7/tS4MX5ciHjtKLJFD+l+JqNxG83DegViT88NuPXAw5qMYjsoyazRPtO/8m DGaYmmEhXLVwQGJjypVkEpBJ1VfGk6orLYNKIYIjrZTp9tBU9fYZhwtKyWapzFgK+Isnf vv6fMdtzKdSWfKstruRS307fDJkTQ3z2KUWPkAiUJT/9tGSlx6ixvleuK/ifX6jcIbH3v q6Zp53bqLdUN2JtJ6QQaCrdLkgixsPcQulJGPYDpRR9tykk/HpMJ9cJqjDT1B+vY1edI3 Labp0MJcfVuwFfMjc0GVxX4dqzeAMnk8lTVd+6cqJ89tjPoCguwly5cEn1N0vZQ2UGg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795371140; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=AwHV/L47aIX6I1PhoJ/2X4nEmV7D+cw1ick7Wr6dTv4=; b=DtiMtlG2NzU8Xoy30n8G9Mme/dv7l5NulXKzH3+QVuDQV7dfW8K9x/sv1efxHsWikGzL rmsllFsAaxIlyRROc3KuvVgeTTZGtswjnMCIpN7LJP1+EEnw9lrR3r680rqVX3oQQj8Lx SmLuLPSFYvC2ElZJP+8d61oDktMsOABUU/Q191vCrLlpNB7950mtgkj6L8g5EesKaXnhQ G+KyBQ2430aFxHreIM4lvNOyHQe40ISgTS6c267VBjYnSSaM9Gs6H70i/oPllvSutADZk JG9deKB3Swu/AZA+OusVGkhzxtCBr64kdRTLO+GJt2qXXIsj7i1bvDtEYmPbvylJVpA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=bairaktaris.de; spf=pass smtp.mailfrom=bairaktaris.de; dkim=pass header.d=bairaktaris.de header.i=@bairaktaris.de header.a=rsa-sha256 header.s=google header.b="yJC7eV/R"; arc=none smtp.remote-ip=209.85.208.41 Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 61A77606A320 for ; Sun, 22 Nov 2026 18:12:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 61A77606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bairaktaris.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bairaktaris.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bairaktaris.de header.i=@bairaktaris.de header.a=rsa-sha256 header.s=google header.b=yJC7eV/R Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-6b8786bb305so3147453a12.0 for ; Sun, 22 Nov 2026 10:12:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bairaktaris.de; s=google; t=1795371139; x=1795975939; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=AwHV/L47aIX6I1PhoJ/2X4nEmV7D+cw1ick7Wr6dTv4=; b=yJC7eV/RcrD0X62aZ6misJv5IOVhVL3maz0KjDgU7SMO9Qn6WDPmdNNJNh0QmoVKBs 8OkeSW7aYMCWUwED+IUQxU+nJEwbT/A0KPLyEeq8opTBOai/s9Jo02ReAgi1wZyJyB6F MZxKT+ut5wrndXzBRbon5WyPjBVjaQsBS23vWiPCitMeNh2JYteqtNW67qbiUfGMX4eq 7MMOYyEINdi9FQFZ1Q9JSdCvhs6mKJ31q7ow6cpP1zyHpvf3AC96P1cQKX3TEEEjYYeL pSWqsiCFvsgWXO+GgE/irM0zCLko5Y/O7LIZFblbyx1Rb8OqUaDJ2ekTeDkYANa3jUBx pEyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795371139; x=1795975939; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=AwHV/L47aIX6I1PhoJ/2X4nEmV7D+cw1ick7Wr6dTv4=; b=CZ7zZBByyoTCBcLFXD0BrwFFaPMxLTLPZu/+KHGcsmrYwsXdMW/nG3ROD/Kp6ZDEk4 Wi7uj1qVyAPdeFMLpk898UDv/M/Q8ZCmN187RWmc9MTLqCn+vuUheK8b5+54cqfz3+ZZ cC1Rnj2MivUNIp+jA4MP7xvfCuTtDdwbLVwExAACo/yDOvg/o1Bo07UF+hcA6GdLQFLo xyNY2O9kNSaXvYxMkVy3bnt8VlrfuL9kZ7lr3uxqj+EyaAuMJ0TGZO7itkmS4wwk5mT7 aI83Xxr1DoOBWLEzsy7dTTxNuKuh5qgnxHZpNPDQ+qRWpvVRZPUIN3/Z6OgetPqsrqai b8Zw== X-Forwarded-Encrypted: i=1; AL+hErFNJzBSZaD+FZ+gOut/Cs0TG38rhlC7Ngp+54qoINGqyBr10xQ16wtRg1D4hJZe5cbvrDefiv0lxOnAoXk=@vger.kernel.org X-Gm-Message-State: APuU4Z8hKn/xjVlFAEMStnITO8aX+AkgcRInrP4fqBigwt/RK16sQ0O+ hpAr5sSG5EQMqfpqiTHrLOjqIqTVM2sJh4RU4Rs/UwQffxLiCjpP6LDuvLRlALOe9Q== X-Gm-Gg: AZFdTZe4DGZYpcE1Lsmj394l3slHBpHkruOxKDrMz6zvtU/aEBpMnODhxXpynExOq+Q gxwjWs+n09pJ04T9/vXM6+hGyOeqHmjNYSVLj+tz0qmQPIYMtHhAj3vyRcc6CLypF6qISozrGdJ /JrooXuYKOdwDuEPH/XFJRlfxCp9F1eTvMxfaYVsYPc7DvXTchsxaCL//pAHvO8+QysoS1BkeFD dhUbytGDiQ+xHiYi8wsAE7CUg3PTqQ5Ohq6I4Ogh19gRVIdSMzLQgoxxRi7EyYpqmTzwqUsqWZ/ nYxdWUUClH/xfCkm/sfpwzLrFcFC/SpBgxMLQpfJ9x2tX7NYTgsjxUDTAyanjjyoTSZC6YF9jT6 JJE4WgZzfMAPWhPldQpU+iDu4/D6BQRw1RQulQk5nsNprNR8Rj7x9rsh9wrw/HViJ5A4PIX2jEf 33FVhpB5PHJfJkrcLGoPCF9TlpQrZH2IJvboB/To06x5gixpNGHFpfS3bHLEhPU6OLrqqBqChuP H3dvhX9NqHaX8kuwu4IVO7kTYsGrQDBcLLUry9Ntr5KHp7ULDZ/ysLEijyOkcjoI5VUDqithaUz vLOAlR3tIlNH0ASz6u5tZu0sqZ3X2lLVJgdBBVDvsMOQ5ncAIdtDgV5J8yLo87ky/AkbfMhiGQe nXfXjpyT3x9Bz/uPPVn3XMhnEk6JmGS+4Nj/QyTuaUIZrDYwFbgg0hHfAHtAMK447vorH/SknnH Ys5xgRuEkgpPlXSuG4n9xa1gU0Ri4Ie+ch355lex7rGPcMhLha4Km4viJ0ZpsmvlXDquqgswdUT j0zgwI9W62sS2cSNmUmd4bFucoIjtecgqj21VHmdlpYhyYm7BkWxky/hQJupH2V776CYngBcQQ1 wLZHOg9RqjkIMv3+8A+zEhSHUJyimnYOKdXhM25HFQnvYOFLla+zLczRKomh0gRrvdehlV9R X-Received: by 2002:a05:6402:569a:b0:6b7:5712:b6c1 with SMTP id 4fb4d7f45d1cf-6ba37ac6db2mr4318502a12.0.1795371138807; Sun, 22 Nov 2026 10:12:18 -0800 (PST) Received: from Desktop.tail070c67.ts.net (p200300f24713a700f1770d5b08d979ed.dip0.t-ipconnect.de. [2003:f2:4713:a700:f177:d5b:8d9:79ed]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6ba370cc257sm4052567a12.13.2026.11.22.10.12.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Nov 2026 10:12:17 -0800 (PST) From: Julius Bairaktaris To: Jeff Johnson Cc: ath11k@lists.infradead.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Baochen Qiang , Jose Ignacio Tornos Martinez , Johannes Berg Subject: [PATCH ath-next 3/9] wifi: ath11k: push TXQs from BH work Date: Sun, 22 Nov 2026 19:12:07 +0100 Message-ID: <20261122181213.1016590-4-julius@bairaktaris.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261122181213.1016590-1-julius@bairaktaris.de> References: <20261122181213.1016590-1-julius@bairaktaris.de> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Each 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 Signed-off-by: Julius Bairaktaris --- drivers/net/wireless/ath/ath11k/core.h | 3 +++ drivers/net/wireless/ath/ath11k/mac.c | 24 +++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/= ath/ath11k/core.h index 8b7bfb0cefcf..74fbff296b60 100644 --- a/drivers/net/wireless/ath/ath11k/core.h +++ b/drivers/net/wireless/ath/ath11k/core.h @@ -715,6 +715,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; =20 struct list_head arvifs; /* should never be NULL; needed for regular htt rx */ diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/a= th/ath11k/mac.c index 090df2f1cadf..0af4f2fe27bb 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -6791,6 +6791,7 @@ static void ath11k_mac_op_stop(struct ieee80211_hw *h= w, 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); =20 if (ar->state_11d =3D=3D ATH11K_11D_PREPARING) { ar->state_11d =3D ATH11K_11D_IDLE; @@ -10211,10 +10212,30 @@ static void ath11k_mac_schedule_txq(struct ath11k= *ar, u8 ac) spin_unlock_bh(&ar->txq_lock[ac]); } =20 +/* + * 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 r= un + * 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 =3D container_of(work, struct ath11k, txq_work); + unsigned long woken =3D 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 =3D hw->priv; + + set_bit(txq->ac, &ar->txq_woken); + queue_work(system_bh_wq, &ar->txq_work); } =20 void ath11k_mac_tx_push_pending(struct ath11k *ar, u8 ac) @@ -10953,6 +10974,7 @@ int ath11k_mac_allocate(struct ath11k_base *ab) =20 for (j =3D 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); --=20 2.53.0 From nobody Tue Nov 24 11:44:06 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.208.53 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795371143; b=ccMVZPZfVX+mugZWXNZV3FmTGeUPpcHRwp0QZXOwnD5xdWD9HnS0OfbAlbD+KYhu+LfI T1TWTtrlCu0BMaUaZxHW1Fe0S96sefnsaosCboRNURvCPmbElOsiUQdqNWAF+imF+8H5S q/xcf9usZ/peyohshYDZbDb/gkUFD9QNz7w4CFyHqjjShHej1Z4fGlWHjb/HqkwfonaUp j1GBua8kZG04SfQdqWbl/5nKUn/LA6/B4UgDaDWx+kQbU5LI2rTSIr3EOlFbS452Xej3S LIlF2nmUqfBM4dGaqNDf6pUrE8k3X6VNfI0CGieHK7/WcBgnT3wBZ3xXRDZajM1uiWg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795371143; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=GAq4IkIOet4Pk0GS2U/anQiFA+lR+8Je61Jyy7n2K/w=; b=27sA3txi8+CtuzIpMd7nPrDkZ3Bx1mGF4ac64LeRBpD5kJQoVykRdfpYE4don0TqfN3h ixKq+IPRVA21+4OOePId6fIGAP11R49uHPlEbCooGcHTGZjI0/hnbDDzl3D6Xj4vDKk9V H6fIHIVggjNGU1WfaI7MaotMwPn5yC7CTeqr4klTSIhTi7xCyMUnOGdFQ8gAPPy+6KXM0 aPbnY3jRal4t0J+CVFpjymuxceX47y7HA8WiFivNdbBk7ku7gMczN37jwj93dkSiZVcrp wEUp2NZB1GTIiPA3MRm/aOdeZxewIE2Htnp0Do5+HCyh1yQXkuJpArNqq5tUQ7lZwlw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=bairaktaris.de; spf=pass smtp.mailfrom=bairaktaris.de; dkim=pass header.d=bairaktaris.de header.i=@bairaktaris.de header.a=rsa-sha256 header.s=google header.b=H5BEZRBF; arc=none smtp.remote-ip=209.85.208.53 Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 99C9F606A68A for ; Sun, 22 Nov 2026 18:12:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 99C9F606A68A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bairaktaris.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bairaktaris.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bairaktaris.de header.i=@bairaktaris.de header.a=rsa-sha256 header.s=google header.b=H5BEZRBF Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-6b8a2518f7cso2889601a12.2 for ; Sun, 22 Nov 2026 10:12:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bairaktaris.de; s=google; t=1795371141; x=1795975941; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=GAq4IkIOet4Pk0GS2U/anQiFA+lR+8Je61Jyy7n2K/w=; b=H5BEZRBFT+OdKFNfXM/uAqjRb+jVSC73Wq89Fe4NH1/hwnKuz2/hovcjDL2mmFNM2A sPnOzN6viQnzAK7FseYSbLZjKdmaPL6ttKiDG4b1iux0bRplsz48CaVtTT5ytn7xXjHl 7QHXHEQaebxMKfU5JOXOd3t/B/qcvO3lm8tR1hPVvx07Ul9hhcb3hIMRfb+qY0QcG1y0 +gGqtYYTMWRGAiNdwAx1Oglf3lwnetQM59UqKVNx7ZA3Kion2oSs0brnPkzo1ZFQ3paH u4r8DZFxOgl19IE9LFGsvLHNttCXt3XaXtMesJO9NYtKANlhhFYBg2sBEeRSAL5mEY1u pMBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795371141; x=1795975941; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=GAq4IkIOet4Pk0GS2U/anQiFA+lR+8Je61Jyy7n2K/w=; b=CmriKzEQ7jLigu0vcovIkRAcm3pYTf7OtK1WP/Oc19+rwl7H4gNuxUVbSRk812rwyl Neq/rTToxCAiGRwb3b/oPEt4wJKgAT0cvhgDZSouYGyYtyBXRH4kAGk8c+5Ic1RiVQx+ aKtpM3gMzeV9eHEdLXsU6tVosDBoXXXuWsqIdhAVrMcdK3iJ4gIVXnUVXHRg0g/QJa5D bVwI5W2H2NxfcWL+1lGO6N7mj22RalPz0LFIUBTfAOcR+/wqZC0J/aKMp+AE+xgQyGUR EofINT2P4cFrcJKw2f+qM2botmFA24zReNCpJbq5psDEvgGctUJ7Rp8YY0b8ZVS1Midm YPCg== X-Forwarded-Encrypted: i=1; AL+hErHmMQPGpuT5slCv5cmvEF0DE+JI+sZqaP0KAgXobBvWJMdZQlQ/FGsJ9flSciDcf9r5LyVkDcy3ROuKE0o=@vger.kernel.org X-Gm-Message-State: APuU4Z84JAFbTdS/lCyQ1A6ryLtUFLENn3nt8lIh4QyLSiQTazNcQbJs LavDaynNN54zxafcpEVqJpYxDsNaqFSck/yoXnUIkWIC3HGArUp0RoDgtXWMnWjhJg== X-Gm-Gg: AZFdTZduiHn+TRa/IQfox51wO24q3X3AkK+FFHS+GOMVGUPfezUsaFkXhMhz+geEZ+u 3qzAa8hlrqnRe2RJOYV9MrrwfEwhH8nm85ebLvHAri+JfIkmpUtBweD5jwZ7jhxOKVbc035clbA k9OlwbRKjTz+sCQLE1BCO3VNWFdpN827ZeOYvQN/Bvbgy/1FC+EpZYPAUtEPj3qI1AOZWZF1+6k nku7SXQQvdzIDR/cDFZI5BcVpk6olVbuwn76/VhtZMpvPuL+i/Hr/2N3frZwl3MAMwDohLqQdgZ dOqQ+x/yzubc1Ysd7JXD50vsSe7t/R8YrLh/L2ZWP0u7S1f/iwpEP1/rQMG0KB+lgPB8SvSV92H CYEaKcYfB8YURhzD0hc84SpSObDkFfGmbCjyZu0cpXsqfIeRmsnEgNyJnXMH/PblqcOKjDgkX1r 73sGCcW8e8wWNtQKd8bj9IBOLmfcPYzGI4Ns9ubLJy+dPGLeFiVBnLb/nsd7DJdSaxuOK1IUFMv gwQS/uca5qCa3Ia1gp+DvnLEGh7xXRdib4Of++nbzbffXI9Q2k2cywgp2QTE37DIvMUJ1WJbSqQ G207yw9/IfuETU1y+UFE7sp9jRCfZqKzTQZIUi/534hossrBRBuSjrvx3PvhLaZUpBugC42EY7H JvnDwHR3iCT5VCEnEeR+qFw81Vz7O4gBJT6nEhj2hMYNfrF15n3wdMY1MmWGubxsiUd5J71NgMH TlIGZqstBrKmPTUnitvCJc0JwTnepR4LbD2PocV2vh2C05/JcrmzGruWDMQ5Ut6XC2ZofzDWF+M L40i9nsKjl6fH9gbXSHkBHeDdzwZDobwK51kaTKqfUPdHRu3vuALvctvEj2jbBPUXu0tOnTspEw 6MPEF6JSWh4f6C7LdSWR8eQCzXZ4j9aSjVCrtdFiG0rZOHWZUdHX0pq6W1ImuNlj1471zHXo X-Received: by 2002:aa7:d819:0:b0:6b8:a703:8ffe with SMTP id 4fb4d7f45d1cf-6ba37c7ba68mr5099318a12.5.1795371140985; Sun, 22 Nov 2026 10:12:20 -0800 (PST) Received: from Desktop.tail070c67.ts.net (p200300f24713a700f1770d5b08d979ed.dip0.t-ipconnect.de. [2003:f2:4713:a700:f177:d5b:8d9:79ed]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6ba370cc257sm4052567a12.13.2026.11.22.10.12.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Nov 2026 10:12:19 -0800 (PST) From: Julius Bairaktaris To: Jeff Johnson Cc: ath11k@lists.infradead.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Baochen Qiang , Jose Ignacio Tornos Martinez , Johannes Berg Subject: [PATCH ath-next 4/9] wifi: ath11k: replace the TX buffer IDR with a table Date: Sun, 22 Nov 2026 19:12:08 +0100 Message-ID: <20261122181213.1016590-5-julius@bairaktaris.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261122181213.1016590-1-julius@bairaktaris.de> References: <20261122181213.1016590-1-julius@bairaktaris.de> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Every 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. Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.12-01460-QCAHKSWPL_SILICONZ-1 ath11k_dp_tx_idr_has_room() now reads the count of free ids, and the num_txbuf counter it read until now goes away. Signed-off-by: Julius Bairaktaris --- 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(-) diff --git a/drivers/net/wireless/ath/ath11k/dp.c b/drivers/net/wireless/at= h/ath11k/dp.c index 833feb981cfc..e7eab9857f29 100644 --- a/drivers/net/wireless/ath/ath11k/dp.c +++ b/drivers/net/wireless/ath/ath11k/dp.c @@ -1015,17 +1015,21 @@ void ath11k_dp_vdev_tx_attach(struct ath11k *ar, st= ruct ath11k_vif *arvif) ath11k_dp_update_vdev_search(arvif); } =20 -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 =3D ctx; - struct sk_buff *msdu =3D skb; + struct sk_buff *msdu; + u32 id; =20 - dma_unmap_single(ab->dev, ATH11K_SKB_CB(msdu)->paddr, msdu->len, - DMA_TO_DEVICE); - - dev_kfree_skb_any(msdu); + for (id =3D 0; tx_ring->bufs && id < DP_TX_IDR_SIZE - 1; id++) { + msdu =3D tx_ring->bufs[id]; + if (!msdu) + continue; =20 - return 0; + dma_unmap_single(ab->dev, ATH11K_SKB_CB(msdu)->paddr, + msdu->len, DMA_TO_DEVICE); + dev_kfree_skb_any(msdu); + } } =20 void ath11k_dp_free(struct ath11k_base *ab) @@ -1042,9 +1046,8 @@ void ath11k_dp_free(struct ath11k_base *ab) =20 for (i =3D 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 =3D NULL; @@ -1093,8 +1096,9 @@ int ath11k_dp_alloc(struct ath11k_base *ab) size =3D sizeof(struct hal_wbm_release_ring) * DP_TX_COMP_RING_SIZE; =20 for (i =3D 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 =3D 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 =3D i; diff --git a/drivers/net/wireless/ath/ath11k/dp.h b/drivers/net/wireless/at= h/ath11k/dp.h index bf7439e8b37d..f3dcba777a34 100644 --- a/drivers/net/wireless/ath/ath11k/dp.h +++ b/drivers/net/wireless/ath/ath11k/dp.h @@ -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; diff --git a/drivers/net/wireless/ath/ath11k/dp_tx.c b/drivers/net/wireless= /ath/ath11k/dp_tx.c index bd5edab32a1f..feeaba575966 100644 --- a/drivers/net/wireless/ath/ath11k/dp_tx.c +++ b/drivers/net/wireless/ath/ath11k/dp_tx.c @@ -79,33 +79,88 @@ enum hal_encrypt_type ath11k_dp_tx_get_encrypt_type(u32= cipher) } } =20 -/* The caller holds tx_ring->tx_idr_lock. */ -static struct sk_buff *ath11k_dp_tx_idr_remove(struct dp_tx_ring *tx_ring, - int msdu_id) +/* + * The ids a ring hands out, as a table indexed by id with a stack of the = free + * ones: the completion's cookie names the buffer directly. Callers of the= id + * helpers hold tx_idr_lock. + */ +int ath11k_dp_tx_bufs_init(struct dp_tx_ring *tx_ring) { - struct sk_buff *msdu; + u32 id; + + tx_ring->bufs =3D kvcalloc(DP_TX_IDR_SIZE - 1, sizeof(*tx_ring->bufs), + GFP_KERNEL); + tx_ring->free_ids =3D kvcalloc(DP_TX_IDR_SIZE - 1, + sizeof(*tx_ring->free_ids), GFP_KERNEL); + if (!tx_ring->bufs || !tx_ring->free_ids) { + ath11k_dp_tx_bufs_free(tx_ring); + return -ENOMEM; + } + + tx_ring->num_free =3D 0; + for (id =3D DP_TX_IDR_SIZE - 1; id--;) + tx_ring->free_ids[tx_ring->num_free++] =3D id; + + return 0; +} + +void ath11k_dp_tx_bufs_free(struct dp_tx_ring *tx_ring) +{ + kvfree(tx_ring->bufs); + kvfree(tx_ring->free_ids); + tx_ring->bufs =3D NULL; + tx_ring->free_ids =3D NULL; + tx_ring->num_free =3D 0; +} + +static int ath11k_dp_tx_buf_get_id(struct dp_tx_ring *tx_ring, + struct sk_buff *skb) +{ + u32 id; + + if (unlikely(!tx_ring->num_free)) + return -ENOSPC; + + id =3D tx_ring->free_ids[--tx_ring->num_free]; + tx_ring->bufs[id] =3D skb; + + return id; +} + +static struct sk_buff *ath11k_dp_tx_buf_put_id(struct dp_tx_ring *tx_ring, + u32 id) +{ + struct sk_buff *skb; + + if (unlikely(id >=3D DP_TX_IDR_SIZE - 1)) + return NULL; + + skb =3D tx_ring->bufs[id]; + if (unlikely(!skb)) + return NULL; =20 - msdu =3D idr_remove(&tx_ring->txbuf_idr, msdu_id); - if (msdu) - atomic_dec(&tx_ring->num_txbuf); + tx_ring->bufs[id] =3D NULL; + tx_ring->free_ids[tx_ring->num_free++] =3D id; =20 - return msdu; + return skb; } =20 /** * ath11k_dp_tx_idr_has_room() - tell whether ath11k_dp_tx() can take a fr= ame * @tx_ring: the ring the frame would go to first * - * ath11k_dp_tx() allocates the frame's MSDU id from the ring's idr, which - * holds DP_TX_IDR_SIZE - 1 ids and frees one when the frame completes. A - * caller that takes a frame from mac80211 only to have it refused for a f= ull - * idr loses the frame, so it checks first. + * ath11k_dp_tx() takes the frame's MSDU id from the ring's free ids, of w= hich + * there are DP_TX_IDR_SIZE - 1, and the frame's completion returns it. A = caller + * that takes a frame from mac80211 only to have it refused for want of an= id + * loses the frame, so it checks first. The count is read without tx_idr_l= ock: + * an id taken in between costs that one frame, as before the check. * - * Return: true if the idr has an id free. + * Return: true if an id is free. */ 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; + /* Read without tx_idr_lock: a stale count costs at most one frame. */ + return data_race(tx_ring->num_free) !=3D 0; } =20 /* @@ -158,10 +213,7 @@ int ath11k_dp_tx(struct ath11k *ar, struct ath11k_vif = *arvif, tx_ring =3D &dp->tx_ring[ti.ring_id]; =20 spin_lock_bh(&tx_ring->tx_idr_lock); - ret =3D idr_alloc(&tx_ring->txbuf_idr, skb, 0, - DP_TX_IDR_SIZE - 1, GFP_ATOMIC); - if (likely(ret >=3D 0)) - atomic_inc(&tx_ring->num_txbuf); + ret =3D ath11k_dp_tx_buf_get_id(tx_ring, skb); spin_unlock_bh(&tx_ring->tx_idr_lock); =20 if (unlikely(ret < 0)) { @@ -320,7 +372,7 @@ int ath11k_dp_tx(struct ath11k *ar, struct ath11k_vif *= arvif, =20 fail_remove_idr: spin_lock_bh(&tx_ring->tx_idr_lock); - ath11k_dp_tx_idr_remove(tx_ring, + ath11k_dp_tx_buf_put_id(tx_ring, FIELD_GET(DP_TX_DESC_ID_MSDU_ID, ti.desc_id)); spin_unlock_bh(&tx_ring->tx_idr_lock); =20 @@ -340,7 +392,7 @@ static void ath11k_dp_tx_free_txbuf(struct ath11k_base = *ab, u8 mac_id, struct ath11k_skb_cb *skb_cb; =20 spin_lock(&tx_ring->tx_idr_lock); - msdu =3D ath11k_dp_tx_idr_remove(tx_ring, msdu_id); + msdu =3D ath11k_dp_tx_buf_put_id(tx_ring, msdu_id); spin_unlock(&tx_ring->tx_idr_lock); =20 if (unlikely(!msdu)) { @@ -383,9 +435,11 @@ void ath11k_dp_tx_free_pending(struct ath11k_base *ab) tx_ring =3D &ab->dp.tx_ring[i]; =20 spin_lock_bh(&tx_ring->tx_idr_lock); - idr_for_each_entry(&tx_ring->txbuf_idr, msdu, msdu_id) { - ath11k_dp_tx_idr_remove(tx_ring, msdu_id); - __skb_queue_tail(&pending, msdu); + for (msdu_id =3D 0; tx_ring->bufs && msdu_id < DP_TX_IDR_SIZE - 1; + msdu_id++) { + msdu =3D ath11k_dp_tx_buf_put_id(tx_ring, msdu_id); + if (msdu) + __skb_queue_tail(&pending, msdu); } spin_unlock_bh(&tx_ring->tx_idr_lock); } @@ -412,7 +466,7 @@ ath11k_dp_tx_htt_tx_complete_buf(struct ath11k_base *ab, struct ath11k_peer *peer; =20 spin_lock(&tx_ring->tx_idr_lock); - msdu =3D ath11k_dp_tx_idr_remove(tx_ring, ts->msdu_id); + msdu =3D ath11k_dp_tx_buf_put_id(tx_ring, ts->msdu_id); spin_unlock(&tx_ring->tx_idr_lock); =20 if (unlikely(!msdu)) { @@ -862,7 +916,7 @@ int ath11k_dp_tx_completion_handler(struct ath11k_base = *ab, int ring_id, } =20 spin_lock(&tx_ring->tx_idr_lock); - msdu =3D ath11k_dp_tx_idr_remove(tx_ring, msdu_id); + msdu =3D ath11k_dp_tx_buf_put_id(tx_ring, msdu_id); if (unlikely(!msdu)) { ath11k_warn(ab, "tx completion for unknown msdu_id %d\n", msdu_id); diff --git a/drivers/net/wireless/ath/ath11k/dp_tx.h b/drivers/net/wireless= /ath/ath11k/dp_tx.h index 380e35e354f5..50b6178ceb38 100644 --- a/drivers/net/wireless/ath/ath11k/dp_tx.h +++ b/drivers/net/wireless/ath/ath11k/dp_tx.h @@ -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); diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/a= th/ath11k/mac.c index 0af4f2fe27bb..513559585371 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -7361,15 +7361,20 @@ static int ath11k_mac_op_add_interface(struct ieee8= 0211_hw *hw, return ret; } =20 -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 =3D ctx; - struct ath11k_skb_cb *skb_cb =3D ATH11K_SKB_CB(skb); + struct ath11k_skb_cb *skb_cb; + u32 id; =20 - if (skb_cb->vif =3D=3D vif) - skb_cb->vif =3D NULL; + for (id =3D 0; id < DP_TX_IDR_SIZE - 1; id++) { + if (!tx_ring->bufs[id]) + continue; =20 - return 0; + skb_cb =3D ATH11K_SKB_CB(tx_ring->bufs[id]); + if (skb_cb->vif =3D=3D vif) + skb_cb->vif =3D NULL; + } } =20 static void ath11k_mac_op_remove_interface(struct ieee80211_hw *hw, @@ -7434,8 +7439,7 @@ static void ath11k_mac_op_remove_interface(struct iee= e80211_hw *hw, =20 for (i =3D 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); } =20 --=20 2.53.0 From nobody Tue Nov 24 11:44:06 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.218.53 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795371146; b=avp4LhB7bLdqo+xFixkhjmM2Y8gEDWtVMkCgjOudZGF78zDzQgU7hu3VzBSdmluth4lf mP4j+I7kxfL4pW277nIwIPmD3reKRj1Efw1pO5WjyfaCfJib8Ovnd5aC8rn3dccJxuAtI PAXT/pr/1wymlKK/lfKUOoqUU8vJb7vd3sntt9Y9u4G/t7CCpvC3tW5afvTSFGZAnYB1M gmLzeB6fwVZxVao3kiuXrDdw05ZIGEw0AsrnkGw332/z4PnHlsjn5pujxNsGWOPB08EIQ rQAHk8rxsJNChY5Cd8k5rKdo8Ra9NQSzv+FUomyGKoi9JXsPE4QJrtZ+jMjnt38TCow== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795371146; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=f2OWmUALbyxBFLTyN5GgUEDKjKDLoZvafZVRZ2yb6Js=; b=sPufyNBVsb67RAHaOP36AR4mOv7Vs8QzWQ6ywJdXTkVRMQpEZASJkBFzlrYO+QXgByjp SCcBi7Yqg6CttVTz3gN0f95cG+2/sGPC/IleQgF2y+I6xcqFfzabU9BPp4B4u51/XeuH9 aQkufgPvIuOghu8lFyGhUrfw/2iIqWvqbeow6kFsak3owTGbb6OE7gmTTn2L0AHx1xJeI YcRQbByWw9WsTfJld49jWzoae7j2WlG5a8Cx6pJqi0MGUMW6PvlaZaNxRQPlzORFfpLeS x43MZ+tdxRlQ4wziL5gAMbC/d5r/PuOfAtYtOOvsoteaIBYhXjxRcoXDqpV4MuUDM9A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=bairaktaris.de; spf=pass smtp.mailfrom=bairaktaris.de; dkim=pass header.d=bairaktaris.de header.i=@bairaktaris.de header.a=rsa-sha256 header.s=google header.b=qaZ3sFwH; arc=none smtp.remote-ip=209.85.218.53 Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5DE97606A681 for ; Sun, 22 Nov 2026 18:12:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5DE97606A681 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bairaktaris.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bairaktaris.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bairaktaris.de header.i=@bairaktaris.de header.a=rsa-sha256 header.s=google header.b=qaZ3sFwH Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-c247f6687dcso378196266b.2 for ; Sun, 22 Nov 2026 10:12:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bairaktaris.de; s=google; t=1795371144; x=1795975944; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=f2OWmUALbyxBFLTyN5GgUEDKjKDLoZvafZVRZ2yb6Js=; b=qaZ3sFwHHxa+jJGYsYorlCgNKhiU/gnbLWp4r+Q2EgCo73fSl9fX8fJPODwbZUxzF1 PM1L/tfpJT9e15NYSXcQxWeKV4wPzy54ALqTmv9bQg5njGlIVhopPXa7GTMY1WH2WKXb eLqO1n7/klmS4KcLiYOh3kSnPL4rqhTFUzs0Lbg+RTg2Ut9S464AFh1KKA9s8DTYimPD B6l9Ql47edO3h6wtdjgFOvrv2whpl2/46OYRweb/5wWFFDsqTlQi+rbgjUUxuQwX2UMo YaZa/Z1EFp87kLpqD59bPrDjo1dh2xjwWjFfoo7A1LmPUihhzMNAABEbmbmX8yAhkp7t Maww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795371144; x=1795975944; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=f2OWmUALbyxBFLTyN5GgUEDKjKDLoZvafZVRZ2yb6Js=; b=RF/V0GqX8tAam2ykXn5iwShT3Pw6QYJ730k1qUawchCVtYQQ9rEfE8fTViZEDVgCnn qU+JduRB38lOoWBgJLTd98r8yTY9KhZVV80GNxoUzWT9MEp3hNjEHmSDEY/VeO/kcXwY xl0sOQfMQ1zma/WnnQbiRZ0tBZERMBUfkkp+vbDnW9zE0s1aoSVdJ5sh2VwF+hu4DiSS AbWsERoD/PL6bGpyBPyc/T0bjGUIaDQURFBFUdzjnfIQOgk23Z6I++a+qGZG4Xz4ANxa Vv1Nh6ZRNWcQp4h+Gy2gTKmih/82ntTHx9o79BbpVfYRV8X/4bS2j3b2cvIVKN+xAmA+ wj0Q== X-Forwarded-Encrypted: i=1; AL+hErHFkyvUNZhF9b2zz7NON9D/RYO6+OL9TwPlKwHvCZx2grswXSdvlkmw5tadaZZb+NGaAGdBgsA3Q6ZoMuU=@vger.kernel.org X-Gm-Message-State: APuU4Z+Wz6HXVEZs8bxjfu+sRi5FmBc6xgELqWaDv9Cc0TmI7joJgceu 8mod8Xg8nOIrzN/Z9FfqhsRYcZNibpj6iPM8O1YXzkGo1jickSbBxU0sQrexlczZaQ== X-Gm-Gg: AZFdTZen3gMq0zdcQYn0k9si5QoTp+g0NdHeSXGApbmnhqedDEGawyHhGsZwrHJGw37 Zz94szyKf9Al6u/DLT2oqN618nJtSu/5tWGRx3e6XBqldN2nMTwzdnS/EqN5efUrnj5tRvBSqbh wpaQ7A701jS9QIRhjSmVQZAomAovu6uQ374+WzoT8Mj+EdRk04b1LPI+4VMwqzcpVdzSNRrrBAs QSFN1iRE1Gt1FdWxBjaPyu1JlYLurys4aMtgcw3w9NA3OpBGE7ta/z7aNH1huIWR355C5/5LOSX vjMHkNdSIILghk/RTXTTSxVZyoAs/lOv5SrSy4N8/6rPB7dXwyeDGQ52eWxc8vxPIeg8xec2QWd /+tuoV5qpTLY1Za5ARQro2oqLvyIbvXHR9xuj6AClrrrTvkwjnOQRQuJ4T3K/qQtzhcJJScQMAx kyF1QPBIOASjBF/HlcIyG/7RmeL9JrG2K+Gphqldw54VtR2/wjEKgngT/JLIh1mvY+rn6hXFhbu nWADM1yC1z3cj07yrpvRkG3Cb6OkRjRGVfhfdJiA3+G7w5CmeEDXF0SJLM2cHvStc5En2xBIyXE H4hu6ISxPWma9BQPKQ97fk5TRJvR2lEkk5yo8nG7OLkBI/vb9yVlHCe3JUZZxz+RNZnA3lh/WKx s+4+QQ1y9aTAGFAZolS/fLhDoNLK3ySHIK5Ztu01WMRhMgO0oBWFnNEQnEI8XRITfjRPhFz+HO6 TgVFgWw7XnljHsGtUS/dUnWZA1t1PrkNLVdDfQo/dNCleQkNV54OW7AM3RP/OD1a5O9AxZCK4Fr FLoOzlIF4QC6sq9lvyfq3ywsb5TWaKLiGLyF8p8/W2ymW8eUYJr+XtMUkEwTO/GqQghG0AQCGhU sf6wWaBLpQEWiAv5JMRmOQTY+ekAgKY/XyAgfgaoLNxATacw1w7veRfLIfhLfJ6XqYB/zVPDeu7 d6TPGZ17qiZ7DSDCRlw== X-Received: by 2002:a17:906:da0e:b0:c46:a72:e0c3 with SMTP id a640c23a62f3a-c513a84dd04mr619183466b.16.1795371143413; Sun, 22 Nov 2026 10:12:23 -0800 (PST) Received: from Desktop.tail070c67.ts.net (p200300f24713a700f1770d5b08d979ed.dip0.t-ipconnect.de. [2003:f2:4713:a700:f177:d5b:8d9:79ed]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6ba370cc257sm4052567a12.13.2026.11.22.10.12.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Nov 2026 10:12:22 -0800 (PST) From: Julius Bairaktaris To: Jeff Johnson Cc: ath11k@lists.infradead.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Baochen Qiang , Jose Ignacio Tornos Martinez , Johannes Berg Subject: [PATCH ath-next 5/9] wifi: ath11k: let the TCL segment TCP batches Date: Sun, 22 Nov 2026 19:12:09 +0100 Message-ID: <20261122181213.1016590-6-julius@bairaktaris.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261122181213.1016590-1-julius@bairaktaris.de> References: <20261122181213.1016590-1-julius@bairaktaris.de> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" mac80211 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. 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. Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.12-01460-QCAHKSWPL_SILICONZ-1 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. Signed-off-by: Julius Bairaktaris --- 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 | 820 +++++++++++++++++++-- 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 | 42 +- 10 files changed, 912 insertions(+), 81 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/core.c b/drivers/net/wireless/= ath/ath11k/core.c index 34cfdedea6ad..f945a7a12744 100644 --- a/drivers/net/wireless/ath/ath11k/core.c +++ b/drivers/net/wireless/ath/ath11k/core.c @@ -120,6 +120,7 @@ static const struct ath11k_hw_params ath11k_hw_params[]= =3D { .sram_dump =3D {}, =20 .tcl_ring_retry =3D true, + .tx_tso =3D true, .tx_ring_size =3D DP_TCL_DATA_RING_SIZE, .smp2p_wow_exit =3D false, .support_dual_stations =3D false, diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/= ath/ath11k/core.h index 74fbff296b60..11c79d0f5c34 100644 --- a/drivers/net/wireless/ath/ath11k/core.h +++ b/drivers/net/wireless/ath/ath11k/core.h @@ -122,6 +122,12 @@ struct ath11k_skb_cb { u32 cipher; struct ath11k *ar; struct ieee80211_vif *vif; + /* + * 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; =20 struct ath11k_skb_rxcb { @@ -908,6 +914,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; }; diff --git a/drivers/net/wireless/ath/ath11k/debugfs.c b/drivers/net/wirele= ss/ath/ath11k/debugfs.c index ffe1f466aefb..28d3a4d8faab 100644 --- a/drivers/net/wireless/ath/ath11k/debugfs.c +++ b/drivers/net/wireless/ath/ath11k/debugfs.c @@ -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]); =20 + len +=3D scnprintf(buf + len, size - len, + "TCP batches segmented by the TCL: %d, their segments: %d, segmented i= n 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 +=3D scnprintf(buf + len, size - len, "\nSOC TX STATS:\n"); len +=3D scnprintf(buf + len, size - len, "\nTCL Ring Full Failures:\n"); =20 diff --git a/drivers/net/wireless/ath/ath11k/dp.c b/drivers/net/wireless/at= h/ath11k/dp.c index e7eab9857f29..1d131ef39b7e 100644 --- a/drivers/net/wireless/ath/ath11k/dp.c +++ b/drivers/net/wireless/ath/ath11k/dp.c @@ -1022,12 +1022,14 @@ static void ath11k_dp_tx_pending_cleanup(struct ath= 11k_base *ab, u32 id; =20 for (id =3D 0; tx_ring->bufs && id < DP_TX_IDR_SIZE - 1; id++) { - msdu =3D tx_ring->bufs[id]; + bool more; + + msdu =3D ath11k_dp_tx_buf_put_id(ab, tx_ring, id, &more, NULL); if (!msdu) continue; =20 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 =3D 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 =3D NULL; } @@ -1096,7 +1098,7 @@ int ath11k_dp_alloc(struct ath11k_base *ab) size =3D sizeof(struct hal_wbm_release_ring) * DP_TX_COMP_RING_SIZE; =20 for (i =3D 0; i < ab->hw_params.hal_params->num_tx_rings; i++) { - ret =3D ath11k_dp_tx_bufs_init(&dp->tx_ring[i]); + ret =3D 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); diff --git a/drivers/net/wireless/ath/ath11k/dp.h b/drivers/net/wireless/at= h/ath11k/dp.h index f3dcba777a34..a923ba792e4b 100644 --- a/drivers/net/wireless/ath/ath11k/dp.h +++ b/drivers/net/wireless/ath/ath11k/dp.h @@ -80,6 +80,29 @@ struct dp_rxdma_ring { =20 #define ATH11K_TX_COMPL_NEXT(x) (((x) + 1) % DP_TX_COMP_RING_SIZE) =20 +/* + * 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 diff --git a/drivers/net/wireless/ath/ath11k/dp_tx.c b/drivers/net/wireless= /ath/ath11k/dp_tx.c index feeaba575966..4fbdd15d1ce0 100644 --- a/drivers/net/wireless/ath/ath11k/dp_tx.c +++ b/drivers/net/wireless/ath/ath11k/dp_tx.c @@ -4,6 +4,9 @@ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. */ =20 +#include +#include + #include "core.h" #include "dp_tx.h" #include "debug.h" @@ -79,12 +82,36 @@ enum hal_encrypt_type ath11k_dp_tx_get_encrypt_type(u32= cipher) } } =20 +/* + * The MSDU extension descriptors of a ring fill each 4096 byte block of t= heir + * memory from its start, and none crosses into the next block. The memory + * from dma_alloc_coherent() is page aligned, so the blocks are too. + */ +#define ATH11K_DP_TX_EXT_BLOCK 4096 +#define ATH11K_DP_TX_EXT_PER_BLOCK (ATH11K_DP_TX_EXT_BLOCK / \ + sizeof(struct hal_tx_msdu_ext)) +#define ATH11K_DP_TX_EXT_SIZE (DIV_ROUND_UP(DP_TX_EXT_DESC_NUM, \ + ATH11K_DP_TX_EXT_PER_BLOCK) * \ + ATH11K_DP_TX_EXT_BLOCK) + +/* + * The buffer of the headers of an extension descriptor frame ends on this + * boundary + */ +#define ATH11K_DP_TX_EXT_ALIGN 8 + +static size_t ath11k_dp_tx_ext_off(unsigned int slot) +{ + return slot / ATH11K_DP_TX_EXT_PER_BLOCK * ATH11K_DP_TX_EXT_BLOCK + + slot % ATH11K_DP_TX_EXT_PER_BLOCK * sizeof(struct hal_tx_msdu_ext); +} + /* * The ids a ring hands out, as a table indexed by id with a stack of the = free * ones: the completion's cookie names the buffer directly. Callers of the= id * helpers hold tx_idr_lock. */ -int ath11k_dp_tx_bufs_init(struct dp_tx_ring *tx_ring) +int ath11k_dp_tx_bufs_init(struct ath11k_base *ab, struct dp_tx_ring *tx_r= ing) { u32 id; =20 @@ -92,25 +119,60 @@ int ath11k_dp_tx_bufs_init(struct dp_tx_ring *tx_ring) GFP_KERNEL); tx_ring->free_ids =3D kvcalloc(DP_TX_IDR_SIZE - 1, sizeof(*tx_ring->free_ids), GFP_KERNEL); - if (!tx_ring->bufs || !tx_ring->free_ids) { - ath11k_dp_tx_bufs_free(tx_ring); + tx_ring->ext_slot =3D kvmalloc_array(DP_TX_IDR_SIZE - 1, + sizeof(*tx_ring->ext_slot), + GFP_KERNEL); + if (ab->hw_params.tx_tso) { + tx_ring->ext =3D dma_alloc_coherent(ab->dev, ATH11K_DP_TX_EXT_SIZE, + &tx_ring->ext_paddr, + GFP_KERNEL); + tx_ring->ext_map =3D kvcalloc(DP_TX_EXT_DESC_NUM, + sizeof(*tx_ring->ext_map), + GFP_KERNEL); + tx_ring->ext_free =3D kvcalloc(DP_TX_EXT_DESC_NUM, + sizeof(*tx_ring->ext_free), + GFP_KERNEL); + } + if (!tx_ring->bufs || !tx_ring->free_ids || !tx_ring->ext_slot || + (ab->hw_params.tx_tso && + (!tx_ring->ext || !tx_ring->ext_map || !tx_ring->ext_free))) { + ath11k_dp_tx_bufs_free(ab, tx_ring); return -ENOMEM; } =20 + memset(tx_ring->ext_slot, 0xff, + (DP_TX_IDR_SIZE - 1) * sizeof(*tx_ring->ext_slot)); + tx_ring->num_free =3D 0; for (id =3D DP_TX_IDR_SIZE - 1; id--;) tx_ring->free_ids[tx_ring->num_free++] =3D id; =20 + tx_ring->ext_num_free =3D 0; + if (tx_ring->ext_free) + for (id =3D DP_TX_EXT_DESC_NUM; id--;) + tx_ring->ext_free[tx_ring->ext_num_free++] =3D id; + return 0; } =20 -void ath11k_dp_tx_bufs_free(struct dp_tx_ring *tx_ring) +void ath11k_dp_tx_bufs_free(struct ath11k_base *ab, struct dp_tx_ring *tx_= ring) { kvfree(tx_ring->bufs); kvfree(tx_ring->free_ids); + kvfree(tx_ring->ext_slot); + if (tx_ring->ext) + dma_free_coherent(ab->dev, ATH11K_DP_TX_EXT_SIZE, + tx_ring->ext, tx_ring->ext_paddr); + kvfree(tx_ring->ext_map); + kvfree(tx_ring->ext_free); tx_ring->bufs =3D NULL; tx_ring->free_ids =3D NULL; + tx_ring->ext_slot =3D NULL; + tx_ring->ext =3D NULL; + tx_ring->ext_map =3D NULL; + tx_ring->ext_free =3D NULL; tx_ring->num_free =3D 0; + tx_ring->ext_num_free =3D 0; } =20 static int ath11k_dp_tx_buf_get_id(struct dp_tx_ring *tx_ring, @@ -127,10 +189,34 @@ static int ath11k_dp_tx_buf_get_id(struct dp_tx_ring = *tx_ring, return id; } =20 -static struct sk_buff *ath11k_dp_tx_buf_put_id(struct dp_tx_ring *tx_ring, - u32 id) +static void ath11k_dp_tx_tso_unmap(struct device *dev, + struct ath11k_dp_tx_ext_map *map) +{ + while (map->num--) + dma_unmap_page(dev, map->dma[map->num], map->len[map->num], + DMA_TO_DEVICE); + map->num =3D 0; +} + +/* + * Releases the buffer of an id. A TSO segment shares its batch with the o= ther + * segments of it: this returns the batch with the completion of its last + * segment only, and NULL with *@more set before that. @seg, if given, gets + * the segment and its batch either way, for the status of the segment. + */ +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) { struct sk_buff *skb; + u16 slot; + + *more =3D false; + if (seg) { + seg->skb =3D NULL; + seg->len =3D 0; + } =20 if (unlikely(id >=3D DP_TX_IDR_SIZE - 1)) return NULL; @@ -142,25 +228,45 @@ static struct sk_buff *ath11k_dp_tx_buf_put_id(struct= dp_tx_ring *tx_ring, tx_ring->bufs[id] =3D NULL; tx_ring->free_ids[tx_ring->num_free++] =3D id; =20 + if (seg) + seg->skb =3D skb; + + slot =3D tx_ring->ext_slot[id]; + if (unlikely(slot !=3D ATH11K_DP_TX_NO_EXT)) { + if (seg) + seg->len =3D tx_ring->ext_map[slot].seg_len; + ath11k_dp_tx_tso_unmap(ab->dev, &tx_ring->ext_map[slot]); + tx_ring->ext_free[tx_ring->ext_num_free++] =3D slot; + tx_ring->ext_slot[id] =3D ATH11K_DP_TX_NO_EXT; + + if (!skb_unref(skb)) { + *more =3D true; + return NULL; + } + } + return skb; } =20 /** * ath11k_dp_tx_idr_has_room() - tell whether ath11k_dp_tx() can take a fr= ame * @tx_ring: the ring the frame would go to first + * @n: the MSDU ids the frame may need, one per segment * - * ath11k_dp_tx() takes the frame's MSDU id from the ring's free ids, of w= hich - * there are DP_TX_IDR_SIZE - 1, and the frame's completion returns it. A = caller - * that takes a frame from mac80211 only to have it refused for want of an= id - * loses the frame, so it checks first. The count is read without tx_idr_l= ock: - * an id taken in between costs that one frame, as before the check. + * ath11k_dp_tx() takes the MSDU id of each segment from the ring's free i= ds, + * of which there are DP_TX_IDR_SIZE - 1, and the segment's completion ret= urns + * it; a TCP batch the TCL cannot take whole is segmented in software and = still + * takes an id per segment. A caller that takes a frame from mac80211 only= to + * have it refused for want of an id loses the frame, so it checks first. = The + * count is read without tx_idr_lock: an id taken in between costs that one + * frame, as before the check. * - * Return: true if an id is free. + * Return: true if @n ids are free. */ -bool ath11k_dp_tx_idr_has_room(struct dp_tx_ring *tx_ring) +bool ath11k_dp_tx_idr_has_room(struct dp_tx_ring *tx_ring, int n) { /* Read without tx_idr_lock: a stale count costs at most one frame. */ - return data_race(tx_ring->num_free) !=3D 0; + return data_race(tx_ring->num_free) >=3D n; } =20 /* @@ -187,6 +293,7 @@ int ath11k_dp_tx(struct ath11k *ar, struct ath11k_vif *= arvif, u32 ring_selector =3D 0; u8 ring_map =3D 0; bool tcl_ring_retry; + bool more; =20 if (unlikely(test_bit(ATH11K_FLAG_CRASH_FLUSH, &ar->ab->dev_flags))) return -ESHUTDOWN; @@ -372,8 +479,9 @@ int ath11k_dp_tx(struct ath11k *ar, struct ath11k_vif *= arvif, =20 fail_remove_idr: spin_lock_bh(&tx_ring->tx_idr_lock); - ath11k_dp_tx_buf_put_id(tx_ring, - FIELD_GET(DP_TX_DESC_ID_MSDU_ID, ti.desc_id)); + ath11k_dp_tx_buf_put_id(ab, tx_ring, + FIELD_GET(DP_TX_DESC_ID_MSDU_ID, ti.desc_id), + &more, NULL); spin_unlock_bh(&tx_ring->tx_idr_lock); =20 if (tcl_ring_retry) @@ -382,20 +490,524 @@ int ath11k_dp_tx(struct ath11k *ar, struct ath11k_vi= f *arvif, return ret; } =20 +/* + * Maps the payload of one segment, @len bytes from *@piece at *@off, where + * piece 0 is the linear part past the headers and piece n is fragment n -= 1. + */ +static int ath11k_dp_tx_tso_map(struct device *dev, struct sk_buff *skb, + struct ath11k_dp_tx_ext_map *map, + struct hal_tx_msdu_ext *ext, + unsigned int *piece, unsigned int *off, + unsigned int len) +{ + struct skb_shared_info *shinfo =3D skb_shinfo(skb); + unsigned int avail, take; + dma_addr_t dma; + + map->num =3D 0; + while (len) { + if (!*piece) + avail =3D skb_headlen(skb) - *off; + else + avail =3D skb_frag_size(&shinfo->frags[*piece - 1]) - *off; + if (!avail) { + if (*piece =3D=3D shinfo->nr_frags) + return -EINVAL; + (*piece)++; + *off =3D 0; + continue; + } + if (map->num =3D=3D HAL_TX_MSDU_EXT_NUM_BUFS - 1) + return -E2BIG; + + take =3D min(avail, len); + /* mapped as pages, as ath11k_dp_tx_tso_unmap() unmaps them */ + if (!*piece) + dma =3D dma_map_page(dev, virt_to_page(skb->data + *off), + offset_in_page(skb->data + *off), + take, DMA_TO_DEVICE); + else + dma =3D skb_frag_dma_map(dev, &shinfo->frags[*piece - 1], + *off, take, DMA_TO_DEVICE); + if (dma_mapping_error(dev, dma)) + return -ENOMEM; + + map->dma[map->num] =3D dma; + map->len[map->num] =3D take; + map->num++; + ext->buf[map->num].addr_lo =3D lower_32_bits(dma); + ext->buf[map->num].info =3D + FIELD_PREP(HAL_TX_MSDU_EXT_BUF_INFO_ADDR_HI, + upper_32_bits(dma)) | + FIELD_PREP(HAL_TX_MSDU_EXT_BUF_INFO_LEN, take); + *off +=3D take; + len -=3D take; + } + + return 0; +} + +/* + * The frames that stay in one linear buffer: the ones the firmware and the + * stack single out by their header, which are short and rare anyway. + */ +static bool ath11k_dp_tx_ctl_frame(struct sk_buff *skb) +{ + struct ethhdr *eth =3D (struct ethhdr *)skb->data; + struct udphdr _udp, *udp; + struct ipv6hdr _ip6, *ip6; + struct iphdr _ip, *ip; + __be16 sport, dport; + + switch (ntohs(eth->h_proto)) { + case ETH_P_ARP: + case ETH_P_PAE: + return true; + case ETH_P_IP: + ip =3D skb_header_pointer(skb, ETH_HLEN, sizeof(_ip), &_ip); + if (!ip || ip->protocol !=3D IPPROTO_UDP || ip->ihl < 5) + return false; + udp =3D skb_header_pointer(skb, ETH_HLEN + ip->ihl * 4, + sizeof(_udp), &_udp); + break; + case ETH_P_IPV6: + ip6 =3D skb_header_pointer(skb, ETH_HLEN, sizeof(_ip6), &_ip6); + if (!ip6 || ip6->nexthdr !=3D IPPROTO_UDP) + return false; + udp =3D skb_header_pointer(skb, ETH_HLEN + sizeof(_ip6), + sizeof(_udp), &_udp); + break; + default: + return false; + } + + if (!udp) + return false; + + /* DHCP and DHCPv6 */ + sport =3D udp->source; + dport =3D udp->dest; + return (sport =3D=3D htons(67) || sport =3D=3D htons(68) || + dport =3D=3D htons(67) || dport =3D=3D htons(68) || + sport =3D=3D htons(546) || sport =3D=3D htons(547) || + dport =3D=3D htons(546) || dport =3D=3D htons(547)); +} + +/* + * Moves the first @len bytes of the frame, its headers, @pad bytes down i= nto + * the head room, with the offsets of the headers, so that they end @pad b= ytes + * earlier; the rest of the frame stays where it is, and the frame is @pad + * bytes longer. The caller makes sure of the head room and of a head that= is + * not shared. Undone by ath11k_dp_tx_ext_unpad(). + */ +static void ath11k_dp_tx_ext_pad(struct sk_buff *skb, unsigned int len, + unsigned int pad) +{ + skb_push(skb, pad); + memmove(skb->data, skb->data + pad, len); + if (skb_mac_header_was_set(skb)) + skb->mac_header -=3D pad; + skb->network_header -=3D pad; + if (skb_transport_header_was_set(skb)) + skb->transport_header -=3D pad; +} + +static void ath11k_dp_tx_ext_unpad(struct sk_buff *skb, unsigned int len, + unsigned int pad) +{ + memmove(skb->data + pad, skb->data, len); + skb_pull(skb, pad); + if (skb_mac_header_was_set(skb)) + skb->mac_header +=3D pad; + skb->network_header +=3D pad; + if (skb_transport_header_was_set(skb)) + skb->transport_header +=3D pad; +} + +/* + * A TCP batch, or a frame with fragments, that the TCL takes from MSDU + * extension descriptors. Each descriptor lists the buffers of one frame: = the + * linear part of the skb, which for a batch holds the headers shared by a= ll + * 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 completi= on + * of the last one reports the batch to mac80211. A frame with fragments h= as + * 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 + * taken before the first is queued. + */ +static int ath11k_dp_tx_ext(struct ath11k *ar, struct ath11k_vif *arvif, + struct sk_buff *skb, int held_ring) +{ + struct skb_shared_info *shinfo =3D skb_shinfo(skb); + struct ieee80211_tx_info *info =3D IEEE80211_SKB_CB(skb); + struct ath11k_skb_cb *skb_cb =3D ATH11K_SKB_CB(skb); + bool tso =3D skb_is_gso(skb); + unsigned int n =3D tso ? shinfo->gso_segs : 1, mss =3D shinfo->gso_size; + unsigned int hdr_len, l2_len =3D 0, ip_off =3D 0, left, piece =3D 0, off; + struct ath11k_base *ab =3D ar->ab; + struct hal_tx_info ti =3D {}; + struct dp_tx_ring *tx_ring; + struct hal_srng *tcl_ring; + u16 ids[ATH11K_DP_TX_TSO_MAX_SEGS], slots[ATH11K_DP_TX_TSO_MAX_SEGS]; + u32 seq =3D 0, flags =3D 0, ip_id =3D 0; + dma_addr_t hdr_dma; + struct tcphdr *th; + unsigned int pad; + int i, j; + + /* a crashed firmware takes no frames; the caller drops this one */ + if (unlikely(test_bit(ATH11K_FLAG_CRASH_FLUSH, &ab->dev_flags))) + return -EAGAIN; + + if (!ab->hw_params.tx_tso || + !(info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) || + ath11k_dp_tx_get_encap_type(arvif, skb) !=3D HAL_TCL_ENCAP_TYPE_ETHER= NET || + skb_has_frag_list(skb) || refcount_read(&skb->users) !=3D 1 || + n > ATH11K_DP_TX_TSO_MAX_SEGS) + return -EAGAIN; + + if (tso) { + if (!(shinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)) || + shinfo->gso_type & SKB_GSO_FRAGLIST || + skb->ip_summed !=3D CHECKSUM_PARTIAL) + return -EAGAIN; + + hdr_len =3D skb_tcp_all_headers(skb); + l2_len =3D skb_network_offset(skb); + /* + * The IP length counts the IPv4 header, but not the IPv6 one. + * An IPv6 batch with extension headers goes to software: the + * descriptor gives the TCL no length of the headers between + * the IPv6 header and TCP. + */ + ip_off =3D l2_len; + if (shinfo->gso_type & SKB_GSO_TCPV6) { + ip_off =3D l2_len + sizeof(struct ipv6hdr); + if (skb_transport_offset(skb) !=3D ip_off) + return -EAGAIN; + } + if (hdr_len > skb_headlen(skb) || l2_len > hdr_len) + return -EAGAIN; + } else { + /* the linear part is the first buffer, then the fragments */ + hdr_len =3D skb_headlen(skb); + if (!shinfo->nr_frags || + shinfo->nr_frags > HAL_TX_MSDU_EXT_NUM_BUFS - 1 || + hdr_len < ETH_HLEN || ath11k_dp_tx_ctl_frame(skb)) + return -EAGAIN; + } + + /* + * The buffer of the headers ends on an 8 byte boundary: if it does + * not, the headers move down into the head room, which has to be + * there and not be shared. + */ + pad =3D ((unsigned long)skb->data + hdr_len) & (ATH11K_DP_TX_EXT_ALIGN - = 1); + if (pad) { + if (skb_cow_head(skb, ATH11K_DP_TX_EXT_ALIGN)) + return -EAGAIN; + shinfo =3D skb_shinfo(skb); + pad =3D ((unsigned long)skb->data + hdr_len) & + (ATH11K_DP_TX_EXT_ALIGN - 1); + } + + if (held_ring >=3D 0) + ti.ring_id =3D held_ring; + else + ti.ring_id =3D ab->hw_params.hw_ops->get_ring_selector(skb_get_queue_map= ping(skb)) % + ab->hw_params.hal_params->num_tx_rings; + tx_ring =3D &ab->dp.tx_ring[ti.ring_id]; + tcl_ring =3D &ab->hal.srng_list[tx_ring->tcl_data_ring.ring_id]; + + spin_lock_bh(&tx_ring->tx_idr_lock); + if (tx_ring->num_free < n || tx_ring->ext_num_free < n) { + spin_unlock_bh(&tx_ring->tx_idr_lock); + return -EAGAIN; + } + for (i =3D 0; i < n; i++) { + slots[i] =3D tx_ring->ext_free[--tx_ring->ext_num_free]; + ids[i] =3D ath11k_dp_tx_buf_get_id(tx_ring, skb); + tx_ring->ext_slot[ids[i]] =3D slots[i]; + tx_ring->ext_map[slots[i]].num =3D 0; + } + spin_unlock_bh(&tx_ring->tx_idr_lock); + + if (pad) + ath11k_dp_tx_ext_pad(skb, hdr_len, pad); + + hdr_dma =3D dma_map_single(ab->dev, skb->data, skb_headlen(skb), + DMA_TO_DEVICE); + if (dma_mapping_error(ab->dev, hdr_dma)) { + i =3D 0; + goto fail_put; + } + + if (tso) { + th =3D tcp_hdr(skb); + seq =3D ntohl(th->seq); + flags =3D (ntohl(tcp_flag_word(th)) >> 16) & 0x1ff; + if (shinfo->gso_type & SKB_GSO_TCPV4) + ip_id =3D ntohs(ip_hdr(skb)->id); + } + + /* the payload in the linear part starts after the gap the headers left */ + off =3D hdr_len + pad; + left =3D skb->len - off; + for (i =3D 0; i < n; i++) { + struct hal_tx_msdu_ext *ext =3D (void *)tx_ring->ext + + ath11k_dp_tx_ext_off(slots[i]); + struct ath11k_dp_tx_ext_map *map =3D &tx_ring->ext_map[slots[i]]; + unsigned int len =3D tso ? min(left, mss) : left; + u32 seg_flags =3D flags; + + if (i) + seg_flags &=3D ~TCPHDR_CWR; + if (i < n - 1) + seg_flags &=3D ~(TCPHDR_FIN | TCPHDR_PSH); + + memset(ext, 0, sizeof(*ext)); + if (ath11k_dp_tx_tso_map(ab->dev, skb, map, ext, &piece, &off, + len)) { + ath11k_dp_tx_tso_unmap(ab->dev, map); + goto fail_unmap; + } + + map->seg_len =3D hdr_len + len; + + if (tso) { + ext->info0 =3D FIELD_PREP(HAL_TX_MSDU_EXT_INFO0_TSO_ENABLE, 1) | + FIELD_PREP(HAL_TX_MSDU_EXT_INFO0_TCP_FLAG, + seg_flags) | + FIELD_PREP(HAL_TX_MSDU_EXT_INFO0_TCP_FLAG_MASK, + 0x1ff); + ext->info1 =3D FIELD_PREP(HAL_TX_MSDU_EXT_INFO1_L2_LEN, + l2_len) | + FIELD_PREP(HAL_TX_MSDU_EXT_INFO1_IP_LEN, + hdr_len - ip_off + len); + ext->tcp_seq =3D seq; + ext->info3 =3D FIELD_PREP(HAL_TX_MSDU_EXT_INFO3_IP_ID, + ip_id); + } + ext->buf[0].addr_lo =3D lower_32_bits(hdr_dma); + ext->buf[0].info =3D + FIELD_PREP(HAL_TX_MSDU_EXT_BUF_INFO_ADDR_HI, + upper_32_bits(hdr_dma)) | + FIELD_PREP(HAL_TX_MSDU_EXT_BUF_INFO_LEN, hdr_len); + + seq +=3D len; + left -=3D len; + if (!(shinfo->gso_type & SKB_GSO_TCP_FIXEDID)) + ip_id =3D (ip_id + 1) & 0xffff; + } + + if (held_ring < 0) { + spin_lock_bh(&tcl_ring->lock); + ath11k_hal_srng_access_begin(ab, tcl_ring); + } + if (ath11k_hal_srng_src_num_free(ab, tcl_ring, held_ring < 0) < n) { + if (held_ring < 0) { + ath11k_hal_srng_access_end(ab, tcl_ring); + spin_unlock_bh(&tcl_ring->lock); + } + ab->soc_stats.tx_err.desc_na[ti.ring_id]++; + goto fail_unmap; + } + + skb_cb->paddr =3D hdr_dma; + skb_cb->vif =3D arvif->vif; + skb_cb->ar =3D ar; + skb_cb->tso_try =3D 0; + skb_cb->tso_bad =3D 0; + refcount_add(n - 1, &skb->users); + + ti.encap_type =3D HAL_TCL_ENCAP_TYPE_ETHERNET; + ti.meta_data_flags =3D arvif->tcl_metadata; + ti.addr_search_flags =3D arvif->hal_addr_search_flags; + ti.search_type =3D arvif->search_type; + ti.type =3D HAL_TCL_DESC_TYPE_EXT_DESC; + ti.lmac_id =3D ar->lmac_id; + ti.bss_ast_hash =3D arvif->ast_hash; + ti.bss_ast_idx =3D arvif->ast_idx; + ti.rbm_id =3D ab->hw_params.hal_params->tcl2wbm_rbm_map[ti.ring_id].rbm_i= d; + ti.tid =3D ath11k_dp_tx_get_tid(skb); + /* the IP, UDP and TCP checksum enables together, also for a batch */ + if (skb->ip_summed =3D=3D CHECKSUM_PARTIAL) + ti.flags0 =3D FIELD_PREP(HAL_TCL_DATA_CMD_INFO1_IP4_CKSUM_EN, 1) | + FIELD_PREP(HAL_TCL_DATA_CMD_INFO1_UDP4_CKSUM_EN, 1) | + FIELD_PREP(HAL_TCL_DATA_CMD_INFO1_UDP6_CKSUM_EN, 1) | + FIELD_PREP(HAL_TCL_DATA_CMD_INFO1_TCP4_CKSUM_EN, 1) | + FIELD_PREP(HAL_TCL_DATA_CMD_INFO1_TCP6_CKSUM_EN, 1); + if (ieee80211_vif_is_mesh(arvif->vif)) + ti.enable_mesh =3D true; + ti.flags1 =3D FIELD_PREP(HAL_TCL_DATA_CMD_INFO2_TID_OVERWRITE, 1); + /* the TCL reads this much of the extension descriptor */ + ti.data_len =3D sizeof(*tx_ring->ext); + + for (i =3D 0; i < n; i++) { + void *desc; + + ti.desc_id =3D FIELD_PREP(DP_TX_DESC_ID_MAC_ID, ar->pdev_idx) | + FIELD_PREP(DP_TX_DESC_ID_MSDU_ID, ids[i]) | + FIELD_PREP(DP_TX_DESC_ID_POOL_ID, + skb_get_queue_mapping(skb) & + (ATH11K_HW_MAX_QUEUES - 1)); + ti.paddr =3D tx_ring->ext_paddr + ath11k_dp_tx_ext_off(slots[i]); + /* the command follows the TLV header of the ring entry */ + desc =3D ath11k_hal_srng_src_get_next_entry(ab, tcl_ring); + ath11k_hal_tx_cmd_desc_setup(ab, desc + sizeof(struct hal_tlv_hdr), + &ti); + } + + if (held_ring < 0) { + /* as the TXQ push: no ring update once the firmware crashed */ + if (likely(!test_bit(ATH11K_FLAG_CRASH_FLUSH, &ab->dev_flags))) { + ath11k_hal_srng_access_end(ab, tcl_ring); + ath11k_dp_shadow_start_timer(ab, tcl_ring, + &ab->dp.tx_ring_timer[ti.ring_id]); + } + spin_unlock_bh(&tcl_ring->lock); + } + + atomic_add(n, &ar->dp.num_tx_pending); + if (tso) { + atomic_inc(&ab->soc_stats.tx_tso_batch); + atomic_add(n, &ab->soc_stats.tx_tso_seg); + } else { + atomic_inc(&ab->soc_stats.tx_sg); + } + + return 0; + +fail_unmap: + for (j =3D 0; j < i; j++) + ath11k_dp_tx_tso_unmap(ab->dev, &tx_ring->ext_map[slots[j]]); + dma_unmap_single(ab->dev, hdr_dma, skb_headlen(skb), DMA_TO_DEVICE); +fail_put: + if (pad) + ath11k_dp_tx_ext_unpad(skb, hdr_len, pad); + spin_lock_bh(&tx_ring->tx_idr_lock); + for (j =3D n; j--;) { + /* no reference was taken yet: release the id and slot only */ + tx_ring->bufs[ids[j]] =3D NULL; + tx_ring->free_ids[tx_ring->num_free++] =3D ids[j]; + tx_ring->ext_slot[ids[j]] =3D ATH11K_DP_TX_NO_EXT; + tx_ring->ext_free[tx_ring->ext_num_free++] =3D slots[j]; + } + spin_unlock_bh(&tx_ring->tx_idr_lock); + + return -EAGAIN; +} + +/* + * A frame with fragments, sent as scatter-gather. Returns -EAGAIN, with t= he + * frame untouched, for one that has to be made linear instead. + */ +int ath11k_dp_tx_sg(struct ath11k *ar, struct ath11k_vif *arvif, + struct sk_buff *skb, int held_ring) +{ + return ath11k_dp_tx_ext(ar, arvif, skb, held_ring); +} + +/* + * A GSO frame from mac80211 is a batch of frames. The TCL takes a TCP bat= ch + * whole; any other, and a batch the TCL cannot take, is split into frames + * here. The frames share the one status mac80211 expects, and the one air= time + * charge of the batch: the last frame reports the status with the charge, + * and the others carry none. + */ +int ath11k_dp_tx_gso(struct ath11k *ar, struct ath11k_vif *arvif, + struct ath11k_sta *arsta, struct sk_buff *skb, + int held_ring) +{ + struct sk_buff *segs, *seg, *next; + struct ieee80211_tx_info *info; + int ret =3D 0; + + if (!ath11k_dp_tx_ext(ar, arvif, skb, held_ring)) + return 0; + + atomic_inc(&ar->ab->soc_stats.tx_tso_sw); + + segs =3D skb_gso_segment(skb, NETIF_F_HW_CSUM); + if (IS_ERR_OR_NULL(segs)) { + ieee80211_free_txskb(ar->hw, skb); + return segs ? PTR_ERR(segs) : -ENOMEM; + } + + /* the frames copy the control buffer, and so the charge */ + consume_skb(skb); + + skb_list_walk_safe(segs, seg, next) { + skb_mark_not_on_list(seg); + if (next) { + info =3D IEEE80211_SKB_CB(seg); + info->tx_time_est =3D 0; + } + if (ret) { + ieee80211_free_txskb(ar->hw, seg); + continue; + } + ret =3D ath11k_dp_tx(ar, arvif, arsta, seg, held_ring); + if (ret) + ieee80211_free_txskb(ar->hw, seg); + } + + return ret; +} + +/* + * Whether a segment went out as the frame asked: acked, or sent when it a= sked + * for no ack. + */ +static bool ath11k_dp_tx_seg_ok(struct sk_buff *skb, enum hal_wbm_tqm_rel_= reason status) +{ + if (IEEE80211_SKB_CB(skb)->flags & IEEE80211_TX_CTL_NO_ACK) + return status =3D=3D HAL_WBM_TQM_REL_REASON_CMD_REMOVE_TX; + + return status =3D=3D HAL_WBM_TQM_REL_REASON_FRAME_ACKED; +} + +/* + * Notes the status of a segment that is not the last of its batch: the ba= tch + * is acked only if every segment is, and its tries are the most of any se= gment. + */ +static void ath11k_dp_tx_seg_note(struct sk_buff *batch, bool ok, u8 try_c= nt) +{ + struct ath11k_skb_cb *skb_cb =3D ATH11K_SKB_CB(batch); + + if (!ok && skb_cb->tso_bad < U8_MAX) + skb_cb->tso_bad++; + if (try_cnt > skb_cb->tso_try) + skb_cb->tso_try =3D try_cnt; +} + static void ath11k_dp_tx_free_txbuf(struct ath11k_base *ab, u8 mac_id, int msdu_id, struct dp_tx_ring *tx_ring, unsigned long *push) { - struct ath11k *ar; + struct ath11k *ar =3D ab->pdevs[mac_id].ar; struct sk_buff *msdu; + struct ath11k_dp_tx_seg seg; struct ath11k_skb_cb *skb_cb; + bool more; =20 spin_lock(&tx_ring->tx_idr_lock); - msdu =3D ath11k_dp_tx_buf_put_id(tx_ring, msdu_id); + msdu =3D ath11k_dp_tx_buf_put_id(ab, tx_ring, msdu_id, &more, &seg); spin_unlock(&tx_ring->tx_idr_lock); =20 if (unlikely(!msdu)) { + if (more) { + /* the segment was not sent, and so is not acked */ + ath11k_dp_tx_seg_note(seg.skb, false, 0); + if (atomic_dec_and_test(&ar->dp.num_tx_pending)) + wake_up(&ar->dp.tx_empty_waitq); + return; + } ath11k_warn(ab, "tx completion for unknown msdu_id %d\n", msdu_id); return; @@ -403,9 +1015,9 @@ static void ath11k_dp_tx_free_txbuf(struct ath11k_base= *ab, u8 mac_id, =20 skb_cb =3D ATH11K_SKB_CB(msdu); =20 - dma_unmap_single(ab->dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE); + dma_unmap_single(ab->dev, skb_cb->paddr, skb_headlen(msdu), + DMA_TO_DEVICE); =20 - ar =3D ab->pdevs[mac_id].ar; __set_bit(mac_id * IEEE80211_NUM_ACS + skb_get_queue_mapping(msdu), push); ieee80211_free_txskb(ar->hw, msdu); @@ -428,6 +1040,7 @@ void ath11k_dp_tx_free_pending(struct ath11k_base *ab) struct dp_tx_ring *tx_ring; struct sk_buff *msdu; int i, msdu_id; + bool more; =20 __skb_queue_head_init(&pending); =20 @@ -437,7 +1050,8 @@ void ath11k_dp_tx_free_pending(struct ath11k_base *ab) spin_lock_bh(&tx_ring->tx_idr_lock); for (msdu_id =3D 0; tx_ring->bufs && msdu_id < DP_TX_IDR_SIZE - 1; msdu_id++) { - msdu =3D ath11k_dp_tx_buf_put_id(tx_ring, msdu_id); + msdu =3D ath11k_dp_tx_buf_put_id(ab, tx_ring, msdu_id, + &more, NULL); if (msdu) __skb_queue_tail(&pending, msdu); } @@ -446,14 +1060,14 @@ void ath11k_dp_tx_free_pending(struct ath11k_base *a= b) =20 while ((msdu =3D __skb_dequeue(&pending))) { skb_cb =3D ATH11K_SKB_CB(msdu); - dma_unmap_single(ab->dev, skb_cb->paddr, msdu->len, + dma_unmap_single(ab->dev, skb_cb->paddr, skb_headlen(msdu), DMA_TO_DEVICE); ieee80211_free_txskb(skb_cb->ar->hw, msdu); } } =20 static void -ath11k_dp_tx_htt_tx_complete_buf(struct ath11k_base *ab, +ath11k_dp_tx_htt_tx_complete_buf(struct ath11k_base *ab, u8 mac_id, struct dp_tx_ring *tx_ring, struct ath11k_dp_htt_wbm_tx_status *ts, unsigned long *push) @@ -461,15 +1075,25 @@ ath11k_dp_tx_htt_tx_complete_buf(struct ath11k_base = *ab, struct ieee80211_tx_status status =3D {}; struct sk_buff *msdu; struct ieee80211_tx_info *info; + struct ath11k_dp_tx_seg seg; struct ath11k_skb_cb *skb_cb; struct ath11k *ar; struct ath11k_peer *peer; + bool more; + bool batch_ok; =20 spin_lock(&tx_ring->tx_idr_lock); - msdu =3D ath11k_dp_tx_buf_put_id(tx_ring, ts->msdu_id); + msdu =3D ath11k_dp_tx_buf_put_id(ab, tx_ring, ts->msdu_id, &more, &seg); spin_unlock(&tx_ring->tx_idr_lock); =20 if (unlikely(!msdu)) { + if (more) { + ath11k_dp_tx_seg_note(seg.skb, ts->acked, 0); + ar =3D ab->pdevs[mac_id].ar; + if (atomic_dec_and_test(&ar->dp.num_tx_pending)) + wake_up(&ar->dp.tx_empty_waitq); + return; + } ath11k_warn(ab, "htt tx completion for unknown msdu_id %d\n", ts->msdu_id); return; @@ -485,16 +1109,20 @@ ath11k_dp_tx_htt_tx_complete_buf(struct ath11k_base = *ab, if (atomic_dec_and_test(&ar->dp.num_tx_pending)) wake_up(&ar->dp.tx_empty_waitq); =20 - dma_unmap_single(ab->dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE); + dma_unmap_single(ab->dev, skb_cb->paddr, skb_headlen(msdu), + DMA_TO_DEVICE); =20 if (!skb_cb->vif) { ieee80211_free_txskb(ar->hw, msdu); return; } =20 + /* the notes of the other segments of a batch share the status */ + batch_ok =3D !seg.len || !skb_cb->tso_bad; + memset(&info->status, 0, sizeof(info->status)); =20 - if (ts->acked) { + if (ts->acked && batch_ok) { if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) { info->flags |=3D IEEE80211_TX_STAT_ACK; info->status.ack_signal =3D ts->ack_rssi; @@ -558,7 +1186,8 @@ ath11k_dp_tx_process_htt_tx_complete(struct ath11k_bas= e *ab, else ts.peer_id =3D HTT_INVALID_PEER_ID; =20 - ath11k_dp_tx_htt_tx_complete_buf(ab, tx_ring, &ts, push); + ath11k_dp_tx_htt_tx_complete_buf(ab, mac_id, tx_ring, &ts, + push); =20 break; case HAL_WBM_REL_HTT_TX_COMP_STATUS_REINJ: @@ -576,19 +1205,18 @@ ath11k_dp_tx_process_htt_tx_complete(struct ath11k_b= ase *ab, } } =20 -static void ath11k_dp_tx_cache_peer_stats(struct ath11k *ar, - struct sk_buff *msdu, +static void ath11k_dp_tx_cache_peer_stats(struct ath11k *ar, u32 len, struct hal_tx_status *ts) { struct ath11k_per_peer_tx_stats *peer_stats =3D &ar->cached_stats; =20 if (ts->try_cnt > 1) { peer_stats->retry_pkts +=3D ts->try_cnt - 1; - peer_stats->retry_bytes +=3D (ts->try_cnt - 1) * msdu->len; + peer_stats->retry_bytes +=3D (ts->try_cnt - 1) * len; =20 if (ts->status !=3D HAL_WBM_TQM_REL_REASON_FRAME_ACKED) { peer_stats->failed_pkts +=3D 1; - peer_stats->failed_bytes +=3D msdu->len; + peer_stats->failed_bytes +=3D len; } } } @@ -709,10 +1337,62 @@ struct ath11k_dp_tx_compl { u16 peer_id; }; =20 +/* + * The statistics of the stations that the completion of every frame feeds, + * @len bytes long: the frame, or the segment of a batch. + */ +static void ath11k_dp_tx_account(struct ath11k *ar, u32 len, + struct hal_tx_status *ts) +{ + if (likely(!ath11k_debugfs_is_extd_tx_stats_enabled(ar) && + !ar->ab->hw_params.single_pdev_only)) + return; + + if (ts->flags & HAL_TX_STATUS_FLAGS_FIRST_MSDU) { + if (ar->last_ppdu_id =3D=3D 0) { + ar->last_ppdu_id =3D ts->ppdu_id; + } else if (ar->last_ppdu_id =3D=3D ts->ppdu_id || + ar->cached_ppdu_id =3D=3D ar->last_ppdu_id) { + ar->cached_ppdu_id =3D ar->last_ppdu_id; + ar->cached_stats.is_ampdu =3D true; + ath11k_dp_tx_update_txcompl(ar, ts); + memset(&ar->cached_stats, 0, + sizeof(struct ath11k_per_peer_tx_stats)); + } else { + ar->cached_stats.is_ampdu =3D false; + ath11k_dp_tx_update_txcompl(ar, ts); + memset(&ar->cached_stats, 0, + sizeof(struct ath11k_per_peer_tx_stats)); + } + ar->last_ppdu_id =3D ts->ppdu_id; + } + + ath11k_dp_tx_cache_peer_stats(ar, len, ts); +} + +/* + * The completion of a segment that is not the last of its batch. Its + * statistics count as those of a frame, and its status goes into the stat= us + * of the batch, which the completion of the last segment reports. + */ +static void ath11k_dp_tx_complete_seg(struct ath11k *ar, struct sk_buff *b= atch, + struct hal_tx_status *ts, u16 seg_len) +{ + if (WARN_ON_ONCE(ts->buf_rel_source !=3D HAL_WBM_REL_SRC_MODULE_TQM)) + return; + + ath11k_dp_tx_seg_note(batch, ath11k_dp_tx_seg_ok(batch, ts->status), + ts->try_cnt); + + if (likely(rcu_access_pointer(ar->ab->pdevs_active[ar->pdev_idx]))) + ath11k_dp_tx_account(ar, seg_len, ts); +} + static void ath11k_dp_tx_complete_msdu(struct ath11k *ar, struct sk_buff *msdu, struct hal_tx_status *ts, - struct ath11k_dp_tx_compl *c) + struct ath11k_dp_tx_compl *c, + u16 seg_len) { struct ieee80211_tx_status status =3D {}; struct ieee80211_rate_status status_rate =3D {}; @@ -720,6 +1400,8 @@ 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; + bool ok; + u8 try_cnt; =20 if (WARN_ON_ONCE(ts->buf_rel_source !=3D HAL_WBM_REL_SRC_MODULE_TQM)) { /* Must not happen */ @@ -728,7 +1410,8 @@ static void ath11k_dp_tx_complete_msdu(struct ath11k *= ar, =20 skb_cb =3D ATH11K_SKB_CB(msdu); =20 - dma_unmap_single(ab->dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE); + dma_unmap_single(ab->dev, skb_cb->paddr, skb_headlen(msdu), + DMA_TO_DEVICE); =20 if (unlikely(!rcu_access_pointer(ab->pdevs_active[ar->pdev_idx]))) { ieee80211_free_txskb(ar->hw, msdu); @@ -741,13 +1424,27 @@ static void ath11k_dp_tx_complete_msdu(struct ath11k= *ar, } =20 info =3D IEEE80211_SKB_CB(msdu); + + /* + * A batch is acked only if all its segments are, and takes the most + * tries of any: mac80211 reads the tries as those of one frame at one + * rate, which a sum over the segments would overstate by their number. + * The notes of the other segments are in the driver's part of the + * buffer that the status overwrites. + */ + ok =3D ath11k_dp_tx_seg_ok(msdu, ts->status); + try_cnt =3D ts->try_cnt; + if (seg_len) { + ok =3D ok && !skb_cb->tso_bad; + try_cnt =3D max(try_cnt, skb_cb->tso_try); + } + memset(&info->status, 0, sizeof(info->status)); =20 /* skip tx rate update from ieee80211_status*/ info->status.rates[0].idx =3D -1; =20 - if (ts->status =3D=3D HAL_WBM_TQM_REL_REASON_FRAME_ACKED && - !(info->flags & IEEE80211_TX_CTL_NO_ACK)) { + if (ok && !(info->flags & IEEE80211_TX_CTL_NO_ACK)) { info->flags |=3D IEEE80211_TX_STAT_ACK; info->status.ack_signal =3D ts->ack_rssi; =20 @@ -758,33 +1455,10 @@ static void ath11k_dp_tx_complete_msdu(struct ath11k= *ar, info->status.flags |=3D IEEE80211_TX_STATUS_ACK_SIGNAL_VALID; } =20 - if (ts->status =3D=3D HAL_WBM_TQM_REL_REASON_CMD_REMOVE_TX && - (info->flags & IEEE80211_TX_CTL_NO_ACK)) + if (ok && (info->flags & IEEE80211_TX_CTL_NO_ACK)) info->flags |=3D IEEE80211_TX_STAT_NOACK_TRANSMITTED; =20 - if (unlikely(ath11k_debugfs_is_extd_tx_stats_enabled(ar)) || - ab->hw_params.single_pdev_only) { - if (ts->flags & HAL_TX_STATUS_FLAGS_FIRST_MSDU) { - if (ar->last_ppdu_id =3D=3D 0) { - ar->last_ppdu_id =3D ts->ppdu_id; - } else if (ar->last_ppdu_id =3D=3D ts->ppdu_id || - ar->cached_ppdu_id =3D=3D ar->last_ppdu_id) { - ar->cached_ppdu_id =3D ar->last_ppdu_id; - ar->cached_stats.is_ampdu =3D true; - ath11k_dp_tx_update_txcompl(ar, ts); - memset(&ar->cached_stats, 0, - sizeof(struct ath11k_per_peer_tx_stats)); - } else { - ar->cached_stats.is_ampdu =3D false; - ath11k_dp_tx_update_txcompl(ar, ts); - memset(&ar->cached_stats, 0, - sizeof(struct ath11k_per_peer_tx_stats)); - } - ar->last_ppdu_id =3D ts->ppdu_id; - } - - ath11k_dp_tx_cache_peer_stats(ar, msdu, ts); - } + ath11k_dp_tx_account(ar, seg_len ?: msdu->len, ts); =20 if (!c->sta || c->peer_id !=3D ts->peer_id) { spin_lock_bh(&ab->base_lock); @@ -809,7 +1483,7 @@ static void ath11k_dp_tx_complete_msdu(struct ath11k *= ar, status.free_list =3D &c->free; =20 status_rate.rate_idx =3D c->rate; - status_rate.try_count =3D 1; + status_rate.try_count =3D max_t(u8, try_cnt, 1); =20 status.rates =3D &status_rate; status.n_rates =3D 1; @@ -859,12 +1533,14 @@ int ath11k_dp_tx_completion_handler(struct ath11k_ba= se *ab, int ring_id, struct hal_tx_status ts =3D {}; struct dp_tx_ring *tx_ring =3D &dp->tx_ring[ring_id]; struct ath11k_dp_tx_compl c =3D { .free =3D LIST_HEAD_INIT(c.free) }; + struct ath11k_dp_tx_seg seg; struct sk_buff *tmp; unsigned long push =3D 0; int done =3D 0; u32 *desc; u32 msdu_id; u8 mac_id, i; + bool more; =20 spin_lock_bh(&status_ring->lock); =20 @@ -916,24 +1592,32 @@ int ath11k_dp_tx_completion_handler(struct ath11k_ba= se *ab, int ring_id, } =20 spin_lock(&tx_ring->tx_idr_lock); - msdu =3D ath11k_dp_tx_buf_put_id(tx_ring, msdu_id); + msdu =3D ath11k_dp_tx_buf_put_id(ab, tx_ring, msdu_id, &more, + &seg); + spin_unlock(&tx_ring->tx_idr_lock); + + ar =3D ab->pdevs[mac_id].ar; + if (unlikely(!msdu)) { + /* not the last segment of a batch */ + if (more) { + ath11k_dp_tx_complete_seg(ar, seg.skb, &ts, + seg.len); + if (atomic_dec_and_test(&ar->dp.num_tx_pending)) + wake_up(&ar->dp.tx_empty_waitq); + continue; + } ath11k_warn(ab, "tx completion for unknown msdu_id %d\n", msdu_id); - spin_unlock(&tx_ring->tx_idr_lock); continue; } - - spin_unlock(&tx_ring->tx_idr_lock); - - ar =3D ab->pdevs[mac_id].ar; __set_bit(mac_id * IEEE80211_NUM_ACS + skb_get_queue_mapping(msdu), &push); =20 if (atomic_dec_and_test(&ar->dp.num_tx_pending)) wake_up(&ar->dp.tx_empty_waitq); =20 - ath11k_dp_tx_complete_msdu(ar, msdu, &ts, &c); + ath11k_dp_tx_complete_msdu(ar, msdu, &ts, &c, seg.len); } =20 list_for_each_entry_safe(msdu, tmp, &c.free, list) { diff --git a/drivers/net/wireless/ath/ath11k/dp_tx.h b/drivers/net/wireless= /ath/ath11k/dp_tx.h index 50b6178ceb38..967f212d33db 100644 --- a/drivers/net/wireless/ath/ath11k/dp_tx.h +++ b/drivers/net/wireless/ath/ath11k/dp_tx.h @@ -21,9 +21,18 @@ void ath11k_dp_tx_update_txcompl(struct ath11k *ar, stru= ct 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 ath11k_sta *arsta, 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_r= ing); +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); diff --git a/drivers/net/wireless/ath/ath11k/hal_desc.h b/drivers/net/wirel= ess/ath/ath11k/hal_desc.h index c8b01f6921c0..d10cd6735ffb 100644 --- a/drivers/net/wireless/ath/ath11k/hal_desc.h +++ b/drivers/net/wireless/ath/ath11k/hal_desc.h @@ -1023,6 +1023,52 @@ enum hal_wbm_htt_tx_comp_status { HAL_WBM_REL_HTT_TX_COMP_STATUS_MEC_NOTIFY, }; =20 +#define HAL_TX_MSDU_EXT_INFO0_TSO_ENABLE BIT(0) +#define HAL_TX_MSDU_EXT_INFO0_TCP_FLAG GENMASK(15, 7) +#define HAL_TX_MSDU_EXT_INFO0_TCP_FLAG_MASK GENMASK(24, 16) +#define HAL_TX_MSDU_EXT_INFO1_L2_LEN GENMASK(15, 0) +#define HAL_TX_MSDU_EXT_INFO1_IP_LEN GENMASK(31, 16) +#define HAL_TX_MSDU_EXT_INFO3_IP_ID GENMASK(15, 0) +#define HAL_TX_MSDU_EXT_BUF_INFO_ADDR_HI GENMASK(7, 0) +#define HAL_TX_MSDU_EXT_BUF_INFO_LEN GENMASK(31, 16) +#define HAL_TX_MSDU_EXT_NUM_BUFS 6 + +struct hal_tx_msdu_ext_buf { + u32 addr_lo; + u32 info; +} __packed; + +struct hal_tx_msdu_ext { + u32 info0; + u32 info1; + u32 tcp_seq; + u32 info3; + u32 info4; + u32 info5; + struct hal_tx_msdu_ext_buf buf[HAL_TX_MSDU_EXT_NUM_BUFS]; +} __packed; + +/* + * hal_tx_msdu_ext + * + * A TCL data command of type HAL_TCL_DESC_TYPE_EXT_DESC points at + * this descriptor instead of at the frame. + * + * tso_enable + * The TCL writes tcp_flag under tcp_flag_mask, the IP length, + * the IP ID and the TCP sequence number into the headers in + * the first buffer, and fills in the checksums the TCL data + * command enables. + * + * l2_length, ip_length + * The length of the L2 header, and the IP length of the packet + * this descriptor makes: the IPv4 total length, or the IPv6 + * payload length. + * + * buf + * Up to six buffers that make up the frame, in order. + */ + struct hal_tcl_data_cmd { struct ath11k_buffer_addr buf_addr_info; u32 info0; diff --git a/drivers/net/wireless/ath/ath11k/hw.h b/drivers/net/wireless/at= h/ath11k/hw.h index b6bc8b72d812..2cf34af05f8f 100644 --- a/drivers/net/wireless/ath/ath11k/hw.h +++ b/drivers/net/wireless/ath/ath11k/hw.h @@ -223,6 +223,7 @@ struct ath11k_hw_params { } sram_dump; =20 bool tcl_ring_retry; + bool tx_tso; u32 tx_ring_size; bool smp2p_wow_exit; bool support_fw_mac_sequence; diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/a= th/ath11k/mac.c index 513559585371..5f2086bf6c5d 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -6559,6 +6559,25 @@ static int ath11k_mac_tx(struct ieee80211_hw *hw, if (control->sta) arsta =3D ath11k_sta_to_arsta(control->sta); =20 + /* + * A GSO frame is taken whole by the TCL, or split here. A frame with + * fragments goes to the TCL as scatter-gather, and is made linear + * only if the TCL cannot take it that way. They free the frame + * themselves when they fail. + */ + if (skb_is_gso(skb)) + return ath11k_dp_tx_gso(ar, arvif, arsta, skb, held_ring); + + if (unlikely(skb_is_nonlinear(skb))) { + if (!ath11k_dp_tx_sg(ar, arvif, skb, held_ring)) + return 0; + + if (skb_linearize(skb)) { + ieee80211_free_txskb(ar->hw, skb); + return -ENOMEM; + } + } + ret =3D ath11k_dp_tx(ar, arvif, arsta, skb, held_ring); if (unlikely(ret)) { ath11k_warn(ar->ab, "failed to transmit frame %d\n", ret); @@ -10123,10 +10142,20 @@ static int ath11k_mac_tx_push_txq(struct ath11k *= ar, struct ieee80211_txq *txq) struct hal_srng *tcl_ring; struct sk_buff *skb; u32 ring_selector; - int num_free, avail; + int num_free, avail, reserve; int ret; u8 ring_id; =20 + /* + * A GSO frame uses a ring entry for each of its segments, at most + * ATH11K_DP_TX_TSO_MAX_SEGS, and its frame is not known before it + * is dequeued: a frame is taken only while a batch of that size + * fits. Only a vif with the encap offload gets GSO frames. + */ + reserve =3D ar->ab->hw_params.tx_tso && + (txq->vif->offload_flags & IEEE80211_OFFLOAD_ENCAP_ENABLED) ? + ATH11K_DP_TX_TSO_MAX_SEGS : 1; + ring_selector =3D ar->ab->hw_params.hw_ops->get_ring_selector(txq->ac); ring_id =3D ring_selector % ar->ab->hw_params.hal_params->num_tx_rings; tx_ring =3D &ar->ab->dp.tx_ring[ring_id]; @@ -10155,12 +10184,14 @@ static int ath11k_mac_tx_push_txq(struct ath11k *= ar, struct ieee80211_txq *txq) avail =3D num_free; =20 ret =3D 0; - while (num_free) { + while (num_free >=3D reserve) { + int used; + if (unlikely(test_bit(ATH11K_FLAG_CRASH_FLUSH, &ar->ab->dev_flags))) break; =20 - if (!ath11k_dp_tx_idr_has_room(tx_ring)) { + if (!ath11k_dp_tx_idr_has_room(tx_ring, reserve)) { ret =3D -ENOSPC; break; } @@ -10169,11 +10200,12 @@ static int ath11k_mac_tx_push_txq(struct ath11k *= ar, struct ieee80211_txq *txq) if (!skb) break; =20 + used =3D skb_is_gso(skb) ? skb_shinfo(skb)->gso_segs : 1; ret =3D ath11k_mac_tx(hw, &control, skb, ring_id); if (unlikely(ret =3D=3D -ENOSPC || ret =3D=3D -ENOMEM)) break; ret =3D 0; - num_free--; + num_free -=3D min(used, num_free); } =20 if (num_free !=3D avail && @@ -10185,7 +10217,7 @@ static int ath11k_mac_tx_push_txq(struct ath11k *ar= , struct ieee80211_txq *txq) spin_unlock_bh(&tcl_ring->lock); spin_unlock_bh(&tx_ring->wake_tx_lock); =20 - if (!num_free) + if (num_free < reserve) ret =3D -ENOSPC; if (unlikely(ret =3D=3D -ENOSPC || ret =3D=3D -ENOMEM)) { if (ath11k_mac_mark_txq_starved(ar, txq->ac)) --=20 2.53.0 From nobody Tue Nov 24 11:44:06 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.208.48 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795371147; b=PgsuVn+y15aagWhH/zJiABsQkOWw61/qEFKlg2Bn3oAdUiFRPRbY3mJPgNOscPB+eWYM ciP9812OoYAZ9hxbJaIVP7noLtEwi1bF/vRfCkf3mS5pIdNvOtQ4+FumpDMR3ju9neld/ zBn3MPT6wRYSKMryQXGWgYPskeUtPPQZ8CgDNV5DBIxPc5DTBlymSAtbRK6k9O41uH10g RI+k9FN08ngqD6KaDPg1Nx1qO4LpZ6TH0vA6fUwkPdMsCwl5FQLMoK5rjra8cQVEv6iXR boWnE21iPLNX/Z+ZK7BWQkPT+RmadoB1qLjkRZQgZIv/01uG0iTSvuGeguhTxHnF1TA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795371147; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=v95im3Rj7N/9zvLa+rvIlqTu9zDfSCo/goL8nxf3T7A=; b=It6wfLjoe91fROVRXh8A4SWEGZk8SZFQKgl/2tAYaxcFn6bhpWNvasMlYrkiJyuPuL/i uewGnBnD7Xh03DO2hlbTJIuLRMv/SklhO7rfvREocDCCSTcic7PWOEq8It4KuKpy1MgHP iRQi7n7PBYDpuMOtWeCX+zywUt2zZGZKQwmdy9fE6QBc0L/qxuu5bCRjlTmtBPieQRqpn 9GfKF9xCetKruH2/BXwvUwAB0T7WsUdexXpDumVAQGKYUPHUcxvWl6HO00KFbaihGC+hf GTysR2FpPNiRlEA9YX/WWh6QW1MAvbDLpOjBWoT8oXNC3aFm3kIJGFmC3QPLcEurhOg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=bairaktaris.de; spf=pass smtp.mailfrom=bairaktaris.de; dkim=pass header.d=bairaktaris.de header.i=@bairaktaris.de header.a=rsa-sha256 header.s=google header.b="j/GaYwEJ"; arc=none smtp.remote-ip=209.85.208.48 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 30910606A680 for ; Sun, 22 Nov 2026 18:12:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 30910606A680 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bairaktaris.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bairaktaris.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bairaktaris.de header.i=@bairaktaris.de header.a=rsa-sha256 header.s=google header.b=j/GaYwEJ Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-6b8977f2785so3395299a12.3 for ; Sun, 22 Nov 2026 10:12:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bairaktaris.de; s=google; t=1795371145; x=1795975945; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=v95im3Rj7N/9zvLa+rvIlqTu9zDfSCo/goL8nxf3T7A=; b=j/GaYwEJmmU916yqS+cd1VYn4bpJYyzyT59IwuexB9AIxkK4NVDVaznebjh4789eFf jymY995I5fIuwLOuu4AXYcVWQL53pWPjiZ2EvjU/JpNfOb9NLFdPW5EQRdUvwqwpCoK4 CdKDtYjo/x2/RmZFaSbeMMYtwzuuiHhVd2lOsEmvvj28tky0Bp567+cI4gV1cRmhP8sy djyXxolHRTaGL2Fa56Z7azWE4TSIEMBvf5bLUGaxvv+Hir0NaDk8PVkX26a5KV3DhKy/ U+UF+QqPceUm6+KnojVt3Sy9Q6UFLMlKVBnFKhsQHjEaCyQzM1XmT9VWJyHpzkDIu40W 0JhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795371145; x=1795975945; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=v95im3Rj7N/9zvLa+rvIlqTu9zDfSCo/goL8nxf3T7A=; b=19wFpHGGJ3UAyPLJDgr/1epJJkyw5fJcWbIDqaL0o6Tj6oseYOFy+BpyWCB6LfH2r/ oCSIXDrxkSeScXOJ9tY5tKoR0YYZ5oOmrHJSxyA60MQGUCTkmK7lqYOQTCkfIB4Ptkmu XjsjhqUiCimdDTv8M5duS7iHjDdMI310XUQ8Y6QJfURnATeIYEhoKAXNHvOqqYAQl6fw 8nCrfbkMG+5j0ymF9bp6pzN8PDHXwmHjUqyCrDPf+uA3DEI0Pod5uzelGCuyqbT9IJLc nZERgH5LaMipmrikY8LFyOmKZyCV8fdtseJl4iGIDg+U4neeW5b6kElzDiBQYqOG92fW nHXg== X-Forwarded-Encrypted: i=1; AL+hErEs3DUe0enQErG/uQNjYolHobqRSBiXGYATmtyP9GbcQfODFNYI/JESCAws9l8L0S8qDz/zgYEJ0A3StXA=@vger.kernel.org X-Gm-Message-State: APuU4Z//xyLU/YxFQS/L4lVoaWXThch5UfQxyIg63bjoGOfqXNrrpu6O CbhCifW06KEY50mB2sHcuYl8Nwgz1zvBUseJ9kGtEmuCZv8BSBsOSA2Ql5Tk1MIvNZYli7NFT25 fG3CQcm10 X-Gm-Gg: AZFdTZcxIkQbZPIgbT8vK6bK2UW1qvwFLydqMx7gOY9jbh5UW+T0n+6qXbxSYGJ+9ZV B6mb/2vTRi2VdVegFuEbeR6lBR5FNENmnnf0PR+oE+CG+nBTilV2PU0qJpY3+Yly8n465dT9bFb DIfNaNJpnKyQ9HG6cJy5Qq7fz/zIaLNynQvtXajMlp5wZ+PNcOBKORhBjKEcsPpiBUkzKv5xbgI 9RvWk5zwvUNKTlAFadXPZXDMtP9GDYKvsw+KFqLaZ3J3JCu8rJ/BTjPqeQ/kkFnWj64K4pe2OIs k3fCkLj6Q2wit/tnK3jtahr6ezsZN+4/0VBx1zgD2rEV1jxrHK4ytf24eNIAodBqlaCJyHLHQIF 4Tm/QkJcJ987l+iC9W9KaI+tEaz600wsWThhuZdyTbJ4zJs5txbX0JIuFQ4StNQ3c78/ImIvAaj /VZcM78Rn8rdWwwH/xTL6bYrOZryrEqiAHFjbgnZY1smDLyqgZY+bkasslIk7L8QC3xWzNFSztr zSl1sK2pgEoiOtIOJXjoZsrlgh6EvVdw/BjFRqFxIzVWQRldA35qSxmdoDtPmXtpTmIPUoq+zk6 GiZB1Gfee0YKwkFKLegWaGKwr58aBL9xQJ4Is3pr1qI4A4ylbIGzM3BEBaeeNb/7iIaw1r/DqU6 5/RNx1AQi7Ls6ooBritAi90R5Y9Mg9gBHjHfoABIWinn0+wAIYbsmd654BPFUshYeGopkPJ1H+5 4buLHsGB474J/w40Ohx4DWps0WrpJ0pOGmbpvwOhq462qaReIbGwXozUcV3AqEfFdP5eezb5wQ1 nS/jABWfY9OGUkbXhE77Dy5lZ8xDRZ7pCFxmdvpYpvTDZ9lH8TWV5KKPmu1HlFghpfvRlBXgNZa 5mmYG5uFY0azABJr89PD2iqWg0NOHo/l1GQScPvY49uWSxLy64A/XRCRGqDnVhFXn8JtRShT X-Received: by 2002:a05:6402:51d4:b0:6b5:8cb3:5e19 with SMTP id 4fb4d7f45d1cf-6ba37e8826emr7380558a12.38.1795371145587; Sun, 22 Nov 2026 10:12:25 -0800 (PST) Received: from Desktop.tail070c67.ts.net (p200300f24713a700f1770d5b08d979ed.dip0.t-ipconnect.de. [2003:f2:4713:a700:f177:d5b:8d9:79ed]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6ba370cc257sm4052567a12.13.2026.11.22.10.12.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Nov 2026 10:12:24 -0800 (PST) From: Julius Bairaktaris To: Jeff Johnson Cc: ath11k@lists.infradead.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Baochen Qiang , Jose Ignacio Tornos Martinez , Johannes Berg Subject: [PATCH ath-next 6/9] wifi: ath11k: offer scatter-gather and TSO with Ethernet encap Date: Sun, 22 Nov 2026 19:12:10 +0100 Message-ID: <20261122181213.1016590-7-julius@bairaktaris.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261122181213.1016590-1-julius@bairaktaris.de> References: <20261122181213.1016590-1-julius@bairaktaris.de> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Tell mac80211 that the AP, AP VLAN and station netdevs may pass TCP batches with fragments (NETIF_F_SG, TSO and TSO6, up to 16 segments) when frames go out with Ethernet encap on a device whose TCL takes them (IPQ8074). mac80211 segments them in software on every other path, and when the airtime of the whole batch would not fit AQL's estimate. Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.12-01460-QCAHKSWPL_SILICONZ-1 Signed-off-by: Julius Bairaktaris --- 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(+) diff --git a/drivers/net/wireless/ath/ath11k/dp_tx.c b/drivers/net/wireless= /ath/ath11k/dp_tx.c index 4fbdd15d1ce0..6d950afb90f1 100644 --- a/drivers/net/wireless/ath/ath11k/dp_tx.c +++ b/drivers/net/wireless/ath/ath11k/dp_tx.c @@ -15,6 +15,12 @@ #include "peer.h" #include "mac.h" =20 +/* 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) { diff --git a/drivers/net/wireless/ath/ath11k/dp_tx.h b/drivers/net/wireless= /ath/ath11k/dp_tx.h index 967f212d33db..a73b5197fac2 100644 --- a/drivers/net/wireless/ath/ath11k/dp_tx.h +++ b/drivers/net/wireless/ath/ath11k/dp_tx.h @@ -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 ath11k_sta *arsta, struct sk_buff *skb, int held_ring); diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/a= th/ath11k/mac.c index 5f2086bf6c5d..1076e3b09cd3 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -10727,6 +10727,18 @@ static int __ath11k_mac_register(struct ath11k *ar) if (ath11k_frame_mode =3D=3D 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 =3D NETIF_F_SG | + NETIF_F_TSO | + NETIF_F_TSO6; + ar->hw->encap_gso_max_segs =3D + ATH11K_DP_TX_TSO_MAX_SEGS; + } } =20 if (cap->nss_ratio_enabled) --=20 2.53.0 From nobody Tue Nov 24 11:44:06 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.208.46 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795371148; b=kwa7tNACpaXZPe3tmwkWdl2GwVeQdcmYAKoWP2nPCcHVjVnZaf7jVBOcbx8x/C3F7+np 5ZPpWyXvCD2ziD47PUfw27ivAgX3s5dWHOpiW5dD+EyH043UGgmRTLQVzJeK4F/si6e7U 7gdpHaNSJ+S5fhtzs8lVVOQBMOPRmkS1ckPKuBf93xm9PItXKSNYr1gRplSJumx6+RLmY 8f34AI30H7a65v4TIOhM8Nemu3Gx/f8qK/wpOZqilAYmD6MbvXSLhIJ0CpMBjtORJb8HJ CVBTbKwuYC7UqbD4M2Nbq7eYoRc17NcIeFW+11c9nQuF56ufheqbK4DkEje56YwdbHw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795371148; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=nnRymrH/K7oTLw9QYuTYFYeqI9p+TNSIh3hf9Y1fVeo=; b=kyRW5zxHGNgCyIHYOopXSEOsQw+4IzGAd7uDY0rni6ilfdis5PPXdRsk1INZ6LQYLqhA DN93mK7qXpWT3UcwO6YkSpTJlFtexOMS28I6qIl4h0oQrzIrde1l91FPmh4UU7UiwH0Ey wnzSvW0x7t1fZHfzi6yFFR1lJXelqy3naDYsnzb81r/CCW6i+97Of2MrIs2c/9wQywoUl Gbh8ued2LAvxAQAugzaa1x1Jtstj5UZOu7b7JIECNGh+HkQ2/BMlVhnSCGqJeZBHS8VLQ h3Fljs+K/zT8EEdjfcmer3rkJTsKJ0iINGE9/wJdmLbiHG8+jGxMq2O4MzyyipYFv0Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=bairaktaris.de; spf=pass smtp.mailfrom=bairaktaris.de; dkim=pass header.d=bairaktaris.de header.i=@bairaktaris.de header.a=rsa-sha256 header.s=google header.b=kKiByMsr; arc=none smtp.remote-ip=209.85.208.46 Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 91024606A339 for ; Sun, 22 Nov 2026 18:12:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 91024606A339 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bairaktaris.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bairaktaris.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bairaktaris.de header.i=@bairaktaris.de header.a=rsa-sha256 header.s=google header.b=kKiByMsr Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-6b894d9a075so2719390a12.2 for ; Sun, 22 Nov 2026 10:12:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bairaktaris.de; s=google; t=1795371147; x=1795975947; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=nnRymrH/K7oTLw9QYuTYFYeqI9p+TNSIh3hf9Y1fVeo=; b=kKiByMsrkjNwXuTk56h5FqDM7S7N0uard4jVBuyv4NZQmL+UrNItMDadSUx6uqM7sL z8wT8XLpQNaioghpmaYhMBcgoclYK5i82Y/1r/i5no7aK+qIoB6YNWTF0llbL6282Yj8 DSYMwhKlnCjm+lGjcRiUnOGV+VASs9Tbd+1+FbEBkLRybZvnabKRtCeFR7PHoypty4qO 5tmoqARpxxP2y26rKLiIwpkoHNapZpaO1qLaclf/rO4DNKguyJ5vLNLdRctP5KZEpohU +fpCS49+Jyj62F6V3jNmxawGOEjWwH9ik24zG3J7dXmCKpszZ865VlnfdFKrKJuMXgPX MCtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795371147; x=1795975947; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=nnRymrH/K7oTLw9QYuTYFYeqI9p+TNSIh3hf9Y1fVeo=; b=C9/uL5Wqb+mS3S0Aj0enU6tFHVfmkHAht+RIRDTWasnYXaZRv0aCw+mRFAlKVYE8Iq VQs9ij33WOpUBTN1ENrGwp7FrUnF7bDfYEkx7gsYKxoja6+ifXxHeJo4unGZNo5mHwpC mCysD6ggVatZ1Rnbew0g0p/K/Bt9QQhSpyEntlpXoMfnLk3boApn2PqO/Shq0EBeI0k1 +QR/5/tfhWdDs904ZaqBjbyS57AXNvNIu51TEVGL4bqxjuMEfTLRL6Hz1ErHllF5OOj1 GRsGX2NzHDgR7a9VclS5lMDkP53DPIbwfG7ZP+wZtgngjui91VOse9Mih21kPyOaCW9k yBhA== X-Forwarded-Encrypted: i=1; AL+hErGlmy9bEurjfol/cLqAL26QdeJgyOOvH/sl+Dhy26ZJSQ5Qtkv2g6Qn05fMpgzpRs19/KG7hKHgEJg67LQ=@vger.kernel.org X-Gm-Message-State: APuU4Z8Eh317NFhR8+mVLY52jQt0dfeAfCtj+6NAjcVESHeYl8D760f4 t0Rjy5cD9tBfiZlwRQcXMF5X8QZwr9BVkhJp+SscayWl8nbWS/KSuyisLLKNJu94zHlld2CGPt0 l6vbGIMe4 X-Gm-Gg: AZFdTZe6zI2I5MBwUNbXkCzRMVMPTpI4DufCJFw4Zp1bHUf+IQ9OlM7H2K1cB6AA6ft SBkd/nO5dNGwA+6T4nSDab5yU5kwYo9SFioyhUp65FTrtdXQV3WCPmlIcxVNo0lFO8UYxP87JxT vYuzUdXQh+Np6S19bGYU5QtB8vD3fpmUN2PxLwzsrh4ToPLNYANsBlVrbGvbdLi7xzeRTxcWBs0 fu1g5r9PldPniycz6LfP/ZCwG2ohJHV+zDW4JXtqcn+HsAQjJX4BJQWoy3NyiDAbZ9BtP0yIFFc oask9KBEfY4NhO8NvMY+TYHxlgW/crkg3Me316gRfQz8Iinm0RzWikB2rfEdp0K5b8w/JYRPqhn scOf/oBUhZD9E/wK9zmpjDq52ZeI+imrXkaqydVKiiNROh5aJVc2rkkHP7A+YtXLLZONH7UMQdx Q0rVI33yXhdB+pGZYFtPzjSowvm8+P7BP8rK2vdc8ho71W7PP4hPuXMfyD71TY99Z8cJpbAHIoL UwxnVPkHzg+CH8LAetJ1fIJnmnaAMW4cs9Ms2UgVClOGxGEj0EZarIAQf7bAMv3dR7hjzkVGz2i SmpoXQSz6hrWxVULYdvoPWHB9KjsoRxY7WLPDs/tyiUqwB9rkverfGsF2QKdCHd3AGtOTSpMyvf tX3GakAEznxNrVTdMZMdMGAFY7DNgNgUNmIWCx7v3za8owlWnnnOmQGSrsxG3yo8U+5FV6jPwa7 19CTYmNEGlLBh68Z0epROFKbWzDb/1eAHsjDb3zoKmt0N7kXHC0llFC/vI2PgN9FSCx08f4DXWV w16cSu447YOqc0at2dO71DYXu5QNInBGy1t5hiJpiB/6eG86jMUK0VAZB/Zd0OjGMZ1AzDYXaJ8 8peNYqlizaeYe5+AZbrnkqpIr5eaOnA6eZcoRIPJ4tURErXcpdcoNjWbN/H/d8HSynSdR9l0 X-Received: by 2002:aa7:d287:0:b0:6b8:818d:520c with SMTP id 4fb4d7f45d1cf-6ba37c7ba50mr4620662a12.5.1795371146993; Sun, 22 Nov 2026 10:12:26 -0800 (PST) Received: from Desktop.tail070c67.ts.net (p200300f24713a700f1770d5b08d979ed.dip0.t-ipconnect.de. [2003:f2:4713:a700:f177:d5b:8d9:79ed]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6ba370cc257sm4052567a12.13.2026.11.22.10.12.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Nov 2026 10:12:26 -0800 (PST) From: Julius Bairaktaris To: Jeff Johnson Cc: ath11k@lists.infradead.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Baochen Qiang , Jose Ignacio Tornos Martinez , Johannes Berg Subject: [PATCH ath-next 7/9] wifi: ath11k: take TCP batches as long as GRO builds them Date: Sun, 22 Nov 2026 19:12:11 +0100 Message-ID: <20261122181213.1016590-8-julius@bairaktaris.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261122181213.1016590-1-julius@bairaktaris.de> References: <20261122181213.1016590-1-julius@bairaktaris.de> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The 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 Signed-off-by: Julius Bairaktaris --- drivers/net/wireless/ath/ath11k/dp.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/dp.h b/drivers/net/wireless/at= h/ath11k/dp.h index a923ba792e4b..1bdf2f564dac 100644 --- a/drivers/net/wireless/ath/ath11k/dp.h +++ b/drivers/net/wireless/ath/ath11k/dp.h @@ -81,10 +81,13 @@ struct dp_rxdma_ring { #define ATH11K_TX_COMPL_NEXT(x) (((x) + 1) % DP_TX_COMP_RING_SIZE) =20 /* - * 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 aggreg= ate + * and more than the 64 KB of any other GRO aggregate hold at an MSS of 10= 24 + * or more. */ -#define ATH11K_DP_TX_TSO_MAX_SEGS 16 +#define ATH11K_DP_TX_TSO_MAX_SEGS 64 #define ATH11K_DP_TX_NO_EXT 0xffff =20 struct ath11k_dp_tx_ext_map { --=20 2.53.0 From nobody Tue Nov 24 11:44:06 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.208.54 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795371151; b=Fq2o3ZELuBJ0Nx3CALSKiwZmotDO8BCKkKeOnz3DkyzbgBOfKnLVp/adnWeJlr0l8uGG 5krBpdp4Srcb4dxdck+Zel7MN/0+X/RCQOnLUCilvAQgjnu6GZJ2VXqTRfswUe64brAhq 6WGV6i4FeHJr2ZfbdVeCOyeM+Qmven1sOeyBMHrKhj2wkvxqHgPGBotV/4dcgoUszN2uE ydS7ZIsugkI2sXokA0B5nZSHOJvxWf/U/AY3fXUHxXF5l8Eh51vdati6cMtgkN2AITjJL rIsSJY353YJr9xl7J2eVtFp1d/2UVIU61dlr2T0rniOEaJ8qNpJWdKeRdCjKACMbanw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795371151; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=g+9Vw6GD+kj8DkWaZDhjtYfJzZmDs1hAIA4ATrmqD4A=; b=VDAp3xbLfO9EEMM0/iROVCWDdXpUWWbBaBMB0MJL6FH+NiAC34uBJh1aJ9oHhxCTsZCK 1sT4HKwfb9ye750ehYhf53jTffa7lrqySOvEeu1uW+O4fnpQ/gh2qC4nBaLGQwPaHIrmG u6iGJfytuBArFXw+UiIBq5koy1iT498UUrHEzp2wmOboORtM5IvQ4I9IZncgZCPGl8Jhz dJdGJf7HQ7zKsFnTcv/HSVKORBLsuvt3t7tmtgL9xE0qzzx2x5btKrCv5L2pysYNiEv71 nDntUg4aBM5fJH5S2Yk49AN037ZSUZM7+mwDO313d/yAKl3d7PN0TGvBJRFbZ+9y9RA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=bairaktaris.de; spf=pass smtp.mailfrom=bairaktaris.de; dkim=pass header.d=bairaktaris.de header.i=@bairaktaris.de header.a=rsa-sha256 header.s=google header.b=n55T4atq; arc=none smtp.remote-ip=209.85.208.54 Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D4C30606A33B for ; Sun, 22 Nov 2026 18:12:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D4C30606A33B Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bairaktaris.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bairaktaris.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bairaktaris.de header.i=@bairaktaris.de header.a=rsa-sha256 header.s=google header.b=n55T4atq Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-6b88bc47e23so3052040a12.2 for ; Sun, 22 Nov 2026 10:12:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bairaktaris.de; s=google; t=1795371149; x=1795975949; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=g+9Vw6GD+kj8DkWaZDhjtYfJzZmDs1hAIA4ATrmqD4A=; b=n55T4atq0RkqaxITMJ1n9Dv2RTjlzbtf5aBwf8j8k3A9cA5QS2DknjUkkx36MhIQ+0 J94D9QeUOAbAMKLHCRWSDP5plHTb4+ZjRJ9Rvu1ot3LP3Nugx7Kh6nhfHsqU6qFc0dg8 uKRzUpWbgKupK0CeMhuHVYiYe4jgNpOFxzibB0tdZFs47+G1ncAx/g4LXa19IZx+oYNK Uy4ar3o7XRW4bUZ5OeWAyPjZlurFACG4T0+kI48ac6eNaV7JupOrNTVsZn+xt4oZi/Xs ZtHTIJvnABHBYWM+4z9aHCYkz3dUAEoshGVVRqZR1OSxmk3BERzQd6KdzaFwwiz8XVkP EhjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795371149; x=1795975949; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=g+9Vw6GD+kj8DkWaZDhjtYfJzZmDs1hAIA4ATrmqD4A=; b=mVxRQ3NsaZfegu6lLptRC5tIYQ8KctppbLsMbIB3WwU3DZDXriYdpXAUm3X9zBwSLV FivjWBmb0bM3lsljphWbGa5VLYRqsfOIl5A+4WiXr7OMuh7nYP2WADYhZfOs6IgQjWKW vQADFWVr8hfXjklryUp3S5KTsis9hDbLLP0UuPbUHCE0NF7OD8byUHyLJxs8AYZki+wu iPXdv3Itx9N3Kjbx09d/DMS7kcseVUa5cURyvK5Lg5vSYMAEnJrn2SalfS/JuYxzMtD2 GwRBqQ+KvOl+VPI45Datxg592ErkfvvAoaOFXhFcoPnBqpiy0D61QZ8hwYrDpdHWFYtW 2Lcw== X-Forwarded-Encrypted: i=1; AL+hErESQwHxGRhAfhfev1bPNxxDKaQGYYXj+6aLm9tdiJgzjE8Zj/uQqcKeQGZtH0yoViX9Yr9AL1S5MsxMc8E=@vger.kernel.org X-Gm-Message-State: APuU4Z/oJwMDTJTEb/kqSwfd3R2gBjQpMbZ+xQ5ZAhpI8s7LJhldd5UV tkPu8A6U9pLZSO0e4ORntT3muqRmHb9dNPOulMntXoOJUax/NjgkRUjmT8XNa13MbQ== X-Gm-Gg: AZFdTZcmpwuZc6wtLgBAuQcB8IJe8M6kYV9sbtKNjb5jZs2C3MacFx3IhLf9SmjImI/ rxEaEmyv5ANd0jyOGlYfFM5ixuEzejvAJwQTyomKpSl+mM6evUrtV7K4Gm4w+WbrSW9lGg3QME/ L0DOpZgAEc+qJ2yUtu5I5QIWTtXzyBjoiQlc2KwQ2zNDZJi2Vpba7rv+GBD1cBlRVsfdX9AdzjQ FVvQxQjxznOnMuttAbOwt76mhXsGSCdplqd+DtrvrB9uIf+3Eh+Ilu5lxTRWOQGXecfXN48sncY iaRF8x0ENeQ9JWpBbA0XBUoeFvG9e/Q4W/7p46LYheDn1K7VM9ANDb8nORDxSLWWjfDF87eFX0c ALylviMcC9CPO83mFvPYZG2O1DG/u9zZz4ZVHtysJa79y5Tsa3eobALKcKIe4pvLs5Vb5KSDQU8 /c8tM50X1aWZmJtJyHJi0phhp/lzfRRVGheqFIIG4/BjTKKKDJRPW//lhwPYHTKqnzS18kl5RGy /KdkmMxWO3Hd7lbP3bOkp638Ww+72eLWEJPc6KsU72lb31kwIcH+/ql2H7LVmi2rPVetR538ru3 b1dL//euJ1DDzBUJuLVStbuf1T+ZVhydH32+2xoBma3xhq3AZQ8sk2jlbFobXa+FLEAnhPrq6Tu ZKgm/pLY1nzDRQdpLd+HpejsQEpQtCA0IcB6Y5q/fmtHbwmcrru3aL9k1V5SoaAj/6Onr54s4Ty NmNiCvs90AiGHf3D43oCcX/AOXIOH99fpbnvdQ7EXoIF/K97sojyarvEUv3mTiVZO5mWo8158+X 3CtuKGt+KZrGcXrAVgAMHHBT+EdqaAfwFLac43EojzhyIANTTkGMycUB1rEPWPheSjXdKZoNqjw BPBhJwtg7VQE2tW3SYvxUvbAueuh/RH+VdNGgRBmCpxZASihSXRxLCtPSSAZmJ0VgBGQatrc X-Received: by 2002:a05:6402:4009:b0:6b9:c43e:19df with SMTP id 4fb4d7f45d1cf-6ba37ed9a8bmr5872445a12.41.1795371149157; Sun, 22 Nov 2026 10:12:29 -0800 (PST) Received: from Desktop.tail070c67.ts.net (p200300f24713a700f1770d5b08d979ed.dip0.t-ipconnect.de. [2003:f2:4713:a700:f177:d5b:8d9:79ed]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6ba370cc257sm4052567a12.13.2026.11.22.10.12.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Nov 2026 10:12:28 -0800 (PST) From: Julius Bairaktaris To: Jeff Johnson Cc: ath11k@lists.infradead.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Baochen Qiang , Jose Ignacio Tornos Martinez , Johannes Berg Subject: [PATCH ath-next 8/9] wifi: ath11k: give an extension descriptor the number of its buffer id Date: Sun, 22 Nov 2026 19:12:12 +0100 Message-ID: <20261122181213.1016590-9-julius@bairaktaris.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261122181213.1016590-1-julius@bairaktaris.de> References: <20261122181213.1016590-1-julius@bairaktaris.de> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A 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 Signed-off-by: Julius Bairaktaris --- drivers/net/wireless/ath/ath11k/dp.h | 21 +++--- drivers/net/wireless/ath/ath11k/dp_tx.c | 95 ++++++++++++------------- 2 files changed, 60 insertions(+), 56 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/dp.h b/drivers/net/wireless/at= h/ath11k/dp.h index 1bdf2f564dac..e47949ed7c4a 100644 --- a/drivers/net/wireless/ath/ath11k/dp.h +++ b/drivers/net/wireless/ath/ath11k/dp.h @@ -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 =20 +/* + * 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 o= ne + * 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); =20 /* 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; diff --git a/drivers/net/wireless/ath/ath11k/dp_tx.c b/drivers/net/wireless= /ath/ath11k/dp_tx.c index 6d950afb90f1..089696bff4c8 100644 --- a/drivers/net/wireless/ath/ath11k/dp_tx.c +++ b/drivers/net/wireless/ath/ath11k/dp_tx.c @@ -114,8 +114,10 @@ static size_t ath11k_dp_tx_ext_off(unsigned int slot) =20 /* * The ids a ring hands out, as a table indexed by id with a stack of the = free - * ones: the completion's cookie names the buffer directly. Callers of the= id - * helpers hold tx_idr_lock. + * ones: the completion's cookie names the buffer directly. The ids below + * ext_ids are those of the extension descriptors and have a stack of their + * own, so that a completion finds the descriptor of its id without a tabl= e. + * Callers of the id helpers hold tx_idr_lock. */ int ath11k_dp_tx_bufs_init(struct ath11k_base *ab, struct dp_tx_ring *tx_r= ing) { @@ -125,9 +127,9 @@ int ath11k_dp_tx_bufs_init(struct ath11k_base *ab, stru= ct dp_tx_ring *tx_ring) GFP_KERNEL); tx_ring->free_ids =3D kvcalloc(DP_TX_IDR_SIZE - 1, sizeof(*tx_ring->free_ids), GFP_KERNEL); - tx_ring->ext_slot =3D kvmalloc_array(DP_TX_IDR_SIZE - 1, - sizeof(*tx_ring->ext_slot), - GFP_KERNEL); + BUILD_BUG_ON(sizeof(struct ath11k_dp_tx_ext_map) !=3D 32); + BUILD_BUG_ON(DP_TX_EXT_DESC_NUM + 1 >=3D DP_TX_IDR_SIZE); + if (ab->hw_params.tx_tso) { tx_ring->ext =3D dma_alloc_coherent(ab->dev, ATH11K_DP_TX_EXT_SIZE, &tx_ring->ext_paddr, @@ -139,24 +141,22 @@ int ath11k_dp_tx_bufs_init(struct ath11k_base *ab, st= ruct dp_tx_ring *tx_ring) sizeof(*tx_ring->ext_free), GFP_KERNEL); } - if (!tx_ring->bufs || !tx_ring->free_ids || !tx_ring->ext_slot || + if (!tx_ring->bufs || !tx_ring->free_ids || (ab->hw_params.tx_tso && (!tx_ring->ext || !tx_ring->ext_map || !tx_ring->ext_free))) { ath11k_dp_tx_bufs_free(ab, tx_ring); return -ENOMEM; } =20 - memset(tx_ring->ext_slot, 0xff, - (DP_TX_IDR_SIZE - 1) * sizeof(*tx_ring->ext_slot)); + tx_ring->ext_ids =3D tx_ring->ext_free ? DP_TX_EXT_DESC_NUM : 0; =20 tx_ring->num_free =3D 0; - for (id =3D DP_TX_IDR_SIZE - 1; id--;) + for (id =3D DP_TX_IDR_SIZE - 1; id-- > tx_ring->ext_ids;) tx_ring->free_ids[tx_ring->num_free++] =3D id; =20 tx_ring->ext_num_free =3D 0; - if (tx_ring->ext_free) - for (id =3D DP_TX_EXT_DESC_NUM; id--;) - tx_ring->ext_free[tx_ring->ext_num_free++] =3D id; + for (id =3D tx_ring->ext_ids; id--;) + tx_ring->ext_free[tx_ring->ext_num_free++] =3D id; =20 return 0; } @@ -165,7 +165,6 @@ void ath11k_dp_tx_bufs_free(struct ath11k_base *ab, str= uct dp_tx_ring *tx_ring) { kvfree(tx_ring->bufs); kvfree(tx_ring->free_ids); - kvfree(tx_ring->ext_slot); if (tx_ring->ext) dma_free_coherent(ab->dev, ATH11K_DP_TX_EXT_SIZE, tx_ring->ext, tx_ring->ext_paddr); @@ -173,12 +172,12 @@ void ath11k_dp_tx_bufs_free(struct ath11k_base *ab, s= truct dp_tx_ring *tx_ring) kvfree(tx_ring->ext_free); tx_ring->bufs =3D NULL; tx_ring->free_ids =3D NULL; - tx_ring->ext_slot =3D NULL; tx_ring->ext =3D NULL; tx_ring->ext_map =3D NULL; tx_ring->ext_free =3D NULL; tx_ring->num_free =3D 0; tx_ring->ext_num_free =3D 0; + tx_ring->ext_ids =3D 0; } =20 static int ath11k_dp_tx_buf_get_id(struct dp_tx_ring *tx_ring, @@ -198,10 +197,11 @@ static int ath11k_dp_tx_buf_get_id(struct dp_tx_ring = *tx_ring, static void ath11k_dp_tx_tso_unmap(struct device *dev, struct ath11k_dp_tx_ext_map *map) { - while (map->num--) - dma_unmap_page(dev, map->dma[map->num], map->len[map->num], - DMA_TO_DEVICE); - map->num =3D 0; + unsigned int i; + + for (i =3D 0; i < ARRAY_SIZE(map->len) && map->len[i]; i++) + dma_unmap_page(dev, map->dma[i], map->len[i], DMA_TO_DEVICE); + map->len[0] =3D 0; } =20 /* @@ -215,8 +215,8 @@ struct sk_buff *ath11k_dp_tx_buf_put_id(struct ath11k_b= ase *ab, bool *more, struct ath11k_dp_tx_seg *seg) { + struct ath11k_dp_tx_ext_map *map; struct sk_buff *skb; - u16 slot; =20 *more =3D false; if (seg) { @@ -232,18 +232,18 @@ struct sk_buff *ath11k_dp_tx_buf_put_id(struct ath11k= _base *ab, return NULL; =20 tx_ring->bufs[id] =3D NULL; - tx_ring->free_ids[tx_ring->num_free++] =3D id; =20 if (seg) seg->skb =3D skb; =20 - slot =3D tx_ring->ext_slot[id]; - if (unlikely(slot !=3D ATH11K_DP_TX_NO_EXT)) { + if (id >=3D tx_ring->ext_ids) { + tx_ring->free_ids[tx_ring->num_free++] =3D id; + } else { + map =3D &tx_ring->ext_map[id]; if (seg) - seg->len =3D tx_ring->ext_map[slot].seg_len; - ath11k_dp_tx_tso_unmap(ab->dev, &tx_ring->ext_map[slot]); - tx_ring->ext_free[tx_ring->ext_num_free++] =3D slot; - tx_ring->ext_slot[id] =3D ATH11K_DP_TX_NO_EXT; + seg->len =3D map->seg_len; + ath11k_dp_tx_tso_unmap(ab->dev, map); + tx_ring->ext_free[tx_ring->ext_num_free++] =3D id; =20 if (!skb_unref(skb)) { *more =3D true; @@ -507,10 +507,11 @@ static int ath11k_dp_tx_tso_map(struct device *dev, s= truct sk_buff *skb, unsigned int len) { struct skb_shared_info *shinfo =3D skb_shinfo(skb); - unsigned int avail, take; + unsigned int avail, take, num =3D 0; dma_addr_t dma; =20 - map->num =3D 0; + /* every piece mapped has a length, so the first 0 ends them */ + memset(map->len, 0, sizeof(map->len)); while (len) { if (!*piece) avail =3D skb_headlen(skb) - *off; @@ -523,7 +524,7 @@ static int ath11k_dp_tx_tso_map(struct device *dev, str= uct sk_buff *skb, *off =3D 0; continue; } - if (map->num =3D=3D HAL_TX_MSDU_EXT_NUM_BUFS - 1) + if (num =3D=3D ARRAY_SIZE(map->len)) return -E2BIG; =20 take =3D min(avail, len); @@ -538,11 +539,11 @@ static int ath11k_dp_tx_tso_map(struct device *dev, s= truct sk_buff *skb, if (dma_mapping_error(dev, dma)) return -ENOMEM; =20 - map->dma[map->num] =3D dma; - map->len[map->num] =3D take; - map->num++; - ext->buf[map->num].addr_lo =3D lower_32_bits(dma); - ext->buf[map->num].info =3D + map->dma[num] =3D dma; + map->len[num] =3D take; + num++; + ext->buf[num].addr_lo =3D lower_32_bits(dma); + ext->buf[num].info =3D FIELD_PREP(HAL_TX_MSDU_EXT_BUF_INFO_ADDR_HI, upper_32_bits(dma)) | FIELD_PREP(HAL_TX_MSDU_EXT_BUF_INFO_LEN, take); @@ -658,7 +659,7 @@ static int ath11k_dp_tx_ext(struct ath11k *ar, struct a= th11k_vif *arvif, struct hal_tx_info ti =3D {}; struct dp_tx_ring *tx_ring; struct hal_srng *tcl_ring; - u16 ids[ATH11K_DP_TX_TSO_MAX_SEGS], slots[ATH11K_DP_TX_TSO_MAX_SEGS]; + u16 ids[ATH11K_DP_TX_TSO_MAX_SEGS]; u32 seq =3D 0, flags =3D 0, ip_id =3D 0; dma_addr_t hdr_dma; struct tcphdr *th; @@ -730,15 +731,15 @@ static int ath11k_dp_tx_ext(struct ath11k *ar, struct= ath11k_vif *arvif, tcl_ring =3D &ab->hal.srng_list[tx_ring->tcl_data_ring.ring_id]; =20 spin_lock_bh(&tx_ring->tx_idr_lock); - if (tx_ring->num_free < n || tx_ring->ext_num_free < n) { + if (tx_ring->ext_num_free < n) { spin_unlock_bh(&tx_ring->tx_idr_lock); return -EAGAIN; } + /* the id of a segment is the number of its extension descriptor */ for (i =3D 0; i < n; i++) { - slots[i] =3D tx_ring->ext_free[--tx_ring->ext_num_free]; - ids[i] =3D ath11k_dp_tx_buf_get_id(tx_ring, skb); - tx_ring->ext_slot[ids[i]] =3D slots[i]; - tx_ring->ext_map[slots[i]].num =3D 0; + ids[i] =3D tx_ring->ext_free[--tx_ring->ext_num_free]; + tx_ring->bufs[ids[i]] =3D skb; + tx_ring->ext_map[ids[i]].len[0] =3D 0; } spin_unlock_bh(&tx_ring->tx_idr_lock); =20 @@ -765,8 +766,8 @@ static int ath11k_dp_tx_ext(struct ath11k *ar, struct a= th11k_vif *arvif, left =3D skb->len - off; for (i =3D 0; i < n; i++) { struct hal_tx_msdu_ext *ext =3D (void *)tx_ring->ext + - ath11k_dp_tx_ext_off(slots[i]); - struct ath11k_dp_tx_ext_map *map =3D &tx_ring->ext_map[slots[i]]; + ath11k_dp_tx_ext_off(ids[i]); + struct ath11k_dp_tx_ext_map *map =3D &tx_ring->ext_map[ids[i]]; unsigned int len =3D tso ? min(left, mss) : left; u32 seg_flags =3D flags; =20 @@ -861,7 +862,7 @@ static int ath11k_dp_tx_ext(struct ath11k *ar, struct a= th11k_vif *arvif, FIELD_PREP(DP_TX_DESC_ID_POOL_ID, skb_get_queue_mapping(skb) & (ATH11K_HW_MAX_QUEUES - 1)); - ti.paddr =3D tx_ring->ext_paddr + ath11k_dp_tx_ext_off(slots[i]); + ti.paddr =3D tx_ring->ext_paddr + ath11k_dp_tx_ext_off(ids[i]); /* the command follows the TLV header of the ring entry */ desc =3D ath11k_hal_srng_src_get_next_entry(ab, tcl_ring); ath11k_hal_tx_cmd_desc_setup(ab, desc + sizeof(struct hal_tlv_hdr), @@ -890,18 +891,16 @@ static int ath11k_dp_tx_ext(struct ath11k *ar, struct= ath11k_vif *arvif, =20 fail_unmap: for (j =3D 0; j < i; j++) - ath11k_dp_tx_tso_unmap(ab->dev, &tx_ring->ext_map[slots[j]]); + ath11k_dp_tx_tso_unmap(ab->dev, &tx_ring->ext_map[ids[j]]); dma_unmap_single(ab->dev, hdr_dma, skb_headlen(skb), DMA_TO_DEVICE); fail_put: if (pad) ath11k_dp_tx_ext_unpad(skb, hdr_len, pad); spin_lock_bh(&tx_ring->tx_idr_lock); for (j =3D n; j--;) { - /* no reference was taken yet: release the id and slot only */ + /* no reference was taken yet: release the id only */ tx_ring->bufs[ids[j]] =3D NULL; - tx_ring->free_ids[tx_ring->num_free++] =3D ids[j]; - tx_ring->ext_slot[ids[j]] =3D ATH11K_DP_TX_NO_EXT; - tx_ring->ext_free[tx_ring->ext_num_free++] =3D slots[j]; + tx_ring->ext_free[tx_ring->ext_num_free++] =3D ids[j]; } spin_unlock_bh(&tx_ring->tx_idr_lock); =20 --=20 2.53.0 From nobody Tue Nov 24 11:44:06 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.208.47 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795371153; b=Tp4QPLiv38S5L8lndTPaUBynn6wriqOgqJaR81aeZ3RrmbT39Lq1xJcncThwoQ6FVnLE qX0Y/waudq+jPq/ALOybB3KmULD7I/U4CN53+SlBXRZjyDNgAOcBTvC4Uk7ofT1h/M7oT kmCF9BN/vrGf5ExPnyXRKDswVEJKFYrF+SVXyRvJHirkFaHUb8h2j+17fBLF0cToKIpSk Bf42GcUgPm4sN0BEHHEMeClppfHDVllRcX4mEK2OBodvOMYWxp4M4/aS2bHSKDqdY6P7Y XTBaEm0JMsYGgje3NJZ5HNBelbqpNkZyi9pr33yIW579vi0duh9SYyGA0/QaI/5fvMA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795371153; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=hRFBwr5nNkuMz7lc4vkcZig/cSlg7IXyKLH1tJ1rFzY=; b=bSnn3lXlqone+yF5eFoI0ur2bzhLf4FydjzbhIaaOzbtnyJiLSfZ6KUxw9YHcamBAfvk MbP8DKmf6P1uPQRlQLVI8Eal9FuSa8Exf3JVpkC2VxbgNiMxYQrtOo0kcqTMskBl1AV48 +cEjelv32GvSMDrB1nSajIVBEOElanJVggEMgrsc+4kRjRozSARPrYX3I4oQGlw2ivBzM jZ7bRt1L2nhrZh7kpIOBr4yHvuJz+I7LPi9Rai+4gXyXEBNX+fWnkCVCxUr48pvZQLR/h 5n3dtAdFUgfjBeZ3vo+8PkEDz3TBVlneYgYwrtNOMX+7oiqHTRmHS0N8MEvFUB18/6g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=bairaktaris.de; spf=pass smtp.mailfrom=bairaktaris.de; dkim=pass header.d=bairaktaris.de header.i=@bairaktaris.de header.a=rsa-sha256 header.s=google header.b="r/AuOn30"; arc=none smtp.remote-ip=209.85.208.47 Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D5E83606A330 for ; Sun, 22 Nov 2026 18:12:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D5E83606A330 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bairaktaris.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bairaktaris.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bairaktaris.de header.i=@bairaktaris.de header.a=rsa-sha256 header.s=google header.b=r/AuOn30 Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-6ba1e22ff4dso2740441a12.2 for ; Sun, 22 Nov 2026 10:12:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bairaktaris.de; s=google; t=1795371151; x=1795975951; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=hRFBwr5nNkuMz7lc4vkcZig/cSlg7IXyKLH1tJ1rFzY=; b=r/AuOn30ugx9/Z0cqbXZw4BY/pO1eUbTQFLh0p2YQMBU9vMNFlCPsMSpQIRDpP8wXm JplkShyVumkohtYVLAMYKDRN1UPJR4r34YwOo4FRuk/RGVViv8bmTY3WP5NdugvEpVqY 2kGq+rO5ElfEZLFNOHCLpibbdLpnyH75PZSZzA2D24SGgmDlEbidMpEInm0M67J25ylI KP1pVnec11yCLFoCuEWjx06P44DGfokxD3rOb50y1Up5/p1jTVglEVnwa8+oL3qtlJgi i4L3jpowporYyw/lIrFZzcFSvOS2PNfhe3ZyRzLKafuMXR8QSKSAcmLUzk91Br7JhBhx lG/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795371151; x=1795975951; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=hRFBwr5nNkuMz7lc4vkcZig/cSlg7IXyKLH1tJ1rFzY=; b=RVGf3rStv6BFhQCJGmIYyzbeezEUMMDHEfQJvUsWRT8U53KEbJG9xdZ2aJUnwHFXLQ kl2R7eJXtlAQB22Xpe7+rE6vent5xIn5HwTd3cHxZ9xOKQ5I+l7JYm198ve9eRJT0lAB nEZoCzPttd0mZ1/bLS3/fOCx36C53kgblApW455HHwAH6aeS1jfZZtRcHHBmVnuLGvCJ Vg0A4SRP9r03PS253bdQ1To3zOO/q0yl6cKd2trsMLxknB8Rl8sK/VYXjTVrVUSaASE+ OaMjp/KDbL9YmaBMANZIXBnFzLkkuedKKZ5h2ALSHSsc+yznkU/BR02r2B+E9UXnkGPy CvZw== X-Forwarded-Encrypted: i=1; AL+hErGWMq5321s/tvzFgWcluD7B2yASzvhuPf7Zu1TGL6I5tAYZrp0873eujzW1MLBYzWlwipqW183wA3rwW8k=@vger.kernel.org X-Gm-Message-State: APuU4Z+/UAWiUzez6H9XTLeApCF4LXpDqnAk2KfoY1IgXERDvCgFFolB YY24QoGuRrR0FDOG2tr+hUrmfhIiAloTeHipf+GAkFzqP+9/N23tiKIF+zKG3DC7mQ== X-Gm-Gg: AZFdTZf8IT1mgV2YldN+nWZIxG7aqtpZNtV5TGyZbQMqepuWS7zVOF0ltZAipnagXOO grLsors4fa1iKqe8BesBocZSJ/ZWGLxdL29LGSAeINkeSlZkrf6lLgjxQROhixS3BbE8iYBBlGo 7awEE2PR1m7IjsslRNO7e6XByym8+6P/S/aCjhSWyaWP5LvJ3ILfLYmEFNDFbtfQ8VrMcOiLaF3 hohHCx22We4Y0oSrNRmihF7F6KGS9HMhCG9s4+5y1e1jlMKofFVOWVxfg/yB0GrXUVNXRzTJoru li0G/6TB6zgP+XUCjnJ0rlnHIGXufr/7Y17qkDoRUf29ntpA0B/qimHrBfKJBg//NSMx3CXGRuc fNt/I7zbXqWTylFYWl4NLhzBujCL+1cm7y3hSWg1WZUJECq0tA1xNGu/52CF45xkzoKBBybCore ETLBZVVJdGiniASBWYdjWLJzASa3RREQ5gukIzXnBDhmxw7qpQGMXwtkwU5b4TByXILw0+YSWKw 7NPjQBmYhkj2+ANAKAKkHIwtH46ySGVHzAVgl9XNxqaYa5LrIkcGxvoYbPNxGMBMlxoEv2S87mR YzawZSzs4+dbwop2Jty4B2K36R/cu9RO5vPEhu6fqcl0YeTQq0vdTHNV9rsOJRQBXr85R3GTzBm 2lc7oeiBvYVfNnCnjYstQh6yhSuTHouDOxEjGtBq1zZv7B4/P0QsjAIawGoRbiDQ6M5d+V6VbcM iO+5y5EhHwyTYplNF4QiuzVkY4JbMhWokyLYXOHfXIe2O/R1dwpOtirg/DxTO4j3Za1DlN0WXh2 Kpy30vJZ0OMUgt3N/7L5cLapEsA5esDBI1b3o7hQ/6TxCkCFjEo0B2TgAsHJfcl4TS9caePgkkm +A4CbDwmBNq0iZ0/QlvHaUrBgXV7UpUJTddPVIfr0jaCRV7/UBlyHa5okjYI7VkDGtcuqLkX X-Received: by 2002:a05:6402:1d4b:b0:6b7:9ced:824 with SMTP id 4fb4d7f45d1cf-6ba37e97cf6mr6095104a12.26.1795371151306; Sun, 22 Nov 2026 10:12:31 -0800 (PST) Received: from Desktop.tail070c67.ts.net (p200300f24713a700f1770d5b08d979ed.dip0.t-ipconnect.de. [2003:f2:4713:a700:f177:d5b:8d9:79ed]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6ba370cc257sm4052567a12.13.2026.11.22.10.12.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Nov 2026 10:12:30 -0800 (PST) From: Julius Bairaktaris To: Jeff Johnson Cc: ath11k@lists.infradead.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Baochen Qiang , Jose Ignacio Tornos Martinez , Johannes Berg Subject: [PATCH ath-next 9/9] wifi: ath11k: count the segments of a TX batch without an atomic Date: Sun, 22 Nov 2026 19:12:13 +0100 Message-ID: <20261122181213.1016590-10-julius@bairaktaris.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261122181213.1016590-1-julius@bairaktaris.de> References: <20261122181213.1016590-1-julius@bairaktaris.de> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A 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 Signed-off-by: Julius Bairaktaris --- drivers/net/wireless/ath/ath11k/core.h | 5 +++++ drivers/net/wireless/ath/ath11k/dp_tx.c | 17 +++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/= ath/ath11k/core.h index 11c79d0f5c34..32f24e1a396f 100644 --- a/drivers/net/wireless/ath/ath11k/core.h +++ b/drivers/net/wireless/ath/ath11k/core.h @@ -128,6 +128,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; =20 struct ath11k_skb_rxcb { diff --git a/drivers/net/wireless/ath/ath11k/dp_tx.c b/drivers/net/wireless= /ath/ath11k/dp_tx.c index 089696bff4c8..2d044ed408c0 100644 --- a/drivers/net/wireless/ath/ath11k/dp_tx.c +++ b/drivers/net/wireless/ath/ath11k/dp_tx.c @@ -245,7 +245,7 @@ struct sk_buff *ath11k_dp_tx_buf_put_id(struct ath11k_b= ase *ab, ath11k_dp_tx_tso_unmap(ab->dev, map); tx_ring->ext_free[tx_ring->ext_num_free++] =3D id; =20 - if (!skb_unref(skb)) { + if (--ATH11K_SKB_CB(skb)->tso_left) { *more =3D true; return NULL; } @@ -638,9 +638,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 completi= on - * of the last one reports the batch to mac80211. A frame with fragments h= as - * 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 @@ -829,7 +829,12 @@ static int ath11k_dp_tx_ext(struct ath11k *ar, struct = ath11k_vif *arvif, skb_cb->ar =3D ar; skb_cb->tso_try =3D 0; skb_cb->tso_bad =3D 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 =3D n; =20 ti.encap_type =3D HAL_TCL_ENCAP_TYPE_ETHERNET; ti.meta_data_flags =3D arvif->tcl_metadata; @@ -898,7 +903,7 @@ static int ath11k_dp_tx_ext(struct ath11k *ar, struct a= th11k_vif *arvif, ath11k_dp_tx_ext_unpad(skb, hdr_len, pad); spin_lock_bh(&tx_ring->tx_idr_lock); for (j =3D 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]] =3D NULL; tx_ring->ext_free[tx_ring->ext_num_free++] =3D ids[j]; } --=20 2.53.0