[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240915171845.4f233a0c@kernel.org>
Date: Sun, 15 Sep 2024 17:18:45 +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 07/10] net: hibmcge: Implement rx_poll
function to receive packets
On Thu, 12 Sep 2024 10:51:24 +0800 Jijie Shao wrote:
> +static int hbg_napi_rx_poll(struct napi_struct *napi, int budget)
> +{
> + struct hbg_ring *ring = container_of(napi, struct hbg_ring, napi);
> + struct hbg_priv *priv = ring->priv;
> + struct hbg_rx_desc *rx_desc;
> + struct hbg_buffer *buffer;
> + u32 packet_done = 0;
> + u32 pkt_len;
> +
> + while (packet_done < budget) {
> + if (unlikely(hbg_queue_is_empty(ring->ntc, ring->ntu, ring)))
> + break;
> +
> + buffer = &ring->queue[ring->ntc];
> + if (unlikely(!buffer->skb))
> + goto next_buffer;
> +
> + if (unlikely(!hbg_sync_data_from_hw(priv, buffer)))
> + break;
> +
> + hbg_dma_unmap(buffer);
> +
> + skb_reserve(buffer->skb, HBG_PACKET_HEAD_SIZE + NET_IP_ALIGN);
> +
> + rx_desc = (struct hbg_rx_desc *)buffer->skb->data;
> + pkt_len = FIELD_GET(HBG_RX_DESC_W2_PKT_LEN_M, rx_desc->word2);
> + skb_put(buffer->skb, pkt_len);
> + buffer->skb->protocol = eth_type_trans(buffer->skb, priv->netdev);
> +
> + dev_sw_netstats_rx_add(priv->netdev, pkt_len);
> + netif_receive_skb(buffer->skb);
why not napi_gro_receive() ?
> + buffer->skb = NULL;
> + hbg_rx_fill_one_buffer(priv);
> +
> +next_buffer:
> + hbg_queue_move_next(ntc, ring);
> + packet_done++;
> + }
> +
> + hbg_rx_fill_buffers(priv);
don't try to refill the buffers if budget is 0, if budget is 0 we
should only do Tx processing (IOW this function should do nothing)
> + if (likely(napi_complete_done(napi, packet_done)))
same comment as on Tx, don't call if not done
> + hbg_hw_irq_enable(priv, HBG_INT_MSK_RX_B, true);
> +
> + return packet_done;
> +}
Powered by blists - more mailing lists