Commit 9a4dda81 authored by David S. Miller's avatar David S. Miller

Merge branch 'thunderx-xdp-mtu'

Matteo Croce says:

====================
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:

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
[  787.019730] nicvf 0002:01:00.1 enP2p1s0v0: Jumbo frames not yet supported with XDP, current MTU 1800.
RTNETLINK answers: Operation not supported
[  800.574568] nicvf 0002:01:00.1 enP2p1s0v0: Link is Up 10000 Mbps Full duplex
[  807.248321] nicvf 0002:01:00.1 enP2p1s0v0: Jumbo frames not yet supported with XDP, current MTU 1500.
RTNETLINK answers: Invalid argument
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 796fff0c 1f227d16
......@@ -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,
......@@ -1582,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))
......@@ -1830,8 +1846,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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment