Skip to contentSkip to conversation

net/af_xdp: make umem configure code more readable

PATCH Applied Haiyue Wang 3 participants 3 messages Feb 9, 2022 – Feb 10, 2022 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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'
	}
---
 drivers/net/af_xdp/rte_eth_af_xdp.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/af_xdp/rte_eth_af_xdp.c +7 -1
index 1b6192fa44..802f912cb7 100644
@@ -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)
Signature · 1 line
2.35.1
Acked-by on v1 1/1
#1 lore raw
Quoted 18 lines

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'
	}
Quoted 1 line

Thanks for the patch!

Quoted 42 lines
---
 drivers/net/af_xdp/rte_eth_af_xdp.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/af_xdp/rte_eth_af_xdp.c +6 -0
index 1b6192fa44..802f912cb7 100644
@@ -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,

drivers/net/af_xdp/rte_eth_af_xdp.c +1 -1
@@ -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

Applied
#2 lore raw
Quoted 18 lines · Ciara
Quoted 18 lines

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'
	}
Quoted 6 lines
Quoted 1 line

Thanks for the patch!

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