[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240915171622.3ef8ff0e@kernel.org>
Date: Sun, 15 Sep 2024 17:16:22 +0200
From: Jakub Kicinski <kuba@...nel.org>
To: Jijie Shao <shaojijie@...wei.com>
Cc: <davem@...emloft.net>, <edumazet@...gle.com>, <pabeni@...hat.com>,
<shenjian15@...wei.com>, <wangpeiyang1@...wei.com>,
<liuyonglong@...wei.com>, <chenhao418@...wei.com>,
<sudongming1@...wei.com>, <xujunsheng@...wei.com>,
<shiyongbang@...wei.com>, <libaihan@...wei.com>, <andrew@...n.ch>,
<jdamato@...tly.com>, <horms@...nel.org>,
<kalesh-anakkur.purayil@...adcom.com>, <jonathan.cameron@...wei.com>,
<shameerali.kolothum.thodi@...wei.com>, <salil.mehta@...wei.com>,
<netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH V10 net-next 06/10] net: hibmcge: Implement
.ndo_start_xmit function
On Thu, 12 Sep 2024 10:51:23 +0800 Jijie Shao wrote:
> +static int hbg_napi_tx_recycle(struct napi_struct *napi, int budget)
> +{
> + struct hbg_ring *ring = container_of(napi, struct hbg_ring, napi);
> + /* This smp_load_acquire() pairs with smp_store_release() in
> + * hbg_start_xmit() called in xmit process.
> + */
> + u32 ntu = smp_load_acquire(&ring->ntu);
> + struct hbg_priv *priv = ring->priv;
> + struct hbg_buffer *buffer;
> + u32 ntc = ring->ntc;
> + int packet_done = 0;
> +
> + while (packet_done < budget) {
you should so some cleanup even if budget is 0
in fact you can hardcode the amount of work Tx NAPI does to 128 and
don't look at the budget as a limit. Per NAPI documentation budget
is for Rx
> + if (unlikely(hbg_queue_is_empty(ntc, ntu, ring)))
> + break;
> +
> + /* make sure HW write desc complete */
> + dma_rmb();
> +
> + buffer = &ring->queue[ntc];
> + if (buffer->state != HBG_TX_STATE_COMPLETE)
> + break;
> +
> + hbg_buffer_free(buffer);
> + ntc = hbg_queue_next_prt(ntc, ring);
> + packet_done++;
> + }
> +
> + /* This smp_store_release() pairs with smp_load_acquire() in
> + * hbg_start_xmit() called in xmit process.
> + */
> + smp_store_release(&ring->ntc, ntc);
> + netif_wake_queue(priv->netdev);
> +
> + if (likely(napi_complete_done(napi, packet_done)))
if packet_done >= budget you should not call napi_complete_done()
as you are not done
> + hbg_hw_irq_enable(priv, HBG_INT_MSK_TX_B, true);
Powered by blists - more mailing lists