Skip to contentSkip to conversation

lpm: add const to lpm arg of rte_lpm_lookup

PATCH In review Stanislaw Kardach 4 participants 7 messages Jun 1, 2022 – Jun 3, 2022 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/2 lpm: add const to lpm arg of rte_lpm_lookup

All other rte_lpm_lookup* functions take lpm argument as a const. As the basic rte_lpm_lookup() performs the same function, it should also do that.

As this function is inline, no API/ABI change happens.

---
 lib/lpm/rte_lpm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/lpm/rte_lpm.h +1 -1
index eb91960e81..1cf863a146 100644
@@ -279,7 +279,7 @@ rte_lpm_delete_all(struct rte_lpm *lpm);
  *   -EINVAL for incorrect arguments, -ENOENT on lookup miss, 0 on lookup hit
  */
 static inline int
-rte_lpm_lookup(struct rte_lpm *lpm, uint32_t ip, uint32_t *next_hop)
+rte_lpm_lookup(const struct rte_lpm *lpm, uint32_t ip, uint32_t *next_hop)
 {
 	unsigned tbl24_index = (ip >> 8);
 	uint32_t tbl_entry;
Signature · 1 line
2.30.2
#1 lore raw

PATCH v4 2/2 lpm: add a scalar version of lookupx4 function

From: Michal Mazurek <[email protected]>

Add an implementation of the rte_lpm_lookupx4() function for platforms without support for vector operations.

This will be useful in the upcoming RISC-V port as well as any platform which may want to start with a basic level of LPM support.

---
 doc/guides/rel_notes/release_22_07.rst |  5 ++++
 lib/lpm/meson.build                    |  1 +
 lib/lpm/rte_lpm.h                      |  4 ++-
 lib/lpm/rte_lpm_scalar.h               | 37 ++++++++++++++++++++++++++
 4 files changed, 46 insertions(+), 1 deletion(-)
 create mode 100644 lib/lpm/rte_lpm_scalar.h
doc/guides/rel_notes/release_22_07.rst +5 -0
index e49cacecef..0cf3f71269 100644
@@ -104,6 +104,11 @@ New Features
   * ``RTE_EVENT_QUEUE_ATTR_WEIGHT``
   * ``RTE_EVENT_QUEUE_ATTR_AFFINITY``
 
+* **Added scalar version of the LPM library.**
+
+  * Added scalar implementation of ``rte_lpm_lookupx4``. This is a fall-back
+    implementation for platforms that don't support vector operations.
+
 
 Removed Items
 -------------
lib/lpm/meson.build +1 -0
index 78d91d3421..6b47361fce 100644
@@ -14,6 +14,7 @@ headers = files('rte_lpm.h', 'rte_lpm6.h')
 indirect_headers += files(
         'rte_lpm_altivec.h',
         'rte_lpm_neon.h',
+        'rte_lpm_scalar.h',
         'rte_lpm_sse.h',
         'rte_lpm_sve.h',
 )
lib/lpm/rte_lpm.h +3 -1
index 1cf863a146..4f38864fde 100644
@@ -405,8 +405,10 @@ rte_lpm_lookupx4(const struct rte_lpm *lpm, xmm_t ip, uint32_t hop[4],
 #endif
 #elif defined(RTE_ARCH_PPC_64)
 #include "rte_lpm_altivec.h"
-#else
+#elif defined(RTE_ARCH_X86)
 #include "rte_lpm_sse.h"
+#else
+#include "rte_lpm_scalar.h"
 #endif
 
 #ifdef __cplusplus
lib/lpm/rte_lpm_scalar.h new file +37 -0
new file mode 100644
index 0000000000..f0d9f37894
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2022 StarFive
+ * Copyright(c) 2022 SiFive
+ * Copyright(c) 2022 Semihalf
+ */
+
+#ifndef _RTE_LPM_SCALAR_H_
+#define _RTE_LPM_SCALAR_H_
+
+#include <rte_vect.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static inline void
+rte_lpm_lookupx4(const struct rte_lpm *lpm, xmm_t ip, uint32_t hop[4],
+		uint32_t defv)
+{
+	uint32_t nh;
+	int ret;
+
+	ret = rte_lpm_lookup(lpm, ((rte_xmm_t)ip).u32[0], &nh);
+	hop[0] = (ret == 0) ? nh : defv;
+	ret = rte_lpm_lookup(lpm, ((rte_xmm_t)ip).u32[1], &nh);
+	hop[1] = (ret == 0) ? nh : defv;
+	ret = rte_lpm_lookup(lpm, ((rte_xmm_t)ip).u32[2], &nh);
+	hop[2] = (ret == 0) ? nh : defv;
+	ret = rte_lpm_lookup(lpm, ((rte_xmm_t)ip).u32[3], &nh);
+	hop[3] = (ret == 0) ? nh : defv;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_LPM_SCALAR_H_ */
Signature · 1 line
2.30.2
Acked-by on v4 2/2
#2 lore raw

Re: [PATCH v4 2/2] lpm: add a scalar version of lookupx4 function

Quoted 10 lines · Stanislaw Kardach

From: Michal Mazurek <[email protected]>

Add an implementation of the rte_lpm_lookupx4() function for platforms without support for vector operations.

This will be useful in the upcoming RISC-V port as well as any platform which may want to start with a basic level of LPM support.

Signature · 2 lines
Regards,
Vladimir
#3 lore raw

Re: [PATCH v4 2/2] lpm: add a scalar version of lookupx4 function

01/06/2022 13:52, Medvedkin, Vladimir:

Quoted 6 lines · Stanislaw Kardach
Quoted 5 lines

From: Michal Mazurek <[email protected]>

Add an implementation of the rte_lpm_lookupx4() function for platforms without support for vector operations.

Quoted 7 lines
Quoted 5 lines

This will be useful in the upcoming RISC-V port as well as any platform which may want to start with a basic level of LPM support.

Series applied, thanks.

#4 lore raw
In reply to Stanislaw Kardach

01/06/2022 13:15, Stanislaw Kardach:

Quoted 5 lines

All other rte_lpm_lookup* functions take lpm argument as a const. As the basic rte_lpm_lookup() performs the same function, it should also do that.

As this function is inline, no API/ABI change happens.

It is an API change and should be noted in the release notes.

Quoted 3 lines

static inline int

lib/lpm/rte_lpm.h +1 -1
-rte_lpm_lookup(struct rte_lpm *lpm, uint32_t ip, uint32_t *next_hop)
+rte_lpm_lookup(const struct rte_lpm *lpm, uint32_t ip, uint32_t *next_hop)
#5 lore raw
Quoted 5 lines · Thomas Monjalon

01/06/2022 13:15, Stanislaw Kardach:

Quoted 4 lines

All other rte_lpm_lookup* functions take lpm argument as a const. As the basic rte_lpm_lookup() performs the same function, it should also do that.

Quoted 8 lines
Quoted 1 line

As this function is inline, no API/ABI change happens.

It is an API change and should be noted in the release notes.

lib/lpm/rte_lpm.h rte_lpm_delete_all(struct rte_lpm *lpm); · line 282

Quoted 3 lines

static inline int

lib/lpm/rte_lpm.h +1 -1
-rte_lpm_lookup(struct rte_lpm *lpm, uint32_t ip, uint32_t *next_hop)
+rte_lpm_lookup(const struct rte_lpm *lpm, uint32_t ip, uint32_t *next_hop)

While I've no particular objection to it appearing in the RN doc, I wonder whether it really counts as an API change. I can't see any practical difference that this change would make to the end user - no source code needs updating for example.

/Bruce

#6 lore raw

03/06/2022 09:29, Bruce Richardson:

Quoted 10 lines · Thomas Monjalon
Quoted 9 lines

01/06/2022 13:15, Stanislaw Kardach:

Quoted 5 lines

All other rte_lpm_lookup* functions take lpm argument as a const. As the basic rte_lpm_lookup() performs the same function, it should also do that.

As this function is inline, no API/ABI change happens.

It is an API change and should be noted in the release notes.

Quoted 8 lines
Quoted 4 lines

lib/lpm/rte_lpm.h rte_lpm_delete_all(struct rte_lpm *lpm); · line 282

Quoted 3 lines

static inline int

lib/lpm/rte_lpm.h +1 -1
-rte_lpm_lookup(struct rte_lpm *lpm, uint32_t ip, uint32_t *next_hop)
+rte_lpm_lookup(const struct rte_lpm *lpm, uint32_t ip, uint32_t *next_hop)

While I've no particular objection to it appearing in the RN doc, I wonder whether it really counts as an API change. I can't see any practical difference that this change would make to the end user - no source code needs updating for example.

Yes you're right, we can skip the release notes here.