mvebu: remove redundant patch for Linksys LED trigger
[openwrt/openwrt.git] / target / linux / mvebu / patches-5.4 / 023-net-mvneta-fix-XDP-support-if-sw-bm-is-used-as-fallb.patch
1 From 44efc78d0e464ce70b45b165c005f8bedc17952e Mon Sep 17 00:00:00 2001
2 From: Lorenzo Bianconi <lorenzo@kernel.org>
3 Date: Wed, 29 Jan 2020 12:50:53 +0100
4 Subject: [PATCH] net: mvneta: fix XDP support if sw bm is used as fallback
5
6 In order to fix XDP support if sw buffer management is used as fallback
7 for hw bm devices, define MVNETA_SKB_HEADROOM as maximum between
8 XDP_PACKET_HEADROOM and NET_SKB_PAD and let the hw aligns the IP header
9 to 4-byte boundary.
10 Fix rx_offset_correction initialization if mvneta_bm_port_init fails in
11 mvneta_resume routine
12
13 Fixes: 0db51da7a8e9 ("net: mvneta: add basic XDP support")
14 Tested-by: Sven Auhagen <sven.auhagen@voleatech.de>
15 Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
16 Signed-off-by: David S. Miller <davem@davemloft.net>
17 ---
18 drivers/net/ethernet/marvell/mvneta.c | 10 +++++++---
19 1 file changed, 7 insertions(+), 3 deletions(-)
20
21 --- a/drivers/net/ethernet/marvell/mvneta.c
22 +++ b/drivers/net/ethernet/marvell/mvneta.c
23 @@ -326,8 +326,7 @@
24 ETH_HLEN + ETH_FCS_LEN, \
25 cache_line_size())
26
27 -#define MVNETA_SKB_HEADROOM (max(XDP_PACKET_HEADROOM, NET_SKB_PAD) + \
28 - NET_IP_ALIGN)
29 +#define MVNETA_SKB_HEADROOM max(XDP_PACKET_HEADROOM, NET_SKB_PAD)
30 #define MVNETA_SKB_PAD (SKB_DATA_ALIGN(sizeof(struct skb_shared_info) + \
31 MVNETA_SKB_HEADROOM))
32 #define MVNETA_SKB_SIZE(len) (SKB_DATA_ALIGN(len) + MVNETA_SKB_PAD)
33 @@ -1174,6 +1173,7 @@ bm_mtu_err:
34 mvneta_bm_pool_destroy(pp->bm_priv, pp->pool_short, 1 << pp->id);
35
36 pp->bm_priv = NULL;
37 + pp->rx_offset_correction = MVNETA_SKB_HEADROOM;
38 mvreg_write(pp, MVNETA_ACC_MODE, MVNETA_ACC_MODE_EXT1);
39 netdev_info(pp->dev, "fail to update MTU, fall back to software BM\n");
40 }
41 @@ -4984,7 +4984,6 @@ static int mvneta_probe(struct platform_
42 SET_NETDEV_DEV(dev, &pdev->dev);
43
44 pp->id = global_port_id++;
45 - pp->rx_offset_correction = MVNETA_SKB_HEADROOM;
46
47 /* Obtain access to BM resources if enabled and already initialized */
48 bm_node = of_parse_phandle(dn, "buffer-manager", 0);
49 @@ -5009,6 +5008,10 @@ static int mvneta_probe(struct platform_
50 }
51 of_node_put(bm_node);
52
53 + /* sw buffer management */
54 + if (!pp->bm_priv)
55 + pp->rx_offset_correction = MVNETA_SKB_HEADROOM;
56 +
57 err = mvneta_init(&pdev->dev, pp);
58 if (err < 0)
59 goto err_netdev;
60 @@ -5166,6 +5169,7 @@ static int mvneta_resume(struct device *
61 err = mvneta_bm_port_init(pdev, pp);
62 if (err < 0) {
63 dev_info(&pdev->dev, "use SW buffer management\n");
64 + pp->rx_offset_correction = MVNETA_SKB_HEADROOM;
65 pp->bm_priv = NULL;
66 }
67 }