mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Madalin Bucur <madalin.bucur@nxp.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, linux-kernel@vger.kernel.org,
	Madalin Bucur <madalin.bucur@nxp.com>
Subject: [PATCH net-next 1/4] dpaa_eth: fix SG mapping
Date: Mon, 19 Feb 2018 10:10:41 -0600	[thread overview]
Message-ID: <20180219161044.30279-2-madalin.bucur@nxp.com> (raw)
In-Reply-To: <20180219161044.30279-1-madalin.bucur@nxp.com>

An issue in the code mapping the skb fragments into
scatter-gather frames was evidentiated by netperf
TCP_SENDFILE tests. This patch addresses the issue.

Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
---
 drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 27 ++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
index a998c36..a5afa60 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
@@ -1889,7 +1889,7 @@ static int skb_to_sg_fd(struct dpaa_priv *priv,
 	void *buffer_start;
 	skb_frag_t *frag;
 	dma_addr_t addr;
-	size_t frag_len;
+	size_t buff_len;
 	void *sgt_buf;
 
 	/* get a page frag to store the SGTable */
@@ -1916,8 +1916,10 @@ static int skb_to_sg_fd(struct dpaa_priv *priv,
 		goto csum_failed;
 	}
 
+	/* SGT[0] is used by the linear part */
 	sgt = (struct qm_sg_entry *)(sgt_buf + priv->tx_headroom);
-	qm_sg_entry_set_len(&sgt[0], skb_headlen(skb));
+	buff_len = skb_headlen(skb);
+	qm_sg_entry_set_len(&sgt[0], buff_len);
 	sgt[0].bpid = FSL_DPAA_BPID_INV;
 	sgt[0].offset = 0;
 	addr = dma_map_single(dev, skb->data,
@@ -1930,27 +1932,28 @@ static int skb_to_sg_fd(struct dpaa_priv *priv,
 	qm_sg_entry_set64(&sgt[0], addr);
 
 	/* populate the rest of SGT entries */
-	frag = &skb_shinfo(skb)->frags[0];
-	frag_len = frag->size;
-	for (i = 1; i <= nr_frags; i++, frag++) {
+	for (i = 0; i < nr_frags; i++) {
+		frag = &skb_shinfo(skb)->frags[i];
+		buff_len = frag->size;
 		WARN_ON(!skb_frag_page(frag));
 		addr = skb_frag_dma_map(dev, frag, 0,
-					frag_len, dma_dir);
+					buff_len, dma_dir);
 		if (unlikely(dma_mapping_error(dev, addr))) {
 			dev_err(dev, "DMA mapping failed");
 			err = -EINVAL;
 			goto sg_map_failed;
 		}
 
-		qm_sg_entry_set_len(&sgt[i], frag_len);
-		sgt[i].bpid = FSL_DPAA_BPID_INV;
-		sgt[i].offset = 0;
+		qm_sg_entry_set_len(&sgt[i + 1], buff_len);
+		sgt[i + 1].bpid = FSL_DPAA_BPID_INV;
+		sgt[i + 1].offset = 0;
 
 		/* keep the offset in the address */
-		qm_sg_entry_set64(&sgt[i], addr);
-		frag_len = frag->size;
+		qm_sg_entry_set64(&sgt[i + 1], addr);
 	}
-	qm_sg_entry_set_f(&sgt[i - 1], frag_len);
+
+	/* Set the final bit in the last used entry of the SGT */
+	qm_sg_entry_set_f(&sgt[nr_frags], buff_len);
 
 	qm_fd_set_sg(fd, priv->tx_headroom, skb->len);
 
-- 
2.1.0

  reply	other threads:[~2018-02-19 16:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-19 16:10 [PATCH net-next 0/4] DPAA Ethernet fixes Madalin Bucur
2018-02-19 16:10 ` Madalin Bucur [this message]
2018-02-20 18:56   ` [PATCH net-next 1/4] dpaa_eth: fix SG mapping David Miller
2018-02-19 16:10 ` [PATCH net-next 2/4] dpaa_eth: make sure all Rx errors are counted Madalin Bucur
2018-02-19 16:10 ` [PATCH net-next 3/4] dpaa_eth: refactor frag count checking Madalin Bucur
2018-02-19 16:10 ` [PATCH net-next 4/4] dpaa_eth: Add allmulti option Madalin Bucur

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=20180219161044.30279-2-madalin.bucur@nxp.com \
    --to=madalin.bucur@nxp.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®