]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mlxsw: Adjust MTU value to hardware check
authorAmit Cohen <amcohen@nvidia.com>
Thu, 13 Jun 2024 14:07:55 +0000 (16:07 +0200)
committerJakub Kicinski <kuba@kernel.org>
Sat, 15 Jun 2024 02:30:34 +0000 (19:30 -0700)
Ethernet frame consists of - Ethernet header, payload, FCS. The MTU value
which is used by user is the size of the payload, which means that when
user sets MTU to X, the total frame size will be larger due to the addition
of the Ethernet header and FCS.

Spectrum ASICs take into account Ethernet header and FCS as part of packet
size for MTU check. Adjust MTU value when user sets MTU, to configure the
MTU size which is required by hardware. The Tx header length which was used
by the driver is not relevant for such calculation, take into account
Ethernet header (with VLAN extension) and FCS.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Link: https://lore.kernel.org/r/f3203c2477bb8ed18b1e79642fa3e3713e1e55bb.1718275854.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlxsw/port.h
drivers/net/ethernet/mellanox/mlxsw/spectrum.c

index aa309615eff3f6e6b0db9f6cd1476fdb0e4f9e3f..0a73b1a4526e053dc5bf079986857300b7cc6ea4 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/types.h>
 
 #define MLXSW_PORT_MAX_MTU             (10 * 1024)
+#define MLXSW_PORT_ETH_FRAME_HDR       (ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN)
 
 #define MLXSW_PORT_DEFAULT_VID         1
 
index 030ed71f945d6cc0e183c0ad0248127c131978de..879daa18cccabcdebb254bfc56253e3ab23c4d4b 100644 (file)
@@ -425,7 +425,7 @@ static int mlxsw_sp_port_mtu_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 mtu)
        struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
        char pmtu_pl[MLXSW_REG_PMTU_LEN];
 
-       mtu += MLXSW_TXHDR_LEN + ETH_HLEN;
+       mtu += MLXSW_PORT_ETH_FRAME_HDR;
        if (mtu > mlxsw_sp_port->max_mtu)
                return -EINVAL;