diff --git a/CMakeLists.txt b/CMakeLists.txt index 3269a85f0..98985e7ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -214,19 +214,27 @@ if (NOT HAVE_WORKING_WERROR) message(FATAL_ERROR "-Werror doesn't work (compiler always creates warnings?). Werror is required for CMake.") endif() -# Look for Python. We prefer some variant of python 3 if the system has it. -FIND_PACKAGE(PythonInterp 3 QUIET) -if (PythonInterp_FOUND) - # pyverbs can only use python3: - if (NO_PYVERBS) - set(CYTHON_EXECUTABLE "") +# Use Python modules based on CMake version for backward compatibility +set(CYTHON_EXECUTABLE "") +if (${CMAKE_VERSION} VERSION_LESS "3.12") + # Look for Python. We prefer some variant of python 3 if the system has it + FIND_PACKAGE(PythonInterp 3 QUIET) + if (PythonInterp_FOUND) + # pyverbs can only use python3: + if (NOT NO_PYVERBS) + FIND_PACKAGE(cython) + endif() else() - FIND_PACKAGE(cython) + # But we still must have python (be it 2) for the build process + FIND_PACKAGE(PythonInterp REQUIRED) endif() else() - # But we still must have python (be it 2) for the build process: - FIND_PACKAGE(PythonInterp REQUIRED) - set(CYTHON_EXECUTABLE "") + # FindPython looks preferably for Python3. If not found, version 2 is searched + FIND_PACKAGE(Python COMPONENTS Interpreter REQUIRED) + set(PYTHON_EXECUTABLE ${Python_EXECUTABLE}) + if (NOT NO_PYVERBS AND Python_VERSION_MAJOR EQUAL 3) + FIND_PACKAGE(cython) + endif() endif() find_program(SYSTEMCTL_BIN systemctl HINTS "/usr/bin" "/bin") @@ -450,8 +458,15 @@ if (CYTHON_EXECUTABLE) # find a matching -devel installation but will happily return a non-matching # one too. We need them both to match exactly to guarantee cython does the # right thing. - FIND_PACKAGE(PythonLibs ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} - EXACT REQUIRED) + if (${CMAKE_VERSION} VERSION_LESS "3.12") + FIND_PACKAGE(PythonLibs ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} + EXACT REQUIRED) + else() + FIND_PACKAGE(Python ${Python_VERSION_MAJOR}.${Python_VERSION_MINOR} + EXACT COMPONENTS Development REQUIRED) + set(PYTHON_LIBRARIES ${Python_LIBRARIES}) + set(PYTHON_INCLUDE_DIRS ${Python_INCLUDE_DIRS}) + endif() # Get a default installation path execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c diff --git a/buildlib/azure-pipelines.yml b/buildlib/azure-pipelines.yml index 91b9135a5..ca0bb5ecd 100644 --- a/buildlib/azure-pipelines.yml +++ b/buildlib/azure-pipelines.yml @@ -34,7 +34,7 @@ resources: image: ucfconsort.azurecr.io/rdma-core/centos9:44.0 endpoint: ucfconsort_registry - container: fedora - image: ucfconsort.azurecr.io/rdma-core/fc38:46.0 + image: ucfconsort.azurecr.io/rdma-core/fc39:49.0 endpoint: ucfconsort_registry - container: xenial image: ucfconsort.azurecr.io/rdma-core/ubuntu-16.04:28.0 @@ -195,7 +195,7 @@ stages: CONTAINER: centos9 SPEC: redhat/rdma-core.spec RPMBUILD_OPTS: --define 'EXTRA_CMAKE_FLAGS -DCMAKE_BUILD_TYPE=Debug -DENABLE_WERROR=1' - fedora38: + fedora39: CONTAINER: fedora SPEC: redhat/rdma-core.spec RPMBUILD_OPTS: --define 'EXTRA_CMAKE_FLAGS -DCMAKE_BUILD_TYPE=Debug -DENABLE_WERROR=1' diff --git a/buildlib/cbuild b/buildlib/cbuild index 691feca7a..3e8714bd7 100755 --- a/buildlib/cbuild +++ b/buildlib/cbuild @@ -220,10 +220,10 @@ class centos9(Environment): (" ".join(sorted(self.pkgs)))) return res -class fc38(Environment): - docker_parent = "fedora:38"; +class fc39(Environment): + docker_parent = "fedora:39"; pkgs = centos8.pkgs | {"util-linux"} - name = "fc38"; + name = "fc39"; specfile = "redhat/rdma-core.spec"; ninja_cmd = "ninja-build"; is_rpm = True; @@ -626,7 +626,7 @@ environments = [centos7(), jammy(), jessie(), stretch(), - fc38(), + fc39(), leap(), tumbleweed(), debian_experimental(), diff --git a/pyverbs/CMakeLists.txt b/pyverbs/CMakeLists.txt index a83db3a67..4ce7ee9c4 100644 --- a/pyverbs/CMakeLists.txt +++ b/pyverbs/CMakeLists.txt @@ -31,6 +31,10 @@ rdma_cython_module(pyverbs "" enums.pyx flow.pyx fork.pyx + libibverbs.pyx + libibverbs_enums.pyx + librdmacm.pyx + librdmacm_enums.pyx mem_alloc.pyx mr.pyx pd.pyx diff --git a/pyverbs/libibverbs.pxd b/pyverbs/libibverbs.pxd index 3f75a011f..fe7912608 100644 --- a/pyverbs/libibverbs.pxd +++ b/pyverbs/libibverbs.pxd @@ -1,9 +1,12 @@ # SPDX-License-Identifier: (GPL-2.0 OR Linux-OpenIB) # Copyright (c) 2018, Mellanox Technologies. All rights reserved. See COPYING file -include 'libibverbs_enums.pxd' +#cython: language_level=3 + from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t from posix.time cimport timespec +from pyverbs.libibverbs_enums cimport * + cdef extern from 'infiniband/verbs.h': diff --git a/pyverbs/libibverbs.pyx b/pyverbs/libibverbs.pyx new file mode 100644 index 000000000..e69de29bb diff --git a/pyverbs/libibverbs_enums.pyx b/pyverbs/libibverbs_enums.pyx new file mode 100644 index 000000000..e69de29bb diff --git a/pyverbs/librdmacm.pxd b/pyverbs/librdmacm.pxd index 0dc966a3a..0d6fa912f 100644 --- a/pyverbs/librdmacm.pxd +++ b/pyverbs/librdmacm.pxd @@ -1,9 +1,12 @@ # SPDX-License-Identifier: (GPL-2.0 OR Linux-OpenIB) # Copyright (c) 2019, Mellanox Technologies. All rights reserved. See COPYING file -include 'libibverbs.pxd' -include 'librdmacm_enums.pxd' +#cython: language_level=3 + from libc.stdint cimport uint8_t, uint32_t +from pyverbs.librdmacm_enums cimport * +from pyverbs.libibverbs cimport * + cdef extern from '': diff --git a/pyverbs/librdmacm.pyx b/pyverbs/librdmacm.pyx new file mode 100644 index 000000000..e69de29bb diff --git a/pyverbs/librdmacm_enums.pyx b/pyverbs/librdmacm_enums.pyx new file mode 100644 index 000000000..e69de29bb diff --git a/pyverbs/pd.pyx b/pyverbs/pd.pyx index e12af1977..2d84e0b68 100644 --- a/pyverbs/pd.pyx +++ b/pyverbs/pd.pyx @@ -1,5 +1,8 @@ # SPDX-License-Identifier: (GPL-2.0 OR Linux-OpenIB) # Copyright (c) 2019, Mellanox Technologies. All rights reserved. + +#cython: legacy_implicit_noexcept=True + from libc.stdint cimport uintptr_t, uint32_t from libc.stdlib cimport malloc import weakref diff --git a/pyverbs/providers/efa/CMakeLists.txt b/pyverbs/providers/efa/CMakeLists.txt index aa9733008..1852dcebd 100644 --- a/pyverbs/providers/efa/CMakeLists.txt +++ b/pyverbs/providers/efa/CMakeLists.txt @@ -4,4 +4,5 @@ rdma_cython_module(pyverbs/providers/efa efa efa_enums.pyx efadv.pyx + libefa.pyx ) diff --git a/pyverbs/providers/efa/efadv_enums.pxd b/pyverbs/providers/efa/efa_enums.pxd similarity index 100% rename from pyverbs/providers/efa/efadv_enums.pxd rename to pyverbs/providers/efa/efa_enums.pxd diff --git a/pyverbs/providers/efa/efa_enums.pyx b/pyverbs/providers/efa/efa_enums.pyx index b3432f146..e69de29bb 100644 --- a/pyverbs/providers/efa/efa_enums.pyx +++ b/pyverbs/providers/efa/efa_enums.pyx @@ -1,22 +0,0 @@ -# SPDX-License-Identifier: (GPL-2.0 OR Linux-OpenIB) -# Copyright 2020-2024 Amazon.com, Inc. or its affiliates. All rights reserved. - -#cython: language_level=3 - -cdef extern from 'infiniband/efadv.h': - - cpdef enum: - EFADV_DEVICE_ATTR_CAPS_RDMA_READ - EFADV_DEVICE_ATTR_CAPS_CQ_WITH_SGID - EFADV_DEVICE_ATTR_CAPS_RDMA_WRITE - - cpdef enum: - EFADV_QP_DRIVER_TYPE_SRD - - cpdef enum: - EFADV_WC_EX_WITH_SGID - - cpdef enum: - EFADV_MR_ATTR_VALIDITY_RECV_IC_ID - EFADV_MR_ATTR_VALIDITY_RDMA_READ_IC_ID - EFADV_MR_ATTR_VALIDITY_RDMA_RECV_IC_ID diff --git a/pyverbs/providers/efa/efadv.pyx b/pyverbs/providers/efa/efadv.pyx index bf8cdba4e..dd8d49380 100644 --- a/pyverbs/providers/efa/efadv.pyx +++ b/pyverbs/providers/efa/efadv.pyx @@ -1,7 +1,7 @@ # SPDX-License-Identifier: (GPL-2.0 OR Linux-OpenIB) # Copyright 2020-2024 Amazon.com, Inc. or its affiliates. All rights reserved. -cimport pyverbs.providers.efa.efadv_enums as dve +cimport pyverbs.providers.efa.efa_enums as dve cimport pyverbs.providers.efa.libefa as dv from pyverbs.addr cimport GID diff --git a/pyverbs/providers/efa/libefa.pxd b/pyverbs/providers/efa/libefa.pxd index ca6471a84..53355e05d 100644 --- a/pyverbs/providers/efa/libefa.pxd +++ b/pyverbs/providers/efa/libefa.pxd @@ -1,6 +1,8 @@ # SPDX-License-Identifier: (GPL-2.0 OR Linux-OpenIB) # Copyright 2020-2024 Amazon.com, Inc. or its affiliates. All rights reserved. +#cython: language_level=3 + from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t cimport pyverbs.libibverbs as v diff --git a/pyverbs/providers/efa/libefa.pyx b/pyverbs/providers/efa/libefa.pyx new file mode 100644 index 000000000..e69de29bb diff --git a/pyverbs/providers/mlx5/CMakeLists.txt b/pyverbs/providers/mlx5/CMakeLists.txt index 5ede08626..17b1eb4f4 100644 --- a/pyverbs/providers/mlx5/CMakeLists.txt +++ b/pyverbs/providers/mlx5/CMakeLists.txt @@ -7,6 +7,7 @@ rdma_cython_module(pyverbs/providers/mlx5 mlx5 dr_matcher.pyx dr_rule.pyx dr_table.pyx + libmlx5.pyx mlx5_enums.pyx mlx5_vfio.pyx mlx5dv.pyx diff --git a/pyverbs/providers/mlx5/libmlx5.pxd b/pyverbs/providers/mlx5/libmlx5.pxd index cc4fdd648..7bcca0ef4 100644 --- a/pyverbs/providers/mlx5/libmlx5.pxd +++ b/pyverbs/providers/mlx5/libmlx5.pxd @@ -1,13 +1,14 @@ # SPDX-License-Identifier: (GPL-2.0 OR Linux-OpenIB) # Copyright (c) 2019 Mellanox Technologies, Inc. All rights reserved. See COPYING file -include 'mlx5dv_enums.pxd' +#cython: language_level=3 from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t from posix.types cimport off_t from libcpp cimport bool cimport libc.stdio as s +from pyverbs.providers.mlx5.mlx5_enums cimport * cimport pyverbs.libibverbs as v diff --git a/pyverbs/providers/mlx5/libmlx5.pyx b/pyverbs/providers/mlx5/libmlx5.pyx new file mode 100644 index 000000000..e69de29bb diff --git a/pyverbs/providers/mlx5/mlx5dv_enums.pxd b/pyverbs/providers/mlx5/mlx5_enums.pxd similarity index 87% rename from pyverbs/providers/mlx5/mlx5dv_enums.pxd rename to pyverbs/providers/mlx5/mlx5_enums.pxd index 34f5617f9..39996cede 100644 --- a/pyverbs/providers/mlx5/mlx5dv_enums.pxd +++ b/pyverbs/providers/mlx5/mlx5_enums.pxd @@ -305,21 +305,6 @@ cdef extern from 'infiniband/mlx5dv.h': cdef unsigned long long MLX5DV_QUERY_PORT_ESW_OWNER_VHCA_ID -_MLX5DV_RES_TYPE_QP = MLX5DV_RES_TYPE_QP -_MLX5DV_RES_TYPE_RWQ = MLX5DV_RES_TYPE_RWQ -_MLX5DV_RES_TYPE_DBR = MLX5DV_RES_TYPE_DBR -_MLX5DV_RES_TYPE_SRQ = MLX5DV_RES_TYPE_SRQ -_MLX5DV_PP_ALLOC_FLAGS_DEDICATED_INDEX = MLX5DV_PP_ALLOC_FLAGS_DEDICATED_INDEX -_MLX5DV_UAR_ALLOC_TYPE_BF = MLX5DV_UAR_ALLOC_TYPE_BF -_MLX5DV_UAR_ALLOC_TYPE_NC = MLX5DV_UAR_ALLOC_TYPE_NC -MLX5DV_QUERY_PORT_VPORT_ = MLX5DV_QUERY_PORT_VPORT -MLX5DV_QUERY_PORT_VPORT_VHCA_ID_ = MLX5DV_QUERY_PORT_VPORT_VHCA_ID -MLX5DV_QUERY_PORT_VPORT_STEERING_ICM_RX_ = MLX5DV_QUERY_PORT_VPORT_STEERING_ICM_RX -MLX5DV_QUERY_PORT_VPORT_STEERING_ICM_TX_ = MLX5DV_QUERY_PORT_VPORT_STEERING_ICM_TX -MLX5DV_QUERY_PORT_VPORT_REG_C0_ = MLX5DV_QUERY_PORT_VPORT_REG_C0 -MLX5DV_QUERY_PORT_ESW_OWNER_VHCA_ID_ = MLX5DV_QUERY_PORT_ESW_OWNER_VHCA_ID - - cdef extern from 'infiniband/mlx5_user_ioctl_verbs.h': cdef enum mlx5_ib_uapi_flow_table_type: pass @@ -335,18 +320,3 @@ cdef extern from 'infiniband/mlx5_api.h': cdef int MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L2_TUNNEL cdef int MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L3_TUNNEL_TO_L2 cdef int MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L3_TUNNEL - -MLX5DV_FLOW_TABLE_TYPE_RDMA_RX_ = MLX5DV_FLOW_TABLE_TYPE_RDMA_RX -MLX5DV_FLOW_TABLE_TYPE_RDMA_TX_ = MLX5DV_FLOW_TABLE_TYPE_RDMA_TX -MLX5DV_FLOW_TABLE_TYPE_NIC_RX_ = MLX5DV_FLOW_TABLE_TYPE_NIC_RX -MLX5DV_FLOW_TABLE_TYPE_NIC_TX_ = MLX5DV_FLOW_TABLE_TYPE_NIC_TX -MLX5DV_FLOW_TABLE_TYPE_FDB_ = MLX5DV_FLOW_TABLE_TYPE_FDB - -MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TUNNEL_TO_L2_ = \ - MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TUNNEL_TO_L2 -MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L2_TUNNEL_ = \ - MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L2_TUNNEL -MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L3_TUNNEL_TO_L2_ = \ - MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L3_TUNNEL_TO_L2 -MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L3_TUNNEL_ = \ - MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L3_TUNNEL diff --git a/pyverbs/providers/mlx5/mlx5_enums.pyx b/pyverbs/providers/mlx5/mlx5_enums.pyx deleted file mode 120000 index ba0e916f9..000000000 --- a/pyverbs/providers/mlx5/mlx5_enums.pyx +++ /dev/null @@ -1 +0,0 @@ -mlx5dv_enums.pxd \ No newline at end of file diff --git a/pyverbs/providers/mlx5/mlx5_enums.pyx b/pyverbs/providers/mlx5/mlx5_enums.pyx new file mode 100644 index 000000000..21fb95b6e --- /dev/null +++ b/pyverbs/providers/mlx5/mlx5_enums.pyx @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: (GPL-2.0 OR Linux-OpenIB) +# Copyright (c) 2024 Nvidia All rights reserved. + +#cython: language_level=3 + +_MLX5DV_RES_TYPE_QP = MLX5DV_RES_TYPE_QP +_MLX5DV_RES_TYPE_RWQ = MLX5DV_RES_TYPE_RWQ +_MLX5DV_RES_TYPE_DBR = MLX5DV_RES_TYPE_DBR +_MLX5DV_RES_TYPE_SRQ = MLX5DV_RES_TYPE_SRQ +_MLX5DV_PP_ALLOC_FLAGS_DEDICATED_INDEX = MLX5DV_PP_ALLOC_FLAGS_DEDICATED_INDEX +_MLX5DV_UAR_ALLOC_TYPE_BF = MLX5DV_UAR_ALLOC_TYPE_BF +_MLX5DV_UAR_ALLOC_TYPE_NC = MLX5DV_UAR_ALLOC_TYPE_NC + +MLX5DV_QUERY_PORT_VPORT_ = MLX5DV_QUERY_PORT_VPORT +MLX5DV_QUERY_PORT_VPORT_VHCA_ID_ = MLX5DV_QUERY_PORT_VPORT_VHCA_ID +MLX5DV_QUERY_PORT_VPORT_STEERING_ICM_RX_ = MLX5DV_QUERY_PORT_VPORT_STEERING_ICM_RX +MLX5DV_QUERY_PORT_VPORT_STEERING_ICM_TX_ = MLX5DV_QUERY_PORT_VPORT_STEERING_ICM_TX +MLX5DV_QUERY_PORT_VPORT_REG_C0_ = MLX5DV_QUERY_PORT_VPORT_REG_C0 +MLX5DV_QUERY_PORT_ESW_OWNER_VHCA_ID_ = MLX5DV_QUERY_PORT_ESW_OWNER_VHCA_ID + +MLX5DV_FLOW_TABLE_TYPE_RDMA_RX_ = MLX5DV_FLOW_TABLE_TYPE_RDMA_RX +MLX5DV_FLOW_TABLE_TYPE_RDMA_TX_ = MLX5DV_FLOW_TABLE_TYPE_RDMA_TX +MLX5DV_FLOW_TABLE_TYPE_NIC_RX_ = MLX5DV_FLOW_TABLE_TYPE_NIC_RX +MLX5DV_FLOW_TABLE_TYPE_NIC_TX_ = MLX5DV_FLOW_TABLE_TYPE_NIC_TX +MLX5DV_FLOW_TABLE_TYPE_FDB_ = MLX5DV_FLOW_TABLE_TYPE_FDB + +MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TUNNEL_TO_L2_ = \ + MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TUNNEL_TO_L2 +MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L2_TUNNEL_ = \ + MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L2_TUNNEL +MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L3_TUNNEL_TO_L2_ = \ + MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L3_TUNNEL_TO_L2 +MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L3_TUNNEL_ = \ + MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L3_TUNNEL diff --git a/pyverbs/providers/mlx5/mlx5dv.pyx b/pyverbs/providers/mlx5/mlx5dv.pyx index deada022b..f553d5e2c 100644 --- a/pyverbs/providers/mlx5/mlx5dv.pyx +++ b/pyverbs/providers/mlx5/mlx5dv.pyx @@ -14,7 +14,7 @@ from pyverbs.providers.mlx5.mlx5dv_crypto cimport Mlx5CryptoLoginAttr, Mlx5Crypt from pyverbs.pyverbs_error import PyverbsUserError, PyverbsRDMAError, PyverbsError from pyverbs.providers.mlx5.dr_action cimport DrActionFlowCounter, DrActionDestTir from pyverbs.providers.mlx5.mlx5dv_sched cimport Mlx5dvSchedLeaf -cimport pyverbs.providers.mlx5.mlx5dv_enums as dve +cimport pyverbs.providers.mlx5.mlx5_enums as dve cimport pyverbs.providers.mlx5.libmlx5 as dv from pyverbs.mem_alloc import posix_memalign from pyverbs.qp cimport QPInitAttrEx, QPEx diff --git a/pyverbs/providers/mlx5/mlx5dv_objects.pyx b/pyverbs/providers/mlx5/mlx5dv_objects.pyx index ec6eeb6d5..e7776205a 100644 --- a/pyverbs/providers/mlx5/mlx5dv_objects.pyx +++ b/pyverbs/providers/mlx5/mlx5dv_objects.pyx @@ -12,7 +12,7 @@ Note: This is not be confused with Mlx5 which holds the ibv__ex that from libc.stdint cimport uintptr_t, uint32_t from pyverbs.pyverbs_error import PyverbsUserError, PyverbsRDMAError -cimport pyverbs.providers.mlx5.mlx5dv_enums as dve +cimport pyverbs.providers.mlx5.mlx5_enums as dve cimport pyverbs.libibverbs as v