Skip to content

Commit 532b49e

Browse files
pmachatadavem330
authored andcommitted
mlxsw: spectrum_span: Derive SBIB from maximum port speed & MTU
The SBIB register configures the size of an internal buffer that the Spectrum ASICs use when mirroring traffic on egress. This size should be taken into account when validating that the port headroom buffers are not larger than the chip can handle. Up until now this was not done, which is incidentally not a problem, because the priority group buffers that mlxsw auto-configures are small enough that the boundary condition could not be violated. However when dcbnl_setbuffer is implemented, the user has control over sizes of PG buffers, and they might overshoot the headroom capacity. However the size of the SBIB buffer depends on port speed, and that cannot be vetoed. Therefore SBIB size should be deduced from maximum port speed. Additionally, once the buffers are configured by hand, the user could get into an uncomfortable situation where their MTU change requests get vetoed, because the SBIB does not fit anymore. Therefore derive SBIB size from maximum permissible MTU as well. Remove all the code that adjusted the SBIB size whenever speed or MTU changed. Signed-off-by: Petr Machata <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3232e8c commit 532b49e

File tree

3 files changed

+4
-67
lines changed

3 files changed

+4
-67
lines changed

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,18 +1003,13 @@ static int mlxsw_sp_port_change_mtu(struct net_device *dev, int mtu)
10031003
err = mlxsw_sp_port_headroom_set(mlxsw_sp_port, mtu, pause_en);
10041004
if (err)
10051005
return err;
1006-
err = mlxsw_sp_span_port_mtu_update(mlxsw_sp_port, mtu);
1007-
if (err)
1008-
goto err_span_port_mtu_update;
10091006
err = mlxsw_sp_port_mtu_set(mlxsw_sp_port, mtu);
10101007
if (err)
10111008
goto err_port_mtu_set;
10121009
dev->mtu = mtu;
10131010
return 0;
10141011

10151012
err_port_mtu_set:
1016-
mlxsw_sp_span_port_mtu_update(mlxsw_sp_port, dev->mtu);
1017-
err_span_port_mtu_update:
10181013
mlxsw_sp_port_headroom_set(mlxsw_sp_port, dev->mtu, pause_en);
10191014
return err;
10201015
}
@@ -1952,8 +1947,6 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port,
19521947

19531948
INIT_DELAYED_WORK(&mlxsw_sp_port->ptp.shaper_dw,
19541949
mlxsw_sp->ptp_ops->shaper_work);
1955-
INIT_DELAYED_WORK(&mlxsw_sp_port->span.speed_update_dw,
1956-
mlxsw_sp_span_speed_update_work);
19571950

19581951
mlxsw_sp->ports[local_port] = mlxsw_sp_port;
19591952
err = register_netdev(dev);
@@ -2010,7 +2003,6 @@ static void mlxsw_sp_port_remove(struct mlxsw_sp *mlxsw_sp, u8 local_port)
20102003
struct mlxsw_sp_port *mlxsw_sp_port = mlxsw_sp->ports[local_port];
20112004

20122005
cancel_delayed_work_sync(&mlxsw_sp_port->periodic_hw_stats.update_dw);
2013-
cancel_delayed_work_sync(&mlxsw_sp_port->span.speed_update_dw);
20142006
cancel_delayed_work_sync(&mlxsw_sp_port->ptp.shaper_dw);
20152007
mlxsw_sp_port_ptp_clear(mlxsw_sp_port);
20162008
mlxsw_core_port_clear(mlxsw_sp->core, local_port, mlxsw_sp);
@@ -2414,7 +2406,6 @@ static void mlxsw_sp_pude_event_func(const struct mlxsw_reg_info *reg,
24142406
netdev_info(mlxsw_sp_port->dev, "link up\n");
24152407
netif_carrier_on(mlxsw_sp_port->dev);
24162408
mlxsw_core_schedule_dw(&mlxsw_sp_port->ptp.shaper_dw, 0);
2417-
mlxsw_core_schedule_dw(&mlxsw_sp_port->span.speed_update_dw, 0);
24182409
} else {
24192410
netdev_info(mlxsw_sp_port->dev, "link down\n");
24202411
netif_carrier_off(mlxsw_sp_port->dev);

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,6 @@ struct mlxsw_sp_port {
316316
struct mlxsw_sp_ptp_port_stats stats;
317317
} ptp;
318318
u8 split_base_local_port;
319-
struct {
320-
struct delayed_work speed_update_dw;
321-
} span;
322319
int max_mtu;
323320
u32 max_speed;
324321
};

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

Lines changed: 4 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -977,21 +977,14 @@ static u32 mlxsw_sp_span_buffsize_get(struct mlxsw_sp *mlxsw_sp, int mtu,
977977
}
978978

979979
static int
980-
mlxsw_sp_span_port_buffer_update(struct mlxsw_sp_port *mlxsw_sp_port, u16 mtu)
980+
mlxsw_sp_span_port_buffer_enable(struct mlxsw_sp_port *mlxsw_sp_port)
981981
{
982982
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
983983
char sbib_pl[MLXSW_REG_SBIB_LEN];
984984
u32 buffsize;
985-
u32 speed;
986-
int err;
987-
988-
err = mlxsw_sp_port_speed_get(mlxsw_sp_port, &speed);
989-
if (err)
990-
return err;
991-
if (speed == SPEED_UNKNOWN)
992-
speed = 0;
993985

994-
buffsize = mlxsw_sp_span_buffsize_get(mlxsw_sp, speed, mtu);
986+
buffsize = mlxsw_sp_span_buffsize_get(mlxsw_sp, mlxsw_sp_port->max_speed,
987+
mlxsw_sp_port->max_mtu);
995988
buffsize = mlxsw_sp_port_headroom_8x_adjust(mlxsw_sp_port, buffsize);
996989
mlxsw_reg_sbib_pack(sbib_pl, mlxsw_sp_port->local_port, buffsize);
997990
return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sbib), sbib_pl);
@@ -1021,48 +1014,6 @@ mlxsw_sp_span_analyzed_port_find(struct mlxsw_sp_span *span, u8 local_port,
10211014
return NULL;
10221015
}
10231016

1024-
int mlxsw_sp_span_port_mtu_update(struct mlxsw_sp_port *port, u16 mtu)
1025-
{
1026-
struct mlxsw_sp *mlxsw_sp = port->mlxsw_sp;
1027-
int err = 0;
1028-
1029-
/* If port is egress mirrored, the shared buffer size should be
1030-
* updated according to the mtu value
1031-
*/
1032-
mutex_lock(&mlxsw_sp->span->analyzed_ports_lock);
1033-
1034-
if (mlxsw_sp_span_analyzed_port_find(mlxsw_sp->span, port->local_port,
1035-
false))
1036-
err = mlxsw_sp_span_port_buffer_update(port, mtu);
1037-
1038-
mutex_unlock(&mlxsw_sp->span->analyzed_ports_lock);
1039-
1040-
return err;
1041-
}
1042-
1043-
void mlxsw_sp_span_speed_update_work(struct work_struct *work)
1044-
{
1045-
struct delayed_work *dwork = to_delayed_work(work);
1046-
struct mlxsw_sp_port *mlxsw_sp_port;
1047-
struct mlxsw_sp *mlxsw_sp;
1048-
1049-
mlxsw_sp_port = container_of(dwork, struct mlxsw_sp_port,
1050-
span.speed_update_dw);
1051-
1052-
/* If port is egress mirrored, the shared buffer size should be
1053-
* updated according to the speed value.
1054-
*/
1055-
mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
1056-
mutex_lock(&mlxsw_sp->span->analyzed_ports_lock);
1057-
1058-
if (mlxsw_sp_span_analyzed_port_find(mlxsw_sp->span,
1059-
mlxsw_sp_port->local_port, false))
1060-
mlxsw_sp_span_port_buffer_update(mlxsw_sp_port,
1061-
mlxsw_sp_port->dev->mtu);
1062-
1063-
mutex_unlock(&mlxsw_sp->span->analyzed_ports_lock);
1064-
}
1065-
10661017
static const struct mlxsw_sp_span_entry_ops *
10671018
mlxsw_sp_span_entry_ops(struct mlxsw_sp *mlxsw_sp,
10681019
const struct net_device *to_dev)
@@ -1180,9 +1131,7 @@ mlxsw_sp_span_analyzed_port_create(struct mlxsw_sp_span *span,
11801131
* does the mirroring.
11811132
*/
11821133
if (!ingress) {
1183-
u16 mtu = mlxsw_sp_port->dev->mtu;
1184-
1185-
err = mlxsw_sp_span_port_buffer_update(mlxsw_sp_port, mtu);
1134+
err = mlxsw_sp_span_port_buffer_enable(mlxsw_sp_port);
11861135
if (err)
11871136
goto err_buffer_update;
11881137
}

0 commit comments

Comments
 (0)