Skip to content

Commit a9108b0

Browse files
AnsuelPaolo Abeni
authored andcommitted
net: dsa: qca8k: move qca8xxx hol fixup to separate function
Move qca8xxx hol fixup to separate function to tidy things up and to permit using a more efficent loop in future patch. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> Link: https://lore.kernel.org/r/20230730074113.21889-4-ansuelsmth@gmail.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 18e8fea commit a9108b0

File tree

1 file changed

+42
-36
lines changed

1 file changed

+42
-36
lines changed

drivers/net/dsa/qca/qca8k-8xxx.c

Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,6 +1756,46 @@ static int qca8k_connect_tag_protocol(struct dsa_switch *ds,
17561756
return 0;
17571757
}
17581758

1759+
static void qca8k_setup_hol_fixup(struct qca8k_priv *priv, int port)
1760+
{
1761+
u32 mask;
1762+
1763+
switch (port) {
1764+
/* The 2 CPU port and port 5 requires some different
1765+
* priority than any other ports.
1766+
*/
1767+
case 0:
1768+
case 5:
1769+
case 6:
1770+
mask = QCA8K_PORT_HOL_CTRL0_EG_PRI0(0x3) |
1771+
QCA8K_PORT_HOL_CTRL0_EG_PRI1(0x4) |
1772+
QCA8K_PORT_HOL_CTRL0_EG_PRI2(0x4) |
1773+
QCA8K_PORT_HOL_CTRL0_EG_PRI3(0x4) |
1774+
QCA8K_PORT_HOL_CTRL0_EG_PRI4(0x6) |
1775+
QCA8K_PORT_HOL_CTRL0_EG_PRI5(0x8) |
1776+
QCA8K_PORT_HOL_CTRL0_EG_PORT(0x1e);
1777+
break;
1778+
default:
1779+
mask = QCA8K_PORT_HOL_CTRL0_EG_PRI0(0x3) |
1780+
QCA8K_PORT_HOL_CTRL0_EG_PRI1(0x4) |
1781+
QCA8K_PORT_HOL_CTRL0_EG_PRI2(0x6) |
1782+
QCA8K_PORT_HOL_CTRL0_EG_PRI3(0x8) |
1783+
QCA8K_PORT_HOL_CTRL0_EG_PORT(0x19);
1784+
}
1785+
regmap_write(priv->regmap, QCA8K_REG_PORT_HOL_CTRL0(port), mask);
1786+
1787+
mask = QCA8K_PORT_HOL_CTRL1_ING(0x6) |
1788+
QCA8K_PORT_HOL_CTRL1_EG_PRI_BUF_EN |
1789+
QCA8K_PORT_HOL_CTRL1_EG_PORT_BUF_EN |
1790+
QCA8K_PORT_HOL_CTRL1_WRED_EN;
1791+
regmap_update_bits(priv->regmap, QCA8K_REG_PORT_HOL_CTRL1(port),
1792+
QCA8K_PORT_HOL_CTRL1_ING_BUF_MASK |
1793+
QCA8K_PORT_HOL_CTRL1_EG_PRI_BUF_EN |
1794+
QCA8K_PORT_HOL_CTRL1_EG_PORT_BUF_EN |
1795+
QCA8K_PORT_HOL_CTRL1_WRED_EN,
1796+
mask);
1797+
}
1798+
17591799
static int
17601800
qca8k_setup(struct dsa_switch *ds)
17611801
{
@@ -1895,42 +1935,8 @@ qca8k_setup(struct dsa_switch *ds)
18951935
* missing settings to improve switch stability under load condition.
18961936
* This problem is limited to qca8337 and other qca8k switch are not affected.
18971937
*/
1898-
if (priv->switch_id == QCA8K_ID_QCA8337) {
1899-
switch (i) {
1900-
/* The 2 CPU port and port 5 requires some different
1901-
* priority than any other ports.
1902-
*/
1903-
case 0:
1904-
case 5:
1905-
case 6:
1906-
mask = QCA8K_PORT_HOL_CTRL0_EG_PRI0(0x3) |
1907-
QCA8K_PORT_HOL_CTRL0_EG_PRI1(0x4) |
1908-
QCA8K_PORT_HOL_CTRL0_EG_PRI2(0x4) |
1909-
QCA8K_PORT_HOL_CTRL0_EG_PRI3(0x4) |
1910-
QCA8K_PORT_HOL_CTRL0_EG_PRI4(0x6) |
1911-
QCA8K_PORT_HOL_CTRL0_EG_PRI5(0x8) |
1912-
QCA8K_PORT_HOL_CTRL0_EG_PORT(0x1e);
1913-
break;
1914-
default:
1915-
mask = QCA8K_PORT_HOL_CTRL0_EG_PRI0(0x3) |
1916-
QCA8K_PORT_HOL_CTRL0_EG_PRI1(0x4) |
1917-
QCA8K_PORT_HOL_CTRL0_EG_PRI2(0x6) |
1918-
QCA8K_PORT_HOL_CTRL0_EG_PRI3(0x8) |
1919-
QCA8K_PORT_HOL_CTRL0_EG_PORT(0x19);
1920-
}
1921-
qca8k_write(priv, QCA8K_REG_PORT_HOL_CTRL0(i), mask);
1922-
1923-
mask = QCA8K_PORT_HOL_CTRL1_ING(0x6) |
1924-
QCA8K_PORT_HOL_CTRL1_EG_PRI_BUF_EN |
1925-
QCA8K_PORT_HOL_CTRL1_EG_PORT_BUF_EN |
1926-
QCA8K_PORT_HOL_CTRL1_WRED_EN;
1927-
qca8k_rmw(priv, QCA8K_REG_PORT_HOL_CTRL1(i),
1928-
QCA8K_PORT_HOL_CTRL1_ING_BUF_MASK |
1929-
QCA8K_PORT_HOL_CTRL1_EG_PRI_BUF_EN |
1930-
QCA8K_PORT_HOL_CTRL1_EG_PORT_BUF_EN |
1931-
QCA8K_PORT_HOL_CTRL1_WRED_EN,
1932-
mask);
1933-
}
1938+
if (priv->switch_id == QCA8K_ID_QCA8337)
1939+
qca8k_setup_hol_fixup(priv, i);
19341940
}
19351941

19361942
/* Special GLOBAL_FC_THRESH value are needed for ar8327 switch */

0 commit comments

Comments
 (0)