* [PATCH net-next] net: fec: Allow reception of frames bigger than 1522 bytes
@ 2017-07-30 17:36 Andrew Lunn
2017-07-31 1:41 ` Andy Duan
2017-07-31 2:26 ` David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Andrew Lunn @ 2017-07-30 17:36 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Fugang Duan, Andrew Lunn
The FEC Receive Control Register has a 14 bit field indicating the
longest frame that my be received. It is being set to 1522. Frames
longer than this are discarded, but counted as being in error.
When using DSA, frames from the switch has an additional header,
either 4 or 8 bytes if a Marvell switch is used. Thus a full MTU frame
of 1522 bytes received by the switch on a port becomes 1530 bytes when
passed to the host via the FEC interface.
Change the maximum receive size to 2048 - 64, where 64 is the maximum
rx_alignment applied on the receive buffer for AVB capable FEC
cores. Use this value also for the maximum receive buffer size. The
driver is already allocating a receive SKB of 2048 bytes, so this
change should not have any significant effects.
Tested on imx51, imx6, vf610.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
drivers/net/ethernet/freescale/fec_main.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index a6e323f15637..47ee74a17a9f 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -173,10 +173,12 @@ MODULE_PARM_DESC(macaddr, "FEC Ethernet MAC address");
#endif /* CONFIG_M5272 */
/* The FEC stores dest/src/type/vlan, data, and checksum for receive packets.
+ *
+ * 2048 byte skbufs are allocated. However, alignment requirements
+ * varies between FEC variants. Worst case is 64, so round down by 64.
*/
-#define PKT_MAXBUF_SIZE 1522
+#define PKT_MAXBUF_SIZE (round_down(2048 - 64, 64))
#define PKT_MINBUF_SIZE 64
-#define PKT_MAXBLR_SIZE 1536
/* FEC receive acceleration */
#define FEC_RACC_IPDIS (1 << 1)
@@ -851,7 +853,7 @@ static void fec_enet_enable_ring(struct net_device *ndev)
for (i = 0; i < fep->num_rx_queues; i++) {
rxq = fep->rx_queue[i];
writel(rxq->bd.dma, fep->hwp + FEC_R_DES_START(i));
- writel(PKT_MAXBLR_SIZE, fep->hwp + FEC_R_BUFF_SIZE(i));
+ writel(PKT_MAXBUF_SIZE, fep->hwp + FEC_R_BUFF_SIZE(i));
/* enable DMA1/2 */
if (i)
--
2.13.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH net-next] net: fec: Allow reception of frames bigger than 1522 bytes
2017-07-30 17:36 [PATCH net-next] net: fec: Allow reception of frames bigger than 1522 bytes Andrew Lunn
@ 2017-07-31 1:41 ` Andy Duan
2017-07-31 2:26 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: Andy Duan @ 2017-07-31 1:41 UTC (permalink / raw)
To: Andrew Lunn, David Miller; +Cc: netdev
From: Andrew Lunn <andrew@lunn.ch> Sent: Monday, July 31, 2017 1:36 AM
>The FEC Receive Control Register has a 14 bit field indicating the longest frame
>that my be received. It is being set to 1522. Frames longer than this are
My -> may
>discarded, but counted as being in error.
>
>When using DSA, frames from the switch has an additional header, either 4 or
>8 bytes if a Marvell switch is used. Thus a full MTU frame of 1522 bytes
>received by the switch on a port becomes 1530 bytes when passed to the host
>via the FEC interface.
>
>Change the maximum receive size to 2048 - 64, where 64 is the maximum
>rx_alignment applied on the receive buffer for AVB capable FEC cores. Use this
>value also for the maximum receive buffer size. The driver is already allocating
>a receive SKB of 2048 bytes, so this change should not have any significant
>effects.
>
>Tested on imx51, imx6, vf610.
>
>Signed-off-by: Andrew Lunn <andrew@lunn.ch>
>---
> drivers/net/ethernet/freescale/fec_main.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
>diff --git a/drivers/net/ethernet/freescale/fec_main.c
>b/drivers/net/ethernet/freescale/fec_main.c
>index a6e323f15637..47ee74a17a9f 100644
>--- a/drivers/net/ethernet/freescale/fec_main.c
>+++ b/drivers/net/ethernet/freescale/fec_main.c
>@@ -173,10 +173,12 @@ MODULE_PARM_DESC(macaddr, "FEC Ethernet
>MAC address"); #endif /* CONFIG_M5272 */
>
> /* The FEC stores dest/src/type/vlan, data, and checksum for receive packets.
>+ *
>+ * 2048 byte skbufs are allocated. However, alignment requirements
>+ * varies between FEC variants. Worst case is 64, so round down by 64.
> */
>-#define PKT_MAXBUF_SIZE 1522
>+#define PKT_MAXBUF_SIZE (round_down(2048 - 64, 64))
> #define PKT_MINBUF_SIZE 64
>-#define PKT_MAXBLR_SIZE 1536
>
> /* FEC receive acceleration */
> #define FEC_RACC_IPDIS (1 << 1)
>@@ -851,7 +853,7 @@ static void fec_enet_enable_ring(struct net_device
>*ndev)
> for (i = 0; i < fep->num_rx_queues; i++) {
> rxq = fep->rx_queue[i];
> writel(rxq->bd.dma, fep->hwp + FEC_R_DES_START(i));
>- writel(PKT_MAXBLR_SIZE, fep->hwp + FEC_R_BUFF_SIZE(i));
>+ writel(PKT_MAXBUF_SIZE, fep->hwp + FEC_R_BUFF_SIZE(i));
>
> /* enable DMA1/2 */
> if (i)
>--
>2.13.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: fec: Allow reception of frames bigger than 1522 bytes
2017-07-30 17:36 [PATCH net-next] net: fec: Allow reception of frames bigger than 1522 bytes Andrew Lunn
2017-07-31 1:41 ` Andy Duan
@ 2017-07-31 2:26 ` David Miller
2017-07-31 2:27 ` Andrew Lunn
1 sibling, 1 reply; 4+ messages in thread
From: David Miller @ 2017-07-31 2:26 UTC (permalink / raw)
To: andrew; +Cc: netdev, fugang.duan
From: Andrew Lunn <andrew@lunn.ch>
Date: Sun, 30 Jul 2017 19:36:05 +0200
> The FEC Receive Control Register has a 14 bit field indicating the
> longest frame that my be received. It is being set to 1522. Frames
> longer than this are discarded, but counted as being in error.
>
> When using DSA, frames from the switch has an additional header,
> either 4 or 8 bytes if a Marvell switch is used. Thus a full MTU frame
> of 1522 bytes received by the switch on a port becomes 1530 bytes when
> passed to the host via the FEC interface.
>
> Change the maximum receive size to 2048 - 64, where 64 is the maximum
> rx_alignment applied on the receive buffer for AVB capable FEC
> cores. Use this value also for the maximum receive buffer size. The
> driver is already allocating a receive SKB of 2048 bytes, so this
> change should not have any significant effects.
>
> Tested on imx51, imx6, vf610.
>
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Applied with commit log message typo fixed.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: fec: Allow reception of frames bigger than 1522 bytes
2017-07-31 2:26 ` David Miller
@ 2017-07-31 2:27 ` Andrew Lunn
0 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2017-07-31 2:27 UTC (permalink / raw)
To: David Miller; +Cc: netdev, fugang.duan
On Sun, Jul 30, 2017 at 07:26:29PM -0700, David Miller wrote:
> From: Andrew Lunn <andrew@lunn.ch>
> Date: Sun, 30 Jul 2017 19:36:05 +0200
>
> > The FEC Receive Control Register has a 14 bit field indicating the
> > longest frame that my be received. It is being set to 1522. Frames
> > longer than this are discarded, but counted as being in error.
> >
> > When using DSA, frames from the switch has an additional header,
> > either 4 or 8 bytes if a Marvell switch is used. Thus a full MTU frame
> > of 1522 bytes received by the switch on a port becomes 1530 bytes when
> > passed to the host via the FEC interface.
> >
> > Change the maximum receive size to 2048 - 64, where 64 is the maximum
> > rx_alignment applied on the receive buffer for AVB capable FEC
> > cores. Use this value also for the maximum receive buffer size. The
> > driver is already allocating a receive SKB of 2048 bytes, so this
> > change should not have any significant effects.
> >
> > Tested on imx51, imx6, vf610.
> >
> > Signed-off-by: Andrew Lunn <andrew@lunn.ch>
>
> Applied with commit log message typo fixed.
Hi David
Thanks for fixing the typo.
Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-07-31 2:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-30 17:36 [PATCH net-next] net: fec: Allow reception of frames bigger than 1522 bytes Andrew Lunn
2017-07-31 1:41 ` Andy Duan
2017-07-31 2:26 ` David Miller
2017-07-31 2:27 ` Andrew Lunn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).