Skip to content

Commit f06fae1

Browse files
madalinbucurgregkh
authored andcommitted
dpaa_eth: DPAA SGT needs to be 256B
[ Upstream commit 595e802 ] The DPAA HW requires that at least 256 bytes from the start of the first scatter-gather table entry are allocated and accessible. The hardware reads the maximum size the table can have in one access, thus requiring that the allocation and mapping to be done for the maximum size of 256B even if there is a smaller number of entries in the table. Signed-off-by: Madalin Bucur <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent fba7c43 commit f06fae1

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

drivers/net/ethernet/freescale/dpaa/dpaa_eth.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ MODULE_PARM_DESC(tx_timeout, "The Tx timeout in ms");
125125
/* Default alignment for start of data in an Rx FD */
126126
#define DPAA_FD_DATA_ALIGNMENT 16
127127

128+
/* The DPAA requires 256 bytes reserved and mapped for the SGT */
129+
#define DPAA_SGT_SIZE 256
130+
128131
/* Values for the L3R field of the FM Parse Results
129132
*/
130133
/* L3 Type field: First IP Present IPv4 */
@@ -1622,8 +1625,8 @@ static struct sk_buff *dpaa_cleanup_tx_fd(const struct dpaa_priv *priv,
16221625

16231626
if (unlikely(qm_fd_get_format(fd) == qm_fd_sg)) {
16241627
nr_frags = skb_shinfo(skb)->nr_frags;
1625-
dma_unmap_single(dev, addr, qm_fd_get_offset(fd) +
1626-
sizeof(struct qm_sg_entry) * (1 + nr_frags),
1628+
dma_unmap_single(dev, addr,
1629+
qm_fd_get_offset(fd) + DPAA_SGT_SIZE,
16271630
dma_dir);
16281631

16291632
/* The sgt buffer has been allocated with netdev_alloc_frag(),
@@ -1907,8 +1910,7 @@ static int skb_to_sg_fd(struct dpaa_priv *priv,
19071910
void *sgt_buf;
19081911

19091912
/* get a page frag to store the SGTable */
1910-
sz = SKB_DATA_ALIGN(priv->tx_headroom +
1911-
sizeof(struct qm_sg_entry) * (1 + nr_frags));
1913+
sz = SKB_DATA_ALIGN(priv->tx_headroom + DPAA_SGT_SIZE);
19121914
sgt_buf = netdev_alloc_frag(sz);
19131915
if (unlikely(!sgt_buf)) {
19141916
netdev_err(net_dev, "netdev_alloc_frag() failed for size %d\n",
@@ -1976,9 +1978,8 @@ static int skb_to_sg_fd(struct dpaa_priv *priv,
19761978
skbh = (struct sk_buff **)buffer_start;
19771979
*skbh = skb;
19781980

1979-
addr = dma_map_single(dev, buffer_start, priv->tx_headroom +
1980-
sizeof(struct qm_sg_entry) * (1 + nr_frags),
1981-
dma_dir);
1981+
addr = dma_map_single(dev, buffer_start,
1982+
priv->tx_headroom + DPAA_SGT_SIZE, dma_dir);
19821983
if (unlikely(dma_mapping_error(dev, addr))) {
19831984
dev_err(dev, "DMA mapping failed");
19841985
err = -EINVAL;

0 commit comments

Comments
 (0)