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 diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c
19 index a1b76dcd2eb6..52ec2800dd89 100644
20 --- a/drivers/net/dsa/qca8k.c
21 +++ b/drivers/net/dsa/qca8k.c
22 @@ -411,6 +411,43 @@ qca8k_regmap_update_bits_eth(struct qca8k_priv *priv, u32 reg, u32 mask, u32 wri
23 return qca8k_write_eth(priv, reg, &val, sizeof(val));
27 +qca8k_bulk_read(struct qca8k_priv *priv, u32 reg, u32 *val, int len)
29 + int i, count = len / sizeof(u32), ret;
31 + if (priv->mgmt_master && !qca8k_read_eth(priv, reg, val, len))
34 + for (i = 0; i < count; i++) {
35 + ret = regmap_read(priv->regmap, reg + (i * 4), val + i);
44 +qca8k_bulk_write(struct qca8k_priv *priv, u32 reg, u32 *val, int len)
46 + int i, count = len / sizeof(u32), ret;
49 + if (priv->mgmt_master && !qca8k_write_eth(priv, reg, val, len))
52 + for (i = 0; i < count; i++) {
55 + ret = regmap_write(priv->regmap, reg + (i * 4), tmp);
64 qca8k_regmap_read(void *ctx, uint32_t reg, uint32_t *val)
66 @@ -546,17 +583,13 @@ qca8k_busy_wait(struct qca8k_priv *priv, u32 reg, u32 mask)
68 qca8k_fdb_read(struct qca8k_priv *priv, struct qca8k_fdb *fdb)
75 /* load the ARL table into an array */
76 - for (i = 0; i < 4; i++) {
77 - ret = qca8k_read(priv, QCA8K_REG_ATU_DATA0 + (i * 4), &val);
83 + ret = qca8k_bulk_read(priv, QCA8K_REG_ATU_DATA0, reg, sizeof(reg));
88 fdb->vid = FIELD_GET(QCA8K_ATU_VID_MASK, reg[2]);
89 @@ -580,7 +613,6 @@ qca8k_fdb_write(struct qca8k_priv *priv, u16 vid, u8 port_mask, const u8 *mac,
96 reg[2] = FIELD_PREP(QCA8K_ATU_VID_MASK, vid);
97 @@ -597,8 +629,7 @@ qca8k_fdb_write(struct qca8k_priv *priv, u16 vid, u8 port_mask, const u8 *mac,
98 reg[0] |= FIELD_PREP(QCA8K_ATU_ADDR5_MASK, mac[5]);
100 /* load the array into the ARL table */
101 - for (i = 0; i < 3; i++)
102 - qca8k_write(priv, QCA8K_REG_ATU_DATA0 + (i * 4), reg[i]);
103 + qca8k_bulk_write(priv, QCA8K_REG_ATU_DATA0, reg, sizeof(reg));