net: marvell: prestera: do not propagate netdev events to prestera_switchdev.c

Replace prestera_bridge_port_event(...) by
prestera_bridge_port_join(...) and prestera_bridge_port_leave().

It simplifies the code by reading netdev event specific handling only
once in prestera_main.c

Signed-off-by: Vadym Kochan <vkochan@marvell.com>
CC: Vladimir Oltean <olteanv@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Vadym Kochan 2021-06-10 18:43:10 +03:00 committed by David S. Miller
parent 3d5048cc54
commit 82bbaa05bf
3 changed files with 19 additions and 37 deletions

View File

@ -509,6 +509,7 @@ static int prestera_netdev_port_event(struct net_device *dev,
unsigned long event, void *ptr)
{
struct netdev_notifier_changeupper_info *info = ptr;
struct prestera_port *port = netdev_priv(dev);
struct netlink_ext_ack *extack;
struct net_device *upper;
@ -532,8 +533,12 @@ static int prestera_netdev_port_event(struct net_device *dev,
break;
case NETDEV_CHANGEUPPER:
if (netif_is_bridge_master(upper))
return prestera_bridge_port_event(dev, event, ptr);
if (netif_is_bridge_master(upper)) {
if (info->linking)
return prestera_bridge_port_join(upper, port);
else
prestera_bridge_port_leave(upper, port);
}
break;
}

View File

@ -422,17 +422,17 @@ err_port_flood_set:
return err;
}
static int prestera_port_bridge_join(struct prestera_port *port,
struct net_device *upper)
int prestera_bridge_port_join(struct net_device *br_dev,
struct prestera_port *port)
{
struct prestera_switchdev *swdev = port->sw->swdev;
struct prestera_bridge_port *br_port;
struct prestera_bridge *bridge;
int err;
bridge = prestera_bridge_by_dev(swdev, upper);
bridge = prestera_bridge_by_dev(swdev, br_dev);
if (!bridge) {
bridge = prestera_bridge_create(swdev, upper);
bridge = prestera_bridge_create(swdev, br_dev);
if (IS_ERR(bridge))
return PTR_ERR(bridge);
}
@ -505,14 +505,14 @@ static int prestera_port_vid_stp_set(struct prestera_port *port, u16 vid,
return prestera_hw_vlan_port_stp_set(port, vid, hw_state);
}
static void prestera_port_bridge_leave(struct prestera_port *port,
struct net_device *upper)
void prestera_bridge_port_leave(struct net_device *br_dev,
struct prestera_port *port)
{
struct prestera_switchdev *swdev = port->sw->swdev;
struct prestera_bridge_port *br_port;
struct prestera_bridge *bridge;
bridge = prestera_bridge_by_dev(swdev, upper);
bridge = prestera_bridge_by_dev(swdev, br_dev);
if (!bridge)
return;
@ -533,32 +533,6 @@ static void prestera_port_bridge_leave(struct prestera_port *port,
prestera_bridge_port_put(br_port);
}
int prestera_bridge_port_event(struct net_device *dev, unsigned long event,
void *ptr)
{
struct netdev_notifier_changeupper_info *info = ptr;
struct prestera_port *port;
struct net_device *upper;
int err;
port = netdev_priv(dev);
upper = info->upper_dev;
switch (event) {
case NETDEV_CHANGEUPPER:
if (info->linking) {
err = prestera_port_bridge_join(port, upper);
if (err)
return err;
} else {
prestera_port_bridge_leave(port, upper);
}
break;
}
return 0;
}
static int prestera_port_attr_br_flags_set(struct prestera_port *port,
struct net_device *dev,
struct switchdev_brport_flags flags)

View File

@ -7,7 +7,10 @@
int prestera_switchdev_init(struct prestera_switch *sw);
void prestera_switchdev_fini(struct prestera_switch *sw);
int prestera_bridge_port_event(struct net_device *dev, unsigned long event,
void *ptr);
int prestera_bridge_port_join(struct net_device *br_dev,
struct prestera_port *port);
void prestera_bridge_port_leave(struct net_device *br_dev,
struct prestera_port *port);
#endif /* _PRESTERA_SWITCHDEV_H_ */