-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
To give ourselves the flexibility of creating netlink commands and ability to refer to page pool instances in uAPIs create IDs for page pools. Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Eric Dumazet <edumazet@google.com> Acked-by: Jesper Dangaard Brouer <hawk@kernel.org> Signed-off-by: Jakub Kicinski <kuba@kernel.org> Reviewed-by: Shakeel Butt <shakeelb@google.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
- Loading branch information
Jakub Kicinski
authored and
Paolo Abeni
committed
Nov 28, 2023
1 parent
23cfaf6
commit f17c696
Showing
5 changed files
with
66 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
|
||
#ifndef __PAGE_POOL_PRIV_H | ||
#define __PAGE_POOL_PRIV_H | ||
|
||
int page_pool_list(struct page_pool *pool); | ||
void page_pool_unlist(struct page_pool *pool); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
|
||
#include <linux/mutex.h> | ||
#include <linux/xarray.h> | ||
#include <net/page_pool/types.h> | ||
|
||
#include "page_pool_priv.h" | ||
|
||
static DEFINE_XARRAY_FLAGS(page_pools, XA_FLAGS_ALLOC1); | ||
static DEFINE_MUTEX(page_pools_lock); | ||
|
||
int page_pool_list(struct page_pool *pool) | ||
{ | ||
static u32 id_alloc_next; | ||
int err; | ||
|
||
mutex_lock(&page_pools_lock); | ||
err = xa_alloc_cyclic(&page_pools, &pool->user.id, pool, xa_limit_32b, | ||
&id_alloc_next, GFP_KERNEL); | ||
if (err < 0) | ||
goto err_unlock; | ||
|
||
mutex_unlock(&page_pools_lock); | ||
return 0; | ||
|
||
err_unlock: | ||
mutex_unlock(&page_pools_lock); | ||
return err; | ||
} | ||
|
||
void page_pool_unlist(struct page_pool *pool) | ||
{ | ||
mutex_lock(&page_pools_lock); | ||
xa_erase(&page_pools, pool->user.id); | ||
mutex_unlock(&page_pools_lock); | ||
} |