netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Roger Quadros <rogerq@kernel.org>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Jesper Dangaard Brouer <hawk@kernel.org>,
	John Fastabend <john.fastabend@gmail.com>,
	Siddharth Vadapalli <s-vadapalli@ti.com>,
	Md Danish Anwar <danishanwar@ti.com>,
	srk@ti.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	bpf@vger.kernel.org
Subject: Re: [PATCH net-next 1/5] net: ethernet: ti: am65-cpsw: remove am65_cpsw_nuss_tx_compl_packets_2g()
Date: Tue, 18 Feb 2025 18:01:20 +0000	[thread overview]
Message-ID: <20250218180120.GC1615191@kernel.org> (raw)
In-Reply-To: <20250217-am65-cpsw-zc-prep-v1-1-ce450a62d64f@kernel.org>

On Mon, Feb 17, 2025 at 09:31:46AM +0200, Roger Quadros wrote:
> The only difference between am65_cpsw_nuss_tx_compl_packets_2g() and
> am65_cpsw_nuss_tx_compl_packets() is the usage of spin_lock() and
> netdev_tx_completed_queue() + am65_cpsw_nuss_tx_wake at every packet
> in the latter.
> 
> Insted of having 2 separate functions for TX completion, merge them

nit, in case there is a v2 for some other reason: Instead

> into one. This will reduce code duplication and make maintenance easier.
> 
> Signed-off-by: Roger Quadros <rogerq@kernel.org>

...

> diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c

...

> @@ -1533,23 +1538,35 @@ static int am65_cpsw_nuss_tx_compl_packets(struct am65_cpsw_common *common,
>  		if (buf_type == AM65_CPSW_TX_BUF_TYPE_SKB) {
>  			skb = am65_cpsw_nuss_tx_compl_packet_skb(tx_chn, desc_dma);
>  			ndev = skb->dev;
> -			total_bytes = skb->len;
> +			pkt_len = skb->len;
>  			napi_consume_skb(skb, budget);
>  		} else {
>  			xdpf = am65_cpsw_nuss_tx_compl_packet_xdp(common, tx_chn,
>  								  desc_dma, &ndev);
> -			total_bytes = xdpf->len;
> +			pkt_len = xdpf->len;
>  			if (buf_type == AM65_CPSW_TX_BUF_TYPE_XDP_TX)
>  				xdp_return_frame_rx_napi(xdpf);
>  			else
>  				xdp_return_frame(xdpf);
>  		}
> +
> +		total_bytes += pkt_len;
>  		num_tx++;
>  
> -		netif_txq = netdev_get_tx_queue(ndev, chn);
> +		if (!single_port) {
> +			/* as packets from multi ports can be interleaved
> +			 * on the same channel, we have to figure out the
> +			 * port/queue at every packet and report it/wake queue.
> +			 */
> +			netif_txq = netdev_get_tx_queue(ndev, chn);
> +			netdev_tx_completed_queue(netif_txq, 1, pkt_len);
> +			am65_cpsw_nuss_tx_wake(tx_chn, ndev, netif_txq);
> +		}
> +	}
>  
> +	if (single_port) {
> +		netif_txq = netdev_get_tx_queue(ndev, chn);
>  		netdev_tx_completed_queue(netif_txq, num_tx, total_bytes);
> -
>  		am65_cpsw_nuss_tx_wake(tx_chn, ndev, netif_txq);
>  	}

Maybe it's not worth it, but it seems that a helper could
avoid duplication of the netif_txq handling immediately above (twice).

Regardless, this looks good to me.

Reviewed-by: Simon Horman <horms@kernel.org>

...

  reply	other threads:[~2025-02-18 18:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-17  7:31 [PATCH net-next 0/5] net: ethernet: ti: am65-cpsw: drop multiple functions and code cleanup Roger Quadros
2025-02-17  7:31 ` [PATCH net-next 1/5] net: ethernet: ti: am65-cpsw: remove am65_cpsw_nuss_tx_compl_packets_2g() Roger Quadros
2025-02-18 18:01   ` Simon Horman [this message]
2025-02-17  7:31 ` [PATCH net-next 2/5] net: ethernet: ti: am65_cpsw: remove cpu argument am65_cpsw_run_xdp Roger Quadros
2025-02-18 18:01   ` Simon Horman
2025-02-17  7:31 ` [PATCH net-next 3/5] net: ethernet: ti: am65-cpsw: use return instead of goto in am65_cpsw_run_xdp() Roger Quadros
2025-02-18 18:02   ` Simon Horman
2025-02-17  7:31 ` [PATCH net-next 4/5] net: ethernet: ti: am65_cpsw: move am65_cpsw_put_page() out of am65_cpsw_run_xdp() Roger Quadros
2025-02-18 18:03   ` Simon Horman
2025-02-24 13:00     ` Roger Quadros
2025-02-17  7:31 ` [PATCH net-next 5/5] net: ethernet: ti am65_cpsw: Drop separate TX completion functions Roger Quadros
2025-02-18 18:04   ` Simon Horman
2025-02-19 12:00 ` [PATCH net-next 0/5] net: ethernet: ti: am65-cpsw: drop multiple functions and code cleanup patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250218180120.GC1615191@kernel.org \
    --to=horms@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=danishanwar@ti.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hawk@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rogerq@kernel.org \
    --cc=s-vadapalli@ti.com \
    --cc=srk@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).