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: 10895629 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 28B1E1708 for ; Thu, 11 Apr 2019 10:26:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1287228CD3 for ; Thu, 11 Apr 2019 10:26:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 06B7E28CD7; Thu, 11 Apr 2019 10:26:54 +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 A7CA528CDA for ; Thu, 11 Apr 2019 10:26:53 +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=WTNUrkpGocCe5u MU+JyEO9yO055YTCaqagXg1X65zLvnC3ExMQaG1eI4ELRPnYktc+OYuUOuH+ChdBPup10YYAkvB9Q W2TTKGXIdNLIrwccC/FCnKjpO5kNet07vUrmcRuiGwM+L8SnOOalQau4lBHaA3SPHsv9cEV9w+VIq eKeggoWnKfe0Ztrs+/YqLxkMn+IJEuwigbu0avuuDo23yo1YorrC/Tf+J2CqGKaJFTsIw/f1eHHX/ I3XdCo6pf6fCGn7QyEAC0SyWi51HY4Jf7BixNkBPMrXBPDXLB63TS1gkk/k2E8z3kcOfKnTIJALG8 ABamXvbWi6NTniMf6KAQ==; 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 1hEWus-0004hm-Ba; Thu, 11 Apr 2019 10:26:46 +0000 Received: from mail-wm1-f65.google.com ([209.85.128.65]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hEWuk-0004bH-LA for linux-arm-kernel@lists.infradead.org; Thu, 11 Apr 2019 10:26:39 +0000 Received: by mail-wm1-f65.google.com with SMTP id r186so1608985wmf.1 for ; Thu, 11 Apr 2019 03:26:38 -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=BNlvmjPl5v8ZgLqA4TCBPaC0s/Qdh1Q5+UcsEW/2LDOhR2jahL0YhknLHlB61095B+ 4pn+w+jU20MayaTNjyTgrYlqg4VRZjILNQCdMZgpO3S2BeSnzMu6MkFuRNqbkUN9Wp/A Vn0DJo6fjDyi7tlWtJzQgFB+Ge/FzRApylr0oldG85aJUlLMbiOnh38zuuQQnF3Lfu15 QZFKJe28bJEmXvtxPDnsg7Zoyhosf41SeJy9O9hgF2zdMv92rigGI8NDX8NwdqHMj8fD s0D177IG6WiX0vUH3WqfubpmXWiQNU3nEHJrXVis1Lyghe3ULjwELIlrE4rcUetXOKwl L2bQ== X-Gm-Message-State: APjAAAXJQek0wXR3ScMTjsjbKRaP9J2fRdR16LrGvxkpiQZdDbT0k1jR IlF1YzONuONyvsRKIeltNthnSw== 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190411_032638_687507_E3F92EC1 X-CRM114-Status: GOOD ( 15.01 ) 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: Robert Richter , Ilias Apalodimas , Jesper Dangaard Brouer , Sunil Goutham , David Miller , linux-arm-kernel@lists.infradead.org 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 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: 10895631 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 B56D01708 for ; Thu, 11 Apr 2019 10:27:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A02CC28B49 for ; Thu, 11 Apr 2019 10:27:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 92F6728CD0; Thu, 11 Apr 2019 10:27:12 +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 4574428B49 for ; Thu, 11 Apr 2019 10:27:12 +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=4S3B5C5TH0bTndrZEdee0wxr9aDFj0aeUmbHK+pr2pk=; b=P3PF3FNE2H9PAj GqOn8u9mP2BDIICeuqczlQPQpTKskccroCEsWZHgU9Wu0zCrBhjRkET2T2310GvxZz41HrwSGUkWo RcfVGXz6Kdv8ANJgqBpHB4aypzb1TKndVyi+By2mB1yjYzD8BbEqA2msA4rhLrrNwnqZVHGuTMRmO ozd2XEIzESk+MMZhLtxiKs9rc4M6bzUFEWodDGt32F0skCTOxq8f0jY/GBGkW17f5DBBML7/BZ323 wfzcf/6hdcYf1T1tJFy3XkBKLqAOrU+nLdp57jIw3EuKUUTwcMmQ3/wdDDC1BERTr82S8MGZ9gXzm QxqLGxzG1IPXNnDtul4A==; 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 1hEWvD-000550-6M; Thu, 11 Apr 2019 10:27:07 +0000 Received: from mail-wm1-f67.google.com ([209.85.128.67]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hEWul-0004bU-RU for linux-arm-kernel@lists.infradead.org; Thu, 11 Apr 2019 10:26:41 +0000 Received: by mail-wm1-f67.google.com with SMTP id q16so6018873wmj.3 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=bt0DPtfm06bqBRp+OaWgKJXRFBqebyBRlaQ91bHAkHPYYNlpWU2u6UAus1ZdPneteD QlvuIon8apcWP1LmNs65MAoFgTIGk8V9ZQJ+oiwEgW5GkSv7ghDNszeiOUmNgPmLL06V FBUF40uB0Ff0aLSvwolGXOdh7iEVc3T6kj0nfoddiZtl5yzApnksArnKyd7nOsAWLnGw OrLCiX6DfQH7cqIV74Y48FQx/9PizU92U0BRlM5fxf6EzGjqf0jrcc6PjMo0zCTkM7OD dGvuP3D+t1CsrvncYxRIRixOjXPZ9V5dWzxVmsb6lBOdw9lNsRS0uhWllnQokS9ti+zd gDXg== X-Gm-Message-State: APjAAAXk5dBhgJpL+B5c/BIV0pA8FfxrW0Fx1v/pp0/eVUmSO9tahUHS 4QZh6UmW7G8tcujdcUmfAliXxQ== 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190411_032639_883725_53657FDC X-CRM114-Status: GOOD ( 12.13 ) 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: Robert Richter , Ilias Apalodimas , Jesper Dangaard Brouer , Sunil Goutham , David Miller , linux-arm-kernel@lists.infradead.org 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 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))