[PATCH v2] staging: fsl-dpaa2/ethsw: Update maintainers for Ethernet Switch driver

2018-07-04 Thread Razvan Stefanescu
Removing myself as the maintainer for this driver and adding Ioana R.
and Ioana C.

Signed-off-by: Razvan Stefanescu 
Acked-by: Ioana Radulescu 
Acked-by: Ioana Ciornei 
---
Changelog
 v2
- add commit message and ack lines

 MAINTAINERS | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index b6d0cc0..0d36546 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4434,7 +4434,8 @@ S:Maintained
 F: drivers/staging/fsl-dpaa2/ethernet
 
 DPAA2 ETHERNET SWITCH DRIVER
-M: Razvan Stefanescu 
+M: Ioana Radulescu 
+M: Ioana Ciornei 
 L: linux-ker...@vger.kernel.org
 S: Maintained
 F: drivers/staging/fsl-dpaa2/ethsw
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: fsl-dpaa2/ethsw: Update maintainers for Ethernet Switch driver

2018-07-03 Thread Razvan Stefanescu
Signed-off-by: Razvan Stefanescu 
---
 MAINTAINERS | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index b6d0cc0..0d36546 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4434,7 +4434,8 @@ S:Maintained
 F: drivers/staging/fsl-dpaa2/ethernet
 
 DPAA2 ETHERNET SWITCH DRIVER
-M: Razvan Stefanescu 
+M: Ioana Radulescu 
+M: Ioana Ciornei 
 L: linux-ker...@vger.kernel.org
 S: Maintained
 F: drivers/staging/fsl-dpaa2/ethsw
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3] staging: fsl-dpaa2/ethsw: Fix tag control information value overwrite

2018-03-28 Thread Razvan Stefanescu
The tag control information (TCI) part of the VLAN header contains several
fields, including PCP (priority code point) and PVID (port VLAN id).

Current implementation uses function ethsw_port_set_tci() to set the PVID
value and mistakenly overwrites the rest of the TCI fields with 0,
including PCP which by default has a value of 7.

Fix this by adding support to retrieve TCI set in hardware. Read existing
value and only updated the PVID fields, leaving others unchanged.

Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
Changelog
 v2: improve patch description

 v3: use the updated MC command stuct name

 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h | 13 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw.c | 42 ++
 drivers/staging/fsl-dpaa2/ethsw/dpsw.h |  6 +
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c| 37 +-
 4 files changed, 79 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
index 1c203e6..da744f2 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
@@ -49,6 +49,8 @@
 #define DPSW_CMDID_IF_SET_FLOODING  DPSW_CMD_ID(0x047)
 #define DPSW_CMDID_IF_SET_BROADCAST DPSW_CMD_ID(0x048)
 
+#define DPSW_CMDID_IF_GET_TCI   DPSW_CMD_ID(0x04A)
+
 #define DPSW_CMDID_IF_SET_LINK_CFG  DPSW_CMD_ID(0x04C)
 
 #define DPSW_CMDID_VLAN_ADD DPSW_CMD_ID(0x060)
@@ -206,6 +208,17 @@ struct dpsw_cmd_if_set_tci {
__le16 conf;
 };
 
+struct dpsw_cmd_if_get_tci {
+   __le16 if_id;
+};
+
+struct dpsw_rsp_if_get_tci {
+   __le16 pad;
+   __le16 vlan_id;
+   u8 dei;
+   u8 pcp;
+};
+
 #define DPSW_STATE_SHIFT   0
 #define DPSW_STATE_SIZE4
 
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
index 9b9bc60..cabed77 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
@@ -529,6 +529,48 @@ int dpsw_if_set_tci(struct fsl_mc_io *mc_io,
 }
 
 /**
+ * dpsw_if_get_tci() - Get default VLAN Tag Control Information (TCI)
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPSW object
+ * @if_id: Interface Identifier
+ * @cfg:   Tag Control Information Configuration
+ *
+ * Return: Completion status. '0' on Success; Error code otherwise.
+ */
+int dpsw_if_get_tci(struct fsl_mc_io *mc_io,
+   u32 cmd_flags,
+   u16 token,
+   u16 if_id,
+   struct dpsw_tci_cfg *cfg)
+{
+   struct fsl_mc_command cmd = { 0 };
+   struct dpsw_cmd_if_get_tci *cmd_params;
+   struct dpsw_rsp_if_get_tci *rsp_params;
+   int err;
+
+   /* prepare command */
+   cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_GET_TCI,
+ cmd_flags,
+ token);
+   cmd_params = (struct dpsw_cmd_if_get_tci *)cmd.params;
+   cmd_params->if_id = cpu_to_le16(if_id);
+
+   /* send command to mc*/
+   err = mc_send_command(mc_io, );
+   if (err)
+   return err;
+
+   /* retrieve response parameters */
+   rsp_params = (struct dpsw_rsp_if_get_tci *)cmd.params;
+   cfg->pcp = rsp_params->pcp;
+   cfg->dei = rsp_params->dei;
+   cfg->vlan_id = le16_to_cpu(rsp_params->vlan_id);
+
+   return 0;
+}
+
+/**
  * dpsw_if_set_stp() - Function sets Spanning Tree Protocol (STP) state.
  * @mc_io: Pointer to MC portal's I/O object
  * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw.h 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
index 3335add..82f80c40 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
@@ -306,6 +306,12 @@ int dpsw_if_set_tci(struct fsl_mc_io *mc_io,
u16 if_id,
const struct dpsw_tci_cfg *cfg);
 
+int dpsw_if_get_tci(struct fsl_mc_io *mc_io,
+   u32 cmd_flags,
+   u16 token,
+   u16 if_id,
+   struct dpsw_tci_cfg *cfg);
+
 /**
  * enum dpsw_stp_state - Spanning Tree Protocol (STP) states
  * @DPSW_STP_STATE_BLOCKING: Blocking state
diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
index c723a04..ab81a6c 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
@@ -50,14 +50,23 @@ static int ethsw_add_vlan(struct ethsw_core *ethsw, u16 vid)
return 0;
 }
 
-static int ethsw_port_set_tci(struct ethsw_port_priv *port_priv,
- struct dpsw_tci_cfg *tci_cfg)
+static int ethsw_port_set_pvid(struct ethsw_port_priv *port_priv, u16 pvid)
 {
 

RE: [PATCH] staging: fsl-dpaa2/ethsw: Fix TCI values overwrite

2018-03-28 Thread Razvan Stefanescu


> -Original Message-
> From: linux-kernel-ow...@vger.kernel.org [mailto:linux-kernel-
> ow...@vger.kernel.org] On Behalf Of Andrew Lunn
> Sent: Tuesday, March 27, 2018 4:38 PM
> To: Razvan Stefanescu <razvan.stefane...@nxp.com>
> Cc: gre...@linuxfoundation.org; de...@driverdev.osuosl.org; linux-
> ker...@vger.kernel.org; net...@vger.kernel.org; Alexandru Marginean
> <alexandru.margin...@nxp.com>; Ruxandra Ioana Ciocoi Radulescu
> <ruxandra.radule...@nxp.com>; Ioana Ciornei <ioana.cior...@nxp.com>;
> Laurentiu Tudor <laurentiu.tu...@nxp.com>; stuyo...@gmail.com
> Subject: Re: [PATCH] staging: fsl-dpaa2/ethsw: Fix TCI values overwrite
> 
> On Tue, Mar 27, 2018 at 08:10:50AM -0500, Razvan Stefanescu wrote:
> > Previous implementation overwrites PCP value, assuming the default value
> is
> > 0, instead of 7.
> >
> > Avoid this by modifying helper function ethsw_port_set_tci() to
> > ethsw_port_set_pvid() and make it update only the vlan_id of the tci_cfg
> > struct.
> 
> Hi Razvan
> 
> It is a good idea to explain acronyms, especially for staging, since
> there are patches for all sorts of devices, can you cannot expect
> everybody to know network specific acronyms.
> 
> By PCP you mean Priority Code Point. TCI i have no idea about.
> 
> Looking at the code, i think you are changing the flow to become
> read/modify/write, instead of just write, which is overwriting the
> previously configured Priority Code Point?
> 
> Please try to add more details to your change logs, to help us
> understand the change.
> 

Thank you Andrew.  I'll address this in v2.

Best regards,
Razvan Stefanescu
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] staging: fsl-dpaa2/ethsw: Fix tag control information value overwrite

2018-03-28 Thread Razvan Stefanescu
The tag control information (TCI) part of the VLAN header contains several
fields, including PCP (priority code point) and PVID (port VLAN id).

Current implementation uses function ethsw_port_set_tci() to set the PVID
value and mistakenly overwrites the rest of the TCI fields with 0,
including PCP which by default has a value of 7.

Fix this by adding support to retrieve TCI set in hardware. Read existing
value and only updated the PVID fields, leaving others unchanged.

Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
Changelog
 v2: improve patch description

 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h | 13 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw.c | 42 ++
 drivers/staging/fsl-dpaa2/ethsw/dpsw.h |  6 +
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c| 37 +-
 4 files changed, 79 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
index 1c203e6..da744f2 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
@@ -49,6 +49,8 @@
 #define DPSW_CMDID_IF_SET_FLOODING  DPSW_CMD_ID(0x047)
 #define DPSW_CMDID_IF_SET_BROADCAST DPSW_CMD_ID(0x048)
 
+#define DPSW_CMDID_IF_GET_TCI   DPSW_CMD_ID(0x04A)
+
 #define DPSW_CMDID_IF_SET_LINK_CFG  DPSW_CMD_ID(0x04C)
 
 #define DPSW_CMDID_VLAN_ADD DPSW_CMD_ID(0x060)
@@ -206,6 +208,17 @@ struct dpsw_cmd_if_set_tci {
__le16 conf;
 };
 
+struct dpsw_cmd_if_get_tci {
+   __le16 if_id;
+};
+
+struct dpsw_rsp_if_get_tci {
+   __le16 pad;
+   __le16 vlan_id;
+   u8 dei;
+   u8 pcp;
+};
+
 #define DPSW_STATE_SHIFT   0
 #define DPSW_STATE_SIZE4
 
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
index 9b9bc60..3ea957c 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
@@ -529,6 +529,48 @@ int dpsw_if_set_tci(struct fsl_mc_io *mc_io,
 }
 
 /**
+ * dpsw_if_get_tci() - Get default VLAN Tag Control Information (TCI)
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPSW object
+ * @if_id: Interface Identifier
+ * @cfg:   Tag Control Information Configuration
+ *
+ * Return: Completion status. '0' on Success; Error code otherwise.
+ */
+int dpsw_if_get_tci(struct fsl_mc_io *mc_io,
+   u32 cmd_flags,
+   u16 token,
+   u16 if_id,
+   struct dpsw_tci_cfg *cfg)
+{
+   struct mc_command cmd = { 0 };
+   struct dpsw_cmd_if_get_tci *cmd_params;
+   struct dpsw_rsp_if_get_tci *rsp_params;
+   int err;
+
+   /* prepare command */
+   cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_GET_TCI,
+ cmd_flags,
+ token);
+   cmd_params = (struct dpsw_cmd_if_get_tci *)cmd.params;
+   cmd_params->if_id = cpu_to_le16(if_id);
+
+   /* send command to mc*/
+   err = mc_send_command(mc_io, );
+   if (err)
+   return err;
+
+   /* retrieve response parameters */
+   rsp_params = (struct dpsw_rsp_if_get_tci *)cmd.params;
+   cfg->pcp = rsp_params->pcp;
+   cfg->dei = rsp_params->dei;
+   cfg->vlan_id = le16_to_cpu(rsp_params->vlan_id);
+
+   return 0;
+}
+
+/**
  * dpsw_if_set_stp() - Function sets Spanning Tree Protocol (STP) state.
  * @mc_io: Pointer to MC portal's I/O object
  * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw.h 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
index 3335add..82f80c40 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
@@ -306,6 +306,12 @@ int dpsw_if_set_tci(struct fsl_mc_io *mc_io,
u16 if_id,
const struct dpsw_tci_cfg *cfg);
 
+int dpsw_if_get_tci(struct fsl_mc_io *mc_io,
+   u32 cmd_flags,
+   u16 token,
+   u16 if_id,
+   struct dpsw_tci_cfg *cfg);
+
 /**
  * enum dpsw_stp_state - Spanning Tree Protocol (STP) states
  * @DPSW_STP_STATE_BLOCKING: Blocking state
diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
index c723a04..ab81a6c 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
@@ -50,14 +50,23 @@ static int ethsw_add_vlan(struct ethsw_core *ethsw, u16 vid)
return 0;
 }
 
-static int ethsw_port_set_tci(struct ethsw_port_priv *port_priv,
- struct dpsw_tci_cfg *tci_cfg)
+static int ethsw_port_set_pvid(struct ethsw_port_priv *port_priv, u16 pvid)
 {
struct ethsw_core *ethsw = port_priv->ethsw_d

[PATCH] staging: fsl-dpaa2/ethsw: Fix TCI values overwrite

2018-03-27 Thread Razvan Stefanescu
Previous implementation overwrites PCP value, assuming the default value is
0, instead of 7.

Avoid this by modifying helper function ethsw_port_set_tci() to
ethsw_port_set_pvid() and make it update only the vlan_id of the tci_cfg
struct.

Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h | 13 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw.c | 42 ++
 drivers/staging/fsl-dpaa2/ethsw/dpsw.h |  6 +
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c| 37 +-
 4 files changed, 79 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
index 1c203e6..da744f2 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
@@ -49,6 +49,8 @@
 #define DPSW_CMDID_IF_SET_FLOODING  DPSW_CMD_ID(0x047)
 #define DPSW_CMDID_IF_SET_BROADCAST DPSW_CMD_ID(0x048)
 
+#define DPSW_CMDID_IF_GET_TCI   DPSW_CMD_ID(0x04A)
+
 #define DPSW_CMDID_IF_SET_LINK_CFG  DPSW_CMD_ID(0x04C)
 
 #define DPSW_CMDID_VLAN_ADD DPSW_CMD_ID(0x060)
@@ -206,6 +208,17 @@ struct dpsw_cmd_if_set_tci {
__le16 conf;
 };
 
+struct dpsw_cmd_if_get_tci {
+   __le16 if_id;
+};
+
+struct dpsw_rsp_if_get_tci {
+   __le16 pad;
+   __le16 vlan_id;
+   u8 dei;
+   u8 pcp;
+};
+
 #define DPSW_STATE_SHIFT   0
 #define DPSW_STATE_SIZE4
 
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
index 9b9bc60..3ea957c 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
@@ -529,6 +529,48 @@ int dpsw_if_set_tci(struct fsl_mc_io *mc_io,
 }
 
 /**
+ * dpsw_if_get_tci() - Get default VLAN Tag Control Information (TCI)
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPSW object
+ * @if_id: Interface Identifier
+ * @cfg:   Tag Control Information Configuration
+ *
+ * Return: Completion status. '0' on Success; Error code otherwise.
+ */
+int dpsw_if_get_tci(struct fsl_mc_io *mc_io,
+   u32 cmd_flags,
+   u16 token,
+   u16 if_id,
+   struct dpsw_tci_cfg *cfg)
+{
+   struct mc_command cmd = { 0 };
+   struct dpsw_cmd_if_get_tci *cmd_params;
+   struct dpsw_rsp_if_get_tci *rsp_params;
+   int err;
+
+   /* prepare command */
+   cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_GET_TCI,
+ cmd_flags,
+ token);
+   cmd_params = (struct dpsw_cmd_if_get_tci *)cmd.params;
+   cmd_params->if_id = cpu_to_le16(if_id);
+
+   /* send command to mc*/
+   err = mc_send_command(mc_io, );
+   if (err)
+   return err;
+
+   /* retrieve response parameters */
+   rsp_params = (struct dpsw_rsp_if_get_tci *)cmd.params;
+   cfg->pcp = rsp_params->pcp;
+   cfg->dei = rsp_params->dei;
+   cfg->vlan_id = le16_to_cpu(rsp_params->vlan_id);
+
+   return 0;
+}
+
+/**
  * dpsw_if_set_stp() - Function sets Spanning Tree Protocol (STP) state.
  * @mc_io: Pointer to MC portal's I/O object
  * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw.h 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
index 3335add..82f80c40 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
@@ -306,6 +306,12 @@ int dpsw_if_set_tci(struct fsl_mc_io *mc_io,
u16 if_id,
const struct dpsw_tci_cfg *cfg);
 
+int dpsw_if_get_tci(struct fsl_mc_io *mc_io,
+   u32 cmd_flags,
+   u16 token,
+   u16 if_id,
+   struct dpsw_tci_cfg *cfg);
+
 /**
  * enum dpsw_stp_state - Spanning Tree Protocol (STP) states
  * @DPSW_STP_STATE_BLOCKING: Blocking state
diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
index c723a04..ab81a6c 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
@@ -50,14 +50,23 @@ static int ethsw_add_vlan(struct ethsw_core *ethsw, u16 vid)
return 0;
 }
 
-static int ethsw_port_set_tci(struct ethsw_port_priv *port_priv,
- struct dpsw_tci_cfg *tci_cfg)
+static int ethsw_port_set_pvid(struct ethsw_port_priv *port_priv, u16 pvid)
 {
struct ethsw_core *ethsw = port_priv->ethsw_data;
struct net_device *netdev = port_priv->netdev;
+   struct dpsw_tci_cfg tci_cfg = { 0 };
bool is_oper;
int err, ret;
 
+   err = dpsw_if_get_tci(ethsw->mc_io, 0, ethsw->dpsw_handle,
+

RE: [PATCH v6 0/6] staging: Introduce DPAA2 Ethernet Switch driver

2018-03-16 Thread Razvan Stefanescu


> -Original Message-
> From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
> Sent: Thursday, March 15, 2018 12:57 PM
> To: Andrew Lunn <and...@lunn.ch>; Laurentiu Tudor
> <laurentiu.tu...@nxp.com>; stuyo...@gmail.com
> Cc: Razvan Stefanescu <razvan.stefane...@nxp.com>;
> de...@driverdev.osuosl.org; a...@arndb.de; gre...@linuxfoundation.org;
> Ioana Ciornei <ioana.cior...@nxp.com>; Alexandru Marginean
> <alexandru.margin...@nxp.com>; Alexander Graf <ag...@suse.de>; linux-
> ker...@vger.kernel.org; net...@vger.kernel.org
> Subject: Re: [PATCH v6 0/6] staging: Introduce DPAA2 Ethernet Switch driver
> 
> On Thu, Mar 15, 2018 at 12:44:37AM +0100, Andrew Lunn wrote:
> > On Wed, Mar 14, 2018 at 10:55:52AM -0500, Razvan Stefanescu wrote:
> > > This patchset introduces the Ethernet Switch Driver for Freescale/NXP
> SoCs
> > > with DPAA2 (DataPath Acceleration Architecture v2). The driver manages
> > > switch objects discovered on the fsl-mc bus. A description of the driver
> > > can be found in the associated README file.
> >
> > Hi Greg
> >
> > This code has much better quality than the usual stuff in staging. I
> > see no reason not to merge it.
> 
> Yeah.  It seems pretty decent.  Stuart, Laurentiu, care to comment?
> 
> Meanwhile, netdev and DaveM aren't even on the CC list and they're the
> ones to ultimately decide.

I'll keep in mind to add Dave M and netdev list on CC for the next 
contributions.
Thank you for the suggestion.

Regards,
Razvan
> 
> regards,
> dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v6 4/6] staging: fsl-dpaa2/ethsw: Add maintainer for Ethernet Switch driver

2018-03-14 Thread Razvan Stefanescu
Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
Changelog:
 v2:
- no changes
 v3:
- no changes
 v4:
- no changes
 v5:
- no changes
 v6:
- no changes

 MAINTAINERS | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index c3c2b75..20d7bf2 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4410,6 +4410,12 @@ L:   linux-ker...@vger.kernel.org
 S: Maintained
 F: drivers/staging/fsl-dpaa2/ethernet
 
+DPAA2 ETHERNET SWITCH DRIVER
+M: Razvan Stefanescu <razvan.stefane...@nxp.com>
+L: linux-ker...@vger.kernel.org
+S: Maintained
+F: drivers/staging/fsl-dpaa2/ethsw
+
 DPT_I2O SCSI RAID DRIVER
 M: Adaptec OEM Raid Solutions <aacr...@adaptec.com>
 L: linux-s...@vger.kernel.org
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v6 6/6] staging: fsl-dpaa2/ethsw: Add TODO

2018-03-14 Thread Razvan Stefanescu
Add a TODO file describing what needs to be added/changed before the driver
can be moved out of staging.

Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
Changelog:
 v2:
- no changes
 v3:
- no changes
 v4:
- remove fsl-mc bus driver dependency as it is out of staging
 v5:
- no changes
 v6:
- add port partitioning requirement

 drivers/staging/fsl-dpaa2/ethsw/TODO | 14 ++
 1 file changed, 14 insertions(+)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/TODO

diff --git a/drivers/staging/fsl-dpaa2/ethsw/TODO 
b/drivers/staging/fsl-dpaa2/ethsw/TODO
new file mode 100644
index 000..24b5e95
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/TODO
@@ -0,0 +1,14 @@
+* Add I/O capabilities on switch port netdevices. This will allow control
+traffic to reach the CPU.
+* Add ACL to redirect control traffic to CPU.
+* Add support for displaying learned FDB entries
+* Add support for multiple FDBs and switch port partitioning
+* MC firmware uprev; the DPAA2 objects used by the Ethernet Switch driver
+need to be kept in sync with binary interface changes in MC
+* refine README file
+* cleanup
+
+NOTE: At least first three of the above are required before getting the
+DPAA2 Ethernet Switch driver out of staging. Another requirement is that
+dpio driver is moved to drivers/soc (this is required for I/O).
+
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v6 5/6] staging: fsl-dpaa2/ethsw: Add README

2018-03-14 Thread Razvan Stefanescu
Add a README file describing the driver architecture, components and
interfaces.

Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
Changelog:
 v2:
- no changes
 v3:
- no changes
 v4:
- no changes
 v5:
- no changes
 v6:
- no changes

 drivers/staging/fsl-dpaa2/ethsw/README | 106 +
 1 file changed, 106 insertions(+)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/README

diff --git a/drivers/staging/fsl-dpaa2/ethsw/README 
b/drivers/staging/fsl-dpaa2/ethsw/README
new file mode 100644
index 000..f6fc07f
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/README
@@ -0,0 +1,106 @@
+DPAA2 Ethernet Switch driver
+
+
+This file provides documentation for the DPAA2 Ethernet Switch driver
+
+
+Contents
+
+   Supported Platforms
+   Architecture Overview
+   Creating an Ethernet Switch
+   Features
+
+
+   Supported Platforms
+===
+This driver provides networking support for Freescale LS2085A, LS2088A
+DPAA2 SoCs.
+
+
+Architecture Overview
+=
+The Ethernet Switch in the DPAA2 architecture consists of several hardware
+resources that provide the functionality. These are allocated and
+configured via the Management Complex (MC) portals. MC abstracts most of
+these resources as DPAA2 objects and exposes ABIs through which they can
+be configured and controlled.
+
+For a more detailed description of the DPAA2 architecture and its object
+abstractions see:
+   drivers/staging/fsl-mc/README.txt
+
+The Ethernet Switch is built on top of a Datapath Switch (DPSW) object.
+
+Configuration interface:
+
+  -
+ | DPAA2 Switch driver |
+  -
+   .
+   .
+  --
+ | DPSW API |
+  --
+   .   software
+ = . ==
+   .   hardware
+  -
+ | MC hardware portals |
+  -
+   .
+   .
+ --
+| DPSW |
+ --
+
+Driver uses the switch device driver model and exposes each switch port as
+a network interface, which can be included in a bridge. Traffic switched
+between ports is offloaded into the hardware. Exposed network interfaces
+are not used for I/O, they are used just for configuration. This
+limitation is going to be addressed in the future.
+
+The DPSW can have ports connected to DPNIs or to PHYs via DPMACs.
+
+
+ [ethA] [ethB] [ethC] [ethD] [ethE] [ethF]
+:  :  :  :  :  :
+:  :  :  :  :  :
+[eth drv]  [eth drv]  [ethsw drv  ]
+:  :  :  :  :  :kernel
+
+:  :  :  :  :  :hardware
+ [DPNI]  [DPNI] [= DPSW =]
+|  |  |  |  |  |
+|   --   |   [DPMAC][DPMAC]
+ ---|  |
+|  |
+  [PHY]  [PHY]
+
+For a more detailed description of the Ethernet switch device driver model
+see:
+   Documentation/networking/switchdev.txt
+
+Creating an Ethernet Switch
+===
+A device is created for the switch objects probed on the MC bus. Each DPSW
+has a number of properties which determine the configuration options and
+associated hardware resources.
+
+A DPSW object (and the other DPAA2 objects needed for a DPAA2 switch) can
+be added to a container on the MC bus in one of two ways: statically,
+through a Datapath Layout Binary file (DPL) that is parsed by MC at boot
+time; or created dynamically at runtime, via the DPAA2 objects APIs.
+
+Features
+
+Driver configures DPSW to perform hardware switching offload of
+unicast/multicast/broadcast (VLAN tagged or untagged) traffic between its
+ports.
+
+It allows configuration of hardware learning, flooding, multicast groups,
+port VLAN configuration and STP state.
+
+Static entries can be added/removed from the FDB.
+
+Hardware statistics for each port are provided through ethtool -S option.
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v6 2/6] staging: fsl-dpaa2/ethsw: Add Freescale DPAA2 Ethernet Switch driver

2018-03-14 Thread Razvan Stefanescu
Introduce the DPAA2 Ethernet Switch driver, which manages Datapath Switch
(DPSW) objects discovered on the MC bus.

Suggested-by: Alexandru Marginean <alexandru.margin...@nxp.com>
Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
Changelog:
 v2:
- fix PVID cleanup in ethsw_port_add_vlan()
- rename err2 to ret in ethsw_port_add/del_vlan()
- avoid duplicate code in ethsw_probe()
- move destroy_workqueue to ethsw_takedown()
- have a function for unregistering notifiers
- above changes implement review comments for v1 from Bogdan P.
 v3:
- no changes
 v4:
- adjust to moving MC-bus out of staging
- support adding/deleting multicast entries to/from FDB
- selectively discard benign MC errors for calling add/delete fdb entries
  multiple times to avoid spamming console with stack traces
- refactor setting TCI to avoid code duplication
- clean probe code error path
 v5:
- replace ethsw_irq0_handler() with NULL
- do not allow adding ports of the same switch to multiple bridge devices
 v6:
- use SPDX license identifier
- fix indentation

 drivers/staging/fsl-dpaa2/ethsw/Makefile |2 +-
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c  | 1507 ++
 drivers/staging/fsl-dpaa2/ethsw/ethsw.h  |   65 ++
 3 files changed, 1573 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.h

diff --git a/drivers/staging/fsl-dpaa2/ethsw/Makefile 
b/drivers/staging/fsl-dpaa2/ethsw/Makefile
index 9846e61..7755603 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/Makefile
+++ b/drivers/staging/fsl-dpaa2/ethsw/Makefile
@@ -7,4 +7,4 @@
 
 obj-$(CONFIG_FSL_DPAA2_ETHSW) += dpaa2-ethsw.o
 
-dpaa2-ethsw-objs := dpsw.o
+dpaa2-ethsw-objs := ethsw.o dpsw.o
diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
new file mode 100644
index 000..5aa6e95
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
@@ -0,0 +1,1507 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * DPAA2 Ethernet Switch driver
+ *
+ * Copyright 2014-2016 Freescale Semiconductor Inc.
+ * Copyright 2017-2018 NXP
+ *
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "ethsw.h"
+
+static struct workqueue_struct *ethsw_owq;
+
+/* Minimal supported DPSW version */
+#define DPSW_MIN_VER_MAJOR 8
+#define DPSW_MIN_VER_MINOR 0
+
+#define DEFAULT_VLAN_ID1
+
+static int ethsw_add_vlan(struct ethsw_core *ethsw, u16 vid)
+{
+   int err;
+
+   struct dpsw_vlan_cfgvcfg = {
+   .fdb_id = 0,
+   };
+
+   if (ethsw->vlans[vid]) {
+   dev_err(ethsw->dev, "VLAN already configured\n");
+   return -EEXIST;
+   }
+
+   err = dpsw_vlan_add(ethsw->mc_io, 0,
+   ethsw->dpsw_handle, vid, );
+   if (err) {
+   dev_err(ethsw->dev, "dpsw_vlan_add err %d\n", err);
+   return err;
+   }
+   ethsw->vlans[vid] = ETHSW_VLAN_MEMBER;
+
+   return 0;
+}
+
+static int ethsw_port_set_tci(struct ethsw_port_priv *port_priv,
+ struct dpsw_tci_cfg *tci_cfg)
+{
+   struct ethsw_core *ethsw = port_priv->ethsw_data;
+   struct net_device *netdev = port_priv->netdev;
+   bool is_oper;
+   int err, ret;
+
+   /* Interface needs to be down to change PVID */
+   is_oper = netif_oper_up(netdev);
+   if (is_oper) {
+   err = dpsw_if_disable(ethsw->mc_io, 0,
+ ethsw->dpsw_handle,
+ port_priv->idx);
+   if (err) {
+   netdev_err(netdev, "dpsw_if_disable err %d\n", err);
+   return err;
+   }
+   }
+
+   err = dpsw_if_set_tci(ethsw->mc_io, 0, ethsw->dpsw_handle,
+ port_priv->idx, tci_cfg);
+   if (err) {
+   netdev_err(netdev, "dpsw_if_set_tci err %d\n", err);
+   goto set_tci_error;
+   }
+
+   /* Delete previous PVID info and mark the new one */
+   if (port_priv->pvid)
+   port_priv->vlans[port_priv->pvid] &= ~ETHSW_VLAN_PVID;
+   port_priv->vlans[tci_cfg->vlan_id] |= ETHSW_VLAN_PVID;
+   port_priv->pvid = tci_cfg->vlan_id;
+
+set_tci_error:
+   if (is_oper) {
+   ret = dpsw_if_enable(ethsw->mc_io, 0,
+ethsw->dpsw_handle,
+port_priv->idx);
+   if (ret) {
+   netdev_err(netdev, "dpsw_if_enable err %d\n", ret);
+   return ret;
+   }
+   }
+
+   return err;
+}
+
+static int ethsw

[PATCH v6 1/6] staging: fsl-dpaa2/ethsw: Add APIs for DPSW object

2018-03-14 Thread Razvan Stefanescu
Add the command build/parse APIs for operating on DPSW objects through
the DPAA2 Management Complex.

Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
Changelog:
 v2:
- use u8 for en parameter of dpsw_if_set_flooding/broadcast()
 v3:
- no changes
 v4:
- adjust to moving MC-bus out of staging
- fix sparse warnings
 v5:
   - no changes
 v6:
   - use SPDX license identifier

 drivers/staging/fsl-dpaa2/Kconfig  |8 +
 drivers/staging/fsl-dpaa2/Makefile |1 +
 drivers/staging/fsl-dpaa2/ethsw/Makefile   |   10 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h |  333 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw.c | 1091 
 drivers/staging/fsl-dpaa2/ethsw/dpsw.h |  554 ++
 6 files changed, 1997 insertions(+)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/Makefile
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.h

diff --git a/drivers/staging/fsl-dpaa2/Kconfig 
b/drivers/staging/fsl-dpaa2/Kconfig
index dfff675..8a508ef 100644
--- a/drivers/staging/fsl-dpaa2/Kconfig
+++ b/drivers/staging/fsl-dpaa2/Kconfig
@@ -16,3 +16,11 @@ config FSL_DPAA2_ETH
---help---
  Ethernet driver for Freescale DPAA2 SoCs, using the
  Freescale MC bus driver
+
+config FSL_DPAA2_ETHSW
+   tristate "Freescale DPAA2 Ethernet Switch"
+   depends on FSL_DPAA2
+   depends on NET_SWITCHDEV
+   ---help---
+   Driver for Freescale DPAA2 Ethernet Switch. Select
+   BRIDGE to have support for bridge tools.
diff --git a/drivers/staging/fsl-dpaa2/Makefile 
b/drivers/staging/fsl-dpaa2/Makefile
index 0836ba8..6cfd76b 100644
--- a/drivers/staging/fsl-dpaa2/Makefile
+++ b/drivers/staging/fsl-dpaa2/Makefile
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_FSL_DPAA2_ETH)+= ethernet/
+obj-$(CONFIG_FSL_DPAA2_ETHSW)  += ethsw/
diff --git a/drivers/staging/fsl-dpaa2/ethsw/Makefile 
b/drivers/staging/fsl-dpaa2/ethsw/Makefile
new file mode 100644
index 000..9846e61
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/Makefile
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Makefile for the Freescale DPAA2 Ethernet Switch
+#
+# Copyright 2014-2017 Freescale Semiconductor Inc.
+# Copyright 2017-2018 NXP
+
+obj-$(CONFIG_FSL_DPAA2_ETHSW) += dpaa2-ethsw.o
+
+dpaa2-ethsw-objs := dpsw.o
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
new file mode 100644
index 000..07407d5
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
@@ -0,0 +1,333 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2014-2016 Freescale Semiconductor Inc.
+ * Copyright 2017-2018 NXP
+ *
+ */
+
+#ifndef __FSL_DPSW_CMD_H
+#define __FSL_DPSW_CMD_H
+
+/* DPSW Version */
+#define DPSW_VER_MAJOR 8
+#define DPSW_VER_MINOR 0
+
+#define DPSW_CMD_BASE_VERSION  1
+#define DPSW_CMD_ID_OFFSET 4
+
+#define DPSW_CMD_ID(id)(((id) << DPSW_CMD_ID_OFFSET) | 
DPSW_CMD_BASE_VERSION)
+
+/* Command IDs */
+#define DPSW_CMDID_CLOSEDPSW_CMD_ID(0x800)
+#define DPSW_CMDID_OPEN DPSW_CMD_ID(0x802)
+
+#define DPSW_CMDID_GET_API_VERSION  DPSW_CMD_ID(0xa02)
+
+#define DPSW_CMDID_ENABLE   DPSW_CMD_ID(0x002)
+#define DPSW_CMDID_DISABLE  DPSW_CMD_ID(0x003)
+#define DPSW_CMDID_GET_ATTR DPSW_CMD_ID(0x004)
+#define DPSW_CMDID_RESETDPSW_CMD_ID(0x005)
+
+#define DPSW_CMDID_SET_IRQ_ENABLE   DPSW_CMD_ID(0x012)
+
+#define DPSW_CMDID_SET_IRQ_MASK DPSW_CMD_ID(0x014)
+
+#define DPSW_CMDID_GET_IRQ_STATUS   DPSW_CMD_ID(0x016)
+#define DPSW_CMDID_CLEAR_IRQ_STATUS DPSW_CMD_ID(0x017)
+
+#define DPSW_CMDID_IF_SET_TCI   DPSW_CMD_ID(0x030)
+#define DPSW_CMDID_IF_SET_STP   DPSW_CMD_ID(0x031)
+
+#define DPSW_CMDID_IF_GET_COUNTER   DPSW_CMD_ID(0x034)
+
+#define DPSW_CMDID_IF_ENABLEDPSW_CMD_ID(0x03D)
+#define DPSW_CMDID_IF_DISABLE   DPSW_CMD_ID(0x03E)
+
+#define DPSW_CMDID_IF_SET_MAX_FRAME_LENGTH  DPSW_CMD_ID(0x044)
+
+#define DPSW_CMDID_IF_GET_LINK_STATEDPSW_CMD_ID(0x046)
+#define DPSW_CMDID_IF_SET_FLOODING  DPSW_CMD_ID(0x047)
+#define DPSW_CMDID_IF_SET_BROADCAST DPSW_CMD_ID(0x048)
+
+#define DPSW_CMDID_VLAN_ADD DPSW_CMD_ID(0x060)
+#define DPSW_CMDID_VLAN_ADD_IF  DPSW_CMD_ID(0x061)
+#define DPSW_CMDID_VLAN_ADD_IF_UNTAGGED DPSW_CMD_ID(0x062)
+
+#define DPSW_CMDID_VLAN_REMOVE_IF   DPSW_CMD_ID(0x064)
+#define DPSW_CMDID_VLAN_REMOVE_IF_UNTAGGED  DPSW_CMD_ID(0x065)
+#define DPSW_CMDID_VLAN_REMOVE_IF_FLOODING  DPSW_CMD_ID(0x066)
+#define DPSW_CMDID_VLAN_REMOVE  DPSW_CMD_ID(0x067)
+
+#define DPSW_CMDID_FDB_ADD_UNICAST  DPSW_CMD_ID(0x084)
+#define DPSW_CM

[PATCH v6 3/6] staging: fsl-dpaa2/ethsw: Add ethtool support

2018-03-14 Thread Razvan Stefanescu
Add driver information, link details and hardware statistics to be
reported via ethtool -S.

Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
Changelog:
 v2:
- no changes
 v3:
- removed driver version
 v4:
- no changes
 v5:
- no changes
 v6:
- use SPDX license identifier

 drivers/staging/fsl-dpaa2/ethsw/Makefile|   2 +-
 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h  |  13 ++
 drivers/staging/fsl-dpaa2/ethsw/dpsw.c  |  32 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw.h  |  32 +
 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c | 182 
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c |   1 +
 drivers/staging/fsl-dpaa2/ethsw/ethsw.h |   2 +
 7 files changed, 263 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c

diff --git a/drivers/staging/fsl-dpaa2/ethsw/Makefile 
b/drivers/staging/fsl-dpaa2/ethsw/Makefile
index 7755603..f6f2cf7 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/Makefile
+++ b/drivers/staging/fsl-dpaa2/ethsw/Makefile
@@ -7,4 +7,4 @@
 
 obj-$(CONFIG_FSL_DPAA2_ETHSW) += dpaa2-ethsw.o
 
-dpaa2-ethsw-objs := ethsw.o dpsw.o
+dpaa2-ethsw-objs := ethsw.o ethsw-ethtool.o dpsw.o
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
index 07407d5..1c203e6 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
@@ -49,6 +49,8 @@
 #define DPSW_CMDID_IF_SET_FLOODING  DPSW_CMD_ID(0x047)
 #define DPSW_CMDID_IF_SET_BROADCAST DPSW_CMD_ID(0x048)
 
+#define DPSW_CMDID_IF_SET_LINK_CFG  DPSW_CMD_ID(0x04C)
+
 #define DPSW_CMDID_VLAN_ADD DPSW_CMD_ID(0x060)
 #define DPSW_CMDID_VLAN_ADD_IF  DPSW_CMD_ID(0x061)
 #define DPSW_CMDID_VLAN_ADD_IF_UNTAGGED DPSW_CMD_ID(0x062)
@@ -237,6 +239,17 @@ struct dpsw_cmd_if_set_max_frame_length {
__le16 frame_length;
 };
 
+struct dpsw_cmd_if_set_link_cfg {
+   /* cmd word 0 */
+   __le16 if_id;
+   u8 pad[6];
+   /* cmd word 1 */
+   __le32 rate;
+   __le32 pad1;
+   /* cmd word 2 */
+   __le64 options;
+};
+
 struct dpsw_cmd_if_get_link_state {
__le16 if_id;
 };
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
index 3f9b86b..aefa52f 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
@@ -358,6 +358,38 @@ int dpsw_get_attributes(struct fsl_mc_io *mc_io,
 }
 
 /**
+ * dpsw_if_set_link_cfg() - Set the link configuration.
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPSW object
+ * @if_id: Interface id
+ * @cfg:   Link configuration
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dpsw_if_set_link_cfg(struct fsl_mc_io *mc_io,
+u32 cmd_flags,
+u16 token,
+u16 if_id,
+struct dpsw_link_cfg *cfg)
+{
+   struct mc_command cmd = { 0 };
+   struct dpsw_cmd_if_set_link_cfg *cmd_params;
+
+   /* prepare command */
+   cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_LINK_CFG,
+ cmd_flags,
+ token);
+   cmd_params = (struct dpsw_cmd_if_set_link_cfg *)cmd.params;
+   cmd_params->if_id = cpu_to_le16(if_id);
+   cmd_params->rate = cpu_to_le32(cfg->rate);
+   cmd_params->options = cpu_to_le64(cfg->options);
+
+   /* send command to mc*/
+   return mc_send_command(mc_io, );
+}
+
+/**
  * dpsw_if_get_link_state - Return the link state
  * @mc_io: Pointer to MC portal's I/O object
  * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw.h 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
index 6de53f6..3335add 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
@@ -220,6 +220,38 @@ enum dpsw_action {
 };
 
 /**
+ * Enable auto-negotiation
+ */
+#define DPSW_LINK_OPT_AUTONEG  0x0001ULL
+/**
+ * Enable half-duplex mode
+ */
+#define DPSW_LINK_OPT_HALF_DUPLEX  0x0002ULL
+/**
+ * Enable pause frames
+ */
+#define DPSW_LINK_OPT_PAUSE0x0004ULL
+/**
+ * Enable a-symmetric pause frames
+ */
+#define DPSW_LINK_OPT_ASYM_PAUSE   0x0008ULL
+
+/**
+ * struct dpsw_link_cfg - Structure representing DPSW link configuration
+ * @rate: Rate
+ * @options: Mask of available options; use 'DPSW_LINK_OPT_' values
+ */
+struct dpsw_link_cfg {
+   u32 rate;
+   u64 options;
+};
+
+int dpsw_if_set_link_cfg(struct fsl_mc_io *mc_io,
+u32 cmd_flags,
+u16 token,
+u16 if_id,
+stru

[PATCH v6 0/6] staging: Introduce DPAA2 Ethernet Switch driver

2018-03-14 Thread Razvan Stefanescu
This patchset introduces the Ethernet Switch Driver for Freescale/NXP SoCs
with DPAA2 (DataPath Acceleration Architecture v2). The driver manages
switch objects discovered on the fsl-mc bus. A description of the driver
can be found in the associated README file.

The patchset consists of:
* A set of libraries containing APIs for configuring and controlling
  Management Complex (MC) switch objects
* The DPAA2 Ethernet Switch driver
* Patch adding ethtool support

Limitations:
* no support for control traffic to/from CPU
* only DPSW ports can be added to a bridge

Changelog:
 v2: addressed comments from Bogdan P.

 v3: addressed comments from Andrew L. (patch 3/6 updated)

 v4: adjust to moving MC-bus out of staging
 support adding/deleting multicast entries to/from FDB
 avoid triggering console stack traces due to benign MC errors
 refactor TCI setting code to avoid code duplication
 fix sparse warning

 v5: addresed comments from Andrew L. (patch 2/6 updated)
 replace ethsw_irq0_handler() with NULL
 do not allow adding ports of the same switch to multiple bridges

 v6: addressed comment from Andrew L. and Greg KH.
 add port partitioning in the TODO file
 replace licensing text with SPDX identifier

Razvan Stefanescu (6):
  staging: fsl-dpaa2/ethsw: Add APIs for DPSW object
  staging: fsl-dpaa2/ethsw: Add Freescale DPAA2 Ethernet Switch driver
  staging: fsl-dpaa2/ethsw: Add ethtool support
  staging: fsl-dpaa2/ethsw: Add maintainer for Ethernet Switch driver
  staging: fsl-dpaa2/ethsw: Add README
  staging: fsl-dpaa2/ethsw: Add TODO

 MAINTAINERS |6 +
 drivers/staging/fsl-dpaa2/Kconfig   |8 +
 drivers/staging/fsl-dpaa2/Makefile  |1 +
 drivers/staging/fsl-dpaa2/ethsw/Makefile|   10 +
 drivers/staging/fsl-dpaa2/ethsw/README  |  106 ++
 drivers/staging/fsl-dpaa2/ethsw/TODO|   14 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h  |  346 ++
 drivers/staging/fsl-dpaa2/ethsw/dpsw.c  | 1123 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw.h  |  586 +
 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c |  182 +++
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 1508 +++
 drivers/staging/fsl-dpaa2/ethsw/ethsw.h |   67 +
 12 files changed, 3957 insertions(+)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/Makefile
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/README
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/TODO
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.h
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.h

-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH v5 1/6] staging: fsl-dpaa2/ethsw: Add APIs for DPSW object

2018-03-14 Thread Razvan Stefanescu
> 
> Can you resend this series and just use the correct SPDX identifiers for
> all of the new files, instead of all of this horrid boiler-plate code?
> 
> That will save me time when I have to go delete all of this in the near
> future :)
> 
> Also, why dual license it?  Are you _SURE_ you want to do that, and are
> totally aware of all of the crazy issues surrounding it?  Hint, it
> almost never means what you might think it does, and I have yet to know
> of anyone doing anything "real" with any dual-licensed Linux kernel
> code.
> 
> Remember, BSD is not the license you want/need for GPL header files that
> are exposed to userspace...
> 
> 
> thanks,
> 
> greg k-h

Thank you for your observation. I will update the patches with the SPDX 
identifiers.

Razvan
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH v5 2/6] staging: fsl-dpaa2/ethsw: Add Freescale DPAA2 Ethernet Switch driver

2018-03-14 Thread Razvan Stefanescu


> -Original Message-
> From: Andrew Lunn [mailto:and...@lunn.ch]
> Sent: Tuesday, March 13, 2018 5:26 PM
> To: Razvan Stefanescu <razvan.stefane...@nxp.com>
> Cc: gre...@linuxfoundation.org; de...@driverdev.osuosl.org; linux-
> ker...@vger.kernel.org; net...@vger.kernel.org; Alexander Graf
> <ag...@suse.de>; a...@arndb.de; Alexandru Marginean
> <alexandru.margin...@nxp.com>; Ruxandra Ioana Ciocoi Radulescu
> <ruxandra.radule...@nxp.com>; Ioana Ciornei <ioana.cior...@nxp.com>;
> Laurentiu Tudor <laurentiu.tu...@nxp.com>; stuyo...@gmail.com
> Subject: Re: [PATCH v5 2/6] staging: fsl-dpaa2/ethsw: Add Freescale DPAA2
> Ethernet Switch driver
> 
> > Hello Andrew,
> >
> > The current driver implementation uses only a single FDB for the switch,
> > so  it is not possible configure multiple flooding domains to accommodate
> > ports partitioning.
> 
> Ah, O.K. Rather than break somebodies network by wrongly flooding, it
> would be better to return -EOPNOTSUPP when the requirement for the
> second FDB is met. The offload to hardware will then not happen, and
> the software bridge will do all the work.
> 
Thank you for your suggestion. I will add to the TODO list in v6.

Razvan
> Andrew
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH v5 2/6] staging: fsl-dpaa2/ethsw: Add Freescale DPAA2 Ethernet Switch driver

2018-03-13 Thread Razvan Stefanescu


> -Original Message-
> From: Andrew Lunn [mailto:and...@lunn.ch]
> Sent: Tuesday, March 13, 2018 4:23 PM
> To: Razvan Stefanescu <razvan.stefane...@nxp.com>
> Cc: gre...@linuxfoundation.org; de...@driverdev.osuosl.org; linux-
> ker...@vger.kernel.org; net...@vger.kernel.org; Alexander Graf
> <ag...@suse.de>; a...@arndb.de; Alexandru Marginean
> <alexandru.margin...@nxp.com>; Ruxandra Ioana Ciocoi Radulescu
> <ruxandra.radule...@nxp.com>; Ioana Ciornei <ioana.cior...@nxp.com>;
> Laurentiu Tudor <laurentiu.tu...@nxp.com>; stuyo...@gmail.com
> Subject: Re: [PATCH v5 2/6] staging: fsl-dpaa2/ethsw: Add Freescale DPAA2
> Ethernet Switch driver
> 
> > +/* For the moment, only flood setting needs to be updated */
> > +static int port_bridge_join(struct net_device *netdev,
> > +   struct net_device *upper_dev)
> > +{
> > +   struct ethsw_port_priv *port_priv = netdev_priv(netdev);
> > +   struct ethsw_core *ethsw = port_priv->ethsw_data;
> > +   int i, err;
> > +
> > +   for (i = 0; i < ethsw->sw_attr.num_ifs; i++)
> > +   if (ethsw->ports[i]->bridge_dev &&
> > +   (ethsw->ports[i]->bridge_dev != upper_dev)) {
> > +   netdev_err(netdev,
> > +  "Another switch port is connected to %s\n",
> > +  ethsw->ports[i]->bridge_dev->name);
> > +   return -EINVAL;
> > +   }
> > +
> > +   /* Enable flooding */
> > +   err = ethsw_port_set_flood(port_priv, 1);
> > +   if (!err)
> > +   port_priv->bridge_dev = upper_dev;
> > +
> > +   return err;
> > +}
> 
> Hi Razvan
> 
> That is not what i was meaning.
> 
> brctl addbr br0
> brctl addbr br1
> brctl addif br0 lan0
> brctl addif br0 lan1
> brctl addif br1 lan2
> brctl addif br1 lan3
> 
> Is there somewhere in the code which sets the scope for the flooding?
> lan0 can flood to lan1, but it should not flood to lan2 or lan3, since
> they are in a different bridge. I was expecting that
> ethsw_port_set_flood() takes upper_dev, in order to configure which
> ports it should flood to.
> 
>   Andrew

Hello Andrew,

The current driver implementation uses only a single FDB for the switch,
so  it is not possible configure multiple flooding domains to accommodate
ports partitioning.
 
The configuration that you mentioned will be possible when support for
multiple FDBs in the switch is added. Ports added to the same bridge
will have their flooding domain limited to a specific FDB.

Switch ports partitioning is a feature on the roadmap. I will add this
information to the TODO list.

Best regards,
Razvan Stefanescu
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 1/6] staging: fsl-dpaa2/ethsw: Add APIs for DPSW object

2018-03-13 Thread Razvan Stefanescu
Add the command build/parse APIs for operating on DPSW objects through
the DPAA2 Management Complex.

Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
Changelog:
 v2:
- use u8 for en parameter of dpsw_if_set_flooding/broadcast()
 v3:
- no changes
 v4:
- adjust to moving MC-bus out of staging
- fix sparse warnings
 v5:
   - no changes

 drivers/staging/fsl-dpaa2/Kconfig  |8 +
 drivers/staging/fsl-dpaa2/Makefile |1 +
 drivers/staging/fsl-dpaa2/ethsw/Makefile   |7 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h |  358 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw.c | 1116 
 drivers/staging/fsl-dpaa2/ethsw/dpsw.h |  579 +++
 6 files changed, 2069 insertions(+)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/Makefile
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.h

diff --git a/drivers/staging/fsl-dpaa2/Kconfig 
b/drivers/staging/fsl-dpaa2/Kconfig
index dfff675..8a508ef 100644
--- a/drivers/staging/fsl-dpaa2/Kconfig
+++ b/drivers/staging/fsl-dpaa2/Kconfig
@@ -16,3 +16,11 @@ config FSL_DPAA2_ETH
---help---
  Ethernet driver for Freescale DPAA2 SoCs, using the
  Freescale MC bus driver
+
+config FSL_DPAA2_ETHSW
+   tristate "Freescale DPAA2 Ethernet Switch"
+   depends on FSL_DPAA2
+   depends on NET_SWITCHDEV
+   ---help---
+   Driver for Freescale DPAA2 Ethernet Switch. Select
+   BRIDGE to have support for bridge tools.
diff --git a/drivers/staging/fsl-dpaa2/Makefile 
b/drivers/staging/fsl-dpaa2/Makefile
index 0836ba8..6cfd76b 100644
--- a/drivers/staging/fsl-dpaa2/Makefile
+++ b/drivers/staging/fsl-dpaa2/Makefile
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_FSL_DPAA2_ETH)+= ethernet/
+obj-$(CONFIG_FSL_DPAA2_ETHSW)  += ethsw/
diff --git a/drivers/staging/fsl-dpaa2/ethsw/Makefile 
b/drivers/staging/fsl-dpaa2/ethsw/Makefile
new file mode 100644
index 000..db137f7
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/Makefile
@@ -0,0 +1,7 @@
+#
+# Makefile for the Freescale DPAA2 Ethernet Switch
+#
+
+obj-$(CONFIG_FSL_DPAA2_ETHSW) += dpaa2-ethsw.o
+
+dpaa2-ethsw-objs := dpsw.o
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
new file mode 100644
index 000..36edef6
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
@@ -0,0 +1,358 @@
+/* Copyright 2013-2016 Freescale Semiconductor Inc.
+ * Copyright 2017-2018 NXP
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of the above-listed copyright holders nor the
+ *  names of any contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef __FSL_DPSW_CMD_H
+#define __FSL_DPSW_CMD_H
+
+/* DPSW Version */
+#define DPSW_VER_MAJOR 8
+#define DPSW_VER_MINOR 0
+
+#define DPSW_CMD_BASE_VERSION  1
+#define DPSW_CMD_ID_OFFSET 4
+
+#define DPSW_CMD_ID(id)(((id) << DPSW_CMD_ID_OFFSET) | 
DPSW_CMD_BASE_VERSION)
+
+/* Command IDs */
+#define DPSW_CMDID_CLOSEDPSW_CMD_ID(0x800)
+#define DPSW_CMDID_OPEN DPSW_CMD_ID(0x802)
+
+#define DPSW_CMDID_GET_API_VERSION  DPSW_CMD_ID(0xa02)
+
+#define DPSW_

[PATCH v5 5/6] staging: fsl-dpaa2/ethsw: Add README

2018-03-13 Thread Razvan Stefanescu
Add a README file describing the driver architecture, components and
interfaces.

Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
Changelog:
 v2:
- no changes
 v3:
- no changes
 v4:
- no changes
 v5:
- no changes

 drivers/staging/fsl-dpaa2/ethsw/README | 106 +
 1 file changed, 106 insertions(+)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/README

diff --git a/drivers/staging/fsl-dpaa2/ethsw/README 
b/drivers/staging/fsl-dpaa2/ethsw/README
new file mode 100644
index 000..f6fc07f
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/README
@@ -0,0 +1,106 @@
+DPAA2 Ethernet Switch driver
+
+
+This file provides documentation for the DPAA2 Ethernet Switch driver
+
+
+Contents
+
+   Supported Platforms
+   Architecture Overview
+   Creating an Ethernet Switch
+   Features
+
+
+   Supported Platforms
+===
+This driver provides networking support for Freescale LS2085A, LS2088A
+DPAA2 SoCs.
+
+
+Architecture Overview
+=
+The Ethernet Switch in the DPAA2 architecture consists of several hardware
+resources that provide the functionality. These are allocated and
+configured via the Management Complex (MC) portals. MC abstracts most of
+these resources as DPAA2 objects and exposes ABIs through which they can
+be configured and controlled.
+
+For a more detailed description of the DPAA2 architecture and its object
+abstractions see:
+   drivers/staging/fsl-mc/README.txt
+
+The Ethernet Switch is built on top of a Datapath Switch (DPSW) object.
+
+Configuration interface:
+
+  -
+ | DPAA2 Switch driver |
+  -
+   .
+   .
+  --
+ | DPSW API |
+  --
+   .   software
+ = . ==
+   .   hardware
+  -
+ | MC hardware portals |
+  -
+   .
+   .
+ --
+| DPSW |
+ --
+
+Driver uses the switch device driver model and exposes each switch port as
+a network interface, which can be included in a bridge. Traffic switched
+between ports is offloaded into the hardware. Exposed network interfaces
+are not used for I/O, they are used just for configuration. This
+limitation is going to be addressed in the future.
+
+The DPSW can have ports connected to DPNIs or to PHYs via DPMACs.
+
+
+ [ethA] [ethB] [ethC] [ethD] [ethE] [ethF]
+:  :  :  :  :  :
+:  :  :  :  :  :
+[eth drv]  [eth drv]  [ethsw drv  ]
+:  :  :  :  :  :kernel
+
+:  :  :  :  :  :hardware
+ [DPNI]  [DPNI] [= DPSW =]
+|  |  |  |  |  |
+|   --   |   [DPMAC][DPMAC]
+ ---|  |
+|  |
+  [PHY]  [PHY]
+
+For a more detailed description of the Ethernet switch device driver model
+see:
+   Documentation/networking/switchdev.txt
+
+Creating an Ethernet Switch
+===
+A device is created for the switch objects probed on the MC bus. Each DPSW
+has a number of properties which determine the configuration options and
+associated hardware resources.
+
+A DPSW object (and the other DPAA2 objects needed for a DPAA2 switch) can
+be added to a container on the MC bus in one of two ways: statically,
+through a Datapath Layout Binary file (DPL) that is parsed by MC at boot
+time; or created dynamically at runtime, via the DPAA2 objects APIs.
+
+Features
+
+Driver configures DPSW to perform hardware switching offload of
+unicast/multicast/broadcast (VLAN tagged or untagged) traffic between its
+ports.
+
+It allows configuration of hardware learning, flooding, multicast groups,
+port VLAN configuration and STP state.
+
+Static entries can be added/removed from the FDB.
+
+Hardware statistics for each port are provided through ethtool -S option.
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 2/6] staging: fsl-dpaa2/ethsw: Add Freescale DPAA2 Ethernet Switch driver

2018-03-13 Thread Razvan Stefanescu
Introduce the DPAA2 Ethernet Switch driver, which manages Datapath Switch
(DPSW) objects discovered on the MC bus.

Suggested-by: Alexandru Marginean <alexandru.margin...@nxp.com>
Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
Changelog:
 v2:
- fix PVID cleanup in ethsw_port_add_vlan()
- rename err2 to ret in ethsw_port_add/del_vlan()
- avoid duplicate code in ethsw_probe()
- move destroy_workqueue to ethsw_takedown()
- have a function for unregistering notifiers
- above changes implement review comments for v1 from Bogdan P.
 v3:
- no changes
 v4:
- adjust to moving MC-bus out of staging
- support adding/deleting multicast entries to/from FDB
- selectively discard benign MC errors for calling add/delete fdb entries
  multiple times to avoid spamming console with stack traces
- refactor setting TCI to avoid code duplication
- clean probe code error path
 v5:
- replace ethsw_irq0_handler() with NULL
- do not allow adding ports of the same switch to multiple bridge devices

 drivers/staging/fsl-dpaa2/ethsw/Makefile |2 +-
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c  | 1531 ++
 drivers/staging/fsl-dpaa2/ethsw/ethsw.h  |   89 ++
 3 files changed, 1621 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.h

diff --git a/drivers/staging/fsl-dpaa2/ethsw/Makefile 
b/drivers/staging/fsl-dpaa2/ethsw/Makefile
index db137f7..a6d72d1 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/Makefile
+++ b/drivers/staging/fsl-dpaa2/ethsw/Makefile
@@ -4,4 +4,4 @@
 
 obj-$(CONFIG_FSL_DPAA2_ETHSW) += dpaa2-ethsw.o
 
-dpaa2-ethsw-objs := dpsw.o
+dpaa2-ethsw-objs := ethsw.o dpsw.o
diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
new file mode 100644
index 000..2127037
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
@@ -0,0 +1,1531 @@
+/* Copyright 2014-2016 Freescale Semiconductor Inc.
+ * Copyright 2017-2018 NXP
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of the above-listed copyright holders nor the
+ *  names of any contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "ethsw.h"
+
+static struct workqueue_struct *ethsw_owq;
+
+/* Minimal supported DPSW version */
+#define DPSW_MIN_VER_MAJOR 8
+#define DPSW_MIN_VER_MINOR 0
+
+#define DEFAULT_VLAN_ID1
+
+static int ethsw_add_vlan(struct ethsw_core *ethsw, u16 vid)
+{
+   int err;
+
+   struct dpsw_vlan_cfgvcfg = {
+   .fdb_id = 0,
+   };
+
+   if (ethsw->vlans[vid]) {
+   dev_err(ethsw->dev, "VLAN already configured\n");
+   return -EEXIST;
+   }
+
+   err = dpsw_vlan_add(ethsw->mc_io, 0,
+   ethsw->dpsw_handle, vid, );
+   if (err) {
+   dev_err(ethsw->dev, "dpsw_vlan_add err %d\n", err);
+   return err;
+   }
+   ethsw->vlans[vid] = ETHSW_VLAN_MEMBER;
+
+   return 0;
+}
+
+static int ethsw_port_set_tci(struct ethsw_port_priv *port_priv,
+  

[PATCH v5 4/6] staging: fsl-dpaa2/ethsw: Add maintainer for Ethernet Switch driver

2018-03-13 Thread Razvan Stefanescu
Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
Changelog:
 v2:
- no changes
 v3:
- no changes
 v4:
- no changes
 v5:
- no changes

 MAINTAINERS | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index c3c2b75..20d7bf2 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4410,6 +4410,12 @@ L:   linux-ker...@vger.kernel.org
 S: Maintained
 F: drivers/staging/fsl-dpaa2/ethernet
 
+DPAA2 ETHERNET SWITCH DRIVER
+M: Razvan Stefanescu <razvan.stefane...@nxp.com>
+L: linux-ker...@vger.kernel.org
+S: Maintained
+F: drivers/staging/fsl-dpaa2/ethsw
+
 DPT_I2O SCSI RAID DRIVER
 M: Adaptec OEM Raid Solutions <aacr...@adaptec.com>
 L: linux-s...@vger.kernel.org
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 0/6] staging: Introduce DPAA2 Ethernet Switch driver

2018-03-13 Thread Razvan Stefanescu
This patchset introduces the Ethernet Switch Driver for Freescale/NXP SoCs
with DPAA2 (DataPath Acceleration Architecture v2). The driver manages
switch objects discovered on the fsl-mc bus. A description of the driver
can be found in the associated README file.

The patchset consists of:
* A set of libraries containing APIs for configuring and controlling
  Management Complex (MC) switch objects
* The DPAA2 Ethernet Switch driver
* Patch adding ethtool support

Limitations:
* no support for control traffic to/from CPU
* only DPSW ports can be added to a bridge

Changelog:
 v2: addressed comments from Bogdan P.

 v3: addressed comments from Andrew L. (patch 3/6 updated)

 v4: adjust to moving MC-bus out of staging
 support adding/deleting multicast entries to/from FDB
 avoid triggering console stack traces due to benign MC errors
 refactor TCI setting code to avoid code duplication
 fix sparse warning

 v5: addresed comments from Andrew L. (patch 2/6 updated)
 replace ethsw_irq0_handler() with NULL
 do not allow adding ports of the same switch to multiple bridges

Razvan Stefanescu (6):
  staging: fsl-dpaa2/ethsw: Add APIs for DPSW object
  staging: fsl-dpaa2/ethsw: Add Freescale DPAA2 Ethernet Switch driver
  staging: fsl-dpaa2/ethsw: Add ethtool support
  staging: fsl-dpaa2/ethsw: Add maintainer for Ethernet Switch driver
  staging: fsl-dpaa2/ethsw: Add README
  staging: fsl-dpaa2/ethsw: Add TODO

 MAINTAINERS |6 +
 drivers/staging/fsl-dpaa2/Kconfig   |8 +
 drivers/staging/fsl-dpaa2/Makefile  |1 +
 drivers/staging/fsl-dpaa2/ethsw/Makefile|7 +
 drivers/staging/fsl-dpaa2/ethsw/README  |  106 ++
 drivers/staging/fsl-dpaa2/ethsw/TODO|   13 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h  |  371 ++
 drivers/staging/fsl-dpaa2/ethsw/dpsw.c  | 1148 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw.h  |  611 +
 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c |  206 +++
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 1532 +++
 drivers/staging/fsl-dpaa2/ethsw/ethsw.h |   91 ++
 12 files changed, 4100 insertions(+)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/Makefile
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/README
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/TODO
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.h
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.h

-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 3/6] staging: fsl-dpaa2/ethsw: Add ethtool support

2018-03-13 Thread Razvan Stefanescu
Add driver information, link details and hardware statistics to be
reported via ethtool -S.

Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
Changelog:
 v2:
- no changes
 v3:
- removed driver version
 v4:
- no changes
 v5:
- no changes

 drivers/staging/fsl-dpaa2/ethsw/Makefile|   2 +-
 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h  |  13 ++
 drivers/staging/fsl-dpaa2/ethsw/dpsw.c  |  32 
 drivers/staging/fsl-dpaa2/ethsw/dpsw.h  |  32 
 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c | 206 
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c |   1 +
 drivers/staging/fsl-dpaa2/ethsw/ethsw.h |   2 +
 7 files changed, 287 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c

diff --git a/drivers/staging/fsl-dpaa2/ethsw/Makefile 
b/drivers/staging/fsl-dpaa2/ethsw/Makefile
index a6d72d1..de92cd9 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/Makefile
+++ b/drivers/staging/fsl-dpaa2/ethsw/Makefile
@@ -4,4 +4,4 @@
 
 obj-$(CONFIG_FSL_DPAA2_ETHSW) += dpaa2-ethsw.o
 
-dpaa2-ethsw-objs := ethsw.o dpsw.o
+dpaa2-ethsw-objs := ethsw.o ethsw-ethtool.o dpsw.o
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
index 36edef6..c45f001 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
@@ -74,6 +74,8 @@
 #define DPSW_CMDID_IF_SET_FLOODING  DPSW_CMD_ID(0x047)
 #define DPSW_CMDID_IF_SET_BROADCAST DPSW_CMD_ID(0x048)
 
+#define DPSW_CMDID_IF_SET_LINK_CFG  DPSW_CMD_ID(0x04C)
+
 #define DPSW_CMDID_VLAN_ADD DPSW_CMD_ID(0x060)
 #define DPSW_CMDID_VLAN_ADD_IF  DPSW_CMD_ID(0x061)
 #define DPSW_CMDID_VLAN_ADD_IF_UNTAGGED DPSW_CMD_ID(0x062)
@@ -262,6 +264,17 @@ struct dpsw_cmd_if_set_max_frame_length {
__le16 frame_length;
 };
 
+struct dpsw_cmd_if_set_link_cfg {
+   /* cmd word 0 */
+   __le16 if_id;
+   u8 pad[6];
+   /* cmd word 1 */
+   __le32 rate;
+   __le32 pad1;
+   /* cmd word 2 */
+   __le64 options;
+};
+
 struct dpsw_cmd_if_get_link_state {
__le16 if_id;
 };
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
index 8e52d74..e63531d 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
@@ -383,6 +383,38 @@ int dpsw_get_attributes(struct fsl_mc_io *mc_io,
 }
 
 /**
+ * dpsw_if_set_link_cfg() - Set the link configuration.
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPSW object
+ * @if_id: Interface id
+ * @cfg:   Link configuration
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dpsw_if_set_link_cfg(struct fsl_mc_io *mc_io,
+u32 cmd_flags,
+u16 token,
+u16 if_id,
+struct dpsw_link_cfg *cfg)
+{
+   struct mc_command cmd = { 0 };
+   struct dpsw_cmd_if_set_link_cfg *cmd_params;
+
+   /* prepare command */
+   cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_LINK_CFG,
+ cmd_flags,
+ token);
+   cmd_params = (struct dpsw_cmd_if_set_link_cfg *)cmd.params;
+   cmd_params->if_id = cpu_to_le16(if_id);
+   cmd_params->rate = cpu_to_le32(cfg->rate);
+   cmd_params->options = cpu_to_le64(cfg->options);
+
+   /* send command to mc*/
+   return mc_send_command(mc_io, );
+}
+
+/**
  * dpsw_if_get_link_state - Return the link state
  * @mc_io: Pointer to MC portal's I/O object
  * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw.h 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
index d13970c..5a0c7ad 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
@@ -245,6 +245,38 @@ enum dpsw_action {
 };
 
 /**
+ * Enable auto-negotiation
+ */
+#define DPSW_LINK_OPT_AUTONEG  0x0001ULL
+/**
+ * Enable half-duplex mode
+ */
+#define DPSW_LINK_OPT_HALF_DUPLEX  0x0002ULL
+/**
+ * Enable pause frames
+ */
+#define DPSW_LINK_OPT_PAUSE0x0004ULL
+/**
+ * Enable a-symmetric pause frames
+ */
+#define DPSW_LINK_OPT_ASYM_PAUSE   0x0008ULL
+
+/**
+ * struct dpsw_link_cfg - Structure representing DPSW link configuration
+ * @rate: Rate
+ * @options: Mask of available options; use 'DPSW_LINK_OPT_' values
+ */
+struct dpsw_link_cfg {
+   u32 rate;
+   u64 options;
+};
+
+int dpsw_if_set_link_cfg(struct fsl_mc_io *mc_io,
+u32 cmd_flags,
+u16 token,
+u16 if_id,
+struct dpsw_link_cfg *cfg);
+/**
  * struct dpsw_l

[PATCH v5 6/6] staging: fsl-dpaa2/ethsw: Add TODO

2018-03-13 Thread Razvan Stefanescu
Add a TODO file describing what needs to be added/changed before the driver
can be moved out of staging.

Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
Changelog:
 v2:
- no changes
 v3:
- no changes
 v4:
- remove fsl-mc bus driver dependency as it is out of staging
 v5:
- no changes

 drivers/staging/fsl-dpaa2/ethsw/TODO | 13 +
 1 file changed, 13 insertions(+)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/TODO

diff --git a/drivers/staging/fsl-dpaa2/ethsw/TODO 
b/drivers/staging/fsl-dpaa2/ethsw/TODO
new file mode 100644
index 000..d186875
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/TODO
@@ -0,0 +1,13 @@
+* Add I/O capabilities on switch port netdevices. This will allow control
+traffic to reach the CPU.
+* Add ACL to redirect control traffic to CPU.
+* Add support for displaying learned FDB entries
+* MC firmware uprev; the DPAA2 objects used by the Ethernet Switch driver
+need to   be kept in sync with binary interface changes in MC
+* refine README file
+* cleanup
+
+NOTE: At least first three of the above are required before getting the
+DPAA2 Ethernet Switch driver out of staging. Another requirement is that
+dpio driver is moved to drivers/soc (this is required for I/O).
+
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH v4 2/6] staging: fsl-dpaa2/ethsw: Add Freescale DPAA2 Ethernet Switch driver

2018-03-12 Thread Razvan Stefanescu


> -Original Message-
> From: Andrew Lunn [mailto:and...@lunn.ch]
> Sent: Monday, March 12, 2018 4:37 PM
> To: Razvan Stefanescu <razvan.stefane...@nxp.com>
> Cc: gre...@linuxfoundation.org; de...@driverdev.osuosl.org; linux-
> ker...@vger.kernel.org; net...@vger.kernel.org; Alexander Graf
> <ag...@suse.de>; a...@arndb.de; Alexandru Marginean
> <alexandru.margin...@nxp.com>; Ruxandra Ioana Ciocoi Radulescu
> <ruxandra.radule...@nxp.com>; Ioana Ciornei <ioana.cior...@nxp.com>;
> Laurentiu Tudor <laurentiu.tu...@nxp.com>; stuyo...@gmail.com
> Subject: Re: [PATCH v4 2/6] staging: fsl-dpaa2/ethsw: Add Freescale DPAA2
> Ethernet Switch driver
> 
> > +static int port_netdevice_event(struct notifier_block *unused,
> > +   unsigned long event, void *ptr)
> > +{
> > +   struct net_device *netdev = netdev_notifier_info_to_dev(ptr);
> > +   struct netdev_notifier_changeupper_info *info = ptr;
> > +   struct net_device *upper_dev;
> > +   int err = 0;
> > +
> > +   if (netdev->netdev_ops != _port_ops)
> > +   return NOTIFY_DONE;
> > +
> > +   /* Handle just upper dev link/unlink for the moment */
> > +   if (event == NETDEV_CHANGEUPPER) {
> > +   upper_dev = info->upper_dev;
> > +   if (netif_is_bridge_master(upper_dev)) {
> > +   if (info->linking)
> > +   err = port_bridge_join(netdev);
> > +   else
> > +   err = port_bridge_leave(netdev);
> > +   }
> > +   }
> > +
> > +   return notifier_from_errno(err);
> > +}
> 
> I could be missing something here, but don't you need to pass to
> port_bridge_join() which bridge the port is joining. There can be
> multiple bridges, so you need to ensure the port joins the correct
> bridge.
> 
Thank you for noticing this. I'll add proper checks in next version.

Razvan

>   Andrew
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 2/6] staging: fsl-dpaa2/ethsw: Add Freescale DPAA2 Ethernet Switch driver

2018-03-12 Thread Razvan Stefanescu
Introduce the DPAA2 Ethernet Switch driver, which manages Datapath Switch
(DPSW) objects discovered on the MC bus.

Suggested-by: Alexandru Marginean <alexandru.margin...@nxp.com>
Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
Changelog:
 v2:
- fix PVID cleanup in ethsw_port_add_vlan()
- rename err2 to ret in ethsw_port_add/del_vlan()
- avoid duplicate code in ethsw_probe()
- move destroy_workqueue to ethsw_takedown()
- have a function for unregistering notifiers
- above changes implement review comments for v1 from Bogdan P.
 v3:
- no changes
 v4:
- adjust to moving MC-bus out of staging
- support adding/deleting multicast entries to/from FDB
- selectively discard benign MC errors for calling add/delete fdb entries
  multiple times to avoid spamming console with stack traces
- refactor setting TCI to avoid code duplication
- clean probe code error path

 drivers/staging/fsl-dpaa2/ethsw/Makefile |2 +-
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c  | 1515 ++
 drivers/staging/fsl-dpaa2/ethsw/ethsw.h  |   88 ++
 3 files changed, 1604 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.h

diff --git a/drivers/staging/fsl-dpaa2/ethsw/Makefile 
b/drivers/staging/fsl-dpaa2/ethsw/Makefile
index db137f7..a6d72d1 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/Makefile
+++ b/drivers/staging/fsl-dpaa2/ethsw/Makefile
@@ -4,4 +4,4 @@
 
 obj-$(CONFIG_FSL_DPAA2_ETHSW) += dpaa2-ethsw.o
 
-dpaa2-ethsw-objs := dpsw.o
+dpaa2-ethsw-objs := ethsw.o dpsw.o
diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
new file mode 100644
index 000..b992434
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
@@ -0,0 +1,1515 @@
+/* Copyright 2014-2016 Freescale Semiconductor Inc.
+ * Copyright 2017-2018 NXP
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of the above-listed copyright holders nor the
+ *  names of any contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "ethsw.h"
+
+static struct workqueue_struct *ethsw_owq;
+
+/* Minimal supported DPSW version */
+#define DPSW_MIN_VER_MAJOR 8
+#define DPSW_MIN_VER_MINOR 0
+
+#define DEFAULT_VLAN_ID1
+
+static int ethsw_add_vlan(struct ethsw_core *ethsw, u16 vid)
+{
+   int err;
+
+   struct dpsw_vlan_cfgvcfg = {
+   .fdb_id = 0,
+   };
+
+   if (ethsw->vlans[vid]) {
+   dev_err(ethsw->dev, "VLAN already configured\n");
+   return -EEXIST;
+   }
+
+   err = dpsw_vlan_add(ethsw->mc_io, 0,
+   ethsw->dpsw_handle, vid, );
+   if (err) {
+   dev_err(ethsw->dev, "dpsw_vlan_add err %d\n", err);
+   return err;
+   }
+   ethsw->vlans[vid] = ETHSW_VLAN_MEMBER;
+
+   return 0;
+}
+
+static int ethsw_port_set_tci(struct ethsw_port_priv *port_priv,
+ struct dpsw_tci_cfg *tci_cfg)
+{
+   struct ethsw_core *ethsw = port_priv->ethsw_data;
+   struct

[PATCH v4 5/6] staging: fsl-dpaa2/ethsw: Add README

2018-03-12 Thread Razvan Stefanescu
Add a README file describing the driver architecture, components and
interfaces.

Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
Changelog:
 v2:
- no changes
 v3:
- no changes
 v4:
- no changes

 drivers/staging/fsl-dpaa2/ethsw/README | 106 +
 1 file changed, 106 insertions(+)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/README

diff --git a/drivers/staging/fsl-dpaa2/ethsw/README 
b/drivers/staging/fsl-dpaa2/ethsw/README
new file mode 100644
index 000..f6fc07f
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/README
@@ -0,0 +1,106 @@
+DPAA2 Ethernet Switch driver
+
+
+This file provides documentation for the DPAA2 Ethernet Switch driver
+
+
+Contents
+
+   Supported Platforms
+   Architecture Overview
+   Creating an Ethernet Switch
+   Features
+
+
+   Supported Platforms
+===
+This driver provides networking support for Freescale LS2085A, LS2088A
+DPAA2 SoCs.
+
+
+Architecture Overview
+=
+The Ethernet Switch in the DPAA2 architecture consists of several hardware
+resources that provide the functionality. These are allocated and
+configured via the Management Complex (MC) portals. MC abstracts most of
+these resources as DPAA2 objects and exposes ABIs through which they can
+be configured and controlled.
+
+For a more detailed description of the DPAA2 architecture and its object
+abstractions see:
+   drivers/staging/fsl-mc/README.txt
+
+The Ethernet Switch is built on top of a Datapath Switch (DPSW) object.
+
+Configuration interface:
+
+  -
+ | DPAA2 Switch driver |
+  -
+   .
+   .
+  --
+ | DPSW API |
+  --
+   .   software
+ = . ==
+   .   hardware
+  -
+ | MC hardware portals |
+  -
+   .
+   .
+ --
+| DPSW |
+ --
+
+Driver uses the switch device driver model and exposes each switch port as
+a network interface, which can be included in a bridge. Traffic switched
+between ports is offloaded into the hardware. Exposed network interfaces
+are not used for I/O, they are used just for configuration. This
+limitation is going to be addressed in the future.
+
+The DPSW can have ports connected to DPNIs or to PHYs via DPMACs.
+
+
+ [ethA] [ethB] [ethC] [ethD] [ethE] [ethF]
+:  :  :  :  :  :
+:  :  :  :  :  :
+[eth drv]  [eth drv]  [ethsw drv  ]
+:  :  :  :  :  :kernel
+
+:  :  :  :  :  :hardware
+ [DPNI]  [DPNI] [= DPSW =]
+|  |  |  |  |  |
+|   --   |   [DPMAC][DPMAC]
+ ---|  |
+|  |
+  [PHY]  [PHY]
+
+For a more detailed description of the Ethernet switch device driver model
+see:
+   Documentation/networking/switchdev.txt
+
+Creating an Ethernet Switch
+===
+A device is created for the switch objects probed on the MC bus. Each DPSW
+has a number of properties which determine the configuration options and
+associated hardware resources.
+
+A DPSW object (and the other DPAA2 objects needed for a DPAA2 switch) can
+be added to a container on the MC bus in one of two ways: statically,
+through a Datapath Layout Binary file (DPL) that is parsed by MC at boot
+time; or created dynamically at runtime, via the DPAA2 objects APIs.
+
+Features
+
+Driver configures DPSW to perform hardware switching offload of
+unicast/multicast/broadcast (VLAN tagged or untagged) traffic between its
+ports.
+
+It allows configuration of hardware learning, flooding, multicast groups,
+port VLAN configuration and STP state.
+
+Static entries can be added/removed from the FDB.
+
+Hardware statistics for each port are provided through ethtool -S option.
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 4/6] staging: fsl-dpaa2/ethsw: Add maintainer for Ethernet Switch driver

2018-03-12 Thread Razvan Stefanescu
Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
Changelog:
 v2:
- no changes
 v3:
- no changes
 v4:
- no changes

 MAINTAINERS | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index c3c2b75..20d7bf2 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4410,6 +4410,12 @@ L:   linux-ker...@vger.kernel.org
 S: Maintained
 F: drivers/staging/fsl-dpaa2/ethernet
 
+DPAA2 ETHERNET SWITCH DRIVER
+M: Razvan Stefanescu <razvan.stefane...@nxp.com>
+L: linux-ker...@vger.kernel.org
+S: Maintained
+F: drivers/staging/fsl-dpaa2/ethsw
+
 DPT_I2O SCSI RAID DRIVER
 M: Adaptec OEM Raid Solutions <aacr...@adaptec.com>
 L: linux-s...@vger.kernel.org
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 1/6] staging: fsl-dpaa2/ethsw: Add APIs for DPSW object

2018-03-12 Thread Razvan Stefanescu
Add the command build/parse APIs for operating on DPSW objects through
the DPAA2 Management Complex.

Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
Changelog:
 v2:
- use u8 for en parameter of dpsw_if_set_flooding/broadcast()
 v3:
- no changes
 v4:
- adjust to moving MC-bus out of staging
- fix sparse warnings

 drivers/staging/fsl-dpaa2/Kconfig  |8 +
 drivers/staging/fsl-dpaa2/Makefile |1 +
 drivers/staging/fsl-dpaa2/ethsw/Makefile   |7 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h |  358 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw.c | 1116 
 drivers/staging/fsl-dpaa2/ethsw/dpsw.h |  579 +++
 6 files changed, 2069 insertions(+)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/Makefile
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.h

diff --git a/drivers/staging/fsl-dpaa2/Kconfig 
b/drivers/staging/fsl-dpaa2/Kconfig
index dfff675..8a508ef 100644
--- a/drivers/staging/fsl-dpaa2/Kconfig
+++ b/drivers/staging/fsl-dpaa2/Kconfig
@@ -16,3 +16,11 @@ config FSL_DPAA2_ETH
---help---
  Ethernet driver for Freescale DPAA2 SoCs, using the
  Freescale MC bus driver
+
+config FSL_DPAA2_ETHSW
+   tristate "Freescale DPAA2 Ethernet Switch"
+   depends on FSL_DPAA2
+   depends on NET_SWITCHDEV
+   ---help---
+   Driver for Freescale DPAA2 Ethernet Switch. Select
+   BRIDGE to have support for bridge tools.
diff --git a/drivers/staging/fsl-dpaa2/Makefile 
b/drivers/staging/fsl-dpaa2/Makefile
index 0836ba8..6cfd76b 100644
--- a/drivers/staging/fsl-dpaa2/Makefile
+++ b/drivers/staging/fsl-dpaa2/Makefile
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_FSL_DPAA2_ETH)+= ethernet/
+obj-$(CONFIG_FSL_DPAA2_ETHSW)  += ethsw/
diff --git a/drivers/staging/fsl-dpaa2/ethsw/Makefile 
b/drivers/staging/fsl-dpaa2/ethsw/Makefile
new file mode 100644
index 000..db137f7
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/Makefile
@@ -0,0 +1,7 @@
+#
+# Makefile for the Freescale DPAA2 Ethernet Switch
+#
+
+obj-$(CONFIG_FSL_DPAA2_ETHSW) += dpaa2-ethsw.o
+
+dpaa2-ethsw-objs := dpsw.o
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
new file mode 100644
index 000..36edef6
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
@@ -0,0 +1,358 @@
+/* Copyright 2013-2016 Freescale Semiconductor Inc.
+ * Copyright 2017-2018 NXP
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of the above-listed copyright holders nor the
+ *  names of any contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef __FSL_DPSW_CMD_H
+#define __FSL_DPSW_CMD_H
+
+/* DPSW Version */
+#define DPSW_VER_MAJOR 8
+#define DPSW_VER_MINOR 0
+
+#define DPSW_CMD_BASE_VERSION  1
+#define DPSW_CMD_ID_OFFSET 4
+
+#define DPSW_CMD_ID(id)(((id) << DPSW_CMD_ID_OFFSET) | 
DPSW_CMD_BASE_VERSION)
+
+/* Command IDs */
+#define DPSW_CMDID_CLOSEDPSW_CMD_ID(0x800)
+#define DPSW_CMDID_OPEN DPSW_CMD_ID(0x802)
+
+#define DPSW_CMDID_GET_API_VERSION  DPSW_CMD_ID(0xa02)
+
+#define DPSW_CMDID_ENABLE

[PATCH v4 3/6] staging: fsl-dpaa2/ethsw: Add ethtool support

2018-03-12 Thread Razvan Stefanescu
Add driver information, link details and hardware statistics to be
reported via ethtool -S.

Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
Changelog:
 v2:
- no changes
 v3:
- removed driver version
 v4:
- no changes

 drivers/staging/fsl-dpaa2/ethsw/Makefile|   2 +-
 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h  |  13 ++
 drivers/staging/fsl-dpaa2/ethsw/dpsw.c  |  32 
 drivers/staging/fsl-dpaa2/ethsw/dpsw.h  |  32 
 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c | 206 
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c |   1 +
 drivers/staging/fsl-dpaa2/ethsw/ethsw.h |   2 +
 7 files changed, 287 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c

diff --git a/drivers/staging/fsl-dpaa2/ethsw/Makefile 
b/drivers/staging/fsl-dpaa2/ethsw/Makefile
index a6d72d1..de92cd9 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/Makefile
+++ b/drivers/staging/fsl-dpaa2/ethsw/Makefile
@@ -4,4 +4,4 @@
 
 obj-$(CONFIG_FSL_DPAA2_ETHSW) += dpaa2-ethsw.o
 
-dpaa2-ethsw-objs := ethsw.o dpsw.o
+dpaa2-ethsw-objs := ethsw.o ethsw-ethtool.o dpsw.o
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
index 36edef6..c45f001 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
@@ -74,6 +74,8 @@
 #define DPSW_CMDID_IF_SET_FLOODING  DPSW_CMD_ID(0x047)
 #define DPSW_CMDID_IF_SET_BROADCAST DPSW_CMD_ID(0x048)
 
+#define DPSW_CMDID_IF_SET_LINK_CFG  DPSW_CMD_ID(0x04C)
+
 #define DPSW_CMDID_VLAN_ADD DPSW_CMD_ID(0x060)
 #define DPSW_CMDID_VLAN_ADD_IF  DPSW_CMD_ID(0x061)
 #define DPSW_CMDID_VLAN_ADD_IF_UNTAGGED DPSW_CMD_ID(0x062)
@@ -262,6 +264,17 @@ struct dpsw_cmd_if_set_max_frame_length {
__le16 frame_length;
 };
 
+struct dpsw_cmd_if_set_link_cfg {
+   /* cmd word 0 */
+   __le16 if_id;
+   u8 pad[6];
+   /* cmd word 1 */
+   __le32 rate;
+   __le32 pad1;
+   /* cmd word 2 */
+   __le64 options;
+};
+
 struct dpsw_cmd_if_get_link_state {
__le16 if_id;
 };
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
index 8e52d74..e63531d 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
@@ -383,6 +383,38 @@ int dpsw_get_attributes(struct fsl_mc_io *mc_io,
 }
 
 /**
+ * dpsw_if_set_link_cfg() - Set the link configuration.
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPSW object
+ * @if_id: Interface id
+ * @cfg:   Link configuration
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dpsw_if_set_link_cfg(struct fsl_mc_io *mc_io,
+u32 cmd_flags,
+u16 token,
+u16 if_id,
+struct dpsw_link_cfg *cfg)
+{
+   struct mc_command cmd = { 0 };
+   struct dpsw_cmd_if_set_link_cfg *cmd_params;
+
+   /* prepare command */
+   cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_LINK_CFG,
+ cmd_flags,
+ token);
+   cmd_params = (struct dpsw_cmd_if_set_link_cfg *)cmd.params;
+   cmd_params->if_id = cpu_to_le16(if_id);
+   cmd_params->rate = cpu_to_le32(cfg->rate);
+   cmd_params->options = cpu_to_le64(cfg->options);
+
+   /* send command to mc*/
+   return mc_send_command(mc_io, );
+}
+
+/**
  * dpsw_if_get_link_state - Return the link state
  * @mc_io: Pointer to MC portal's I/O object
  * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw.h 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
index d13970c..5a0c7ad 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
@@ -245,6 +245,38 @@ enum dpsw_action {
 };
 
 /**
+ * Enable auto-negotiation
+ */
+#define DPSW_LINK_OPT_AUTONEG  0x0001ULL
+/**
+ * Enable half-duplex mode
+ */
+#define DPSW_LINK_OPT_HALF_DUPLEX  0x0002ULL
+/**
+ * Enable pause frames
+ */
+#define DPSW_LINK_OPT_PAUSE0x0004ULL
+/**
+ * Enable a-symmetric pause frames
+ */
+#define DPSW_LINK_OPT_ASYM_PAUSE   0x0008ULL
+
+/**
+ * struct dpsw_link_cfg - Structure representing DPSW link configuration
+ * @rate: Rate
+ * @options: Mask of available options; use 'DPSW_LINK_OPT_' values
+ */
+struct dpsw_link_cfg {
+   u32 rate;
+   u64 options;
+};
+
+int dpsw_if_set_link_cfg(struct fsl_mc_io *mc_io,
+u32 cmd_flags,
+u16 token,
+u16 if_id,
+struct dpsw_link_cfg *cfg);
+/**
  * struct dpsw_link_state - Structure r

[PATCH v4 6/6] staging: fsl-dpaa2/ethsw: Add TODO

2018-03-12 Thread Razvan Stefanescu
Add a TODO file describing what needs to be added/changed before the driver
can be moved out of staging.

Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
Changelog:
 v2:
- no changes
 v3:
- no changes
 v4:
- remove fsl-mc bus driver dependency as it is out of staging

 drivers/staging/fsl-dpaa2/ethsw/TODO | 13 +
 1 file changed, 13 insertions(+)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/TODO

diff --git a/drivers/staging/fsl-dpaa2/ethsw/TODO 
b/drivers/staging/fsl-dpaa2/ethsw/TODO
new file mode 100644
index 000..d186875
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/TODO
@@ -0,0 +1,13 @@
+* Add I/O capabilities on switch port netdevices. This will allow control
+traffic to reach the CPU.
+* Add ACL to redirect control traffic to CPU.
+* Add support for displaying learned FDB entries
+* MC firmware uprev; the DPAA2 objects used by the Ethernet Switch driver
+need to   be kept in sync with binary interface changes in MC
+* refine README file
+* cleanup
+
+NOTE: At least first three of the above are required before getting the
+DPAA2 Ethernet Switch driver out of staging. Another requirement is that
+dpio driver is moved to drivers/soc (this is required for I/O).
+
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 0/6] staging: Introduce DPAA2 Ethernet Switch driver

2018-03-12 Thread Razvan Stefanescu
This patchset introduces the Ethernet Switch Driver for Freescale/NXP SoCs
with DPAA2 (DataPath Acceleration Architecture v2). The driver manages
switch objects discovered on the fsl-mc bus. A description of the driver
can be found in the associated README file.

The patchset consists of:
* A set of libraries containing APIs for configuring and controlling
  Management Complex (MC) switch objects
* The DPAA2 Ethernet Switch driver
* Patch adding ethtool support

Limitations:
* no support for control traffic to/from CPU
* only DPSW ports can be added to a bridge

Changelog:
 v2: addressed comments from Bogdan P.

 v3: addressed comments from Andrew L. (patch 3/6 updated)

 v4: adjust to moving MC-bus out of staging
 support adding/deleting multicast entries to/from FDB
 avoid triggering console stack traces due to benign MC errors
 refactor TCI setting code to avoid code duplication
 fix sparse warning

Razvan Stefanescu (6):
  staging: fsl-dpaa2/ethsw: Add APIs for DPSW object
  staging: fsl-dpaa2/ethsw: Add Freescale DPAA2 Ethernet Switch driver
  staging: fsl-dpaa2/ethsw: Add ethtool support
  staging: fsl-dpaa2/ethsw: Add maintainer for Ethernet Switch driver
  staging: fsl-dpaa2/ethsw: Add README
  staging: fsl-dpaa2/ethsw: Add TODO

 MAINTAINERS |6 +
 drivers/staging/fsl-dpaa2/Kconfig   |8 +
 drivers/staging/fsl-dpaa2/Makefile  |1 +
 drivers/staging/fsl-dpaa2/ethsw/Makefile|7 +
 drivers/staging/fsl-dpaa2/ethsw/README  |  106 ++
 drivers/staging/fsl-dpaa2/ethsw/TODO|   13 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h  |  371 ++
 drivers/staging/fsl-dpaa2/ethsw/dpsw.c  | 1148 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw.h  |  611 +
 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c |  206 +++
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 1516 +++
 drivers/staging/fsl-dpaa2/ethsw/ethsw.h |   90 ++
 12 files changed, 4083 insertions(+)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/Makefile
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/README
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/TODO
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.h
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.h

-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 4/6] staging: fsl-dpaa2/ethsw: Add maintainer for Ethernet Switch driver

2017-10-05 Thread Razvan Stefanescu
Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
Changelog:
 v2:
- no changes
 v3:
- no changes

 MAINTAINERS | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 2281af4..cfd4f74 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4297,6 +4297,12 @@ L:   linux-ker...@vger.kernel.org
 S: Maintained
 F: drivers/staging/fsl-dpaa2/ethernet
 
+DPAA2 ETHERNET SWITCH DRIVER
+M: Razvan Stefanescu <razvan.stefane...@nxp.com>
+L: linux-ker...@vger.kernel.org
+S: Maintained
+F: drivers/staging/fsl-dpaa2/ethsw
+
 DPT_I2O SCSI RAID DRIVER
 M: Adaptec OEM Raid Solutions <aacr...@adaptec.com>
 L: linux-s...@vger.kernel.org
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 5/6] staging: fsl-dpaa2/ethsw: Add README

2017-10-05 Thread Razvan Stefanescu
Add a README file describing the driver architecture, components and
interfaces.

Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
Changelog:
 v2:
- no changes
 v3:
- no changes

 drivers/staging/fsl-dpaa2/ethsw/README | 106 +
 1 file changed, 106 insertions(+)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/README

diff --git a/drivers/staging/fsl-dpaa2/ethsw/README 
b/drivers/staging/fsl-dpaa2/ethsw/README
new file mode 100644
index 000..f6fc07f
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/README
@@ -0,0 +1,106 @@
+DPAA2 Ethernet Switch driver
+
+
+This file provides documentation for the DPAA2 Ethernet Switch driver
+
+
+Contents
+
+   Supported Platforms
+   Architecture Overview
+   Creating an Ethernet Switch
+   Features
+
+
+   Supported Platforms
+===
+This driver provides networking support for Freescale LS2085A, LS2088A
+DPAA2 SoCs.
+
+
+Architecture Overview
+=
+The Ethernet Switch in the DPAA2 architecture consists of several hardware
+resources that provide the functionality. These are allocated and
+configured via the Management Complex (MC) portals. MC abstracts most of
+these resources as DPAA2 objects and exposes ABIs through which they can
+be configured and controlled.
+
+For a more detailed description of the DPAA2 architecture and its object
+abstractions see:
+   drivers/staging/fsl-mc/README.txt
+
+The Ethernet Switch is built on top of a Datapath Switch (DPSW) object.
+
+Configuration interface:
+
+  -
+ | DPAA2 Switch driver |
+  -
+   .
+   .
+  --
+ | DPSW API |
+  --
+   .   software
+ = . ==
+   .   hardware
+  -
+ | MC hardware portals |
+  -
+   .
+   .
+ --
+| DPSW |
+ --
+
+Driver uses the switch device driver model and exposes each switch port as
+a network interface, which can be included in a bridge. Traffic switched
+between ports is offloaded into the hardware. Exposed network interfaces
+are not used for I/O, they are used just for configuration. This
+limitation is going to be addressed in the future.
+
+The DPSW can have ports connected to DPNIs or to PHYs via DPMACs.
+
+
+ [ethA] [ethB] [ethC] [ethD] [ethE] [ethF]
+:  :  :  :  :  :
+:  :  :  :  :  :
+[eth drv]  [eth drv]  [ethsw drv  ]
+:  :  :  :  :  :kernel
+
+:  :  :  :  :  :hardware
+ [DPNI]  [DPNI] [= DPSW =]
+|  |  |  |  |  |
+|   --   |   [DPMAC][DPMAC]
+ ---|  |
+|  |
+  [PHY]  [PHY]
+
+For a more detailed description of the Ethernet switch device driver model
+see:
+   Documentation/networking/switchdev.txt
+
+Creating an Ethernet Switch
+===
+A device is created for the switch objects probed on the MC bus. Each DPSW
+has a number of properties which determine the configuration options and
+associated hardware resources.
+
+A DPSW object (and the other DPAA2 objects needed for a DPAA2 switch) can
+be added to a container on the MC bus in one of two ways: statically,
+through a Datapath Layout Binary file (DPL) that is parsed by MC at boot
+time; or created dynamically at runtime, via the DPAA2 objects APIs.
+
+Features
+
+Driver configures DPSW to perform hardware switching offload of
+unicast/multicast/broadcast (VLAN tagged or untagged) traffic between its
+ports.
+
+It allows configuration of hardware learning, flooding, multicast groups,
+port VLAN configuration and STP state.
+
+Static entries can be added/removed from the FDB.
+
+Hardware statistics for each port are provided through ethtool -S option.
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 0/6] staging: Introduce DPAA2 Ethernet Switch driver

2017-10-05 Thread Razvan Stefanescu
This patchset introduces the Ethernet Switch Driver for Freescale/NXP SoCs
with DPAA2 (DataPath Acceleration Architecture v2). The driver manages
switch objects discovered on the fsl-mc bus. A description of the driver
can be found in the associated README file.

The patchset consists of:
* A set of libraries containing APIs for configuring and controlling
  Management Complex (MC) switch objects
* The DPAA2 Ethernet Switch driver
* Patch adding ethtool support

Limitations:
* no support for control traffic to/from CPU
* only DPSW ports can be added to a bridge

Changelog:
 v2: addressed comments from Bogdan P.
 
 v3: addressed comments from Andrew L. (patch 3/6 updated)

Razvan Stefanescu (6):
  staging: fsl-dpaa2/ethsw: Add APIs for DPSW object
  staging: fsl-dpaa2/ethsw: Add Freescale DPAA2 Ethernet Switch driver
  staging: fsl-dpaa2/ethsw: Add ethtool support
  staging: fsl-dpaa2/ethsw: Add maintainer for Ethernet Switch driver
  staging: fsl-dpaa2/ethsw: Add README
  staging: fsl-dpaa2/ethsw: Add TODO

 MAINTAINERS |6 +
 drivers/staging/fsl-dpaa2/Kconfig   |8 +
 drivers/staging/fsl-dpaa2/Makefile  |1 +
 drivers/staging/fsl-dpaa2/ethsw/Makefile|7 +
 drivers/staging/fsl-dpaa2/ethsw/README  |  106 ++
 drivers/staging/fsl-dpaa2/ethsw/TODO|   14 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h  |  371 ++
 drivers/staging/fsl-dpaa2/ethsw/dpsw.c  | 1147 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw.h  |  611 +
 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c |  206 +++
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 1532 +++
 drivers/staging/fsl-dpaa2/ethsw/ethsw.h |   90 ++
 12 files changed, 4099 insertions(+)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/Makefile
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/README
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/TODO
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.h
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.h

-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 1/6] staging: fsl-dpaa2/ethsw: Add APIs for DPSW object

2017-10-05 Thread Razvan Stefanescu
Add the command build/parse APIs for operating on DPSW objects through
the DPAA2 Management Complex.

Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
Changelog:
 v2:
- use u8 for en parameter of dpsw_if_set_flooding/broadcast()
 v3:
- no changes

 drivers/staging/fsl-dpaa2/Kconfig  |8 +
 drivers/staging/fsl-dpaa2/Makefile |1 +
 drivers/staging/fsl-dpaa2/ethsw/Makefile   |7 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h |  358 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw.c | 1115 
 drivers/staging/fsl-dpaa2/ethsw/dpsw.h |  579 +++
 6 files changed, 2068 insertions(+)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/Makefile
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.h

diff --git a/drivers/staging/fsl-dpaa2/Kconfig 
b/drivers/staging/fsl-dpaa2/Kconfig
index dfff675..8a508ef 100644
--- a/drivers/staging/fsl-dpaa2/Kconfig
+++ b/drivers/staging/fsl-dpaa2/Kconfig
@@ -16,3 +16,11 @@ config FSL_DPAA2_ETH
---help---
  Ethernet driver for Freescale DPAA2 SoCs, using the
  Freescale MC bus driver
+
+config FSL_DPAA2_ETHSW
+   tristate "Freescale DPAA2 Ethernet Switch"
+   depends on FSL_DPAA2
+   depends on NET_SWITCHDEV
+   ---help---
+   Driver for Freescale DPAA2 Ethernet Switch. Select
+   BRIDGE to have support for bridge tools.
diff --git a/drivers/staging/fsl-dpaa2/Makefile 
b/drivers/staging/fsl-dpaa2/Makefile
index 0836ba8..6cfd76b 100644
--- a/drivers/staging/fsl-dpaa2/Makefile
+++ b/drivers/staging/fsl-dpaa2/Makefile
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_FSL_DPAA2_ETH)+= ethernet/
+obj-$(CONFIG_FSL_DPAA2_ETHSW)  += ethsw/
diff --git a/drivers/staging/fsl-dpaa2/ethsw/Makefile 
b/drivers/staging/fsl-dpaa2/ethsw/Makefile
new file mode 100644
index 000..db137f7
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/Makefile
@@ -0,0 +1,7 @@
+#
+# Makefile for the Freescale DPAA2 Ethernet Switch
+#
+
+obj-$(CONFIG_FSL_DPAA2_ETHSW) += dpaa2-ethsw.o
+
+dpaa2-ethsw-objs := dpsw.o
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
new file mode 100644
index 000..ddfd820
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
@@ -0,0 +1,358 @@
+/* Copyright 2013-2016 Freescale Semiconductor Inc.
+ * Copyright 2017 NXP
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of the above-listed copyright holders nor the
+ *  names of any contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef __FSL_DPSW_CMD_H
+#define __FSL_DPSW_CMD_H
+
+/* DPSW Version */
+#define DPSW_VER_MAJOR 8
+#define DPSW_VER_MINOR 0
+
+#define DPSW_CMD_BASE_VERSION  1
+#define DPSW_CMD_ID_OFFSET 4
+
+#define DPSW_CMD_ID(id)(((id) << DPSW_CMD_ID_OFFSET) | 
DPSW_CMD_BASE_VERSION)
+
+/* Command IDs */
+#define DPSW_CMDID_CLOSEDPSW_CMD_ID(0x800)
+#define DPSW_CMDID_OPEN DPSW_CMD_ID(0x802)
+
+#define DPSW_CMDID_GET_API_VERSION  DPSW_CMD_ID(0xa02)
+
+#define DPSW_CMDID_ENABLE   DPSW_CMD_ID(0x002)
+#define DPSW_CMDID_DISABLE  DPSW_

[PATCH v3 6/6] staging: fsl-dpaa2/ethsw: Add TODO

2017-10-05 Thread Razvan Stefanescu
Add a TODO file describing what needs to be added/changed before the driver
can be moved out of staging.

Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
Changelog:
 v2:
- no changes
 v3:
- no changes

 drivers/staging/fsl-dpaa2/ethsw/TODO | 14 ++
 1 file changed, 14 insertions(+)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/TODO

diff --git a/drivers/staging/fsl-dpaa2/ethsw/TODO 
b/drivers/staging/fsl-dpaa2/ethsw/TODO
new file mode 100644
index 000..d3f12c3
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/TODO
@@ -0,0 +1,14 @@
+* Add I/O capabilities on switch port netdevices. This will allow control
+traffic to reach the CPU.
+* Add ACL to redirect control traffic to CPU.
+* Add support for displaying learned FDB entries
+* MC firmware uprev; the DPAA2 objects used by the Ethernet Switch driver
+need to   be kept in sync with binary interface changes in MC
+* refine README file
+* cleanup
+
+NOTE: At least first three of the above are required before getting the
+DPAA2 Ethernet Switch driver out of staging. Another requirement is that
+the fsl-mc bus driver is moved to drivers/bus and dpio driver is moved to
+drivers/soc (this is required for I/O).
+
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 2/6] staging: fsl-dpaa2/ethsw: Add Freescale DPAA2 Ethernet Switch driver

2017-10-05 Thread Razvan Stefanescu
Introduce the DPAA2 Ethernet Switch driver, which manages Datapath Switch
(DPSW) objects discovered on the MC bus.

Suggested-by: Alexandru Marginean <alexandru.margin...@nxp.com>
Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
Changelog:
 v2:
- fix PVID cleanup in ethsw_port_add_vlan()
- rename err2 to ret in ethsw_port_add/del_vlan()
- avoid duplicate code in ethsw_probe()
- move destroy_workqueue to ethsw_takedown()
- have a function for unregistering notifiers
- above changes implement review comments for v1 from Bogdan P.
 v3:
- no changes

 drivers/staging/fsl-dpaa2/ethsw/Makefile |2 +-
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c  | 1531 ++
 drivers/staging/fsl-dpaa2/ethsw/ethsw.h  |   88 ++
 3 files changed, 1620 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.h

diff --git a/drivers/staging/fsl-dpaa2/ethsw/Makefile 
b/drivers/staging/fsl-dpaa2/ethsw/Makefile
index db137f7..a6d72d1 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/Makefile
+++ b/drivers/staging/fsl-dpaa2/ethsw/Makefile
@@ -4,4 +4,4 @@
 
 obj-$(CONFIG_FSL_DPAA2_ETHSW) += dpaa2-ethsw.o
 
-dpaa2-ethsw-objs := dpsw.o
+dpaa2-ethsw-objs := ethsw.o dpsw.o
diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
new file mode 100644
index 000..f45e5bb
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
@@ -0,0 +1,1531 @@
+/* Copyright 2014-2016 Freescale Semiconductor Inc.
+ * Copyright 2017 NXP
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of the above-listed copyright holders nor the
+ *  names of any contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include "../../fsl-mc/include/mc.h"
+
+#include "ethsw.h"
+
+static struct workqueue_struct *ethsw_owq;
+
+/* Minimal supported DPSW version */
+#define DPSW_MIN_VER_MAJOR 8
+#define DPSW_MIN_VER_MINOR 0
+
+#define DEFAULT_VLAN_ID1
+
+static int ethsw_add_vlan(struct ethsw_core *ethsw, u16 vid)
+{
+   int err;
+
+   struct dpsw_vlan_cfgvcfg = {
+   .fdb_id = 0,
+   };
+
+   if (ethsw->vlans[vid]) {
+   dev_err(ethsw->dev, "VLAN already configured\n");
+   return -EEXIST;
+   }
+
+   err = dpsw_vlan_add(ethsw->mc_io, 0,
+   ethsw->dpsw_handle, vid, );
+   if (err) {
+   dev_err(ethsw->dev, "dpsw_vlan_add err %d\n", err);
+   return err;
+   }
+   ethsw->vlans[vid] = ETHSW_VLAN_MEMBER;
+
+   return 0;
+}
+
+static int ethsw_port_add_vlan(struct ethsw_port_priv *port_priv,
+  u16 vid, u16 flags)
+{
+   struct ethsw_core *ethsw = port_priv->ethsw_data;
+   struct net_device *netdev = port_priv->netdev;
+   struct dpsw_vlan_if_cfg vcfg;
+   bool is_oper;
+   int err, ret;
+
+   if (port_priv->vlans[vid]) {
+   netdev_warn(netdev, "VLAN %d already configured\n", vid);
+   return -EEXIST;
+   }
+
+   vcfg.num_ifs = 1;
+ 

[PATCH v3 3/6] staging: fsl-dpaa2/ethsw: Add ethtool support

2017-10-05 Thread Razvan Stefanescu
Add driver information, link details and hardware statistics to be
reported via ethtool -S.

Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
Changelog:
 v2:
- no changes
 v3:
- removed driver version

 drivers/staging/fsl-dpaa2/ethsw/Makefile|   2 +-
 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h  |  13 ++
 drivers/staging/fsl-dpaa2/ethsw/dpsw.c  |  32 
 drivers/staging/fsl-dpaa2/ethsw/dpsw.h  |  32 
 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c | 206 
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c |   1 +
 drivers/staging/fsl-dpaa2/ethsw/ethsw.h |   2 +
 7 files changed, 287 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c

diff --git a/drivers/staging/fsl-dpaa2/ethsw/Makefile 
b/drivers/staging/fsl-dpaa2/ethsw/Makefile
index a6d72d1..de92cd9 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/Makefile
+++ b/drivers/staging/fsl-dpaa2/ethsw/Makefile
@@ -4,4 +4,4 @@
 
 obj-$(CONFIG_FSL_DPAA2_ETHSW) += dpaa2-ethsw.o
 
-dpaa2-ethsw-objs := ethsw.o dpsw.o
+dpaa2-ethsw-objs := ethsw.o ethsw-ethtool.o dpsw.o
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
index ddfd820..06b71122 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
@@ -74,6 +74,8 @@
 #define DPSW_CMDID_IF_SET_FLOODING  DPSW_CMD_ID(0x047)
 #define DPSW_CMDID_IF_SET_BROADCAST DPSW_CMD_ID(0x048)
 
+#define DPSW_CMDID_IF_SET_LINK_CFG  DPSW_CMD_ID(0x04C)
+
 #define DPSW_CMDID_VLAN_ADD DPSW_CMD_ID(0x060)
 #define DPSW_CMDID_VLAN_ADD_IF  DPSW_CMD_ID(0x061)
 #define DPSW_CMDID_VLAN_ADD_IF_UNTAGGED DPSW_CMD_ID(0x062)
@@ -262,6 +264,17 @@ struct dpsw_cmd_if_set_max_frame_length {
__le16 frame_length;
 };
 
+struct dpsw_cmd_if_set_link_cfg {
+   /* cmd word 0 */
+   __le16 if_id;
+   u8 pad[6];
+   /* cmd word 1 */
+   __le32 rate;
+   __le32 pad1;
+   /* cmd word 2 */
+   __le64 options;
+};
+
 struct dpsw_cmd_if_get_link_state {
__le16 if_id;
 };
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
index e65b6f5..f1a1fac 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
@@ -383,6 +383,38 @@ int dpsw_get_attributes(struct fsl_mc_io *mc_io,
 }
 
 /**
+ * dpsw_if_set_link_cfg() - Set the link configuration.
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPSW object
+ * @if_id: Interface id
+ * @cfg:   Link configuration
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dpsw_if_set_link_cfg(struct fsl_mc_io *mc_io,
+u32 cmd_flags,
+u16 token,
+u16 if_id,
+struct dpsw_link_cfg *cfg)
+{
+   struct mc_command cmd = { 0 };
+   struct dpsw_cmd_if_set_link_cfg *cmd_params;
+
+   /* prepare command */
+   cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_LINK_CFG,
+ cmd_flags,
+ token);
+   cmd_params = (struct dpsw_cmd_if_set_link_cfg *)cmd.params;
+   cmd_params->if_id = cpu_to_le16(if_id);
+   cmd_params->rate = cpu_to_le32(cfg->rate);
+   cmd_params->options = cpu_to_le64(cfg->options);
+
+   /* send command to mc*/
+   return mc_send_command(mc_io, );
+}
+
+/**
  * dpsw_if_get_link_state - Return the link state
  * @mc_io: Pointer to MC portal's I/O object
  * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw.h 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
index 7fa8a61..87369a5 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
@@ -245,6 +245,38 @@ enum dpsw_action {
 };
 
 /**
+ * Enable auto-negotiation
+ */
+#define DPSW_LINK_OPT_AUTONEG  0x0001ULL
+/**
+ * Enable half-duplex mode
+ */
+#define DPSW_LINK_OPT_HALF_DUPLEX  0x0002ULL
+/**
+ * Enable pause frames
+ */
+#define DPSW_LINK_OPT_PAUSE0x0004ULL
+/**
+ * Enable a-symmetric pause frames
+ */
+#define DPSW_LINK_OPT_ASYM_PAUSE   0x0008ULL
+
+/**
+ * struct dpsw_link_cfg - Structure representing DPSW link configuration
+ * @rate: Rate
+ * @options: Mask of available options; use 'DPSW_LINK_OPT_' values
+ */
+struct dpsw_link_cfg {
+   u32 rate;
+   u64 options;
+};
+
+int dpsw_if_set_link_cfg(struct fsl_mc_io *mc_io,
+u32 cmd_flags,
+u16 token,
+u16 if_id,
+struct dpsw_link_cfg *cfg);
+/**
  * struct dpsw_link_state - Structure representing DPSW link 

RE: [PATCH 5/6] staging: fsl-dpaa2/ethsw: Add README

2017-10-03 Thread Razvan Stefanescu
> -Original Message-
> From: linux-arm-kernel [mailto:linux-arm-kernel-boun...@lists.infradead.org]
> On Behalf Of Andrew Lunn
> Sent: Tuesday, September 19, 2017 3:18 PM
> To: Razvan Stefanescu <razvan.stefane...@nxp.com>
> Cc: de...@driverdev.osuosl.org; Ruxandra Ioana Radulescu
> <ruxandra.radule...@nxp.com>; a...@arndb.de; gre...@linuxfoundation.org;
> Alexandru Marginean <alexandru.margin...@nxp.com>; linux-
> ker...@vger.kernel.org; ag...@suse.de; stuyo...@gmail.com; Bogdan
> Purcareata <bogdan.purcare...@nxp.com>; linux-arm-
> ker...@lists.infradead.org; Laurentiu Tudor <laurentiu.tu...@nxp.com>
> Subject: Re: [PATCH 5/6] staging: fsl-dpaa2/ethsw: Add README
> 
> On Tue, Sep 19, 2017 at 12:01:37PM +0300, Razvan Stefanescu wrote:
> > +Driver uses the switch device driver model and exposes each switch port as
> > +a network interface, which can be included in a bridge. Traffic switched
> > +between ports is offloaded into the hardware. Exposed network interfaces
> > +are not used for I/O, they are used just for configuration. This
> > +limitation is going to be addressed in the future.
> 
> Hi Razvan
> 
> Could you briefly describe how Ethernet frames get from the CPU to the
> switch. This is what decided if you should write a plain switchdev
> driver, or a DSA driver.
> 
>   Andrew
> 
Hello Andrew,

CPU frame handling will be added in a later. Each netdevice associated 
to a switch port will have I/O capabilities like dpaa2-ethernet devices.
The dpaa2-ethsw will use ACLs to redirect specific types of frames
(i.e BPDUs) to CPU.

Best regards,
Razvan S.



___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH v2 3/6] staging: fsl-dpaa2/ethsw: Add ethtool support

2017-10-02 Thread Razvan Stefanescu


> -Original Message-
> From: Andrew Lunn [mailto:and...@lunn.ch]
> Sent: Monday, October 02, 2017 18:37
> To: Razvan Stefanescu <razvan.stefane...@nxp.com>
> Cc: gre...@linuxfoundation.org; de...@driverdev.osuosl.org; linux-
> ker...@vger.kernel.org; net...@vger.kernel.org; ag...@suse.de;
> a...@arndb.de; Alexandru Marginean <alexandru.margin...@nxp.com>;
> Bogdan Purcareata <bogdan.purcare...@nxp.com>; Ruxandra Ioana Radulescu
> <ruxandra.radule...@nxp.com>; Laurentiu Tudor <laurentiu.tu...@nxp.com>;
> stuyo...@gmail.com
> Subject: Re: [PATCH v2 3/6] staging: fsl-dpaa2/ethsw: Add ethtool support
> 
> Hi Razvan
> 
> > +static void ethsw_get_drvinfo(struct net_device *netdev,
> > + struct ethtool_drvinfo *drvinfo)
> > +{
> > +   struct ethsw_port_priv *port_priv = netdev_priv(netdev);
> > +   u16 version_major, version_minor;
> > +   int err;
> > +
> > +   strlcpy(drvinfo->driver, KBUILD_MODNAME, sizeof(drvinfo->driver));
> > +   strlcpy(drvinfo->version, ethsw_drv_version, sizeof(drvinfo->version));
> 
> Software driver versions are mostly useless. I would suggest you
> remove this.
> 
>Andrew
Thank you. I'll remove it in v3.

Best regards,
Razvan S.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 2/6] staging: fsl-dpaa2/ethsw: Add Freescale DPAA2 Ethernet Switch driver

2017-10-02 Thread Razvan Stefanescu
Introduce the DPAA2 Ethernet Switch driver, which manages Datapath Switch
(DPSW) objects discovered on the MC bus.

Suggested-by: Alexandru Marginean <alexandru.margin...@nxp.com>
Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
Changelog:
 v2:
- fix PVID cleanup in ethsw_port_add_vlan()
- rename err2 to ret in ethsw_port_add/del_vlan()
- avoid duplicate code in ethsw_probe()
- move destroy_workqueue to ethsw_takedown()
- have a function for unregistering notifiers
- above changes implement review comments for v1 from Bogdan P.

 drivers/staging/fsl-dpaa2/ethsw/Makefile |2 +-
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c  | 1531 ++
 drivers/staging/fsl-dpaa2/ethsw/ethsw.h  |   88 ++
 3 files changed, 1620 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.h

diff --git a/drivers/staging/fsl-dpaa2/ethsw/Makefile 
b/drivers/staging/fsl-dpaa2/ethsw/Makefile
index db137f7..a6d72d1 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/Makefile
+++ b/drivers/staging/fsl-dpaa2/ethsw/Makefile
@@ -4,4 +4,4 @@
 
 obj-$(CONFIG_FSL_DPAA2_ETHSW) += dpaa2-ethsw.o
 
-dpaa2-ethsw-objs := dpsw.o
+dpaa2-ethsw-objs := ethsw.o dpsw.o
diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
new file mode 100644
index 000..f45e5bb
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
@@ -0,0 +1,1531 @@
+/* Copyright 2014-2016 Freescale Semiconductor Inc.
+ * Copyright 2017 NXP
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of the above-listed copyright holders nor the
+ *  names of any contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include "../../fsl-mc/include/mc.h"
+
+#include "ethsw.h"
+
+static struct workqueue_struct *ethsw_owq;
+
+/* Minimal supported DPSW version */
+#define DPSW_MIN_VER_MAJOR 8
+#define DPSW_MIN_VER_MINOR 0
+
+#define DEFAULT_VLAN_ID1
+
+static int ethsw_add_vlan(struct ethsw_core *ethsw, u16 vid)
+{
+   int err;
+
+   struct dpsw_vlan_cfgvcfg = {
+   .fdb_id = 0,
+   };
+
+   if (ethsw->vlans[vid]) {
+   dev_err(ethsw->dev, "VLAN already configured\n");
+   return -EEXIST;
+   }
+
+   err = dpsw_vlan_add(ethsw->mc_io, 0,
+   ethsw->dpsw_handle, vid, );
+   if (err) {
+   dev_err(ethsw->dev, "dpsw_vlan_add err %d\n", err);
+   return err;
+   }
+   ethsw->vlans[vid] = ETHSW_VLAN_MEMBER;
+
+   return 0;
+}
+
+static int ethsw_port_add_vlan(struct ethsw_port_priv *port_priv,
+  u16 vid, u16 flags)
+{
+   struct ethsw_core *ethsw = port_priv->ethsw_data;
+   struct net_device *netdev = port_priv->netdev;
+   struct dpsw_vlan_if_cfg vcfg;
+   bool is_oper;
+   int err, ret;
+
+   if (port_priv->vlans[vid]) {
+   netdev_warn(netdev, "VLAN %d already configured\n", vid);
+   return -EEXIST;
+   }
+
+   vcfg.num_ifs = 1;
+   vcfg.if_id[0] 

[PATCH v2 5/6] staging: fsl-dpaa2/ethsw: Add README

2017-10-02 Thread Razvan Stefanescu
Add a README file describing the driver architecture, components and
interfaces.

Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
Changelog:
 v2:
- no changes

 drivers/staging/fsl-dpaa2/ethsw/README | 106 +
 1 file changed, 106 insertions(+)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/README

diff --git a/drivers/staging/fsl-dpaa2/ethsw/README 
b/drivers/staging/fsl-dpaa2/ethsw/README
new file mode 100644
index 000..f6fc07f
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/README
@@ -0,0 +1,106 @@
+DPAA2 Ethernet Switch driver
+
+
+This file provides documentation for the DPAA2 Ethernet Switch driver
+
+
+Contents
+
+   Supported Platforms
+   Architecture Overview
+   Creating an Ethernet Switch
+   Features
+
+
+   Supported Platforms
+===
+This driver provides networking support for Freescale LS2085A, LS2088A
+DPAA2 SoCs.
+
+
+Architecture Overview
+=
+The Ethernet Switch in the DPAA2 architecture consists of several hardware
+resources that provide the functionality. These are allocated and
+configured via the Management Complex (MC) portals. MC abstracts most of
+these resources as DPAA2 objects and exposes ABIs through which they can
+be configured and controlled.
+
+For a more detailed description of the DPAA2 architecture and its object
+abstractions see:
+   drivers/staging/fsl-mc/README.txt
+
+The Ethernet Switch is built on top of a Datapath Switch (DPSW) object.
+
+Configuration interface:
+
+  -
+ | DPAA2 Switch driver |
+  -
+   .
+   .
+  --
+ | DPSW API |
+  --
+   .   software
+ = . ==
+   .   hardware
+  -
+ | MC hardware portals |
+  -
+   .
+   .
+ --
+| DPSW |
+ --
+
+Driver uses the switch device driver model and exposes each switch port as
+a network interface, which can be included in a bridge. Traffic switched
+between ports is offloaded into the hardware. Exposed network interfaces
+are not used for I/O, they are used just for configuration. This
+limitation is going to be addressed in the future.
+
+The DPSW can have ports connected to DPNIs or to PHYs via DPMACs.
+
+
+ [ethA] [ethB] [ethC] [ethD] [ethE] [ethF]
+:  :  :  :  :  :
+:  :  :  :  :  :
+[eth drv]  [eth drv]  [ethsw drv  ]
+:  :  :  :  :  :kernel
+
+:  :  :  :  :  :hardware
+ [DPNI]  [DPNI] [= DPSW =]
+|  |  |  |  |  |
+|   --   |   [DPMAC][DPMAC]
+ ---|  |
+|  |
+  [PHY]  [PHY]
+
+For a more detailed description of the Ethernet switch device driver model
+see:
+   Documentation/networking/switchdev.txt
+
+Creating an Ethernet Switch
+===
+A device is created for the switch objects probed on the MC bus. Each DPSW
+has a number of properties which determine the configuration options and
+associated hardware resources.
+
+A DPSW object (and the other DPAA2 objects needed for a DPAA2 switch) can
+be added to a container on the MC bus in one of two ways: statically,
+through a Datapath Layout Binary file (DPL) that is parsed by MC at boot
+time; or created dynamically at runtime, via the DPAA2 objects APIs.
+
+Features
+
+Driver configures DPSW to perform hardware switching offload of
+unicast/multicast/broadcast (VLAN tagged or untagged) traffic between its
+ports.
+
+It allows configuration of hardware learning, flooding, multicast groups,
+port VLAN configuration and STP state.
+
+Static entries can be added/removed from the FDB.
+
+Hardware statistics for each port are provided through ethtool -S option.
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 4/6] staging: fsl-dpaa2/ethsw: Add maintainer for Ethernet Switch driver

2017-10-02 Thread Razvan Stefanescu
Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
Changelog:
 v2:
- no changes

 MAINTAINERS | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 2281af4..cfd4f74 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4297,6 +4297,12 @@ L:   linux-ker...@vger.kernel.org
 S: Maintained
 F: drivers/staging/fsl-dpaa2/ethernet
 
+DPAA2 ETHERNET SWITCH DRIVER
+M: Razvan Stefanescu <razvan.stefane...@nxp.com>
+L: linux-ker...@vger.kernel.org
+S: Maintained
+F: drivers/staging/fsl-dpaa2/ethsw
+
 DPT_I2O SCSI RAID DRIVER
 M: Adaptec OEM Raid Solutions <aacr...@adaptec.com>
 L: linux-s...@vger.kernel.org
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 6/6] staging: fsl-dpaa2/ethsw: Add TODO

2017-10-02 Thread Razvan Stefanescu
Add a TODO file describing what needs to be added/changed before the driver
can be moved out of staging.

Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
Changelog:
 v2:
- no changes

 drivers/staging/fsl-dpaa2/ethsw/TODO | 14 ++
 1 file changed, 14 insertions(+)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/TODO

diff --git a/drivers/staging/fsl-dpaa2/ethsw/TODO 
b/drivers/staging/fsl-dpaa2/ethsw/TODO
new file mode 100644
index 000..d3f12c3
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/TODO
@@ -0,0 +1,14 @@
+* Add I/O capabilities on switch port netdevices. This will allow control
+traffic to reach the CPU.
+* Add ACL to redirect control traffic to CPU.
+* Add support for displaying learned FDB entries
+* MC firmware uprev; the DPAA2 objects used by the Ethernet Switch driver
+need to   be kept in sync with binary interface changes in MC
+* refine README file
+* cleanup
+
+NOTE: At least first three of the above are required before getting the
+DPAA2 Ethernet Switch driver out of staging. Another requirement is that
+the fsl-mc bus driver is moved to drivers/bus and dpio driver is moved to
+drivers/soc (this is required for I/O).
+
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 1/6] staging: fsl-dpaa2/ethsw: Add APIs for DPSW object

2017-10-02 Thread Razvan Stefanescu
Add the command build/parse APIs for operating on DPSW objects through
the DPAA2 Management Complex.

Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
Changelog:
 v2:
- use u8 for en parameter of dpsw_if_set_flooding/broadcast()

 drivers/staging/fsl-dpaa2/Kconfig  |8 +
 drivers/staging/fsl-dpaa2/Makefile |1 +
 drivers/staging/fsl-dpaa2/ethsw/Makefile   |7 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h |  358 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw.c | 1115 
 drivers/staging/fsl-dpaa2/ethsw/dpsw.h |  579 +++
 6 files changed, 2068 insertions(+)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/Makefile
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.h

diff --git a/drivers/staging/fsl-dpaa2/Kconfig 
b/drivers/staging/fsl-dpaa2/Kconfig
index dfff675..8a508ef 100644
--- a/drivers/staging/fsl-dpaa2/Kconfig
+++ b/drivers/staging/fsl-dpaa2/Kconfig
@@ -16,3 +16,11 @@ config FSL_DPAA2_ETH
---help---
  Ethernet driver for Freescale DPAA2 SoCs, using the
  Freescale MC bus driver
+
+config FSL_DPAA2_ETHSW
+   tristate "Freescale DPAA2 Ethernet Switch"
+   depends on FSL_DPAA2
+   depends on NET_SWITCHDEV
+   ---help---
+   Driver for Freescale DPAA2 Ethernet Switch. Select
+   BRIDGE to have support for bridge tools.
diff --git a/drivers/staging/fsl-dpaa2/Makefile 
b/drivers/staging/fsl-dpaa2/Makefile
index 0836ba8..6cfd76b 100644
--- a/drivers/staging/fsl-dpaa2/Makefile
+++ b/drivers/staging/fsl-dpaa2/Makefile
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_FSL_DPAA2_ETH)+= ethernet/
+obj-$(CONFIG_FSL_DPAA2_ETHSW)  += ethsw/
diff --git a/drivers/staging/fsl-dpaa2/ethsw/Makefile 
b/drivers/staging/fsl-dpaa2/ethsw/Makefile
new file mode 100644
index 000..db137f7
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/Makefile
@@ -0,0 +1,7 @@
+#
+# Makefile for the Freescale DPAA2 Ethernet Switch
+#
+
+obj-$(CONFIG_FSL_DPAA2_ETHSW) += dpaa2-ethsw.o
+
+dpaa2-ethsw-objs := dpsw.o
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
new file mode 100644
index 000..ddfd820
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
@@ -0,0 +1,358 @@
+/* Copyright 2013-2016 Freescale Semiconductor Inc.
+ * Copyright 2017 NXP
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of the above-listed copyright holders nor the
+ *  names of any contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef __FSL_DPSW_CMD_H
+#define __FSL_DPSW_CMD_H
+
+/* DPSW Version */
+#define DPSW_VER_MAJOR 8
+#define DPSW_VER_MINOR 0
+
+#define DPSW_CMD_BASE_VERSION  1
+#define DPSW_CMD_ID_OFFSET 4
+
+#define DPSW_CMD_ID(id)(((id) << DPSW_CMD_ID_OFFSET) | 
DPSW_CMD_BASE_VERSION)
+
+/* Command IDs */
+#define DPSW_CMDID_CLOSEDPSW_CMD_ID(0x800)
+#define DPSW_CMDID_OPEN DPSW_CMD_ID(0x802)
+
+#define DPSW_CMDID_GET_API_VERSION  DPSW_CMD_ID(0xa02)
+
+#define DPSW_CMDID_ENABLE   DPSW_CMD_ID(0x002)
+#define DPSW_CMDID_DISABLE  DPSW_

[PATCH v2 3/6] staging: fsl-dpaa2/ethsw: Add ethtool support

2017-10-02 Thread Razvan Stefanescu
Add driver information, link details and hardware statistics to be
reported via ethtool -S.

Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
Changelog:
 v2:
- no changes

 drivers/staging/fsl-dpaa2/ethsw/Makefile|   2 +-
 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h  |  13 ++
 drivers/staging/fsl-dpaa2/ethsw/dpsw.c  |  32 
 drivers/staging/fsl-dpaa2/ethsw/dpsw.h  |  32 
 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c | 207 
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c |   3 +
 drivers/staging/fsl-dpaa2/ethsw/ethsw.h |   3 +
 7 files changed, 291 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c

diff --git a/drivers/staging/fsl-dpaa2/ethsw/Makefile 
b/drivers/staging/fsl-dpaa2/ethsw/Makefile
index a6d72d1..de92cd9 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/Makefile
+++ b/drivers/staging/fsl-dpaa2/ethsw/Makefile
@@ -4,4 +4,4 @@
 
 obj-$(CONFIG_FSL_DPAA2_ETHSW) += dpaa2-ethsw.o
 
-dpaa2-ethsw-objs := ethsw.o dpsw.o
+dpaa2-ethsw-objs := ethsw.o ethsw-ethtool.o dpsw.o
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
index ddfd820..06b71122 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
@@ -74,6 +74,8 @@
 #define DPSW_CMDID_IF_SET_FLOODING  DPSW_CMD_ID(0x047)
 #define DPSW_CMDID_IF_SET_BROADCAST DPSW_CMD_ID(0x048)
 
+#define DPSW_CMDID_IF_SET_LINK_CFG  DPSW_CMD_ID(0x04C)
+
 #define DPSW_CMDID_VLAN_ADD DPSW_CMD_ID(0x060)
 #define DPSW_CMDID_VLAN_ADD_IF  DPSW_CMD_ID(0x061)
 #define DPSW_CMDID_VLAN_ADD_IF_UNTAGGED DPSW_CMD_ID(0x062)
@@ -262,6 +264,17 @@ struct dpsw_cmd_if_set_max_frame_length {
__le16 frame_length;
 };
 
+struct dpsw_cmd_if_set_link_cfg {
+   /* cmd word 0 */
+   __le16 if_id;
+   u8 pad[6];
+   /* cmd word 1 */
+   __le32 rate;
+   __le32 pad1;
+   /* cmd word 2 */
+   __le64 options;
+};
+
 struct dpsw_cmd_if_get_link_state {
__le16 if_id;
 };
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
index e65b6f5..f1a1fac 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
@@ -383,6 +383,38 @@ int dpsw_get_attributes(struct fsl_mc_io *mc_io,
 }
 
 /**
+ * dpsw_if_set_link_cfg() - Set the link configuration.
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPSW object
+ * @if_id: Interface id
+ * @cfg:   Link configuration
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dpsw_if_set_link_cfg(struct fsl_mc_io *mc_io,
+u32 cmd_flags,
+u16 token,
+u16 if_id,
+struct dpsw_link_cfg *cfg)
+{
+   struct mc_command cmd = { 0 };
+   struct dpsw_cmd_if_set_link_cfg *cmd_params;
+
+   /* prepare command */
+   cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_LINK_CFG,
+ cmd_flags,
+ token);
+   cmd_params = (struct dpsw_cmd_if_set_link_cfg *)cmd.params;
+   cmd_params->if_id = cpu_to_le16(if_id);
+   cmd_params->rate = cpu_to_le32(cfg->rate);
+   cmd_params->options = cpu_to_le64(cfg->options);
+
+   /* send command to mc*/
+   return mc_send_command(mc_io, );
+}
+
+/**
  * dpsw_if_get_link_state - Return the link state
  * @mc_io: Pointer to MC portal's I/O object
  * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw.h 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
index 7fa8a61..87369a5 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
@@ -245,6 +245,38 @@ enum dpsw_action {
 };
 
 /**
+ * Enable auto-negotiation
+ */
+#define DPSW_LINK_OPT_AUTONEG  0x0001ULL
+/**
+ * Enable half-duplex mode
+ */
+#define DPSW_LINK_OPT_HALF_DUPLEX  0x0002ULL
+/**
+ * Enable pause frames
+ */
+#define DPSW_LINK_OPT_PAUSE0x0004ULL
+/**
+ * Enable a-symmetric pause frames
+ */
+#define DPSW_LINK_OPT_ASYM_PAUSE   0x0008ULL
+
+/**
+ * struct dpsw_link_cfg - Structure representing DPSW link configuration
+ * @rate: Rate
+ * @options: Mask of available options; use 'DPSW_LINK_OPT_' values
+ */
+struct dpsw_link_cfg {
+   u32 rate;
+   u64 options;
+};
+
+int dpsw_if_set_link_cfg(struct fsl_mc_io *mc_io,
+u32 cmd_flags,
+u16 token,
+u16 if_id,
+struct dpsw_link_cfg *cfg);
+/**
  * struct dpsw_link_state - Structure representing DPSW link state
  * @rate: Rate
  * @optio

[PATCH v2 0/6] staging: Introduce DPAA2 Ethernet Switch driver

2017-10-02 Thread Razvan Stefanescu
This patchset introduces the Ethernet Switch Driver for Freescale/NXP SoCs
with DPAA2 (DataPath Acceleration Architecture v2). The driver manages
switch objects discovered on the fsl-mc bus. A description of the driver
can be found in the associated README file.

The patchset consists of:
* A set of libraries containing APIs for configuring and controlling
  Management Complex (MC) switch objects
* The DPAA2 Ethernet Switch driver
* Patch adding ethtool support

Limitations:
* no support for control traffic to/from CPU
* only DPSW ports can be added to a bridge

Changelog:
 v2: addressed comments from Bogdan P.

Razvan Stefanescu (6):
  staging: fsl-dpaa2/ethsw: Add APIs for DPSW object
  staging: fsl-dpaa2/ethsw: Add Freescale DPAA2 Ethernet Switch driver
  staging: fsl-dpaa2/ethsw: Add ethtool support
  staging: fsl-dpaa2/ethsw: Add maintainer for Ethernet Switch driver
  staging: fsl-dpaa2/ethsw: Add README
  staging: fsl-dpaa2/ethsw: Add TODO

 MAINTAINERS |6 +
 drivers/staging/fsl-dpaa2/Kconfig   |8 +
 drivers/staging/fsl-dpaa2/Makefile  |1 +
 drivers/staging/fsl-dpaa2/ethsw/Makefile|7 +
 drivers/staging/fsl-dpaa2/ethsw/README  |  106 ++
 drivers/staging/fsl-dpaa2/ethsw/TODO|   14 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h  |  371 ++
 drivers/staging/fsl-dpaa2/ethsw/dpsw.c  | 1147 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw.h  |  611 +
 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c |  207 +++
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 1534 +++
 drivers/staging/fsl-dpaa2/ethsw/ethsw.h |   91 ++
 12 files changed, 4103 insertions(+)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/Makefile
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/README
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/TODO
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.h
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.h

-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [RESEND PATCH 2/6] staging: fsl-dpaa2/ethsw: Add Freescale DPAA2 Ethernet Switch driver

2017-10-02 Thread Razvan Stefanescu
> -Original Message-
> From: Florian Fainelli [mailto:f.faine...@gmail.com]
> Sent: Friday, September 29, 2017 19:11
> To: Razvan Stefanescu <razvan.stefane...@nxp.com>; Bogdan Purcareata
> <bogdan.purcare...@nxp.com>; gre...@linuxfoundation.org
> Cc: de...@driverdev.osuosl.org; linux-ker...@vger.kernel.org;
> net...@vger.kernel.org; ag...@suse.de; a...@arndb.de; Alexandru Marginean
> <alexandru.margin...@nxp.com>; Ruxandra Ioana Radulescu
> <ruxandra.radule...@nxp.com>; Laurentiu Tudor <laurentiu.tu...@nxp.com>;
> stuyo...@gmail.com
> Subject: RE: [RESEND PATCH 2/6] staging: fsl-dpaa2/ethsw: Add Freescale DPAA2
> Ethernet Switch driver
> 
> On September 29, 2017 6:59:18 AM PDT, Razvan Stefanescu
> <razvan.stefane...@nxp.com> wrote:
> >
> >
> >> -Original Message-----
> >> From: Bogdan Purcareata
> >> Sent: Friday, September 29, 2017 16:36
> >> To: Razvan Stefanescu <razvan.stefane...@nxp.com>;
> >> gre...@linuxfoundation.org
> >> Cc: de...@driverdev.osuosl.org; linux-ker...@vger.kernel.org;
> >> net...@vger.kernel.org; ag...@suse.de; a...@arndb.de; Alexandru
> >Marginean
> >> <alexandru.margin...@nxp.com>; Ruxandra Ioana Radulescu
> >> <ruxandra.radule...@nxp.com>; Laurentiu Tudor
> ><laurentiu.tu...@nxp.com>;
> >> stuyo...@gmail.com
> >> Subject: RE: [RESEND PATCH 2/6] staging: fsl-dpaa2/ethsw: Add
> >Freescale DPAA2
> >> Ethernet Switch driver
> >>
> >> > Introduce the DPAA2 Ethernet Switch driver, which manages Datapath
> >Switch
> >> > (DPSW) objects discovered on the MC bus.
> >> >
> >> > Suggested-by: Alexandru Marginean <alexandru.margin...@nxp.com>
> >> > Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
> 
> This looks pretty good for a new switchdev driver, is there a reason you can't
> target drivers/net/ethernet instead of staging? Is it because the MC bus code 
> is
> still in staging (AFAICT)?
> 
Yes, driver depends on MC bus, which is still in staging.  Also, control traffic
code will require access to DPIO functions, that are also in staging.

Best regards,
Razvan S.
> --
> Florian
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [RESEND PATCH 2/6] staging: fsl-dpaa2/ethsw: Add Freescale DPAA2 Ethernet Switch driver

2017-09-29 Thread Razvan Stefanescu


> -Original Message-
> From: Bogdan Purcareata
> Sent: Friday, September 29, 2017 16:36
> To: Razvan Stefanescu <razvan.stefane...@nxp.com>;
> gre...@linuxfoundation.org
> Cc: de...@driverdev.osuosl.org; linux-ker...@vger.kernel.org;
> net...@vger.kernel.org; ag...@suse.de; a...@arndb.de; Alexandru Marginean
> <alexandru.margin...@nxp.com>; Ruxandra Ioana Radulescu
> <ruxandra.radule...@nxp.com>; Laurentiu Tudor <laurentiu.tu...@nxp.com>;
> stuyo...@gmail.com
> Subject: RE: [RESEND PATCH 2/6] staging: fsl-dpaa2/ethsw: Add Freescale DPAA2
> Ethernet Switch driver
> 
> > Introduce the DPAA2 Ethernet Switch driver, which manages Datapath Switch
> > (DPSW) objects discovered on the MC bus.
> >
> > Suggested-by: Alexandru Marginean <alexandru.margin...@nxp.com>
> > Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
> > ---
> >  drivers/staging/fsl-dpaa2/ethsw/Makefile |2 +-
> >  drivers/staging/fsl-dpaa2/ethsw/ethsw.c  | 1523
> ++
> >  drivers/staging/fsl-dpaa2/ethsw/ethsw.h  |   88 ++
> >  3 files changed, 1612 insertions(+), 1 deletion(-)
> >  create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.c
> >  create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.h
> >
> > diff --git a/drivers/staging/fsl-dpaa2/ethsw/Makefile b/drivers/staging/fsl-
> > dpaa2/ethsw/Makefile
> > index db137f7..a6d72d1 100644
> > --- a/drivers/staging/fsl-dpaa2/ethsw/Makefile
> > +++ b/drivers/staging/fsl-dpaa2/ethsw/Makefile
> > @@ -4,4 +4,4 @@
> >
> >  obj-$(CONFIG_FSL_DPAA2_ETHSW) += dpaa2-ethsw.o
> >
> > -dpaa2-ethsw-objs := dpsw.o
> > +dpaa2-ethsw-objs := ethsw.o dpsw.o
> > diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-
> > dpaa2/ethsw/ethsw.c
> > new file mode 100644
> > index 000..ae86078
> > --- /dev/null
> > +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
> > @@ -0,0 +1,1523 @@
> > +/* Copyright 2014-2016 Freescale Semiconductor Inc.
> > + * Copyright 2017 NXP
> > + *
> > + * Redistribution and use in source and binary forms, with or without
> > + * modification, are permitted provided that the following conditions are 
> > met:
> > + * * Redistributions of source code must retain the above copyright
> > + *  notice, this list of conditions and the following disclaimer.
> > + * * Redistributions in binary form must reproduce the above copyright
> > + *  notice, this list of conditions and the following disclaimer in the
> > + *  documentation and/or other materials provided with the distribution.
> > + * * Neither the name of the above-listed copyright holders nor the
> > + *  names of any contributors may be used to endorse or promote products
> > + *  derived from this software without specific prior written permission.
> > + *
> > + *
> > + * ALTERNATIVELY, this software may be distributed under the terms of the
> > + * GNU General Public License ("GPL") as published by the Free Software
> > + * Foundation, either version 2 of that License or (at your option) any
> > + * later version.
> > + *
> > + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
> CONTRIBUTORS "AS IS"
> > + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> LIMITED TO, THE
> > + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
> PARTICULAR PURPOSE
> > + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
> CONTRIBUTORS BE
> > + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> > + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
> PROCUREMENT OF
> > + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
> BUSINESS
> > + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
> WHETHER IN
> > + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
> OTHERWISE)
> > + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
> ADVISED OF THE
> > + * POSSIBILITY OF SUCH DAMAGE.
> > + */
> > +
> > +#include 
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include "../../fsl-mc/include/mc.h"
> > +
> > +#include "ethsw.h"
> > +
> > +static struct workqueue_struct *ethsw_owq;
> > +
> > +/* Minimal supported DPSW version */
> > +#define DPSW_MIN_VER_MAJOR 8
> > +#define DPSW_MIN_VER_MINOR 0
> > +
> > +#define DEFAULT_VLAN_ID1
> > +
> > +static int ethsw_add_vl

[RESEND PATCH 4/6] staging: fsl-dpaa2/ethsw: Add maintainer for Ethernet Switch driver

2017-09-19 Thread Razvan Stefanescu
Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
 MAINTAINERS | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 2281af4..cfd4f74 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4297,6 +4297,12 @@ L:   linux-ker...@vger.kernel.org
 S: Maintained
 F: drivers/staging/fsl-dpaa2/ethernet
 
+DPAA2 ETHERNET SWITCH DRIVER
+M: Razvan Stefanescu <razvan.stefane...@nxp.com>
+L: linux-ker...@vger.kernel.org
+S: Maintained
+F: drivers/staging/fsl-dpaa2/ethsw
+
 DPT_I2O SCSI RAID DRIVER
 M: Adaptec OEM Raid Solutions <aacr...@adaptec.com>
 L: linux-s...@vger.kernel.org
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[RESEND PATCH 5/6] staging: fsl-dpaa2/ethsw: Add README

2017-09-19 Thread Razvan Stefanescu
Add a README file describing the driver architecture, components and
interfaces.

Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethsw/README | 106 +
 1 file changed, 106 insertions(+)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/README

diff --git a/drivers/staging/fsl-dpaa2/ethsw/README 
b/drivers/staging/fsl-dpaa2/ethsw/README
new file mode 100644
index 000..f6fc07f
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/README
@@ -0,0 +1,106 @@
+DPAA2 Ethernet Switch driver
+
+
+This file provides documentation for the DPAA2 Ethernet Switch driver
+
+
+Contents
+
+   Supported Platforms
+   Architecture Overview
+   Creating an Ethernet Switch
+   Features
+
+
+   Supported Platforms
+===
+This driver provides networking support for Freescale LS2085A, LS2088A
+DPAA2 SoCs.
+
+
+Architecture Overview
+=
+The Ethernet Switch in the DPAA2 architecture consists of several hardware
+resources that provide the functionality. These are allocated and
+configured via the Management Complex (MC) portals. MC abstracts most of
+these resources as DPAA2 objects and exposes ABIs through which they can
+be configured and controlled.
+
+For a more detailed description of the DPAA2 architecture and its object
+abstractions see:
+   drivers/staging/fsl-mc/README.txt
+
+The Ethernet Switch is built on top of a Datapath Switch (DPSW) object.
+
+Configuration interface:
+
+  -
+ | DPAA2 Switch driver |
+  -
+   .
+   .
+  --
+ | DPSW API |
+  --
+   .   software
+ = . ==
+   .   hardware
+  -
+ | MC hardware portals |
+  -
+   .
+   .
+ --
+| DPSW |
+ --
+
+Driver uses the switch device driver model and exposes each switch port as
+a network interface, which can be included in a bridge. Traffic switched
+between ports is offloaded into the hardware. Exposed network interfaces
+are not used for I/O, they are used just for configuration. This
+limitation is going to be addressed in the future.
+
+The DPSW can have ports connected to DPNIs or to PHYs via DPMACs.
+
+
+ [ethA] [ethB] [ethC] [ethD] [ethE] [ethF]
+:  :  :  :  :  :
+:  :  :  :  :  :
+[eth drv]  [eth drv]  [ethsw drv  ]
+:  :  :  :  :  :kernel
+
+:  :  :  :  :  :hardware
+ [DPNI]  [DPNI] [= DPSW =]
+|  |  |  |  |  |
+|   --   |   [DPMAC][DPMAC]
+ ---|  |
+|  |
+  [PHY]  [PHY]
+
+For a more detailed description of the Ethernet switch device driver model
+see:
+   Documentation/networking/switchdev.txt
+
+Creating an Ethernet Switch
+===
+A device is created for the switch objects probed on the MC bus. Each DPSW
+has a number of properties which determine the configuration options and
+associated hardware resources.
+
+A DPSW object (and the other DPAA2 objects needed for a DPAA2 switch) can
+be added to a container on the MC bus in one of two ways: statically,
+through a Datapath Layout Binary file (DPL) that is parsed by MC at boot
+time; or created dynamically at runtime, via the DPAA2 objects APIs.
+
+Features
+
+Driver configures DPSW to perform hardware switching offload of
+unicast/multicast/broadcast (VLAN tagged or untagged) traffic between its
+ports.
+
+It allows configuration of hardware learning, flooding, multicast groups,
+port VLAN configuration and STP state.
+
+Static entries can be added/removed from the FDB.
+
+Hardware statistics for each port are provided through ethtool -S option.
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[RESEND PATCH 2/6] staging: fsl-dpaa2/ethsw: Add Freescale DPAA2 Ethernet Switch driver

2017-09-19 Thread Razvan Stefanescu
Introduce the DPAA2 Ethernet Switch driver, which manages Datapath Switch
(DPSW) objects discovered on the MC bus.

Suggested-by: Alexandru Marginean <alexandru.margin...@nxp.com>
Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethsw/Makefile |2 +-
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c  | 1523 ++
 drivers/staging/fsl-dpaa2/ethsw/ethsw.h  |   88 ++
 3 files changed, 1612 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.h

diff --git a/drivers/staging/fsl-dpaa2/ethsw/Makefile 
b/drivers/staging/fsl-dpaa2/ethsw/Makefile
index db137f7..a6d72d1 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/Makefile
+++ b/drivers/staging/fsl-dpaa2/ethsw/Makefile
@@ -4,4 +4,4 @@
 
 obj-$(CONFIG_FSL_DPAA2_ETHSW) += dpaa2-ethsw.o
 
-dpaa2-ethsw-objs := dpsw.o
+dpaa2-ethsw-objs := ethsw.o dpsw.o
diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
new file mode 100644
index 000..ae86078
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
@@ -0,0 +1,1523 @@
+/* Copyright 2014-2016 Freescale Semiconductor Inc.
+ * Copyright 2017 NXP
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of the above-listed copyright holders nor the
+ *  names of any contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include "../../fsl-mc/include/mc.h"
+
+#include "ethsw.h"
+
+static struct workqueue_struct *ethsw_owq;
+
+/* Minimal supported DPSW version */
+#define DPSW_MIN_VER_MAJOR 8
+#define DPSW_MIN_VER_MINOR 0
+
+#define DEFAULT_VLAN_ID1
+
+static int ethsw_add_vlan(struct ethsw_core *ethsw, u16 vid)
+{
+   int err;
+
+   struct dpsw_vlan_cfgvcfg = {
+   .fdb_id = 0,
+   };
+
+   if (ethsw->vlans[vid]) {
+   dev_err(ethsw->dev, "VLAN already configured\n");
+   return -EEXIST;
+   }
+
+   err = dpsw_vlan_add(ethsw->mc_io, 0,
+   ethsw->dpsw_handle, vid, );
+   if (err) {
+   dev_err(ethsw->dev, "dpsw_vlan_add err %d\n", err);
+   return err;
+   }
+   ethsw->vlans[vid] = ETHSW_VLAN_MEMBER;
+
+   return 0;
+}
+
+static int ethsw_port_add_vlan(struct ethsw_port_priv *port_priv,
+  u16 vid, u16 flags)
+{
+   struct ethsw_core *ethsw = port_priv->ethsw_data;
+   struct net_device *netdev = port_priv->netdev;
+   struct dpsw_vlan_if_cfg vcfg;
+   bool is_oper;
+   int err, err2;
+
+   if (port_priv->vlans[vid]) {
+   netdev_warn(netdev, "VLAN %d already configured\n", vid);
+   return -EEXIST;
+   }
+
+   vcfg.num_ifs = 1;
+   vcfg.if_id[0] = port_priv->idx;
+   err = dpsw_vlan_add_if(ethsw->mc_io, 0, ethsw->dpsw_handle, vid, );
+   if (err) {
+   netdev_err(netdev, "dpsw_vlan_add_if err %d\n", err);
+   return err;
+   }
+
+   port_priv->vlans[vid] = ETHSW_VLAN_MEMBER;
+
+   if (flags & BRIDGE_VLAN_

[RESEND PATCH 1/6] staging: fsl-dpaa2/ethsw: Add APIs for DPSW object

2017-09-19 Thread Razvan Stefanescu
Add the command build/parse APIs for operating on DPSW objects through
the DPAA2 Management Complex.

Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
 drivers/staging/fsl-dpaa2/Kconfig  |8 +
 drivers/staging/fsl-dpaa2/Makefile |1 +
 drivers/staging/fsl-dpaa2/ethsw/Makefile   |7 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h |  358 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw.c | 1115 
 drivers/staging/fsl-dpaa2/ethsw/dpsw.h |  579 +++
 6 files changed, 2068 insertions(+)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/Makefile
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.h

diff --git a/drivers/staging/fsl-dpaa2/Kconfig 
b/drivers/staging/fsl-dpaa2/Kconfig
index dfff675..8a508ef 100644
--- a/drivers/staging/fsl-dpaa2/Kconfig
+++ b/drivers/staging/fsl-dpaa2/Kconfig
@@ -16,3 +16,11 @@ config FSL_DPAA2_ETH
---help---
  Ethernet driver for Freescale DPAA2 SoCs, using the
  Freescale MC bus driver
+
+config FSL_DPAA2_ETHSW
+   tristate "Freescale DPAA2 Ethernet Switch"
+   depends on FSL_DPAA2
+   depends on NET_SWITCHDEV
+   ---help---
+   Driver for Freescale DPAA2 Ethernet Switch. Select
+   BRIDGE to have support for bridge tools.
diff --git a/drivers/staging/fsl-dpaa2/Makefile 
b/drivers/staging/fsl-dpaa2/Makefile
index 0836ba8..6cfd76b 100644
--- a/drivers/staging/fsl-dpaa2/Makefile
+++ b/drivers/staging/fsl-dpaa2/Makefile
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_FSL_DPAA2_ETH)+= ethernet/
+obj-$(CONFIG_FSL_DPAA2_ETHSW)  += ethsw/
diff --git a/drivers/staging/fsl-dpaa2/ethsw/Makefile 
b/drivers/staging/fsl-dpaa2/ethsw/Makefile
new file mode 100644
index 000..db137f7
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/Makefile
@@ -0,0 +1,7 @@
+#
+# Makefile for the Freescale DPAA2 Ethernet Switch
+#
+
+obj-$(CONFIG_FSL_DPAA2_ETHSW) += dpaa2-ethsw.o
+
+dpaa2-ethsw-objs := dpsw.o
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
new file mode 100644
index 000..ddfd820
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
@@ -0,0 +1,358 @@
+/* Copyright 2013-2016 Freescale Semiconductor Inc.
+ * Copyright 2017 NXP
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of the above-listed copyright holders nor the
+ *  names of any contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef __FSL_DPSW_CMD_H
+#define __FSL_DPSW_CMD_H
+
+/* DPSW Version */
+#define DPSW_VER_MAJOR 8
+#define DPSW_VER_MINOR 0
+
+#define DPSW_CMD_BASE_VERSION  1
+#define DPSW_CMD_ID_OFFSET 4
+
+#define DPSW_CMD_ID(id)(((id) << DPSW_CMD_ID_OFFSET) | 
DPSW_CMD_BASE_VERSION)
+
+/* Command IDs */
+#define DPSW_CMDID_CLOSEDPSW_CMD_ID(0x800)
+#define DPSW_CMDID_OPEN DPSW_CMD_ID(0x802)
+
+#define DPSW_CMDID_GET_API_VERSION  DPSW_CMD_ID(0xa02)
+
+#define DPSW_CMDID_ENABLE   DPSW_CMD_ID(0x002)
+#define DPSW_CMDID_DISABLE  DPSW_CMD_ID(0x003)
+#define DPSW_CMDID_GET_ATTR DPSW_CMD_ID(0x004)
+#define DPSW_CMDID_RESET   

[RESEND PATCH 6/6] staging: fsl-dpaa2/ethsw: Add TODO

2017-09-19 Thread Razvan Stefanescu
Add a TODO file describing what needs to be added/changed before the driver
can be moved out of staging.

Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethsw/TODO | 14 ++
 1 file changed, 14 insertions(+)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/TODO

diff --git a/drivers/staging/fsl-dpaa2/ethsw/TODO 
b/drivers/staging/fsl-dpaa2/ethsw/TODO
new file mode 100644
index 000..d3f12c3
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/TODO
@@ -0,0 +1,14 @@
+* Add I/O capabilities on switch port netdevices. This will allow control
+traffic to reach the CPU.
+* Add ACL to redirect control traffic to CPU.
+* Add support for displaying learned FDB entries
+* MC firmware uprev; the DPAA2 objects used by the Ethernet Switch driver
+need to   be kept in sync with binary interface changes in MC
+* refine README file
+* cleanup
+
+NOTE: At least first three of the above are required before getting the
+DPAA2 Ethernet Switch driver out of staging. Another requirement is that
+the fsl-mc bus driver is moved to drivers/bus and dpio driver is moved to
+drivers/soc (this is required for I/O).
+
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[RESEND PATCH 3/6] staging: fsl-dpaa2/ethsw: Add ethtool support

2017-09-19 Thread Razvan Stefanescu
Add driver information, link details and hardware statistics to be
reported via ethtool -S.

Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethsw/Makefile|   2 +-
 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h  |  13 ++
 drivers/staging/fsl-dpaa2/ethsw/dpsw.c  |  32 
 drivers/staging/fsl-dpaa2/ethsw/dpsw.h  |  32 
 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c | 207 
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c |   3 +
 drivers/staging/fsl-dpaa2/ethsw/ethsw.h |   3 +
 7 files changed, 291 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c

diff --git a/drivers/staging/fsl-dpaa2/ethsw/Makefile 
b/drivers/staging/fsl-dpaa2/ethsw/Makefile
index a6d72d1..de92cd9 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/Makefile
+++ b/drivers/staging/fsl-dpaa2/ethsw/Makefile
@@ -4,4 +4,4 @@
 
 obj-$(CONFIG_FSL_DPAA2_ETHSW) += dpaa2-ethsw.o
 
-dpaa2-ethsw-objs := ethsw.o dpsw.o
+dpaa2-ethsw-objs := ethsw.o ethsw-ethtool.o dpsw.o
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
index ddfd820..06b71122 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
@@ -74,6 +74,8 @@
 #define DPSW_CMDID_IF_SET_FLOODING  DPSW_CMD_ID(0x047)
 #define DPSW_CMDID_IF_SET_BROADCAST DPSW_CMD_ID(0x048)
 
+#define DPSW_CMDID_IF_SET_LINK_CFG  DPSW_CMD_ID(0x04C)
+
 #define DPSW_CMDID_VLAN_ADD DPSW_CMD_ID(0x060)
 #define DPSW_CMDID_VLAN_ADD_IF  DPSW_CMD_ID(0x061)
 #define DPSW_CMDID_VLAN_ADD_IF_UNTAGGED DPSW_CMD_ID(0x062)
@@ -262,6 +264,17 @@ struct dpsw_cmd_if_set_max_frame_length {
__le16 frame_length;
 };
 
+struct dpsw_cmd_if_set_link_cfg {
+   /* cmd word 0 */
+   __le16 if_id;
+   u8 pad[6];
+   /* cmd word 1 */
+   __le32 rate;
+   __le32 pad1;
+   /* cmd word 2 */
+   __le64 options;
+};
+
 struct dpsw_cmd_if_get_link_state {
__le16 if_id;
 };
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
index f36b92b..601172a 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
@@ -383,6 +383,38 @@ int dpsw_get_attributes(struct fsl_mc_io *mc_io,
 }
 
 /**
+ * dpsw_if_set_link_cfg() - Set the link configuration.
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPSW object
+ * @if_id: Interface id
+ * @cfg:   Link configuration
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dpsw_if_set_link_cfg(struct fsl_mc_io *mc_io,
+u32 cmd_flags,
+u16 token,
+u16 if_id,
+struct dpsw_link_cfg *cfg)
+{
+   struct mc_command cmd = { 0 };
+   struct dpsw_cmd_if_set_link_cfg *cmd_params;
+
+   /* prepare command */
+   cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_LINK_CFG,
+ cmd_flags,
+ token);
+   cmd_params = (struct dpsw_cmd_if_set_link_cfg *)cmd.params;
+   cmd_params->if_id = cpu_to_le16(if_id);
+   cmd_params->rate = cpu_to_le32(cfg->rate);
+   cmd_params->options = cpu_to_le64(cfg->options);
+
+   /* send command to mc*/
+   return mc_send_command(mc_io, );
+}
+
+/**
  * dpsw_if_get_link_state - Return the link state
  * @mc_io: Pointer to MC portal's I/O object
  * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw.h 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
index e9c2906..5feadc2 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
@@ -245,6 +245,38 @@ enum dpsw_action {
 };
 
 /**
+ * Enable auto-negotiation
+ */
+#define DPSW_LINK_OPT_AUTONEG  0x0001ULL
+/**
+ * Enable half-duplex mode
+ */
+#define DPSW_LINK_OPT_HALF_DUPLEX  0x0002ULL
+/**
+ * Enable pause frames
+ */
+#define DPSW_LINK_OPT_PAUSE0x0004ULL
+/**
+ * Enable a-symmetric pause frames
+ */
+#define DPSW_LINK_OPT_ASYM_PAUSE   0x0008ULL
+
+/**
+ * struct dpsw_link_cfg - Structure representing DPSW link configuration
+ * @rate: Rate
+ * @options: Mask of available options; use 'DPSW_LINK_OPT_' values
+ */
+struct dpsw_link_cfg {
+   u32 rate;
+   u64 options;
+};
+
+int dpsw_if_set_link_cfg(struct fsl_mc_io *mc_io,
+u32 cmd_flags,
+u16 token,
+u16 if_id,
+struct dpsw_link_cfg *cfg);
+/**
  * struct dpsw_link_state - Structure representing DPSW link state
  * @rate: Rate
  * @options: Mask of available options; use 'D

[RESEND PATCH 0/6] staging: Introduce DPAA2 Ethernet Switch driver

2017-09-19 Thread Razvan Stefanescu
This patchset introduces the Ethernet Switch Driver for Freescale/NXP SoCs
with DPAA2 (DataPath Acceleration Architecture v2). The driver manages
switch objects discovered on the fsl-mc bus. A description of the driver
can be found in the associated README file.

The patchset consists of:
* A set of libraries containing APIs for configuring and controlling
  Management Complex (MC) switch objects
* The DPAA2 Ethernet Switch driver
* Patch adding ethtool support

Limitations:
* no support for control traffic to/from CPU
* only DPSW ports can be added to a bridge

Resending in order to add the netdev list (and remove the arm one), based
on Andrew Lunn's suggestion.

Razvan Stefanescu (6):
  staging: fsl-dpaa2/ethsw: Add APIs for DPSW object
  staging: fsl-dpaa2/ethsw: Add Freescale DPAA2 Ethernet Switch driver
  staging: fsl-dpaa2/ethsw: Add ethtool support
  staging: fsl-dpaa2/ethsw: Add maintainer for Ethernet Switch driver
  staging: fsl-dpaa2/ethsw: Add README
  staging: fsl-dpaa2/ethsw: Add TODO

 MAINTAINERS |6 +
 drivers/staging/fsl-dpaa2/Kconfig   |8 +
 drivers/staging/fsl-dpaa2/Makefile  |1 +
 drivers/staging/fsl-dpaa2/ethsw/Makefile|7 +
 drivers/staging/fsl-dpaa2/ethsw/README  |  106 ++
 drivers/staging/fsl-dpaa2/ethsw/TODO|   14 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h  |  371 ++
 drivers/staging/fsl-dpaa2/ethsw/dpsw.c  | 1147 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw.h  |  611 +
 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c |  207 +++
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 1526 +++
 drivers/staging/fsl-dpaa2/ethsw/ethsw.h |   91 ++
 12 files changed, 4095 insertions(+)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/Makefile
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/README
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/TODO
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.h
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.h

-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 6/6] staging: fsl-dpaa2/ethsw: Add TODO

2017-09-19 Thread Razvan Stefanescu
Add a TODO file describing what needs to be added/changed before the driver
can be moved out of staging.

Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethsw/TODO | 14 ++
 1 file changed, 14 insertions(+)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/TODO

diff --git a/drivers/staging/fsl-dpaa2/ethsw/TODO 
b/drivers/staging/fsl-dpaa2/ethsw/TODO
new file mode 100644
index 000..d3f12c3
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/TODO
@@ -0,0 +1,14 @@
+* Add I/O capabilities on switch port netdevices. This will allow control
+traffic to reach the CPU.
+* Add ACL to redirect control traffic to CPU.
+* Add support for displaying learned FDB entries
+* MC firmware uprev; the DPAA2 objects used by the Ethernet Switch driver
+need to   be kept in sync with binary interface changes in MC
+* refine README file
+* cleanup
+
+NOTE: At least first three of the above are required before getting the
+DPAA2 Ethernet Switch driver out of staging. Another requirement is that
+the fsl-mc bus driver is moved to drivers/bus and dpio driver is moved to
+drivers/soc (this is required for I/O).
+
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 5/6] staging: fsl-dpaa2/ethsw: Add README

2017-09-19 Thread Razvan Stefanescu
Add a README file describing the driver architecture, components and
interfaces.

Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethsw/README | 106 +
 1 file changed, 106 insertions(+)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/README

diff --git a/drivers/staging/fsl-dpaa2/ethsw/README 
b/drivers/staging/fsl-dpaa2/ethsw/README
new file mode 100644
index 000..f6fc07f
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/README
@@ -0,0 +1,106 @@
+DPAA2 Ethernet Switch driver
+
+
+This file provides documentation for the DPAA2 Ethernet Switch driver
+
+
+Contents
+
+   Supported Platforms
+   Architecture Overview
+   Creating an Ethernet Switch
+   Features
+
+
+   Supported Platforms
+===
+This driver provides networking support for Freescale LS2085A, LS2088A
+DPAA2 SoCs.
+
+
+Architecture Overview
+=
+The Ethernet Switch in the DPAA2 architecture consists of several hardware
+resources that provide the functionality. These are allocated and
+configured via the Management Complex (MC) portals. MC abstracts most of
+these resources as DPAA2 objects and exposes ABIs through which they can
+be configured and controlled.
+
+For a more detailed description of the DPAA2 architecture and its object
+abstractions see:
+   drivers/staging/fsl-mc/README.txt
+
+The Ethernet Switch is built on top of a Datapath Switch (DPSW) object.
+
+Configuration interface:
+
+  -
+ | DPAA2 Switch driver |
+  -
+   .
+   .
+  --
+ | DPSW API |
+  --
+   .   software
+ = . ==
+   .   hardware
+  -
+ | MC hardware portals |
+  -
+   .
+   .
+ --
+| DPSW |
+ --
+
+Driver uses the switch device driver model and exposes each switch port as
+a network interface, which can be included in a bridge. Traffic switched
+between ports is offloaded into the hardware. Exposed network interfaces
+are not used for I/O, they are used just for configuration. This
+limitation is going to be addressed in the future.
+
+The DPSW can have ports connected to DPNIs or to PHYs via DPMACs.
+
+
+ [ethA] [ethB] [ethC] [ethD] [ethE] [ethF]
+:  :  :  :  :  :
+:  :  :  :  :  :
+[eth drv]  [eth drv]  [ethsw drv  ]
+:  :  :  :  :  :kernel
+
+:  :  :  :  :  :hardware
+ [DPNI]  [DPNI] [= DPSW =]
+|  |  |  |  |  |
+|   --   |   [DPMAC][DPMAC]
+ ---|  |
+|  |
+  [PHY]  [PHY]
+
+For a more detailed description of the Ethernet switch device driver model
+see:
+   Documentation/networking/switchdev.txt
+
+Creating an Ethernet Switch
+===
+A device is created for the switch objects probed on the MC bus. Each DPSW
+has a number of properties which determine the configuration options and
+associated hardware resources.
+
+A DPSW object (and the other DPAA2 objects needed for a DPAA2 switch) can
+be added to a container on the MC bus in one of two ways: statically,
+through a Datapath Layout Binary file (DPL) that is parsed by MC at boot
+time; or created dynamically at runtime, via the DPAA2 objects APIs.
+
+Features
+
+Driver configures DPSW to perform hardware switching offload of
+unicast/multicast/broadcast (VLAN tagged or untagged) traffic between its
+ports.
+
+It allows configuration of hardware learning, flooding, multicast groups,
+port VLAN configuration and STP state.
+
+Static entries can be added/removed from the FDB.
+
+Hardware statistics for each port are provided through ethtool -S option.
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 0/6] staging: Introduce DPAA2 Ethernet Switch driver

2017-09-19 Thread Razvan Stefanescu
This patchset introduces the Ethernet Switch Driver for Freescale/NXP SoCs
with DPAA2 (DataPath Acceleration Architecture v2). The driver manages
switch objects discovered on the fsl-mc bus. A description of the driver
can be found in the associated README file.

The patchset consists of:
* A set of libraries containing APIs for configuring and controlling
  Management Complex (MC) switch objects
* The DPAA2 Ethernet Switch driver
* Patch adding ethtool support

Limitations:
* no support for control traffic to/from CPU
* only DPSW ports can be added to a bridge

Razvan Stefanescu (6):
  staging: fsl-dpaa2/ethsw: Add APIs for DPSW object
  staging: fsl-dpaa2/ethsw: Add Freescale DPAA2 Ethernet Switch driver
  staging: fsl-dpaa2/ethsw: Add ethtool support
  staging: fsl-dpaa2/ethsw: Add maintainer for Ethernet Switch driver
  staging: fsl-dpaa2/ethsw: Add README
  staging: fsl-dpaa2/ethsw: Add TODO

 MAINTAINERS |6 +
 drivers/staging/fsl-dpaa2/Kconfig   |8 +
 drivers/staging/fsl-dpaa2/Makefile  |1 +
 drivers/staging/fsl-dpaa2/ethsw/Makefile|7 +
 drivers/staging/fsl-dpaa2/ethsw/README  |  106 ++
 drivers/staging/fsl-dpaa2/ethsw/TODO|   14 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h  |  371 ++
 drivers/staging/fsl-dpaa2/ethsw/dpsw.c  | 1147 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw.h  |  611 +
 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c |  207 +++
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 1526 +++
 drivers/staging/fsl-dpaa2/ethsw/ethsw.h |   91 ++
 12 files changed, 4095 insertions(+)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/Makefile
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/README
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/TODO
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.h
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.h

-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/6] staging: fsl-dpaa2/ethsw: Add ethtool support

2017-09-19 Thread Razvan Stefanescu
Add driver information, link details and hardware statistics to be
reported via ethtool -S.

Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethsw/Makefile|   2 +-
 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h  |  13 ++
 drivers/staging/fsl-dpaa2/ethsw/dpsw.c  |  32 
 drivers/staging/fsl-dpaa2/ethsw/dpsw.h  |  32 
 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c | 207 
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c |   3 +
 drivers/staging/fsl-dpaa2/ethsw/ethsw.h |   3 +
 7 files changed, 291 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c

diff --git a/drivers/staging/fsl-dpaa2/ethsw/Makefile 
b/drivers/staging/fsl-dpaa2/ethsw/Makefile
index a6d72d1..de92cd9 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/Makefile
+++ b/drivers/staging/fsl-dpaa2/ethsw/Makefile
@@ -4,4 +4,4 @@
 
 obj-$(CONFIG_FSL_DPAA2_ETHSW) += dpaa2-ethsw.o
 
-dpaa2-ethsw-objs := ethsw.o dpsw.o
+dpaa2-ethsw-objs := ethsw.o ethsw-ethtool.o dpsw.o
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
index ddfd820..06b71122 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
@@ -74,6 +74,8 @@
 #define DPSW_CMDID_IF_SET_FLOODING  DPSW_CMD_ID(0x047)
 #define DPSW_CMDID_IF_SET_BROADCAST DPSW_CMD_ID(0x048)
 
+#define DPSW_CMDID_IF_SET_LINK_CFG  DPSW_CMD_ID(0x04C)
+
 #define DPSW_CMDID_VLAN_ADD DPSW_CMD_ID(0x060)
 #define DPSW_CMDID_VLAN_ADD_IF  DPSW_CMD_ID(0x061)
 #define DPSW_CMDID_VLAN_ADD_IF_UNTAGGED DPSW_CMD_ID(0x062)
@@ -262,6 +264,17 @@ struct dpsw_cmd_if_set_max_frame_length {
__le16 frame_length;
 };
 
+struct dpsw_cmd_if_set_link_cfg {
+   /* cmd word 0 */
+   __le16 if_id;
+   u8 pad[6];
+   /* cmd word 1 */
+   __le32 rate;
+   __le32 pad1;
+   /* cmd word 2 */
+   __le64 options;
+};
+
 struct dpsw_cmd_if_get_link_state {
__le16 if_id;
 };
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
index f36b92b..601172a 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw.c
@@ -383,6 +383,38 @@ int dpsw_get_attributes(struct fsl_mc_io *mc_io,
 }
 
 /**
+ * dpsw_if_set_link_cfg() - Set the link configuration.
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPSW object
+ * @if_id: Interface id
+ * @cfg:   Link configuration
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dpsw_if_set_link_cfg(struct fsl_mc_io *mc_io,
+u32 cmd_flags,
+u16 token,
+u16 if_id,
+struct dpsw_link_cfg *cfg)
+{
+   struct mc_command cmd = { 0 };
+   struct dpsw_cmd_if_set_link_cfg *cmd_params;
+
+   /* prepare command */
+   cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_LINK_CFG,
+ cmd_flags,
+ token);
+   cmd_params = (struct dpsw_cmd_if_set_link_cfg *)cmd.params;
+   cmd_params->if_id = cpu_to_le16(if_id);
+   cmd_params->rate = cpu_to_le32(cfg->rate);
+   cmd_params->options = cpu_to_le64(cfg->options);
+
+   /* send command to mc*/
+   return mc_send_command(mc_io, );
+}
+
+/**
  * dpsw_if_get_link_state - Return the link state
  * @mc_io: Pointer to MC portal's I/O object
  * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw.h 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
index e9c2906..5feadc2 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h
@@ -245,6 +245,38 @@ enum dpsw_action {
 };
 
 /**
+ * Enable auto-negotiation
+ */
+#define DPSW_LINK_OPT_AUTONEG  0x0001ULL
+/**
+ * Enable half-duplex mode
+ */
+#define DPSW_LINK_OPT_HALF_DUPLEX  0x0002ULL
+/**
+ * Enable pause frames
+ */
+#define DPSW_LINK_OPT_PAUSE0x0004ULL
+/**
+ * Enable a-symmetric pause frames
+ */
+#define DPSW_LINK_OPT_ASYM_PAUSE   0x0008ULL
+
+/**
+ * struct dpsw_link_cfg - Structure representing DPSW link configuration
+ * @rate: Rate
+ * @options: Mask of available options; use 'DPSW_LINK_OPT_' values
+ */
+struct dpsw_link_cfg {
+   u32 rate;
+   u64 options;
+};
+
+int dpsw_if_set_link_cfg(struct fsl_mc_io *mc_io,
+u32 cmd_flags,
+u16 token,
+u16 if_id,
+struct dpsw_link_cfg *cfg);
+/**
  * struct dpsw_link_state - Structure representing DPSW link state
  * @rate: Rate
  * @options: Mask of available options; use 'D

[PATCH 2/6] staging: fsl-dpaa2/ethsw: Add Freescale DPAA2 Ethernet Switch driver

2017-09-19 Thread Razvan Stefanescu
Introduce the DPAA2 Ethernet Switch driver, which manages Datapath Switch
(DPSW) objects discovered on the MC bus.

Suggested-by: Alexandru Marginean <alexandru.margin...@nxp.com>
Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethsw/Makefile |2 +-
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c  | 1523 ++
 drivers/staging/fsl-dpaa2/ethsw/ethsw.h  |   88 ++
 3 files changed, 1612 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/ethsw.h

diff --git a/drivers/staging/fsl-dpaa2/ethsw/Makefile 
b/drivers/staging/fsl-dpaa2/ethsw/Makefile
index db137f7..a6d72d1 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/Makefile
+++ b/drivers/staging/fsl-dpaa2/ethsw/Makefile
@@ -4,4 +4,4 @@
 
 obj-$(CONFIG_FSL_DPAA2_ETHSW) += dpaa2-ethsw.o
 
-dpaa2-ethsw-objs := dpsw.o
+dpaa2-ethsw-objs := ethsw.o dpsw.o
diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
new file mode 100644
index 000..ae86078
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
@@ -0,0 +1,1523 @@
+/* Copyright 2014-2016 Freescale Semiconductor Inc.
+ * Copyright 2017 NXP
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of the above-listed copyright holders nor the
+ *  names of any contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include "../../fsl-mc/include/mc.h"
+
+#include "ethsw.h"
+
+static struct workqueue_struct *ethsw_owq;
+
+/* Minimal supported DPSW version */
+#define DPSW_MIN_VER_MAJOR 8
+#define DPSW_MIN_VER_MINOR 0
+
+#define DEFAULT_VLAN_ID1
+
+static int ethsw_add_vlan(struct ethsw_core *ethsw, u16 vid)
+{
+   int err;
+
+   struct dpsw_vlan_cfgvcfg = {
+   .fdb_id = 0,
+   };
+
+   if (ethsw->vlans[vid]) {
+   dev_err(ethsw->dev, "VLAN already configured\n");
+   return -EEXIST;
+   }
+
+   err = dpsw_vlan_add(ethsw->mc_io, 0,
+   ethsw->dpsw_handle, vid, );
+   if (err) {
+   dev_err(ethsw->dev, "dpsw_vlan_add err %d\n", err);
+   return err;
+   }
+   ethsw->vlans[vid] = ETHSW_VLAN_MEMBER;
+
+   return 0;
+}
+
+static int ethsw_port_add_vlan(struct ethsw_port_priv *port_priv,
+  u16 vid, u16 flags)
+{
+   struct ethsw_core *ethsw = port_priv->ethsw_data;
+   struct net_device *netdev = port_priv->netdev;
+   struct dpsw_vlan_if_cfg vcfg;
+   bool is_oper;
+   int err, err2;
+
+   if (port_priv->vlans[vid]) {
+   netdev_warn(netdev, "VLAN %d already configured\n", vid);
+   return -EEXIST;
+   }
+
+   vcfg.num_ifs = 1;
+   vcfg.if_id[0] = port_priv->idx;
+   err = dpsw_vlan_add_if(ethsw->mc_io, 0, ethsw->dpsw_handle, vid, );
+   if (err) {
+   netdev_err(netdev, "dpsw_vlan_add_if err %d\n", err);
+   return err;
+   }
+
+   port_priv->vlans[vid] = ETHSW_VLAN_MEMBER;
+
+   if (flags & BRIDGE_VLAN_

[PATCH 4/6] staging: fsl-dpaa2/ethsw: Add maintainer for Ethernet Switch driver

2017-09-19 Thread Razvan Stefanescu
Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
 MAINTAINERS | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 2281af4..cfd4f74 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4297,6 +4297,12 @@ L:   linux-ker...@vger.kernel.org
 S: Maintained
 F: drivers/staging/fsl-dpaa2/ethernet
 
+DPAA2 ETHERNET SWITCH DRIVER
+M: Razvan Stefanescu <razvan.stefane...@nxp.com>
+L: linux-ker...@vger.kernel.org
+S: Maintained
+F: drivers/staging/fsl-dpaa2/ethsw
+
 DPT_I2O SCSI RAID DRIVER
 M: Adaptec OEM Raid Solutions <aacr...@adaptec.com>
 L: linux-s...@vger.kernel.org
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/6] staging: fsl-dpaa2/ethsw: Add APIs for DPSW object

2017-09-19 Thread Razvan Stefanescu
Add the command build/parse APIs for operating on DPSW objects through
the DPAA2 Management Complex.

Signed-off-by: Razvan Stefanescu <razvan.stefane...@nxp.com>
---
 drivers/staging/fsl-dpaa2/Kconfig  |8 +
 drivers/staging/fsl-dpaa2/Makefile |1 +
 drivers/staging/fsl-dpaa2/ethsw/Makefile   |7 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h |  358 +
 drivers/staging/fsl-dpaa2/ethsw/dpsw.c | 1115 
 drivers/staging/fsl-dpaa2/ethsw/dpsw.h |  579 +++
 6 files changed, 2068 insertions(+)
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/Makefile
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.c
 create mode 100644 drivers/staging/fsl-dpaa2/ethsw/dpsw.h

diff --git a/drivers/staging/fsl-dpaa2/Kconfig 
b/drivers/staging/fsl-dpaa2/Kconfig
index dfff675..8a508ef 100644
--- a/drivers/staging/fsl-dpaa2/Kconfig
+++ b/drivers/staging/fsl-dpaa2/Kconfig
@@ -16,3 +16,11 @@ config FSL_DPAA2_ETH
---help---
  Ethernet driver for Freescale DPAA2 SoCs, using the
  Freescale MC bus driver
+
+config FSL_DPAA2_ETHSW
+   tristate "Freescale DPAA2 Ethernet Switch"
+   depends on FSL_DPAA2
+   depends on NET_SWITCHDEV
+   ---help---
+   Driver for Freescale DPAA2 Ethernet Switch. Select
+   BRIDGE to have support for bridge tools.
diff --git a/drivers/staging/fsl-dpaa2/Makefile 
b/drivers/staging/fsl-dpaa2/Makefile
index 0836ba8..6cfd76b 100644
--- a/drivers/staging/fsl-dpaa2/Makefile
+++ b/drivers/staging/fsl-dpaa2/Makefile
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_FSL_DPAA2_ETH)+= ethernet/
+obj-$(CONFIG_FSL_DPAA2_ETHSW)  += ethsw/
diff --git a/drivers/staging/fsl-dpaa2/ethsw/Makefile 
b/drivers/staging/fsl-dpaa2/ethsw/Makefile
new file mode 100644
index 000..db137f7
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/Makefile
@@ -0,0 +1,7 @@
+#
+# Makefile for the Freescale DPAA2 Ethernet Switch
+#
+
+obj-$(CONFIG_FSL_DPAA2_ETHSW) += dpaa2-ethsw.o
+
+dpaa2-ethsw-objs := dpsw.o
diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h 
b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
new file mode 100644
index 000..ddfd820
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h
@@ -0,0 +1,358 @@
+/* Copyright 2013-2016 Freescale Semiconductor Inc.
+ * Copyright 2017 NXP
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of the above-listed copyright holders nor the
+ *  names of any contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef __FSL_DPSW_CMD_H
+#define __FSL_DPSW_CMD_H
+
+/* DPSW Version */
+#define DPSW_VER_MAJOR 8
+#define DPSW_VER_MINOR 0
+
+#define DPSW_CMD_BASE_VERSION  1
+#define DPSW_CMD_ID_OFFSET 4
+
+#define DPSW_CMD_ID(id)(((id) << DPSW_CMD_ID_OFFSET) | 
DPSW_CMD_BASE_VERSION)
+
+/* Command IDs */
+#define DPSW_CMDID_CLOSEDPSW_CMD_ID(0x800)
+#define DPSW_CMDID_OPEN DPSW_CMD_ID(0x802)
+
+#define DPSW_CMDID_GET_API_VERSION  DPSW_CMD_ID(0xa02)
+
+#define DPSW_CMDID_ENABLE   DPSW_CMD_ID(0x002)
+#define DPSW_CMDID_DISABLE  DPSW_CMD_ID(0x003)
+#define DPSW_CMDID_GET_ATTR DPSW_CMD_ID(0x004)
+#define DPSW_CMDID_RESET