[PATCH] staging: fsl-dpaa2/ethsw: Fix uninitialized variables

2018-08-30 Thread Ioana Radulescu
Functions port_vlans_add() and port_vlans_del() could,
in theory, return an uninitialized variable. Fix this
by initializing the variable in question at declaration.

Signed-off-by: Ioana Radulescu 
Reported-by: Dan Carpenter 
---
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
index ecdd3d8..c1616c3 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
@@ -717,7 +717,7 @@ static int port_vlans_add(struct net_device *netdev,
  struct switchdev_trans *trans)
 {
struct ethsw_port_priv *port_priv = netdev_priv(netdev);
-   int vid, err;
+   int vid, err = 0;
 
if (netif_is_bridge_master(vlan->obj.orig_dev))
return -EOPNOTSUPP;
@@ -872,7 +872,7 @@ static int port_vlans_del(struct net_device *netdev,
  const struct switchdev_obj_port_vlan *vlan)
 {
struct ethsw_port_priv *port_priv = netdev_priv(netdev);
-   int vid, err;
+   int vid, err = 0;
 
if (netif_is_bridge_master(vlan->obj.orig_dev))
return -EOPNOTSUPP;
-- 
2.7.4

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


[PATCH net-next v2 0/2] dpaa2-eth: Move DPAA2 Ethernet driver

2018-08-29 Thread Ioana Radulescu
The Freescale/NXP DPAA2 Ethernet driver was first included in
drivers/staging, due to its dependencies on two components located
there at the time of its initial submission:
* the fsl-mc bus driver, which was moved to drivers/bus in kernel 4.17
* the dpio driver, which was moved to drivers/soc/fsl in kernel 4.18

More information on the DPAA2 architecture and the interactions
between the fsl-mc bus and the objects present on it can be found in:
Documentation/networking/dpaa2/overview.rst

For easier review, the patch is generated without the -M option,
although the driver files are moved without any code changes.

changes since v1[1]:
* remove RFC label, since dependencies have been merged on net-next
* add patch fixing a possible race at probe (reported by Andrew Lunn)

[1] https://lore.kernel.org/patchwork/patch/971333/

Ioana Radulescu (2):
  staging: fsl-dpaa2/eth: Delay netdev_register() call
  dpaa2-eth: Move DPAA2 Ethernet driver from staging to drivers/net

 Documentation/networking/dpaa2/ethernet-driver.rst |  185 ++
 Documentation/networking/dpaa2/index.rst   |1 +
 MAINTAINERS|4 +-
 drivers/net/ethernet/freescale/Kconfig |8 +
 drivers/net/ethernet/freescale/Makefile|2 +
 drivers/net/ethernet/freescale/dpaa2/Makefile  |   11 +
 .../net/ethernet/freescale/dpaa2/dpaa2-eth-trace.h |  158 ++
 drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c   | 2654 +++
 drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h   |  412 +++
 .../net/ethernet/freescale/dpaa2/dpaa2-ethtool.c   |  280 ++
 drivers/net/ethernet/freescale/dpaa2/dpkg.h|  480 
 drivers/net/ethernet/freescale/dpaa2/dpni-cmd.h|  518 
 drivers/net/ethernet/freescale/dpaa2/dpni.c| 1600 
 drivers/net/ethernet/freescale/dpaa2/dpni.h|  824 ++
 drivers/staging/fsl-dpaa2/Kconfig  |8 -
 drivers/staging/fsl-dpaa2/Makefile |1 -
 drivers/staging/fsl-dpaa2/ethernet/Makefile|   11 -
 drivers/staging/fsl-dpaa2/ethernet/TODO|   18 -
 .../staging/fsl-dpaa2/ethernet/dpaa2-eth-trace.h   |  158 --
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 2661 
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h |  412 ---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c |  280 --
 drivers/staging/fsl-dpaa2/ethernet/dpkg.h  |  480 
 drivers/staging/fsl-dpaa2/ethernet/dpni-cmd.h  |  518 
 drivers/staging/fsl-dpaa2/ethernet/dpni.c  | 1600 
 drivers/staging/fsl-dpaa2/ethernet/dpni.h  |  824 --
 .../staging/fsl-dpaa2/ethernet/ethernet-driver.rst |  185 --
 27 files changed, 7135 insertions(+), 7158 deletions(-)
 create mode 100644 Documentation/networking/dpaa2/ethernet-driver.rst
 create mode 100644 drivers/net/ethernet/freescale/dpaa2/Makefile
 create mode 100644 drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-trace.h
 create mode 100644 drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
 create mode 100644 drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h
 create mode 100644 drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c
 create mode 100644 drivers/net/ethernet/freescale/dpaa2/dpkg.h
 create mode 100644 drivers/net/ethernet/freescale/dpaa2/dpni-cmd.h
 create mode 100644 drivers/net/ethernet/freescale/dpaa2/dpni.c
 create mode 100644 drivers/net/ethernet/freescale/dpaa2/dpni.h
 delete mode 100644 drivers/staging/fsl-dpaa2/ethernet/Makefile
 delete mode 100644 drivers/staging/fsl-dpaa2/ethernet/TODO
 delete mode 100644 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth-trace.h
 delete mode 100644 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
 delete mode 100644 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
 delete mode 100644 drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
 delete mode 100644 drivers/staging/fsl-dpaa2/ethernet/dpkg.h
 delete mode 100644 drivers/staging/fsl-dpaa2/ethernet/dpni-cmd.h
 delete mode 100644 drivers/staging/fsl-dpaa2/ethernet/dpni.c
 delete mode 100644 drivers/staging/fsl-dpaa2/ethernet/dpni.h
 delete mode 100644 drivers/staging/fsl-dpaa2/ethernet/ethernet-driver.rst

-- 
2.7.4

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


[PATCH net-next v2 1/2] staging: fsl-dpaa2/eth: Delay netdev_register() call

2018-08-29 Thread Ioana Radulescu
Only call netdev_register() at the end of the probe function,
once all other necessary bits and pieces are properly initialized.

We keep the rest of the netdevice initialization code in place,
at the earlier point of the probing sequence, including the
settings previously done in ndo_init.

Signed-off-by: Ioana Radulescu 
Suggested-by: Andrew Lunn 
---
v2: new patch

 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 71 --
 1 file changed, 32 insertions(+), 39 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 9329fca..559154a 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -1143,34 +1143,6 @@ static int dpaa2_eth_stop(struct net_device *net_dev)
return 0;
 }
 
-static int dpaa2_eth_init(struct net_device *net_dev)
-{
-   u64 supported = 0;
-   u64 not_supported = 0;
-   struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
-   u32 options = priv->dpni_attrs.options;
-
-   /* Capabilities listing */
-   supported |= IFF_LIVE_ADDR_CHANGE;
-
-   if (options & DPNI_OPT_NO_MAC_FILTER)
-   not_supported |= IFF_UNICAST_FLT;
-   else
-   supported |= IFF_UNICAST_FLT;
-
-   net_dev->priv_flags |= supported;
-   net_dev->priv_flags &= ~not_supported;
-
-   /* Features */
-   net_dev->features = NETIF_F_RXCSUM |
-   NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
-   NETIF_F_SG | NETIF_F_HIGHDMA |
-   NETIF_F_LLTX;
-   net_dev->hw_features = net_dev->features;
-
-   return 0;
-}
-
 static int dpaa2_eth_set_addr(struct net_device *net_dev, void *addr)
 {
struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
@@ -1418,7 +1390,6 @@ static const struct net_device_ops dpaa2_eth_ops = {
.ndo_open = dpaa2_eth_open,
.ndo_start_xmit = dpaa2_eth_tx,
.ndo_stop = dpaa2_eth_stop,
-   .ndo_init = dpaa2_eth_init,
.ndo_set_mac_address = dpaa2_eth_set_addr,
.ndo_get_stats64 = dpaa2_eth_get_stats,
.ndo_set_rx_mode = dpaa2_eth_set_rx_mode,
@@ -2316,11 +2287,14 @@ static int netdev_init(struct net_device *net_dev)
 {
struct device *dev = net_dev->dev.parent;
struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
+   u32 options = priv->dpni_attrs.options;
+   u64 supported = 0, not_supported = 0;
u8 bcast_addr[ETH_ALEN];
u8 num_queues;
int err;
 
net_dev->netdev_ops = _eth_ops;
+   net_dev->ethtool_ops = _ethtool_ops;
 
err = set_mac_addr(priv);
if (err)
@@ -2356,12 +2330,23 @@ static int netdev_init(struct net_device *net_dev)
return err;
}
 
-   /* Our .ndo_init will be called herein */
-   err = register_netdev(net_dev);
-   if (err < 0) {
-   dev_err(dev, "register_netdev() failed\n");
-   return err;
-   }
+   /* Capabilities listing */
+   supported |= IFF_LIVE_ADDR_CHANGE;
+
+   if (options & DPNI_OPT_NO_MAC_FILTER)
+   not_supported |= IFF_UNICAST_FLT;
+   else
+   supported |= IFF_UNICAST_FLT;
+
+   net_dev->priv_flags |= supported;
+   net_dev->priv_flags &= ~not_supported;
+
+   /* Features */
+   net_dev->features = NETIF_F_RXCSUM |
+   NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
+   NETIF_F_SG | NETIF_F_HIGHDMA |
+   NETIF_F_LLTX;
+   net_dev->hw_features = net_dev->features;
 
return 0;
 }
@@ -2561,28 +2546,36 @@ static int dpaa2_eth_probe(struct fsl_mc_device 
*dpni_dev)
if (err)
goto err_alloc_rings;
 
-   net_dev->ethtool_ops = _ethtool_ops;
-
err = setup_irqs(dpni_dev);
if (err) {
netdev_warn(net_dev, "Failed to set link interrupt, fall back 
to polling\n");
priv->poll_thread = kthread_run(poll_link_state, priv,
"%s_poll_link", net_dev->name);
if (IS_ERR(priv->poll_thread)) {
-   netdev_err(net_dev, "Error starting polling thread\n");
+   dev_err(dev, "Error starting polling thread\n");
goto err_poll_thread;
}
priv->do_link_poll = true;
}
 
+   err = register_netdev(net_dev);
+   if (err < 0) {
+   dev_err(dev, "register_netdev() failed\n");
+   goto err_netdev_reg;
+   }
+
dev_info(dev, "Probed interface %s\n", net_dev->name);
return 0;
 
+err_netdev_reg:
+   if (priv->do_link_poll)
+   kthread_stop(priv->poll_thr

[PATCH] staging: fsl-dpaa2/eth: Use named arguments in function definition

2018-08-02 Thread Ioana Radulescu
Checkpatch complains about unnamed arguments in a function
prototype, so fix it.

Signed-off-by: Ioana Radulescu 
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
index 6b70c66..5064667 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
@@ -277,10 +277,10 @@ struct dpaa2_eth_fq {
struct dpaa2_eth_channel *channel;
enum dpaa2_eth_fq_type type;
 
-   void (*consume)(struct dpaa2_eth_priv *,
-   struct dpaa2_eth_channel *,
-   const struct dpaa2_fd *,
-   struct napi_struct *,
+   void (*consume)(struct dpaa2_eth_priv *priv,
+   struct dpaa2_eth_channel *ch,
+   const struct dpaa2_fd *fd,
+   struct napi_struct *napi,
u16 queue_id);
struct dpaa2_eth_fq_stats stats;
 };
-- 
2.7.4

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


[PATCH 0/4] staging: fsl-dpaa2/eth: Private header cleanup

2018-08-01 Thread Ioana Radulescu
Private header file net.h receives a cleanup and the remaining code
is then merged into dpkg.h

This patchset depends on:
staging: fsl-dpaa2/eth: add SPDX license identifiers
(https://lore.kernel.org/patchwork/patch/969402/)

Ioana Radulescu (4):
  staging: fsl-dpaa2/eth: Cleanup comments
  staging: fsl-dpaa2/eth: Remove dead code
  staging: fsl-dpaa2/eth: Use BIT() macro
  staging: fsl-dpaa2/eth: Merge header files

 drivers/staging/fsl-dpaa2/ethernet/dpkg.h | 350 ++-
 drivers/staging/fsl-dpaa2/ethernet/net.h  | 452 --
 2 files changed, 349 insertions(+), 453 deletions(-)
 delete mode 100644 drivers/staging/fsl-dpaa2/ethernet/net.h

-- 
2.7.4

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


[PATCH 1/4] staging: fsl-dpaa2/eth: Cleanup comments

2018-08-01 Thread Ioana Radulescu
Comments in file net.h are too fancy for their own good,
so convert them to the regular format.

Signed-off-by: Ioana Radulescu 
---
 drivers/staging/fsl-dpaa2/ethernet/net.h | 76 
 1 file changed, 38 insertions(+), 38 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/net.h 
b/drivers/staging/fsl-dpaa2/ethernet/net.h
index 75a2d3a..ddea940 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/net.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/net.h
@@ -6,11 +6,9 @@
 
 #define LAST_HDR_INDEX 0x
 
-/*/
-/*Protocol fields*/
-/*/
+/* Protocol fields */
 
-/*  Ethernet fields  */
+/* Ethernet fields */
 #define NH_FLD_ETH_DA (1)
 #define NH_FLD_ETH_SA (NH_FLD_ETH_DA << 1)
 #define NH_FLD_ETH_LENGTH (NH_FLD_ETH_DA << 2)
@@ -21,7 +19,7 @@
 
 #define NH_FLD_ETH_ADDR_SIZE 6
 
-/***  VLAN fields  ***/
+/* VLAN fields */
 #define NH_FLD_VLAN_VPRI  (1)
 #define NH_FLD_VLAN_CFI   (NH_FLD_VLAN_VPRI << 1)
 #define NH_FLD_VLAN_VID   (NH_FLD_VLAN_VPRI << 2)
@@ -33,7 +31,7 @@
   NH_FLD_VLAN_CFI | \
   NH_FLD_VLAN_VID)
 
-/  IP (generic) fields  **/
+/* IP (generic) fields */
 #define NH_FLD_IP_VER (1)
 #define NH_FLD_IP_DSCP(NH_FLD_IP_VER << 2)
 #define NH_FLD_IP_ECN (NH_FLD_IP_VER << 3)
@@ -46,7 +44,7 @@
 
 #define NH_FLD_IP_PROTO_SIZE  1
 
-/*  IPV4 fields  */
+/* IPV4 fields */
 #define NH_FLD_IPV4_VER   (1)
 #define NH_FLD_IPV4_HDR_LEN   (NH_FLD_IPV4_VER << 1)
 #define NH_FLD_IPV4_TOS   (NH_FLD_IPV4_VER << 2)
@@ -67,7 +65,7 @@
 #define NH_FLD_IPV4_ADDR_SIZE 4
 #define NH_FLD_IPV4_PROTO_SIZE1
 
-/*  IPV6 fields  */
+/* IPV6 fields */
 #define NH_FLD_IPV6_VER   (1)
 #define NH_FLD_IPV6_TC(NH_FLD_IPV6_VER << 1)
 #define NH_FLD_IPV6_SRC_IP(NH_FLD_IPV6_VER << 2)
@@ -81,7 +79,7 @@
 #define NH_FLD_IPV6_ADDR_SIZE 16
 #define NH_FLD_IPV6_NEXT_HDR_SIZE 1
 
-/*  ICMP fields  */
+/* ICMP fields */
 #define NH_FLD_ICMP_TYPE  (1)
 #define NH_FLD_ICMP_CODE  (NH_FLD_ICMP_TYPE << 1)
 #define NH_FLD_ICMP_CKSUM (NH_FLD_ICMP_TYPE << 2)
@@ -92,14 +90,14 @@
 #define NH_FLD_ICMP_CODE_SIZE 1
 #define NH_FLD_ICMP_TYPE_SIZE 1
 
-/*  IGMP fields  */
+/* IGMP fields */
 #define NH_FLD_IGMP_VERSION   (1)
 #define NH_FLD_IGMP_TYPE  (NH_FLD_IGMP_VERSION << 1)
 #define NH_FLD_IGMP_CKSUM (NH_FLD_IGMP_VERSION << 2)
 #define NH_FLD_IGMP_DATA  (NH_FLD_IGMP_VERSION << 3)
 #define NH_FLD_IGMP_ALL_FIELDS((NH_FLD_IGMP_VERSION << 4) - 1)
 
-/*  TCP fields  **/
+/* TCP fields */
 #define NH_FLD_TCP_PORT_SRC   (1)
 #define NH_FLD_TCP_PORT_DST   (NH_FLD_TCP_PORT_SRC << 1)
 #define NH_FLD_TCP_SEQ(NH_FLD_TCP_PORT_SRC << 2)
@@ -115,7 +113,7 @@
 
 #define NH_FLD_TCP_PORT_SIZE  2
 
-/*  UDP fields  **/
+/* UDP fields */
 #define NH_FLD_UDP_PORT_SRC   (1)
 #define NH_FLD_UDP_PORT_DST   (NH_FLD_UDP_PORT_SRC << 1)
 #define NH_FLD_UDP_LEN(NH_FLD_UDP_PORT_SRC << 2)
@@ -124,7 +122,7 @@
 
 #define NH_FLD_UDP_PORT_SIZE  2
 
-/***  UDP-lite fields  ***/
+/* UDP-lite fields */
 #define NH_FLD_UDP_LITE_PORT_SRC  (1)
 #define NH_FLD_UDP_LITE_PORT_DST  (NH_FLD_UDP_LITE_PORT_SRC << 1)
 #define NH_FLD_UDP_LITE_ALL_FIELDS \
@@ -132,7 +130,7 @@
 
 #define NH_FLD_UDP_LITE_PORT_SIZE 2
 
-/***  UDP-encap-ESP fields  **/
+/* UDP-encap-ESP fields */
 

[PATCH 3/4] staging: fsl-dpaa2/eth: Use BIT() macro

2018-08-01 Thread Ioana Radulescu
File net.h has several bitmask defines that could be implemented
more clearly using the BIT() macro.

Signed-off-by: Ioana Radulescu 
---
 drivers/staging/fsl-dpaa2/ethernet/net.h | 448 +++
 1 file changed, 219 insertions(+), 229 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/net.h 
b/drivers/staging/fsl-dpaa2/ethernet/net.h
index 2461d6e..81f5a91 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/net.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/net.h
@@ -7,307 +7,297 @@
 /* Protocol fields */
 
 /* Ethernet fields */
-#define NH_FLD_ETH_DA (1)
-#define NH_FLD_ETH_SA (NH_FLD_ETH_DA << 1)
-#define NH_FLD_ETH_LENGTH (NH_FLD_ETH_DA << 2)
-#define NH_FLD_ETH_TYPE   (NH_FLD_ETH_DA << 3)
-#define NH_FLD_ETH_FINAL_CKSUM(NH_FLD_ETH_DA << 4)
-#define NH_FLD_ETH_PADDING(NH_FLD_ETH_DA << 5)
-#define NH_FLD_ETH_ALL_FIELDS ((NH_FLD_ETH_DA << 6) - 1)
+#define NH_FLD_ETH_DA  BIT(0)
+#define NH_FLD_ETH_SA  BIT(1)
+#define NH_FLD_ETH_LENGTH  BIT(2)
+#define NH_FLD_ETH_TYPEBIT(3)
+#define NH_FLD_ETH_FINAL_CKSUM BIT(4)
+#define NH_FLD_ETH_PADDING BIT(5)
+#define NH_FLD_ETH_ALL_FIELDS  (BIT(6) - 1)
 
 /* VLAN fields */
-#define NH_FLD_VLAN_VPRI  (1)
-#define NH_FLD_VLAN_CFI   (NH_FLD_VLAN_VPRI << 1)
-#define NH_FLD_VLAN_VID   (NH_FLD_VLAN_VPRI << 2)
-#define NH_FLD_VLAN_LENGTH(NH_FLD_VLAN_VPRI << 3)
-#define NH_FLD_VLAN_TYPE  (NH_FLD_VLAN_VPRI << 4)
-#define NH_FLD_VLAN_ALL_FIELDS((NH_FLD_VLAN_VPRI << 5) - 1)
+#define NH_FLD_VLAN_VPRI   BIT(0)
+#define NH_FLD_VLAN_CFIBIT(1)
+#define NH_FLD_VLAN_VIDBIT(2)
+#define NH_FLD_VLAN_LENGTH BIT(3)
+#define NH_FLD_VLAN_TYPE   BIT(4)
+#define NH_FLD_VLAN_ALL_FIELDS (BIT(5) - 1)
 
-#define NH_FLD_VLAN_TCI   (NH_FLD_VLAN_VPRI | \
-  NH_FLD_VLAN_CFI | \
-  NH_FLD_VLAN_VID)
+#define NH_FLD_VLAN_TCI(NH_FLD_VLAN_VPRI | \
+NH_FLD_VLAN_CFI | \
+NH_FLD_VLAN_VID)
 
 /* IP (generic) fields */
-#define NH_FLD_IP_VER (1)
-#define NH_FLD_IP_DSCP(NH_FLD_IP_VER << 2)
-#define NH_FLD_IP_ECN (NH_FLD_IP_VER << 3)
-#define NH_FLD_IP_PROTO   (NH_FLD_IP_VER << 4)
-#define NH_FLD_IP_SRC (NH_FLD_IP_VER << 5)
-#define NH_FLD_IP_DST (NH_FLD_IP_VER << 6)
-#define NH_FLD_IP_TOS_TC  (NH_FLD_IP_VER << 7)
-#define NH_FLD_IP_ID  (NH_FLD_IP_VER << 8)
-#define NH_FLD_IP_ALL_FIELDS  ((NH_FLD_IP_VER << 9) - 1)
+#define NH_FLD_IP_VER  BIT(0)
+#define NH_FLD_IP_DSCP BIT(2)
+#define NH_FLD_IP_ECN  BIT(3)
+#define NH_FLD_IP_PROTOBIT(4)
+#define NH_FLD_IP_SRC  BIT(5)
+#define NH_FLD_IP_DST  BIT(6)
+#define NH_FLD_IP_TOS_TC   BIT(7)
+#define NH_FLD_IP_ID   BIT(8)
+#define NH_FLD_IP_ALL_FIELDS   (BIT(9) - 1)
 
 /* IPV4 fields */
-#define NH_FLD_IPV4_VER   (1)
-#define NH_FLD_IPV4_HDR_LEN   (NH_FLD_IPV4_VER << 1)
-#define NH_FLD_IPV4_TOS   (NH_FLD_IPV4_VER << 2)
-#define NH_FLD_IPV4_TOTAL_LEN (NH_FLD_IPV4_VER << 3)
-#define NH_FLD_IPV4_ID(NH_FLD_IPV4_VER << 4)
-#define NH_FLD_IPV4_FLAG_D(NH_FLD_IPV4_VER << 5)
-#define NH_FLD_IPV4_FLAG_M(NH_FLD_IPV4_VER << 6)
-#define NH_FLD_IPV4_OFFSET(NH_FLD_IPV4_VER << 7)
-#define NH_FLD_IPV4_TTL   (NH_FLD_IPV4_VER << 8)
-#define NH_FLD_IPV4_PROTO (NH_FLD_IPV4_VER << 9)
-#define NH_FLD_IPV4_CKSUM (NH_FLD_IPV4_VER << 10)
-#define NH_FLD_IPV4_SRC_IP(NH_FLD_IPV4_VER << 11)
-#define NH_FLD_IPV4_DST_IP(NH_FLD_IPV4_VER << 12)
-#define NH_FLD_IPV4_OPTS  (NH_FLD_IPV4_VER << 13)
-#define NH_FLD_IPV4_OPTS_COUNT

[PATCH 4/4] staging: fsl-dpaa2/eth: Merge header files

2018-08-01 Thread Ioana Radulescu
File net.h contains definitions that are exclusively used by
the key generator/classification API. Merge its contents with
dpkg.h in order to reduce the number of private headers.

Signed-off-by: Ioana Radulescu 
---
 drivers/staging/fsl-dpaa2/ethernet/dpkg.h | 350 -
 drivers/staging/fsl-dpaa2/ethernet/net.h  | 357 --
 2 files changed, 349 insertions(+), 358 deletions(-)
 delete mode 100644 drivers/staging/fsl-dpaa2/ethernet/net.h

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpkg.h 
b/drivers/staging/fsl-dpaa2/ethernet/dpkg.h
index 099ff02..6de613b1 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpkg.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpkg.h
@@ -5,7 +5,6 @@
 #define __FSL_DPKG_H_
 
 #include 
-#include "net.h"
 
 /* Data Path Key Generator API
  * Contains initialization APIs and runtime APIs for the Key Generator
@@ -58,6 +57,355 @@ struct dpkg_mask {
u8 offset;
 };
 
+/* Protocol fields */
+
+/* Ethernet fields */
+#define NH_FLD_ETH_DA  BIT(0)
+#define NH_FLD_ETH_SA  BIT(1)
+#define NH_FLD_ETH_LENGTH  BIT(2)
+#define NH_FLD_ETH_TYPEBIT(3)
+#define NH_FLD_ETH_FINAL_CKSUM BIT(4)
+#define NH_FLD_ETH_PADDING BIT(5)
+#define NH_FLD_ETH_ALL_FIELDS  (BIT(6) - 1)
+
+/* VLAN fields */
+#define NH_FLD_VLAN_VPRI   BIT(0)
+#define NH_FLD_VLAN_CFIBIT(1)
+#define NH_FLD_VLAN_VIDBIT(2)
+#define NH_FLD_VLAN_LENGTH BIT(3)
+#define NH_FLD_VLAN_TYPE   BIT(4)
+#define NH_FLD_VLAN_ALL_FIELDS (BIT(5) - 1)
+
+#define NH_FLD_VLAN_TCI(NH_FLD_VLAN_VPRI | \
+NH_FLD_VLAN_CFI | \
+NH_FLD_VLAN_VID)
+
+/* IP (generic) fields */
+#define NH_FLD_IP_VER  BIT(0)
+#define NH_FLD_IP_DSCP BIT(2)
+#define NH_FLD_IP_ECN  BIT(3)
+#define NH_FLD_IP_PROTOBIT(4)
+#define NH_FLD_IP_SRC  BIT(5)
+#define NH_FLD_IP_DST  BIT(6)
+#define NH_FLD_IP_TOS_TC   BIT(7)
+#define NH_FLD_IP_ID   BIT(8)
+#define NH_FLD_IP_ALL_FIELDS   (BIT(9) - 1)
+
+/* IPV4 fields */
+#define NH_FLD_IPV4_VERBIT(0)
+#define NH_FLD_IPV4_HDR_LENBIT(1)
+#define NH_FLD_IPV4_TOSBIT(2)
+#define NH_FLD_IPV4_TOTAL_LEN  BIT(3)
+#define NH_FLD_IPV4_ID BIT(4)
+#define NH_FLD_IPV4_FLAG_D BIT(5)
+#define NH_FLD_IPV4_FLAG_M BIT(6)
+#define NH_FLD_IPV4_OFFSET BIT(7)
+#define NH_FLD_IPV4_TTLBIT(8)
+#define NH_FLD_IPV4_PROTO  BIT(9)
+#define NH_FLD_IPV4_CKSUM  BIT(10)
+#define NH_FLD_IPV4_SRC_IP BIT(11)
+#define NH_FLD_IPV4_DST_IP BIT(12)
+#define NH_FLD_IPV4_OPTS   BIT(13)
+#define NH_FLD_IPV4_OPTS_COUNT BIT(14)
+#define NH_FLD_IPV4_ALL_FIELDS (BIT(15) - 1)
+
+/* IPV6 fields */
+#define NH_FLD_IPV6_VERBIT(0)
+#define NH_FLD_IPV6_TC BIT(1)
+#define NH_FLD_IPV6_SRC_IP BIT(2)
+#define NH_FLD_IPV6_DST_IP BIT(3)
+#define NH_FLD_IPV6_NEXT_HDR   BIT(4)
+#define NH_FLD_IPV6_FL BIT(5)
+#define NH_FLD_IPV6_HOP_LIMIT  BIT(6)
+#define NH_FLD_IPV6_ID BIT(7)
+#define NH_FLD_IPV6_ALL_FIELDS (BIT(8) - 1)
+
+/* ICMP fields */
+#define NH_FLD_ICMP_TYPE   BIT(0)
+#define NH_FLD_ICMP_CODE   BIT(1)
+#define NH_FLD_ICMP_CKSUM  BIT(2)
+#define NH_FLD_ICMP_ID BIT(3)
+#define NH_FLD_ICMP_SQ_NUM BIT(4)
+#define NH_FLD_ICMP_ALL_FIELDS (BIT(5) - 1)
+
+/* IGMP fields */
+#define NH_FLD_IGMP_VERSIONBIT(0)
+#define NH_FLD_IGMP_TYPE   BIT(1)
+#define NH_FLD_IGMP_CKSUM  BIT(2)
+#define NH_FLD_IGMP_DATA   BIT(3)
+#define NH_FLD_IGMP_ALL_FIELDS (BIT(4) - 1)
+
+/* TCP fields */
+#define NH_FLD_TCP_PORT_SRCBIT(0)
+#define NH_FLD_TCP_PORT_DSTBIT(1)
+#define NH_FLD_TCP_SEQ BIT(2)
+#define NH_FLD_TCP_ACK BIT(3)
+#define NH_FLD_TCP_OFFSET  BIT(4)
+#define NH_FLD

[PATCH 2/4] staging: fsl-dpaa2/eth: Remove dead code

2018-08-01 Thread Ioana Radulescu
File net.h contains unused defines, so remove them.

Signed-off-by: Ioana Radulescu 
---
 drivers/staging/fsl-dpaa2/ethernet/net.h | 85 
 1 file changed, 85 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/net.h 
b/drivers/staging/fsl-dpaa2/ethernet/net.h
index ddea940..2461d6e 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/net.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/net.h
@@ -4,8 +4,6 @@
 #ifndef __FSL_NET_H
 #define __FSL_NET_H
 
-#define LAST_HDR_INDEX 0x
-
 /* Protocol fields */
 
 /* Ethernet fields */
@@ -17,8 +15,6 @@
 #define NH_FLD_ETH_PADDING(NH_FLD_ETH_DA << 5)
 #define NH_FLD_ETH_ALL_FIELDS ((NH_FLD_ETH_DA << 6) - 1)
 
-#define NH_FLD_ETH_ADDR_SIZE 6
-
 /* VLAN fields */
 #define NH_FLD_VLAN_VPRI  (1)
 #define NH_FLD_VLAN_CFI   (NH_FLD_VLAN_VPRI << 1)
@@ -42,8 +38,6 @@
 #define NH_FLD_IP_ID  (NH_FLD_IP_VER << 8)
 #define NH_FLD_IP_ALL_FIELDS  ((NH_FLD_IP_VER << 9) - 1)
 
-#define NH_FLD_IP_PROTO_SIZE  1
-
 /* IPV4 fields */
 #define NH_FLD_IPV4_VER   (1)
 #define NH_FLD_IPV4_HDR_LEN   (NH_FLD_IPV4_VER << 1)
@@ -62,9 +56,6 @@
 #define NH_FLD_IPV4_OPTS_COUNT(NH_FLD_IPV4_VER << 14)
 #define NH_FLD_IPV4_ALL_FIELDS((NH_FLD_IPV4_VER << 15) - 1)
 
-#define NH_FLD_IPV4_ADDR_SIZE 4
-#define NH_FLD_IPV4_PROTO_SIZE1
-
 /* IPV6 fields */
 #define NH_FLD_IPV6_VER   (1)
 #define NH_FLD_IPV6_TC(NH_FLD_IPV6_VER << 1)
@@ -76,9 +67,6 @@
 #define NH_FLD_IPV6_ID   (NH_FLD_IPV6_VER << 7)
 #define NH_FLD_IPV6_ALL_FIELDS((NH_FLD_IPV6_VER << 8) - 1)
 
-#define NH_FLD_IPV6_ADDR_SIZE 16
-#define NH_FLD_IPV6_NEXT_HDR_SIZE 1
-
 /* ICMP fields */
 #define NH_FLD_ICMP_TYPE  (1)
 #define NH_FLD_ICMP_CODE  (NH_FLD_ICMP_TYPE << 1)
@@ -87,9 +75,6 @@
 #define NH_FLD_ICMP_SQ_NUM(NH_FLD_ICMP_TYPE << 4)
 #define NH_FLD_ICMP_ALL_FIELDS((NH_FLD_ICMP_TYPE << 5) - 1)
 
-#define NH_FLD_ICMP_CODE_SIZE 1
-#define NH_FLD_ICMP_TYPE_SIZE 1
-
 /* IGMP fields */
 #define NH_FLD_IGMP_VERSION   (1)
 #define NH_FLD_IGMP_TYPE  (NH_FLD_IGMP_VERSION << 1)
@@ -111,8 +96,6 @@
 #define NH_FLD_TCP_OPTS_COUNT (NH_FLD_TCP_PORT_SRC << 10)
 #define NH_FLD_TCP_ALL_FIELDS ((NH_FLD_TCP_PORT_SRC << 11) - 1)
 
-#define NH_FLD_TCP_PORT_SIZE  2
-
 /* UDP fields */
 #define NH_FLD_UDP_PORT_SRC   (1)
 #define NH_FLD_UDP_PORT_DST   (NH_FLD_UDP_PORT_SRC << 1)
@@ -120,16 +103,12 @@
 #define NH_FLD_UDP_CKSUM  (NH_FLD_UDP_PORT_SRC << 3)
 #define NH_FLD_UDP_ALL_FIELDS ((NH_FLD_UDP_PORT_SRC << 4) - 1)
 
-#define NH_FLD_UDP_PORT_SIZE  2
-
 /* UDP-lite fields */
 #define NH_FLD_UDP_LITE_PORT_SRC  (1)
 #define NH_FLD_UDP_LITE_PORT_DST  (NH_FLD_UDP_LITE_PORT_SRC << 1)
 #define NH_FLD_UDP_LITE_ALL_FIELDS \
((NH_FLD_UDP_LITE_PORT_SRC << 2) - 1)
 
-#define NH_FLD_UDP_LITE_PORT_SIZE 2
-
 /* UDP-encap-ESP fields */
 #define NH_FLD_UDP_ENC_ESP_PORT_SRC (1)
 #define NH_FLD_UDP_ENC_ESP_PORT_DST (NH_FLD_UDP_ENC_ESP_PORT_SRC << 1)
@@ -140,9 +119,6 @@
 #define NH_FLD_UDP_ENC_ESP_ALL_FIELDS \
((NH_FLD_UDP_ENC_ESP_PORT_SRC << 6) - 1)
 
-#define NH_FLD_UDP_ENC_ESP_PORT_SIZE2
-#define NH_FLD_UDP_ENC_ESP_SPI_SIZE 4
-
 /* SCTP fields */
 #define NH_FLD_SCTP_PORT_SRC  (1)
 #define NH_FLD_SCTP_PORT_DST  (NH_FLD_SCTP_PORT_SRC << 1)
@@ -150,15 +126,11 @@
 #define NH_FLD_SCTP_CKSUM (NH_FLD_SCTP_PORT_SRC << 3)
 #define NH_FLD_SCTP_ALL_FIELDS((NH_FLD_SCTP_PORT_SRC << 4) - 1)
 
-#define NH_FLD_SCTP_PORT_SIZE 2
-
 /* DCCP fields */
 #define NH_FLD_DCCP_PORT_SRC  (1)
 #define NH_FLD_DCCP_PORT_DST  (NH_FLD_DCCP_PORT_SRC << 1)
 #define NH_FLD_DCCP_ALL_FIELDS((NH_FLD_DCCP_PORT_SRC << 2) - 1)
 
-#define NH_FLD_DCCP_PORT_SIZE 2
-
 /* IPHC fields */
 #define NH_FLD_IPHC_CID   (1)
 #define NH_FLD_IPHC_CID_TYPE  (NH_FLD_IPHC_CID << 1)
@@ -324,7 +296,6 @@
 #define NH_FLD_IPSEC_ESP_SEQUENCE_NUM (NH_FLD_IPSEC_ESP_SPI << 1)
 #define NH_FLD_IPSEC_ESP_ALL_FIELDS   ((NH_FLD_IPSEC_ESP_SPI << 2) - 1)
 
-#define NH_FLD_IPSEC_ESP_SPI_SIZE 4
 
 /* MPLS fields 

[PATCH 2/2] staging: fsl-dpaa2/eth: Remove unused driver version

2018-07-27 Thread Ioana Radulescu
We never really used the driver version, so no point
in keeping it around.

Signed-off-by: Ioana Radulescu 
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 2 --
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 1 -
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c | 2 --
 3 files changed, 5 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 5dd73b1..41dd6d88 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -55,8 +55,6 @@ MODULE_LICENSE("Dual BSD/GPL");
 MODULE_AUTHOR("Freescale Semiconductor, Inc");
 MODULE_DESCRIPTION("Freescale DPAA2 Ethernet Driver");
 
-const char dpaa2_eth_drv_version[] = "0.1";
-
 static void *dpaa2_iova_to_virt(struct iommu_domain *domain,
dma_addr_t iova_addr)
 {
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
index 5589738..6cf8a4b 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
@@ -392,7 +392,6 @@ struct dpaa2_eth_priv {
 #define DPAA2_CLASSIFIER_DMA_SIZE 256
 
 extern const struct ethtool_ops dpaa2_ethtool_ops;
-extern const char dpaa2_eth_drv_version[];
 extern int dpaa2_phc_index;
 
 static inline int dpaa2_eth_cmp_dpni_ver(struct dpaa2_eth_priv *priv,
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
index 1ae779a..8a3c3da 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
@@ -82,8 +82,6 @@ static void dpaa2_eth_get_drvinfo(struct net_device *net_dev,
struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
 
strlcpy(drvinfo->driver, KBUILD_MODNAME, sizeof(drvinfo->driver));
-   strlcpy(drvinfo->version, dpaa2_eth_drv_version,
-   sizeof(drvinfo->version));
 
snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
 "%u.%u", priv->dpni_ver_major, priv->dpni_ver_minor);
-- 
2.7.4

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


[PATCH 1/2] staging: fsl-dpaa2/eth: Update default hash key

2018-07-27 Thread Ioana Radulescu
In our documentation, we claim to use a 5-tuple key for Rx hash
distribution of flows. The code however configures a key composed
of all supported header fields.

Update the Rx hash key to contain only the documented fields:
{IP src, IP dst, IP nextproto, L4 src, L4 dst}, which was the
original intention and makes most sense as a default.

Signed-off-by: Ioana Radulescu 
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 6 +++---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 5 -
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index da993ed..5dd73b1 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -2195,10 +2195,10 @@ static int bind_dpni(struct dpaa2_eth_priv *priv)
return err;
}
 
-   /* have the interface implicitly distribute traffic based on supported
-* header fields
+   /* have the interface implicitly distribute traffic based on
+* the default hash key
 */
-   err = dpaa2_eth_set_hash(net_dev, DPAA2_RXH_SUPPORTED);
+   err = dpaa2_eth_set_hash(net_dev, DPAA2_RXH_DEFAULT);
if (err)
dev_err(dev, "Failed to configure hashing\n");
 
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
index 905a4e6..5589738 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
@@ -377,11 +377,14 @@ struct dpaa2_eth_priv {
u64 rx_hash_fields;
 };
 
-/* default Rx hash options, set during probing */
 #define DPAA2_RXH_SUPPORTED(RXH_L2DA | RXH_VLAN | RXH_L3_PROTO \
| RXH_IP_SRC | RXH_IP_DST | RXH_L4_B_0_1 \
| RXH_L4_B_2_3)
 
+/* default Rx hash options, set during probing */
+#define DPAA2_RXH_DEFAULT  (RXH_L3_PROTO | RXH_IP_SRC | RXH_IP_DST | \
+RXH_L4_B_0_1 | RXH_L4_B_2_3)
+
 #define dpaa2_eth_hash_enabled(priv)   \
((priv)->dpni_attrs.num_queues > 1)
 
-- 
2.7.4

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


[PATCH] staging: fsl-dpaa2/ethsw: Fix error message

2018-07-25 Thread Ioana Radulescu
Error message was referencing wrong function, fix it.

Signed-off-by: Ioana Radulescu 
---
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
index 0d54564e..ecdd3d8 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
@@ -179,7 +179,7 @@ static int ethsw_port_set_flood(struct ethsw_port_priv 
*port_priv, u8 flag)
   port_priv->idx, flag);
if (err) {
netdev_err(port_priv->netdev,
-  "dpsw_fdb_set_learning_mode err %d\n", err);
+  "dpsw_if_set_flooding err %d\n", err);
return err;
}
port_priv->flood = !!flag;
-- 
2.7.4

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


[PATCH] staging: fsl-dpaa2/eth: Remove unnecessary cast

2018-07-12 Thread Ioana Radulescu
There's no need to explicitly cast DPAA2_ETH_MFL to u16,
so remove it.

Signed-off-by: Ioana Radulescu 
Suggested-by: Dan Carpenter 
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 4ae2371..da993ed 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -2366,7 +2366,7 @@ static int netdev_init(struct net_device *net_dev)
/* Set MTU upper limit; lower limit is 68B (default value) */
net_dev->max_mtu = DPAA2_ETH_MAX_MTU;
err = dpni_set_max_frame_length(priv->mc_io, 0, priv->mc_token,
-   (u16)DPAA2_ETH_MFL);
+   DPAA2_ETH_MFL);
if (err) {
dev_err(dev, "dpni_set_max_frame_length() failed\n");
return err;
-- 
2.7.4

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


[PATCH 1/5] staging: fsl-dpaa2/eth: Fix DMA mapping direction

2018-07-09 Thread Ioana Radulescu
We are using DMA_FROM_DEVICE when mapping RX frame buffers,
but DMA_BIDIRECTIONAL for unmap. Fix the direction for DMA
unmapping operation.

Fixes: 87eb55e418b7 ("staging: fsl-dpaa2/eth: Fix potential endless loop")

Signed-off-by: Ioana Radulescu 
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 3963717..537d5bb 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -767,7 +767,7 @@ static void free_bufs(struct dpaa2_eth_priv *priv, u64 
*buf_array, int count)
for (i = 0; i < count; i++) {
vaddr = dpaa2_iova_to_virt(priv->iommu_domain, buf_array[i]);
dma_unmap_single(dev, buf_array[i], DPAA2_ETH_RX_BUF_SIZE,
-DMA_BIDIRECTIONAL);
+DMA_FROM_DEVICE);
skb_free_frag(vaddr);
}
 }
-- 
2.7.4

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


[PATCH 5/5] staging: fsl-dpaa2/eth: Remove Rx frame size check

2018-07-09 Thread Ioana Radulescu
Most Ethernet drivers don't enforce the MTU value as upper limit
for ingress frames. We too support receiving frames larger than
MTU, so allow that.

Remove our ndo_change_mtu implementation, letting the default
stack implementation handle things. Also, set the max frame length
allowed by hardware only once at probe time, with the largest
possible value.

Signed-off-by: Ioana Radulescu 
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 26 ++
 1 file changed, 6 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 24e069c..4ae2371 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -1243,25 +1243,6 @@ static void dpaa2_eth_get_stats(struct net_device 
*net_dev,
}
 }
 
-static int dpaa2_eth_change_mtu(struct net_device *net_dev, int mtu)
-{
-   struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
-   int err;
-
-   /* Set the maximum Rx frame length to match the transmit side;
-* account for L2 headers when computing the MFL
-*/
-   err = dpni_set_max_frame_length(priv->mc_io, 0, priv->mc_token,
-   (u16)DPAA2_ETH_L2_MAX_FRM(mtu));
-   if (err) {
-   netdev_err(net_dev, "dpni_set_max_frame_length() failed\n");
-   return err;
-   }
-
-   net_dev->mtu = mtu;
-   return 0;
-}
-
 /* Copy mac unicast addresses from @net_dev to @priv.
  * Its sole purpose is to make dpaa2_eth_set_rx_mode() more readable.
  */
@@ -1469,7 +1450,6 @@ static const struct net_device_ops dpaa2_eth_ops = {
.ndo_init = dpaa2_eth_init,
.ndo_set_mac_address = dpaa2_eth_set_addr,
.ndo_get_stats64 = dpaa2_eth_get_stats,
-   .ndo_change_mtu = dpaa2_eth_change_mtu,
.ndo_set_rx_mode = dpaa2_eth_set_rx_mode,
.ndo_set_features = dpaa2_eth_set_features,
.ndo_do_ioctl = dpaa2_eth_ioctl,
@@ -2385,6 +2365,12 @@ static int netdev_init(struct net_device *net_dev)
 
/* Set MTU upper limit; lower limit is 68B (default value) */
net_dev->max_mtu = DPAA2_ETH_MAX_MTU;
+   err = dpni_set_max_frame_length(priv->mc_io, 0, priv->mc_token,
+   (u16)DPAA2_ETH_MFL);
+   if (err) {
+   dev_err(dev, "dpni_set_max_frame_length() failed\n");
+   return err;
+   }
 
/* Set actual number of queues in the net device */
num_queues = dpaa2_eth_queue_count(priv);
-- 
2.7.4

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


[PATCH 4/5] staging: fsl-dpaa2/eth: MTU cleanup

2018-07-09 Thread Ioana Radulescu
Don't set the lower MTU limit explicitly, since we use
the default value anyway.

Signed-off-by: Ioana Radulescu 
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 439b260..24e069c 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -2383,8 +2383,7 @@ static int netdev_init(struct net_device *net_dev)
return err;
}
 
-   /* Set MTU limits */
-   net_dev->min_mtu = 68;
+   /* Set MTU upper limit; lower limit is 68B (default value) */
net_dev->max_mtu = DPAA2_ETH_MAX_MTU;
 
/* Set actual number of queues in the net device */
-- 
2.7.4

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


[PATCH 0/5] staging: fsl-dpaa2/eth: Cleanup and minor fixes

2018-07-09 Thread Ioana Radulescu
One bug fix, one small functional change and a couple of
cleanup patches.

Ioana Radulescu (5):
  staging: fsl-dpaa2/eth: Fix DMA mapping direction
  staging: fsl-dpaa2/eth: Remove obsolete reference
  staging: fsl-dpaa2/eth: Remove pointless instruction
  staging: fsl-dpaa2/eth: MTU cleanup
  staging: fsl-dpaa2/eth: Remove Rx frame size check

 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 34 ++
 1 file changed, 8 insertions(+), 26 deletions(-)

-- 
2.7.4

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


[PATCH 3/5] staging: fsl-dpaa2/eth: Remove pointless instruction

2018-07-09 Thread Ioana Radulescu
We don't need to call dev_set_drvdata(dev, NULL) on driver
remove since core kernel code also performs this step.

Signed-off-by: Ioana Radulescu 
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 6331e8d..439b260 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -2676,7 +2676,6 @@ static int dpaa2_eth_remove(struct fsl_mc_device *ls_dev)
 
fsl_mc_portal_free(priv->mc_io);
 
-   dev_set_drvdata(dev, NULL);
free_netdev(net_dev);
 
dev_dbg(net_dev->dev.parent, "Removed interface %s\n", net_dev->name);
-- 
2.7.4

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


[PATCH 2/5] staging: fsl-dpaa2/eth: Remove obsolete reference

2018-07-09 Thread Ioana Radulescu
Commit 2b7c86eb7bf3 ("staging: fsl-dpaa2/eth: Don't enable FAS on Tx")
removed the status field from the TX confirm frame annotation,
but a reference to it remained in the description of free_tx_fd().
Remove it.

Signed-off-by: Ioana Radulescu 
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 537d5bb..6331e8d 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -522,8 +522,6 @@ static int build_single_fd(struct dpaa2_eth_priv *priv,
  * back-pointed to is also freed.
  * This can be called either from dpaa2_eth_tx_conf() or on the error path of
  * dpaa2_eth_tx().
- * Optionally, return the frame annotation status word (FAS), which needs
- * to be checked if we're on the confirmation path.
  */
 static void free_tx_fd(const struct dpaa2_eth_priv *priv,
   const struct dpaa2_fd *fd)
-- 
2.7.4

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


[PATCH] staging: fsl-dpaa2/eth: Use debug level for message

2018-03-23 Thread Ioana Radulescu
The driver remove() function prints a message when the operation
is completed. Make this a debug level message to avoid polluting
the kernel log wih too much information.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 14bd8fe..553678d 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -2578,7 +2578,7 @@ static int dpaa2_eth_remove(struct fsl_mc_device *ls_dev)
dev_set_drvdata(dev, NULL);
free_netdev(net_dev);
 
-   dev_info(net_dev->dev.parent, "Removed interface %s\n", net_dev->name);
+   dev_dbg(net_dev->dev.parent, "Removed interface %s\n", net_dev->name);
 
return 0;
 }
-- 
2.7.4

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


[PATCH 7/9] staging: fsl-dpaa2/eth: Cleanup TX frame freeing code

2018-03-23 Thread Ioana Radulescu
Cleanup code in free_tx_fd() that deals with S/G frames:
- remove local variables that aren't really needed
- in the frame sw annotation area, store the actual SG table
buffer size, which is needed on free, rather then recompute
it based on number of S/G entries

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 17 +
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h |  2 +-
 2 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index f58c85a..9994922 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -406,7 +406,7 @@ static int build_sg_fd(struct dpaa2_eth_priv *priv,
swa->skb = skb;
swa->scl = scl;
swa->num_sg = num_sg;
-   swa->num_dma_bufs = num_dma_bufs;
+   swa->sgt_size = sgt_buf_size;
 
/* Separately map the SGT buffer */
addr = dma_map_single(dev, sgt_buf, sgt_buf_size, DMA_BIDIRECTIONAL);
@@ -489,9 +489,6 @@ static void free_tx_fd(const struct dpaa2_eth_priv *priv,
dma_addr_t fd_addr;
struct sk_buff **skbh, *skb;
unsigned char *buffer_start;
-   int unmap_size;
-   struct scatterlist *scl;
-   int num_sg, num_dma_bufs;
struct dpaa2_eth_swa *swa;
u8 fd_format = dpaa2_fd_get_format(fd);
 
@@ -510,18 +507,14 @@ static void free_tx_fd(const struct dpaa2_eth_priv *priv,
} else if (fd_format == dpaa2_fd_sg) {
swa = (struct dpaa2_eth_swa *)skbh;
skb = swa->skb;
-   scl = swa->scl;
-   num_sg = swa->num_sg;
-   num_dma_bufs = swa->num_dma_bufs;
 
/* Unmap the scatterlist */
-   dma_unmap_sg(dev, scl, num_sg, DMA_BIDIRECTIONAL);
-   kfree(scl);
+   dma_unmap_sg(dev, swa->scl, swa->num_sg, DMA_BIDIRECTIONAL);
+   kfree(swa->scl);
 
/* Unmap the SGT buffer */
-   unmap_size = priv->tx_data_offset +
-  sizeof(struct dpaa2_sg_entry) * (1 + num_dma_bufs);
-   dma_unmap_single(dev, fd_addr, unmap_size, DMA_BIDIRECTIONAL);
+   dma_unmap_single(dev, fd_addr, swa->sgt_size,
+DMA_BIDIRECTIONAL);
} else {
netdev_dbg(priv->net_dev, "Invalid FD format\n");
return;
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
index 5ac014f..fc9a255 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
@@ -108,7 +108,7 @@ struct dpaa2_eth_swa {
struct sk_buff *skb;
struct scatterlist *scl;
int num_sg;
-   int num_dma_bufs;
+   int sgt_size;
 };
 
 /* Annotation valid bits in FD FRC */
-- 
2.7.4

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


[PATCH 8/9] staging: fsl-dpaa2/eth: Fix SGT allocation

2018-03-23 Thread Ioana Radulescu
We mistakenly allocate space for too many entries in the
scatter-gather table of multi buffer egress frames.

While it doesn't have a negative impact from a functional
point of view, it wastes resources so fix it.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 9994922..14bd8fe 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -373,7 +373,7 @@ static int build_sg_fd(struct dpaa2_eth_priv *priv,
 
/* Prepare the HW SGT structure */
sgt_buf_size = priv->tx_data_offset +
-  sizeof(struct dpaa2_sg_entry) * (1 + num_dma_bufs);
+  sizeof(struct dpaa2_sg_entry) *  num_dma_bufs;
sgt_buf = netdev_alloc_frag(sgt_buf_size + DPAA2_ETH_TX_BUF_ALIGN);
if (unlikely(!sgt_buf)) {
err = -ENOMEM;
-- 
2.7.4

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


[PATCH 9/9] staging: fsl-dpaa2/eth: Change max number of Tx queues

2018-03-23 Thread Ioana Radulescu
We use DPAA2_ETH_MAX_TX_QUEUES to dimension the array holding
information on Tx queues. At most, we can have one queue per cpu.

Until now we used the NR_CPUS macro to set the upper limit on number
of Tx queues. However, the platforms that the DPAA2 Ethernet driver
supports have at most 16 cores, whereas NR_CPUS is Kconfigurable and
can be much higher.

Avoid allocating memory we'll never use, by setting
DPAA2_ETH_MAX_TX_QUEUES to 16. Same for DPAA2_ETH_MAX_DPCONS.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
index fc9a255..54cea2f 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
@@ -251,11 +251,11 @@ struct dpaa2_eth_ch_stats {
 
 /* Maximum number of queues associated with a DPNI */
 #define DPAA2_ETH_MAX_RX_QUEUES16
-#define DPAA2_ETH_MAX_TX_QUEUESNR_CPUS
+#define DPAA2_ETH_MAX_TX_QUEUES16
 #define DPAA2_ETH_MAX_QUEUES   (DPAA2_ETH_MAX_RX_QUEUES + \
DPAA2_ETH_MAX_TX_QUEUES)
 
-#define DPAA2_ETH_MAX_DPCONS   NR_CPUS
+#define DPAA2_ETH_MAX_DPCONS   16
 
 enum dpaa2_eth_fq_type {
DPAA2_RX_FQ = 0,
-- 
2.7.4

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


[PATCH 6/9] staging: fsl-dpaa2/eth: Change link settings on the fly

2018-03-23 Thread Ioana Radulescu
Newer MC versions allow us to change link settings while the
interface is up. Only check interface status if we are using
an old version.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
index dfbfa94..bfc8b64 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
@@ -119,6 +119,8 @@ dpaa2_eth_get_link_ksettings(struct net_device *net_dev,
return err;
 }
 
+#define DPNI_DYNAMIC_LINK_SET_VER_MAJOR7
+#define DPNI_DYNAMIC_LINK_SET_VER_MINOR1
 static int
 dpaa2_eth_set_link_ksettings(struct net_device *net_dev,
 const struct ethtool_link_ksettings *link_settings)
@@ -127,15 +129,16 @@ dpaa2_eth_set_link_ksettings(struct net_device *net_dev,
struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
int err = 0;
 
-   netdev_dbg(net_dev, "Setting link parameters...");
-
-   /* Due to a temporary MC limitation, the DPNI must be down
+   /* If using an older MC version, the DPNI must be down
 * in order to be able to change link settings. Taking steps to let
 * the user know that.
 */
-   if (netif_running(net_dev)) {
-   netdev_info(net_dev, "Sorry, interface must be brought down 
first.\n");
-   return -EACCES;
+   if (dpaa2_eth_cmp_dpni_ver(priv, DPNI_DYNAMIC_LINK_SET_VER_MAJOR,
+  DPNI_DYNAMIC_LINK_SET_VER_MINOR) < 0) {
+   if (netif_running(net_dev)) {
+   netdev_info(net_dev, "Interface must be brought down 
first.\n");
+   return -EACCES;
+   }
}
 
cfg.rate = link_settings->base.speed;
-- 
2.7.4

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


[PATCH 3/9] staging: fsl-dpaa2/eth: Remove unused field

2018-03-23 Thread Ioana Radulescu
Remove dpio_id field in struct dpaa2_eth_channel, which wasn't
used anywhere in the code.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
index b8990cf..63ea64b 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
@@ -285,7 +285,6 @@ struct dpaa2_eth_channel {
struct fsl_mc_device *dpcon;
int dpcon_id;
int ch_id;
-   int dpio_id;
struct napi_struct napi;
struct dpaa2_io *dpio;
struct dpaa2_io_store *store;
-- 
2.7.4

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


[PATCH 5/9] staging: fsl-dpaa2/eth: Add DPNI version check

2018-03-23 Thread Ioana Radulescu
The DPAA2 Ethernet driver assumes the DPNI objects that it
uses to build network interfaces have a minimum supported
API version, but until now it did nothing to enforce this
requirement.

Add a check at probe time to make sure the DPNI object is
compatible with the set of MC commands we intend to use
on it.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 15 +++
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 10 ++
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c | 11 ++-
 3 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 9fb88f2..f58c85a 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -1846,6 +1846,21 @@ static int setup_dpni(struct fsl_mc_device *ls_dev)
return err;
}
 
+   /* Check if we can work with this DPNI object */
+   err = dpni_get_api_version(priv->mc_io, 0, >dpni_ver_major,
+  >dpni_ver_minor);
+   if (err) {
+   dev_err(dev, "dpni_get_api_version() failed\n");
+   goto close;
+   }
+   if (dpaa2_eth_cmp_dpni_ver(priv, DPNI_VER_MAJOR, DPNI_VER_MINOR) < 0) {
+   dev_err(dev, "DPNI version %u.%u not supported, need >= 
%u.%u\n",
+   priv->dpni_ver_major, priv->dpni_ver_minor,
+   DPNI_VER_MAJOR, DPNI_VER_MINOR);
+   err = -ENOTSUPP;
+   goto close;
+   }
+
ls_dev->mc_io = priv->mc_io;
ls_dev->mc_handle = priv->mc_token;
 
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
index c4816e6..5ac014f 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
@@ -311,6 +311,8 @@ struct dpaa2_eth_priv {
struct dpaa2_eth_channel *channel[DPAA2_ETH_MAX_DPCONS];
 
struct dpni_attr dpni_attrs;
+   u16 dpni_ver_major;
+   u16 dpni_ver_minor;
u16 tx_data_offset;
 
struct fsl_mc_device *dpbp_dev;
@@ -354,6 +356,14 @@ struct dpaa2_eth_priv {
 extern const struct ethtool_ops dpaa2_ethtool_ops;
 extern const char dpaa2_eth_drv_version[];
 
+static inline int dpaa2_eth_cmp_dpni_ver(struct dpaa2_eth_priv *priv,
+u16 ver_major, u16 ver_minor)
+{
+   if (priv->dpni_ver_major == ver_major)
+   return priv->dpni_ver_minor - ver_minor;
+   return priv->dpni_ver_major - ver_major;
+}
+
 /* Hardware only sees DPAA2_ETH_RX_BUF_SIZE, but the skb built around
  * the buffer also needs space for its shared info struct, and we need
  * to allocate enough to accommodate hardware alignment restrictions
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
index 070a3f2..dfbfa94 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
@@ -78,20 +78,13 @@ static void dpaa2_eth_get_drvinfo(struct net_device 
*net_dev,
  struct ethtool_drvinfo *drvinfo)
 {
struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
-   u16 fw_major, fw_minor;
-   int err;
 
strlcpy(drvinfo->driver, KBUILD_MODNAME, sizeof(drvinfo->driver));
strlcpy(drvinfo->version, dpaa2_eth_drv_version,
sizeof(drvinfo->version));
 
-   err =  dpni_get_api_version(priv->mc_io, 0, _major, _minor);
-   if (!err)
-   snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
-"%u.%u", fw_major, fw_minor);
-   else
-   strlcpy(drvinfo->fw_version, "N/A",
-   sizeof(drvinfo->fw_version));
+   snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
+"%u.%u", priv->dpni_ver_major, priv->dpni_ver_minor);
 
strlcpy(drvinfo->bus_info, dev_name(net_dev->dev.parent->parent),
sizeof(drvinfo->bus_info));
-- 
2.7.4

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


[PATCH 4/9] staging: fsl-dpaa2/eth: Remove packed attribute

2018-03-23 Thread Ioana Radulescu
Structure dpaa2_fas is naturally aligned, so no need to use
the __packed attribute explicitly.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
index 63ea64b..c4816e6 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
@@ -142,7 +142,7 @@ struct dpaa2_fas {
u8 ppid;
__le16 ifpid;
__le32 status;
-} __packed;
+};
 
 /* Frame annotation status word is located in the first 8 bytes
  * of the buffer's hardware annoatation area
-- 
2.7.4

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


[PATCH 1/9] staging: fsl-dpaa2/eth: Use generic irq handler

2018-03-23 Thread Ioana Radulescu
For the link state interrupt, we used a dummy non-threaded
irq handler, which had the same implementation as the generic
irq_default_primary_handler() function.

Give up on using our own irq handler and let the kernel use
the generic one instead.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index ac1a750..beb5959 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -2317,11 +2317,6 @@ static int poll_link_state(void *arg)
return 0;
 }
 
-static irqreturn_t dpni_irq0_handler(int irq_num, void *arg)
-{
-   return IRQ_WAKE_THREAD;
-}
-
 static irqreturn_t dpni_irq0_handler_thread(int irq_num, void *arg)
 {
u32 status = ~0;
@@ -2356,8 +2351,7 @@ static int setup_irqs(struct fsl_mc_device *ls_dev)
 
irq = ls_dev->irqs[0];
err = devm_request_threaded_irq(_dev->dev, irq->msi_desc->irq,
-   dpni_irq0_handler,
-   dpni_irq0_handler_thread,
+   NULL, dpni_irq0_handler_thread,
IRQF_NO_SUSPEND | IRQF_ONESHOT,
dev_name(_dev->dev), _dev->dev);
if (err < 0) {
-- 
2.7.4

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


[PATCH 0/9] staging: fsl-dpaa2/eth: Cleanup

2018-03-23 Thread Ioana Radulescu
A set of cleanup patches with limited functional impact.

Ioana Radulescu (9):
  staging: fsl-dpaa2/eth: Use generic irq handler
  staging: fsl-dpaa2/eth: Move print message
  staging: fsl-dpaa2/eth: Remove unused field
  staging: fsl-dpaa2/eth: Remove packed attribute
  staging: fsl-dpaa2/eth: Add DPNI version check
  staging: fsl-dpaa2/eth: Change link settings on the fly
  staging: fsl-dpaa2/eth: Cleanup TX frame freeing code
  staging: fsl-dpaa2/eth: Fix SGT allocation
  staging: fsl-dpaa2/eth: Change max number of Tx queues

 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 47 --
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 11 ++---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c | 31 +++---
 3 files changed, 46 insertions(+), 43 deletions(-)

-- 
2.7.4

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


[PATCH 2/9] staging: fsl-dpaa2/eth: Move print message

2018-03-23 Thread Ioana Radulescu
Let the driver remove() function print an informative message
after it finishes removing the network interface, not at an
arbitrary point during cleanup.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index beb5959..9fb88f2 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -2550,7 +2550,6 @@ static int dpaa2_eth_remove(struct fsl_mc_device *ls_dev)
priv = netdev_priv(net_dev);
 
unregister_netdev(net_dev);
-   dev_info(net_dev->dev.parent, "Removed interface %s\n", net_dev->name);
 
if (priv->do_link_poll)
kthread_stop(priv->poll_thread);
@@ -2571,6 +2570,8 @@ static int dpaa2_eth_remove(struct fsl_mc_device *ls_dev)
dev_set_drvdata(dev, NULL);
free_netdev(net_dev);
 
+   dev_info(net_dev->dev.parent, "Removed interface %s\n", net_dev->name);
+
return 0;
 }
 
-- 
2.7.4

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


[PATCH v2] staging: fsl-dpaa2/eth: Defer probing if no MC portal available

2018-03-20 Thread Ioana Radulescu
MC portals may not be available at the initial probing attempt
due to dependencies on other modules.

Check the return value of the MC portal allocation function and
defer probing in case it's not available yet. For all other error
cases the behaviour stays the same.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
Suggested-by: Nipun Gupta <nipun.gu...@nxp.com>
---
v2: rebase on latest driver code

 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index f013af6..ac1a750 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -2441,7 +2441,10 @@ static int dpaa2_eth_probe(struct fsl_mc_device 
*dpni_dev)
err = fsl_mc_portal_allocate(dpni_dev, FSL_MC_IO_ATOMIC_CONTEXT_PORTAL,
 >mc_io);
if (err) {
-   dev_err(dev, "MC portal allocation failed\n");
+   if (err == -ENXIO)
+   err = -EPROBE_DEFER;
+   else
+   dev_err(dev, "MC portal allocation failed\n");
goto err_portal_alloc;
}
 
-- 
2.7.4

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


[PATCH] staging: fsl-dpaa2/eth: Fix incorrect kfree

2018-03-14 Thread Ioana Radulescu
Use netdev_alloc_frag() instead of kmalloc to allocate space for
the S/G table of egress multi-buffer frames.

This fixes a bug where an unaligned pointer received from the
allocator would be overwritten with the 64B aligned value,
leading to a wrong address being later passed to kfree.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
Reported-by: Dan Carpenter <dan.carpen...@oracle.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index c81a01f..f013af6 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -374,12 +374,14 @@ static int build_sg_fd(struct dpaa2_eth_priv *priv,
/* Prepare the HW SGT structure */
sgt_buf_size = priv->tx_data_offset +
   sizeof(struct dpaa2_sg_entry) * (1 + num_dma_bufs);
-   sgt_buf = kzalloc(sgt_buf_size + DPAA2_ETH_TX_BUF_ALIGN, GFP_ATOMIC);
+   sgt_buf = netdev_alloc_frag(sgt_buf_size + DPAA2_ETH_TX_BUF_ALIGN);
if (unlikely(!sgt_buf)) {
err = -ENOMEM;
goto sgt_buf_alloc_failed;
}
sgt_buf = PTR_ALIGN(sgt_buf, DPAA2_ETH_TX_BUF_ALIGN);
+   memset(sgt_buf, 0, sgt_buf_size);
+
sgt = (struct dpaa2_sg_entry *)(sgt_buf + priv->tx_data_offset);
 
/* Fill in the HW SGT structure.
@@ -421,7 +423,7 @@ static int build_sg_fd(struct dpaa2_eth_priv *priv,
return 0;
 
 dma_map_single_failed:
-   kfree(sgt_buf);
+   skb_free_frag(sgt_buf);
 sgt_buf_alloc_failed:
dma_unmap_sg(dev, scl, num_sg, DMA_BIDIRECTIONAL);
 dma_map_sg_failed:
@@ -525,9 +527,9 @@ static void free_tx_fd(const struct dpaa2_eth_priv *priv,
return;
}
 
-   /* Free SGT buffer kmalloc'ed on tx */
+   /* Free SGT buffer allocated on tx */
if (fd_format != dpaa2_fd_single)
-   kfree(skbh);
+   skb_free_frag(skbh);
 
/* Move on with skb release */
dev_kfree_skb(skb);
-- 
2.7.4

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


[PATCH v2 2/2] staging: fsl-dpaa2/eth: allow the driver to compile multi-arch

2018-03-09 Thread Ioana Radulescu
Drop dependency on ARCH_LAYERSCAPE (which in turn depends on ARM64),
thus allowing this driver to compile on all architectures supported
by the fsl-mc bus driver.

This was compile tested on:
 - powerpc (corenet_basic_defconfig, ppc64_defconfig)
 - x86 (i386_defconfig, x86_64_defconfig, needs CONFIG_OF)
 - arm64 (defconfig)

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
v2: no change

 drivers/staging/fsl-dpaa2/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/fsl-dpaa2/Kconfig 
b/drivers/staging/fsl-dpaa2/Kconfig
index dfff675..730fd6d 100644
--- a/drivers/staging/fsl-dpaa2/Kconfig
+++ b/drivers/staging/fsl-dpaa2/Kconfig
@@ -4,7 +4,7 @@
 
 config FSL_DPAA2
bool "Freescale DPAA2 devices"
-   depends on FSL_MC_BUS && ARCH_LAYERSCAPE
+   depends on FSL_MC_BUS
---help---
  Build drivers for Freescale DataPath Acceleration
  Architecture (DPAA2) family of SoCs.
-- 
2.7.4

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


[PATCH v2 1/2] staging: fsl-dpaa2/eth: Use __leXX types where needed

2018-03-09 Thread Ioana Radulescu
One MC command structure got away with using uXX fields instead
of __leXX. Fix it.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
v2: new patch

 drivers/staging/fsl-dpaa2/ethernet/dpni-cmd.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpni-cmd.h 
b/drivers/staging/fsl-dpaa2/ethernet/dpni-cmd.h
index 3120e22..d6f96f302 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpni-cmd.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpni-cmd.h
@@ -539,8 +539,8 @@ struct dpni_rsp_get_taildrop {
 };
 
 struct dpni_rsp_get_api_version {
-   u16 major;
-   u16 minor;
+   __le16 major;
+   __le16 minor;
 };
 
 #endif /* _FSL_DPNI_CMD_H */
-- 
2.7.4

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


[PATCH v2 0/2] fsl-dpaa2/eth: Enable multi-arch compile

2018-03-09 Thread Ioana Radulescu
The Ethernet driver can be built on multiple architectures, so
remove the ARCH_LAYERSCAPE dependency from its Kconfig.

This patchset is marked as v2 because it includes the final patch
from this set: https://lkml.org/lkml/2018/2/26/626, preceeded by
a patch fixing a sparse warning when building on x86_64.

Ioana Radulescu (2):
  staging: fsl-dpaa2/eth: Use __leXX types where needed
  staging: fsl-dpaa2/eth: allow the driver to compile multi-arch

 drivers/staging/fsl-dpaa2/Kconfig | 2 +-
 drivers/staging/fsl-dpaa2/ethernet/dpni-cmd.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

-- 
2.7.4

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


[PATCH 5/5] staging: fsl-mc/dpio: Remove dead code

2018-03-06 Thread Ioana Radulescu
Function qbman_pull_desc_set_token() is not used at all, so remove it.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-mc/bus/dpio/qbman-portal.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c 
b/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
index 7e55b56..116fafb 100644
--- a/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
+++ b/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
@@ -522,11 +522,6 @@ void qbman_pull_desc_set_numframes(struct qbman_pull_desc 
*d, u8 numframes)
d->numf = numframes - 1;
 }
 
-static void qbman_pull_desc_set_token(struct qbman_pull_desc *d, u8 token)
-{
-   d->tok = token;
-}
-
 /*
  * Exactly one of the following descriptor "actions" should be set. (Calling 
any
  * one of these will replace the effect of any prior call to one of these.)
-- 
2.7.4

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


[PATCH 4/5] staging: fsl-mc/dpio: Fix incorrect masking

2018-03-06 Thread Ioana Radulescu
In qbman_swp_alt_fq_state(), we need to mask the fqid value
before converting it to little endian, otherwise we write a
wrong value to hardware when running in big endian mode.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-mc/bus/dpio/qbman-portal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c 
b/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
index 377f4d9..7e55b56 100644
--- a/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
+++ b/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
@@ -927,7 +927,7 @@ int qbman_swp_alt_fq_state(struct qbman_swp *s, u32 fqid,
if (!p)
return -EBUSY;
 
-   p->fqid = cpu_to_le32(fqid) & ALT_FQ_FQID_MASK;
+   p->fqid = cpu_to_le32(fqid & ALT_FQ_FQID_MASK);
 
/* Complete the management command */
r = qbman_swp_mc_complete(s, p, alt_fq_verb);
-- 
2.7.4

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


[PATCH 3/5] staging: fsl-mc/dpio: Use __leXX types where needed

2018-03-06 Thread Ioana Radulescu
Structures that are mapped to hardware registers should explicitly
specify the expected endianness for fields larger than 1 byte.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-mc/bus/dpio/qbman-portal.c | 16 
 drivers/staging/fsl-mc/bus/dpio/qbman-portal.h | 24 
 2 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c 
b/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
index 7b75c93..377f4d9 100644
--- a/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
+++ b/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
@@ -830,7 +830,7 @@ int qbman_swp_release(struct qbman_swp *s, const struct 
qbman_release_desc *d,
 struct qbman_acquire_desc {
u8 verb;
u8 reserved;
-   u16 bpid;
+   __le16 bpid;
u8 num;
u8 reserved2[59];
 };
@@ -838,10 +838,10 @@ struct qbman_acquire_desc {
 struct qbman_acquire_rslt {
u8 verb;
u8 rslt;
-   u16 reserved;
+   __le16 reserved;
u8 num;
u8 reserved2[3];
-   u64 buf[7];
+   __le64 buf[7];
 };
 
 /**
@@ -904,7 +904,7 @@ int qbman_swp_acquire(struct qbman_swp *s, u16 bpid, u64 
*buffers,
 struct qbman_alt_fq_state_desc {
u8 verb;
u8 reserved[3];
-   u32 fqid;
+   __le32 fqid;
u8 reserved2[56];
 };
 
@@ -953,11 +953,11 @@ int qbman_swp_alt_fq_state(struct qbman_swp *s, u32 fqid,
 struct qbman_cdan_ctrl_desc {
u8 verb;
u8 reserved;
-   u16 ch;
+   __le16 ch;
u8 we;
u8 ctrl;
-   u16 reserved2;
-   u64 cdan_ctx;
+   __le16 reserved2;
+   __le64 cdan_ctx;
u8 reserved3[48];
 
 };
@@ -965,7 +965,7 @@ struct qbman_cdan_ctrl_desc {
 struct qbman_cdan_ctrl_rslt {
u8 verb;
u8 rslt;
-   u16 ch;
+   __le16 ch;
u8 reserved[60];
 };
 
diff --git a/drivers/staging/fsl-mc/bus/dpio/qbman-portal.h 
b/drivers/staging/fsl-mc/bus/dpio/qbman-portal.h
index fb8b9d3..4488a44 100644
--- a/drivers/staging/fsl-mc/bus/dpio/qbman-portal.h
+++ b/drivers/staging/fsl-mc/bus/dpio/qbman-portal.h
@@ -32,8 +32,8 @@ struct qbman_pull_desc {
u8 numf;
u8 tok;
u8 reserved;
-   u32 dq_src;
-   u64 rsp_addr;
+   __le32 dq_src;
+   __le64 rsp_addr;
u64 rsp_addr_virt;
u8 padding[40];
 };
@@ -70,17 +70,17 @@ enum qbman_pull_type_e {
 struct qbman_eq_desc {
u8 verb;
u8 dca;
-   u16 seqnum;
-   u16 orpid;
-   u16 reserved1;
-   u32 tgtid;
-   u32 tag;
-   u16 qdbin;
+   __le16 seqnum;
+   __le16 orpid;
+   __le16 reserved1;
+   __le32 tgtid;
+   __le32 tag;
+   __le16 qdbin;
u8 qpri;
u8 reserved[3];
u8 wae;
u8 rspid;
-   u64 rsp_addr;
+   __le64 rsp_addr;
u8 fd[32];
 };
 
@@ -88,9 +88,9 @@ struct qbman_eq_desc {
 struct qbman_release_desc {
u8 verb;
u8 reserved;
-   u16 bpid;
-   u32 reserved2;
-   u64 buf[7];
+   __le16 bpid;
+   __le32 reserved2;
+   __le64 buf[7];
 };
 
 /* Management command result codes */
-- 
2.7.4

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


[PATCH 2/5] staging: fsl-mc/dpio: Fix cast truncate warning

2018-03-06 Thread Ioana Radulescu
Sparse reports the following warning:
drivers/staging/fsl-mc/include/dpaa2-fd.h:421:30:
warning: cast truncates bits from constant value (7fff becomes 7fff)

Fix this by explicitly masking the value with 0x.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-mc/include/dpaa2-fd.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/fsl-mc/include/dpaa2-fd.h 
b/drivers/staging/fsl-mc/include/dpaa2-fd.h
index 70501d7..b55b89b 100644
--- a/drivers/staging/fsl-mc/include/dpaa2-fd.h
+++ b/drivers/staging/fsl-mc/include/dpaa2-fd.h
@@ -418,8 +418,8 @@ static inline bool dpaa2_sg_is_final(const struct 
dpaa2_sg_entry *sg)
  */
 static inline void dpaa2_sg_set_final(struct dpaa2_sg_entry *sg, bool final)
 {
-   sg->format_offset &= cpu_to_le16(~(SG_FINAL_FLAG_MASK
-<< SG_FINAL_FLAG_SHIFT));
+   sg->format_offset &= cpu_to_le16((~(SG_FINAL_FLAG_MASK
+<< SG_FINAL_FLAG_SHIFT)) & 0x);
sg->format_offset |= cpu_to_le16(final << SG_FINAL_FLAG_SHIFT);
 }
 
-- 
2.7.4

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


[PATCH 1/5] staging: fsl-mc/dpio: Fix incorrect cast

2018-03-06 Thread Ioana Radulescu
Move the cast in dpaa2_sg_get_addr() to the right place.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-mc/include/dpaa2-fd.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/fsl-mc/include/dpaa2-fd.h 
b/drivers/staging/fsl-mc/include/dpaa2-fd.h
index 3e02200..70501d7 100644
--- a/drivers/staging/fsl-mc/include/dpaa2-fd.h
+++ b/drivers/staging/fsl-mc/include/dpaa2-fd.h
@@ -287,7 +287,7 @@ enum dpaa2_sg_format {
  */
 static inline dma_addr_t dpaa2_sg_get_addr(const struct dpaa2_sg_entry *sg)
 {
-   return le64_to_cpu((dma_addr_t)sg->addr);
+   return (dma_addr_t)le64_to_cpu(sg->addr);
 }
 
 /**
-- 
2.7.4

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


[PATCH 0/5] staging: fsl-mc/dpio: Fix sparse warnings

2018-03-06 Thread Ioana Radulescu
Some code cleanup and bug fixes based on warnings reported by sparse
when building on x86.

Ioana Radulescu (5):
  staging: fsl-mc/dpio: Fix incorrect cast
  staging: fsl-mc/dpio: Fix cast truncate warning
  staging: fsl-mc/dpio: Use __leXX types where needed
  staging: fsl-mc/dpio: Fix incorrect masking
  staging: fsl-dpaa2/dpio: Remove dead code

 drivers/staging/fsl-mc/bus/dpio/qbman-portal.c | 23 +--
 drivers/staging/fsl-mc/bus/dpio/qbman-portal.h | 24 
 drivers/staging/fsl-mc/include/dpaa2-fd.h  |  6 +++---
 3 files changed, 24 insertions(+), 29 deletions(-)

-- 
2.7.4

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


[PATCH 3/4] staging: fsl-dpaa2/eth: Fix incorrect casts

2018-02-26 Thread Ioana Radulescu
The DPAA2 Ethernet driver incorrectly assumes virtual addresses
are always 64b long, which causes compiler errors when building
for a 32b platform.

Fix this by using explicit casts to uintptr_t where necessary.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index dc7be538..c81a01f 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -324,7 +324,7 @@ static int consume_frames(struct dpaa2_eth_channel *ch)
}
 
fd = dpaa2_dq_fd(dq);
-   fq = (struct dpaa2_eth_fq *)dpaa2_dq_fqd_ctx(dq);
+   fq = (struct dpaa2_eth_fq *)(uintptr_t)dpaa2_dq_fqd_ctx(dq);
fq->stats.frames++;
 
fq->consume(priv, ch, fd, >napi, fq->flowid);
@@ -1905,7 +1905,7 @@ static int setup_rx_flow(struct dpaa2_eth_priv *priv,
queue.destination.id = fq->channel->dpcon_id;
queue.destination.type = DPNI_DEST_DPCON;
queue.destination.priority = 1;
-   queue.user_context = (u64)fq;
+   queue.user_context = (u64)(uintptr_t)fq;
err = dpni_set_queue(priv->mc_io, 0, priv->mc_token,
 DPNI_QUEUE_RX, 0, fq->flowid,
 DPNI_QUEUE_OPT_USER_CTX | DPNI_QUEUE_OPT_DEST,
@@ -1957,7 +1957,7 @@ static int setup_tx_flow(struct dpaa2_eth_priv *priv,
queue.destination.id = fq->channel->dpcon_id;
queue.destination.type = DPNI_DEST_DPCON;
queue.destination.priority = 0;
-   queue.user_context = (u64)fq;
+   queue.user_context = (u64)(uintptr_t)fq;
err = dpni_set_queue(priv->mc_io, 0, priv->mc_token,
 DPNI_QUEUE_TX_CONFIRM, 0, fq->flowid,
 DPNI_QUEUE_OPT_USER_CTX | DPNI_QUEUE_OPT_DEST,
-- 
2.7.4

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


[PATCH 0/4] staging: fsl-mc/dpio, fsl-dpaa2/eth: Enable multi-arch compile

2018-02-26 Thread Ioana Radulescu
The DPAA2 DPIO and Ethernet drivers need only a couple of small
fixes in order to compile correctly for 32b platforms.

Update the drivers and remove ARCH_LAYERSCAPE from their Kconfig
dependencies.

Ioana Radulescu (4):
  staging: fsl-mc/dpio: Fix incorrect casts
  staging: fsl-mc/dpio: allow the driver to compile multi-arch
  staging: fsl-dpaa2/eth: Fix incorrect casts
  staging: fsl-dpaa2/eth: allow the driver to compile multi-arch

 drivers/staging/fsl-dpaa2/Kconfig  | 2 +-
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 6 +++---
 drivers/staging/fsl-mc/bus/Kconfig | 2 +-
 drivers/staging/fsl-mc/bus/dpio/dpio-service.c | 4 ++--
 drivers/staging/fsl-mc/bus/dpio/qbman-portal.c | 4 ++--
 5 files changed, 9 insertions(+), 9 deletions(-)

-- 
2.7.4

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


[PATCH 2/4] staging: fsl-mc/dpio: allow the driver to compile multi-arch

2018-02-26 Thread Ioana Radulescu
Drop dependency on ARCH_LAYERSCAPE (which in turn depends on ARM64),
thus allowing this driver to compile on all architectures supported
by the fsl-mc bus driver.

This was compile tested on:
 - powerpc (corenet_basic_defconfig, ppc64_defconfig)
 - x86 (i386_defconfig, x86_64_defconfig, needs CONFIG_OF)
 - arm64 (defconfig)

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-mc/bus/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/fsl-mc/bus/Kconfig 
b/drivers/staging/fsl-mc/bus/Kconfig
index 5f4115d..3424530 100644
--- a/drivers/staging/fsl-mc/bus/Kconfig
+++ b/drivers/staging/fsl-mc/bus/Kconfig
@@ -7,7 +7,7 @@
 
 config FSL_MC_DPIO
 tristate "QorIQ DPAA2 DPIO driver"
-depends on FSL_MC_BUS && ARCH_LAYERSCAPE
+depends on FSL_MC_BUS
 help
  Driver for the DPAA2 DPIO object.  A DPIO provides queue and
  buffer management facilities for software to interact with
-- 
2.7.4

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


[PATCH 1/4] staging: fsl-mc/dpio: Fix incorrect casts

2018-02-26 Thread Ioana Radulescu
The DPIO driver incorrectly assumes virtual addresses are always
64b long, which causes compiler errors when building for a 32b
platform.

Fix this by using explicit casts to uintptr_t where necessary.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-mc/bus/dpio/dpio-service.c | 4 ++--
 drivers/staging/fsl-mc/bus/dpio/qbman-portal.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c 
b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
index 1acff7e..14ed2be 100644
--- a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
+++ b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
@@ -192,7 +192,7 @@ irqreturn_t dpaa2_io_irq(struct dpaa2_io *obj)
u64 q64;
 
q64 = qbman_result_SCN_ctx(dq);
-   ctx = (void *)q64;
+   ctx = (void *)(uintptr_t)q64;
ctx->cb(ctx);
} else {
pr_crit("fsl-mc-dpio: Unrecognised/ignored DQRR 
entry\n");
@@ -237,7 +237,7 @@ int dpaa2_io_service_register(struct dpaa2_io *d,
return -ENODEV;
 
ctx->dpio_id = d->dpio_desc.dpio_id;
-   ctx->qman64 = (u64)ctx;
+   ctx->qman64 = (u64)(uintptr_t)ctx;
ctx->dpio_private = d;
spin_lock_irqsave(>lock_notifications, irqflags);
list_add(>node, >notifications);
diff --git a/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c 
b/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
index 376e9ed..f57c151 100644
--- a/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
+++ b/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
@@ -497,7 +497,7 @@ void qbman_pull_desc_set_storage(struct qbman_pull_desc *d,
 int stash)
 {
/* save the virtual address */
-   d->rsp_addr_virt = (u64)storage;
+   d->rsp_addr_virt = (u64)(uintptr_t)storage;
 
if (!storage) {
d->verb &= ~(1 << QB_VDQCR_VERB_RLS_SHIFT);
@@ -590,7 +590,7 @@ int qbman_swp_pull(struct qbman_swp *s, struct 
qbman_pull_desc *d)
atomic_inc(>vdq.available);
return -EBUSY;
}
-   s->vdq.storage = (void *)d->rsp_addr_virt;
+   s->vdq.storage = (void *)(uintptr_t)d->rsp_addr_virt;
p = qbman_get_cmd(s, QBMAN_CENA_SWP_VDQCR);
p->numf = d->numf;
p->tok = QMAN_DQ_TOKEN_VALID;
-- 
2.7.4

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


[PATCH 4/4] staging: fsl-dpaa2/eth: allow the driver to compile multi-arch

2018-02-26 Thread Ioana Radulescu
Drop dependency on ARCH_LAYERSCAPE (which in turn depends on ARM64),
thus allowing this driver to compile on all architectures supported
by the fsl-mc bus driver.

This was compile tested on:
 - powerpc (corenet_basic_defconfig, ppc64_defconfig)
 - x86 (i386_defconfig, x86_64_defconfig, needs CONFIG_OF)
 - arm64 (defconfig)

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/fsl-dpaa2/Kconfig 
b/drivers/staging/fsl-dpaa2/Kconfig
index dfff675..730fd6d 100644
--- a/drivers/staging/fsl-dpaa2/Kconfig
+++ b/drivers/staging/fsl-dpaa2/Kconfig
@@ -4,7 +4,7 @@
 
 config FSL_DPAA2
bool "Freescale DPAA2 devices"
-   depends on FSL_MC_BUS && ARCH_LAYERSCAPE
+   depends on FSL_MC_BUS
---help---
  Build drivers for Freescale DataPath Acceleration
  Architecture (DPAA2) family of SoCs.
-- 
2.7.4

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


[PATCH] staging: fsl-dpaa2/eth: Defer probing if no MC portal available

2018-02-08 Thread Ioana Radulescu
MC portals may not be available at the initial probing attempt
due to dependencies on other modules.

Check the return value of the MC portal allocation function and
defer probing in case it's not available yet. For all other error
cases the behaviour stays the same.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
Suggested-by: Nipun Gupta <nipun.gu...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 2817e67..e4c2804 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -2440,7 +2440,10 @@ static int dpaa2_eth_probe(struct fsl_mc_device 
*dpni_dev)
err = fsl_mc_portal_allocate(dpni_dev, FSL_MC_IO_ATOMIC_CONTEXT_PORTAL,
 >mc_io);
if (err) {
-   dev_err(dev, "MC portal allocation failed\n");
+   if (err == -ENXIO)
+   err = -EPROBE_DEFER;
+   else
+   dev_err(dev, "MC portal allocation failed\n");
goto err_portal_alloc;
}
 
-- 
2.7.4

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


[PATCH v2] staging: fsl-mc: Convert documentation to rst format

2018-01-16 Thread Ioana Radulescu
Update the doc file to comply with the rst format.

It's not integrated into the documentation build structure yet,
since it's still located in drivers/staging.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
v2: patch generated with -M option

 .../staging/fsl-mc/{README.txt => overview.rst}| 655 +++--
 1 file changed, 336 insertions(+), 319 deletions(-)
 rename drivers/staging/fsl-mc/{README.txt => overview.rst} (14%)

diff --git a/drivers/staging/fsl-mc/README.txt 
b/drivers/staging/fsl-mc/overview.rst
similarity index 14%
rename from drivers/staging/fsl-mc/README.txt
rename to drivers/staging/fsl-mc/overview.rst
index 0ea5cd7..79fede4 100644
--- a/drivers/staging/fsl-mc/README.txt
+++ b/drivers/staging/fsl-mc/overview.rst
@@ -1,24 +1,16 @@
-Copyright (C) 2015 Freescale Semiconductor Inc.
+.. include:: 
 
 DPAA2 (Data Path Acceleration Architecture Gen2) Overview
--
+=
+
+:Copyright: |copy| 2015 Freescale Semiconductor Inc.
+:Copyright: |copy| 2018 NXP
 
 This document provides an overview of the Freescale DPAA2 architecture
 and how it is integrated into the Linux kernel.
 
-Contents summary
-   -DPAA2 overview
-   -Overview of DPAA2 objects
-   -DPAA2 Linux driver architecture overview
--bus driver
--DPRC driver
--allocator
--DPIO driver
--Ethernet
--MAC
-
 Introduction
-
+
 
 DPAA2 is a hardware architecture designed for high-speeed network
 packet processing.  DPAA2 consists of sophisticated mechanisms for
@@ -29,48 +21,47 @@ autonomous L2 switching, virtual Ethernet bridging, and 
accelerator
 A DPAA2 hardware component called the Management Complex (or MC) manages the
 DPAA2 hardware resources.  The MC provides an object-based abstraction for
 software drivers to use the DPAA2 hardware.
-
 The MC uses DPAA2 hardware resources such as queues, buffer pools, and
 network ports to create functional objects/devices such as network
 interfaces, an L2 switch, or accelerator instances.
-
 The MC provides memory-mapped I/O command interfaces (MC portals)
 which DPAA2 software drivers use to operate on DPAA2 objects.
 
 The diagram below shows an overview of the DPAA2 resource management
-architecture:
-
- +--+
- |  OS  |
- |DPAA2 drivers |
- | ||
- +-|+
-   |
-   | (create,discover,connect
-   |  config,use,destroy)
-   |
- DPAA2 |
- +| mc portal |-+
- | ||
- |   +- - - - - - - - - - - - -V- - -+  |
- |   |   |  |
- |   |   Management Complex (MC) |  |
- |   |   |  |
- |   +- - - - - - - - - - - - - - - -+  |
- |  |
- | Hardware  Hardware   |
- | Resources Objects|
- | - ---|
- | -queues   -DPRC  |
- | -buffer pools -DPMCP |
- | -Eth MACs/ports   -DPIO  |
- | -network interface-DPNI  |
- |  profiles -DPMAC |
- | -queue portals-DPBP  |
- | -MC portals...   |
- |  ... |
- |  |
- +--+
+architecture::
+
+   +--+
+   |  OS  |
+   |DPAA2 drivers |
+   | ||
+   +-|+
+ |
+ | (create,discover,connect
+ |  config,use,destroy)
+ |
+DPAA2|
+   +| mc portal |-+
+   | ||
+   |   +- - - - - - - - - - - - -V- - -+  |
+   |   |   |  |
+   |   |   Management Complex (MC) |  |
+   |   |   |  |
+   |   +- - - - - - - - - - - - - - - -+  |
+   |  |
+   | Hardware  Hardware   |
+   | Resources

[PATCH 0/2] staging: fsl-mc/dpio, fsl-dpaa2/eth: Use affine DPIO services

2018-01-05 Thread Ioana Radulescu
The first patch introduces a new DPIO API function allowing
the selection of a cpu-affine service. In the second patch,
the Ethernet driver uses this new API to map cpu-affine DPIO
services to channels.

This adds a significant performance boost on the frame dequeue
side (see numbers below), but, more importantly, helps us avoid
a scenario leading to the kernel running out of memory:

In an unidirectional IP forwarding test running on 8cores, with
ingress traffic @10Gbps, the rate with which Tx frames are
enqueued by the cpu on Tx queues is higher than the rate with
which cores manage to dequeue Tx confirmation frames. So these
confirmation frames increasingly accumulate on hardware queues,
eventually gobbling up all system memory.

Enforcing DPIO service affinity takes advantage of the way
our hardware was designed to be used, eliminating the bottleneck
that caused the imbalance between Rx and Tx processing paths.

Performance numbers measured on a LS2088A board with 8cores @2GHz:

Bidirectional IP forwarding, 512 flows with 64B frames:
1.68Mpps (before) vs 3.77Mpps (after)
Unidirectional IP forwarding, 512 flows with 64B frames:
1.33Mpps (and OOM after ~5-8min) vs 3.72Mpps
TCP netperf (client), 256 flows:
17.27Gbps with 100% cpu load vs 18.78Gbps with 77.6% cpu load

Ioana Radulescu (2):
  staging: fsl-mc/dpio: Add dpaa2_io_service_select() API
  staging: fsl-dpaa2/eth: Use affine DPIO services

 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 24 ++--
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h |  1 +
 drivers/staging/fsl-mc/bus/dpio/dpio-service.c | 17 +
 drivers/staging/fsl-mc/include/dpaa2-io.h  |  2 ++
 4 files changed, 34 insertions(+), 10 deletions(-)

-- 
2.7.4

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


[PATCH 2/2] staging: fsl-dpaa2/eth: Use affine DPIO services

2018-01-05 Thread Ioana Radulescu
Use the newly added DPIO service API to map cpu-affine DPIO services
to channels.

The DPAA2 Ethernet driver already had mappings of frame queues and
channels to cpus, but had no control over the DPIOs used. We can
now ensure full affinity of hotpath hardware resources to cores,
which improves performance and almost eliminates some resource
contentions (e.g. enqueue/dequeue busy counters should be close to
zero from now on).

Making the pull channel operation core affine brings the most
significant benefits. This ensures the same DPIO service will be
used for all dequeue commands issued for a certain frame queue,
which is in line with the way hardware is optimized.

Additionally, we also use affine DPIOs for the frame enqueue and
buffer release operations in order to avoid resource contention.
dpaa2_io_service_register() and dpaa2_io_service_rearm()
functions receive an affine DPIO as argument mostly for uniformity,
but this doesn't change the previous functionality.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 24 ++--
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h |  1 +
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 824c4ad..2817e67 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -597,7 +597,8 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct 
net_device *net_dev)
queue_mapping = skb_get_queue_mapping(skb);
fq = >fq[queue_mapping];
for (i = 0; i < DPAA2_ETH_ENQUEUE_RETRIES; i++) {
-   err = dpaa2_io_service_enqueue_qd(NULL, priv->tx_qdid, 0,
+   err = dpaa2_io_service_enqueue_qd(fq->channel->dpio,
+ priv->tx_qdid, 0,
  fq->tx_qdbin, );
if (err != -EBUSY)
break;
@@ -719,7 +720,8 @@ static void free_bufs(struct dpaa2_eth_priv *priv, u64 
*buf_array, int count)
 /* Perform a single release command to add buffers
  * to the specified buffer pool
  */
-static int add_bufs(struct dpaa2_eth_priv *priv, u16 bpid)
+static int add_bufs(struct dpaa2_eth_priv *priv,
+   struct dpaa2_eth_channel *ch, u16 bpid)
 {
struct device *dev = priv->net_dev->dev.parent;
u64 buf_array[DPAA2_ETH_BUFS_PER_CMD];
@@ -753,7 +755,7 @@ static int add_bufs(struct dpaa2_eth_priv *priv, u16 bpid)
 
 release_bufs:
/* In case the portal is busy, retry until successful */
-   while ((err = dpaa2_io_service_release(NULL, bpid,
+   while ((err = dpaa2_io_service_release(ch->dpio, bpid,
   buf_array, i)) == -EBUSY)
cpu_relax();
 
@@ -794,7 +796,7 @@ static int seed_pool(struct dpaa2_eth_priv *priv, u16 bpid)
for (j = 0; j < priv->num_channels; j++) {
for (i = 0; i < DPAA2_ETH_NUM_BUFS;
 i += DPAA2_ETH_BUFS_PER_CMD) {
-   new_count = add_bufs(priv, bpid);
+   new_count = add_bufs(priv, priv->channel[j], bpid);
priv->channel[j]->buf_count += new_count;
 
if (new_count < DPAA2_ETH_BUFS_PER_CMD) {
@@ -852,7 +854,7 @@ static int refill_pool(struct dpaa2_eth_priv *priv,
return 0;
 
do {
-   new_count = add_bufs(priv, bpid);
+   new_count = add_bufs(priv, ch, bpid);
if (unlikely(!new_count)) {
/* Out of memory; abort for now, we'll try later on */
break;
@@ -873,7 +875,8 @@ static int pull_channel(struct dpaa2_eth_channel *ch)
 
/* Retry while portal is busy */
do {
-   err = dpaa2_io_service_pull_channel(NULL, ch->ch_id, ch->store);
+   err = dpaa2_io_service_pull_channel(ch->dpio, ch->ch_id,
+   ch->store);
dequeues++;
cpu_relax();
} while (err == -EBUSY);
@@ -923,7 +926,7 @@ static int dpaa2_eth_poll(struct napi_struct *napi, int 
budget)
if (cleaned < budget && napi_complete_done(napi, cleaned)) {
/* Re-enable data available notifications */
do {
-   err = dpaa2_io_service_rearm(NULL, >nctx);
+   err = dpaa2_io_service_rearm(ch->dpio, >nctx);
cpu_relax();
} while (err == -EBUSY);
WARN_ONCE(err, "CDAN notifications rearm failed on core %d",
@@ -1531,7 +1534,8 @@ static int setup_dpio(struct dpaa2_eth_priv *priv)
nctx->desired_cpu = i;
 

[PATCH 1/2] staging: fsl-mc/dpio: Add dpaa2_io_service_select() API

2018-01-05 Thread Ioana Radulescu
All DPIO service API functions receive a dpaa2_io service pointer
as parameter (NULL meaning any service will do) which indicates
the hardware resource to be used to execute the specified command.

There isn't however any available API for obtaining such a service
reference that could be used further, effectively forcing the users
to always request a random service for DPIO operations.
(The DPIO driver holds internally an array mapping services to cpus,
and affine services can be indirectly requested by a couple of API
functions: dpaa2_io_service_register and dpaa2_io_service_rearm
use the cpu id provided by the user to select the corresponding
service)

This patch adds a function for selecting a DPIO service based on
the specified cpu id. If the user provides a "don't care" value
for the cpu, we revert to the default behavior and return the next
DPIO, taken in a round-robin fashion from a list of available
services.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-mc/bus/dpio/dpio-service.c | 17 +
 drivers/staging/fsl-mc/include/dpaa2-io.h  |  2 ++
 2 files changed, 19 insertions(+)

diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c 
b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
index a8a8e15..6e8994c 100644
--- a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
+++ b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
@@ -104,6 +104,23 @@ static inline struct dpaa2_io *service_select(struct 
dpaa2_io *d)
 }
 
 /**
+ * dpaa2_io_service_select() - return a dpaa2_io service affined to this cpu
+ * @cpu: the cpu id
+ *
+ * Return the affine dpaa2_io service, or NULL if there is no service affined
+ * to the specified cpu. If DPAA2_IO_ANY_CPU is used, return the next available
+ * service.
+ */
+struct dpaa2_io *dpaa2_io_service_select(int cpu)
+{
+   if (cpu == DPAA2_IO_ANY_CPU)
+   return service_select(NULL);
+
+   return service_select_by_cpu(NULL, cpu);
+}
+EXPORT_SYMBOL_GPL(dpaa2_io_service_select);
+
+/**
  * dpaa2_io_create() - create a dpaa2_io object.
  * @desc: the dpaa2_io descriptor
  *
diff --git a/drivers/staging/fsl-mc/include/dpaa2-io.h 
b/drivers/staging/fsl-mc/include/dpaa2-io.h
index 07ad15a..9d70251 100644
--- a/drivers/staging/fsl-mc/include/dpaa2-io.h
+++ b/drivers/staging/fsl-mc/include/dpaa2-io.h
@@ -88,6 +88,8 @@ void dpaa2_io_down(struct dpaa2_io *d);
 
 irqreturn_t dpaa2_io_irq(struct dpaa2_io *obj);
 
+struct dpaa2_io *dpaa2_io_service_select(int cpu);
+
 /**
  * struct dpaa2_io_notification_ctx - The DPIO notification context structure
  * @cb:   The callback to be invoked when the notification arrives
-- 
2.7.4

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


[PATCH 1/2] staging: fsl-dpaa2/eth: Flow affinity for IP forwarding

2017-12-21 Thread Ioana Radulescu
The driver xmit function chooses an egress FQ based on the current
core id. The network stack itself sets a mapping field in the skb
based on many things - the default one being a hash on packet fields,
which the current driver ignores.

This patch saves the ingress frame flow affinity information in the
skb. In case of forwarded frames, this info will then be used for Tx
and Tx confirmation hardware queue selection, ensuring all processing
of the given frame is done on a single core.

Signed-off-by: Bogdan Purcareata <bogdan.purcare...@nxp.com>
Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 16 ++--
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h |  3 ++-
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 7f3e4fa..b63ae09 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -230,7 +230,8 @@ static struct sk_buff *build_frag_skb(struct dpaa2_eth_priv 
*priv,
 static void dpaa2_eth_rx(struct dpaa2_eth_priv *priv,
 struct dpaa2_eth_channel *ch,
 const struct dpaa2_fd *fd,
-struct napi_struct *napi)
+struct napi_struct *napi,
+u16 queue_id)
 {
dma_addr_t addr = dpaa2_fd_get_addr(fd);
u8 fd_format = dpaa2_fd_get_format(fd);
@@ -281,6 +282,7 @@ static void dpaa2_eth_rx(struct dpaa2_eth_priv *priv,
}
 
skb->protocol = eth_type_trans(skb, priv->net_dev);
+   skb_record_rx_queue(skb, queue_id);
 
percpu_stats->rx_packets++;
percpu_stats->rx_bytes += dpaa2_fd_get_len(fd);
@@ -325,7 +327,7 @@ static int consume_frames(struct dpaa2_eth_channel *ch)
fq = (struct dpaa2_eth_fq *)dpaa2_dq_fqd_ctx(dq);
fq->stats.frames++;
 
-   fq->consume(priv, ch, fd, >napi);
+   fq->consume(priv, ch, fd, >napi, fq->flowid);
cleaned++;
} while (!is_last);
 
@@ -588,10 +590,11 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, 
struct net_device *net_dev)
/* Tracing point */
trace_dpaa2_tx_fd(net_dev, );
 
-   /* TxConf FQ selection primarily based on cpu affinity; this is
-* non-migratable context, so it's safe to call smp_processor_id().
+   /* TxConf FQ selection relies on queue id from the stack.
+* In case of a forwarded frame from another DPNI interface, we choose
+* a queue affined to the same core that processed the Rx frame
 */
-   queue_mapping = smp_processor_id() % dpaa2_eth_queue_count(priv);
+   queue_mapping = skb_get_queue_mapping(skb);
fq = >fq[queue_mapping];
for (i = 0; i < DPAA2_ETH_ENQUEUE_RETRIES; i++) {
err = dpaa2_io_service_enqueue_qd(NULL, priv->tx_qdid, 0,
@@ -622,7 +625,8 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct 
net_device *net_dev)
 static void dpaa2_eth_tx_conf(struct dpaa2_eth_priv *priv,
  struct dpaa2_eth_channel *ch,
  const struct dpaa2_fd *fd,
- struct napi_struct *napi __always_unused)
+ struct napi_struct *napi __always_unused,
+ u16 queue_id __always_unused)
 {
struct rtnl_link_stats64 *percpu_stats;
struct dpaa2_eth_drv_stats *percpu_extras;
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
index d68ac38..fb8fb5c 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
@@ -276,7 +276,8 @@ struct dpaa2_eth_fq {
void (*consume)(struct dpaa2_eth_priv *,
struct dpaa2_eth_channel *,
const struct dpaa2_fd *,
-   struct napi_struct *);
+   struct napi_struct *,
+   u16 queue_id);
struct dpaa2_eth_fq_stats stats;
 };
 
-- 
2.7.4

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


[PATCH 2/2] staging: fsl-dpaa2/eth: Flow affinity for non-forwarded traffic

2017-12-21 Thread Ioana Radulescu
The previous patch ensures Tx flow affinity for forwarded frames,
but for termination traffic the initial flow affinity is determined
based on the skb hash, which is expected to hit only a few Tx queues
when there is a small number of flows.

Instead, use XPS (transmit packet steering) to set netdevice queue
affinity to the sending core.

Signed-off-by: Bogdan Purcareata <bogdan.purcare...@nxp.com>
Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index b63ae09..824c4ad 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -1620,9 +1620,10 @@ static struct dpaa2_eth_channel 
*get_affine_channel(struct dpaa2_eth_priv *priv,
 static void set_fq_affinity(struct dpaa2_eth_priv *priv)
 {
struct device *dev = priv->net_dev->dev.parent;
+   struct cpumask xps_mask;
struct dpaa2_eth_fq *fq;
int rx_cpu, txc_cpu;
-   int i;
+   int i, err;
 
/* For each FQ, pick one channel/CPU to deliver frames to.
 * This may well change at runtime, either through irqbalance or
@@ -1641,6 +1642,17 @@ static void set_fq_affinity(struct dpaa2_eth_priv *priv)
break;
case DPAA2_TX_CONF_FQ:
fq->target_cpu = txc_cpu;
+
+   /* Tell the stack to affine to txc_cpu the Tx queue
+* associated with the confirmation one
+*/
+   cpumask_clear(_mask);
+   cpumask_set_cpu(txc_cpu, _mask);
+   err = netif_set_xps_queue(priv->net_dev, _mask,
+ fq->flowid);
+   if (err)
+   dev_err(dev, "Error setting XPS queue\n");
+
txc_cpu = cpumask_next(txc_cpu, >dpio_cpumask);
if (txc_cpu >= nr_cpu_ids)
txc_cpu = cpumask_first(>dpio_cpumask);
-- 
2.7.4

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


[PATCH 5/6] staging: fsl-dpaa2/eth: Compute needed headroom per frame

2017-12-08 Thread Ioana Radulescu
For non-linear skbs we build scatter-gather frames and allocate
a new buffer for the S/G table in which we reserve the required
headroom, so the actual skb headroom size doesn't matter.

Rather than use a one-size-fits-all approach, decide when to
enforce headroom requirements on a frame by frame basis.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c |  9 ++---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 11 ---
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 2c12859..8edb7c1 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -437,7 +437,8 @@ static int build_single_fd(struct dpaa2_eth_priv *priv,
struct sk_buff **skbh;
dma_addr_t addr;
 
-   buffer_start = PTR_ALIGN(skb->data - dpaa2_eth_needed_headroom(priv),
+   buffer_start = PTR_ALIGN(skb->data -
+dpaa2_eth_needed_headroom(priv, skb),
 DPAA2_ETH_TX_BUF_ALIGN);
 
/* Store a backpointer to the skb at the beginning of the buffer
@@ -532,15 +533,17 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, 
struct net_device *net_dev)
struct dpaa2_eth_drv_stats *percpu_extras;
struct dpaa2_eth_fq *fq;
u16 queue_mapping;
+   unsigned int needed_headroom;
int err, i;
 
percpu_stats = this_cpu_ptr(priv->percpu_stats);
percpu_extras = this_cpu_ptr(priv->percpu_extras);
 
-   if (skb_headroom(skb) < dpaa2_eth_needed_headroom(priv)) {
+   needed_headroom = dpaa2_eth_needed_headroom(priv, skb);
+   if (skb_headroom(skb) < needed_headroom) {
struct sk_buff *ns;
 
-   ns = skb_realloc_headroom(skb, dpaa2_eth_needed_headroom(priv));
+   ns = skb_realloc_headroom(skb, needed_headroom);
if (unlikely(!ns)) {
percpu_stats->tx_dropped++;
goto err_alloc_headroom;
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
index 546a862..4ea41d8 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
@@ -364,9 +364,13 @@ static inline unsigned int dpaa2_eth_buf_raw_size(struct 
dpaa2_eth_priv *priv)
 }
 
 static inline
-unsigned int dpaa2_eth_needed_headroom(struct dpaa2_eth_priv *priv)
+unsigned int dpaa2_eth_needed_headroom(struct dpaa2_eth_priv *priv,
+  struct sk_buff *skb)
 {
-   return priv->tx_data_offset + DPAA2_ETH_TX_BUF_ALIGN;
+   if (skb_is_nonlinear(skb))
+   return 0;
+
+   return DPAA2_ETH_SWA_SIZE + DPAA2_ETH_TX_BUF_ALIGN;
 }
 
 /* Extra headroom space requested to hardware, in order to make sure there's
@@ -374,7 +378,8 @@ unsigned int dpaa2_eth_needed_headroom(struct 
dpaa2_eth_priv *priv)
  */
 static inline unsigned int dpaa2_eth_rx_head_room(struct dpaa2_eth_priv *priv)
 {
-   return dpaa2_eth_needed_headroom(priv) - DPAA2_ETH_RX_HWA_SIZE;
+   return priv->tx_data_offset + DPAA2_ETH_TX_BUF_ALIGN -
+  DPAA2_ETH_RX_HWA_SIZE;
 }
 
 static int dpaa2_eth_queue_count(struct dpaa2_eth_priv *priv)
-- 
2.7.4

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


[PATCH 4/6] staging: fsl-dpaa2/eth: Don't enable FAS on Tx

2017-12-08 Thread Ioana Radulescu
For Tx confirmed frames that have an error indication in the frame
descriptor, we look at the Frame Annotation Status field (in the
buffer headroom) for details on the root cause and then print
a debug message with that information.

While useful in initial development stages, it doesn't bring
enough added value to justify reserving 64B of headroom for all
Tx frames (FAS is only 8B long, but we must reserve chunks of 64B
from the hardware annotation area).

If we remove the need for FAS field from egress frames, we can
renounce hardware annotation completely, since FAS is the only
HWA field we currently use.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 73 +-
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h |  6 ---
 2 files changed, 13 insertions(+), 66 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 6de6cdd..2c12859 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -348,7 +348,6 @@ static int build_sg_fd(struct dpaa2_eth_priv *priv,
int num_sg;
int num_dma_bufs;
struct dpaa2_eth_swa *swa;
-   struct dpaa2_fas *fas;
 
/* Create and map scatterlist.
 * We don't advertise NETIF_F_FRAGLIST, so skb_to_sgvec() will not have
@@ -379,15 +378,6 @@ static int build_sg_fd(struct dpaa2_eth_priv *priv,
goto sgt_buf_alloc_failed;
}
sgt_buf = PTR_ALIGN(sgt_buf, DPAA2_ETH_TX_BUF_ALIGN);
-
-   /* PTA from egress side is passed as is to the confirmation side so
-* we need to clear some fields here in order to find consistent values
-* on TX confirmation. We are clearing FAS (Frame Annotation Status)
-* field from the hardware annotation area
-*/
-   fas = dpaa2_get_fas(sgt_buf, true);
-   memset(fas, 0, DPAA2_FAS_SIZE);
-
sgt = (struct dpaa2_sg_entry *)(sgt_buf + priv->tx_data_offset);
 
/* Fill in the HW SGT structure.
@@ -424,8 +414,7 @@ static int build_sg_fd(struct dpaa2_eth_priv *priv,
dpaa2_fd_set_format(fd, dpaa2_fd_sg);
dpaa2_fd_set_addr(fd, addr);
dpaa2_fd_set_len(fd, skb->len);
-   dpaa2_fd_set_ctrl(fd, DPAA2_FD_CTRL_ASAL | DPAA2_FD_CTRL_PTA |
- DPAA2_FD_CTRL_PTV1);
+   dpaa2_fd_set_ctrl(fd, DPAA2_FD_CTRL_PTA | DPAA2_FD_CTRL_PTV1);
 
return 0;
 
@@ -445,21 +434,12 @@ static int build_single_fd(struct dpaa2_eth_priv *priv,
 {
struct device *dev = priv->net_dev->dev.parent;
u8 *buffer_start;
-   struct dpaa2_fas *fas;
struct sk_buff **skbh;
dma_addr_t addr;
 
buffer_start = PTR_ALIGN(skb->data - dpaa2_eth_needed_headroom(priv),
 DPAA2_ETH_TX_BUF_ALIGN);
 
-   /* PTA from egress side is passed as is to the confirmation side so
-* we need to clear some fields here in order to find consistent values
-* on TX confirmation. We are clearing FAS (Frame Annotation Status)
-* field from the hardware annotation area
-*/
-   fas = dpaa2_get_fas(buffer_start, true);
-   memset(fas, 0, DPAA2_FAS_SIZE);
-
/* Store a backpointer to the skb at the beginning of the buffer
 * (in the private data area) such that we can release it
 * on Tx confirm
@@ -477,8 +457,7 @@ static int build_single_fd(struct dpaa2_eth_priv *priv,
dpaa2_fd_set_offset(fd, (u16)(skb->data - buffer_start));
dpaa2_fd_set_len(fd, skb->len);
dpaa2_fd_set_format(fd, dpaa2_fd_single);
-   dpaa2_fd_set_ctrl(fd, DPAA2_FD_CTRL_ASAL | DPAA2_FD_CTRL_PTA |
- DPAA2_FD_CTRL_PTV1);
+   dpaa2_fd_set_ctrl(fd, DPAA2_FD_CTRL_PTA | DPAA2_FD_CTRL_PTV1);
 
return 0;
 }
@@ -493,8 +472,7 @@ static int build_single_fd(struct dpaa2_eth_priv *priv,
  * to be checked if we're on the confirmation path.
  */
 static void free_tx_fd(const struct dpaa2_eth_priv *priv,
-  const struct dpaa2_fd *fd,
-  u32 *status)
+  const struct dpaa2_fd *fd)
 {
struct device *dev = priv->net_dev->dev.parent;
dma_addr_t fd_addr;
@@ -505,11 +483,9 @@ static void free_tx_fd(const struct dpaa2_eth_priv *priv,
int num_sg, num_dma_bufs;
struct dpaa2_eth_swa *swa;
u8 fd_format = dpaa2_fd_get_format(fd);
-   struct dpaa2_fas *fas;
 
fd_addr = dpaa2_fd_get_addr(fd);
skbh = dpaa2_iova_to_virt(priv->iommu_domain, fd_addr);
-   fas = dpaa2_get_fas(skbh, true);
 
if (fd_format == dpaa2_fd_single) {
skb = *skbh;
@@ -536,19 +512,10 @@ static void free_tx_fd(const struct dpaa2_eth_priv *priv,
   sizeof(struct dpaa2_sg_entry) * (1 + num_dma_bufs);
dma_unmap_single(dev, fd

[PATCH 6/6] staging: fsl-dpaa2/eth: Make Tx buffer alignment optional

2017-12-08 Thread Ioana Radulescu
Aligning the Tx buffers at 64B is a performance optimization
recommendation, not a hard requirement.

Make optional the alignment of Tx FD buffers, without enforcing
a reallocation in case there is not enough headroom for it.

On Rx, we keep allocating buffers with enough headroom to allow
Tx alignment of forwarded frames.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 14 ++
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h |  2 +-
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 8edb7c1..7f3e4fa 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -433,13 +433,19 @@ static int build_single_fd(struct dpaa2_eth_priv *priv,
   struct dpaa2_fd *fd)
 {
struct device *dev = priv->net_dev->dev.parent;
-   u8 *buffer_start;
+   u8 *buffer_start, *aligned_start;
struct sk_buff **skbh;
dma_addr_t addr;
 
-   buffer_start = PTR_ALIGN(skb->data -
-dpaa2_eth_needed_headroom(priv, skb),
-DPAA2_ETH_TX_BUF_ALIGN);
+   buffer_start = skb->data - dpaa2_eth_needed_headroom(priv, skb);
+
+   /* If there's enough room to align the FD address, do it.
+* It will help hardware optimize accesses.
+*/
+   aligned_start = PTR_ALIGN(buffer_start - DPAA2_ETH_TX_BUF_ALIGN,
+ DPAA2_ETH_TX_BUF_ALIGN);
+   if (aligned_start >= skb->head)
+   buffer_start = aligned_start;
 
/* Store a backpointer to the skb at the beginning of the buffer
 * (in the private data area) such that we can release it
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
index 4ea41d8..d68ac38 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
@@ -370,7 +370,7 @@ unsigned int dpaa2_eth_needed_headroom(struct 
dpaa2_eth_priv *priv,
if (skb_is_nonlinear(skb))
return 0;
 
-   return DPAA2_ETH_SWA_SIZE + DPAA2_ETH_TX_BUF_ALIGN;
+   return DPAA2_ETH_SWA_SIZE;
 }
 
 /* Extra headroom space requested to hardware, in order to make sure there's
-- 
2.7.4

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


[PATCH 1/6] staging: fsl-dpaa2/eth: Fix access to FAS field

2017-12-08 Thread Ioana Radulescu
Commit 4b2d9fe87950 ("staging: fsl-dpaa2/eth: Extra headroom in RX
buffers") removes the software annotation (SWA) area from the RX
buffer layout, as it's not used by anyone, but fails to update the
macros for accessing hardware annotation (HWA) fields, which is
right after the SWA in the buffer headroom.

This may lead to some frame annotation status fields (e.g. indication
if L3/L4 checksum is valid) to be read incorrectly.

Turn the accessor macros into inline functions and add a bool param
to specify if SWA is present or not.

Fixes: 4b2d9fe87950 ("staging: fsl-dpaa2/eth: Extra headroom in RX buffers")

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c |  8 
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 13 +
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 0d8ed00..c8a8e3a 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -249,7 +249,7 @@ static void dpaa2_eth_rx(struct dpaa2_eth_priv *priv,
vaddr = dpaa2_iova_to_virt(priv->iommu_domain, addr);
dma_unmap_single(dev, addr, DPAA2_ETH_RX_BUF_SIZE, DMA_FROM_DEVICE);
 
-   fas = dpaa2_get_fas(vaddr);
+   fas = dpaa2_get_fas(vaddr, false);
prefetch(fas);
buf_data = vaddr + dpaa2_fd_get_offset(fd);
prefetch(buf_data);
@@ -385,7 +385,7 @@ static int build_sg_fd(struct dpaa2_eth_priv *priv,
 * on TX confirmation. We are clearing FAS (Frame Annotation Status)
 * field from the hardware annotation area
 */
-   fas = dpaa2_get_fas(sgt_buf);
+   fas = dpaa2_get_fas(sgt_buf, true);
memset(fas, 0, DPAA2_FAS_SIZE);
 
sgt = (struct dpaa2_sg_entry *)(sgt_buf + priv->tx_data_offset);
@@ -458,7 +458,7 @@ static int build_single_fd(struct dpaa2_eth_priv *priv,
 * on TX confirmation. We are clearing FAS (Frame Annotation Status)
 * field from the hardware annotation area
 */
-   fas = dpaa2_get_fas(buffer_start);
+   fas = dpaa2_get_fas(buffer_start, true);
memset(fas, 0, DPAA2_FAS_SIZE);
 
/* Store a backpointer to the skb at the beginning of the buffer
@@ -510,7 +510,7 @@ static void free_tx_fd(const struct dpaa2_eth_priv *priv,
 
fd_addr = dpaa2_fd_get_addr(fd);
skbh = dpaa2_iova_to_virt(priv->iommu_domain, fd_addr);
-   fas = dpaa2_get_fas(skbh);
+   fas = dpaa2_get_fas(skbh, true);
 
if (fd_format == dpaa2_fd_single) {
skb = *skbh;
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
index 5b3ab9f..3a4e939 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
@@ -153,10 +153,15 @@ struct dpaa2_fas {
 #define DPAA2_FAS_SIZE (sizeof(struct dpaa2_fas))
 
 /* Accessors for the hardware annotation fields that we use */
-#define dpaa2_get_hwa(buf_addr) \
-   ((void *)(buf_addr) + DPAA2_ETH_SWA_SIZE)
-#define dpaa2_get_fas(buf_addr) \
-   (struct dpaa2_fas *)(dpaa2_get_hwa(buf_addr) + DPAA2_FAS_OFFSET)
+static inline void *dpaa2_get_hwa(void *buf_addr, bool swa)
+{
+   return buf_addr + (swa ? DPAA2_ETH_SWA_SIZE : 0);
+}
+
+static inline struct dpaa2_fas *dpaa2_get_fas(void *buf_addr, bool swa)
+{
+   return dpaa2_get_hwa(buf_addr, swa) + DPAA2_FAS_OFFSET;
+}
 
 /* Error and status bits in the frame annotation status word */
 /* Debug frame, otherwise supposed to be discarded */
-- 
2.7.4

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


[PATCH 0/6] staging: fsl-dpaa2/eth: Frame buffer optimizations

2017-12-08 Thread Ioana Radulescu
This patchset continues the work related to frame buffer layout.

The first two patches fix an issue and simplify some rather convoluted
formulas introduced by a previous commit.

The third adds a new counter for TX skb reallocations due to
insufficient headroom. This helped us notice that most of the frames
originated on the core had skbs with too little headroom, leading to
additional alloc/free operations and a performance penalty for
egress termination traffic.

A closer look at hardware requirements vs recommandations showed
that we don't in fact need to be so strict with our TX buffer layout.
The last three patches in this set remove all restrictions that are
not mandatory from a functional standpoint, lowering the required
TX headroom from 192B to 64B.

This helps avoid realloc's for most TCP frames. On a LS2088A board
with one core @2GHz, running a netperf TCP_SENDFILE test (as client),
we see an increase in throughput from 3.79Gbps to 5.11Gbps. For UDP
traffic no improvement is observed, since the stack usually creates
skbs with minimal headroom (2B) for UDP frames.

Ioana Radulescu (6):
  staging: fsl-dpaa2/eth: Fix access to FAS field
  staging: fsl-dpaa2/eth: Don't set netdev->needed_headroom
  staging: fsl-dpaa2/eth: Add counter for skb reallocs
  staging: fsl-dpaa2/eth: Don't enable FAS on Tx
  staging: fsl-dpaa2/eth: Compute needed headroom per frame
  staging: fsl-dpaa2/eth: Make Tx buffer alignment optional

 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 111 +
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h |  31 +++---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c |   1 +
 3 files changed, 46 insertions(+), 97 deletions(-)

-- 
2.7.4

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


[PATCH 3/6] staging: fsl-dpaa2/eth: Add counter for skb reallocs

2017-12-08 Thread Ioana Radulescu
Add a counter for the number of egress frames that need to be
realloc'ed due to insufficient headroom space.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 1 +
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 1 +
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c | 1 +
 3 files changed, 3 insertions(+)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 04db65c..6de6cdd 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -578,6 +578,7 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct 
net_device *net_dev)
percpu_stats->tx_dropped++;
goto err_alloc_headroom;
}
+   percpu_extras->tx_reallocs++;
dev_kfree_skb(skb);
skb = ns;
}
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
index 63b09d1..6940a98 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
@@ -231,6 +231,7 @@ struct dpaa2_eth_drv_stats {
__u64   tx_conf_bytes;
__u64   tx_sg_frames;
__u64   tx_sg_bytes;
+   __u64   tx_reallocs;
__u64   rx_sg_frames;
__u64   rx_sg_bytes;
/* Enqueues retried due to portal busy */
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
index ebe8fd6..070a3f2 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
@@ -62,6 +62,7 @@ static char dpaa2_ethtool_extras[][ETH_GSTRING_LEN] = {
"[drv] tx conf bytes",
"[drv] tx sg frames",
"[drv] tx sg bytes",
+   "[drv] tx realloc frames",
"[drv] rx sg frames",
"[drv] rx sg bytes",
"[drv] enqueue portal busy",
-- 
2.7.4

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


[PATCH 2/6] staging: fsl-dpaa2/eth: Don't set netdev->needed_headroom

2017-12-08 Thread Ioana Radulescu
Commit 4b2d9fe87950 ("staging: fsl-dpaa2/eth: Extra headroom in RX
buffers") tried to avoid the performance penalty of doing skb
reallocations in the network stack for IP forwarded frames between
two DPAA2 Ethernet interfaces. This led to a (too) complicated
formula that relies on the stack's internal implementation.

Instead, it's safer and easier to just not request any guarantee
from the stack. We already double check in the driver the required
headroom size of egress frames and realloc the skb if needed, so
we don't need to add any extra code.

On forwarding between two of our own interfaces, there is no
functional change; for traffic forwarded from a different device or
generated on the core, skb realloc operations are moved from the stack
to our driver, with no visible impact on performance.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 24 ++--
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h |  2 +-
 2 files changed, 3 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index c8a8e3a..04db65c 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -449,8 +449,7 @@ static int build_single_fd(struct dpaa2_eth_priv *priv,
struct sk_buff **skbh;
dma_addr_t addr;
 
-   buffer_start = PTR_ALIGN(skb->data - priv->tx_data_offset -
-DPAA2_ETH_TX_BUF_ALIGN,
+   buffer_start = PTR_ALIGN(skb->data - dpaa2_eth_needed_headroom(priv),
 DPAA2_ETH_TX_BUF_ALIGN);
 
/* PTA from egress side is passed as is to the confirmation side so
@@ -571,7 +570,7 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct 
net_device *net_dev)
percpu_stats = this_cpu_ptr(priv->percpu_stats);
percpu_extras = this_cpu_ptr(priv->percpu_extras);
 
-   if (unlikely(skb_headroom(skb) < dpaa2_eth_needed_headroom(priv))) {
+   if (skb_headroom(skb) < dpaa2_eth_needed_headroom(priv)) {
struct sk_buff *ns;
 
ns = skb_realloc_headroom(skb, dpaa2_eth_needed_headroom(priv));
@@ -2273,7 +2272,6 @@ static int netdev_init(struct net_device *net_dev)
 {
struct device *dev = net_dev->dev.parent;
struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
-   u16 rx_headroom, req_headroom;
u8 bcast_addr[ETH_ALEN];
u8 num_queues;
int err;
@@ -2292,24 +2290,6 @@ static int netdev_init(struct net_device *net_dev)
return err;
}
 
-   /* Reserve enough space to align buffer as per hardware requirement;
-* NOTE: priv->tx_data_offset MUST be initialized at this point.
-*/
-   net_dev->needed_headroom = dpaa2_eth_needed_headroom(priv);
-
-   /* If headroom guaranteed by hardware in the Rx frame buffer is
-* smaller than the Tx headroom required by the stack, issue a
-* one time warning. This will most likely mean skbs forwarded to
-* another DPAA2 network interface will get reallocated, with a
-* significant performance impact.
-*/
-   req_headroom = LL_RESERVED_SPACE(net_dev) - ETH_HLEN;
-   rx_headroom = ALIGN(DPAA2_ETH_RX_HWA_SIZE +
-   dpaa2_eth_rx_head_room(priv), priv->rx_buf_align);
-   if (req_headroom > rx_headroom)
-   dev_info_once(dev, "Required headroom (%d) greater than 
available (%d)\n",
- req_headroom, rx_headroom);
-
/* Set MTU limits */
net_dev->min_mtu = 68;
net_dev->max_mtu = DPAA2_ETH_MAX_MTU;
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
index 3a4e939..63b09d1 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
@@ -371,7 +371,7 @@ static inline unsigned int dpaa2_eth_buf_raw_size(struct 
dpaa2_eth_priv *priv)
 static inline
 unsigned int dpaa2_eth_needed_headroom(struct dpaa2_eth_priv *priv)
 {
-   return priv->tx_data_offset + DPAA2_ETH_TX_BUF_ALIGN - HH_DATA_MOD;
+   return priv->tx_data_offset + DPAA2_ETH_TX_BUF_ALIGN;
 }
 
 /* Extra headroom space requested to hardware, in order to make sure there's
-- 
2.7.4

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


[PATCH 7/9] staging: fsl-dpaa2/eth: Use implicit clear of link interrupt

2017-10-11 Thread Ioana Radulescu
dpni_get_irq_status() also looks at the input value of its
status parameter, and if not null it automatically clears
from pending state the bits that are set there.

Use this feature to avoid a separate MC command for clearing
the interrupt event bits after reading the status.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 12 +++-
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 6540ab0..3a8bad1 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -2332,7 +2332,7 @@ static irqreturn_t dpni_irq0_handler(int irq_num, void 
*arg)
 
 static irqreturn_t dpni_irq0_handler_thread(int irq_num, void *arg)
 {
-   u32 status = 0, clear = 0;
+   u32 status = ~0;
struct device *dev = (struct device *)arg;
struct fsl_mc_device *dpni_dev = to_fsl_mc_device(dev);
struct net_device *net_dev = dev_get_drvdata(dev);
@@ -2342,18 +2342,12 @@ static irqreturn_t dpni_irq0_handler_thread(int 
irq_num, void *arg)
  DPNI_IRQ_INDEX, );
if (unlikely(err)) {
netdev_err(net_dev, "Can't get irq status (err %d)\n", err);
-   clear = 0x;
-   goto out;
+   return IRQ_HANDLED;
}
 
-   if (status & DPNI_IRQ_EVENT_LINK_CHANGED) {
-   clear |= DPNI_IRQ_EVENT_LINK_CHANGED;
+   if (status & DPNI_IRQ_EVENT_LINK_CHANGED)
link_state_update(netdev_priv(net_dev));
-   }
 
-out:
-   dpni_clear_irq_status(dpni_dev->mc_io, 0, dpni_dev->mc_handle,
- DPNI_IRQ_INDEX, clear);
return IRQ_HANDLED;
 }
 
-- 
2.7.4

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


[PATCH 9/9] staging: fsl-dpaa2/eth: Add firmware version

2017-10-11 Thread Ioana Radulescu
Include firmware version in the driver information exported
through ethtool.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c | 14 +-
 drivers/staging/fsl-dpaa2/ethernet/dpni-cmd.h  |  5 
 drivers/staging/fsl-dpaa2/ethernet/dpni.c  | 32 ++
 drivers/staging/fsl-dpaa2/ethernet/dpni.h  |  5 
 4 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
index 031179a..ebe8fd6 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
@@ -76,10 +76,22 @@ static char dpaa2_ethtool_extras[][ETH_GSTRING_LEN] = {
 static void dpaa2_eth_get_drvinfo(struct net_device *net_dev,
  struct ethtool_drvinfo *drvinfo)
 {
+   struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
+   u16 fw_major, fw_minor;
+   int err;
+
strlcpy(drvinfo->driver, KBUILD_MODNAME, sizeof(drvinfo->driver));
strlcpy(drvinfo->version, dpaa2_eth_drv_version,
sizeof(drvinfo->version));
-   strlcpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version));
+
+   err =  dpni_get_api_version(priv->mc_io, 0, _major, _minor);
+   if (!err)
+   snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
+"%u.%u", fw_major, fw_minor);
+   else
+   strlcpy(drvinfo->fw_version, "N/A",
+   sizeof(drvinfo->fw_version));
+
strlcpy(drvinfo->bus_info, dev_name(net_dev->dev.parent->parent),
sizeof(drvinfo->bus_info));
 }
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpni-cmd.h 
b/drivers/staging/fsl-dpaa2/ethernet/dpni-cmd.h
index 57df222..3120e22 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpni-cmd.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpni-cmd.h
@@ -538,4 +538,9 @@ struct dpni_rsp_get_taildrop {
__le32 threshold;
 };
 
+struct dpni_rsp_get_api_version {
+   u16 major;
+   u16 minor;
+};
+
 #endif /* _FSL_DPNI_CMD_H */
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpni.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpni.c
index 04a5b14..e8be761 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpni.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpni.c
@@ -1594,3 +1594,35 @@ int dpni_get_taildrop(struct fsl_mc_io *mc_io,
 
return 0;
 }
+
+/**
+ * dpni_get_api_version() - Get Data Path Network Interface API version
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @major_ver: Major version of data path network interface API
+ * @minor_ver: Minor version of data path network interface API
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dpni_get_api_version(struct fsl_mc_io *mc_io,
+u32 cmd_flags,
+u16 *major_ver,
+u16 *minor_ver)
+{
+   struct dpni_rsp_get_api_version *rsp_params;
+   struct mc_command cmd = { 0 };
+   int err;
+
+   cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_API_VERSION,
+ cmd_flags, 0);
+
+   err = mc_send_command(mc_io, );
+   if (err)
+   return err;
+
+   rsp_params = (struct dpni_rsp_get_api_version *)cmd.params;
+   *major_ver = le16_to_cpu(rsp_params->major);
+   *minor_ver = le16_to_cpu(rsp_params->minor);
+
+   return 0;
+}
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpni.h 
b/drivers/staging/fsl-dpaa2/ethernet/dpni.h
index 282e5e8..ce86a81 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpni.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpni.h
@@ -829,4 +829,9 @@ struct dpni_rule_cfg {
u8  key_size;
 };
 
+int dpni_get_api_version(struct fsl_mc_io *mc_io,
+u32 cmd_flags,
+u16 *major_ver,
+u16 *minor_ver);
+
 #endif /* __FSL_DPNI_H */
-- 
2.7.4

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


[PATCH 1/9] staging: fsl-dpaa2/eth: Fix potential endless loop

2017-10-11 Thread Ioana Radulescu
We incorrectly assumed that dpaa2_io_release() can only
return -EBUSY as an error code, when in fact it can also
fail in case some of its arguments don't have valid values.

Make sure we only retry the operation while the portal is
busy and abort for all other error cases, otherwise we risk
entering an endless loop.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
Signed-off-by: Bogdan Purcareata <bogdan.purcare...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 58 --
 1 file changed, 35 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 26017fe..801ba07 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -718,6 +718,23 @@ static int set_tx_csum(struct dpaa2_eth_priv *priv, bool 
enable)
return 0;
 }
 
+/* Free buffers acquired from the buffer pool or which were meant to
+ * be released in the pool
+ */
+static void free_bufs(struct dpaa2_eth_priv *priv, u64 *buf_array, int count)
+{
+   struct device *dev = priv->net_dev->dev.parent;
+   void *vaddr;
+   int i;
+
+   for (i = 0; i < count; i++) {
+   vaddr = dpaa2_iova_to_virt(priv->iommu_domain, buf_array[i]);
+   dma_unmap_single(dev, buf_array[i], DPAA2_ETH_RX_BUF_SIZE,
+DMA_BIDIRECTIONAL);
+   skb_free_frag(vaddr);
+   }
+}
+
 /* Perform a single release command to add buffers
  * to the specified buffer pool
  */
@@ -727,7 +744,7 @@ static int add_bufs(struct dpaa2_eth_priv *priv, u16 bpid)
u64 buf_array[DPAA2_ETH_BUFS_PER_CMD];
void *buf;
dma_addr_t addr;
-   int i;
+   int i, err;
 
for (i = 0; i < DPAA2_ETH_BUFS_PER_CMD; i++) {
/* Allocate buffer visible to WRIOP + skb shared info +
@@ -754,22 +771,27 @@ static int add_bufs(struct dpaa2_eth_priv *priv, u16 bpid)
}
 
 release_bufs:
-   /* In case the portal is busy, retry until successful.
-* The buffer release function would only fail if the QBMan portal
-* was busy, which implies portal contention (i.e. more CPUs than
-* portals, i.e. GPPs w/o affine DPIOs). For all practical purposes,
-* there is little we can realistically do, short of giving up -
-* in which case we'd risk depleting the buffer pool and never again
-* receiving the Rx interrupt which would kick-start the refill logic.
-* So just keep retrying, at the risk of being moved to ksoftirqd.
-*/
-   while (dpaa2_io_service_release(NULL, bpid, buf_array, i))
+   /* In case the portal is busy, retry until successful */
+   while ((err = dpaa2_io_service_release(NULL, bpid,
+  buf_array, i)) == -EBUSY)
cpu_relax();
+
+   /* If release command failed, clean up and bail out;
+* not much else we can do about it
+*/
+   if (err) {
+   free_bufs(priv, buf_array, i);
+   return 0;
+   }
+
return i;
 
 err_map:
skb_free_frag(buf);
 err_alloc:
+   /* If we managed to allocate at least some buffers,
+* release them to hardware
+*/
if (i)
goto release_bufs;
 
@@ -811,10 +833,8 @@ static int seed_pool(struct dpaa2_eth_priv *priv, u16 bpid)
  */
 static void drain_bufs(struct dpaa2_eth_priv *priv, int count)
 {
-   struct device *dev = priv->net_dev->dev.parent;
u64 buf_array[DPAA2_ETH_BUFS_PER_CMD];
-   void *vaddr;
-   int ret, i;
+   int ret;
 
do {
ret = dpaa2_io_service_acquire(NULL, priv->bpid,
@@ -823,15 +843,7 @@ static void drain_bufs(struct dpaa2_eth_priv *priv, int 
count)
netdev_err(priv->net_dev, "dpaa2_io_service_acquire() 
failed\n");
return;
}
-   for (i = 0; i < ret; i++) {
-   /* Same logic as on regular Rx path */
-   vaddr = dpaa2_iova_to_virt(priv->iommu_domain,
-  buf_array[i]);
-   dma_unmap_single(dev, buf_array[i],
-DPAA2_ETH_RX_BUF_SIZE,
-DMA_FROM_DEVICE);
-   skb_free_frag(vaddr);
-   }
+   free_bufs(priv, buf_array, ret);
} while (ret);
 }
 
-- 
2.7.4

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


[PATCH 2/9] staging: fsl-dpaa2/eth: Account for Rx FD buffers on error path

2017-10-11 Thread Ioana Radulescu
On Rx path, if we fail to build an skb from the incoming FD,
we still need to update the channel buffer count accordingly,
otherwise we risk depleting the pool while the software counter
still sees available buffers.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 801ba07..e9fe1c9 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -131,6 +131,8 @@ static struct sk_buff *build_linear_skb(struct 
dpaa2_eth_priv *priv,
u16 fd_offset = dpaa2_fd_get_offset(fd);
u32 fd_length = dpaa2_fd_get_len(fd);
 
+   ch->buf_count--;
+
skb = build_skb(fd_vaddr, DPAA2_ETH_RX_BUF_SIZE +
SKB_DATA_ALIGN(sizeof(struct skb_shared_info)));
if (unlikely(!skb))
@@ -139,8 +141,6 @@ static struct sk_buff *build_linear_skb(struct 
dpaa2_eth_priv *priv,
skb_reserve(skb, fd_offset);
skb_put(skb, fd_length);
 
-   ch->buf_count--;
-
return skb;
 }
 
@@ -178,8 +178,15 @@ static struct sk_buff *build_frag_skb(struct 
dpaa2_eth_priv *priv,
/* We build the skb around the first data buffer */
skb = build_skb(sg_vaddr, DPAA2_ETH_RX_BUF_SIZE +
SKB_DATA_ALIGN(sizeof(struct skb_shared_info)));
-   if (unlikely(!skb))
-   return NULL;
+   if (unlikely(!skb)) {
+   /* We still need to subtract the buffers used
+* by this FD from our software counter
+*/
+   while (!dpaa2_sg_is_final([i]) &&
+  i < DPAA2_ETH_MAX_SG_ENTRIES)
+   i++;
+   break;
+   }
 
sg_offset = dpaa2_sg_get_offset(sge);
skb_reserve(skb, sg_offset);
-- 
2.7.4

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


[PATCH 5/9] staging: fsl-dpaa2/eth: Refactor interrupt arming in NAPI poll

2017-10-11 Thread Ioana Radulescu
Take into consideration the return value of napi_complete_done(),
since there might be an indication that it's not suitable to
enable driver interrupts yet.

Signed-off-by: Bogdan Purcareata 
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index f390de6..a0be9ab 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -948,8 +948,7 @@ static int dpaa2_eth_poll(struct napi_struct *napi, int 
budget)
break;
}
 
-   if (cleaned < budget) {
-   napi_complete_done(napi, cleaned);
+   if (cleaned < budget && napi_complete_done(napi, cleaned)) {
/* Re-enable data available notifications */
do {
err = dpaa2_io_service_rearm(NULL, >nctx);
-- 
2.7.4

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


[PATCH 3/9] staging: fsl-dpaa2/eth: Check SGT final bit is present

2017-10-11 Thread Ioana Radulescu
For scatter-gather ingress frames, we expect to receive
a list of fragments from the hardware, last of which is
marked with a "final" bit.

Add a check to make sure the Rx frame has this bit set
correctly; there's not much we can do in case of a
malformed frame, but at least issue a warning.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index e9fe1c9..6f009d1 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -213,6 +213,8 @@ static struct sk_buff *build_frag_skb(struct dpaa2_eth_priv 
*priv,
break;
}
 
+   WARN_ONCE(i == DPAA2_ETH_MAX_SG_ENTRIES, "Final bit not set in SGT");
+
/* Count all data buffers + SG table buffer */
ch->buf_count -= i + 2;
 
-- 
2.7.4

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


[PATCH 4/9] staging: fsl-dpaa2/eth: Check if notification rearm is successful

2017-10-11 Thread Ioana Radulescu
In case dpaa2_io_service_rearm() fails with an error other then
EBUSY, it will do so silently; add a check for this and a warning
message, as a failure here means we're unable to receive any
more traffic on the current cpu.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 6f009d1..f390de6 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -955,6 +955,8 @@ static int dpaa2_eth_poll(struct napi_struct *napi, int 
budget)
err = dpaa2_io_service_rearm(NULL, >nctx);
cpu_relax();
} while (err == -EBUSY);
+   WARN_ONCE(err, "CDAN notifications rearm failed on core %d",
+ ch->nctx.desired_cpu);
}
 
ch->stats.frames += cleaned;
-- 
2.7.4

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


[PATCH 8/9] staging: fsl-dpaa2/eth: Don't use netdev_err too early

2017-10-11 Thread Ioana Radulescu
Early during probe the netdevice name is not initialized yet,
so use dev_err instead of netdev_err when printing error
messages.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 3a8bad1..9fbc0ee 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -2114,7 +2114,7 @@ static int bind_dpni(struct dpaa2_eth_priv *priv)
 */
err = dpaa2_eth_set_hash(net_dev, DPAA2_RXH_SUPPORTED);
if (err)
-   netdev_err(net_dev, "Failed to configure hashing\n");
+   dev_err(dev, "Failed to configure hashing\n");
 
/* Configure handling of error frames */
err_cfg.errors = DPAA2_FAS_RX_ERR_MASK;
-- 
2.7.4

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


[PATCH 6/9] staging: fsl-dpaa2/eth: Fix double DMA unmap

2017-10-11 Thread Ioana Radulescu
In case we fail to allocate a skb for a fragmented ingress
frame, the cleanup function will attempt to unmap again the
first frame fragment, which had already been unmapped during
early Rx processing.

Avoid this by freeing the first buffer immediately in case
we hit an error, leaving the cleanup function to free only
the subsequent buffers.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index a0be9ab..6540ab0 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -104,9 +104,11 @@ static void free_rx_fd(struct dpaa2_eth_priv *priv,
/* We don't support any other format */
return;
 
-   /* For S/G frames, we first need to free all SG entries */
+   /* For S/G frames, we first need to free all SG entries
+* except the first one, which was taken care of already
+*/
sgt = vaddr + dpaa2_fd_get_offset(fd);
-   for (i = 0; i < DPAA2_ETH_MAX_SG_ENTRIES; i++) {
+   for (i = 1; i < DPAA2_ETH_MAX_SG_ENTRIES; i++) {
addr = dpaa2_sg_get_addr([i]);
sg_vaddr = dpaa2_iova_to_virt(priv->iommu_domain, addr);
dma_unmap_single(dev, addr, DPAA2_ETH_RX_BUF_SIZE,
@@ -179,6 +181,11 @@ static struct sk_buff *build_frag_skb(struct 
dpaa2_eth_priv *priv,
skb = build_skb(sg_vaddr, DPAA2_ETH_RX_BUF_SIZE +
SKB_DATA_ALIGN(sizeof(struct skb_shared_info)));
if (unlikely(!skb)) {
+   /* Free the first SG entry now, since we already
+* unmapped it and obtained the virtual address
+*/
+   skb_free_frag(sg_vaddr);
+
/* We still need to subtract the buffers used
 * by this FD from our software counter
 */
-- 
2.7.4

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


[PATCH v2] staging: fsl-mc/dpio: Fix incorrect comparison

2017-09-28 Thread Ioana Radulescu
For some dpio functions, a cpu id parameter value of -1 is
valid and means "any". But when trying to validate this param
value against an upper limit, in this case num_possible_cpus(),
we risk obtaining the wrong result due to an implicit cast.

Avoid an incorrect check result by explicitly comparing the
cpu id with the "any" value before verifying the upper bound.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
v2:
 - make condition more clear (as suggested by Dan Carpenter)
 - don't use unlikely()

 drivers/staging/fsl-mc/bus/dpio/dpio-service.c | 4 ++--
 drivers/staging/fsl-mc/include/dpaa2-io.h  | 6 --
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c 
b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
index f809682..a609ec8 100644
--- a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
+++ b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
@@ -76,7 +76,7 @@ static inline struct dpaa2_io *service_select_by_cpu(struct 
dpaa2_io *d,
if (d)
return d;
 
-   if (unlikely(cpu >= num_possible_cpus()))
+   if (cpu != DPAA2_IO_ANY_CPU && cpu >= num_possible_cpus())
return NULL;
 
/*
@@ -121,7 +121,7 @@ struct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc 
*desc)
return NULL;
 
/* check if CPU is out of range (-1 means any cpu) */
-   if (desc->cpu >= num_possible_cpus()) {
+   if (desc->cpu != DPAA2_IO_ANY_CPU && desc->cpu >= num_possible_cpus()) {
kfree(obj);
return NULL;
}
diff --git a/drivers/staging/fsl-mc/include/dpaa2-io.h 
b/drivers/staging/fsl-mc/include/dpaa2-io.h
index c564609..afc2d06 100644
--- a/drivers/staging/fsl-mc/include/dpaa2-io.h
+++ b/drivers/staging/fsl-mc/include/dpaa2-io.h
@@ -54,6 +54,8 @@ struct device;
  * for dequeue.
  */
 
+#define DPAA2_IO_ANY_CPU   -1
+
 /**
  * struct dpaa2_io_desc - The DPIO descriptor
  * @receives_notifications: Use notificaton mode. Non-zero if the DPIO
@@ -91,8 +93,8 @@ irqreturn_t dpaa2_io_irq(struct dpaa2_io *obj);
  * @cb:   The callback to be invoked when the notification arrives
  * @is_cdan:  Zero for FQDAN, non-zero for CDAN
  * @id:   FQID or channel ID, needed for rearm
- * @desired_cpu:  The cpu on which the notifications will show up. -1 means
- *any CPU.
+ * @desired_cpu:  The cpu on which the notifications will show up. Use
+ *DPAA2_IO_ANY_CPU if don't care
  * @dpio_id:  The dpio index
  * @qman64:   The 64-bit context value shows up in the FQDAN/CDAN.
  * @node: The list node
-- 
2.7.4

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


RE: [PATCH] staging: fsl-mc/dpio: Fix incorrect comparison

2017-09-28 Thread Ruxandra Ioana Radulescu
> -Original Message-
> From: gre...@linuxfoundation.org [mailto:gre...@linuxfoundation.org]
> Sent: Thursday, September 28, 2017 4:18 PM
> To: Ruxandra Ioana Radulescu <ruxandra.radule...@nxp.com>
> Cc: Dan Carpenter <dan.carpen...@oracle.com>;
> de...@driverdev.osuosl.org; a...@arndb.de; stuyo...@gmail.com; Roy
> Pledge <roy.ple...@nxp.com>; linux-ker...@vger.kernel.org;
> ag...@suse.de; Bogdan Purcareata <bogdan.purcare...@nxp.com>;
> Laurentiu Tudor <laurentiu.tu...@nxp.com>
> Subject: Re: [PATCH] staging: fsl-mc/dpio: Fix incorrect comparison
> 
> On Thu, Sep 28, 2017 at 01:07:48PM +, Ruxandra Ioana Radulescu wrote:
> > > -Original Message-
> > > From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
> > > Sent: Thursday, September 28, 2017 3:49 PM
> > > To: Ruxandra Ioana Radulescu <ruxandra.radule...@nxp.com>
> > > Cc: gre...@linuxfoundation.org; de...@driverdev.osuosl.org;
> > > a...@arndb.de; stuyo...@gmail.com; Roy Pledge
> <roy.ple...@nxp.com>;
> > > linux-ker...@vger.kernel.org; ag...@suse.de; Bogdan Purcareata
> > > <bogdan.purcare...@nxp.com>; Laurentiu Tudor
> > > <laurentiu.tu...@nxp.com>
> > > Subject: Re: [PATCH] staging: fsl-mc/dpio: Fix incorrect comparison
> > >
> > > On Wed, Sep 27, 2017 at 12:57:28PM -0500, Ioana Radulescu wrote:
> > > > diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
> > > b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
> > > > index f809682..26922fc 100644
> > > > --- a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
> > > > +++ b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
> > > > @@ -76,7 +76,7 @@ static inline struct dpaa2_io
> > > *service_select_by_cpu(struct dpaa2_io *d,
> > > > if (d)
> > > > return d;
> > > >
> > > > -   if (unlikely(cpu >= num_possible_cpus()))
> > > > +   if (unlikely(cpu >= (int)num_possible_cpus()))
> > >
> > >
> > > Drivers shouldn't use likely/unlikley.
> >
> > I was under the impression it's ok to use them on hotpath
> > (and while not entirely obvious, this function is called on
> > other drivers' hotpath).
> 
> Only use it if you can measure the difference.  If you can not, then do
> not use it as the compiler and the CPU will guess it better than you
> will.
> 
> This has been proven many times, something like 80% of our
> likely/unlikely usage in the kernel is wrong because of this, see the
> work from Andi Kleen many years ago in this area.
> 
> So please remove it.  Unless you can prove it matters, and if so,
> document that.
 
Greg, thanks for the explanation. Will remove it in v2.

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


RE: [PATCH] staging: fsl-mc/dpio: Fix incorrect comparison

2017-09-28 Thread Ruxandra Ioana Radulescu
> -Original Message-
> From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
> Sent: Thursday, September 28, 2017 3:49 PM
> To: Ruxandra Ioana Radulescu <ruxandra.radule...@nxp.com>
> Cc: gre...@linuxfoundation.org; de...@driverdev.osuosl.org;
> a...@arndb.de; stuyo...@gmail.com; Roy Pledge <roy.ple...@nxp.com>;
> linux-ker...@vger.kernel.org; ag...@suse.de; Bogdan Purcareata
> <bogdan.purcare...@nxp.com>; Laurentiu Tudor
> <laurentiu.tu...@nxp.com>
> Subject: Re: [PATCH] staging: fsl-mc/dpio: Fix incorrect comparison
> 
> On Wed, Sep 27, 2017 at 12:57:28PM -0500, Ioana Radulescu wrote:
> > diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
> b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
> > index f809682..26922fc 100644
> > --- a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
> > +++ b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
> > @@ -76,7 +76,7 @@ static inline struct dpaa2_io
> *service_select_by_cpu(struct dpaa2_io *d,
> > if (d)
> > return d;
> >
> > -   if (unlikely(cpu >= num_possible_cpus()))
> > +   if (unlikely(cpu >= (int)num_possible_cpus()))
> 
> 
> Drivers shouldn't use likely/unlikley.
 
I was under the impression it's ok to use them on hotpath
(and while not entirely obvious, this function is called on
other drivers' hotpath).

> Please write it more explicitly like this:
> 
>   if (cpu != -1 && cpu >= num_possible_cpus())
>   return NULL;
> 
> Same for the other one as well.

Will rewrite as you suggested in the second email and send a v2.

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


[PATCH] staging: fsl-mc/dpio: Fix incorrect comparison

2017-09-27 Thread Ioana Radulescu
For some dpio functions, a negative cpu id parameter value is
valid and means "any". But when trying to validate this param
value against an upper limit, in this case num_possible_cpus(),
we risk obtaining the wrong result due to an implicit cast
to unsigned.

Avoid an incorrect check result when cpu id is negative, by
explicitly stating the comparison is between signed values.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-mc/bus/dpio/dpio-service.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c 
b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
index f809682..26922fc 100644
--- a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
+++ b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
@@ -76,7 +76,7 @@ static inline struct dpaa2_io *service_select_by_cpu(struct 
dpaa2_io *d,
if (d)
return d;
 
-   if (unlikely(cpu >= num_possible_cpus()))
+   if (unlikely(cpu >= (int)num_possible_cpus()))
return NULL;
 
/*
@@ -121,7 +121,7 @@ struct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc 
*desc)
return NULL;
 
/* check if CPU is out of range (-1 means any cpu) */
-   if (desc->cpu >= num_possible_cpus()) {
+   if (desc->cpu >= (int)num_possible_cpus()) {
kfree(obj);
return NULL;
}
-- 
2.7.4

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


[PATCH] staging: fsl-dpaa2/eth: Remove dead code

2017-06-29 Thread Ioana Radulescu
All possible values of the switch statement are explicitly
handled, so there's no need to have a default branch.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
index 5312edc26f01..031179ab3a22 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
@@ -217,8 +217,6 @@ static void dpaa2_eth_get_ethtool_stats(struct net_device 
*net_dev,
case 2:
num_cnt = sizeof(dpni_stats.page_2) / sizeof(u64);
break;
-   default:
-   break;
}
for (k = 0; k < num_cnt; k++)
*(data + i++) = dpni_stats.raw.counter[k];
-- 
2.11.0

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


RE: [PATCH] staging: fsl-dpaa2/eth: fix a couple of implicit includes

2017-06-22 Thread Ruxandra Ioana Radulescu
> -Original Message-
> From: laurentiu.tu...@nxp.com [mailto:laurentiu.tu...@nxp.com]
> Sent: Thursday, June 22, 2017 3:52 PM
> To: gre...@linuxfoundation.org; Ruxandra Ioana Radulescu
> <ruxandra.radule...@nxp.com>
> Cc: de...@driverdev.osuosl.org; linux-ker...@vger.kernel.org; Bogdan
> Purcareata <bogdan.purcare...@nxp.com>; Leo Li <leoyang...@nxp.com>;
> stuyo...@gmail.com; Roy Pledge <roy.ple...@nxp.com>; linux-arm-
> ker...@lists.infradead.org; Laurentiu Tudor <laurentiu.tu...@nxp.com>
> Subject: [PATCH] staging: fsl-dpaa2/eth: fix a couple of implicit includes
> 
> From: Laurentiu Tudor <laurentiu.tu...@nxp.com>
> 
> dpni.c is using byte order macros and error codes but does
> not explicitly include the required kernel header, so add it.
> 
> Signed-off-by: Laurentiu Tudor <laurentiu.tu...@nxp.com>
 
Acked-by: Ioana Radulescu <ruxandra.radule...@nxp.com>

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


[PATCH] staging: fsl-mc/dpio: Propagate error code

2017-06-15 Thread Ioana Radulescu
dpaa2_io_service_register() returns zero even if
qbman_swp_CDAN_set() encountered an error. Fix this
by propagating the error code so the caller is informed
data availability notifications are not properly set
for a channel.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-mc/bus/dpio/dpio-service.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c 
b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
index e5d66749614c..762f045f53f7 100644
--- a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
+++ b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
@@ -260,9 +260,9 @@ int dpaa2_io_service_register(struct dpaa2_io *d,
 
/* Enable the generation of CDAN notifications */
if (ctx->is_cdan)
-   qbman_swp_CDAN_set_context_enable(d->swp,
- (u16)ctx->id,
- ctx->qman64);
+   return qbman_swp_CDAN_set_context_enable(d->swp,
+(u16)ctx->id,
+ctx->qman64);
return 0;
 }
 EXPORT_SYMBOL(dpaa2_io_service_register);
-- 
2.11.0

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


RE: [PATCH 15/18] staging: fsl-dpaa2/eth: Reorder priv fields

2017-06-14 Thread Ruxandra Ioana Radulescu
> -Original Message-
> From: Greg KH [mailto:gre...@linuxfoundation.org]
> Sent: Tuesday, June 13, 2017 1:04 PM
> To: Ruxandra Ioana Radulescu <ruxandra.radule...@nxp.com>
> Cc: de...@driverdev.osuosl.org; stuyo...@gmail.com; a...@arndb.de;
> linux-ker...@vger.kernel.org; ag...@suse.de; Bharat Bhushan
> <bharat.bhus...@nxp.com>; Bogdan Purcareata
> <bogdan.purcare...@nxp.com>; linux-arm-ker...@lists.infradead.org;
> Laurentiu Tudor <laurentiu.tu...@nxp.com>
> Subject: Re: [PATCH 15/18] staging: fsl-dpaa2/eth: Reorder priv fields
> 
> On Tue, Jun 06, 2017 at 10:00:38AM -0500, Ioana Radulescu wrote:
> > Reorder fields in the device's private structure such that
> > the ones most used on the hotpath are at the beginning of
> > the structure.
> >
> > This brings a small performance improvement due to better
> > cache usage.
> 
> Really?  What kind of performance improvement?  Always be specific.

Fair point, thanks.

The test scenario was ipfwd with small frames and the improvement ~1%,
but I took this patch from an internal repo, so I need to redo the
measurements on the current tree before resending.

> 
> Please fix up and resend.

We're preparing a larger patchset with several optimizations, I'll
probably include the v2 there.

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


[PATCH 11/18] staging: fsl-dpaa2/eth: Update ethtool stats names

2017-06-06 Thread Ioana Radulescu
Add a label to the ethtool statistics counters, to differentiate
between hardware counters and driver specific ones.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c | 54 +++---
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
index 6a331c74e542..5312edc26f01 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
@@ -35,40 +35,40 @@
 
 /* To be kept in sync with DPNI statistics */
 static char dpaa2_ethtool_stats[][ETH_GSTRING_LEN] = {
-   "rx frames",
-   "rx bytes",
-   "rx mcast frames",
-   "rx mcast bytes",
-   "rx bcast frames",
-   "rx bcast bytes",
-   "tx frames",
-   "tx bytes",
-   "tx mcast frames",
-   "tx mcast bytes",
-   "tx bcast frames",
-   "tx bcast bytes",
-   "rx filtered frames",
-   "rx discarded frames",
-   "rx nobuffer discards",
-   "tx discarded frames",
-   "tx confirmed frames",
+   "[hw] rx frames",
+   "[hw] rx bytes",
+   "[hw] rx mcast frames",
+   "[hw] rx mcast bytes",
+   "[hw] rx bcast frames",
+   "[hw] rx bcast bytes",
+   "[hw] tx frames",
+   "[hw] tx bytes",
+   "[hw] tx mcast frames",
+   "[hw] tx mcast bytes",
+   "[hw] tx bcast frames",
+   "[hw] tx bcast bytes",
+   "[hw] rx filtered frames",
+   "[hw] rx discarded frames",
+   "[hw] rx nobuffer discards",
+   "[hw] tx discarded frames",
+   "[hw] tx confirmed frames",
 };
 
 #define DPAA2_ETH_NUM_STATSARRAY_SIZE(dpaa2_ethtool_stats)
 
 static char dpaa2_ethtool_extras[][ETH_GSTRING_LEN] = {
/* per-cpu stats */
-   "tx conf frames",
-   "tx conf bytes",
-   "tx sg frames",
-   "tx sg bytes",
-   "rx sg frames",
-   "rx sg bytes",
-   "enqueue portal busy",
+   "[drv] tx conf frames",
+   "[drv] tx conf bytes",
+   "[drv] tx sg frames",
+   "[drv] tx sg bytes",
+   "[drv] rx sg frames",
+   "[drv] rx sg bytes",
+   "[drv] enqueue portal busy",
/* Channel stats */
-   "dequeue portal busy",
-   "channel pull errors",
-   "cdan",
+   "[drv] dequeue portal busy",
+   "[drv] channel pull errors",
+   "[drv] cdan",
 };
 
 #define DPAA2_ETH_NUM_EXTRA_STATS  ARRAY_SIZE(dpaa2_ethtool_extras)
-- 
2.11.0

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


[PATCH 15/18] staging: fsl-dpaa2/eth: Reorder priv fields

2017-06-06 Thread Ioana Radulescu
Reorder fields in the device's private structure such that
the ones most used on the hotpath are at the beginning of
the structure.

This brings a small performance improvement due to better
cache usage.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 26 +++---
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
index 886a0681fee1..c760e9b77e22 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
@@ -290,34 +290,30 @@ struct dpaa2_eth_hash_fields {
 /* Driver private data */
 struct dpaa2_eth_priv {
struct net_device *net_dev;
+   /* Standard statistics */
+   struct rtnl_link_stats64 __percpu *percpu_stats;
+   /* Extra stats, in addition to the ones known by the kernel */
+   struct dpaa2_eth_drv_stats __percpu *percpu_extras;
+   struct iommu_domain *iommu_domain;
+   u16 tx_data_offset;
+   u16 bpid;
+   u16 tx_qdid;
 
u8 num_fqs;
-   struct dpaa2_eth_fq fq[DPAA2_ETH_MAX_QUEUES];
-
u8 num_channels;
+   struct dpaa2_eth_fq fq[DPAA2_ETH_MAX_QUEUES];
struct dpaa2_eth_channel *channel[DPAA2_ETH_MAX_DPCONS];
 
+   struct fsl_mc_io *mc_io;
+   u16 mc_token;
struct dpni_attr dpni_attrs;
-   u16 tx_data_offset;
-
struct fsl_mc_device *dpbp_dev;
-   u16 bpid;
-   struct iommu_domain *iommu_domain;
 
-   u16 tx_qdid;
-   struct fsl_mc_io *mc_io;
/* Cores which have an affine DPIO/DPCON.
 * This is the cpu set on which Rx and Tx conf frames are processed
 */
struct cpumask dpio_cpumask;
 
-   /* Standard statistics */
-   struct rtnl_link_stats64 __percpu *percpu_stats;
-   /* Extra stats, in addition to the ones known by the kernel */
-   struct dpaa2_eth_drv_stats __percpu *percpu_extras;
-
-   u16 mc_token;
-
struct dpni_link_state link_state;
bool do_link_poll;
struct task_struct *poll_thread;
-- 
2.11.0

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


[PATCH 03/18] staging: fsl-dpaa2/eth: Fix return type of ndo_start_xmit

2017-06-06 Thread Ioana Radulescu
ndo_start_xmit() returns a value of type netdev_tx_t. Update
our ndo function to use the correct type.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index f0ef3a7c0f73..a9e245df2488 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -551,7 +551,7 @@ static void free_tx_fd(const struct dpaa2_eth_priv *priv,
dev_kfree_skb(skb);
 }
 
-static int dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev)
+static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct net_device 
*net_dev)
 {
struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
struct dpaa2_fd fd;
-- 
2.11.0

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


[PATCH 17/18] staging: fsl-dpaa2/eth: Refactor MAC address setup

2017-06-06 Thread Ioana Radulescu
The driver logic for allocating a MAC address to a net device
is complicated enough to deserve a function of its own. While
here, cleanup a bit the code comments.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 46 --
 1 file changed, 29 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 7dca8c2e5ff9..3f7f61b9c462 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -2162,15 +2162,12 @@ static void free_rings(struct dpaa2_eth_priv *priv)
dpaa2_io_store_destroy(priv->channel[i]->store);
 }
 
-static int netdev_init(struct net_device *net_dev)
+static int set_mac_addr(struct dpaa2_eth_priv *priv)
 {
-   int err;
+   struct net_device *net_dev = priv->net_dev;
struct device *dev = net_dev->dev.parent;
-   struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
u8 mac_addr[ETH_ALEN], dpni_mac_addr[ETH_ALEN];
-   u8 bcast_addr[ETH_ALEN];
-
-   net_dev->netdev_ops = _eth_ops;
+   int err;
 
/* Get firmware address, if any */
err = dpni_get_port_mac_addr(priv->mc_io, 0, priv->mc_token, mac_addr);
@@ -2183,7 +2180,7 @@ static int netdev_init(struct net_device *net_dev)
err = dpni_get_primary_mac_addr(priv->mc_io, 0, priv->mc_token,
dpni_mac_addr);
if (err) {
-   dev_err(dev, "dpni_get_primary_mac_addr() failed (%d)\n", err);
+   dev_err(dev, "dpni_get_primary_mac_addr() failed\n");
return err;
}
 
@@ -2201,18 +2198,19 @@ static int netdev_init(struct net_device *net_dev)
}
memcpy(net_dev->dev_addr, mac_addr, net_dev->addr_len);
} else if (is_zero_ether_addr(dpni_mac_addr)) {
-   /* Fills in net_dev->dev_addr, as required by
-* register_netdevice()
+   /* No MAC address configured, fill in net_dev->dev_addr
+* with a random one
 */
eth_hw_addr_random(net_dev);
-   /* Make the user aware, without cluttering the boot log */
-   dev_dbg_once(dev, " device(s) have all-zero hwaddr, replaced 
with random\n");
+   dev_dbg_once(dev, "device(s) have all-zero hwaddr, replaced 
with random\n");
+
err = dpni_set_primary_mac_addr(priv->mc_io, 0, priv->mc_token,
net_dev->dev_addr);
if (err) {
-   dev_err(dev, "dpni_set_primary_mac_addr(): %d\n", err);
+   dev_err(dev, "dpni_set_primary_mac_addr() failed\n");
return err;
}
+
/* Override NET_ADDR_RANDOM set by eth_hw_addr_random(); for all
 * practical purposes, this will be our "permanent" mac address,
 * at least until the next reboot. This move will also permit
@@ -2226,14 +2224,28 @@ static int netdev_init(struct net_device *net_dev)
memcpy(net_dev->dev_addr, dpni_mac_addr, net_dev->addr_len);
}
 
-   /* Explicitly add the broadcast address to the MAC filtering table;
-* the MC won't do that for us.
-*/
+   return 0;
+}
+
+static int netdev_init(struct net_device *net_dev)
+{
+   struct device *dev = net_dev->dev.parent;
+   struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
+   u8 bcast_addr[ETH_ALEN];
+   int err;
+
+   net_dev->netdev_ops = _eth_ops;
+
+   err = set_mac_addr(priv);
+   if (err)
+   return err;
+
+   /* Explicitly add the broadcast address to the MAC filtering table */
eth_broadcast_addr(bcast_addr);
err = dpni_add_mac_addr(priv->mc_io, 0, priv->mc_token, bcast_addr);
if (err) {
-   dev_warn(dev, "dpni_add_mac_addr() failed (%d)\n", err);
-   /* Won't return an error; at least, we'd have egress traffic */
+   dev_err(dev, "dpni_add_mac_addr() failed\n");
+   return err;
}
 
/* Reserve enough space to align buffer as per hardware requirement;
-- 
2.11.0

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


[PATCH 05/18] staging: fsl-dpaa2/eth: Add error message newlines

2017-06-06 Thread Ioana Radulescu
A few error/warning messages lacked a newline at the end
of the text. Add it for improved consistency and cosmetics.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 14 +++---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c |  6 +++---
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index f63054e071b3..c4252f47d57d 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -975,7 +975,7 @@ static int link_state_update(struct dpaa2_eth_priv *priv)
netif_carrier_off(priv->net_dev);
}
 
-   netdev_info(priv->net_dev, "Link Event: state %s",
+   netdev_info(priv->net_dev, "Link Event: state %s\n",
state.up ? "up" : "down");
 
return 0;
@@ -1806,7 +1806,7 @@ static int setup_dpni(struct fsl_mc_device *ls_dev)
}
 
if ((priv->tx_data_offset % 64) != 0)
-   dev_warn(dev, "Tx data offset (%d) not a multiple of 64B",
+   dev_warn(dev, "Tx data offset (%d) not a multiple of 64B\n",
 priv->tx_data_offset);
 
/* Accommodate software annotation space (SWA) */
@@ -2002,7 +2002,7 @@ static int dpaa2_eth_set_hash(struct net_device *net_dev, 
u64 flags)
 
err = dpni_prepare_key_cfg(_cfg, dma_mem);
if (err) {
-   dev_err(dev, "dpni_prepare_key_cfg error %d", err);
+   dev_err(dev, "dpni_prepare_key_cfg error %d\n", err);
goto err_prep_key;
}
 
@@ -2261,7 +2261,7 @@ static irqreturn_t dpni_irq0_handler_thread(int irq_num, 
void *arg)
err = dpni_get_irq_status(dpni_dev->mc_io, 0, dpni_dev->mc_handle,
  DPNI_IRQ_INDEX, );
if (unlikely(err)) {
-   netdev_err(net_dev, "Can't get irq status (err %d)", err);
+   netdev_err(net_dev, "Can't get irq status (err %d)\n", err);
clear = 0x;
goto out;
}
@@ -2295,21 +2295,21 @@ static int setup_irqs(struct fsl_mc_device *ls_dev)
IRQF_NO_SUSPEND | IRQF_ONESHOT,
dev_name(_dev->dev), _dev->dev);
if (err < 0) {
-   dev_err(_dev->dev, "devm_request_threaded_irq(): %d", err);
+   dev_err(_dev->dev, "devm_request_threaded_irq(): %d\n", err);
goto free_mc_irq;
}
 
err = dpni_set_irq_mask(ls_dev->mc_io, 0, ls_dev->mc_handle,
DPNI_IRQ_INDEX, DPNI_IRQ_EVENT_LINK_CHANGED);
if (err < 0) {
-   dev_err(_dev->dev, "dpni_set_irq_mask(): %d", err);
+   dev_err(_dev->dev, "dpni_set_irq_mask(): %d\n", err);
goto free_irq;
}
 
err = dpni_set_irq_enable(ls_dev->mc_io, 0, ls_dev->mc_handle,
  DPNI_IRQ_INDEX, 1);
if (err < 0) {
-   dev_err(_dev->dev, "dpni_set_irq_enable(): %d", err);
+   dev_err(_dev->dev, "dpni_set_irq_enable(): %d\n", err);
goto free_irq;
}
 
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
index 89888b6115bf..6a331c74e542 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
@@ -94,7 +94,7 @@ dpaa2_eth_get_link_ksettings(struct net_device *net_dev,
 
err = dpni_get_link_state(priv->mc_io, 0, priv->mc_token, );
if (err) {
-   netdev_err(net_dev, "ERROR %d getting link state", err);
+   netdev_err(net_dev, "ERROR %d getting link state\n", err);
goto out;
}
 
@@ -147,7 +147,7 @@ dpaa2_eth_set_link_ksettings(struct net_device *net_dev,
/* ethtool will be loud enough if we return an error; no point
 * in putting our own error message on the console by default
 */
-   netdev_dbg(net_dev, "ERROR %d setting link cfg", err);
+   netdev_dbg(net_dev, "ERROR %d setting link cfg\n", err);
 
return err;
 }
@@ -206,7 +206,7 @@ static void dpaa2_eth_get_ethtool_stats(struct net_device 
*net_dev,
err = dpni_get_statistics(priv->mc_io, 0, priv->mc_token,
  j, _stats);
if (err != 0)
-   netdev_warn(net_dev, "dpni_get_stats(%d) failed", j);
+   ne

[PATCH 09/18] staging: fsl-dpaa2/eth: Reset dpbp

2017-06-06 Thread Ioana Radulescu
Reset the buffer pool object before using it, like we do
for the other DPAA2 objects.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index d3ec384c7364..fd56fbd20087 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -1687,6 +1687,12 @@ static int setup_dpbp(struct dpaa2_eth_priv *priv)
goto err_open;
}
 
+   err = dpbp_reset(priv->mc_io, 0, dpbp_dev->mc_handle);
+   if (err) {
+   dev_err(dev, "dpbp_reset() failed\n");
+   goto err_reset;
+   }
+
err = dpbp_enable(priv->mc_io, 0, dpbp_dev->mc_handle);
if (err) {
dev_err(dev, "dpbp_enable() failed\n");
@@ -1705,6 +1711,7 @@ static int setup_dpbp(struct dpaa2_eth_priv *priv)
 err_get_attr:
dpbp_disable(priv->mc_io, 0, dpbp_dev->mc_handle);
 err_enable:
+err_reset:
dpbp_close(priv->mc_io, 0, dpbp_dev->mc_handle);
 err_open:
fsl_mc_object_free(dpbp_dev);
-- 
2.11.0

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


[PATCH 01/18] staging: fsl-dpaa2/eth: Add "static" keyword where needed

2017-06-06 Thread Ioana Radulescu
Make a couple of locally used functions and structures static.
Issue found through static analysis tool.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 6 +++---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 2 --
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c | 4 ++--
 3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 49c435bad706..8ff8951f31b9 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -1162,8 +1162,8 @@ static int dpaa2_eth_set_addr(struct net_device *net_dev, 
void *addr)
 /** Fill in counters maintained by the GPP driver. These may be different from
  * the hardware counters obtained by ethtool.
  */
-void dpaa2_eth_get_stats(struct net_device *net_dev,
-struct rtnl_link_stats64 *stats)
+static void dpaa2_eth_get_stats(struct net_device *net_dev,
+   struct rtnl_link_stats64 *stats)
 {
struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
struct rtnl_link_stats64 *percpu_stats;
@@ -1958,7 +1958,7 @@ static const struct dpaa2_eth_hash_fields hash_fields[] = 
{
 /* Set RX hash options
  * flags is a combination of RXH_ bits
  */
-int dpaa2_eth_set_hash(struct net_device *net_dev, u64 flags)
+static int dpaa2_eth_set_hash(struct net_device *net_dev, u64 flags)
 {
struct device *dev = net_dev->dev.parent;
struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
index 55b47623008c..539da71470d9 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
@@ -339,8 +339,6 @@ struct dpaa2_eth_priv {
 extern const struct ethtool_ops dpaa2_ethtool_ops;
 extern const char dpaa2_eth_drv_version[];
 
-int dpaa2_eth_set_hash(struct net_device *net_dev, u64 flags);
-
 static int dpaa2_eth_queue_count(struct dpaa2_eth_priv *priv)
 {
return priv->dpni_attrs.num_queues;
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
index dd0cffa908ef..89888b6115bf 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
@@ -34,7 +34,7 @@
 #include "dpaa2-eth.h"
 
 /* To be kept in sync with DPNI statistics */
-char dpaa2_ethtool_stats[][ETH_GSTRING_LEN] = {
+static char dpaa2_ethtool_stats[][ETH_GSTRING_LEN] = {
"rx frames",
"rx bytes",
"rx mcast frames",
@@ -56,7 +56,7 @@ char dpaa2_ethtool_stats[][ETH_GSTRING_LEN] = {
 
 #define DPAA2_ETH_NUM_STATSARRAY_SIZE(dpaa2_ethtool_stats)
 
-char dpaa2_ethtool_extras[][ETH_GSTRING_LEN] = {
+static char dpaa2_ethtool_extras[][ETH_GSTRING_LEN] = {
/* per-cpu stats */
"tx conf frames",
"tx conf bytes",
-- 
2.11.0

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


[PATCH 12/18] staging: fsl-dpaa2/eth: Add accessor for FAS field

2017-06-06 Thread Ioana Radulescu
Introduce a helper macro for accessing the frame annotation
status field in a frame buffer.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 31 --
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h |  6 +
 2 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 025b5f6559a4..d81c56f4d859 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -227,6 +227,7 @@ static void dpaa2_eth_rx(struct dpaa2_eth_priv *priv,
struct dpaa2_eth_drv_stats *percpu_extras;
struct device *dev = priv->net_dev->dev.parent;
struct dpaa2_fas *fas;
+   void *buf_data;
u32 status = 0;
 
/* Tracing point */
@@ -235,8 +236,10 @@ static void dpaa2_eth_rx(struct dpaa2_eth_priv *priv,
vaddr = dpaa2_iova_to_virt(priv->iommu_domain, addr);
dma_unmap_single(dev, addr, DPAA2_ETH_RX_BUF_SIZE, DMA_FROM_DEVICE);
 
-   prefetch(vaddr + priv->buf_layout.private_data_size);
-   prefetch(vaddr + dpaa2_fd_get_offset(fd));
+   fas = dpaa2_get_fas(vaddr);
+   prefetch(fas);
+   buf_data = vaddr + dpaa2_fd_get_offset(fd);
+   prefetch(buf_data);
 
percpu_stats = this_cpu_ptr(priv->percpu_stats);
percpu_extras = this_cpu_ptr(priv->percpu_extras);
@@ -244,9 +247,7 @@ static void dpaa2_eth_rx(struct dpaa2_eth_priv *priv,
if (fd_format == dpaa2_fd_single) {
skb = build_linear_skb(priv, ch, fd, vaddr);
} else if (fd_format == dpaa2_fd_sg) {
-   struct dpaa2_sg_entry *sgt =
-   vaddr + dpaa2_fd_get_offset(fd);
-   skb = build_frag_skb(priv, ch, sgt);
+   skb = build_frag_skb(priv, ch, buf_data);
skb_free_frag(vaddr);
percpu_extras->rx_sg_frames++;
percpu_extras->rx_sg_bytes += dpaa2_fd_get_len(fd);
@@ -262,8 +263,6 @@ static void dpaa2_eth_rx(struct dpaa2_eth_priv *priv,
 
/* Check if we need to validate the L4 csum */
if (likely(dpaa2_fd_get_frc(fd) & DPAA2_FD_FRC_FASV)) {
-   fas = (struct dpaa2_fas *)
-   (vaddr + priv->buf_layout.private_data_size);
status = le32_to_cpu(fas->status);
validate_rx_csum(priv, status, skb);
}
@@ -327,7 +326,6 @@ static int build_sg_fd(struct dpaa2_eth_priv *priv,
 {
struct device *dev = priv->net_dev->dev.parent;
void *sgt_buf = NULL;
-   void *hwa;
dma_addr_t addr;
int nr_frags = skb_shinfo(skb)->nr_frags;
struct dpaa2_sg_entry *sgt;
@@ -337,6 +335,7 @@ static int build_sg_fd(struct dpaa2_eth_priv *priv,
int num_sg;
int num_dma_bufs;
struct dpaa2_eth_swa *swa;
+   struct dpaa2_fas *fas;
 
/* Create and map scatterlist.
 * We don't advertise NETIF_F_FRAGLIST, so skb_to_sgvec() will not have
@@ -373,8 +372,8 @@ static int build_sg_fd(struct dpaa2_eth_priv *priv,
 * on TX confirmation. We are clearing FAS (Frame Annotation Status)
 * field from the hardware annotation area
 */
-   hwa = sgt_buf + priv->buf_layout.private_data_size;
-   memset(hwa + DPAA2_FAS_OFFSET, 0, DPAA2_FAS_SIZE);
+   fas = dpaa2_get_fas(sgt_buf);
+   memset(fas, 0, DPAA2_FAS_SIZE);
 
sgt = (struct dpaa2_sg_entry *)(sgt_buf + priv->tx_data_offset);
 
@@ -433,7 +432,7 @@ static int build_single_fd(struct dpaa2_eth_priv *priv,
 {
struct device *dev = priv->net_dev->dev.parent;
u8 *buffer_start;
-   void *hwa;
+   struct dpaa2_fas *fas;
struct sk_buff **skbh;
dma_addr_t addr;
 
@@ -446,8 +445,8 @@ static int build_single_fd(struct dpaa2_eth_priv *priv,
 * on TX confirmation. We are clearing FAS (Frame Annotation Status)
 * field from the hardware annotation area
 */
-   hwa = buffer_start + priv->buf_layout.private_data_size;
-   memset(hwa + DPAA2_FAS_OFFSET, 0, DPAA2_FAS_SIZE);
+   fas = dpaa2_get_fas(buffer_start);
+   memset(fas, 0, DPAA2_FAS_SIZE);
 
/* Store a backpointer to the skb at the beginning of the buffer
 * (in the private data area) such that we can release it
@@ -498,6 +497,7 @@ static void free_tx_fd(const struct dpaa2_eth_priv *priv,
 
fd_addr = dpaa2_fd_get_addr(fd);
skbh = dpaa2_iova_to_virt(priv->iommu_domain, fd_addr);
+   fas = dpaa2_get_fas(skbh);
 
if (fd_format == dpaa2_fd_single) {
skb = *skbh;
@@ -534,11 +534,8 @@ static void free_tx_fd(const struct dpaa2_eth_priv *priv,
 * buffer but before we free it. The caller function is responsible
 * for checking the status value.

[PATCH 18/18] staging: fsl-dpaa2/eth: Update number of netdev queues

2017-06-06 Thread Ioana Radulescu
Currently, the netdevice is allocated with a default number of Rx/Tx
queues equal to CONFIG_NR_CPUS, meaning the maximum number of cores
supported by the current kernel. The actual number of queues is
reflected by the DPNI object attribute, so update the netdevice
configuration based on that.

Signed-off-by: Bogdan Purcareata <bogdan.purcare...@nxp.com>
Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 3f7f61b9c462..224f3937f313 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -2232,6 +2232,7 @@ static int netdev_init(struct net_device *net_dev)
struct device *dev = net_dev->dev.parent;
struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
u8 bcast_addr[ETH_ALEN];
+   u8 num_queues;
int err;
 
net_dev->netdev_ops = _eth_ops;
@@ -2257,6 +2258,19 @@ static int netdev_init(struct net_device *net_dev)
net_dev->min_mtu = 68;
net_dev->max_mtu = DPAA2_ETH_MAX_MTU;
 
+   /* Set actual number of queues in the net device */
+   num_queues = dpaa2_eth_queue_count(priv);
+   err = netif_set_real_num_tx_queues(net_dev, num_queues);
+   if (err) {
+   dev_err(dev, "netif_set_real_num_tx_queues() failed\n");
+   return err;
+   }
+   err = netif_set_real_num_rx_queues(net_dev, num_queues);
+   if (err) {
+   dev_err(dev, "netif_set_real_num_rx_queues() failed\n");
+   return err;
+   }
+
/* Our .ndo_init will be called herein */
err = register_netdev(net_dev);
if (err < 0) {
-- 
2.11.0

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


[PATCH 02/18] staging: fsl-dpaa2/eth: Initialize variable before use

2017-06-06 Thread Ioana Radulescu
In dpni_get_irq_status(), status is both in and out parameter,
so initialize before use.
Issue found through static analysis tool.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 8ff8951f31b9..f0ef3a7c0f73 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -2252,7 +2252,7 @@ static irqreturn_t dpni_irq0_handler(int irq_num, void 
*arg)
 
 static irqreturn_t dpni_irq0_handler_thread(int irq_num, void *arg)
 {
-   u32 status, clear = 0;
+   u32 status = 0, clear = 0;
struct device *dev = (struct device *)arg;
struct fsl_mc_device *dpni_dev = to_fsl_mc_device(dev);
struct net_device *net_dev = dev_get_drvdata(dev);
-- 
2.11.0

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


[PATCH 06/18] staging: fsl-dpaa2/eth: Minor cleanup in dpaa2_eth_set_hash

2017-06-06 Thread Ioana Radulescu
We already have a variable for the DMA mapping device,
so use that directly.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index c4252f47d57d..bf6f300affa7 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -2009,10 +2009,10 @@ static int dpaa2_eth_set_hash(struct net_device 
*net_dev, u64 flags)
memset(_cfg, 0, sizeof(dist_cfg));
 
/* Prepare for setting the rx dist */
-   dist_cfg.key_cfg_iova = dma_map_single(net_dev->dev.parent, dma_mem,
+   dist_cfg.key_cfg_iova = dma_map_single(dev, dma_mem,
   DPAA2_CLASSIFIER_DMA_SIZE,
   DMA_TO_DEVICE);
-   if (dma_mapping_error(net_dev->dev.parent, dist_cfg.key_cfg_iova)) {
+   if (dma_mapping_error(dev, dist_cfg.key_cfg_iova)) {
dev_err(dev, "DMA mapping failed\n");
err = -ENOMEM;
goto err_dma_map;
@@ -2022,7 +2022,7 @@ static int dpaa2_eth_set_hash(struct net_device *net_dev, 
u64 flags)
dist_cfg.dist_mode = DPNI_DIST_MODE_HASH;
 
err = dpni_set_rx_tc_dist(priv->mc_io, 0, priv->mc_token, 0, _cfg);
-   dma_unmap_single(net_dev->dev.parent, dist_cfg.key_cfg_iova,
+   dma_unmap_single(dev, dist_cfg.key_cfg_iova,
 DPAA2_CLASSIFIER_DMA_SIZE, DMA_TO_DEVICE);
if (err)
dev_err(dev, "dpni_set_rx_tc_dist() error %d\n", err);
-- 
2.11.0

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


[PATCH 14/18] staging: fsl-dpaa2/eth: Only store bpid in priv struct

2017-06-06 Thread Ioana Radulescu
We only need to know the buffer pool id, so save exactly
that in the device's private structure, instead of the
entire DPBP attributes struct.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 12 +++-
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h |  2 +-
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index ee71e158b0a9..26f209c78ff9 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -798,7 +798,7 @@ static void drain_bufs(struct dpaa2_eth_priv *priv, int 
count)
int ret, i;
 
do {
-   ret = dpaa2_io_service_acquire(NULL, priv->dpbp_attrs.bpid,
+   ret = dpaa2_io_service_acquire(NULL, priv->bpid,
   buf_array, count);
if (ret < 0) {
netdev_err(priv->net_dev, "dpaa2_io_service_acquire() 
failed\n");
@@ -895,7 +895,7 @@ static int dpaa2_eth_poll(struct napi_struct *napi, int 
budget)
break;
 
/* Refill pool if appropriate */
-   refill_pool(priv, ch, priv->dpbp_attrs.bpid);
+   refill_pool(priv, ch, priv->bpid);
 
store_cleaned = consume_frames(ch);
cleaned += store_cleaned;
@@ -980,14 +980,14 @@ static int dpaa2_eth_open(struct net_device *net_dev)
struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
int err;
 
-   err = seed_pool(priv, priv->dpbp_attrs.bpid);
+   err = seed_pool(priv, priv->bpid);
if (err) {
/* Not much to do; the buffer pool, though not filled up,
 * may still contain some buffers which would enable us
 * to limp on.
 */
netdev_err(net_dev, "Buffer seeding failed for DPBP %d 
(bpid=%d)\n",
-  priv->dpbp_dev->obj_desc.id, priv->dpbp_attrs.bpid);
+  priv->dpbp_dev->obj_desc.id, priv->bpid);
}
 
/* We'll only start the txqs when the link is actually ready; make sure
@@ -1671,6 +1671,7 @@ static int setup_dpbp(struct dpaa2_eth_priv *priv)
int err;
struct fsl_mc_device *dpbp_dev;
struct device *dev = priv->net_dev->dev.parent;
+   struct dpbp_attr dpbp_attrs;
 
err = fsl_mc_object_allocate(to_fsl_mc_device(dev), FSL_MC_POOL_DPBP,
 _dev);
@@ -1701,11 +1702,12 @@ static int setup_dpbp(struct dpaa2_eth_priv *priv)
}
 
err = dpbp_get_attributes(priv->mc_io, 0, dpbp_dev->mc_handle,
- >dpbp_attrs);
+ _attrs);
if (err) {
dev_err(dev, "dpbp_get_attributes() failed\n");
goto err_get_attr;
}
+   priv->bpid = dpbp_attrs.bpid;
 
return 0;
 
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
index 6697b508cf23..886a0681fee1 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
@@ -301,7 +301,7 @@ struct dpaa2_eth_priv {
u16 tx_data_offset;
 
struct fsl_mc_device *dpbp_dev;
-   struct dpbp_attr dpbp_attrs;
+   u16 bpid;
struct iommu_domain *iommu_domain;
 
u16 tx_qdid;
-- 
2.11.0

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


[PATCH 16/18] staging: fsl-dpaa2/eth: Errors checking update

2017-06-06 Thread Ioana Radulescu
On the egress path, frame errors are reported using both a FD control
field and the frame annotation status. The current code only handles
FAS errors. Update to look at both fields when accounting Tx errors.

Signed-off-by: Bogdan Purcareata <bogdan.purcare...@nxp.com>
Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
Note: Checkpatch complains about a macro(DPAA2_FAS_RX_ERR_MASK) being
too complex. It's just a bitmask with all possible Rx FAS error bits
and I'm not sure how the extra parantheses recommended by checkpatch
would help, so leaving it as is.

 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 36 --
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 17 ++--
 2 files changed, 43 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 26f209c78ff9..7dca8c2e5ff9 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -534,7 +534,7 @@ static void free_tx_fd(const struct dpaa2_eth_priv *priv,
 * buffer but before we free it. The caller function is responsible
 * for checking the status value.
 */
-   if (status && (dpaa2_fd_get_frc(fd) & DPAA2_FD_FRC_FASV))
+   if (status)
*status = le32_to_cpu(fas->status);
 
/* Free SGT buffer kmalloc'ed on tx */
@@ -638,6 +638,8 @@ static void dpaa2_eth_tx_conf(struct dpaa2_eth_priv *priv,
struct rtnl_link_stats64 *percpu_stats;
struct dpaa2_eth_drv_stats *percpu_extras;
u32 status = 0;
+   u32 fd_errors;
+   bool has_fas_errors = false;
 
/* Tracing point */
trace_dpaa2_tx_conf_fd(priv->net_dev, fd);
@@ -646,13 +648,31 @@ static void dpaa2_eth_tx_conf(struct dpaa2_eth_priv *priv,
percpu_extras->tx_conf_frames++;
percpu_extras->tx_conf_bytes += dpaa2_fd_get_len(fd);
 
-   free_tx_fd(priv, fd, );
-
-   if (unlikely(status & DPAA2_ETH_TXCONF_ERR_MASK)) {
-   percpu_stats = this_cpu_ptr(priv->percpu_stats);
-   /* Tx-conf logically pertains to the egress path. */
-   percpu_stats->tx_errors++;
+   /* Check frame errors in the FD field */
+   fd_errors = dpaa2_fd_get_ctrl(fd) & DPAA2_FD_TX_ERR_MASK;
+   if (unlikely(fd_errors)) {
+   /* We only check error bits in the FAS field if corresponding
+* FAERR bit is set in FD and the FAS field is marked as valid
+*/
+   has_fas_errors = (fd_errors & DPAA2_FD_CTRL_FAERR) &&
+!!(dpaa2_fd_get_frc(fd) & DPAA2_FD_FRC_FASV);
+   if (net_ratelimit())
+   netdev_dbg(priv->net_dev, "TX frame FD error: %x08\n",
+  fd_errors);
}
+
+   free_tx_fd(priv, fd, has_fas_errors ?  : NULL);
+
+   if (likely(!fd_errors))
+   return;
+
+   percpu_stats = this_cpu_ptr(priv->percpu_stats);
+   /* Tx-conf logically pertains to the egress path. */
+   percpu_stats->tx_errors++;
+
+   if (has_fas_errors && net_ratelimit())
+   netdev_dbg(priv->net_dev, "TX frame FAS error: %x08\n",
+  status & DPAA2_FAS_TX_ERR_MASK);
 }
 
 static int set_rx_csum(struct dpaa2_eth_priv *priv, bool enable)
@@ -2069,7 +2089,7 @@ static int bind_dpni(struct dpaa2_eth_priv *priv)
netdev_err(net_dev, "Failed to configure hashing\n");
 
/* Configure handling of error frames */
-   err_cfg.errors = DPAA2_ETH_RX_ERR_MASK;
+   err_cfg.errors = DPAA2_FAS_RX_ERR_MASK;
err_cfg.set_frame_annotation = 1;
err_cfg.error_action = DPNI_ERROR_ACTION_DISCARD;
err = dpni_set_errors_behavior(priv->mc_io, 0, priv->mc_token,
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
index c760e9b77e22..b492c8723bb6 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
@@ -120,6 +120,19 @@ struct dpaa2_eth_swa {
 #define DPAA2_FD_FRC_FASWOV0x0800
 #define DPAA2_FD_FRC_FAICFDV   0x0400
 
+/* Error bits in FD CTRL */
+#define DPAA2_FD_CTRL_UFD  0x0004
+#define DPAA2_FD_CTRL_SBE  0x0008
+#define DPAA2_FD_CTRL_FSE  0x0010
+#define DPAA2_FD_CTRL_FAERR0x0020
+
+#define DPAA2_FD_RX_ERR_MASK   (DPAA2_FD_CTRL_SBE  | \
+DPAA2_FD_CTRL_FAERR)
+#define DPAA2_FD_TX_ERR_MASK   (DPAA2_FD_CTRL_UFD  | \
+DPAA2_FD_CTRL_SBE  | \
+DPAA2_FD_CTRL_FSE  | \
+

[PATCH 10/18] staging: fsl-dpaa2/eth: Defer probing if no DPIOs found

2017-06-06 Thread Ioana Radulescu
If the Ethernet driver doesn't find any DPIO devices during probe,
it may be either because there's none available or because they
haven't been probed yet. Request deferred probing in case it's
the latter.

Signed-off-by: Bharat Bhushan <bharat.bhus...@nxp.com>
Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index fd56fbd20087..025b5f6559a4 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -1510,6 +1510,7 @@ static int setup_dpio(struct dpaa2_eth_priv *priv)
if (!channel) {
dev_info(dev,
 "No affine channel for cpu %d and above\n", i);
+   err = -ENODEV;
goto err_alloc_ch;
}
 
@@ -1524,10 +1525,13 @@ static int setup_dpio(struct dpaa2_eth_priv *priv)
/* Register the new context */
err = dpaa2_io_service_register(NULL, nctx);
if (err) {
-   dev_info(dev, "No affine DPIO for cpu %d\n", i);
+   dev_dbg(dev, "No affine DPIO for cpu %d\n", i);
/* If no affine DPIO for this core, there's probably
-* none available for next cores either.
+* none available for next cores either. Signal we want
+* to retry later, in case the DPIO devices weren't
+* probed yet.
 */
+   err = -EPROBE_DEFER;
goto err_service_reg;
}
 
@@ -1565,7 +1569,7 @@ static int setup_dpio(struct dpaa2_eth_priv *priv)
 err_alloc_ch:
if (cpumask_empty(>dpio_cpumask)) {
dev_err(dev, "No cpu with an affine DPIO/DPCON\n");
-   return -ENODEV;
+   return err;
}
 
dev_info(dev, "Cores %*pbl available for processing ingress traffic\n",
-- 
2.11.0

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


[PATCH 04/18] staging: fsl-dpaa2/eth: Remove incorrect error path

2017-06-06 Thread Ioana Radulescu
Not having Rx hashing distribution enabled for an
interface is a valid configuration and shouldn't be
treated as an error.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index a9e245df2488..f63054e071b3 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -1969,8 +1969,8 @@ static int dpaa2_eth_set_hash(struct net_device *net_dev, 
u64 flags)
int err = 0;
 
if (!dpaa2_eth_hash_enabled(priv)) {
-   dev_err(dev, "Hashing support is not enabled\n");
-   return -EOPNOTSUPP;
+   dev_dbg(dev, "Hashing support is not enabled\n");
+   return 0;
}
 
memset(_cfg, 0, sizeof(cls_cfg));
-- 
2.11.0

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


[PATCH 13/18] staging: fsl-dpaa2/eth: Remove unused fields from priv struct

2017-06-06 Thread Ioana Radulescu
Remove the dpni_id and buffer_layout fields from device's
private structure. They're only used at probe so we don't
need to store them for further use.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 33 +-
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h |  5 
 2 files changed, 16 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index d81c56f4d859..ee71e158b0a9 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -1734,15 +1734,14 @@ static int setup_dpni(struct fsl_mc_device *ls_dev)
struct device *dev = _dev->dev;
struct dpaa2_eth_priv *priv;
struct net_device *net_dev;
+   struct dpni_buffer_layout buf_layout = {0};
int err;
 
net_dev = dev_get_drvdata(dev);
priv = netdev_priv(net_dev);
 
-   priv->dpni_id = ls_dev->obj_desc.id;
-
/* get a handle for the DPNI object */
-   err = dpni_open(priv->mc_io, 0, priv->dpni_id, >mc_token);
+   err = dpni_open(priv->mc_io, 0, ls_dev->obj_desc.id, >mc_token);
if (err) {
dev_err(dev, "dpni_open() failed\n");
goto err_open;
@@ -1766,35 +1765,35 @@ static int setup_dpni(struct fsl_mc_device *ls_dev)
 
/* Configure buffer layouts */
/* rx buffer */
-   priv->buf_layout.pass_parser_result = true;
-   priv->buf_layout.pass_frame_status = true;
-   priv->buf_layout.private_data_size = DPAA2_ETH_SWA_SIZE;
-   priv->buf_layout.data_align = DPAA2_ETH_RX_BUF_ALIGN;
-   priv->buf_layout.options = DPNI_BUF_LAYOUT_OPT_PARSER_RESULT |
-  DPNI_BUF_LAYOUT_OPT_FRAME_STATUS |
-  DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE |
-  DPNI_BUF_LAYOUT_OPT_DATA_ALIGN;
+   buf_layout.pass_parser_result = true;
+   buf_layout.pass_frame_status = true;
+   buf_layout.private_data_size = DPAA2_ETH_SWA_SIZE;
+   buf_layout.data_align = DPAA2_ETH_RX_BUF_ALIGN;
+   buf_layout.options = DPNI_BUF_LAYOUT_OPT_PARSER_RESULT |
+DPNI_BUF_LAYOUT_OPT_FRAME_STATUS |
+DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE |
+DPNI_BUF_LAYOUT_OPT_DATA_ALIGN;
err = dpni_set_buffer_layout(priv->mc_io, 0, priv->mc_token,
-DPNI_QUEUE_RX, >buf_layout);
+DPNI_QUEUE_RX, _layout);
if (err) {
dev_err(dev, "dpni_set_buffer_layout(RX) failed\n");
goto err_buf_layout;
}
 
/* tx buffer */
-   priv->buf_layout.options = DPNI_BUF_LAYOUT_OPT_FRAME_STATUS |
-  DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE;
+   buf_layout.options = DPNI_BUF_LAYOUT_OPT_FRAME_STATUS |
+DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE;
err = dpni_set_buffer_layout(priv->mc_io, 0, priv->mc_token,
-DPNI_QUEUE_TX, >buf_layout);
+DPNI_QUEUE_TX, _layout);
if (err) {
dev_err(dev, "dpni_set_buffer_layout(TX) failed\n");
goto err_buf_layout;
}
 
/* tx-confirm buffer */
-   priv->buf_layout.options = DPNI_BUF_LAYOUT_OPT_FRAME_STATUS;
+   buf_layout.options = DPNI_BUF_LAYOUT_OPT_FRAME_STATUS;
err = dpni_set_buffer_layout(priv->mc_io, 0, priv->mc_token,
-DPNI_QUEUE_TX_CONFIRM, >buf_layout);
+DPNI_QUEUE_TX_CONFIRM, _layout);
if (err) {
dev_err(dev, "dpni_set_buffer_layout(TX_CONF) failed\n");
goto err_buf_layout;
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
index 6462e2cbe4be..6697b508cf23 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
@@ -297,12 +297,7 @@ struct dpaa2_eth_priv {
u8 num_channels;
struct dpaa2_eth_channel *channel[DPAA2_ETH_MAX_DPCONS];
 
-   int dpni_id;
struct dpni_attr dpni_attrs;
-   /* Insofar as the MC is concerned, we're using one layout on all 3 types
-* of buffers (Rx, Tx, Tx-Conf).
-*/
-   struct dpni_buffer_layout buf_layout;
u16 tx_data_offset;
 
struct fsl_mc_device *dpbp_dev;
-- 
2.11.0

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


[PATCH 07/18] staging: fsl-dpaa2/eth: Don't use GFP_DMA

2017-06-06 Thread Ioana Radulescu
Don't use GFP_DMA when allocating memory for the hash key,
as we don't actually need to allocate from the lowest zone.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index bf6f300affa7..57628cd3ecf2 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -1996,7 +1996,7 @@ static int dpaa2_eth_set_hash(struct net_device *net_dev, 
u64 flags)
priv->rx_hash_fields |= hash_fields[i].rxnfc_field;
}
 
-   dma_mem = kzalloc(DPAA2_CLASSIFIER_DMA_SIZE, GFP_DMA | GFP_KERNEL);
+   dma_mem = kzalloc(DPAA2_CLASSIFIER_DMA_SIZE, GFP_KERNEL);
if (!dma_mem)
return -ENOMEM;
 
-- 
2.11.0

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


[PATCH 00/18] staging: fsl-dpaa2/eth: Code cleanup and minor fixes

2017-06-06 Thread Ioana Radulescu
This patch series contains fixes for a few minor bugs and
code cleanup and cosmetics. No significant functional changes.

Ioana Radulescu (18):
  staging: fsl-dpaa2/eth: Add "static" keyword where needed
  staging: fsl-dpaa2/eth: Initialize variable before use
  staging: fsl-dpaa2/eth: Fix return type of ndo_start_xmit
  staging: fsl-dpaa2/eth: Remove incorrect error path
  staging: fsl-dpaa2/eth: Add error message newlines
  staging: fsl-dpaa2/eth: Minor cleanup in dpaa2_eth_set_hash
  staging: fsl-dpaa2/eth: Don't use GFP_DMA
  staging: fsl-dpaa2/eth: Always call napi_gro_receive()
  staging: fsl-dpaa2/eth: Reset dpbp
  staging: fsl-dpaa2/eth: Defer probing if no DPIOs found
  staging: fsl-dpaa2/eth: Update ethtool stats names
  staging: fsl-dpaa2/eth: Add accessor for FAS field
  staging: fsl-dpaa2/eth: Remove unused fields from priv struct
  staging: fsl-dpaa2/eth: Only store bpid in priv struct
  staging: fsl-dpaa2/eth: Reorder priv fields
  staging: fsl-dpaa2/eth: Errors checking update
  staging: fsl-dpaa2/eth: Refactor MAC address setup
  staging: fsl-dpaa2/eth: Update number of netdev queues

 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 228 +
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h |  56 ++---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c |  64 +++---
 3 files changed, 204 insertions(+), 144 deletions(-)

-- 
2.11.0

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


[PATCH 08/18] staging: fsl-dpaa2/eth: Always call napi_gro_receive()

2017-06-06 Thread Ioana Radulescu
The function itself checks whether GRO support is enabled
and acts accordingly, so we don't need to verify it in the
driver as well.

Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 57628cd3ecf2..d3ec384c7364 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -273,10 +273,7 @@ static void dpaa2_eth_rx(struct dpaa2_eth_priv *priv,
percpu_stats->rx_packets++;
percpu_stats->rx_bytes += dpaa2_fd_get_len(fd);
 
-   if (priv->net_dev->features & NETIF_F_GRO)
-   napi_gro_receive(napi, skb);
-   else
-   netif_receive_skb(skb);
+   napi_gro_receive(napi, skb);
 
return;
 
-- 
2.11.0

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


RE: [PATCH 1/2] staging: fsl-dpaa2/eth: Fix address translations

2017-05-25 Thread Ruxandra Ioana Radulescu
> -Original Message-
> From: Laurentiu Tudor
> Sent: Wednesday, May 24, 2017 3:34 PM
> To: Ruxandra Ioana Radulescu <ruxandra.radule...@nxp.com>;
> gre...@linuxfoundation.org
> Cc: de...@driverdev.osuosl.org; linux-ker...@vger.kernel.org;
> ag...@suse.de; a...@arndb.de; linux-arm-ker...@lists.infradead.org;
> io...@lists.linux-foundation.org; Bogdan Purcareata
> <bogdan.purcare...@nxp.com>; stuyo...@gmail.com; Nipun Gupta
> <nipun.gu...@nxp.com>
> Subject: Re: [PATCH 1/2] staging: fsl-dpaa2/eth: Fix address translations
> 
> Hi Ioana,
> 
> Debatable nit inline.
> 
> On 05/24/2017 03:13 PM, Ioana Radulescu wrote:
> > Use the correct mechanisms for translating a DMA-mapped IOVA
> > address into a virtual one. Without this fix, once SMMU is
> > enabled on Layerscape platforms, the Ethernet driver throws
> > IOMMU translation faults.
> >
> > Signed-off-by: Nipun Gupta <nipun.gu...@nxp.com>
> > Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
> > ---
> >   drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 25
> +++--
> >   drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h |  1 +
> >   2 files changed, 20 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
> b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
> > index 6f9eed66c64d..3fee0d6f17e0 100644
> > --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
> > +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
> > @@ -37,6 +37,7 @@
> >   #include 
> >   #include 
> >   #include 
> > +#include 
> >
> >   #include "../../fsl-mc/include/mc.h"
> >   #include "../../fsl-mc/include/mc-sys.h"
> > @@ -54,6 +55,16 @@ MODULE_DESCRIPTION("Freescale DPAA2 Ethernet
> Driver");
> >
> >   const char dpaa2_eth_drv_version[] = "0.1";
> >
> > +static void *dpaa2_iova_to_virt(struct iommu_domain *domain,
> 
> if you pass a "struct dpaa2_eth_priv *priv" instead of "iommu_domain"
> you can move the priv->iommu_domain reference in the function and
> slightly simplify the call sites.
 
Fair point, but I'd prefer keeping this function independent of the
Ethernet driver's private data structure. This way, if other (future)
DPAA2 drivers will need a similar function, we can just move it
to a common area instead of duplicating the code.

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


[PATCH 2/2] staging: fsl-dpaa2/eth: Map Tx buffers as bidirectional

2017-05-24 Thread Ioana Radulescu
WRIOP hardware may need to write to the hardware annotation
area of Tx buffers (e.g. frame status bits) and also to
the data area (e.g. L4 checksum in frame header).

Map these buffers as DMA_BIDIRECTIONAL, otherwise the
write transaction through SMMU will not be allowed.

Signed-off-by: Nipun Gupta <nipun.gu...@nxp.com>
Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 3fee0d6f17e0..49c435bad706 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -355,7 +355,7 @@ static int build_sg_fd(struct dpaa2_eth_priv *priv,
 
sg_init_table(scl, nr_frags + 1);
num_sg = skb_to_sgvec(skb, scl, 0, skb->len);
-   num_dma_bufs = dma_map_sg(dev, scl, num_sg, DMA_TO_DEVICE);
+   num_dma_bufs = dma_map_sg(dev, scl, num_sg, DMA_BIDIRECTIONAL);
if (unlikely(!num_dma_bufs)) {
err = -ENOMEM;
goto dma_map_sg_failed;
@@ -406,7 +406,7 @@ static int build_sg_fd(struct dpaa2_eth_priv *priv,
swa->num_dma_bufs = num_dma_bufs;
 
/* Separately map the SGT buffer */
-   addr = dma_map_single(dev, sgt_buf, sgt_buf_size, DMA_TO_DEVICE);
+   addr = dma_map_single(dev, sgt_buf, sgt_buf_size, DMA_BIDIRECTIONAL);
if (unlikely(dma_mapping_error(dev, addr))) {
err = -ENOMEM;
goto dma_map_single_failed;
@@ -423,7 +423,7 @@ static int build_sg_fd(struct dpaa2_eth_priv *priv,
 dma_map_single_failed:
kfree(sgt_buf);
 sgt_buf_alloc_failed:
-   dma_unmap_sg(dev, scl, num_sg, DMA_TO_DEVICE);
+   dma_unmap_sg(dev, scl, num_sg, DMA_BIDIRECTIONAL);
 dma_map_sg_failed:
kfree(scl);
return err;
@@ -461,7 +461,7 @@ static int build_single_fd(struct dpaa2_eth_priv *priv,
 
addr = dma_map_single(dev, buffer_start,
  skb_tail_pointer(skb) - buffer_start,
- DMA_TO_DEVICE);
+ DMA_BIDIRECTIONAL);
if (unlikely(dma_mapping_error(dev, addr)))
return -ENOMEM;
 
@@ -510,7 +510,7 @@ static void free_tx_fd(const struct dpaa2_eth_priv *priv,
 */
dma_unmap_single(dev, fd_addr,
 skb_tail_pointer(skb) - buffer_start,
-DMA_TO_DEVICE);
+DMA_BIDIRECTIONAL);
} else if (fd_format == dpaa2_fd_sg) {
swa = (struct dpaa2_eth_swa *)skbh;
skb = swa->skb;
@@ -519,13 +519,13 @@ static void free_tx_fd(const struct dpaa2_eth_priv *priv,
num_dma_bufs = swa->num_dma_bufs;
 
/* Unmap the scatterlist */
-   dma_unmap_sg(dev, scl, num_sg, DMA_TO_DEVICE);
+   dma_unmap_sg(dev, scl, num_sg, DMA_BIDIRECTIONAL);
kfree(scl);
 
/* Unmap the SGT buffer */
unmap_size = priv->tx_data_offset +
   sizeof(struct dpaa2_sg_entry) * (1 + num_dma_bufs);
-   dma_unmap_single(dev, fd_addr, unmap_size, DMA_TO_DEVICE);
+   dma_unmap_single(dev, fd_addr, unmap_size, DMA_BIDIRECTIONAL);
} else {
/* Unsupported format, mark it as errored and give up */
if (status)
-- 
2.11.0

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


[PATCH 1/2] staging: fsl-dpaa2/eth: Fix address translations

2017-05-24 Thread Ioana Radulescu
Use the correct mechanisms for translating a DMA-mapped IOVA
address into a virtual one. Without this fix, once SMMU is
enabled on Layerscape platforms, the Ethernet driver throws
IOMMU translation faults.

Signed-off-by: Nipun Gupta <nipun.gu...@nxp.com>
Signed-off-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 25 +++--
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h |  1 +
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 6f9eed66c64d..3fee0d6f17e0 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -37,6 +37,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "../../fsl-mc/include/mc.h"
 #include "../../fsl-mc/include/mc-sys.h"
@@ -54,6 +55,16 @@ MODULE_DESCRIPTION("Freescale DPAA2 Ethernet Driver");
 
 const char dpaa2_eth_drv_version[] = "0.1";
 
+static void *dpaa2_iova_to_virt(struct iommu_domain *domain,
+   dma_addr_t iova_addr)
+{
+   phys_addr_t phys_addr;
+
+   phys_addr = domain ? iommu_iova_to_phys(domain, iova_addr) : iova_addr;
+
+   return phys_to_virt(phys_addr);
+}
+
 static void validate_rx_csum(struct dpaa2_eth_priv *priv,
 u32 fd_status,
 struct sk_buff *skb)
@@ -98,12 +109,11 @@ static void free_rx_fd(struct dpaa2_eth_priv *priv,
sgt = vaddr + dpaa2_fd_get_offset(fd);
for (i = 0; i < DPAA2_ETH_MAX_SG_ENTRIES; i++) {
addr = dpaa2_sg_get_addr([i]);
+   sg_vaddr = dpaa2_iova_to_virt(priv->iommu_domain, addr);
dma_unmap_single(dev, addr, DPAA2_ETH_RX_BUF_SIZE,
 DMA_FROM_DEVICE);
 
-   sg_vaddr = phys_to_virt(addr);
skb_free_frag(sg_vaddr);
-
if (dpaa2_sg_is_final([i]))
break;
}
@@ -159,10 +169,10 @@ static struct sk_buff *build_frag_skb(struct 
dpaa2_eth_priv *priv,
 
/* Get the address and length from the S/G entry */
sg_addr = dpaa2_sg_get_addr(sge);
+   sg_vaddr = dpaa2_iova_to_virt(priv->iommu_domain, sg_addr);
dma_unmap_single(dev, sg_addr, DPAA2_ETH_RX_BUF_SIZE,
 DMA_FROM_DEVICE);
 
-   sg_vaddr = phys_to_virt(sg_addr);
sg_length = dpaa2_sg_get_len(sge);
 
if (i == 0) {
@@ -222,8 +232,8 @@ static void dpaa2_eth_rx(struct dpaa2_eth_priv *priv,
/* Tracing point */
trace_dpaa2_rx_fd(priv->net_dev, fd);
 
+   vaddr = dpaa2_iova_to_virt(priv->iommu_domain, addr);
dma_unmap_single(dev, addr, DPAA2_ETH_RX_BUF_SIZE, DMA_FROM_DEVICE);
-   vaddr = phys_to_virt(addr);
 
prefetch(vaddr + priv->buf_layout.private_data_size);
prefetch(vaddr + dpaa2_fd_get_offset(fd));
@@ -490,7 +500,7 @@ static void free_tx_fd(const struct dpaa2_eth_priv *priv,
struct dpaa2_fas *fas;
 
fd_addr = dpaa2_fd_get_addr(fd);
-   skbh = phys_to_virt(fd_addr);
+   skbh = dpaa2_iova_to_virt(priv->iommu_domain, fd_addr);
 
if (fd_format == dpaa2_fd_single) {
skb = *skbh;
@@ -802,10 +812,11 @@ static void drain_bufs(struct dpaa2_eth_priv *priv, int 
count)
}
for (i = 0; i < ret; i++) {
/* Same logic as on regular Rx path */
+   vaddr = dpaa2_iova_to_virt(priv->iommu_domain,
+  buf_array[i]);
dma_unmap_single(dev, buf_array[i],
 DPAA2_ETH_RX_BUF_SIZE,
 DMA_FROM_DEVICE);
-   vaddr = phys_to_virt(buf_array[i]);
skb_free_frag(vaddr);
}
} while (ret);
@@ -2358,6 +2369,8 @@ static int dpaa2_eth_probe(struct fsl_mc_device *dpni_dev)
priv = netdev_priv(net_dev);
priv->net_dev = net_dev;
 
+   priv->iommu_domain = iommu_get_domain_for_dev(dev);
+
/* Obtain a MC portal */
err = fsl_mc_portal_allocate(dpni_dev, FSL_MC_IO_ATOMIC_CONTEXT_PORTAL,
 >mc_io);
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
index c67cced55b72..55b47623008c 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
@@ -301,6 +301,7 @@ struct dpaa2_eth_priv {
 
struct fsl_mc_device *dpbp_dev;
struct dpbp_attr dpbp_attrs;
+   struct iommu_domain *iommu_domain;
 
u16 tx_qdid;
struct fsl_mc_io *

RE: [PATCH] staging: fsl-dpaa2/eth: add ETHERNET dependency

2017-05-17 Thread Ruxandra Ioana Radulescu
> -Original Message-
> From: Arnd Bergmann [mailto:a...@arndb.de]
> Sent: Tuesday, May 16, 2017 2:30 PM
> To: Greg Kroah-Hartman <gre...@linuxfoundation.org>; Arnd Bergmann
> <a...@arndb.de>
> Cc: Ruxandra Ioana Radulescu <ruxandra.radule...@nxp.com>;
> de...@driverdev.osuosl.org; linux-ker...@vger.kernel.org
> Subject: [PATCH] staging: fsl-dpaa2/eth: add ETHERNET dependency
> 
> The new driver cannot link correctly when the netdevice infrastructure
> is disabled:
> 
> ERROR: "netdev_info" [drivers/staging/fsl-dpaa2/ethernet/fsl-dpaa2-eth.ko]
> undefined!
> ERROR: "skb_to_sgvec" [drivers/staging/fsl-dpaa2/ethernet/fsl-dpaa2-
> eth.ko] undefined!
> ERROR: "napi_disable" [drivers/staging/fsl-dpaa2/ethernet/fsl-dpaa2-
> eth.ko] undefined!
> ERROR: "napi_schedule_prep" [drivers/staging/fsl-dpaa2/ethernet/fsl-
> dpaa2-eth.ko] undefined!
> ERROR: "__napi_schedule_irqoff" [drivers/staging/fsl-dpaa2/ethernet/fsl-
> dpaa2-eth.ko] undefined!
> ERROR: "netif_carrier_on" [drivers/staging/fsl-dpaa2/ethernet/fsl-dpaa2-
> eth.ko] undefined!
> 
> This adds a dependency on NETDEVICES and ETHERNET.
> 
> Fixes: 0352d1d85201 ("staging: fsl-dpaa2/eth: Add APIs for DPNI objects")
> Signed-off-by: Arnd Bergmann <a...@arndb.de>
> ---
>  drivers/staging/fsl-dpaa2/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/staging/fsl-dpaa2/Kconfig b/drivers/staging/fsl-
> dpaa2/Kconfig
> index 2e325cb747ae..730fd6d4db33 100644
> --- a/drivers/staging/fsl-dpaa2/Kconfig
> +++ b/drivers/staging/fsl-dpaa2/Kconfig
> @@ -12,6 +12,7 @@ config FSL_DPAA2
>  config FSL_DPAA2_ETH
>   tristate "Freescale DPAA2 Ethernet"
>   depends on FSL_DPAA2 && FSL_MC_DPIO
> + depends on NETDEVICES && ETHERNET
>   ---help---
> Ethernet driver for Freescale DPAA2 SoCs, using the
> Freescale MC bus driver
> --
> 2.9.0

Thanks!
Acked-by: Ioana Radulescu <ruxandra.radule...@nxp.com>
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


  1   2   >