aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIdo Schimmel <idosch@mellanox.com>2016-04-06 11:10:03 -0400
committerDavid S. Miller <davem@davemloft.net>2016-04-06 17:24:17 -0400
commitff6551ec0c2748a31087878f00bcaf6db2f82116 (patch)
tree0b9fb60d24d0f7feb106b8e720ee7b16ee1b726a
parent1a1984490f5c123ee62394bc435a2c09db15cc18 (diff)
mlxsw: spectrum: Correctly configure headroom size
When packets ingress the switch they are assigned a switch priority and directed to the corresponding priority group (PG) buffer in the port's headroom buffer. Since we now map all switch priorities to priority group 0 (PG0) by default, there is no need to allocate the other priority groups during initialization. The only exception is PG9, which is used for control traffic. At minimum, the PG should be able to store the currently classified packet (pipeline latency isn't 0) and also the packets arriving during the classification time. However, an incoming packet will not be buffered if there is no available MTU-sized buffer space for storing it. The buffer needed to accommodate for pipeline latency is variable and needs to take into account both the current link speed and current latency of the pipeline, which is time-dependent. Testing showed that setting the PG's size to twice the current MTU is optimal. Since PG9 is used strictly for control packets and not subject to flow control, we are not going to resize it according to user configuration, so we simply set it according to worst case scenario, which is twice the maximum MTU. In any case, later patches in the series will allow a user to direct lossless flows to other PGs than PG0 and set their size to accommodate for round-trip propagation delay. The above change also requires us to resize the PG buffer whenever the port's MTU is changed. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/spectrum.c25
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c19
2 files changed, 34 insertions, 10 deletions
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index cb5f36e497e9..4576d59a98a2 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -449,16 +449,39 @@ static int mlxsw_sp_port_set_mac_address(struct net_device *dev, void *p)
449 return 0; 449 return 0;
450} 450}
451 451
452static int mlxsw_sp_port_headroom_set(struct mlxsw_sp_port *mlxsw_sp_port,
453 int mtu)
454{
455 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
456 u16 pg_size = 2 * MLXSW_SP_BYTES_TO_CELLS(mtu);
457 char pbmc_pl[MLXSW_REG_PBMC_LEN];
458 int err;
459
460 mlxsw_reg_pbmc_pack(pbmc_pl, mlxsw_sp_port->local_port, 0, 0);
461 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(pbmc), pbmc_pl);
462 if (err)
463 return err;
464 mlxsw_reg_pbmc_lossy_buffer_pack(pbmc_pl, 0, pg_size);
465 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pbmc), pbmc_pl);
466}
467
452static int mlxsw_sp_port_change_mtu(struct net_device *dev, int mtu) 468static int mlxsw_sp_port_change_mtu(struct net_device *dev, int mtu)
453{ 469{
454 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); 470 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev);
455 int err; 471 int err;
456 472
457 err = mlxsw_sp_port_mtu_set(mlxsw_sp_port, mtu); 473 err = mlxsw_sp_port_headroom_set(mlxsw_sp_port, mtu);
458 if (err) 474 if (err)
459 return err; 475 return err;
476 err = mlxsw_sp_port_mtu_set(mlxsw_sp_port, mtu);
477 if (err)
478 goto err_port_mtu_set;
460 dev->mtu = mtu; 479 dev->mtu = mtu;
461 return 0; 480 return 0;
481
482err_port_mtu_set:
483 mlxsw_sp_port_headroom_set(mlxsw_sp_port, dev->mtu);
484 return err;
462} 485}
463 486
464static struct rtnl_link_stats64 * 487static struct rtnl_link_stats64 *
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
index dadb6e1ccf82..e7a5b73188f1 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
@@ -35,6 +35,7 @@
35#include <linux/kernel.h> 35#include <linux/kernel.h>
36#include <linux/types.h> 36#include <linux/types.h>
37#include <linux/dcbnl.h> 37#include <linux/dcbnl.h>
38#include <linux/if_ether.h>
38 39
39#include "spectrum.h" 40#include "spectrum.h"
40#include "core.h" 41#include "core.h"
@@ -53,15 +54,15 @@ struct mlxsw_sp_pb {
53 } 54 }
54 55
55static const struct mlxsw_sp_pb mlxsw_sp_pbs[] = { 56static const struct mlxsw_sp_pb mlxsw_sp_pbs[] = {
56 MLXSW_SP_PB(0, 208), 57 MLXSW_SP_PB(0, 2 * MLXSW_SP_BYTES_TO_CELLS(ETH_FRAME_LEN)),
57 MLXSW_SP_PB(1, 208), 58 MLXSW_SP_PB(1, 0),
58 MLXSW_SP_PB(2, 208), 59 MLXSW_SP_PB(2, 0),
59 MLXSW_SP_PB(3, 208), 60 MLXSW_SP_PB(3, 0),
60 MLXSW_SP_PB(4, 208), 61 MLXSW_SP_PB(4, 0),
61 MLXSW_SP_PB(5, 208), 62 MLXSW_SP_PB(5, 0),
62 MLXSW_SP_PB(6, 208), 63 MLXSW_SP_PB(6, 0),
63 MLXSW_SP_PB(7, 208), 64 MLXSW_SP_PB(7, 0),
64 MLXSW_SP_PB(9, 208), 65 MLXSW_SP_PB(9, 2 * MLXSW_SP_BYTES_TO_CELLS(MLXSW_PORT_MAX_MTU)),
65}; 66};
66 67
67#define MLXSW_SP_PBS_LEN ARRAY_SIZE(mlxsw_sp_pbs) 68#define MLXSW_SP_PBS_LEN ARRAY_SIZE(mlxsw_sp_pbs)