diff options
author | Jakov Petrina <jakov.petrina@sartura.hr> | 2020-05-25 14:14:40 +0200 |
---|---|---|
committer | Luka Perkov <luka.perkov@sartura.hr> | 2020-05-28 11:43:13 +0200 |
commit | 3dbb658d26062b34e5a540a4477e4a768628c42c (patch) | |
tree | eb3342be7f0e8693c3ae1442668ee4a1ba26b04d /target | |
parent | 76f9aa6f4bfd12fba34fc44aef890c48d4fb1024 (diff) | |
download | upstream-3dbb658d26062b34e5a540a4477e4a768628c42c.tar.gz upstream-3dbb658d26062b34e5a540a4477e4a768628c42c.tar.bz2 upstream-3dbb658d26062b34e5a540a4477e4a768628c42c.zip |
linux: mvebu: backport mvneta XDP support fixes
This patch backports additional fixes for XDP support in the mvneta driver. These
changes are found upstream as commits:
b37fa92e20ef2 net: mvneta: fix build skb for bm capable devices
f383b2950070c net: mvneta: rely on page_pool_recycle_direct in mvneta_run_xdp
79572c98c554d mvneta driver disallow XDP program on hardware buffer management
44efc78d0e464 net: mvneta: fix XDP support if sw bm is used as fallback
Signed-off-by: Jakov Petrina <jakov.petrina@sartura.hr>
Diffstat (limited to 'target')
4 files changed, 200 insertions, 0 deletions
diff --git a/target/linux/mvebu/patches-5.4/020-net-mvneta-fix-build-skb-for-bm-capable-devices.patch b/target/linux/mvebu/patches-5.4/020-net-mvneta-fix-build-skb-for-bm-capable-devices.patch new file mode 100644 index 0000000000..94de008e76 --- /dev/null +++ b/target/linux/mvebu/patches-5.4/020-net-mvneta-fix-build-skb-for-bm-capable-devices.patch @@ -0,0 +1,41 @@ +From b37fa92e20ef28aada852cbf03b368d29a20478c Mon Sep 17 00:00:00 2001 +From: Lorenzo Bianconi <lorenzo@kernel.org> +Date: Thu, 14 Nov 2019 01:25:55 +0200 +Subject: [PATCH] net: mvneta: fix build skb for bm capable devices + +Fix build_skb for bm capable devices when they fall-back using swbm path +(e.g. when bm properties are configured in device tree but +CONFIG_MVNETA_BM_ENABLE is not set). In this case rx_offset_correction is +overwritten so we need to use it building skb instead of +MVNETA_SKB_HEADROOM directly + +Fixes: 8dc9a0888f4c ("net: mvneta: rely on build_skb in mvneta_rx_swbm poll routine") +Fixes: 0db51da7a8e9 ("net: mvneta: add basic XDP support") +Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> +Reported-by: Andrew Lunn <andrew@lunn.ch> +Tested-by: Andrew Lunn <andrew@lunn.ch> +Signed-off-by: David S. Miller <davem@davemloft.net> +--- + drivers/net/ethernet/marvell/mvneta.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/drivers/net/ethernet/marvell/mvneta.c ++++ b/drivers/net/ethernet/marvell/mvneta.c +@@ -2165,7 +2165,7 @@ mvneta_swbm_rx_frame(struct mvneta_port + prefetch(data); + + xdp->data_hard_start = data; +- xdp->data = data + MVNETA_SKB_HEADROOM + MVNETA_MH_SIZE; ++ xdp->data = data + pp->rx_offset_correction + MVNETA_MH_SIZE; + xdp->data_end = xdp->data + data_len; + xdp_set_data_meta_invalid(xdp); + +@@ -2230,7 +2230,7 @@ mvneta_swbm_add_rx_fragment(struct mvnet + /* refill descriptor with new buffer later */ + skb_add_rx_frag(rxq->skb, + skb_shinfo(rxq->skb)->nr_frags, +- page, MVNETA_SKB_HEADROOM, data_len, ++ page, pp->rx_offset_correction, data_len, + PAGE_SIZE); + } + page_pool_release_page(rxq->page_pool, page); diff --git a/target/linux/mvebu/patches-5.4/021-net-mvneta-rely-on-page_pool_recycle_direct-in-mvnet.patch b/target/linux/mvebu/patches-5.4/021-net-mvneta-rely-on-page_pool_recycle_direct-in-mvnet.patch new file mode 100644 index 0000000000..a4ee285b04 --- /dev/null +++ b/target/linux/mvebu/patches-5.4/021-net-mvneta-rely-on-page_pool_recycle_direct-in-mvnet.patch @@ -0,0 +1,39 @@ +From f383b2950070ce4f34e74db94f70bb565b746e97 Mon Sep 17 00:00:00 2001 +From: Lorenzo Bianconi <lorenzo@kernel.org> +Date: Wed, 20 Nov 2019 16:54:17 +0200 +Subject: [PATCH] net: mvneta: rely on page_pool_recycle_direct in + mvneta_run_xdp + +Rely on page_pool_recycle_direct and not on xdp_return_buff in +mvneta_run_xdp. This is a preliminary patch to limit the dma sync len +to the one strictly necessary + +Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> +Acked-by: Jesper Dangaard Brouer <brouer@redhat.com> +Signed-off-by: David S. Miller <davem@davemloft.net> +--- + drivers/net/ethernet/marvell/mvneta.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +--- a/drivers/net/ethernet/marvell/mvneta.c ++++ b/drivers/net/ethernet/marvell/mvneta.c +@@ -2108,7 +2108,8 @@ mvneta_run_xdp(struct mvneta_port *pp, s + err = xdp_do_redirect(pp->dev, xdp, prog); + if (err) { + ret = MVNETA_XDP_DROPPED; +- xdp_return_buff(xdp); ++ page_pool_recycle_direct(rxq->page_pool, ++ virt_to_head_page(xdp->data)); + } else { + ret = MVNETA_XDP_REDIR; + } +@@ -2117,7 +2118,8 @@ mvneta_run_xdp(struct mvneta_port *pp, s + case XDP_TX: + ret = mvneta_xdp_xmit_back(pp, xdp); + if (ret != MVNETA_XDP_TX) +- xdp_return_buff(xdp); ++ page_pool_recycle_direct(rxq->page_pool, ++ virt_to_head_page(xdp->data)); + break; + default: + bpf_warn_invalid_xdp_action(act); diff --git a/target/linux/mvebu/patches-5.4/022-mvneta-driver-disallow-XDP-program-on-hardware-buffe.patch b/target/linux/mvebu/patches-5.4/022-mvneta-driver-disallow-XDP-program-on-hardware-buffe.patch new file mode 100644 index 0000000000..57ad8b6958 --- /dev/null +++ b/target/linux/mvebu/patches-5.4/022-mvneta-driver-disallow-XDP-program-on-hardware-buffe.patch @@ -0,0 +1,53 @@ +From 79572c98c554dcdb080bca547c871a51716dcdf8 Mon Sep 17 00:00:00 2001 +From: Sven Auhagen <sven.auhagen@voleatech.de> +Date: Sat, 25 Jan 2020 08:07:03 +0000 +Subject: [PATCH] mvneta driver disallow XDP program on hardware buffer + management + +Recently XDP Support was added to the mvneta driver +for software buffer management only. +It is still possible to attach an XDP program if +hardware buffer management is used. +It is not doing anything at that point. + +The patch disallows attaching XDP programs to mvneta +if hardware buffer management is used. + +I am sorry about that. It is my first submission and I am having +some troubles with the format of my emails. + +v4 -> v5: +- Remove extra tabs + +v3 -> v4: +- Please ignore v3 I accidentally submitted + my other patch with git-send-mail and v4 is correct + +v2 -> v3: +- My mailserver corrupted the patch + resubmission with git-send-email + +v1 -> v2: +- Fixing the patches indentation + +Signed-off-by: Sven Auhagen <sven.auhagen@voleatech.de> +Signed-off-by: David S. Miller <davem@davemloft.net> +--- + drivers/net/ethernet/marvell/mvneta.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +--- a/drivers/net/ethernet/marvell/mvneta.c ++++ b/drivers/net/ethernet/marvell/mvneta.c +@@ -4231,6 +4231,12 @@ static int mvneta_xdp_setup(struct net_d + return -EOPNOTSUPP; + } + ++ if (pp->bm_priv) { ++ NL_SET_ERR_MSG_MOD(extack, ++ "Hardware Buffer Management not supported on XDP"); ++ return -EOPNOTSUPP; ++ } ++ + need_update = !!pp->xdp_prog != !!prog; + if (running && need_update) + mvneta_stop(dev); diff --git a/target/linux/mvebu/patches-5.4/023-net-mvneta-fix-XDP-support-if-sw-bm-is-used-as-fallb.patch b/target/linux/mvebu/patches-5.4/023-net-mvneta-fix-XDP-support-if-sw-bm-is-used-as-fallb.patch new file mode 100644 index 0000000000..38b874cd49 --- /dev/null +++ b/target/linux/mvebu/patches-5.4/023-net-mvneta-fix-XDP-support-if-sw-bm-is-used-as-fallb.patch @@ -0,0 +1,67 @@ +From 44efc78d0e464ce70b45b165c005f8bedc17952e Mon Sep 17 00:00:00 2001 +From: Lorenzo Bianconi <lorenzo@kernel.org> +Date: Wed, 29 Jan 2020 12:50:53 +0100 +Subject: [PATCH] net: mvneta: fix XDP support if sw bm is used as fallback + +In order to fix XDP support if sw buffer management is used as fallback +for hw bm devices, define MVNETA_SKB_HEADROOM as maximum between +XDP_PACKET_HEADROOM and NET_SKB_PAD and let the hw aligns the IP header +to 4-byte boundary. +Fix rx_offset_correction initialization if mvneta_bm_port_init fails in +mvneta_resume routine + +Fixes: 0db51da7a8e9 ("net: mvneta: add basic XDP support") +Tested-by: Sven Auhagen <sven.auhagen@voleatech.de> +Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> +Signed-off-by: David S. Miller <davem@davemloft.net> +--- + drivers/net/ethernet/marvell/mvneta.c | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +--- a/drivers/net/ethernet/marvell/mvneta.c ++++ b/drivers/net/ethernet/marvell/mvneta.c +@@ -324,8 +324,7 @@ + ETH_HLEN + ETH_FCS_LEN, \ + cache_line_size()) + +-#define MVNETA_SKB_HEADROOM (max(XDP_PACKET_HEADROOM, NET_SKB_PAD) + \ +- NET_IP_ALIGN) ++#define MVNETA_SKB_HEADROOM max(XDP_PACKET_HEADROOM, NET_SKB_PAD) + #define MVNETA_SKB_PAD (SKB_DATA_ALIGN(sizeof(struct skb_shared_info) + \ + MVNETA_SKB_HEADROOM)) + #define MVNETA_SKB_SIZE(len) (SKB_DATA_ALIGN(len) + MVNETA_SKB_PAD) +@@ -1172,6 +1171,7 @@ bm_mtu_err: + mvneta_bm_pool_destroy(pp->bm_priv, pp->pool_short, 1 << pp->id); + + pp->bm_priv = NULL; ++ pp->rx_offset_correction = MVNETA_SKB_HEADROOM; + mvreg_write(pp, MVNETA_ACC_MODE, MVNETA_ACC_MODE_EXT1); + netdev_info(pp->dev, "fail to update MTU, fall back to software BM\n"); + } +@@ -4954,7 +4954,6 @@ static int mvneta_probe(struct platform_ + SET_NETDEV_DEV(dev, &pdev->dev); + + pp->id = global_port_id++; +- pp->rx_offset_correction = MVNETA_SKB_HEADROOM; + + /* Obtain access to BM resources if enabled and already initialized */ + bm_node = of_parse_phandle(dn, "buffer-manager", 0); +@@ -4979,6 +4978,10 @@ static int mvneta_probe(struct platform_ + } + of_node_put(bm_node); + ++ /* sw buffer management */ ++ if (!pp->bm_priv) ++ pp->rx_offset_correction = MVNETA_SKB_HEADROOM; ++ + err = mvneta_init(&pdev->dev, pp); + if (err < 0) + goto err_netdev; +@@ -5136,6 +5139,7 @@ static int mvneta_resume(struct device * + err = mvneta_bm_port_init(pdev, pp); + if (err < 0) { + dev_info(&pdev->dev, "use SW buffer management\n"); ++ pp->rx_offset_correction = MVNETA_SKB_HEADROOM; + pp->bm_priv = NULL; + } + } |