From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 62D873B71C7 for ; Mon, 20 Jul 2026 07:09:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784531361; cv=none; b=UVEGIZs/4q0YMHcYEhGmgAG9aa41pkBCH9KQIzf+sOfcjmCxK6mhqerjhbVRXfJzFr9YyW9KVvjfSbbScGURPzwrjR3OqN1w0dLlq+8O84v08jsY7TMX5hZbpQG9oRtvDiuoLZvBkYcOKTN6wx/wt3vQgfbchGkHUEaPB0U/6X8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784531361; c=relaxed/simple; bh=lU5XdN+Z+fIhyxORcq1+yYr903O+u/Ar8alvznAu4CU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uisEy+/gHRB+MDA71cokd8RVd7D6xzGxMU1ACjC4JfXuyr9GibiNNqdMXeUzz1DNaV3slgvoIfX6ba28IhlPN2xIRiWnBpkXZA6IJq01ZJ6gY7XWwdHrQ0zLt5iMVon4s2dXRW1uyDfPwmOM2TU+37WcPaVGPLpIWfWWPsAVexA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=dG4uWqcc; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dG4uWqcc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784531354; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=twTRlkMXD/z1Gr2vCEQL+bD8mFIwWASPUQB9fXMASFg=; b=dG4uWqcc8onotCAbVpLv/BTJ9q9w1F0bc8ltBvAZe64GFc5B0Z2DAorOLXF/w+oA1ltfT0 VWyO4l2Z+Ll5K1kJG/1A3yrudoAQHmVbHHB6tBV9EkFuYF8dFvEZSUUJUAz/HB0BhxHhbe 5jiWAE/zUNfjsQR31HIVp8NlYp9cij4= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-341-oBNwQL9iNnGKbuYFahqJ_g-1; Mon, 20 Jul 2026 03:09:11 -0400 X-MC-Unique: oBNwQL9iNnGKbuYFahqJ_g-1 X-Mimecast-MFC-AGG-ID: oBNwQL9iNnGKbuYFahqJ_g_1784531350 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9616E1802174; Mon, 20 Jul 2026 07:09:09 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.48.69]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DBB6F180058C; Mon, 20 Jul 2026 07:09:06 +0000 (UTC) From: Jose Ignacio Tornos Martinez To: jjohnson@kernel.org Cc: ath11k@lists.infradead.org, ath12k@lists.infradead.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Jose Ignacio Tornos Martinez Subject: [PATCH v3 1/3] wifi: mac80211: add ieee80211_tx_peek API Date: Mon, 20 Jul 2026 09:08:49 +0200 Message-ID: <20260720070852.206495-2-jtornosm@redhat.com> In-Reply-To: <20260720070852.206495-1-jtornosm@redhat.com> References: <20260720070852.206495-1-jtornosm@redhat.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Add ieee80211_tx_peek() to allow drivers to inspect the next frame in a TXQ without removing it. Drivers implementing custom wake_tx_queue operations may need to determine which hardware TX ring to use before dequeuing a packet, using properties like the skb hash or queue mapping that are only available from the skb itself. The function checks pending fragments first, then iterates through all fair-queue flows (new_flows and old_flows) to find the first queued frame, matching the iteration behavior of fq_tin_dequeue. It also pre-caches the skb hash via skb_get_hash() so that hash-based ring selectors see a stable value through the subsequent dequeue and TX path. Signed-off-by: Jose Ignacio Tornos Martinez --- v3: no modification v2: https://lore.kernel.org/all/20260715125017.277242-2-jtornosm@redhat.com/ include/net/mac80211.h | 20 ++++++++++++++++++++ net/mac80211/tx.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 4f95da023746..9289b8dca972 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -7742,6 +7742,26 @@ void ieee80211_unreserve_tid(struct ieee80211_sta *sta, u8 tid); struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw, struct ieee80211_txq *txq); +/** + * ieee80211_tx_peek - peek at the next packet in a software tx queue + * + * @hw: pointer as obtained from ieee80211_alloc_hw() + * @txq: pointer obtained from station or virtual interface, or from + * ieee80211_next_txq() + * + * Return: the next skb without dequeuing it, or %NULL if the queue is empty. + * The returned pointer is const — the caller must not modify or free the skb. + * The skb remains queued and will be returned by a subsequent + * ieee80211_tx_dequeue() call. + * + * This is useful for drivers that need to inspect the next frame (e.g. to + * determine the target TX ring) before deciding whether to dequeue. + * + * Must be called in the same context as ieee80211_tx_dequeue(). + */ +const struct sk_buff *ieee80211_tx_peek(struct ieee80211_hw *hw, + struct ieee80211_txq *txq); + /** * ieee80211_tx_dequeue_ni - dequeue a packet from a software tx queue * (in process context) diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index c13b209fad47..91bfd8ef9428 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -3857,6 +3857,45 @@ static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata, return true; } +const struct sk_buff *ieee80211_tx_peek(struct ieee80211_hw *hw, + struct ieee80211_txq *txq) +{ + struct txq_info *txqi = container_of(txq, struct txq_info, txq); + struct ieee80211_local *local = hw_to_local(hw); + struct fq_tin *tin = &txqi->tin; + struct fq *fq = &local->fq; + struct sk_buff *skb = NULL; + struct fq_flow *flow; + + WARN_ON_ONCE(softirq_count() == 0); + + spin_lock_bh(&fq->lock); + + skb = skb_peek(&txqi->frags); + if (skb) + goto out; + + list_for_each_entry(flow, &tin->new_flows, flowchain) { + skb = skb_peek(&flow->queue); + if (skb) + goto out; + } + + list_for_each_entry(flow, &tin->old_flows, flowchain) { + skb = skb_peek(&flow->queue); + if (skb) + goto out; + } + +out: + if (skb) + skb_get_hash(skb); + + spin_unlock_bh(&fq->lock); + return skb; +} +EXPORT_SYMBOL_GPL(ieee80211_tx_peek); + struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw, struct ieee80211_txq *txq) { -- 2.54.0