From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA766299A8E; Tue, 29 Apr 2025 23:52:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745970723; cv=none; b=hJN5jXdqqBnWlk50cOh5fkhZXiRBoAIAuTy+Rp9hjW0T8XCukQdeHcGaJutaWauBoS1dDwzbGOMImk4KRUoez8T7rOFh4IQK74CG6ZaVd7mvdf0N7DrxYpWaOi425KWWqwRM9CZ49rSoYuuGX9/loQA7AZncSEiNG9HhqgojGq0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745970723; c=relaxed/simple; bh=xmeNq9buQRAwM6xGb2/qRztME82rUq9GOeiuMrabL5s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=e/9XGlAHOG2avrCeWr12I+J9pN2hrtScBVkpzcKORbLT6wayqhfPzrg+M2YzvRVu4PNgkSH2nb2mYz8F9XkgMkdr0PjEAtz8sBEncgspRGN6mRCSBvbHc0auL+GQ9xmeIqgGMyaFSWFFXMYhVs73H+CRjHyTVi1bO3Fc1Wq6wiA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CmdEduwB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CmdEduwB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 051B2C4CEED; Tue, 29 Apr 2025 23:52:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745970723; bh=xmeNq9buQRAwM6xGb2/qRztME82rUq9GOeiuMrabL5s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CmdEduwBzNDf+D4TuIa3pZ+hx4eCGXhMvXq5wh9QYMMz2N8q7y11Us9lrsrpJzBwn 1HErSqI47G6Sr9NZOy0crDXdrWf4Qgx0QOyXn38N4BCp5HiUHj/CyY0/YEJ7aJcd0d qieUjz8DmMcw4cvy8EJFcabKPeKfW/fiErLSEf2qWgWNKF8NTXpcO0ljZMDnCkOWcT yx5eAwNSpQNRibLiW3dgPVfn5Z+5Dgc9jQy8FNrkw57U4s1iU7HuSVpKQasL7dWjW4 UogrJxWVdEh4RXkk8PeLiteaNABHB8Qk5gWOU4rwF3+7Hmwj3P2+B/nH8zxHIRCSxR WSIuGgxrd6NbA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Vladimir Oltean , Wei Fang , Jakub Kicinski , Sasha Levin , claudiu.manoil@nxp.com, xiaoning.wang@nxp.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, imx@lists.linux.dev, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 6.12 22/37] net: enetc: refactor bulk flipping of RX buffers to separate function Date: Tue, 29 Apr 2025 19:51:07 -0400 Message-Id: <20250429235122.537321-22-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250429235122.537321-1-sashal@kernel.org> References: <20250429235122.537321-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.12.25 Content-Transfer-Encoding: 8bit From: Vladimir Oltean [ Upstream commit 1d587faa5be7e9785b682cc5f58ba8f4100c13ea ] This small snippet of code ensures that we do something with the array of RX software buffer descriptor elements after passing the skb to the stack. In this case, we see if the other half of the page is reusable, and if so, we "turn around" the buffers, making them directly usable by enetc_refill_rx_ring() without going to enetc_new_page(). We will need to perform this kind of buffer flipping from a new code path, i.e. from XDP_PASS. Currently, enetc_build_skb() does it there buffer by buffer, but in a subsequent change we will stop using enetc_build_skb() for XDP_PASS. Signed-off-by: Vladimir Oltean Reviewed-by: Wei Fang Link: https://patch.msgid.link/20250417120005.3288549-3-vladimir.oltean@nxp.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/ethernet/freescale/enetc/enetc.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index f662a5d54986c..d8272b7a55fcb 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -1572,6 +1572,16 @@ static void enetc_xdp_drop(struct enetc_bdr *rx_ring, int rx_ring_first, } } +static void enetc_bulk_flip_buff(struct enetc_bdr *rx_ring, int rx_ring_first, + int rx_ring_last) +{ + while (rx_ring_first != rx_ring_last) { + enetc_flip_rx_buff(rx_ring, + &rx_ring->rx_swbd[rx_ring_first]); + enetc_bdr_idx_inc(rx_ring, &rx_ring_first); + } +} + static int enetc_clean_rx_ring_xdp(struct enetc_bdr *rx_ring, struct napi_struct *napi, int work_limit, struct bpf_prog *prog) @@ -1687,11 +1697,7 @@ static int enetc_clean_rx_ring_xdp(struct enetc_bdr *rx_ring, enetc_xdp_drop(rx_ring, orig_i, i); rx_ring->stats.xdp_redirect_failures++; } else { - while (orig_i != i) { - enetc_flip_rx_buff(rx_ring, - &rx_ring->rx_swbd[orig_i]); - enetc_bdr_idx_inc(rx_ring, &orig_i); - } + enetc_bulk_flip_buff(rx_ring, orig_i, i); xdp_redirect_frm_cnt++; rx_ring->stats.xdp_redirect++; } -- 2.39.5