]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.20/mlxsw-__mlxsw_sp_port_headroom_set-fix-a-use-of-loca.patch
patches for 4.20
[thirdparty/kernel/stable-queue.git] / queue-4.20 / mlxsw-__mlxsw_sp_port_headroom_set-fix-a-use-of-loca.patch
1 From 2aad67f8d919f7e8f4284a78ad12741ac3377fd5 Mon Sep 17 00:00:00 2001
2 From: Petr Machata <petrm@mellanox.com>
3 Date: Sun, 17 Feb 2019 07:18:41 +0000
4 Subject: mlxsw: __mlxsw_sp_port_headroom_set(): Fix a use of local variable
5
6 [ Upstream commit 289460404f6947ef1c38e67d680be9a84161250b ]
7
8 The function-local variable "delay" enters the loop interpreted as delay
9 in bits. However, inside the loop it gets overwritten by the result of
10 mlxsw_sp_pg_buf_delay_get(), and thus leaves the loop as quantity in
11 cells. Thus on second and further loop iterations, the headroom for a
12 given priority is configured with a wrong size.
13
14 Fix by introducing a loop-local variable, delay_cells. Rename thres to
15 thres_cells for consistency.
16
17 Fixes: f417f04da589 ("mlxsw: spectrum: Refactor port buffer configuration")
18 Signed-off-by: Petr Machata <petrm@mellanox.com>
19 Acked-by: Jiri Pirko <jiri@mellanox.com>
20 Signed-off-by: Ido Schimmel <idosch@mellanox.com>
21 Signed-off-by: David S. Miller <davem@davemloft.net>
22 Signed-off-by: Sasha Levin <sashal@kernel.org>
23 ---
24 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 12 +++++++-----
25 1 file changed, 7 insertions(+), 5 deletions(-)
26
27 diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
28 index 8f1180fff9551..280173b489624 100644
29 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
30 +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
31 @@ -845,8 +845,9 @@ int __mlxsw_sp_port_headroom_set(struct mlxsw_sp_port *mlxsw_sp_port, int mtu,
32 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
33 bool configure = false;
34 bool pfc = false;
35 + u16 thres_cells;
36 + u16 delay_cells;
37 bool lossy;
38 - u16 thres;
39
40 for (j = 0; j < IEEE_8021QAZ_MAX_TCS; j++) {
41 if (prio_tc[j] == i) {
42 @@ -860,10 +861,11 @@ int __mlxsw_sp_port_headroom_set(struct mlxsw_sp_port *mlxsw_sp_port, int mtu,
43 continue;
44
45 lossy = !(pfc || pause_en);
46 - thres = mlxsw_sp_pg_buf_threshold_get(mlxsw_sp, mtu);
47 - delay = mlxsw_sp_pg_buf_delay_get(mlxsw_sp, mtu, delay, pfc,
48 - pause_en);
49 - mlxsw_sp_pg_buf_pack(pbmc_pl, i, thres + delay, thres, lossy);
50 + thres_cells = mlxsw_sp_pg_buf_threshold_get(mlxsw_sp, mtu);
51 + delay_cells = mlxsw_sp_pg_buf_delay_get(mlxsw_sp, mtu, delay,
52 + pfc, pause_en);
53 + mlxsw_sp_pg_buf_pack(pbmc_pl, i, thres_cells + delay_cells,
54 + thres_cells, lossy);
55 }
56
57 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pbmc), pbmc_pl);
58 --
59 2.19.1
60