Skip to content

Commit f422abe

Browse files
IoanaCiorneidavem330
authored andcommitted
dpaa2-eth: increase the needed headroom to account for alignment
Increase the needed headroom to account for a 64 byte alignment restriction which, with this patch, we make mandatory on the Tx path. The case in which the amount of headroom needed is not available is already handled by the driver which instead sends a S/G frame with the first buffer only holding the SW and HW annotation areas. Without this patch, we can empirically see data corruption happening between Tx and Tx confirmation which sometimes leads to the SW annotation area being overwritten. Since this is an old IP where the hardware team cannot help to understand the underlying behavior, we make the Tx alignment mandatory for all frames to avoid the crash on Tx conf. Also, remove the comment that suggested that this is just an optimization. This patch also sets the needed_headroom net device field to the usual value that the driver would need on the Tx path: - 64 bytes for the software annotation area - 64 bytes to account for a 64 byte aligned buffer address Fixes: 6e2387e ("staging: fsl-dpaa2/eth: Add Freescale DPAA2 Ethernet driver") Closes: https://lore.kernel.org/netdev/[email protected]/ Signed-off-by: Ioana Ciornei <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a524eab commit f422abe

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,14 +1073,12 @@ static int dpaa2_eth_build_single_fd(struct dpaa2_eth_priv *priv,
10731073
dma_addr_t addr;
10741074

10751075
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-
*/
10801076
aligned_start = PTR_ALIGN(buffer_start - DPAA2_ETH_TX_BUF_ALIGN,
10811077
DPAA2_ETH_TX_BUF_ALIGN);
10821078
if (aligned_start >= skb->head)
10831079
buffer_start = aligned_start;
1080+
else
1081+
return -ENOMEM;
10841082

10851083
/* Store a backpointer to the skb at the beginning of the buffer
10861084
* (in the private data area) such that we can release it
@@ -4967,6 +4965,8 @@ static int dpaa2_eth_probe(struct fsl_mc_device *dpni_dev)
49674965
if (err)
49684966
goto err_dl_port_add;
49694967

4968+
net_dev->needed_headroom = DPAA2_ETH_SWA_SIZE + DPAA2_ETH_TX_BUF_ALIGN;
4969+
49704970
err = register_netdev(net_dev);
49714971
if (err < 0) {
49724972
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)