|
@@ -1468,6 +1468,7 @@ static int _mv88e6xxx_vlan_init(struct dsa_switch *ds, u16 vid,
|
|
struct mv88e6xxx_vtu_stu_entry vlan = {
|
|
struct mv88e6xxx_vtu_stu_entry vlan = {
|
|
.valid = true,
|
|
.valid = true,
|
|
.vid = vid,
|
|
.vid = vid,
|
|
|
|
+ .fid = vid, /* We use one FID per VLAN */
|
|
};
|
|
};
|
|
int i;
|
|
int i;
|
|
|
|
|
|
@@ -1501,22 +1502,10 @@ static int _mv88e6xxx_vlan_init(struct dsa_switch *ds, u16 vid,
|
|
return err;
|
|
return err;
|
|
}
|
|
}
|
|
|
|
|
|
- /* Non-bridged ports and bridge groups use FIDs from 1 to
|
|
|
|
- * num_ports; VLANs use FIDs from num_ports+1 to 4095.
|
|
|
|
- */
|
|
|
|
- vlan.fid = find_next_zero_bit(ps->fid_bitmap, VLAN_N_VID,
|
|
|
|
- ps->num_ports + 1);
|
|
|
|
- if (unlikely(vlan.fid == VLAN_N_VID)) {
|
|
|
|
- pr_err("no more FID available for VLAN %d\n", vid);
|
|
|
|
- return -ENOSPC;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/* Clear all MAC addresses from the new database */
|
|
/* Clear all MAC addresses from the new database */
|
|
err = _mv88e6xxx_atu_flush(ds, vlan.fid, true);
|
|
err = _mv88e6xxx_atu_flush(ds, vlan.fid, true);
|
|
if (err)
|
|
if (err)
|
|
return err;
|
|
return err;
|
|
-
|
|
|
|
- set_bit(vlan.fid, ps->fid_bitmap);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
*entry = vlan;
|
|
*entry = vlan;
|
|
@@ -1556,7 +1545,6 @@ int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port, u16 vid)
|
|
{
|
|
{
|
|
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
|
|
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
|
|
struct mv88e6xxx_vtu_stu_entry vlan;
|
|
struct mv88e6xxx_vtu_stu_entry vlan;
|
|
- bool keep = false;
|
|
|
|
int i, err;
|
|
int i, err;
|
|
|
|
|
|
mutex_lock(&ps->smi_mutex);
|
|
mutex_lock(&ps->smi_mutex);
|
|
@@ -1574,28 +1562,22 @@ int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port, u16 vid)
|
|
vlan.data[port] = GLOBAL_VTU_DATA_MEMBER_TAG_NON_MEMBER;
|
|
vlan.data[port] = GLOBAL_VTU_DATA_MEMBER_TAG_NON_MEMBER;
|
|
|
|
|
|
/* keep the VLAN unless all ports are excluded */
|
|
/* keep the VLAN unless all ports are excluded */
|
|
|
|
+ vlan.valid = false;
|
|
for (i = 0; i < ps->num_ports; ++i) {
|
|
for (i = 0; i < ps->num_ports; ++i) {
|
|
if (dsa_is_cpu_port(ds, i))
|
|
if (dsa_is_cpu_port(ds, i))
|
|
continue;
|
|
continue;
|
|
|
|
|
|
if (vlan.data[i] != GLOBAL_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
|
|
if (vlan.data[i] != GLOBAL_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
|
|
- keep = true;
|
|
|
|
|
|
+ vlan.valid = true;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- vlan.valid = keep;
|
|
|
|
err = _mv88e6xxx_vtu_loadpurge(ds, &vlan);
|
|
err = _mv88e6xxx_vtu_loadpurge(ds, &vlan);
|
|
if (err)
|
|
if (err)
|
|
goto unlock;
|
|
goto unlock;
|
|
|
|
|
|
err = _mv88e6xxx_atu_remove(ds, vlan.fid, port, false);
|
|
err = _mv88e6xxx_atu_remove(ds, vlan.fid, port, false);
|
|
- if (err)
|
|
|
|
- goto unlock;
|
|
|
|
-
|
|
|
|
- if (!keep)
|
|
|
|
- clear_bit(vlan.fid, ps->fid_bitmap);
|
|
|
|
-
|
|
|
|
unlock:
|
|
unlock:
|
|
mutex_unlock(&ps->smi_mutex);
|
|
mutex_unlock(&ps->smi_mutex);
|
|
|
|
|
|
@@ -1722,37 +1704,13 @@ static int _mv88e6xxx_atu_load(struct dsa_switch *ds,
|
|
return _mv88e6xxx_atu_cmd(ds, GLOBAL_ATU_OP_LOAD_DB);
|
|
return _mv88e6xxx_atu_cmd(ds, GLOBAL_ATU_OP_LOAD_DB);
|
|
}
|
|
}
|
|
|
|
|
|
-static int _mv88e6xxx_port_vid_to_fid(struct dsa_switch *ds, int port, u16 vid)
|
|
|
|
-{
|
|
|
|
- struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
|
|
|
|
- struct mv88e6xxx_vtu_stu_entry vlan;
|
|
|
|
- int err;
|
|
|
|
-
|
|
|
|
- if (vid == 0)
|
|
|
|
- return ps->fid[port];
|
|
|
|
-
|
|
|
|
- err = _mv88e6xxx_port_vtu_getnext(ds, port, vid - 1, &vlan);
|
|
|
|
- if (err)
|
|
|
|
- return err;
|
|
|
|
-
|
|
|
|
- if (vlan.vid == vid)
|
|
|
|
- return vlan.fid;
|
|
|
|
-
|
|
|
|
- return -ENOENT;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
static int _mv88e6xxx_port_fdb_load(struct dsa_switch *ds, int port,
|
|
static int _mv88e6xxx_port_fdb_load(struct dsa_switch *ds, int port,
|
|
const unsigned char *addr, u16 vid,
|
|
const unsigned char *addr, u16 vid,
|
|
u8 state)
|
|
u8 state)
|
|
{
|
|
{
|
|
struct mv88e6xxx_atu_entry entry = { 0 };
|
|
struct mv88e6xxx_atu_entry entry = { 0 };
|
|
- int ret;
|
|
|
|
-
|
|
|
|
- ret = _mv88e6xxx_port_vid_to_fid(ds, port, vid);
|
|
|
|
- if (ret < 0)
|
|
|
|
- return ret;
|
|
|
|
|
|
|
|
- entry.fid = ret;
|
|
|
|
|
|
+ entry.fid = vid; /* We use one FID per VLAN */
|
|
entry.state = state;
|
|
entry.state = state;
|
|
ether_addr_copy(entry.mac, addr);
|
|
ether_addr_copy(entry.mac, addr);
|
|
if (state != GLOBAL_ATU_DATA_STATE_UNUSED) {
|
|
if (state != GLOBAL_ATU_DATA_STATE_UNUSED) {
|
|
@@ -1767,6 +1725,10 @@ int mv88e6xxx_port_fdb_prepare(struct dsa_switch *ds, int port,
|
|
const struct switchdev_obj_port_fdb *fdb,
|
|
const struct switchdev_obj_port_fdb *fdb,
|
|
struct switchdev_trans *trans)
|
|
struct switchdev_trans *trans)
|
|
{
|
|
{
|
|
|
|
+ /* We don't use per-port FDB */
|
|
|
|
+ if (fdb->vid == 0)
|
|
|
|
+ return -EOPNOTSUPP;
|
|
|
|
+
|
|
/* We don't need any dynamic resource from the kernel (yet),
|
|
/* We don't need any dynamic resource from the kernel (yet),
|
|
* so skip the prepare phase.
|
|
* so skip the prepare phase.
|
|
*/
|
|
*/
|
|
@@ -1864,16 +1826,11 @@ int mv88e6xxx_port_fdb_getnext(struct dsa_switch *ds, int port,
|
|
{
|
|
{
|
|
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
|
|
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
|
|
struct mv88e6xxx_atu_entry next;
|
|
struct mv88e6xxx_atu_entry next;
|
|
- u16 fid;
|
|
|
|
|
|
+ u16 fid = *vid; /* We use one FID per VLAN */
|
|
int ret;
|
|
int ret;
|
|
|
|
|
|
mutex_lock(&ps->smi_mutex);
|
|
mutex_lock(&ps->smi_mutex);
|
|
|
|
|
|
- ret = _mv88e6xxx_port_vid_to_fid(ds, port, *vid);
|
|
|
|
- if (ret < 0)
|
|
|
|
- goto unlock;
|
|
|
|
- fid = ret;
|
|
|
|
-
|
|
|
|
do {
|
|
do {
|
|
if (is_broadcast_ether_addr(addr)) {
|
|
if (is_broadcast_ether_addr(addr)) {
|
|
struct mv88e6xxx_vtu_stu_entry vtu;
|
|
struct mv88e6xxx_vtu_stu_entry vtu;
|
|
@@ -1924,7 +1881,7 @@ static void mv88e6xxx_bridge_work(struct work_struct *work)
|
|
static int mv88e6xxx_setup_port(struct dsa_switch *ds, int port)
|
|
static int mv88e6xxx_setup_port(struct dsa_switch *ds, int port)
|
|
{
|
|
{
|
|
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
|
|
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
|
|
- int ret, fid;
|
|
|
|
|
|
+ int ret;
|
|
u16 reg;
|
|
u16 reg;
|
|
|
|
|
|
mutex_lock(&ps->smi_mutex);
|
|
mutex_lock(&ps->smi_mutex);
|
|
@@ -2143,15 +2100,11 @@ static int mv88e6xxx_setup_port(struct dsa_switch *ds, int port)
|
|
if (ret)
|
|
if (ret)
|
|
goto abort;
|
|
goto abort;
|
|
|
|
|
|
- /* Port based VLAN map: give each port its own address
|
|
|
|
|
|
+ /* Port based VLAN map: do not give each port its own address
|
|
* database, allow the CPU port to talk to each of the 'real'
|
|
* database, allow the CPU port to talk to each of the 'real'
|
|
* ports, and allow each of the 'real' ports to only talk to
|
|
* ports, and allow each of the 'real' ports to only talk to
|
|
* the upstream port.
|
|
* the upstream port.
|
|
*/
|
|
*/
|
|
- fid = port + 1;
|
|
|
|
- ps->fid[port] = fid;
|
|
|
|
- set_bit(fid, ps->fid_bitmap);
|
|
|
|
-
|
|
|
|
if (dsa_is_cpu_port(ds, port))
|
|
if (dsa_is_cpu_port(ds, port))
|
|
reg = BIT(ps->num_ports) - 1;
|
|
reg = BIT(ps->num_ports) - 1;
|
|
else
|
|
else
|