From nobody Thu Sep 18 02:48:47 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3AC5C4332F for ; Tue, 13 Dec 2022 11:05:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235353AbiLMLFR (ORCPT ); Tue, 13 Dec 2022 06:05:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229576AbiLMLEY (ORCPT ); Tue, 13 Dec 2022 06:04:24 -0500 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C420E10C5; Tue, 13 Dec 2022 03:04:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1670929463; x=1702465463; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tQWynMwI6beWgXu1++OI8/HcznIn+RkDmF5yOjh7mMw=; b=LFHpmRUCAAciOhXHarEHBH9Xn9PQTHdl9h1EBwSXrkZZI2jzcDc7RwZN 7Y/J4Xyhy5MFsKOyz4pdiXNUBXIiWvBY7aD6UogaGztEnOtWFTrbKkMGE fl/kckpAOHtsKQultjo8ixpWxwhFqnY5byBB+9iQaTWgggJlb6LV6nLG5 532jZv/wFjvaYa+/M8Mvn3YRgeJAMv3ztwtHoWAh2JY3m/Isu/gj/9k2p pKJbOoAX8vmkr+Zs7uZD/qJ2YeiLPqw44VVBERHsnxLJq6BzTNyIp334z EIDwo6hchPYaYFO9GnNDGe+6PGoNO6CDDBvLc8b7wsz7AUtyneFE4JfxL Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10559"; a="305744404" X-IronPort-AV: E=Sophos;i="5.96,241,1665471600"; d="scan'208";a="305744404" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Dec 2022 03:04:23 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10559"; a="679263050" X-IronPort-AV: E=Sophos;i="5.96,241,1665471600"; d="scan'208";a="679263050" Received: from unknown (HELO paamrpdk12-S2600BPB.aw.intel.com) ([10.228.151.145]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Dec 2022 03:04:21 -0800 From: Tirthendu Sarkar To: tirtha@gmail.com, jesse.brandeburg@intel.com, anthony.l.nguyen@intel.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, magnus.karlsson@intel.com, maciej.fijalkowski@intel.com Subject: [PATCH intel-next 4/5] i40e: pull out rx buffer allocation to end of i40e_clean_rx_irq() Date: Tue, 13 Dec 2022 16:20:22 +0530 Message-Id: <20221213105023.196409-5-tirthendu.sarkar@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213105023.196409-1-tirthendu.sarkar@intel.com> References: <20221213105023.196409-1-tirthendu.sarkar@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Previously i40e_alloc_rx_buffers() was called for every 32 cleaned buffers. For multi-buffers this may not be optimal as there may be more cleaned buffers in each i40e_clean_rx_irq() call. So this is now pulled out of the loop and moved to the end of i40e_clean_rx_irq(). As a consequence instead of counting the number of buffers to be cleaned, I40E_DESC_UNUSED() can be used to call i40e_alloc_rx_buffers(). Signed-off-by: Tirthendu Sarkar --- drivers/net/ethernet/intel/i40e/i40e_txrx.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethe= rnet/intel/i40e/i40e_txrx.c index e01bcc91a196..dc9dc0acdd37 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c +++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c @@ -2425,7 +2425,6 @@ static int i40e_clean_rx_irq(struct i40e_ring *rx_rin= g, int budget, unsigned int *rx_cleaned) { unsigned int total_rx_bytes =3D 0, total_rx_packets =3D 0, frame_sz =3D 0; - u16 cleaned_count =3D I40E_DESC_UNUSED(rx_ring); unsigned int offset =3D rx_ring->rx_offset; struct sk_buff *skb =3D rx_ring->skb; u16 ntp =3D rx_ring->next_to_process; @@ -2450,13 +2449,6 @@ static int i40e_clean_rx_irq(struct i40e_ring *rx_ri= ng, int budget, unsigned int size; u64 qword; =20 - /* return some buffers to hardware, one at a time is too slow */ - if (cleaned_count >=3D I40E_RX_BUFFER_WRITE) { - failure =3D failure || - i40e_alloc_rx_buffers(rx_ring, cleaned_count); - cleaned_count =3D 0; - } - rx_desc =3D I40E_RX_DESC(rx_ring, ntp); =20 /* status_error_len will always be zero for unused descriptors @@ -2479,7 +2471,6 @@ static int i40e_clean_rx_irq(struct i40e_ring *rx_rin= g, int budget, rx_buffer =3D i40e_rx_bi(rx_ring, ntp); I40E_INC_NEXT(ntp, ntc, rmax); i40e_reuse_rx_page(rx_ring, rx_buffer); - cleaned_count++; continue; } =20 @@ -2531,7 +2522,6 @@ static int i40e_clean_rx_irq(struct i40e_ring *rx_rin= g, int budget, } =20 i40e_put_rx_buffer(rx_ring, rx_buffer); - cleaned_count++; =20 I40E_INC_NEXT(ntp, ntc, rmax); if (i40e_is_non_eop(rx_ring, rx_desc)) @@ -2558,6 +2548,8 @@ static int i40e_clean_rx_irq(struct i40e_ring *rx_rin= g, int budget, rx_ring->next_to_process =3D ntp; rx_ring->next_to_clean =3D ntc; =20 + failure =3D i40e_alloc_rx_buffers(rx_ring, I40E_DESC_UNUSED(rx_ring)); + i40e_finalize_xdp_rx(rx_ring, xdp_xmit); rx_ring->skb =3D skb; =20 --=20 2.34.1