return _mv88e6xxx_vtu_stu_data_write(chip, entry, 2);
}
-static int _mv88e6xxx_vtu_vid_write(struct mv88e6xxx_chip *chip, u16 vid)
-{
- return mv88e6xxx_g1_write(chip, GLOBAL_VTU_VID,
- vid & GLOBAL_VTU_VID_MASK);
-}
-
static int _mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
struct mv88e6xxx_vtu_entry *entry)
{
if (err)
return err;
- err = mv88e6xxx_g1_read(chip, GLOBAL_VTU_VID, &val);
+ err = mv88e6xxx_g1_vtu_vid_read(chip, &next);
if (err)
return err;
- next.vid = val & GLOBAL_VTU_VID_MASK;
- next.valid = !!(val & GLOBAL_VTU_VID_VALID);
-
if (next.valid) {
err = mv88e6xxx_vtu_data_read(chip, &next);
if (err)
int (*cb)(struct switchdev_obj *obj))
{
struct mv88e6xxx_chip *chip = ds->priv;
- struct mv88e6xxx_vtu_entry next;
+ struct mv88e6xxx_vtu_entry next = {
+ .vid = chip->info->max_vid,
+ };
u16 pvid;
int err;
if (err)
goto unlock;
- err = _mv88e6xxx_vtu_vid_write(chip, GLOBAL_VTU_VID_MASK);
+ err = mv88e6xxx_g1_vtu_vid_write(chip, &next);
if (err)
goto unlock;
struct mv88e6xxx_vtu_entry *entry)
{
u16 op = GLOBAL_VTU_OP_VTU_LOAD_PURGE;
- u16 reg = 0;
int err;
err = mv88e6xxx_g1_vtu_op_wait(chip);
if (err)
return err;
+ err = mv88e6xxx_g1_vtu_vid_write(chip, entry);
+ if (err)
+ return err;
+
if (!entry->valid)
goto loadpurge;
op |= (entry->fid & 0xf0) << 8;
op |= entry->fid & 0xf;
}
-
- reg = GLOBAL_VTU_VID_VALID;
loadpurge:
- reg |= entry->vid & GLOBAL_VTU_VID_MASK;
- err = mv88e6xxx_g1_write(chip, GLOBAL_VTU_VID, reg);
- if (err)
- return err;
-
return mv88e6xxx_g1_vtu_op(chip, op);
}
struct mv88e6xxx_vtu_entry next = {
.sid = sid,
};
- u16 val;
int err;
err = mv88e6xxx_g1_vtu_op_wait(chip);
if (err)
return err;
- err = mv88e6xxx_g1_read(chip, GLOBAL_VTU_VID, &val);
+ err = mv88e6xxx_g1_vtu_vid_read(chip, &next);
if (err)
return err;
- next.valid = !!(val & GLOBAL_VTU_VID_VALID);
-
if (next.valid) {
err = mv88e6xxx_stu_data_read(chip, &next);
if (err)
static int _mv88e6xxx_stu_loadpurge(struct mv88e6xxx_chip *chip,
struct mv88e6xxx_vtu_entry *entry)
{
- u16 reg = 0;
int err;
err = mv88e6xxx_g1_vtu_op_wait(chip);
err = mv88e6xxx_stu_data_write(chip, entry);
if (err)
return err;
-
- reg = GLOBAL_VTU_VID_VALID;
loadpurge:
- err = mv88e6xxx_g1_write(chip, GLOBAL_VTU_VID, reg);
+ err = mv88e6xxx_g1_vtu_vid_write(chip, entry);
if (err)
return err;
static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
{
DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
- struct mv88e6xxx_vtu_entry vlan;
+ struct mv88e6xxx_vtu_entry vlan = {
+ .vid = chip->info->max_vid,
+ };
int i, err;
bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
}
/* Set every FID bit used by the VLAN entries */
- err = _mv88e6xxx_vtu_vid_write(chip, GLOBAL_VTU_VID_MASK);
+ err = mv88e6xxx_g1_vtu_vid_write(chip, &vlan);
if (err)
return err;
if (!vid)
return -EINVAL;
- err = _mv88e6xxx_vtu_vid_write(chip, vid - 1);
+ entry->vid = vid - 1;
+ entry->valid = false;
+ err = mv88e6xxx_g1_vtu_vid_write(chip, entry);
if (err)
return err;
u16 vid_begin, u16 vid_end)
{
struct mv88e6xxx_chip *chip = ds->priv;
- struct mv88e6xxx_vtu_entry vlan;
+ struct mv88e6xxx_vtu_entry vlan = {
+ .vid = vid_begin - 1,
+ };
int i, err;
if (!vid_begin)
mutex_lock(&chip->reg_lock);
- err = _mv88e6xxx_vtu_vid_write(chip, vid_begin - 1);
+ err = mv88e6xxx_g1_vtu_vid_write(chip, &vlan);
if (err)
goto unlock;
return err;
/* Dump VLANs' Filtering Information Databases */
- err = _mv88e6xxx_vtu_vid_write(chip, vlan.vid);
+ err = mv88e6xxx_g1_vtu_vid_write(chip, &vlan);
if (err)
return err;
return mv88e6xxx_g1_vtu_op_wait(chip);
}
+/* Offset 0x06: VTU VID Register */
+
+int mv88e6xxx_g1_vtu_vid_read(struct mv88e6xxx_chip *chip,
+ struct mv88e6xxx_vtu_entry *entry)
+{
+ u16 val;
+ int err;
+
+ err = mv88e6xxx_g1_read(chip, GLOBAL_VTU_VID, &val);
+ if (err)
+ return err;
+
+ entry->vid = val & 0xfff;
+ entry->valid = !!(val & GLOBAL_VTU_VID_VALID);
+
+ return 0;
+}
+
+int mv88e6xxx_g1_vtu_vid_write(struct mv88e6xxx_chip *chip,
+ struct mv88e6xxx_vtu_entry *entry)
+{
+ u16 val = entry->vid & 0xfff;
+
+ if (entry->valid)
+ val |= GLOBAL_VTU_VID_VALID;
+
+ return mv88e6xxx_g1_write(chip, GLOBAL_VTU_VID, val);
+}
+
/* VLAN Translation Unit Operations */
int mv88e6xxx_g1_vtu_flush(struct mv88e6xxx_chip *chip)