mlxsw: spectrum_router: Embed netevent notifier block in router struct
authorIdo Schimmel <idosch@mellanox.com>
Thu, 2 Nov 2017 16:14:06 +0000 (17:14 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 3 Nov 2017 06:40:41 +0000 (15:40 +0900)
We are going to need to respond to netevents notifying us about
multipath hash updates by configuring the device's hash parameters.

Embed the netevent notifier in the router struct so that we could
retrieve it upon notifications and use it to configure the device.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Reviewed-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.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 3f4be9556e56fe18fb15687091135106a3cabad7..52f38b4806695e7e2fe1b67f27c1591c55f01276 100644 (file)
@@ -4574,10 +4574,6 @@ static struct notifier_block mlxsw_sp_inet6addr_nb __read_mostly = {
        .notifier_call = mlxsw_sp_inet6addr_event,
 };
 
-static struct notifier_block mlxsw_sp_router_netevent_nb __read_mostly = {
-       .notifier_call = mlxsw_sp_router_netevent_event,
-};
-
 static const struct pci_device_id mlxsw_sp_pci_id_table[] = {
        {PCI_VDEVICE(MELLANOX, PCI_DEVICE_ID_MELLANOX_SPECTRUM), 0},
        {0, },
@@ -4596,7 +4592,6 @@ static int __init mlxsw_sp_module_init(void)
        register_inetaddr_notifier(&mlxsw_sp_inetaddr_nb);
        register_inet6addr_validator_notifier(&mlxsw_sp_inet6addr_valid_nb);
        register_inet6addr_notifier(&mlxsw_sp_inet6addr_nb);
-       register_netevent_notifier(&mlxsw_sp_router_netevent_nb);
 
        err = mlxsw_core_driver_register(&mlxsw_sp_driver);
        if (err)
@@ -4611,7 +4606,6 @@ static int __init mlxsw_sp_module_init(void)
 err_pci_driver_register:
        mlxsw_core_driver_unregister(&mlxsw_sp_driver);
 err_core_driver_register:
-       unregister_netevent_notifier(&mlxsw_sp_router_netevent_nb);
        unregister_inet6addr_notifier(&mlxsw_sp_inet6addr_nb);
        unregister_inet6addr_validator_notifier(&mlxsw_sp_inet6addr_valid_nb);
        unregister_inetaddr_notifier(&mlxsw_sp_inetaddr_nb);
@@ -4623,7 +4617,6 @@ static void __exit mlxsw_sp_module_exit(void)
 {
        mlxsw_pci_driver_unregister(&mlxsw_sp_pci_driver);
        mlxsw_core_driver_unregister(&mlxsw_sp_driver);
-       unregister_netevent_notifier(&mlxsw_sp_router_netevent_nb);
        unregister_inet6addr_notifier(&mlxsw_sp_inet6addr_nb);
        unregister_inet6addr_validator_notifier(&mlxsw_sp_inet6addr_valid_nb);
        unregister_inetaddr_notifier(&mlxsw_sp_inetaddr_nb);
index aa0cefb25e186727878b7bcee7390ccb70132999..b2393bb8cef9c48e687b4d2e00c61b5e344b29d4 100644 (file)
@@ -385,8 +385,6 @@ static inline void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port)
 /* spectrum_router.c */
 int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp);
 void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp);
-int mlxsw_sp_router_netevent_event(struct notifier_block *unused,
-                                  unsigned long event, void *ptr);
 int mlxsw_sp_netdevice_router_port_event(struct net_device *dev);
 int mlxsw_sp_inetaddr_event(struct notifier_block *unused,
                            unsigned long event, void *ptr);
index 9fe4cdb231899fef9bf04f9581891ce75f7ab74a..d49c1c92a0fa45aa1170f7f06f3c414987283b50 100644 (file)
@@ -96,6 +96,7 @@ struct mlxsw_sp_router {
        struct list_head ipip_list;
        bool aborted;
        struct notifier_block fib_nb;
+       struct notifier_block netevent_nb;
        const struct mlxsw_sp_rif_ops **rif_ops_arr;
        const struct mlxsw_sp_ipip_ops **ipip_ops_arr;
 };
@@ -2076,8 +2077,8 @@ out:
        kfree(neigh_work);
 }
 
-int mlxsw_sp_router_netevent_event(struct notifier_block *unused,
-                                  unsigned long event, void *ptr)
+static int mlxsw_sp_router_netevent_event(struct notifier_block *unused,
+                                         unsigned long event, void *ptr)
 {
        struct mlxsw_sp_neigh_event_work *neigh_work;
        struct mlxsw_sp_port *mlxsw_sp_port;
@@ -6720,6 +6721,12 @@ int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp)
        if (err)
                goto err_neigh_init;
 
+       mlxsw_sp->router->netevent_nb.notifier_call =
+               mlxsw_sp_router_netevent_event;
+       err = register_netevent_notifier(&mlxsw_sp->router->netevent_nb);
+       if (err)
+               goto err_register_netevent_notifier;
+
        mlxsw_sp->router->fib_nb.notifier_call = mlxsw_sp_router_fib_event;
        err = register_fib_notifier(&mlxsw_sp->router->fib_nb,
                                    mlxsw_sp_router_fib_dump_flush);
@@ -6729,6 +6736,8 @@ int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp)
        return 0;
 
 err_register_fib_notifier:
+       unregister_netevent_notifier(&mlxsw_sp->router->netevent_nb);
+err_register_netevent_notifier:
        mlxsw_sp_neigh_fini(mlxsw_sp);
 err_neigh_init:
        mlxsw_sp_vrs_fini(mlxsw_sp);
@@ -6754,6 +6763,7 @@ err_router_init:
 void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp)
 {
        unregister_fib_notifier(&mlxsw_sp->router->fib_nb);
+       unregister_netevent_notifier(&mlxsw_sp->router->netevent_nb);
        mlxsw_sp_neigh_fini(mlxsw_sp);
        mlxsw_sp_vrs_fini(mlxsw_sp);
        mlxsw_sp_mr_fini(mlxsw_sp);