RE: [RFC,v3 02/10] dpaa_eth: add support for DPAA Ethernet

2015-06-15 Thread Madalin-Cristian Bucur
 -Original Message-
 From: Eric Dumazet [mailto:eric.duma...@gmail.com]
 
 On Wed, 2015-06-10 at 07:38 +, Madalin-Cristian Bucur wrote:
  Hi Eric,
 
  Can you please tell us if this change would be for the better?
 
  I was about to say yes to this request but checked and no other Ethernet
 driver seems to use the queue trans_start.
  I was able to find your patch net: tx scalability works : trans_start [
 http://patchwork.ozlabs.org/patch/27104/ ] but did not find more about this
 topic.
 
 
 Drivers no longer have to worry about updating trans_start themselves.
 Core networking stack handles this.
 
 Check txq_trans_update() done from netdev_start_xmit()

I'll remove the updates, thank you.

Madalin
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

RE: [RFC,v3 02/10] dpaa_eth: add support for DPAA Ethernet

2015-06-15 Thread Madalin-Cristian Bucur
 -Original Message-
 From: Eric Dumazet [mailto:eric.duma...@gmail.com]
 
 On Wed, 2015-04-29 at 17:56 +0300, Madalin Bucur wrote:
  This introduces the Freescale Data Path Acceleration Architecture
  (DPAA) Ethernet driver (dpaa_eth) that builds upon the DPAA QMan,
  BMan, PAMU and FMan drivers to deliver Ethernet connectivity on
  the Freescale DPAA QorIQ platforms.
 ...
 
  +   /* We're going to store the skb backpointer at the beginning
  +* of the data buffer, so we need a privately owned skb
  +*/
  +
  +   /* Code borrowed from skb_unshare(). */
  +   if (skb_cloned(skb)) {
  +   struct sk_buff *nskb = skb_copy(skb, GFP_ATOMIC);
  +
  +   /* Finally, create a contig FD from this skb */
  +   skb_to_contig_fd(priv, skb, fd, countptr, offset);
  +
  +   kfree_skb(skb);
  +   skb = nskb;
  +   /* skb_copy() has now linearized the skbuff. */
  +   }
  +
 
 You know that TCP packets are clones, right ?
 This code is killing performance.
 
 TCP allows the headers part being modified by a driver if needed.
 
 You should use skb_header_cloned() instead.

Thank you, I'll address this. I plan to do something like this:

+   if (!nonlinear) {
+   /* We're going to store the skb backpointer at the beginning
+* of the data buffer, so we need a privately owned skb
+*/
+
+   /* make sure skb is not shared, skb_cow_head() assumes it's not 
*/
+   skb = skb_share_check(skb, GFP_ATOMIC);
+   if (!skb)
+   goto enomem;
+
+   /* verify the skb head is not cloned */
+   if (skb_cow_head(skb, priv-tx_headroom))
+   goto enomem;
+
+   nonlinear = skb_is_nonlinear(skb);
+   }

but I'm not sure the skb_share_check() is required on tx.
I'm also a bit puzzled by the aliasing between shared and cloned terms
(i.e. skb_unshare() could be named something like skb_unclone();
 the skb_share_check() not only checks but also unshares an skb so
 the already taken skb_unshare() name would probably fit too).

Madalin
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [RFC,v3 02/10] dpaa_eth: add support for DPAA Ethernet

2015-06-15 Thread Eric Dumazet
On Mon, 2015-06-15 at 13:40 +, Madalin-Cristian Bucur wrote:
  -Original Message-
  From: Eric Dumazet [mailto:eric.duma...@gmail.com]
  
  On Wed, 2015-04-29 at 17:56 +0300, Madalin Bucur wrote:
   This introduces the Freescale Data Path Acceleration Architecture
   (DPAA) Ethernet driver (dpaa_eth) that builds upon the DPAA QMan,
   BMan, PAMU and FMan drivers to deliver Ethernet connectivity on
   the Freescale DPAA QorIQ platforms.
  ...
  
   + /* We're going to store the skb backpointer at the beginning
   +  * of the data buffer, so we need a privately owned skb
   +  */
   +
   + /* Code borrowed from skb_unshare(). */
   + if (skb_cloned(skb)) {
   + struct sk_buff *nskb = skb_copy(skb, GFP_ATOMIC);
   +
   + /* Finally, create a contig FD from this skb */
   + skb_to_contig_fd(priv, skb, fd, countptr, offset);
   +
   + kfree_skb(skb);
   + skb = nskb;
   + /* skb_copy() has now linearized the skbuff. */
   + }
   +
  
  You know that TCP packets are clones, right ?
  This code is killing performance.
  
  TCP allows the headers part being modified by a driver if needed.
  
  You should use skb_header_cloned() instead.
 
 Thank you, I'll address this. I plan to do something like this:
 
 +   if (!nonlinear) {
 +   /* We're going to store the skb backpointer at the beginning
 +* of the data buffer, so we need a privately owned skb
 +*/
 +
 +   /* make sure skb is not shared, skb_cow_head() assumes it's 
 not */
 +   skb = skb_share_check(skb, GFP_ATOMIC);
 +   if (!skb)
 +   goto enomem;
 +
 +   /* verify the skb head is not cloned */
 +   if (skb_cow_head(skb, priv-tx_headroom))
 +   goto enomem;
 +
 +   nonlinear = skb_is_nonlinear(skb);
 +   }
 
 but I'm not sure the skb_share_check() is required on tx.
 I'm also a bit puzzled by the aliasing between shared and cloned terms
 (i.e. skb_unshare() could be named something like skb_unclone();
  the skb_share_check() not only checks but also unshares an skb so
  the already taken skb_unshare() name would probably fit too).

A driver can ask tx skbs to be not shared, even if pktgen is used with
clone=X on it.

dev-priv_flags = ~IFF_TX_SKB_SHARING;

This way, you can avoid skb_share_check() completely. Only pktgen will
care.

Most skb_share_check() calls in drivers/net are related to input paths
on virtual drivers.



___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

RE: [RFC,v3 02/10] dpaa_eth: add support for DPAA Ethernet

2015-06-10 Thread Madalin-Cristian Bucur
Hi Eric,

Can you please tell us if this change would be for the better?

I was about to say yes to this request but checked and no other Ethernet driver 
seems to use the queue trans_start.
I was able to find your patch net: tx scalability works : trans_start [ 
http://patchwork.ozlabs.org/patch/27104/ ] but did not find more about this 
topic.
 
Thank you,
Madalin

 -Original Message-
 From: Xie Jianhua-B29408
 Sent: Wednesday, June 10, 2015 9:00 AM
 To: Bucur Madalin-Cristian-B32716; net...@vger.kernel.org; linuxppc-
 d...@lists.ozlabs.org
 Cc: linux-ker...@vger.kernel.org
 Subject: RE: [RFC,v3 02/10] dpaa_eth: add support for DPAA Ethernet
 
 
 
  -Original Message-
  From: Linuxppc-dev [mailto:linuxppc-dev-
  bounces+jianhua.xie=freescale@lists.ozlabs.org] On Behalf Of
 Madalin
  Bucur
  Sent: Wednesday, April 29, 2015 10:57 PM
  To: net...@vger.kernel.org; linuxppc-dev@lists.ozlabs.org
  Cc: linux-ker...@vger.kernel.org; Bucur Madalin-Cristian-B32716
  Subject: [RFC,v3 02/10] dpaa_eth: add support for DPAA Ethernet
 
  This introduces the Freescale Data Path Acceleration Architecture
  (DPAA) Ethernet driver (dpaa_eth) that builds upon the DPAA QMan,
  BMan, PAMU and FMan drivers to deliver Ethernet connectivity on
  the Freescale DPAA QorIQ platforms.
 
 Snip..
 
  +
  +   if (unlikely(dpa_xmit(priv, percpu_stats, queue_mapping, fd)  0))
  +   goto xmit_failed;
  +
  +   net_dev-trans_start = jiffies;
 
 It is probably better to use netdev_queue-trans_start to instead of
 net_dev-trans_start on SMP.
 
 Best Regards,
 Jianhua
 
  +   return NETDEV_TX_OK;
  +
  +xmit_failed:
  +   if (fd.cmd  FM_FD_CMD_FCO) {
  +   (*countptr)--;
  +   dpa_fd_release(net_dev, fd);
  +   percpu_stats-tx_errors++;
  +   return NETDEV_TX_OK;
  +   }
  +   _dpa_cleanup_tx_fd(priv, fd);
  +   percpu_stats-tx_errors++;
  +   dev_kfree_skb(skb);
  +   return NETDEV_TX_OK;
  +}
  --
  1.7.11.7
 
  ___
  Linuxppc-dev mailing list
  Linuxppc-dev@lists.ozlabs.org
  https://lists.ozlabs.org/listinfo/linuxppc-dev
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [RFC,v3 02/10] dpaa_eth: add support for DPAA Ethernet

2015-06-10 Thread Eric Dumazet
On Wed, 2015-06-10 at 07:38 +, Madalin-Cristian Bucur wrote:
 Hi Eric,
 
 Can you please tell us if this change would be for the better?
 
 I was about to say yes to this request but checked and no other Ethernet 
 driver seems to use the queue trans_start.
 I was able to find your patch net: tx scalability works : trans_start [ 
 http://patchwork.ozlabs.org/patch/27104/ ] but did not find more about this 
 topic.
  

Drivers no longer have to worry about updating trans_start themselves.
Core networking stack handles this.

Check txq_trans_update() done from netdev_start_xmit()


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

RE: [RFC,v3 02/10] dpaa_eth: add support for DPAA Ethernet

2015-06-10 Thread Jianhua Xie


 -Original Message-
 From: Linuxppc-dev [mailto:linuxppc-dev-
 bounces+jianhua.xie=freescale@lists.ozlabs.org] On Behalf Of Madalin
 Bucur
 Sent: Wednesday, April 29, 2015 10:57 PM
 To: net...@vger.kernel.org; linuxppc-dev@lists.ozlabs.org
 Cc: linux-ker...@vger.kernel.org; Bucur Madalin-Cristian-B32716
 Subject: [RFC,v3 02/10] dpaa_eth: add support for DPAA Ethernet
 
 This introduces the Freescale Data Path Acceleration Architecture
 (DPAA) Ethernet driver (dpaa_eth) that builds upon the DPAA QMan,
 BMan, PAMU and FMan drivers to deliver Ethernet connectivity on
 the Freescale DPAA QorIQ platforms.
 
Snip..

 +
 + if (unlikely(dpa_xmit(priv, percpu_stats, queue_mapping, fd)  0))
 + goto xmit_failed;
 +
 + net_dev-trans_start = jiffies;

It is probably better to use netdev_queue-trans_start to instead of 
net_dev-trans_start on SMP.

Best Regards,
Jianhua

 + return NETDEV_TX_OK;
 +
 +xmit_failed:
 + if (fd.cmd  FM_FD_CMD_FCO) {
 + (*countptr)--;
 + dpa_fd_release(net_dev, fd);
 + percpu_stats-tx_errors++;
 + return NETDEV_TX_OK;
 + }
 + _dpa_cleanup_tx_fd(priv, fd);
 + percpu_stats-tx_errors++;
 + dev_kfree_skb(skb);
 + return NETDEV_TX_OK;
 +}
 --
 1.7.11.7
 
 ___
 Linuxppc-dev mailing list
 Linuxppc-dev@lists.ozlabs.org
 https://lists.ozlabs.org/listinfo/linuxppc-dev
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [RFC,v3 02/10] dpaa_eth: add support for DPAA Ethernet

2015-06-10 Thread Eric Dumazet
On Wed, 2015-04-29 at 17:56 +0300, Madalin Bucur wrote:
 This introduces the Freescale Data Path Acceleration Architecture
 (DPAA) Ethernet driver (dpaa_eth) that builds upon the DPAA QMan,
 BMan, PAMU and FMan drivers to deliver Ethernet connectivity on
 the Freescale DPAA QorIQ platforms.
...

 + /* We're going to store the skb backpointer at the beginning
 +  * of the data buffer, so we need a privately owned skb
 +  */
 +
 + /* Code borrowed from skb_unshare(). */
 + if (skb_cloned(skb)) {
 + struct sk_buff *nskb = skb_copy(skb, GFP_ATOMIC);
 +
 + /* Finally, create a contig FD from this skb */
 + skb_to_contig_fd(priv, skb, fd, countptr, offset);
 +
 + kfree_skb(skb);
 + skb = nskb;
 + /* skb_copy() has now linearized the skbuff. */
 + }
 +

You know that TCP packets are clones, right ?
This code is killing performance.

TCP allows the headers part being modified by a driver if needed.

You should use skb_header_cloned() instead.



___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[RFC,v3 02/10] dpaa_eth: add support for DPAA Ethernet

2015-04-29 Thread Madalin Bucur
This introduces the Freescale Data Path Acceleration Architecture
(DPAA) Ethernet driver (dpaa_eth) that builds upon the DPAA QMan,
BMan, PAMU and FMan drivers to deliver Ethernet connectivity on
the Freescale DPAA QorIQ platforms.

Signed-off-by: Madalin Bucur madalin.bu...@freescale.com
---
 drivers/net/ethernet/freescale/Kconfig |2 +
 drivers/net/ethernet/freescale/Makefile|1 +
 drivers/net/ethernet/freescale/dpaa/Kconfig|   46 +
 drivers/net/ethernet/freescale/dpaa/Makefile   |   13 +
 drivers/net/ethernet/freescale/dpaa/dpaa_eth.c |  829 +
 drivers/net/ethernet/freescale/dpaa/dpaa_eth.h |  446 +++
 .../net/ethernet/freescale/dpaa/dpaa_eth_common.c  | 1280 
 .../net/ethernet/freescale/dpaa/dpaa_eth_common.h  |  119 ++
 drivers/net/ethernet/freescale/dpaa/dpaa_eth_sg.c  |  428 +++
 9 files changed, 3164 insertions(+)
 create mode 100644 drivers/net/ethernet/freescale/dpaa/Kconfig
 create mode 100644 drivers/net/ethernet/freescale/dpaa/Makefile
 create mode 100644 drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
 create mode 100644 drivers/net/ethernet/freescale/dpaa/dpaa_eth.h
 create mode 100644 drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c
 create mode 100644 drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.h
 create mode 100644 drivers/net/ethernet/freescale/dpaa/dpaa_eth_sg.c

diff --git a/drivers/net/ethernet/freescale/Kconfig 
b/drivers/net/ethernet/freescale/Kconfig
index 24e938d..36830a1 100644
--- a/drivers/net/ethernet/freescale/Kconfig
+++ b/drivers/net/ethernet/freescale/Kconfig
@@ -94,4 +94,6 @@ config GIANFAR
  This driver supports the Gigabit TSEC on the MPC83xx, MPC85xx,
  and MPC86xx family of chips, and the FEC on the 8540.
 
+source drivers/net/ethernet/freescale/dpaa/Kconfig
+
 endif # NET_VENDOR_FREESCALE
diff --git a/drivers/net/ethernet/freescale/Makefile 
b/drivers/net/ethernet/freescale/Makefile
index 4097c58..ae13dc5 100644
--- a/drivers/net/ethernet/freescale/Makefile
+++ b/drivers/net/ethernet/freescale/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_FS_ENET) += fs_enet/
 obj-$(CONFIG_FSL_PQ_MDIO) += fsl_pq_mdio.o
 obj-$(CONFIG_FSL_XGMAC_MDIO) += xgmac_mdio.o
 obj-$(CONFIG_GIANFAR) += gianfar_driver.o
+obj-$(CONFIG_FSL_DPAA_ETH) += dpaa/
 obj-$(CONFIG_PTP_1588_CLOCK_GIANFAR) += gianfar_ptp.o
 gianfar_driver-objs := gianfar.o \
gianfar_ethtool.o
diff --git a/drivers/net/ethernet/freescale/dpaa/Kconfig 
b/drivers/net/ethernet/freescale/dpaa/Kconfig
new file mode 100644
index 000..1f3a203
--- /dev/null
+++ b/drivers/net/ethernet/freescale/dpaa/Kconfig
@@ -0,0 +1,46 @@
+menuconfig FSL_DPAA_ETH
+   tristate DPAA Ethernet
+   depends on FSL_SOC  FSL_BMAN  FSL_QMAN  FSL_FMAN
+   select PHYLIB
+   select FSL_FMAN_MAC
+   ---help---
+ Data Path Acceleration Architecture Ethernet driver,
+ supporting the Freescale QorIQ chips.
+ Depends on Freescale Buffer Manager and Queue Manager
+ driver and Frame Manager Driver.
+
+if FSL_DPAA_ETH
+
+config FSL_DPAA_CS_THRESHOLD_1G
+   hex Egress congestion threshold on 1G ports
+   range 0x1000 0x1000
+   default 0x0600
+   ---help---
+ The size in bytes of the egress Congestion State notification 
threshold on 1G ports.
+ The 1G dTSECs can quite easily be flooded by cores doing Tx in a 
tight loop
+ (e.g. by sending UDP datagrams at while(1) speed),
+ and the larger the frame size, the more acute the problem.
+ So we have to find a balance between these factors:
+  - avoiding the device staying congested for a prolonged time 
(risking
+ the netdev watchdog to fire - see also the tx_timeout module 
param);
+   - affecting performance of protocols such as TCP, which 
otherwise
+behave well under the congestion notification mechanism;
+  - preventing the Tx cores from tightly-looping (as if the 
congestion
+threshold was too low to be effective);
+  - running out of memory if the CS threshold is set too high.
+
+config FSL_DPAA_CS_THRESHOLD_10G
+   hex Egress congestion threshold on 10G ports
+   range 0x1000 0x2000
+   default 0x1000
+   ---help ---
+ The size in bytes of the egress Congestion State notification 
threshold on 10G ports.
+
+config FSL_DPAA_INGRESS_CS_THRESHOLD
+   hex Ingress congestion threshold on FMan ports
+   default 0x1000
+   ---help---
+ The size in bytes of the ingress tail-drop threshold on FMan ports.
+ Traffic piling up above this value will be rejected by QMan and 
discarded by FMan.
+
+endif # FSL_DPAA_ETH
diff --git a/drivers/net/ethernet/freescale/dpaa/Makefile 
b/drivers/net/ethernet/freescale/dpaa/Makefile
new file mode 100644
index 000..cf126dd
--- /dev/null
+++ b/drivers/net/ethernet/freescale/dpaa/Makefile
@@