Commit 9b4ed7d2 authored by Horatiu Vultur's avatar Horatiu Vultur Committed by David S. Miller

net: lan966x: Split lan966x_fdb_event_work

Split the function lan966x_fdb_event_work. One case for when the
orig_dev is a bridge and one case when orig_dev is lan966x port.
This is preparation for lag support. There is no functional change.
Signed-off-by: default avatarHoratiu Vultur <horatiu.vultur@microchip.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7c300735
......@@ -8,6 +8,7 @@ struct lan966x_fdb_event_work {
struct work_struct work;
struct switchdev_notifier_fdb_info fdb_info;
struct net_device *dev;
struct net_device *orig_dev;
struct lan966x *lan966x;
unsigned long event;
};
......@@ -127,21 +128,15 @@ void lan966x_fdb_deinit(struct lan966x *lan966x)
lan966x_fdb_purge_entries(lan966x);
}
static void lan966x_fdb_event_work(struct work_struct *work)
static void lan966x_fdb_port_event_work(struct lan966x_fdb_event_work *fdb_work)
{
struct lan966x_fdb_event_work *fdb_work =
container_of(work, struct lan966x_fdb_event_work, work);
struct switchdev_notifier_fdb_info *fdb_info;
struct net_device *dev = fdb_work->dev;
struct lan966x_port *port;
struct lan966x *lan966x;
int ret;
fdb_info = &fdb_work->fdb_info;
lan966x = fdb_work->lan966x;
if (lan966x_netdevice_check(dev)) {
port = netdev_priv(dev);
port = netdev_priv(fdb_work->orig_dev);
fdb_info = &fdb_work->fdb_info;
switch (fdb_work->event) {
case SWITCHDEV_FDB_ADD_TO_DEVICE:
......@@ -157,9 +152,16 @@ static void lan966x_fdb_event_work(struct work_struct *work)
fdb_info->vid);
break;
}
} else {
if (!netif_is_bridge_master(dev))
goto out;
}
static void lan966x_fdb_bridge_event_work(struct lan966x_fdb_event_work *fdb_work)
{
struct switchdev_notifier_fdb_info *fdb_info;
struct lan966x *lan966x;
int ret;
lan966x = fdb_work->lan966x;
fdb_info = &fdb_work->fdb_info;
/* In case the bridge is called */
switch (fdb_work->event) {
......@@ -190,12 +192,22 @@ static void lan966x_fdb_event_work(struct work_struct *work)
fdb_info->vid);
break;
}
}
}
static void lan966x_fdb_event_work(struct work_struct *work)
{
struct lan966x_fdb_event_work *fdb_work =
container_of(work, struct lan966x_fdb_event_work, work);
if (lan966x_netdevice_check(fdb_work->orig_dev))
lan966x_fdb_port_event_work(fdb_work);
else if (netif_is_bridge_master(fdb_work->orig_dev))
lan966x_fdb_bridge_event_work(fdb_work);
out:
kfree(fdb_work->fdb_info.addr);
dev_put(fdb_work->dev);
dev_put(fdb_work->orig_dev);
kfree(fdb_work);
dev_put(dev);
}
int lan966x_handle_fdb(struct net_device *dev,
......@@ -221,7 +233,8 @@ int lan966x_handle_fdb(struct net_device *dev,
if (!fdb_work)
return -ENOMEM;
fdb_work->dev = orig_dev;
fdb_work->dev = dev;
fdb_work->orig_dev = orig_dev;
fdb_work->lan966x = lan966x;
fdb_work->event = event;
INIT_WORK(&fdb_work->work, lan966x_fdb_event_work);
......@@ -231,6 +244,7 @@ int lan966x_handle_fdb(struct net_device *dev,
goto err_addr_alloc;
ether_addr_copy((u8 *)fdb_work->fdb_info.addr, fdb_info->addr);
dev_hold(dev);
dev_hold(orig_dev);
queue_work(lan966x->fdb_work, &fdb_work->work);
......
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