Message ID | 20230208024333.10465-1-kerneljasonxing@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3212405wrn; Tue, 7 Feb 2023 18:45:51 -0800 (PST) X-Google-Smtp-Source: AK7set9et/ytPETisbUyzdA4lyx1D0sDmfx2+qZsXUyRtRkEEs1RoB0qBo5rFcYF7ThKO4Tz5NBC X-Received: by 2002:a17:90a:bb8e:b0:22c:890a:f489 with SMTP id v14-20020a17090abb8e00b0022c890af489mr6891987pjr.8.1675824350909; Tue, 07 Feb 2023 18:45:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675824350; cv=none; d=google.com; s=arc-20160816; b=RiyoAyhPcjtqcsaq7804hsT1rapY9I0Gi7HtbEtEhYycWvQfjNzA/eQZRyT9L5WFTM 1mEJyS0o9tdunTR3YUv3IpFwJ/h+smb08mkvpyh7ALlYN2c+xrSVLi6gsXoMi455h5wC KdJU9tM8DwY1OKpgCxG1Q+4+NhxTQrPYWKG+fym3s3H+XxG8s2BcSmXZXtTemvioPV1L Z5UdOcn3mtvVatc/qtSkViSKS9pQEdlgzU2qGxyYyK7njN4XtrD2VWs+730sxWL/ay0X /hwsagbbl+G5TXe5lQHPc5ZV8Nq/INY2MaGhVL9kwy653lb3riZEFEmk73U3DNlEuZjL 4slA== 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=La3OH/wxxUC+XGiTFrGm7IEcXqspoaqeInslaM1lK3o=; b=hFZjA32Gy4nIY2qGiLAWYJzzD9XbExZesRqUQNT85KNPb3AZFTaBSggsTnJJr/VoD7 uZi+7MutGLw7A+ROLJfLf/FVU4TfPyHaohMMXj4Ox+IMCI0wBE0D9eJDPsi6rpKeHjTX gLh2cLKsljy0ePcTcAy2swwh9YWMdhj6XmWVZlRA105GXwcQIbl31bPmHtWYbRswvuCj kwm8OxtBBs+X0gyW0UmifA1rC2BIee7F4VsyD7R0EIXnotTELFZDBu/5Wp6ra7MDOIId QfuLiH0PjQUl0YGf+yMvbnJy4gMMf5u7Z7ogsOjczicKUQaC3FToahXNzDimOZCEt1wM ZfqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HcoAEA6t; 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 b14-20020a17090a488e00b0022e5e5a80e3si718143pjh.117.2023.02.07.18.45.37; Tue, 07 Feb 2023 18:45:50 -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=HcoAEA6t; 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 S229836AbjBHCoE (ORCPT <rfc822;kmanaouilinux@gmail.com> + 99 others); Tue, 7 Feb 2023 21:44:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229557AbjBHCoB (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 7 Feb 2023 21:44:01 -0500 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E29ED2138; Tue, 7 Feb 2023 18:44:00 -0800 (PST) Received: by mail-pl1-x62d.google.com with SMTP id h15so10396457plk.12; Tue, 07 Feb 2023 18:44:00 -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=La3OH/wxxUC+XGiTFrGm7IEcXqspoaqeInslaM1lK3o=; b=HcoAEA6t13WP2R5z5xB0i39ady4K0zU6k1HBKc6Dmim0YBCX2HkUXoIAWMAfq5F9Ug u5AhG+Cs6exh7j7jEl/Y3nNbsc9ZUBZTaXwjijYD1HNxbRSkiWYv+qYshRdbS+Fn+RAQ It6Gkapc18/oiepO/BZ2sF5RwvwaeHuWHm+q2v9UG3u/nFG6UIGHpmFr9RwHjD6ympPG YVyxh6ucWUj5OBbrPXHKt3kAMRAyshdidtpcBF8z7+HK9YcrVjBXkK7upIkvDqcenTv0 mVqcpBNaKF8wzGdE1+5A9CnjpsOvqy7WiYYPyXWKfXO1X3iOw8JaY8B7U7EHgc6Z7szK Pllw== 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=La3OH/wxxUC+XGiTFrGm7IEcXqspoaqeInslaM1lK3o=; b=zRfQNwM5d+Z3imZwgRBbOCDzD40ncMkEunOmZaW0GT64CLVHlwNsPtQrr/DK14lLiw dJqGoVW+5JWfl7tS2ln0Hg2bI0PxMpFe2Vpbm1MMtS0NY4anM1Hlixygo/Z+sxhYlCX1 lhy4EPSmmemEMbG1RMQE0k05VwZWjAbpTiQpCN9sUo6CzojQm2mLiuFnhkvooLyrDpRk Iv2rR8YxJo0JAzxnWo4ZMPvywnrNVzlkHoypsaiETY8qiQa+eMkaiuwmrL28/hwr+eSa tOE8cdYk9Uo6KcwBKMeo9qnjr6Ib792fud6Vw4UoA6IGRQCD8HWXGMeX+F6iYNzpQnzv o3kw== X-Gm-Message-State: AO0yUKXwrtwEIRxMUfEky/0MixJnvFMWKjihvrvbovltoT9l6bYRz2Pa KQrk9P9uuGlxBxPSN9Jyb7g= X-Received: by 2002:a05:6a20:7d95:b0:bc:5f20:140d with SMTP id v21-20020a056a207d9500b000bc5f20140dmr6731933pzj.30.1675824240304; Tue, 07 Feb 2023 18:44:00 -0800 (PST) Received: from KERNELXING-MB0.tencent.com ([103.7.29.31]) by smtp.gmail.com with ESMTPSA id jk3-20020a170903330300b001960735c652sm9660835plb.169.2023.02.07.18.43.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 18:43:59 -0800 (PST) From: Jason Xing <kerneljasonxing@gmail.com> 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 <kernelxing@tencent.com> Subject: [PATCH net v4 1/3] ixgbe: allow to increase MTU to 3K with XDP enabled Date: Wed, 8 Feb 2023 10:43:32 +0800 Message-Id: <20230208024333.10465-1-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756909127072107283?= X-GMAIL-MSGID: =?utf-8?q?1757229194752481719?= |
Series |
[net,v4,1/3] ixgbe: allow to increase MTU to 3K with XDP enabled
|
|
Commit Message
Jason Xing
Feb. 8, 2023, 2:43 a.m. UTC
From: Jason Xing <kernelxing@tencent.com> 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 <kernelxing@tencent.com> --- v4: 1) use ':' instead of '-' for kdoc 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(-)
Comments
On Wed, 2023-02-08 at 10:43 +0800, Jason Xing wrote: > From: Jason Xing <kernelxing@tencent.com> > > 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 <kernelxing@tencent.com> This is based on the broken premise that w/ XDP we are using a 4K page. The ixgbe driver isn't using page pool and is therefore running on different limitations. The ixgbe driver is only using 2K slices of the 4K page. In addition that is reduced to 1.5K to allow for headroom and the shared info in the buffer. Currently the only way a 3K buffer would work is if FCoE is enabled and in that case the driver is using order 1 pages and still using the split buffer approach. Changing the MTU to more than 1.5K will allow multi-buffer frames which would break things when you try to use XDP_REDIRECT or XDP_TX on frames over 1.5K in size. For things like XDP_PASS, XDP_DROP, and XDP_ABORT it should still work as long as you don't attempt to reach beyond the 1.5K boundary. Until this driver supports XDP multi-buffer I don't think you can increase the MTU past 1.5K. If you are wanting a larger MTU you should look at enabling XDP multi-buffer and then just drop the XDP limitations entirely. > --- > v4: > 1) use ':' instead of '-' for kdoc > > 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..25ca329f7d3c 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; > +} > + There is no difference in the buffer allocation approach for LEGACY vs non-legacy. The difference is if we are building the frame around the buffer using build_skb or we are adding it as a frag and then copying out the header. > /** > * 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; > } > } >
On Wed, Feb 08, 2023 at 07:37:57AM -0800, Alexander H Duyck wrote: > On Wed, 2023-02-08 at 10:43 +0800, Jason Xing wrote: > > From: Jason Xing <kernelxing@tencent.com> > > > > 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 <kernelxing@tencent.com> > > This is based on the broken premise that w/ XDP we are using a 4K page. > The ixgbe driver isn't using page pool and is therefore running on > different limitations. The ixgbe driver is only using 2K slices of the > 4K page. In addition that is reduced to 1.5K to allow for headroom and > the shared info in the buffer. > > Currently the only way a 3K buffer would work is if FCoE is enabled and > in that case the driver is using order 1 pages and still using the > split buffer approach. Hey Alex, interesting, we based this on the following logic from ixgbe_set_rx_buffer_len() I guess: #if (PAGE_SIZE < 8192) if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) set_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state); if (IXGBE_2K_TOO_SMALL_WITH_PADDING || (max_frame > (ETH_FRAME_LEN + ETH_FCS_LEN))) set_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state); #endif so we assumed that ixgbe is no different than i40e/ice in these terms, but we ignored whole overhead of LRO/RSC that ixgbe carries. I am not actively working with ixgbe but I know that you were the main dev of it, so without premature dive into the datasheet and codebase, are you really sure that 3k mtu for XDP is a no go? > > Changing the MTU to more than 1.5K will allow multi-buffer frames which > would break things when you try to use XDP_REDIRECT or XDP_TX on frames > over 1.5K in size. For things like XDP_PASS, XDP_DROP, and XDP_ABORT it > should still work as long as you don't attempt to reach beyond the 1.5K > boundary. > > Until this driver supports XDP multi-buffer I don't think you can > increase the MTU past 1.5K. If you are wanting a larger MTU you should > look at enabling XDP multi-buffer and then just drop the XDP > limitations entirely. > > > --- > > v4: > > 1) use ':' instead of '-' for kdoc > > > > 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..25ca329f7d3c 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; > > +} > > + > > There is no difference in the buffer allocation approach for LEGACY vs > non-legacy. The difference is if we are building the frame around the > buffer using build_skb or we are adding it as a frag and then copying > out the header. > > > /** > > * 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; > > } > > } > > >
On Wed, 2023-02-08 at 17:27 +0100, Maciej Fijalkowski wrote: > On Wed, Feb 08, 2023 at 07:37:57AM -0800, Alexander H Duyck wrote: > > On Wed, 2023-02-08 at 10:43 +0800, Jason Xing wrote: > > > From: Jason Xing <kernelxing@tencent.com> > > > > > > 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 <kernelxing@tencent.com> > > > > This is based on the broken premise that w/ XDP we are using a 4K page. > > The ixgbe driver isn't using page pool and is therefore running on > > different limitations. The ixgbe driver is only using 2K slices of the > > 4K page. In addition that is reduced to 1.5K to allow for headroom and > > the shared info in the buffer. > > > > Currently the only way a 3K buffer would work is if FCoE is enabled and > > in that case the driver is using order 1 pages and still using the > > split buffer approach. > > Hey Alex, interesting, we based this on the following logic from > ixgbe_set_rx_buffer_len() I guess: > > #if (PAGE_SIZE < 8192) > if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) > set_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state); > > if (IXGBE_2K_TOO_SMALL_WITH_PADDING || > (max_frame > (ETH_FRAME_LEN + ETH_FCS_LEN))) > set_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state); > #endif > > so we assumed that ixgbe is no different than i40e/ice in these terms, but > we ignored whole overhead of LRO/RSC that ixgbe carries. If XDP is already enabled the LRO/RSC cannot be enabled. I think that is already disabled if we have XDP enabled. > I am not actively working with ixgbe but I know that you were the main dev > of it, so without premature dive into the datasheet and codebase, are you > really sure that 3k mtu for XDP is a no go? I think I mixed up fm10k and ixgbe, either that or I was thinking of the legacy setup. They all kind of blur together as I had worked on pretty much all the Intel drivers up to i40e the last time I was updating them for all the Rx path stuff. :) So if I am reading things right the issue is that if XDP is enabled you cannot set a 3K MTU, but if you set the 3K MTU first then you can enable XDP after the fact right? Looking it over again after re-reading the code this looks good to me. Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>
On Wed, Feb 08, 2023 at 10:57:22AM -0800, Alexander H Duyck wrote: > On Wed, 2023-02-08 at 17:27 +0100, Maciej Fijalkowski wrote: > > On Wed, Feb 08, 2023 at 07:37:57AM -0800, Alexander H Duyck wrote: > > > On Wed, 2023-02-08 at 10:43 +0800, Jason Xing wrote: > > > > From: Jason Xing <kernelxing@tencent.com> > > > > > > > > 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 <kernelxing@tencent.com> > > > > > > This is based on the broken premise that w/ XDP we are using a 4K page. > > > The ixgbe driver isn't using page pool and is therefore running on > > > different limitations. The ixgbe driver is only using 2K slices of the > > > 4K page. In addition that is reduced to 1.5K to allow for headroom and > > > the shared info in the buffer. > > > > > > Currently the only way a 3K buffer would work is if FCoE is enabled and > > > in that case the driver is using order 1 pages and still using the > > > split buffer approach. > > > > Hey Alex, interesting, we based this on the following logic from > > ixgbe_set_rx_buffer_len() I guess: > > > > #if (PAGE_SIZE < 8192) > > if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) > > set_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state); > > > > if (IXGBE_2K_TOO_SMALL_WITH_PADDING || > > (max_frame > (ETH_FRAME_LEN + ETH_FCS_LEN))) > > set_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state); > > #endif > > > > so we assumed that ixgbe is no different than i40e/ice in these terms, but > > we ignored whole overhead of LRO/RSC that ixgbe carries. > > If XDP is already enabled the LRO/RSC cannot be enabled. I think that > is already disabled if we have XDP enabled. > > > I am not actively working with ixgbe but I know that you were the main dev > > of it, so without premature dive into the datasheet and codebase, are you > > really sure that 3k mtu for XDP is a no go? > > I think I mixed up fm10k and ixgbe, either that or I was thinking of > the legacy setup. They all kind of blur together as I had worked on > pretty much all the Intel drivers up to i40e the last time I was > updating them for all the Rx path stuff. :) > > So if I am reading things right the issue is that if XDP is enabled you > cannot set a 3K MTU, but if you set the 3K MTU first then you can > enable XDP after the fact right? Yes and vice versa - when XDP is on then you should be able to work with 3k mtus. > > Looking it over again after re-reading the code this looks good to me. > > Reviewed-by: Alexander Duyck <alexanderduyck@fb.com> Awesome :) > > > > >
>-----Original Message----- >From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of >Jason Xing >Sent: 08 February 2023 08:14 >To: Brandeburg, Jesse <jesse.brandeburg@intel.com>; Nguyen, Anthony L ><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; Lobakin, Alexandr ><alexandr.lobakin@intel.com>; Fijalkowski, Maciej ><maciej.fijalkowski@intel.com> >Cc: kerneljasonxing@gmail.com; netdev@vger.kernel.org; linux- >kernel@vger.kernel.org; intel-wired-lan@lists.osuosl.org; >bpf@vger.kernel.org; Jason Xing <kernelxing@tencent.com> >Subject: [Intel-wired-lan] [PATCH net v4 1/3] ixgbe: allow to increase MTU to >3K with XDP enabled > >From: Jason Xing <kernelxing@tencent.com> > >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 <kernelxing@tencent.com> >--- >v4: >1) use ':' instead of '-' for kdoc > >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(-) > Tested-by: Chandan Kumar Rout <chandanx.rout@intel.com> (A Contingent Worker at Intel)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index ab8370c413f3..25ca329f7d3c 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; } }