1 From 4f3701fc599820568ba4395070d34e4248800fc0 Mon Sep 17 00:00:00 2001
2 From: Ansuel Smith <ansuelsmth@gmail.com>
3 Date: Wed, 2 Feb 2022 01:03:35 +0100
4 Subject: [PATCH 16/16] net: dsa: qca8k: introduce qca8k_bulk_read/write
7 Introduce qca8k_bulk_read/write() function to use mgmt Ethernet way to
8 read/write packet in bulk. Make use of this new function in the fdb
9 function and while at it reduce the reg for fdb_read from 4 to 3 as the
10 max bit for the ARL(fdb) table is 83 bits.
12 Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
13 Signed-off-by: David S. Miller <davem@davemloft.net>
15 drivers/net/dsa/qca8k.c | 55 ++++++++++++++++++++++++++++++++---------
16 1 file changed, 43 insertions(+), 12 deletions(-)
18 --- a/drivers/net/dsa/qca8k.c
19 +++ b/drivers/net/dsa/qca8k.c
20 @@ -412,6 +412,43 @@ qca8k_regmap_update_bits_eth(struct qca8
24 +qca8k_bulk_read(struct qca8k_priv *priv, u32 reg, u32 *val, int len)
26 + int i, count = len / sizeof(u32), ret;
28 + if (priv->mgmt_master && !qca8k_read_eth(priv, reg, val, len))
31 + for (i = 0; i < count; i++) {
32 + ret = regmap_read(priv->regmap, reg + (i * 4), val + i);
41 +qca8k_bulk_write(struct qca8k_priv *priv, u32 reg, u32 *val, int len)
43 + int i, count = len / sizeof(u32), ret;
46 + if (priv->mgmt_master && !qca8k_write_eth(priv, reg, val, len))
49 + for (i = 0; i < count; i++) {
52 + ret = regmap_write(priv->regmap, reg + (i * 4), tmp);
61 qca8k_regmap_read(void *ctx, uint32_t reg, uint32_t *val)
63 struct qca8k_priv *priv = (struct qca8k_priv *)ctx;
64 @@ -546,17 +583,13 @@ qca8k_busy_wait(struct qca8k_priv *priv,
66 qca8k_fdb_read(struct qca8k_priv *priv, struct qca8k_fdb *fdb)
73 /* load the ARL table into an array */
74 - for (i = 0; i < 4; i++) {
75 - ret = qca8k_read(priv, QCA8K_REG_ATU_DATA0 + (i * 4), &val);
81 + ret = qca8k_bulk_read(priv, QCA8K_REG_ATU_DATA0, reg, sizeof(reg));
86 fdb->vid = FIELD_GET(QCA8K_ATU_VID_MASK, reg[2]);
87 @@ -580,7 +613,6 @@ qca8k_fdb_write(struct qca8k_priv *priv,
94 reg[2] = FIELD_PREP(QCA8K_ATU_VID_MASK, vid);
95 @@ -597,8 +629,7 @@ qca8k_fdb_write(struct qca8k_priv *priv,
96 reg[0] |= FIELD_PREP(QCA8K_ATU_ADDR5_MASK, mac[5]);
98 /* load the array into the ARL table */
99 - for (i = 0; i < 3; i++)
100 - qca8k_write(priv, QCA8K_REG_ATU_DATA0 + (i * 4), reg[i]);
101 + qca8k_bulk_write(priv, QCA8K_REG_ATU_DATA0, reg, sizeof(reg));