Skip to content

Commit 66a5763

Browse files
idoschdavem330
authored andcommitted
mlxsw: spectrum_router: Demultiplex FIB event based on family
The FIB notification block currently only handles IPv4 events, but we want to start handling IPv6 events soon, so lay the groundwork now. Do that by preparing the work item and process it according to the notified address family. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a460aa8 commit 66a5763

File tree

1 file changed

+44
-21
lines changed

1 file changed

+44
-21
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3040,7 +3040,7 @@ struct mlxsw_sp_fib_event_work {
30403040
unsigned long event;
30413041
};
30423042

3043-
static void mlxsw_sp_router_fib_event_work(struct work_struct *work)
3043+
static void mlxsw_sp_router_fib4_event_work(struct work_struct *work)
30443044
{
30453045
struct mlxsw_sp_fib_event_work *fib_work =
30463046
container_of(work, struct mlxsw_sp_fib_event_work, work);
@@ -3085,6 +3085,42 @@ static void mlxsw_sp_router_fib_event_work(struct work_struct *work)
30853085
kfree(fib_work);
30863086
}
30873087

3088+
static void mlxsw_sp_router_fib6_event_work(struct work_struct *work)
3089+
{
3090+
}
3091+
3092+
static void mlxsw_sp_router_fib4_event(struct mlxsw_sp_fib_event_work *fib_work,
3093+
struct fib_notifier_info *info)
3094+
{
3095+
switch (fib_work->event) {
3096+
case FIB_EVENT_ENTRY_REPLACE: /* fall through */
3097+
case FIB_EVENT_ENTRY_APPEND: /* fall through */
3098+
case FIB_EVENT_ENTRY_ADD: /* fall through */
3099+
case FIB_EVENT_ENTRY_DEL:
3100+
memcpy(&fib_work->fen_info, info, sizeof(fib_work->fen_info));
3101+
/* Take referece on fib_info to prevent it from being
3102+
* freed while work is queued. Release it afterwards.
3103+
*/
3104+
fib_info_hold(fib_work->fen_info.fi);
3105+
break;
3106+
case FIB_EVENT_RULE_ADD: /* fall through */
3107+
case FIB_EVENT_RULE_DEL:
3108+
memcpy(&fib_work->fr_info, info, sizeof(fib_work->fr_info));
3109+
fib_rule_get(fib_work->fr_info.rule);
3110+
break;
3111+
case FIB_EVENT_NH_ADD: /* fall through */
3112+
case FIB_EVENT_NH_DEL:
3113+
memcpy(&fib_work->fnh_info, info, sizeof(fib_work->fnh_info));
3114+
fib_info_hold(fib_work->fnh_info.fib_nh->nh_parent);
3115+
break;
3116+
}
3117+
}
3118+
3119+
static void mlxsw_sp_router_fib6_event(struct mlxsw_sp_fib_event_work *fib_work,
3120+
struct fib_notifier_info *info)
3121+
{
3122+
}
3123+
30883124
/* Called with rcu_read_lock() */
30893125
static int mlxsw_sp_router_fib_event(struct notifier_block *nb,
30903126
unsigned long event, void *ptr)
@@ -3100,31 +3136,18 @@ static int mlxsw_sp_router_fib_event(struct notifier_block *nb,
31003136
if (WARN_ON(!fib_work))
31013137
return NOTIFY_BAD;
31023138

3103-
INIT_WORK(&fib_work->work, mlxsw_sp_router_fib_event_work);
31043139
router = container_of(nb, struct mlxsw_sp_router, fib_nb);
31053140
fib_work->mlxsw_sp = router->mlxsw_sp;
31063141
fib_work->event = event;
31073142

3108-
switch (event) {
3109-
case FIB_EVENT_ENTRY_REPLACE: /* fall through */
3110-
case FIB_EVENT_ENTRY_APPEND: /* fall through */
3111-
case FIB_EVENT_ENTRY_ADD: /* fall through */
3112-
case FIB_EVENT_ENTRY_DEL:
3113-
memcpy(&fib_work->fen_info, ptr, sizeof(fib_work->fen_info));
3114-
/* Take referece on fib_info to prevent it from being
3115-
* freed while work is queued. Release it afterwards.
3116-
*/
3117-
fib_info_hold(fib_work->fen_info.fi);
3143+
switch (info->family) {
3144+
case AF_INET:
3145+
INIT_WORK(&fib_work->work, mlxsw_sp_router_fib4_event_work);
3146+
mlxsw_sp_router_fib4_event(fib_work, info);
31183147
break;
3119-
case FIB_EVENT_RULE_ADD: /* fall through */
3120-
case FIB_EVENT_RULE_DEL:
3121-
memcpy(&fib_work->fr_info, ptr, sizeof(fib_work->fr_info));
3122-
fib_rule_get(fib_work->fr_info.rule);
3123-
break;
3124-
case FIB_EVENT_NH_ADD: /* fall through */
3125-
case FIB_EVENT_NH_DEL:
3126-
memcpy(&fib_work->fnh_info, ptr, sizeof(fib_work->fnh_info));
3127-
fib_info_hold(fib_work->fnh_info.fib_nh->nh_parent);
3148+
case AF_INET6:
3149+
INIT_WORK(&fib_work->work, mlxsw_sp_router_fib6_event_work);
3150+
mlxsw_sp_router_fib6_event(fib_work, info);
31283151
break;
31293152
}
31303153

0 commit comments

Comments
 (0)