1 From a9108b0712bf018dc69020864b21485b71b17dfc Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Sun, 30 Jul 2023 09:41:12 +0200
4 Subject: [PATCH 3/4] net: dsa: qca8k: move qca8xxx hol fixup to separate
7 Move qca8xxx hol fixup to separate function to tidy things up and to
8 permit using a more efficent loop in future patch.
10 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
11 Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
12 Link: https://lore.kernel.org/r/20230730074113.21889-4-ansuelsmth@gmail.com
13 Signed-off-by: Paolo Abeni <pabeni@redhat.com>
15 drivers/net/dsa/qca/qca8k-8xxx.c | 78 +++++++++++++++++---------------
16 1 file changed, 42 insertions(+), 36 deletions(-)
18 --- a/drivers/net/dsa/qca/qca8k-8xxx.c
19 +++ b/drivers/net/dsa/qca/qca8k-8xxx.c
20 @@ -1773,6 +1773,46 @@ static int qca8k_connect_tag_protocol(st
24 +static void qca8k_setup_hol_fixup(struct qca8k_priv *priv, int port)
29 + /* The 2 CPU port and port 5 requires some different
30 + * priority than any other ports.
35 + mask = QCA8K_PORT_HOL_CTRL0_EG_PRI0(0x3) |
36 + QCA8K_PORT_HOL_CTRL0_EG_PRI1(0x4) |
37 + QCA8K_PORT_HOL_CTRL0_EG_PRI2(0x4) |
38 + QCA8K_PORT_HOL_CTRL0_EG_PRI3(0x4) |
39 + QCA8K_PORT_HOL_CTRL0_EG_PRI4(0x6) |
40 + QCA8K_PORT_HOL_CTRL0_EG_PRI5(0x8) |
41 + QCA8K_PORT_HOL_CTRL0_EG_PORT(0x1e);
44 + mask = QCA8K_PORT_HOL_CTRL0_EG_PRI0(0x3) |
45 + QCA8K_PORT_HOL_CTRL0_EG_PRI1(0x4) |
46 + QCA8K_PORT_HOL_CTRL0_EG_PRI2(0x6) |
47 + QCA8K_PORT_HOL_CTRL0_EG_PRI3(0x8) |
48 + QCA8K_PORT_HOL_CTRL0_EG_PORT(0x19);
50 + regmap_write(priv->regmap, QCA8K_REG_PORT_HOL_CTRL0(port), mask);
52 + mask = QCA8K_PORT_HOL_CTRL1_ING(0x6) |
53 + QCA8K_PORT_HOL_CTRL1_EG_PRI_BUF_EN |
54 + QCA8K_PORT_HOL_CTRL1_EG_PORT_BUF_EN |
55 + QCA8K_PORT_HOL_CTRL1_WRED_EN;
56 + regmap_update_bits(priv->regmap, QCA8K_REG_PORT_HOL_CTRL1(port),
57 + QCA8K_PORT_HOL_CTRL1_ING_BUF_MASK |
58 + QCA8K_PORT_HOL_CTRL1_EG_PRI_BUF_EN |
59 + QCA8K_PORT_HOL_CTRL1_EG_PORT_BUF_EN |
60 + QCA8K_PORT_HOL_CTRL1_WRED_EN,
65 qca8k_setup(struct dsa_switch *ds)
67 @@ -1908,42 +1948,8 @@ qca8k_setup(struct dsa_switch *ds)
68 * missing settings to improve switch stability under load condition.
69 * This problem is limited to qca8337 and other qca8k switch are not affected.
71 - if (priv->switch_id == QCA8K_ID_QCA8337) {
73 - /* The 2 CPU port and port 5 requires some different
74 - * priority than any other ports.
79 - mask = QCA8K_PORT_HOL_CTRL0_EG_PRI0(0x3) |
80 - QCA8K_PORT_HOL_CTRL0_EG_PRI1(0x4) |
81 - QCA8K_PORT_HOL_CTRL0_EG_PRI2(0x4) |
82 - QCA8K_PORT_HOL_CTRL0_EG_PRI3(0x4) |
83 - QCA8K_PORT_HOL_CTRL0_EG_PRI4(0x6) |
84 - QCA8K_PORT_HOL_CTRL0_EG_PRI5(0x8) |
85 - QCA8K_PORT_HOL_CTRL0_EG_PORT(0x1e);
88 - mask = QCA8K_PORT_HOL_CTRL0_EG_PRI0(0x3) |
89 - QCA8K_PORT_HOL_CTRL0_EG_PRI1(0x4) |
90 - QCA8K_PORT_HOL_CTRL0_EG_PRI2(0x6) |
91 - QCA8K_PORT_HOL_CTRL0_EG_PRI3(0x8) |
92 - QCA8K_PORT_HOL_CTRL0_EG_PORT(0x19);
94 - qca8k_write(priv, QCA8K_REG_PORT_HOL_CTRL0(i), mask);
96 - mask = QCA8K_PORT_HOL_CTRL1_ING(0x6) |
97 - QCA8K_PORT_HOL_CTRL1_EG_PRI_BUF_EN |
98 - QCA8K_PORT_HOL_CTRL1_EG_PORT_BUF_EN |
99 - QCA8K_PORT_HOL_CTRL1_WRED_EN;
100 - qca8k_rmw(priv, QCA8K_REG_PORT_HOL_CTRL1(i),
101 - QCA8K_PORT_HOL_CTRL1_ING_BUF_MASK |
102 - QCA8K_PORT_HOL_CTRL1_EG_PRI_BUF_EN |
103 - QCA8K_PORT_HOL_CTRL1_EG_PORT_BUF_EN |
104 - QCA8K_PORT_HOL_CTRL1_WRED_EN,
107 + if (priv->switch_id == QCA8K_ID_QCA8337)
108 + qca8k_setup_hol_fixup(priv, i);
111 /* Special GLOBAL_FC_THRESH value are needed for ar8327 switch */