Commit 6fb8661c authored by David S. Miller's avatar David S. Miller

Merge branch 'dsa-unicast-filtering'

Vladimir Oltean says:

====================
DSA unicast filtering

This series doesn't attempt anything extremely brave, it just changes
the way in which standalone ports which support FDB isolation work.

Up until now, DSA has recommended that switch drivers configure
standalone ports in a separate VID/FID with learning disabled, and with
the CPU port as the only destination, reached trivially via flooding.
That works, except that standalone ports will deliver all packets to the
CPU. We can leverage the hardware FDB as a MAC DA filter, and disable
flooding towards the CPU port, to force the dropping of packets with
unknown MAC DA.

We handle port promiscuity by re-enabling flooding towards the CPU port.
This is relevant because the bridge puts its automatic (learning +
flooding) ports in promiscuous mode, and this makes some things work
automagically, like for example bridging with a foreign interface.
We don't delve yet into the territory of managing CPU flooding more
aggressively while under a bridge.

The only switch driver that benefits from this work right now is the
NXP LS1028A switch (felix). The others need to implement FDB isolation
first, before DSA is going to install entries to the port's standalone
database. Otherwise, these entries might collide with bridge FDB/MDB
entries.

This work was done mainly to have all the required features in place
before somebody starts seriously architecting DSA support for multiple
CPU ports. Otherwise it is much more difficult to bolt these features on
top of multiple CPU ports.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 43113ff7 ac455209
...@@ -25,6 +25,141 @@ ...@@ -25,6 +25,141 @@
#include <net/dsa.h> #include <net/dsa.h>
#include "felix.h" #include "felix.h"
/* Translate the DSA database API into the ocelot switch library API,
* which uses VID 0 for all ports that aren't part of a bridge,
* and expects the bridge_dev to be NULL in that case.
*/
static struct net_device *felix_classify_db(struct dsa_db db)
{
switch (db.type) {
case DSA_DB_PORT:
case DSA_DB_LAG:
return NULL;
case DSA_DB_BRIDGE:
return db.bridge.dev;
default:
return ERR_PTR(-EOPNOTSUPP);
}
}
/* We are called before felix_npi_port_init(), so ocelot->npi is -1. */
static int felix_migrate_fdbs_to_npi_port(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid,
struct dsa_db db)
{
struct net_device *bridge_dev = felix_classify_db(db);
struct ocelot *ocelot = ds->priv;
int cpu = ocelot->num_phys_ports;
int err;
err = ocelot_fdb_del(ocelot, port, addr, vid, bridge_dev);
if (err)
return err;
return ocelot_fdb_add(ocelot, cpu, addr, vid, bridge_dev);
}
static int felix_migrate_mdbs_to_npi_port(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid,
struct dsa_db db)
{
struct net_device *bridge_dev = felix_classify_db(db);
struct switchdev_obj_port_mdb mdb;
struct ocelot *ocelot = ds->priv;
int cpu = ocelot->num_phys_ports;
int err;
memset(&mdb, 0, sizeof(mdb));
ether_addr_copy(mdb.addr, addr);
mdb.vid = vid;
err = ocelot_port_mdb_del(ocelot, port, &mdb, bridge_dev);
if (err)
return err;
return ocelot_port_mdb_add(ocelot, cpu, &mdb, bridge_dev);
}
static void felix_migrate_pgid_bit(struct dsa_switch *ds, int from, int to,
int pgid)
{
struct ocelot *ocelot = ds->priv;
bool on;
u32 val;
val = ocelot_read_rix(ocelot, ANA_PGID_PGID, pgid);
on = !!(val & BIT(from));
val &= ~BIT(from);
if (on)
val |= BIT(to);
else
val &= ~BIT(to);
ocelot_write_rix(ocelot, val, ANA_PGID_PGID, pgid);
}
static void felix_migrate_flood_to_npi_port(struct dsa_switch *ds, int port)
{
struct ocelot *ocelot = ds->priv;
felix_migrate_pgid_bit(ds, port, ocelot->num_phys_ports, PGID_UC);
felix_migrate_pgid_bit(ds, port, ocelot->num_phys_ports, PGID_MC);
felix_migrate_pgid_bit(ds, port, ocelot->num_phys_ports, PGID_BC);
}
static void
felix_migrate_flood_to_tag_8021q_port(struct dsa_switch *ds, int port)
{
struct ocelot *ocelot = ds->priv;
felix_migrate_pgid_bit(ds, ocelot->num_phys_ports, port, PGID_UC);
felix_migrate_pgid_bit(ds, ocelot->num_phys_ports, port, PGID_MC);
felix_migrate_pgid_bit(ds, ocelot->num_phys_ports, port, PGID_BC);
}
/* ocelot->npi was already set to -1 by felix_npi_port_deinit, so
* ocelot_fdb_add() will not redirect FDB entries towards the
* CPU port module here, which is what we want.
*/
static int
felix_migrate_fdbs_to_tag_8021q_port(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid,
struct dsa_db db)
{
struct net_device *bridge_dev = felix_classify_db(db);
struct ocelot *ocelot = ds->priv;
int cpu = ocelot->num_phys_ports;
int err;
err = ocelot_fdb_del(ocelot, cpu, addr, vid, bridge_dev);
if (err)
return err;
return ocelot_fdb_add(ocelot, port, addr, vid, bridge_dev);
}
static int
felix_migrate_mdbs_to_tag_8021q_port(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid,
struct dsa_db db)
{
struct net_device *bridge_dev = felix_classify_db(db);
struct switchdev_obj_port_mdb mdb;
struct ocelot *ocelot = ds->priv;
int cpu = ocelot->num_phys_ports;
int err;
memset(&mdb, 0, sizeof(mdb));
ether_addr_copy(mdb.addr, addr);
mdb.vid = vid;
err = ocelot_port_mdb_del(ocelot, cpu, &mdb, bridge_dev);
if (err)
return err;
return ocelot_port_mdb_add(ocelot, port, &mdb, bridge_dev);
}
/* Set up VCAP ES0 rules for pushing a tag_8021q VLAN towards the CPU such that /* Set up VCAP ES0 rules for pushing a tag_8021q VLAN towards the CPU such that
* the tagger can perform RX source port identification. * the tagger can perform RX source port identification.
*/ */
...@@ -327,10 +462,9 @@ static int felix_update_trapping_destinations(struct dsa_switch *ds, ...@@ -327,10 +462,9 @@ static int felix_update_trapping_destinations(struct dsa_switch *ds,
return 0; return 0;
} }
static int felix_setup_tag_8021q(struct dsa_switch *ds, int cpu) static int felix_setup_tag_8021q(struct dsa_switch *ds, int cpu, bool change)
{ {
struct ocelot *ocelot = ds->priv; struct ocelot *ocelot = ds->priv;
unsigned long cpu_flood;
struct dsa_port *dp; struct dsa_port *dp;
int err; int err;
...@@ -352,22 +486,27 @@ static int felix_setup_tag_8021q(struct dsa_switch *ds, int cpu) ...@@ -352,22 +486,27 @@ static int felix_setup_tag_8021q(struct dsa_switch *ds, int cpu)
ANA_PORT_CPU_FWD_BPDU_CFG, dp->index); ANA_PORT_CPU_FWD_BPDU_CFG, dp->index);
} }
/* In tag_8021q mode, the CPU port module is unused, except for PTP
* frames. So we want to disable flooding of any kind to the CPU port
* module, since packets going there will end in a black hole.
*/
cpu_flood = ANA_PGID_PGID_PGID(BIT(ocelot->num_phys_ports));
ocelot_rmw_rix(ocelot, 0, cpu_flood, ANA_PGID_PGID, PGID_UC);
ocelot_rmw_rix(ocelot, 0, cpu_flood, ANA_PGID_PGID, PGID_MC);
ocelot_rmw_rix(ocelot, 0, cpu_flood, ANA_PGID_PGID, PGID_BC);
err = dsa_tag_8021q_register(ds, htons(ETH_P_8021AD)); err = dsa_tag_8021q_register(ds, htons(ETH_P_8021AD));
if (err) if (err)
return err; return err;
if (change) {
err = dsa_port_walk_fdbs(ds, cpu,
felix_migrate_fdbs_to_tag_8021q_port);
if (err)
goto out_tag_8021q_unregister;
err = dsa_port_walk_mdbs(ds, cpu,
felix_migrate_mdbs_to_tag_8021q_port);
if (err)
goto out_migrate_fdbs;
felix_migrate_flood_to_tag_8021q_port(ds, cpu);
}
err = felix_update_trapping_destinations(ds, true); err = felix_update_trapping_destinations(ds, true);
if (err) if (err)
goto out_tag_8021q_unregister; goto out_migrate_flood;
/* The ownership of the CPU port module's queues might have just been /* The ownership of the CPU port module's queues might have just been
* transferred to the tag_8021q tagger from the NPI-based tagger. * transferred to the tag_8021q tagger from the NPI-based tagger.
...@@ -380,6 +519,14 @@ static int felix_setup_tag_8021q(struct dsa_switch *ds, int cpu) ...@@ -380,6 +519,14 @@ static int felix_setup_tag_8021q(struct dsa_switch *ds, int cpu)
return 0; return 0;
out_migrate_flood:
if (change)
felix_migrate_flood_to_npi_port(ds, cpu);
if (change)
dsa_port_walk_mdbs(ds, cpu, felix_migrate_mdbs_to_npi_port);
out_migrate_fdbs:
if (change)
dsa_port_walk_fdbs(ds, cpu, felix_migrate_fdbs_to_npi_port);
out_tag_8021q_unregister: out_tag_8021q_unregister:
dsa_tag_8021q_unregister(ds); dsa_tag_8021q_unregister(ds);
return err; return err;
...@@ -454,30 +601,35 @@ static void felix_npi_port_deinit(struct ocelot *ocelot, int port) ...@@ -454,30 +601,35 @@ static void felix_npi_port_deinit(struct ocelot *ocelot, int port)
ocelot_fields_write(ocelot, port, SYS_PAUSE_CFG_PAUSE_ENA, 1); ocelot_fields_write(ocelot, port, SYS_PAUSE_CFG_PAUSE_ENA, 1);
} }
static int felix_setup_tag_npi(struct dsa_switch *ds, int cpu) static int felix_setup_tag_npi(struct dsa_switch *ds, int cpu, bool change)
{ {
struct ocelot *ocelot = ds->priv; struct ocelot *ocelot = ds->priv;
unsigned long cpu_flood; int err;
felix_npi_port_init(ocelot, cpu); if (change) {
err = dsa_port_walk_fdbs(ds, cpu,
felix_migrate_fdbs_to_npi_port);
if (err)
return err;
/* Include the CPU port module (and indirectly, the NPI port) err = dsa_port_walk_mdbs(ds, cpu,
* in the forwarding mask for unknown unicast - the hardware felix_migrate_mdbs_to_npi_port);
* default value for ANA_FLOODING_FLD_UNICAST excludes if (err)
* BIT(ocelot->num_phys_ports), and so does ocelot_init, goto out_migrate_fdbs;
* since Ocelot relies on whitelisting MAC addresses towards
* PGID_CPU. felix_migrate_flood_to_npi_port(ds, cpu);
* We do this because DSA does not yet perform RX filtering, }
* and the NPI port does not perform source address learning,
* so traffic sent to Linux is effectively unknown from the felix_npi_port_init(ocelot, cpu);
* switch's perspective.
*/
cpu_flood = ANA_PGID_PGID_PGID(BIT(ocelot->num_phys_ports));
ocelot_rmw_rix(ocelot, cpu_flood, cpu_flood, ANA_PGID_PGID, PGID_UC);
ocelot_rmw_rix(ocelot, cpu_flood, cpu_flood, ANA_PGID_PGID, PGID_MC);
ocelot_rmw_rix(ocelot, cpu_flood, cpu_flood, ANA_PGID_PGID, PGID_BC);
return 0; return 0;
out_migrate_fdbs:
if (change)
dsa_port_walk_fdbs(ds, cpu,
felix_migrate_fdbs_to_tag_8021q_port);
return err;
} }
static void felix_teardown_tag_npi(struct dsa_switch *ds, int cpu) static void felix_teardown_tag_npi(struct dsa_switch *ds, int cpu)
...@@ -488,17 +640,17 @@ static void felix_teardown_tag_npi(struct dsa_switch *ds, int cpu) ...@@ -488,17 +640,17 @@ static void felix_teardown_tag_npi(struct dsa_switch *ds, int cpu)
} }
static int felix_set_tag_protocol(struct dsa_switch *ds, int cpu, static int felix_set_tag_protocol(struct dsa_switch *ds, int cpu,
enum dsa_tag_protocol proto) enum dsa_tag_protocol proto, bool change)
{ {
int err; int err;
switch (proto) { switch (proto) {
case DSA_TAG_PROTO_SEVILLE: case DSA_TAG_PROTO_SEVILLE:
case DSA_TAG_PROTO_OCELOT: case DSA_TAG_PROTO_OCELOT:
err = felix_setup_tag_npi(ds, cpu); err = felix_setup_tag_npi(ds, cpu, change);
break; break;
case DSA_TAG_PROTO_OCELOT_8021Q: case DSA_TAG_PROTO_OCELOT_8021Q:
err = felix_setup_tag_8021q(ds, cpu); err = felix_setup_tag_8021q(ds, cpu, change);
break; break;
default: default:
err = -EPROTONOSUPPORT; err = -EPROTONOSUPPORT;
...@@ -542,9 +694,9 @@ static int felix_change_tag_protocol(struct dsa_switch *ds, int cpu, ...@@ -542,9 +694,9 @@ static int felix_change_tag_protocol(struct dsa_switch *ds, int cpu,
felix_del_tag_protocol(ds, cpu, old_proto); felix_del_tag_protocol(ds, cpu, old_proto);
err = felix_set_tag_protocol(ds, cpu, proto); err = felix_set_tag_protocol(ds, cpu, proto, true);
if (err) { if (err) {
felix_set_tag_protocol(ds, cpu, old_proto); felix_set_tag_protocol(ds, cpu, old_proto, true);
return err; return err;
} }
...@@ -592,23 +744,6 @@ static int felix_fdb_dump(struct dsa_switch *ds, int port, ...@@ -592,23 +744,6 @@ static int felix_fdb_dump(struct dsa_switch *ds, int port,
return ocelot_fdb_dump(ocelot, port, cb, data); return ocelot_fdb_dump(ocelot, port, cb, data);
} }
/* Translate the DSA database API into the ocelot switch library API,
* which uses VID 0 for all ports that aren't part of a bridge,
* and expects the bridge_dev to be NULL in that case.
*/
static struct net_device *felix_classify_db(struct dsa_db db)
{
switch (db.type) {
case DSA_DB_PORT:
case DSA_DB_LAG:
return NULL;
case DSA_DB_BRIDGE:
return db.bridge.dev;
default:
return ERR_PTR(-EOPNOTSUPP);
}
}
static int felix_fdb_add(struct dsa_switch *ds, int port, static int felix_fdb_add(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid, const unsigned char *addr, u16 vid,
struct dsa_db db) struct dsa_db db)
...@@ -1260,7 +1395,7 @@ static int felix_setup(struct dsa_switch *ds) ...@@ -1260,7 +1395,7 @@ static int felix_setup(struct dsa_switch *ds)
/* The initial tag protocol is NPI which always returns 0, so /* The initial tag protocol is NPI which always returns 0, so
* there's no real point in checking for errors. * there's no real point in checking for errors.
*/ */
felix_set_tag_protocol(ds, dp->index, felix->tag_proto); felix_set_tag_protocol(ds, dp->index, felix->tag_proto, false);
break; break;
} }
......
...@@ -2886,6 +2886,9 @@ EXPORT_SYMBOL(ocelot_port_pre_bridge_flags); ...@@ -2886,6 +2886,9 @@ EXPORT_SYMBOL(ocelot_port_pre_bridge_flags);
void ocelot_port_bridge_flags(struct ocelot *ocelot, int port, void ocelot_port_bridge_flags(struct ocelot *ocelot, int port,
struct switchdev_brport_flags flags) struct switchdev_brport_flags flags)
{ {
if (port == ocelot->npi)
port = ocelot->num_phys_ports;
if (flags.mask & BR_LEARNING) if (flags.mask & BR_LEARNING)
ocelot_port_set_learning(ocelot, port, ocelot_port_set_learning(ocelot, port,
!!(flags.val & BR_LEARNING)); !!(flags.val & BR_LEARNING));
......
...@@ -1219,6 +1219,13 @@ struct dsa_switch_driver { ...@@ -1219,6 +1219,13 @@ struct dsa_switch_driver {
struct net_device *dsa_dev_to_net_device(struct device *dev); struct net_device *dsa_dev_to_net_device(struct device *dev);
typedef int dsa_fdb_walk_cb_t(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid,
struct dsa_db db);
int dsa_port_walk_fdbs(struct dsa_switch *ds, int port, dsa_fdb_walk_cb_t cb);
int dsa_port_walk_mdbs(struct dsa_switch *ds, int port, dsa_fdb_walk_cb_t cb);
/* Keep inline for faster access in hot path */ /* Keep inline for faster access in hot path */
static inline bool netdev_uses_dsa(const struct net_device *dev) static inline bool netdev_uses_dsa(const struct net_device *dev)
{ {
......
...@@ -467,6 +467,46 @@ struct dsa_port *dsa_port_from_netdev(struct net_device *netdev) ...@@ -467,6 +467,46 @@ struct dsa_port *dsa_port_from_netdev(struct net_device *netdev)
} }
EXPORT_SYMBOL_GPL(dsa_port_from_netdev); EXPORT_SYMBOL_GPL(dsa_port_from_netdev);
int dsa_port_walk_fdbs(struct dsa_switch *ds, int port, dsa_fdb_walk_cb_t cb)
{
struct dsa_port *dp = dsa_to_port(ds, port);
struct dsa_mac_addr *a;
int err;
mutex_lock(&dp->addr_lists_lock);
list_for_each_entry(a, &dp->fdbs, list) {
err = cb(ds, port, a->addr, a->vid, a->db);
if (err)
break;
}
mutex_unlock(&dp->addr_lists_lock);
return err;
}
EXPORT_SYMBOL_GPL(dsa_port_walk_fdbs);
int dsa_port_walk_mdbs(struct dsa_switch *ds, int port, dsa_fdb_walk_cb_t cb)
{
struct dsa_port *dp = dsa_to_port(ds, port);
struct dsa_mac_addr *a;
int err;
mutex_lock(&dp->addr_lists_lock);
list_for_each_entry(a, &dp->mdbs, list) {
err = cb(ds, port, a->addr, a->vid, a->db);
if (err)
break;
}
mutex_unlock(&dp->addr_lists_lock);
return err;
}
EXPORT_SYMBOL_GPL(dsa_port_walk_mdbs);
static int __init dsa_init_module(void) static int __init dsa_init_module(void)
{ {
int rc; int rc;
......
...@@ -144,6 +144,21 @@ struct dsa_switchdev_event_work { ...@@ -144,6 +144,21 @@ struct dsa_switchdev_event_work {
bool host_addr; bool host_addr;
}; };
enum dsa_standalone_event {
DSA_UC_ADD,
DSA_UC_DEL,
DSA_MC_ADD,
DSA_MC_DEL,
};
struct dsa_standalone_event_work {
struct work_struct work;
struct net_device *dev;
enum dsa_standalone_event event;
unsigned char addr[ETH_ALEN];
u16 vid;
};
struct dsa_slave_priv { struct dsa_slave_priv {
/* Copy of CPU port xmit for faster access in slave transmit hot path */ /* Copy of CPU port xmit for faster access in slave transmit hot path */
struct sk_buff * (*xmit)(struct sk_buff *skb, struct sk_buff * (*xmit)(struct sk_buff *skb,
...@@ -223,10 +238,14 @@ int dsa_port_fdb_add(struct dsa_port *dp, const unsigned char *addr, ...@@ -223,10 +238,14 @@ int dsa_port_fdb_add(struct dsa_port *dp, const unsigned char *addr,
u16 vid); u16 vid);
int dsa_port_fdb_del(struct dsa_port *dp, const unsigned char *addr, int dsa_port_fdb_del(struct dsa_port *dp, const unsigned char *addr,
u16 vid); u16 vid);
int dsa_port_host_fdb_add(struct dsa_port *dp, const unsigned char *addr, int dsa_port_standalone_host_fdb_add(struct dsa_port *dp,
u16 vid); const unsigned char *addr, u16 vid);
int dsa_port_host_fdb_del(struct dsa_port *dp, const unsigned char *addr, int dsa_port_standalone_host_fdb_del(struct dsa_port *dp,
u16 vid); const unsigned char *addr, u16 vid);
int dsa_port_bridge_host_fdb_add(struct dsa_port *dp, const unsigned char *addr,
u16 vid);
int dsa_port_bridge_host_fdb_del(struct dsa_port *dp, const unsigned char *addr,
u16 vid);
int dsa_port_lag_fdb_add(struct dsa_port *dp, const unsigned char *addr, int dsa_port_lag_fdb_add(struct dsa_port *dp, const unsigned char *addr,
u16 vid); u16 vid);
int dsa_port_lag_fdb_del(struct dsa_port *dp, const unsigned char *addr, int dsa_port_lag_fdb_del(struct dsa_port *dp, const unsigned char *addr,
...@@ -236,10 +255,14 @@ int dsa_port_mdb_add(const struct dsa_port *dp, ...@@ -236,10 +255,14 @@ int dsa_port_mdb_add(const struct dsa_port *dp,
const struct switchdev_obj_port_mdb *mdb); const struct switchdev_obj_port_mdb *mdb);
int dsa_port_mdb_del(const struct dsa_port *dp, int dsa_port_mdb_del(const struct dsa_port *dp,
const struct switchdev_obj_port_mdb *mdb); const struct switchdev_obj_port_mdb *mdb);
int dsa_port_host_mdb_add(const struct dsa_port *dp, int dsa_port_standalone_host_mdb_add(const struct dsa_port *dp,
const struct switchdev_obj_port_mdb *mdb); const struct switchdev_obj_port_mdb *mdb);
int dsa_port_host_mdb_del(const struct dsa_port *dp, int dsa_port_standalone_host_mdb_del(const struct dsa_port *dp,
const struct switchdev_obj_port_mdb *mdb); const struct switchdev_obj_port_mdb *mdb);
int dsa_port_bridge_host_mdb_add(const struct dsa_port *dp,
const struct switchdev_obj_port_mdb *mdb);
int dsa_port_bridge_host_mdb_del(const struct dsa_port *dp,
const struct switchdev_obj_port_mdb *mdb);
int dsa_port_pre_bridge_flags(const struct dsa_port *dp, int dsa_port_pre_bridge_flags(const struct dsa_port *dp,
struct switchdev_brport_flags flags, struct switchdev_brport_flags flags,
struct netlink_ext_ack *extack); struct netlink_ext_ack *extack);
...@@ -502,6 +525,20 @@ static inline void *dsa_etype_header_pos_tx(struct sk_buff *skb) ...@@ -502,6 +525,20 @@ static inline void *dsa_etype_header_pos_tx(struct sk_buff *skb)
int dsa_switch_register_notifier(struct dsa_switch *ds); int dsa_switch_register_notifier(struct dsa_switch *ds);
void dsa_switch_unregister_notifier(struct dsa_switch *ds); void dsa_switch_unregister_notifier(struct dsa_switch *ds);
static inline bool dsa_switch_supports_uc_filtering(struct dsa_switch *ds)
{
return ds->ops->port_fdb_add && ds->ops->port_fdb_del &&
ds->fdb_isolation && !ds->vlan_filtering_is_global &&
!ds->needs_standalone_vlan_filtering;
}
static inline bool dsa_switch_supports_mc_filtering(struct dsa_switch *ds)
{
return ds->ops->port_mdb_add && ds->ops->port_mdb_del &&
ds->fdb_isolation && !ds->vlan_filtering_is_global &&
!ds->needs_standalone_vlan_filtering;
}
/* dsa2.c */ /* dsa2.c */
void dsa_lag_map(struct dsa_switch_tree *dst, struct dsa_lag *lag); void dsa_lag_map(struct dsa_switch_tree *dst, struct dsa_lag *lag);
void dsa_lag_unmap(struct dsa_switch_tree *dst, struct dsa_lag *lag); void dsa_lag_unmap(struct dsa_switch_tree *dst, struct dsa_lag *lag);
......
...@@ -835,20 +835,43 @@ int dsa_port_fdb_del(struct dsa_port *dp, const unsigned char *addr, ...@@ -835,20 +835,43 @@ int dsa_port_fdb_del(struct dsa_port *dp, const unsigned char *addr,
return dsa_port_notify(dp, DSA_NOTIFIER_FDB_DEL, &info); return dsa_port_notify(dp, DSA_NOTIFIER_FDB_DEL, &info);
} }
int dsa_port_host_fdb_add(struct dsa_port *dp, const unsigned char *addr, static int dsa_port_host_fdb_add(struct dsa_port *dp,
u16 vid) const unsigned char *addr, u16 vid,
struct dsa_db db)
{ {
struct dsa_notifier_fdb_info info = { struct dsa_notifier_fdb_info info = {
.sw_index = dp->ds->index, .sw_index = dp->ds->index,
.port = dp->index, .port = dp->index,
.addr = addr, .addr = addr,
.vid = vid, .vid = vid,
.db = { .db = db,
.type = DSA_DB_BRIDGE, };
.bridge = *dp->bridge,
}, if (!dp->ds->fdb_isolation)
info.db.bridge.num = 0;
return dsa_port_notify(dp, DSA_NOTIFIER_HOST_FDB_ADD, &info);
}
int dsa_port_standalone_host_fdb_add(struct dsa_port *dp,
const unsigned char *addr, u16 vid)
{
struct dsa_db db = {
.type = DSA_DB_PORT,
.dp = dp,
}; };
return dsa_port_host_fdb_add(dp, addr, vid, db);
}
int dsa_port_bridge_host_fdb_add(struct dsa_port *dp,
const unsigned char *addr, u16 vid)
{
struct dsa_port *cpu_dp = dp->cpu_dp; struct dsa_port *cpu_dp = dp->cpu_dp;
struct dsa_db db = {
.type = DSA_DB_BRIDGE,
.bridge = *dp->bridge,
};
int err; int err;
/* Avoid a call to __dev_set_promiscuity() on the master, which /* Avoid a call to __dev_set_promiscuity() on the master, which
...@@ -861,26 +884,46 @@ int dsa_port_host_fdb_add(struct dsa_port *dp, const unsigned char *addr, ...@@ -861,26 +884,46 @@ int dsa_port_host_fdb_add(struct dsa_port *dp, const unsigned char *addr,
return err; return err;
} }
if (!dp->ds->fdb_isolation) return dsa_port_host_fdb_add(dp, addr, vid, db);
info.db.bridge.num = 0;
return dsa_port_notify(dp, DSA_NOTIFIER_HOST_FDB_ADD, &info);
} }
int dsa_port_host_fdb_del(struct dsa_port *dp, const unsigned char *addr, static int dsa_port_host_fdb_del(struct dsa_port *dp,
u16 vid) const unsigned char *addr, u16 vid,
struct dsa_db db)
{ {
struct dsa_notifier_fdb_info info = { struct dsa_notifier_fdb_info info = {
.sw_index = dp->ds->index, .sw_index = dp->ds->index,
.port = dp->index, .port = dp->index,
.addr = addr, .addr = addr,
.vid = vid, .vid = vid,
.db = { .db = db,
.type = DSA_DB_BRIDGE, };
.bridge = *dp->bridge,
}, if (!dp->ds->fdb_isolation)
info.db.bridge.num = 0;
return dsa_port_notify(dp, DSA_NOTIFIER_HOST_FDB_DEL, &info);
}
int dsa_port_standalone_host_fdb_del(struct dsa_port *dp,
const unsigned char *addr, u16 vid)
{
struct dsa_db db = {
.type = DSA_DB_PORT,
.dp = dp,
}; };
return dsa_port_host_fdb_del(dp, addr, vid, db);
}
int dsa_port_bridge_host_fdb_del(struct dsa_port *dp,
const unsigned char *addr, u16 vid)
{
struct dsa_port *cpu_dp = dp->cpu_dp; struct dsa_port *cpu_dp = dp->cpu_dp;
struct dsa_db db = {
.type = DSA_DB_BRIDGE,
.bridge = *dp->bridge,
};
int err; int err;
if (cpu_dp->master->priv_flags & IFF_UNICAST_FLT) { if (cpu_dp->master->priv_flags & IFF_UNICAST_FLT) {
...@@ -889,10 +932,7 @@ int dsa_port_host_fdb_del(struct dsa_port *dp, const unsigned char *addr, ...@@ -889,10 +932,7 @@ int dsa_port_host_fdb_del(struct dsa_port *dp, const unsigned char *addr,
return err; return err;
} }
if (!dp->ds->fdb_isolation) return dsa_port_host_fdb_del(dp, addr, vid, db);
info.db.bridge.num = 0;
return dsa_port_notify(dp, DSA_NOTIFIER_HOST_FDB_DEL, &info);
} }
int dsa_port_lag_fdb_add(struct dsa_port *dp, const unsigned char *addr, int dsa_port_lag_fdb_add(struct dsa_port *dp, const unsigned char *addr,
...@@ -982,54 +1022,94 @@ int dsa_port_mdb_del(const struct dsa_port *dp, ...@@ -982,54 +1022,94 @@ int dsa_port_mdb_del(const struct dsa_port *dp,
return dsa_port_notify(dp, DSA_NOTIFIER_MDB_DEL, &info); return dsa_port_notify(dp, DSA_NOTIFIER_MDB_DEL, &info);
} }
int dsa_port_host_mdb_add(const struct dsa_port *dp, static int dsa_port_host_mdb_add(const struct dsa_port *dp,
const struct switchdev_obj_port_mdb *mdb) const struct switchdev_obj_port_mdb *mdb,
struct dsa_db db)
{ {
struct dsa_notifier_mdb_info info = { struct dsa_notifier_mdb_info info = {
.sw_index = dp->ds->index, .sw_index = dp->ds->index,
.port = dp->index, .port = dp->index,
.mdb = mdb, .mdb = mdb,
.db = { .db = db,
.type = DSA_DB_BRIDGE, };
.bridge = *dp->bridge,
}, if (!dp->ds->fdb_isolation)
info.db.bridge.num = 0;
return dsa_port_notify(dp, DSA_NOTIFIER_HOST_MDB_ADD, &info);
}
int dsa_port_standalone_host_mdb_add(const struct dsa_port *dp,
const struct switchdev_obj_port_mdb *mdb)
{
struct dsa_db db = {
.type = DSA_DB_PORT,
.dp = dp,
}; };
return dsa_port_host_mdb_add(dp, mdb, db);
}
int dsa_port_bridge_host_mdb_add(const struct dsa_port *dp,
const struct switchdev_obj_port_mdb *mdb)
{
struct dsa_port *cpu_dp = dp->cpu_dp; struct dsa_port *cpu_dp = dp->cpu_dp;
struct dsa_db db = {
.type = DSA_DB_BRIDGE,
.bridge = *dp->bridge,
};
int err; int err;
err = dev_mc_add(cpu_dp->master, mdb->addr); err = dev_mc_add(cpu_dp->master, mdb->addr);
if (err) if (err)
return err; return err;
if (!dp->ds->fdb_isolation) return dsa_port_host_mdb_add(dp, mdb, db);
info.db.bridge.num = 0;
return dsa_port_notify(dp, DSA_NOTIFIER_HOST_MDB_ADD, &info);
} }
int dsa_port_host_mdb_del(const struct dsa_port *dp, static int dsa_port_host_mdb_del(const struct dsa_port *dp,
const struct switchdev_obj_port_mdb *mdb) const struct switchdev_obj_port_mdb *mdb,
struct dsa_db db)
{ {
struct dsa_notifier_mdb_info info = { struct dsa_notifier_mdb_info info = {
.sw_index = dp->ds->index, .sw_index = dp->ds->index,
.port = dp->index, .port = dp->index,
.mdb = mdb, .mdb = mdb,
.db = { .db = db,
.type = DSA_DB_BRIDGE, };
.bridge = *dp->bridge,
}, if (!dp->ds->fdb_isolation)
info.db.bridge.num = 0;
return dsa_port_notify(dp, DSA_NOTIFIER_HOST_MDB_DEL, &info);
}
int dsa_port_standalone_host_mdb_del(const struct dsa_port *dp,
const struct switchdev_obj_port_mdb *mdb)
{
struct dsa_db db = {
.type = DSA_DB_PORT,
.dp = dp,
}; };
return dsa_port_host_mdb_del(dp, mdb, db);
}
int dsa_port_bridge_host_mdb_del(const struct dsa_port *dp,
const struct switchdev_obj_port_mdb *mdb)
{
struct dsa_port *cpu_dp = dp->cpu_dp; struct dsa_port *cpu_dp = dp->cpu_dp;
struct dsa_db db = {
.type = DSA_DB_BRIDGE,
.bridge = *dp->bridge,
};
int err; int err;
err = dev_mc_del(cpu_dp->master, mdb->addr); err = dev_mc_del(cpu_dp->master, mdb->addr);
if (err) if (err)
return err; return err;
if (!dp->ds->fdb_isolation) return dsa_port_host_mdb_del(dp, mdb, db);
info.db.bridge.num = 0;
return dsa_port_notify(dp, DSA_NOTIFIER_HOST_MDB_DEL, &info);
} }
int dsa_port_vlan_add(struct dsa_port *dp, int dsa_port_vlan_add(struct dsa_port *dp,
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment