From patchwork Mon Apr 12 15:41:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ong Boon Leong X-Patchwork-Id: 12198361 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 875E0C433B4 for ; Mon, 12 Apr 2021 15:39:50 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 280AB6124C for ; Mon, 12 Apr 2021 15:39:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 280AB6124C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=d5d5rgJ4LM+ulD7GUhsheEYJtijOwQ9MXVux+bLl7VA=; b=WT1Jzk9euSGx5ieS0Uot4EkyB os6y74NKeIrXsNHjzqAiFb4j/GovHr8hwqWTDkYy2gnX6gTGM6pqyT3nUYd/2b7Xh7372nn0pPz4q a/L37qItY0Jb4nIqtTyW778B/HDemg6EIkUWJZfZWTRMeENLR2vbtvkUhZP5c7rjKJ+F8yiH+x95k J/VqgApe0MuWjq2HOLkI1BYR4zx6crU82lhWGZE7c9Et4I++pPzlPrWy1xG2qHf3zNE5jwF6xNoMy Th28bAv1JGyFbiLvqoO+o/YrpQl43N61Z7wsA1HNV8Y+8qOUSpGyYE24ImONU/cvZL19GiavI7wt6 uRhCl2Mug==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lVydW-0077TE-Bn; Mon, 12 Apr 2021 15:38:02 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lVycx-0077Nl-Sb for linux-arm-kernel@desiato.infradead.org; Mon, 12 Apr 2021 15:37:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=XQ7CvwByubJccqd4IV+Dr/4SUTcO2lLLiuJFrCOHTIs=; b=dnWjaTgNgJkCrXHJhbpQNHtkwy mRhuc6416NBUabPQDF9yGjsvlRFz3eVygcsUgV3mhRS4c2nefKfXv971PSO8AgWmjIS/0p6ULh8BZ LpxS4+dZmt53XIBW5YqiuBfyqcBpbKO1b8v1IBQc240U/9qvKzt+xDAlisXuOM1ItR3fSp5lqUuCQ SmLNivKnkA0Xz1cUDW8gQX746lJPbWMI6FRkopaiW6z0IHiYWXiInxUBFw7i7FJm8JFVQKCn7iIcl KzFT+HjePLS+I5Ei3686zWTRVsAeWZehK0rM4l9AQmItgEifcVJmJGwPIXd6tRsTcRIoSZg7YLzU8 LeBgzdcA==; Received: from mga07.intel.com ([134.134.136.100]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lVycs-006LmE-Rx for linux-arm-kernel@lists.infradead.org; Mon, 12 Apr 2021 15:37:26 +0000 IronPort-SDR: B/L4lorkU86ggdngIKuXswOHsEfuHW6+xkisiU4cuyHo1q1uKKFBGVFwjhJX4eCg6VAm7Sgkw6 OPVv7RfwiHkw== X-IronPort-AV: E=McAfee;i="6200,9189,9952"; a="258195900" X-IronPort-AV: E=Sophos;i="5.82,216,1613462400"; d="scan'208";a="258195900" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2021 08:37:22 -0700 IronPort-SDR: rU/QyxVH7CHZoRRJbWZmdzItTKVYNwJYF7MWf8wpED05IDgbda7spPyxXfCi3RBrhR9xWdKIAV YWqk+WeCgRSg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,216,1613462400"; d="scan'208";a="614609549" Received: from glass.png.intel.com ([10.158.65.59]) by fmsmga005.fm.intel.com with ESMTP; 12 Apr 2021 08:37:18 -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: 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 2/7] net: stmmac: introduce dma_recycle_rx_skbufs for stmmac_reinit_rx_buffers Date: Mon, 12 Apr 2021 23:41:25 +0800 Message-Id: <20210412154130.20742-3-boon.leong.ong@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210412154130.20742-1-boon.leong.ong@intel.com> References: <20210412154130.20742-1-boon.leong.ong@intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210412_083722_960894_2A7195F7 X-CRM114-Status: GOOD ( 12.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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];