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 <arkadis@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Arkadi Sharshevsky 2017-08-06 16:15:49 +03:00 committed by David S. Miller
parent dc0cbff3ff
commit 2bedde1abb
12 changed files with 112 additions and 204 deletions

View File

@ -1227,8 +1227,7 @@ static void b53_arl_search_rd(struct b53_device *dev, u8 idx,
} }
static int b53_fdb_copy(int port, const struct b53_arl_entry *ent, static int b53_fdb_copy(int port, const struct b53_arl_entry *ent,
struct switchdev_obj_port_fdb *fdb, dsa_fdb_dump_cb_t *cb, void *data)
switchdev_obj_dump_cb_t *cb)
{ {
if (!ent->is_valid) if (!ent->is_valid)
return 0; return 0;
@ -1236,16 +1235,11 @@ static int b53_fdb_copy(int port, const struct b53_arl_entry *ent,
if (port != ent->port) if (port != ent->port)
return 0; return 0;
ether_addr_copy(fdb->addr, ent->mac); return cb(ent->mac, ent->vid, ent->is_static, data);
fdb->vid = ent->vid;
fdb->ndm_state = ent->is_static ? NUD_NOARP : NUD_REACHABLE;
return cb(&fdb->obj);
} }
int b53_fdb_dump(struct dsa_switch *ds, int port, int b53_fdb_dump(struct dsa_switch *ds, int port,
struct switchdev_obj_port_fdb *fdb, dsa_fdb_dump_cb_t *cb, void *data)
switchdev_obj_dump_cb_t *cb)
{ {
struct b53_device *priv = ds->priv; struct b53_device *priv = ds->priv;
struct b53_arl_entry results[2]; struct b53_arl_entry results[2];
@ -1263,13 +1257,13 @@ int b53_fdb_dump(struct dsa_switch *ds, int port,
return ret; return ret;
b53_arl_search_rd(priv, 0, &results[0]); b53_arl_search_rd(priv, 0, &results[0]);
ret = b53_fdb_copy(port, &results[0], fdb, cb); ret = b53_fdb_copy(port, &results[0], cb, data);
if (ret) if (ret)
return ret; return ret;
if (priv->num_arl_entries > 2) { if (priv->num_arl_entries > 2) {
b53_arl_search_rd(priv, 1, &results[1]); b53_arl_search_rd(priv, 1, &results[1]);
ret = b53_fdb_copy(port, &results[1], fdb, cb); ret = b53_fdb_copy(port, &results[1], cb, data);
if (ret) if (ret)
return ret; return ret;

View File

@ -398,8 +398,7 @@ int b53_fdb_add(struct dsa_switch *ds, int port,
int b53_fdb_del(struct dsa_switch *ds, int port, int b53_fdb_del(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid); const unsigned char *addr, u16 vid);
int b53_fdb_dump(struct dsa_switch *ds, int port, int b53_fdb_dump(struct dsa_switch *ds, int port,
struct switchdev_obj_port_fdb *fdb, dsa_fdb_dump_cb_t *cb, void *data);
switchdev_obj_dump_cb_t *cb);
int b53_mirror_add(struct dsa_switch *ds, int port, int b53_mirror_add(struct dsa_switch *ds, int port,
struct dsa_mall_mirror_tc_entry *mirror, bool ingress); struct dsa_mall_mirror_tc_entry *mirror, bool ingress);
void b53_mirror_del(struct dsa_switch *ds, int port, void b53_mirror_del(struct dsa_switch *ds, int port,

View File

@ -805,12 +805,11 @@ static void convert_alu(struct alu_struct *alu, u32 *alu_table)
} }
static int ksz_port_fdb_dump(struct dsa_switch *ds, int port, static int ksz_port_fdb_dump(struct dsa_switch *ds, int port,
struct switchdev_obj_port_fdb *fdb, dsa_fdb_dump_cb_t *cb, void *data)
switchdev_obj_dump_cb_t *cb)
{ {
struct ksz_device *dev = ds->priv; struct ksz_device *dev = ds->priv;
int ret = 0; int ret = 0;
u32 data; u32 ksz_data;
u32 alu_table[4]; u32 alu_table[4];
struct alu_struct alu; struct alu_struct alu;
int timeout; int timeout;
@ -823,8 +822,8 @@ static int ksz_port_fdb_dump(struct dsa_switch *ds, int port,
do { do {
timeout = 1000; timeout = 1000;
do { do {
ksz_read32(dev, REG_SW_ALU_CTRL__4, &data); ksz_read32(dev, REG_SW_ALU_CTRL__4, &ksz_data);
if ((data & ALU_VALID) || !(data & ALU_START)) if ((ksz_data & ALU_VALID) || !(ksz_data & ALU_START))
break; break;
usleep_range(1, 10); usleep_range(1, 10);
} while (timeout-- > 0); } while (timeout-- > 0);
@ -841,18 +840,11 @@ static int ksz_port_fdb_dump(struct dsa_switch *ds, int port,
convert_alu(&alu, alu_table); convert_alu(&alu, alu_table);
if (alu.port_forward & BIT(port)) { if (alu.port_forward & BIT(port)) {
fdb->vid = alu.fid; ret = cb(alu.mac, alu.fid, alu.is_static, data);
if (alu.is_static)
fdb->ndm_state = NUD_NOARP;
else
fdb->ndm_state = NUD_REACHABLE;
ether_addr_copy(fdb->addr, alu.mac);
ret = cb(&fdb->obj);
if (ret) if (ret)
goto exit; goto exit;
} }
} while (data & ALU_START); } while (ksz_data & ALU_START);
exit: exit:

View File

@ -834,8 +834,7 @@ mt7530_port_fdb_del(struct dsa_switch *ds, int port,
static int static int
mt7530_port_fdb_dump(struct dsa_switch *ds, int port, mt7530_port_fdb_dump(struct dsa_switch *ds, int port,
struct switchdev_obj_port_fdb *fdb, dsa_fdb_dump_cb_t *cb, void *data)
switchdev_obj_dump_cb_t *cb)
{ {
struct mt7530_priv *priv = ds->priv; struct mt7530_priv *priv = ds->priv;
struct mt7530_fdb _fdb = { 0 }; struct mt7530_fdb _fdb = { 0 };
@ -853,11 +852,8 @@ mt7530_port_fdb_dump(struct dsa_switch *ds, int port,
if (rsp & ATC_SRCH_HIT) { if (rsp & ATC_SRCH_HIT) {
mt7530_fdb_read(priv, &_fdb); mt7530_fdb_read(priv, &_fdb);
if (_fdb.port_mask & BIT(port)) { if (_fdb.port_mask & BIT(port)) {
ether_addr_copy(fdb->addr, _fdb.mac); ret = cb(_fdb.mac, _fdb.vid, _fdb.noarp,
fdb->vid = _fdb.vid; data);
fdb->ndm_state = _fdb.noarp ?
NUD_NOARP : NUD_REACHABLE;
ret = cb(&fdb->obj);
if (ret < 0) if (ret < 0)
break; break;
} }

View File

@ -1381,10 +1381,10 @@ static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip, static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
u16 fid, u16 vid, int port, u16 fid, u16 vid, int port,
struct switchdev_obj *obj, dsa_fdb_dump_cb_t *cb, void *data)
switchdev_obj_dump_cb_t *cb)
{ {
struct mv88e6xxx_atu_entry addr; struct mv88e6xxx_atu_entry addr;
bool is_static;
int err; int err;
addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED; addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
@ -1401,24 +1401,12 @@ static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
if (addr.trunk || (addr.portvec & BIT(port)) == 0) if (addr.trunk || (addr.portvec & BIT(port)) == 0)
continue; continue;
if (obj->id == SWITCHDEV_OBJ_ID_PORT_FDB) {
struct switchdev_obj_port_fdb *fdb;
if (!is_unicast_ether_addr(addr.mac)) if (!is_unicast_ether_addr(addr.mac))
continue; continue;
fdb = SWITCHDEV_OBJ_PORT_FDB(obj); is_static = (addr.state ==
fdb->vid = vid; MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
ether_addr_copy(fdb->addr, addr.mac); err = cb(addr.mac, vid, is_static, data);
if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC)
fdb->ndm_state = NUD_NOARP;
else
fdb->ndm_state = NUD_REACHABLE;
} else {
return -EOPNOTSUPP;
}
err = cb(obj);
if (err) if (err)
return err; return err;
} while (!is_broadcast_ether_addr(addr.mac)); } while (!is_broadcast_ether_addr(addr.mac));
@ -1427,8 +1415,7 @@ static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
} }
static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port, static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
struct switchdev_obj *obj, dsa_fdb_dump_cb_t *cb, void *data)
switchdev_obj_dump_cb_t *cb)
{ {
struct mv88e6xxx_vtu_entry vlan = { struct mv88e6xxx_vtu_entry vlan = {
.vid = chip->info->max_vid, .vid = chip->info->max_vid,
@ -1441,7 +1428,7 @@ static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
if (err) if (err)
return err; return err;
err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, obj, cb); err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
if (err) if (err)
return err; return err;
@ -1455,7 +1442,7 @@ static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
break; break;
err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port, err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
obj, cb); cb, data);
if (err) if (err)
return err; return err;
} while (vlan.vid < chip->info->max_vid); } while (vlan.vid < chip->info->max_vid);
@ -1464,14 +1451,13 @@ static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
} }
static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port, static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
struct switchdev_obj_port_fdb *fdb, dsa_fdb_dump_cb_t *cb, void *data)
switchdev_obj_dump_cb_t *cb)
{ {
struct mv88e6xxx_chip *chip = ds->priv; struct mv88e6xxx_chip *chip = ds->priv;
int err; int err;
mutex_lock(&chip->reg_lock); mutex_lock(&chip->reg_lock);
err = mv88e6xxx_port_db_dump(chip, port, &fdb->obj, cb); err = mv88e6xxx_port_db_dump(chip, port, cb, data);
mutex_unlock(&chip->reg_lock); mutex_unlock(&chip->reg_lock);
return err; return err;

View File

@ -801,27 +801,20 @@ qca8k_port_fdb_del(struct dsa_switch *ds, int port,
static int static int
qca8k_port_fdb_dump(struct dsa_switch *ds, int port, qca8k_port_fdb_dump(struct dsa_switch *ds, int port,
struct switchdev_obj_port_fdb *fdb, dsa_fdb_dump_cb_t *cb, void *data)
switchdev_obj_dump_cb_t *cb)
{ {
struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv; struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv;
struct qca8k_fdb _fdb = { 0 }; struct qca8k_fdb _fdb = { 0 };
int cnt = QCA8K_NUM_FDB_RECORDS; int cnt = QCA8K_NUM_FDB_RECORDS;
bool is_static;
int ret = 0; int ret = 0;
mutex_lock(&priv->reg_mutex); mutex_lock(&priv->reg_mutex);
while (cnt-- && !qca8k_fdb_next(priv, &_fdb, port)) { while (cnt-- && !qca8k_fdb_next(priv, &_fdb, port)) {
if (!_fdb.aging) if (!_fdb.aging)
break; break;
is_static = (_fdb.aging == QCA8K_ATU_STATUS_STATIC);
ether_addr_copy(fdb->addr, _fdb.mac); ret = cb(_fdb.mac, _fdb.vid, is_static, data);
fdb->vid = _fdb.vid;
if (_fdb.aging == QCA8K_ATU_STATUS_STATIC)
fdb->ndm_state = NUD_NOARP;
else
fdb->ndm_state = NUD_REACHABLE;
ret = cb(&fdb->obj);
if (ret) if (ret)
break; break;
} }

View File

@ -272,6 +272,8 @@ static inline u8 dsa_upstream_port(struct dsa_switch *ds)
return ds->rtable[dst->cpu_dp->ds->index]; return ds->rtable[dst->cpu_dp->ds->index];
} }
typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid,
bool is_static, void *data);
struct dsa_switch_ops { struct dsa_switch_ops {
/* /*
* Legacy probing. * Legacy probing.
@ -386,8 +388,7 @@ struct dsa_switch_ops {
int (*port_fdb_del)(struct dsa_switch *ds, int port, int (*port_fdb_del)(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid); const unsigned char *addr, u16 vid);
int (*port_fdb_dump)(struct dsa_switch *ds, int port, int (*port_fdb_dump)(struct dsa_switch *ds, int port,
struct switchdev_obj_port_fdb *fdb, dsa_fdb_dump_cb_t *cb, void *data);
switchdev_obj_dump_cb_t *cb);
/* /*
* Multicast database * Multicast database

View File

@ -208,9 +208,6 @@ int switchdev_port_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
int switchdev_port_fdb_del(struct ndmsg *ndm, struct nlattr *tb[], int switchdev_port_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],
struct net_device *dev, const unsigned char *addr, struct net_device *dev, const unsigned char *addr,
u16 vid); u16 vid);
int switchdev_port_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb,
struct net_device *dev,
struct net_device *filter_dev, int *idx);
void switchdev_port_fwd_mark_set(struct net_device *dev, void switchdev_port_fwd_mark_set(struct net_device *dev,
struct net_device *group_dev, struct net_device *group_dev,
bool joining); bool joining);
@ -309,15 +306,6 @@ static inline int switchdev_port_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
static inline int switchdev_port_fdb_dump(struct sk_buff *skb,
struct netlink_callback *cb,
struct net_device *dev,
struct net_device *filter_dev,
int *idx)
{
return *idx;
}
static inline bool switchdev_port_same_parent_id(struct net_device *a, static inline bool switchdev_port_same_parent_id(struct net_device *a,
struct net_device *b) struct net_device *b)
{ {

View File

@ -133,8 +133,6 @@ 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_fdb_dump(struct dsa_port *dp, struct switchdev_obj_port_fdb *fdb,
switchdev_obj_dump_cb_t *cb);
int dsa_port_mdb_add(struct dsa_port *dp, int dsa_port_mdb_add(struct dsa_port *dp,
const struct switchdev_obj_port_mdb *mdb, const struct switchdev_obj_port_mdb *mdb,
struct switchdev_trans *trans); struct switchdev_trans *trans);

View File

@ -173,17 +173,6 @@ 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_fdb_dump(struct dsa_port *dp, struct switchdev_obj_port_fdb *fdb,
switchdev_obj_dump_cb_t *cb)
{
struct dsa_switch *ds = dp->ds;
if (ds->ops->port_fdb_dump)
return ds->ops->port_fdb_dump(ds, dp->index, fdb, cb);
return -EOPNOTSUPP;
}
int dsa_port_mdb_add(struct dsa_port *dp, int dsa_port_mdb_add(struct dsa_port *dp,
const struct switchdev_obj_port_mdb *mdb, const struct switchdev_obj_port_mdb *mdb,
struct switchdev_trans *trans) struct switchdev_trans *trans)

View File

@ -199,6 +199,83 @@ static int dsa_slave_set_mac_address(struct net_device *dev, void *a)
return 0; return 0;
} }
struct dsa_slave_dump_ctx {
struct net_device *dev;
struct sk_buff *skb;
struct netlink_callback *cb;
int idx;
};
static int
dsa_slave_port_fdb_do_dump(const unsigned char *addr, u16 vid,
bool is_static, void *data)
{
struct dsa_slave_dump_ctx *dump = data;
u32 portid = NETLINK_CB(dump->cb->skb).portid;
u32 seq = dump->cb->nlh->nlmsg_seq;
struct nlmsghdr *nlh;
struct ndmsg *ndm;
if (dump->idx < dump->cb->args[2])
goto skip;
nlh = nlmsg_put(dump->skb, portid, seq, RTM_NEWNEIGH,
sizeof(*ndm), NLM_F_MULTI);
if (!nlh)
return -EMSGSIZE;
ndm = nlmsg_data(nlh);
ndm->ndm_family = AF_BRIDGE;
ndm->ndm_pad1 = 0;
ndm->ndm_pad2 = 0;
ndm->ndm_flags = NTF_SELF;
ndm->ndm_type = 0;
ndm->ndm_ifindex = dump->dev->ifindex;
ndm->ndm_state = is_static ? NUD_NOARP : NUD_REACHABLE;
if (nla_put(dump->skb, NDA_LLADDR, ETH_ALEN, addr))
goto nla_put_failure;
if (vid && nla_put_u16(dump->skb, NDA_VLAN, vid))
goto nla_put_failure;
nlmsg_end(dump->skb, nlh);
skip:
dump->idx++;
return 0;
nla_put_failure:
nlmsg_cancel(dump->skb, nlh);
return -EMSGSIZE;
}
static int
dsa_slave_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb,
struct net_device *dev, struct net_device *filter_dev,
int *idx)
{
struct dsa_slave_dump_ctx dump = {
.dev = dev,
.skb = skb,
.cb = cb,
.idx = *idx,
};
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_port *dp = p->dp;
struct dsa_switch *ds = dp->ds;
int err;
if (!ds->ops->port_fdb_dump)
return -EOPNOTSUPP;
err = ds->ops->port_fdb_dump(ds, dp->index,
dsa_slave_port_fdb_do_dump,
&dump);
*idx = dump.idx;
return err;
}
static int dsa_slave_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) static int dsa_slave_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{ {
struct dsa_slave_priv *p = netdev_priv(dev); struct dsa_slave_priv *p = netdev_priv(dev);
@ -287,26 +364,6 @@ static int dsa_slave_port_obj_del(struct net_device *dev,
return err; return err;
} }
static int dsa_slave_port_obj_dump(struct net_device *dev,
struct switchdev_obj *obj,
switchdev_obj_dump_cb_t *cb)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_port *dp = p->dp;
int err;
switch (obj->id) {
case SWITCHDEV_OBJ_ID_PORT_FDB:
err = dsa_port_fdb_dump(dp, SWITCHDEV_OBJ_PORT_FDB(obj), cb);
break;
default:
err = -EOPNOTSUPP;
break;
}
return err;
}
static int dsa_slave_port_attr_get(struct net_device *dev, static int dsa_slave_port_attr_get(struct net_device *dev,
struct switchdev_attr *attr) struct switchdev_attr *attr)
{ {
@ -974,7 +1031,7 @@ static const struct net_device_ops dsa_slave_netdev_ops = {
.ndo_set_mac_address = dsa_slave_set_mac_address, .ndo_set_mac_address = dsa_slave_set_mac_address,
.ndo_fdb_add = dsa_legacy_fdb_add, .ndo_fdb_add = dsa_legacy_fdb_add,
.ndo_fdb_del = dsa_legacy_fdb_del, .ndo_fdb_del = dsa_legacy_fdb_del,
.ndo_fdb_dump = switchdev_port_fdb_dump, .ndo_fdb_dump = dsa_slave_fdb_dump,
.ndo_do_ioctl = dsa_slave_ioctl, .ndo_do_ioctl = dsa_slave_ioctl,
.ndo_get_iflink = dsa_slave_get_iflink, .ndo_get_iflink = dsa_slave_get_iflink,
#ifdef CONFIG_NET_POLL_CONTROLLER #ifdef CONFIG_NET_POLL_CONTROLLER
@ -992,7 +1049,6 @@ static const struct switchdev_ops dsa_slave_switchdev_ops = {
.switchdev_port_attr_set = dsa_slave_port_attr_set, .switchdev_port_attr_set = dsa_slave_port_attr_set,
.switchdev_port_obj_add = dsa_slave_port_obj_add, .switchdev_port_obj_add = dsa_slave_port_obj_add,
.switchdev_port_obj_del = dsa_slave_port_obj_del, .switchdev_port_obj_del = dsa_slave_port_obj_del,
.switchdev_port_obj_dump = dsa_slave_port_obj_dump,
}; };
static struct device_type dsa_type = { static struct device_type dsa_type = {

View File

@ -1009,90 +1009,6 @@ int switchdev_port_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],
} }
EXPORT_SYMBOL_GPL(switchdev_port_fdb_del); EXPORT_SYMBOL_GPL(switchdev_port_fdb_del);
struct switchdev_fdb_dump {
struct switchdev_obj_port_fdb fdb;
struct net_device *dev;
struct sk_buff *skb;
struct netlink_callback *cb;
int idx;
};
static int switchdev_port_fdb_dump_cb(struct switchdev_obj *obj)
{
struct switchdev_obj_port_fdb *fdb = SWITCHDEV_OBJ_PORT_FDB(obj);
struct switchdev_fdb_dump *dump =
container_of(fdb, struct switchdev_fdb_dump, fdb);
u32 portid = NETLINK_CB(dump->cb->skb).portid;
u32 seq = dump->cb->nlh->nlmsg_seq;
struct nlmsghdr *nlh;
struct ndmsg *ndm;
if (dump->idx < dump->cb->args[2])
goto skip;
nlh = nlmsg_put(dump->skb, portid, seq, RTM_NEWNEIGH,
sizeof(*ndm), NLM_F_MULTI);
if (!nlh)
return -EMSGSIZE;
ndm = nlmsg_data(nlh);
ndm->ndm_family = AF_BRIDGE;
ndm->ndm_pad1 = 0;
ndm->ndm_pad2 = 0;
ndm->ndm_flags = NTF_SELF;
ndm->ndm_type = 0;
ndm->ndm_ifindex = dump->dev->ifindex;
ndm->ndm_state = fdb->ndm_state;
if (nla_put(dump->skb, NDA_LLADDR, ETH_ALEN, fdb->addr))
goto nla_put_failure;
if (fdb->vid && nla_put_u16(dump->skb, NDA_VLAN, fdb->vid))
goto nla_put_failure;
nlmsg_end(dump->skb, nlh);
skip:
dump->idx++;
return 0;
nla_put_failure:
nlmsg_cancel(dump->skb, nlh);
return -EMSGSIZE;
}
/**
* switchdev_port_fdb_dump - Dump port FDB (MAC/VLAN) entries
*
* @skb: netlink skb
* @cb: netlink callback
* @dev: port device
* @filter_dev: filter device
* @idx:
*
* Dump FDB entries from switch device.
*/
int switchdev_port_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb,
struct net_device *dev,
struct net_device *filter_dev, int *idx)
{
struct switchdev_fdb_dump dump = {
.fdb.obj.orig_dev = dev,
.fdb.obj.id = SWITCHDEV_OBJ_ID_PORT_FDB,
.dev = dev,
.skb = skb,
.cb = cb,
.idx = *idx,
};
int err;
err = switchdev_port_obj_dump(dev, &dump.fdb.obj,
switchdev_port_fdb_dump_cb);
*idx = dump.idx;
return err;
}
EXPORT_SYMBOL_GPL(switchdev_port_fdb_dump);
bool switchdev_port_same_parent_id(struct net_device *a, bool switchdev_port_same_parent_id(struct net_device *a,
struct net_device *b) struct net_device *b)
{ {