From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (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 4DAA634DB41; Sat, 14 Mar 2026 09:49:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773481754; cv=none; b=U4CHXb9JbLVC6+Mj59qV6RT9lYUnEImdpeTVuUCpFLWGtfg7D7QtSmkaBWn2LiHFpIJ8fngwWx44zowDwAEjS1A6yU+Kt4b1Mf/avGBChwEmmM0Dm6Lm2okNFyz41BSuggpNGt/hfTbhUnPe2mMu69vOYpYbMLQ8Z9PCDqZM9/Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773481754; c=relaxed/simple; bh=qqUc6IGecAKIHqxhBHUK67Qb9DpkM7wobrznfxJh7Lk=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=X/iFEX2L5g/cwhGFCK1DfvEWv+pV8hkx8B14lTAc53o5Hmlmak464IcnqJFZvc0MpzdLdExpZX/SThmDHbsFJ5DzRlP15/ttUoe2clwAiAurLIa1ib7XfqhvYM+vRhelS5lMjlTdZcjBeugI7zeD03ksU8KMK0bSuMW5ODgxVUo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=RJITm808; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="RJITm808" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Vwljc2bReMp+ReRMVI0DIpKEZxv2RLRL09hipjwo8dA=; b=RJITm808HJxNAgngepUVHWS4BO iS1JZsplQN3QOH8t7a58fK5PYFKjotLQcYo8VuisOgWcFYj6MFmi1Oj0XOtVeBgib3vCBP9jANtoo I8h4psS2ADNjdhoHTYbJBlgntsOrgeIEpaFIFD2u+blY4peG7w+WIcXKUB65aNaPK+TIBxca/c95M S4WuoIYVguJB/rzcUvDMkBkVBCblmqbX82HizILz7BG+57Wdx14LCRQIZlBfc0Dl5OA6czTsGHO4p 2xVvxEYpGJvQ7W3gSzV0RkGRe41fOu3YDOgYzs8uzE8euoxKeKtKlw0KXx7wJ4RZc0wc11o3YQzdQ aEHLZvew==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:40726 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w1LWr-0000000023J-1JE0; Sat, 14 Mar 2026 09:43:29 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.98.2) (envelope-from ) id 1w1LWo-0000000DGSw-1MCe; Sat, 14 Mar 2026 09:43:26 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn Cc: Alexandre Torgue , Alexei Starovoitov , Andrew Lunn , bpf@vger.kernel.org, Daniel Borkmann , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Jesper Dangaard Brouer , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, netdev@vger.kernel.org, Paolo Abeni , Stanislav Fomichev Subject: [PATCH net-next v4 13/15] net: stmmac: add helper to set transmit tail pointer Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" Message-Id: Sender: Russell King Date: Sat, 14 Mar 2026 09:43:26 +0000 Setting the queue transmit tail pointer follows a common pattern: calculate the DMA address, and then call stmmac_set_tx_tail_ptr(). The only difference between all the call sites is the index used. Factor this out into a static function. Signed-off-by: Russell King (Oracle) --- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index da1726b887f3..4521469c5e1d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -385,6 +385,18 @@ static struct dma_desc *stmmac_get_tx_desc(struct stmmac_priv *priv, return &tx_q->dma_tx[index]; } +static void stmmac_set_queue_tx_tail_ptr(struct stmmac_priv *priv, + struct stmmac_tx_queue *tx_q, + unsigned int chan, unsigned int index) +{ + int desc_size; + + desc_size = stmmac_get_tx_desc_size(priv, tx_q); + + tx_q->tx_tail_addr = tx_q->dma_tx_phy + index * desc_size; + stmmac_set_tx_tail_ptr(priv, priv->ioaddr, tx_q->tx_tail_addr, chan); +} + static size_t stmmac_get_rx_desc_size(struct stmmac_priv *priv) { if (priv->extend_desc) @@ -3311,9 +3323,7 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv) stmmac_init_tx_chan(priv, priv->ioaddr, priv->plat->dma_cfg, tx_q->dma_tx_phy, chan); - tx_q->tx_tail_addr = tx_q->dma_tx_phy; - stmmac_set_tx_tail_ptr(priv, priv->ioaddr, - tx_q->tx_tail_addr, chan); + stmmac_set_queue_tx_tail_ptr(priv, tx_q, chan, 0); } return ret; @@ -4326,9 +4336,6 @@ static void stmmac_tso_allocator(struct stmmac_priv *priv, dma_addr_t des, static void stmmac_flush_tx_descriptors(struct stmmac_priv *priv, int queue) { struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[queue]; - int desc_size; - - desc_size = stmmac_get_tx_desc_size(priv, tx_q); /* The own bit must be the latest setting done when prepare the * descriptor and then barrier is needed to make sure that @@ -4336,8 +4343,7 @@ static void stmmac_flush_tx_descriptors(struct stmmac_priv *priv, int queue) */ wmb(); - tx_q->tx_tail_addr = tx_q->dma_tx_phy + (tx_q->cur_tx * desc_size); - stmmac_set_tx_tail_ptr(priv, priv->ioaddr, tx_q->tx_tail_addr, queue); + stmmac_set_queue_tx_tail_ptr(priv, tx_q, queue, tx_q->cur_tx); } /** @@ -6967,9 +6973,7 @@ void stmmac_enable_tx_queue(struct stmmac_priv *priv, u32 queue) if (tx_q->tbs & STMMAC_TBS_AVAIL) stmmac_enable_tbs(priv, priv->ioaddr, 1, tx_q->queue_index); - tx_q->tx_tail_addr = tx_q->dma_tx_phy; - stmmac_set_tx_tail_ptr(priv, priv->ioaddr, - tx_q->tx_tail_addr, tx_q->queue_index); + stmmac_set_queue_tx_tail_ptr(priv, tx_q, tx_q->queue_index, 0); stmmac_start_tx_dma(priv, queue); @@ -7070,9 +7074,7 @@ int stmmac_xdp_open(struct net_device *dev) stmmac_init_tx_chan(priv, priv->ioaddr, priv->plat->dma_cfg, tx_q->dma_tx_phy, chan); - tx_q->tx_tail_addr = tx_q->dma_tx_phy; - stmmac_set_tx_tail_ptr(priv, priv->ioaddr, - tx_q->tx_tail_addr, chan); + stmmac_set_queue_tx_tail_ptr(priv, tx_q, chan, 0); hrtimer_setup(&tx_q->txtimer, stmmac_tx_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); } -- 2.47.3