1 From 2af4c8f51e2a55173f412ea51d5715378bba15be Mon Sep 17 00:00:00 2001
2 From: Camelia Groza <camelia.groza@nxp.com>
3 Date: Thu, 14 Sep 2017 10:40:53 +0300
4 Subject: [PATCH] sdk_dpaa: ls1043a errata: maintain timestamp info
6 When creating a new skb for the errata workaround, maintain the socket
7 and timestamp configurations for timestamp hardware offloading.
9 Signed-off-by: Camelia Groza <camelia.groza@nxp.com>
11 .../net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c | 44 +++++++++++++++-------
12 1 file changed, 31 insertions(+), 13 deletions(-)
14 --- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c
15 +++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c
17 #include <linux/skbuff.h>
18 #include <linux/highmem.h>
19 #include <linux/fsl_bman.h>
20 +#include <net/sock.h>
23 #include "dpaa_eth_common.h"
24 @@ -808,7 +809,11 @@ static struct sk_buff *a010022_realign_s
28 - headroom = priv->tx_headroom;
29 + /* Guarantee the minimum required headroom */
30 + if (skb_headroom(skb) >= priv->tx_headroom)
31 + headroom = skb_headroom(skb);
33 + headroom = priv->tx_headroom;
35 npage = alloc_page(GFP_ATOMIC);
36 if (unlikely(!npage)) {
37 @@ -832,8 +837,11 @@ static struct sk_buff *a010022_realign_s
41 - /* Code borrowed and adapted from skb_copy() */
42 - skb_reserve(nskb, headroom);
43 + /* Reserve only the needed headroom in order to guarantee the data's
45 + * Code borrowed and adapted from skb_copy().
47 + skb_reserve(nskb, priv->tx_headroom);
48 skb_put(nskb, skb->len);
49 if (skb_copy_bits(skb, 0, nskb->data, skb->len)) {
50 WARN_ONCE(1, "skb parsing failure\n");
51 @@ -841,6 +849,16 @@ static struct sk_buff *a010022_realign_s
53 copy_skb_header(nskb, skb);
55 +#ifdef CONFIG_FSL_DPAA_TS
56 + /* Copy relevant timestamp info from the old skb to the new */
57 + if (priv->ts_tx_en) {
58 + skb_shinfo(nskb)->tx_flags = skb_shinfo(skb)->tx_flags;
59 + skb_shinfo(nskb)->hwtstamps = skb_shinfo(skb)->hwtstamps;
60 + skb_shinfo(nskb)->tskey = skb_shinfo(skb)->tskey;
62 + skb_set_owner_w(nskb, skb->sk);
65 /* We move the headroom when we align it so we have to reset the
66 * network and transport header offsets relative to the new data
67 * pointer. The checksum offload relies on these offsets.
68 @@ -1041,6 +1059,16 @@ int __hot dpa_tx_extended(struct sk_buff
73 + if (unlikely(dpaa_errata_a010022) && a010022_check_skb(skb, priv)) {
74 + skb = a010022_realign_skb(skb, priv);
76 + goto skb_to_fd_failed;
80 + nonlinear = skb_is_nonlinear(skb);
82 #ifdef CONFIG_FSL_DPAA_1588
83 if (priv->tsu && priv->tsu->valid && priv->tsu->hwts_tx_en_ioctl)
84 fd.cmd |= FM_FD_CMD_UPD;
85 @@ -1052,16 +1080,6 @@ int __hot dpa_tx_extended(struct sk_buff
86 skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
87 #endif /* CONFIG_FSL_DPAA_TS */
90 - if (unlikely(dpaa_errata_a010022) && a010022_check_skb(skb, priv)) {
91 - skb = a010022_realign_skb(skb, priv);
93 - goto skb_to_fd_failed;
97 - nonlinear = skb_is_nonlinear(skb);
99 /* MAX_SKB_FRAGS is larger than our DPA_SGT_MAX_ENTRIES; make sure
100 * we don't feed FMan with more fragments than it supports.
101 * Btw, we're using the first sgt entry to store the linear part of