summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt7
-rw-r--r--cmake/modules/FindQAT.cmake40
-rw-r--r--cmake/modules/FindQatDrv.cmake8
-rw-r--r--src/compressor/CMakeLists.txt6
-rw-r--r--src/crypto/CMakeLists.txt2
-rw-r--r--src/crypto/qat/CMakeLists.txt4
-rw-r--r--src/crypto/qat/qcccrypto.cc7
-rw-r--r--src/crypto/qat/qcccrypto.h10
8 files changed, 76 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 50c8905ca0a..213c6b69473 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -307,10 +307,15 @@ endif()
option(WITH_BLUEFS "libbluefs library" OFF)
+option(WITH_QATLIB "Enable QAT with qatlib" OFF)
option(WITH_QATDRV "Enable QAT with out-of-tree driver" OFF)
+
if(WITH_QATDRV)
find_package(QatDrv REQUIRED COMPONENTS qat_s usdm_drv_s)
- set(HAVE_QATDRV TRUE)
+ set(HAVE_QAT TRUE)
+elseif(WITH_QATLIB)
+ find_package(QAT REQUIRED)
+ set(HAVE_QAT TRUE)
endif()
option(WITH_QATZIP "Enable QATZIP" OFF)
diff --git a/cmake/modules/FindQAT.cmake b/cmake/modules/FindQAT.cmake
new file mode 100644
index 00000000000..9044e549392
--- /dev/null
+++ b/cmake/modules/FindQAT.cmake
@@ -0,0 +1,40 @@
+find_package(PkgConfig)
+pkg_search_module(PC_QAT libqat qatlib QUIET)
+
+find_path(QAT_INCLUDE_DIR
+ NAMES qat/cpa.h
+ HINTS ${PC_QAT_INCLUDE_DIRS})
+
+find_library(QAT_LIBRARY
+ NAMES qat
+ HINTS ${PC_QAT_LIBRARY_DIRS})
+
+find_library(QAT_USDM_LIBRARY
+ NAMES usdm
+ HINTS ${PC_QAT_LIBRARY_DIRS})
+
+set(QAT_VERSION ${PC_QAT_VERSION})
+set(QAT_LIBRARIES ${QAT_LIBRARY} ${QAT_USDM_LIBRARY})
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(QAT
+ REQUIRED_VARS QAT_LIBRARY QAT_USDM_LIBRARY QAT_INCLUDE_DIR
+ VERSION_VAR QAT_VERSION)
+
+mark_as_advanced(QAT_LIBRARY QAT_USDM_LIBRARY QAT_LIBRARIES QAT_INCLUDE_DIR QAT_VERSION)
+
+if(QAT_FOUND AND NOT (TARGET QAT::qat))
+ add_library(QAT::qat UNKNOWN IMPORTED)
+ set_target_properties(QAT::qat PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${QAT_INCLUDE_DIR}"
+ IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+ IMPORTED_LOCATION "${QAT_LIBRARY}")
+endif()
+
+if(QAT_FOUND AND NOT (TARGET QAT::usdm))
+ add_library(QAT::usdm UNKNOWN IMPORTED)
+ set_target_properties(QAT::usdm PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${QAT_INCLUDE_DIR}"
+ IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+ IMPORTED_LOCATION "${QAT_USDM_LIBRARY}")
+endif()
diff --git a/cmake/modules/FindQatDrv.cmake b/cmake/modules/FindQatDrv.cmake
index 3305a38c06c..e2849d9c89b 100644
--- a/cmake/modules/FindQatDrv.cmake
+++ b/cmake/modules/FindQatDrv.cmake
@@ -74,7 +74,15 @@ foreach(component ${QatDrv_FIND_COMPONENTS})
add_library(QatDrv::${component} STATIC IMPORTED GLOBAL)
set_target_properties(QatDrv::${component} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${QatDrv_INCLUDE_DIRS}"
+ INTERFACE_COMPILE_OPTIONS "-DHAVE_QATDRV"
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${QatDrv_${component}_LIBRARIES}")
endif()
+
+ # add alias targets to match FindQAT.cmake
+ if(component STREQUAL "qat_s")
+ add_library(QAT::qat ALIAS QatDrv::qat_s)
+ elseif(component STREQUAL "usdm_drv_s")
+ add_library(QAT::usdm ALIAS QatDrv::usdm_drv_s)
+ endif()
endforeach()
diff --git a/src/compressor/CMakeLists.txt b/src/compressor/CMakeLists.txt
index 3e99f8b7387..1f9cab5f3c7 100644
--- a/src/compressor/CMakeLists.txt
+++ b/src/compressor/CMakeLists.txt
@@ -6,10 +6,10 @@ if (HAVE_QATZIP)
endif()
add_library(compressor_objs OBJECT ${compressor_srcs})
add_dependencies(compressor_objs common-objs)
-if(HAVE_QATZIP AND HAVE_QATDRV)
+if(HAVE_QATZIP AND HAVE_QAT)
target_link_libraries(compressor_objs PRIVATE
- QatDrv::qat_s
- QatDrv::usdm_drv_s
+ QAT::qat
+ QAT::usdm
qatzip::qatzip
)
endif()
diff --git a/src/crypto/CMakeLists.txt b/src/crypto/CMakeLists.txt
index 33daee11482..d1ba381999f 100644
--- a/src/crypto/CMakeLists.txt
+++ b/src/crypto/CMakeLists.txt
@@ -7,6 +7,6 @@ if(HAVE_INTEL AND HAVE_NASM_X64_AVX2 AND (NOT APPLE))
add_subdirectory(isa-l)
endif()
-if(WITH_QATDRV)
+if(HAVE_QAT)
add_subdirectory(qat)
endif()
diff --git a/src/crypto/qat/CMakeLists.txt b/src/crypto/qat/CMakeLists.txt
index 77791cacf79..04bc0b7e7f4 100644
--- a/src/crypto/qat/CMakeLists.txt
+++ b/src/crypto/qat/CMakeLists.txt
@@ -12,8 +12,8 @@ add_library(ceph_crypto_qat SHARED ${qat_crypto_plugin_srcs})
add_dependencies(crypto_plugins ceph_crypto_qat)
target_link_libraries(ceph_crypto_qat PRIVATE
- QatDrv::qat_s
- QatDrv::usdm_drv_s
+ QAT::qat
+ QAT::usdm
spawn)
add_dependencies(crypto_plugins ceph_crypto_qat)
diff --git a/src/crypto/qat/qcccrypto.cc b/src/crypto/qat/qcccrypto.cc
index 6110e28c792..56681c74517 100644
--- a/src/crypto/qat/qcccrypto.cc
+++ b/src/crypto/qat/qcccrypto.cc
@@ -88,7 +88,9 @@ void QccCrypto::QccFreeInstance(int entry) {
void QccCrypto::cleanup() {
icp_sal_userStop();
+#ifdef HAVE_QATDRV
qaeMemDestroy();
+#endif
is_init = false;
init_called = false;
derr << "Failure during QAT init sequence. Quitting" << dendl;
@@ -139,6 +141,7 @@ bool QccCrypto::init(const size_t chunk_size, const size_t max_requests) {
dout(15) << "First init for QAT" << dendl;
init_called = true;
+#ifdef HAVE_QATDRV
// Find if the usermode memory driver is available. We need to this to
// create contiguous memory needed by QAT.
stat = qaeMemInit();
@@ -147,7 +150,7 @@ bool QccCrypto::init(const size_t chunk_size, const size_t max_requests) {
this->cleanup();
return false;
}
-
+#endif
stat = icp_sal_userStart("CEPH");
if (stat != CPA_STATUS_SUCCESS) {
derr << "Unable to start qat device" << dendl;
@@ -300,7 +303,9 @@ bool QccCrypto::destroy() {
//Un-init memory driver and QAT HW
icp_sal_userStop();
+#ifdef HAVE_QATDRV
qaeMemDestroy();
+#endif
init_called = false;
is_init = false;
return true;
diff --git a/src/crypto/qat/qcccrypto.h b/src/crypto/qat/qcccrypto.h
index 973688fbf0c..cd17a909e2d 100644
--- a/src/crypto/qat/qcccrypto.h
+++ b/src/crypto/qat/qcccrypto.h
@@ -20,6 +20,7 @@
#include <boost/asio/thread_pool.hpp>
#include <boost/asio/use_future.hpp>
extern "C" {
+#ifdef HAVE_QATDRV
#include "cpa.h"
#include "cpa_cy_sym_dp.h"
#include "cpa_cy_im.h"
@@ -29,6 +30,15 @@ extern "C" {
#include "icp_sal_user.h"
#include "icp_sal_poll.h"
#include "qae_mem_utils.h"
+#else
+#include <qat/cpa.h>
+#include <qat/cpa_cy_im.h>
+#include <qat/cpa_cy_sym_dp.h>
+#include <qat/cpa_cy_sym.h>
+#include <qat/qae_mem.h>
+#include <qat/icp_sal_user.h>
+#include <qat/icp_sal_poll.h>
+#endif
}
class QccCrypto {