DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 0/8] Enable building more on Windows
@ 2022-12-01  1:44 Stephen Hemminger
  2022-12-01  1:44 ` [PATCH 1/8] net/null: build null PMD " Stephen Hemminger
                   ` (9 more replies)
  0 siblings, 10 replies; 66+ messages in thread
From: Stephen Hemminger @ 2022-12-01  1:44 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

While diagnosing some Windows cross build errors;
noticed that lots of important DPDK libraries are not
being built on Windows.

This patchset enables build them.
Tested with MingW cross build.

Stephen Hemminger (8):
  net/null: build null PMD on Windows
  net/ring: build on Windows
  lpm: enable on Windows
  reorder: build on Windows
  ip_frag: enable build on Windows
  rib: enable on Windows
  fib: enable on Windows
  pcapng: windows compatability

 app/test/meson.build         |  2 +-
 app/test/test_fib.c          | 22 +-------------
 app/test/test_fib6.c         | 24 ++-------------
 app/test/test_fib6_perf.c    | 15 +--------
 app/test/test_fib_perf.c     | 19 ++----------
 app/test/test_ipfrag.c       | 12 --------
 app/test/test_lpm.c          | 15 +--------
 app/test/test_lpm6.c         | 12 --------
 app/test/test_lpm6_data.h    |  3 +-
 app/test/test_lpm6_perf.c    | 14 +--------
 app/test/test_lpm_perf.c     | 39 ++++++++----------------
 app/test/test_reorder.c      | 11 -------
 app/test/test_rib.c          | 19 ------------
 app/test/test_rib6.c         | 24 ++-------------
 drivers/net/null/meson.build |  6 ----
 drivers/net/ring/meson.build |  6 ----
 lib/fib/meson.build          |  6 ----
 lib/fib/rte_fib.c            |  1 +
 lib/fib/rte_fib6.c           |  1 +
 lib/ip_frag/ip_frag_common.h |  2 ++
 lib/ip_frag/meson.build      |  6 ----
 lib/lpm/meson.build          |  6 ----
 lib/pcapng/meson.build       |  6 ----
 lib/pcapng/rte_pcapng.c      | 59 ++++++++++++++++++++++++++++++++++--
 lib/reorder/meson.build      |  6 ----
 lib/reorder/rte_reorder.c    |  1 +
 lib/rib/meson.build          |  6 ----
 lib/rib/rte_rib.c            |  1 +
 lib/rib/rte_rib6.c           |  1 +
 29 files changed, 90 insertions(+), 255 deletions(-)

-- 
2.35.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH 1/8] net/null: build null PMD on Windows
  2022-12-01  1:44 [PATCH 0/8] Enable building more on Windows Stephen Hemminger
@ 2022-12-01  1:44 ` Stephen Hemminger
  2022-12-01 23:51   ` Tyler Retzlaff
  2022-12-01  1:44 ` [PATCH 2/8] net/ring: build " Stephen Hemminger
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 66+ messages in thread
From: Stephen Hemminger @ 2022-12-01  1:44 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tetsuya Mukawa

Builds fine with current code, no changes needed.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/null/meson.build | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/net/null/meson.build b/drivers/net/null/meson.build
index 4a483955a7a9..a51f8f5211b0 100644
--- a/drivers/net/null/meson.build
+++ b/drivers/net/null/meson.build
@@ -1,11 +1,5 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_eth_null.c')
 pmd_supports_disable_iova_as_pa = true
-- 
2.35.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH 2/8] net/ring: build on Windows
  2022-12-01  1:44 [PATCH 0/8] Enable building more on Windows Stephen Hemminger
  2022-12-01  1:44 ` [PATCH 1/8] net/null: build null PMD " Stephen Hemminger
@ 2022-12-01  1:44 ` Stephen Hemminger
  2022-12-01 23:52   ` Tyler Retzlaff
  2022-12-14 23:18   ` Kadam, Pallavi
  2022-12-01  1:44 ` [PATCH 3/8] lpm: enable " Stephen Hemminger
                   ` (7 subsequent siblings)
  9 siblings, 2 replies; 66+ messages in thread
From: Stephen Hemminger @ 2022-12-01  1:44 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Bruce Richardson

This driver builds ok on windows, but need to modify the
test meson build to skip the eventdev test on Windows.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/meson.build         | 2 +-
 drivers/net/ring/meson.build | 6 ------
 2 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/app/test/meson.build b/app/test/meson.build
index f34d19e3c3cb..a713f0382280 100644
--- a/app/test/meson.build
+++ b/app/test/meson.build
@@ -390,7 +390,7 @@ if dpdk_conf.has('RTE_NET_BOND')
         driver_test_names += 'link_bonding_mode4_autotest'
     endif
 endif
-if dpdk_conf.has('RTE_NET_RING')
+if dpdk_conf.has('RTE_LIB_EVENTDEV') and dpdk_conf.has('RTE_NET_RING')
     test_deps += 'net_ring'
     test_sources += 'test_pmd_ring_perf.c'
     test_sources += 'test_pmd_ring.c'
diff --git a/drivers/net/ring/meson.build b/drivers/net/ring/meson.build
index 72792e26b05a..3534a3cc2287 100644
--- a/drivers/net/ring/meson.build
+++ b/drivers/net/ring/meson.build
@@ -1,12 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_eth_ring.c')
 headers = files('rte_eth_ring.h')
 pmd_supports_disable_iova_as_pa = true
-- 
2.35.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH 3/8] lpm: enable on Windows
  2022-12-01  1:44 [PATCH 0/8] Enable building more on Windows Stephen Hemminger
  2022-12-01  1:44 ` [PATCH 1/8] net/null: build null PMD " Stephen Hemminger
  2022-12-01  1:44 ` [PATCH 2/8] net/ring: build " Stephen Hemminger
@ 2022-12-01  1:44 ` Stephen Hemminger
  2022-12-01 23:53   ` Tyler Retzlaff
  2022-12-01  1:44 ` [PATCH 4/8] reorder: build " Stephen Hemminger
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 66+ messages in thread
From: Stephen Hemminger @ 2022-12-01  1:44 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Bruce Richardson, Vladimir Medvedkin

This builds on Windows without changes.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_lpm.c       | 15 +--------------
 app/test/test_lpm6.c      | 12 ------------
 app/test/test_lpm6_data.h |  3 ++-
 app/test/test_lpm6_perf.c | 14 +-------------
 app/test/test_lpm_perf.c  | 39 ++++++++++++---------------------------
 lib/lpm/meson.build       |  6 ------
 6 files changed, 16 insertions(+), 73 deletions(-)

diff --git a/app/test/test_lpm.c b/app/test/test_lpm.c
index bceb9ae743d7..37b460af3a96 100644
--- a/app/test/test_lpm.c
+++ b/app/test/test_lpm.c
@@ -2,18 +2,6 @@
  * Copyright(c) 2010-2014 Intel Corporation
  */
 
-#include "test.h"
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_lpm(void)
-{
-	printf("lpm not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
@@ -22,6 +10,7 @@ test_lpm(void)
 #include <rte_lpm.h>
 #include <rte_malloc.h>
 
+#include "test.h"
 #include "test_xmmt_ops.h"
 
 #define TEST_LPM_ASSERT(cond) do {                                            \
@@ -1595,6 +1584,4 @@ test_lpm(void)
 	return global_status;
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(lpm_autotest, test_lpm);
diff --git a/app/test/test_lpm6.c b/app/test/test_lpm6.c
index 1f44392db739..b6b6f8615ea5 100644
--- a/app/test/test_lpm6.c
+++ b/app/test/test_lpm6.c
@@ -10,16 +10,6 @@
 #include <string.h>
 
 #include <rte_memory.h>
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_lpm6(void)
-{
-	printf("lpm6 not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
 #include <rte_lpm6.h>
 
 #include "test_lpm6_data.h"
@@ -1803,6 +1793,4 @@ test_lpm6(void)
 	return global_status;
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(lpm6_autotest, test_lpm6);
diff --git a/app/test/test_lpm6_data.h b/app/test/test_lpm6_data.h
index da9b161f20e5..3a1fa25f8433 100644
--- a/app/test/test_lpm6_data.h
+++ b/app/test/test_lpm6_data.h
@@ -6,6 +6,7 @@
 
 #include <stdint.h>
 #include <stdlib.h>
+#include <rte_random.h>
 
 struct rules_tbl_entry {
 	uint8_t ip[16];
@@ -1129,7 +1130,7 @@ static void generate_large_ips_table(int gen_expected_next_hop)
 
 	for (i = 0; i < NUM_IPS_ENTRIES; i++) {
 		for (j = 0; j < 16; j++)
-			large_ips_table[i].ip[j] = lrand48();
+			large_ips_table[i].ip[j] = rte_rand();
 	}
 
 	for (k = j = 0, i = 0; i < NUM_IPS_ENTRIES; i++) {
diff --git a/app/test/test_lpm6_perf.c b/app/test/test_lpm6_perf.c
index aaf2773b6fac..5b684686a687 100644
--- a/app/test/test_lpm6_perf.c
+++ b/app/test/test_lpm6_perf.c
@@ -2,17 +2,6 @@
  * Copyright(c) 2010-2014 Intel Corporation
  */
 
-#include "test.h"
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_lpm6_perf(void)
-{
-	printf("lpm6_perf not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
 
 #include <stdio.h>
 #include <stdint.h>
@@ -24,6 +13,7 @@ test_lpm6_perf(void)
 #include <rte_memory.h>
 #include <rte_lpm6.h>
 
+#include "test.h"
 #include "test_lpm6_data.h"
 
 #define TEST_LPM_ASSERT(cond) do {                                            \
@@ -171,6 +161,4 @@ test_lpm6_perf(void)
 	return 0;
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(lpm6_perf_autotest, test_lpm6_perf);
diff --git a/app/test/test_lpm_perf.c b/app/test/test_lpm_perf.c
index e858716f909b..e72437ba3850 100644
--- a/app/test/test_lpm_perf.c
+++ b/app/test/test_lpm_perf.c
@@ -3,17 +3,6 @@
  * Copyright(c) 2020 Arm Limited
  */
 
-#include "test.h"
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_lpm_perf(void)
-{
-	printf("lpm_perf not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
@@ -25,7 +14,9 @@ test_lpm_perf(void)
 #include <rte_malloc.h>
 #include <rte_ip.h>
 #include <rte_lpm.h>
+#include <rte_spinlock.h>
 
+#include "test.h"
 #include "test_xmmt_ops.h"
 
 struct rte_lpm *lpm;
@@ -34,8 +25,9 @@ static volatile uint8_t writer_done;
 static volatile uint32_t thr_id;
 static uint64_t gwrite_cycles;
 static uint32_t num_writers;
-/* LPM APIs are not thread safe, use mutex to provide thread safety */
-static pthread_mutex_t lpm_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+/* LPM APIs are not thread safe, use spinlock */
+static rte_spinlock_t lpm_lock = RTE_SPINLOCK_INITIALIZER;
 
 /* Report quiescent state interval every 1024 lookups. Larger critical
  * sections in reader will result in writer polling multiple times.
@@ -267,7 +259,7 @@ static void generate_random_rule_prefix(uint32_t ip_class, uint8_t depth)
 	/* Only generate rest bits except the most significant
 	 * fixed bits for IP address class
 	 */
-	start = lrand48() & mask;
+	start = rte_rand() & mask;
 	ptr_rule = &large_route_table[num_route_entries];
 	ptr_ldepth_rule = &large_ldepth_route_table[num_ldepth_route_entries];
 	for (k = 0; k < rule_num; k++) {
@@ -296,7 +288,7 @@ static void insert_rule_in_random_pos(uint32_t ip, uint8_t depth)
 	struct route_rule tmp;
 
 	do {
-		pos = lrand48();
+		pos = rte_rand();
 		try_count++;
 	} while ((try_count < 10) && (pos > num_route_entries));
 
@@ -452,8 +444,7 @@ test_lpm_rcu_qsbr_writer(void *arg)
 	for (i = 0; i < RCU_ITERATIONS; i++) {
 		/* Add all the entries */
 		for (j = si; j < ei; j++) {
-			if (num_writers > 1)
-				pthread_mutex_lock(&lpm_mutex);
+			rte_spinlock_lock(&lpm_lock);
 			if (rte_lpm_add(lpm, large_ldepth_route_table[j].ip,
 					large_ldepth_route_table[j].depth,
 					next_hop_add) != 0) {
@@ -461,22 +452,19 @@ test_lpm_rcu_qsbr_writer(void *arg)
 					i, j);
 				goto error;
 			}
-			if (num_writers > 1)
-				pthread_mutex_unlock(&lpm_mutex);
+			rte_spinlock_unlock(&lpm_lock);
 		}
 
 		/* Delete all the entries */
 		for (j = si; j < ei; j++) {
-			if (num_writers > 1)
-				pthread_mutex_lock(&lpm_mutex);
+			rte_spinlock_lock(&lpm_lock);
 			if (rte_lpm_delete(lpm, large_ldepth_route_table[j].ip,
 				large_ldepth_route_table[j].depth) != 0) {
 				printf("Failed to delete iteration %d, route# %d\n",
 					i, j);
 				goto error;
 			}
-			if (num_writers > 1)
-				pthread_mutex_unlock(&lpm_mutex);
+			rte_spinlock_unlock(&lpm_lock);
 		}
 	}
 
@@ -487,8 +475,7 @@ test_lpm_rcu_qsbr_writer(void *arg)
 	return 0;
 
 error:
-	if (num_writers > 1)
-		pthread_mutex_unlock(&lpm_mutex);
+	rte_spinlock_unlock(&lpm_lock);
 	return -1;
 }
 
@@ -773,6 +760,4 @@ test_lpm_perf(void)
 	return 0;
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(lpm_perf_autotest, test_lpm_perf);
diff --git a/lib/lpm/meson.build b/lib/lpm/meson.build
index 6b47361fcec0..4cd48886fc41 100644
--- a/lib/lpm/meson.build
+++ b/lib/lpm/meson.build
@@ -1,12 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_lpm.c', 'rte_lpm6.c')
 headers = files('rte_lpm.h', 'rte_lpm6.h')
 # since header files have different names, we can install all vector headers
-- 
2.35.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH 4/8] reorder: build on Windows
  2022-12-01  1:44 [PATCH 0/8] Enable building more on Windows Stephen Hemminger
                   ` (2 preceding siblings ...)
  2022-12-01  1:44 ` [PATCH 3/8] lpm: enable " Stephen Hemminger
@ 2022-12-01  1:44 ` Stephen Hemminger
  2022-12-01 23:53   ` Tyler Retzlaff
  2022-12-01  1:44 ` [PATCH 5/8] ip_frag: enable " Stephen Hemminger
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 66+ messages in thread
From: Stephen Hemminger @ 2022-12-01  1:44 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Reshma Pattan

This builds on Windows if sys/queue.h is included.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_reorder.c   | 11 -----------
 lib/reorder/meson.build   |  6 ------
 lib/reorder/rte_reorder.c |  1 +
 3 files changed, 1 insertion(+), 17 deletions(-)

diff --git a/app/test/test_reorder.c b/app/test/test_reorder.c
index f0714a5c18a3..9ebd91477536 100644
--- a/app/test/test_reorder.c
+++ b/app/test/test_reorder.c
@@ -11,16 +11,6 @@
 #include <rte_cycles.h>
 #include <rte_errno.h>
 #include <rte_mbuf.h>
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_reorder(void)
-{
-	printf("reorder not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-#else
-
 #include <rte_reorder.h>
 #include <rte_lcore.h>
 #include <rte_malloc.h>
@@ -395,6 +385,5 @@ test_reorder(void)
 	return unit_test_suite_runner(&reorder_test_suite);
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
 
 REGISTER_TEST_COMMAND(reorder_autotest, test_reorder);
diff --git a/lib/reorder/meson.build b/lib/reorder/meson.build
index 621c1f350103..03aed53d9007 100644
--- a/lib/reorder/meson.build
+++ b/lib/reorder/meson.build
@@ -1,12 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_reorder.c')
 headers = files('rte_reorder.h')
 deps += ['mbuf']
diff --git a/lib/reorder/rte_reorder.c b/lib/reorder/rte_reorder.c
index 385ee479da42..00e2cf043e04 100644
--- a/lib/reorder/rte_reorder.c
+++ b/lib/reorder/rte_reorder.c
@@ -3,6 +3,7 @@
  */
 
 #include <string.h>
+#include <sys/queue.h>
 
 #include <rte_string_fns.h>
 #include <rte_log.h>
-- 
2.35.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH 5/8] ip_frag: enable build on Windows
  2022-12-01  1:44 [PATCH 0/8] Enable building more on Windows Stephen Hemminger
                   ` (3 preceding siblings ...)
  2022-12-01  1:44 ` [PATCH 4/8] reorder: build " Stephen Hemminger
@ 2022-12-01  1:44 ` Stephen Hemminger
  2022-12-01 23:54   ` Tyler Retzlaff
  2022-12-01  1:44 ` [PATCH 6/8] rib: enable " Stephen Hemminger
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 66+ messages in thread
From: Stephen Hemminger @ 2022-12-01  1:44 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Konstantin Ananyev

This build works on Windows if sys/queue.h is included.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_ipfrag.c       | 12 ------------
 lib/ip_frag/ip_frag_common.h |  2 ++
 lib/ip_frag/meson.build      |  6 ------
 3 files changed, 2 insertions(+), 18 deletions(-)

diff --git a/app/test/test_ipfrag.c b/app/test/test_ipfrag.c
index 88cc4cdeea8d..402ce361c1a2 100644
--- a/app/test/test_ipfrag.c
+++ b/app/test/test_ipfrag.c
@@ -10,17 +10,6 @@
 #include <rte_cycles.h>
 #include <rte_hexdump.h>
 #include <rte_ip.h>
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_ipfrag(void)
-{
-	printf("ipfrag not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
 #include <rte_ip_frag.h>
 #include <rte_mbuf.h>
 #include <rte_random.h>
@@ -520,6 +509,5 @@ test_ipfrag(void)
 	return unit_test_suite_runner(&ipfrag_testsuite);
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
 
 REGISTER_TEST_COMMAND(ipfrag_autotest, test_ipfrag);
diff --git a/lib/ip_frag/ip_frag_common.h b/lib/ip_frag/ip_frag_common.h
index 9c0dbdeb6eb9..0f4ad72a90d9 100644
--- a/lib/ip_frag/ip_frag_common.h
+++ b/lib/ip_frag/ip_frag_common.h
@@ -8,6 +8,8 @@
 #include "rte_ip_frag.h"
 #include "ip_reassembly.h"
 
+#include <sys/queue.h>
+
 /* logging macros. */
 #ifdef RTE_LIBRTE_IP_FRAG_DEBUG
 #define	IP_FRAG_LOG(lvl, fmt, args...)	RTE_LOG(lvl, USER1, fmt, ##args)
diff --git a/lib/ip_frag/meson.build b/lib/ip_frag/meson.build
index 3a252bdaf6a4..ea2de09f7528 100644
--- a/lib/ip_frag/meson.build
+++ b/lib/ip_frag/meson.build
@@ -1,12 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files(
         'rte_ipv4_fragmentation.c',
         'rte_ipv6_fragmentation.c',
-- 
2.35.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH 6/8] rib: enable on Windows
  2022-12-01  1:44 [PATCH 0/8] Enable building more on Windows Stephen Hemminger
                   ` (4 preceding siblings ...)
  2022-12-01  1:44 ` [PATCH 5/8] ip_frag: enable " Stephen Hemminger
@ 2022-12-01  1:44 ` Stephen Hemminger
  2022-12-01 23:54   ` Tyler Retzlaff
  2022-12-01  1:44 ` [PATCH 7/8] fib: " Stephen Hemminger
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 66+ messages in thread
From: Stephen Hemminger @ 2022-12-01  1:44 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Vladimir Medvedkin

The RIB library builds on Windows as long as sys/queue.h is included

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_rib.c  | 19 -------------------
 app/test/test_rib6.c | 24 ++----------------------
 lib/rib/meson.build  |  6 ------
 lib/rib/rte_rib.c    |  1 +
 lib/rib/rte_rib6.c   |  1 +
 5 files changed, 4 insertions(+), 47 deletions(-)

diff --git a/app/test/test_rib.c b/app/test/test_rib.c
index 06058f8f7c52..65b685641094 100644
--- a/app/test/test_rib.c
+++ b/app/test/test_rib.c
@@ -10,23 +10,6 @@
 #include <stdlib.h>
 
 #include <rte_ip.h>
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_rib(void)
-{
-	printf("rib not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-static int
-test_slow_rib(void)
-{
-	printf("slow_rib not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-#else
-
 #include <rte_rib.h>
 
 typedef int32_t (*rte_rib_test)(void);
@@ -380,7 +363,5 @@ test_slow_rib(void)
 	return unit_test_suite_runner(&rib_slow_tests);
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(rib_autotest, test_rib);
 REGISTER_TEST_COMMAND(rib_slow_autotest, test_slow_rib);
diff --git a/app/test/test_rib6.c b/app/test/test_rib6.c
index ba79aedea5f7..336b779d2e1e 100644
--- a/app/test/test_rib6.c
+++ b/app/test/test_rib6.c
@@ -3,32 +3,14 @@
  * Copyright(c) 2019 Intel Corporation
  */
 
-#include "test.h"
-
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
-
 #include <rte_ip.h>
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_rib6(void)
-{
-	printf("rib6 not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-static int
-test_slow_rib6(void)
-{
-	printf("slow_rib6 not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-#else
-
 #include <rte_rib6.h>
 
+#include "test.h"
+
 typedef int32_t (*rte_rib6_test)(void);
 
 static int32_t test_create_invalid(void);
@@ -385,7 +367,5 @@ test_slow_rib6(void)
 	return unit_test_suite_runner(&rib6_slow_tests);
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(rib6_autotest, test_rib6);
 REGISTER_TEST_COMMAND(rib6_slow_autotest, test_slow_rib6);
diff --git a/lib/rib/meson.build b/lib/rib/meson.build
index bda7f576e976..7bacbb453592 100644
--- a/lib/rib/meson.build
+++ b/lib/rib/meson.build
@@ -2,12 +2,6 @@
 # Copyright(c) 2018 Vladimir Medvedkin <medvedkinv@gmail.com>
 # Copyright(c) 2019 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_rib.c', 'rte_rib6.c')
 headers = files('rte_rib.h', 'rte_rib6.h')
 deps += ['mempool']
diff --git a/lib/rib/rte_rib.c b/lib/rib/rte_rib.c
index b0794edf66f5..812a2597d117 100644
--- a/lib/rib/rte_rib.c
+++ b/lib/rib/rte_rib.c
@@ -5,6 +5,7 @@
 
 #include <stdbool.h>
 #include <stdint.h>
+#include <sys/queue.h>
 
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
diff --git a/lib/rib/rte_rib6.c b/lib/rib/rte_rib6.c
index 19e4ff97c479..ae44281ae105 100644
--- a/lib/rib/rte_rib6.c
+++ b/lib/rib/rte_rib6.c
@@ -5,6 +5,7 @@
 
 #include <stdbool.h>
 #include <stdint.h>
+#include <sys/queue.h>
 
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
-- 
2.35.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH 7/8] fib: enable on Windows
  2022-12-01  1:44 [PATCH 0/8] Enable building more on Windows Stephen Hemminger
                   ` (5 preceding siblings ...)
  2022-12-01  1:44 ` [PATCH 6/8] rib: enable " Stephen Hemminger
@ 2022-12-01  1:44 ` Stephen Hemminger
  2022-12-01 23:54   ` Tyler Retzlaff
  2022-12-01  1:44 ` [PATCH 8/8] pcapng: windows compatability Stephen Hemminger
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 66+ messages in thread
From: Stephen Hemminger @ 2022-12-01  1:44 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Vladimir Medvedkin

The FIB library builds on Windows as long as sys/queue.h is defined.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_fib.c       | 22 +---------------------
 app/test/test_fib6.c      | 24 ++----------------------
 app/test/test_fib6_perf.c | 15 +--------------
 app/test/test_fib_perf.c  | 19 +++----------------
 lib/fib/meson.build       |  6 ------
 lib/fib/rte_fib.c         |  1 +
 lib/fib/rte_fib6.c        |  1 +
 7 files changed, 9 insertions(+), 79 deletions(-)

diff --git a/app/test/test_fib.c b/app/test/test_fib.c
index a2d1ea8f3abc..eb69d6e2fd4c 100644
--- a/app/test/test_fib.c
+++ b/app/test/test_fib.c
@@ -9,28 +9,10 @@
 
 #include <rte_ip.h>
 #include <rte_log.h>
+#include <rte_fib.h>
 
 #include "test.h"
 
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_fib(void)
-{
-	printf("fib not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-static int
-test_slow_fib(void)
-{
-	printf("slow_fib not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
-#include <rte_fib.h>
-
 typedef int32_t (*rte_fib_test)(void);
 
 static int32_t test_create_invalid(void);
@@ -433,7 +415,5 @@ test_slow_fib(void)
 	return unit_test_suite_runner(&fib_slow_tests);
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(fib_autotest, test_fib);
 REGISTER_TEST_COMMAND(fib_slow_autotest, test_slow_fib);
diff --git a/app/test/test_fib6.c b/app/test/test_fib6.c
index cd971e6ecdfb..15ad09178ae2 100644
--- a/app/test/test_fib6.c
+++ b/app/test/test_fib6.c
@@ -9,29 +9,11 @@
 
 #include <rte_memory.h>
 #include <rte_log.h>
-
-#include "test.h"
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_fib6(void)
-{
-	printf("fib not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-static int
-test_slow_fib6(void)
-{
-	printf("slow_fib not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
 #include <rte_rib6.h>
 #include <rte_fib6.h>
 
+#include "test.h"
+
 typedef int32_t (*rte_fib6_test)(void);
 
 static int32_t test_create_invalid(void);
@@ -442,7 +424,5 @@ test_slow_fib6(void)
 	return unit_test_suite_runner(&fib6_slow_tests);
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(fib6_autotest, test_fib6);
 REGISTER_TEST_COMMAND(fib6_slow_autotest, test_slow_fib6);
diff --git a/app/test/test_fib6_perf.c b/app/test/test_fib6_perf.c
index 21d2b65318e9..add20c2331b1 100644
--- a/app/test/test_fib6_perf.c
+++ b/app/test/test_fib6_perf.c
@@ -10,21 +10,10 @@
 #include <rte_cycles.h>
 #include <rte_random.h>
 #include <rte_memory.h>
+#include <rte_fib6.h>
 
 #include "test.h"
 
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_fib6_perf(void)
-{
-	printf("fib6_perf not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
-#include <rte_fib6.h>
-
 #include "test_lpm6_data.h"
 
 #define TEST_FIB_ASSERT(cond) do {				\
@@ -167,6 +156,4 @@ test_fib6_perf(void)
 	return 0;
 }
 
-#endif /*ifdef RTE_EXEC_ENV_WINDOWS*/
-
 REGISTER_TEST_COMMAND(fib6_perf_autotest, test_fib6_perf);
diff --git a/app/test/test_fib_perf.c b/app/test/test_fib_perf.c
index 9787874cc9b7..b56293e64f41 100644
--- a/app/test/test_fib_perf.c
+++ b/app/test/test_fib_perf.c
@@ -12,22 +12,11 @@
 #include <rte_random.h>
 #include <rte_branch_prediction.h>
 #include <rte_ip.h>
+#include <rte_fib.h>
 
 #include "test.h"
 #include "test_xmmt_ops.h"
 
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_fib_perf(void)
-{
-	printf("fib_perf not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
-#include <rte_fib.h>
-
 #define TEST_FIB_ASSERT(cond) do {				\
 	if (!(cond)) {						\
 		printf("Error at line %d:\n", __LINE__);	\
@@ -246,7 +235,7 @@ static void generate_random_rule_prefix(uint32_t ip_class, uint8_t depth)
 	/* Only generate rest bits except the most significant
 	 * fixed bits for IP address class
 	 */
-	start = lrand48() & mask;
+	start = rte_rand() & mask;
 	ptr_rule = &large_route_table[num_route_entries];
 	for (k = 0; k < rule_num; k++) {
 		ptr_rule->ip = (start << (RTE_FIB_MAX_DEPTH - depth))
@@ -265,7 +254,7 @@ static void insert_rule_in_random_pos(uint32_t ip, uint8_t depth)
 	struct route_rule tmp;
 
 	do {
-		pos = lrand48();
+		pos = rte_rand();
 		try_count++;
 	} while ((try_count < 10) && (pos > num_route_entries));
 
@@ -420,6 +409,4 @@ test_fib_perf(void)
 	return 0;
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(fib_perf_autotest, test_fib_perf);
diff --git a/lib/fib/meson.build b/lib/fib/meson.build
index 9b848d08417c..ddcae0617a73 100644
--- a/lib/fib/meson.build
+++ b/lib/fib/meson.build
@@ -2,12 +2,6 @@
 # Copyright(c) 2018 Vladimir Medvedkin <medvedkinv@gmail.com>
 # Copyright(c) 2019 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_fib.c', 'rte_fib6.c', 'dir24_8.c', 'trie.c')
 headers = files('rte_fib.h', 'rte_fib6.h')
 deps += ['rib']
diff --git a/lib/fib/rte_fib.c b/lib/fib/rte_fib.c
index 8af4c4091908..0c3b20e00a5a 100644
--- a/lib/fib/rte_fib.c
+++ b/lib/fib/rte_fib.c
@@ -5,6 +5,7 @@
 
 #include <stdint.h>
 #include <string.h>
+#include <sys/queue.h>
 
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
diff --git a/lib/fib/rte_fib6.c b/lib/fib/rte_fib6.c
index 4b8e22b142b9..28c69b38999f 100644
--- a/lib/fib/rte_fib6.c
+++ b/lib/fib/rte_fib6.c
@@ -5,6 +5,7 @@
 
 #include <stdint.h>
 #include <string.h>
+#include <sys/queue.h>
 
 #include <rte_eal_memconfig.h>
 #include <rte_tailq.h>
-- 
2.35.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH 8/8] pcapng: windows compatability
  2022-12-01  1:44 [PATCH 0/8] Enable building more on Windows Stephen Hemminger
                   ` (6 preceding siblings ...)
  2022-12-01  1:44 ` [PATCH 7/8] fib: " Stephen Hemminger
@ 2022-12-01  1:44 ` Stephen Hemminger
  2022-12-01 23:55   ` Tyler Retzlaff
  2023-02-07  0:19 ` [PATCH v2 0/8] Enable building more libraries on Windows Stephen Hemminger
  2023-03-09 21:31 ` [PATCH v5 " Stephen Hemminger
  9 siblings, 1 reply; 66+ messages in thread
From: Stephen Hemminger @ 2022-12-01  1:44 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Reshma Pattan

Allow building on Windows, need to provide some compatability
wrappers for writev() and if_nametoindex.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/pcapng/meson.build  |  6 -----
 lib/pcapng/rte_pcapng.c | 59 +++++++++++++++++++++++++++++++++++++++--
 2 files changed, 57 insertions(+), 8 deletions(-)

diff --git a/lib/pcapng/meson.build b/lib/pcapng/meson.build
index da938bbcb733..4549925d41b6 100644
--- a/lib/pcapng/meson.build
+++ b/lib/pcapng/meson.build
@@ -1,12 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2019 Microsoft Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_pcapng.c')
 headers = files('rte_pcapng.h')
 
diff --git a/lib/pcapng/rte_pcapng.c b/lib/pcapng/rte_pcapng.c
index 80d08e1a3bde..888f8b84cd97 100644
--- a/lib/pcapng/rte_pcapng.c
+++ b/lib/pcapng/rte_pcapng.c
@@ -3,15 +3,18 @@
  */
 
 #include <errno.h>
-#include <net/if.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/uio.h>
 #include <time.h>
 #include <unistd.h>
 
+#ifndef RTE_EXEC_ENV_WINDOWS
+#include <net/if.h>
+#include <sys/uio.h>
+#endif
+
 #include <bus_driver.h>
 #include <rte_common.h>
 #include <rte_cycles.h>
@@ -20,6 +23,7 @@
 #include <rte_ethdev.h>
 #include <rte_ether.h>
 #include <rte_mbuf.h>
+#include <rte_os_shim.h>
 #include <rte_pcapng.h>
 #include <rte_reciprocal.h>
 #include <rte_time.h>
@@ -44,6 +48,57 @@ static struct pcapng_time {
 	struct rte_reciprocal_u64 tsc_hz_inverse;
 } pcapng_time;
 
+
+#ifdef RTE_EXEC_ENV_WINDOWS
+/*
+ * Windows does not have writev() call.
+ * Emulate this by copying to a new buffer.
+ * The copy is necessary since pcapng needs to be thread-safe
+ * and do atomic write operations.
+ */
+
+#define IOV_MAX 128
+struct iovec {
+	void   *iov_base;
+	size_t  iov_len;
+};
+
+static ssize_t writev(int fd, const struct iovec *iov, int iovcnt)
+{
+	size_t bytes = 0;
+	uint8_t *ptr;
+	void *tmp_buf;
+	ssize_t ret;
+	int i;
+
+	for (i = 0; i < iovcnt; i++)
+		bytes += iov[i].iov_len;
+
+	if (unlikely(bytes == 0))
+		return 0;
+
+	tmp_buf = malloc(bytes);
+	if (unlikely(tmp_buf == NULL)) {
+		errno = ENOMEM;
+		return -1;
+	}
+
+	ptr = tmp_buf;
+	for (i = 0; i < iovcnt; i++) {
+		rte_memcpy(ptr, iov[i].iov_base, iov[i].iov_len);
+		ptr += iov[i].iov_len;
+	}
+
+	ret = write(fd, tmp_buf, bytes);
+	free(tmp_buf);
+	return ret;
+}
+
+#define IF_NAMESIZE	16
+/* compatiablity wrapper because name is optional */
+#define if_indextoname(ifindex, ifname) NULL
+#endif
+
 static inline void
 pcapng_init(void)
 {
-- 
2.35.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH 1/8] net/null: build null PMD on Windows
  2022-12-01  1:44 ` [PATCH 1/8] net/null: build null PMD " Stephen Hemminger
@ 2022-12-01 23:51   ` Tyler Retzlaff
  0 siblings, 0 replies; 66+ messages in thread
From: Tyler Retzlaff @ 2022-12-01 23:51 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, Tetsuya Mukawa

On Wed, Nov 30, 2022 at 05:44:32PM -0800, Stephen Hemminger wrote:
> Builds fine with current code, no changes needed.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---

Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH 2/8] net/ring: build on Windows
  2022-12-01  1:44 ` [PATCH 2/8] net/ring: build " Stephen Hemminger
@ 2022-12-01 23:52   ` Tyler Retzlaff
  2022-12-14 23:18   ` Kadam, Pallavi
  1 sibling, 0 replies; 66+ messages in thread
From: Tyler Retzlaff @ 2022-12-01 23:52 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, Bruce Richardson

On Wed, Nov 30, 2022 at 05:44:33PM -0800, Stephen Hemminger wrote:
> This driver builds ok on windows, but need to modify the
> test meson build to skip the eventdev test on Windows.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---

Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH 3/8] lpm: enable on Windows
  2022-12-01  1:44 ` [PATCH 3/8] lpm: enable " Stephen Hemminger
@ 2022-12-01 23:53   ` Tyler Retzlaff
  0 siblings, 0 replies; 66+ messages in thread
From: Tyler Retzlaff @ 2022-12-01 23:53 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, Bruce Richardson, Vladimir Medvedkin

On Wed, Nov 30, 2022 at 05:44:34PM -0800, Stephen Hemminger wrote:
> This builds on Windows without changes.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---

Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH 4/8] reorder: build on Windows
  2022-12-01  1:44 ` [PATCH 4/8] reorder: build " Stephen Hemminger
@ 2022-12-01 23:53   ` Tyler Retzlaff
  0 siblings, 0 replies; 66+ messages in thread
From: Tyler Retzlaff @ 2022-12-01 23:53 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, Reshma Pattan

On Wed, Nov 30, 2022 at 05:44:35PM -0800, Stephen Hemminger wrote:
> This builds on Windows if sys/queue.h is included.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---

Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH 5/8] ip_frag: enable build on Windows
  2022-12-01  1:44 ` [PATCH 5/8] ip_frag: enable " Stephen Hemminger
@ 2022-12-01 23:54   ` Tyler Retzlaff
  0 siblings, 0 replies; 66+ messages in thread
From: Tyler Retzlaff @ 2022-12-01 23:54 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, Konstantin Ananyev

On Wed, Nov 30, 2022 at 05:44:36PM -0800, Stephen Hemminger wrote:
> This build works on Windows if sys/queue.h is included.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---

Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH 6/8] rib: enable on Windows
  2022-12-01  1:44 ` [PATCH 6/8] rib: enable " Stephen Hemminger
@ 2022-12-01 23:54   ` Tyler Retzlaff
  0 siblings, 0 replies; 66+ messages in thread
From: Tyler Retzlaff @ 2022-12-01 23:54 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, Vladimir Medvedkin

On Wed, Nov 30, 2022 at 05:44:37PM -0800, Stephen Hemminger wrote:
> The RIB library builds on Windows as long as sys/queue.h is included
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---

Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH 7/8] fib: enable on Windows
  2022-12-01  1:44 ` [PATCH 7/8] fib: " Stephen Hemminger
@ 2022-12-01 23:54   ` Tyler Retzlaff
  0 siblings, 0 replies; 66+ messages in thread
From: Tyler Retzlaff @ 2022-12-01 23:54 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, Vladimir Medvedkin

On Wed, Nov 30, 2022 at 05:44:38PM -0800, Stephen Hemminger wrote:
> The FIB library builds on Windows as long as sys/queue.h is defined.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---

Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH 8/8] pcapng: windows compatability
  2022-12-01  1:44 ` [PATCH 8/8] pcapng: windows compatability Stephen Hemminger
@ 2022-12-01 23:55   ` Tyler Retzlaff
  0 siblings, 0 replies; 66+ messages in thread
From: Tyler Retzlaff @ 2022-12-01 23:55 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, Reshma Pattan

On Wed, Nov 30, 2022 at 05:44:39PM -0800, Stephen Hemminger wrote:
> Allow building on Windows, need to provide some compatability
> wrappers for writev() and if_nametoindex.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---

Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH 2/8] net/ring: build on Windows
  2022-12-01  1:44 ` [PATCH 2/8] net/ring: build " Stephen Hemminger
  2022-12-01 23:52   ` Tyler Retzlaff
@ 2022-12-14 23:18   ` Kadam, Pallavi
  2022-12-15  3:22     ` Stephen Hemminger
  1 sibling, 1 reply; 66+ messages in thread
From: Kadam, Pallavi @ 2022-12-14 23:18 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: Bruce Richardson

[-- Attachment #1: Type: text/plain, Size: 551 bytes --]

Hi Stephen,

Thanks for enabling this support.

On 11/30/2022 5:44 PM, Stephen Hemminger wrote:
> This driver builds ok on windows, but need to modify the
> test meson build to skip the eventdev test on Windows.
>
> Signed-off-by: Stephen Hemminger<stephen@networkplumber.org>
> ---

There is still a build error with clang compiler on Windows
as mentioned by Dmitry:

../drivers/net/ring/rte_eth_ring.c:542:12: error: use of undeclared identifier 'PATH_MAX'
         char name[PATH_MAX];
                   ^
#include <rte_os_shim.h> is missing

>   

[-- Attachment #2: Type: text/html, Size: 36617 bytes --]

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH 2/8] net/ring: build on Windows
  2022-12-14 23:18   ` Kadam, Pallavi
@ 2022-12-15  3:22     ` Stephen Hemminger
  2022-12-15 17:48       ` Tyler Retzlaff
  0 siblings, 1 reply; 66+ messages in thread
From: Stephen Hemminger @ 2022-12-15  3:22 UTC (permalink / raw)
  To: Kadam, Pallavi; +Cc: dev, Bruce Richardson

On Wed, 14 Dec 2022 15:18:08 -0800
"Kadam, Pallavi" <pallavi.kadam@intel.com> wrote:

> Hi Stephen,
> 
> Thanks for enabling this support.
> 
> On 11/30/2022 5:44 PM, Stephen Hemminger wrote:
> > This driver builds ok on windows, but need to modify the
> > test meson build to skip the eventdev test on Windows.
> >
> > Signed-off-by: Stephen Hemminger<stephen@networkplumber.org>
> > ---  
> 
> There is still a build error with clang compiler on Windows
> as mentioned by Dmitry:
> 
> ../drivers/net/ring/rte_eth_ring.c:542:12: error: use of undeclared identifier 'PATH_MAX'
>          char name[PATH_MAX];
>                    ^
> #include <rte_os_shim.h> is missing
> 
> >     

It is in the mingw version but not other compilers.

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH 2/8] net/ring: build on Windows
  2022-12-15  3:22     ` Stephen Hemminger
@ 2022-12-15 17:48       ` Tyler Retzlaff
  2022-12-15 18:09         ` Dmitry Kozlyuk
  0 siblings, 1 reply; 66+ messages in thread
From: Tyler Retzlaff @ 2022-12-15 17:48 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Kadam, Pallavi, dev, Bruce Richardson

On Wed, Dec 14, 2022 at 07:22:15PM -0800, Stephen Hemminger wrote:
> On Wed, 14 Dec 2022 15:18:08 -0800
> "Kadam, Pallavi" <pallavi.kadam@intel.com> wrote:
> 
> > Hi Stephen,
> > 
> > Thanks for enabling this support.
> > 
> > On 11/30/2022 5:44 PM, Stephen Hemminger wrote:
> > > This driver builds ok on windows, but need to modify the
> > > test meson build to skip the eventdev test on Windows.
> > >
> > > Signed-off-by: Stephen Hemminger<stephen@networkplumber.org>
> > > ---  
> > 
> > There is still a build error with clang compiler on Windows
> > as mentioned by Dmitry:
> > 
> > ../drivers/net/ring/rte_eth_ring.c:542:12: error: use of undeclared identifier 'PATH_MAX'
> >          char name[PATH_MAX];
> >                    ^
> > #include <rte_os_shim.h> is missing
> > 
> > >     
> 
> It is in the mingw version but not other compilers.

not sure if it helps but in the sludge of my memory i think you can use
MAX_PATH.

so maybe a little 
#ifndef PATH_MAX
#define PATH_MAX MAX_PATH
#endif

in the os shim?

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH 2/8] net/ring: build on Windows
  2022-12-15 17:48       ` Tyler Retzlaff
@ 2022-12-15 18:09         ` Dmitry Kozlyuk
  0 siblings, 0 replies; 66+ messages in thread
From: Dmitry Kozlyuk @ 2022-12-15 18:09 UTC (permalink / raw)
  To: Tyler Retzlaff; +Cc: Stephen Hemminger, Kadam, Pallavi, dev, Bruce Richardson

2022-12-15 09:48 (UTC-0800), Tyler Retzlaff:
> On Wed, Dec 14, 2022 at 07:22:15PM -0800, Stephen Hemminger wrote:
> > On Wed, 14 Dec 2022 15:18:08 -0800
> > "Kadam, Pallavi" <pallavi.kadam@intel.com> wrote:
[...]
> > > There is still a build error with clang compiler on Windows
> > > as mentioned by Dmitry:
> > > 
> > > ../drivers/net/ring/rte_eth_ring.c:542:12: error: use of undeclared identifier 'PATH_MAX'
> > >          char name[PATH_MAX];
> > >                    ^
> > > #include <rte_os_shim.h> is missing
> > >   
> > > >       
> > 
> > It is in the mingw version but not other compilers.  
> 
> not sure if it helps but in the sludge of my memory i think you can use
> MAX_PATH.
> 
> so maybe a little 
> #ifndef PATH_MAX
> #define PATH_MAX MAX_PATH
> #endif
> 
> in the os shim?

It is in rte_os_shim.h already (for MinGW), just needs to be included.

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 0/8] Enable building more libraries on Windows
  2022-12-01  1:44 [PATCH 0/8] Enable building more on Windows Stephen Hemminger
                   ` (7 preceding siblings ...)
  2022-12-01  1:44 ` [PATCH 8/8] pcapng: windows compatability Stephen Hemminger
@ 2023-02-07  0:19 ` Stephen Hemminger
  2023-02-07  0:19   ` [PATCH v2 1/8] net/null: build null PMD " Stephen Hemminger
                     ` (10 more replies)
  2023-03-09 21:31 ` [PATCH v5 " Stephen Hemminger
  9 siblings, 11 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-02-07  0:19 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

While diagnosing some Windows cross build errors;
noticed that lots of important DPDK libraries are not
being built on Windows.

Stephen Hemminger (8):
  net/null: build null PMD on Windows
  net/ring: build on Windows
  lpm: enable on Windows
  reorder: build on Windows
  ip_frag: enable build on Windows
  rib: enable on Windows
  fib: enable on Windows
  pcapng: windows compatibility

v2 - fix unnecessary PATH_MAX in net/ring driver

 app/test/meson.build            |  2 +-
 app/test/test_fib.c             | 22 +-----------
 app/test/test_fib6.c            | 24 ++------------
 app/test/test_fib6_perf.c       | 15 +--------
 app/test/test_fib_perf.c        | 19 ++---------
 app/test/test_ipfrag.c          | 12 -------
 app/test/test_lpm.c             | 15 +--------
 app/test/test_lpm6.c            | 12 -------
 app/test/test_lpm6_data.h       |  3 +-
 app/test/test_lpm6_perf.c       | 14 +-------
 app/test/test_lpm_perf.c        | 39 +++++++---------------
 app/test/test_reorder.c         | 11 ------
 app/test/test_rib.c             | 19 -----------
 app/test/test_rib6.c            | 24 ++------------
 drivers/net/null/meson.build    |  6 ----
 drivers/net/ring/meson.build    |  6 ----
 drivers/net/ring/rte_eth_ring.c |  3 +-
 lib/fib/meson.build             |  6 ----
 lib/fib/rte_fib.c               |  1 +
 lib/fib/rte_fib6.c              |  1 +
 lib/ip_frag/ip_frag_common.h    |  2 ++
 lib/ip_frag/meson.build         |  6 ----
 lib/lpm/meson.build             |  6 ----
 lib/pcapng/meson.build          |  6 ----
 lib/pcapng/rte_pcapng.c         | 59 +++++++++++++++++++++++++++++++--
 lib/reorder/meson.build         |  6 ----
 lib/reorder/rte_reorder.c       |  1 +
 lib/rib/meson.build             |  6 ----
 lib/rib/rte_rib.c               |  1 +
 lib/rib/rte_rib6.c              |  1 +
 30 files changed, 92 insertions(+), 256 deletions(-)

-- 
2.39.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 1/8] net/null: build null PMD on Windows
  2023-02-07  0:19 ` [PATCH v2 0/8] Enable building more libraries on Windows Stephen Hemminger
@ 2023-02-07  0:19   ` Stephen Hemminger
  2023-02-07  0:19   ` [PATCH v2 2/8] net/ring: build " Stephen Hemminger
                     ` (9 subsequent siblings)
  10 siblings, 0 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-02-07  0:19 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tyler Retzlaff, Tetsuya Mukawa

Builds fine with current code, no changes needed.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 drivers/net/null/meson.build | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/net/null/meson.build b/drivers/net/null/meson.build
index 4a483955a7a9..a51f8f5211b0 100644
--- a/drivers/net/null/meson.build
+++ b/drivers/net/null/meson.build
@@ -1,11 +1,5 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_eth_null.c')
 pmd_supports_disable_iova_as_pa = true
-- 
2.39.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 2/8] net/ring: build on Windows
  2023-02-07  0:19 ` [PATCH v2 0/8] Enable building more libraries on Windows Stephen Hemminger
  2023-02-07  0:19   ` [PATCH v2 1/8] net/null: build null PMD " Stephen Hemminger
@ 2023-02-07  0:19   ` Stephen Hemminger
  2023-02-07  0:19   ` [PATCH v2 3/8] lpm: enable " Stephen Hemminger
                     ` (8 subsequent siblings)
  10 siblings, 0 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-02-07  0:19 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tyler Retzlaff, Bruce Richardson

The command line arguments are stored in node_action_pair
and the name[] was sized to PATH_MAX which does not exist on Windows.
Since the name is either "CREATE" or "ATTACH" it is not
related to PATH_MAX (4096).

With this fix driver builds ok on windows, but need to modify the
test meson build to skip the eventdev test on Windows.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 app/test/meson.build            | 2 +-
 drivers/net/ring/meson.build    | 6 ------
 drivers/net/ring/rte_eth_ring.c | 3 ++-
 3 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/app/test/meson.build b/app/test/meson.build
index f34d19e3c3cb..a713f0382280 100644
--- a/app/test/meson.build
+++ b/app/test/meson.build
@@ -390,7 +390,7 @@ if dpdk_conf.has('RTE_NET_BOND')
         driver_test_names += 'link_bonding_mode4_autotest'
     endif
 endif
-if dpdk_conf.has('RTE_NET_RING')
+if dpdk_conf.has('RTE_LIB_EVENTDEV') and dpdk_conf.has('RTE_NET_RING')
     test_deps += 'net_ring'
     test_sources += 'test_pmd_ring_perf.c'
     test_sources += 'test_pmd_ring.c'
diff --git a/drivers/net/ring/meson.build b/drivers/net/ring/meson.build
index 72792e26b05a..3534a3cc2287 100644
--- a/drivers/net/ring/meson.build
+++ b/drivers/net/ring/meson.build
@@ -1,12 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_eth_ring.c')
 headers = files('rte_eth_ring.h')
 pmd_supports_disable_iova_as_pa = true
diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index bd5a47dd9017..564d6a726403 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -17,6 +17,7 @@
 #define ETH_RING_NUMA_NODE_ACTION_ARG	"nodeaction"
 #define ETH_RING_ACTION_CREATE		"CREATE"
 #define ETH_RING_ACTION_ATTACH		"ATTACH"
+#define ETH_RING_ACTION_MAX_LEN		8 /* CREATE | ACTION */
 #define ETH_RING_INTERNAL_ARG		"internal"
 #define ETH_RING_INTERNAL_ARG_MAX_LEN	19 /* "0x..16chars..\0" */
 
@@ -539,7 +540,7 @@ eth_dev_ring_create(const char *name,
 }
 
 struct node_action_pair {
-	char name[PATH_MAX];
+	char name[ETH_RING_ACTION_MAX_LEN];
 	unsigned int node;
 	enum dev_action action;
 };
-- 
2.39.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 3/8] lpm: enable on Windows
  2023-02-07  0:19 ` [PATCH v2 0/8] Enable building more libraries on Windows Stephen Hemminger
  2023-02-07  0:19   ` [PATCH v2 1/8] net/null: build null PMD " Stephen Hemminger
  2023-02-07  0:19   ` [PATCH v2 2/8] net/ring: build " Stephen Hemminger
@ 2023-02-07  0:19   ` Stephen Hemminger
  2023-02-07  0:19   ` [PATCH v2 4/8] reorder: build " Stephen Hemminger
                     ` (7 subsequent siblings)
  10 siblings, 0 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-02-07  0:19 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Tyler Retzlaff, Bruce Richardson, Vladimir Medvedkin

This builds on Windows without changes.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 app/test/test_lpm.c       | 15 +--------------
 app/test/test_lpm6.c      | 12 ------------
 app/test/test_lpm6_data.h |  3 ++-
 app/test/test_lpm6_perf.c | 14 +-------------
 app/test/test_lpm_perf.c  | 39 ++++++++++++---------------------------
 lib/lpm/meson.build       |  6 ------
 6 files changed, 16 insertions(+), 73 deletions(-)

diff --git a/app/test/test_lpm.c b/app/test/test_lpm.c
index bceb9ae743d7..37b460af3a96 100644
--- a/app/test/test_lpm.c
+++ b/app/test/test_lpm.c
@@ -2,18 +2,6 @@
  * Copyright(c) 2010-2014 Intel Corporation
  */
 
-#include "test.h"
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_lpm(void)
-{
-	printf("lpm not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
@@ -22,6 +10,7 @@ test_lpm(void)
 #include <rte_lpm.h>
 #include <rte_malloc.h>
 
+#include "test.h"
 #include "test_xmmt_ops.h"
 
 #define TEST_LPM_ASSERT(cond) do {                                            \
@@ -1595,6 +1584,4 @@ test_lpm(void)
 	return global_status;
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(lpm_autotest, test_lpm);
diff --git a/app/test/test_lpm6.c b/app/test/test_lpm6.c
index 1f44392db739..b6b6f8615ea5 100644
--- a/app/test/test_lpm6.c
+++ b/app/test/test_lpm6.c
@@ -10,16 +10,6 @@
 #include <string.h>
 
 #include <rte_memory.h>
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_lpm6(void)
-{
-	printf("lpm6 not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
 #include <rte_lpm6.h>
 
 #include "test_lpm6_data.h"
@@ -1803,6 +1793,4 @@ test_lpm6(void)
 	return global_status;
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(lpm6_autotest, test_lpm6);
diff --git a/app/test/test_lpm6_data.h b/app/test/test_lpm6_data.h
index da9b161f20e5..3a1fa25f8433 100644
--- a/app/test/test_lpm6_data.h
+++ b/app/test/test_lpm6_data.h
@@ -6,6 +6,7 @@
 
 #include <stdint.h>
 #include <stdlib.h>
+#include <rte_random.h>
 
 struct rules_tbl_entry {
 	uint8_t ip[16];
@@ -1129,7 +1130,7 @@ static void generate_large_ips_table(int gen_expected_next_hop)
 
 	for (i = 0; i < NUM_IPS_ENTRIES; i++) {
 		for (j = 0; j < 16; j++)
-			large_ips_table[i].ip[j] = lrand48();
+			large_ips_table[i].ip[j] = rte_rand();
 	}
 
 	for (k = j = 0, i = 0; i < NUM_IPS_ENTRIES; i++) {
diff --git a/app/test/test_lpm6_perf.c b/app/test/test_lpm6_perf.c
index aaf2773b6fac..5b684686a687 100644
--- a/app/test/test_lpm6_perf.c
+++ b/app/test/test_lpm6_perf.c
@@ -2,17 +2,6 @@
  * Copyright(c) 2010-2014 Intel Corporation
  */
 
-#include "test.h"
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_lpm6_perf(void)
-{
-	printf("lpm6_perf not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
 
 #include <stdio.h>
 #include <stdint.h>
@@ -24,6 +13,7 @@ test_lpm6_perf(void)
 #include <rte_memory.h>
 #include <rte_lpm6.h>
 
+#include "test.h"
 #include "test_lpm6_data.h"
 
 #define TEST_LPM_ASSERT(cond) do {                                            \
@@ -171,6 +161,4 @@ test_lpm6_perf(void)
 	return 0;
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(lpm6_perf_autotest, test_lpm6_perf);
diff --git a/app/test/test_lpm_perf.c b/app/test/test_lpm_perf.c
index e858716f909b..e72437ba3850 100644
--- a/app/test/test_lpm_perf.c
+++ b/app/test/test_lpm_perf.c
@@ -3,17 +3,6 @@
  * Copyright(c) 2020 Arm Limited
  */
 
-#include "test.h"
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_lpm_perf(void)
-{
-	printf("lpm_perf not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
@@ -25,7 +14,9 @@ test_lpm_perf(void)
 #include <rte_malloc.h>
 #include <rte_ip.h>
 #include <rte_lpm.h>
+#include <rte_spinlock.h>
 
+#include "test.h"
 #include "test_xmmt_ops.h"
 
 struct rte_lpm *lpm;
@@ -34,8 +25,9 @@ static volatile uint8_t writer_done;
 static volatile uint32_t thr_id;
 static uint64_t gwrite_cycles;
 static uint32_t num_writers;
-/* LPM APIs are not thread safe, use mutex to provide thread safety */
-static pthread_mutex_t lpm_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+/* LPM APIs are not thread safe, use spinlock */
+static rte_spinlock_t lpm_lock = RTE_SPINLOCK_INITIALIZER;
 
 /* Report quiescent state interval every 1024 lookups. Larger critical
  * sections in reader will result in writer polling multiple times.
@@ -267,7 +259,7 @@ static void generate_random_rule_prefix(uint32_t ip_class, uint8_t depth)
 	/* Only generate rest bits except the most significant
 	 * fixed bits for IP address class
 	 */
-	start = lrand48() & mask;
+	start = rte_rand() & mask;
 	ptr_rule = &large_route_table[num_route_entries];
 	ptr_ldepth_rule = &large_ldepth_route_table[num_ldepth_route_entries];
 	for (k = 0; k < rule_num; k++) {
@@ -296,7 +288,7 @@ static void insert_rule_in_random_pos(uint32_t ip, uint8_t depth)
 	struct route_rule tmp;
 
 	do {
-		pos = lrand48();
+		pos = rte_rand();
 		try_count++;
 	} while ((try_count < 10) && (pos > num_route_entries));
 
@@ -452,8 +444,7 @@ test_lpm_rcu_qsbr_writer(void *arg)
 	for (i = 0; i < RCU_ITERATIONS; i++) {
 		/* Add all the entries */
 		for (j = si; j < ei; j++) {
-			if (num_writers > 1)
-				pthread_mutex_lock(&lpm_mutex);
+			rte_spinlock_lock(&lpm_lock);
 			if (rte_lpm_add(lpm, large_ldepth_route_table[j].ip,
 					large_ldepth_route_table[j].depth,
 					next_hop_add) != 0) {
@@ -461,22 +452,19 @@ test_lpm_rcu_qsbr_writer(void *arg)
 					i, j);
 				goto error;
 			}
-			if (num_writers > 1)
-				pthread_mutex_unlock(&lpm_mutex);
+			rte_spinlock_unlock(&lpm_lock);
 		}
 
 		/* Delete all the entries */
 		for (j = si; j < ei; j++) {
-			if (num_writers > 1)
-				pthread_mutex_lock(&lpm_mutex);
+			rte_spinlock_lock(&lpm_lock);
 			if (rte_lpm_delete(lpm, large_ldepth_route_table[j].ip,
 				large_ldepth_route_table[j].depth) != 0) {
 				printf("Failed to delete iteration %d, route# %d\n",
 					i, j);
 				goto error;
 			}
-			if (num_writers > 1)
-				pthread_mutex_unlock(&lpm_mutex);
+			rte_spinlock_unlock(&lpm_lock);
 		}
 	}
 
@@ -487,8 +475,7 @@ test_lpm_rcu_qsbr_writer(void *arg)
 	return 0;
 
 error:
-	if (num_writers > 1)
-		pthread_mutex_unlock(&lpm_mutex);
+	rte_spinlock_unlock(&lpm_lock);
 	return -1;
 }
 
@@ -773,6 +760,4 @@ test_lpm_perf(void)
 	return 0;
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(lpm_perf_autotest, test_lpm_perf);
diff --git a/lib/lpm/meson.build b/lib/lpm/meson.build
index 6b47361fcec0..4cd48886fc41 100644
--- a/lib/lpm/meson.build
+++ b/lib/lpm/meson.build
@@ -1,12 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_lpm.c', 'rte_lpm6.c')
 headers = files('rte_lpm.h', 'rte_lpm6.h')
 # since header files have different names, we can install all vector headers
-- 
2.39.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 4/8] reorder: build on Windows
  2023-02-07  0:19 ` [PATCH v2 0/8] Enable building more libraries on Windows Stephen Hemminger
                     ` (2 preceding siblings ...)
  2023-02-07  0:19   ` [PATCH v2 3/8] lpm: enable " Stephen Hemminger
@ 2023-02-07  0:19   ` Stephen Hemminger
  2023-02-07  0:19   ` [PATCH v2 5/8] ip_frag: enable " Stephen Hemminger
                     ` (6 subsequent siblings)
  10 siblings, 0 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-02-07  0:19 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tyler Retzlaff, Reshma Pattan

This builds on Windows if sys/queue.h is included.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 app/test/test_reorder.c   | 11 -----------
 lib/reorder/meson.build   |  6 ------
 lib/reorder/rte_reorder.c |  1 +
 3 files changed, 1 insertion(+), 17 deletions(-)

diff --git a/app/test/test_reorder.c b/app/test/test_reorder.c
index f0714a5c18a3..9ebd91477536 100644
--- a/app/test/test_reorder.c
+++ b/app/test/test_reorder.c
@@ -11,16 +11,6 @@
 #include <rte_cycles.h>
 #include <rte_errno.h>
 #include <rte_mbuf.h>
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_reorder(void)
-{
-	printf("reorder not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-#else
-
 #include <rte_reorder.h>
 #include <rte_lcore.h>
 #include <rte_malloc.h>
@@ -395,6 +385,5 @@ test_reorder(void)
 	return unit_test_suite_runner(&reorder_test_suite);
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
 
 REGISTER_TEST_COMMAND(reorder_autotest, test_reorder);
diff --git a/lib/reorder/meson.build b/lib/reorder/meson.build
index 621c1f350103..03aed53d9007 100644
--- a/lib/reorder/meson.build
+++ b/lib/reorder/meson.build
@@ -1,12 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_reorder.c')
 headers = files('rte_reorder.h')
 deps += ['mbuf']
diff --git a/lib/reorder/rte_reorder.c b/lib/reorder/rte_reorder.c
index 385ee479da42..00e2cf043e04 100644
--- a/lib/reorder/rte_reorder.c
+++ b/lib/reorder/rte_reorder.c
@@ -3,6 +3,7 @@
  */
 
 #include <string.h>
+#include <sys/queue.h>
 
 #include <rte_string_fns.h>
 #include <rte_log.h>
-- 
2.39.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 5/8] ip_frag: enable build on Windows
  2023-02-07  0:19 ` [PATCH v2 0/8] Enable building more libraries on Windows Stephen Hemminger
                     ` (3 preceding siblings ...)
  2023-02-07  0:19   ` [PATCH v2 4/8] reorder: build " Stephen Hemminger
@ 2023-02-07  0:19   ` Stephen Hemminger
  2023-02-07  0:19   ` [PATCH v2 6/8] rib: enable " Stephen Hemminger
                     ` (5 subsequent siblings)
  10 siblings, 0 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-02-07  0:19 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tyler Retzlaff, Konstantin Ananyev

This build works on Windows if sys/queue.h is included.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 app/test/test_ipfrag.c       | 12 ------------
 lib/ip_frag/ip_frag_common.h |  2 ++
 lib/ip_frag/meson.build      |  6 ------
 3 files changed, 2 insertions(+), 18 deletions(-)

diff --git a/app/test/test_ipfrag.c b/app/test/test_ipfrag.c
index 88cc4cdeea8d..402ce361c1a2 100644
--- a/app/test/test_ipfrag.c
+++ b/app/test/test_ipfrag.c
@@ -10,17 +10,6 @@
 #include <rte_cycles.h>
 #include <rte_hexdump.h>
 #include <rte_ip.h>
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_ipfrag(void)
-{
-	printf("ipfrag not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
 #include <rte_ip_frag.h>
 #include <rte_mbuf.h>
 #include <rte_random.h>
@@ -520,6 +509,5 @@ test_ipfrag(void)
 	return unit_test_suite_runner(&ipfrag_testsuite);
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
 
 REGISTER_TEST_COMMAND(ipfrag_autotest, test_ipfrag);
diff --git a/lib/ip_frag/ip_frag_common.h b/lib/ip_frag/ip_frag_common.h
index 9c0dbdeb6eb9..0f4ad72a90d9 100644
--- a/lib/ip_frag/ip_frag_common.h
+++ b/lib/ip_frag/ip_frag_common.h
@@ -8,6 +8,8 @@
 #include "rte_ip_frag.h"
 #include "ip_reassembly.h"
 
+#include <sys/queue.h>
+
 /* logging macros. */
 #ifdef RTE_LIBRTE_IP_FRAG_DEBUG
 #define	IP_FRAG_LOG(lvl, fmt, args...)	RTE_LOG(lvl, USER1, fmt, ##args)
diff --git a/lib/ip_frag/meson.build b/lib/ip_frag/meson.build
index 3a252bdaf6a4..ea2de09f7528 100644
--- a/lib/ip_frag/meson.build
+++ b/lib/ip_frag/meson.build
@@ -1,12 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files(
         'rte_ipv4_fragmentation.c',
         'rte_ipv6_fragmentation.c',
-- 
2.39.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 6/8] rib: enable on Windows
  2023-02-07  0:19 ` [PATCH v2 0/8] Enable building more libraries on Windows Stephen Hemminger
                     ` (4 preceding siblings ...)
  2023-02-07  0:19   ` [PATCH v2 5/8] ip_frag: enable " Stephen Hemminger
@ 2023-02-07  0:19   ` Stephen Hemminger
  2023-02-07  0:19   ` [PATCH v2 7/8] fib: " Stephen Hemminger
                     ` (4 subsequent siblings)
  10 siblings, 0 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-02-07  0:19 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tyler Retzlaff, Vladimir Medvedkin

The RIB library builds on Windows as long as sys/queue.h is included

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 app/test/test_rib.c  | 19 -------------------
 app/test/test_rib6.c | 24 ++----------------------
 lib/rib/meson.build  |  6 ------
 lib/rib/rte_rib.c    |  1 +
 lib/rib/rte_rib6.c   |  1 +
 5 files changed, 4 insertions(+), 47 deletions(-)

diff --git a/app/test/test_rib.c b/app/test/test_rib.c
index 06058f8f7c52..65b685641094 100644
--- a/app/test/test_rib.c
+++ b/app/test/test_rib.c
@@ -10,23 +10,6 @@
 #include <stdlib.h>
 
 #include <rte_ip.h>
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_rib(void)
-{
-	printf("rib not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-static int
-test_slow_rib(void)
-{
-	printf("slow_rib not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-#else
-
 #include <rte_rib.h>
 
 typedef int32_t (*rte_rib_test)(void);
@@ -380,7 +363,5 @@ test_slow_rib(void)
 	return unit_test_suite_runner(&rib_slow_tests);
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(rib_autotest, test_rib);
 REGISTER_TEST_COMMAND(rib_slow_autotest, test_slow_rib);
diff --git a/app/test/test_rib6.c b/app/test/test_rib6.c
index ba79aedea5f7..336b779d2e1e 100644
--- a/app/test/test_rib6.c
+++ b/app/test/test_rib6.c
@@ -3,32 +3,14 @@
  * Copyright(c) 2019 Intel Corporation
  */
 
-#include "test.h"
-
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
-
 #include <rte_ip.h>
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_rib6(void)
-{
-	printf("rib6 not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-static int
-test_slow_rib6(void)
-{
-	printf("slow_rib6 not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-#else
-
 #include <rte_rib6.h>
 
+#include "test.h"
+
 typedef int32_t (*rte_rib6_test)(void);
 
 static int32_t test_create_invalid(void);
@@ -385,7 +367,5 @@ test_slow_rib6(void)
 	return unit_test_suite_runner(&rib6_slow_tests);
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(rib6_autotest, test_rib6);
 REGISTER_TEST_COMMAND(rib6_slow_autotest, test_slow_rib6);
diff --git a/lib/rib/meson.build b/lib/rib/meson.build
index bda7f576e976..7bacbb453592 100644
--- a/lib/rib/meson.build
+++ b/lib/rib/meson.build
@@ -2,12 +2,6 @@
 # Copyright(c) 2018 Vladimir Medvedkin <medvedkinv@gmail.com>
 # Copyright(c) 2019 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_rib.c', 'rte_rib6.c')
 headers = files('rte_rib.h', 'rte_rib6.h')
 deps += ['mempool']
diff --git a/lib/rib/rte_rib.c b/lib/rib/rte_rib.c
index b0794edf66f5..812a2597d117 100644
--- a/lib/rib/rte_rib.c
+++ b/lib/rib/rte_rib.c
@@ -5,6 +5,7 @@
 
 #include <stdbool.h>
 #include <stdint.h>
+#include <sys/queue.h>
 
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
diff --git a/lib/rib/rte_rib6.c b/lib/rib/rte_rib6.c
index 19e4ff97c479..ae44281ae105 100644
--- a/lib/rib/rte_rib6.c
+++ b/lib/rib/rte_rib6.c
@@ -5,6 +5,7 @@
 
 #include <stdbool.h>
 #include <stdint.h>
+#include <sys/queue.h>
 
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
-- 
2.39.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 7/8] fib: enable on Windows
  2023-02-07  0:19 ` [PATCH v2 0/8] Enable building more libraries on Windows Stephen Hemminger
                     ` (5 preceding siblings ...)
  2023-02-07  0:19   ` [PATCH v2 6/8] rib: enable " Stephen Hemminger
@ 2023-02-07  0:19   ` Stephen Hemminger
  2023-02-07  0:19   ` [PATCH v2 8/8] pcapng: windows compatibility Stephen Hemminger
                     ` (3 subsequent siblings)
  10 siblings, 0 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-02-07  0:19 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tyler Retzlaff, Vladimir Medvedkin

The FIB library builds on Windows as long as sys/queue.h is defined.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 app/test/test_fib.c       | 22 +---------------------
 app/test/test_fib6.c      | 24 ++----------------------
 app/test/test_fib6_perf.c | 15 +--------------
 app/test/test_fib_perf.c  | 19 +++----------------
 lib/fib/meson.build       |  6 ------
 lib/fib/rte_fib.c         |  1 +
 lib/fib/rte_fib6.c        |  1 +
 7 files changed, 9 insertions(+), 79 deletions(-)

diff --git a/app/test/test_fib.c b/app/test/test_fib.c
index a2d1ea8f3abc..eb69d6e2fd4c 100644
--- a/app/test/test_fib.c
+++ b/app/test/test_fib.c
@@ -9,28 +9,10 @@
 
 #include <rte_ip.h>
 #include <rte_log.h>
+#include <rte_fib.h>
 
 #include "test.h"
 
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_fib(void)
-{
-	printf("fib not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-static int
-test_slow_fib(void)
-{
-	printf("slow_fib not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
-#include <rte_fib.h>
-
 typedef int32_t (*rte_fib_test)(void);
 
 static int32_t test_create_invalid(void);
@@ -433,7 +415,5 @@ test_slow_fib(void)
 	return unit_test_suite_runner(&fib_slow_tests);
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(fib_autotest, test_fib);
 REGISTER_TEST_COMMAND(fib_slow_autotest, test_slow_fib);
diff --git a/app/test/test_fib6.c b/app/test/test_fib6.c
index cd971e6ecdfb..15ad09178ae2 100644
--- a/app/test/test_fib6.c
+++ b/app/test/test_fib6.c
@@ -9,29 +9,11 @@
 
 #include <rte_memory.h>
 #include <rte_log.h>
-
-#include "test.h"
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_fib6(void)
-{
-	printf("fib not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-static int
-test_slow_fib6(void)
-{
-	printf("slow_fib not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
 #include <rte_rib6.h>
 #include <rte_fib6.h>
 
+#include "test.h"
+
 typedef int32_t (*rte_fib6_test)(void);
 
 static int32_t test_create_invalid(void);
@@ -442,7 +424,5 @@ test_slow_fib6(void)
 	return unit_test_suite_runner(&fib6_slow_tests);
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(fib6_autotest, test_fib6);
 REGISTER_TEST_COMMAND(fib6_slow_autotest, test_slow_fib6);
diff --git a/app/test/test_fib6_perf.c b/app/test/test_fib6_perf.c
index 21d2b65318e9..add20c2331b1 100644
--- a/app/test/test_fib6_perf.c
+++ b/app/test/test_fib6_perf.c
@@ -10,21 +10,10 @@
 #include <rte_cycles.h>
 #include <rte_random.h>
 #include <rte_memory.h>
+#include <rte_fib6.h>
 
 #include "test.h"
 
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_fib6_perf(void)
-{
-	printf("fib6_perf not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
-#include <rte_fib6.h>
-
 #include "test_lpm6_data.h"
 
 #define TEST_FIB_ASSERT(cond) do {				\
@@ -167,6 +156,4 @@ test_fib6_perf(void)
 	return 0;
 }
 
-#endif /*ifdef RTE_EXEC_ENV_WINDOWS*/
-
 REGISTER_TEST_COMMAND(fib6_perf_autotest, test_fib6_perf);
diff --git a/app/test/test_fib_perf.c b/app/test/test_fib_perf.c
index 9787874cc9b7..b56293e64f41 100644
--- a/app/test/test_fib_perf.c
+++ b/app/test/test_fib_perf.c
@@ -12,22 +12,11 @@
 #include <rte_random.h>
 #include <rte_branch_prediction.h>
 #include <rte_ip.h>
+#include <rte_fib.h>
 
 #include "test.h"
 #include "test_xmmt_ops.h"
 
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_fib_perf(void)
-{
-	printf("fib_perf not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
-#include <rte_fib.h>
-
 #define TEST_FIB_ASSERT(cond) do {				\
 	if (!(cond)) {						\
 		printf("Error at line %d:\n", __LINE__);	\
@@ -246,7 +235,7 @@ static void generate_random_rule_prefix(uint32_t ip_class, uint8_t depth)
 	/* Only generate rest bits except the most significant
 	 * fixed bits for IP address class
 	 */
-	start = lrand48() & mask;
+	start = rte_rand() & mask;
 	ptr_rule = &large_route_table[num_route_entries];
 	for (k = 0; k < rule_num; k++) {
 		ptr_rule->ip = (start << (RTE_FIB_MAX_DEPTH - depth))
@@ -265,7 +254,7 @@ static void insert_rule_in_random_pos(uint32_t ip, uint8_t depth)
 	struct route_rule tmp;
 
 	do {
-		pos = lrand48();
+		pos = rte_rand();
 		try_count++;
 	} while ((try_count < 10) && (pos > num_route_entries));
 
@@ -420,6 +409,4 @@ test_fib_perf(void)
 	return 0;
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(fib_perf_autotest, test_fib_perf);
diff --git a/lib/fib/meson.build b/lib/fib/meson.build
index 9b848d08417c..ddcae0617a73 100644
--- a/lib/fib/meson.build
+++ b/lib/fib/meson.build
@@ -2,12 +2,6 @@
 # Copyright(c) 2018 Vladimir Medvedkin <medvedkinv@gmail.com>
 # Copyright(c) 2019 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_fib.c', 'rte_fib6.c', 'dir24_8.c', 'trie.c')
 headers = files('rte_fib.h', 'rte_fib6.h')
 deps += ['rib']
diff --git a/lib/fib/rte_fib.c b/lib/fib/rte_fib.c
index 8af4c4091908..0c3b20e00a5a 100644
--- a/lib/fib/rte_fib.c
+++ b/lib/fib/rte_fib.c
@@ -5,6 +5,7 @@
 
 #include <stdint.h>
 #include <string.h>
+#include <sys/queue.h>
 
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
diff --git a/lib/fib/rte_fib6.c b/lib/fib/rte_fib6.c
index 4b8e22b142b9..28c69b38999f 100644
--- a/lib/fib/rte_fib6.c
+++ b/lib/fib/rte_fib6.c
@@ -5,6 +5,7 @@
 
 #include <stdint.h>
 #include <string.h>
+#include <sys/queue.h>
 
 #include <rte_eal_memconfig.h>
 #include <rte_tailq.h>
-- 
2.39.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 8/8] pcapng: windows compatibility
  2023-02-07  0:19 ` [PATCH v2 0/8] Enable building more libraries on Windows Stephen Hemminger
                     ` (6 preceding siblings ...)
  2023-02-07  0:19   ` [PATCH v2 7/8] fib: " Stephen Hemminger
@ 2023-02-07  0:19   ` Stephen Hemminger
  2023-02-07 22:13   ` [PATCH v2 0/8] Enable building more libraries on Windows Dmitry Kozlyuk
                     ` (2 subsequent siblings)
  10 siblings, 0 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-02-07  0:19 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tyler Retzlaff, Reshma Pattan

Allow building on Windows, need to provide some comparability
wrappers for writev() and if_nametoindex.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/pcapng/meson.build  |  6 -----
 lib/pcapng/rte_pcapng.c | 59 +++++++++++++++++++++++++++++++++++++++--
 2 files changed, 57 insertions(+), 8 deletions(-)

diff --git a/lib/pcapng/meson.build b/lib/pcapng/meson.build
index da938bbcb733..4549925d41b6 100644
--- a/lib/pcapng/meson.build
+++ b/lib/pcapng/meson.build
@@ -1,12 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2019 Microsoft Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_pcapng.c')
 headers = files('rte_pcapng.h')
 
diff --git a/lib/pcapng/rte_pcapng.c b/lib/pcapng/rte_pcapng.c
index ea004939e63e..89d444d6ab5b 100644
--- a/lib/pcapng/rte_pcapng.c
+++ b/lib/pcapng/rte_pcapng.c
@@ -3,15 +3,18 @@
  */
 
 #include <errno.h>
-#include <net/if.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/uio.h>
 #include <time.h>
 #include <unistd.h>
 
+#ifndef RTE_EXEC_ENV_WINDOWS
+#include <net/if.h>
+#include <sys/uio.h>
+#endif
+
 #include <bus_driver.h>
 #include <rte_common.h>
 #include <rte_cycles.h>
@@ -20,6 +23,7 @@
 #include <rte_ethdev.h>
 #include <rte_ether.h>
 #include <rte_mbuf.h>
+#include <rte_os_shim.h>
 #include <rte_pcapng.h>
 #include <rte_reciprocal.h>
 #include <rte_time.h>
@@ -47,6 +51,57 @@ static struct pcapng_time {
 	struct rte_reciprocal_u64 tsc_hz_inverse;
 } pcapng_time;
 
+
+#ifdef RTE_EXEC_ENV_WINDOWS
+/*
+ * Windows does not have writev() call.
+ * Emulate this by copying to a new buffer.
+ * The copy is necessary since pcapng needs to be thread-safe
+ * and do atomic write operations.
+ */
+
+#define IOV_MAX 128
+struct iovec {
+	void   *iov_base;
+	size_t  iov_len;
+};
+
+static ssize_t writev(int fd, const struct iovec *iov, int iovcnt)
+{
+	size_t bytes = 0;
+	uint8_t *ptr;
+	void *tmp_buf;
+	ssize_t ret;
+	int i;
+
+	for (i = 0; i < iovcnt; i++)
+		bytes += iov[i].iov_len;
+
+	if (unlikely(bytes == 0))
+		return 0;
+
+	tmp_buf = malloc(bytes);
+	if (unlikely(tmp_buf == NULL)) {
+		errno = ENOMEM;
+		return -1;
+	}
+
+	ptr = tmp_buf;
+	for (i = 0; i < iovcnt; i++) {
+		rte_memcpy(ptr, iov[i].iov_base, iov[i].iov_len);
+		ptr += iov[i].iov_len;
+	}
+
+	ret = write(fd, tmp_buf, bytes);
+	free(tmp_buf);
+	return ret;
+}
+
+#define IF_NAMESIZE	16
+/* compatiablity wrapper because name is optional */
+#define if_indextoname(ifindex, ifname) NULL
+#endif
+
 static inline void
 pcapng_init(void)
 {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 0/8] Enable building more libraries on Windows
  2023-02-07  0:19 ` [PATCH v2 0/8] Enable building more libraries on Windows Stephen Hemminger
                     ` (7 preceding siblings ...)
  2023-02-07  0:19   ` [PATCH v2 8/8] pcapng: windows compatibility Stephen Hemminger
@ 2023-02-07 22:13   ` Dmitry Kozlyuk
  2023-02-09  9:16     ` David Marchand
  2023-02-19 17:50   ` [PATCH v3 " Stephen Hemminger
  2023-02-19 23:14   ` [PATCH v4 0/9] Enable building more libraries on Windows Stephen Hemminger
  10 siblings, 1 reply; 66+ messages in thread
From: Dmitry Kozlyuk @ 2023-02-07 22:13 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

2023-02-06 16:19 (UTC-0800), Stephen Hemminger:
> While diagnosing some Windows cross build errors;
> noticed that lots of important DPDK libraries are not
> being built on Windows.
> 
> Stephen Hemminger (8):
>   net/null: build null PMD on Windows
>   net/ring: build on Windows
>   lpm: enable on Windows
>   reorder: build on Windows
>   ip_frag: enable build on Windows
>   rib: enable on Windows
>   fib: enable on Windows
>   pcapng: windows compatibility
> 
> v2 - fix unnecessary PATH_MAX in net/ring driver

Looks like #include <rte_os_shim.h> is still needed in rte_eth_ring.h
to avoid the fatal warning about `strdup()` with clang (MS CRT, actually).
For the series,
Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 0/8] Enable building more libraries on Windows
  2023-02-07 22:13   ` [PATCH v2 0/8] Enable building more libraries on Windows Dmitry Kozlyuk
@ 2023-02-09  9:16     ` David Marchand
  0 siblings, 0 replies; 66+ messages in thread
From: David Marchand @ 2023-02-09  9:16 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Dmitry Kozlyuk, dev

Hello Stephen,

On Tue, Feb 7, 2023 at 11:13 PM Dmitry Kozlyuk <dmitry.kozliuk@gmail.com> wrote:
>
> 2023-02-06 16:19 (UTC-0800), Stephen Hemminger:
> > While diagnosing some Windows cross build errors;
> > noticed that lots of important DPDK libraries are not
> > being built on Windows.
> >
> > Stephen Hemminger (8):
> >   net/null: build null PMD on Windows
> >   net/ring: build on Windows
> >   lpm: enable on Windows
> >   reorder: build on Windows
> >   ip_frag: enable build on Windows
> >   rib: enable on Windows
> >   fib: enable on Windows
> >   pcapng: windows compatibility
> >
> > v2 - fix unnecessary PATH_MAX in net/ring driver
>
> Looks like #include <rte_os_shim.h> is still needed in rte_eth_ring.h
> to avoid the fatal warning about `strdup()` with clang (MS CRT, actually).

We need a new revision.
Thanks.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v3 0/8] Enable building more libraries on Windows
  2023-02-07  0:19 ` [PATCH v2 0/8] Enable building more libraries on Windows Stephen Hemminger
                     ` (8 preceding siblings ...)
  2023-02-07 22:13   ` [PATCH v2 0/8] Enable building more libraries on Windows Dmitry Kozlyuk
@ 2023-02-19 17:50   ` Stephen Hemminger
  2023-02-19 17:50     ` [PATCH v3 1/8] net/null: build null PMD " Stephen Hemminger
                       ` (7 more replies)
  2023-02-19 23:14   ` [PATCH v4 0/9] Enable building more libraries on Windows Stephen Hemminger
  10 siblings, 8 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-02-19 17:50 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

While diagnosing some Windows cross build errors;
noticed that lots of important DPDK libraries are not
being built on Windows.

Stephen Hemminger (8):
  net/null: build null PMD on Windows
  net/ring: build on Windows
  lpm: enable on Windows
  reorder: build on Windows
  ip_frag: enable build on Windows
  rib: enable on Windows
  fib: enable on Windows
  pcapng: windows compatibility

v3 - add rte_os_shim.h to rte_ring to fix use of
     strdup() breaking with stricter MS compiler

v2 - fix unnecessary PATH_MAX in net/ring driver

Stephen Hemminger (8):
  net/null: build null PMD on Windows
  net/ring: build on Windows
  lpm: enable on Windows
  reorder: build on Windows
  ip_frag: enable build on Windows
  rib: enable on Windows
  fib: enable on Windows
  pcapng: windows compatibility

 app/test/meson.build            |  2 +-
 app/test/test_fib.c             | 22 +-----------
 app/test/test_fib6.c            | 24 ++------------
 app/test/test_fib6_perf.c       | 15 +--------
 app/test/test_fib_perf.c        | 19 ++---------
 app/test/test_ipfrag.c          | 12 -------
 app/test/test_lpm.c             | 15 +--------
 app/test/test_lpm6.c            | 12 -------
 app/test/test_lpm6_data.h       |  3 +-
 app/test/test_lpm6_perf.c       | 14 +-------
 app/test/test_lpm_perf.c        | 39 +++++++---------------
 app/test/test_reorder.c         | 11 ------
 app/test/test_rib.c             | 19 -----------
 app/test/test_rib6.c            | 24 ++------------
 drivers/net/null/meson.build    |  6 ----
 drivers/net/ring/meson.build    |  6 ----
 drivers/net/ring/rte_eth_ring.c |  4 ++-
 lib/fib/meson.build             |  6 ----
 lib/fib/rte_fib.c               |  1 +
 lib/fib/rte_fib6.c              |  1 +
 lib/ip_frag/ip_frag_common.h    |  2 ++
 lib/ip_frag/meson.build         |  6 ----
 lib/lpm/meson.build             |  6 ----
 lib/pcapng/meson.build          |  6 ----
 lib/pcapng/rte_pcapng.c         | 59 +++++++++++++++++++++++++++++++--
 lib/reorder/meson.build         |  6 ----
 lib/reorder/rte_reorder.c       |  1 +
 lib/rib/meson.build             |  6 ----
 lib/rib/rte_rib.c               |  1 +
 lib/rib/rte_rib6.c              |  1 +
 30 files changed, 93 insertions(+), 256 deletions(-)

-- 
2.39.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v3 1/8] net/null: build null PMD on Windows
  2023-02-19 17:50   ` [PATCH v3 " Stephen Hemminger
@ 2023-02-19 17:50     ` Stephen Hemminger
  2023-02-19 17:50     ` [PATCH v3 2/8] net/ring: build " Stephen Hemminger
                       ` (6 subsequent siblings)
  7 siblings, 0 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-02-19 17:50 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tyler Retzlaff, Tetsuya Mukawa

Builds fine with current code, no changes needed.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 drivers/net/null/meson.build | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/net/null/meson.build b/drivers/net/null/meson.build
index 4a483955a7a9..a51f8f5211b0 100644
--- a/drivers/net/null/meson.build
+++ b/drivers/net/null/meson.build
@@ -1,11 +1,5 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_eth_null.c')
 pmd_supports_disable_iova_as_pa = true
-- 
2.39.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v3 2/8] net/ring: build on Windows
  2023-02-19 17:50   ` [PATCH v3 " Stephen Hemminger
  2023-02-19 17:50     ` [PATCH v3 1/8] net/null: build null PMD " Stephen Hemminger
@ 2023-02-19 17:50     ` Stephen Hemminger
  2023-02-19 17:50     ` [PATCH v3 3/8] lpm: enable " Stephen Hemminger
                       ` (5 subsequent siblings)
  7 siblings, 0 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-02-19 17:50 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tyler Retzlaff, Bruce Richardson

The command line arguments are stored in node_action_pair
and the name[] was sized to PATH_MAX which does not exist on Windows.
Since the name is either "CREATE" or "ATTACH" it is not
related to PATH_MAX (4096).

With this fix driver builds ok on windows, but need to modify the
test meson build to skip the eventdev test on Windows.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 app/test/meson.build            | 2 +-
 drivers/net/ring/meson.build    | 6 ------
 drivers/net/ring/rte_eth_ring.c | 4 +++-
 3 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/app/test/meson.build b/app/test/meson.build
index f34d19e3c3cb..a713f0382280 100644
--- a/app/test/meson.build
+++ b/app/test/meson.build
@@ -390,7 +390,7 @@ if dpdk_conf.has('RTE_NET_BOND')
         driver_test_names += 'link_bonding_mode4_autotest'
     endif
 endif
-if dpdk_conf.has('RTE_NET_RING')
+if dpdk_conf.has('RTE_LIB_EVENTDEV') and dpdk_conf.has('RTE_NET_RING')
     test_deps += 'net_ring'
     test_sources += 'test_pmd_ring_perf.c'
     test_sources += 'test_pmd_ring.c'
diff --git a/drivers/net/ring/meson.build b/drivers/net/ring/meson.build
index 72792e26b05a..3534a3cc2287 100644
--- a/drivers/net/ring/meson.build
+++ b/drivers/net/ring/meson.build
@@ -1,12 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_eth_ring.c')
 headers = files('rte_eth_ring.h')
 pmd_supports_disable_iova_as_pa = true
diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index bd5a47dd9017..e8bc9b627102 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -9,6 +9,7 @@
 #include <ethdev_driver.h>
 #include <rte_malloc.h>
 #include <rte_memcpy.h>
+#include <rte_os_shim.h>
 #include <rte_string_fns.h>
 #include <bus_vdev_driver.h>
 #include <rte_kvargs.h>
@@ -17,6 +18,7 @@
 #define ETH_RING_NUMA_NODE_ACTION_ARG	"nodeaction"
 #define ETH_RING_ACTION_CREATE		"CREATE"
 #define ETH_RING_ACTION_ATTACH		"ATTACH"
+#define ETH_RING_ACTION_MAX_LEN		8 /* CREATE | ACTION */
 #define ETH_RING_INTERNAL_ARG		"internal"
 #define ETH_RING_INTERNAL_ARG_MAX_LEN	19 /* "0x..16chars..\0" */
 
@@ -539,7 +541,7 @@ eth_dev_ring_create(const char *name,
 }
 
 struct node_action_pair {
-	char name[PATH_MAX];
+	char name[ETH_RING_ACTION_MAX_LEN];
 	unsigned int node;
 	enum dev_action action;
 };
-- 
2.39.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v3 3/8] lpm: enable on Windows
  2023-02-19 17:50   ` [PATCH v3 " Stephen Hemminger
  2023-02-19 17:50     ` [PATCH v3 1/8] net/null: build null PMD " Stephen Hemminger
  2023-02-19 17:50     ` [PATCH v3 2/8] net/ring: build " Stephen Hemminger
@ 2023-02-19 17:50     ` Stephen Hemminger
  2023-02-19 17:50     ` [PATCH v3 4/8] reorder: build " Stephen Hemminger
                       ` (4 subsequent siblings)
  7 siblings, 0 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-02-19 17:50 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Tyler Retzlaff, Bruce Richardson, Vladimir Medvedkin

This builds on Windows without changes.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 app/test/test_lpm.c       | 15 +--------------
 app/test/test_lpm6.c      | 12 ------------
 app/test/test_lpm6_data.h |  3 ++-
 app/test/test_lpm6_perf.c | 14 +-------------
 app/test/test_lpm_perf.c  | 39 ++++++++++++---------------------------
 lib/lpm/meson.build       |  6 ------
 6 files changed, 16 insertions(+), 73 deletions(-)

diff --git a/app/test/test_lpm.c b/app/test/test_lpm.c
index bceb9ae743d7..37b460af3a96 100644
--- a/app/test/test_lpm.c
+++ b/app/test/test_lpm.c
@@ -2,18 +2,6 @@
  * Copyright(c) 2010-2014 Intel Corporation
  */
 
-#include "test.h"
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_lpm(void)
-{
-	printf("lpm not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
@@ -22,6 +10,7 @@ test_lpm(void)
 #include <rte_lpm.h>
 #include <rte_malloc.h>
 
+#include "test.h"
 #include "test_xmmt_ops.h"
 
 #define TEST_LPM_ASSERT(cond) do {                                            \
@@ -1595,6 +1584,4 @@ test_lpm(void)
 	return global_status;
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(lpm_autotest, test_lpm);
diff --git a/app/test/test_lpm6.c b/app/test/test_lpm6.c
index 1f44392db739..b6b6f8615ea5 100644
--- a/app/test/test_lpm6.c
+++ b/app/test/test_lpm6.c
@@ -10,16 +10,6 @@
 #include <string.h>
 
 #include <rte_memory.h>
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_lpm6(void)
-{
-	printf("lpm6 not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
 #include <rte_lpm6.h>
 
 #include "test_lpm6_data.h"
@@ -1803,6 +1793,4 @@ test_lpm6(void)
 	return global_status;
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(lpm6_autotest, test_lpm6);
diff --git a/app/test/test_lpm6_data.h b/app/test/test_lpm6_data.h
index da9b161f20e5..3a1fa25f8433 100644
--- a/app/test/test_lpm6_data.h
+++ b/app/test/test_lpm6_data.h
@@ -6,6 +6,7 @@
 
 #include <stdint.h>
 #include <stdlib.h>
+#include <rte_random.h>
 
 struct rules_tbl_entry {
 	uint8_t ip[16];
@@ -1129,7 +1130,7 @@ static void generate_large_ips_table(int gen_expected_next_hop)
 
 	for (i = 0; i < NUM_IPS_ENTRIES; i++) {
 		for (j = 0; j < 16; j++)
-			large_ips_table[i].ip[j] = lrand48();
+			large_ips_table[i].ip[j] = rte_rand();
 	}
 
 	for (k = j = 0, i = 0; i < NUM_IPS_ENTRIES; i++) {
diff --git a/app/test/test_lpm6_perf.c b/app/test/test_lpm6_perf.c
index aaf2773b6fac..5b684686a687 100644
--- a/app/test/test_lpm6_perf.c
+++ b/app/test/test_lpm6_perf.c
@@ -2,17 +2,6 @@
  * Copyright(c) 2010-2014 Intel Corporation
  */
 
-#include "test.h"
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_lpm6_perf(void)
-{
-	printf("lpm6_perf not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
 
 #include <stdio.h>
 #include <stdint.h>
@@ -24,6 +13,7 @@ test_lpm6_perf(void)
 #include <rte_memory.h>
 #include <rte_lpm6.h>
 
+#include "test.h"
 #include "test_lpm6_data.h"
 
 #define TEST_LPM_ASSERT(cond) do {                                            \
@@ -171,6 +161,4 @@ test_lpm6_perf(void)
 	return 0;
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(lpm6_perf_autotest, test_lpm6_perf);
diff --git a/app/test/test_lpm_perf.c b/app/test/test_lpm_perf.c
index e858716f909b..e72437ba3850 100644
--- a/app/test/test_lpm_perf.c
+++ b/app/test/test_lpm_perf.c
@@ -3,17 +3,6 @@
  * Copyright(c) 2020 Arm Limited
  */
 
-#include "test.h"
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_lpm_perf(void)
-{
-	printf("lpm_perf not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
@@ -25,7 +14,9 @@ test_lpm_perf(void)
 #include <rte_malloc.h>
 #include <rte_ip.h>
 #include <rte_lpm.h>
+#include <rte_spinlock.h>
 
+#include "test.h"
 #include "test_xmmt_ops.h"
 
 struct rte_lpm *lpm;
@@ -34,8 +25,9 @@ static volatile uint8_t writer_done;
 static volatile uint32_t thr_id;
 static uint64_t gwrite_cycles;
 static uint32_t num_writers;
-/* LPM APIs are not thread safe, use mutex to provide thread safety */
-static pthread_mutex_t lpm_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+/* LPM APIs are not thread safe, use spinlock */
+static rte_spinlock_t lpm_lock = RTE_SPINLOCK_INITIALIZER;
 
 /* Report quiescent state interval every 1024 lookups. Larger critical
  * sections in reader will result in writer polling multiple times.
@@ -267,7 +259,7 @@ static void generate_random_rule_prefix(uint32_t ip_class, uint8_t depth)
 	/* Only generate rest bits except the most significant
 	 * fixed bits for IP address class
 	 */
-	start = lrand48() & mask;
+	start = rte_rand() & mask;
 	ptr_rule = &large_route_table[num_route_entries];
 	ptr_ldepth_rule = &large_ldepth_route_table[num_ldepth_route_entries];
 	for (k = 0; k < rule_num; k++) {
@@ -296,7 +288,7 @@ static void insert_rule_in_random_pos(uint32_t ip, uint8_t depth)
 	struct route_rule tmp;
 
 	do {
-		pos = lrand48();
+		pos = rte_rand();
 		try_count++;
 	} while ((try_count < 10) && (pos > num_route_entries));
 
@@ -452,8 +444,7 @@ test_lpm_rcu_qsbr_writer(void *arg)
 	for (i = 0; i < RCU_ITERATIONS; i++) {
 		/* Add all the entries */
 		for (j = si; j < ei; j++) {
-			if (num_writers > 1)
-				pthread_mutex_lock(&lpm_mutex);
+			rte_spinlock_lock(&lpm_lock);
 			if (rte_lpm_add(lpm, large_ldepth_route_table[j].ip,
 					large_ldepth_route_table[j].depth,
 					next_hop_add) != 0) {
@@ -461,22 +452,19 @@ test_lpm_rcu_qsbr_writer(void *arg)
 					i, j);
 				goto error;
 			}
-			if (num_writers > 1)
-				pthread_mutex_unlock(&lpm_mutex);
+			rte_spinlock_unlock(&lpm_lock);
 		}
 
 		/* Delete all the entries */
 		for (j = si; j < ei; j++) {
-			if (num_writers > 1)
-				pthread_mutex_lock(&lpm_mutex);
+			rte_spinlock_lock(&lpm_lock);
 			if (rte_lpm_delete(lpm, large_ldepth_route_table[j].ip,
 				large_ldepth_route_table[j].depth) != 0) {
 				printf("Failed to delete iteration %d, route# %d\n",
 					i, j);
 				goto error;
 			}
-			if (num_writers > 1)
-				pthread_mutex_unlock(&lpm_mutex);
+			rte_spinlock_unlock(&lpm_lock);
 		}
 	}
 
@@ -487,8 +475,7 @@ test_lpm_rcu_qsbr_writer(void *arg)
 	return 0;
 
 error:
-	if (num_writers > 1)
-		pthread_mutex_unlock(&lpm_mutex);
+	rte_spinlock_unlock(&lpm_lock);
 	return -1;
 }
 
@@ -773,6 +760,4 @@ test_lpm_perf(void)
 	return 0;
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(lpm_perf_autotest, test_lpm_perf);
diff --git a/lib/lpm/meson.build b/lib/lpm/meson.build
index 6b47361fcec0..4cd48886fc41 100644
--- a/lib/lpm/meson.build
+++ b/lib/lpm/meson.build
@@ -1,12 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_lpm.c', 'rte_lpm6.c')
 headers = files('rte_lpm.h', 'rte_lpm6.h')
 # since header files have different names, we can install all vector headers
-- 
2.39.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v3 4/8] reorder: build on Windows
  2023-02-19 17:50   ` [PATCH v3 " Stephen Hemminger
                       ` (2 preceding siblings ...)
  2023-02-19 17:50     ` [PATCH v3 3/8] lpm: enable " Stephen Hemminger
@ 2023-02-19 17:50     ` Stephen Hemminger
  2023-02-19 17:50     ` [PATCH v3 5/8] ip_frag: enable " Stephen Hemminger
                       ` (3 subsequent siblings)
  7 siblings, 0 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-02-19 17:50 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tyler Retzlaff, Reshma Pattan

This builds on Windows if sys/queue.h is included.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 app/test/test_reorder.c   | 11 -----------
 lib/reorder/meson.build   |  6 ------
 lib/reorder/rte_reorder.c |  1 +
 3 files changed, 1 insertion(+), 17 deletions(-)

diff --git a/app/test/test_reorder.c b/app/test/test_reorder.c
index f0714a5c18a3..9ebd91477536 100644
--- a/app/test/test_reorder.c
+++ b/app/test/test_reorder.c
@@ -11,16 +11,6 @@
 #include <rte_cycles.h>
 #include <rte_errno.h>
 #include <rte_mbuf.h>
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_reorder(void)
-{
-	printf("reorder not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-#else
-
 #include <rte_reorder.h>
 #include <rte_lcore.h>
 #include <rte_malloc.h>
@@ -395,6 +385,5 @@ test_reorder(void)
 	return unit_test_suite_runner(&reorder_test_suite);
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
 
 REGISTER_TEST_COMMAND(reorder_autotest, test_reorder);
diff --git a/lib/reorder/meson.build b/lib/reorder/meson.build
index 621c1f350103..03aed53d9007 100644
--- a/lib/reorder/meson.build
+++ b/lib/reorder/meson.build
@@ -1,12 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_reorder.c')
 headers = files('rte_reorder.h')
 deps += ['mbuf']
diff --git a/lib/reorder/rte_reorder.c b/lib/reorder/rte_reorder.c
index 385ee479da42..00e2cf043e04 100644
--- a/lib/reorder/rte_reorder.c
+++ b/lib/reorder/rte_reorder.c
@@ -3,6 +3,7 @@
  */
 
 #include <string.h>
+#include <sys/queue.h>
 
 #include <rte_string_fns.h>
 #include <rte_log.h>
-- 
2.39.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v3 5/8] ip_frag: enable build on Windows
  2023-02-19 17:50   ` [PATCH v3 " Stephen Hemminger
                       ` (3 preceding siblings ...)
  2023-02-19 17:50     ` [PATCH v3 4/8] reorder: build " Stephen Hemminger
@ 2023-02-19 17:50     ` Stephen Hemminger
  2023-02-19 17:50     ` [PATCH v3 6/8] rib: enable " Stephen Hemminger
                       ` (2 subsequent siblings)
  7 siblings, 0 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-02-19 17:50 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tyler Retzlaff, Konstantin Ananyev

This build works on Windows if sys/queue.h is included.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 app/test/test_ipfrag.c       | 12 ------------
 lib/ip_frag/ip_frag_common.h |  2 ++
 lib/ip_frag/meson.build      |  6 ------
 3 files changed, 2 insertions(+), 18 deletions(-)

diff --git a/app/test/test_ipfrag.c b/app/test/test_ipfrag.c
index 88cc4cdeea8d..402ce361c1a2 100644
--- a/app/test/test_ipfrag.c
+++ b/app/test/test_ipfrag.c
@@ -10,17 +10,6 @@
 #include <rte_cycles.h>
 #include <rte_hexdump.h>
 #include <rte_ip.h>
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_ipfrag(void)
-{
-	printf("ipfrag not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
 #include <rte_ip_frag.h>
 #include <rte_mbuf.h>
 #include <rte_random.h>
@@ -520,6 +509,5 @@ test_ipfrag(void)
 	return unit_test_suite_runner(&ipfrag_testsuite);
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
 
 REGISTER_TEST_COMMAND(ipfrag_autotest, test_ipfrag);
diff --git a/lib/ip_frag/ip_frag_common.h b/lib/ip_frag/ip_frag_common.h
index 9c0dbdeb6eb9..0f4ad72a90d9 100644
--- a/lib/ip_frag/ip_frag_common.h
+++ b/lib/ip_frag/ip_frag_common.h
@@ -8,6 +8,8 @@
 #include "rte_ip_frag.h"
 #include "ip_reassembly.h"
 
+#include <sys/queue.h>
+
 /* logging macros. */
 #ifdef RTE_LIBRTE_IP_FRAG_DEBUG
 #define	IP_FRAG_LOG(lvl, fmt, args...)	RTE_LOG(lvl, USER1, fmt, ##args)
diff --git a/lib/ip_frag/meson.build b/lib/ip_frag/meson.build
index 3a252bdaf6a4..ea2de09f7528 100644
--- a/lib/ip_frag/meson.build
+++ b/lib/ip_frag/meson.build
@@ -1,12 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files(
         'rte_ipv4_fragmentation.c',
         'rte_ipv6_fragmentation.c',
-- 
2.39.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v3 6/8] rib: enable on Windows
  2023-02-19 17:50   ` [PATCH v3 " Stephen Hemminger
                       ` (4 preceding siblings ...)
  2023-02-19 17:50     ` [PATCH v3 5/8] ip_frag: enable " Stephen Hemminger
@ 2023-02-19 17:50     ` Stephen Hemminger
  2023-02-19 17:50     ` [PATCH v3 7/8] fib: " Stephen Hemminger
  2023-02-19 17:50     ` [PATCH v3 8/8] pcapng: windows compatibility Stephen Hemminger
  7 siblings, 0 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-02-19 17:50 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tyler Retzlaff, Vladimir Medvedkin

The RIB library builds on Windows as long as sys/queue.h is included

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 app/test/test_rib.c  | 19 -------------------
 app/test/test_rib6.c | 24 ++----------------------
 lib/rib/meson.build  |  6 ------
 lib/rib/rte_rib.c    |  1 +
 lib/rib/rte_rib6.c   |  1 +
 5 files changed, 4 insertions(+), 47 deletions(-)

diff --git a/app/test/test_rib.c b/app/test/test_rib.c
index 06058f8f7c52..65b685641094 100644
--- a/app/test/test_rib.c
+++ b/app/test/test_rib.c
@@ -10,23 +10,6 @@
 #include <stdlib.h>
 
 #include <rte_ip.h>
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_rib(void)
-{
-	printf("rib not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-static int
-test_slow_rib(void)
-{
-	printf("slow_rib not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-#else
-
 #include <rte_rib.h>
 
 typedef int32_t (*rte_rib_test)(void);
@@ -380,7 +363,5 @@ test_slow_rib(void)
 	return unit_test_suite_runner(&rib_slow_tests);
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(rib_autotest, test_rib);
 REGISTER_TEST_COMMAND(rib_slow_autotest, test_slow_rib);
diff --git a/app/test/test_rib6.c b/app/test/test_rib6.c
index ba79aedea5f7..336b779d2e1e 100644
--- a/app/test/test_rib6.c
+++ b/app/test/test_rib6.c
@@ -3,32 +3,14 @@
  * Copyright(c) 2019 Intel Corporation
  */
 
-#include "test.h"
-
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
-
 #include <rte_ip.h>
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_rib6(void)
-{
-	printf("rib6 not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-static int
-test_slow_rib6(void)
-{
-	printf("slow_rib6 not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-#else
-
 #include <rte_rib6.h>
 
+#include "test.h"
+
 typedef int32_t (*rte_rib6_test)(void);
 
 static int32_t test_create_invalid(void);
@@ -385,7 +367,5 @@ test_slow_rib6(void)
 	return unit_test_suite_runner(&rib6_slow_tests);
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(rib6_autotest, test_rib6);
 REGISTER_TEST_COMMAND(rib6_slow_autotest, test_slow_rib6);
diff --git a/lib/rib/meson.build b/lib/rib/meson.build
index bda7f576e976..7bacbb453592 100644
--- a/lib/rib/meson.build
+++ b/lib/rib/meson.build
@@ -2,12 +2,6 @@
 # Copyright(c) 2018 Vladimir Medvedkin <medvedkinv@gmail.com>
 # Copyright(c) 2019 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_rib.c', 'rte_rib6.c')
 headers = files('rte_rib.h', 'rte_rib6.h')
 deps += ['mempool']
diff --git a/lib/rib/rte_rib.c b/lib/rib/rte_rib.c
index b0794edf66f5..812a2597d117 100644
--- a/lib/rib/rte_rib.c
+++ b/lib/rib/rte_rib.c
@@ -5,6 +5,7 @@
 
 #include <stdbool.h>
 #include <stdint.h>
+#include <sys/queue.h>
 
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
diff --git a/lib/rib/rte_rib6.c b/lib/rib/rte_rib6.c
index 19e4ff97c479..ae44281ae105 100644
--- a/lib/rib/rte_rib6.c
+++ b/lib/rib/rte_rib6.c
@@ -5,6 +5,7 @@
 
 #include <stdbool.h>
 #include <stdint.h>
+#include <sys/queue.h>
 
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
-- 
2.39.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v3 7/8] fib: enable on Windows
  2023-02-19 17:50   ` [PATCH v3 " Stephen Hemminger
                       ` (5 preceding siblings ...)
  2023-02-19 17:50     ` [PATCH v3 6/8] rib: enable " Stephen Hemminger
@ 2023-02-19 17:50     ` Stephen Hemminger
  2023-02-19 17:50     ` [PATCH v3 8/8] pcapng: windows compatibility Stephen Hemminger
  7 siblings, 0 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-02-19 17:50 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tyler Retzlaff, Vladimir Medvedkin

The FIB library builds on Windows as long as sys/queue.h is defined.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 app/test/test_fib.c       | 22 +---------------------
 app/test/test_fib6.c      | 24 ++----------------------
 app/test/test_fib6_perf.c | 15 +--------------
 app/test/test_fib_perf.c  | 19 +++----------------
 lib/fib/meson.build       |  6 ------
 lib/fib/rte_fib.c         |  1 +
 lib/fib/rte_fib6.c        |  1 +
 7 files changed, 9 insertions(+), 79 deletions(-)

diff --git a/app/test/test_fib.c b/app/test/test_fib.c
index a2d1ea8f3abc..eb69d6e2fd4c 100644
--- a/app/test/test_fib.c
+++ b/app/test/test_fib.c
@@ -9,28 +9,10 @@
 
 #include <rte_ip.h>
 #include <rte_log.h>
+#include <rte_fib.h>
 
 #include "test.h"
 
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_fib(void)
-{
-	printf("fib not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-static int
-test_slow_fib(void)
-{
-	printf("slow_fib not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
-#include <rte_fib.h>
-
 typedef int32_t (*rte_fib_test)(void);
 
 static int32_t test_create_invalid(void);
@@ -433,7 +415,5 @@ test_slow_fib(void)
 	return unit_test_suite_runner(&fib_slow_tests);
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(fib_autotest, test_fib);
 REGISTER_TEST_COMMAND(fib_slow_autotest, test_slow_fib);
diff --git a/app/test/test_fib6.c b/app/test/test_fib6.c
index cd971e6ecdfb..15ad09178ae2 100644
--- a/app/test/test_fib6.c
+++ b/app/test/test_fib6.c
@@ -9,29 +9,11 @@
 
 #include <rte_memory.h>
 #include <rte_log.h>
-
-#include "test.h"
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_fib6(void)
-{
-	printf("fib not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-static int
-test_slow_fib6(void)
-{
-	printf("slow_fib not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
 #include <rte_rib6.h>
 #include <rte_fib6.h>
 
+#include "test.h"
+
 typedef int32_t (*rte_fib6_test)(void);
 
 static int32_t test_create_invalid(void);
@@ -442,7 +424,5 @@ test_slow_fib6(void)
 	return unit_test_suite_runner(&fib6_slow_tests);
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(fib6_autotest, test_fib6);
 REGISTER_TEST_COMMAND(fib6_slow_autotest, test_slow_fib6);
diff --git a/app/test/test_fib6_perf.c b/app/test/test_fib6_perf.c
index 21d2b65318e9..add20c2331b1 100644
--- a/app/test/test_fib6_perf.c
+++ b/app/test/test_fib6_perf.c
@@ -10,21 +10,10 @@
 #include <rte_cycles.h>
 #include <rte_random.h>
 #include <rte_memory.h>
+#include <rte_fib6.h>
 
 #include "test.h"
 
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_fib6_perf(void)
-{
-	printf("fib6_perf not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
-#include <rte_fib6.h>
-
 #include "test_lpm6_data.h"
 
 #define TEST_FIB_ASSERT(cond) do {				\
@@ -167,6 +156,4 @@ test_fib6_perf(void)
 	return 0;
 }
 
-#endif /*ifdef RTE_EXEC_ENV_WINDOWS*/
-
 REGISTER_TEST_COMMAND(fib6_perf_autotest, test_fib6_perf);
diff --git a/app/test/test_fib_perf.c b/app/test/test_fib_perf.c
index 9787874cc9b7..b56293e64f41 100644
--- a/app/test/test_fib_perf.c
+++ b/app/test/test_fib_perf.c
@@ -12,22 +12,11 @@
 #include <rte_random.h>
 #include <rte_branch_prediction.h>
 #include <rte_ip.h>
+#include <rte_fib.h>
 
 #include "test.h"
 #include "test_xmmt_ops.h"
 
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_fib_perf(void)
-{
-	printf("fib_perf not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
-#include <rte_fib.h>
-
 #define TEST_FIB_ASSERT(cond) do {				\
 	if (!(cond)) {						\
 		printf("Error at line %d:\n", __LINE__);	\
@@ -246,7 +235,7 @@ static void generate_random_rule_prefix(uint32_t ip_class, uint8_t depth)
 	/* Only generate rest bits except the most significant
 	 * fixed bits for IP address class
 	 */
-	start = lrand48() & mask;
+	start = rte_rand() & mask;
 	ptr_rule = &large_route_table[num_route_entries];
 	for (k = 0; k < rule_num; k++) {
 		ptr_rule->ip = (start << (RTE_FIB_MAX_DEPTH - depth))
@@ -265,7 +254,7 @@ static void insert_rule_in_random_pos(uint32_t ip, uint8_t depth)
 	struct route_rule tmp;
 
 	do {
-		pos = lrand48();
+		pos = rte_rand();
 		try_count++;
 	} while ((try_count < 10) && (pos > num_route_entries));
 
@@ -420,6 +409,4 @@ test_fib_perf(void)
 	return 0;
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(fib_perf_autotest, test_fib_perf);
diff --git a/lib/fib/meson.build b/lib/fib/meson.build
index 9b848d08417c..ddcae0617a73 100644
--- a/lib/fib/meson.build
+++ b/lib/fib/meson.build
@@ -2,12 +2,6 @@
 # Copyright(c) 2018 Vladimir Medvedkin <medvedkinv@gmail.com>
 # Copyright(c) 2019 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_fib.c', 'rte_fib6.c', 'dir24_8.c', 'trie.c')
 headers = files('rte_fib.h', 'rte_fib6.h')
 deps += ['rib']
diff --git a/lib/fib/rte_fib.c b/lib/fib/rte_fib.c
index 8af4c4091908..0c3b20e00a5a 100644
--- a/lib/fib/rte_fib.c
+++ b/lib/fib/rte_fib.c
@@ -5,6 +5,7 @@
 
 #include <stdint.h>
 #include <string.h>
+#include <sys/queue.h>
 
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
diff --git a/lib/fib/rte_fib6.c b/lib/fib/rte_fib6.c
index 4b8e22b142b9..28c69b38999f 100644
--- a/lib/fib/rte_fib6.c
+++ b/lib/fib/rte_fib6.c
@@ -5,6 +5,7 @@
 
 #include <stdint.h>
 #include <string.h>
+#include <sys/queue.h>
 
 #include <rte_eal_memconfig.h>
 #include <rte_tailq.h>
-- 
2.39.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v3 8/8] pcapng: windows compatibility
  2023-02-19 17:50   ` [PATCH v3 " Stephen Hemminger
                       ` (6 preceding siblings ...)
  2023-02-19 17:50     ` [PATCH v3 7/8] fib: " Stephen Hemminger
@ 2023-02-19 17:50     ` Stephen Hemminger
  7 siblings, 0 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-02-19 17:50 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tyler Retzlaff, Reshma Pattan

Allow building on Windows, need to provide some comparability
wrappers for writev() and if_nametoindex.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/pcapng/meson.build  |  6 -----
 lib/pcapng/rte_pcapng.c | 59 +++++++++++++++++++++++++++++++++++++++--
 2 files changed, 57 insertions(+), 8 deletions(-)

diff --git a/lib/pcapng/meson.build b/lib/pcapng/meson.build
index da938bbcb733..4549925d41b6 100644
--- a/lib/pcapng/meson.build
+++ b/lib/pcapng/meson.build
@@ -1,12 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2019 Microsoft Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_pcapng.c')
 headers = files('rte_pcapng.h')
 
diff --git a/lib/pcapng/rte_pcapng.c b/lib/pcapng/rte_pcapng.c
index 65c8c77fa405..d4b2db773160 100644
--- a/lib/pcapng/rte_pcapng.c
+++ b/lib/pcapng/rte_pcapng.c
@@ -3,15 +3,18 @@
  */
 
 #include <errno.h>
-#include <net/if.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/uio.h>
 #include <time.h>
 #include <unistd.h>
 
+#ifndef RTE_EXEC_ENV_WINDOWS
+#include <net/if.h>
+#include <sys/uio.h>
+#endif
+
 #include <bus_driver.h>
 #include <rte_common.h>
 #include <rte_cycles.h>
@@ -20,6 +23,7 @@
 #include <rte_ethdev.h>
 #include <rte_ether.h>
 #include <rte_mbuf.h>
+#include <rte_os_shim.h>
 #include <rte_pcapng.h>
 #include <rte_reciprocal.h>
 #include <rte_time.h>
@@ -47,6 +51,57 @@ static struct pcapng_time {
 	struct rte_reciprocal_u64 tsc_hz_inverse;
 } pcapng_time;
 
+
+#ifdef RTE_EXEC_ENV_WINDOWS
+/*
+ * Windows does not have writev() call.
+ * Emulate this by copying to a new buffer.
+ * The copy is necessary since pcapng needs to be thread-safe
+ * and do atomic write operations.
+ */
+
+#define IOV_MAX 128
+struct iovec {
+	void   *iov_base;
+	size_t  iov_len;
+};
+
+static ssize_t writev(int fd, const struct iovec *iov, int iovcnt)
+{
+	size_t bytes = 0;
+	uint8_t *ptr;
+	void *tmp_buf;
+	ssize_t ret;
+	int i;
+
+	for (i = 0; i < iovcnt; i++)
+		bytes += iov[i].iov_len;
+
+	if (unlikely(bytes == 0))
+		return 0;
+
+	tmp_buf = malloc(bytes);
+	if (unlikely(tmp_buf == NULL)) {
+		errno = ENOMEM;
+		return -1;
+	}
+
+	ptr = tmp_buf;
+	for (i = 0; i < iovcnt; i++) {
+		rte_memcpy(ptr, iov[i].iov_base, iov[i].iov_len);
+		ptr += iov[i].iov_len;
+	}
+
+	ret = write(fd, tmp_buf, bytes);
+	free(tmp_buf);
+	return ret;
+}
+
+#define IF_NAMESIZE	16
+/* compatiablity wrapper because name is optional */
+#define if_indextoname(ifindex, ifname) NULL
+#endif
+
 static inline void
 pcapng_init(void)
 {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v4 0/9] Enable building more libraries on Windows
  2023-02-07  0:19 ` [PATCH v2 0/8] Enable building more libraries on Windows Stephen Hemminger
                     ` (9 preceding siblings ...)
  2023-02-19 17:50   ` [PATCH v3 " Stephen Hemminger
@ 2023-02-19 23:14   ` Stephen Hemminger
  2023-02-19 23:14     ` [PATCH v4 1/9] net/null: build null PMD " Stephen Hemminger
                       ` (9 more replies)
  10 siblings, 10 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-02-19 23:14 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

While diagnosing some Windows cross build errors;
noticed that lots of important DPDK libraries are not
being built on Windows.

Stephen Hemminger (8):
  net/null: build null PMD on Windows
  net/ring: build on Windows
  lpm: enable on Windows
  reorder: build on Windows
  ip_frag: enable build on Windows
  rib: enable on Windows
  fib: enable on Windows
  pcapng: windows compatibility

v4 - fix spelling in commnet
     enable build of lib/table as well

v3 - add rte_os_shim.h to rte_ring to fix use of
     strdup() breaking with stricter MS compiler

v2 - fix unnecessary PATH_MAX in net/ring driver

Stephen Hemminger (9):
  net/null: build null PMD on Windows
  net/ring: build on Windows
  lpm: enable on Windows
  reorder: build on Windows
  ip_frag: enable build on Windows
  rib: enable on Windows
  fib: enable on Windows
  pcapng: windows compatibility
  table: enable build on Windows

 app/test/meson.build            |  2 +-
 app/test/test_fib.c             | 22 +-----------
 app/test/test_fib6.c            | 24 ++------------
 app/test/test_fib6_perf.c       | 15 +--------
 app/test/test_fib_perf.c        | 19 ++---------
 app/test/test_ipfrag.c          | 12 -------
 app/test/test_lpm.c             | 15 +--------
 app/test/test_lpm6.c            | 12 -------
 app/test/test_lpm6_data.h       |  3 +-
 app/test/test_lpm6_perf.c       | 14 +-------
 app/test/test_lpm_perf.c        | 39 +++++++---------------
 app/test/test_reorder.c         | 11 ------
 app/test/test_rib.c             | 19 -----------
 app/test/test_rib6.c            | 24 ++------------
 drivers/net/null/meson.build    |  6 ----
 drivers/net/ring/meson.build    |  6 ----
 drivers/net/ring/rte_eth_ring.c |  4 ++-
 lib/fib/meson.build             |  6 ----
 lib/fib/rte_fib.c               |  1 +
 lib/fib/rte_fib6.c              |  1 +
 lib/ip_frag/ip_frag_common.h    |  2 ++
 lib/ip_frag/meson.build         |  6 ----
 lib/lpm/meson.build             |  6 ----
 lib/pcapng/meson.build          |  6 ----
 lib/pcapng/rte_pcapng.c         | 59 +++++++++++++++++++++++++++++++--
 lib/reorder/meson.build         |  6 ----
 lib/reorder/rte_reorder.c       |  1 +
 lib/rib/meson.build             |  6 ----
 lib/rib/rte_rib.c               |  1 +
 lib/rib/rte_rib6.c              |  1 +
 lib/table/meson.build           |  6 ----
 31 files changed, 93 insertions(+), 262 deletions(-)

-- 
2.39.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v4 1/9] net/null: build null PMD on Windows
  2023-02-19 23:14   ` [PATCH v4 0/9] Enable building more libraries on Windows Stephen Hemminger
@ 2023-02-19 23:14     ` Stephen Hemminger
  2023-02-19 23:14     ` [PATCH v4 2/9] net/ring: build " Stephen Hemminger
                       ` (8 subsequent siblings)
  9 siblings, 0 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-02-19 23:14 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tyler Retzlaff, Tetsuya Mukawa

Builds fine with current code, no changes needed.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 drivers/net/null/meson.build | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/net/null/meson.build b/drivers/net/null/meson.build
index 4a483955a7a9..a51f8f5211b0 100644
--- a/drivers/net/null/meson.build
+++ b/drivers/net/null/meson.build
@@ -1,11 +1,5 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_eth_null.c')
 pmd_supports_disable_iova_as_pa = true
-- 
2.39.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v4 2/9] net/ring: build on Windows
  2023-02-19 23:14   ` [PATCH v4 0/9] Enable building more libraries on Windows Stephen Hemminger
  2023-02-19 23:14     ` [PATCH v4 1/9] net/null: build null PMD " Stephen Hemminger
@ 2023-02-19 23:14     ` Stephen Hemminger
  2023-03-09 21:10       ` David Marchand
  2023-02-19 23:14     ` [PATCH v4 3/9] lpm: enable " Stephen Hemminger
                       ` (7 subsequent siblings)
  9 siblings, 1 reply; 66+ messages in thread
From: Stephen Hemminger @ 2023-02-19 23:14 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tyler Retzlaff, Bruce Richardson

The command line arguments are stored in node_action_pair
and the name[] was sized to PATH_MAX which does not exist on Windows.
Since the name is either "CREATE" or "ATTACH" it is not
related to PATH_MAX (4096).

With this fix driver builds ok on windows, but need to modify the
test meson build to skip the eventdev test on Windows.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 app/test/meson.build            | 2 +-
 drivers/net/ring/meson.build    | 6 ------
 drivers/net/ring/rte_eth_ring.c | 4 +++-
 3 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/app/test/meson.build b/app/test/meson.build
index f34d19e3c3cb..a713f0382280 100644
--- a/app/test/meson.build
+++ b/app/test/meson.build
@@ -390,7 +390,7 @@ if dpdk_conf.has('RTE_NET_BOND')
         driver_test_names += 'link_bonding_mode4_autotest'
     endif
 endif
-if dpdk_conf.has('RTE_NET_RING')
+if dpdk_conf.has('RTE_LIB_EVENTDEV') and dpdk_conf.has('RTE_NET_RING')
     test_deps += 'net_ring'
     test_sources += 'test_pmd_ring_perf.c'
     test_sources += 'test_pmd_ring.c'
diff --git a/drivers/net/ring/meson.build b/drivers/net/ring/meson.build
index 72792e26b05a..3534a3cc2287 100644
--- a/drivers/net/ring/meson.build
+++ b/drivers/net/ring/meson.build
@@ -1,12 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_eth_ring.c')
 headers = files('rte_eth_ring.h')
 pmd_supports_disable_iova_as_pa = true
diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index bd5a47dd9017..e8bc9b627102 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -9,6 +9,7 @@
 #include <ethdev_driver.h>
 #include <rte_malloc.h>
 #include <rte_memcpy.h>
+#include <rte_os_shim.h>
 #include <rte_string_fns.h>
 #include <bus_vdev_driver.h>
 #include <rte_kvargs.h>
@@ -17,6 +18,7 @@
 #define ETH_RING_NUMA_NODE_ACTION_ARG	"nodeaction"
 #define ETH_RING_ACTION_CREATE		"CREATE"
 #define ETH_RING_ACTION_ATTACH		"ATTACH"
+#define ETH_RING_ACTION_MAX_LEN		8 /* CREATE | ACTION */
 #define ETH_RING_INTERNAL_ARG		"internal"
 #define ETH_RING_INTERNAL_ARG_MAX_LEN	19 /* "0x..16chars..\0" */
 
@@ -539,7 +541,7 @@ eth_dev_ring_create(const char *name,
 }
 
 struct node_action_pair {
-	char name[PATH_MAX];
+	char name[ETH_RING_ACTION_MAX_LEN];
 	unsigned int node;
 	enum dev_action action;
 };
-- 
2.39.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v4 3/9] lpm: enable on Windows
  2023-02-19 23:14   ` [PATCH v4 0/9] Enable building more libraries on Windows Stephen Hemminger
  2023-02-19 23:14     ` [PATCH v4 1/9] net/null: build null PMD " Stephen Hemminger
  2023-02-19 23:14     ` [PATCH v4 2/9] net/ring: build " Stephen Hemminger
@ 2023-02-19 23:14     ` Stephen Hemminger
  2023-02-19 23:14     ` [PATCH v4 4/9] reorder: build " Stephen Hemminger
                       ` (6 subsequent siblings)
  9 siblings, 0 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-02-19 23:14 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Tyler Retzlaff, Bruce Richardson, Vladimir Medvedkin

This builds on Windows without changes.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 app/test/test_lpm.c       | 15 +--------------
 app/test/test_lpm6.c      | 12 ------------
 app/test/test_lpm6_data.h |  3 ++-
 app/test/test_lpm6_perf.c | 14 +-------------
 app/test/test_lpm_perf.c  | 39 ++++++++++++---------------------------
 lib/lpm/meson.build       |  6 ------
 6 files changed, 16 insertions(+), 73 deletions(-)

diff --git a/app/test/test_lpm.c b/app/test/test_lpm.c
index bceb9ae743d7..37b460af3a96 100644
--- a/app/test/test_lpm.c
+++ b/app/test/test_lpm.c
@@ -2,18 +2,6 @@
  * Copyright(c) 2010-2014 Intel Corporation
  */
 
-#include "test.h"
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_lpm(void)
-{
-	printf("lpm not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
@@ -22,6 +10,7 @@ test_lpm(void)
 #include <rte_lpm.h>
 #include <rte_malloc.h>
 
+#include "test.h"
 #include "test_xmmt_ops.h"
 
 #define TEST_LPM_ASSERT(cond) do {                                            \
@@ -1595,6 +1584,4 @@ test_lpm(void)
 	return global_status;
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(lpm_autotest, test_lpm);
diff --git a/app/test/test_lpm6.c b/app/test/test_lpm6.c
index 1f44392db739..b6b6f8615ea5 100644
--- a/app/test/test_lpm6.c
+++ b/app/test/test_lpm6.c
@@ -10,16 +10,6 @@
 #include <string.h>
 
 #include <rte_memory.h>
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_lpm6(void)
-{
-	printf("lpm6 not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
 #include <rte_lpm6.h>
 
 #include "test_lpm6_data.h"
@@ -1803,6 +1793,4 @@ test_lpm6(void)
 	return global_status;
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(lpm6_autotest, test_lpm6);
diff --git a/app/test/test_lpm6_data.h b/app/test/test_lpm6_data.h
index da9b161f20e5..3a1fa25f8433 100644
--- a/app/test/test_lpm6_data.h
+++ b/app/test/test_lpm6_data.h
@@ -6,6 +6,7 @@
 
 #include <stdint.h>
 #include <stdlib.h>
+#include <rte_random.h>
 
 struct rules_tbl_entry {
 	uint8_t ip[16];
@@ -1129,7 +1130,7 @@ static void generate_large_ips_table(int gen_expected_next_hop)
 
 	for (i = 0; i < NUM_IPS_ENTRIES; i++) {
 		for (j = 0; j < 16; j++)
-			large_ips_table[i].ip[j] = lrand48();
+			large_ips_table[i].ip[j] = rte_rand();
 	}
 
 	for (k = j = 0, i = 0; i < NUM_IPS_ENTRIES; i++) {
diff --git a/app/test/test_lpm6_perf.c b/app/test/test_lpm6_perf.c
index aaf2773b6fac..5b684686a687 100644
--- a/app/test/test_lpm6_perf.c
+++ b/app/test/test_lpm6_perf.c
@@ -2,17 +2,6 @@
  * Copyright(c) 2010-2014 Intel Corporation
  */
 
-#include "test.h"
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_lpm6_perf(void)
-{
-	printf("lpm6_perf not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
 
 #include <stdio.h>
 #include <stdint.h>
@@ -24,6 +13,7 @@ test_lpm6_perf(void)
 #include <rte_memory.h>
 #include <rte_lpm6.h>
 
+#include "test.h"
 #include "test_lpm6_data.h"
 
 #define TEST_LPM_ASSERT(cond) do {                                            \
@@ -171,6 +161,4 @@ test_lpm6_perf(void)
 	return 0;
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(lpm6_perf_autotest, test_lpm6_perf);
diff --git a/app/test/test_lpm_perf.c b/app/test/test_lpm_perf.c
index e858716f909b..e72437ba3850 100644
--- a/app/test/test_lpm_perf.c
+++ b/app/test/test_lpm_perf.c
@@ -3,17 +3,6 @@
  * Copyright(c) 2020 Arm Limited
  */
 
-#include "test.h"
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_lpm_perf(void)
-{
-	printf("lpm_perf not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
@@ -25,7 +14,9 @@ test_lpm_perf(void)
 #include <rte_malloc.h>
 #include <rte_ip.h>
 #include <rte_lpm.h>
+#include <rte_spinlock.h>
 
+#include "test.h"
 #include "test_xmmt_ops.h"
 
 struct rte_lpm *lpm;
@@ -34,8 +25,9 @@ static volatile uint8_t writer_done;
 static volatile uint32_t thr_id;
 static uint64_t gwrite_cycles;
 static uint32_t num_writers;
-/* LPM APIs are not thread safe, use mutex to provide thread safety */
-static pthread_mutex_t lpm_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+/* LPM APIs are not thread safe, use spinlock */
+static rte_spinlock_t lpm_lock = RTE_SPINLOCK_INITIALIZER;
 
 /* Report quiescent state interval every 1024 lookups. Larger critical
  * sections in reader will result in writer polling multiple times.
@@ -267,7 +259,7 @@ static void generate_random_rule_prefix(uint32_t ip_class, uint8_t depth)
 	/* Only generate rest bits except the most significant
 	 * fixed bits for IP address class
 	 */
-	start = lrand48() & mask;
+	start = rte_rand() & mask;
 	ptr_rule = &large_route_table[num_route_entries];
 	ptr_ldepth_rule = &large_ldepth_route_table[num_ldepth_route_entries];
 	for (k = 0; k < rule_num; k++) {
@@ -296,7 +288,7 @@ static void insert_rule_in_random_pos(uint32_t ip, uint8_t depth)
 	struct route_rule tmp;
 
 	do {
-		pos = lrand48();
+		pos = rte_rand();
 		try_count++;
 	} while ((try_count < 10) && (pos > num_route_entries));
 
@@ -452,8 +444,7 @@ test_lpm_rcu_qsbr_writer(void *arg)
 	for (i = 0; i < RCU_ITERATIONS; i++) {
 		/* Add all the entries */
 		for (j = si; j < ei; j++) {
-			if (num_writers > 1)
-				pthread_mutex_lock(&lpm_mutex);
+			rte_spinlock_lock(&lpm_lock);
 			if (rte_lpm_add(lpm, large_ldepth_route_table[j].ip,
 					large_ldepth_route_table[j].depth,
 					next_hop_add) != 0) {
@@ -461,22 +452,19 @@ test_lpm_rcu_qsbr_writer(void *arg)
 					i, j);
 				goto error;
 			}
-			if (num_writers > 1)
-				pthread_mutex_unlock(&lpm_mutex);
+			rte_spinlock_unlock(&lpm_lock);
 		}
 
 		/* Delete all the entries */
 		for (j = si; j < ei; j++) {
-			if (num_writers > 1)
-				pthread_mutex_lock(&lpm_mutex);
+			rte_spinlock_lock(&lpm_lock);
 			if (rte_lpm_delete(lpm, large_ldepth_route_table[j].ip,
 				large_ldepth_route_table[j].depth) != 0) {
 				printf("Failed to delete iteration %d, route# %d\n",
 					i, j);
 				goto error;
 			}
-			if (num_writers > 1)
-				pthread_mutex_unlock(&lpm_mutex);
+			rte_spinlock_unlock(&lpm_lock);
 		}
 	}
 
@@ -487,8 +475,7 @@ test_lpm_rcu_qsbr_writer(void *arg)
 	return 0;
 
 error:
-	if (num_writers > 1)
-		pthread_mutex_unlock(&lpm_mutex);
+	rte_spinlock_unlock(&lpm_lock);
 	return -1;
 }
 
@@ -773,6 +760,4 @@ test_lpm_perf(void)
 	return 0;
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(lpm_perf_autotest, test_lpm_perf);
diff --git a/lib/lpm/meson.build b/lib/lpm/meson.build
index 6b47361fcec0..4cd48886fc41 100644
--- a/lib/lpm/meson.build
+++ b/lib/lpm/meson.build
@@ -1,12 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_lpm.c', 'rte_lpm6.c')
 headers = files('rte_lpm.h', 'rte_lpm6.h')
 # since header files have different names, we can install all vector headers
-- 
2.39.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v4 4/9] reorder: build on Windows
  2023-02-19 23:14   ` [PATCH v4 0/9] Enable building more libraries on Windows Stephen Hemminger
                       ` (2 preceding siblings ...)
  2023-02-19 23:14     ` [PATCH v4 3/9] lpm: enable " Stephen Hemminger
@ 2023-02-19 23:14     ` Stephen Hemminger
  2023-02-19 23:14     ` [PATCH v4 5/9] ip_frag: enable " Stephen Hemminger
                       ` (5 subsequent siblings)
  9 siblings, 0 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-02-19 23:14 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tyler Retzlaff, Reshma Pattan

This builds on Windows if sys/queue.h is included.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 app/test/test_reorder.c   | 11 -----------
 lib/reorder/meson.build   |  6 ------
 lib/reorder/rte_reorder.c |  1 +
 3 files changed, 1 insertion(+), 17 deletions(-)

diff --git a/app/test/test_reorder.c b/app/test/test_reorder.c
index f0714a5c18a3..9ebd91477536 100644
--- a/app/test/test_reorder.c
+++ b/app/test/test_reorder.c
@@ -11,16 +11,6 @@
 #include <rte_cycles.h>
 #include <rte_errno.h>
 #include <rte_mbuf.h>
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_reorder(void)
-{
-	printf("reorder not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-#else
-
 #include <rte_reorder.h>
 #include <rte_lcore.h>
 #include <rte_malloc.h>
@@ -395,6 +385,5 @@ test_reorder(void)
 	return unit_test_suite_runner(&reorder_test_suite);
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
 
 REGISTER_TEST_COMMAND(reorder_autotest, test_reorder);
diff --git a/lib/reorder/meson.build b/lib/reorder/meson.build
index 621c1f350103..03aed53d9007 100644
--- a/lib/reorder/meson.build
+++ b/lib/reorder/meson.build
@@ -1,12 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_reorder.c')
 headers = files('rte_reorder.h')
 deps += ['mbuf']
diff --git a/lib/reorder/rte_reorder.c b/lib/reorder/rte_reorder.c
index 385ee479da42..00e2cf043e04 100644
--- a/lib/reorder/rte_reorder.c
+++ b/lib/reorder/rte_reorder.c
@@ -3,6 +3,7 @@
  */
 
 #include <string.h>
+#include <sys/queue.h>
 
 #include <rte_string_fns.h>
 #include <rte_log.h>
-- 
2.39.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v4 5/9] ip_frag: enable build on Windows
  2023-02-19 23:14   ` [PATCH v4 0/9] Enable building more libraries on Windows Stephen Hemminger
                       ` (3 preceding siblings ...)
  2023-02-19 23:14     ` [PATCH v4 4/9] reorder: build " Stephen Hemminger
@ 2023-02-19 23:14     ` Stephen Hemminger
  2023-02-19 23:14     ` [PATCH v4 6/9] rib: enable " Stephen Hemminger
                       ` (4 subsequent siblings)
  9 siblings, 0 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-02-19 23:14 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tyler Retzlaff, Konstantin Ananyev

This build works on Windows if sys/queue.h is included.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 app/test/test_ipfrag.c       | 12 ------------
 lib/ip_frag/ip_frag_common.h |  2 ++
 lib/ip_frag/meson.build      |  6 ------
 3 files changed, 2 insertions(+), 18 deletions(-)

diff --git a/app/test/test_ipfrag.c b/app/test/test_ipfrag.c
index 88cc4cdeea8d..402ce361c1a2 100644
--- a/app/test/test_ipfrag.c
+++ b/app/test/test_ipfrag.c
@@ -10,17 +10,6 @@
 #include <rte_cycles.h>
 #include <rte_hexdump.h>
 #include <rte_ip.h>
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_ipfrag(void)
-{
-	printf("ipfrag not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
 #include <rte_ip_frag.h>
 #include <rte_mbuf.h>
 #include <rte_random.h>
@@ -520,6 +509,5 @@ test_ipfrag(void)
 	return unit_test_suite_runner(&ipfrag_testsuite);
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
 
 REGISTER_TEST_COMMAND(ipfrag_autotest, test_ipfrag);
diff --git a/lib/ip_frag/ip_frag_common.h b/lib/ip_frag/ip_frag_common.h
index 9c0dbdeb6eb9..0f4ad72a90d9 100644
--- a/lib/ip_frag/ip_frag_common.h
+++ b/lib/ip_frag/ip_frag_common.h
@@ -8,6 +8,8 @@
 #include "rte_ip_frag.h"
 #include "ip_reassembly.h"
 
+#include <sys/queue.h>
+
 /* logging macros. */
 #ifdef RTE_LIBRTE_IP_FRAG_DEBUG
 #define	IP_FRAG_LOG(lvl, fmt, args...)	RTE_LOG(lvl, USER1, fmt, ##args)
diff --git a/lib/ip_frag/meson.build b/lib/ip_frag/meson.build
index 3a252bdaf6a4..ea2de09f7528 100644
--- a/lib/ip_frag/meson.build
+++ b/lib/ip_frag/meson.build
@@ -1,12 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files(
         'rte_ipv4_fragmentation.c',
         'rte_ipv6_fragmentation.c',
-- 
2.39.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v4 6/9] rib: enable on Windows
  2023-02-19 23:14   ` [PATCH v4 0/9] Enable building more libraries on Windows Stephen Hemminger
                       ` (4 preceding siblings ...)
  2023-02-19 23:14     ` [PATCH v4 5/9] ip_frag: enable " Stephen Hemminger
@ 2023-02-19 23:14     ` Stephen Hemminger
  2023-02-19 23:14     ` [PATCH v4 7/9] fib: " Stephen Hemminger
                       ` (3 subsequent siblings)
  9 siblings, 0 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-02-19 23:14 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tyler Retzlaff, Vladimir Medvedkin

The RIB library builds on Windows as long as sys/queue.h is included

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 app/test/test_rib.c  | 19 -------------------
 app/test/test_rib6.c | 24 ++----------------------
 lib/rib/meson.build  |  6 ------
 lib/rib/rte_rib.c    |  1 +
 lib/rib/rte_rib6.c   |  1 +
 5 files changed, 4 insertions(+), 47 deletions(-)

diff --git a/app/test/test_rib.c b/app/test/test_rib.c
index 06058f8f7c52..65b685641094 100644
--- a/app/test/test_rib.c
+++ b/app/test/test_rib.c
@@ -10,23 +10,6 @@
 #include <stdlib.h>
 
 #include <rte_ip.h>
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_rib(void)
-{
-	printf("rib not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-static int
-test_slow_rib(void)
-{
-	printf("slow_rib not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-#else
-
 #include <rte_rib.h>
 
 typedef int32_t (*rte_rib_test)(void);
@@ -380,7 +363,5 @@ test_slow_rib(void)
 	return unit_test_suite_runner(&rib_slow_tests);
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(rib_autotest, test_rib);
 REGISTER_TEST_COMMAND(rib_slow_autotest, test_slow_rib);
diff --git a/app/test/test_rib6.c b/app/test/test_rib6.c
index ba79aedea5f7..336b779d2e1e 100644
--- a/app/test/test_rib6.c
+++ b/app/test/test_rib6.c
@@ -3,32 +3,14 @@
  * Copyright(c) 2019 Intel Corporation
  */
 
-#include "test.h"
-
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
-
 #include <rte_ip.h>
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_rib6(void)
-{
-	printf("rib6 not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-static int
-test_slow_rib6(void)
-{
-	printf("slow_rib6 not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-#else
-
 #include <rte_rib6.h>
 
+#include "test.h"
+
 typedef int32_t (*rte_rib6_test)(void);
 
 static int32_t test_create_invalid(void);
@@ -385,7 +367,5 @@ test_slow_rib6(void)
 	return unit_test_suite_runner(&rib6_slow_tests);
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(rib6_autotest, test_rib6);
 REGISTER_TEST_COMMAND(rib6_slow_autotest, test_slow_rib6);
diff --git a/lib/rib/meson.build b/lib/rib/meson.build
index bda7f576e976..7bacbb453592 100644
--- a/lib/rib/meson.build
+++ b/lib/rib/meson.build
@@ -2,12 +2,6 @@
 # Copyright(c) 2018 Vladimir Medvedkin <medvedkinv@gmail.com>
 # Copyright(c) 2019 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_rib.c', 'rte_rib6.c')
 headers = files('rte_rib.h', 'rte_rib6.h')
 deps += ['mempool']
diff --git a/lib/rib/rte_rib.c b/lib/rib/rte_rib.c
index b0794edf66f5..812a2597d117 100644
--- a/lib/rib/rte_rib.c
+++ b/lib/rib/rte_rib.c
@@ -5,6 +5,7 @@
 
 #include <stdbool.h>
 #include <stdint.h>
+#include <sys/queue.h>
 
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
diff --git a/lib/rib/rte_rib6.c b/lib/rib/rte_rib6.c
index 19e4ff97c479..ae44281ae105 100644
--- a/lib/rib/rte_rib6.c
+++ b/lib/rib/rte_rib6.c
@@ -5,6 +5,7 @@
 
 #include <stdbool.h>
 #include <stdint.h>
+#include <sys/queue.h>
 
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
-- 
2.39.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v4 7/9] fib: enable on Windows
  2023-02-19 23:14   ` [PATCH v4 0/9] Enable building more libraries on Windows Stephen Hemminger
                       ` (5 preceding siblings ...)
  2023-02-19 23:14     ` [PATCH v4 6/9] rib: enable " Stephen Hemminger
@ 2023-02-19 23:14     ` Stephen Hemminger
  2023-02-19 23:14     ` [PATCH v4 8/9] pcapng: windows compatibility Stephen Hemminger
                       ` (2 subsequent siblings)
  9 siblings, 0 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-02-19 23:14 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tyler Retzlaff, Vladimir Medvedkin

The FIB library builds on Windows as long as sys/queue.h is defined.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 app/test/test_fib.c       | 22 +---------------------
 app/test/test_fib6.c      | 24 ++----------------------
 app/test/test_fib6_perf.c | 15 +--------------
 app/test/test_fib_perf.c  | 19 +++----------------
 lib/fib/meson.build       |  6 ------
 lib/fib/rte_fib.c         |  1 +
 lib/fib/rte_fib6.c        |  1 +
 7 files changed, 9 insertions(+), 79 deletions(-)

diff --git a/app/test/test_fib.c b/app/test/test_fib.c
index a2d1ea8f3abc..eb69d6e2fd4c 100644
--- a/app/test/test_fib.c
+++ b/app/test/test_fib.c
@@ -9,28 +9,10 @@
 
 #include <rte_ip.h>
 #include <rte_log.h>
+#include <rte_fib.h>
 
 #include "test.h"
 
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_fib(void)
-{
-	printf("fib not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-static int
-test_slow_fib(void)
-{
-	printf("slow_fib not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
-#include <rte_fib.h>
-
 typedef int32_t (*rte_fib_test)(void);
 
 static int32_t test_create_invalid(void);
@@ -433,7 +415,5 @@ test_slow_fib(void)
 	return unit_test_suite_runner(&fib_slow_tests);
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(fib_autotest, test_fib);
 REGISTER_TEST_COMMAND(fib_slow_autotest, test_slow_fib);
diff --git a/app/test/test_fib6.c b/app/test/test_fib6.c
index cd971e6ecdfb..15ad09178ae2 100644
--- a/app/test/test_fib6.c
+++ b/app/test/test_fib6.c
@@ -9,29 +9,11 @@
 
 #include <rte_memory.h>
 #include <rte_log.h>
-
-#include "test.h"
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_fib6(void)
-{
-	printf("fib not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-static int
-test_slow_fib6(void)
-{
-	printf("slow_fib not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
 #include <rte_rib6.h>
 #include <rte_fib6.h>
 
+#include "test.h"
+
 typedef int32_t (*rte_fib6_test)(void);
 
 static int32_t test_create_invalid(void);
@@ -442,7 +424,5 @@ test_slow_fib6(void)
 	return unit_test_suite_runner(&fib6_slow_tests);
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(fib6_autotest, test_fib6);
 REGISTER_TEST_COMMAND(fib6_slow_autotest, test_slow_fib6);
diff --git a/app/test/test_fib6_perf.c b/app/test/test_fib6_perf.c
index 21d2b65318e9..add20c2331b1 100644
--- a/app/test/test_fib6_perf.c
+++ b/app/test/test_fib6_perf.c
@@ -10,21 +10,10 @@
 #include <rte_cycles.h>
 #include <rte_random.h>
 #include <rte_memory.h>
+#include <rte_fib6.h>
 
 #include "test.h"
 
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_fib6_perf(void)
-{
-	printf("fib6_perf not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
-#include <rte_fib6.h>
-
 #include "test_lpm6_data.h"
 
 #define TEST_FIB_ASSERT(cond) do {				\
@@ -167,6 +156,4 @@ test_fib6_perf(void)
 	return 0;
 }
 
-#endif /*ifdef RTE_EXEC_ENV_WINDOWS*/
-
 REGISTER_TEST_COMMAND(fib6_perf_autotest, test_fib6_perf);
diff --git a/app/test/test_fib_perf.c b/app/test/test_fib_perf.c
index 9787874cc9b7..b56293e64f41 100644
--- a/app/test/test_fib_perf.c
+++ b/app/test/test_fib_perf.c
@@ -12,22 +12,11 @@
 #include <rte_random.h>
 #include <rte_branch_prediction.h>
 #include <rte_ip.h>
+#include <rte_fib.h>
 
 #include "test.h"
 #include "test_xmmt_ops.h"
 
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_fib_perf(void)
-{
-	printf("fib_perf not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
-#include <rte_fib.h>
-
 #define TEST_FIB_ASSERT(cond) do {				\
 	if (!(cond)) {						\
 		printf("Error at line %d:\n", __LINE__);	\
@@ -246,7 +235,7 @@ static void generate_random_rule_prefix(uint32_t ip_class, uint8_t depth)
 	/* Only generate rest bits except the most significant
 	 * fixed bits for IP address class
 	 */
-	start = lrand48() & mask;
+	start = rte_rand() & mask;
 	ptr_rule = &large_route_table[num_route_entries];
 	for (k = 0; k < rule_num; k++) {
 		ptr_rule->ip = (start << (RTE_FIB_MAX_DEPTH - depth))
@@ -265,7 +254,7 @@ static void insert_rule_in_random_pos(uint32_t ip, uint8_t depth)
 	struct route_rule tmp;
 
 	do {
-		pos = lrand48();
+		pos = rte_rand();
 		try_count++;
 	} while ((try_count < 10) && (pos > num_route_entries));
 
@@ -420,6 +409,4 @@ test_fib_perf(void)
 	return 0;
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(fib_perf_autotest, test_fib_perf);
diff --git a/lib/fib/meson.build b/lib/fib/meson.build
index 9b848d08417c..ddcae0617a73 100644
--- a/lib/fib/meson.build
+++ b/lib/fib/meson.build
@@ -2,12 +2,6 @@
 # Copyright(c) 2018 Vladimir Medvedkin <medvedkinv@gmail.com>
 # Copyright(c) 2019 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_fib.c', 'rte_fib6.c', 'dir24_8.c', 'trie.c')
 headers = files('rte_fib.h', 'rte_fib6.h')
 deps += ['rib']
diff --git a/lib/fib/rte_fib.c b/lib/fib/rte_fib.c
index 8af4c4091908..0c3b20e00a5a 100644
--- a/lib/fib/rte_fib.c
+++ b/lib/fib/rte_fib.c
@@ -5,6 +5,7 @@
 
 #include <stdint.h>
 #include <string.h>
+#include <sys/queue.h>
 
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
diff --git a/lib/fib/rte_fib6.c b/lib/fib/rte_fib6.c
index 4b8e22b142b9..28c69b38999f 100644
--- a/lib/fib/rte_fib6.c
+++ b/lib/fib/rte_fib6.c
@@ -5,6 +5,7 @@
 
 #include <stdint.h>
 #include <string.h>
+#include <sys/queue.h>
 
 #include <rte_eal_memconfig.h>
 #include <rte_tailq.h>
-- 
2.39.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v4 8/9] pcapng: windows compatibility
  2023-02-19 23:14   ` [PATCH v4 0/9] Enable building more libraries on Windows Stephen Hemminger
                       ` (6 preceding siblings ...)
  2023-02-19 23:14     ` [PATCH v4 7/9] fib: " Stephen Hemminger
@ 2023-02-19 23:14     ` Stephen Hemminger
  2023-02-19 23:14     ` [PATCH v4 9/9] table: enable build on Windows Stephen Hemminger
  2023-03-10 14:06     ` [PATCH v4 0/9] Enable building more libraries " David Marchand
  9 siblings, 0 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-02-19 23:14 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tyler Retzlaff, Reshma Pattan

Allow building on Windows, need to provide some comparability
wrappers for writev() and if_nametoindex.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/pcapng/meson.build  |  6 -----
 lib/pcapng/rte_pcapng.c | 59 +++++++++++++++++++++++++++++++++++++++--
 2 files changed, 57 insertions(+), 8 deletions(-)

diff --git a/lib/pcapng/meson.build b/lib/pcapng/meson.build
index da938bbcb733..4549925d41b6 100644
--- a/lib/pcapng/meson.build
+++ b/lib/pcapng/meson.build
@@ -1,12 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2019 Microsoft Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_pcapng.c')
 headers = files('rte_pcapng.h')
 
diff --git a/lib/pcapng/rte_pcapng.c b/lib/pcapng/rte_pcapng.c
index 65c8c77fa405..3c91fc77644a 100644
--- a/lib/pcapng/rte_pcapng.c
+++ b/lib/pcapng/rte_pcapng.c
@@ -3,15 +3,18 @@
  */
 
 #include <errno.h>
-#include <net/if.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/uio.h>
 #include <time.h>
 #include <unistd.h>
 
+#ifndef RTE_EXEC_ENV_WINDOWS
+#include <net/if.h>
+#include <sys/uio.h>
+#endif
+
 #include <bus_driver.h>
 #include <rte_common.h>
 #include <rte_cycles.h>
@@ -20,6 +23,7 @@
 #include <rte_ethdev.h>
 #include <rte_ether.h>
 #include <rte_mbuf.h>
+#include <rte_os_shim.h>
 #include <rte_pcapng.h>
 #include <rte_reciprocal.h>
 #include <rte_time.h>
@@ -47,6 +51,57 @@ static struct pcapng_time {
 	struct rte_reciprocal_u64 tsc_hz_inverse;
 } pcapng_time;
 
+
+#ifdef RTE_EXEC_ENV_WINDOWS
+/*
+ * Windows does not have writev() call.
+ * Emulate this by copying to a new buffer.
+ * The copy is necessary since pcapng needs to be thread-safe
+ * and do atomic write operations.
+ */
+
+#define IOV_MAX 128
+struct iovec {
+	void   *iov_base;
+	size_t  iov_len;
+};
+
+static ssize_t writev(int fd, const struct iovec *iov, int iovcnt)
+{
+	size_t bytes = 0;
+	uint8_t *ptr;
+	void *tmp_buf;
+	ssize_t ret;
+	int i;
+
+	for (i = 0; i < iovcnt; i++)
+		bytes += iov[i].iov_len;
+
+	if (unlikely(bytes == 0))
+		return 0;
+
+	tmp_buf = malloc(bytes);
+	if (unlikely(tmp_buf == NULL)) {
+		errno = ENOMEM;
+		return -1;
+	}
+
+	ptr = tmp_buf;
+	for (i = 0; i < iovcnt; i++) {
+		rte_memcpy(ptr, iov[i].iov_base, iov[i].iov_len);
+		ptr += iov[i].iov_len;
+	}
+
+	ret = write(fd, tmp_buf, bytes);
+	free(tmp_buf);
+	return ret;
+}
+
+#define IF_NAMESIZE	16
+/* compatibility wrapper because name is optional */
+#define if_indextoname(ifindex, ifname) NULL
+#endif
+
 static inline void
 pcapng_init(void)
 {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v4 9/9] table: enable build on Windows
  2023-02-19 23:14   ` [PATCH v4 0/9] Enable building more libraries on Windows Stephen Hemminger
                       ` (7 preceding siblings ...)
  2023-02-19 23:14     ` [PATCH v4 8/9] pcapng: windows compatibility Stephen Hemminger
@ 2023-02-19 23:14     ` Stephen Hemminger
  2023-03-06 21:07       ` Tyler Retzlaff
  2023-03-10 14:06     ` [PATCH v4 0/9] Enable building more libraries " David Marchand
  9 siblings, 1 reply; 66+ messages in thread
From: Stephen Hemminger @ 2023-02-19 23:14 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

There doesn't seem to be anything keeping this from building on Windows.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/table/meson.build | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/lib/table/meson.build b/lib/table/meson.build
index 4f826b4b27e8..f8cef24b5918 100644
--- a/lib/table/meson.build
+++ b/lib/table/meson.build
@@ -1,12 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files(
         'rte_swx_keycmp.c',
         'rte_swx_table_em.c',
-- 
2.39.1


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v4 9/9] table: enable build on Windows
  2023-02-19 23:14     ` [PATCH v4 9/9] table: enable build on Windows Stephen Hemminger
@ 2023-03-06 21:07       ` Tyler Retzlaff
  0 siblings, 0 replies; 66+ messages in thread
From: Tyler Retzlaff @ 2023-03-06 21:07 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, Cristian Dumitrescu

On Sun, Feb 19, 2023 at 03:14:16PM -0800, Stephen Hemminger wrote:
> There doesn't seem to be anything keeping this from building on Windows.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---

Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>

this series looks good to me, i see no barrier to having it merged?

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v4 2/9] net/ring: build on Windows
  2023-02-19 23:14     ` [PATCH v4 2/9] net/ring: build " Stephen Hemminger
@ 2023-03-09 21:10       ` David Marchand
  2023-03-09 21:21         ` Stephen Hemminger
  0 siblings, 1 reply; 66+ messages in thread
From: David Marchand @ 2023-03-09 21:10 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, Tyler Retzlaff, Bruce Richardson

On Mon, Feb 20, 2023 at 12:14 AM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> The command line arguments are stored in node_action_pair
> and the name[] was sized to PATH_MAX which does not exist on Windows.
> Since the name is either "CREATE" or "ATTACH" it is not
> related to PATH_MAX (4096).
>
> With this fix driver builds ok on windows, but need to modify the
> test meson build to skip the eventdev test on Windows.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---
>  app/test/meson.build            | 2 +-
>  drivers/net/ring/meson.build    | 6 ------
>  drivers/net/ring/rte_eth_ring.c | 4 +++-
>  3 files changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/app/test/meson.build b/app/test/meson.build
> index f34d19e3c3cb..a713f0382280 100644
> --- a/app/test/meson.build
> +++ b/app/test/meson.build
> @@ -390,7 +390,7 @@ if dpdk_conf.has('RTE_NET_BOND')
>          driver_test_names += 'link_bonding_mode4_autotest'
>      endif
>  endif
> -if dpdk_conf.has('RTE_NET_RING')
> +if dpdk_conf.has('RTE_LIB_EVENTDEV') and dpdk_conf.has('RTE_NET_RING')
>      test_deps += 'net_ring'
>      test_sources += 'test_pmd_ring_perf.c'
>      test_sources += 'test_pmd_ring.c'
> diff --git a/drivers/net/ring/meson.build b/drivers/net/ring/meson.build
> index 72792e26b05a..3534a3cc2287 100644
> --- a/drivers/net/ring/meson.build
> +++ b/drivers/net/ring/meson.build
> @@ -1,12 +1,6 @@
>  # SPDX-License-Identifier: BSD-3-Clause
>  # Copyright(c) 2017 Intel Corporation
>
> -if is_windows
> -    build = false
> -    reason = 'not supported on Windows'
> -    subdir_done()
> -endif
> -
>  sources = files('rte_eth_ring.c')
>  headers = files('rte_eth_ring.h')
>  pmd_supports_disable_iova_as_pa = true
> diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
> index bd5a47dd9017..e8bc9b627102 100644
> --- a/drivers/net/ring/rte_eth_ring.c
> +++ b/drivers/net/ring/rte_eth_ring.c
> @@ -9,6 +9,7 @@
>  #include <ethdev_driver.h>
>  #include <rte_malloc.h>
>  #include <rte_memcpy.h>
> +#include <rte_os_shim.h>

Is it still needed, since this patch drops use of PATH_MAX?


>  #include <rte_string_fns.h>
>  #include <bus_vdev_driver.h>
>  #include <rte_kvargs.h>
> @@ -17,6 +18,7 @@
>  #define ETH_RING_NUMA_NODE_ACTION_ARG  "nodeaction"
>  #define ETH_RING_ACTION_CREATE         "CREATE"
>  #define ETH_RING_ACTION_ATTACH         "ATTACH"
> +#define ETH_RING_ACTION_MAX_LEN                8 /* CREATE | ACTION */
>  #define ETH_RING_INTERNAL_ARG          "internal"
>  #define ETH_RING_INTERNAL_ARG_MAX_LEN  19 /* "0x..16chars..\0" */
>
> @@ -539,7 +541,7 @@ eth_dev_ring_create(const char *name,
>  }
>
>  struct node_action_pair {
> -       char name[PATH_MAX];
> +       char name[ETH_RING_ACTION_MAX_LEN];
>         unsigned int node;
>         enum dev_action action;
>  };
> --
> 2.39.1
>


-- 
David Marchand


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v4 2/9] net/ring: build on Windows
  2023-03-09 21:10       ` David Marchand
@ 2023-03-09 21:21         ` Stephen Hemminger
  2023-03-10  9:34           ` David Marchand
  0 siblings, 1 reply; 66+ messages in thread
From: Stephen Hemminger @ 2023-03-09 21:21 UTC (permalink / raw)
  To: David Marchand; +Cc: dev, Tyler Retzlaff, Bruce Richardson

On Thu, 9 Mar 2023 22:10:03 +0100
David Marchand <david.marchand@redhat.com> wrote:

> > diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
> > index bd5a47dd9017..e8bc9b627102 100644
> > --- a/drivers/net/ring/rte_eth_ring.c
> > +++ b/drivers/net/ring/rte_eth_ring.c
> > @@ -9,6 +9,7 @@
> >  #include <ethdev_driver.h>
> >  #include <rte_malloc.h>
> >  #include <rte_memcpy.h>
> > +#include <rte_os_shim.h>  
> 
> Is it still needed, since this patch drops use of PATH_MAX?

Let me submit a version without, I don't run windows just do cross builds.

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v5 0/9] Enable building more libraries on Windows
  2022-12-01  1:44 [PATCH 0/8] Enable building more on Windows Stephen Hemminger
                   ` (8 preceding siblings ...)
  2023-02-07  0:19 ` [PATCH v2 0/8] Enable building more libraries on Windows Stephen Hemminger
@ 2023-03-09 21:31 ` Stephen Hemminger
  2023-03-09 21:31   ` [PATCH v5 1/9] net/null: build null PMD " Stephen Hemminger
                     ` (8 more replies)
  9 siblings, 9 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-03-09 21:31 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

While diagnosing some Windows cross build errors;
noticed that lots of important DPDK libraries are not
being built on Windows.

Stephen Hemminger (8):
  net/null: build null PMD on Windows
  net/ring: build on Windows
  lpm: enable on Windows
  reorder: build on Windows
  ip_frag: enable build on Windows
  rib: enable on Windows
  fib: enable on Windows
  pcapng: windows compatibility

v5 - remove no longer needed rte_os_shim.h in ring

v4 - fix spelling in commnet
     enable build of lib/table as well

v3 - add rte_os_shim.h to rte_ring to fix use of
     strdup() breaking with stricter MS compiler

v2 - fix unnecessary PATH_MAX in net/ring driver

Stephen Hemminger (9):
  net/null: build null PMD on Windows
  net/ring: build on Windows
  lpm: enable on Windows
  reorder: build on Windows
  ip_frag: enable build on Windows
  rib: enable on Windows
  fib: enable on Windows
  pcapng: windows compatibility
  table: enable build on Windows

 app/test/meson.build            |  2 +-
 app/test/test_fib.c             | 22 +-----------
 app/test/test_fib6.c            | 24 ++------------
 app/test/test_fib6_perf.c       | 15 +--------
 app/test/test_fib_perf.c        | 19 ++---------
 app/test/test_ipfrag.c          | 12 -------
 app/test/test_lpm.c             | 15 +--------
 app/test/test_lpm6.c            | 12 -------
 app/test/test_lpm6_data.h       |  3 +-
 app/test/test_lpm6_perf.c       | 14 +-------
 app/test/test_lpm_perf.c        | 39 +++++++---------------
 app/test/test_reorder.c         | 11 ------
 app/test/test_rib.c             | 19 -----------
 app/test/test_rib6.c            | 24 ++------------
 drivers/net/null/meson.build    |  6 ----
 drivers/net/ring/meson.build    |  6 ----
 drivers/net/ring/rte_eth_ring.c |  3 +-
 lib/fib/meson.build             |  6 ----
 lib/fib/rte_fib.c               |  1 +
 lib/fib/rte_fib6.c              |  1 +
 lib/ip_frag/ip_frag_common.h    |  2 ++
 lib/ip_frag/meson.build         |  6 ----
 lib/lpm/meson.build             |  6 ----
 lib/pcapng/meson.build          |  6 ----
 lib/pcapng/rte_pcapng.c         | 59 +++++++++++++++++++++++++++++++--
 lib/reorder/meson.build         |  6 ----
 lib/reorder/rte_reorder.c       |  1 +
 lib/rib/meson.build             |  6 ----
 lib/rib/rte_rib.c               |  1 +
 lib/rib/rte_rib6.c              |  1 +
 lib/table/meson.build           |  6 ----
 31 files changed, 92 insertions(+), 262 deletions(-)

-- 
2.39.2


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v5 1/9] net/null: build null PMD on Windows
  2023-03-09 21:31 ` [PATCH v5 " Stephen Hemminger
@ 2023-03-09 21:31   ` Stephen Hemminger
  2023-03-09 21:31   ` [PATCH v5 2/9] net/ring: build " Stephen Hemminger
                     ` (7 subsequent siblings)
  8 siblings, 0 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-03-09 21:31 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tyler Retzlaff

Builds fine with current code, no changes needed.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 drivers/net/null/meson.build | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/net/null/meson.build b/drivers/net/null/meson.build
index 4a483955a7a9..a51f8f5211b0 100644
--- a/drivers/net/null/meson.build
+++ b/drivers/net/null/meson.build
@@ -1,11 +1,5 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_eth_null.c')
 pmd_supports_disable_iova_as_pa = true
-- 
2.39.2


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v5 2/9] net/ring: build on Windows
  2023-03-09 21:31 ` [PATCH v5 " Stephen Hemminger
  2023-03-09 21:31   ` [PATCH v5 1/9] net/null: build null PMD " Stephen Hemminger
@ 2023-03-09 21:31   ` Stephen Hemminger
  2023-03-09 21:31   ` [PATCH v5 3/9] lpm: enable " Stephen Hemminger
                     ` (6 subsequent siblings)
  8 siblings, 0 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-03-09 21:31 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tyler Retzlaff

The command line arguments are stored in node_action_pair
and the name[] was sized to PATH_MAX which does not exist on Windows.
Since the name is either "CREATE" or "ATTACH" it is not
related to PATH_MAX (4096).

With this fix driver builds ok on windows, but need to modify the
test meson build to skip the eventdev test on Windows.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 app/test/meson.build            | 2 +-
 drivers/net/ring/meson.build    | 6 ------
 drivers/net/ring/rte_eth_ring.c | 3 ++-
 3 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/app/test/meson.build b/app/test/meson.build
index 2db5ccf4ff93..5d788148780c 100644
--- a/app/test/meson.build
+++ b/app/test/meson.build
@@ -391,7 +391,7 @@ if dpdk_conf.has('RTE_NET_BOND')
         driver_test_names += 'link_bonding_mode4_autotest'
     endif
 endif
-if dpdk_conf.has('RTE_NET_RING')
+if dpdk_conf.has('RTE_LIB_EVENTDEV') and dpdk_conf.has('RTE_NET_RING')
     test_deps += 'net_ring'
     test_sources += 'test_pmd_ring_perf.c'
     test_sources += 'test_pmd_ring.c'
diff --git a/drivers/net/ring/meson.build b/drivers/net/ring/meson.build
index 72792e26b05a..3534a3cc2287 100644
--- a/drivers/net/ring/meson.build
+++ b/drivers/net/ring/meson.build
@@ -1,12 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_eth_ring.c')
 headers = files('rte_eth_ring.h')
 pmd_supports_disable_iova_as_pa = true
diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index bd5a47dd9017..564d6a726403 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -17,6 +17,7 @@
 #define ETH_RING_NUMA_NODE_ACTION_ARG	"nodeaction"
 #define ETH_RING_ACTION_CREATE		"CREATE"
 #define ETH_RING_ACTION_ATTACH		"ATTACH"
+#define ETH_RING_ACTION_MAX_LEN		8 /* CREATE | ACTION */
 #define ETH_RING_INTERNAL_ARG		"internal"
 #define ETH_RING_INTERNAL_ARG_MAX_LEN	19 /* "0x..16chars..\0" */
 
@@ -539,7 +540,7 @@ eth_dev_ring_create(const char *name,
 }
 
 struct node_action_pair {
-	char name[PATH_MAX];
+	char name[ETH_RING_ACTION_MAX_LEN];
 	unsigned int node;
 	enum dev_action action;
 };
-- 
2.39.2


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v5 3/9] lpm: enable on Windows
  2023-03-09 21:31 ` [PATCH v5 " Stephen Hemminger
  2023-03-09 21:31   ` [PATCH v5 1/9] net/null: build null PMD " Stephen Hemminger
  2023-03-09 21:31   ` [PATCH v5 2/9] net/ring: build " Stephen Hemminger
@ 2023-03-09 21:31   ` Stephen Hemminger
  2023-03-09 21:31   ` [PATCH v5 4/9] reorder: build " Stephen Hemminger
                     ` (5 subsequent siblings)
  8 siblings, 0 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-03-09 21:31 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tyler Retzlaff

This builds on Windows without changes.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 app/test/test_lpm.c       | 15 +--------------
 app/test/test_lpm6.c      | 12 ------------
 app/test/test_lpm6_data.h |  3 ++-
 app/test/test_lpm6_perf.c | 14 +-------------
 app/test/test_lpm_perf.c  | 39 ++++++++++++---------------------------
 lib/lpm/meson.build       |  6 ------
 6 files changed, 16 insertions(+), 73 deletions(-)

diff --git a/app/test/test_lpm.c b/app/test/test_lpm.c
index bceb9ae743d7..37b460af3a96 100644
--- a/app/test/test_lpm.c
+++ b/app/test/test_lpm.c
@@ -2,18 +2,6 @@
  * Copyright(c) 2010-2014 Intel Corporation
  */
 
-#include "test.h"
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_lpm(void)
-{
-	printf("lpm not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
@@ -22,6 +10,7 @@ test_lpm(void)
 #include <rte_lpm.h>
 #include <rte_malloc.h>
 
+#include "test.h"
 #include "test_xmmt_ops.h"
 
 #define TEST_LPM_ASSERT(cond) do {                                            \
@@ -1595,6 +1584,4 @@ test_lpm(void)
 	return global_status;
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(lpm_autotest, test_lpm);
diff --git a/app/test/test_lpm6.c b/app/test/test_lpm6.c
index 1f44392db739..b6b6f8615ea5 100644
--- a/app/test/test_lpm6.c
+++ b/app/test/test_lpm6.c
@@ -10,16 +10,6 @@
 #include <string.h>
 
 #include <rte_memory.h>
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_lpm6(void)
-{
-	printf("lpm6 not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
 #include <rte_lpm6.h>
 
 #include "test_lpm6_data.h"
@@ -1803,6 +1793,4 @@ test_lpm6(void)
 	return global_status;
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(lpm6_autotest, test_lpm6);
diff --git a/app/test/test_lpm6_data.h b/app/test/test_lpm6_data.h
index da9b161f20e5..3a1fa25f8433 100644
--- a/app/test/test_lpm6_data.h
+++ b/app/test/test_lpm6_data.h
@@ -6,6 +6,7 @@
 
 #include <stdint.h>
 #include <stdlib.h>
+#include <rte_random.h>
 
 struct rules_tbl_entry {
 	uint8_t ip[16];
@@ -1129,7 +1130,7 @@ static void generate_large_ips_table(int gen_expected_next_hop)
 
 	for (i = 0; i < NUM_IPS_ENTRIES; i++) {
 		for (j = 0; j < 16; j++)
-			large_ips_table[i].ip[j] = lrand48();
+			large_ips_table[i].ip[j] = rte_rand();
 	}
 
 	for (k = j = 0, i = 0; i < NUM_IPS_ENTRIES; i++) {
diff --git a/app/test/test_lpm6_perf.c b/app/test/test_lpm6_perf.c
index aaf2773b6fac..5b684686a687 100644
--- a/app/test/test_lpm6_perf.c
+++ b/app/test/test_lpm6_perf.c
@@ -2,17 +2,6 @@
  * Copyright(c) 2010-2014 Intel Corporation
  */
 
-#include "test.h"
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_lpm6_perf(void)
-{
-	printf("lpm6_perf not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
 
 #include <stdio.h>
 #include <stdint.h>
@@ -24,6 +13,7 @@ test_lpm6_perf(void)
 #include <rte_memory.h>
 #include <rte_lpm6.h>
 
+#include "test.h"
 #include "test_lpm6_data.h"
 
 #define TEST_LPM_ASSERT(cond) do {                                            \
@@ -171,6 +161,4 @@ test_lpm6_perf(void)
 	return 0;
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(lpm6_perf_autotest, test_lpm6_perf);
diff --git a/app/test/test_lpm_perf.c b/app/test/test_lpm_perf.c
index e858716f909b..e72437ba3850 100644
--- a/app/test/test_lpm_perf.c
+++ b/app/test/test_lpm_perf.c
@@ -3,17 +3,6 @@
  * Copyright(c) 2020 Arm Limited
  */
 
-#include "test.h"
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_lpm_perf(void)
-{
-	printf("lpm_perf not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
@@ -25,7 +14,9 @@ test_lpm_perf(void)
 #include <rte_malloc.h>
 #include <rte_ip.h>
 #include <rte_lpm.h>
+#include <rte_spinlock.h>
 
+#include "test.h"
 #include "test_xmmt_ops.h"
 
 struct rte_lpm *lpm;
@@ -34,8 +25,9 @@ static volatile uint8_t writer_done;
 static volatile uint32_t thr_id;
 static uint64_t gwrite_cycles;
 static uint32_t num_writers;
-/* LPM APIs are not thread safe, use mutex to provide thread safety */
-static pthread_mutex_t lpm_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+/* LPM APIs are not thread safe, use spinlock */
+static rte_spinlock_t lpm_lock = RTE_SPINLOCK_INITIALIZER;
 
 /* Report quiescent state interval every 1024 lookups. Larger critical
  * sections in reader will result in writer polling multiple times.
@@ -267,7 +259,7 @@ static void generate_random_rule_prefix(uint32_t ip_class, uint8_t depth)
 	/* Only generate rest bits except the most significant
 	 * fixed bits for IP address class
 	 */
-	start = lrand48() & mask;
+	start = rte_rand() & mask;
 	ptr_rule = &large_route_table[num_route_entries];
 	ptr_ldepth_rule = &large_ldepth_route_table[num_ldepth_route_entries];
 	for (k = 0; k < rule_num; k++) {
@@ -296,7 +288,7 @@ static void insert_rule_in_random_pos(uint32_t ip, uint8_t depth)
 	struct route_rule tmp;
 
 	do {
-		pos = lrand48();
+		pos = rte_rand();
 		try_count++;
 	} while ((try_count < 10) && (pos > num_route_entries));
 
@@ -452,8 +444,7 @@ test_lpm_rcu_qsbr_writer(void *arg)
 	for (i = 0; i < RCU_ITERATIONS; i++) {
 		/* Add all the entries */
 		for (j = si; j < ei; j++) {
-			if (num_writers > 1)
-				pthread_mutex_lock(&lpm_mutex);
+			rte_spinlock_lock(&lpm_lock);
 			if (rte_lpm_add(lpm, large_ldepth_route_table[j].ip,
 					large_ldepth_route_table[j].depth,
 					next_hop_add) != 0) {
@@ -461,22 +452,19 @@ test_lpm_rcu_qsbr_writer(void *arg)
 					i, j);
 				goto error;
 			}
-			if (num_writers > 1)
-				pthread_mutex_unlock(&lpm_mutex);
+			rte_spinlock_unlock(&lpm_lock);
 		}
 
 		/* Delete all the entries */
 		for (j = si; j < ei; j++) {
-			if (num_writers > 1)
-				pthread_mutex_lock(&lpm_mutex);
+			rte_spinlock_lock(&lpm_lock);
 			if (rte_lpm_delete(lpm, large_ldepth_route_table[j].ip,
 				large_ldepth_route_table[j].depth) != 0) {
 				printf("Failed to delete iteration %d, route# %d\n",
 					i, j);
 				goto error;
 			}
-			if (num_writers > 1)
-				pthread_mutex_unlock(&lpm_mutex);
+			rte_spinlock_unlock(&lpm_lock);
 		}
 	}
 
@@ -487,8 +475,7 @@ test_lpm_rcu_qsbr_writer(void *arg)
 	return 0;
 
 error:
-	if (num_writers > 1)
-		pthread_mutex_unlock(&lpm_mutex);
+	rte_spinlock_unlock(&lpm_lock);
 	return -1;
 }
 
@@ -773,6 +760,4 @@ test_lpm_perf(void)
 	return 0;
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(lpm_perf_autotest, test_lpm_perf);
diff --git a/lib/lpm/meson.build b/lib/lpm/meson.build
index 6b47361fcec0..4cd48886fc41 100644
--- a/lib/lpm/meson.build
+++ b/lib/lpm/meson.build
@@ -1,12 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_lpm.c', 'rte_lpm6.c')
 headers = files('rte_lpm.h', 'rte_lpm6.h')
 # since header files have different names, we can install all vector headers
-- 
2.39.2


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v5 4/9] reorder: build on Windows
  2023-03-09 21:31 ` [PATCH v5 " Stephen Hemminger
                     ` (2 preceding siblings ...)
  2023-03-09 21:31   ` [PATCH v5 3/9] lpm: enable " Stephen Hemminger
@ 2023-03-09 21:31   ` Stephen Hemminger
  2023-03-09 21:31   ` [PATCH v5 5/9] ip_frag: enable " Stephen Hemminger
                     ` (4 subsequent siblings)
  8 siblings, 0 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-03-09 21:31 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tyler Retzlaff

This builds on Windows if sys/queue.h is included.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 app/test/test_reorder.c   | 11 -----------
 lib/reorder/meson.build   |  6 ------
 lib/reorder/rte_reorder.c |  1 +
 3 files changed, 1 insertion(+), 17 deletions(-)

diff --git a/app/test/test_reorder.c b/app/test/test_reorder.c
index f391597a7836..39e48c3df1fa 100644
--- a/app/test/test_reorder.c
+++ b/app/test/test_reorder.c
@@ -11,16 +11,6 @@
 #include <rte_cycles.h>
 #include <rte_errno.h>
 #include <rte_mbuf.h>
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_reorder(void)
-{
-	printf("reorder not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-#else
-
 #include <rte_reorder.h>
 #include <rte_lcore.h>
 #include <rte_malloc.h>
@@ -557,6 +547,5 @@ test_reorder(void)
 	return unit_test_suite_runner(&reorder_test_suite);
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
 
 REGISTER_TEST_COMMAND(reorder_autotest, test_reorder);
diff --git a/lib/reorder/meson.build b/lib/reorder/meson.build
index 621c1f350103..03aed53d9007 100644
--- a/lib/reorder/meson.build
+++ b/lib/reorder/meson.build
@@ -1,12 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_reorder.c')
 headers = files('rte_reorder.h')
 deps += ['mbuf']
diff --git a/lib/reorder/rte_reorder.c b/lib/reorder/rte_reorder.c
index 6e029c9e02fd..9026403ea675 100644
--- a/lib/reorder/rte_reorder.c
+++ b/lib/reorder/rte_reorder.c
@@ -3,6 +3,7 @@
  */
 
 #include <string.h>
+#include <sys/queue.h>
 
 #include <rte_string_fns.h>
 #include <rte_log.h>
-- 
2.39.2


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v5 5/9] ip_frag: enable build on Windows
  2023-03-09 21:31 ` [PATCH v5 " Stephen Hemminger
                     ` (3 preceding siblings ...)
  2023-03-09 21:31   ` [PATCH v5 4/9] reorder: build " Stephen Hemminger
@ 2023-03-09 21:31   ` Stephen Hemminger
  2023-03-09 21:31   ` [PATCH v5 6/9] rib: enable " Stephen Hemminger
                     ` (3 subsequent siblings)
  8 siblings, 0 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-03-09 21:31 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tyler Retzlaff

This build works on Windows if sys/queue.h is included.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 app/test/test_ipfrag.c       | 12 ------------
 lib/ip_frag/ip_frag_common.h |  2 ++
 lib/ip_frag/meson.build      |  6 ------
 3 files changed, 2 insertions(+), 18 deletions(-)

diff --git a/app/test/test_ipfrag.c b/app/test/test_ipfrag.c
index 88cc4cdeea8d..402ce361c1a2 100644
--- a/app/test/test_ipfrag.c
+++ b/app/test/test_ipfrag.c
@@ -10,17 +10,6 @@
 #include <rte_cycles.h>
 #include <rte_hexdump.h>
 #include <rte_ip.h>
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_ipfrag(void)
-{
-	printf("ipfrag not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
 #include <rte_ip_frag.h>
 #include <rte_mbuf.h>
 #include <rte_random.h>
@@ -520,6 +509,5 @@ test_ipfrag(void)
 	return unit_test_suite_runner(&ipfrag_testsuite);
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
 
 REGISTER_TEST_COMMAND(ipfrag_autotest, test_ipfrag);
diff --git a/lib/ip_frag/ip_frag_common.h b/lib/ip_frag/ip_frag_common.h
index 9c0dbdeb6eb9..0f4ad72a90d9 100644
--- a/lib/ip_frag/ip_frag_common.h
+++ b/lib/ip_frag/ip_frag_common.h
@@ -8,6 +8,8 @@
 #include "rte_ip_frag.h"
 #include "ip_reassembly.h"
 
+#include <sys/queue.h>
+
 /* logging macros. */
 #ifdef RTE_LIBRTE_IP_FRAG_DEBUG
 #define	IP_FRAG_LOG(lvl, fmt, args...)	RTE_LOG(lvl, USER1, fmt, ##args)
diff --git a/lib/ip_frag/meson.build b/lib/ip_frag/meson.build
index 3a252bdaf6a4..ea2de09f7528 100644
--- a/lib/ip_frag/meson.build
+++ b/lib/ip_frag/meson.build
@@ -1,12 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files(
         'rte_ipv4_fragmentation.c',
         'rte_ipv6_fragmentation.c',
-- 
2.39.2


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v5 6/9] rib: enable on Windows
  2023-03-09 21:31 ` [PATCH v5 " Stephen Hemminger
                     ` (4 preceding siblings ...)
  2023-03-09 21:31   ` [PATCH v5 5/9] ip_frag: enable " Stephen Hemminger
@ 2023-03-09 21:31   ` Stephen Hemminger
  2023-03-09 21:31   ` [PATCH v5 7/9] fib: " Stephen Hemminger
                     ` (2 subsequent siblings)
  8 siblings, 0 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-03-09 21:31 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tyler Retzlaff

The RIB library builds on Windows as long as sys/queue.h is included

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 app/test/test_rib.c  | 19 -------------------
 app/test/test_rib6.c | 24 ++----------------------
 lib/rib/meson.build  |  6 ------
 lib/rib/rte_rib.c    |  1 +
 lib/rib/rte_rib6.c   |  1 +
 5 files changed, 4 insertions(+), 47 deletions(-)

diff --git a/app/test/test_rib.c b/app/test/test_rib.c
index 06058f8f7c52..65b685641094 100644
--- a/app/test/test_rib.c
+++ b/app/test/test_rib.c
@@ -10,23 +10,6 @@
 #include <stdlib.h>
 
 #include <rte_ip.h>
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_rib(void)
-{
-	printf("rib not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-static int
-test_slow_rib(void)
-{
-	printf("slow_rib not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-#else
-
 #include <rte_rib.h>
 
 typedef int32_t (*rte_rib_test)(void);
@@ -380,7 +363,5 @@ test_slow_rib(void)
 	return unit_test_suite_runner(&rib_slow_tests);
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(rib_autotest, test_rib);
 REGISTER_TEST_COMMAND(rib_slow_autotest, test_slow_rib);
diff --git a/app/test/test_rib6.c b/app/test/test_rib6.c
index ba79aedea5f7..336b779d2e1e 100644
--- a/app/test/test_rib6.c
+++ b/app/test/test_rib6.c
@@ -3,32 +3,14 @@
  * Copyright(c) 2019 Intel Corporation
  */
 
-#include "test.h"
-
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
-
 #include <rte_ip.h>
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_rib6(void)
-{
-	printf("rib6 not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-static int
-test_slow_rib6(void)
-{
-	printf("slow_rib6 not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-#else
-
 #include <rte_rib6.h>
 
+#include "test.h"
+
 typedef int32_t (*rte_rib6_test)(void);
 
 static int32_t test_create_invalid(void);
@@ -385,7 +367,5 @@ test_slow_rib6(void)
 	return unit_test_suite_runner(&rib6_slow_tests);
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(rib6_autotest, test_rib6);
 REGISTER_TEST_COMMAND(rib6_slow_autotest, test_slow_rib6);
diff --git a/lib/rib/meson.build b/lib/rib/meson.build
index bda7f576e976..7bacbb453592 100644
--- a/lib/rib/meson.build
+++ b/lib/rib/meson.build
@@ -2,12 +2,6 @@
 # Copyright(c) 2018 Vladimir Medvedkin <medvedkinv@gmail.com>
 # Copyright(c) 2019 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_rib.c', 'rte_rib6.c')
 headers = files('rte_rib.h', 'rte_rib6.h')
 deps += ['mempool']
diff --git a/lib/rib/rte_rib.c b/lib/rib/rte_rib.c
index b0794edf66f5..812a2597d117 100644
--- a/lib/rib/rte_rib.c
+++ b/lib/rib/rte_rib.c
@@ -5,6 +5,7 @@
 
 #include <stdbool.h>
 #include <stdint.h>
+#include <sys/queue.h>
 
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
diff --git a/lib/rib/rte_rib6.c b/lib/rib/rte_rib6.c
index 19e4ff97c479..ae44281ae105 100644
--- a/lib/rib/rte_rib6.c
+++ b/lib/rib/rte_rib6.c
@@ -5,6 +5,7 @@
 
 #include <stdbool.h>
 #include <stdint.h>
+#include <sys/queue.h>
 
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
-- 
2.39.2


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v5 7/9] fib: enable on Windows
  2023-03-09 21:31 ` [PATCH v5 " Stephen Hemminger
                     ` (5 preceding siblings ...)
  2023-03-09 21:31   ` [PATCH v5 6/9] rib: enable " Stephen Hemminger
@ 2023-03-09 21:31   ` Stephen Hemminger
  2023-03-09 21:31   ` [PATCH v5 8/9] pcapng: windows compatibility Stephen Hemminger
  2023-03-09 21:31   ` [PATCH v5 9/9] table: enable build on Windows Stephen Hemminger
  8 siblings, 0 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-03-09 21:31 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tyler Retzlaff

The FIB library builds on Windows as long as sys/queue.h is defined.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 app/test/test_fib.c       | 22 +---------------------
 app/test/test_fib6.c      | 24 ++----------------------
 app/test/test_fib6_perf.c | 15 +--------------
 app/test/test_fib_perf.c  | 19 +++----------------
 lib/fib/meson.build       |  6 ------
 lib/fib/rte_fib.c         |  1 +
 lib/fib/rte_fib6.c        |  1 +
 7 files changed, 9 insertions(+), 79 deletions(-)

diff --git a/app/test/test_fib.c b/app/test/test_fib.c
index a2d1ea8f3abc..eb69d6e2fd4c 100644
--- a/app/test/test_fib.c
+++ b/app/test/test_fib.c
@@ -9,28 +9,10 @@
 
 #include <rte_ip.h>
 #include <rte_log.h>
+#include <rte_fib.h>
 
 #include "test.h"
 
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_fib(void)
-{
-	printf("fib not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-static int
-test_slow_fib(void)
-{
-	printf("slow_fib not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
-#include <rte_fib.h>
-
 typedef int32_t (*rte_fib_test)(void);
 
 static int32_t test_create_invalid(void);
@@ -433,7 +415,5 @@ test_slow_fib(void)
 	return unit_test_suite_runner(&fib_slow_tests);
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(fib_autotest, test_fib);
 REGISTER_TEST_COMMAND(fib_slow_autotest, test_slow_fib);
diff --git a/app/test/test_fib6.c b/app/test/test_fib6.c
index cd971e6ecdfb..15ad09178ae2 100644
--- a/app/test/test_fib6.c
+++ b/app/test/test_fib6.c
@@ -9,29 +9,11 @@
 
 #include <rte_memory.h>
 #include <rte_log.h>
-
-#include "test.h"
-
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_fib6(void)
-{
-	printf("fib not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-static int
-test_slow_fib6(void)
-{
-	printf("slow_fib not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
 #include <rte_rib6.h>
 #include <rte_fib6.h>
 
+#include "test.h"
+
 typedef int32_t (*rte_fib6_test)(void);
 
 static int32_t test_create_invalid(void);
@@ -442,7 +424,5 @@ test_slow_fib6(void)
 	return unit_test_suite_runner(&fib6_slow_tests);
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(fib6_autotest, test_fib6);
 REGISTER_TEST_COMMAND(fib6_slow_autotest, test_slow_fib6);
diff --git a/app/test/test_fib6_perf.c b/app/test/test_fib6_perf.c
index 21d2b65318e9..add20c2331b1 100644
--- a/app/test/test_fib6_perf.c
+++ b/app/test/test_fib6_perf.c
@@ -10,21 +10,10 @@
 #include <rte_cycles.h>
 #include <rte_random.h>
 #include <rte_memory.h>
+#include <rte_fib6.h>
 
 #include "test.h"
 
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_fib6_perf(void)
-{
-	printf("fib6_perf not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
-#include <rte_fib6.h>
-
 #include "test_lpm6_data.h"
 
 #define TEST_FIB_ASSERT(cond) do {				\
@@ -167,6 +156,4 @@ test_fib6_perf(void)
 	return 0;
 }
 
-#endif /*ifdef RTE_EXEC_ENV_WINDOWS*/
-
 REGISTER_TEST_COMMAND(fib6_perf_autotest, test_fib6_perf);
diff --git a/app/test/test_fib_perf.c b/app/test/test_fib_perf.c
index 9787874cc9b7..b56293e64f41 100644
--- a/app/test/test_fib_perf.c
+++ b/app/test/test_fib_perf.c
@@ -12,22 +12,11 @@
 #include <rte_random.h>
 #include <rte_branch_prediction.h>
 #include <rte_ip.h>
+#include <rte_fib.h>
 
 #include "test.h"
 #include "test_xmmt_ops.h"
 
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_fib_perf(void)
-{
-	printf("fib_perf not supported on Windows, skipping test\n");
-	return TEST_SKIPPED;
-}
-
-#else
-
-#include <rte_fib.h>
-
 #define TEST_FIB_ASSERT(cond) do {				\
 	if (!(cond)) {						\
 		printf("Error at line %d:\n", __LINE__);	\
@@ -246,7 +235,7 @@ static void generate_random_rule_prefix(uint32_t ip_class, uint8_t depth)
 	/* Only generate rest bits except the most significant
 	 * fixed bits for IP address class
 	 */
-	start = lrand48() & mask;
+	start = rte_rand() & mask;
 	ptr_rule = &large_route_table[num_route_entries];
 	for (k = 0; k < rule_num; k++) {
 		ptr_rule->ip = (start << (RTE_FIB_MAX_DEPTH - depth))
@@ -265,7 +254,7 @@ static void insert_rule_in_random_pos(uint32_t ip, uint8_t depth)
 	struct route_rule tmp;
 
 	do {
-		pos = lrand48();
+		pos = rte_rand();
 		try_count++;
 	} while ((try_count < 10) && (pos > num_route_entries));
 
@@ -420,6 +409,4 @@ test_fib_perf(void)
 	return 0;
 }
 
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
 REGISTER_TEST_COMMAND(fib_perf_autotest, test_fib_perf);
diff --git a/lib/fib/meson.build b/lib/fib/meson.build
index 9b848d08417c..ddcae0617a73 100644
--- a/lib/fib/meson.build
+++ b/lib/fib/meson.build
@@ -2,12 +2,6 @@
 # Copyright(c) 2018 Vladimir Medvedkin <medvedkinv@gmail.com>
 # Copyright(c) 2019 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_fib.c', 'rte_fib6.c', 'dir24_8.c', 'trie.c')
 headers = files('rte_fib.h', 'rte_fib6.h')
 deps += ['rib']
diff --git a/lib/fib/rte_fib.c b/lib/fib/rte_fib.c
index 8af4c4091908..0c3b20e00a5a 100644
--- a/lib/fib/rte_fib.c
+++ b/lib/fib/rte_fib.c
@@ -5,6 +5,7 @@
 
 #include <stdint.h>
 #include <string.h>
+#include <sys/queue.h>
 
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
diff --git a/lib/fib/rte_fib6.c b/lib/fib/rte_fib6.c
index 4b8e22b142b9..28c69b38999f 100644
--- a/lib/fib/rte_fib6.c
+++ b/lib/fib/rte_fib6.c
@@ -5,6 +5,7 @@
 
 #include <stdint.h>
 #include <string.h>
+#include <sys/queue.h>
 
 #include <rte_eal_memconfig.h>
 #include <rte_tailq.h>
-- 
2.39.2


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v5 8/9] pcapng: windows compatibility
  2023-03-09 21:31 ` [PATCH v5 " Stephen Hemminger
                     ` (6 preceding siblings ...)
  2023-03-09 21:31   ` [PATCH v5 7/9] fib: " Stephen Hemminger
@ 2023-03-09 21:31   ` Stephen Hemminger
  2023-03-09 21:31   ` [PATCH v5 9/9] table: enable build on Windows Stephen Hemminger
  8 siblings, 0 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-03-09 21:31 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Tyler Retzlaff

Allow building on Windows, need to provide some comparability
wrappers for writev() and if_nametoindex.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/pcapng/meson.build  |  6 -----
 lib/pcapng/rte_pcapng.c | 59 +++++++++++++++++++++++++++++++++++++++--
 2 files changed, 57 insertions(+), 8 deletions(-)

diff --git a/lib/pcapng/meson.build b/lib/pcapng/meson.build
index da938bbcb733..4549925d41b6 100644
--- a/lib/pcapng/meson.build
+++ b/lib/pcapng/meson.build
@@ -1,12 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2019 Microsoft Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files('rte_pcapng.c')
 headers = files('rte_pcapng.h')
 
diff --git a/lib/pcapng/rte_pcapng.c b/lib/pcapng/rte_pcapng.c
index 65c8c77fa405..3c91fc77644a 100644
--- a/lib/pcapng/rte_pcapng.c
+++ b/lib/pcapng/rte_pcapng.c
@@ -3,15 +3,18 @@
  */
 
 #include <errno.h>
-#include <net/if.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/uio.h>
 #include <time.h>
 #include <unistd.h>
 
+#ifndef RTE_EXEC_ENV_WINDOWS
+#include <net/if.h>
+#include <sys/uio.h>
+#endif
+
 #include <bus_driver.h>
 #include <rte_common.h>
 #include <rte_cycles.h>
@@ -20,6 +23,7 @@
 #include <rte_ethdev.h>
 #include <rte_ether.h>
 #include <rte_mbuf.h>
+#include <rte_os_shim.h>
 #include <rte_pcapng.h>
 #include <rte_reciprocal.h>
 #include <rte_time.h>
@@ -47,6 +51,57 @@ static struct pcapng_time {
 	struct rte_reciprocal_u64 tsc_hz_inverse;
 } pcapng_time;
 
+
+#ifdef RTE_EXEC_ENV_WINDOWS
+/*
+ * Windows does not have writev() call.
+ * Emulate this by copying to a new buffer.
+ * The copy is necessary since pcapng needs to be thread-safe
+ * and do atomic write operations.
+ */
+
+#define IOV_MAX 128
+struct iovec {
+	void   *iov_base;
+	size_t  iov_len;
+};
+
+static ssize_t writev(int fd, const struct iovec *iov, int iovcnt)
+{
+	size_t bytes = 0;
+	uint8_t *ptr;
+	void *tmp_buf;
+	ssize_t ret;
+	int i;
+
+	for (i = 0; i < iovcnt; i++)
+		bytes += iov[i].iov_len;
+
+	if (unlikely(bytes == 0))
+		return 0;
+
+	tmp_buf = malloc(bytes);
+	if (unlikely(tmp_buf == NULL)) {
+		errno = ENOMEM;
+		return -1;
+	}
+
+	ptr = tmp_buf;
+	for (i = 0; i < iovcnt; i++) {
+		rte_memcpy(ptr, iov[i].iov_base, iov[i].iov_len);
+		ptr += iov[i].iov_len;
+	}
+
+	ret = write(fd, tmp_buf, bytes);
+	free(tmp_buf);
+	return ret;
+}
+
+#define IF_NAMESIZE	16
+/* compatibility wrapper because name is optional */
+#define if_indextoname(ifindex, ifname) NULL
+#endif
+
 static inline void
 pcapng_init(void)
 {
-- 
2.39.2


^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v5 9/9] table: enable build on Windows
  2023-03-09 21:31 ` [PATCH v5 " Stephen Hemminger
                     ` (7 preceding siblings ...)
  2023-03-09 21:31   ` [PATCH v5 8/9] pcapng: windows compatibility Stephen Hemminger
@ 2023-03-09 21:31   ` Stephen Hemminger
  8 siblings, 0 replies; 66+ messages in thread
From: Stephen Hemminger @ 2023-03-09 21:31 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

There doesn't seem to be anything keeping this from building on Windows.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/table/meson.build | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/lib/table/meson.build b/lib/table/meson.build
index 4f826b4b27e8..f8cef24b5918 100644
--- a/lib/table/meson.build
+++ b/lib/table/meson.build
@@ -1,12 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-if is_windows
-    build = false
-    reason = 'not supported on Windows'
-    subdir_done()
-endif
-
 sources = files(
         'rte_swx_keycmp.c',
         'rte_swx_table_em.c',
-- 
2.39.2


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v4 2/9] net/ring: build on Windows
  2023-03-09 21:21         ` Stephen Hemminger
@ 2023-03-10  9:34           ` David Marchand
  0 siblings, 0 replies; 66+ messages in thread
From: David Marchand @ 2023-03-10  9:34 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, Tyler Retzlaff, Bruce Richardson

On Thu, Mar 9, 2023 at 10:21 PM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> On Thu, 9 Mar 2023 22:10:03 +0100
> David Marchand <david.marchand@redhat.com> wrote:
>
> > > diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
> > > index bd5a47dd9017..e8bc9b627102 100644
> > > --- a/drivers/net/ring/rte_eth_ring.c
> > > +++ b/drivers/net/ring/rte_eth_ring.c
> > > @@ -9,6 +9,7 @@
> > >  #include <ethdev_driver.h>
> > >  #include <rte_malloc.h>
> > >  #include <rte_memcpy.h>
> > > +#include <rte_os_shim.h>
> >
> > Is it still needed, since this patch drops use of PATH_MAX?
>
> Let me submit a version without, I don't run windows just do cross builds.

Good thing you did.

So we still need this include for hack on strdup.
So the v4 series is enough.

If I manage to merge it today..., I'll simply update the commitlog.

libtmp_rte_net_ring.a.p" "-Idrivers" "-I..\drivers"
"-Idrivers\net\ring" "-I..\drivers\net\ring" "-Ilib\ethdev"
"-I..\lib\ethdev" "-I." "-I.." "-Iconfig" "-I..\config"
"-Ilib\eal\include" "-I..\lib\eal\include" "-Ilib\eal\windows\include"
"-I..\lib\eal\windows\include" "-Ilib\eal\x86\include"
"-I..\lib\eal\x86\include" "-Ilib\eal\common" "-I..\lib\eal\common"
"-Ilib\eal" "-I..\lib\eal" "-Ilib\kvargs" "-I..\lib\kvargs"
"-Ilib\net" "-I..\lib\net" "-Ilib\mbuf" "-I..\lib\mbuf"
"-Ilib\mempool" "-I..\lib\mempool" "-Ilib\ring" "-I..\lib\ring"
"-Ilib\metrics" "-I..\lib\metrics" "-Ilib\telemetry"
"-I..\lib\telemetry" "-Ilib\meter" "-I..\lib\meter"
"-Idrivers\bus\pci" "-I..\drivers\bus\pci"
"-I..\drivers\bus\pci\windows" "-Ilib\pci" "-I..\lib\pci"
"-Idrivers\bus\vdev" "-I..\drivers\bus\vdev" "-IC:\Program
Files\Mellanox\MLNX_WinOF2_DevX_SDK\inc" "-Xclang"
"-fcolor-diagnostics" "-pipe" "-D_FILE_OFFSET_BITS=64" "-Wall"
"-Winvalid-pch" "-Wextra" "-Werror" "-O3" "-include" "rte_config.h"
"-Wcast-qual" "-Wdeprecated" "-Wformat" "-Wformat-nonliteral"
"-Wformat-security" "-Wmissing-declarations" "-Wmissing-prototypes"
"-Wnested-externs" "-Wold-style-definition" "-Wpointer-arith"
"-Wsign-compare" "-Wstrict-prototypes" "-Wundef" "-Wwrite-strings"
"-Wno-address-of-packed-member" "-Wno-missing-field-initializers"
"-D_GNU_SOURCE" "-D_WIN32_WINNT=0x0A00" "-D_CRT_SECURE_NO_WARNINGS"
"-march=native" "-DALLOW_EXPERIMENTAL_API" "-DALLOW_INTERNAL_API"
"-DRTE_LOG_DEFAULT_LOGTYPE=pmd.net.ring" -MD -MQ
drivers/libtmp_rte_net_ring.a.p/net_ring_rte_eth_ring.c.obj -MF
"drivers\libtmp_rte_net_ring.a.p\net_ring_rte_eth_ring.c.obj.d" -o
drivers/libtmp_rte_net_ring.a.p/net_ring_rte_eth_ring.c.obj "-c"
../drivers/net/ring/rte_eth_ring.c
../drivers/net/ring/rte_eth_ring.c:564:9: error: 'strdup' is
deprecated: The POSIX name for this item is deprecated. Instead, use
the ISO C and C++ conformant name: _strdup. See online help for
details. [-Werror,-Wdeprecated-declarations]
        name = strdup(value);
               ^
C:\Program Files (x86)\Windows
Kits\10\Include\10.0.18362.0\ucrt\string.h:535:20: note: 'strdup' has
been explicitly marked deprecated here
    _Check_return_ _CRT_NONSTDC_DEPRECATE(_strdup)
                   ^
C:\Program Files (x86)\Windows
Kits\10\Include\10.0.18362.0\ucrt\corecrt.h:335:50: note: expanded
from macro '_CRT_NONSTDC_DEPRECATE'
        #define _CRT_NONSTDC_DEPRECATE(_NewName) _CRT_DEPRECATE_TEXT(
           \
                                                 ^
C:\Program Files (x86)\Microsoft Visual
Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\vcruntime.h:310:47:
note: expanded from macro '_CRT_DEPRECATE_TEXT'
#define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated(_Text))
                                              ^
1 error generated


-- 
David Marchand


^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v4 0/9] Enable building more libraries on Windows
  2023-02-19 23:14   ` [PATCH v4 0/9] Enable building more libraries on Windows Stephen Hemminger
                       ` (8 preceding siblings ...)
  2023-02-19 23:14     ` [PATCH v4 9/9] table: enable build on Windows Stephen Hemminger
@ 2023-03-10 14:06     ` David Marchand
  9 siblings, 0 replies; 66+ messages in thread
From: David Marchand @ 2023-03-10 14:06 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, Tyler Retzlaff, Thomas Monjalon

On Mon, Feb 20, 2023 at 12:14 AM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> While diagnosing some Windows cross build errors;
> noticed that lots of important DPDK libraries are not
> being built on Windows.
>
> Stephen Hemminger (8):
>   net/null: build null PMD on Windows
>   net/ring: build on Windows
>   lpm: enable on Windows
>   reorder: build on Windows
>   ip_frag: enable build on Windows
>   rib: enable on Windows
>   fib: enable on Windows
>   pcapng: windows compatibility

Tweaked commitlogs and applied.
Thanks.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 66+ messages in thread

end of thread, other threads:[~2023-03-10 14:07 UTC | newest]

Thread overview: 66+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-01  1:44 [PATCH 0/8] Enable building more on Windows Stephen Hemminger
2022-12-01  1:44 ` [PATCH 1/8] net/null: build null PMD " Stephen Hemminger
2022-12-01 23:51   ` Tyler Retzlaff
2022-12-01  1:44 ` [PATCH 2/8] net/ring: build " Stephen Hemminger
2022-12-01 23:52   ` Tyler Retzlaff
2022-12-14 23:18   ` Kadam, Pallavi
2022-12-15  3:22     ` Stephen Hemminger
2022-12-15 17:48       ` Tyler Retzlaff
2022-12-15 18:09         ` Dmitry Kozlyuk
2022-12-01  1:44 ` [PATCH 3/8] lpm: enable " Stephen Hemminger
2022-12-01 23:53   ` Tyler Retzlaff
2022-12-01  1:44 ` [PATCH 4/8] reorder: build " Stephen Hemminger
2022-12-01 23:53   ` Tyler Retzlaff
2022-12-01  1:44 ` [PATCH 5/8] ip_frag: enable " Stephen Hemminger
2022-12-01 23:54   ` Tyler Retzlaff
2022-12-01  1:44 ` [PATCH 6/8] rib: enable " Stephen Hemminger
2022-12-01 23:54   ` Tyler Retzlaff
2022-12-01  1:44 ` [PATCH 7/8] fib: " Stephen Hemminger
2022-12-01 23:54   ` Tyler Retzlaff
2022-12-01  1:44 ` [PATCH 8/8] pcapng: windows compatability Stephen Hemminger
2022-12-01 23:55   ` Tyler Retzlaff
2023-02-07  0:19 ` [PATCH v2 0/8] Enable building more libraries on Windows Stephen Hemminger
2023-02-07  0:19   ` [PATCH v2 1/8] net/null: build null PMD " Stephen Hemminger
2023-02-07  0:19   ` [PATCH v2 2/8] net/ring: build " Stephen Hemminger
2023-02-07  0:19   ` [PATCH v2 3/8] lpm: enable " Stephen Hemminger
2023-02-07  0:19   ` [PATCH v2 4/8] reorder: build " Stephen Hemminger
2023-02-07  0:19   ` [PATCH v2 5/8] ip_frag: enable " Stephen Hemminger
2023-02-07  0:19   ` [PATCH v2 6/8] rib: enable " Stephen Hemminger
2023-02-07  0:19   ` [PATCH v2 7/8] fib: " Stephen Hemminger
2023-02-07  0:19   ` [PATCH v2 8/8] pcapng: windows compatibility Stephen Hemminger
2023-02-07 22:13   ` [PATCH v2 0/8] Enable building more libraries on Windows Dmitry Kozlyuk
2023-02-09  9:16     ` David Marchand
2023-02-19 17:50   ` [PATCH v3 " Stephen Hemminger
2023-02-19 17:50     ` [PATCH v3 1/8] net/null: build null PMD " Stephen Hemminger
2023-02-19 17:50     ` [PATCH v3 2/8] net/ring: build " Stephen Hemminger
2023-02-19 17:50     ` [PATCH v3 3/8] lpm: enable " Stephen Hemminger
2023-02-19 17:50     ` [PATCH v3 4/8] reorder: build " Stephen Hemminger
2023-02-19 17:50     ` [PATCH v3 5/8] ip_frag: enable " Stephen Hemminger
2023-02-19 17:50     ` [PATCH v3 6/8] rib: enable " Stephen Hemminger
2023-02-19 17:50     ` [PATCH v3 7/8] fib: " Stephen Hemminger
2023-02-19 17:50     ` [PATCH v3 8/8] pcapng: windows compatibility Stephen Hemminger
2023-02-19 23:14   ` [PATCH v4 0/9] Enable building more libraries on Windows Stephen Hemminger
2023-02-19 23:14     ` [PATCH v4 1/9] net/null: build null PMD " Stephen Hemminger
2023-02-19 23:14     ` [PATCH v4 2/9] net/ring: build " Stephen Hemminger
2023-03-09 21:10       ` David Marchand
2023-03-09 21:21         ` Stephen Hemminger
2023-03-10  9:34           ` David Marchand
2023-02-19 23:14     ` [PATCH v4 3/9] lpm: enable " Stephen Hemminger
2023-02-19 23:14     ` [PATCH v4 4/9] reorder: build " Stephen Hemminger
2023-02-19 23:14     ` [PATCH v4 5/9] ip_frag: enable " Stephen Hemminger
2023-02-19 23:14     ` [PATCH v4 6/9] rib: enable " Stephen Hemminger
2023-02-19 23:14     ` [PATCH v4 7/9] fib: " Stephen Hemminger
2023-02-19 23:14     ` [PATCH v4 8/9] pcapng: windows compatibility Stephen Hemminger
2023-02-19 23:14     ` [PATCH v4 9/9] table: enable build on Windows Stephen Hemminger
2023-03-06 21:07       ` Tyler Retzlaff
2023-03-10 14:06     ` [PATCH v4 0/9] Enable building more libraries " David Marchand
2023-03-09 21:31 ` [PATCH v5 " Stephen Hemminger
2023-03-09 21:31   ` [PATCH v5 1/9] net/null: build null PMD " Stephen Hemminger
2023-03-09 21:31   ` [PATCH v5 2/9] net/ring: build " Stephen Hemminger
2023-03-09 21:31   ` [PATCH v5 3/9] lpm: enable " Stephen Hemminger
2023-03-09 21:31   ` [PATCH v5 4/9] reorder: build " Stephen Hemminger
2023-03-09 21:31   ` [PATCH v5 5/9] ip_frag: enable " Stephen Hemminger
2023-03-09 21:31   ` [PATCH v5 6/9] rib: enable " Stephen Hemminger
2023-03-09 21:31   ` [PATCH v5 7/9] fib: " Stephen Hemminger
2023-03-09 21:31   ` [PATCH v5 8/9] pcapng: windows compatibility Stephen Hemminger
2023-03-09 21:31   ` [PATCH v5 9/9] table: enable build on Windows Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).