[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c38c1482-1574-4cc9-9ebf-aa5ad30d627a@redhat.com>
Date: Tue, 27 Aug 2024 11:53:56 +0200
From: Paolo Abeni <pabeni@...hat.com>
To: Justin Lai <justinlai0215@...ltek.com>, kuba@...nel.org
Cc: davem@...emloft.net, edumazet@...gle.com, linux-kernel@...r.kernel.org,
netdev@...r.kernel.org, andrew@...n.ch, jiri@...nulli.us, horms@...nel.org,
rkannoth@...vell.com, jdamato@...tly.com, pkshih@...ltek.com,
larry.chiu@...ltek.com
Subject: Re: [PATCH net-next v28 07/13] rtase: Implement a function to receive
packets
Hi,
On 8/22/24 11:37, Justin Lai wrote:
> +static int rx_handler(struct rtase_ring *ring, int budget)
> +{
> + union rtase_rx_desc *desc_base = ring->desc;
> + u32 pkt_size, cur_rx, delta, entry, status;
> + struct rtase_private *tp = ring->ivec->tp;
> + struct net_device *dev = tp->dev;
> + union rtase_rx_desc *desc;
> + struct sk_buff *skb;
> + int workdone = 0;
> +
> + cur_rx = ring->cur_idx;
> + entry = cur_rx % RTASE_NUM_DESC;
> + desc = &desc_base[entry];
> +
> + do {
> + status = le32_to_cpu(desc->desc_status.opts1);
> +
> + if (status & RTASE_DESC_OWN)
> + break;
> +
> + /* This barrier is needed to keep us from reading
> + * any other fields out of the rx descriptor until
> + * we know the status of RTASE_DESC_OWN
> + */
> + dma_rmb();
> +
> + if (unlikely(status & RTASE_RX_RES)) {
> + if (net_ratelimit())
> + netdev_warn(dev, "Rx ERROR. status = %08x\n",
> + status);
> +
> + tp->stats.rx_errors++;
> +
> + if (status & (RTASE_RX_RWT | RTASE_RX_RUNT))
> + tp->stats.rx_length_errors++;
> +
> + if (status & RTASE_RX_CRC)
> + tp->stats.rx_crc_errors++;
> +
> + if (dev->features & NETIF_F_RXALL)
> + goto process_pkt;
> +
> + rtase_mark_to_asic(desc, tp->rx_buf_sz);
> + goto skip_process_pkt;
> + }
> +
> +process_pkt:
> + pkt_size = status & RTASE_RX_PKT_SIZE_MASK;
> + if (likely(!(dev->features & NETIF_F_RXFCS)))
> + pkt_size -= ETH_FCS_LEN;
> +
> + /* The driver does not support incoming fragmented frames.
> + * They are seen as a symptom of over-mtu sized frames.
> + */
> + if (unlikely(rtase_fragmented_frame(status))) {
> + tp->stats.rx_dropped++;
> + tp->stats.rx_length_errors++;
> + rtase_mark_to_asic(desc, tp->rx_buf_sz);
> + goto skip_process_pkt;
> + }
> +
> + dma_sync_single_for_cpu(&tp->pdev->dev,
> + ring->mis.data_phy_addr[entry],
> + tp->rx_buf_sz, DMA_FROM_DEVICE);
> +
> + skb = build_skb(ring->data_buf[entry], PAGE_SIZE);
> + if (!skb) {
> + netdev_err(dev, "skb build failed\n");
I'm sorry for this late feedback, but the above message should be
dropped, too.
As pointed out by Jakub in the previous revision, this allocation can
fail, and the counter increase below will give exactly the same amount
of information, without potentially filling the dmseg buffer.
FWIW, I think the above is the last item pending.
Thanks,
Paolo
Powered by blists - more mailing lists