Skip to content

Commit 37b8da1

Browse files
Arkadi Sharshevskydavem330
authored andcommitted
net: dsa: Move FDB add/del implementation inside DSA
Currently DSA uses switchdev's implementation of FDB add/del ndos. This patch moves the implementation inside DSA in order to support the legacy way for static FDB configuration. Signed-off-by: Arkadi Sharshevsky <[email protected]> Reviewed-by: Vivien Didelot <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c9eb3e0 commit 37b8da1

File tree

3 files changed

+31
-12
lines changed

3 files changed

+31
-12
lines changed

net/dsa/dsa_priv.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,13 @@ bool dsa_schedule_work(struct work_struct *work);
111111
/* legacy.c */
112112
int dsa_legacy_register(void);
113113
void dsa_legacy_unregister(void);
114+
int dsa_legacy_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
115+
struct net_device *dev,
116+
const unsigned char *addr, u16 vid,
117+
u16 flags);
118+
int dsa_legacy_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],
119+
struct net_device *dev,
120+
const unsigned char *addr, u16 vid);
114121

115122
/* port.c */
116123
int dsa_port_set_state(struct dsa_port *dp, u8 state,

net/dsa/legacy.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,28 @@ static int dsa_resume(struct device *d)
739739
}
740740
#endif
741741

742+
/* legacy way, bypassing the bridge *****************************************/
743+
int dsa_legacy_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
744+
struct net_device *dev,
745+
const unsigned char *addr, u16 vid,
746+
u16 flags)
747+
{
748+
struct dsa_slave_priv *p = netdev_priv(dev);
749+
struct dsa_port *dp = p->dp;
750+
751+
return dsa_port_fdb_add(dp, addr, vid);
752+
}
753+
754+
int dsa_legacy_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],
755+
struct net_device *dev,
756+
const unsigned char *addr, u16 vid)
757+
{
758+
struct dsa_slave_priv *p = netdev_priv(dev);
759+
struct dsa_port *dp = p->dp;
760+
761+
return dsa_port_fdb_del(dp, addr, vid);
762+
}
763+
742764
static SIMPLE_DEV_PM_OPS(dsa_pm_ops, dsa_suspend, dsa_resume);
743765

744766
static const struct of_device_id dsa_of_match_table[] = {

net/dsa/slave.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,6 @@ static int dsa_slave_port_obj_add(struct net_device *dev,
250250
*/
251251

252252
switch (obj->id) {
253-
case SWITCHDEV_OBJ_ID_PORT_FDB:
254-
if (switchdev_trans_ph_prepare(trans))
255-
return 0;
256-
err = dsa_port_fdb_add(dp, SWITCHDEV_OBJ_PORT_FDB(obj)->addr,
257-
SWITCHDEV_OBJ_PORT_FDB(obj)->vid);
258-
break;
259253
case SWITCHDEV_OBJ_ID_PORT_MDB:
260254
err = dsa_port_mdb_add(dp, SWITCHDEV_OBJ_PORT_MDB(obj), trans);
261255
break;
@@ -279,10 +273,6 @@ static int dsa_slave_port_obj_del(struct net_device *dev,
279273
int err;
280274

281275
switch (obj->id) {
282-
case SWITCHDEV_OBJ_ID_PORT_FDB:
283-
err = dsa_port_fdb_del(dp, SWITCHDEV_OBJ_PORT_FDB(obj)->addr,
284-
SWITCHDEV_OBJ_PORT_FDB(obj)->vid);
285-
break;
286276
case SWITCHDEV_OBJ_ID_PORT_MDB:
287277
err = dsa_port_mdb_del(dp, SWITCHDEV_OBJ_PORT_MDB(obj));
288278
break;
@@ -985,8 +975,8 @@ static const struct net_device_ops dsa_slave_netdev_ops = {
985975
.ndo_change_rx_flags = dsa_slave_change_rx_flags,
986976
.ndo_set_rx_mode = dsa_slave_set_rx_mode,
987977
.ndo_set_mac_address = dsa_slave_set_mac_address,
988-
.ndo_fdb_add = switchdev_port_fdb_add,
989-
.ndo_fdb_del = switchdev_port_fdb_del,
978+
.ndo_fdb_add = dsa_legacy_fdb_add,
979+
.ndo_fdb_del = dsa_legacy_fdb_del,
990980
.ndo_fdb_dump = switchdev_port_fdb_dump,
991981
.ndo_do_ioctl = dsa_slave_ioctl,
992982
.ndo_get_iflink = dsa_slave_get_iflink,

0 commit comments

Comments
 (0)