netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/6] net: dsa: implement port_fdb_dump in drivers
@ 2015-10-13 16:46 Vivien Didelot
  2015-10-13 16:46 ` [PATCH net-next v2 1/6] net: dsa: add port_fdb_dump function Vivien Didelot
                   ` (5 more replies)
  0 siblings, 6 replies; 15+ messages in thread
From: Vivien Didelot @ 2015-10-13 16:46 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, kernel, David S. Miller, Scott Feldman, Jiri Pirko,
	Florian Fainelli, Andrew Lunn, Vivien Didelot

Not all switch chips provide a Get Next kind of operation to dump FDB entries.
It is preferred to let the driver handle the dump operation the way it works
best for the chip. Thus, drop port_fdb_getnext and implement the port_fdb_dump
operation in DSA, which pushes the switchdev FDB dump callback down to the
drivers. mv88e6xxx is the only driver affected and is updated accordingly.

v1 -> v2: fix a few "return err" instead of "goto unlock" in mv88e6xxx.c

Vivien Didelot (6):
  net: dsa: add port_fdb_dump function
  net: dsa: mv88e6xxx: write VID outside of VTU Get Next code
  net: dsa: mv88e6xxx: write MAC outside of ATU Get Next code
  net: dsa: mv88e6xxx: implement port_fdb_dump
  net: dsa: mv88e6xxx: remove port_fdb_getnext
  net: dsa: remove port_fdb_getnext

 drivers/net/dsa/mv88e6171.c |   2 +-
 drivers/net/dsa/mv88e6352.c |   2 +-
 drivers/net/dsa/mv88e6xxx.c | 138 ++++++++++++++++++++++++--------------------
 drivers/net/dsa/mv88e6xxx.h |   5 +-
 include/net/dsa.h           |   8 ++-
 net/dsa/slave.c             |  26 +--------
 6 files changed, 89 insertions(+), 92 deletions(-)

-- 
2.6.1

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH net-next v2 1/6] net: dsa: add port_fdb_dump function
  2015-10-13 16:46 [PATCH net-next v2 0/6] net: dsa: implement port_fdb_dump in drivers Vivien Didelot
@ 2015-10-13 16:46 ` Vivien Didelot
  2015-10-14 13:12   ` David Miller
  2015-10-14 18:49   ` Florian Fainelli
  2015-10-13 16:46 ` [PATCH net-next v2 2/6] net: dsa: mv88e6xxx: write VID outside of VTU Get Next code Vivien Didelot
                   ` (4 subsequent siblings)
  5 siblings, 2 replies; 15+ messages in thread
From: Vivien Didelot @ 2015-10-13 16:46 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, kernel, David S. Miller, Scott Feldman, Jiri Pirko,
	Florian Fainelli, Andrew Lunn, Vivien Didelot

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>
---
 include/net/dsa.h | 5 +++++
 net/dsa/slave.c   | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index e005886..c5c48c5 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -198,7 +198,9 @@ static inline u8 dsa_upstream_port(struct dsa_switch *ds)
 }
 
 struct switchdev_trans;
+struct switchdev_obj;
 struct switchdev_obj_port_fdb;
+typedef int switchdev_obj_dump_cb_t(struct switchdev_obj *obj);
 
 struct dsa_switch_driver {
 	struct list_head	list;
@@ -330,6 +332,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,
+				 switchdev_obj_dump_cb_t *cb);
 };
 
 void register_switch_driver(struct dsa_switch_driver *type);
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 43d7342..a4e3416 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -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;
 
-- 
2.6.1

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH net-next v2 2/6] net: dsa: mv88e6xxx: write VID outside of VTU Get Next code
  2015-10-13 16:46 [PATCH net-next v2 0/6] net: dsa: implement port_fdb_dump in drivers Vivien Didelot
  2015-10-13 16:46 ` [PATCH net-next v2 1/6] net: dsa: add port_fdb_dump function Vivien Didelot
@ 2015-10-13 16:46 ` Vivien Didelot
  2015-10-13 16:46 ` [PATCH net-next v2 3/6] net: dsa: mv88e6xxx: write MAC outside of ATU " Vivien Didelot
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 15+ messages in thread
From: Vivien Didelot @ 2015-10-13 16:46 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, kernel, David S. Miller, Scott Feldman, Jiri Pirko,
	Florian Fainelli, Andrew Lunn, Vivien Didelot

There is no need to write the VLAN ID before every Get Next operation,
since the VTU VID register is not cleared between calls.

Move the VID write call in a _mv88e6xxx_vtu_vid_write function outside
of _mv88e6xxx_vtu_getnext so future code could call VTU Get Next
multiple times and save a few register accesses.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
 drivers/net/dsa/mv88e6xxx.c | 45 ++++++++++++++++++++++++++++++++++-----------
 1 file changed, 34 insertions(+), 11 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 63736f9..8c87b03 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -1259,7 +1259,13 @@ static int _mv88e6xxx_vtu_stu_data_write(struct dsa_switch *ds,
 	return 0;
 }
 
-static int _mv88e6xxx_vtu_getnext(struct dsa_switch *ds, u16 vid,
+static int _mv88e6xxx_vtu_vid_write(struct dsa_switch *ds, u16 vid)
+{
+	return _mv88e6xxx_reg_write(ds, REG_GLOBAL, GLOBAL_VTU_VID,
+				    vid & GLOBAL_VTU_VID_MASK);
+}
+
+static int _mv88e6xxx_vtu_getnext(struct dsa_switch *ds,
 				  struct mv88e6xxx_vtu_stu_entry *entry)
 {
 	struct mv88e6xxx_vtu_stu_entry next = { 0 };
@@ -1269,11 +1275,6 @@ static int _mv88e6xxx_vtu_getnext(struct dsa_switch *ds, u16 vid,
 	if (ret < 0)
 		return ret;
 
-	ret = _mv88e6xxx_reg_write(ds, REG_GLOBAL, GLOBAL_VTU_VID,
-				   vid & GLOBAL_VTU_VID_MASK);
-	if (ret < 0)
-		return ret;
-
 	ret = _mv88e6xxx_vtu_cmd(ds, GLOBAL_VTU_OP_VTU_GET_NEXT);
 	if (ret < 0)
 		return ret;
@@ -1485,7 +1486,12 @@ int mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port, u16 vid,
 	int err;
 
 	mutex_lock(&ps->smi_mutex);
-	err = _mv88e6xxx_vtu_getnext(ds, vid - 1, &vlan);
+
+	err = _mv88e6xxx_vtu_vid_write(ds, vid - 1);
+	if (err)
+		goto unlock;
+
+	err = _mv88e6xxx_vtu_getnext(ds, &vlan);
 	if (err)
 		goto unlock;
 
@@ -1514,7 +1520,11 @@ int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port, u16 vid)
 
 	mutex_lock(&ps->smi_mutex);
 
-	err = _mv88e6xxx_vtu_getnext(ds, vid - 1, &vlan);
+	err = _mv88e6xxx_vtu_vid_write(ds, vid - 1);
+	if (err)
+		goto unlock;
+
+	err = _mv88e6xxx_vtu_getnext(ds, &vlan);
 	if (err)
 		goto unlock;
 
@@ -1558,7 +1568,11 @@ static int _mv88e6xxx_port_vtu_getnext(struct dsa_switch *ds, int port, u16 vid,
 		if (vid == 4095)
 			return -ENOENT;
 
-		err = _mv88e6xxx_vtu_getnext(ds, vid, entry);
+		err = _mv88e6xxx_vtu_vid_write(ds, vid);
+		if (err)
+			return err;
+
+		err = _mv88e6xxx_vtu_getnext(ds, entry);
 		if (err)
 			return err;
 
@@ -1584,7 +1598,12 @@ int mv88e6xxx_vlan_getnext(struct dsa_switch *ds, u16 *vid,
 		return -ENOENT;
 
 	mutex_lock(&ps->smi_mutex);
-	err = _mv88e6xxx_vtu_getnext(ds, *vid, &next);
+	err = _mv88e6xxx_vtu_vid_write(ds, *vid);
+	if (err)
+		goto unlock;
+
+	err = _mv88e6xxx_vtu_getnext(ds, &next);
+unlock:
 	mutex_unlock(&ps->smi_mutex);
 
 	if (err)
@@ -2274,10 +2293,14 @@ static int mv88e6xxx_vtu_show(struct seq_file *s, void *p)
 
 	mutex_lock(&ps->smi_mutex);
 
+	ret = _mv88e6xxx_vtu_vid_write(ds, vid);
+	if (ret < 0)
+		goto unlock;
+
 	do {
 		struct mv88e6xxx_vtu_stu_entry next = { 0 };
 
-		ret = _mv88e6xxx_vtu_getnext(ds, vid, &next);
+		ret = _mv88e6xxx_vtu_getnext(ds, &next);
 		if (ret < 0)
 			goto unlock;
 
-- 
2.6.1

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH net-next v2 3/6] net: dsa: mv88e6xxx: write MAC outside of ATU Get Next code
  2015-10-13 16:46 [PATCH net-next v2 0/6] net: dsa: implement port_fdb_dump in drivers Vivien Didelot
  2015-10-13 16:46 ` [PATCH net-next v2 1/6] net: dsa: add port_fdb_dump function Vivien Didelot
  2015-10-13 16:46 ` [PATCH net-next v2 2/6] net: dsa: mv88e6xxx: write VID outside of VTU Get Next code Vivien Didelot
@ 2015-10-13 16:46 ` Vivien Didelot
  2015-10-13 17:35   ` Florian Fainelli
  2015-10-13 18:48   ` Vivien Didelot
  2015-10-13 16:46 ` [PATCH net-next v2 4/6] net: dsa: mv88e6xxx: implement port_fdb_dump Vivien Didelot
                   ` (2 subsequent siblings)
  5 siblings, 2 replies; 15+ messages in thread
From: Vivien Didelot @ 2015-10-13 16:46 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, kernel, David S. Miller, Scott Feldman, Jiri Pirko,
	Florian Fainelli, Andrew Lunn, Vivien Didelot

There is no need to write the MAC address before every Get Next
operation, since ATU MAC registers are not cleared between calls.

Move the _mv88e6xxx_atu_mac_write call outside of _mv88e6xxx_atu_getnext
so future code could call ATU Get Next multiple times and save a few
register access.
---
 drivers/net/dsa/mv88e6xxx.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 8c87b03..7b15b98 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -1751,7 +1751,6 @@ int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
 }
 
 static int _mv88e6xxx_atu_getnext(struct dsa_switch *ds, u16 fid,
-				  const unsigned char *addr,
 				  struct mv88e6xxx_atu_entry *entry)
 {
 	struct mv88e6xxx_atu_entry next = { 0 };
@@ -1763,10 +1762,6 @@ static int _mv88e6xxx_atu_getnext(struct dsa_switch *ds, u16 fid,
 	if (ret < 0)
 		return ret;
 
-	ret = _mv88e6xxx_atu_mac_write(ds, addr);
-	if (ret < 0)
-		return ret;
-
 	ret = _mv88e6xxx_reg_write(ds, REG_GLOBAL, GLOBAL_ATU_FID, fid);
 	if (ret < 0)
 		return ret;
@@ -1827,7 +1822,11 @@ int mv88e6xxx_port_fdb_getnext(struct dsa_switch *ds, int port,
 			fid = vtu.fid;
 		}
 
-		ret = _mv88e6xxx_atu_getnext(ds, fid, addr, &next);
+		ret = _mv88e6xxx_atu_mac_write(ds, addr);
+		if (ret < 0)
+			goto unlock;
+
+		ret = _mv88e6xxx_atu_getnext(ds, fid, &next);
 		if (ret < 0)
 			goto unlock;
 
-- 
2.6.1

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH net-next v2 4/6] net: dsa: mv88e6xxx: implement port_fdb_dump
  2015-10-13 16:46 [PATCH net-next v2 0/6] net: dsa: implement port_fdb_dump in drivers Vivien Didelot
                   ` (2 preceding siblings ...)
  2015-10-13 16:46 ` [PATCH net-next v2 3/6] net: dsa: mv88e6xxx: write MAC outside of ATU " Vivien Didelot
@ 2015-10-13 16:46 ` Vivien Didelot
  2015-10-14 17:38   ` Scott Feldman
  2015-10-13 16:46 ` [PATCH net-next v2 5/6] net: dsa: mv88e6xxx: remove port_fdb_getnext Vivien Didelot
  2015-10-13 16:46 ` [PATCH net-next v2 6/6] net: dsa: " Vivien Didelot
  5 siblings, 1 reply; 15+ messages in thread
From: Vivien Didelot @ 2015-10-13 16:46 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, kernel, David S. Miller, Scott Feldman, Jiri Pirko,
	Florian Fainelli, Andrew Lunn, Vivien Didelot

Implement the port_fdb_dump DSA operation.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
 drivers/net/dsa/mv88e6171.c |  1 +
 drivers/net/dsa/mv88e6352.c |  1 +
 drivers/net/dsa/mv88e6xxx.c | 65 +++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/dsa/mv88e6xxx.h |  3 +++
 4 files changed, 70 insertions(+)

diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c
index dfca352..489deb8 100644
--- a/drivers/net/dsa/mv88e6171.c
+++ b/drivers/net/dsa/mv88e6171.c
@@ -123,6 +123,7 @@ struct dsa_switch_driver mv88e6171_switch_driver = {
 	.port_fdb_add		= mv88e6xxx_port_fdb_add,
 	.port_fdb_del		= mv88e6xxx_port_fdb_del,
 	.port_fdb_getnext	= mv88e6xxx_port_fdb_getnext,
+	.port_fdb_dump		= mv88e6xxx_port_fdb_dump,
 };
 
 MODULE_ALIAS("platform:mv88e6171");
diff --git a/drivers/net/dsa/mv88e6352.c b/drivers/net/dsa/mv88e6352.c
index 796fdcb..6b8fd24 100644
--- a/drivers/net/dsa/mv88e6352.c
+++ b/drivers/net/dsa/mv88e6352.c
@@ -350,6 +350,7 @@ struct dsa_switch_driver mv88e6352_switch_driver = {
 	.port_fdb_add		= mv88e6xxx_port_fdb_add,
 	.port_fdb_del		= mv88e6xxx_port_fdb_del,
 	.port_fdb_getnext	= mv88e6xxx_port_fdb_getnext,
+	.port_fdb_dump		= mv88e6xxx_port_fdb_dump,
 };
 
 MODULE_ALIAS("platform:mv88e6172");
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 7b15b98..a1740b4 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -1799,6 +1799,71 @@ static int _mv88e6xxx_atu_getnext(struct dsa_switch *ds, u16 fid,
 	return 0;
 }
 
+int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
+			    struct switchdev_obj_port_fdb *fdb,
+			    switchdev_obj_dump_cb_t *cb)
+{
+	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
+	struct mv88e6xxx_vtu_stu_entry vlan = {
+		.vid = GLOBAL_VTU_VID_MASK, /* all ones */
+	};
+	int err;
+
+	mutex_lock(&ps->smi_mutex);
+
+	err = _mv88e6xxx_vtu_vid_write(ds, vlan.vid);
+	if (err)
+		goto unlock;
+
+	do {
+		struct mv88e6xxx_atu_entry addr = {
+			.mac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
+		};
+
+		err = _mv88e6xxx_vtu_getnext(ds, &vlan);
+		if (err)
+			goto unlock;
+
+		if (!vlan.valid)
+			break;
+
+		err = _mv88e6xxx_atu_mac_write(ds, addr.mac);
+		if (err)
+			goto unlock;
+
+		do {
+			err = _mv88e6xxx_atu_getnext(ds, vlan.fid, &addr);
+			if (err)
+				goto unlock;
+
+			if (addr.state == GLOBAL_ATU_DATA_STATE_UNUSED)
+				break;
+
+			if (!addr.trunk && addr.portv_trunkid & BIT(port)) {
+				bool is_static = addr.state ==
+					(is_multicast_ether_addr(addr.mac) ?
+					 GLOBAL_ATU_DATA_STATE_MC_STATIC :
+					 GLOBAL_ATU_DATA_STATE_UC_STATIC);
+
+				fdb->vid = vlan.vid;
+				fdb->addr = addr.mac;
+				fdb->ndm_state = is_static ? NUD_NOARP :
+					NUD_REACHABLE;
+
+				err = cb(&fdb->obj);
+				if (err)
+					goto unlock;
+			}
+		} while (!is_broadcast_ether_addr(addr.mac));
+
+	} while (vlan.vid < GLOBAL_VTU_VID_MASK);
+
+unlock:
+	mutex_unlock(&ps->smi_mutex);
+
+	return err;
+}
+
 /* get next entry for port */
 int mv88e6xxx_port_fdb_getnext(struct dsa_switch *ds, int port,
 			       unsigned char *addr, u16 *vid, bool *is_static)
diff --git a/drivers/net/dsa/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx.h
index ba94f17..08e0fbb 100644
--- a/drivers/net/dsa/mv88e6xxx.h
+++ b/drivers/net/dsa/mv88e6xxx.h
@@ -481,6 +481,9 @@ int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
 			   const struct switchdev_obj_port_fdb *fdb);
 int mv88e6xxx_port_fdb_getnext(struct dsa_switch *ds, int port,
 			       unsigned char *addr, u16 *vid, bool *is_static);
+int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
+			    struct switchdev_obj_port_fdb *fdb,
+			    switchdev_obj_dump_cb_t *cb);
 int mv88e6xxx_phy_page_read(struct dsa_switch *ds, int port, int page, int reg);
 int mv88e6xxx_phy_page_write(struct dsa_switch *ds, int port, int page,
 			     int reg, int val);
-- 
2.6.1

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH net-next v2 5/6] net: dsa: mv88e6xxx: remove port_fdb_getnext
  2015-10-13 16:46 [PATCH net-next v2 0/6] net: dsa: implement port_fdb_dump in drivers Vivien Didelot
                   ` (3 preceding siblings ...)
  2015-10-13 16:46 ` [PATCH net-next v2 4/6] net: dsa: mv88e6xxx: implement port_fdb_dump Vivien Didelot
@ 2015-10-13 16:46 ` Vivien Didelot
  2015-10-13 16:46 ` [PATCH net-next v2 6/6] net: dsa: " Vivien Didelot
  5 siblings, 0 replies; 15+ messages in thread
From: Vivien Didelot @ 2015-10-13 16:46 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, kernel, David S. Miller, Scott Feldman, Jiri Pirko,
	Florian Fainelli, Andrew Lunn, Vivien Didelot

Now that port_fdb_dump is implemented and even simpler, get rid of
port_fdb_getnext.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
 drivers/net/dsa/mv88e6171.c |  1 -
 drivers/net/dsa/mv88e6352.c |  1 -
 drivers/net/dsa/mv88e6xxx.c | 73 ---------------------------------------------
 drivers/net/dsa/mv88e6xxx.h |  2 --
 4 files changed, 77 deletions(-)

diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c
index 489deb8..2c8eb6f 100644
--- a/drivers/net/dsa/mv88e6171.c
+++ b/drivers/net/dsa/mv88e6171.c
@@ -122,7 +122,6 @@ struct dsa_switch_driver mv88e6171_switch_driver = {
 	.port_fdb_prepare	= mv88e6xxx_port_fdb_prepare,
 	.port_fdb_add		= mv88e6xxx_port_fdb_add,
 	.port_fdb_del		= mv88e6xxx_port_fdb_del,
-	.port_fdb_getnext	= mv88e6xxx_port_fdb_getnext,
 	.port_fdb_dump		= mv88e6xxx_port_fdb_dump,
 };
 
diff --git a/drivers/net/dsa/mv88e6352.c b/drivers/net/dsa/mv88e6352.c
index 6b8fd24..cbf4dd8 100644
--- a/drivers/net/dsa/mv88e6352.c
+++ b/drivers/net/dsa/mv88e6352.c
@@ -349,7 +349,6 @@ struct dsa_switch_driver mv88e6352_switch_driver = {
 	.port_fdb_prepare	= mv88e6xxx_port_fdb_prepare,
 	.port_fdb_add		= mv88e6xxx_port_fdb_add,
 	.port_fdb_del		= mv88e6xxx_port_fdb_del,
-	.port_fdb_getnext	= mv88e6xxx_port_fdb_getnext,
 	.port_fdb_dump		= mv88e6xxx_port_fdb_dump,
 };
 
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index a1740b4..980460a 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -1559,33 +1559,6 @@ unlock:
 	return err;
 }
 
-static int _mv88e6xxx_port_vtu_getnext(struct dsa_switch *ds, int port, u16 vid,
-				       struct mv88e6xxx_vtu_stu_entry *entry)
-{
-	int err;
-
-	do {
-		if (vid == 4095)
-			return -ENOENT;
-
-		err = _mv88e6xxx_vtu_vid_write(ds, vid);
-		if (err)
-			return err;
-
-		err = _mv88e6xxx_vtu_getnext(ds, entry);
-		if (err)
-			return err;
-
-		if (!entry->valid)
-			return -ENOENT;
-
-		vid = entry->vid;
-	} while (entry->data[port] != GLOBAL_VTU_DATA_MEMBER_TAG_TAGGED &&
-		 entry->data[port] != GLOBAL_VTU_DATA_MEMBER_TAG_UNTAGGED);
-
-	return 0;
-}
-
 int mv88e6xxx_vlan_getnext(struct dsa_switch *ds, u16 *vid,
 			   unsigned long *ports, unsigned long *untagged)
 {
@@ -1864,52 +1837,6 @@ unlock:
 	return err;
 }
 
-/* get next entry for port */
-int mv88e6xxx_port_fdb_getnext(struct dsa_switch *ds, int port,
-			       unsigned char *addr, u16 *vid, bool *is_static)
-{
-	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
-	struct mv88e6xxx_atu_entry next;
-	u16 fid = *vid; /* We use one FID per VLAN */
-	int ret;
-
-	mutex_lock(&ps->smi_mutex);
-
-	do {
-		if (is_broadcast_ether_addr(addr)) {
-			struct mv88e6xxx_vtu_stu_entry vtu;
-
-			ret = _mv88e6xxx_port_vtu_getnext(ds, port, *vid, &vtu);
-			if (ret < 0)
-				goto unlock;
-
-			*vid = vtu.vid;
-			fid = vtu.fid;
-		}
-
-		ret = _mv88e6xxx_atu_mac_write(ds, addr);
-		if (ret < 0)
-			goto unlock;
-
-		ret = _mv88e6xxx_atu_getnext(ds, fid, &next);
-		if (ret < 0)
-			goto unlock;
-
-		ether_addr_copy(addr, next.mac);
-
-		if (next.state == GLOBAL_ATU_DATA_STATE_UNUSED)
-			continue;
-	} while (next.trunk || (next.portv_trunkid & BIT(port)) == 0);
-
-	*is_static = next.state == (is_multicast_ether_addr(addr) ?
-				    GLOBAL_ATU_DATA_STATE_MC_STATIC :
-				    GLOBAL_ATU_DATA_STATE_UC_STATIC);
-unlock:
-	mutex_unlock(&ps->smi_mutex);
-
-	return ret;
-}
-
 static void mv88e6xxx_bridge_work(struct work_struct *work)
 {
 	struct mv88e6xxx_priv_state *ps;
diff --git a/drivers/net/dsa/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx.h
index 08e0fbb..c921427 100644
--- a/drivers/net/dsa/mv88e6xxx.h
+++ b/drivers/net/dsa/mv88e6xxx.h
@@ -479,8 +479,6 @@ int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
 			   struct switchdev_trans *trans);
 int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
 			   const struct switchdev_obj_port_fdb *fdb);
-int mv88e6xxx_port_fdb_getnext(struct dsa_switch *ds, int port,
-			       unsigned char *addr, u16 *vid, bool *is_static);
 int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
 			    struct switchdev_obj_port_fdb *fdb,
 			    switchdev_obj_dump_cb_t *cb);
-- 
2.6.1

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH net-next v2 6/6] net: dsa: remove port_fdb_getnext
  2015-10-13 16:46 [PATCH net-next v2 0/6] net: dsa: implement port_fdb_dump in drivers Vivien Didelot
                   ` (4 preceding siblings ...)
  2015-10-13 16:46 ` [PATCH net-next v2 5/6] net: dsa: mv88e6xxx: remove port_fdb_getnext Vivien Didelot
@ 2015-10-13 16:46 ` Vivien Didelot
  2015-10-14 18:50   ` Florian Fainelli
  5 siblings, 1 reply; 15+ messages in thread
From: Vivien Didelot @ 2015-10-13 16:46 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, kernel, David S. Miller, Scott Feldman, Jiri Pirko,
	Florian Fainelli, Andrew Lunn, Vivien Didelot

No driver implements port_fdb_getnext anymore, and port_fdb_dump is
preferred anyway, so remove this function from DSA.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
 include/net/dsa.h |  3 ---
 net/dsa/slave.c   | 25 +------------------------
 2 files changed, 1 insertion(+), 27 deletions(-)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index c5c48c5..d8ab2f9 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -329,9 +329,6 @@ struct dsa_switch_driver {
 				struct switchdev_trans *trans);
 	int	(*port_fdb_del)(struct dsa_switch *ds, int port,
 				const struct switchdev_obj_port_fdb *fdb);
-	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,
 				 switchdev_obj_dump_cb_t *cb);
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index a4e3416..5908893 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -378,34 +378,11 @@ static int dsa_slave_port_fdb_dump(struct net_device *dev,
 {
 	struct dsa_slave_priv *p = netdev_priv(dev);
 	struct dsa_switch *ds = p->parent;
-	unsigned char addr[ETH_ALEN] = { 0 };
-	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;
-
-	for (;;) {
-		bool is_static;
-
-		ret = ds->drv->port_fdb_getnext(ds, p->port, addr, &vid,
-						&is_static);
-		if (ret < 0)
-			break;
-
-		fdb->addr = addr;
-		fdb->vid = vid;
-		fdb->ndm_state = is_static ? NUD_NOARP : NUD_REACHABLE;
-
-		ret = cb(&fdb->obj);
-		if (ret < 0)
-			break;
-	}
-
-	return ret == -ENOENT ? 0 : ret;
+	return -EOPNOTSUPP;
 }
 
 static int dsa_slave_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
-- 
2.6.1

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH net-next v2 3/6] net: dsa: mv88e6xxx: write MAC outside of ATU Get Next code
  2015-10-13 16:46 ` [PATCH net-next v2 3/6] net: dsa: mv88e6xxx: write MAC outside of ATU " Vivien Didelot
@ 2015-10-13 17:35   ` Florian Fainelli
  2015-10-13 18:11     ` Vivien Didelot
  2015-10-13 18:48   ` Vivien Didelot
  1 sibling, 1 reply; 15+ messages in thread
From: Florian Fainelli @ 2015-10-13 17:35 UTC (permalink / raw)
  To: Vivien Didelot, netdev
  Cc: linux-kernel, kernel, David S. Miller, Scott Feldman, Jiri Pirko,
	Andrew Lunn

On 13/10/15 09:46, Vivien Didelot wrote:
> There is no need to write the MAC address before every Get Next
> operation, since ATU MAC registers are not cleared between calls.
> 
> Move the _mv88e6xxx_atu_mac_write call outside of _mv88e6xxx_atu_getnext
> so future code could call ATU Get Next multiple times and save a few
> register access.

Missing SoB tag here.
-- 
Florian

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH net-next v2 3/6] net: dsa: mv88e6xxx: write MAC outside of ATU Get Next code
  2015-10-13 17:35   ` Florian Fainelli
@ 2015-10-13 18:11     ` Vivien Didelot
  2015-10-13 18:43       ` Florian Fainelli
  0 siblings, 1 reply; 15+ messages in thread
From: Vivien Didelot @ 2015-10-13 18:11 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: netdev, linux-kernel, kernel, David S. Miller, Scott Feldman,
	Jiri Pirko, Andrew Lunn

On Oct. Tuesday 13 (42) 10:35 AM, Florian Fainelli wrote:
> On 13/10/15 09:46, Vivien Didelot wrote:
> > There is no need to write the MAC address before every Get Next
> > operation, since ATU MAC registers are not cleared between calls.
> > 
> > Move the _mv88e6xxx_atu_mac_write call outside of _mv88e6xxx_atu_getnext
> > so future code could call ATU Get Next multiple times and save a few
> > register access.
> 
> Missing SoB tag here.

Damn, good catch. Can I add it in reply to the patch, or should I send a
v3?

Thanks,
-v

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH net-next v2 3/6] net: dsa: mv88e6xxx: write MAC outside of ATU Get Next code
  2015-10-13 18:11     ` Vivien Didelot
@ 2015-10-13 18:43       ` Florian Fainelli
  0 siblings, 0 replies; 15+ messages in thread
From: Florian Fainelli @ 2015-10-13 18:43 UTC (permalink / raw)
  To: Vivien Didelot
  Cc: netdev, linux-kernel, kernel, David S. Miller, Scott Feldman,
	Jiri Pirko, Andrew Lunn

On 13/10/15 11:11, Vivien Didelot wrote:
> On Oct. Tuesday 13 (42) 10:35 AM, Florian Fainelli wrote:
>> On 13/10/15 09:46, Vivien Didelot wrote:
>>> There is no need to write the MAC address before every Get Next
>>> operation, since ATU MAC registers are not cleared between calls.
>>>
>>> Move the _mv88e6xxx_atu_mac_write call outside of _mv88e6xxx_atu_getnext
>>> so future code could call ATU Get Next multiple times and save a few
>>> register access.
>>
>> Missing SoB tag here.
> 
> Damn, good catch. Can I add it in reply to the patch, or should I send a
> v3?

I am fairly positive patchwork should be able to pick it up, so replying
to your patch might just do it fine.
-- 
Florian

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH net-next v2 3/6] net: dsa: mv88e6xxx: write MAC outside of ATU Get Next code
  2015-10-13 16:46 ` [PATCH net-next v2 3/6] net: dsa: mv88e6xxx: write MAC outside of ATU " Vivien Didelot
  2015-10-13 17:35   ` Florian Fainelli
@ 2015-10-13 18:48   ` Vivien Didelot
  1 sibling, 0 replies; 15+ messages in thread
From: Vivien Didelot @ 2015-10-13 18:48 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, kernel, David S. Miller, Scott Feldman, Jiri Pirko,
	Florian Fainelli, Andrew Lunn

On Oct. Tuesday 13 (42) 12:46 PM, Vivien Didelot wrote:
> There is no need to write the MAC address before every Get Next
> operation, since ATU MAC registers are not cleared between calls.
> 
> Move the _mv88e6xxx_atu_mac_write call outside of _mv88e6xxx_atu_getnext
> so future code could call ATU Get Next multiple times and save a few
> register access.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH net-next v2 1/6] net: dsa: add port_fdb_dump function
  2015-10-13 16:46 ` [PATCH net-next v2 1/6] net: dsa: add port_fdb_dump function Vivien Didelot
@ 2015-10-14 13:12   ` David Miller
  2015-10-14 18:49   ` Florian Fainelli
  1 sibling, 0 replies; 15+ messages in thread
From: David Miller @ 2015-10-14 13:12 UTC (permalink / raw)
  To: vivien.didelot
  Cc: netdev, linux-kernel, kernel, sfeldma, jiri, f.fainelli, andrew

From: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Date: Tue, 13 Oct 2015 12:46:18 -0400

> @@ -198,7 +198,9 @@ static inline u8 dsa_upstream_port(struct dsa_switch *ds)
>  }
>  
>  struct switchdev_trans;
> +struct switchdev_obj;
>  struct switchdev_obj_port_fdb;
> +typedef int switchdev_obj_dump_cb_t(struct switchdev_obj *obj);
>  
>  struct dsa_switch_driver {
>  	struct list_head	list;
 ...
> @@ -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)

I realize you're fighting include file dependency issues, but this is
rediculous.  Now you're using two different typedefs for this callback
function pointer.

This is why typedef's suck.

We should just opencode "int (*cb)(struct switchdev_obj *)" everywhere
and kill these typedefs which are obviously just getting in the way
and making us do silly things.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH net-next v2 4/6] net: dsa: mv88e6xxx: implement port_fdb_dump
  2015-10-13 16:46 ` [PATCH net-next v2 4/6] net: dsa: mv88e6xxx: implement port_fdb_dump Vivien Didelot
@ 2015-10-14 17:38   ` Scott Feldman
  0 siblings, 0 replies; 15+ messages in thread
From: Scott Feldman @ 2015-10-14 17:38 UTC (permalink / raw)
  To: Vivien Didelot
  Cc: Netdev, linux-kernel@vger.kernel.org, kernel, David S. Miller,
	Jiri Pirko, Florian Fainelli, Andrew Lunn

On Tue, Oct 13, 2015 at 9:46 AM, Vivien Didelot
<vivien.didelot@savoirfairelinux.com> wrote:
> Implement the port_fdb_dump DSA operation.
>
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>

Reviewed-by: Scott Feldman <sfeldma@gmail.com>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH net-next v2 1/6] net: dsa: add port_fdb_dump function
  2015-10-13 16:46 ` [PATCH net-next v2 1/6] net: dsa: add port_fdb_dump function Vivien Didelot
  2015-10-14 13:12   ` David Miller
@ 2015-10-14 18:49   ` Florian Fainelli
  1 sibling, 0 replies; 15+ messages in thread
From: Florian Fainelli @ 2015-10-14 18:49 UTC (permalink / raw)
  To: Vivien Didelot, netdev
  Cc: linux-kernel, kernel, David S. Miller, Scott Feldman, Jiri Pirko,
	Andrew Lunn

On 13/10/15 09:46, Vivien Didelot wrote:
> 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>

Acked-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH net-next v2 6/6] net: dsa: remove port_fdb_getnext
  2015-10-13 16:46 ` [PATCH net-next v2 6/6] net: dsa: " Vivien Didelot
@ 2015-10-14 18:50   ` Florian Fainelli
  0 siblings, 0 replies; 15+ messages in thread
From: Florian Fainelli @ 2015-10-14 18:50 UTC (permalink / raw)
  To: Vivien Didelot, netdev
  Cc: linux-kernel, kernel, David S. Miller, Scott Feldman, Jiri Pirko,
	Andrew Lunn

On 13/10/15 09:46, Vivien Didelot wrote:
> No driver implements port_fdb_getnext anymore, and port_fdb_dump is
> preferred anyway, so remove this function from DSA.
> 
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>

Acked-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2015-10-14 18:50 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-13 16:46 [PATCH net-next v2 0/6] net: dsa: implement port_fdb_dump in drivers Vivien Didelot
2015-10-13 16:46 ` [PATCH net-next v2 1/6] net: dsa: add port_fdb_dump function Vivien Didelot
2015-10-14 13:12   ` David Miller
2015-10-14 18:49   ` Florian Fainelli
2015-10-13 16:46 ` [PATCH net-next v2 2/6] net: dsa: mv88e6xxx: write VID outside of VTU Get Next code Vivien Didelot
2015-10-13 16:46 ` [PATCH net-next v2 3/6] net: dsa: mv88e6xxx: write MAC outside of ATU " Vivien Didelot
2015-10-13 17:35   ` Florian Fainelli
2015-10-13 18:11     ` Vivien Didelot
2015-10-13 18:43       ` Florian Fainelli
2015-10-13 18:48   ` Vivien Didelot
2015-10-13 16:46 ` [PATCH net-next v2 4/6] net: dsa: mv88e6xxx: implement port_fdb_dump Vivien Didelot
2015-10-14 17:38   ` Scott Feldman
2015-10-13 16:46 ` [PATCH net-next v2 5/6] net: dsa: mv88e6xxx: remove port_fdb_getnext Vivien Didelot
2015-10-13 16:46 ` [PATCH net-next v2 6/6] net: dsa: " Vivien Didelot
2015-10-14 18:50   ` Florian Fainelli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).