diff mbox series

[net-next,6/8] net: lan966x: Extend FDB to support also lag

Message ID 20220626130451.1079933-7-horatiu.vultur@microchip.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: lan966x: Add lag support | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 75 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Horatiu Vultur June 26, 2022, 1:04 p.m. UTC
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  | 31 +++++++++++++++++++
 .../ethernet/microchip/lan966x/lan966x_lag.c  | 16 ++++++++++
 .../ethernet/microchip/lan966x/lan966x_main.h |  7 +++++
 3 files changed, 54 insertions(+)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_fdb.c b/drivers/net/ethernet/microchip/lan966x/lan966x_fdb.c
index 2e186e9d9893..154efbd0c319 100644
--- a/drivers/net/ethernet/microchip/lan966x/lan966x_fdb.c
+++ b/drivers/net/ethernet/microchip/lan966x/lan966x_fdb.c
@@ -194,6 +194,35 @@  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_lag_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_lag_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 =
@@ -203,6 +232,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);
 	dev_put(fdb_work->orig_dev);
diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_lag.c b/drivers/net/ethernet/microchip/lan966x/lan966x_lag.c
index c721a05d44d2..db21bd358e4e 100644
--- a/drivers/net/ethernet/microchip/lan966x/lan966x_lag.c
+++ b/drivers/net/ethernet/microchip/lan966x/lan966x_lag.c
@@ -294,3 +294,19 @@  u32 lan966x_lag_get_mask(struct lan966x *lan966x, struct net_device *bond,
 
 	return mask;
 }
+
+void lan966x_lag_mac_del_entry(struct lan966x *lan966x,
+			       const unsigned char *addr,
+			       u16 vid)
+{
+	lan966x_mac_del_entry(lan966x, addr, vid);
+}
+
+int lan966x_lag_mac_add_entry(struct lan966x *lan966x,
+			      struct lan966x_port *port,
+			      const unsigned char *addr,
+			      u16 vid)
+{
+	lan966x_mac_del_entry(lan966x, addr, vid);
+	return lan966x_mac_add_entry(lan966x, port, addr, vid);
+}
diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h b/drivers/net/ethernet/microchip/lan966x/lan966x_main.h
index 2c382cf8fe3a..7b4805813549 100644
--- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h
+++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.h
@@ -426,6 +426,13 @@  int lan966x_lag_netdev_changeupper(struct net_device *dev,
 bool lan966x_lag_first_port(struct net_device *lag, struct net_device *dev);
 u32 lan966x_lag_get_mask(struct lan966x *lan966x, struct net_device *bond,
 			 bool only_active_ports);
+void lan966x_lag_mac_del_entry(struct lan966x *lan966x,
+			       const unsigned char *addr,
+			       u16 vid);
+int lan966x_lag_mac_add_entry(struct lan966x *lan966x,
+			      struct lan966x_port *port,
+			      const unsigned char *addr,
+			      u16 vid);
 
 int lan966x_port_changeupper(struct net_device *dev,
 			     struct net_device *brport_dev,