Skip to content

Commit ceff5ef

Browse files
viviendavem330
authored andcommitted
net: dsa: mv88e6xxx: implement port_vlan_dump
Remove the port_pvid_get and vlan_getnext functions in favor of a simpler mv88e6xxx_port_vlan_dump function. Signed-off-by: Vivien Didelot <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 65aebfc commit ceff5ef

File tree

4 files changed

+56
-66
lines changed

4 files changed

+56
-66
lines changed

drivers/net/dsa/mv88e6171.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,10 @@ struct dsa_switch_driver mv88e6171_switch_driver = {
106106
.port_join_bridge = mv88e6xxx_port_bridge_join,
107107
.port_leave_bridge = mv88e6xxx_port_bridge_leave,
108108
.port_stp_update = mv88e6xxx_port_stp_update,
109-
.port_pvid_get = mv88e6xxx_port_pvid_get,
110109
.port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
111110
.port_vlan_add = mv88e6xxx_port_vlan_add,
112111
.port_vlan_del = mv88e6xxx_port_vlan_del,
113-
.vlan_getnext = mv88e6xxx_vlan_getnext,
112+
.port_vlan_dump = mv88e6xxx_port_vlan_dump,
114113
.port_fdb_prepare = mv88e6xxx_port_fdb_prepare,
115114
.port_fdb_add = mv88e6xxx_port_fdb_add,
116115
.port_fdb_del = mv88e6xxx_port_fdb_del,

drivers/net/dsa/mv88e6352.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,11 +327,10 @@ struct dsa_switch_driver mv88e6352_switch_driver = {
327327
.port_join_bridge = mv88e6xxx_port_bridge_join,
328328
.port_leave_bridge = mv88e6xxx_port_bridge_leave,
329329
.port_stp_update = mv88e6xxx_port_stp_update,
330-
.port_pvid_get = mv88e6xxx_port_pvid_get,
331330
.port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
332331
.port_vlan_add = mv88e6xxx_port_vlan_add,
333332
.port_vlan_del = mv88e6xxx_port_vlan_del,
334-
.vlan_getnext = mv88e6xxx_vlan_getnext,
333+
.port_vlan_dump = mv88e6xxx_port_vlan_dump,
335334
.port_fdb_prepare = mv88e6xxx_port_fdb_prepare,
336335
.port_fdb_add = mv88e6xxx_port_fdb_add,
337336
.port_fdb_del = mv88e6xxx_port_fdb_del,

drivers/net/dsa/mv88e6xxx.c

Lines changed: 51 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,19 +1151,6 @@ static int _mv88e6xxx_port_pvid_get(struct dsa_switch *ds, int port, u16 *pvid)
11511151
return 0;
11521152
}
11531153

1154-
int mv88e6xxx_port_pvid_get(struct dsa_switch *ds, int port, u16 *pvid)
1155-
{
1156-
int ret;
1157-
1158-
ret = mv88e6xxx_reg_read(ds, REG_PORT(port), PORT_DEFAULT_VLAN);
1159-
if (ret < 0)
1160-
return ret;
1161-
1162-
*pvid = ret & PORT_DEFAULT_VLAN_MASK;
1163-
1164-
return 0;
1165-
}
1166-
11671154
static int _mv88e6xxx_port_pvid_set(struct dsa_switch *ds, int port, u16 pvid)
11681155
{
11691156
return _mv88e6xxx_reg_write(ds, REG_PORT(port), PORT_DEFAULT_VLAN,
@@ -1306,6 +1293,57 @@ static int _mv88e6xxx_vtu_getnext(struct dsa_switch *ds,
13061293
return 0;
13071294
}
13081295

1296+
int mv88e6xxx_port_vlan_dump(struct dsa_switch *ds, int port,
1297+
struct switchdev_obj_port_vlan *vlan,
1298+
int (*cb)(struct switchdev_obj *obj))
1299+
{
1300+
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
1301+
struct mv88e6xxx_vtu_stu_entry next;
1302+
u16 pvid;
1303+
int err;
1304+
1305+
mutex_lock(&ps->smi_mutex);
1306+
1307+
err = _mv88e6xxx_port_pvid_get(ds, port, &pvid);
1308+
if (err)
1309+
goto unlock;
1310+
1311+
err = _mv88e6xxx_vtu_vid_write(ds, GLOBAL_VTU_VID_MASK);
1312+
if (err)
1313+
goto unlock;
1314+
1315+
do {
1316+
err = _mv88e6xxx_vtu_getnext(ds, &next);
1317+
if (err)
1318+
break;
1319+
1320+
if (!next.valid)
1321+
break;
1322+
1323+
if (next.data[port] == GLOBAL_VTU_DATA_MEMBER_TAG_NON_MEMBER)
1324+
continue;
1325+
1326+
/* reinit and dump this VLAN obj */
1327+
vlan->vid_begin = vlan->vid_end = next.vid;
1328+
vlan->flags = 0;
1329+
1330+
if (next.data[port] == GLOBAL_VTU_DATA_MEMBER_TAG_UNTAGGED)
1331+
vlan->flags |= BRIDGE_VLAN_INFO_UNTAGGED;
1332+
1333+
if (next.vid == pvid)
1334+
vlan->flags |= BRIDGE_VLAN_INFO_PVID;
1335+
1336+
err = cb(&vlan->obj);
1337+
if (err)
1338+
break;
1339+
} while (next.vid < GLOBAL_VTU_VID_MASK);
1340+
1341+
unlock:
1342+
mutex_unlock(&ps->smi_mutex);
1343+
1344+
return err;
1345+
}
1346+
13091347
static int _mv88e6xxx_vtu_loadpurge(struct dsa_switch *ds,
13101348
struct mv88e6xxx_vtu_stu_entry *entry)
13111349
{
@@ -1675,52 +1713,6 @@ int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
16751713
return err;
16761714
}
16771715

1678-
int mv88e6xxx_vlan_getnext(struct dsa_switch *ds, u16 *vid,
1679-
unsigned long *ports, unsigned long *untagged)
1680-
{
1681-
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
1682-
struct mv88e6xxx_vtu_stu_entry next;
1683-
int port;
1684-
int err;
1685-
1686-
if (*vid == 4095)
1687-
return -ENOENT;
1688-
1689-
mutex_lock(&ps->smi_mutex);
1690-
err = _mv88e6xxx_vtu_vid_write(ds, *vid);
1691-
if (err)
1692-
goto unlock;
1693-
1694-
err = _mv88e6xxx_vtu_getnext(ds, &next);
1695-
unlock:
1696-
mutex_unlock(&ps->smi_mutex);
1697-
1698-
if (err)
1699-
return err;
1700-
1701-
if (!next.valid)
1702-
return -ENOENT;
1703-
1704-
*vid = next.vid;
1705-
1706-
for (port = 0; port < ps->num_ports; ++port) {
1707-
clear_bit(port, ports);
1708-
clear_bit(port, untagged);
1709-
1710-
if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1711-
continue;
1712-
1713-
if (next.data[port] == GLOBAL_VTU_DATA_MEMBER_TAG_TAGGED ||
1714-
next.data[port] == GLOBAL_VTU_DATA_MEMBER_TAG_UNTAGGED)
1715-
set_bit(port, ports);
1716-
1717-
if (next.data[port] == GLOBAL_VTU_DATA_MEMBER_TAG_UNTAGGED)
1718-
set_bit(port, untagged);
1719-
}
1720-
1721-
return 0;
1722-
}
1723-
17241716
static int _mv88e6xxx_atu_mac_write(struct dsa_switch *ds,
17251717
const unsigned char *addr)
17261718
{

drivers/net/dsa/mv88e6xxx.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -494,9 +494,9 @@ int mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
494494
struct switchdev_trans *trans);
495495
int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
496496
const struct switchdev_obj_port_vlan *vlan);
497-
int mv88e6xxx_port_pvid_get(struct dsa_switch *ds, int port, u16 *vid);
498-
int mv88e6xxx_vlan_getnext(struct dsa_switch *ds, u16 *vid,
499-
unsigned long *ports, unsigned long *untagged);
497+
int mv88e6xxx_port_vlan_dump(struct dsa_switch *ds, int port,
498+
struct switchdev_obj_port_vlan *vlan,
499+
int (*cb)(struct switchdev_obj *obj));
500500
int mv88e6xxx_port_fdb_prepare(struct dsa_switch *ds, int port,
501501
const struct switchdev_obj_port_fdb *fdb,
502502
struct switchdev_trans *trans);

0 commit comments

Comments
 (0)