* [PATCH net-next v2 1/3] net: dsa: add port_fdb_prepare
2015-10-08 15:35 [PATCH net-next v2 0/3] net: dsa: push switchdev prepare phase in FDB ops Vivien Didelot
@ 2015-10-08 15:35 ` Vivien Didelot
2015-10-08 15:48 ` Jiri Pirko
2015-10-08 15:35 ` [PATCH net-next v2 2/3] net: dsa: push prepare phase in port_fdb_add Vivien Didelot
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Vivien Didelot @ 2015-10-08 15:35 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel, David S. Miller, Scott Feldman, Jiri Pirko,
Florian Fainelli, Andrew Lunn, Vivien Didelot
Push the prepare phase for FDB operations down to the DSA drivers, with
a new port_fdb_prepare function. Currently only mv88e6xxx is affected.
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 | 10 ++++++++++
drivers/net/dsa/mv88e6xxx.h | 3 +++
include/net/dsa.h | 6 ++++++
net/dsa/slave.c | 7 +++++--
6 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c
index c95cfab..ca3330a 100644
--- a/drivers/net/dsa/mv88e6171.c
+++ b/drivers/net/dsa/mv88e6171.c
@@ -121,6 +121,7 @@ struct dsa_switch_driver mv88e6171_switch_driver = {
.port_vlan_add = mv88e6xxx_port_vlan_add,
.port_vlan_del = mv88e6xxx_port_vlan_del,
.vlan_getnext = mv88e6xxx_vlan_getnext,
+ .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,
diff --git a/drivers/net/dsa/mv88e6352.c b/drivers/net/dsa/mv88e6352.c
index 3736706..078a358 100644
--- a/drivers/net/dsa/mv88e6352.c
+++ b/drivers/net/dsa/mv88e6352.c
@@ -348,6 +348,7 @@ struct dsa_switch_driver mv88e6352_switch_driver = {
.port_vlan_add = mv88e6xxx_port_vlan_add,
.port_vlan_del = mv88e6xxx_port_vlan_del,
.vlan_getnext = mv88e6xxx_vlan_getnext,
+ .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,
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 6053d11..9fbb727 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -1841,6 +1841,16 @@ static int _mv88e6xxx_port_fdb_load(struct dsa_switch *ds, int port,
return _mv88e6xxx_atu_load(ds, &entry);
}
+int mv88e6xxx_port_fdb_prepare(struct dsa_switch *ds, int port,
+ const struct switchdev_obj_port_fdb *fdb,
+ struct switchdev_trans *trans)
+{
+ /* We don't need any dynamic resource from the kernel (yet),
+ * so skip the prepare phase.
+ */
+ return 0;
+}
+
int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid)
{
diff --git a/drivers/net/dsa/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx.h
index 39b261f..4475640 100644
--- a/drivers/net/dsa/mv88e6xxx.h
+++ b/drivers/net/dsa/mv88e6xxx.h
@@ -479,6 +479,9 @@ int mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port, u16 vid,
int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port, u16 vid);
int mv88e6xxx_vlan_getnext(struct dsa_switch *ds, u16 *vid,
unsigned long *ports, unsigned long *untagged);
+int mv88e6xxx_port_fdb_prepare(struct dsa_switch *ds, int port,
+ const struct switchdev_obj_port_fdb *fdb,
+ struct switchdev_trans *trans);
int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid);
int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
diff --git a/include/net/dsa.h b/include/net/dsa.h
index b34d812..4f66f84 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -197,6 +197,9 @@ static inline u8 dsa_upstream_port(struct dsa_switch *ds)
return ds->pd->rtable[dst->cpu_switch];
}
+struct switchdev_trans;
+struct switchdev_obj_port_fdb;
+
struct dsa_switch_driver {
struct list_head list;
@@ -316,6 +319,9 @@ struct dsa_switch_driver {
/*
* Forwarding database
*/
+ int (*port_fdb_prepare)(struct dsa_switch *ds, int port,
+ const struct switchdev_obj_port_fdb *fdb,
+ struct switchdev_trans *trans);
int (*port_fdb_add)(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid);
int (*port_fdb_del)(struct dsa_switch *ds, int port,
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 4f607bc..48e8c15 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -346,10 +346,13 @@ static int dsa_slave_port_fdb_add(struct net_device *dev,
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_switch *ds = p->parent;
- int ret = -EOPNOTSUPP;
+ int ret;
+
+ if (!ds->drv->port_fdb_prepare || !ds->drv->port_fdb_add)
+ return -EOPNOTSUPP;
if (switchdev_trans_ph_prepare(trans))
- ret = ds->drv->port_fdb_add ? 0 : -EOPNOTSUPP;
+ ret = ds->drv->port_fdb_prepare(ds, p->port, fdb, trans);
else
ret = ds->drv->port_fdb_add(ds, p->port, fdb->addr, fdb->vid);
--
2.6.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH net-next v2 1/3] net: dsa: add port_fdb_prepare
2015-10-08 15:35 ` [PATCH net-next v2 1/3] net: dsa: add port_fdb_prepare Vivien Didelot
@ 2015-10-08 15:48 ` Jiri Pirko
0 siblings, 0 replies; 8+ messages in thread
From: Jiri Pirko @ 2015-10-08 15:48 UTC (permalink / raw)
To: Vivien Didelot
Cc: netdev, linux-kernel, kernel, David S. Miller, Scott Feldman,
Florian Fainelli, Andrew Lunn
Thu, Oct 08, 2015 at 05:35:12PM CEST, vivien.didelot@savoirfairelinux.com wrote:
>Push the prepare phase for FDB operations down to the DSA drivers, with
>a new port_fdb_prepare function. Currently only mv88e6xxx is affected.
>
>Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH net-next v2 2/3] net: dsa: push prepare phase in port_fdb_add
2015-10-08 15:35 [PATCH net-next v2 0/3] net: dsa: push switchdev prepare phase in FDB ops Vivien Didelot
2015-10-08 15:35 ` [PATCH net-next v2 1/3] net: dsa: add port_fdb_prepare Vivien Didelot
@ 2015-10-08 15:35 ` Vivien Didelot
2015-10-08 15:48 ` Jiri Pirko
2015-10-08 15:35 ` [PATCH net-next v2 3/3] net: dsa: use switchdev obj in port_fdb_del Vivien Didelot
2015-10-11 12:29 ` [PATCH net-next v2 0/3] net: dsa: push switchdev prepare phase in FDB ops David Miller
3 siblings, 1 reply; 8+ messages in thread
From: Vivien Didelot @ 2015-10-08 15:35 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel, David S. Miller, Scott Feldman, Jiri Pirko,
Florian Fainelli, Andrew Lunn, Vivien Didelot
Now that the prepare phase is pushed down to the DSA drivers, propagate
it to the port_fdb_add function.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
drivers/net/dsa/mv88e6xxx.c | 8 +++++---
drivers/net/dsa/mv88e6xxx.h | 3 ++-
include/net/dsa.h | 3 ++-
net/dsa/slave.c | 2 +-
4 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 9fbb727..9223273 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -23,6 +23,7 @@
#include <linux/phy.h>
#include <linux/seq_file.h>
#include <net/dsa.h>
+#include <net/switchdev.h>
#include "mv88e6xxx.h"
/* MDIO bus access can be nested in the case of PHYs connected to the
@@ -1852,16 +1853,17 @@ int mv88e6xxx_port_fdb_prepare(struct dsa_switch *ds, int port,
}
int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
- const unsigned char *addr, u16 vid)
+ const struct switchdev_obj_port_fdb *fdb,
+ struct switchdev_trans *trans)
{
- int state = is_multicast_ether_addr(addr) ?
+ int state = is_multicast_ether_addr(fdb->addr) ?
GLOBAL_ATU_DATA_STATE_MC_STATIC :
GLOBAL_ATU_DATA_STATE_UC_STATIC;
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
int ret;
mutex_lock(&ps->smi_mutex);
- ret = _mv88e6xxx_port_fdb_load(ds, port, addr, vid, state);
+ ret = _mv88e6xxx_port_fdb_load(ds, port, fdb->addr, fdb->vid, state);
mutex_unlock(&ps->smi_mutex);
return ret;
diff --git a/drivers/net/dsa/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx.h
index 4475640..e688bee 100644
--- a/drivers/net/dsa/mv88e6xxx.h
+++ b/drivers/net/dsa/mv88e6xxx.h
@@ -483,7 +483,8 @@ int mv88e6xxx_port_fdb_prepare(struct dsa_switch *ds, int port,
const struct switchdev_obj_port_fdb *fdb,
struct switchdev_trans *trans);
int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
- const unsigned char *addr, u16 vid);
+ const struct switchdev_obj_port_fdb *fdb,
+ struct switchdev_trans *trans);
int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid);
int mv88e6xxx_port_fdb_getnext(struct dsa_switch *ds, int port,
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 4f66f84..ce8f9b7 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -323,7 +323,8 @@ struct dsa_switch_driver {
const struct switchdev_obj_port_fdb *fdb,
struct switchdev_trans *trans);
int (*port_fdb_add)(struct dsa_switch *ds, int port,
- const unsigned char *addr, u16 vid);
+ const struct switchdev_obj_port_fdb *fdb,
+ struct switchdev_trans *trans);
int (*port_fdb_del)(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid);
int (*port_fdb_getnext)(struct dsa_switch *ds, int port,
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 48e8c15..6f7f27e 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -354,7 +354,7 @@ static int dsa_slave_port_fdb_add(struct net_device *dev,
if (switchdev_trans_ph_prepare(trans))
ret = ds->drv->port_fdb_prepare(ds, p->port, fdb, trans);
else
- ret = ds->drv->port_fdb_add(ds, p->port, fdb->addr, fdb->vid);
+ ret = ds->drv->port_fdb_add(ds, p->port, fdb, trans);
return ret;
}
--
2.6.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH net-next v2 2/3] net: dsa: push prepare phase in port_fdb_add
2015-10-08 15:35 ` [PATCH net-next v2 2/3] net: dsa: push prepare phase in port_fdb_add Vivien Didelot
@ 2015-10-08 15:48 ` Jiri Pirko
0 siblings, 0 replies; 8+ messages in thread
From: Jiri Pirko @ 2015-10-08 15:48 UTC (permalink / raw)
To: Vivien Didelot
Cc: netdev, linux-kernel, kernel, David S. Miller, Scott Feldman,
Florian Fainelli, Andrew Lunn
Thu, Oct 08, 2015 at 05:35:13PM CEST, vivien.didelot@savoirfairelinux.com wrote:
>Now that the prepare phase is pushed down to the DSA drivers, propagate
>it to the port_fdb_add function.
>
>Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH net-next v2 3/3] net: dsa: use switchdev obj in port_fdb_del
2015-10-08 15:35 [PATCH net-next v2 0/3] net: dsa: push switchdev prepare phase in FDB ops Vivien Didelot
2015-10-08 15:35 ` [PATCH net-next v2 1/3] net: dsa: add port_fdb_prepare Vivien Didelot
2015-10-08 15:35 ` [PATCH net-next v2 2/3] net: dsa: push prepare phase in port_fdb_add Vivien Didelot
@ 2015-10-08 15:35 ` Vivien Didelot
2015-10-08 15:48 ` Jiri Pirko
2015-10-11 12:29 ` [PATCH net-next v2 0/3] net: dsa: push switchdev prepare phase in FDB ops David Miller
3 siblings, 1 reply; 8+ messages in thread
From: Vivien Didelot @ 2015-10-08 15:35 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel, David S. Miller, Scott Feldman, Jiri Pirko,
Florian Fainelli, Andrew Lunn, Vivien Didelot
For consistency with the FDB add operation, propagate the
switchdev_obj_port_fdb structure in the DSA drivers.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
drivers/net/dsa/mv88e6xxx.c | 4 ++--
drivers/net/dsa/mv88e6xxx.h | 2 +-
include/net/dsa.h | 2 +-
net/dsa/slave.c | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 9223273..e381bfc 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -1870,13 +1870,13 @@ int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
}
int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
- const unsigned char *addr, u16 vid)
+ const struct switchdev_obj_port_fdb *fdb)
{
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
int ret;
mutex_lock(&ps->smi_mutex);
- ret = _mv88e6xxx_port_fdb_load(ds, port, addr, vid,
+ ret = _mv88e6xxx_port_fdb_load(ds, port, fdb->addr, fdb->vid,
GLOBAL_ATU_DATA_STATE_UNUSED);
mutex_unlock(&ps->smi_mutex);
diff --git a/drivers/net/dsa/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx.h
index e688bee..1347a73 100644
--- a/drivers/net/dsa/mv88e6xxx.h
+++ b/drivers/net/dsa/mv88e6xxx.h
@@ -486,7 +486,7 @@ int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
const struct switchdev_obj_port_fdb *fdb,
struct switchdev_trans *trans);
int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
- const unsigned char *addr, u16 vid);
+ 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_phy_page_read(struct dsa_switch *ds, int port, int page, int reg);
diff --git a/include/net/dsa.h b/include/net/dsa.h
index ce8f9b7..e005886 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -326,7 +326,7 @@ struct dsa_switch_driver {
const struct switchdev_obj_port_fdb *fdb,
struct switchdev_trans *trans);
int (*port_fdb_del)(struct dsa_switch *ds, int port,
- const unsigned char *addr, u16 vid);
+ 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);
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 6f7f27e..bb2bd3b 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -367,7 +367,7 @@ static int dsa_slave_port_fdb_del(struct net_device *dev,
int ret = -EOPNOTSUPP;
if (ds->drv->port_fdb_del)
- ret = ds->drv->port_fdb_del(ds, p->port, fdb->addr, fdb->vid);
+ ret = ds->drv->port_fdb_del(ds, p->port, fdb);
return ret;
}
--
2.6.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH net-next v2 3/3] net: dsa: use switchdev obj in port_fdb_del
2015-10-08 15:35 ` [PATCH net-next v2 3/3] net: dsa: use switchdev obj in port_fdb_del Vivien Didelot
@ 2015-10-08 15:48 ` Jiri Pirko
0 siblings, 0 replies; 8+ messages in thread
From: Jiri Pirko @ 2015-10-08 15:48 UTC (permalink / raw)
To: Vivien Didelot
Cc: netdev, linux-kernel, kernel, David S. Miller, Scott Feldman,
Florian Fainelli, Andrew Lunn
Thu, Oct 08, 2015 at 05:35:14PM CEST, vivien.didelot@savoirfairelinux.com wrote:
>For consistency with the FDB add operation, propagate the
>switchdev_obj_port_fdb structure in the DSA drivers.
>
>Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next v2 0/3] net: dsa: push switchdev prepare phase in FDB ops
2015-10-08 15:35 [PATCH net-next v2 0/3] net: dsa: push switchdev prepare phase in FDB ops Vivien Didelot
` (2 preceding siblings ...)
2015-10-08 15:35 ` [PATCH net-next v2 3/3] net: dsa: use switchdev obj in port_fdb_del Vivien Didelot
@ 2015-10-11 12:29 ` David Miller
3 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2015-10-11 12:29 UTC (permalink / raw)
To: vivien.didelot
Cc: netdev, linux-kernel, kernel, sfeldma, jiri, f.fainelli, andrew
From: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Date: Thu, 8 Oct 2015 11:35:11 -0400
> This patchset pushes the switchdev prepare phase for the FDB add and del
> operations down to the DSA drivers. Currently only mv88e6xxx is affected.
>
> Since the dump requires a bit of refactoring in the driver, it'll come in a
> future patchset.
>
> Changes in v2:
> * forward declare switchdev structs instead of fixing the dsa.h include.
Series applied, thanks.
^ permalink raw reply [flat|nested] 8+ messages in thread