e7fd78cae1a7d9430a3c50bb2e5d5bdb4e5eb612
[openwrt/staging/ynezz.git] /
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
5
6 When creating a new skb for the errata workaround, maintain the socket
7 and timestamp configurations for timestamp hardware offloading.
8
9 Signed-off-by: Camelia Groza <camelia.groza@nxp.com>
10 ---
11 .../net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c | 44 +++++++++++++++-------
12 1 file changed, 31 insertions(+), 13 deletions(-)
13
14 --- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c
15 +++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c
16 @@ -42,6 +42,7 @@
17 #include <linux/skbuff.h>
18 #include <linux/highmem.h>
19 #include <linux/fsl_bman.h>
20 +#include <net/sock.h>
21
22 #include "dpaa_eth.h"
23 #include "dpaa_eth_common.h"
24 @@ -808,7 +809,11 @@ static struct sk_buff *a010022_realign_s
25 struct page *npage;
26 void *npage_addr;
27
28 - headroom = priv->tx_headroom;
29 + /* Guarantee the minimum required headroom */
30 + if (skb_headroom(skb) >= priv->tx_headroom)
31 + headroom = skb_headroom(skb);
32 + else
33 + headroom = priv->tx_headroom;
34
35 npage = alloc_page(GFP_ATOMIC);
36 if (unlikely(!npage)) {
37 @@ -832,8 +837,11 @@ static struct sk_buff *a010022_realign_s
38 if (unlikely(!nskb))
39 goto err;
40
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
44 + * alignment.
45 + * Code borrowed and adapted from skb_copy().
46 + */
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
52 }
53 copy_skb_header(nskb, skb);
54
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;
61 + if (skb->sk)
62 + skb_set_owner_w(nskb, skb->sk);
63 + }
64 +#endif
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
69
70 clear_fd(&fd);
71
72 +#ifndef CONFIG_PPC
73 + if (unlikely(dpaa_errata_a010022) && a010022_check_skb(skb, priv)) {
74 + skb = a010022_realign_skb(skb, priv);
75 + if (!skb)
76 + goto skb_to_fd_failed;
77 + }
78 +#endif
79 +
80 + nonlinear = skb_is_nonlinear(skb);
81 +
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 */
88
89 -#ifndef CONFIG_PPC
90 - if (unlikely(dpaa_errata_a010022) && a010022_check_skb(skb, priv)) {
91 - skb = a010022_realign_skb(skb, priv);
92 - if (!skb)
93 - goto skb_to_fd_failed;
94 - }
95 -#endif
96 -
97 - nonlinear = skb_is_nonlinear(skb);
98 -
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