Skip to content

Commit ccf49ce

Browse files
committed
Merge branch 'dpaa2-eth-fixes'
Ioana Ciornei says: ==================== dpaa2-eth: various fixes The first patch fixes a memory corruption issue happening between the Tx and Tx confirmation of a packet by making the Tx alignment at 64bytes mandatory instead of optional as it was previously. The second patch fixes the Rx copybreak code path which recycled the initial data buffer before all processing was done on the packet. Changes in v2: - squashed patches #1 and #2 ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents a524eab + beb1930 commit ccf49ce

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,6 @@ struct sk_buff *dpaa2_eth_alloc_skb(struct dpaa2_eth_priv *priv,
516516

517517
memcpy(skb->data, fd_vaddr + fd_offset, fd_length);
518518

519-
dpaa2_eth_recycle_buf(priv, ch, dpaa2_fd_get_addr(fd));
520-
521519
return skb;
522520
}
523521

@@ -589,6 +587,7 @@ void dpaa2_eth_rx(struct dpaa2_eth_priv *priv,
589587
struct rtnl_link_stats64 *percpu_stats;
590588
struct dpaa2_eth_drv_stats *percpu_extras;
591589
struct device *dev = priv->net_dev->dev.parent;
590+
bool recycle_rx_buf = false;
592591
void *buf_data;
593592
u32 xdp_act;
594593

@@ -618,6 +617,8 @@ void dpaa2_eth_rx(struct dpaa2_eth_priv *priv,
618617
dma_unmap_page(dev, addr, priv->rx_buf_size,
619618
DMA_BIDIRECTIONAL);
620619
skb = dpaa2_eth_build_linear_skb(ch, fd, vaddr);
620+
} else {
621+
recycle_rx_buf = true;
621622
}
622623
} else if (fd_format == dpaa2_fd_sg) {
623624
WARN_ON(priv->xdp_prog);
@@ -637,6 +638,9 @@ void dpaa2_eth_rx(struct dpaa2_eth_priv *priv,
637638
goto err_build_skb;
638639

639640
dpaa2_eth_receive_skb(priv, ch, fd, vaddr, fq, percpu_stats, skb);
641+
642+
if (recycle_rx_buf)
643+
dpaa2_eth_recycle_buf(priv, ch, dpaa2_fd_get_addr(fd));
640644
return;
641645

642646
err_build_skb:
@@ -1073,14 +1077,12 @@ static int dpaa2_eth_build_single_fd(struct dpaa2_eth_priv *priv,
10731077
dma_addr_t addr;
10741078

10751079
buffer_start = skb->data - dpaa2_eth_needed_headroom(skb);
1076-
1077-
/* If there's enough room to align the FD address, do it.
1078-
* It will help hardware optimize accesses.
1079-
*/
10801080
aligned_start = PTR_ALIGN(buffer_start - DPAA2_ETH_TX_BUF_ALIGN,
10811081
DPAA2_ETH_TX_BUF_ALIGN);
10821082
if (aligned_start >= skb->head)
10831083
buffer_start = aligned_start;
1084+
else
1085+
return -ENOMEM;
10841086

10851087
/* Store a backpointer to the skb at the beginning of the buffer
10861088
* (in the private data area) such that we can release it
@@ -4967,6 +4969,8 @@ static int dpaa2_eth_probe(struct fsl_mc_device *dpni_dev)
49674969
if (err)
49684970
goto err_dl_port_add;
49694971

4972+
net_dev->needed_headroom = DPAA2_ETH_SWA_SIZE + DPAA2_ETH_TX_BUF_ALIGN;
4973+
49704974
err = register_netdev(net_dev);
49714975
if (err < 0) {
49724976
dev_err(dev, "register_netdev() failed\n");

drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ static inline bool dpaa2_eth_rx_pause_enabled(u64 link_options)
740740

741741
static inline unsigned int dpaa2_eth_needed_headroom(struct sk_buff *skb)
742742
{
743-
unsigned int headroom = DPAA2_ETH_SWA_SIZE;
743+
unsigned int headroom = DPAA2_ETH_SWA_SIZE + DPAA2_ETH_TX_BUF_ALIGN;
744744

745745
/* If we don't have an skb (e.g. XDP buffer), we only need space for
746746
* the software annotation area

0 commit comments

Comments
 (0)