Skip to content

Commit 595e802

Browse files
madalinbucurdavem330
authored andcommitted
dpaa_eth: DPAA SGT needs to be 256B
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]>
1 parent b95f6fb commit 595e802

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 */
@@ -1617,8 +1620,8 @@ static struct sk_buff *dpaa_cleanup_tx_fd(const struct dpaa_priv *priv,
16171620

16181621
if (unlikely(qm_fd_get_format(fd) == qm_fd_sg)) {
16191622
nr_frags = skb_shinfo(skb)->nr_frags;
1620-
dma_unmap_single(dev, addr, qm_fd_get_offset(fd) +
1621-
sizeof(struct qm_sg_entry) * (1 + nr_frags),
1623+
dma_unmap_single(dev, addr,
1624+
qm_fd_get_offset(fd) + DPAA_SGT_SIZE,
16221625
dma_dir);
16231626

16241627
/* The sgt buffer has been allocated with netdev_alloc_frag(),
@@ -1903,8 +1906,7 @@ static int skb_to_sg_fd(struct dpaa_priv *priv,
19031906
void *sgt_buf;
19041907

19051908
/* get a page frag to store the SGTable */
1906-
sz = SKB_DATA_ALIGN(priv->tx_headroom +
1907-
sizeof(struct qm_sg_entry) * (1 + nr_frags));
1909+
sz = SKB_DATA_ALIGN(priv->tx_headroom + DPAA_SGT_SIZE);
19081910
sgt_buf = netdev_alloc_frag(sz);
19091911
if (unlikely(!sgt_buf)) {
19101912
netdev_err(net_dev, "netdev_alloc_frag() failed for size %d\n",
@@ -1972,9 +1974,8 @@ static int skb_to_sg_fd(struct dpaa_priv *priv,
19721974
skbh = (struct sk_buff **)buffer_start;
19731975
*skbh = skb;
19741976

1975-
addr = dma_map_single(dev, buffer_start, priv->tx_headroom +
1976-
sizeof(struct qm_sg_entry) * (1 + nr_frags),
1977-
dma_dir);
1977+
addr = dma_map_single(dev, buffer_start,
1978+
priv->tx_headroom + DPAA_SGT_SIZE, dma_dir);
19781979
if (unlikely(dma_mapping_error(dev, addr))) {
19791980
dev_err(dev, "DMA mapping failed");
19801981
err = -EINVAL;

0 commit comments

Comments
 (0)