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

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.

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] 5+ messages in thread

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

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] 5+ messages in thread

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

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..a923a4daaa9e 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 header for VLAN, QinQ.
+	 */
+	if (nic->xdp_prog && new_mtu > MAX_XDP_MTU) {
+		netdev_warn(dev, "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] 5+ messages in thread

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

From: Matteo Croce <mcroce@redhat.com>
Date: Mon,  8 Apr 2019 23:06:45 +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.

Series applied and queued up for -stable.

_______________________________________________
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] 5+ messages in thread

* Re: [PATCH net v2 0/2] Fix thunderx MTU with XDP
  2019-04-11  2:35 ` [PATCH net v2 0/2] Fix thunderx MTU " David Miller
@ 2019-04-11  2:35   ` David Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2019-04-11  2:35 UTC (permalink / raw)
  To: mcroce; +Cc: rric, netdev, ilias.apalodimas, brouer, sgoutham, linux-arm-kernel

From: David Miller <davem@davemloft.net>
Date: Wed, 10 Apr 2019 19:35:16 -0700 (PDT)

> From: Matteo Croce <mcroce@redhat.com>
> Date: Mon,  8 Apr 2019 23:06:45 +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.
> 
> Series applied and queued up for -stable.

Actually, reverted, -ENOCOMPILE:

drivers/net/ethernet/cavium/thunder/nicvf_main.c: In function ‘nicvf_change_mtu’:
drivers/net/ethernet/cavium/thunder/nicvf_main.c:1596:15: error: ‘dev’ undeclared (first use in this function); did you mean ‘cdev’?
   netdev_warn(dev, "Jumbo frames not yet supported with XDP, current MTU %d.\n",
               ^~~
               cdev
drivers/net/ethernet/cavium/thunder/nicvf_main.c:1596:15: note: each undeclared identifier is reported only once for each function it appears in
_______________________________________________
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] 5+ messages in thread

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-08 21:06 [PATCH net v2 0/2] Fix thunderx MTU with XDP Matteo Croce
2019-04-08 21:06 ` [PATCH net v2 1/2] net: thunderx: raise XDP MTU to 1508 Matteo Croce
2019-04-08 21:06 ` [PATCH net v2 2/2] net: thunderx: don't allow jumbo frames with XDP Matteo Croce
2019-04-11  2:35 ` [PATCH net v2 0/2] Fix thunderx MTU " David Miller
2019-04-11  2:35   ` 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).