linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Dege <michael.dege@renesas.com>
To: "Yoshihiro Shimoda" <yoshihiro.shimoda.uh@renesas.com>,
	"Niklas Söderlund" <niklas.soderlund@ragnatech.se>,
	"Paul Barker" <paul@pbarker.dev>,
	"Andrew Lunn" <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	 linux-kernel@vger.kernel.org,
	Michael Dege <michael.dege@renesas.com>,
	 Nikita Yushchenko <nikita.yoush@cogentembedded.com>
Subject: [PATCH 3/3] net: renesas: rswitch: add modifiable ageing time
Date: Fri, 04 Jul 2025 07:51:17 +0200	[thread overview]
Message-ID: <20250704-add_l2_switching-v1-3-ff882aacb258@renesas.com> (raw)
In-Reply-To: <20250704-add_l2_switching-v1-0-ff882aacb258@renesas.com>

This commit allows the setting of the MAC table aging in the R-Car S4
Rswitch using the SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME attribute.

Signed-off-by: Michael Dege <michael.dege@renesas.com>
---
 drivers/net/ethernet/renesas/rswitch.h    |  1 +
 drivers/net/ethernet/renesas/rswitch_l2.c | 26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/drivers/net/ethernet/renesas/rswitch.h b/drivers/net/ethernet/renesas/rswitch.h
index 45a9d02c5b5d3e7b62554bd56c6c0cb9231f684c..11ff1102668b081e395664ea73e19e0ecef74e24 100644
--- a/drivers/net/ethernet/renesas/rswitch.h
+++ b/drivers/net/ethernet/renesas/rswitch.h
@@ -849,6 +849,7 @@ enum rswitch_gwca_mode {
 #define FWMACAGC_MACDESOG	BIT(29)
 
 #define RSW_AGEING_TIME		300
+#define RSW_MAX_AGEING_TIME	65535
 
 /* TOP */
 #define TPEMIMC7(queue)		(TPEMIMC70 + (queue) * 4)
diff --git a/drivers/net/ethernet/renesas/rswitch_l2.c b/drivers/net/ethernet/renesas/rswitch_l2.c
index 242beb1f15c089585f5fe5019f626df8824b971a..c8a8a60a20e70f7ce421280ed35c0c4afe1ed039 100644
--- a/drivers/net/ethernet/renesas/rswitch_l2.c
+++ b/drivers/net/ethernet/renesas/rswitch_l2.c
@@ -196,6 +196,30 @@ static int rswitch_netdevice_event(struct notifier_block *nb,
 	return NOTIFY_OK;
 }
 
+static int rswitch_update_ageing_time(struct net_device *ndev, clock_t time)
+{
+	struct rswitch_device *rdev = netdev_priv(ndev);
+	u32 reg_val, time_val;
+
+	if (!is_rdev(ndev))
+		return -ENODEV;
+
+	/* Although brctl accepts the ageing time parameter in seconds, the value
+	 * passed to the driver is multiplied by 100. We need it in seconds.
+	 */
+	time_val = (u32)time / 100;
+
+	if (time_val > RSW_MAX_AGEING_TIME)
+		return -EINVAL;
+
+	rdev = netdev_priv(ndev);
+	reg_val = FIELD_PREP(FWMACAGC_MACAGT, time_val);
+	reg_val |= FWMACAGC_MACAGE | FWMACAGC_MACAGSL;
+	iowrite32(reg_val, rdev->priv->addr + FWMACAGC);
+
+	return 0;
+}
+
 static int rswitch_port_attr_set(struct net_device *ndev, const void *ctx,
 				 const struct switchdev_attr *attr,
 				 struct netlink_ext_ack *extack)
@@ -203,6 +227,8 @@ static int rswitch_port_attr_set(struct net_device *ndev, const void *ctx,
 	switch (attr->id) {
 	case SWITCHDEV_ATTR_ID_PORT_STP_STATE:
 		return rswitch_port_update_stp_state(ndev, attr->u.stp_state);
+	case SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME:
+		return rswitch_update_ageing_time(ndev, attr->u.ageing_time);
 	default:
 		return -EOPNOTSUPP;
 	}

-- 
2.49.0


  parent reply	other threads:[~2025-07-04  5:51 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-04  5:51 [PATCH 0/3] net: renesas: rswitch: R-Car S4 add HW offloading for layer 2 switching Michael Dege
2025-07-04  5:51 ` [PATCH 1/3] net: renesas: rswitch: rename rswitch.c to rswitch_main.c Michael Dege
2025-07-04  8:34   ` Andrew Lunn
2025-07-04  9:11   ` Niklas Söderlund
2025-07-04  5:51 ` [PATCH 2/3] net: renesas: rswitch: add offloading for L2 switching Michael Dege
2025-07-04  8:43   ` Andrew Lunn
2025-07-04  9:02     ` Nikita Yushchenko
2025-07-04 17:49       ` Andrew Lunn
2025-07-07  8:13     ` Michael Dege
2025-07-07  8:42       ` Michael Dege
2025-07-07 11:30       ` Andrew Lunn
2025-07-04  5:51 ` Michael Dege [this message]
2025-07-07 12:50   ` [PATCH 3/3] net: renesas: rswitch: add modifiable ageing time Geert Uytterhoeven
2025-07-07 12:59     ` Michael Dege
2025-07-04  8:33 ` [PATCH 0/3] net: renesas: rswitch: R-Car S4 add HW offloading for layer 2 switching Andrew Lunn
2025-07-07 10:41   ` Michael Dege
2025-07-07 11:53     ` Andrew Lunn
2025-07-07 12:25       ` Michael Dege
2025-07-04  8:46 ` Andrew Lunn
2025-07-04  9:05   ` Nikita Yushchenko
2025-07-04 17:53     ` Andrew Lunn
2025-07-04 17:56       ` Nikita Yushchenko

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=20250704-add_l2_switching-v1-3-ff882aacb258@renesas.com \
    --to=michael.dege@renesas.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nikita.yoush@cogentembedded.com \
    --cc=niklas.soderlund@ragnatech.se \
    --cc=pabeni@redhat.com \
    --cc=paul@pbarker.dev \
    --cc=yoshihiro.shimoda.uh@renesas.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).