The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [net PATCH v2 0/2] Fix maximum TX/RX frame sizes in ravb driver
@ 2024-08-28 10:22 Paul Barker
  2024-08-28 10:22 ` [net PATCH v2 1/2] net: ravb: Fix maximum TX frame size for GbEth devices Paul Barker
  2024-08-28 10:22 ` [net PATCH v2 2/2] net: ravb: Fix R-Car RX frame size limit Paul Barker
  0 siblings, 2 replies; 4+ messages in thread
From: Paul Barker @ 2024-08-28 10:22 UTC (permalink / raw)
  To: Sergey Shtylyov, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Niklas Söderlund, Andrew Lunn
  Cc: Paul Barker, Biju Das, Claudiu Beznea, Lad Prabhakar,
	Mitsuhiro Kimura, netdev, linux-renesas-soc, linux-kernel

These patches fix a couple of bugs in the maximum supported TX/RX frame
sizes in the ravb driver.

  * For the GbEth IP, we were advertising a maximum TX frame size/MTU
    that was larger that the maximum the hardware can transmit.

  * For the R-Car AVB IP, we were unnecessarily setting the maximum RX
    frame size/MRU based on the MTU, which by default is smaller than
    the maximum the hardware can receive.

For the R-Car AVB IP, the maximum TX frame size should be 2047 (not
2048), but additional work will be required to validate that change so
it is not included in this series.

Changes v1->v2:
  * Rebase on net tree as these are both bugfixes.
  * Pick up Reveiwed-by tags.

Paul Barker (2):
  net: ravb: Fix maximum TX frame size for GbEth devices
  net: ravb: Fix R-Car RX frame size limit

 drivers/net/ethernet/renesas/ravb.h      |  1 +
 drivers/net/ethernet/renesas/ravb_main.c | 10 ++++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [net PATCH v2 1/2] net: ravb: Fix maximum TX frame size for GbEth devices
  2024-08-28 10:22 [net PATCH v2 0/2] Fix maximum TX/RX frame sizes in ravb driver Paul Barker
@ 2024-08-28 10:22 ` Paul Barker
  2024-08-28 10:22 ` [net PATCH v2 2/2] net: ravb: Fix R-Car RX frame size limit Paul Barker
  1 sibling, 0 replies; 4+ messages in thread
From: Paul Barker @ 2024-08-28 10:22 UTC (permalink / raw)
  To: Sergey Shtylyov, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Niklas Söderlund, Andrew Lunn
  Cc: Paul Barker, Biju Das, Claudiu Beznea, Lad Prabhakar,
	Mitsuhiro Kimura, Geert Uytterhoeven, netdev, linux-renesas-soc,
	linux-kernel

The datasheets for all SoCs using the GbEth IP specify a maximum
transmission frame size of 1.5 kByte. I've confirmed through internal
discussions that support for 1522 byte frames has been validated, which
allows us to support the default MTU of 1500 bytes after reserving space
for the Ethernet header, frame checksums and an optional VLAN tag.

Fixes: 2e95e08ac009 ("ravb: Add rx_max_buf_size to struct ravb_hw_info")
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: Paul Barker <paul.barker.ct@bp.renesas.com>
---
 drivers/net/ethernet/renesas/ravb.h      | 1 +
 drivers/net/ethernet/renesas/ravb_main.c | 6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index 9893c91af105..a7de5cf6b317 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -1052,6 +1052,7 @@ struct ravb_hw_info {
 	netdev_features_t net_features;
 	int stats_len;
 	u32 tccr_mask;
+	u32 tx_max_frame_size;
 	u32 rx_max_frame_size;
 	u32 rx_buffer_size;
 	u32 rx_desc_size;
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index c02fb296bf7d..471a68b0146e 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -2674,6 +2674,7 @@ static const struct ravb_hw_info ravb_gen2_hw_info = {
 	.net_features = NETIF_F_RXCSUM,
 	.stats_len = ARRAY_SIZE(ravb_gstrings_stats),
 	.tccr_mask = TCCR_TSRQ0 | TCCR_TSRQ1 | TCCR_TSRQ2 | TCCR_TSRQ3,
+	.tx_max_frame_size = SZ_2K,
 	.rx_max_frame_size = SZ_2K,
 	.rx_buffer_size = SZ_2K +
 			  SKB_DATA_ALIGN(sizeof(struct skb_shared_info)),
@@ -2696,6 +2697,7 @@ static const struct ravb_hw_info ravb_gen3_hw_info = {
 	.net_features = NETIF_F_RXCSUM,
 	.stats_len = ARRAY_SIZE(ravb_gstrings_stats),
 	.tccr_mask = TCCR_TSRQ0 | TCCR_TSRQ1 | TCCR_TSRQ2 | TCCR_TSRQ3,
+	.tx_max_frame_size = SZ_2K,
 	.rx_max_frame_size = SZ_2K,
 	.rx_buffer_size = SZ_2K +
 			  SKB_DATA_ALIGN(sizeof(struct skb_shared_info)),
@@ -2721,6 +2723,7 @@ static const struct ravb_hw_info ravb_gen4_hw_info = {
 	.net_features = NETIF_F_RXCSUM,
 	.stats_len = ARRAY_SIZE(ravb_gstrings_stats),
 	.tccr_mask = TCCR_TSRQ0 | TCCR_TSRQ1 | TCCR_TSRQ2 | TCCR_TSRQ3,
+	.tx_max_frame_size = SZ_2K,
 	.rx_max_frame_size = SZ_2K,
 	.rx_buffer_size = SZ_2K +
 			  SKB_DATA_ALIGN(sizeof(struct skb_shared_info)),
@@ -2770,6 +2773,7 @@ static const struct ravb_hw_info gbeth_hw_info = {
 	.net_features = NETIF_F_RXCSUM | NETIF_F_HW_CSUM,
 	.stats_len = ARRAY_SIZE(ravb_gstrings_stats_gbeth),
 	.tccr_mask = TCCR_TSRQ0,
+	.tx_max_frame_size = 1522,
 	.rx_max_frame_size = SZ_8K,
 	.rx_buffer_size = SZ_2K,
 	.rx_desc_size = sizeof(struct ravb_rx_desc),
@@ -2981,7 +2985,7 @@ static int ravb_probe(struct platform_device *pdev)
 	priv->avb_link_active_low =
 		of_property_read_bool(np, "renesas,ether-link-active-low");
 
-	ndev->max_mtu = info->rx_max_frame_size -
+	ndev->max_mtu = info->tx_max_frame_size -
 		(ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN);
 	ndev->min_mtu = ETH_MIN_MTU;
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [net PATCH v2 2/2] net: ravb: Fix R-Car RX frame size limit
  2024-08-28 10:22 [net PATCH v2 0/2] Fix maximum TX/RX frame sizes in ravb driver Paul Barker
  2024-08-28 10:22 ` [net PATCH v2 1/2] net: ravb: Fix maximum TX frame size for GbEth devices Paul Barker
@ 2024-08-28 10:22 ` Paul Barker
  2024-08-28 15:03   ` Niklas Söderlund
  1 sibling, 1 reply; 4+ messages in thread
From: Paul Barker @ 2024-08-28 10:22 UTC (permalink / raw)
  To: Sergey Shtylyov, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Niklas Söderlund, Andrew Lunn
  Cc: Paul Barker, Biju Das, Claudiu Beznea, Lad Prabhakar,
	Mitsuhiro Kimura, Geert Uytterhoeven, netdev, linux-renesas-soc,
	linux-kernel

The RX frame size limit should not be based on the current MTU setting.
Instead it should be based on the hardware capabilities.

Fixes: c156633f1353 ("Renesas Ethernet AVB driver proper")
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: Paul Barker <paul.barker.ct@bp.renesas.com>
---
 drivers/net/ethernet/renesas/ravb_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 471a68b0146e..b103632de4d4 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -555,8 +555,10 @@ static void ravb_emac_init_gbeth(struct net_device *ndev)
 
 static void ravb_emac_init_rcar(struct net_device *ndev)
 {
+	struct ravb_private *priv = netdev_priv(ndev);
+
 	/* Receive frame limit set register */
-	ravb_write(ndev, ndev->mtu + ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN, RFLR);
+	ravb_write(ndev, priv->info->rx_max_frame_size + ETH_FCS_LEN, RFLR);
 
 	/* EMAC Mode: PAUSE prohibition; Duplex; RX Checksum; TX; RX */
 	ravb_write(ndev, ECMR_ZPF | ECMR_DM |
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [net PATCH v2 2/2] net: ravb: Fix R-Car RX frame size limit
  2024-08-28 10:22 ` [net PATCH v2 2/2] net: ravb: Fix R-Car RX frame size limit Paul Barker
@ 2024-08-28 15:03   ` Niklas Söderlund
  0 siblings, 0 replies; 4+ messages in thread
From: Niklas Söderlund @ 2024-08-28 15:03 UTC (permalink / raw)
  To: Paul Barker
  Cc: Sergey Shtylyov, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Andrew Lunn, Biju Das, Claudiu Beznea, Lad Prabhakar,
	Mitsuhiro Kimura, Geert Uytterhoeven, netdev, linux-renesas-soc,
	linux-kernel

Hi Paul,

Thanks for your work.

On 2024-08-28 11:22:26 +0100, Paul Barker wrote:
> The RX frame size limit should not be based on the current MTU setting.
> Instead it should be based on the hardware capabilities.
> 
> Fixes: c156633f1353 ("Renesas Ethernet AVB driver proper")
> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> Signed-off-by: Paul Barker <paul.barker.ct@bp.renesas.com>

Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

> ---
>  drivers/net/ethernet/renesas/ravb_main.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> index 471a68b0146e..b103632de4d4 100644
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
> @@ -555,8 +555,10 @@ static void ravb_emac_init_gbeth(struct net_device *ndev)
>  
>  static void ravb_emac_init_rcar(struct net_device *ndev)
>  {
> +	struct ravb_private *priv = netdev_priv(ndev);
> +
>  	/* Receive frame limit set register */

I wonder if we also should expand this comment to explain the addition 
of ETH_FCS_LEN, I have to look this up every time :-) How would you feel 
about adding something like?

    /* Set receive frame length
     *
     * The length set here described the frame from the destination 
     * address up to and including the CRC data. However only the frame 
     * data, exuding the CRC, are transferred to memory. To allow for 
     * the largest frames add the CRC length to the maximum Rx 
     * descriptor size.
     */

> -	ravb_write(ndev, ndev->mtu + ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN, RFLR);
> +	ravb_write(ndev, priv->info->rx_max_frame_size + ETH_FCS_LEN, RFLR);
>  
>  	/* EMAC Mode: PAUSE prohibition; Duplex; RX Checksum; TX; RX */
>  	ravb_write(ndev, ECMR_ZPF | ECMR_DM |
> -- 
> 2.43.0
> 

-- 
Kind Regards,
Niklas Söderlund

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-08-28 15:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-28 10:22 [net PATCH v2 0/2] Fix maximum TX/RX frame sizes in ravb driver Paul Barker
2024-08-28 10:22 ` [net PATCH v2 1/2] net: ravb: Fix maximum TX frame size for GbEth devices Paul Barker
2024-08-28 10:22 ` [net PATCH v2 2/2] net: ravb: Fix R-Car RX frame size limit Paul Barker
2024-08-28 15:03   ` Niklas Söderlund

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox