forked from Poco-Ye/rk-ethernet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
0001-net-ethernet-stmmac-Workaround-for-tx-checksum-error.patch
59 lines (53 loc) · 1.67 KB
/
0001-net-ethernet-stmmac-Workaround-for-tx-checksum-error.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
From 330126d68d1ecd63fb8ff10f6e3962a945610faf Mon Sep 17 00:00:00 2001
From: David Wu <[email protected]>
Date: Wed, 10 Apr 2019 11:43:11 +0800
Subject: [PATCH] net: ethernet: stmmac: Workaround for tx checksum error
Change-Id: Ib0f45ff087e7e7e1c5ef9869b316441314151478
Signed-off-by: David Wu <[email protected]>
---
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 27 +++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 22748ea4498f..965a9d6a2c41 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1942,6 +1942,23 @@ static int stmmac_release(struct net_device *dev)
return 0;
}
+static bool stmmac_tx_skb_need_linearize(struct sk_buff *skb, struct net_device *dev)
+{
+ int nfrags = skb_shinfo(skb)->nr_frags, i;
+
+ if (skb->len != dev->mtu + ETH_HLEN)
+ return false;
+
+ for (i = 0; i < nfrags; i++) {
+ const skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
+
+ if (!IS_ALIGNED((unsigned long)frag->page_offset, 4))
+ return true;
+ }
+
+ return false;
+}
+
/**
* stmmac_xmit - Tx entry point of the driver
* @skb : the socket buffer
@@ -1973,6 +1990,16 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
return NETDEV_TX_BUSY;
}
+ if (stmmac_tx_skb_need_linearize(skb, dev)) {
+ if (skb_linearize(skb)) {
+ spin_unlock(&priv->tx_lock);
+ return NETDEV_TX_BUSY;
+ } else {
+ nfrags = skb_shinfo(skb)->nr_frags;
+ nopaged_len = skb_headlen(skb);
+ }
+ }
+
if (priv->tx_path_in_lpi_mode)
stmmac_disable_eee_mode(priv);
--
2.19.1