summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorMiaomiao Liu <miaomiao.liu@intel.com>2022-01-14 06:40:11 +0100
committerMiaomiao Liu <miaomiao.liu@intel.com>2022-02-08 07:06:07 +0100
commit082dcf0a58b47946cc1375a7e8336b261d499f64 (patch)
tree100e136ddff4f629465bc2bf4c978482ef46dcdb /cmake
parentMerge pull request #44921 from cyx1231st/wip-seastore-cleanup-lba (diff)
downloadceph-082dcf0a58b47946cc1375a7e8336b261d499f64.tar.xz
ceph-082dcf0a58b47946cc1375a7e8336b261d499f64.zip
cmake: replace BuildQatDrv.cmake with FindQatDrv.cmake
because QAT driver with version v1.7.l.4.14.0 or higher cannot be dowmloaded directly by URL, FindQatDrv.cmake can find the locally installed QAT package and libraries Signed-off-by: Miaomiao Liu <miaomiao.liu@intel.com> Signed-off-by: Hualong Feng <hualong.feng@intel.com>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/BuildQatDrv.cmake33
-rw-r--r--cmake/modules/FindQatDrv.cmake80
2 files changed, 80 insertions, 33 deletions
diff --git a/cmake/modules/BuildQatDrv.cmake b/cmake/modules/BuildQatDrv.cmake
deleted file mode 100644
index ebf33d6464c..00000000000
--- a/cmake/modules/BuildQatDrv.cmake
+++ /dev/null
@@ -1,33 +0,0 @@
-##
-# Make file for QAT linux driver project
-##
-
-set(qatdrv_root_dir "${CMAKE_BINARY_DIR}/qatdrv")
-set(qatdrv_url "https://01.org/sites/default/files/downloads/intelr-quickassist-technology/qat1.7.l.4.2.0-00012.tar.gz")
-set(qatdrv_url_hash "SHA256=47990b3283ded748799dba42d4b0e1bdc0be3cf3978bd587533cd12788b03856")
-set(qatdrv_config_args "--enable-qat-uio")
-
-include(ExternalProject)
-ExternalProject_Add(QatDrv
- URL ${qatdrv_url}
- URL_HASH ${qatdrv_url_hash}
- CONFIGURE_COMMAND ${qatdrv_env} ./configure ${qatdrv_config_args}
-
-# Temporarily forcing single thread as multi-threaded make is causing build
-# failues.
- BUILD_COMMAND make -j1 quickassist-all
- BUILD_IN_SOURCE 1
- INSTALL_COMMAND ""
- TEST_COMMAND ""
- PREFIX ${qatdrv_root_dir})
-
-set(QatDrv_INCLUDE_DIRS
- ${qatdrv_root_dir}/src/QatDrv/quickassist/include
- ${qatdrv_root_dir}/src/QatDrv/quickassist/lookaside/access_layer/include
- ${qatdrv_root_dir}/src/QatDrv/quickassist/include/lac
- ${qatdrv_root_dir}/src/QatDrv/quickassist/utilities/libusdm_drv
- ${qatdrv_root_dir}/src/QatDrv/quickassist/utilities/libusdm_drv/linux/include)
-
-set(QatDrv_LIBRARIES
- ${qatdrv_root_dir}/src/QatDrv/build/libqat_s.so
- ${qatdrv_root_dir}/src/QatDrv/build/libusdm_drv_s.so)
diff --git a/cmake/modules/FindQatDrv.cmake b/cmake/modules/FindQatDrv.cmake
new file mode 100644
index 00000000000..3305a38c06c
--- /dev/null
+++ b/cmake/modules/FindQatDrv.cmake
@@ -0,0 +1,80 @@
+# - Find_QatDrv
+# Find the qat driver library and includes
+#
+# QatDrv_INCLUDE_DIRS = where to find cap.h, qae_mem.h, etc
+# QatDrv_LIBRARIES - List of libraries when using qat driver
+# QatDrv_FOUND - True if qat driver found
+
+set(expected_version "v1.7.L.4.14.0-00031")
+set(expected_version_url "https://www.intel.com/content/www/us/en/download/19081/intel-quickassist-technology-intel-qat-driver-for-linux-for-intel-server-boards-and-systems-based-on-intel-62x-chipset.html")
+
+function(get_qatdrv_version versionfile)
+ file(STRINGS "${versionfile}" QAT_VERSION_LINE
+ REGEX "^PACKAGE_VERSION_MAJOR_NUMBER=[0-9]+$")
+ string(REGEX REPLACE "^PACKAGE_VERSION_MAJOR_NUMBER=([0-9]+)$"
+ "\\1" QAT_VERSION1 "${QAT_VERSION_LINE}")
+ unset(QAT_VERSION_LINE)
+ file(STRINGS "${versionfile}" QAT_VERSION_LINE
+ REGEX "^PACKAGE_VERSION_MINOR_NUMBER=[0-9]+$")
+ string(REGEX REPLACE "^PACKAGE_VERSION_MINOR_NUMBER=([0-9]+)$"
+ "\\1" QAT_VERSION2 "${QAT_VERSION_LINE}")
+ unset(QAT_VERSION_LINE)
+ file(STRINGS "${versionfile}" QAT_VERSION_LINE
+ REGEX "^PACKAGE_VERSION_PATCH_NUMBER=[0-9]+$")
+ string(REGEX REPLACE "^PACKAGE_VERSION_PATCH_NUMBER=([0-9]+)$"
+ "\\1" QAT_VERSION3 "${QAT_VERSION_LINE}")
+ unset(QAT_VERSION_LINE)
+ file(STRINGS "${versionfile}" QAT_VERSION_LINE
+ REGEX "^PACKAGE_VERSION_BUILD_NUMBER=[0-9]+$")
+ string(REGEX REPLACE "^PACKAGE_VERSION_BUILD_NUMBER=([0-9]+)$"
+ "\\1" QAT_VERSION4 "${QAT_VERSION_LINE}")
+
+ set(QatDrv_VERSION_MAJOR ${QAT_VERSION1} PARENT_SCOPE)
+ set(QatDrv_VERSION_MINOR ${QAT_VERSION2} PARENT_SCOPE)
+ set(QatDrv_VERSION_PATCH ${QAT_VERSION3} PARENT_SCOPE)
+ set(QatDrv_VERSION_TWEAK ${QAT_VERSION4} PARENT_SCOPE)
+ set(QatDrv_VERSION_COUNT 4 PARENT_SCOPE)
+ set(QatDrv_VERSION ${QAT_VERSION1}.${QAT_VERSION2}.${QAT_VERSION3}.${QAT_VERSION4}
+ PARENT_SCOPE)
+endfunction()
+
+find_path(QATDRV_INCLUDE_DIR
+ name quickassist/include/cpa.h
+ HINTS $ENV{ICP_ROOT} /opt/APP/driver/QAT
+ NO_DEFAULT_PATH)
+if(QATDRV_INCLUDE_DIR)
+ get_qatdrv_version(${QATDRV_INCLUDE_DIR}/versionfile)
+ set(QatDrv_INCLUDE_DIRS
+ ${QATDRV_INCLUDE_DIR}/quickassist/include
+ ${QATDRV_INCLUDE_DIR}/quickassist/include/dc
+ ${QATDRV_INCLUDE_DIR}/quickassist/lookaside/access_layer/include
+ ${QATDRV_INCLUDE_DIR}/quickassist/include/lac
+ ${QATDRV_INCLUDE_DIR}/quickassist/utilities/libusdm_drv
+ ${QATDRV_INCLUDE_DIR}/quickassist/utilities/libusdm_drv/include)
+endif()
+foreach(component ${QatDrv_FIND_COMPONENTS})
+ find_library(QatDrv_${component}_LIBRARIES
+ NAMES ${component}
+ HINTS ${QATDRV_INCLUDE_DIR}/build/)
+ mark_as_advanced(QatDrv_INCLUDE_DIRS
+ QatDrv_${component}_LIBRARIES)
+ list(APPEND QatDrv_LIBRARIES "${QatDrv_${component}_LIBRARIES}")
+endforeach()
+
+set(failure_message "Please ensure QAT driver has been installed with version no less than ${expected_version}. And set the environment variable \"ICP_ROOT\" for the QAT driver package root directory, i.e. \"export ICP_ROOT=/the/directory/of/QAT\". Or download and install QAT driver ${expected_version} manually at the link ${expected_version_url}. Remember to set the environment variable \"ICP_ROOT\" for the package root directory.")
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(QatDrv
+ REQUIRED_VARS QatDrv_LIBRARIES QatDrv_INCLUDE_DIRS
+ VERSION_VAR QatDrv_VERSION
+ FAIL_MESSAGE ${failure_message})
+
+foreach(component ${QatDrv_FIND_COMPONENTS})
+ if(NOT TARGET QatDrv::${component})
+ add_library(QatDrv::${component} STATIC IMPORTED GLOBAL)
+ set_target_properties(QatDrv::${component} PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${QatDrv_INCLUDE_DIRS}"
+ IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+ IMPORTED_LOCATION "${QatDrv_${component}_LIBRARIES}")
+ endif()
+endforeach()