Commit e6980b57 authored by Casper Andersson's avatar Casper Andersson Committed by David S. Miller

net: sparx5: Use vid 1 when bridge default vid 0 to avoid collision

Standalone ports use vid 0. Let the bridge use vid 1 when
"vlan_default_pvid 0" is set to avoid collisions. Since no
VLAN is created when default pvid is 0 this is set
at "PORT_ATTR_SET" and handled in the Switchdev fdb handler.
Signed-off-by: default avatarCasper Andersson <casper.casan@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b8f7544a
...@@ -102,6 +102,11 @@ static int sparx5_port_attr_set(struct net_device *dev, const void *ctx, ...@@ -102,6 +102,11 @@ static int sparx5_port_attr_set(struct net_device *dev, const void *ctx,
sparx5_port_attr_ageing_set(port, attr->u.ageing_time); sparx5_port_attr_ageing_set(port, attr->u.ageing_time);
break; break;
case SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING: case SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING:
/* Used PVID 1 when default_pvid is 0, to avoid
* collision with non-bridged ports.
*/
if (port->pvid == 0)
port->pvid = 1;
port->vlan_aware = attr->u.vlan_filtering; port->vlan_aware = attr->u.vlan_filtering;
sparx5_vlan_port_apply(port->sparx5, port); sparx5_vlan_port_apply(port->sparx5, port);
break; break;
...@@ -137,6 +142,9 @@ static int sparx5_port_bridge_join(struct sparx5_port *port, ...@@ -137,6 +142,9 @@ static int sparx5_port_bridge_join(struct sparx5_port *port,
if (err) if (err)
goto err_switchdev_offload; goto err_switchdev_offload;
/* Remove standalone port entry */
sparx5_mact_forget(sparx5, ndev->dev_addr, 0);
/* Port enters in bridge mode therefor don't need to copy to CPU /* Port enters in bridge mode therefor don't need to copy to CPU
* frames for multicast in case the bridge is not requesting them * frames for multicast in case the bridge is not requesting them
*/ */
...@@ -165,6 +173,9 @@ static void sparx5_port_bridge_leave(struct sparx5_port *port, ...@@ -165,6 +173,9 @@ static void sparx5_port_bridge_leave(struct sparx5_port *port,
port->pvid = NULL_VID; port->pvid = NULL_VID;
port->vid = NULL_VID; port->vid = NULL_VID;
/* Forward frames to CPU */
sparx5_mact_learn(sparx5, PGID_CPU, port->ndev->dev_addr, 0);
/* Port enters in host more therefore restore mc list */ /* Port enters in host more therefore restore mc list */
__dev_mc_sync(port->ndev, sparx5_mc_sync, sparx5_mc_unsync); __dev_mc_sync(port->ndev, sparx5_mc_sync, sparx5_mc_unsync);
} }
...@@ -249,6 +260,7 @@ static void sparx5_switchdev_bridge_fdb_event_work(struct work_struct *work) ...@@ -249,6 +260,7 @@ static void sparx5_switchdev_bridge_fdb_event_work(struct work_struct *work)
struct sparx5_port *port; struct sparx5_port *port;
struct sparx5 *sparx5; struct sparx5 *sparx5;
bool host_addr; bool host_addr;
u16 vid;
rtnl_lock(); rtnl_lock();
if (!sparx5_netdevice_check(dev)) { if (!sparx5_netdevice_check(dev)) {
...@@ -262,17 +274,25 @@ static void sparx5_switchdev_bridge_fdb_event_work(struct work_struct *work) ...@@ -262,17 +274,25 @@ static void sparx5_switchdev_bridge_fdb_event_work(struct work_struct *work)
fdb_info = &switchdev_work->fdb_info; fdb_info = &switchdev_work->fdb_info;
/* Used PVID 1 when default_pvid is 0, to avoid
* collision with non-bridged ports.
*/
if (fdb_info->vid == 0)
vid = 1;
else
vid = fdb_info->vid;
switch (switchdev_work->event) { switch (switchdev_work->event) {
case SWITCHDEV_FDB_ADD_TO_DEVICE: case SWITCHDEV_FDB_ADD_TO_DEVICE:
if (host_addr) if (host_addr)
sparx5_add_mact_entry(sparx5, dev, PGID_CPU, sparx5_add_mact_entry(sparx5, dev, PGID_CPU,
fdb_info->addr, fdb_info->vid); fdb_info->addr, vid);
else else
sparx5_add_mact_entry(sparx5, port->ndev, port->portno, sparx5_add_mact_entry(sparx5, port->ndev, port->portno,
fdb_info->addr, fdb_info->vid); fdb_info->addr, vid);
break; break;
case SWITCHDEV_FDB_DEL_TO_DEVICE: case SWITCHDEV_FDB_DEL_TO_DEVICE:
sparx5_del_mact_entry(sparx5, fdb_info->addr, fdb_info->vid); sparx5_del_mact_entry(sparx5, fdb_info->addr, vid);
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