mlxsw: spectrum: Move handling of router events to router code
authorPetr Machata <petrm@nvidia.com>
Sun, 8 May 2022 08:08:18 +0000 (11:08 +0300)
committerDavid S. Miller <davem@davemloft.net>
Sun, 8 May 2022 10:46:20 +0000 (11:46 +0100)
The events NETDEV_PRE_CHANGEADDR, NETDEV_CHANGEADDR and NETDEV_CHANGEMTU
have implications for in-ASIC router interface objects, and as such are
handled in the router module. Move the handling from the central dispatcher
in spectrum.c to the new notifier handler in the router module.

Signed-off-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum.c
drivers/net/ethernet/mellanox/mlxsw/spectrum.h
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c

index 367b9b6..afc03ba 100644 (file)
@@ -5004,18 +5004,6 @@ static int mlxsw_sp_netdevice_vxlan_event(struct mlxsw_sp *mlxsw_sp,
        return 0;
 }
 
-static bool mlxsw_sp_netdevice_event_is_router(unsigned long event)
-{
-       switch (event) {
-       case NETDEV_PRE_CHANGEADDR:
-       case NETDEV_CHANGEADDR:
-       case NETDEV_CHANGEMTU:
-               return true;
-       default:
-               return false;
-       }
-}
-
 static int mlxsw_sp_netdevice_event(struct notifier_block *nb,
                                    unsigned long event, void *ptr)
 {
@@ -5040,8 +5028,6 @@ static int mlxsw_sp_netdevice_event(struct notifier_block *nb,
        else if (mlxsw_sp_netdev_is_ipip_ul(mlxsw_sp, dev))
                err = mlxsw_sp_netdevice_ipip_ul_event(mlxsw_sp, dev,
                                                       event, ptr);
-       else if (mlxsw_sp_netdevice_event_is_router(event))
-               err = mlxsw_sp_netdevice_router_port_event(dev, event, ptr);
        else if (mlxsw_sp_port_dev_check(dev))
                err = mlxsw_sp_netdevice_port_event(dev, dev, event, ptr);
        else if (netif_is_lag_master(dev))
index a20e2a1..983195e 100644 (file)
@@ -718,8 +718,6 @@ union mlxsw_sp_l3addr {
 int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp,
                         struct netlink_ext_ack *extack);
 void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp);
-int mlxsw_sp_netdevice_router_port_event(struct net_device *dev,
-                                        unsigned long event, void *ptr);
 void mlxsw_sp_rif_macvlan_del(struct mlxsw_sp *mlxsw_sp,
                              const struct net_device *macvlan_dev);
 int mlxsw_sp_inetaddr_valid_event(struct notifier_block *unused,
index 01f1020..d5a8307 100644 (file)
@@ -9438,8 +9438,20 @@ mlxsw_sp_netdevice_offload_xstats_cmd(struct mlxsw_sp *mlxsw_sp,
        return err;
 }
 
-int mlxsw_sp_netdevice_router_port_event(struct net_device *dev,
-                                        unsigned long event, void *ptr)
+static bool mlxsw_sp_is_router_event(unsigned long event)
+{
+       switch (event) {
+       case NETDEV_PRE_CHANGEADDR:
+       case NETDEV_CHANGEADDR:
+       case NETDEV_CHANGEMTU:
+               return true;
+       default:
+               return false;
+       }
+}
+
+static int mlxsw_sp_netdevice_router_port_event(struct net_device *dev,
+                                               unsigned long event, void *ptr)
 {
        struct netlink_ext_ack *extack = netdev_notifier_info_to_extack(ptr);
        struct mlxsw_sp *mlxsw_sp;
@@ -9557,6 +9569,8 @@ static int mlxsw_sp_router_netdevice_event(struct notifier_block *nb,
        if (mlxsw_sp_is_offload_xstats_event(event))
                err = mlxsw_sp_netdevice_offload_xstats_cmd(mlxsw_sp, dev,
                                                            event, ptr);
+       else if (mlxsw_sp_is_router_event(event))
+               err = mlxsw_sp_netdevice_router_port_event(dev, event, ptr);
        else if (mlxsw_sp_is_vrf_event(event, ptr))
                err = mlxsw_sp_netdevice_vrf_event(dev, event, ptr);