diff mbox series

[net-next,v2,13/18] xsk: allow attaching XSk pool via xdp_rxq_info_reg_mem_model()

Message ID 20241015145350.4077765-14-aleksander.lobakin@intel.com (mailing list archive)
State Changes Requested
Delegated to: BPF
Headers show
Series idpf: XDP chapter III: core XDP changes (+libeth_xdp) | expand

Checks

Context Check Description
netdev/series_format fail Series longer than 15 patches
netdev/tree_selection success Clearly marked for net-next, async
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 5 this patch: 5
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 1 maintainers not CCed: hawk@kernel.org
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 7 this patch: 7
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-10-16--12-00 (tests: 776)

Commit Message

Alexander Lobakin Oct. 15, 2024, 2:53 p.m. UTC
When you register an XSk pool as XDP Rxq info memory model, you then
need to manually attach it after the registration.
Let the user combine both actions into one by just passing a pointer
to the pool directly to xdp_rxq_info_reg_mem_model(), which will take
care of calling xsk_pool_set_rxq_info(). This looks similar to how a
&page_pool gets registered and reduce repeating driver code.

Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
---
 net/core/xdp.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Maciej Fijalkowski Oct. 17, 2024, 12:49 p.m. UTC | #1
On Tue, Oct 15, 2024 at 04:53:45PM +0200, Alexander Lobakin wrote:
> When you register an XSk pool as XDP Rxq info memory model, you then
> need to manually attach it after the registration.
> Let the user combine both actions into one by just passing a pointer
> to the pool directly to xdp_rxq_info_reg_mem_model(), which will take
> care of calling xsk_pool_set_rxq_info(). This looks similar to how a
> &page_pool gets registered and reduce repeating driver code.
> 
> Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>

Makes sense, but why not address callsites in drivers while at it?
Otherwise in case this would be merged this would be called twice. Not a
big deal though.

Acked-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>

> ---
>  net/core/xdp.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/net/core/xdp.c b/net/core/xdp.c
> index 9dc103a09b5c..371c26c203b2 100644
> --- a/net/core/xdp.c
> +++ b/net/core/xdp.c
> @@ -358,6 +358,9 @@ int xdp_rxq_info_reg_mem_model(struct xdp_rxq_info *xdp_rxq,
>  	if (IS_ERR(xdp_alloc))
>  		return PTR_ERR(xdp_alloc);
>  
> +	if (type == MEM_TYPE_XSK_BUFF_POOL && allocator)
> +		xsk_pool_set_rxq_info(allocator, xdp_rxq);
> +
>  	if (trace_mem_connect_enabled() && xdp_alloc)
>  		trace_mem_connect(xdp_alloc, xdp_rxq);
>  	return 0;
> -- 
> 2.46.2
>
Alexander Lobakin Oct. 21, 2024, 2:23 p.m. UTC | #2
From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Date: Thu, 17 Oct 2024 14:49:51 +0200

> On Tue, Oct 15, 2024 at 04:53:45PM +0200, Alexander Lobakin wrote:
>> When you register an XSk pool as XDP Rxq info memory model, you then
>> need to manually attach it after the registration.
>> Let the user combine both actions into one by just passing a pointer
>> to the pool directly to xdp_rxq_info_reg_mem_model(), which will take
>> care of calling xsk_pool_set_rxq_info(). This looks similar to how a
>> &page_pool gets registered and reduce repeating driver code.
>>
>> Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
> 
> Makes sense, but why not address callsites in drivers while at it?
> Otherwise in case this would be merged this would be called twice. Not a
> big deal though.

You said yourself that this series is big enough already :D
This won't be called twice as here I call it only when
`allocator != NULL`, but all the callsites pass NULL when they
want to register an XSk pool. It's not NULL only in case of
Page Pool.

> 
> Acked-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>

Thanks,
Olek
diff mbox series

Patch

diff --git a/net/core/xdp.c b/net/core/xdp.c
index 9dc103a09b5c..371c26c203b2 100644
--- a/net/core/xdp.c
+++ b/net/core/xdp.c
@@ -358,6 +358,9 @@  int xdp_rxq_info_reg_mem_model(struct xdp_rxq_info *xdp_rxq,
 	if (IS_ERR(xdp_alloc))
 		return PTR_ERR(xdp_alloc);
 
+	if (type == MEM_TYPE_XSK_BUFF_POOL && allocator)
+		xsk_pool_set_rxq_info(allocator, xdp_rxq);
+
 	if (trace_mem_connect_enabled() && xdp_alloc)
 		trace_mem_connect(xdp_alloc, xdp_rxq);
 	return 0;