mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net v2 0/1] net: ethernet: ti: am65-cpsw: Allow for MTU values
@ 2024-01-05  8:55 Sanjuán García, Jorge
  2024-01-05  8:55 ` [PATCH net v2 1/1] net: ethernet: ti: am65-cpsw: Fix max mtu to fit ethernet frames Sanjuán García, Jorge
  2024-01-12  1:00 ` [PATCH net v2 0/1] net: ethernet: ti: am65-cpsw: Allow for MTU values patchwork-bot+netdevbpf
  0 siblings, 2 replies; 5+ messages in thread
From: Sanjuán García, Jorge @ 2024-01-05  8:55 UTC (permalink / raw)
  To: andrew, davem, edumazet, kuba, pabeni, s-vadapalli
  Cc: grygorii.strashko, netdev, linux-kernel, Sanjuán García, Jorge

The am65-cpsw-nuss driver has a fixed definition for the maximum ethernet
frame length of 1522 bytes (AM65_CPSW_MAX_PACKET_SIZE). This limits the switch
ports to only operate at a maximum MTU of 1500 bytes. When combining this CPSW
switch with a DSA switch connected to one of its ports this limitation shows up.
The extra 8 bytes the DSA subsystem adds internally to the ethernet frame
create resulting frames bigger than 1522 bytes (1518 for non VLAN + 8 for DSA
stuff) so they get dropped by the switch.

One of the issues with the the am65-cpsw-nuss driver is that the network device
max_mtu was being set to the same fixed value defined for the max total frame
length (1522 bytes). This makes the DSA subsystem believe that the MTU of the
interface can be set to 1508 bytes to make room for the extra 8 bytes of the DSA
headers. However, all packages created assuming the 1500 bytes payload get
dropped by the switch as oversized.

This series offers a solution to this problem. The max_mtu advertised on the
network device and the actual max frame size configured on the switch registers
are made consistent by letting the extra room needed for the ethernet headers
and the frame checksum (22 bytes including VLAN).

Changes in v2:
 - Just set the max_mtu to a fixed value and calculate the overheads.
 - Define the max packet size as part of the only commit of this series.

Jorge Sanjuan Garcia (1):
  net: ethernet: ti: am65-cpsw: Fix max mtu to fit ethernet frames

 drivers/net/ethernet/ti/am65-cpsw-nuss.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

-- 
2.34.1

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

* [PATCH net v2 1/1] net: ethernet: ti: am65-cpsw: Fix max mtu to fit ethernet frames
  2024-01-05  8:55 [PATCH net v2 0/1] net: ethernet: ti: am65-cpsw: Allow for MTU values Sanjuán García, Jorge
@ 2024-01-05  8:55 ` Sanjuán García, Jorge
  2024-01-11  9:18   ` Horatiu Vultur
  2024-01-11  9:46   ` Siddharth Vadapalli
  2024-01-12  1:00 ` [PATCH net v2 0/1] net: ethernet: ti: am65-cpsw: Allow for MTU values patchwork-bot+netdevbpf
  1 sibling, 2 replies; 5+ messages in thread
From: Sanjuán García, Jorge @ 2024-01-05  8:55 UTC (permalink / raw)
  To: andrew, davem, edumazet, kuba, pabeni, s-vadapalli
  Cc: grygorii.strashko, netdev, linux-kernel, Sanjuán García, Jorge

The value of AM65_CPSW_MAX_PACKET_SIZE represents the maximum length
of a received frame. This value is written to the register
AM65_CPSW_PORT_REG_RX_MAXLEN.

The maximum MTU configured on the network device should then leave
some room for the ethernet headers and frame check. Otherwise, if
the network interface is configured to its maximum mtu possible,
the frames will be larger than AM65_CPSW_MAX_PACKET_SIZE and will
get dropped as oversized.

The switch supports ethernet frame sizes between 64 and 2024 bytes
(including VLAN) as stated in the technical reference manual, so
define AM65_CPSW_MAX_PACKET_SIZE with that maximum size.

Fixes: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver")
Signed-off-by: Jorge Sanjuan Garcia <jorge.sanjuangarcia@duagon.com>
---
 drivers/net/ethernet/ti/am65-cpsw-nuss.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index 7651f90f51f2..3c7854537cb5 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -56,7 +56,7 @@
 #define AM65_CPSW_MAX_PORTS	8
 
 #define AM65_CPSW_MIN_PACKET_SIZE	VLAN_ETH_ZLEN
-#define AM65_CPSW_MAX_PACKET_SIZE	(VLAN_ETH_FRAME_LEN + ETH_FCS_LEN)
+#define AM65_CPSW_MAX_PACKET_SIZE	2024
 
 #define AM65_CPSW_REG_CTL		0x004
 #define AM65_CPSW_REG_STAT_PORT_EN	0x014
@@ -2196,7 +2196,8 @@ am65_cpsw_nuss_init_port_ndev(struct am65_cpsw_common *common, u32 port_idx)
 	eth_hw_addr_set(port->ndev, port->slave.mac_addr);
 
 	port->ndev->min_mtu = AM65_CPSW_MIN_PACKET_SIZE;
-	port->ndev->max_mtu = AM65_CPSW_MAX_PACKET_SIZE;
+	port->ndev->max_mtu = AM65_CPSW_MAX_PACKET_SIZE -
+			      (VLAN_ETH_HLEN + ETH_FCS_LEN);
 	port->ndev->hw_features = NETIF_F_SG |
 				  NETIF_F_RXCSUM |
 				  NETIF_F_HW_CSUM |
-- 
2.34.1

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

* Re: [PATCH net v2 1/1] net: ethernet: ti: am65-cpsw: Fix max mtu to fit ethernet frames
  2024-01-05  8:55 ` [PATCH net v2 1/1] net: ethernet: ti: am65-cpsw: Fix max mtu to fit ethernet frames Sanjuán García, Jorge
@ 2024-01-11  9:18   ` Horatiu Vultur
  2024-01-11  9:46   ` Siddharth Vadapalli
  1 sibling, 0 replies; 5+ messages in thread
From: Horatiu Vultur @ 2024-01-11  9:18 UTC (permalink / raw)
  To: Sanjuán García, Jorge
  Cc: andrew, davem, edumazet, kuba, pabeni, s-vadapalli,
	grygorii.strashko, netdev, linux-kernel

The 01/05/2024 08:55, Sanjuán García, Jorge wrote:
 
> The value of AM65_CPSW_MAX_PACKET_SIZE represents the maximum length
> of a received frame. This value is written to the register
> AM65_CPSW_PORT_REG_RX_MAXLEN.
> 
> The maximum MTU configured on the network device should then leave
> some room for the ethernet headers and frame check. Otherwise, if
> the network interface is configured to its maximum mtu possible,
> the frames will be larger than AM65_CPSW_MAX_PACKET_SIZE and will
> get dropped as oversized.
> 
> The switch supports ethernet frame sizes between 64 and 2024 bytes
> (including VLAN) as stated in the technical reference manual, so
> define AM65_CPSW_MAX_PACKET_SIZE with that maximum size.
> 
> Fixes: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver")
> Signed-off-by: Jorge Sanjuan Garcia <jorge.sanjuangarcia@duagon.com>

In case you send a single patch then, it is not required to create a
cover letter. Other then that it looks OK.

Reviewed-by: Horatiu Vultur <horatiu.vultur@microchip.com>

> ---
>  drivers/net/ethernet/ti/am65-cpsw-nuss.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> index 7651f90f51f2..3c7854537cb5 100644
> --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> @@ -56,7 +56,7 @@
>  #define AM65_CPSW_MAX_PORTS    8
> 
>  #define AM65_CPSW_MIN_PACKET_SIZE      VLAN_ETH_ZLEN
> -#define AM65_CPSW_MAX_PACKET_SIZE      (VLAN_ETH_FRAME_LEN + ETH_FCS_LEN)
> +#define AM65_CPSW_MAX_PACKET_SIZE      2024
> 
>  #define AM65_CPSW_REG_CTL              0x004
>  #define AM65_CPSW_REG_STAT_PORT_EN     0x014
> @@ -2196,7 +2196,8 @@ am65_cpsw_nuss_init_port_ndev(struct am65_cpsw_common *common, u32 port_idx)
>         eth_hw_addr_set(port->ndev, port->slave.mac_addr);
> 
>         port->ndev->min_mtu = AM65_CPSW_MIN_PACKET_SIZE;
> -       port->ndev->max_mtu = AM65_CPSW_MAX_PACKET_SIZE;
> +       port->ndev->max_mtu = AM65_CPSW_MAX_PACKET_SIZE -
> +                             (VLAN_ETH_HLEN + ETH_FCS_LEN);
>         port->ndev->hw_features = NETIF_F_SG |
>                                   NETIF_F_RXCSUM |
>                                   NETIF_F_HW_CSUM |
> --
> 2.34.1
> 

-- 
/Horatiu

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

* Re: [PATCH net v2 1/1] net: ethernet: ti: am65-cpsw: Fix max mtu to fit ethernet frames
  2024-01-05  8:55 ` [PATCH net v2 1/1] net: ethernet: ti: am65-cpsw: Fix max mtu to fit ethernet frames Sanjuán García, Jorge
  2024-01-11  9:18   ` Horatiu Vultur
@ 2024-01-11  9:46   ` Siddharth Vadapalli
  1 sibling, 0 replies; 5+ messages in thread
From: Siddharth Vadapalli @ 2024-01-11  9:46 UTC (permalink / raw)
  To: Sanjuán García, Jorge, andrew, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-kernel, s-vadapalli



On 05/01/24 14:25, Sanjuán García, Jorge wrote:
> The value of AM65_CPSW_MAX_PACKET_SIZE represents the maximum length
> of a received frame. This value is written to the register
> AM65_CPSW_PORT_REG_RX_MAXLEN.
> 
> The maximum MTU configured on the network device should then leave
> some room for the ethernet headers and frame check. Otherwise, if
> the network interface is configured to its maximum mtu possible,
> the frames will be larger than AM65_CPSW_MAX_PACKET_SIZE and will
> get dropped as oversized.
> 
> The switch supports ethernet frame sizes between 64 and 2024 bytes
> (including VLAN) as stated in the technical reference manual, so
> define AM65_CPSW_MAX_PACKET_SIZE with that maximum size.
> 
> Fixes: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth 
> subsystem driver")
> Signed-off-by: Jorge Sanjuan Garcia <jorge.sanjuangarcia@duagon.com>

Reviewed-by: Siddharth Vadapalli <s-vadapalli@ti.com>

> ---
>   drivers/net/ethernet/ti/am65-cpsw-nuss.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c 
> b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> index 7651f90f51f2..3c7854537cb5 100644
> --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> @@ -56,7 +56,7 @@
>   #define AM65_CPSW_MAX_PORTS     8
> 
>   #define AM65_CPSW_MIN_PACKET_SIZE       VLAN_ETH_ZLEN
> -#define AM65_CPSW_MAX_PACKET_SIZE      (VLAN_ETH_FRAME_LEN + ETH_FCS_LEN)
> +#define AM65_CPSW_MAX_PACKET_SIZE      2024
> 
>   #define AM65_CPSW_REG_CTL               0x004
>   #define AM65_CPSW_REG_STAT_PORT_EN      0x014
> @@ -2196,7 +2196,8 @@ am65_cpsw_nuss_init_port_ndev(struct am65_cpsw_common 
> *common, u32 port_idx)
>           eth_hw_addr_set(port->ndev, port->slave.mac_addr);
> 
>           port->ndev->min_mtu = AM65_CPSW_MIN_PACKET_SIZE;
> -       port->ndev->max_mtu = AM65_CPSW_MAX_PACKET_SIZE;
> +       port->ndev->max_mtu = AM65_CPSW_MAX_PACKET_SIZE -
> +                             (VLAN_ETH_HLEN + ETH_FCS_LEN);
>           port->ndev->hw_features = NETIF_F_SG |
>                                     NETIF_F_RXCSUM |
>                                     NETIF_F_HW_CSUM |

...

-- 
Regards,
Siddharth.

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

* Re: [PATCH net v2 0/1] net: ethernet: ti: am65-cpsw: Allow for MTU values
  2024-01-05  8:55 [PATCH net v2 0/1] net: ethernet: ti: am65-cpsw: Allow for MTU values Sanjuán García, Jorge
  2024-01-05  8:55 ` [PATCH net v2 1/1] net: ethernet: ti: am65-cpsw: Fix max mtu to fit ethernet frames Sanjuán García, Jorge
@ 2024-01-12  1:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-01-12  1:00 UTC (permalink / raw)
  To: =?utf-8?q?Sanju=C3=A1n_Garc=C3=ADa=2C_Jorge_=3CJorge=2ESanjuanGarcia=40duago?=,
	=?utf-8?q?n=2Ecom=3E?=
  Cc: andrew, davem, edumazet, kuba, pabeni, s-vadapalli,
	grygorii.strashko, netdev, linux-kernel

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 5 Jan 2024 08:55:39 +0000 you wrote:
> The am65-cpsw-nuss driver has a fixed definition for the maximum ethernet
> frame length of 1522 bytes (AM65_CPSW_MAX_PACKET_SIZE). This limits the switch
> ports to only operate at a maximum MTU of 1500 bytes. When combining this CPSW
> switch with a DSA switch connected to one of its ports this limitation shows up.
> The extra 8 bytes the DSA subsystem adds internally to the ethernet frame
> create resulting frames bigger than 1522 bytes (1518 for non VLAN + 8 for DSA
> stuff) so they get dropped by the switch.
> 
> [...]

Here is the summary with links:
  - [net,v2,1/1] net: ethernet: ti: am65-cpsw: Fix max mtu to fit ethernet frames
    https://git.kernel.org/netdev/net/c/64e47d8afb5c

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2024-01-12  1:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-05  8:55 [PATCH net v2 0/1] net: ethernet: ti: am65-cpsw: Allow for MTU values Sanjuán García, Jorge
2024-01-05  8:55 ` [PATCH net v2 1/1] net: ethernet: ti: am65-cpsw: Fix max mtu to fit ethernet frames Sanjuán García, Jorge
2024-01-11  9:18   ` Horatiu Vultur
2024-01-11  9:46   ` Siddharth Vadapalli
2024-01-12  1:00 ` [PATCH net v2 0/1] net: ethernet: ti: am65-cpsw: Allow for MTU values patchwork-bot+netdevbpf

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

all inboxes | Powered by JetHome®