From patchwork Mon Apr 8 21:06:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matteo Croce X-Patchwork-Id: 10890167 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3759713B5 for ; Mon, 8 Apr 2019 21:07:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17BCC287E8 for ; Mon, 8 Apr 2019 21:07:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07961287EA; Mon, 8 Apr 2019 21:07:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 02D7B287E8 for ; Mon, 8 Apr 2019 21:07:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Z8Av4MDHtm+CvBWw0v44Fkhe7jLVgGRSNZAdXTigHD4=; b=eNDLNd/LqxX+i/ kJq/p900XAxPJGFQeUMa/4oNaQpijhYjB9o7M/t6LrgDdsUsk/GfyK4crn+Hmt6s0Wp6Xgc3xLYfv qrxnhb/Wn/z0OexvDT4lWltzTyD22SlVcJ7eub8heDLkbp2Pvud8aRsTNigM/FqswVyI4/ZO1oj5g nmJiNKT6HUIt04vclbcDb5j6INaiP1t2ksAaHyALvoLKjBHv+vu5I0NFTLbPAWx3coipwbUbaLZp0 6hhV1VAdQgaOa/HeXm0QD7tz0qumfYCiJqTn53gzcHh740rWBEadLu/q3GSf2Xymx8Ljs4phom7Ln kxwqQpjFDLsT8b9cGP6w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hDbTu-0008Sw-3F; Mon, 08 Apr 2019 21:07:06 +0000 Received: from mail-wm1-f68.google.com ([209.85.128.68]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hDbTp-0008PA-P2 for linux-arm-kernel@lists.infradead.org; Mon, 08 Apr 2019 21:07:03 +0000 Received: by mail-wm1-f68.google.com with SMTP id v14so827788wmf.2 for ; Mon, 08 Apr 2019 14:07:01 -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=jmsR5efXot1i3tS1mgdqG6MlXj+F8KnYGO3lfxj9u9khMMcK/utdqT0/OP7nrjOY1r ubDM5nvit60H6nYuF2OKc+V3RM90fmLrXofjhRFE6AYlRGEr1FOSqrFx4pqfJkmoZMCZ 4h3msNZj9mTS6YOMpad+rgQ41jADdsSHNumjLunT9E1MWi2vkXsI8F/FwL6J20+7RIw7 1htZarKcrakt6Ti+RsGur/h/kHJcGUhPy6sDoEihvT+sVT14y2fpDPO7TZ2tx8zESInS Val4PsFV33SLRlQGanFZXcd9oCkJh3gjkOlgorI/BAStMMgSPwNhBj0/lYdk00uwls+3 C6ow== X-Gm-Message-State: APjAAAVpigZCv0R7UODW34J5HIk75mGpsP1GSJTn+kkeXbqEUqbmfDO6 23otV4uPRzSsotrMKk+AkpP6Tg== X-Google-Smtp-Source: APXvYqz/XPhvfpx7anzdblj4u3/aaMGbSujreyX47dn9tGQ6Ux+EIWRWmPyay9QooM1dLi/GQoPh/A== X-Received: by 2002:a1c:a103:: with SMTP id k3mr19189258wme.8.1554757620222; Mon, 08 Apr 2019 14:07:00 -0700 (PDT) Received: from raver.teknoraver.net (net-93-70-69-135.cust.vodafonedsl.it. [93.70.69.135]) by smtp.gmail.com with ESMTPSA id b9sm18540663wmc.9.2019.04.08.14.06.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Apr 2019 14:06:59 -0700 (PDT) From: Matteo Croce To: netdev@vger.kernel.org Subject: [PATCH net v2 1/2] net: thunderx: raise XDP MTU to 1508 Date: Mon, 8 Apr 2019 23:06:46 +0200 Message-Id: <20190408210647.7385-2-mcroce@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190408210647.7385-1-mcroce@redhat.com> References: <20190408210647.7385-1-mcroce@redhat.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190408_140701_810289_ECDE5BA7 X-CRM114-Status: GOOD ( 15.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ilias Apalodimas , Sunil Goutham , Robert Richter , linux-arm-kernel@lists.infradead.org, Jesper Dangaard Brouer Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 Mon Apr 8 21:06:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matteo Croce X-Patchwork-Id: 10890169 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 37D2C13B5 for ; Mon, 8 Apr 2019 21:07:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1CCC5287E8 for ; Mon, 8 Apr 2019 21:07:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 112ED287EA; Mon, 8 Apr 2019 21:07:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A5C10287E8 for ; Mon, 8 Apr 2019 21:07:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8pmbW1nHWohysluAO4o/UfZ4cCNFXWFXoMjQGv9f4RU=; b=hZTFoktSN9al/J vsBTJHSpbpLQsWgPmDW5Bq4Y8/xNgqH4nov6w2JfRHHma+UmVzLjzMEZt3QusYk6QUy/9CqB6N6dz yL1FIrvMrB97ldqrFK4vNcuvvdbp5stCGE/y0vybwBMAZaL/EbFNLhSsq2EGSTojB+2n0cNFJWjdR WxoEahSLxzrytVunZHgmPE76OVo2MlkVU1xRr/FWB4xHsqHozQ092fQJwyP54ES/PLQ/ZdVR9XrKQ dsNl6dJ30xzQ8/MyOisua380mKtnsScA8C1G0tPftOwnCeqGjKFP3H/8RtS+CtLwWaHspo3wuoKKq hPRDu+omWeni/kzGH6sQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hDbU7-0000HM-PD; Mon, 08 Apr 2019 21:07:19 +0000 Received: from mail-wr1-f65.google.com ([209.85.221.65]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hDbU1-0000As-9p for linux-arm-kernel@lists.infradead.org; Mon, 08 Apr 2019 21:07:18 +0000 Received: by mail-wr1-f65.google.com with SMTP id h4so18069355wre.7 for ; Mon, 08 Apr 2019 14:07:13 -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=8GFiHDRdwz++IbzXDeuG8PyZnYrnLyrpERHimmc0BIA=; b=JfjnHqQU10fZg/l5shwpSNIkVrLBpXPRwO6F2D9EiGRn7XcpQCgt/Zu4UD1o9ISsns Lt0ABxJAMxkjBZ4/vnLFegRG+LT5BYesJv0mbRIw6YUxkjuvJEaGtBXq7uDEeXfRjZcn oMeBoErscABb1bRSCaXok2BW2lyFt11NKDF8kJAzG/1mIieScNgmhkpv8pFkCdcm4dkT LH2psNog6FYw4XyBEbYPNNbtBlGY1O8kDhasYRqn0C6M4Tyt06YZ4IIiQdYplYoMVyI+ 1hxUzhqfLv/Rf9vHxUhr3UVjov3dXrR0MZt82n5mXnxQgvIpeaLz6zXGfHguUAVeRUFt XupQ== X-Gm-Message-State: APjAAAV+u/s4PjYhh7rWYUIjx/dlE931BOoH7UrEe5Nh03FCnj8NZA93 gGCOfRoHNc8aHtXdCjwNYXLMfg== X-Google-Smtp-Source: APXvYqx4g7ogtCH5cWFWThZmavqwS03uUnNA9BD+6D2SavUNdspWvKXzNgfENhKEGBD8n+5leDTnFg== X-Received: by 2002:a5d:4047:: with SMTP id w7mr21162042wrp.255.1554757631707; Mon, 08 Apr 2019 14:07:11 -0700 (PDT) Received: from raver.teknoraver.net (net-93-70-69-135.cust.vodafonedsl.it. [93.70.69.135]) by smtp.gmail.com with ESMTPSA id w16sm45041883wrt.84.2019.04.08.14.07.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Apr 2019 14:07:10 -0700 (PDT) From: Matteo Croce To: netdev@vger.kernel.org Subject: [PATCH net v2 2/2] net: thunderx: don't allow jumbo frames with XDP Date: Mon, 8 Apr 2019 23:06:47 +0200 Message-Id: <20190408210647.7385-3-mcroce@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190408210647.7385-1-mcroce@redhat.com> References: <20190408210647.7385-1-mcroce@redhat.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190408_140713_563866_0AFB212F X-CRM114-Status: GOOD ( 12.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ilias Apalodimas , Sunil Goutham , Robert Richter , linux-arm-kernel@lists.infradead.org, Jesper Dangaard Brouer Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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))