[v1] net/af_xdp: make umem configure code more readable

Message ID 20220209124358.137807-1-haiyue.wang@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series [v1] net/af_xdp: make umem configure code more readable |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS

Commit Message

Wang, Haiyue Feb. 9, 2022, 12:43 p.m. UTC
  The below compile time defined style make the code not so readable, the
first function end block is after "#endif" segment.

	#if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG)

	xdp_umem_configure()
	{

	#else
	xdp_umem_configure()
	{

	#endif
		'shared code block'
	}

Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
---
 drivers/net/af_xdp/rte_eth_af_xdp.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
  

Comments

Loftus, Ciara Feb. 10, 2022, 8:53 a.m. UTC | #1
> Subject: [PATCH v1] net/af_xdp: make umem configure code more readable
> 
> The below compile time defined style make the code not so readable, the
> first function end block is after "#endif" segment.
> 
> 	#if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG)
> 
> 	xdp_umem_configure()
> 	{
> 
> 	#else
> 	xdp_umem_configure()
> 	{
> 
> 	#endif
> 		'shared code block'
> 	}
> 
> Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>

Thanks for the patch!

Acked-by: Ciara Loftus <ciara.loftus@intel.com>

> ---
>  drivers/net/af_xdp/rte_eth_af_xdp.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c
> b/drivers/net/af_xdp/rte_eth_af_xdp.c
> index 1b6192fa44..802f912cb7 100644
> --- a/drivers/net/af_xdp/rte_eth_af_xdp.c
> +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
> @@ -1078,6 +1078,12 @@ xsk_umem_info *xdp_umem_configure(struct
> pmd_internals *internals,
>  		__atomic_store_n(&umem->refcnt, 1, __ATOMIC_RELEASE);
>  	}
> 
> +	return umem;
> +
> +err:
> +	xdp_umem_destroy(umem);
> +	return NULL;
> +}
>  #else
>  static struct
>  xsk_umem_info *xdp_umem_configure(struct pmd_internals *internals,
> @@ -1138,13 +1144,13 @@ xsk_umem_info *xdp_umem_configure(struct
> pmd_internals *internals,
>  	}
>  	umem->mz = mz;
> 
> -#endif
>  	return umem;
> 
>  err:
>  	xdp_umem_destroy(umem);
>  	return NULL;
>  }
> +#endif
> 
>  static int
>  load_custom_xdp_prog(const char *prog_path, int if_index, struct bpf_map
> **map)
> --
> 2.35.1
  
Ferruh Yigit Feb. 10, 2022, 10:31 a.m. UTC | #2
On 2/10/2022 8:53 AM, Loftus, Ciara wrote:
>> Subject: [PATCH v1] net/af_xdp: make umem configure code more readable
>>
>> The below compile time defined style make the code not so readable, the
>> first function end block is after "#endif" segment.
>>
>> 	#if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG)
>>
>> 	xdp_umem_configure()
>> 	{
>>
>> 	#else
>> 	xdp_umem_configure()
>> 	{
>>
>> 	#endif
>> 		'shared code block'
>> 	}
>>
>> Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
> 
> Thanks for the patch!
> 
> Acked-by: Ciara Loftus <ciara.loftus@intel.com>
> 

Applied to dpdk-next-net/main, thanks.
  

Patch

diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 1b6192fa44..802f912cb7 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -1078,6 +1078,12 @@  xsk_umem_info *xdp_umem_configure(struct pmd_internals *internals,
 		__atomic_store_n(&umem->refcnt, 1, __ATOMIC_RELEASE);
 	}
 
+	return umem;
+
+err:
+	xdp_umem_destroy(umem);
+	return NULL;
+}
 #else
 static struct
 xsk_umem_info *xdp_umem_configure(struct pmd_internals *internals,
@@ -1138,13 +1144,13 @@  xsk_umem_info *xdp_umem_configure(struct pmd_internals *internals,
 	}
 	umem->mz = mz;
 
-#endif
 	return umem;
 
 err:
 	xdp_umem_destroy(umem);
 	return NULL;
 }
+#endif
 
 static int
 load_custom_xdp_prog(const char *prog_path, int if_index, struct bpf_map **map)