From: Vladimir Oltean <olteanv@gmail.com>
To: f.fainelli@gmail.com, vivien.didelot@gmail.com, andrew@lunn.ch,
davem@davemloft.net
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Vladimir Oltean <olteanv@gmail.com>
Subject: [PATCH v5 net-next 08/12] net: dsa: sja1105: Add support for configuring address ageing time
Date: Thu, 2 May 2019 23:23:36 +0300 [thread overview]
Message-ID: <20190502202340.21054-9-olteanv@gmail.com> (raw)
In-Reply-To: <20190502202340.21054-1-olteanv@gmail.com>
If STP is active, this setting is applied on bridged ports each time an
Ethernet link is established (topology changes).
Since the setting is global to the switch and a reset is required to
change it, resets are prevented if the new callback does not change the
value that the hardware already is programmed for.
Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
Changes in v5:
Changed "aging" to "ageing" in commit message to be consistent with the
code.
Changes in v4:
Patch is new.
drivers/net/dsa/sja1105/sja1105.h | 4 ++++
drivers/net/dsa/sja1105/sja1105_main.c | 29 ++++++++++++++++++++++++--
2 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/drivers/net/dsa/sja1105/sja1105.h b/drivers/net/dsa/sja1105/sja1105.h
index 38506bde83c6..0489d9adf957 100644
--- a/drivers/net/dsa/sja1105/sja1105.h
+++ b/drivers/net/dsa/sja1105/sja1105.h
@@ -12,6 +12,10 @@
#define SJA1105_NUM_PORTS 5
#define SJA1105_NUM_TC 8
#define SJA1105ET_FDB_BIN_SIZE 4
+/* The hardware value is in multiples of 10 ms.
+ * The passed parameter is in multiples of 1 ms.
+ */
+#define SJA1105_AGEING_TIME_MS(ms) ((ms) / 10)
/* Keeps the different addresses between E/T and P/Q/R/S */
struct sja1105_regs {
diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c
index 28b11c7a81e7..f5205ce85dbe 100644
--- a/drivers/net/dsa/sja1105/sja1105_main.c
+++ b/drivers/net/dsa/sja1105/sja1105_main.c
@@ -193,8 +193,8 @@ static int sja1105_init_l2_lookup_params(struct sja1105_private *priv)
{
struct sja1105_table *table;
struct sja1105_l2_lookup_params_entry default_l2_lookup_params = {
- /* TODO Learned FDB entries are never forgotten */
- .maxage = 0,
+ /* Learned FDB entries are forgotten after 300 seconds */
+ .maxage = SJA1105_AGEING_TIME_MS(300000),
/* All entries within a FDB bin are available for learning */
.dyn_tbsz = SJA1105ET_FDB_BIN_SIZE,
/* 2^8 + 2^5 + 2^3 + 2^2 + 2^1 + 1 in Koopman notation */
@@ -1249,10 +1249,35 @@ static int sja1105_setup(struct dsa_switch *ds)
return 0;
}
+/* The MAXAGE setting belongs to the L2 Forwarding Parameters table,
+ * which cannot be reconfigured at runtime. So a switch reset is required.
+ */
+static int sja1105_set_ageing_time(struct dsa_switch *ds,
+ unsigned int ageing_time)
+{
+ struct sja1105_l2_lookup_params_entry *l2_lookup_params;
+ struct sja1105_private *priv = ds->priv;
+ struct sja1105_table *table;
+ unsigned int maxage;
+
+ table = &priv->static_config.tables[BLK_IDX_L2_LOOKUP_PARAMS];
+ l2_lookup_params = table->entries;
+
+ maxage = SJA1105_AGEING_TIME_MS(ageing_time);
+
+ if (l2_lookup_params->maxage == maxage)
+ return 0;
+
+ l2_lookup_params->maxage = maxage;
+
+ return sja1105_static_config_reload(priv);
+}
+
static const struct dsa_switch_ops sja1105_switch_ops = {
.get_tag_protocol = sja1105_get_tag_protocol,
.setup = sja1105_setup,
.adjust_link = sja1105_adjust_link,
+ .set_ageing_time = sja1105_set_ageing_time,
.get_strings = sja1105_get_strings,
.get_ethtool_stats = sja1105_get_ethtool_stats,
.get_sset_count = sja1105_get_sset_count,
--
2.17.1
next prev parent reply other threads:[~2019-05-02 20:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-02 20:23 [PATCH v5 net-next 00/12] NXP SJA1105 DSA driver Vladimir Oltean
2019-05-02 20:23 ` [PATCH v5 net-next 01/12] lib: Add support for generic packing operations Vladimir Oltean
2019-05-02 20:23 ` [PATCH v5 net-next 02/12] net: dsa: Introduce driver for NXP SJA1105 5-port L2 switch Vladimir Oltean
2019-05-02 20:23 ` [PATCH v5 net-next 03/12] net: dsa: sja1105: Add support for FDB and MDB management Vladimir Oltean
2019-05-02 20:23 ` [PATCH v5 net-next 04/12] net: dsa: sja1105: Error out if RGMII delays are requested in DT Vladimir Oltean
2019-05-02 20:23 ` [PATCH v5 net-next 05/12] ether: Add dedicated Ethertype for pseudo-802.1Q DSA tagging Vladimir Oltean
2019-05-02 20:23 ` [PATCH v5 net-next 06/12] net: dsa: sja1105: Add support for VLAN operations Vladimir Oltean
2019-05-02 20:23 ` [PATCH v5 net-next 07/12] net: dsa: sja1105: Add support for ethtool port counters Vladimir Oltean
2019-05-02 20:23 ` Vladimir Oltean [this message]
2019-05-02 20:23 ` [PATCH v5 net-next 09/12] net: dsa: sja1105: Prevent PHY jabbering during switch reset Vladimir Oltean
2019-05-02 20:23 ` [PATCH v5 net-next 10/12] net: dsa: sja1105: Reject unsupported link modes for AN Vladimir Oltean
2019-05-02 20:23 ` [PATCH v5 net-next 11/12] Documentation: net: dsa: Add details about NXP SJA1105 driver Vladimir Oltean
2019-05-02 20:23 ` [PATCH v5 net-next 12/12] dt-bindings: net: dsa: Add documentation for " Vladimir Oltean
2019-05-03 14:51 ` [PATCH v5 net-next 00/12] NXP SJA1105 DSA driver David Miller
2019-05-03 14:51 ` Vladimir Oltean
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190502202340.21054-9-olteanv@gmail.com \
--to=olteanv@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=vivien.didelot@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).