All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: page pool: allow to pass zero flags to page_pool_init()
@ 2020-03-25 14:12 Denis Kirjanov
  2020-03-25 15:02 ` Jesper Dangaard Brouer
  0 siblings, 1 reply; 3+ messages in thread
From: Denis Kirjanov @ 2020-03-25 14:12 UTC (permalink / raw)
  To: netdev; +Cc: hawk, ilias.apalodimas, Denis Kirjanov

page pool API can be useful for non-DMA cases like
xen-netfront driver so let's allow to pass zero flags to
page pool flags.

Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
---
 net/core/page_pool.c | 36 +++++++++++++++++++-----------------
 1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/net/core/page_pool.c b/net/core/page_pool.c
index 10d2b25..eeeb0d9 100644
--- a/net/core/page_pool.c
+++ b/net/core/page_pool.c
@@ -39,27 +39,29 @@ static int page_pool_init(struct page_pool *pool,
 	if (ring_qsize > 32768)
 		return -E2BIG;
 
-	/* DMA direction is either DMA_FROM_DEVICE or DMA_BIDIRECTIONAL.
-	 * DMA_BIDIRECTIONAL is for allowing page used for DMA sending,
-	 * which is the XDP_TX use-case.
-	 */
-	if ((pool->p.dma_dir != DMA_FROM_DEVICE) &&
-	    (pool->p.dma_dir != DMA_BIDIRECTIONAL))
-		return -EINVAL;
-
-	if (pool->p.flags & PP_FLAG_DMA_SYNC_DEV) {
-		/* In order to request DMA-sync-for-device the page
-		 * needs to be mapped
+	if (pool->p.flags) {
+		/* DMA direction is either DMA_FROM_DEVICE or DMA_BIDIRECTIONAL.
+		 * DMA_BIDIRECTIONAL is for allowing page used for DMA sending,
+		 * which is the XDP_TX use-case.
 		 */
-		if (!(pool->p.flags & PP_FLAG_DMA_MAP))
+		if ((pool->p.dma_dir != DMA_FROM_DEVICE) &&
+		    (pool->p.dma_dir != DMA_BIDIRECTIONAL))
 			return -EINVAL;
 
-		if (!pool->p.max_len)
-			return -EINVAL;
+		if (pool->p.flags & PP_FLAG_DMA_SYNC_DEV) {
+			/* In order to request DMA-sync-for-device the page
+			 * needs to be mapped
+			 */
+			if (!(pool->p.flags & PP_FLAG_DMA_MAP))
+				return -EINVAL;
 
-		/* pool->p.offset has to be set according to the address
-		 * offset used by the DMA engine to start copying rx data
-		 */
+			if (!pool->p.max_len)
+				return -EINVAL;
+
+			/* pool->p.offset has to be set according to the address
+			 * offset used by the DMA engine to start copying rx data
+			 */
+		}
 	}
 
 	if (ptr_ring_init(&pool->ring, ring_qsize, GFP_KERNEL) < 0)
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-03-25 19:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-25 14:12 [PATCH net-next] net: page pool: allow to pass zero flags to page_pool_init() Denis Kirjanov
2020-03-25 15:02 ` Jesper Dangaard Brouer
2020-03-25 19:16   ` Denis Kirjanov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.