Skip to contentSkip to conversation

lib/lpm: use standard atomic_store_explicit

PATCH In review Andre Muezerie 3 participants 9 messages Dec 4, 2024 – Jun 3, 2025 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/lpm: use standard atomic_store_explicit

MSVC issues the warning below:

../lib/lpm/rte_lpm.c(297): warning C4013
'__atomic_store' undefined; assuming extern returning int
../lib/lpm/rte_lpm.c(298): error C2065:
'__ATOMIC_RELAXED': undeclared identifier

The fix is to use standard atomic_store_explicit() instead of gcc specific __atomic_store(). atomic_store_explicit() was already being used in other parts of DPDK and is compatible
with many compilers, including MSVC.

---
 lib/lpm/rte_lpm.c | 108 ++++++++++++++++++++++++++++++----------------
 lib/lpm/rte_lpm.h |  56 ++++++++++++++----------
 2 files changed, 104 insertions(+), 60 deletions(-)
lib/lpm/rte_lpm.c +70 -38
index a5c9e7c9fc..7ec85f1718 100644
@@ -294,8 +294,8 @@ __lpm_rcu_qsbr_free_resource(void *p, void *data, unsigned int n)
 
 	RTE_SET_USED(n);
 	/* Set tbl8 group invalid */
-	__atomic_store(&tbl8[tbl8_group_index], &zero_tbl8_entry,
-		__ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&tbl8[tbl8_group_index].val,
+			zero_tbl8_entry.val, rte_memory_order_relaxed);
 }
 
 /* Associate QSBR variable with an LPM object.
@@ -515,8 +515,8 @@ _tbl8_alloc(struct __rte_lpm *i_lpm)
 					RTE_LPM_TBL8_GROUP_NUM_ENTRIES *
 					sizeof(tbl8_entry[0]));
 
-			__atomic_store(tbl8_entry, &new_tbl8_entry,
-					__ATOMIC_RELAXED);
+			rte_atomic_store_explicit(&tbl8_entry->val, new_tbl8_entry.val,
+					rte_memory_order_relaxed);
 
 			/* Return group index for allocated tbl8 group. */
 			return group_idx;
@@ -551,15 +551,19 @@ tbl8_free(struct __rte_lpm *i_lpm, uint32_t tbl8_group_start)
 
 	if (i_lpm->v == NULL) {
 		/* Set tbl8 group invalid*/
-		__atomic_store(&i_lpm->lpm.tbl8[tbl8_group_start], &zero_tbl8_entry,
-				__ATOMIC_RELAXED);
+		struct rte_lpm_tbl_entry *tbl8_entry =
+				&i_lpm->lpm.tbl8[tbl8_group_start];
+		rte_atomic_store_explicit(&tbl8_entry->val, zero_tbl8_entry.val,
+				rte_memory_order_relaxed);
 	} else if (i_lpm->rcu_mode == RTE_LPM_QSBR_MODE_SYNC) {
 		/* Wait for quiescent state change. */
 		rte_rcu_qsbr_synchronize(i_lpm->v,
 			RTE_QSBR_THRID_INVALID);
 		/* Set tbl8 group invalid*/
-		__atomic_store(&i_lpm->lpm.tbl8[tbl8_group_start], &zero_tbl8_entry,
-				__ATOMIC_RELAXED);
+		struct rte_lpm_tbl_entry *tbl8_entry =
+				&i_lpm->lpm.tbl8[tbl8_group_start];
+		rte_atomic_store_explicit(&tbl8_entry->val, zero_tbl8_entry.val,
+				rte_memory_order_relaxed);
 	} else if (i_lpm->rcu_mode == RTE_LPM_QSBR_MODE_DQ) {
 		/* Push into QSBR defer queue. */
 		status = rte_rcu_qsbr_dq_enqueue(i_lpm->dq,
@@ -602,8 +606,10 @@ add_depth_small(struct __rte_lpm *i_lpm, uint32_t ip, uint8_t depth,
 			/* Setting tbl24 entry in one go to avoid race
 			 * conditions
 			 */
-			__atomic_store(&i_lpm->lpm.tbl24[i], &new_tbl24_entry,
-					__ATOMIC_RELEASE);
+			struct rte_lpm_tbl_entry *tbl24_entry =
+					&i_lpm->lpm.tbl24[i];
+			rte_atomic_store_explicit(&tbl24_entry->val, new_tbl24_entry.val,
+					rte_memory_order_release);
 
 			continue;
 		}
@@ -632,9 +638,11 @@ add_depth_small(struct __rte_lpm *i_lpm, uint32_t ip, uint8_t depth,
 					 * Setting tbl8 entry in one go to avoid
 					 * race conditions
 					 */
-					__atomic_store(&i_lpm->lpm.tbl8[j],
-						&new_tbl8_entry,
-						__ATOMIC_RELAXED);
+					struct rte_lpm_tbl_entry *tbl8_entry =
+							&i_lpm->lpm.tbl8[j];
+					rte_atomic_store_explicit(&tbl8_entry->val,
+							new_tbl8_entry.val,
+							rte_memory_order_relaxed);
 
 					continue;
 				}
@@ -679,8 +687,10 @@ add_depth_big(struct __rte_lpm *i_lpm, uint32_t ip_masked, uint8_t depth,
 				.valid_group = i_lpm->lpm.tbl8[i].valid_group,
 				.next_hop = next_hop,
 			};
-			__atomic_store(&i_lpm->lpm.tbl8[i], &new_tbl8_entry,
-					__ATOMIC_RELAXED);
+			struct rte_lpm_tbl_entry *tbl8_entry =
+					&i_lpm->lpm.tbl8[i];
+			rte_atomic_store_explicit(&tbl8_entry->val, new_tbl8_entry.val,
+					rte_memory_order_relaxed);
 		}
 
 		/*
@@ -699,8 +709,10 @@ add_depth_big(struct __rte_lpm *i_lpm, uint32_t ip_masked, uint8_t depth,
 		/* The tbl24 entry must be written only after the
 		 * tbl8 entries are written.
 		 */
-		__atomic_store(&i_lpm->lpm.tbl24[tbl24_index], &new_tbl24_entry,
-				__ATOMIC_RELEASE);
+		struct rte_lpm_tbl_entry *tbl24_entry =
+				&i_lpm->lpm.tbl24[tbl24_index];
+		rte_atomic_store_explicit(&tbl24_entry->val, new_tbl24_entry.val,
+				rte_memory_order_release);
 
 	} /* If valid entry but not extended calculate the index into Table8. */
 	else if (i_lpm->lpm.tbl24[tbl24_index].valid_group == 0) {
@@ -724,8 +736,10 @@ add_depth_big(struct __rte_lpm *i_lpm, uint32_t ip_masked, uint8_t depth,
 				.valid_group = i_lpm->lpm.tbl8[i].valid_group,
 				.next_hop = i_lpm->lpm.tbl24[tbl24_index].next_hop,
 			};
-			__atomic_store(&i_lpm->lpm.tbl8[i], &new_tbl8_entry,
-					__ATOMIC_RELAXED);
+			struct rte_lpm_tbl_entry *tbl8_entry =
+					&i_lpm->lpm.tbl8[i];
+			rte_atomic_store_explicit(&tbl8_entry->val, new_tbl8_entry.val,
+					rte_memory_order_relaxed);
 		}
 
 		tbl8_index = tbl8_group_start + (ip_masked & 0xFF);
@@ -738,8 +752,10 @@ add_depth_big(struct __rte_lpm *i_lpm, uint32_t ip_masked, uint8_t depth,
 				.valid_group = i_lpm->lpm.tbl8[i].valid_group,
 				.next_hop = next_hop,
 			};
-			__atomic_store(&i_lpm->lpm.tbl8[i], &new_tbl8_entry,
-					__ATOMIC_RELAXED);
+			struct rte_lpm_tbl_entry *tbl8_entry =
+					&i_lpm->lpm.tbl8[i];
+			rte_atomic_store_explicit(&tbl8_entry->val, new_tbl8_entry.val,
+					rte_memory_order_relaxed);
 		}
 
 		/*
@@ -758,8 +774,10 @@ add_depth_big(struct __rte_lpm *i_lpm, uint32_t ip_masked, uint8_t depth,
 		/* The tbl24 entry must be written only after the
 		 * tbl8 entries are written.
 		 */
-		__atomic_store(&i_lpm->lpm.tbl24[tbl24_index], &new_tbl24_entry,
-				__ATOMIC_RELEASE);
+		struct rte_lpm_tbl_entry *tbl24_entry =
+				&i_lpm->lpm.tbl24[tbl24_index];
+		rte_atomic_store_explicit(&tbl24_entry->val, new_tbl24_entry.val,
+				rte_memory_order_release);
 
 	} else { /*
 		* If it is valid, extended entry calculate the index into tbl8.
@@ -784,8 +802,10 @@ add_depth_big(struct __rte_lpm *i_lpm, uint32_t ip_masked, uint8_t depth,
 				 * Setting tbl8 entry in one go to avoid race
 				 * condition
 				 */
-				__atomic_store(&i_lpm->lpm.tbl8[i], &new_tbl8_entry,
-						__ATOMIC_RELAXED);
+				struct rte_lpm_tbl_entry *tbl8_entry =
+						&i_lpm->lpm.tbl8[i];
+				rte_atomic_store_explicit(&tbl8_entry->val,
+						new_tbl8_entry.val, rte_memory_order_relaxed);
 
 				continue;
 			}
@@ -924,8 +944,10 @@ delete_depth_small(struct __rte_lpm *i_lpm, uint32_t ip_masked,
 
 			if (i_lpm->lpm.tbl24[i].valid_group == 0 &&
 					i_lpm->lpm.tbl24[i].depth <= depth) {
-				__atomic_store(&i_lpm->lpm.tbl24[i],
-					&zero_tbl24_entry, __ATOMIC_RELEASE);
+				struct rte_lpm_tbl_entry *tbl24_entry =
+						&i_lpm->lpm.tbl24[i];
+				rte_atomic_store_explicit(&tbl24_entry->val,
+						zero_tbl24_entry.val, rte_memory_order_release);
 			} else if (i_lpm->lpm.tbl24[i].valid_group == 1) {
 				/*
 				 * If TBL24 entry is extended, then there has
@@ -970,8 +992,10 @@ delete_depth_small(struct __rte_lpm *i_lpm, uint32_t ip_masked,
 
 			if (i_lpm->lpm.tbl24[i].valid_group == 0 &&
 					i_lpm->lpm.tbl24[i].depth <= depth) {
-				__atomic_store(&i_lpm->lpm.tbl24[i], &new_tbl24_entry,
-						__ATOMIC_RELEASE);
+				struct rte_lpm_tbl_entry *tbl24_entry =
+						&i_lpm->lpm.tbl24[i];
+				rte_atomic_store_explicit(&tbl24_entry->val,
+						new_tbl24_entry.val, rte_memory_order_release);
 			} else  if (i_lpm->lpm.tbl24[i].valid_group == 1) {
 				/*
 				 * If TBL24 entry is extended, then there has
@@ -986,10 +1010,13 @@ delete_depth_small(struct __rte_lpm *i_lpm, uint32_t ip_masked,
 				for (j = tbl8_index; j < (tbl8_index +
 					RTE_LPM_TBL8_GROUP_NUM_ENTRIES); j++) {
 
-					if (i_lpm->lpm.tbl8[j].depth <= depth)
-						__atomic_store(&i_lpm->lpm.tbl8[j],
-							&new_tbl8_entry,
-							__ATOMIC_RELAXED);
+					if (i_lpm->lpm.tbl8[j].depth <= depth) {
+						struct rte_lpm_tbl_entry *tbl8_entry =
+								&i_lpm->lpm.tbl8[j];
+						rte_atomic_store_explicit(&tbl8_entry->val,
+								new_tbl8_entry.val,
+								rte_memory_order_relaxed);
+					}
 				}
 			}
 		}
@@ -1097,9 +1124,12 @@ delete_depth_big(struct __rte_lpm *i_lpm, uint32_t ip_masked,
 		 * rule_to_delete must be modified.
 		 */
 		for (i = tbl8_index; i < (tbl8_index + tbl8_range); i++) {
-			if (i_lpm->lpm.tbl8[i].depth <= depth)
-				__atomic_store(&i_lpm->lpm.tbl8[i], &new_tbl8_entry,
-						__ATOMIC_RELAXED);
+			if (i_lpm->lpm.tbl8[i].depth <= depth) {
+				struct rte_lpm_tbl_entry *tbl8_entry =
+						&i_lpm->lpm.tbl8[i];
+				rte_atomic_store_explicit(&tbl8_entry->val,
+						new_tbl8_entry.val, rte_memory_order_relaxed);
+			}
 		}
 	}
 
@@ -1130,8 +1160,10 @@ delete_depth_big(struct __rte_lpm *i_lpm, uint32_t ip_masked,
 		/* Set tbl24 before freeing tbl8 to avoid race condition.
 		 * Prevent the free of the tbl8 group from hoisting.
 		 */
-		__atomic_store(&i_lpm->lpm.tbl24[tbl24_index], &new_tbl24_entry,
-				__ATOMIC_RELAXED);
+		struct rte_lpm_tbl_entry *tbl24_entry =
+				&i_lpm->lpm.tbl24[tbl24_index];
+		rte_atomic_store_explicit(&tbl24_entry->val, new_tbl24_entry.val,
+				rte_memory_order_relaxed);
 		rte_atomic_thread_fence(rte_memory_order_release);
 		status = tbl8_free(i_lpm, tbl8_group_start);
 	}
lib/lpm/rte_lpm.h +34 -22

72 lines not on this page · raw message

Signature · 1 line
2.47.0.vfs.0.3
#1 lore raw

Hello Andre,

Quoted 8 lines · Andre Muezerie

MSVC issues the warning below:

../lib/lpm/rte_lpm.c(297): warning C4013
'__atomic_store' undefined; assuming extern returning int
../lib/lpm/rte_lpm.c(298): error C2065:
'__ATOMIC_RELAXED': undeclared identifier

Quoted 7 lines

The fix is to use standard atomic_store_explicit() instead of gcc specific __atomic_store(). atomic_store_explicit() was already being used in other parts of DPDK and is compatible
with many compilers, including MSVC.

With this change, is there anything remaining that blocks this library compilation with MSVC?
If not, please update meson.build so that CI can test lpm compilation with MSVC on this patch (and that will detect regressions once merged).

Signature · 1 line
David Marchand
#2 lore raw
Quoted 18 lines · David Marchand

Hello Andre,

Quoted 14 lines · Andre Muezerie

MSVC issues the warning below:

../lib/lpm/rte_lpm.c(297): warning C4013
'__atomic_store' undefined; assuming extern returning int
../lib/lpm/rte_lpm.c(298): error C2065:
'__ATOMIC_RELAXED': undeclared identifier

The fix is to use standard atomic_store_explicit() instead of gcc specific __atomic_store(). atomic_store_explicit() was already being used in other parts of DPDK and is compatible
with many compilers, including MSVC.

Quoted 11 lines
Quoted 1 line

With this change, is there anything remaining that blocks this library compilation with MSVC?
If not, please update meson.build so that CI can test lpm compilation with MSVC on this patch (and that will detect regressions once merged).

Signature · 1 line
David Marchand

Hi David,

I'm eager to enable lpm to be compiled with MSVC. Even though this was the last issue I observed for this lib on my machine, lpm depends on hash, which depends on net, which depends on mbuf and mbuf is not enabled for MSVC yet.

I have several fixes affecting these pending review and would prefer to not depend on lpm's dependencies for the system to start compiling this code in case some critical fix gets completed later. I have not analyzed all sequences in which patches can be completed, and it's quite possible that some sequences would result in MSVC compilation failures if the libs were enabled in meson.build.

However, this code would still get compiled on Linux as usual, and hopefully we can enable all these libs once the patches get completed. I am aware that regressions can happen before that point. We will address them if that happens.

It is tricky to handle so many paches/dependencies. Let me know if there's something that can be improved.

Andre

#3 lore raw
Quoted 31 lines · Andre Muezerie
Quoted 18 lines · David Marchand

Hello Andre,

Quoted 14 lines · Andre Muezerie

MSVC issues the warning below:

../lib/lpm/rte_lpm.c(297): warning C4013
'__atomic_store' undefined; assuming extern returning int
../lib/lpm/rte_lpm.c(298): error C2065:
'__ATOMIC_RELAXED': undeclared identifier

The fix is to use standard atomic_store_explicit() instead of gcc specific __atomic_store(). atomic_store_explicit() was already being used in other parts of DPDK and is compatible
with many compilers, including MSVC.

Quoted 11 lines
Quoted 1 line

With this change, is there anything remaining that blocks this library compilation with MSVC?
If not, please update meson.build so that CI can test lpm compilation with MSVC on this patch (and that will detect regressions once merged).

Signature · 1 line
David Marchand
Quoted 7 lines

Hi David,

I'm eager to enable lpm to be compiled with MSVC. Even though this was the last issue I observed for this lib on my machine, lpm depends on hash, which depends on net, which depends on mbuf and mbuf is not enabled for MSVC yet.

I was a bit curious about this dependency chain and decided to investigate a bit. The "weak link" in this chain appears to me to be the link between the hash library and the net library. Within the hash library, I believe only the thash functionality depends on net, for definitions of the ipv6 headers and address fields.

If we want to break that dependency (temporarily, since net is pretty much an essential DPDK lib), the following patch should work.

Regards,
/Bruce

lib/hash/meson.build +16 -6
index e6cb1ebe3b..f9096edd67 100644
@@ -6,24 +6,34 @@ headers = files(
         'rte_hash_crc.h',
         'rte_hash.h',
         'rte_jhash.h',
-        'rte_thash.h',
-        'rte_thash_gfni.h',
 )
 indirect_headers += files(
         'rte_crc_arm64.h',
         'rte_crc_generic.h',
         'rte_crc_sw.h',
         'rte_crc_x86.h',
-        'rte_thash_x86_gfni.h',
 )
 
 sources = files(
         'rte_cuckoo_hash.c',
         'rte_hash_crc.c',
         'rte_fbk_hash.c',
+)
+
+deps = ['rcu']
+
+if dpdk_conf.has('RTE_LIB_NET')
+    headers += files(
+        'rte_thash.h',
+        'rte_thash_gfni.h',
+    )
+    indirect_headers += files(
+        'rte_thash_x86_gfni.h',
+    )
+    sources += files(
         'rte_thash.c',
         'rte_thash_gfni.c',
         'rte_thash_gf2_poly_math.c',
-)
-
-deps = ['net', 'rcu']
+    )
+    deps += ['net']
+endif
#4 lore raw
Quoted 86 lines · Bruce Richardson
Quoted 31 lines · Andre Muezerie
Quoted 18 lines · David Marchand

Hello Andre,

Quoted 14 lines · Andre Muezerie

MSVC issues the warning below:

../lib/lpm/rte_lpm.c(297): warning C4013
'__atomic_store' undefined; assuming extern returning int
../lib/lpm/rte_lpm.c(298): error C2065:
'__ATOMIC_RELAXED': undeclared identifier

The fix is to use standard atomic_store_explicit() instead of gcc specific __atomic_store(). atomic_store_explicit() was already being used in other parts of DPDK and is compatible
with many compilers, including MSVC.

Quoted 11 lines
Quoted 1 line

With this change, is there anything remaining that blocks this library compilation with MSVC?
If not, please update meson.build so that CI can test lpm compilation with MSVC on this patch (and that will detect regressions once merged).

Signature · 1 line
David Marchand
Quoted 7 lines

Hi David,

I'm eager to enable lpm to be compiled with MSVC. Even though this was the last issue I observed for this lib on my machine, lpm depends on hash, which depends on net, which depends on mbuf and mbuf is not enabled for MSVC yet.

I was a bit curious about this dependency chain and decided to investigate a bit. The "weak link" in this chain appears to me to be the link between the hash library and the net library. Within the hash library, I believe only the thash functionality depends on net, for definitions of the ipv6 headers and address fields.

If we want to break that dependency (temporarily, since net is pretty much an essential DPDK lib), the following patch should work.

Regards,
/Bruce

lib/hash/meson.build +12 -3
index e6cb1ebe3b..f9096edd67 100644
@@ -6,24 +6,34 @@ headers = files(
         'rte_hash_crc.h',
         'rte_hash.h',
         'rte_jhash.h',
-        'rte_thash.h',
-        'rte_thash_gfni.h',
 )
 indirect_headers += files(
         'rte_crc_arm64.h',
         'rte_crc_generic.h',
         'rte_crc_sw.h',
         'rte_crc_x86.h',
-        'rte_thash_x86_gfni.h',
 )
 
 sources = files(
         'rte_cuckoo_hash.c',
         'rte_hash_crc.c',
         'rte_fbk_hash.c',
+)
+
+deps = ['rcu']
+
+if dpdk_conf.has('RTE_LIB_NET')
+    headers += files(
+        'rte_thash.h',
+        'rte_thash_gfni.h',
+    )
+    indirect_headers += files(
+        'rte_thash_x86_gfni.h',
+    )

lib/hash/meson.build headers = files( · line 39

Quoted 10 lines
lib/hash/meson.build +4 -3
+    sources += files(
         'rte_thash.c',
         'rte_thash_gfni.c',
         'rte_thash_gf2_poly_math.c',
-)
-
-deps = ['net', 'rcu']
+    )
+    deps += ['net']
+endif

That's a great suggestion. Unfortunately hash also directly depends on rcu, which is also not yet enabled for MSVC due to pending reviews.

Regards,
Andre Muezerie

#5 lore raw

v2 cover enable lpm to be compiled with MSVC

In reply to Andre Muezerie

This patchset resolves all issues related to lpm that until now prevented it from being built using MSVC.

After resolving the issues it enables lpm to be compiled with MSVC.

v2:
- Updated meson.build to enable lpm for MSVC

Andre Muezerie (2):
lib/lpm: use standard atomic_store_explicit
lib/lpm: enable lpm to be compiled with MSVC

 lib/lpm/meson.build |   6 ---
 lib/lpm/rte_lpm.c   | 108 ++++++++++++++++++++++++++++----------------
 lib/lpm/rte_lpm.h   |  56 ++++++++++++++---------
 3 files changed, 104 insertions(+), 66 deletions(-)

--
2.49.0.vfs.0.3

#6 lore raw

PATCH v2 1/2 lib/lpm: use standard atomic_store_explicit

MSVC issues the warning below:

../lib/lpm/rte_lpm.c(297): warning C4013
'__atomic_store' undefined; assuming extern returning int
../lib/lpm/rte_lpm.c(298): error C2065:
'__ATOMIC_RELAXED': undeclared identifier

The fix is to use standard atomic_store_explicit() instead of gcc specific __atomic_store(). atomic_store_explicit() was already being used in other parts of DPDK and is compatible with many compilers, including MSVC.

---
 lib/lpm/rte_lpm.c | 108 ++++++++++++++++++++++++++++++----------------
 lib/lpm/rte_lpm.h |  56 ++++++++++++++----------
 2 files changed, 104 insertions(+), 60 deletions(-)
lib/lpm/rte_lpm.c +70 -38
index 7058be6918..6dab86a05e 100644
@@ -298,8 +298,8 @@ __lpm_rcu_qsbr_free_resource(void *p, void *data, unsigned int n)
 
 	RTE_SET_USED(n);
 	/* Set tbl8 group invalid */
-	__atomic_store(&tbl8[tbl8_group_index], &zero_tbl8_entry,
-		__ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&tbl8[tbl8_group_index].val,
+			zero_tbl8_entry.val, rte_memory_order_relaxed);
 }
 
 /* Associate QSBR variable with an LPM object.
@@ -520,8 +520,8 @@ _tbl8_alloc(struct __rte_lpm *i_lpm)
 					RTE_LPM_TBL8_GROUP_NUM_ENTRIES *
 					sizeof(tbl8_entry[0]));
 
-			__atomic_store(tbl8_entry, &new_tbl8_entry,
-					__ATOMIC_RELAXED);
+			rte_atomic_store_explicit(&tbl8_entry->val, new_tbl8_entry.val,
+					rte_memory_order_relaxed);
 
 			/* Return group index for allocated tbl8 group. */
 			return group_idx;
@@ -556,15 +556,19 @@ tbl8_free(struct __rte_lpm *i_lpm, uint32_t tbl8_group_start)
 
 	if (i_lpm->v == NULL) {
 		/* Set tbl8 group invalid*/
-		__atomic_store(&i_lpm->lpm.tbl8[tbl8_group_start], &zero_tbl8_entry,
-				__ATOMIC_RELAXED);
+		struct rte_lpm_tbl_entry *tbl8_entry =
+				&i_lpm->lpm.tbl8[tbl8_group_start];
+		rte_atomic_store_explicit(&tbl8_entry->val, zero_tbl8_entry.val,
+				rte_memory_order_relaxed);
 	} else if (i_lpm->rcu_mode == RTE_LPM_QSBR_MODE_SYNC) {
 		/* Wait for quiescent state change. */
 		rte_rcu_qsbr_synchronize(i_lpm->v,
 			RTE_QSBR_THRID_INVALID);
 		/* Set tbl8 group invalid*/
-		__atomic_store(&i_lpm->lpm.tbl8[tbl8_group_start], &zero_tbl8_entry,
-				__ATOMIC_RELAXED);
+		struct rte_lpm_tbl_entry *tbl8_entry =
+				&i_lpm->lpm.tbl8[tbl8_group_start];
+		rte_atomic_store_explicit(&tbl8_entry->val, zero_tbl8_entry.val,
+				rte_memory_order_relaxed);
 	} else if (i_lpm->rcu_mode == RTE_LPM_QSBR_MODE_DQ) {
 		/* Push into QSBR defer queue. */
 		status = rte_rcu_qsbr_dq_enqueue(i_lpm->dq,
@@ -607,8 +611,10 @@ add_depth_small(struct __rte_lpm *i_lpm, uint32_t ip, uint8_t depth,
 			/* Setting tbl24 entry in one go to avoid race
 			 * conditions
 			 */
-			__atomic_store(&i_lpm->lpm.tbl24[i], &new_tbl24_entry,
-					__ATOMIC_RELEASE);
+			struct rte_lpm_tbl_entry *tbl24_entry =
+					&i_lpm->lpm.tbl24[i];
+			rte_atomic_store_explicit(&tbl24_entry->val, new_tbl24_entry.val,
+					rte_memory_order_release);
 
 			continue;
 		}
@@ -637,9 +643,11 @@ add_depth_small(struct __rte_lpm *i_lpm, uint32_t ip, uint8_t depth,
 					 * Setting tbl8 entry in one go to avoid
 					 * race conditions
 					 */
-					__atomic_store(&i_lpm->lpm.tbl8[j],
-						&new_tbl8_entry,
-						__ATOMIC_RELAXED);
+					struct rte_lpm_tbl_entry *tbl8_entry =
+							&i_lpm->lpm.tbl8[j];
+					rte_atomic_store_explicit(&tbl8_entry->val,
+							new_tbl8_entry.val,
+							rte_memory_order_relaxed);
 
 					continue;
 				}
@@ -684,8 +692,10 @@ add_depth_big(struct __rte_lpm *i_lpm, uint32_t ip_masked, uint8_t depth,
 				.valid_group = i_lpm->lpm.tbl8[i].valid_group,
 				.next_hop = next_hop,
 			};
-			__atomic_store(&i_lpm->lpm.tbl8[i], &new_tbl8_entry,
-					__ATOMIC_RELAXED);
+			struct rte_lpm_tbl_entry *tbl8_entry =
+					&i_lpm->lpm.tbl8[i];
+			rte_atomic_store_explicit(&tbl8_entry->val, new_tbl8_entry.val,
+					rte_memory_order_relaxed);
 		}
 
 		/*
@@ -704,8 +714,10 @@ add_depth_big(struct __rte_lpm *i_lpm, uint32_t ip_masked, uint8_t depth,
 		/* The tbl24 entry must be written only after the
 		 * tbl8 entries are written.
 		 */
-		__atomic_store(&i_lpm->lpm.tbl24[tbl24_index], &new_tbl24_entry,
-				__ATOMIC_RELEASE);
+		struct rte_lpm_tbl_entry *tbl24_entry =
+				&i_lpm->lpm.tbl24[tbl24_index];
+		rte_atomic_store_explicit(&tbl24_entry->val, new_tbl24_entry.val,
+				rte_memory_order_release);
 
 	} /* If valid entry but not extended calculate the index into Table8. */
 	else if (i_lpm->lpm.tbl24[tbl24_index].valid_group == 0) {
@@ -729,8 +741,10 @@ add_depth_big(struct __rte_lpm *i_lpm, uint32_t ip_masked, uint8_t depth,
 				.valid_group = i_lpm->lpm.tbl8[i].valid_group,
 				.next_hop = i_lpm->lpm.tbl24[tbl24_index].next_hop,
 			};
-			__atomic_store(&i_lpm->lpm.tbl8[i], &new_tbl8_entry,
-					__ATOMIC_RELAXED);
+			struct rte_lpm_tbl_entry *tbl8_entry =
+					&i_lpm->lpm.tbl8[i];
+			rte_atomic_store_explicit(&tbl8_entry->val, new_tbl8_entry.val,
+					rte_memory_order_relaxed);
 		}
 
 		tbl8_index = tbl8_group_start + (ip_masked & 0xFF);
@@ -743,8 +757,10 @@ add_depth_big(struct __rte_lpm *i_lpm, uint32_t ip_masked, uint8_t depth,
 				.valid_group = i_lpm->lpm.tbl8[i].valid_group,
 				.next_hop = next_hop,
 			};
-			__atomic_store(&i_lpm->lpm.tbl8[i], &new_tbl8_entry,
-					__ATOMIC_RELAXED);
+			struct rte_lpm_tbl_entry *tbl8_entry =
+					&i_lpm->lpm.tbl8[i];
+			rte_atomic_store_explicit(&tbl8_entry->val, new_tbl8_entry.val,
+					rte_memory_order_relaxed);
 		}
 
 		/*
@@ -763,8 +779,10 @@ add_depth_big(struct __rte_lpm *i_lpm, uint32_t ip_masked, uint8_t depth,
 		/* The tbl24 entry must be written only after the
 		 * tbl8 entries are written.
 		 */
-		__atomic_store(&i_lpm->lpm.tbl24[tbl24_index], &new_tbl24_entry,
-				__ATOMIC_RELEASE);
+		struct rte_lpm_tbl_entry *tbl24_entry =
+				&i_lpm->lpm.tbl24[tbl24_index];
+		rte_atomic_store_explicit(&tbl24_entry->val, new_tbl24_entry.val,
+				rte_memory_order_release);
 
 	} else { /*
 		* If it is valid, extended entry calculate the index into tbl8.
@@ -789,8 +807,10 @@ add_depth_big(struct __rte_lpm *i_lpm, uint32_t ip_masked, uint8_t depth,
 				 * Setting tbl8 entry in one go to avoid race
 				 * condition
 				 */
-				__atomic_store(&i_lpm->lpm.tbl8[i], &new_tbl8_entry,
-						__ATOMIC_RELAXED);
+				struct rte_lpm_tbl_entry *tbl8_entry =
+						&i_lpm->lpm.tbl8[i];
+				rte_atomic_store_explicit(&tbl8_entry->val,
+						new_tbl8_entry.val, rte_memory_order_relaxed);
 
 				continue;
 			}
@@ -931,8 +951,10 @@ delete_depth_small(struct __rte_lpm *i_lpm, uint32_t ip_masked,
 
 			if (i_lpm->lpm.tbl24[i].valid_group == 0 &&
 					i_lpm->lpm.tbl24[i].depth <= depth) {
-				__atomic_store(&i_lpm->lpm.tbl24[i],
-					&zero_tbl24_entry, __ATOMIC_RELEASE);
+				struct rte_lpm_tbl_entry *tbl24_entry =
+						&i_lpm->lpm.tbl24[i];
+				rte_atomic_store_explicit(&tbl24_entry->val,
+						zero_tbl24_entry.val, rte_memory_order_release);
 			} else if (i_lpm->lpm.tbl24[i].valid_group == 1) {
 				/*
 				 * If TBL24 entry is extended, then there has
@@ -977,8 +999,10 @@ delete_depth_small(struct __rte_lpm *i_lpm, uint32_t ip_masked,
 
 			if (i_lpm->lpm.tbl24[i].valid_group == 0 &&
 					i_lpm->lpm.tbl24[i].depth <= depth) {
-				__atomic_store(&i_lpm->lpm.tbl24[i], &new_tbl24_entry,
-						__ATOMIC_RELEASE);
+				struct rte_lpm_tbl_entry *tbl24_entry =
+						&i_lpm->lpm.tbl24[i];
+				rte_atomic_store_explicit(&tbl24_entry->val,
+						new_tbl24_entry.val, rte_memory_order_release);
 			} else  if (i_lpm->lpm.tbl24[i].valid_group == 1) {
 				/*
 				 * If TBL24 entry is extended, then there has
@@ -993,10 +1017,13 @@ delete_depth_small(struct __rte_lpm *i_lpm, uint32_t ip_masked,
 				for (j = tbl8_index; j < (tbl8_index +
 					RTE_LPM_TBL8_GROUP_NUM_ENTRIES); j++) {
 
-					if (i_lpm->lpm.tbl8[j].depth <= depth)
-						__atomic_store(&i_lpm->lpm.tbl8[j],
-							&new_tbl8_entry,
-							__ATOMIC_RELAXED);
+					if (i_lpm->lpm.tbl8[j].depth <= depth) {
+						struct rte_lpm_tbl_entry *tbl8_entry =
+								&i_lpm->lpm.tbl8[j];
+						rte_atomic_store_explicit(&tbl8_entry->val,
+								new_tbl8_entry.val,
+								rte_memory_order_relaxed);
+					}
 				}
 			}
 		}
@@ -1104,9 +1131,12 @@ delete_depth_big(struct __rte_lpm *i_lpm, uint32_t ip_masked,
 		 * rule_to_delete must be modified.
 		 */
 		for (i = tbl8_index; i < (tbl8_index + tbl8_range); i++) {
-			if (i_lpm->lpm.tbl8[i].depth <= depth)
-				__atomic_store(&i_lpm->lpm.tbl8[i], &new_tbl8_entry,
-						__ATOMIC_RELAXED);
+			if (i_lpm->lpm.tbl8[i].depth <= depth) {
+				struct rte_lpm_tbl_entry *tbl8_entry =
+						&i_lpm->lpm.tbl8[i];
+				rte_atomic_store_explicit(&tbl8_entry->val,
+						new_tbl8_entry.val, rte_memory_order_relaxed);
+			}
 		}
 	}
 
@@ -1137,8 +1167,10 @@ delete_depth_big(struct __rte_lpm *i_lpm, uint32_t ip_masked,
 		/* Set tbl24 before freeing tbl8 to avoid race condition.
 		 * Prevent the free of the tbl8 group from hoisting.
 		 */
-		__atomic_store(&i_lpm->lpm.tbl24[tbl24_index], &new_tbl24_entry,
-				__ATOMIC_RELAXED);
+		struct rte_lpm_tbl_entry *tbl24_entry =
+				&i_lpm->lpm.tbl24[tbl24_index];
+		rte_atomic_store_explicit(&tbl24_entry->val, new_tbl24_entry.val,
+				rte_memory_order_relaxed);
 		rte_atomic_thread_fence(rte_memory_order_release);
 		status = tbl8_free(i_lpm, tbl8_group_start);
 	}
lib/lpm/rte_lpm.h +34 -22

72 lines not on this page · raw message

Signature · 1 line
2.49.0.vfs.0.3
#7 lore raw

PATCH v2 2/2 lib/lpm: enable lpm to be compiled with MSVC

In reply to Andre Muezerie

Now that all issues related to lpm are addressed it can be enabled for MSVC.

---
 lib/lpm/meson.build | 6 ------
 1 file changed, 6 deletions(-)
lib/lpm/meson.build +0 -6
index fae4f79fb9..cff8fed473 100644
@@ -1,12 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-if is_ms_compiler
-    build = false
-    reason = 'not supported building with Visual Studio Toolset'
-    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
Signature · 1 line
2.49.0.vfs.0.3
#8 lore raw

Re: [PATCH v2 0/2] enable lpm to be compiled with MSVC

In reply to Andre Muezerie
Quoted 5 lines · Andre Muezerie

This patchset resolves all issues related to lpm that until now prevented it from being built using MSVC.

After resolving the issues it enables lpm to be compiled with MSVC.

Series applied, thanks.

Signature · 1 line
David Marchand