linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] Fix thunderx MTU with XDP
@ 2019-04-11 10:26 Matteo Croce
  2019-04-11 10:26 ` [PATCH v3 1/2] net: thunderx: raise XDP MTU to 1508 Matteo Croce
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Matteo Croce @ 2019-04-11 10:26 UTC (permalink / raw)
  To: netdev
  Cc: Robert Richter, Ilias Apalodimas, Jesper Dangaard Brouer,
	Sunil Goutham, David Miller, linux-arm-kernel

The thunderx driver can't use XDP with all MTU values.
This patches sets the right MTU values, and add a check to avoid setting
a wrong value which will not function.

v3: Fix a copy-paste from two functions, tested on proper hardware:

# ip link show dev enP2p1s0v0
2: enP2p1s0v0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether 1c:1b:0d:0d:52:a4 brd ff:ff:ff:ff:ff:ff
# ip link set enP2p1s0v0 mtu 1800
# ip link set dev enP2p1s0v0 xdpdrv object mtu.o
[  787.019730] nicvf 0002:01:00.1 enP2p1s0v0: Jumbo frames not yet supported with XDP, current MTU 1800.
RTNETLINK answers: Operation not supported
# ip link set enP2p1s0v0 mtu 1500
# ip link set dev enP2p1s0v0 xdpdrv object mtu.o
[  800.574568] nicvf 0002:01:00.1 enP2p1s0v0: Link is Up 10000 Mbps Full duplex
# ip link set enP2p1s0v0 mtu 1600
[  807.248321] nicvf 0002:01:00.1 enP2p1s0v0: Jumbo frames not yet supported with XDP, current MTU 1500.
RTNETLINK answers: Invalid argument

Matteo Croce (2):
  net: thunderx: raise XDP MTU to 1508
  net: thunderx: don't allow jumbo frames with XDP

 .../net/ethernet/cavium/thunder/nicvf_main.c  | 22 +++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

-- 
2.21.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v3 1/2] net: thunderx: raise XDP MTU to 1508
  2019-04-11 10:26 [PATCH v3 0/2] Fix thunderx MTU with XDP Matteo Croce
@ 2019-04-11 10:26 ` Matteo Croce
  2019-04-11 13:04   ` Jesper Dangaard Brouer
  2019-04-11 10:26 ` [PATCH v3 2/2] net: thunderx: don't allow jumbo frames with XDP Matteo Croce
  2019-04-11 18:11 ` [PATCH v3 0/2] Fix thunderx MTU " David Miller
  2 siblings, 1 reply; 6+ messages in thread
From: Matteo Croce @ 2019-04-11 10:26 UTC (permalink / raw)
  To: netdev
  Cc: Robert Richter, Ilias Apalodimas, Jesper Dangaard Brouer,
	Sunil Goutham, David Miller, linux-arm-kernel

The thunderx driver splits frames bigger than 1530 bytes to multiple
pages, making impossible to run an eBPF program on it.
This leads to a maximum MTU of 1508 if QinQ is in use.

The thunderx driver forbids to load an eBPF program if the MTU is higher
than 1500 bytes. Raise the limit to 1508 so it is possible to use L2
protocols which need some more headroom.

Fixes: 05c773f52b96e ("net: thunderx: Add basic XDP support")
Signed-off-by: Matteo Croce <mcroce@redhat.com>
---
 drivers/net/ethernet/cavium/thunder/nicvf_main.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
index 28eac9056211..debc8c861c6b 100644
--- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c
+++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
@@ -32,6 +32,13 @@
 #define DRV_NAME	"nicvf"
 #define DRV_VERSION	"1.0"
 
+/* NOTE: Packets bigger than 1530 are split across multiple pages and XDP needs
+ * the buffer to be contiguous. Allow XDP to be set up only if we don't exceed
+ * this value, keeping headroom for the 14 byte Ethernet header and two
+ * VLAN tags (for QinQ)
+ */
+#define MAX_XDP_MTU	(1530 - ETH_HLEN - VLAN_HLEN * 2)
+
 /* Supported devices */
 static const struct pci_device_id nicvf_id_table[] = {
 	{ PCI_DEVICE_SUB(PCI_VENDOR_ID_CAVIUM,
@@ -1830,8 +1837,10 @@ static int nicvf_xdp_setup(struct nicvf *nic, struct bpf_prog *prog)
 	bool bpf_attached = false;
 	int ret = 0;
 
-	/* For now just support only the usual MTU sized frames */
-	if (prog && (dev->mtu > 1500)) {
+	/* For now just support only the usual MTU sized frames,
+	 * plus some headroom for VLAN, QinQ.
+	 */
+	if (prog && dev->mtu > MAX_XDP_MTU) {
 		netdev_warn(dev, "Jumbo frames not yet supported with XDP, current MTU %d.\n",
 			    dev->mtu);
 		return -EOPNOTSUPP;
-- 
2.21.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v3 2/2] net: thunderx: don't allow jumbo frames with XDP
  2019-04-11 10:26 [PATCH v3 0/2] Fix thunderx MTU with XDP Matteo Croce
  2019-04-11 10:26 ` [PATCH v3 1/2] net: thunderx: raise XDP MTU to 1508 Matteo Croce
@ 2019-04-11 10:26 ` Matteo Croce
  2019-04-11 13:05   ` Jesper Dangaard Brouer
  2019-04-11 18:11 ` [PATCH v3 0/2] Fix thunderx MTU " David Miller
  2 siblings, 1 reply; 6+ messages in thread
From: Matteo Croce @ 2019-04-11 10:26 UTC (permalink / raw)
  To: netdev
  Cc: Robert Richter, Ilias Apalodimas, Jesper Dangaard Brouer,
	Sunil Goutham, David Miller, linux-arm-kernel

The thunderx driver forbids to load an eBPF program if the MTU is too high,
but this can be circumvented by loading the eBPF, then raising the MTU.

Fix this by limiting the MTU if an eBPF program is already loaded.

Fixes: 05c773f52b96e ("net: thunderx: Add basic XDP support")
Signed-off-by: Matteo Croce <mcroce@redhat.com>
---
 drivers/net/ethernet/cavium/thunder/nicvf_main.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
index debc8c861c6b..c032bef1b776 100644
--- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c
+++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
@@ -1589,6 +1589,15 @@ static int nicvf_change_mtu(struct net_device *netdev, int new_mtu)
 	struct nicvf *nic = netdev_priv(netdev);
 	int orig_mtu = netdev->mtu;
 
+	/* For now just support only the usual MTU sized frames,
+	 * plus some headroom for VLAN, QinQ.
+	 */
+	if (nic->xdp_prog && new_mtu > MAX_XDP_MTU) {
+		netdev_warn(netdev, "Jumbo frames not yet supported with XDP, current MTU %d.\n",
+			    netdev->mtu);
+		return -EINVAL;
+	}
+
 	netdev->mtu = new_mtu;
 
 	if (!netif_running(netdev))
-- 
2.21.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v3 1/2] net: thunderx: raise XDP MTU to 1508
  2019-04-11 10:26 ` [PATCH v3 1/2] net: thunderx: raise XDP MTU to 1508 Matteo Croce
@ 2019-04-11 13:04   ` Jesper Dangaard Brouer
  0 siblings, 0 replies; 6+ messages in thread
From: Jesper Dangaard Brouer @ 2019-04-11 13:04 UTC (permalink / raw)
  To: Matteo Croce
  Cc: Robert Richter, netdev, Ilias Apalodimas, brouer, Sunil Goutham,
	David Miller, linux-arm-kernel

On Thu, 11 Apr 2019 12:26:32 +0200
Matteo Croce <mcroce@redhat.com> wrote:

> The thunderx driver splits frames bigger than 1530 bytes to multiple
> pages, making impossible to run an eBPF program on it.
> This leads to a maximum MTU of 1508 if QinQ is in use.
> 
> The thunderx driver forbids to load an eBPF program if the MTU is higher
> than 1500 bytes. Raise the limit to 1508 so it is possible to use L2
> protocols which need some more headroom.
> 
> Fixes: 05c773f52b96e ("net: thunderx: Add basic XDP support")
> Signed-off-by: Matteo Croce <mcroce@redhat.com>
> ---
>  drivers/net/ethernet/cavium/thunder/nicvf_main.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)

LGTM

Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>

-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3 2/2] net: thunderx: don't allow jumbo frames with XDP
  2019-04-11 10:26 ` [PATCH v3 2/2] net: thunderx: don't allow jumbo frames with XDP Matteo Croce
@ 2019-04-11 13:05   ` Jesper Dangaard Brouer
  0 siblings, 0 replies; 6+ messages in thread
From: Jesper Dangaard Brouer @ 2019-04-11 13:05 UTC (permalink / raw)
  To: Matteo Croce
  Cc: Robert Richter, netdev, Ilias Apalodimas, brouer, Sunil Goutham,
	David Miller, linux-arm-kernel

On Thu, 11 Apr 2019 12:26:33 +0200
Matteo Croce <mcroce@redhat.com> wrote:

> The thunderx driver forbids to load an eBPF program if the MTU is too high,
> but this can be circumvented by loading the eBPF, then raising the MTU.
> 
> Fix this by limiting the MTU if an eBPF program is already loaded.
> 
> Fixes: 05c773f52b96e ("net: thunderx: Add basic XDP support")
> Signed-off-by: Matteo Croce <mcroce@redhat.com>

LGTM

Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>

-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3 0/2] Fix thunderx MTU with XDP
  2019-04-11 10:26 [PATCH v3 0/2] Fix thunderx MTU with XDP Matteo Croce
  2019-04-11 10:26 ` [PATCH v3 1/2] net: thunderx: raise XDP MTU to 1508 Matteo Croce
  2019-04-11 10:26 ` [PATCH v3 2/2] net: thunderx: don't allow jumbo frames with XDP Matteo Croce
@ 2019-04-11 18:11 ` David Miller
  2 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2019-04-11 18:11 UTC (permalink / raw)
  To: mcroce; +Cc: rric, netdev, ilias.apalodimas, brouer, sgoutham, linux-arm-kernel

From: Matteo Croce <mcroce@redhat.com>
Date: Thu, 11 Apr 2019 12:26:31 +0200

> The thunderx driver can't use XDP with all MTU values.
> This patches sets the right MTU values, and add a check to avoid setting
> a wrong value which will not function.
> 
> v3: Fix a copy-paste from two functions, tested on proper hardware:
 ...

Series applied and queued up for -stable, thanks.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-04-11 18:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-11 10:26 [PATCH v3 0/2] Fix thunderx MTU with XDP Matteo Croce
2019-04-11 10:26 ` [PATCH v3 1/2] net: thunderx: raise XDP MTU to 1508 Matteo Croce
2019-04-11 13:04   ` Jesper Dangaard Brouer
2019-04-11 10:26 ` [PATCH v3 2/2] net: thunderx: don't allow jumbo frames with XDP Matteo Croce
2019-04-11 13:05   ` Jesper Dangaard Brouer
2019-04-11 18:11 ` [PATCH v3 0/2] Fix thunderx MTU " David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).