From patchwork Thu Sep 30 14:06:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 12528481 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 031F9C433EF for ; Thu, 30 Sep 2021 14:07:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DE3466142A for ; Thu, 30 Sep 2021 14:07:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351778AbhI3OJG (ORCPT ); Thu, 30 Sep 2021 10:09:06 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:50390 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351669AbhI3OJF (ORCPT ); Thu, 30 Sep 2021 10:09:05 -0400 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1633010842; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=IyrJmCu4eyZQOsViNW5NAFasbLvR7GyoPKIT5sQFDmc=; b=G4iMSzg1dC4/NYjfjfq6v9nSYh3KMTMxB1ItgZAGBVk7bVCx2nHxNdlBDa7gSL+VUc9FHY x177GYvSXVLXjoa4RZ3LYblskOqhaiMzBLoHfNqzjJ5ove0n0bbRYX9XefNWO5YbYU61tW yOxvQD873WOO67GKOeYrRJ1z86qFWuRNl/hE+ro7poo6+w/K2aWdbrNHoIE3Cxcurk4U3x ioxeswCvxmcFQC9aP10bjEL2LNSB8/5U4pWy99+qNAr065qNBg3943I+5OkjjuPPHU9CVb /IqSSaARF3sAXJdRjSEObelX0tDHPwXUXk+I5C1voHeWjr8r3apUodFXS/gVXA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1633010842; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=IyrJmCu4eyZQOsViNW5NAFasbLvR7GyoPKIT5sQFDmc=; b=UYqWDFCFbK5h07G8dyDHF4UJEMOC531yauPYAliwBIDZa0GOrD279WBo0Vucg1mguFQAbK V8jz11H9kuZHpeBg== To: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org Cc: Jesse Brandeburg , Tony Nguyen , "David S . Miller" , Jakub Kicinski , Kurt Kanzenbach , Thomas Gleixner , Sebastian Andrzej Siewior Subject: [PATCH net-next v2] ixgbe: Consider xsk pool's frame size for MTU size Date: Thu, 30 Sep 2021 16:06:51 +0200 Message-Id: <20210930140651.2249972-1-bigeasy@linutronix.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The driver has to a ensure that a network packet is not using more than one page for its data if a XDP program is used. This results in an upper limit of 1500 bytes. This can be increased a little if the MTU was programmed to 1514..3072 bytes before loading the XDP program. By setting this increased MTU size the driver will set the __IXGBE_RX_3K_BUFFER flag which in turn will allow to use 3KiB as the upper limit. This looks like a hack and the upper limit is could increased further. If the user configured a memory pool then PAGE_SIZE is used as BSIZEPKT and RLPML is set to pool's memory size as is the card's maximum frame size. The result is that a MTU of 3520 bytes can be programmed and every packet is stored a single page. If a RX ring has a pool assigned use its size while comparing for the maximal MTU size. Signed-off-by: Sebastian Andrzej Siewior --- v1…v2: Remove RFC. Repost of https://lore.kernel.org/r/20210622162616.eadk2u5hmf4ru5jd@linutronix.de drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 24e06ba6f5e93..ed451f32e1980 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -6722,6 +6722,23 @@ static void ixgbe_free_all_rx_resources(struct ixgbe_adapter *adapter) ixgbe_free_rx_resources(adapter->rx_ring[i]); } +static int ixgbe_validate_frame_size(unsigned int frame_size, + struct ixgbe_ring *ring) +{ + struct xsk_buff_pool *xsk_pool; + unsigned int buf_len; + + xsk_pool = ring->xsk_pool; + if (xsk_pool) + buf_len = xsk_pool_get_rx_frame_size(xsk_pool); + else + buf_len = ixgbe_rx_bufsz(ring); + + if (frame_size > buf_len) + return -EINVAL; + return 0; +} + /** * ixgbe_change_mtu - Change the Maximum Transfer Unit * @netdev: network interface device structure @@ -6741,7 +6758,7 @@ static int ixgbe_change_mtu(struct net_device *netdev, int new_mtu) 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)) { + if (ixgbe_validate_frame_size(new_frame_size, ring)) { e_warn(probe, "Requested MTU size is not supported with XDP\n"); return -EINVAL; } @@ -10126,7 +10143,7 @@ static int ixgbe_xdp_setup(struct net_device *dev, struct bpf_prog *prog) if (ring_is_rsc_enabled(ring)) return -EINVAL; - if (frame_size > ixgbe_rx_bufsz(ring)) + if (ixgbe_validate_frame_size(frame_size, ring)) return -EINVAL; }