All of lore.kernel.org
 help / color / mirror / Atom feed
From: Giuseppe Cavallaro <peppe.cavallaro@st.com>
To: <netdev@vger.kernel.org>
Cc: <alexandre.torgue@st.com>, Giuseppe Cavallaro <peppe.cavallaro@st.com>
Subject: [PATCH (net-next.git) 16/18] stmmac: do not perform zero-copy for rx frames
Date: Wed, 9 Dec 2015 09:37:52 +0100	[thread overview]
Message-ID: <1449650274-14896-17-git-send-email-peppe.cavallaro@st.com> (raw)
In-Reply-To: <1449650274-14896-1-git-send-email-peppe.cavallaro@st.com>

This patch is to allow this driver to copy tiny frames during the reception
process. This is giving more stability while stressing the driver on STi
embedded systems.

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |   67 ++++++++++++++++-----
 1 files changed, 52 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 6b83213..d68775a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -98,6 +98,10 @@ static int buf_sz = DEFAULT_BUFSIZE;
 module_param(buf_sz, int, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(buf_sz, "DMA buffer size");
 
+static int minrx = 256;
+module_param(minrx, int, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(minrx, "Copy only tiny-frames");
+
 static const u32 default_msg_level = (NETIF_MSG_DRV | NETIF_MSG_PROBE |
 				      NETIF_MSG_LINK | NETIF_MSG_IFUP |
 				      NETIF_MSG_IFDOWN | NETIF_MSG_TIMER);
@@ -147,6 +151,8 @@ static void stmmac_verify_args(void)
 		pause = PAUSE_TIME;
 	if (eee_timer < 0)
 		eee_timer = STMMAC_DEFAULT_LPI_TIMER;
+	if (minrx < 0)
+		minrx = ETH_FRAME_LEN;
 }
 
 /**
@@ -2198,8 +2204,7 @@ static inline void stmmac_rx_refill(struct stmmac_priv *priv)
 			struct sk_buff *skb;
 
 			skb = netdev_alloc_skb_ip_align(priv->dev, bfsize);
-
-			if (unlikely(skb == NULL))
+			if (unlikely(!skb))
 				break;
 
 			priv->rx_skbuff[entry] = skb;
@@ -2322,23 +2327,52 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit)
 					pr_debug("\tframe size %d, COE: %d\n",
 						 frame_len, status);
 			}
-			skb = priv->rx_skbuff[entry];
-			if (unlikely(!skb)) {
-				pr_err("%s: Inconsistent Rx descriptor chain\n",
-				       priv->dev->name);
-				priv->dev->stats.rx_dropped++;
-				break;
+
+			if (unlikely(frame_len < minrx)) {
+				skb = netdev_alloc_skb_ip_align(priv->dev,
+								frame_len);
+				if (unlikely(!skb)) {
+					if (net_ratelimit())
+						dev_warn(priv->device,
+							 "packet dropped\n");
+					priv->dev->stats.rx_dropped++;
+					break;
+				}
+
+				dma_sync_single_for_cpu(priv->device,
+							priv->rx_skbuff_dma
+							[entry], frame_len,
+							DMA_FROM_DEVICE);
+				skb_copy_to_linear_data(skb,
+							priv->
+							rx_skbuff[entry]->data,
+							frame_len);
+
+				skb_put(skb, frame_len);
+				dma_sync_single_for_device(priv->device,
+							   priv->rx_skbuff_dma
+							   [entry], frame_len,
+							   DMA_FROM_DEVICE);
+			} else {
+				skb = priv->rx_skbuff[entry];
+				if (unlikely(!skb)) {
+					pr_err("%s: Inconsistent Rx chain\n",
+					       priv->dev->name);
+					priv->dev->stats.rx_dropped++;
+					break;
+				}
+				prefetch(skb->data - NET_IP_ALIGN);
+				priv->rx_skbuff[entry] = NULL;
+
+				skb_put(skb, frame_len);
+				dma_unmap_single(priv->device,
+						 priv->rx_skbuff_dma[entry],
+						 priv->dma_buf_sz,
+						 DMA_FROM_DEVICE);
 			}
-			prefetch(skb->data - NET_IP_ALIGN);
-			priv->rx_skbuff[entry] = NULL;
 
 			stmmac_get_rx_hwtstamp(priv, entry, skb);
 
-			skb_put(skb, frame_len);
-			dma_unmap_single(priv->device,
-					 priv->rx_skbuff_dma[entry],
-					 priv->dma_buf_sz, DMA_FROM_DEVICE);
-
 			if (netif_msg_pktdata(priv)) {
 				pr_debug("frame received (%dbytes)", frame_len);
 				print_pkt(skb->data, frame_len);
@@ -3235,6 +3269,9 @@ static int __init stmmac_cmdline_opt(char *str)
 		} else if (!strncmp(opt, "chain_mode:", 11)) {
 			if (kstrtoint(opt + 11, 0, &chain_mode))
 				goto err;
+		} else if (!strncmp(opt, "minrx:", 6)) {
+			if (kstrtoint(opt + 6, 0, &minrx))
+				goto err;
 		}
 	}
 	return 0;
-- 
1.7.4.4

  parent reply	other threads:[~2015-12-09  8:28 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-09  8:37 [PATCH (net-next.git) 00/18] stmmac: enhance driver performances and update the version Giuseppe Cavallaro
2015-12-09  8:37 ` [PATCH (net-next.git) 01/18] stmmac: share reset function between dwmac100 and dwmac1000 Giuseppe Cavallaro
2015-12-09  8:37 ` [PATCH (net-next.git) 02/18] stmmac: rework DMA bus setting and introduce new platform AXI structure Giuseppe Cavallaro
2015-12-09  8:37 ` [PATCH (net-next.git) 03/18] stmmac: change descriptor layout Giuseppe Cavallaro
2015-12-09  8:37 ` [PATCH (net-next.git) 04/18] stmmac: remove modulo in stmmac_xmit() Giuseppe Cavallaro
2015-12-09  8:37 ` [PATCH (net-next.git) 05/18] stmmac: add length field to dma data Giuseppe Cavallaro
2015-12-09  8:37 ` [PATCH (net-next.git) 06/18] stmmac: add last_segment " Giuseppe Cavallaro
2015-12-09  8:37 ` [PATCH (net-next.git) 07/18] stmmac: add is_jumbo " Giuseppe Cavallaro
2015-12-09  8:37 ` [PATCH (net-next.git) 08/18] stmmac: merge get_rx_owner into rx_status routine Giuseppe Cavallaro
2015-12-09  8:37 ` [PATCH (net-next.git) 09/18] stmmac: optimize tx desc management Giuseppe Cavallaro
2015-12-09  8:37 ` [PATCH (net-next.git) 10/18] stmmac: optimize tx clean function Giuseppe Cavallaro
2015-12-09  8:37 ` [PATCH (net-next.git) 11/18] stmmac: set dirty index out of the loop Giuseppe Cavallaro
2015-12-09  8:37 ` [PATCH (net-next.git) 12/18] stmmac: first frame prep at the end of xmit routine Giuseppe Cavallaro
2015-12-09  8:37 ` [PATCH (net-next.git) 13/18] stmmac: perf, remove modulo in stmmac_rx() Giuseppe Cavallaro
2015-12-09 17:21   ` David Laight
2015-12-10  5:11     ` Giuseppe CAVALLARO
2015-12-10  5:51       ` Giuseppe CAVALLARO
2015-12-09  8:37 ` [PATCH (net-next.git) 14/18] stmmac: do not poll phy handler when attach a switch Giuseppe Cavallaro
2015-12-09  8:37 ` [PATCH (net-next.git) 15/18] stmmac: fix phy init when attached to a phy Giuseppe Cavallaro
2015-12-09  8:37 ` Giuseppe Cavallaro [this message]
2015-12-12  1:09   ` [PATCH (net-next.git) 16/18] stmmac: do not perform zero-copy for rx frames David Miller
2015-12-16 11:33     ` Giuseppe CAVALLARO
2015-12-09  8:37 ` [PATCH (net-next.git) 17/18] stmmac: tune rx copy via threshold Giuseppe Cavallaro
2015-12-09  8:37 ` [PATCH (net-next.git) 18/18] stmmac: update version to Oct_2015 Giuseppe Cavallaro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1449650274-14896-17-git-send-email-peppe.cavallaro@st.com \
    --to=peppe.cavallaro@st.com \
    --cc=alexandre.torgue@st.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.