Commit 2ecf87ae authored by Petr Machata's avatar Petr Machata Committed by David S. Miller

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: default avatarPetr Machata <petrm@nvidia.com>
Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 60fbc521
...@@ -590,21 +590,28 @@ static int mlxsw_sp_port_dev_addr_init(struct mlxsw_sp_port *mlxsw_sp_port) ...@@ -590,21 +590,28 @@ static int mlxsw_sp_port_dev_addr_init(struct mlxsw_sp_port *mlxsw_sp_port)
return mlxsw_sp_port_dev_addr_set(mlxsw_sp_port, addr); return mlxsw_sp_port_dev_addr_set(mlxsw_sp_port, addr);
} }
static int mlxsw_sp_port_mtu_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 mtu) static int mlxsw_sp_port_max_mtu_get(struct mlxsw_sp_port *mlxsw_sp_port, int *p_max_mtu)
{ {
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
char pmtu_pl[MLXSW_REG_PMTU_LEN]; char pmtu_pl[MLXSW_REG_PMTU_LEN];
int max_mtu;
int err; int err;
mtu += MLXSW_TXHDR_LEN + ETH_HLEN;
mlxsw_reg_pmtu_pack(pmtu_pl, mlxsw_sp_port->local_port, 0); mlxsw_reg_pmtu_pack(pmtu_pl, mlxsw_sp_port->local_port, 0);
err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(pmtu), pmtu_pl); err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(pmtu), pmtu_pl);
if (err) if (err)
return err; return err;
max_mtu = mlxsw_reg_pmtu_max_mtu_get(pmtu_pl);
if (mtu > max_mtu) *p_max_mtu = mlxsw_reg_pmtu_max_mtu_get(pmtu_pl);
return 0;
}
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;
if (mtu > mlxsw_sp_port->max_mtu)
return -EINVAL; return -EINVAL;
mlxsw_reg_pmtu_pack(pmtu_pl, mlxsw_sp_port->local_port, mtu); 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, ...@@ -1842,6 +1849,13 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port,
goto err_port_speed_by_width_set; goto err_port_speed_by_width_set;
} }
err = mlxsw_sp_port_max_mtu_get(mlxsw_sp_port, &mlxsw_sp_port->max_mtu);
if (err) {
dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to get maximum MTU\n",
mlxsw_sp_port->local_port);
goto err_port_max_mtu_get;
}
err = mlxsw_sp_port_mtu_set(mlxsw_sp_port, ETH_DATA_LEN); err = mlxsw_sp_port_mtu_set(mlxsw_sp_port, ETH_DATA_LEN);
if (err) { if (err) {
dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to set MTU\n", 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, ...@@ -1966,6 +1980,7 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port,
err_port_buffers_init: err_port_buffers_init:
err_port_admin_status_set: err_port_admin_status_set:
err_port_mtu_set: err_port_mtu_set:
err_port_max_mtu_get:
err_port_speed_by_width_set: err_port_speed_by_width_set:
err_port_system_port_mapping_set: err_port_system_port_mapping_set:
err_dev_addr_init: err_dev_addr_init:
......
...@@ -319,6 +319,7 @@ struct mlxsw_sp_port { ...@@ -319,6 +319,7 @@ struct mlxsw_sp_port {
struct { struct {
struct delayed_work speed_update_dw; struct delayed_work speed_update_dw;
} span; } span;
int max_mtu;
}; };
struct mlxsw_sp_port_type_speed_ops { struct mlxsw_sp_port_type_speed_ops {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment