diff mbox series

[net-next,8/8] net: lan966x: Update PGID when lag ports are changing link status

Message ID 20220626130451.1079933-9-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, 54 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
When a port under a bond device is changing it's link status it is
required to recalculate the PGID entries. Otherwise the HW will still
try to transmit frames on the port that is down.

Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
---
 .../net/ethernet/microchip/lan966x/lan966x_lag.c | 16 ++++++++++++++++
 .../ethernet/microchip/lan966x/lan966x_main.h    |  3 +++
 .../ethernet/microchip/lan966x/lan966x_port.c    |  6 ++++++
 3 files changed, 25 insertions(+)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_lag.c b/drivers/net/ethernet/microchip/lan966x/lan966x_lag.c
index 4ce41a55737c..eec5d6912757 100644
--- a/drivers/net/ethernet/microchip/lan966x/lan966x_lag.c
+++ b/drivers/net/ethernet/microchip/lan966x/lan966x_lag.c
@@ -151,6 +151,22 @@  void lan966x_lag_port_leave(struct lan966x_port *port, struct net_device *bond)
 	lan966x_lag_set_aggr_pgids(lan966x);
 }
 
+void lan966x_lag_port_down(struct lan966x_port *port)
+{
+	port->bond_fix = port->bond;
+	lan966x_lag_port_leave(port, port->bond);
+}
+
+void lan966x_lag_port_up(struct lan966x_port *port)
+{
+	struct lan966x *lan966x = port->lan966x;
+
+	port->bond = port->bond_fix;
+	lan966x_lag_set_port_ids(lan966x);
+	lan966x_update_fwd_mask(lan966x);
+	lan966x_lag_set_aggr_pgids(lan966x);
+}
+
 int lan966x_lag_port_prechangeupper(struct net_device *dev,
 				    struct netdev_notifier_changeupper_info *info)
 {
diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h b/drivers/net/ethernet/microchip/lan966x/lan966x_main.h
index c1f5ca5d91a4..23264e70fb8a 100644
--- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h
+++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.h
@@ -293,6 +293,7 @@  struct lan966x_port {
 	struct sk_buff_head tx_skbs;
 
 	struct net_device *bond;
+	struct net_device *bond_fix;
 	bool lag_tx_active;
 };
 
@@ -420,6 +421,8 @@  int lan966x_lag_port_join(struct lan966x_port *port,
 			  struct net_device *bond,
 			  struct netlink_ext_ack *extack);
 void lan966x_lag_port_leave(struct lan966x_port *port, struct net_device *bond);
+void lan966x_lag_port_down(struct lan966x_port *port);
+void lan966x_lag_port_up(struct lan966x_port *port);
 int lan966x_lag_port_prechangeupper(struct net_device *dev,
 				    struct netdev_notifier_changeupper_info *info);
 int lan966x_lag_port_changelowerstate(struct net_device *dev,
diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_port.c b/drivers/net/ethernet/microchip/lan966x/lan966x_port.c
index f141644e4372..e99478a443cb 100644
--- a/drivers/net/ethernet/microchip/lan966x/lan966x_port.c
+++ b/drivers/net/ethernet/microchip/lan966x/lan966x_port.c
@@ -274,11 +274,17 @@  static void lan966x_port_link_up(struct lan966x_port *port)
 void lan966x_port_config_down(struct lan966x_port *port)
 {
 	lan966x_port_link_down(port);
+
+	if (port->bond)
+		lan966x_lag_port_down(port);
 }
 
 void lan966x_port_config_up(struct lan966x_port *port)
 {
 	lan966x_port_link_up(port);
+
+	if (port->bond_fix)
+		lan966x_lag_port_up(port);
 }
 
 void lan966x_port_status_get(struct lan966x_port *port,