Skip to content

Commit 2bedde1

Browse files
Arkadi Sharshevskydavem330
authored andcommitted
net: dsa: Move FDB dump implementation inside DSA
>From all switchdev devices only DSA requires special FDB dump. This is due to lack of ability for syncing the hardware learned FDBs with the bridge. Due to this it is removed from switchdev and moved inside DSA. Signed-off-by: Arkadi Sharshevsky <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent dc0cbff commit 2bedde1

File tree

12 files changed

+112
-204
lines changed

12 files changed

+112
-204
lines changed

drivers/net/dsa/b53/b53_common.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,25 +1227,19 @@ static void b53_arl_search_rd(struct b53_device *dev, u8 idx,
12271227
}
12281228

12291229
static int b53_fdb_copy(int port, const struct b53_arl_entry *ent,
1230-
struct switchdev_obj_port_fdb *fdb,
1231-
switchdev_obj_dump_cb_t *cb)
1230+
dsa_fdb_dump_cb_t *cb, void *data)
12321231
{
12331232
if (!ent->is_valid)
12341233
return 0;
12351234

12361235
if (port != ent->port)
12371236
return 0;
12381237

1239-
ether_addr_copy(fdb->addr, ent->mac);
1240-
fdb->vid = ent->vid;
1241-
fdb->ndm_state = ent->is_static ? NUD_NOARP : NUD_REACHABLE;
1242-
1243-
return cb(&fdb->obj);
1238+
return cb(ent->mac, ent->vid, ent->is_static, data);
12441239
}
12451240

12461241
int b53_fdb_dump(struct dsa_switch *ds, int port,
1247-
struct switchdev_obj_port_fdb *fdb,
1248-
switchdev_obj_dump_cb_t *cb)
1242+
dsa_fdb_dump_cb_t *cb, void *data)
12491243
{
12501244
struct b53_device *priv = ds->priv;
12511245
struct b53_arl_entry results[2];
@@ -1263,13 +1257,13 @@ int b53_fdb_dump(struct dsa_switch *ds, int port,
12631257
return ret;
12641258

12651259
b53_arl_search_rd(priv, 0, &results[0]);
1266-
ret = b53_fdb_copy(port, &results[0], fdb, cb);
1260+
ret = b53_fdb_copy(port, &results[0], cb, data);
12671261
if (ret)
12681262
return ret;
12691263

12701264
if (priv->num_arl_entries > 2) {
12711265
b53_arl_search_rd(priv, 1, &results[1]);
1272-
ret = b53_fdb_copy(port, &results[1], fdb, cb);
1266+
ret = b53_fdb_copy(port, &results[1], cb, data);
12731267
if (ret)
12741268
return ret;
12751269

drivers/net/dsa/b53/b53_priv.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,7 @@ int b53_fdb_add(struct dsa_switch *ds, int port,
398398
int b53_fdb_del(struct dsa_switch *ds, int port,
399399
const unsigned char *addr, u16 vid);
400400
int b53_fdb_dump(struct dsa_switch *ds, int port,
401-
struct switchdev_obj_port_fdb *fdb,
402-
switchdev_obj_dump_cb_t *cb);
401+
dsa_fdb_dump_cb_t *cb, void *data);
403402
int b53_mirror_add(struct dsa_switch *ds, int port,
404403
struct dsa_mall_mirror_tc_entry *mirror, bool ingress);
405404
void b53_mirror_del(struct dsa_switch *ds, int port,

drivers/net/dsa/microchip/ksz_common.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -805,12 +805,11 @@ static void convert_alu(struct alu_struct *alu, u32 *alu_table)
805805
}
806806

807807
static int ksz_port_fdb_dump(struct dsa_switch *ds, int port,
808-
struct switchdev_obj_port_fdb *fdb,
809-
switchdev_obj_dump_cb_t *cb)
808+
dsa_fdb_dump_cb_t *cb, void *data)
810809
{
811810
struct ksz_device *dev = ds->priv;
812811
int ret = 0;
813-
u32 data;
812+
u32 ksz_data;
814813
u32 alu_table[4];
815814
struct alu_struct alu;
816815
int timeout;
@@ -823,8 +822,8 @@ static int ksz_port_fdb_dump(struct dsa_switch *ds, int port,
823822
do {
824823
timeout = 1000;
825824
do {
826-
ksz_read32(dev, REG_SW_ALU_CTRL__4, &data);
827-
if ((data & ALU_VALID) || !(data & ALU_START))
825+
ksz_read32(dev, REG_SW_ALU_CTRL__4, &ksz_data);
826+
if ((ksz_data & ALU_VALID) || !(ksz_data & ALU_START))
828827
break;
829828
usleep_range(1, 10);
830829
} while (timeout-- > 0);
@@ -841,18 +840,11 @@ static int ksz_port_fdb_dump(struct dsa_switch *ds, int port,
841840
convert_alu(&alu, alu_table);
842841

843842
if (alu.port_forward & BIT(port)) {
844-
fdb->vid = alu.fid;
845-
if (alu.is_static)
846-
fdb->ndm_state = NUD_NOARP;
847-
else
848-
fdb->ndm_state = NUD_REACHABLE;
849-
ether_addr_copy(fdb->addr, alu.mac);
850-
851-
ret = cb(&fdb->obj);
843+
ret = cb(alu.mac, alu.fid, alu.is_static, data);
852844
if (ret)
853845
goto exit;
854846
}
855-
} while (data & ALU_START);
847+
} while (ksz_data & ALU_START);
856848

857849
exit:
858850

drivers/net/dsa/mt7530.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -834,8 +834,7 @@ mt7530_port_fdb_del(struct dsa_switch *ds, int port,
834834

835835
static int
836836
mt7530_port_fdb_dump(struct dsa_switch *ds, int port,
837-
struct switchdev_obj_port_fdb *fdb,
838-
switchdev_obj_dump_cb_t *cb)
837+
dsa_fdb_dump_cb_t *cb, void *data)
839838
{
840839
struct mt7530_priv *priv = ds->priv;
841840
struct mt7530_fdb _fdb = { 0 };
@@ -853,11 +852,8 @@ mt7530_port_fdb_dump(struct dsa_switch *ds, int port,
853852
if (rsp & ATC_SRCH_HIT) {
854853
mt7530_fdb_read(priv, &_fdb);
855854
if (_fdb.port_mask & BIT(port)) {
856-
ether_addr_copy(fdb->addr, _fdb.mac);
857-
fdb->vid = _fdb.vid;
858-
fdb->ndm_state = _fdb.noarp ?
859-
NUD_NOARP : NUD_REACHABLE;
860-
ret = cb(&fdb->obj);
855+
ret = cb(_fdb.mac, _fdb.vid, _fdb.noarp,
856+
data);
861857
if (ret < 0)
862858
break;
863859
}

drivers/net/dsa/mv88e6xxx/chip.c

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,10 +1381,10 @@ static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
13811381

13821382
static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
13831383
u16 fid, u16 vid, int port,
1384-
struct switchdev_obj *obj,
1385-
switchdev_obj_dump_cb_t *cb)
1384+
dsa_fdb_dump_cb_t *cb, void *data)
13861385
{
13871386
struct mv88e6xxx_atu_entry addr;
1387+
bool is_static;
13881388
int err;
13891389

13901390
addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
@@ -1401,24 +1401,12 @@ static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
14011401
if (addr.trunk || (addr.portvec & BIT(port)) == 0)
14021402
continue;
14031403

1404-
if (obj->id == SWITCHDEV_OBJ_ID_PORT_FDB) {
1405-
struct switchdev_obj_port_fdb *fdb;
1406-
1407-
if (!is_unicast_ether_addr(addr.mac))
1408-
continue;
1409-
1410-
fdb = SWITCHDEV_OBJ_PORT_FDB(obj);
1411-
fdb->vid = vid;
1412-
ether_addr_copy(fdb->addr, addr.mac);
1413-
if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC)
1414-
fdb->ndm_state = NUD_NOARP;
1415-
else
1416-
fdb->ndm_state = NUD_REACHABLE;
1417-
} else {
1418-
return -EOPNOTSUPP;
1419-
}
1404+
if (!is_unicast_ether_addr(addr.mac))
1405+
continue;
14201406

1421-
err = cb(obj);
1407+
is_static = (addr.state ==
1408+
MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
1409+
err = cb(addr.mac, vid, is_static, data);
14221410
if (err)
14231411
return err;
14241412
} while (!is_broadcast_ether_addr(addr.mac));
@@ -1427,8 +1415,7 @@ static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
14271415
}
14281416

14291417
static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
1430-
struct switchdev_obj *obj,
1431-
switchdev_obj_dump_cb_t *cb)
1418+
dsa_fdb_dump_cb_t *cb, void *data)
14321419
{
14331420
struct mv88e6xxx_vtu_entry vlan = {
14341421
.vid = chip->info->max_vid,
@@ -1441,7 +1428,7 @@ static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
14411428
if (err)
14421429
return err;
14431430

1444-
err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, obj, cb);
1431+
err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
14451432
if (err)
14461433
return err;
14471434

@@ -1455,7 +1442,7 @@ static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
14551442
break;
14561443

14571444
err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
1458-
obj, cb);
1445+
cb, data);
14591446
if (err)
14601447
return err;
14611448
} while (vlan.vid < chip->info->max_vid);
@@ -1464,14 +1451,13 @@ static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
14641451
}
14651452

14661453
static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
1467-
struct switchdev_obj_port_fdb *fdb,
1468-
switchdev_obj_dump_cb_t *cb)
1454+
dsa_fdb_dump_cb_t *cb, void *data)
14691455
{
14701456
struct mv88e6xxx_chip *chip = ds->priv;
14711457
int err;
14721458

14731459
mutex_lock(&chip->reg_lock);
1474-
err = mv88e6xxx_port_db_dump(chip, port, &fdb->obj, cb);
1460+
err = mv88e6xxx_port_db_dump(chip, port, cb, data);
14751461
mutex_unlock(&chip->reg_lock);
14761462

14771463
return err;

drivers/net/dsa/qca8k.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -801,27 +801,20 @@ qca8k_port_fdb_del(struct dsa_switch *ds, int port,
801801

802802
static int
803803
qca8k_port_fdb_dump(struct dsa_switch *ds, int port,
804-
struct switchdev_obj_port_fdb *fdb,
805-
switchdev_obj_dump_cb_t *cb)
804+
dsa_fdb_dump_cb_t *cb, void *data)
806805
{
807806
struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv;
808807
struct qca8k_fdb _fdb = { 0 };
809808
int cnt = QCA8K_NUM_FDB_RECORDS;
809+
bool is_static;
810810
int ret = 0;
811811

812812
mutex_lock(&priv->reg_mutex);
813813
while (cnt-- && !qca8k_fdb_next(priv, &_fdb, port)) {
814814
if (!_fdb.aging)
815815
break;
816-
817-
ether_addr_copy(fdb->addr, _fdb.mac);
818-
fdb->vid = _fdb.vid;
819-
if (_fdb.aging == QCA8K_ATU_STATUS_STATIC)
820-
fdb->ndm_state = NUD_NOARP;
821-
else
822-
fdb->ndm_state = NUD_REACHABLE;
823-
824-
ret = cb(&fdb->obj);
816+
is_static = (_fdb.aging == QCA8K_ATU_STATUS_STATIC);
817+
ret = cb(_fdb.mac, _fdb.vid, is_static, data);
825818
if (ret)
826819
break;
827820
}

include/net/dsa.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ static inline u8 dsa_upstream_port(struct dsa_switch *ds)
272272
return ds->rtable[dst->cpu_dp->ds->index];
273273
}
274274

275+
typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid,
276+
bool is_static, void *data);
275277
struct dsa_switch_ops {
276278
/*
277279
* Legacy probing.
@@ -386,8 +388,7 @@ struct dsa_switch_ops {
386388
int (*port_fdb_del)(struct dsa_switch *ds, int port,
387389
const unsigned char *addr, u16 vid);
388390
int (*port_fdb_dump)(struct dsa_switch *ds, int port,
389-
struct switchdev_obj_port_fdb *fdb,
390-
switchdev_obj_dump_cb_t *cb);
391+
dsa_fdb_dump_cb_t *cb, void *data);
391392

392393
/*
393394
* Multicast database

include/net/switchdev.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,6 @@ int switchdev_port_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
208208
int switchdev_port_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],
209209
struct net_device *dev, const unsigned char *addr,
210210
u16 vid);
211-
int switchdev_port_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb,
212-
struct net_device *dev,
213-
struct net_device *filter_dev, int *idx);
214211
void switchdev_port_fwd_mark_set(struct net_device *dev,
215212
struct net_device *group_dev,
216213
bool joining);
@@ -309,15 +306,6 @@ static inline int switchdev_port_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],
309306
return -EOPNOTSUPP;
310307
}
311308

312-
static inline int switchdev_port_fdb_dump(struct sk_buff *skb,
313-
struct netlink_callback *cb,
314-
struct net_device *dev,
315-
struct net_device *filter_dev,
316-
int *idx)
317-
{
318-
return *idx;
319-
}
320-
321309
static inline bool switchdev_port_same_parent_id(struct net_device *a,
322310
struct net_device *b)
323311
{

net/dsa/dsa_priv.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,6 @@ int dsa_port_fdb_add(struct dsa_port *dp, const unsigned char *addr,
133133
u16 vid);
134134
int dsa_port_fdb_del(struct dsa_port *dp, const unsigned char *addr,
135135
u16 vid);
136-
int dsa_port_fdb_dump(struct dsa_port *dp, struct switchdev_obj_port_fdb *fdb,
137-
switchdev_obj_dump_cb_t *cb);
138136
int dsa_port_mdb_add(struct dsa_port *dp,
139137
const struct switchdev_obj_port_mdb *mdb,
140138
struct switchdev_trans *trans);

net/dsa/port.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -173,17 +173,6 @@ int dsa_port_fdb_del(struct dsa_port *dp, const unsigned char *addr,
173173
return dsa_port_notify(dp, DSA_NOTIFIER_FDB_DEL, &info);
174174
}
175175

176-
int dsa_port_fdb_dump(struct dsa_port *dp, struct switchdev_obj_port_fdb *fdb,
177-
switchdev_obj_dump_cb_t *cb)
178-
{
179-
struct dsa_switch *ds = dp->ds;
180-
181-
if (ds->ops->port_fdb_dump)
182-
return ds->ops->port_fdb_dump(ds, dp->index, fdb, cb);
183-
184-
return -EOPNOTSUPP;
185-
}
186-
187176
int dsa_port_mdb_add(struct dsa_port *dp,
188177
const struct switchdev_obj_port_mdb *mdb,
189178
struct switchdev_trans *trans)

0 commit comments

Comments
 (0)