net: dsa: add port_fdb_dump function
authorVivien Didelot <vivien.didelot@savoirfairelinux.com>
Thu, 22 Oct 2015 13:34:38 +0000 (09:34 -0400)
committerDavid S. Miller <davem@davemloft.net>
Thu, 22 Oct 2015 14:38:35 +0000 (07:38 -0700)
Not all switch chips support a Get Next operation to iterate on its FDB.
So add a more simple port_fdb_dump function for them.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/dsa.h
net/dsa/slave.c

index e00588625bc298874fd7011026e7dcf6ab60e3c0..0cfa44af8fd2458482038e27664eeed3a90fcce8 100644 (file)
@@ -198,6 +198,7 @@ static inline u8 dsa_upstream_port(struct dsa_switch *ds)
 }
 
 struct switchdev_trans;
+struct switchdev_obj;
 struct switchdev_obj_port_fdb;
 
 struct dsa_switch_driver {
@@ -330,6 +331,9 @@ struct dsa_switch_driver {
        int     (*port_fdb_getnext)(struct dsa_switch *ds, int port,
                                    unsigned char *addr, u16 *vid,
                                    bool *is_static);
+       int     (*port_fdb_dump)(struct dsa_switch *ds, int port,
+                                struct switchdev_obj_port_fdb *fdb,
+                                int (*cb)(struct switchdev_obj *obj));
 };
 
 void register_switch_driver(struct dsa_switch_driver *type);
index b0b8da0f5af890efd18fe15ca99e2e56dd428112..d76e62b8dc9c83963b1a865d3720b12a0d199409 100644 (file)
@@ -382,6 +382,9 @@ static int dsa_slave_port_fdb_dump(struct net_device *dev,
        u16 vid = 0;
        int ret;
 
+       if (ds->drv->port_fdb_dump)
+               return ds->drv->port_fdb_dump(ds, p->port, fdb, cb);
+
        if (!ds->drv->port_fdb_getnext)
                return -EOPNOTSUPP;