From patchwork Sat Dec 10 13:53:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 13070330 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 846FAC4332F for ; Sat, 10 Dec 2022 13:53:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229824AbiLJNxq (ORCPT ); Sat, 10 Dec 2022 08:53:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229634AbiLJNxo (ORCPT ); Sat, 10 Dec 2022 08:53:44 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B5CA13EA3 for ; Sat, 10 Dec 2022 05:53:43 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DE4F560C01 for ; Sat, 10 Dec 2022 13:53:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB82EC433D2; Sat, 10 Dec 2022 13:53:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670680422; bh=mpdGakfRPcbqDUyFyzefmi7AzdYG54Xi4qvjir3KvgM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B5uPlrVIAoDGSBjwmrVcKPph2cqx/Pbj4+Umz37WpD3os9gp6LOzMfVY1d+R5vz27 TFTY59bOEfAobkLI6UyagGW7QPUze7JK8cjIqyGC2MRnht/dr31j46MN+c0iFdUHtT Kwcyq1FJrBLdLicqG51krYNlc6oO6I8PEfXhrfwWf091wjvOoYQFYj6BfxNeO52AHL fj9/aAYW+uqJ4EwDp7XflrD9Earq09ngkdZMBixRUrkAzTCj3/X9Vqf9yzEfpS/uM4 4XMYWp/CUadL4qCWPT1GCcZPDwzf8WQ6hqHySHCLgxpTDmZekk/Wu3/9q6wqFtNOY1 qMZ9ppXiudYJQ== From: Lorenzo Bianconi To: netdev@vger.kernel.org Cc: claudiu.manoil@nxp.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, vladimir.oltean@nxp.com, lorenzo.bianconi@redhat.com Subject: [PATCH v3 net-next 1/2] net: ethernet: enetc: unlock XDP_REDIRECT for XDP non-linear buffers Date: Sat, 10 Dec 2022 14:53:10 +0100 Message-Id: <18fe33e35b49d4b265d75489331f5c817489a26e.1670680119.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Even if full XDP_REDIRECT is not supported yet for non-linear XDP buffers since we allow redirecting just into CPUMAPs, unlock XDP_REDIRECT for S/G XDP buffer and rely on XDP stack to properly take care of the frames. Signed-off-by: Lorenzo Bianconi --- drivers/net/ethernet/freescale/enetc/enetc.c | 25 ++++++++------------ 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index 8671591cb750..cd8f5f0c6b54 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -1412,6 +1412,16 @@ static void enetc_add_rx_buff_to_xdp(struct enetc_bdr *rx_ring, int i, /* To be used for XDP_TX */ rx_swbd->len = size; + if (!xdp_buff_has_frags(xdp_buff)) { + xdp_buff_set_frags_flag(xdp_buff); + shinfo->xdp_frags_size = size; + } else { + shinfo->xdp_frags_size += size; + } + + if (page_is_pfmemalloc(rx_swbd->page)) + xdp_buff_set_frag_pfmemalloc(xdp_buff); + skb_frag_off_set(frag, rx_swbd->page_offset); skb_frag_size_set(frag, size); __skb_frag_set_page(frag, rx_swbd->page); @@ -1601,22 +1611,7 @@ static int enetc_clean_rx_ring_xdp(struct enetc_bdr *rx_ring, } break; case XDP_REDIRECT: - /* xdp_return_frame does not support S/G in the sense - * that it leaks the fragments (__xdp_return should not - * call page_frag_free only for the initial buffer). - * Until XDP_REDIRECT gains support for S/G let's keep - * the code structure in place, but dead. We drop the - * S/G frames ourselves to avoid memory leaks which - * would otherwise leave the kernel OOM. - */ - if (unlikely(cleaned_cnt - orig_cleaned_cnt != 1)) { - enetc_xdp_drop(rx_ring, orig_i, i); - rx_ring->stats.xdp_redirect_sg++; - break; - } - tmp_orig_i = orig_i; - while (orig_i != i) { enetc_flip_rx_buff(rx_ring, &rx_ring->rx_swbd[orig_i]); From patchwork Sat Dec 10 13:53:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 13070331 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF13CC4332F for ; Sat, 10 Dec 2022 13:53:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229830AbiLJNxu (ORCPT ); Sat, 10 Dec 2022 08:53:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229763AbiLJNxs (ORCPT ); Sat, 10 Dec 2022 08:53:48 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37DEE1706D for ; Sat, 10 Dec 2022 05:53:47 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CB24C60C01 for ; Sat, 10 Dec 2022 13:53:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB7FAC433EF; Sat, 10 Dec 2022 13:53:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670680426; bh=W9cc5B3lyI30sbvRELtApFZRccn3R4UlyQ2m+7kWX60=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QxifPqGII28Yq8NpCXfjs60G5H6JoB8AJPEmEjiitbLF3fBhYZPCeXGeuw++jaE8e JXTS/2HMAUM+eRqk2b2RRoa/KLzc9u5QdmWPio5jtUC6kvCEYi5+Z58PTo2ukrYdzO PWZP8AWGiSe5gm0LDo72Wux5fA7O+X8vNcrT8Y4tdoR9IHjPKS0mGlN1GXKeSSNquM fU8sYTOkmGu/YNNg50YWA+bAOjC/OjMp8NYcwODGPKAEWwVScWaJypdSsDkQbK5bs6 7kGwIxK02XV3zk9ixmF212xhhhRohEaq1Ipl4ONStmmR+2ZDPNQ6jwC6uzvsS6KBtZ gywv2nD1NmXFw== From: Lorenzo Bianconi To: netdev@vger.kernel.org Cc: claudiu.manoil@nxp.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, vladimir.oltean@nxp.com, lorenzo.bianconi@redhat.com Subject: [PATCH v3 net-next 2/2] net: ethernet: enetc: get rid of xdp_redirect_sg counter Date: Sat, 10 Dec 2022 14:53:11 +0100 Message-Id: <813922f4a7e343197b4e4018fb7c5992bd45ea30.1670680119.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Remove xdp_redirect_sg counter and the related ethtool entry since it is no longer used. Signed-off-by: Lorenzo Bianconi --- drivers/net/ethernet/freescale/enetc/enetc.h | 1 - drivers/net/ethernet/freescale/enetc/enetc_ethtool.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index c6d8cc15c270..416e4138dbaf 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -70,7 +70,6 @@ struct enetc_ring_stats { unsigned int xdp_tx_drops; unsigned int xdp_redirect; unsigned int xdp_redirect_failures; - unsigned int xdp_redirect_sg; unsigned int recycles; unsigned int recycle_failures; unsigned int win_drop; diff --git a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c index c8369e3752b0..d45f305eb03c 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c @@ -197,7 +197,6 @@ static const char rx_ring_stats[][ETH_GSTRING_LEN] = { "Rx ring %2d recycle failures", "Rx ring %2d redirects", "Rx ring %2d redirect failures", - "Rx ring %2d redirect S/G", }; static const char tx_ring_stats[][ETH_GSTRING_LEN] = { @@ -291,7 +290,6 @@ static void enetc_get_ethtool_stats(struct net_device *ndev, data[o++] = priv->rx_ring[i]->stats.recycle_failures; data[o++] = priv->rx_ring[i]->stats.xdp_redirect; data[o++] = priv->rx_ring[i]->stats.xdp_redirect_failures; - data[o++] = priv->rx_ring[i]->stats.xdp_redirect_sg; } if (!enetc_si_is_pf(priv->si))