[PATCH v2 11/22] app/test: include headers directly

Stephen Hemminger <[email protected]> Mon, 3 Aug 2026 09:51:57 -0700
Newsgroups org.dpdk.dev
Message-ID <[email protected]>
The test code was getting network headers indirectly via inclusion
of rte_ethdev.h. This will change in the future, instead get the
headers directly.

For BPF test, use the tool "iwyu" to get more complete set of headers.
Replace use of htons() with equivalent DPDK byteorder macro.

Signed-off-by: Stephen Hemminger <[email protected]>
---
 app/test-eventdev/test_pipeline_common.h |  1 +
 app/test/test_bpf.c                      | 18 +++++++++++++-----
 app/test/test_security_inline_macsec.c   |  2 ++
 app/test/test_security_inline_proto.c    |  1 +
 4 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/app/test-eventdev/test_pipeline_common.h b/app/test-eventdev/test_pipeline_common.h
index 61370fb799..e9f20e7f62 100644
--- a/app/test-eventdev/test_pipeline_common.h
+++ b/app/test-eventdev/test_pipeline_common.h
@@ -12,6 +12,7 @@
 #include <rte_cycles.h>
 #include <rte_ethdev.h>
 #include <rte_ether.h>
+#include <rte_ip.h>
 #include <rte_event_eth_rx_adapter.h>
 #include <rte_event_eth_tx_adapter.h>
 #include <rte_eventdev.h>
diff --git a/app/test/test_bpf.c b/app/test/test_bpf.c
index 3205afaa63..2fea37396e 100644
--- a/app/test/test_bpf.c
+++ b/app/test/test_bpf.c
@@ -5,16 +5,26 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdint.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdalign.h>
 #include <inttypes.h>
+#include <errno.h>
+#include <limits.h>
 #include <unistd.h>
 
-#include <rte_memory.h>
+#include <rte_bitops.h>
 #include <rte_debug.h>
 #include <rte_hexdump.h>
 #include <rte_malloc.h>
+#include <rte_memcpy.h>
+#include <rte_mbuf.h>
 #include <rte_random.h>
 #include <rte_byteorder.h>
 #include <rte_errno.h>
+#include <rte_ether.h>
+#include <rte_ip.h>
 
 #include "test.h"
 
@@ -30,8 +40,6 @@ test_bpf(void)
 #else
 
 #include <rte_bpf.h>
-#include <rte_ether.h>
-#include <rte_ip.h>
 
 
 /* Tests of most simple BPF programs (no instructions, one instruction etc.) */
@@ -1331,7 +1339,7 @@ test_jump2_check(uint64_t rc, const void *arg)
 	uint16_t eth_type;
 	uint64_t v = -1;
 
-	if (eth_hdr->ether_type == htons(0x8100)) {
+	if (eth_hdr->ether_type == rte_cpu_to_be_16(0x8100)) {
 		const struct rte_vlan_hdr *vlan_hdr =
 			(const void *)(eth_hdr + 1);
 		eth_type = vlan_hdr->eth_proto;
@@ -1341,7 +1349,7 @@ test_jump2_check(uint64_t rc, const void *arg)
 		next = eth_hdr + 1;
 	}
 
-	if (eth_type == htons(0x0800)) {
+	if (eth_type == rte_cpu_to_be_16(0x0800)) {
 		ipv4_hdr = next;
 		if ((ipv4_hdr->dst_addr & rte_cpu_to_be_32(TEST_NETMASK)) ==
 		    rte_cpu_to_be_32(TEST_SUBNET)) {
diff --git a/app/test/test_security_inline_macsec.c b/app/test/test_security_inline_macsec.c
index a929ff5326..43672ef237 100644
--- a/app/test/test_security_inline_macsec.c
+++ b/app/test/test_security_inline_macsec.c
@@ -8,6 +8,8 @@
 #include <rte_ethdev.h>
 #include <rte_malloc.h>
 #include <rte_security.h>
+#include <rte_flow.h>
+#include <rte_macsec.h>
 
 #include "test.h"
 #include "test_security_inline_macsec_vectors.h"
diff --git a/app/test/test_security_inline_proto.c b/app/test/test_security_inline_proto.c
index 0b1f7fbbab..99111e5432 100644
--- a/app/test/test_security_inline_proto.c
+++ b/app/test/test_security_inline_proto.c
@@ -7,6 +7,7 @@
 #include <inttypes.h>
 
 #include <rte_ethdev.h>
+#include <rte_flow.h>
 #include <rte_malloc.h>
 #include <rte_security.h>
 
-- 
2.53.0