netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Justin Lai <justinlai0215@realtek.com>
Cc: <davem@davemloft.net>, <edumazet@google.com>, <pabeni@redhat.com>,
	<linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>,
	<andrew@lunn.ch>, <pkshih@realtek.com>, <larry.chiu@realtek.com>
Subject: Re: [PATCH net-next v14 06/13] rtase: Implement .ndo_start_xmit function
Date: Tue, 12 Dec 2023 11:32:12 -0800	[thread overview]
Message-ID: <20231212113212.1cfb9e19@kernel.org> (raw)
In-Reply-To: <20231208094733.1671296-7-justinlai0215@realtek.com>

On Fri, 8 Dec 2023 17:47:26 +0800 Justin Lai wrote:
> +static int tx_handler(struct rtase_ring *ring, int budget)

I don't see how this is called, the way you split the submission makes
it a bit hard to review, oh well. Anyway - if you pass the NAPI budget
here - that's not right, it may be 0, and you'd loop forever.
For Tx - you should try to reap some fixed number of packets, say 128,
the budget is for Rx, not for Tx.

> +	const struct rtase_private *tp = ring->ivec->tp;
> +	struct net_device *dev = tp->dev;
> +	int workdone = 0;
> +	u32 dirty_tx;
> +	u32 tx_left;
> +
> +	dirty_tx = ring->dirty_idx;
> +	tx_left = READ_ONCE(ring->cur_idx) - dirty_tx;
> +
> +	while (tx_left > 0) {
> +		u32 entry = dirty_tx % NUM_DESC;
> +		struct tx_desc *desc = ring->desc +
> +				       sizeof(struct tx_desc) * entry;
> +		u32 len = ring->mis.len[entry];
> +		u32 status;
> +
> +		status = le32_to_cpu(desc->opts1);
> +
> +		if (status & DESC_OWN)
> +			break;
> +
> +		rtase_unmap_tx_skb(tp->pdev, len, desc);
> +		ring->mis.len[entry] = 0;
> +		if (ring->skbuff[entry]) {
> +			dev_consume_skb_any(ring->skbuff[entry]);

napi_consume_skb, assuming you call this from NAPI

> +			ring->skbuff[entry] = NULL;
> +		}
> +
> +		dev->stats.tx_bytes += len;
> +		dev->stats.tx_packets++;
> +		dirty_tx++;
> +		tx_left--;
> +		workdone++;
> +
> +		if (workdone == budget)
> +			break;
> +	}
> +
> +	if (ring->dirty_idx != dirty_tx) {
> +		WRITE_ONCE(ring->dirty_idx, dirty_tx);
> +
> +		if (__netif_subqueue_stopped(dev, ring->index) &&
> +		    rtase_tx_avail(ring))
> +			netif_start_subqueue(dev, ring->index);

Please use the start / stop macros from include/net/netdev_queues.h
I'm pretty sure the current code is racy.

> +		if (ring->cur_idx != dirty_tx)
> +			rtase_w8(tp, RTASE_TPPOLL, BIT(ring->index));
> +	}
> +
> +	return workdone;
> +}

> +	/* multiqueues */
> +	q_idx = skb_get_queue_mapping(skb);
> +	ring = &tp->tx_ring[q_idx];

As Paolo pointed out elsewhere you seem to only support one queue.
Remove this indirection, please, and always use queue 0, otherwise
it's a bit confusing.

  reply	other threads:[~2023-12-12 19:32 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-08  9:47 [PATCH net-next v14 00/13] Add Realtek automotive PCIe driver Justin Lai
2023-12-08  9:47 ` [PATCH net-next v14 01/13] rtase: Add pci table supported in this module Justin Lai
2023-12-12  9:36   ` Paolo Abeni
2023-12-12 16:05     ` Jakub Kicinski
2023-12-14 12:42     ` JustinLai0215
2023-12-08  9:47 ` [PATCH net-next v14 02/13] rtase: Implement the .ndo_open function Justin Lai
2023-12-12  9:49   ` Paolo Abeni
2023-12-14 12:44     ` JustinLai0215
2023-12-08  9:47 ` [PATCH net-next v14 03/13] rtase: Implement the rtase_down function Justin Lai
2023-12-12 19:27   ` Jakub Kicinski
2023-12-14 12:54     ` JustinLai0215
2023-12-08  9:47 ` [PATCH net-next v14 04/13] rtase: Implement the interrupt routine and rtase_poll Justin Lai
2023-12-08  9:47 ` [PATCH net-next v14 05/13] rtase: Implement hardware configuration function Justin Lai
2023-12-08  9:47 ` [PATCH net-next v14 06/13] rtase: Implement .ndo_start_xmit function Justin Lai
2023-12-12 19:32   ` Jakub Kicinski [this message]
2023-12-14 13:00     ` JustinLai0215
2023-12-14 17:24       ` Jakub Kicinski
2023-12-18 10:27     ` Justin Lai
2023-12-08  9:47 ` [PATCH net-next v14 07/13] rtase: Implement a function to receive packets Justin Lai
2023-12-12 10:04   ` Paolo Abeni
2023-12-14 12:45     ` JustinLai0215
2023-12-18 10:18     ` Justin Lai
2023-12-08  9:47 ` [PATCH net-next v14 08/13] rtase: Implement net_device_ops Justin Lai
2023-12-12 10:09   ` Paolo Abeni
2023-12-14 12:47     ` JustinLai0215
2023-12-08  9:47 ` [PATCH net-next v14 09/13] rtase: Implement pci_driver suspend and resume function Justin Lai
2023-12-12 19:19   ` Jakub Kicinski
2023-12-14 12:48     ` JustinLai0215
2023-12-08  9:47 ` [PATCH net-next v14 10/13] rtase: Implement ethtool function Justin Lai
2023-12-12 19:21   ` Jakub Kicinski
2023-12-08  9:47 ` [PATCH net-next v14 11/13] rtase: Add a Makefile in the rtase folder Justin Lai
2023-12-08  9:47 ` [PATCH net-next v14 12/13] realtek: Update the Makefile and Kconfig in the realtek folder Justin Lai
2023-12-08  9:47 ` [PATCH net-next v14 13/13] MAINTAINERS: Add the rtase ethernet driver entry Justin Lai
2023-12-12 19:22   ` Jakub Kicinski
2023-12-14 12:51     ` JustinLai0215
2023-12-14 17:27       ` Jakub Kicinski

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=20231212113212.1cfb9e19@kernel.org \
    --to=kuba@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=justinlai0215@realtek.com \
    --cc=larry.chiu@realtek.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pkshih@realtek.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).