Skip to content

Commit 6a3bdc5

Browse files
Ansueldavem330
authored andcommitted
net: dsa: qca8k: add set_ageing_time support
qca8k support setting ageing time in step of 7s. Add support for it and set the max value accepted of 7645m. Documentation talks about support for 10000m but that values doesn't make sense as the value doesn't match the max value in the reg. Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com> Reviewed-by: Vladimir Oltean <olteanv@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 4592538 commit 6a3bdc5

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

drivers/net/dsa/qca8k.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,6 +1257,10 @@ qca8k_setup(struct dsa_switch *ds)
12571257
/* We don't have interrupts for link changes, so we need to poll */
12581258
ds->pcs_poll = true;
12591259

1260+
/* Set min a max ageing value supported */
1261+
ds->ageing_time_min = 7000;
1262+
ds->ageing_time_max = 458745000;
1263+
12601264
return 0;
12611265
}
12621266

@@ -1796,6 +1800,26 @@ qca8k_port_fast_age(struct dsa_switch *ds, int port)
17961800
mutex_unlock(&priv->reg_mutex);
17971801
}
17981802

1803+
static int
1804+
qca8k_set_ageing_time(struct dsa_switch *ds, unsigned int msecs)
1805+
{
1806+
struct qca8k_priv *priv = ds->priv;
1807+
unsigned int secs = msecs / 1000;
1808+
u32 val;
1809+
1810+
/* AGE_TIME reg is set in 7s step */
1811+
val = secs / 7;
1812+
1813+
/* Handle case with 0 as val to NOT disable
1814+
* learning
1815+
*/
1816+
if (!val)
1817+
val = 1;
1818+
1819+
return regmap_update_bits(priv->regmap, QCA8K_REG_ATU_CTRL, QCA8K_ATU_AGE_TIME_MASK,
1820+
QCA8K_ATU_AGE_TIME(val));
1821+
}
1822+
17991823
static int
18001824
qca8k_port_enable(struct dsa_switch *ds, int port,
18011825
struct phy_device *phy)
@@ -1995,6 +2019,7 @@ static const struct dsa_switch_ops qca8k_switch_ops = {
19952019
.get_strings = qca8k_get_strings,
19962020
.get_ethtool_stats = qca8k_get_ethtool_stats,
19972021
.get_sset_count = qca8k_get_sset_count,
2022+
.set_ageing_time = qca8k_set_ageing_time,
19982023
.get_mac_eee = qca8k_get_mac_eee,
19992024
.set_mac_eee = qca8k_set_mac_eee,
20002025
.port_enable = qca8k_port_enable,

drivers/net/dsa/qca8k.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@
175175
#define QCA8K_VTU_FUNC1_BUSY BIT(31)
176176
#define QCA8K_VTU_FUNC1_VID_MASK GENMASK(27, 16)
177177
#define QCA8K_VTU_FUNC1_FULL BIT(4)
178+
#define QCA8K_REG_ATU_CTRL 0x618
179+
#define QCA8K_ATU_AGE_TIME_MASK GENMASK(15, 0)
180+
#define QCA8K_ATU_AGE_TIME(x) FIELD_PREP(QCA8K_ATU_AGE_TIME_MASK, (x))
178181
#define QCA8K_REG_GLOBAL_FW_CTRL0 0x620
179182
#define QCA8K_GLOBAL_FW_CTRL0_CPU_PORT_EN BIT(10)
180183
#define QCA8K_REG_GLOBAL_FW_CTRL1 0x624

0 commit comments

Comments
 (0)