Commit c30f5d01 authored by Petr Machata's avatar Petr Machata Committed by David S. Miller

mlxsw: spectrum: Move netdevice NB to struct mlxsw_sp

So far, all netdevice notifications that the driver cared about were
related to its own ports, and mlxsw_sp could be retrieved from the
netdevice's private data. For IP-in-IP offloading however, the driver
cares about events on foreign netdevices, and getting at mlxsw_sp or
router data structures from the handler is inconvenient.

Therefore move the netdevice notifier blocks from global scope to struct
mlxsw_sp to allow retrieval from the notifier block pointer itself.
Signed-off-by: default avatarPetr Machata <petrm@mellanox.com>
Reviewed-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 36c0a9df
...@@ -3667,6 +3667,9 @@ static int mlxsw_sp_basic_trap_groups_set(struct mlxsw_core *mlxsw_core) ...@@ -3667,6 +3667,9 @@ static int mlxsw_sp_basic_trap_groups_set(struct mlxsw_core *mlxsw_core)
return mlxsw_reg_write(mlxsw_core, MLXSW_REG(htgt), htgt_pl); return mlxsw_reg_write(mlxsw_core, MLXSW_REG(htgt), htgt_pl);
} }
static int mlxsw_sp_netdevice_event(struct notifier_block *unused,
unsigned long event, void *ptr);
static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core, static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core,
const struct mlxsw_bus_info *mlxsw_bus_info) const struct mlxsw_bus_info *mlxsw_bus_info)
{ {
...@@ -3736,6 +3739,16 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core, ...@@ -3736,6 +3739,16 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core,
goto err_router_init; goto err_router_init;
} }
/* Initialize netdevice notifier after router is initialized, so that
* the event handler can use router structures.
*/
mlxsw_sp->netdevice_nb.notifier_call = mlxsw_sp_netdevice_event;
err = register_netdevice_notifier(&mlxsw_sp->netdevice_nb);
if (err) {
dev_err(mlxsw_sp->bus_info->dev, "Failed to register netdev notifier\n");
goto err_netdev_notifier;
}
err = mlxsw_sp_span_init(mlxsw_sp); err = mlxsw_sp_span_init(mlxsw_sp);
if (err) { if (err) {
dev_err(mlxsw_sp->bus_info->dev, "Failed to init span system\n"); dev_err(mlxsw_sp->bus_info->dev, "Failed to init span system\n");
...@@ -3769,6 +3782,8 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core, ...@@ -3769,6 +3782,8 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core,
err_acl_init: err_acl_init:
mlxsw_sp_span_fini(mlxsw_sp); mlxsw_sp_span_fini(mlxsw_sp);
err_span_init: err_span_init:
unregister_netdevice_notifier(&mlxsw_sp->netdevice_nb);
err_netdev_notifier:
mlxsw_sp_router_fini(mlxsw_sp); mlxsw_sp_router_fini(mlxsw_sp);
err_router_init: err_router_init:
mlxsw_sp_afa_fini(mlxsw_sp); mlxsw_sp_afa_fini(mlxsw_sp);
...@@ -3795,6 +3810,7 @@ static void mlxsw_sp_fini(struct mlxsw_core *mlxsw_core) ...@@ -3795,6 +3810,7 @@ static void mlxsw_sp_fini(struct mlxsw_core *mlxsw_core)
mlxsw_sp_dpipe_fini(mlxsw_sp); mlxsw_sp_dpipe_fini(mlxsw_sp);
mlxsw_sp_acl_fini(mlxsw_sp); mlxsw_sp_acl_fini(mlxsw_sp);
mlxsw_sp_span_fini(mlxsw_sp); mlxsw_sp_span_fini(mlxsw_sp);
unregister_netdevice_notifier(&mlxsw_sp->netdevice_nb);
mlxsw_sp_router_fini(mlxsw_sp); mlxsw_sp_router_fini(mlxsw_sp);
mlxsw_sp_afa_fini(mlxsw_sp); mlxsw_sp_afa_fini(mlxsw_sp);
mlxsw_sp_counter_pool_fini(mlxsw_sp); mlxsw_sp_counter_pool_fini(mlxsw_sp);
...@@ -4501,10 +4517,6 @@ static int mlxsw_sp_netdevice_event(struct notifier_block *unused, ...@@ -4501,10 +4517,6 @@ static int mlxsw_sp_netdevice_event(struct notifier_block *unused,
return notifier_from_errno(err); return notifier_from_errno(err);
} }
static struct notifier_block mlxsw_sp_netdevice_nb __read_mostly = {
.notifier_call = mlxsw_sp_netdevice_event,
};
static struct notifier_block mlxsw_sp_inetaddr_nb __read_mostly = { static struct notifier_block mlxsw_sp_inetaddr_nb __read_mostly = {
.notifier_call = mlxsw_sp_inetaddr_event, .notifier_call = mlxsw_sp_inetaddr_event,
.priority = 10, /* Must be called before FIB notifier block */ .priority = 10, /* Must be called before FIB notifier block */
...@@ -4532,7 +4544,6 @@ static int __init mlxsw_sp_module_init(void) ...@@ -4532,7 +4544,6 @@ static int __init mlxsw_sp_module_init(void)
{ {
int err; int err;
register_netdevice_notifier(&mlxsw_sp_netdevice_nb);
register_inetaddr_notifier(&mlxsw_sp_inetaddr_nb); register_inetaddr_notifier(&mlxsw_sp_inetaddr_nb);
register_inet6addr_notifier(&mlxsw_sp_inet6addr_nb); register_inet6addr_notifier(&mlxsw_sp_inet6addr_nb);
register_netevent_notifier(&mlxsw_sp_router_netevent_nb); register_netevent_notifier(&mlxsw_sp_router_netevent_nb);
...@@ -4553,7 +4564,6 @@ static int __init mlxsw_sp_module_init(void) ...@@ -4553,7 +4564,6 @@ static int __init mlxsw_sp_module_init(void)
unregister_netevent_notifier(&mlxsw_sp_router_netevent_nb); unregister_netevent_notifier(&mlxsw_sp_router_netevent_nb);
unregister_inet6addr_notifier(&mlxsw_sp_inet6addr_nb); unregister_inet6addr_notifier(&mlxsw_sp_inet6addr_nb);
unregister_inetaddr_notifier(&mlxsw_sp_inetaddr_nb); unregister_inetaddr_notifier(&mlxsw_sp_inetaddr_nb);
unregister_netdevice_notifier(&mlxsw_sp_netdevice_nb);
return err; return err;
} }
...@@ -4564,7 +4574,6 @@ static void __exit mlxsw_sp_module_exit(void) ...@@ -4564,7 +4574,6 @@ static void __exit mlxsw_sp_module_exit(void)
unregister_netevent_notifier(&mlxsw_sp_router_netevent_nb); unregister_netevent_notifier(&mlxsw_sp_router_netevent_nb);
unregister_inet6addr_notifier(&mlxsw_sp_inet6addr_nb); unregister_inet6addr_notifier(&mlxsw_sp_inet6addr_nb);
unregister_inetaddr_notifier(&mlxsw_sp_inetaddr_nb); unregister_inetaddr_notifier(&mlxsw_sp_inetaddr_nb);
unregister_netdevice_notifier(&mlxsw_sp_netdevice_nb);
} }
module_init(mlxsw_sp_module_init); module_init(mlxsw_sp_module_init);
......
...@@ -161,6 +161,7 @@ struct mlxsw_sp { ...@@ -161,6 +161,7 @@ struct mlxsw_sp {
struct { struct {
DECLARE_BITMAP(usage, MLXSW_SP_KVD_LINEAR_SIZE); DECLARE_BITMAP(usage, MLXSW_SP_KVD_LINEAR_SIZE);
} kvdl; } kvdl;
struct notifier_block netdevice_nb;
struct mlxsw_sp_counter_pool *counter_pool; struct mlxsw_sp_counter_pool *counter_pool;
struct { struct {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment