From patchwork Thu Apr 11 10:26:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matteo Croce X-Patchwork-Id: 1083849 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44fxyn3TgQz9ryj for ; Thu, 11 Apr 2019 20:26:41 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726682AbfDKK0k (ORCPT ); Thu, 11 Apr 2019 06:26:40 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:33733 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726026AbfDKK0j (ORCPT ); Thu, 11 Apr 2019 06:26:39 -0400 Received: by mail-wm1-f66.google.com with SMTP id z6so1610767wmi.0 for ; Thu, 11 Apr 2019 03:26:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iF5YaZOw9A73xNUlwuizd4zKRqsvoxVZycHkFebqv8M=; b=XwrTPke0SW6NLofZt1/ST3ZacOLwhhoXjHBS3E3KIK4G6K0pfWsqUqIVe98zCFGuFv 8vPC6RhelWyq5hGKgUQf22vskSc7NwbgojlQ5QdBj0tffOjQSKdqxxCGxFVMvf0W/UTC xJ6uH+NvlppEokOBaIh1EnF58fS3Y1MBQaMC7m5rSOslyL3kbTHZJjsSqjBvUxbFo6P0 lX37PTjzcJW/1S5cGo0ktYytJD9WesTMDwZbhT94fePCx9k+X2Jo2SweUp00F7tUtcx4 bVIEn28CWTe7YeBIwsoYnHoYxgzOsTaeCWZ/egtUe5pTSHKZFatYzH22gJE/SibY6DQG gk8w== X-Gm-Message-State: APjAAAXlwSMIHiqjKouw5jk7ioBw5uVyH/Zm/k3PsCrfCHs7U8i1QYwO 12TD3EZzQLrWmNVf0j2rMfwwan1nA4A= X-Google-Smtp-Source: APXvYqzf1eWmOqqvJc0bn/xp2JMe6mZ/bnKRYnQwU8ezmQp8RvjE8fbmXY5aB+cKzJmtPN+o7KUYrQ== X-Received: by 2002:a1c:9dc8:: with SMTP id g191mr6327712wme.132.1554978397053; Thu, 11 Apr 2019 03:26:37 -0700 (PDT) Received: from mcroce-redhat.mxp.redhat.com (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.gmail.com with ESMTPSA id 204sm7681684wmc.1.2019.04.11.03.26.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Apr 2019 03:26:36 -0700 (PDT) From: Matteo Croce To: netdev@vger.kernel.org Cc: Sunil Goutham , Robert Richter , linux-arm-kernel@lists.infradead.org, Ilias Apalodimas , Jesper Dangaard Brouer , David Miller Subject: [PATCH v3 1/2] net: thunderx: raise XDP MTU to 1508 Date: Thu, 11 Apr 2019 12:26:32 +0200 Message-Id: <20190411102633.3685-2-mcroce@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190411102633.3685-1-mcroce@redhat.com> References: <20190411102633.3685-1-mcroce@redhat.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 Acked-by: Jesper Dangaard Brouer --- 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; From patchwork Thu Apr 11 10:26:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matteo Croce X-Patchwork-Id: 1083850 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44fxyq0gn6z9ryj for ; Thu, 11 Apr 2019 20:26:43 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726691AbfDKK0l (ORCPT ); Thu, 11 Apr 2019 06:26:41 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:34516 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726635AbfDKK0k (ORCPT ); Thu, 11 Apr 2019 06:26:40 -0400 Received: by mail-wm1-f68.google.com with SMTP id r186so1609039wmf.1 for ; Thu, 11 Apr 2019 03:26:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Gi3SOf8ZFfPE0FWhRc13sB95XG0PUYYR4jIgV6Oweg4=; b=WqdWRTJEuf2wFh7paFR+DijGSZQ743M2h0zKSRDxilPQpkCnukY9zjrppEd+x6ubY4 puCGOZ1RfLvsTSCM1jfrRCKUmLmYtIUbDftAWeIvzhfZVVniEWd037r0XE2nWEADexF7 b9Q/n6iPQ3GGtvSs0mWjaP9IWRCChA8Y40STmPt53PRsDX2GkkiC1n2+G6AjSxcY/byX q76AgYYckQ+rS40m7Ijy59Tn/1G+0o9D/ucewmJL4rua6FUbdh0AXdCJIJmUh7YGwTtI zMAymCLu67WruuBqlLWvXANPCbvancZBk6u6VbBTGCsbYVe7zScj/zeIIJx5ylpdI+K/ cSZg== X-Gm-Message-State: APjAAAUwLJ7Pp2wLuW2evrrpLbHj4Ib9/gmSIa/MfHWNKcn4+BPoDDpx 6srO1UfngOts6TJj1Fk2TGd4q6xyx1Y= X-Google-Smtp-Source: APXvYqy88040TxWxZ41cUacGsJ6l1tKbw3r1Ixd4i0FLCcUj1xFn8/py1a7gEPyCwm+h9/zlzieAxA== X-Received: by 2002:a05:600c:c4:: with SMTP id u4mr6328000wmm.80.1554978398248; Thu, 11 Apr 2019 03:26:38 -0700 (PDT) Received: from mcroce-redhat.mxp.redhat.com (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.gmail.com with ESMTPSA id 204sm7681684wmc.1.2019.04.11.03.26.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Apr 2019 03:26:37 -0700 (PDT) From: Matteo Croce To: netdev@vger.kernel.org Cc: Sunil Goutham , Robert Richter , linux-arm-kernel@lists.infradead.org, Ilias Apalodimas , Jesper Dangaard Brouer , David Miller Subject: [PATCH v3 2/2] net: thunderx: don't allow jumbo frames with XDP Date: Thu, 11 Apr 2019 12:26:33 +0200 Message-Id: <20190411102633.3685-3-mcroce@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190411102633.3685-1-mcroce@redhat.com> References: <20190411102633.3685-1-mcroce@redhat.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 Acked-by: Jesper Dangaard Brouer --- 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))