提交 bdc17fad 编写于 作者: D David S. Miller

Merge branch 'mlxsw-vlan'

Jiri Pirko says:

====================
mlxsw: small driver update

Couple of VLAN-related patches.
====================
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
...@@ -342,14 +342,35 @@ static int mlxsw_sp_port_add_vids(struct net_device *dev, u16 vid_begin, ...@@ -342,14 +342,35 @@ static int mlxsw_sp_port_add_vids(struct net_device *dev, u16 vid_begin,
return err; return err;
} }
static int __mlxsw_sp_port_vlans_set(struct mlxsw_sp_port *mlxsw_sp_port,
u16 vid_begin, u16 vid_end, bool is_member,
bool untagged)
{
u16 vid, vid_e;
int err;
for (vid = vid_begin; vid <= vid_end;
vid += MLXSW_REG_SPVM_REC_MAX_COUNT) {
vid_e = min((u16) (vid + MLXSW_REG_SPVM_REC_MAX_COUNT - 1),
vid_end);
err = mlxsw_sp_port_vlan_set(mlxsw_sp_port, vid, vid_e,
is_member, untagged);
if (err)
return err;
}
return 0;
}
static int __mlxsw_sp_port_vlans_add(struct mlxsw_sp_port *mlxsw_sp_port, static int __mlxsw_sp_port_vlans_add(struct mlxsw_sp_port *mlxsw_sp_port,
u16 vid_begin, u16 vid_end, u16 vid_begin, u16 vid_end,
bool flag_untagged, bool flag_pvid) bool flag_untagged, bool flag_pvid)
{ {
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
struct net_device *dev = mlxsw_sp_port->dev; struct net_device *dev = mlxsw_sp_port->dev;
u16 vid, last_visited_vid, old_pvid;
enum mlxsw_reg_svfa_mt mt; enum mlxsw_reg_svfa_mt mt;
u16 vid, vid_e;
int err; int err;
/* In case this is invoked with BRIDGE_FLAGS_SELF and port is /* In case this is invoked with BRIDGE_FLAGS_SELF and port is
...@@ -377,15 +398,18 @@ static int __mlxsw_sp_port_vlans_add(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -377,15 +398,18 @@ static int __mlxsw_sp_port_vlans_add(struct mlxsw_sp_port *mlxsw_sp_port,
if (err) { if (err) {
netdev_err(dev, "Failed to create FID=VID=%d mapping\n", netdev_err(dev, "Failed to create FID=VID=%d mapping\n",
vid); vid);
return err; goto err_port_vid_to_fid_set;
}
} }
} }
/* Set FID mapping according to port's mode */ /* Set FID mapping according to port's mode */
for (vid = vid_begin; vid <= vid_end; vid++) {
err = mlxsw_sp_port_fid_map(mlxsw_sp_port, vid); err = mlxsw_sp_port_fid_map(mlxsw_sp_port, vid);
if (err) { if (err) {
netdev_err(dev, "Failed to map FID=%d", vid); netdev_err(dev, "Failed to map FID=%d", vid);
return err; last_visited_vid = --vid;
goto err_port_fid_map;
} }
} }
...@@ -393,40 +417,62 @@ static int __mlxsw_sp_port_vlans_add(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -393,40 +417,62 @@ static int __mlxsw_sp_port_vlans_add(struct mlxsw_sp_port *mlxsw_sp_port,
true, false); true, false);
if (err) { if (err) {
netdev_err(dev, "Failed to configure flooding\n"); netdev_err(dev, "Failed to configure flooding\n");
return err; goto err_port_flood_set;
} }
for (vid = vid_begin; vid <= vid_end; err = __mlxsw_sp_port_vlans_set(mlxsw_sp_port, vid_begin, vid_end,
vid += MLXSW_REG_SPVM_REC_MAX_COUNT) { true, flag_untagged);
vid_e = min((u16) (vid + MLXSW_REG_SPVM_REC_MAX_COUNT - 1),
vid_end);
err = mlxsw_sp_port_vlan_set(mlxsw_sp_port, vid, vid_e, true,
flag_untagged);
if (err) { if (err) {
netdev_err(mlxsw_sp_port->dev, "Unable to add VIDs %d-%d\n", netdev_err(dev, "Unable to add VIDs %d-%d\n", vid_begin,
vid, vid_e); vid_end);
return err; goto err_port_vlans_set;
}
} }
vid = vid_begin; old_pvid = mlxsw_sp_port->pvid;
if (flag_pvid && mlxsw_sp_port->pvid != vid) { if (flag_pvid && old_pvid != vid_begin) {
err = mlxsw_sp_port_pvid_set(mlxsw_sp_port, vid); err = mlxsw_sp_port_pvid_set(mlxsw_sp_port, vid_begin);
if (err) { if (err) {
netdev_err(mlxsw_sp_port->dev, "Unable to add PVID %d\n", netdev_err(dev, "Unable to add PVID %d\n", vid_begin);
vid); goto err_port_pvid_set;
return err;
} }
mlxsw_sp_port->pvid = vid; mlxsw_sp_port->pvid = vid_begin;
} }
/* Changing activity bits only if HW operation succeded */ /* Changing activity bits only if HW operation succeded */
for (vid = vid_begin; vid <= vid_end; vid++) for (vid = vid_begin; vid <= vid_end; vid++)
set_bit(vid, mlxsw_sp_port->active_vlans); set_bit(vid, mlxsw_sp_port->active_vlans);
return mlxsw_sp_port_stp_state_set(mlxsw_sp_port, /* STP state change must be done after we set active VLANs */
err = mlxsw_sp_port_stp_state_set(mlxsw_sp_port,
mlxsw_sp_port->stp_state); mlxsw_sp_port->stp_state);
if (err) {
netdev_err(dev, "Failed to set STP state\n");
goto err_port_stp_state_set;
}
return 0;
err_port_vid_to_fid_set:
mlxsw_sp_fid_destroy(mlxsw_sp, vid);
return err;
err_port_stp_state_set:
for (vid = vid_begin; vid <= vid_end; vid++)
clear_bit(vid, mlxsw_sp_port->active_vlans);
if (old_pvid != mlxsw_sp_port->pvid)
mlxsw_sp_port_pvid_set(mlxsw_sp_port, old_pvid);
err_port_pvid_set:
__mlxsw_sp_port_vlans_set(mlxsw_sp_port, vid_begin, vid_end, false,
false);
err_port_vlans_set:
__mlxsw_sp_port_flood_set(mlxsw_sp_port, vid_begin, vid_end, false,
false);
err_port_flood_set:
last_visited_vid = vid_end;
err_port_fid_map:
for (vid = last_visited_vid; vid >= vid_begin; vid--)
mlxsw_sp_port_fid_unmap(mlxsw_sp_port, vid);
return err;
} }
static int mlxsw_sp_port_vlans_add(struct mlxsw_sp_port *mlxsw_sp_port, static int mlxsw_sp_port_vlans_add(struct mlxsw_sp_port *mlxsw_sp_port,
...@@ -532,7 +578,7 @@ static int __mlxsw_sp_port_vlans_del(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -532,7 +578,7 @@ static int __mlxsw_sp_port_vlans_del(struct mlxsw_sp_port *mlxsw_sp_port,
u16 vid_begin, u16 vid_end, bool init) u16 vid_begin, u16 vid_end, bool init)
{ {
struct net_device *dev = mlxsw_sp_port->dev; struct net_device *dev = mlxsw_sp_port->dev;
u16 vid, vid_e; u16 vid, pvid;
int err; int err;
/* In case this is invoked with BRIDGE_FLAGS_SELF and port is /* In case this is invoked with BRIDGE_FLAGS_SELF and port is
...@@ -542,30 +588,23 @@ static int __mlxsw_sp_port_vlans_del(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -542,30 +588,23 @@ static int __mlxsw_sp_port_vlans_del(struct mlxsw_sp_port *mlxsw_sp_port,
if (!init && !mlxsw_sp_port->bridged) if (!init && !mlxsw_sp_port->bridged)
return mlxsw_sp_port_kill_vids(dev, vid_begin, vid_end); return mlxsw_sp_port_kill_vids(dev, vid_begin, vid_end);
for (vid = vid_begin; vid <= vid_end; err = __mlxsw_sp_port_vlans_set(mlxsw_sp_port, vid_begin, vid_end,
vid += MLXSW_REG_SPVM_REC_MAX_COUNT) { false, false);
vid_e = min((u16) (vid + MLXSW_REG_SPVM_REC_MAX_COUNT - 1),
vid_end);
err = mlxsw_sp_port_vlan_set(mlxsw_sp_port, vid, vid_e, false,
false);
if (err) { if (err) {
netdev_err(mlxsw_sp_port->dev, "Unable to del VIDs %d-%d\n", netdev_err(dev, "Unable to del VIDs %d-%d\n", vid_begin,
vid, vid_e); vid_end);
return err; return err;
} }
}
if ((mlxsw_sp_port->pvid >= vid_begin) && pvid = mlxsw_sp_port->pvid;
(mlxsw_sp_port->pvid <= vid_end)) { if (pvid >= vid_begin && pvid <= vid_end && pvid != 1) {
/* Default VLAN is always 1 */ /* Default VLAN is always 1 */
mlxsw_sp_port->pvid = 1; err = mlxsw_sp_port_pvid_set(mlxsw_sp_port, 1);
err = mlxsw_sp_port_pvid_set(mlxsw_sp_port,
mlxsw_sp_port->pvid);
if (err) { if (err) {
netdev_err(mlxsw_sp_port->dev, "Unable to del PVID %d\n", netdev_err(dev, "Unable to del PVID %d\n", pvid);
vid);
return err; return err;
} }
mlxsw_sp_port->pvid = 1;
} }
if (init) if (init)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册