Subject: Re: Ethernet issue on imx6

From: "Russell King (Oracle)" <[email-masked]>
Date: Mon, 16 Oct 2023 22:47:11 +0100

On Mon, Oct 16, 2023 at 09:37:58PM +0200, Eric Dumazet wrote:
> diff --git a/drivers/net/ethernet/freescale/fec_main.c
> b/drivers/net/ethernet/freescale/fec_main.c
> index 77c8e9cfb44562e73bfa89d06c5d4b179d755502..520436d579d66cc3263527373d754a206cb5bcd6
> 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -753,7 +753,6 @@ fec_enet_txq_put_hdr_tso(struct fec_enet_priv_tx_q *txq,
>         struct fec_enet_private *fep = netdev_priv(ndev);
>         int hdr_len = skb_tcp_all_headers(skb);
>         struct bufdesc_ex *ebdp = container_of(bdp, struct bufdesc_ex, desc);
> -       void *bufaddr;
>         unsigned long dmabuf;
>         unsigned short status;
>         unsigned int estatus = 0;
> @@ -762,11 +761,11 @@ fec_enet_txq_put_hdr_tso(struct fec_enet_priv_tx_q *txq,
>         status &= ~BD_ENET_TX_STATS;
>         status |= (BD_ENET_TX_TC | BD_ENET_TX_READY);
> 
> -       bufaddr = txq->tso_hdrs + index * TSO_HEADER_SIZE;
>         dmabuf = txq->tso_hdrs_dma + index * TSO_HEADER_SIZE;
> -       if (((unsigned long)bufaddr) & fep->tx_align ||
> -               fep->quirks & FEC_QUIRK_SWAP_FRAME) {
> -               memcpy(txq->tx_bounce[index], skb->data, hdr_len);
> +       if (fep->quirks & FEC_QUIRK_SWAP_FRAME) {
> +               void *bufaddr = txq->tso_hdrs + index * TSO_HEADER_SIZE;
> +
> +               memcpy(txq->tx_bounce[index], bufaddr, hdr_len);
>                 bufaddr = txq->tx_bounce[index];
> 
>                 if (fep->quirks & FEC_QUIRK_SWAP_FRAME)

I'm not sure this has any effect on the reported issue.

1. For imx6 based devices, FEC_QUIRK_SWAP_FRAME is not set.
2. fep->tx_align is 15, TSO_HEADER_SIZE is 256, and ->tso_hdrs is
   derived from dma_alloc_coherent() which will be page aligned.
   So this condition will also always be false.

So, while the patch looks correct to me, I think it will only have an
effect on imx28 based systems that set FEC_QUIRK_SWAP_FRAME, and for
that it looks correct to me, since the header is always located in
txq->tso_hdrs and we need to copy it from there into the "bounce"
buffer.

Reviewed-by: Russell King (Oracle) <[email-masked]>

Thanks!

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!