mlxsw: spectrum_buffers: Update port headroom configuration
authorPetr Machata <petrm@mellanox.com>
Wed, 20 Feb 2019 19:32:27 +0000 (19:32 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 21 Feb 2019 23:57:46 +0000 (15:57 -0800)
The recommendation for headroom size for 100Gbps port and 100m cable is
101.6KB, reduced accordingly for split ports. The closest higher number
evenly divisible by cell size for both Spectrum-1 and Spectrum-2, and
such that the number of cells can be further divided by maximum split
factor of 4, is 102528 bytes, or 25632 bytes per lane.

Update mlxsw_sp_port_pb_init() to compute the headroom taking into
account this recommended per-lane value and number of lanes actually
dedicated to a given port.

Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c

index bb327dfe1336e8691e969496125d8a4123447441..65ef4a9f6afb25e73ded2a891e845bba7f73c4be 100644 (file)
@@ -260,24 +260,24 @@ static int mlxsw_sp_sb_pm_occ_query(struct mlxsw_sp *mlxsw_sp, u8 local_port,
                                     (unsigned long) pm);
 }
 
-static const u16 mlxsw_sp_pbs[] = {
-       [0] = 2 * ETH_FRAME_LEN,
-       [9] = 2 * MLXSW_PORT_MAX_MTU,
-};
-
-#define MLXSW_SP_PBS_LEN ARRAY_SIZE(mlxsw_sp_pbs)
+/* 1/4 of a headroom necessary for 100Gbps port and 100m cable. */
+#define MLXSW_SP_PB_HEADROOM 25632
 #define MLXSW_SP_PB_UNUSED 8
 
 static int mlxsw_sp_port_pb_init(struct mlxsw_sp_port *mlxsw_sp_port)
 {
+       const u32 pbs[] = {
+               [0] = MLXSW_SP_PB_HEADROOM * mlxsw_sp_port->mapping.width,
+               [9] = 2 * MLXSW_PORT_MAX_MTU,
+       };
        struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
        char pbmc_pl[MLXSW_REG_PBMC_LEN];
        int i;
 
        mlxsw_reg_pbmc_pack(pbmc_pl, mlxsw_sp_port->local_port,
                            0xffff, 0xffff / 2);
-       for (i = 0; i < MLXSW_SP_PBS_LEN; i++) {
-               u16 size = mlxsw_sp_bytes_cells(mlxsw_sp, mlxsw_sp_pbs[i]);
+       for (i = 0; i < ARRAY_SIZE(pbs); i++) {
+               u16 size = mlxsw_sp_bytes_cells(mlxsw_sp, pbs[i]);
 
                if (i == MLXSW_SP_PB_UNUSED)
                        continue;