[v3] hash: put GFNI stubs back

Message ID 20240307013715.114013-1-stephen@networkplumber.org (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series [v3] hash: put GFNI stubs back |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build fail github build: failed
ci/iol-intel-Performance success Performance Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS

Commit Message

Stephen Hemminger March 7, 2024, 1:36 a.m. UTC
  Make the GFNI stub functions always built. This solves the conditional
linking problem. If GFNI is available, they will never get used.

Fixes: 07d836e5929d ("hash: uninline GFNI stubs")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
v3 - fix typo in call to ___rte_thash_gfni_bulk

 lib/hash/rte_thash_gfni.c |  9 +++------
 lib/hash/rte_thash_gfni.h | 30 +++++++++++++++++++++++-------
 lib/hash/version.map      |  9 +++++++--
 3 files changed, 33 insertions(+), 15 deletions(-)
  

Comments

David Marchand March 7, 2024, 11:05 a.m. UTC | #1
Hello,

On Thu, Mar 7, 2024 at 2:37 AM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> Make the GFNI stub functions always built. This solves the conditional
> linking problem. If GFNI is available, they will never get used.
>
> Fixes: 07d836e5929d ("hash: uninline GFNI stubs")
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
> v3 - fix typo in call to ___rte_thash_gfni_bulk
>
>  lib/hash/rte_thash_gfni.c |  9 +++------
>  lib/hash/rte_thash_gfni.h | 30 +++++++++++++++++++++++-------
>  lib/hash/version.map      |  9 +++++++--
>  3 files changed, 33 insertions(+), 15 deletions(-)
>
> diff --git a/lib/hash/rte_thash_gfni.c b/lib/hash/rte_thash_gfni.c
> index f1525f9838de..5ead51dd3426 100644
> --- a/lib/hash/rte_thash_gfni.c
> +++ b/lib/hash/rte_thash_gfni.c
> @@ -4,18 +4,17 @@
>
>  #include <stdbool.h>
>
> +#include <rte_compat.h>

This should be in the header since this is where the __rte_internal tag is used.
Moving this inclusion will fix the failing headers check for arches != x86:
http://mails.dpdk.org/archives/test-report/2024-March/603562.html


>  #include <rte_log.h>
>  #include <rte_thash_gfni.h>
>
> -#ifndef RTE_THASH_GFNI_DEFINED
> -
>  RTE_LOG_REGISTER_SUFFIX(hash_gfni_logtype, gfni, INFO);
>  #define RTE_LOGTYPE_HASH hash_gfni_logtype
>  #define HASH_LOG(level, ...) \
>         RTE_LOG_LINE(level, HASH, "" __VA_ARGS__)
>
>  uint32_t
> -rte_thash_gfni(const uint64_t *mtrx __rte_unused,
> +___rte_thash_gfni(const uint64_t *mtrx __rte_unused,

Let's go with a s/___rte_thash_gfni/rte_thash_gfni_stub/g.


>         const uint8_t *key __rte_unused, int len __rte_unused)
>  {
>         static bool warned;
> @@ -30,7 +29,7 @@ rte_thash_gfni(const uint64_t *mtrx __rte_unused,
>  }
>
>  void
> -rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
> +___rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
>         int len __rte_unused, uint8_t *tuple[] __rte_unused,
>         uint32_t val[], uint32_t num)
>  {
> @@ -47,5 +46,3 @@ rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
>         for (i = 0; i < num; i++)
>                 val[i] = 0;
>  }
> -
> -#endif
> diff --git a/lib/hash/rte_thash_gfni.h b/lib/hash/rte_thash_gfni.h
> index eed55fc86c86..432d5b63a12e 100644
> --- a/lib/hash/rte_thash_gfni.h
> +++ b/lib/hash/rte_thash_gfni.h
> @@ -17,11 +17,22 @@ extern "C" {
>
>  #endif
>
> -#ifndef RTE_THASH_GFNI_DEFINED
> +/*
> + * @internal
> + * Stubs defined for only used when GFNI is not available

This reads strange, I'll reword when applying as:
* Stubs only used when GFNI is not available


> + */
> +__rte_internal
> +uint32_t
> +___rte_thash_gfni(const uint64_t *mtrx, const uint8_t *key, int len);
> +
> +__rte_internal
> +void
> +___rte_thash_gfni_bulk(const uint64_t *mtrx, int len, uint8_t *tuple[],
> +                      uint32_t val[], uint32_t num);
>
> +#ifndef RTE_THASH_GFNI_DEFINED
>  /**
>   * Calculate Toeplitz hash.
> - * Dummy implementation.
>   *
>   * @param m
>   *  Pointer to the matrices generated from the corresponding
> @@ -33,12 +44,14 @@ extern "C" {
>   * @return
>   *  Calculated Toeplitz hash value.
>   */
> -uint32_t
> -rte_thash_gfni(const uint64_t *mtrx, const uint8_t *key, int len);
> +static inline uint32_t
> +rte_thash_gfni(const uint64_t *mtrx, const uint8_t *key, int len)
> +{
> +       return ___rte_thash_gfni(mtrx, key, len);
> +}
>
>  /**
>   * Bulk implementation for Toeplitz hash.
> - * Dummy implementation.
>   *
>   * @param m
>   *  Pointer to the matrices generated from the corresponding
> @@ -53,9 +66,12 @@ rte_thash_gfni(const uint64_t *mtrx, const uint8_t *key, int len);
>   * @param num
>   *  Number of tuples to hash.
>   */
> -void
> +static inline void
>  rte_thash_gfni_bulk(const uint64_t *mtrx, int len, uint8_t *tuple[],
> -       uint32_t val[], uint32_t num);
> +       uint32_t val[], uint32_t num)
> +{
> +       return ___rte_thash_gfni_bulk(mtrx, len, tuple, val, num);
> +}
>
>  #endif /* RTE_THASH_GFNI_DEFINED */
>
> diff --git a/lib/hash/version.map b/lib/hash/version.map
> index 6b2afebf6b46..942e2998578f 100644
> --- a/lib/hash/version.map
> +++ b/lib/hash/version.map
> @@ -41,10 +41,15 @@ DPDK_24 {
>         rte_thash_get_gfni_matrices;
>         rte_thash_get_helper;
>         rte_thash_get_key;
> -       rte_thash_gfni;
> -       rte_thash_gfni_bulk;
>         rte_thash_gfni_supported;
>         rte_thash_init_ctx;
>
>         local: *;
>  };
> +
> +INTERNAL {
> +       global:
> +
> +       ___rte_thash_gfni;
> +       ___rte_thash_gfni_bulk;
> +};
> --
> 2.43.0
>

The rest lgtm but I can't reproduce a link error in the first place.
I'll wait for Tyler to confirm this patch fixes the issue he hit.
  
Tyler Retzlaff March 7, 2024, 5:36 p.m. UTC | #2
On Wed, Mar 06, 2024 at 05:36:42PM -0800, Stephen Hemminger wrote:
> Make the GFNI stub functions always built. This solves the conditional
> linking problem. If GFNI is available, they will never get used.
> 
> Fixes: 07d836e5929d ("hash: uninline GFNI stubs")
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---

I can confirm that v3 of the series allows me to complete build & link
with LLVM 14 / clang.

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

> v3 - fix typo in call to ___rte_thash_gfni_bulk
> 
>  lib/hash/rte_thash_gfni.c |  9 +++------
>  lib/hash/rte_thash_gfni.h | 30 +++++++++++++++++++++++-------
>  lib/hash/version.map      |  9 +++++++--
>  3 files changed, 33 insertions(+), 15 deletions(-)
> 
> diff --git a/lib/hash/rte_thash_gfni.c b/lib/hash/rte_thash_gfni.c
> index f1525f9838de..5ead51dd3426 100644
> --- a/lib/hash/rte_thash_gfni.c
> +++ b/lib/hash/rte_thash_gfni.c
> @@ -4,18 +4,17 @@
>  
>  #include <stdbool.h>
>  
> +#include <rte_compat.h>
>  #include <rte_log.h>
>  #include <rte_thash_gfni.h>
>  
> -#ifndef RTE_THASH_GFNI_DEFINED
> -
>  RTE_LOG_REGISTER_SUFFIX(hash_gfni_logtype, gfni, INFO);
>  #define RTE_LOGTYPE_HASH hash_gfni_logtype
>  #define HASH_LOG(level, ...) \
>  	RTE_LOG_LINE(level, HASH, "" __VA_ARGS__)
>  
>  uint32_t
> -rte_thash_gfni(const uint64_t *mtrx __rte_unused,
> +___rte_thash_gfni(const uint64_t *mtrx __rte_unused,
>  	const uint8_t *key __rte_unused, int len __rte_unused)
>  {
>  	static bool warned;
> @@ -30,7 +29,7 @@ rte_thash_gfni(const uint64_t *mtrx __rte_unused,
>  }
>  
>  void
> -rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
> +___rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
>  	int len __rte_unused, uint8_t *tuple[] __rte_unused,
>  	uint32_t val[], uint32_t num)
>  {
> @@ -47,5 +46,3 @@ rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
>  	for (i = 0; i < num; i++)
>  		val[i] = 0;
>  }
> -
> -#endif
> diff --git a/lib/hash/rte_thash_gfni.h b/lib/hash/rte_thash_gfni.h
> index eed55fc86c86..432d5b63a12e 100644
> --- a/lib/hash/rte_thash_gfni.h
> +++ b/lib/hash/rte_thash_gfni.h
> @@ -17,11 +17,22 @@ extern "C" {
>  
>  #endif
>  
> -#ifndef RTE_THASH_GFNI_DEFINED
> +/*
> + * @internal
> + * Stubs defined for only used when GFNI is not available
> + */
> +__rte_internal
> +uint32_t
> +___rte_thash_gfni(const uint64_t *mtrx, const uint8_t *key, int len);
> +
> +__rte_internal
> +void
> +___rte_thash_gfni_bulk(const uint64_t *mtrx, int len, uint8_t *tuple[],
> +		       uint32_t val[], uint32_t num);
>  
> +#ifndef RTE_THASH_GFNI_DEFINED
>  /**
>   * Calculate Toeplitz hash.
> - * Dummy implementation.
>   *
>   * @param m
>   *  Pointer to the matrices generated from the corresponding
> @@ -33,12 +44,14 @@ extern "C" {
>   * @return
>   *  Calculated Toeplitz hash value.
>   */
> -uint32_t
> -rte_thash_gfni(const uint64_t *mtrx, const uint8_t *key, int len);
> +static inline uint32_t
> +rte_thash_gfni(const uint64_t *mtrx, const uint8_t *key, int len)
> +{
> +	return ___rte_thash_gfni(mtrx, key, len);
> +}
>  
>  /**
>   * Bulk implementation for Toeplitz hash.
> - * Dummy implementation.
>   *
>   * @param m
>   *  Pointer to the matrices generated from the corresponding
> @@ -53,9 +66,12 @@ rte_thash_gfni(const uint64_t *mtrx, const uint8_t *key, int len);
>   * @param num
>   *  Number of tuples to hash.
>   */
> -void
> +static inline void
>  rte_thash_gfni_bulk(const uint64_t *mtrx, int len, uint8_t *tuple[],
> -	uint32_t val[], uint32_t num);
> +	uint32_t val[], uint32_t num)
> +{
> +	return ___rte_thash_gfni_bulk(mtrx, len, tuple, val, num);
> +}
>  
>  #endif /* RTE_THASH_GFNI_DEFINED */
>  
> diff --git a/lib/hash/version.map b/lib/hash/version.map
> index 6b2afebf6b46..942e2998578f 100644
> --- a/lib/hash/version.map
> +++ b/lib/hash/version.map
> @@ -41,10 +41,15 @@ DPDK_24 {
>  	rte_thash_get_gfni_matrices;
>  	rte_thash_get_helper;
>  	rte_thash_get_key;
> -	rte_thash_gfni;
> -	rte_thash_gfni_bulk;
>  	rte_thash_gfni_supported;
>  	rte_thash_init_ctx;
>  
>  	local: *;
>  };
> +
> +INTERNAL {
> +	global:
> +
> +	___rte_thash_gfni;
> +	___rte_thash_gfni_bulk;
> +};
> -- 
> 2.43.0
  
David Marchand March 7, 2024, 5:59 p.m. UTC | #3
On Thu, Mar 7, 2024 at 6:37 PM Tyler Retzlaff
<roretzla@linux.microsoft.com> wrote:
> On Wed, Mar 06, 2024 at 05:36:42PM -0800, Stephen Hemminger wrote:
> > Make the GFNI stub functions always built. This solves the conditional
> > linking problem. If GFNI is available, they will never get used.
> >
> > Fixes: 07d836e5929d ("hash: uninline GFNI stubs")
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> Tested-by: Tyler Retzlaff <roretzla@linux.microsoft.com>

Applied with the edits I mentionned previously.
  
Stephen Hemminger March 7, 2024, 8:23 p.m. UTC | #4
On Thu, 7 Mar 2024 18:59:11 +0100
David Marchand <david.marchand@redhat.com> wrote:

> On Thu, Mar 7, 2024 at 6:37 PM Tyler Retzlaff
> <roretzla@linux.microsoft.com> wrote:
> > On Wed, Mar 06, 2024 at 05:36:42PM -0800, Stephen Hemminger wrote:  
> > > Make the GFNI stub functions always built. This solves the conditional
> > > linking problem. If GFNI is available, they will never get used.
> > >
> > > Fixes: 07d836e5929d ("hash: uninline GFNI stubs")
> > > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>  
> > Tested-by: Tyler Retzlaff <roretzla@linux.microsoft.com>  
> 
> Applied with the edits I mentionned previously.
> 
> 

I noticed that there is an still an unnecessary inclusion of rte_log.h
in rte_thash_gfni.h but that doesn't matter.
  

Patch

diff --git a/lib/hash/rte_thash_gfni.c b/lib/hash/rte_thash_gfni.c
index f1525f9838de..5ead51dd3426 100644
--- a/lib/hash/rte_thash_gfni.c
+++ b/lib/hash/rte_thash_gfni.c
@@ -4,18 +4,17 @@ 
 
 #include <stdbool.h>
 
+#include <rte_compat.h>
 #include <rte_log.h>
 #include <rte_thash_gfni.h>
 
-#ifndef RTE_THASH_GFNI_DEFINED
-
 RTE_LOG_REGISTER_SUFFIX(hash_gfni_logtype, gfni, INFO);
 #define RTE_LOGTYPE_HASH hash_gfni_logtype
 #define HASH_LOG(level, ...) \
 	RTE_LOG_LINE(level, HASH, "" __VA_ARGS__)
 
 uint32_t
-rte_thash_gfni(const uint64_t *mtrx __rte_unused,
+___rte_thash_gfni(const uint64_t *mtrx __rte_unused,
 	const uint8_t *key __rte_unused, int len __rte_unused)
 {
 	static bool warned;
@@ -30,7 +29,7 @@  rte_thash_gfni(const uint64_t *mtrx __rte_unused,
 }
 
 void
-rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
+___rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
 	int len __rte_unused, uint8_t *tuple[] __rte_unused,
 	uint32_t val[], uint32_t num)
 {
@@ -47,5 +46,3 @@  rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
 	for (i = 0; i < num; i++)
 		val[i] = 0;
 }
-
-#endif
diff --git a/lib/hash/rte_thash_gfni.h b/lib/hash/rte_thash_gfni.h
index eed55fc86c86..432d5b63a12e 100644
--- a/lib/hash/rte_thash_gfni.h
+++ b/lib/hash/rte_thash_gfni.h
@@ -17,11 +17,22 @@  extern "C" {
 
 #endif
 
-#ifndef RTE_THASH_GFNI_DEFINED
+/*
+ * @internal
+ * Stubs defined for only used when GFNI is not available
+ */
+__rte_internal
+uint32_t
+___rte_thash_gfni(const uint64_t *mtrx, const uint8_t *key, int len);
+
+__rte_internal
+void
+___rte_thash_gfni_bulk(const uint64_t *mtrx, int len, uint8_t *tuple[],
+		       uint32_t val[], uint32_t num);
 
+#ifndef RTE_THASH_GFNI_DEFINED
 /**
  * Calculate Toeplitz hash.
- * Dummy implementation.
  *
  * @param m
  *  Pointer to the matrices generated from the corresponding
@@ -33,12 +44,14 @@  extern "C" {
  * @return
  *  Calculated Toeplitz hash value.
  */
-uint32_t
-rte_thash_gfni(const uint64_t *mtrx, const uint8_t *key, int len);
+static inline uint32_t
+rte_thash_gfni(const uint64_t *mtrx, const uint8_t *key, int len)
+{
+	return ___rte_thash_gfni(mtrx, key, len);
+}
 
 /**
  * Bulk implementation for Toeplitz hash.
- * Dummy implementation.
  *
  * @param m
  *  Pointer to the matrices generated from the corresponding
@@ -53,9 +66,12 @@  rte_thash_gfni(const uint64_t *mtrx, const uint8_t *key, int len);
  * @param num
  *  Number of tuples to hash.
  */
-void
+static inline void
 rte_thash_gfni_bulk(const uint64_t *mtrx, int len, uint8_t *tuple[],
-	uint32_t val[], uint32_t num);
+	uint32_t val[], uint32_t num)
+{
+	return ___rte_thash_gfni_bulk(mtrx, len, tuple, val, num);
+}
 
 #endif /* RTE_THASH_GFNI_DEFINED */
 
diff --git a/lib/hash/version.map b/lib/hash/version.map
index 6b2afebf6b46..942e2998578f 100644
--- a/lib/hash/version.map
+++ b/lib/hash/version.map
@@ -41,10 +41,15 @@  DPDK_24 {
 	rte_thash_get_gfni_matrices;
 	rte_thash_get_helper;
 	rte_thash_get_key;
-	rte_thash_gfni;
-	rte_thash_gfni_bulk;
 	rte_thash_gfni_supported;
 	rte_thash_init_ctx;
 
 	local: *;
 };
+
+INTERNAL {
+	global:
+
+	___rte_thash_gfni;
+	___rte_thash_gfni_bulk;
+};