]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net: lan966x: Extend FDB to support also lag
authorHoratiu Vultur <horatiu.vultur@microchip.com>
Wed, 17 Aug 2022 19:34:48 +0000 (21:34 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 22 Aug 2022 13:00:54 +0000 (14:00 +0100)
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/microchip/lan966x/lan966x_fdb.c
drivers/net/ethernet/microchip/lan966x/lan966x_switchdev.c

index 5142e7c0de3124c2fe33d5274ca5c403ee01435e..2ea263e893ee64483ddbd14c53e1b75a40b6ec05 100644 (file)
@@ -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);
index 5bf574111bce611fbf474eb4826afd729282a281..1c88120eb291a2bc8efc7982c09af4fab5975c0e 100644 (file)
@@ -348,6 +348,7 @@ int lan966x_port_prechangeupper(struct net_device *dev,
                        return err;
 
                switchdev_bridge_port_unoffload(brport_dev, port, NULL, NULL);
+               lan966x_fdb_flush_workqueue(port->lan966x);
        }
 
        return err;