From patchwork Tue Jul 30 02:26:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mina Almasry X-Patchwork-Id: 13746355 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2061E41E22 for ; Tue, 30 Jul 2024 02:26:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722306403; cv=none; b=cwhfEAcy4KayKh4KgN1wydSfWI0GjVfxFP/aau/6D6EWoLabB+2s6bGl5FxFmkLd5wLyxw018QCLqzY4r2eWP3dBKt/VdK69+io1GNjSkBPmnPFkWsp1IZTOtcoE+t0TNEoEETHPUNTlXu7+wrduWvjAmyumTksqKHN7qYBTMCI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722306403; c=relaxed/simple; bh=EujhD2n1Ke7lPZKkibOLBAZurseJRlXkSsBCc47I7oE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=nZHJJRIrE1X6xFY2VzGVg5gGQ5l9KelPw+Eh+oZ33cu8eSk4Fh5/U4TpkL1BVFRhTnA6lc1nNABU/NwGaEcz1Eynbx92MHfenu+Z2+OqPgWl++jgsgoHQFBeMLijcO3Aqhz8PRHeETNFAdoZdapkF9pKoaAD/aSk5Kgz0vWqbgo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--almasrymina.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=PMiBfkyB; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--almasrymina.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="PMiBfkyB" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-664aa55c690so74754877b3.2 for ; Mon, 29 Jul 2024 19:26:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1722306399; x=1722911199; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=qpjJDC2/7eGvs2TUXo8T6/AXlUgH8srqN9C/rVg09l8=; b=PMiBfkyBoM++DGBz1g4NuSQnzPasJvL6kbjQziLAoPgtfrChbOkv2KnLHBoA9X2o1K h69ROOhwNEiBrsJWA3ATMuYT/e/Tu7BhTJihT5Cn8U/ZZTNjQ1mGwK40YzVZ9FCfI5vt l7IaEpnL+sJ0QElLc0gEH3++hSFLGj4NhdvTNpoIRTJ4nWdITQV93jybGCoMI2GTQmvG 6Cm3+aIApcPGLnH47QtitQP/w78Di0s1Ufsgss+mj+74dIpgoWap79E3/kpB55ItB+Q5 HAilTjS/4inOrx8WDBKdLAEuaaaDZN5fCmV3QxA2NoM/56A9qWcphMcLMJuy2xtj416d Cpkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722306399; x=1722911199; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qpjJDC2/7eGvs2TUXo8T6/AXlUgH8srqN9C/rVg09l8=; b=G3l6UCZyzU2y6Uvd9rJoLAu64Eosp+OR/ZD52y5nd2Aocvr7Ms2wN3LmYtRHlKDXlx 3GzUrw6rDgxiXYPy0FbLUSs89FJASGiNjLSeQRUli44i3uvIOAkFgAGZYJ3/hQpary1Z v6tfsxgdbIZW0sYeXqPplDWiNLb/3kbGuv29VzTCXxQnyuT2xMQOwrcBBA4JnEAfd+uv Zp4fmwq18pQ94XXNWHERS6v3wJT89ZdCPnkz4hbCdbq/r7EUNbZzxWvg8BrENCkl0b+X aavKNhK6IQkffbSqU1HPimgNpICX/46TZ2KB5Za3vMZZFRDOBXu2oHE4QiqPqSvO0OSV mn4Q== X-Forwarded-Encrypted: i=1; AJvYcCVExBa6CzzyIB/MgLvP1CMch3x0STnWGGcZnLoxkdsmd9TfNXSTur8O/YccYIOGrT3UPK4TVaaG0O8r8h5UifNxRaBx X-Gm-Message-State: AOJu0YyHR3k6xiwW28ksWDmn2oY+sGQhCNwFGloUVqFFVaiaCzONCP/R 4r1JPM0awXNlUxD70lzGQ2shf6dKmGOfNXCWsiYeMJ2G22bLdRsP4phVMZNUpi9DmX/y7wA2jRo FLCo9Hrc/J2KZtIWQtVmEag== X-Google-Smtp-Source: AGHT+IHxQctUGKYgd5oy7kYkF4T9KZlsamRVSF7Lno+W8mdbELZDi6ZWUht6vp6IR2OIsIspamJFWs+eE7Qt6tSYEw== X-Received: from almasrymina.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:4bc5]) (user=almasrymina job=sendgmr) by 2002:a05:6902:154d:b0:e03:589b:cbe1 with SMTP id 3f1490d57ef6-e0b545431eamr671930276.7.1722306398655; Mon, 29 Jul 2024 19:26:38 -0700 (PDT) Date: Tue, 30 Jul 2024 02:26:09 +0000 In-Reply-To: <20240730022623.98909-1-almasrymina@google.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240730022623.98909-1-almasrymina@google.com> X-Mailer: git-send-email 2.46.0.rc1.232.g9752f9e123-goog Message-ID: <20240730022623.98909-6-almasrymina@google.com> Subject: [PATCH net-next v17 05/14] page_pool: move dmaddr helpers to .c file From: Mina Almasry To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-alpha@vger.kernel.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, sparclinux@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: Mina Almasry , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Donald Hunter , Jonathan Corbet , Richard Henderson , Ivan Kokshaysky , Matt Turner , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Andreas Larsson , Jesper Dangaard Brouer , Ilias Apalodimas , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Arnd Bergmann , Steffen Klassert , Herbert Xu , David Ahern , Willem de Bruijn , Shuah Khan , Sumit Semwal , " =?utf-8?q?Christian_K=C3=B6nig?= " , Bagas Sanjaya , Christoph Hellwig , Nikolay Aleksandrov , Taehee Yoo , Pavel Begunkov , David Wei , Jason Gunthorpe , Yunsheng Lin , Shailend Chand , Harshitha Ramamurthy , Shakeel Butt , Jeroen de Borst , Praveen Kaligineedi X-Patchwork-Delegate: kuba@kernel.org These helpers are used for setup and init of buffers, and their implementation need not be static inline in the header file. Moving the implementation to the .c file allows us to hide netmem implementation details in internal header files rather than the public file. Signed-off-by: Mina Almasry --- include/net/page_pool/helpers.h | 30 ++---------------------------- net/core/page_pool.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/include/net/page_pool/helpers.h b/include/net/page_pool/helpers.h index 2b43a893c619d..8f27ecc00bb16 100644 --- a/include/net/page_pool/helpers.h +++ b/include/net/page_pool/helpers.h @@ -399,17 +399,7 @@ static inline void page_pool_free_va(struct page_pool *pool, void *va, page_pool_put_page(pool, virt_to_head_page(va), -1, allow_direct); } -static inline dma_addr_t page_pool_get_dma_addr_netmem(netmem_ref netmem) -{ - struct page *page = netmem_to_page(netmem); - - dma_addr_t ret = page->dma_addr; - - if (PAGE_POOL_32BIT_ARCH_WITH_64BIT_DMA) - ret <<= PAGE_SHIFT; - - return ret; -} +dma_addr_t page_pool_get_dma_addr_netmem(netmem_ref netmem); /** * page_pool_get_dma_addr() - Retrieve the stored DMA address. @@ -423,23 +413,7 @@ static inline dma_addr_t page_pool_get_dma_addr(const struct page *page) return page_pool_get_dma_addr_netmem(page_to_netmem((struct page *)page)); } -static inline bool page_pool_set_dma_addr_netmem(netmem_ref netmem, - dma_addr_t addr) -{ - struct page *page = netmem_to_page(netmem); - - if (PAGE_POOL_32BIT_ARCH_WITH_64BIT_DMA) { - page->dma_addr = addr >> PAGE_SHIFT; - - /* We assume page alignment to shave off bottom bits, - * if this "compression" doesn't work we need to drop. - */ - return addr != (dma_addr_t)page->dma_addr << PAGE_SHIFT; - } - - page->dma_addr = addr; - return false; -} +bool page_pool_set_dma_addr_netmem(netmem_ref netmem, dma_addr_t addr); /** * page_pool_dma_sync_for_cpu - sync Rx page for CPU after it's written by HW diff --git a/net/core/page_pool.c b/net/core/page_pool.c index 2abe6e919224d..a032f731d4146 100644 --- a/net/core/page_pool.c +++ b/net/core/page_pool.c @@ -1099,3 +1099,34 @@ void page_pool_update_nid(struct page_pool *pool, int new_nid) } } EXPORT_SYMBOL(page_pool_update_nid); + +dma_addr_t page_pool_get_dma_addr_netmem(netmem_ref netmem) +{ + struct page *page = netmem_to_page(netmem); + + dma_addr_t ret = page->dma_addr; + + if (PAGE_POOL_32BIT_ARCH_WITH_64BIT_DMA) + ret <<= PAGE_SHIFT; + + return ret; +} +EXPORT_SYMBOL(page_pool_get_dma_addr_netmem); + +bool page_pool_set_dma_addr_netmem(netmem_ref netmem, dma_addr_t addr) +{ + struct page *page = netmem_to_page(netmem); + + if (PAGE_POOL_32BIT_ARCH_WITH_64BIT_DMA) { + page->dma_addr = addr >> PAGE_SHIFT; + + /* We assume page alignment to shave off bottom bits, + * if this "compression" doesn't work we need to drop. + */ + return addr != (dma_addr_t)page->dma_addr << PAGE_SHIFT; + } + + page->dma_addr = addr; + return false; +} +EXPORT_SYMBOL(page_pool_set_dma_addr_netmem);