[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aWZrECQIy+a8yEcJ@lizhi-Precision-Tower-5810>
Date: Tue, 13 Jan 2026 10:56:00 -0500
From: Frank Li <Frank.li@....com>
To: Wei Fang <wei.fang@....com>
Cc: shenwei.wang@....com, xiaoning.wang@....com, andrew+netdev@...n.ch,
davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
pabeni@...hat.com, ast@...nel.org, daniel@...earbox.net,
hawk@...nel.org, john.fastabend@...il.com, sdf@...ichev.me,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
imx@...ts.linux.dev, bpf@...r.kernel.org
Subject: Re: [PATCH net-next 03/11] net: fec: add rx_shift to indicate the
extra bytes padded in front of RX frame
On Tue, Jan 13, 2026 at 11:29:31AM +0800, Wei Fang wrote:
> The FEC of some platforms supports RX FIFO shift-16, it means the actual
> frame data starts at bit 16 of the first word read from RX FIFO aligning
> the Ethernet payload on a 32-bit boundary. The MAC writes two additional
> bytes in front of each frame received into the RX FIFO. Currently, the
> fec_enet_rx_queue() updates the data_start, sub_len and the rx_bytes
> statistics by checking whether FEC_QUIRK_HAS_RACC is set. This makes the
> code less concise, so rx_shift is added to represent the number of extra
> bytes padded in front of the RX frame. Furthermore, when adding separate
> RX handling functions for XDP copy mode and zero copy mode in the future,
> it will no longer be necessary to check FEC_QUIRK_HAS_RACC to update the
> corresponding variables.
>
> Signed-off-by: Wei Fang <wei.fang@....com>
> ---
Reviewed-by: Frank Li <Frank.Li@....com>
> drivers/net/ethernet/freescale/fec.h | 1 +
> drivers/net/ethernet/freescale/fec_main.c | 21 ++++++++-------------
> 2 files changed, 9 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h
> index fd9a93d02f8e..ad7aba1a8536 100644
> --- a/drivers/net/ethernet/freescale/fec.h
> +++ b/drivers/net/ethernet/freescale/fec.h
> @@ -643,6 +643,7 @@ struct fec_enet_private {
> struct pm_qos_request pm_qos_req;
>
> unsigned int tx_align;
> + unsigned int rx_shift;
>
> /* hw interrupt coalesce */
> unsigned int rx_pkts_itr;
> diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
> index 0fa78ca9bc04..68410cb3ef0a 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -1799,22 +1799,14 @@ fec_enet_rx_queue(struct net_device *ndev, u16 queue_id, int budget)
> struct bufdesc_ex *ebdp = NULL;
> int index = 0;
> bool need_swap = fep->quirks & FEC_QUIRK_SWAP_FRAME;
> + u32 data_start = FEC_ENET_XDP_HEADROOM + fep->rx_shift;
> struct bpf_prog *xdp_prog = READ_ONCE(fep->xdp_prog);
> u32 ret, xdp_result = FEC_ENET_XDP_PASS;
> - u32 data_start = FEC_ENET_XDP_HEADROOM;
> + u32 sub_len = 4 + fep->rx_shift;
> int cpu = smp_processor_id();
> struct xdp_buff xdp;
> struct page *page;
> __fec32 cbd_bufaddr;
> - u32 sub_len = 4;
> -
> - /*If it has the FEC_QUIRK_HAS_RACC quirk property, the bit of
> - * FEC_RACC_SHIFT16 is set by default in the probe function.
> - */
> - if (fep->quirks & FEC_QUIRK_HAS_RACC) {
> - data_start += 2;
> - sub_len += 2;
> - }
>
> #if defined(CONFIG_COLDFIRE) && !defined(CONFIG_COLDFIRE_COHERENT_DMA)
> /*
> @@ -1847,9 +1839,7 @@ fec_enet_rx_queue(struct net_device *ndev, u16 queue_id, int budget)
> /* Process the incoming frame. */
> ndev->stats.rx_packets++;
> pkt_len = fec16_to_cpu(bdp->cbd_datlen);
> - ndev->stats.rx_bytes += pkt_len;
> - if (fep->quirks & FEC_QUIRK_HAS_RACC)
> - ndev->stats.rx_bytes -= 2;
> + ndev->stats.rx_bytes += pkt_len - fep->rx_shift;
>
> index = fec_enet_get_bd_index(bdp, &rxq->bd);
> page = rxq->rx_buf[index];
> @@ -4602,6 +4592,11 @@ fec_probe(struct platform_device *pdev)
>
> ndev->max_mtu = fep->max_buf_size - ETH_HLEN - ETH_FCS_LEN;
>
> + if (fep->quirks & FEC_QUIRK_HAS_RACC)
> + fep->rx_shift = 2;
> + else
> + fep->rx_shift = 0;
> +
> ret = register_netdev(ndev);
> if (ret)
> goto failed_register;
> --
> 2.34.1
>
Powered by blists - more mailing lists