fix mlx5 build with MinGW
Subsystems (2)
cover fix mlx5 build with MinGW
The first patch is a fix for EAL Windows.
The 2 other patches are cleaning up mlx5 for Windows.
The result is to make possible to compile mlx5 on Linux for Windows.
Thomas Monjalon (3):
eal/windows: fix pedantic build
common/mlx5: get Windows dependency from standard variables net/mlx5: fix Windows build with MinGW GCC 12
doc/guides/platform/mlx5.rst | 12 ++- drivers/common/mlx5/meson.build | 4 +- drivers/common/mlx5/windows/meson.build | 28 +++--- drivers/common/mlx5/windows/mlx5_win_defs.h | 100 +++++++++++--------- drivers/net/mlx5/meson.build | 11 ++- drivers/net/mlx5/windows/mlx5_os.c | 4 +- lib/eal/windows/include/pthread.h | 3 +- 7 files changed, 89 insertions(+), 73 deletions(-)
Signature · 1 line
2.39.0
PATCH 1/3 eal/windows: fix pedantic build
MinGW GCC 12 shows an illegal pointer conversion
when included in a pedantic module:
lib/eal/windows/include/pthread.h:137:41: error:
ISO C forbids conversion of object pointer to function pointer type [-Werror=pedantic]
137 | hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)threadfunc,
| ^
By using uintptr_t, the compiler is forced to accept the conversion.
--- lib/eal/windows/include/pthread.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
lib/eal/windows/include/pthread.h +2 -1
@@ -134,7 +134,8 @@ pthread_create(void *threadid, const void *threadattr, void *threadfunc, {RTE_SET_USED (threadattr);HANDLE hThread; - hThread =CreateThread (NULL ,0 , (LPTHREAD_START_ROUTINE )threadfunc, + hThread =CreateThread (NULL ,0 , + (LPTHREAD_START_ROUTINE )(uintptr_t )threadfunc, args,0 , (LPDWORD )threadid);if (hThread) {SetPriorityClass (GetCurrentProcess (),NORMAL_PRIORITY_CLASS );
Signature · 1 line
2.39.0
Re: [PATCH 1/3] eal/windows: fix pedantic build
Quoted 9 lines · Thomas Monjalon
MinGW GCC 12 shows an illegal pointer conversion
when included in a pedantic module:
lib/eal/windows/include/pthread.h:137:41: error:
ISO C forbids conversion of object pointer to function pointer type [-Werror=pedantic]
137 | hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)threadfunc,
| ^
Quoted 7 lines
Fixes e8428a9d89f1 ("eal/windows: add some basic functions and macros")By using
uintptr_t, the compiler is forced to accept the conversion.Signed-off-by Thomas Monjalon <[email protected]>---
PATCH 2/3 common/mlx5: get Windows dependency from standard variables
In reply to Thomas MonjalonIt was requested to provide path to DevX library through DEVX_INC_PATH and DEVX_LIB_PATH.
It was non-standard and triggers some issues with recent Meson.
Using CFLAGS/LDFLAGS is standard and simpler.
It is also possible to use the Meson options -Dc_args and -Dc_link_args. There are 2 options to provide:
-I<include_directory>
-L<library_directory>
--- doc/guides/platform/mlx5.rst | 12 ++++++----- drivers/common/mlx5/windows/meson.build | 28 ++++++++++++------------- 2 files changed, 21 insertions(+), 19 deletions(-)
doc/guides/platform/mlx5.rst +7 -5
@@ -259,13 +259,15 @@ configured by the ``ibverbs_link`` build option: Compilation on Windows ~~~~~~~~~~~~~~~~~~~~~~ -The DevX SDK location must be set through two environment variables: +The DevX SDK location must be set through CFLAGS/LDFLAGS, +either:: -``DEVX_LIB_PATH`` - path to the DevX lib file. + meson -Dc_args=-Idevx/inc -Dc_link_args=-Ldevx/lib -``DEVX_INC_PATH`` - path to the DevX header files. +or:: + + export CFLAGS=-Idevx/inc + export LDFLAGS=-Ldevx/lib .. _mlx5_common_env:
drivers/common/mlx5/windows/meson.build +14 -14
@@ -1,6 +1,20 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright 2019 Mellanox Technologies, Ltd +if not cc.has_header('mlx5devx.h') + build = false + reason = 'missing dependency, "mlx5devx.h"' + subdir_done() +endif + +devxlib = cc.find_library('mlx5devx', required: true) +if not devxlib.found() + build = false + reason = 'missing dependency, "mlx5devx"' + subdir_done() +endif +ext_deps += devxlib + includes += include_directories('.') sources += files(
@@ -8,20 +22,6 @@ sources += files( 'mlx5_common_os.c', ) -res_lib = run_command(python3, '-c', 'import os; print(os.environ["DEVX_LIB_PATH"])', check: false) -res_inc = run_command(python3, '-c', 'import os; print(os.environ["DEVX_INC_PATH"])', check: false) - -if (res_lib.returncode() != 0 or res_inc.returncode() != 0) - build = false - reason = 'DevX environment variables are not set, DEVX_LIB_PATH and DEVX_INC_PATH vars must be exported' - subdir_done() -endif - -devx_lib_dir = res_lib.stdout().strip() -devx_inc_dir = res_inc.stdout().strip() - -ext_deps += cc.find_library('mlx5devx', dirs: devx_lib_dir, required: true) -includes += include_directories(devx_inc_dir) cflags_options = [ '-std=c11', '-Wno-strict-prototypes',
Signature · 1 line
2.39.0
PATCH 3/3 net/mlx5: fix Windows build with MinGW GCC 12
In reply to Thomas MonjalonWith recent changes in Meson and MinGW toolchain, the driver mlx5 was not able to compile on Linux for Windows.
There were errors due to non-typed constants, constant going over int range forbidden in pedantic mode, vector Rx functions undefined in Windows case, and minimum-comparison of different types.
--- drivers/common/mlx5/meson.build | 4 +- drivers/common/mlx5/windows/mlx5_win_defs.h | 100 +++++++++++--------- drivers/net/mlx5/meson.build | 11 ++- drivers/net/mlx5/windows/mlx5_os.c | 4 +- 4 files changed, 66 insertions(+), 53 deletions(-)
drivers/common/mlx5/meson.build +2 -2
@@ -1,9 +1,9 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright 2019 Mellanox Technologies, Ltd -if not (is_linux or (is_windows and is_ms_linker)) +if not (is_linux or is_windows) build = false - reason = 'only supported on Linux and Windows build with clang' + reason = 'only supported on Linux and Windows' subdir_done() endif
drivers/common/mlx5/windows/mlx5_win_defs.h +56 -44
160 lines not on this page · raw message
drivers/net/mlx5/meson.build +6 -5
@@ -49,11 +49,12 @@ if is_linux 'mlx5_hws_cnt.c', 'mlx5_flow_verbs.c', ) - if (dpdk_conf.has('RTE_ARCH_X86_64') - or dpdk_conf.has('RTE_ARCH_ARM64') - or dpdk_conf.has('RTE_ARCH_PPC_64')) - sources += files('mlx5_rxtx_vec.c') - endif +endif + +if (dpdk_conf.has('RTE_ARCH_X86_64') + or dpdk_conf.has('RTE_ARCH_ARM64') + or dpdk_conf.has('RTE_ARCH_PPC_64')) + sources += files('mlx5_rxtx_vec.c') endif cflags_options = [
drivers/net/mlx5/windows/mlx5_os.c +2 -2
@@ -193,8 +193,8 @@ mlx5_os_capabilities_prepare(struct mlx5_dev_ctx_shared *sh)* Once DPDK supports it, take max size from device attr. */ sh->dev_cap.ind_table_max_size = -RTE_MIN (1 << hca_attr->rss_ind_tbl_cap, - (unsigned int )RTE_ETH_RSS_RETA_SIZE_512 ); +RTE_MIN ((uint32_t )1 << hca_attr->rss_ind_tbl_cap, + (uint32_t )RTE_ETH_RSS_RETA_SIZE_512 );DRV_LOG (DEBUG ,"Maximum Rx indirection table size is %u" , sh->dev_cap.ind_table_max_size); }
Signature · 1 line
2.39.0
v2 cover fix Windows build with MinGW and mlx5
In reply to Thomas MonjalonThe first patch is a fix for EAL Windows.
The 3 other patches are cleaning up mlx5 for Windows.
The result is to make possible to compile mlx5 on Linux for Windows.
v2: improve mlx5 doc and remove weak attribute from mlx5
Thomas Monjalon (4):
eal/windows: fix pedantic build
common/mlx5: get Windows dependency from standard variables net/mlx5: remove weak stub functions
net/mlx5: fix Windows build with MinGW GCC 12
doc/guides/platform/mlx5.rst | 11 ++- drivers/common/mlx5/meson.build | 4 +- drivers/common/mlx5/windows/meson.build | 28 +++--- drivers/common/mlx5/windows/mlx5_win_defs.h | 100 +++++++++++--------- drivers/net/mlx5/meson.build | 13 ++- drivers/net/mlx5/mlx5_rx.c | 35 ------- drivers/net/mlx5/mlx5_rxtx_vec_null.c | 38 ++++++++ drivers/net/mlx5/windows/mlx5_os.c | 4 +- lib/eal/windows/include/pthread.h | 3 +- 9 files changed, 128 insertions(+), 108 deletions(-) create mode 100644 drivers/net/mlx5/mlx5_rxtx_vec_null.c
Signature · 1 line
2.39.0
PATCH v2 1/4 eal/windows: fix pedantic build
MinGW GCC 12 shows an illegal pointer conversion
when included in a pedantic module:
lib/eal/windows/include/pthread.h:137:41: error:
ISO C forbids conversion of object pointer to function pointer type [-Werror=pedantic]
137 | hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)threadfunc,
| ^
By using uintptr_t, the compiler is forced to accept the conversion.
--- lib/eal/windows/include/pthread.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
lib/eal/windows/include/pthread.h +2 -1
@@ -134,7 +134,8 @@ pthread_create(void *threadid, const void *threadattr, void *threadfunc, {RTE_SET_USED (threadattr);HANDLE hThread; - hThread =CreateThread (NULL ,0 , (LPTHREAD_START_ROUTINE )threadfunc, + hThread =CreateThread (NULL ,0 , + (LPTHREAD_START_ROUTINE )(uintptr_t )threadfunc, args,0 , (LPDWORD )threadid);if (hThread) {SetPriorityClass (GetCurrentProcess (),NORMAL_PRIORITY_CLASS );
Signature · 1 line
2.39.0
Thomas Monjalon
AppliedRe: [PATCH v2 1/4] eal/windows: fix pedantic build
12/01/2023 21:37, Thomas Monjalon:
Quoted 9 lines
MinGW GCC 12 shows an illegal pointer conversion
when included in a pedantic module:
lib/eal/windows/include/pthread.h:137:41: error:
ISO C forbids conversion of object pointer to function pointer type [-Werror=pedantic]
137 | hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)threadfunc,
| ^
Quoted 7 lines
Fixes e8428a9d89f1 ("eal/windows: add some basic functions and macros")By using
uintptr_t, the compiler is forced to accept the conversion.Signed-off-by Thomas Monjalon <[email protected]>Acked-by Tyler Retzlaff <[email protected]>
Applied this single patch, so the rest of the series can be managed in mlx tree.
PATCH v2 2/4 common/mlx5: get Windows dependency from standard variables
In reply to Thomas MonjalonIt was requested to provide path to DevX library through DEVX_INC_PATH and DEVX_LIB_PATH.
It was non-standard and triggers some issues with recent Meson.
Using CFLAGS/LDFLAGS is standard and simpler.
It is also possible to use the Meson options -Dc_args and -Dc_link_args. There are 2 options to provide:
-I<include_directory>
-L<library_directory>
--- doc/guides/platform/mlx5.rst | 11 +++++----- drivers/common/mlx5/windows/meson.build | 28 ++++++++++++------------- 2 files changed, 20 insertions(+), 19 deletions(-)
doc/guides/platform/mlx5.rst +6 -5
@@ -259,13 +259,14 @@ configured by the ``ibverbs_link`` build option: Compilation on Windows ~~~~~~~~~~~~~~~~~~~~~~ -The DevX SDK location must be set through two environment variables: +The DevX SDK location must be set through CFLAGS/LDFLAGS, +either:: -``DEVX_LIB_PATH`` - path to the DevX lib file. + meson.exe setup "-Dc_args=-I\"%DEVX_INC_PATH%\"" "-Dc_link_args=-L\"%DEVX_LIB_PATH%\"" ... -``DEVX_INC_PATH`` - path to the DevX header files. +or:: + + set CFLAGS=-I"%DEVX_INC_PATH%" && set LDFLAGS=-L"%DEVX_LIB_PATH%" && meson.exe setup ... .. _mlx5_common_env:
drivers/common/mlx5/windows/meson.build +14 -14
@@ -1,6 +1,20 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright 2019 Mellanox Technologies, Ltd +if not cc.has_header('mlx5devx.h') + build = false + reason = 'missing dependency, "mlx5devx.h"' + subdir_done() +endif + +devxlib = cc.find_library('mlx5devx', required: true) +if not devxlib.found() + build = false + reason = 'missing dependency, "mlx5devx"' + subdir_done() +endif +ext_deps += devxlib + includes += include_directories('.') sources += files(
@@ -8,20 +22,6 @@ sources += files( 'mlx5_common_os.c', ) -res_lib = run_command(python3, '-c', 'import os; print(os.environ["DEVX_LIB_PATH"])', check: false) -res_inc = run_command(python3, '-c', 'import os; print(os.environ["DEVX_INC_PATH"])', check: false) - -if (res_lib.returncode() != 0 or res_inc.returncode() != 0) - build = false - reason = 'DevX environment variables are not set, DEVX_LIB_PATH and DEVX_INC_PATH vars must be exported' - subdir_done() -endif - -devx_lib_dir = res_lib.stdout().strip() -devx_inc_dir = res_inc.stdout().strip() - -ext_deps += cc.find_library('mlx5devx', dirs: devx_lib_dir, required: true) -includes += include_directories(devx_inc_dir) cflags_options = [ '-std=c11', '-Wno-strict-prototypes',
Signature · 1 line
2.39.0
PATCH v2 3/4 net/mlx5: remove weak stub functions
In reply to Thomas MonjalonThe vector Rx functions are conditionally compiled. Some stub functions were also always compiled with weak attribute. If there is no vector support, the weak functions were linked.
These weak functions are moved in a specific file which is compiled only if there is no vector support. This way it is simpler to understand,
and the weak attributes can be removed.
This change helps to compile with MinGW GCC
which has no support for weak functions.
--- drivers/net/mlx5/meson.build | 13 +++++---- drivers/net/mlx5/mlx5_rx.c | 35 ------------------------ drivers/net/mlx5/mlx5_rxtx_vec_null.c | 38 +++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 40 deletions(-) create mode 100644 drivers/net/mlx5/mlx5_rxtx_vec_null.c
drivers/net/mlx5/meson.build +8 -5
@@ -49,11 +49,14 @@ if is_linux 'mlx5_hws_cnt.c', 'mlx5_flow_verbs.c', ) - if (dpdk_conf.has('RTE_ARCH_X86_64') - or dpdk_conf.has('RTE_ARCH_ARM64') - or dpdk_conf.has('RTE_ARCH_PPC_64')) - sources += files('mlx5_rxtx_vec.c') - endif +endif + +if is_linux and (dpdk_conf.has('RTE_ARCH_X86_64') + or dpdk_conf.has('RTE_ARCH_ARM64') + or dpdk_conf.has('RTE_ARCH_PPC_64')) + sources += files('mlx5_rxtx_vec.c') +else + sources += files('mlx5_rxtx_vec_null.c') endif cflags_options = [
drivers/net/mlx5/mlx5_rx.c +0 -35
@@ -1185,41 +1185,6 @@ mlx5_rx_burst_mprq(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)return i; } -/* -* Vectorized Rx routines are not compiled in when required vector instructions -* are not supported on a target architecture. -* The following null stubs are needed for linkage when those are not included -* outside of this file (e.g. mlx5_rxtx_vec_sse.c for x86). -*/ - -__rte_weak uint16_t -mlx5_rx_burst_vec(void *dpdk_rxq __rte_unused, - struct rte_mbuf **pkts __rte_unused, - uint16_t pkts_n __rte_unused) -{ -return 0 ; -} - -__rte_weak uint16_t -mlx5_rx_burst_mprq_vec(void *dpdk_rxq __rte_unused, - struct rte_mbuf **pkts __rte_unused, - uint16_t pkts_n __rte_unused) -{ -return 0 ; -} - -__rte_weak int -mlx5_rxq_check_vec_support(struct mlx5_rxq_data *rxq __rte_unused) -{ -return -ENOTSUP ; -} - -__rte_weak int -mlx5_check_vec_rx_support(struct rte_eth_dev *dev __rte_unused) -{ -return -ENOTSUP ; -} -int mlx5_rx_queue_lwm_query (struct rte_eth_dev *dev,uint16_t *queue_id,uint8_t *lwm)
drivers/net/mlx5/mlx5_rxtx_vec_null.c new file +38 -0
@@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (c) 2023 NVIDIA Corporation & Affiliates +*/ + +#include <rte_common.h> + +#include "mlx5_rx.h" + +struct rte_mbuf ; +struct rte_eth_dev ; + +uint16_t +mlx5_rx_burst_vec(void *dpdk_rxq __rte_unused, + struct rte_mbuf **pkts __rte_unused, + uint16_t pkts_n __rte_unused) +{ +return 0 ; +} + +uint16_t +mlx5_rx_burst_mprq_vec(void *dpdk_rxq __rte_unused, + struct rte_mbuf **pkts __rte_unused, + uint16_t pkts_n __rte_unused) +{ +return 0 ; +} + +int +mlx5_rxq_check_vec_support(struct mlx5_rxq_data *rxq __rte_unused) +{ +return -ENOTSUP ; +} + +int +mlx5_check_vec_rx_support(struct rte_eth_dev *dev __rte_unused) +{ +return -ENOTSUP ; +}
Signature · 1 line
2.39.0
Re: [PATCH v2 3/4] net/mlx5: remove weak stub functions
2023-01-12 21:37 (UTC+0100), Thomas Monjalon:
Quoted 32 lines
The vector Rx functions are conditionally compiled. Some stub functions were also always compiled with weak attribute. If there is no vector support, the weak functions were linked.
These weak functions are moved in a specific file which is compiled only if there is no vector support. This way it is simpler to understand,
and the weak attributes can be removed.This change helps to compile with MinGW GCC
which has no support for weak functions.Signed-off-by Thomas Monjalon <[email protected]>--- drivers/net/mlx5/meson.build | 13 +++++---- drivers/net/mlx5/mlx5_rx.c | 35 ------------------------ drivers/net/mlx5/mlx5_rxtx_vec_null.c | 38 +++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 40 deletions(-) create mode 100644 drivers/net/mlx5/mlx5_rxtx_vec_null.cdrivers/net/mlx5/meson.build +0
-4@@ -49,11 +49,14 @@ if is_linux 'mlx5_hws_cnt.c', 'mlx5_flow_verbs.c', ) - if (dpdk_conf.has('RTE_ARCH_X86_64') - or dpdk_conf.has('RTE_ARCH_ARM64') - or dpdk_conf.has('RTE_ARCH_PPC_64')) - sources += files('mlx5_rxtx_vec.c')
drivers/net/mlx5/meson.build if is_linux · line 60
Quoted 10 lines
drivers/net/mlx5/meson.build +8
-1- endif +endif + +if is_linux and (dpdk_conf.has('RTE_ARCH_X86_64') + or dpdk_conf.has('RTE_ARCH_ARM64') + or dpdk_conf.has('RTE_ARCH_PPC_64')) + sources += files('mlx5_rxtx_vec.c') +else + sources += files('mlx5_rxtx_vec_null.c') endif
Can "is_linux" be dropped now?
I suspect that vector routines were compiled only for Linux to prevent linker errors from both weak and non-weak symbols present, not because vector code is somehow Linux-specific.
Re: [PATCH v2 3/4] net/mlx5: remove weak stub functions
23/01/2023 20:42, Dmitry Kozlyuk:
Quoted 40 lines
2023-01-12 21:37 (UTC+0100), Thomas Monjalon:
Quoted 39 lines
The vector Rx functions are conditionally compiled. Some stub functions were also always compiled with weak attribute. If there is no vector support, the weak functions were linked.
These weak functions are moved in a specific file which is compiled only if there is no vector support. This way it is simpler to understand,
and the weak attributes can be removed.This change helps to compile with MinGW GCC
which has no support for weak functions.Signed-off-by Thomas Monjalon <[email protected]>--- drivers/net/mlx5/meson.build | 13 +++++---- drivers/net/mlx5/mlx5_rx.c | 35 ------------------------ drivers/net/mlx5/mlx5_rxtx_vec_null.c | 38 +++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 40 deletions(-) create mode 100644 drivers/net/mlx5/mlx5_rxtx_vec_null.cdrivers/net/mlx5/meson.build +6
-5@@ -49,11 +49,14 @@ if is_linux 'mlx5_hws_cnt.c', 'mlx5_flow_verbs.c', ) - if (dpdk_conf.has('RTE_ARCH_X86_64') - or dpdk_conf.has('RTE_ARCH_ARM64') - or dpdk_conf.has('RTE_ARCH_PPC_64')) - sources += files('mlx5_rxtx_vec.c') - endif +endif + +if is_linux and (dpdk_conf.has('RTE_ARCH_X86_64') + or dpdk_conf.has('RTE_ARCH_ARM64') + or dpdk_conf.has('RTE_ARCH_PPC_64')) + sources += files('mlx5_rxtx_vec.c')
Quoted 8 lines
drivers/net/mlx5/meson.build if is_linux · line 60
Quoted 3 lines
drivers/net/mlx5/meson.build +2
-0+else + sources += files('mlx5_rxtx_vec_null.c') endifCan "
is_linux" be dropped now?
I suspect that vector routines were compiled only for Linux to prevent linker errors from both weak and non-weak symbols present, not because vector code is somehow Linux-specific.
Maybe but we should enable vector routines on Windows in a separate patch.
PATCH v2 4/4 net/mlx5: fix Windows build with MinGW GCC 12
In reply to Thomas MonjalonWith recent changes in Meson and MinGW toolchain, the driver mlx5 was not able to compile on Linux for Windows.
There were errors due to system detection, non-typed constants, constant going over int range forbidden in pedantic mode, and minimum-comparison of different types.
--- drivers/common/mlx5/meson.build | 4 +- drivers/common/mlx5/windows/mlx5_win_defs.h | 100 +++++++++++--------- drivers/net/mlx5/windows/mlx5_os.c | 4 +- 3 files changed, 60 insertions(+), 48 deletions(-)
drivers/common/mlx5/meson.build +2 -2
@@ -1,9 +1,9 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright 2019 Mellanox Technologies, Ltd -if not (is_linux or (is_windows and is_ms_linker)) +if not (is_linux or is_windows) build = false - reason = 'only supported on Linux and Windows build with clang' + reason = 'only supported on Linux and Windows' subdir_done() endif
drivers/common/mlx5/windows/mlx5_win_defs.h +56 -44
160 lines not on this page · raw message
drivers/net/mlx5/windows/mlx5_os.c +2 -2
@@ -193,8 +193,8 @@ mlx5_os_capabilities_prepare(struct mlx5_dev_ctx_shared *sh)* Once DPDK supports it, take max size from device attr. */ sh->dev_cap.ind_table_max_size = -RTE_MIN (1 << hca_attr->rss_ind_tbl_cap, - (unsigned int )RTE_ETH_RSS_RETA_SIZE_512 ); +RTE_MIN ((uint32_t )1 << hca_attr->rss_ind_tbl_cap, + (uint32_t )RTE_ETH_RSS_RETA_SIZE_512 );DRV_LOG (DEBUG ,"Maximum Rx indirection table size is %u" , sh->dev_cap.ind_table_max_size); }
Signature · 1 line
2.39.0
v3 cover mlx5: fix Windows build with Linux MinGW
In reply to Thomas MonjalonThe result is to make possible to compile mlx5 on Linux for Windows.
v2: improve mlx5 doc and remove weak attribute from mlx5
v3: avoid MinGW on Windows - EAL patch already applied
Thomas Monjalon (3):
common/mlx5: get Windows dependency from standard variables net/mlx5: remove weak stub functions
net/mlx5: fix Windows build with MinGW GCC 12
doc/guides/platform/mlx5.rst | 11 ++- drivers/common/mlx5/meson.build | 9 +- drivers/common/mlx5/windows/meson.build | 28 +++--- drivers/common/mlx5/windows/mlx5_win_defs.h | 100 +++++++++++--------- drivers/net/mlx5/meson.build | 13 ++- drivers/net/mlx5/mlx5_rx.c | 35 ------- drivers/net/mlx5/mlx5_rxtx_vec_null.c | 38 ++++++++ drivers/net/mlx5/windows/mlx5_os.c | 4 +- 8 files changed, 131 insertions(+), 107 deletions(-) create mode 100644 drivers/net/mlx5/mlx5_rxtx_vec_null.c
Signature · 1 line
2.39.1
PATCH v3 1/3 common/mlx5: get Windows dependency from standard variables
The DevX library path had to be provided through the variables DEVX_INC_PATH and DEVX_LIB_PATH.
It was non-standard and triggers some issues with recent Meson.
Using CFLAGS/LDFLAGS is standard and simpler.
It is also possible to use the Meson options -Dc_args and -Dc_link_args. There are 2 options to provide:
-I<include_directory>
-L<library_directory>
--- doc/guides/platform/mlx5.rst | 11 +++++----- drivers/common/mlx5/windows/meson.build | 28 ++++++++++++------------- 2 files changed, 20 insertions(+), 19 deletions(-)
doc/guides/platform/mlx5.rst +6 -5
@@ -259,13 +259,14 @@ configured by the ``ibverbs_link`` build option: Compilation on Windows ~~~~~~~~~~~~~~~~~~~~~~ -The DevX SDK location must be set through two environment variables: +The DevX SDK location must be set through CFLAGS/LDFLAGS, +either:: -``DEVX_LIB_PATH`` - path to the DevX lib file. + meson.exe setup "-Dc_args=-I\"%DEVX_INC_PATH%\"" "-Dc_link_args=-L\"%DEVX_LIB_PATH%\"" ... -``DEVX_INC_PATH`` - path to the DevX header files. +or:: + + set CFLAGS=-I"%DEVX_INC_PATH%" && set LDFLAGS=-L"%DEVX_LIB_PATH%" && meson.exe setup ... .. _mlx5_common_env:
drivers/common/mlx5/windows/meson.build +14 -14
@@ -1,6 +1,20 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright 2019 Mellanox Technologies, Ltd +if not cc.has_header('mlx5devx.h') + build = false + reason = 'missing dependency, "mlx5devx.h"' + subdir_done() +endif + +devxlib = cc.find_library('mlx5devx', required: true) +if not devxlib.found() + build = false + reason = 'missing dependency, "mlx5devx"' + subdir_done() +endif +ext_deps += devxlib + includes += include_directories('.') sources += files(
@@ -8,20 +22,6 @@ sources += files( 'mlx5_common_os.c', ) -res_lib = run_command(python3, '-c', 'import os; print(os.environ["DEVX_LIB_PATH"])', check: false) -res_inc = run_command(python3, '-c', 'import os; print(os.environ["DEVX_INC_PATH"])', check: false) - -if (res_lib.returncode() != 0 or res_inc.returncode() != 0) - build = false - reason = 'DevX environment variables are not set, DEVX_LIB_PATH and DEVX_INC_PATH vars must be exported' - subdir_done() -endif - -devx_lib_dir = res_lib.stdout().strip() -devx_inc_dir = res_inc.stdout().strip() - -ext_deps += cc.find_library('mlx5devx', dirs: devx_lib_dir, required: true) -includes += include_directories(devx_inc_dir) cflags_options = [ '-std=c11', '-Wno-strict-prototypes',
Signature · 1 line
2.39.1
Re: [PATCH v3 1/3] common/mlx5: get Windows dependency from standard variables
Quoted 3 lines · Thomas Monjalon
The DevX library path had to be provided through the variables
DEVX_INC_PATHandDEVX_LIB_PATH.
It was non-standard and triggers some issues with recent Meson.
is it possible for meson to search the default install location that the devx sdk installation is normally located on windows? then only if you installed it to some silly non-default location you have to provide CFLAGS/LDFLAGS?
Quoted 9 lines
Using CFLAGS/LDFLAGS is standard and simpler.
It is also possible to use the Meson options -Dc_args and -Dc_link_args. There are 2 options to provide:
-I<include_directory>
-L<library_directory>Signed-off-by Thomas Monjalon <[email protected]>---
Re: [PATCH v3 1/3] common/mlx5: get Windows dependency from standard variables
02/03/2023 18:17, Tyler Retzlaff:
Quoted 9 lines · Thomas Monjalon
Quoted 3 lines
The DevX library path had to be provided through the variables
DEVX_INC_PATHandDEVX_LIB_PATH.
It was non-standard and triggers some issues with recent Meson.is it possible for meson to search the default install location that the devx sdk installation is normally located on windows? then only if you installed it to some silly non-default location you have to provide CFLAGS/LDFLAGS?
Meson will look into standard system directories I guess, but DevX is never installed in a system directory. Which path do you have in mind?
Re: [PATCH v3 1/3] common/mlx5: get Windows dependency from standard variables
Quoted 6 lines · Thomas Monjalon
02/03/2023 18:17, Tyler Retzlaff:
Quoted 5 lines · Thomas Monjalon
Quoted 3 lines
The DevX library path had to be provided through the variables
DEVX_INC_PATHandDEVX_LIB_PATH.
It was non-standard and triggers some issues with recent Meson.
Quoted 8 lines
Quoted 4 lines
is it possible for meson to search the default install location that the devx sdk installation is normally located on windows? then only if you installed it to some silly non-default location you have to provide CFLAGS/LDFLAGS?
Meson will look into standard system directories I guess, but DevX is never installed in a system directory. Which path do you have in mind?
i think when i install the sdk it goes here by default if i just mash the next button. is it wrong to take a look at this path by default?
C:\Program Files\Mellanox\MLNX_WinOF2_DevX_SDK\{inc,lib}
Quoted 2 lines
Re: [PATCH v3 1/3] common/mlx5: get Windows dependency from standard variables
03/03/2023 22:09, Tyler Retzlaff:
Quoted 12 lines · Thomas Monjalon
Quoted 11 lines
02/03/2023 18:17, Tyler Retzlaff:
Quoted 9 lines · Thomas Monjalon
Quoted 3 lines
The DevX library path had to be provided through the variables
DEVX_INC_PATHandDEVX_LIB_PATH.
It was non-standard and triggers some issues with recent Meson.is it possible for meson to search the default install location that the devx sdk installation is normally located on windows? then only if you installed it to some silly non-default location you have to provide CFLAGS/LDFLAGS?
Quoted 8 lines
Quoted 3 lines
Meson will look into standard system directories I guess, but DevX is never installed in a system directory. Which path do you have in mind?
i think when i install the sdk it goes here by default if i just mash the next button. is it wrong to take a look at this path by default?
C:\Program Files\Mellanox\MLNX_WinOF2_DevX_SDK\{inc,lib}
If we have 2 versions in 2 directories,
and we look at the default location, then we can miss the right one. I'm afraid such facility induce more complications at the end.
Re: [PATCH v3 1/3] common/mlx5: get Windows dependency from standard variables
Quoted 17 lines · Thomas Monjalon
03/03/2023 22:09, Tyler Retzlaff:
Quoted 16 lines · Thomas Monjalon
Quoted 14 lines
02/03/2023 18:17, Tyler Retzlaff:
Quoted 9 lines · Thomas Monjalon
Quoted 3 lines
The DevX library path had to be provided through the variables
DEVX_INC_PATHandDEVX_LIB_PATH.
It was non-standard and triggers some issues with recent Meson.is it possible for meson to search the default install location that the devx sdk installation is normally located on windows? then only if you installed it to some silly non-default location you have to provide CFLAGS/LDFLAGS?
Meson will look into standard system directories I guess, but DevX is never installed in a system directory. Which path do you have in mind?
Quoted 8 lines
Quoted 4 lines
i think when i install the sdk it goes here by default if i just mash the next button. is it wrong to take a look at this path by default?
C:\Program Files\Mellanox\MLNX_WinOF2_DevX_SDK\{inc,lib}
If we have 2 versions in 2 directories,
and we look at the default location, then we can miss the right one. I'm afraid such facility induce more complications at the end.
oh, didn't realize you can have multiple installations. suppose you could "pick the newest" but maybe that's not terribly sensible.
RE: [PATCH v3 1/3] common/mlx5: get Windows dependency from standard variables
In reply to Thomas MonjalonQuoted 96 lines
Subject: [PATCH v3 1/3] common/mlx5: get Windows dependency from standard variables
External email: Use caution opening links or attachments
The DevX library path had to be provided through the variables
DEVX_INC_PATHandDEVX_LIB_PATH.
It was non-standard and triggers some issues with recent Meson.Using CFLAGS/LDFLAGS is standard and simpler.
It is also possible to use the Meson options -Dc_args and -Dc_link_args. There are 2 options to provide:
-I<include_directory>
-L<library_directory>Signed-off-by Thomas Monjalon <[email protected]>--- doc/guides/platform/mlx5.rst | 11 +++++----- drivers/common/mlx5/windows/meson.build | 28 ++++++++++++------------(quoted diff) +0
-1- 2 files changed, 20 insertions(+), 19 deletions(-)doc/guides/platform/mlx5.rst +3
-3@@ -259,13 +259,14 @@ configured by the ``ibverbs_link`` build option: Compilation on Windows ~~~~~~~~~~~~~~~~~~~~~~ -The DevX SDK location must be set through two environment variables: +The DevX SDK location must be set through CFLAGS/LDFLAGS, +either:: -``DEVX_LIB_PATH`` - path to the DevX lib file. + meson.exe setup "-Dc_args=-I\"%DEVX_INC_PATH%\"" "-Dc_link_args=-L\"%DEVX_LIB_PATH%\"" ...
-``DEVX_INC_PATH``
doc/guides/platform/mlx5.rst +3
-1- path to the DevX header files. +or:: + + set CFLAGS=-I"%DEVX_INC_PATH%" && set LDFLAGS=-L"%DEVX_LIB_PATH%" && meson.exe setup ...
..
_mlx5_common_env:drivers/common/mlx5/windows/meson.build +0
-0@@ -1,6 +1,20 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright 2019 MellanoxTechnologies, Ltd
drivers/common/mlx5/windows/meson.build +14
-1+if not cc.has_header('mlx5devx.h') + build = false + reason = 'missing dependency, "mlx5devx.h"' + subdir_done() +endif + +devxlib = cc.find_library('mlx5devx', required: true) if not +devxlib.found() + build = false + reason = 'missing dependency, "mlx5devx"' + subdir_done() +endif +ext_deps += devxlib + includes += include_directories('.') sources += files(@@ -8,20 +22,6 @@ sources += files( 'mlx5_common_os.c', ) -res_lib = run_command(python3, '-c', 'import os;
print(os.environ["DEVX_LIB_PATH"])', check: false) -res_inc =run_command(python3, '-c', 'import os; print(os.environ["DEVX_INC_PATH"])', check: false)drivers/common/mlx5/windows/meson.build +0
-4- -if (res_lib.returncode() != 0 or res_inc.returncode() != 0) - build = false - reason = 'DevX environment variables are not set, DEVX_LIB_PATH and
DEVX_INC_PATHvars must be exported'drivers/common/mlx5/windows/meson.build +0
-4- subdir_done() -endif - -devx_lib_dir = res_lib.stdout().strip() -devx_inc_dir =res_inc.stdout().strip()
drivers/common/mlx5/windows/meson.build +0
-2- -ext_deps += cc.find_library('mlx5devx', dirs: devx_lib_dir, required: true) -includes +=
include_directories(devx_inc_dir)cflags_options= [
Quoted 4 lines
'-std=c11', '-Wno-strict-prototypes',--
2.39.1
PATCH v3 2/3 net/mlx5: remove weak stub functions
In reply to Thomas MonjalonThe vector Rx functions are conditionally compiled. Some stub functions were also always compiled with weak attribute. If there is no vector support, the weak functions were linked.
These weak functions are moved in a specific file which is compiled only if there is no vector support. This way it is simpler to understand,
and the weak attributes can be removed.
This change helps to compile with MinGW GCC
which has no support for weak functions.
--- drivers/net/mlx5/meson.build | 13 +++++---- drivers/net/mlx5/mlx5_rx.c | 35 ------------------------ drivers/net/mlx5/mlx5_rxtx_vec_null.c | 38 +++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 40 deletions(-) create mode 100644 drivers/net/mlx5/mlx5_rxtx_vec_null.c
drivers/net/mlx5/meson.build +8 -5
@@ -49,11 +49,14 @@ if is_linux 'mlx5_hws_cnt.c', 'mlx5_flow_verbs.c', ) - if (dpdk_conf.has('RTE_ARCH_X86_64') - or dpdk_conf.has('RTE_ARCH_ARM64') - or dpdk_conf.has('RTE_ARCH_PPC_64')) - sources += files('mlx5_rxtx_vec.c') - endif +endif + +if is_linux and (dpdk_conf.has('RTE_ARCH_X86_64') + or dpdk_conf.has('RTE_ARCH_ARM64') + or dpdk_conf.has('RTE_ARCH_PPC_64')) + sources += files('mlx5_rxtx_vec.c') +else + sources += files('mlx5_rxtx_vec_null.c') endif cflags_options = [
drivers/net/mlx5/mlx5_rx.c +0 -35
@@ -1262,41 +1262,6 @@ mlx5_rx_burst_mprq(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)return i; } -/* -* Vectorized Rx routines are not compiled in when required vector instructions -* are not supported on a target architecture. -* The following null stubs are needed for linkage when those are not included -* outside of this file (e.g. mlx5_rxtx_vec_sse.c for x86). -*/ - -__rte_weak uint16_t -mlx5_rx_burst_vec(void *dpdk_rxq __rte_unused, - struct rte_mbuf **pkts __rte_unused, - uint16_t pkts_n __rte_unused) -{ -return 0 ; -} - -__rte_weak uint16_t -mlx5_rx_burst_mprq_vec(void *dpdk_rxq __rte_unused, - struct rte_mbuf **pkts __rte_unused, - uint16_t pkts_n __rte_unused) -{ -return 0 ; -} - -__rte_weak int -mlx5_rxq_check_vec_support(struct mlx5_rxq_data *rxq __rte_unused) -{ -return -ENOTSUP ; -} - -__rte_weak int -mlx5_check_vec_rx_support(struct rte_eth_dev *dev __rte_unused) -{ -return -ENOTSUP ; -} -int mlx5_rx_queue_lwm_query (struct rte_eth_dev *dev,uint16_t *queue_id,uint8_t *lwm)
drivers/net/mlx5/mlx5_rxtx_vec_null.c new file +38 -0
@@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (c) 2023 NVIDIA Corporation & Affiliates +*/ + +#include <rte_common.h> + +#include "mlx5_rx.h" + +struct rte_mbuf ; +struct rte_eth_dev ; + +uint16_t +mlx5_rx_burst_vec(void *dpdk_rxq __rte_unused, + struct rte_mbuf **pkts __rte_unused, + uint16_t pkts_n __rte_unused) +{ +return 0 ; +} + +uint16_t +mlx5_rx_burst_mprq_vec(void *dpdk_rxq __rte_unused, + struct rte_mbuf **pkts __rte_unused, + uint16_t pkts_n __rte_unused) +{ +return 0 ; +} + +int +mlx5_rxq_check_vec_support(struct mlx5_rxq_data *rxq __rte_unused) +{ +return -ENOTSUP ; +} + +int +mlx5_check_vec_rx_support(struct rte_eth_dev *dev __rte_unused) +{ +return -ENOTSUP ; +}
Signature · 1 line
2.39.1
Re: [PATCH v3 2/3] net/mlx5: remove weak stub functions
Quoted 9 lines · Thomas Monjalon
The vector Rx functions are conditionally compiled. Some stub functions were also always compiled with weak attribute. If there is no vector support, the weak functions were linked.
These weak functions are moved in a specific file which is compiled only if there is no vector support. This way it is simpler to understand,
and the weak attributes can be removed.
Quoted 5 lines
This change helps to compile with MinGW GCC
which has no support for weak functions.Signed-off-by Thomas Monjalon <[email protected]>---
Tal Shnaiderman
Acked-byRE: [PATCH v3 2/3] net/mlx5: remove weak stub functions
Quoted 15 lines
Subject: Re: [PATCH v3 2/3] net/mlx5: remove weak stub functions
External email: Use caution opening links or attachments
Quoted 9 lines · Thomas Monjalon
The vector Rx functions are conditionally compiled. Some stub functions were also always compiled with weak attribute. If there is no vector support, the weak functions were linked.
These weak functions are moved in a specific file which is compiled only if there is no vector support.
This way it is simpler to understand,
and the weak attributes can be removed.
Quoted 7 lines
Quoted 5 lines
This change helps to compile with MinGW GCC which has no support for weak functions.
Signed-off-by Thomas Monjalon <[email protected]>---
Acked-by Tyler Retzlaff <[email protected]>
PATCH v3 3/3 net/mlx5: fix Windows build with MinGW GCC 12
In reply to Thomas MonjalonWith recent changes in Meson and MinGW toolchain, the driver mlx5 was not able to compile on Linux for Windows.
There were errors due to system detection, non-typed constants, constant going over int range forbidden in pedantic mode, and minimum-comparison of different types.
--- drivers/common/mlx5/meson.build | 9 +- drivers/common/mlx5/windows/mlx5_win_defs.h | 100 +++++++++++--------- drivers/net/mlx5/windows/mlx5_os.c | 4 +- 3 files changed, 65 insertions(+), 48 deletions(-)
drivers/common/mlx5/meson.build +7 -2
@@ -1,9 +1,14 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright 2019 Mellanox Technologies, Ltd -if not (is_linux or (is_windows and is_ms_linker)) +if not (is_linux or is_windows) build = false - reason = 'only supported on Linux and Windows build with clang' + reason = 'only supported on Linux and Windows' + subdir_done() +endif +if is_windows and not is_ms_linker and not meson.is_cross_build() + build = false + reason = 'MinGW is supported only for cross-compilation test' subdir_done() endif
drivers/common/mlx5/windows/mlx5_win_defs.h +56 -44
160 lines not on this page · raw message
drivers/net/mlx5/windows/mlx5_os.c +2 -2
@@ -193,8 +193,8 @@ mlx5_os_capabilities_prepare(struct mlx5_dev_ctx_shared *sh)* Once DPDK supports it, take max size from device attr. */ sh->dev_cap.ind_table_max_size = -RTE_MIN (1 << hca_attr->rss_ind_tbl_cap, - (unsigned int )RTE_ETH_RSS_RETA_SIZE_512 ); +RTE_MIN ((uint32_t )1 << hca_attr->rss_ind_tbl_cap, + (uint32_t )RTE_ETH_RSS_RETA_SIZE_512 );DRV_LOG (DEBUG ,"Maximum Rx indirection table size is %u" , sh->dev_cap.ind_table_max_size); }
Signature · 1 line
2.39.1
Re: [PATCH v3 3/3] net/mlx5: fix Windows build with MinGW GCC 12
Quoted 11 lines · Thomas Monjalon
With recent changes in Meson and MinGW toolchain, the driver mlx5 was not able to compile on Linux for Windows.
There were errors due to system detection, non-typed constants, constant going over int range forbidden in pedantic mode, and minimum-comparison of different types.
Signed-off-by Thomas Monjalon <[email protected]>---
lgtm
Tal Shnaiderman
Acked-byRE: [PATCH v3 3/3] net/mlx5: fix Windows build with MinGW GCC 12
Quoted 13 lines
Subject: Re: [PATCH v3 3/3] net/mlx5: fix Windows build with MinGW GCC 12
External email: Use caution opening links or attachments
Quoted 7 lines · Thomas Monjalon
With recent changes in Meson and MinGW toolchain, the driver mlx5 was not able to compile on Linux for Windows.
There were errors due to system detection, non-typed constants, constant going over int range forbidden in pedantic mode, and minimum-comparison of different types.
Quoted 8 lines
Quoted 4 lines
Signed-off-by Thomas Monjalon <[email protected]>---
lgtm
Acked-by Tyler Retzlaff <[email protected]>
RE: [PATCH v3 0/3] mlx5: fix Windows build with Linux MinGW
In reply to Thomas MonjalonHi,
Quoted 28 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Thursday, March 2, 2023 3:22 PM
To: [email protected]
Cc: Tal Shnaiderman <[email protected]>
Subject: [PATCH v3 0/3] mlx5: fix Windows build with Linux MinGWThe result is to make possible to compile mlx5 on Linux for Windows.
v2: improve mlx5 doc and remove weak attribute from mlx5
v3: avoid MinGW on Windows - EAL patch already appliedThomas Monjalon (3):
common/mlx5: get Windows dependency from standard variables net/mlx5: remove weak stub functions
net/mlx5: fix Windows build with MinGW GCC 12doc/guides/platform/mlx5.rst | 11 ++- drivers/common/mlx5/meson.build | 9 +- drivers/common/mlx5/windows/meson.build | 28 +++--- drivers/common/mlx5/windows/mlx5_win_defs.h | 100 +++++++++++------ --- drivers/net/mlx5/meson.build | 13 ++- drivers/net/mlx5/mlx5_rx.c | 35 ------- drivers/net/mlx5/mlx5_rxtx_vec_null.c | 38 ++++++++ drivers/net/mlx5/windows/mlx5_os.c | 4 +- 8 files changed, 131 insertions(+), 107 deletions(-) create mode 100644
Quoted 4 lines
drivers/net/mlx5/mlx5_rxtx_vec_null.c--
2.39.1
Series applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh