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: 1081520 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 44dNK34G4gz9sCF for ; Tue, 9 Apr 2019 07:07:03 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726920AbfDHVHC (ORCPT ); Mon, 8 Apr 2019 17:07:02 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:50446 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726517AbfDHVHC (ORCPT ); Mon, 8 Apr 2019 17:07:02 -0400 Received: by mail-wm1-f65.google.com with SMTP id z11so919994wmi.0 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=GMo6kq/QgeWHX+ZKwniPIIfp2saUCsEMhWlWLACyHSFNIrYfUHB44y7Rqxy6iBE/mN XkL4M+ZefDjzv6QmrwtJhlT8D6nKHYMZ3r7AA9lbiNKl6Jw964EJoDhcCCIQidc3dkRA DA3ug5fo1kwBuRVlV55mtu2sqx6NchDfyO2jMKGN/uiKXF3EcWdrtkeptZTeJQeXXJuw C4oMi5RZcul9cuy+7wZQAwNb10CjAoU8VujK8/2JeFmZS4YKlATNfHpCakUD0dPNY496 BotRqdihQR+12BIDE6tPteF0QvF4+Br4IE7ZTraQKf6JWz26fOLuQB6lii8vNK4dD3b/ dp5g== X-Gm-Message-State: APjAAAWv7p4ti40MojcIt4Ju3rBwNH36C2MALGbJPJjFBtEznMC/SCtL PeTG8dXqej6EDDXt5lWTUT1AiGrgrMg= 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 Cc: Sunil Goutham , Robert Richter , linux-arm-kernel@lists.infradead.org, Ilias Apalodimas , Jesper Dangaard Brouer 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 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 --- 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: 1081521 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 44dNKH12Wmz9s47 for ; Tue, 9 Apr 2019 07:07:15 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729120AbfDHVHO (ORCPT ); Mon, 8 Apr 2019 17:07:14 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:42473 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726517AbfDHVHN (ORCPT ); Mon, 8 Apr 2019 17:07:13 -0400 Received: by mail-wr1-f65.google.com with SMTP id g3so18042961wrx.9 for ; Mon, 08 Apr 2019 14:07:12 -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=VRLvnNAy0Ci+/IRyKDH2pYDLag7U27b5ul30a/4A8NbwThqfDuuMkALd5MiRgitMnp Xs4TV2uSdO3Oo3VNBUsU/5WYESIuUUITWin4590ojz2d2jEDT/b3/JQVFElurF58ApcU BO3Pi6DMMR6NgH2p18LTzJ0F8mTBZhP1UKEYaWZwwfRwEZ8bTIzioLFHRTDFo6zpymdZ zuQfMQfSKL6/aKougbUi0zl+B7S5Vwv0De45difurFXlnoiytNdhxKMQGsDb0eqD8of6 KyC+XxNEHzOuU8QLMvMxQWdLr8g4xJIaOtsG9Jl1r04qmPOJNLsibbDLdPzNRyHQugZH EUtA== X-Gm-Message-State: APjAAAVi2CD27B0H4J9/bytUTZyZwm31cFje05TvwI7vvF4PcDmdJDVz QaS+09q6pG72qTojcMLwIdbXiCyNeJ8= 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 Cc: Sunil Goutham , Robert Richter , linux-arm-kernel@lists.infradead.org, Ilias Apalodimas , Jesper Dangaard Brouer 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 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 --- 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))