net/mlx5: fix compilation issues on old kernels

Message ID 1531675899-27007-1-git-send-email-motih@mellanox.com (mailing list archive)
State Accepted, archived
Delegated to: Shahaf Shuler
Headers
Series net/mlx5: fix compilation issues on old kernels |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation fail Compilation issues

Commit Message

Moti Haimovsky July 15, 2018, 5:31 p.m. UTC
  This commit fixes compilation errors due to missing definitions
found when compiling mlx5 PMD from DPDK 17.11-LTS on Ubuntu 12.4
with kernel 3.15.

Fixes: 75ef62a94301 ("net/mlx5: fix link speed capability information")
Fixes: 5bfc9fc112dd ("net/mlx5: use static assert for compile-time sanity checks")
Cc: stable@dpdk.org

Signed-off-by: Moti Haimovsky <motih@mellanox.com>
---
 drivers/net/mlx5/Makefile      | 45 ++++++++++++++++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_defs.h   |  5 +++++
 drivers/net/mlx5/mlx5_ethdev.c | 26 ++++++++++++++++++++++++
 3 files changed, 76 insertions(+)
  

Comments

Shahaf Shuler July 23, 2018, 7:57 a.m. UTC | #1
Sunday, July 15, 2018 8:32 PM, Mordechay Haimovsky:
> Subject: [PATCH] net/mlx5: fix compilation issues on old kernels
> 
> This commit fixes compilation errors due to missing definitions found when
> compiling mlx5 PMD from DPDK 17.11-LTS on Ubuntu 12.4 with kernel 3.15.
> 
> Fixes: 75ef62a94301 ("net/mlx5: fix link speed capability information")
> Fixes: 5bfc9fc112dd ("net/mlx5: use static assert for compile-time sanity
> checks")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Moti Haimovsky <motih@mellanox.com>

Acked-by: Shahaf Shuler <shahafs@mellanox.com>

Applied to next-net-mlx, thanks.

> ---
>  drivers/net/mlx5/Makefile      | 45
> ++++++++++++++++++++++++++++++++++++++++++
>  drivers/net/mlx5/mlx5_defs.h   |  5 +++++
>  drivers/net/mlx5/mlx5_ethdev.c | 26 ++++++++++++++++++++++++
>  3 files changed, 76 insertions(+)
> 
> diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile index
> d86c6bb..156c130 100644
> --- a/drivers/net/mlx5/Makefile
> +++ b/drivers/net/mlx5/Makefile
> @@ -197,6 +197,51 @@ mlx5_autoconf.h.new: $(RTE_SDK)/buildtools/auto-
> config-h.sh
>  		linux/if_link.h \
>  		enum IFLA_PHYS_PORT_NAME \
>  		$(AUTOCONF_OUTPUT)
> +	$Q sh -- '$<' '$@' \
> +		HAVE_SUPPORTED_40000baseKR4_Full \
> +		/usr/include/linux/ethtool.h \
> +		define SUPPORTED_40000baseKR4_Full \
> +		$(AUTOCONF_OUTPUT)
> +	$Q sh -- '$<' '$@' \
> +		HAVE_SUPPORTED_40000baseCR4_Full \
> +		/usr/include/linux/ethtool.h \
> +		define SUPPORTED_40000baseCR4_Full \
> +		$(AUTOCONF_OUTPUT)
> +	$Q sh -- '$<' '$@' \
> +		HAVE_SUPPORTED_40000baseSR4_Full \
> +		/usr/include/linux/ethtool.h \
> +		define SUPPORTED_40000baseSR4_Full \
> +		$(AUTOCONF_OUTPUT)
> +	$Q sh -- '$<' '$@' \
> +		HAVE_SUPPORTED_40000baseLR4_Full \
> +		/usr/include/linux/ethtool.h \
> +		define SUPPORTED_40000baseLR4_Full \
> +		$(AUTOCONF_OUTPUT)
> +	$Q sh -- '$<' '$@' \
> +		HAVE_SUPPORTED_56000baseKR4_Full \
> +		/usr/include/linux/ethtool.h \
> +		define SUPPORTED_56000baseKR4_Full \
> +		$(AUTOCONF_OUTPUT)
> +	$Q sh -- '$<' '$@' \
> +		HAVE_SUPPORTED_56000baseCR4_Full \
> +		/usr/include/linux/ethtool.h \
> +		define SUPPORTED_56000baseCR4_Full \
> +		$(AUTOCONF_OUTPUT)
> +	$Q sh -- '$<' '$@' \
> +		HAVE_SUPPORTED_56000baseSR4_Full \
> +		/usr/include/linux/ethtool.h \
> +		define SUPPORTED_56000baseSR4_Full \
> +		$(AUTOCONF_OUTPUT)
> +	$Q sh -- '$<' '$@' \
> +		HAVE_SUPPORTED_56000baseLR4_Full \
> +		/usr/include/linux/ethtool.h \
> +		define SUPPORTED_56000baseLR4_Full \
> +		$(AUTOCONF_OUTPUT)
> +	$Q sh -- '$<' '$@' \
> +		HAVE_STATIC_ASSERT \
> +		/usr/include/assert.h \
> +		define static_assert \
> +		$(AUTOCONF_OUTPUT)
> 
>  # Create mlx5_autoconf.h or update it in case it differs from the new one.
> 
> diff --git a/drivers/net/mlx5/mlx5_defs.h b/drivers/net/mlx5/mlx5_defs.h
> index f6ec415..439cc15 100644
> --- a/drivers/net/mlx5/mlx5_defs.h
> +++ b/drivers/net/mlx5/mlx5_defs.h
> @@ -128,4 +128,9 @@
>  /* Cache size of mempool for Multi-Packet RQ. */  #define
> MLX5_MPRQ_MP_CACHE_SZ 32
> 
> +/* Definition of static_assert found in /usr/include/assert.h */
> +#ifndef HAVE_STATIC_ASSERT #define static_assert _Static_assert #endif
> +
>  #endif /* RTE_PMD_MLX5_DEFS_H_ */
> diff --git a/drivers/net/mlx5/mlx5_ethdev.c
> b/drivers/net/mlx5/mlx5_ethdev.c index 6e44d5f..4b2231f 100644
> --- a/drivers/net/mlx5/mlx5_ethdev.c
> +++ b/drivers/net/mlx5/mlx5_ethdev.c
> @@ -42,6 +42,32 @@
>  #include "mlx5_rxtx.h"
>  #include "mlx5_utils.h"
> 
> +/* Supported speed values found in /usr/include/linux/ethtool.h */
> +#ifndef HAVE_SUPPORTED_40000baseKR4_Full #define
> +SUPPORTED_40000baseKR4_Full (1 << 23) #endif #ifndef
> +HAVE_SUPPORTED_40000baseCR4_Full #define
> SUPPORTED_40000baseCR4_Full (1
> +<< 24) #endif #ifndef HAVE_SUPPORTED_40000baseSR4_Full #define
> +SUPPORTED_40000baseSR4_Full (1 << 25) #endif #ifndef
> +HAVE_SUPPORTED_40000baseLR4_Full #define
> SUPPORTED_40000baseLR4_Full (1
> +<< 26) #endif #ifndef HAVE_SUPPORTED_56000baseKR4_Full #define
> +SUPPORTED_56000baseKR4_Full (1 << 27) #endif #ifndef
> +HAVE_SUPPORTED_56000baseCR4_Full #define
> SUPPORTED_56000baseCR4_Full (1
> +<< 28) #endif #ifndef HAVE_SUPPORTED_56000baseSR4_Full #define
> +SUPPORTED_56000baseSR4_Full (1 << 29) #endif #ifndef
> +HAVE_SUPPORTED_56000baseLR4_Full #define
> SUPPORTED_56000baseLR4_Full (1
> +<< 30) #endif
> +
>  /* Add defines in case the running kernel is not the same as user headers. */
> #ifndef ETHTOOL_GLINKSETTINGS  struct ethtool_link_settings {
> --
> 1.8.3.1
  

Patch

diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile
index d86c6bb..156c130 100644
--- a/drivers/net/mlx5/Makefile
+++ b/drivers/net/mlx5/Makefile
@@ -197,6 +197,51 @@  mlx5_autoconf.h.new: $(RTE_SDK)/buildtools/auto-config-h.sh
 		linux/if_link.h \
 		enum IFLA_PHYS_PORT_NAME \
 		$(AUTOCONF_OUTPUT)
+	$Q sh -- '$<' '$@' \
+		HAVE_SUPPORTED_40000baseKR4_Full \
+		/usr/include/linux/ethtool.h \
+		define SUPPORTED_40000baseKR4_Full \
+		$(AUTOCONF_OUTPUT)
+	$Q sh -- '$<' '$@' \
+		HAVE_SUPPORTED_40000baseCR4_Full \
+		/usr/include/linux/ethtool.h \
+		define SUPPORTED_40000baseCR4_Full \
+		$(AUTOCONF_OUTPUT)
+	$Q sh -- '$<' '$@' \
+		HAVE_SUPPORTED_40000baseSR4_Full \
+		/usr/include/linux/ethtool.h \
+		define SUPPORTED_40000baseSR4_Full \
+		$(AUTOCONF_OUTPUT)
+	$Q sh -- '$<' '$@' \
+		HAVE_SUPPORTED_40000baseLR4_Full \
+		/usr/include/linux/ethtool.h \
+		define SUPPORTED_40000baseLR4_Full \
+		$(AUTOCONF_OUTPUT)
+	$Q sh -- '$<' '$@' \
+		HAVE_SUPPORTED_56000baseKR4_Full \
+		/usr/include/linux/ethtool.h \
+		define SUPPORTED_56000baseKR4_Full \
+		$(AUTOCONF_OUTPUT)
+	$Q sh -- '$<' '$@' \
+		HAVE_SUPPORTED_56000baseCR4_Full \
+		/usr/include/linux/ethtool.h \
+		define SUPPORTED_56000baseCR4_Full \
+		$(AUTOCONF_OUTPUT)
+	$Q sh -- '$<' '$@' \
+		HAVE_SUPPORTED_56000baseSR4_Full \
+		/usr/include/linux/ethtool.h \
+		define SUPPORTED_56000baseSR4_Full \
+		$(AUTOCONF_OUTPUT)
+	$Q sh -- '$<' '$@' \
+		HAVE_SUPPORTED_56000baseLR4_Full \
+		/usr/include/linux/ethtool.h \
+		define SUPPORTED_56000baseLR4_Full \
+		$(AUTOCONF_OUTPUT)
+	$Q sh -- '$<' '$@' \
+		HAVE_STATIC_ASSERT \
+		/usr/include/assert.h \
+		define static_assert \
+		$(AUTOCONF_OUTPUT)
 
 # Create mlx5_autoconf.h or update it in case it differs from the new one.
 
diff --git a/drivers/net/mlx5/mlx5_defs.h b/drivers/net/mlx5/mlx5_defs.h
index f6ec415..439cc15 100644
--- a/drivers/net/mlx5/mlx5_defs.h
+++ b/drivers/net/mlx5/mlx5_defs.h
@@ -128,4 +128,9 @@ 
 /* Cache size of mempool for Multi-Packet RQ. */
 #define MLX5_MPRQ_MP_CACHE_SZ 32
 
+/* Definition of static_assert found in /usr/include/assert.h */
+#ifndef HAVE_STATIC_ASSERT
+#define static_assert _Static_assert
+#endif
+
 #endif /* RTE_PMD_MLX5_DEFS_H_ */
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index 6e44d5f..4b2231f 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -42,6 +42,32 @@ 
 #include "mlx5_rxtx.h"
 #include "mlx5_utils.h"
 
+/* Supported speed values found in /usr/include/linux/ethtool.h */
+#ifndef HAVE_SUPPORTED_40000baseKR4_Full
+#define SUPPORTED_40000baseKR4_Full (1 << 23)
+#endif
+#ifndef HAVE_SUPPORTED_40000baseCR4_Full
+#define SUPPORTED_40000baseCR4_Full (1 << 24)
+#endif
+#ifndef HAVE_SUPPORTED_40000baseSR4_Full
+#define SUPPORTED_40000baseSR4_Full (1 << 25)
+#endif
+#ifndef HAVE_SUPPORTED_40000baseLR4_Full
+#define SUPPORTED_40000baseLR4_Full (1 << 26)
+#endif
+#ifndef HAVE_SUPPORTED_56000baseKR4_Full
+#define SUPPORTED_56000baseKR4_Full (1 << 27)
+#endif
+#ifndef HAVE_SUPPORTED_56000baseCR4_Full
+#define SUPPORTED_56000baseCR4_Full (1 << 28)
+#endif
+#ifndef HAVE_SUPPORTED_56000baseSR4_Full
+#define SUPPORTED_56000baseSR4_Full (1 << 29)
+#endif
+#ifndef HAVE_SUPPORTED_56000baseLR4_Full
+#define SUPPORTED_56000baseLR4_Full (1 << 30)
+#endif
+
 /* Add defines in case the running kernel is not the same as user headers. */
 #ifndef ETHTOOL_GLINKSETTINGS
 struct ethtool_link_settings {