All of lore.kernel.org
 help / color / mirror / Atom feed
From: Horatiu Vultur <horatiu.vultur@microchip.com>
To: <linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>
Cc: <UNGLinuxDriver@microchip.com>, <davem@davemloft.net>,
	<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
	<vladimir.oltean@nxp.com>,
	Horatiu Vultur <horatiu.vultur@microchip.com>
Subject: [PATCH net-next v3 6/7] net: lan966x: Extend FDB to support also lag
Date: Fri, 1 Jul 2022 22:52:26 +0200	[thread overview]
Message-ID: <20220701205227.1337160-7-horatiu.vultur@microchip.com> (raw)
In-Reply-To: <20220701205227.1337160-1-horatiu.vultur@microchip.com>

Offload FDB entries when the original device is a lag interface. Because
all the ports under the lag have the same chip id, which is the chip id
of first port, then add the entries only for the first port.

Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
---
 .../ethernet/microchip/lan966x/lan966x_fdb.c  | 30 +++++++++++++++++++
 .../microchip/lan966x/lan966x_switchdev.c     |  4 ++-
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_fdb.c b/drivers/net/ethernet/microchip/lan966x/lan966x_fdb.c
index 5142e7c0de31..2ea263e893ee 100644
--- a/drivers/net/ethernet/microchip/lan966x/lan966x_fdb.c
+++ b/drivers/net/ethernet/microchip/lan966x/lan966x_fdb.c
@@ -199,6 +199,34 @@ static void lan966x_fdb_bridge_event_work(struct lan966x_fdb_event_work *fdb_wor
 	}
 }
 
+static void lan966x_fdb_lag_event_work(struct lan966x_fdb_event_work *fdb_work)
+{
+	struct switchdev_notifier_fdb_info *fdb_info;
+	struct lan966x_port *port;
+	struct lan966x *lan966x;
+
+	if (!lan966x_lag_first_port(fdb_work->orig_dev, fdb_work->dev))
+		return;
+
+	lan966x = fdb_work->lan966x;
+	port = netdev_priv(fdb_work->dev);
+	fdb_info = &fdb_work->fdb_info;
+
+	switch (fdb_work->event) {
+	case SWITCHDEV_FDB_ADD_TO_DEVICE:
+		if (!fdb_info->added_by_user)
+			break;
+		lan966x_mac_add_entry(lan966x, port, fdb_info->addr,
+				      fdb_info->vid);
+		break;
+	case SWITCHDEV_FDB_DEL_TO_DEVICE:
+		if (!fdb_info->added_by_user)
+			break;
+		lan966x_mac_del_entry(lan966x, fdb_info->addr, fdb_info->vid);
+		break;
+	}
+}
+
 static void lan966x_fdb_event_work(struct work_struct *work)
 {
 	struct lan966x_fdb_event_work *fdb_work =
@@ -208,6 +236,8 @@ static void lan966x_fdb_event_work(struct work_struct *work)
 		lan966x_fdb_port_event_work(fdb_work);
 	else if (netif_is_bridge_master(fdb_work->orig_dev))
 		lan966x_fdb_bridge_event_work(fdb_work);
+	else if (netif_is_lag_master(fdb_work->orig_dev))
+		lan966x_fdb_lag_event_work(fdb_work);
 
 	kfree(fdb_work->fdb_info.addr);
 	kfree(fdb_work);
diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_switchdev.c b/drivers/net/ethernet/microchip/lan966x/lan966x_switchdev.c
index 0cd53dca87ce..ced0194f6246 100644
--- a/drivers/net/ethernet/microchip/lan966x/lan966x_switchdev.c
+++ b/drivers/net/ethernet/microchip/lan966x/lan966x_switchdev.c
@@ -345,8 +345,10 @@ int lan966x_port_prechangeupper(struct net_device *dev,
 	if (netif_is_lag_master(info->upper_dev) && info->linking)
 		err = lan966x_lag_port_prechangeupper(dev, info);
 
-	if (netif_is_lag_master(info->upper_dev) && !info->linking)
+	if (netif_is_lag_master(info->upper_dev) && !info->linking) {
 		switchdev_bridge_port_unoffload(brport_dev, port, NULL, NULL);
+		lan966x_fdb_flush_workqueue(port->lan966x);
+	}
 
 	return err;
 }
-- 
2.33.0


  parent reply	other threads:[~2022-07-01 20:50 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-01 20:52 [PATCH net-next v3 0/7] net: lan966x: Add lag support Horatiu Vultur
2022-07-01 20:52 ` [PATCH net-next v3 1/7] net: lan966x: Add reqisters used to configure lag interfaces Horatiu Vultur
2022-07-02 14:30   ` Vladimir Oltean
2022-07-01 20:52 ` [PATCH net-next v3 2/7] net: lan966x: Split lan966x_fdb_event_work Horatiu Vultur
2022-07-02 14:08   ` Vladimir Oltean
2022-07-05 21:59     ` Horatiu Vultur
2022-07-01 20:52 ` [PATCH net-next v3 3/7] net: lan966x: Expose lan966x_switchdev_nb and lan966x_switchdev_blocking_nb Horatiu Vultur
2022-07-01 20:52 ` [PATCH net-next v3 4/7] net: lan966x: Extend lan966x_foreign_bridging_check Horatiu Vultur
2022-07-02 14:30   ` Vladimir Oltean
2022-07-01 20:52 ` [PATCH net-next v3 5/7] net: lan966x: Add lag support for lan966x Horatiu Vultur
2022-07-02 14:12   ` Vladimir Oltean
2022-07-05 18:38   ` kernel test robot
2022-07-06  8:45     ` Vladimir Oltean
2022-07-06  8:45       ` Vladimir Oltean
2022-07-01 20:52 ` Horatiu Vultur [this message]
2022-07-01 20:52 ` [PATCH net-next v3 7/7] net: lan966x: Extend MAC to support also lag interfaces Horatiu Vultur

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=20220701205227.1337160-7-horatiu.vultur@microchip.com \
    --to=horatiu.vultur@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=vladimir.oltean@nxp.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.