Commit e9ba0fbc authored by Ido Schimmel's avatar Ido Schimmel Committed by David S. Miller

bridge: switchdev: Allow clearing FDB entry offload indication

Currently, an FDB entry only ceases being offloaded when it is deleted.
This changes with VxLAN encapsulation.

Devices capable of performing VxLAN encapsulation usually have only one
FDB table, unlike the software data path which has two - one in the
bridge driver and another in the VxLAN driver.

Therefore, bridge FDB entries pointing to a VxLAN device are only
offloaded if there is a corresponding entry in the VxLAN FDB.

Allow clearing the offload indication in case the corresponding entry
was deleted from the VxLAN FDB.
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Reviewed-by: default avatarPetr Machata <petrm@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 045a5a99
...@@ -2090,12 +2090,13 @@ void mlxsw_sp_port_bridge_leave(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -2090,12 +2090,13 @@ void mlxsw_sp_port_bridge_leave(struct mlxsw_sp_port *mlxsw_sp_port,
static void static void
mlxsw_sp_fdb_call_notifiers(enum switchdev_notifier_type type, mlxsw_sp_fdb_call_notifiers(enum switchdev_notifier_type type,
const char *mac, u16 vid, const char *mac, u16 vid,
struct net_device *dev) struct net_device *dev, bool offloaded)
{ {
struct switchdev_notifier_fdb_info info; struct switchdev_notifier_fdb_info info;
info.addr = mac; info.addr = mac;
info.vid = vid; info.vid = vid;
info.offloaded = offloaded;
call_switchdev_notifiers(type, dev, &info.info); call_switchdev_notifiers(type, dev, &info.info);
} }
...@@ -2147,7 +2148,7 @@ static void mlxsw_sp_fdb_notify_mac_process(struct mlxsw_sp *mlxsw_sp, ...@@ -2147,7 +2148,7 @@ static void mlxsw_sp_fdb_notify_mac_process(struct mlxsw_sp *mlxsw_sp,
if (!do_notification) if (!do_notification)
return; return;
type = adding ? SWITCHDEV_FDB_ADD_TO_BRIDGE : SWITCHDEV_FDB_DEL_TO_BRIDGE; type = adding ? SWITCHDEV_FDB_ADD_TO_BRIDGE : SWITCHDEV_FDB_DEL_TO_BRIDGE;
mlxsw_sp_fdb_call_notifiers(type, mac, vid, bridge_port->dev); mlxsw_sp_fdb_call_notifiers(type, mac, vid, bridge_port->dev, adding);
return; return;
...@@ -2207,7 +2208,7 @@ static void mlxsw_sp_fdb_notify_mac_lag_process(struct mlxsw_sp *mlxsw_sp, ...@@ -2207,7 +2208,7 @@ static void mlxsw_sp_fdb_notify_mac_lag_process(struct mlxsw_sp *mlxsw_sp,
if (!do_notification) if (!do_notification)
return; return;
type = adding ? SWITCHDEV_FDB_ADD_TO_BRIDGE : SWITCHDEV_FDB_DEL_TO_BRIDGE; type = adding ? SWITCHDEV_FDB_ADD_TO_BRIDGE : SWITCHDEV_FDB_DEL_TO_BRIDGE;
mlxsw_sp_fdb_call_notifiers(type, mac, vid, bridge_port->dev); mlxsw_sp_fdb_call_notifiers(type, mac, vid, bridge_port->dev, adding);
return; return;
...@@ -2312,7 +2313,7 @@ static void mlxsw_sp_switchdev_bridge_fdb_event_work(struct work_struct *work) ...@@ -2312,7 +2313,7 @@ static void mlxsw_sp_switchdev_bridge_fdb_event_work(struct work_struct *work)
break; break;
mlxsw_sp_fdb_call_notifiers(SWITCHDEV_FDB_OFFLOADED, mlxsw_sp_fdb_call_notifiers(SWITCHDEV_FDB_OFFLOADED,
fdb_info->addr, fdb_info->addr,
fdb_info->vid, dev); fdb_info->vid, dev, true);
break; break;
case SWITCHDEV_FDB_DEL_TO_DEVICE: case SWITCHDEV_FDB_DEL_TO_DEVICE:
fdb_info = &switchdev_work->fdb_info; fdb_info = &switchdev_work->fdb_info;
......
...@@ -2728,6 +2728,7 @@ rocker_fdb_offload_notify(struct rocker_port *rocker_port, ...@@ -2728,6 +2728,7 @@ rocker_fdb_offload_notify(struct rocker_port *rocker_port,
info.addr = recv_info->addr; info.addr = recv_info->addr;
info.vid = recv_info->vid; info.vid = recv_info->vid;
info.offloaded = true;
call_switchdev_notifiers(SWITCHDEV_FDB_OFFLOADED, call_switchdev_notifiers(SWITCHDEV_FDB_OFFLOADED,
rocker_port->dev, &info.info); rocker_port->dev, &info.info);
} }
......
...@@ -159,7 +159,8 @@ struct switchdev_notifier_fdb_info { ...@@ -159,7 +159,8 @@ struct switchdev_notifier_fdb_info {
struct switchdev_notifier_info info; /* must be first */ struct switchdev_notifier_info info; /* must be first */
const unsigned char *addr; const unsigned char *addr;
u16 vid; u16 vid;
bool added_by_user; u8 added_by_user:1,
offloaded:1;
}; };
static inline struct net_device * static inline struct net_device *
......
...@@ -151,7 +151,7 @@ static int br_switchdev_event(struct notifier_block *unused, ...@@ -151,7 +151,7 @@ static int br_switchdev_event(struct notifier_block *unused,
break; break;
} }
br_fdb_offloaded_set(br, p, fdb_info->addr, br_fdb_offloaded_set(br, p, fdb_info->addr,
fdb_info->vid); fdb_info->vid, true);
break; break;
case SWITCHDEV_FDB_DEL_TO_BRIDGE: case SWITCHDEV_FDB_DEL_TO_BRIDGE:
fdb_info = ptr; fdb_info = ptr;
...@@ -163,7 +163,7 @@ static int br_switchdev_event(struct notifier_block *unused, ...@@ -163,7 +163,7 @@ static int br_switchdev_event(struct notifier_block *unused,
case SWITCHDEV_FDB_OFFLOADED: case SWITCHDEV_FDB_OFFLOADED:
fdb_info = ptr; fdb_info = ptr;
br_fdb_offloaded_set(br, p, fdb_info->addr, br_fdb_offloaded_set(br, p, fdb_info->addr,
fdb_info->vid); fdb_info->vid, fdb_info->offloaded);
break; break;
} }
......
...@@ -1152,7 +1152,7 @@ int br_fdb_external_learn_del(struct net_bridge *br, struct net_bridge_port *p, ...@@ -1152,7 +1152,7 @@ int br_fdb_external_learn_del(struct net_bridge *br, struct net_bridge_port *p,
} }
void br_fdb_offloaded_set(struct net_bridge *br, struct net_bridge_port *p, void br_fdb_offloaded_set(struct net_bridge *br, struct net_bridge_port *p,
const unsigned char *addr, u16 vid) const unsigned char *addr, u16 vid, bool offloaded)
{ {
struct net_bridge_fdb_entry *fdb; struct net_bridge_fdb_entry *fdb;
...@@ -1160,7 +1160,7 @@ void br_fdb_offloaded_set(struct net_bridge *br, struct net_bridge_port *p, ...@@ -1160,7 +1160,7 @@ void br_fdb_offloaded_set(struct net_bridge *br, struct net_bridge_port *p,
fdb = br_fdb_find(br, addr, vid); fdb = br_fdb_find(br, addr, vid);
if (fdb) if (fdb)
fdb->offloaded = 1; fdb->offloaded = offloaded;
spin_unlock_bh(&br->hash_lock); spin_unlock_bh(&br->hash_lock);
} }
...@@ -574,7 +574,7 @@ int br_fdb_external_learn_del(struct net_bridge *br, struct net_bridge_port *p, ...@@ -574,7 +574,7 @@ int br_fdb_external_learn_del(struct net_bridge *br, struct net_bridge_port *p,
const unsigned char *addr, u16 vid, const unsigned char *addr, u16 vid,
bool swdev_notify); bool swdev_notify);
void br_fdb_offloaded_set(struct net_bridge *br, struct net_bridge_port *p, void br_fdb_offloaded_set(struct net_bridge *br, struct net_bridge_port *p,
const unsigned char *addr, u16 vid); const unsigned char *addr, u16 vid, bool offloaded);
/* br_forward.c */ /* br_forward.c */
enum br_pkt_type { enum br_pkt_type {
......
...@@ -103,7 +103,7 @@ int br_switchdev_set_port_flag(struct net_bridge_port *p, ...@@ -103,7 +103,7 @@ int br_switchdev_set_port_flag(struct net_bridge_port *p,
static void static void
br_switchdev_fdb_call_notifiers(bool adding, const unsigned char *mac, br_switchdev_fdb_call_notifiers(bool adding, const unsigned char *mac,
u16 vid, struct net_device *dev, u16 vid, struct net_device *dev,
bool added_by_user) bool added_by_user, bool offloaded)
{ {
struct switchdev_notifier_fdb_info info; struct switchdev_notifier_fdb_info info;
unsigned long notifier_type; unsigned long notifier_type;
...@@ -111,6 +111,7 @@ br_switchdev_fdb_call_notifiers(bool adding, const unsigned char *mac, ...@@ -111,6 +111,7 @@ br_switchdev_fdb_call_notifiers(bool adding, const unsigned char *mac,
info.addr = mac; info.addr = mac;
info.vid = vid; info.vid = vid;
info.added_by_user = added_by_user; info.added_by_user = added_by_user;
info.offloaded = offloaded;
notifier_type = adding ? SWITCHDEV_FDB_ADD_TO_DEVICE : SWITCHDEV_FDB_DEL_TO_DEVICE; notifier_type = adding ? SWITCHDEV_FDB_ADD_TO_DEVICE : SWITCHDEV_FDB_DEL_TO_DEVICE;
call_switchdev_notifiers(notifier_type, dev, &info.info); call_switchdev_notifiers(notifier_type, dev, &info.info);
} }
...@@ -126,13 +127,15 @@ br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb, int type) ...@@ -126,13 +127,15 @@ br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb, int type)
br_switchdev_fdb_call_notifiers(false, fdb->key.addr.addr, br_switchdev_fdb_call_notifiers(false, fdb->key.addr.addr,
fdb->key.vlan_id, fdb->key.vlan_id,
fdb->dst->dev, fdb->dst->dev,
fdb->added_by_user); fdb->added_by_user,
fdb->offloaded);
break; break;
case RTM_NEWNEIGH: case RTM_NEWNEIGH:
br_switchdev_fdb_call_notifiers(true, fdb->key.addr.addr, br_switchdev_fdb_call_notifiers(true, fdb->key.addr.addr,
fdb->key.vlan_id, fdb->key.vlan_id,
fdb->dst->dev, fdb->dst->dev,
fdb->added_by_user); fdb->added_by_user,
fdb->offloaded);
break; break;
} }
} }
......
...@@ -1478,6 +1478,7 @@ static void dsa_slave_switchdev_event_work(struct work_struct *work) ...@@ -1478,6 +1478,7 @@ static void dsa_slave_switchdev_event_work(struct work_struct *work)
netdev_dbg(dev, "fdb add failed err=%d\n", err); netdev_dbg(dev, "fdb add failed err=%d\n", err);
break; break;
} }
fdb_info->offloaded = true;
call_switchdev_notifiers(SWITCHDEV_FDB_OFFLOADED, dev, call_switchdev_notifiers(SWITCHDEV_FDB_OFFLOADED, dev,
&fdb_info->info); &fdb_info->info);
break; break;
......
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