Skip to content

Commit 2ecf87a

Browse files
pmachatadavem330
authored andcommitted
mlxsw: spectrum: Keep maximum MTU around
The maximum port MTU depends on port type. On Spectrum, mlxsw configures all ports as Ethernet ports, and the maximum MTU therefore never changes. Besides checking MTU configuration, maximum MTU will also be handy when setting SBIB, the internal buffer used for traffic mirroring. Therefore, keep it in struct mlxsw_sp_port for easy access. Signed-off-by: Petr Machata <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 60fbc52 commit 2ecf87a

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -590,21 +590,28 @@ static int mlxsw_sp_port_dev_addr_init(struct mlxsw_sp_port *mlxsw_sp_port)
590590
return mlxsw_sp_port_dev_addr_set(mlxsw_sp_port, addr);
591591
}
592592

593-
static int mlxsw_sp_port_mtu_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 mtu)
593+
static int mlxsw_sp_port_max_mtu_get(struct mlxsw_sp_port *mlxsw_sp_port, int *p_max_mtu)
594594
{
595595
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
596596
char pmtu_pl[MLXSW_REG_PMTU_LEN];
597-
int max_mtu;
598597
int err;
599598

600-
mtu += MLXSW_TXHDR_LEN + ETH_HLEN;
601599
mlxsw_reg_pmtu_pack(pmtu_pl, mlxsw_sp_port->local_port, 0);
602600
err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(pmtu), pmtu_pl);
603601
if (err)
604602
return err;
605-
max_mtu = mlxsw_reg_pmtu_max_mtu_get(pmtu_pl);
606603

607-
if (mtu > max_mtu)
604+
*p_max_mtu = mlxsw_reg_pmtu_max_mtu_get(pmtu_pl);
605+
return 0;
606+
}
607+
608+
static int mlxsw_sp_port_mtu_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 mtu)
609+
{
610+
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
611+
char pmtu_pl[MLXSW_REG_PMTU_LEN];
612+
613+
mtu += MLXSW_TXHDR_LEN + ETH_HLEN;
614+
if (mtu > mlxsw_sp_port->max_mtu)
608615
return -EINVAL;
609616

610617
mlxsw_reg_pmtu_pack(pmtu_pl, mlxsw_sp_port->local_port, mtu);
@@ -1842,6 +1849,13 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port,
18421849
goto err_port_speed_by_width_set;
18431850
}
18441851

1852+
err = mlxsw_sp_port_max_mtu_get(mlxsw_sp_port, &mlxsw_sp_port->max_mtu);
1853+
if (err) {
1854+
dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to get maximum MTU\n",
1855+
mlxsw_sp_port->local_port);
1856+
goto err_port_max_mtu_get;
1857+
}
1858+
18451859
err = mlxsw_sp_port_mtu_set(mlxsw_sp_port, ETH_DATA_LEN);
18461860
if (err) {
18471861
dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to set MTU\n",
@@ -1966,6 +1980,7 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port,
19661980
err_port_buffers_init:
19671981
err_port_admin_status_set:
19681982
err_port_mtu_set:
1983+
err_port_max_mtu_get:
19691984
err_port_speed_by_width_set:
19701985
err_port_system_port_mapping_set:
19711986
err_dev_addr_init:

drivers/net/ethernet/mellanox/mlxsw/spectrum.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ struct mlxsw_sp_port {
319319
struct {
320320
struct delayed_work speed_update_dw;
321321
} span;
322+
int max_mtu;
322323
};
323324

324325
struct mlxsw_sp_port_type_speed_ops {

0 commit comments

Comments
 (0)