Fix thunderx MTU with XDP
Subsystems (3)
v3 cover Fix thunderx MTU with XDP
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 argumentMatteo 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(-)
Signature · 1 line
2.21.0
PATCH v3 1/2 net: thunderx: raise XDP MTU to 1508
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.
--- drivers/net/ethernet/cavium/thunder/nicvf_main.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/net/ethernet/cavium/thunder/nicvf_main.c +11 -2
@@ -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 ;
Signature · 1 line
2.21.0
Re: [PATCH v3 1/2] net: thunderx: raise XDP MTU to 1508
Quoted 8 lines · On Thu, 11 Apr 2019 12:26:32 +0200 Matteo Croce <[email protected]> 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.
Quoted 5 lines
Fixes 05c773f52b96e ("net: thunderx: Add basic XDP support")Signed-off-by Matteo Croce <[email protected]>--- drivers/net/ethernet/cavium/thunder/nicvf_main.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
LGTM
Signature · 4 lines
Best regards, Jesper Dangaard Brouer MSc.CS, Principal Kernel Engineer at Red Hat LinkedIn: http://www.linkedin.com/in/brouer
PATCH v3 2/2 net: thunderx: don't allow jumbo frames with XDP
In reply to Matteo CroceThe 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.
--- drivers/net/ethernet/cavium/thunder/nicvf_main.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/net/ethernet/cavium/thunder/nicvf_main.c +9 -0
@@ -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))
Signature · 1 line
2.21.0
Re: [PATCH v3 2/2] net: thunderx: don't allow jumbo frames with XDP
Quoted 7 lines · On Thu, 11 Apr 2019 12:26:33 +0200 Matteo Croce <[email protected]> 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 <[email protected]>
LGTM
Signature · 4 lines
Best regards, Jesper Dangaard Brouer MSc.CS, Principal Kernel Engineer at Red Hat LinkedIn: http://www.linkedin.com/in/brouer
David Miller
maintainerFrom: Matteo Croce <[email protected]>
Date: Thu, 11 Apr 2019 12:26:31 +0200
Quoted 5 lines
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.