Skip to content

Commit

Permalink
dpaa_eth: fix SG mapping
Browse files Browse the repository at this point in the history
An issue in the code mapping the skb fragments into
scatter-gather frames was evidentiated by netperf
TCP_SENDFILE tests. The size was set wrong for all
fragments but the first, affecting the transmission
of any skb with more than one fragment.

Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Madalin Bucur authored and David S. Miller committed Feb 27, 2018
1 parent afdd6ae commit 120d75e
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
frag_len = skb_headlen(skb);
qm_sg_entry_set_len(&sgt[0], frag_len);
sgt[0].bpid = FSL_DPAA_BPID_INV;
sgt[0].offset = 0;
addr = dma_map_single(dev, skb->data,
Expand All @@ -1930,9 +1932,9 @@ 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];
frag_len = frag->size;
WARN_ON(!skb_frag_page(frag));
addr = skb_frag_dma_map(dev, frag, 0,
frag_len, dma_dir);
Expand All @@ -1942,15 +1944,16 @@ static int skb_to_sg_fd(struct dpaa_priv *priv,
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], frag_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], frag_len);

qm_fd_set_sg(fd, priv->tx_headroom, skb->len);

Expand Down

0 comments on commit 120d75e

Please sign in to comment.