Skip to content

Commit

Permalink
drivers: net: dsa: add fdb entry flags to drivers
Browse files Browse the repository at this point in the history
Ignore fdb entries with set flags coming in on all drivers.

Signed-off-by: Hans J. Schultz <netdev@kapio-technology.com>
  • Loading branch information
Hans J. Schultz authored and intel-lab-lkp committed Oct 10, 2022
1 parent 16361ec commit c43f9a7
Show file tree
Hide file tree
Showing 16 changed files with 122 additions and 42 deletions.
12 changes: 10 additions & 2 deletions drivers/net/dsa/b53/b53_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1684,11 +1684,15 @@ static int b53_arl_op(struct b53_device *dev, int op, int port,

int b53_fdb_add(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid,
struct dsa_db db)
u16 fdb_flags, struct dsa_db db)
{
struct b53_device *priv = ds->priv;
int ret;

/* Ignore entries with set flags */
if (fdb_flags)
return 0;

/* 5325 and 5365 require some more massaging, but could
* be supported eventually
*/
Expand All @@ -1705,11 +1709,15 @@ EXPORT_SYMBOL(b53_fdb_add);

int b53_fdb_del(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid,
struct dsa_db db)
u16 fdb_flags, struct dsa_db db)
{
struct b53_device *priv = ds->priv;
int ret;

/* Ignore entries with set flags */
if (fdb_flags)
return 0;

mutex_lock(&priv->arl_mutex);
ret = b53_arl_op(priv, 0, port, addr, vid, false);
mutex_unlock(&priv->arl_mutex);
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/dsa/b53/b53_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,10 @@ int b53_vlan_del(struct dsa_switch *ds, int port,
const struct switchdev_obj_port_vlan *vlan);
int b53_fdb_add(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid,
struct dsa_db db);
u16 fdb_flags, struct dsa_db db);
int b53_fdb_del(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid,
struct dsa_db db);
u16 fdb_flags, struct dsa_db db);
int b53_fdb_dump(struct dsa_switch *ds, int port,
dsa_fdb_dump_cb_t *cb, void *data);
int b53_mdb_add(struct dsa_switch *ds, int port,
Expand Down
12 changes: 10 additions & 2 deletions drivers/net/dsa/hirschmann/hellcreek.c
Original file line number Diff line number Diff line change
Expand Up @@ -839,12 +839,16 @@ static int hellcreek_fdb_get(struct hellcreek *hellcreek,

static int hellcreek_fdb_add(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid,
struct dsa_db db)
u16 fdb_flags, struct dsa_db db)
{
struct hellcreek_fdb_entry entry = { 0 };
struct hellcreek *hellcreek = ds->priv;
int ret;

/* Ignore entries with set flags */
if (fdb_flags)
return 0;

dev_dbg(hellcreek->dev, "Add FDB entry for MAC=%pM\n", addr);

mutex_lock(&hellcreek->reg_lock);
Expand Down Expand Up @@ -885,12 +889,16 @@ static int hellcreek_fdb_add(struct dsa_switch *ds, int port,

static int hellcreek_fdb_del(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid,
struct dsa_db db)
u16 fdb_flags, struct dsa_db db)
{
struct hellcreek_fdb_entry entry = { 0 };
struct hellcreek *hellcreek = ds->priv;
int ret;

/* Ignore entries with set flags */
if (fdb_flags)
return 0;

dev_dbg(hellcreek->dev, "Delete FDB entry for MAC=%pM\n", addr);

mutex_lock(&hellcreek->reg_lock);
Expand Down
12 changes: 10 additions & 2 deletions drivers/net/dsa/lan9303-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1192,10 +1192,14 @@ static void lan9303_port_fast_age(struct dsa_switch *ds, int port)

static int lan9303_port_fdb_add(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid,
struct dsa_db db)
u16 fdb_flags, struct dsa_db db)
{
struct lan9303 *chip = ds->priv;

/* Ignore entries with set flags */
if (fdb_flags)
return 0;

dev_dbg(chip->dev, "%s(%d, %pM, %d)\n", __func__, port, addr, vid);
if (vid)
return -EOPNOTSUPP;
Expand All @@ -1205,10 +1209,14 @@ static int lan9303_port_fdb_add(struct dsa_switch *ds, int port,

static int lan9303_port_fdb_del(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid,
struct dsa_db db)
u16 fdb_flags, struct dsa_db db)
{
struct lan9303 *chip = ds->priv;

/* Ignore entries with set flags */
if (fdb_flags)
return 0;

dev_dbg(chip->dev, "%s(%d, %pM, %d)\n", __func__, port, addr, vid);
if (vid)
return -EOPNOTSUPP;
Expand Down
12 changes: 10 additions & 2 deletions drivers/net/dsa/lantiq_gswip.c
Original file line number Diff line number Diff line change
Expand Up @@ -1399,15 +1399,23 @@ static int gswip_port_fdb(struct dsa_switch *ds, int port,

static int gswip_port_fdb_add(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid,
struct dsa_db db)
u16 fdb_flags, struct dsa_db db)
{
/* Ignore entries with set flags */
if (fdb_flags)
return 0;

return gswip_port_fdb(ds, port, addr, vid, true);
}

static int gswip_port_fdb_del(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid,
struct dsa_db db)
u16 fdb_flags, struct dsa_db db)
{
/* Ignore entries with set flags */
if (fdb_flags)
return 0;

return gswip_port_fdb(ds, port, addr, vid, false);
}

Expand Down
8 changes: 4 additions & 4 deletions drivers/net/dsa/microchip/ksz9477.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,8 @@ int ksz9477_port_vlan_del(struct ksz_device *dev, int port,
return 0;
}

int ksz9477_fdb_add(struct ksz_device *dev, int port,
const unsigned char *addr, u16 vid, struct dsa_db db)
int ksz9477_fdb_add(struct ksz_device *dev, int port, const unsigned char *addr,
u16 vid, struct dsa_db db)
{
u32 alu_table[4];
u32 data;
Expand Down Expand Up @@ -513,8 +513,8 @@ int ksz9477_fdb_add(struct ksz_device *dev, int port,
return ret;
}

int ksz9477_fdb_del(struct ksz_device *dev, int port,
const unsigned char *addr, u16 vid, struct dsa_db db)
int ksz9477_fdb_del(struct ksz_device *dev, int port, const unsigned char *addr,
u16 vid, struct dsa_db db)
{
u32 alu_table[4];
u32 data;
Expand Down
8 changes: 4 additions & 4 deletions drivers/net/dsa/microchip/ksz9477.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ void ksz9477_get_caps(struct ksz_device *dev, int port,
struct phylink_config *config);
int ksz9477_fdb_dump(struct ksz_device *dev, int port,
dsa_fdb_dump_cb_t *cb, void *data);
int ksz9477_fdb_add(struct ksz_device *dev, int port,
const unsigned char *addr, u16 vid, struct dsa_db db);
int ksz9477_fdb_del(struct ksz_device *dev, int port,
const unsigned char *addr, u16 vid, struct dsa_db db);
int ksz9477_fdb_add(struct ksz_device *dev, int port, const unsigned char *addr,
u16 vid, struct dsa_db db);
int ksz9477_fdb_del(struct ksz_device *dev, int port, const unsigned char *addr,
u16 vid, struct dsa_db db);
int ksz9477_mdb_add(struct ksz_device *dev, int port,
const struct switchdev_obj_port_mdb *mdb, struct dsa_db db);
int ksz9477_mdb_del(struct ksz_device *dev, int port,
Expand Down
14 changes: 11 additions & 3 deletions drivers/net/dsa/microchip/ksz_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -2227,22 +2227,30 @@ static int ksz_set_ageing_time(struct dsa_switch *ds, unsigned int msecs)

static int ksz_port_fdb_add(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid,
struct dsa_db db)
u16 fdb_flags, struct dsa_db db)
{
struct ksz_device *dev = ds->priv;

/* Ignore entries with set flags */
if (fdb_flags)
return 0;

if (!dev->dev_ops->fdb_add)
return -EOPNOTSUPP;

return dev->dev_ops->fdb_add(dev, port, addr, vid, db);
}

static int ksz_port_fdb_del(struct dsa_switch *ds, int port,
const unsigned char *addr,
u16 vid, struct dsa_db db)
const unsigned char *addr, u16 vid,
u16 fdb_flags, struct dsa_db db)
{
struct ksz_device *dev = ds->priv;

/* Ignore entries with set flags */
if (fdb_flags)
return 0;

if (!dev->dev_ops->fdb_del)
return -EOPNOTSUPP;

Expand Down
12 changes: 10 additions & 2 deletions drivers/net/dsa/mt7530.c
Original file line number Diff line number Diff line change
Expand Up @@ -1369,12 +1369,16 @@ mt7530_port_bridge_leave(struct dsa_switch *ds, int port,
static int
mt7530_port_fdb_add(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid,
struct dsa_db db)
u16 fdb_flags, struct dsa_db db)
{
struct mt7530_priv *priv = ds->priv;
int ret;
u8 port_mask = BIT(port);

/* Ignore entries with set flags */
if (fdb_flags)
return 0;

mutex_lock(&priv->reg_mutex);
mt7530_fdb_write(priv, vid, port_mask, addr, -1, STATIC_ENT);
ret = mt7530_fdb_cmd(priv, MT7530_FDB_WRITE, NULL);
Expand All @@ -1386,12 +1390,16 @@ mt7530_port_fdb_add(struct dsa_switch *ds, int port,
static int
mt7530_port_fdb_del(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid,
struct dsa_db db)
u16 fdb_flags, struct dsa_db db)
{
struct mt7530_priv *priv = ds->priv;
int ret;
u8 port_mask = BIT(port);

/* Ignore entries with set flags */
if (fdb_flags)
return 0;

mutex_lock(&priv->reg_mutex);
mt7530_fdb_write(priv, vid, port_mask, addr, -1, STATIC_EMP);
ret = mt7530_fdb_cmd(priv, MT7530_FDB_WRITE, NULL);
Expand Down
12 changes: 10 additions & 2 deletions drivers/net/dsa/mv88e6xxx/chip.c
Original file line number Diff line number Diff line change
Expand Up @@ -2722,11 +2722,15 @@ static int mv88e6xxx_vlan_msti_set(struct dsa_switch *ds,

static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid,
struct dsa_db db)
u16 fdb_flags, struct dsa_db db)
{
struct mv88e6xxx_chip *chip = ds->priv;
int err;

/* Ignore entries with flags set */
if (fdb_flags)
return 0;

mv88e6xxx_reg_lock(chip);
err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Expand All @@ -2737,11 +2741,15 @@ static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,

static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid,
struct dsa_db db)
u16 fdb_flags, struct dsa_db db)
{
struct mv88e6xxx_chip *chip = ds->priv;
int err;

/* Ignore entries with flags set */
if (fdb_flags)
return 0;

mv88e6xxx_reg_lock(chip);
err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, 0);
mv88e6xxx_reg_unlock(chip);
Expand Down
12 changes: 10 additions & 2 deletions drivers/net/dsa/ocelot/felix.c
Original file line number Diff line number Diff line change
Expand Up @@ -782,12 +782,16 @@ static int felix_fdb_dump(struct dsa_switch *ds, int port,

static int felix_fdb_add(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid,
struct dsa_db db)
u16 fdb_flags, struct dsa_db db)
{
struct net_device *bridge_dev = felix_classify_db(db);
struct dsa_port *dp = dsa_to_port(ds, port);
struct ocelot *ocelot = ds->priv;

/* Ignore entries with set flags */
if (fdb_flags)
return 0;

if (IS_ERR(bridge_dev))
return PTR_ERR(bridge_dev);

Expand All @@ -803,12 +807,16 @@ static int felix_fdb_add(struct dsa_switch *ds, int port,

static int felix_fdb_del(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid,
struct dsa_db db)
u16 fdb_flags, struct dsa_db db)
{
struct net_device *bridge_dev = felix_classify_db(db);
struct dsa_port *dp = dsa_to_port(ds, port);
struct ocelot *ocelot = ds->priv;

/* Ignore entries with set flags */
if (fdb_flags)
return 0;

if (IS_ERR(bridge_dev))
return PTR_ERR(bridge_dev);

Expand Down
12 changes: 10 additions & 2 deletions drivers/net/dsa/qca/qca8k-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -795,21 +795,29 @@ int qca8k_port_fdb_insert(struct qca8k_priv *priv, const u8 *addr,

int qca8k_port_fdb_add(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid,
struct dsa_db db)
u16 fdb_flags, struct dsa_db db)
{
struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv;
u16 port_mask = BIT(port);

/* Ignore entries with set flags */
if (fdb_flags)
return 0;

return qca8k_port_fdb_insert(priv, addr, port_mask, vid);
}

int qca8k_port_fdb_del(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid,
struct dsa_db db)
u16 fdb_flags, struct dsa_db db)
{
struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv;
u16 port_mask = BIT(port);

/* Ignore entries with set flags */
if (fdb_flags)
return 0;

if (!vid)
vid = QCA8K_PORT_VID_DEF;

Expand Down
4 changes: 2 additions & 2 deletions drivers/net/dsa/qca/qca8k.h
Original file line number Diff line number Diff line change
Expand Up @@ -479,10 +479,10 @@ int qca8k_port_fdb_insert(struct qca8k_priv *priv, const u8 *addr,
u16 port_mask, u16 vid);
int qca8k_port_fdb_add(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid,
struct dsa_db db);
u16 fdb_flags, struct dsa_db db);
int qca8k_port_fdb_del(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid,
struct dsa_db db);
u16 fdb_flags, struct dsa_db db);
int qca8k_port_fdb_dump(struct dsa_switch *ds, int port,
dsa_fdb_dump_cb_t *cb, void *data);

Expand Down

0 comments on commit c43f9a7

Please sign in to comment.