Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2476374pxb; Tue, 13 Apr 2021 02:54:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzME1Z0x7v9W5AwGyFakyaA/yiUow7BFuGse0gWLaDgXeK0XYI8RvxREBi/qAe2lIybtzxr X-Received: by 2002:a17:90a:b10a:: with SMTP id z10mr3919844pjq.161.1618307691089; Tue, 13 Apr 2021 02:54:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618307691; cv=none; d=google.com; s=arc-20160816; b=xxV9z4yeqpOcuA5tGk+SwrvM/LByrx4OxhycbEPpTIYp02yeeaPoD0oiB0gbgBBFVy tvq0o5LbR8504r99ad+hVlwI5jqAO4QJkSAEoREPFTV58PURsACtAVzc+3QRFXiMa5Sp NMxtshRlejyK+OfK6X6NfXMMo393lchP7HJukvK0zrS0/1yhc7lQZ4aqMYQr+d2iK6np jYZkmWSg8RbS7mSnii1hxURICe+DW5jeMV+QjkcjaWSWmc9/gIr7Qd2GtsLVFmMbZ5CE s6CR46/11afXwUMI5FZLqh9bKcmK8pIIH4LoL74dHeUJSuwhYQSGUuJkaoCbxQ6aaIiR ZqMg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=XQ7CvwByubJccqd4IV+Dr/4SUTcO2lLLiuJFrCOHTIs=; b=pBx57Id2eZ+eFl0ql/Md88U7qQ63CURlCFjdnXnERjFWnjpQPDL+waC8Gg8H62C3sJ +t76fIQaQ99pk3yUKF3Fw5erlIwQLHxU2tPJamWmjGeH6AA0B6L39+B+oDMU7BXWd7ns ws7FJzSL4j+mhPT5mi7+0wtBmILQ0/ymJSGIKrH2V+eLL3IQ5bJJz9yui/8SW6LEMj6j FYEjx4VWHKgDNsoakMTYIgn5+jVd0y0NdhykD7BZTROiBt/jE2E9o60eM0rTKk8dkoue zvFT7oB++suazdUpHnOciyEj/HuqFHy5IdLd/zW5gc/Cra9pv0RtfmuIJDkbvvUY76RY CxGw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d4si3124252pjs.1.2021.04.13.02.54.39; Tue, 13 Apr 2021 02:54:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238432AbhDMJc5 (ORCPT + 99 others); Tue, 13 Apr 2021 05:32:57 -0400 Received: from mga04.intel.com ([192.55.52.120]:20457 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230251AbhDMJco (ORCPT ); Tue, 13 Apr 2021 05:32:44 -0400 IronPort-SDR: pEKVL+JUTPNUdSXufZXjIDJPdeKa8LnOEMGt4sxW5YDe9H/sujs4BDrRz3vCtvd58gBGIo2aqk GzsWmaC1Osmw== X-IronPort-AV: E=McAfee;i="6200,9189,9952"; a="192247350" X-IronPort-AV: E=Sophos;i="5.82,219,1613462400"; d="scan'208";a="192247350" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2021 02:32:24 -0700 IronPort-SDR: rKmz5953TVTjrac7+HQsxRg+QzizWZAvu7ZVaUyWJXiddu2k4mczWcqTf76K84pDmNgbsz+LZj asyQzj5l+NJQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,219,1613462400"; d="scan'208";a="424178125" Received: from glass.png.intel.com ([10.158.65.59]) by orsmga008.jf.intel.com with ESMTP; 13 Apr 2021 02:32:19 -0700 From: Ong Boon Leong To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S . Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend Cc: alexandre.torgue@foss.st.com, Maxime Coquelin , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, Ong Boon Leong Subject: [PATCH net-next v2 2/7] net: stmmac: introduce dma_recycle_rx_skbufs for stmmac_reinit_rx_buffers Date: Tue, 13 Apr 2021 17:36:21 +0800 Message-Id: <20210413093626.3447-3-boon.leong.ong@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210413093626.3447-1-boon.leong.ong@intel.com> References: <20210413093626.3447-1-boon.leong.ong@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Rearrange RX buffer page_pool recycling logics into dma_recycle_rx_skbufs, so that we prepare stmmac_reinit_rx_buffers() for XSK pool expansion. Signed-off-by: Ong Boon Leong --- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 44 ++++++++++++------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index f6d3d26ce45a..a6c3414fd231 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1512,6 +1512,31 @@ static int stmmac_alloc_rx_buffers(struct stmmac_priv *priv, u32 queue, return 0; } +/** + * dma_recycle_rx_skbufs - recycle RX dma buffers + * @priv: private structure + * @queue: RX queue index + */ +static void dma_recycle_rx_skbufs(struct stmmac_priv *priv, u32 queue) +{ + struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; + int i; + + for (i = 0; i < priv->dma_rx_size; i++) { + struct stmmac_rx_buffer *buf = &rx_q->buf_pool[i]; + + if (buf->page) { + page_pool_recycle_direct(rx_q->page_pool, buf->page); + buf->page = NULL; + } + + if (priv->sph && buf->sec_page) { + page_pool_recycle_direct(rx_q->page_pool, buf->sec_page); + buf->sec_page = NULL; + } + } +} + /** * stmmac_reinit_rx_buffers - reinit the RX descriptor buffer. * @priv: driver private structure @@ -1524,23 +1549,8 @@ static void stmmac_reinit_rx_buffers(struct stmmac_priv *priv) u32 queue; int i; - for (queue = 0; queue < rx_count; queue++) { - struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; - - for (i = 0; i < priv->dma_rx_size; i++) { - struct stmmac_rx_buffer *buf = &rx_q->buf_pool[i]; - - if (buf->page) { - page_pool_recycle_direct(rx_q->page_pool, buf->page); - buf->page = NULL; - } - - if (priv->sph && buf->sec_page) { - page_pool_recycle_direct(rx_q->page_pool, buf->sec_page); - buf->sec_page = NULL; - } - } - } + for (queue = 0; queue < rx_count; queue++) + dma_recycle_rx_skbufs(priv, queue); for (queue = 0; queue < rx_count; queue++) { struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; -- 2.25.1