From patchwork Tue Jan 31 03:23:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 50580 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2540209wrn; Mon, 30 Jan 2023 19:47:17 -0800 (PST) X-Google-Smtp-Source: AK7set+CDUjoNwIMXwLmT0CyFRjaJSNGCz1NexVnQgwx5SGtJeiRCEpaaJ/cTuQVHMhIIN0mQYTz X-Received: by 2002:a05:6a20:a00c:b0:bc:f189:505b with SMTP id p12-20020a056a20a00c00b000bcf189505bmr8652001pzj.46.1675136836733; Mon, 30 Jan 2023 19:47:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675136836; cv=none; d=google.com; s=arc-20160816; b=H9Dsi69+m4PSKjcLy7so7bFTleiiwxdrIaS3dhSVYjgpklvJ/KdZRG7HFUJOUDX/pt ZLEpm90dHwhVt4bkmuur94+sSpyTNxwg/pbcrPpMtsLkqmtGb83eYJBzaxk4VE+4Ps5S 7uPD8r7nwNhTUlya0XtiMSsQAObNtUgNsrlsD0BealPk7+0rnaAf8v4Wx8p/atJlelbk Vwnh3EdcDLlnD4XOtlJlheKrKsXPuylOUBP9KvI4zGOLpsy5pocDH3a98IoJJJ7S3zcZ V9uNj8CYspa/8J9vGblSVAtV2YGpFUTMJk69SPuMRTQrfcBOZw32a/hMmpv4vAHpAx6F ytRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=I7aOuN0Z7cOy5dqAaUiuywFRmsjtA1MOUQCg+0SjNXU=; b=a6wq//fA3qXNiIl3Yhed+dkfLn/eNH7etqKjA6Gf6wmlWwX+/u+OBIYhqo+H6aEX6Z sGFA7dS6/uXIbmvMoTsc0S3htUMjPBt4Xat2zfGmSV/OFtPrvvoDB1Gr0x9gucnmJwPC dtDlummNPn+Sh99mqLD9TapBrprgg9STs4dRvMRQjywqMomWDmLTbDPmSum7QDuelKHh ih3HPC51q78w/lQF9tmt56mQM8MqVDn8lUVdbDFxj9qOV3+6+NdRSAfjyAwT1St4dk7x /qE0scvz2P/TsfPzK7VDBlVh0NRVP1OV0k5ukVG90mHvYzUsaG/MZbAVNFkl3c09+N0R 2qAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=QLP6qnxq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w191-20020a6382c8000000b004d09ab32905si14659806pgd.256.2023.01.30.19.47.01; Mon, 30 Jan 2023 19:47:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=QLP6qnxq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229895AbjAaDYz (ORCPT + 99 others); Mon, 30 Jan 2023 22:24:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230306AbjAaDYu (ORCPT ); Mon, 30 Jan 2023 22:24:50 -0500 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 715552DE51; Mon, 30 Jan 2023 19:24:49 -0800 (PST) Received: by mail-pg1-x52f.google.com with SMTP id f3so9146025pgc.2; Mon, 30 Jan 2023 19:24:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=I7aOuN0Z7cOy5dqAaUiuywFRmsjtA1MOUQCg+0SjNXU=; b=QLP6qnxqtTVUGl8ftH1gx2SHFDp02aveZTLQWaEOtDVIhjkRGUGKMk4EpnBNTjEMlk 1rBuU1LF13nS12x7YzruzYDNrITQ50V3D9ZwxIu4okbxWH6j68pqU6HzH4d0mgMYblMi HOMRc4MZmxa1zygmqSMOatsw5R+MuyeIzSQpi0Ace2iJBsdIqOjuWrePd48IjOjX935U 1Fplq+GekDXsYlncVjlLu2ia7+kYovFP9bJz/HTX+W4iKtHLgdnnmRaOdpF8rghpjDoV b6+BdmJPqzpfznLLxThiKt0XOAxz0eHB3wZan1KdmVHd9wSahApJzACHQucJ+R4LhFaP 0zOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=I7aOuN0Z7cOy5dqAaUiuywFRmsjtA1MOUQCg+0SjNXU=; b=w1p8ycQ3ZqPIc3d+9bMslPRTG194nErOUDWt5+g4ipG7vEpiWjxT5Drpw42dozRWOJ /QhRfsCjR5PdhRXpfw+gpwS3XJnVZ9/oJGnDiA+WHku/LOG6qVpL+txuaRG3V+WVp52a pGZiNnnA8PrfY605YbcY0/1i7HCA5PGYzkkRKN3c+E7lXdIfcyVGUZj1+qDmvJtXGFu7 hkWqKyc/mJTkFi8Em7zv5RcaVQd2sFsCsH1jo4dZKctDeOY4Ov5anJmvrKjivFFjcjJU depERLLEXxkfv3TxYWPpel+PulTjhLPthr4/A8HCbhMAtoOc1WPa0+XjNly8EK2eXHn0 T19Q== X-Gm-Message-State: AO0yUKWVXn4kcmmZR//cTRUpWoYP8aWWNwuiHPdbEkAFw8hHEq3dByuU KiRHXPPEAYKQyCs5QhC8ei0= X-Received: by 2002:a62:585:0:b0:590:32a9:b276 with SMTP id 127-20020a620585000000b0059032a9b276mr19003810pff.22.1675135488934; Mon, 30 Jan 2023 19:24:48 -0800 (PST) Received: from KERNELXING-MB0.tencent.com ([103.7.29.31]) by smtp.gmail.com with ESMTPSA id 189-20020a6215c6000000b005906dbf5f80sm8207545pfv.163.2023.01.30.19.24.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 19:24:48 -0800 (PST) From: Jason Xing To: jesse.brandeburg@intel.com, anthony.l.nguyen@intel.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, alexandr.lobakin@intel.com, maciej.fijalkowski@intel.com Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, kerneljasonxing@gmail.com, Jason Xing Subject: [PATCH v3 net] ixgbe: allow to increase MTU to 3K with XDP enabled Date: Tue, 31 Jan 2023 11:23:57 +0800 Message-Id: <20230131032357.34029-1-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756508283589367086?= X-GMAIL-MSGID: =?utf-8?q?1756508283589367086?= From: Jason Xing Recently I encountered one case where I cannot increase the MTU size directly from 1500 to a much bigger value with XDP enabled if the server is equipped with IXGBE card, which happened on thousands of servers in production environment. After appling the current patch, we can set the maximum MTU size to 3K. This patch follows the behavior of changing MTU as i40e/ice does. Referrences: [1] commit 23b44513c3e6 ("ice: allow 3k MTU for XDP") [2] commit 0c8493d90b6b ("i40e: add XDP support for pass and drop actions") Fixes: fabf1bce103a ("ixgbe: Prevent unsupported configurations with XDP") Signed-off-by: Jason Xing --- v3: 1) modify the titile and body message. v2: 1) change the commit message. 2) modify the logic when changing MTU size suggested by Maciej and Alexander. --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index ab8370c413f3..2c1b6eb60436 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -6777,6 +6777,18 @@ static void ixgbe_free_all_rx_resources(struct ixgbe_adapter *adapter) ixgbe_free_rx_resources(adapter->rx_ring[i]); } +/** + * ixgbe_max_xdp_frame_size - returns the maximum allowed frame size for XDP + * @adapter - device handle, pointer to adapter + */ +static int ixgbe_max_xdp_frame_size(struct ixgbe_adapter *adapter) +{ + if (PAGE_SIZE >= 8192 || adapter->flags2 & IXGBE_FLAG2_RX_LEGACY) + return IXGBE_RXBUFFER_2K; + else + return IXGBE_RXBUFFER_3K; +} + /** * ixgbe_change_mtu - Change the Maximum Transfer Unit * @netdev: network interface device structure @@ -6788,18 +6800,13 @@ static int ixgbe_change_mtu(struct net_device *netdev, int new_mtu) { struct ixgbe_adapter *adapter = netdev_priv(netdev); - if (adapter->xdp_prog) { + if (ixgbe_enabled_xdp_adapter(adapter)) { int new_frame_size = new_mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN; - int i; - - for (i = 0; i < adapter->num_rx_queues; i++) { - struct ixgbe_ring *ring = adapter->rx_ring[i]; - if (new_frame_size > ixgbe_rx_bufsz(ring)) { - e_warn(probe, "Requested MTU size is not supported with XDP\n"); - return -EINVAL; - } + if (new_frame_size > ixgbe_max_xdp_frame_size(adapter)) { + e_warn(probe, "Requested MTU size is not supported with XDP\n"); + return -EINVAL; } }