diff --git a/1000-bugfix-support-5.10.patch b/1000-bugfix-support-5.10.patch new file mode 100644 index 0000000000000000000000000000000000000000..f10dec65b8cecd7cf995ee33e0a0c6f7977c7de1 --- /dev/null +++ b/1000-bugfix-support-5.10.patch @@ -0,0 +1,190 @@ +commit 6d3281629dd2d2eb46a4e88964e79fd1fccfedc5 +Author: Jiayu Ni +Date: Mon Oct 10 09:14:12 2022 +0800 + + Support 5.10 + +diff --git a/quickassist/qat/drivers/crypto/qat/Makefile b/quickassist/qat/drivers/crypto/qat/Makefile +index e7280d8..5312e72 100644 +--- a/quickassist/qat/drivers/crypto/qat/Makefile ++++ b/quickassist/qat/drivers/crypto/qat/Makefile +@@ -11,11 +11,9 @@ else ifeq ($(shell test $(VERSION) -ge 4 -a $(PATCHLEVEL) -ge 10; echo $$?), 0) + CONFIG_QAT_MDEV=1 + endif + endif +-ifeq ($(CONFIG_QAT_MDEV), 1) +-ifdef CONFIG_IRQ_BYPASS_MANAGER +- export CONFIG_CRYPTO_DEV_QAT_VDCM=m +-endif +-endif ++ ++export CONFIG_CRYPTO_DEV_QAT_VDCM=m ++ + + obj-$(CONFIG_CRYPTO_DEV_QAT) += qat_common/ + obj-$(CONFIG_CRYPTO_DEV_QAT_DH895xCC) += qat_dh895xcc/ +diff --git a/quickassist/qat/drivers/crypto/qat/qat_common/adf_vdcm_adi.c b/quickassist/qat/drivers/crypto/qat/qat_common/adf_vdcm_adi.c +index 1315682..2173eb0 100644 +--- a/quickassist/qat/drivers/crypto/qat/qat_common/adf_vdcm_adi.c ++++ b/quickassist/qat/drivers/crypto/qat/qat_common/adf_vdcm_adi.c +@@ -15,7 +15,7 @@ + #include + #endif + #endif +-#if (KERNEL_VERSION(5, 11, 0) <= LINUX_VERSION_CODE) ++#if (KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE) + #include + #endif + #include "adf_common_drv.h" +@@ -409,7 +409,7 @@ void adf_vqat_release_irqs(struct adf_vdcm_vqat *vqat) + #endif + + #ifdef INTEL_NEXT +-#if (KERNEL_VERSION(5, 11, 0) > LINUX_VERSION_CODE) ++#if (KERNEL_VERSION(5, 10, 0) > LINUX_VERSION_CODE) + static int adf_vqat_get_pasid(struct adf_vdcm_vqat *vqat) + { + #if ((KERNEL_VERSION(5, 6, 0) == LINUX_VERSION_CODE) || \ +@@ -445,7 +445,7 @@ static int adf_vqat_get_pasid(struct adf_vdcm_vqat *vqat) + } + #endif + #endif +-#if (KERNEL_VERSION(5, 11, 0) <= LINUX_VERSION_CODE) ++#if (KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE) + static int adf_vqat_get_pasid(struct adf_vdcm_vqat *vqat) + { + struct vfio_group *vfio_group; +@@ -536,12 +536,7 @@ static inline int adf_vqat_setup_iommu(struct adf_vdcm_vqat *vqat) + return -EINVAL; + } + /* Set mdev iommu device */ +-#if KERNEL_VERSION(5, 16, 0) <= LINUX_VERSION_CODE +- dev_err(mdev_dev(vqat->mdev), +- "%s : SIOV is not supported with this kernel\n", __func__); +- return -EINVAL; +- +-#elif KERNEL_VERSION(5, 13, 0) <= LINUX_VERSION_CODE ++#if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE + mdev_set_iommu_device(vqat->mdev, + &GET_DEV(vqat->parent)); + return 0; +@@ -1000,7 +995,7 @@ static void adf_vdcm_adi_vqat_release(struct adf_vdcm_vqat *vqat) + { + dev_info(mdev_dev(vqat->mdev), "Release vqat %p\n", vqat); + adf_vqat_release_irqs(vqat); +-#if (KERNEL_VERSION(5, 11, 0) <= LINUX_VERSION_CODE) ++#if (KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE) + vfio_group_put_external_user(vqat->group); + #endif + adf_vdcm_adi_vqat_do_reset(vqat, false); +diff --git a/quickassist/qat/drivers/crypto/qat/qat_common/adf_vdcm_core.c b/quickassist/qat/drivers/crypto/qat/qat_common/adf_vdcm_core.c +index 616df63..5dc63ee 100644 +--- a/quickassist/qat/drivers/crypto/qat/qat_common/adf_vdcm_core.c ++++ b/quickassist/qat/drivers/crypto/qat/qat_common/adf_vdcm_core.c +@@ -58,7 +58,7 @@ struct adf_vdcm_ctx_blk { + static struct service_hndl adf_vdcm_srv_hndl; + static struct adf_vdcm_vqat_type adf_vqat_types[QAT_VQAT_TYPES_MAX]; + +-#if KERNEL_VERSION(5, 13, 0) <= LINUX_VERSION_CODE ++#if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE + static struct adf_vdcm_vqat_type *adf_vdcm_lookup_vqat_type(struct device *dev, + struct mdev_type *mtype); + #else +@@ -428,7 +428,7 @@ void adf_vdcm_notify_vqat_iov(struct adf_vdcm_vqat *vqat, u32 queue) + adf_vdcm_notify_vqat(vqat, ADF_VQAT_MISC_IRQ); + } + +-#if KERNEL_VERSION(5, 13, 0) <= LINUX_VERSION_CODE ++#if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE + static int adf_vdcm_vqat_create(struct mdev_device *mdev) + #else + static int adf_vdcm_vqat_create(struct kobject *kobj, struct mdev_device *mdev) +@@ -441,7 +441,7 @@ static int adf_vdcm_vqat_create(struct kobject *kobj, struct mdev_device *mdev) + struct adf_accel_dev *parent; + struct adf_vdcm_vqat_ops *ops; + +-#if KERNEL_VERSION(5, 13, 0) <= LINUX_VERSION_CODE ++#if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE + vqat_type = adf_vdcm_lookup_vqat_type(par_dev, mdev->type); + if (!vqat_type || !vqat_type->ag) + return -EOPNOTSUPP; +@@ -491,7 +491,7 @@ static int adf_vdcm_vqat_create(struct kobject *kobj, struct mdev_device *mdev) + return 0; + } + +-#if (KERNEL_VERSION(5, 11, 0) <= LINUX_VERSION_CODE) ++#if (KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE) + static void adf_vdcm_vqat_request(struct mdev_device *mdev, unsigned int count) + { + struct adf_vdcm_vqat *vqat = mdev_get_drvdata(mdev); +@@ -1342,7 +1342,7 @@ static long adf_vdcm_vqat_ioctl(struct mdev_device *mdev, unsigned int cmd, + return 0; + } + +-#if KERNEL_VERSION(5, 13, 0) <= LINUX_VERSION_CODE ++#if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE + static ssize_t + available_instances_show(struct mdev_type *mtype, + struct mdev_type_attribute *attr, char *buf) +@@ -1351,14 +1351,14 @@ static ssize_t + available_instances_show(struct kobject *kobj, struct device *dev, char *buf) + #endif + { +-#if KERNEL_VERSION(5, 13, 0) <= LINUX_VERSION_CODE ++#if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE + struct device *dev = mtype_get_parent_dev(mtype); + #endif + struct pci_dev *pdev = container_of(dev, struct pci_dev, dev); + struct adf_accel_dev *accel_dev = NULL; + struct adf_vdcm_vqat_type *vqat_type; + +-#if KERNEL_VERSION(5, 13, 0) <= LINUX_VERSION_CODE ++#if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE + vqat_type = adf_vdcm_lookup_vqat_type(dev, mtype); + #else + vqat_type = adf_vdcm_lookup_vqat_type(dev, kobject_name(kobj)); +@@ -1392,7 +1392,7 @@ available_instances_show(struct kobject *kobj, struct device *dev, char *buf) + + MDEV_TYPE_ATTR_RO(available_instances); + +-#if KERNEL_VERSION(5, 13, 0) <= LINUX_VERSION_CODE ++#if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE + static ssize_t + name_show(struct mdev_type *mtype, struct mdev_type_attribute *attr, char *buf) + #else +@@ -1400,7 +1400,7 @@ static ssize_t + name_show(struct kobject *kobj, struct device *dev, char *buf) + #endif + { +-#if KERNEL_VERSION(5, 13, 0) <= LINUX_VERSION_CODE ++#if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE + struct adf_vdcm_vqat_type *vqat_type; + struct device *par_dev = mtype_get_parent_dev(mtype); + +@@ -1417,7 +1417,7 @@ name_show(struct kobject *kobj, struct device *dev, char *buf) + + MDEV_TYPE_ATTR_RO(name); + +-#if KERNEL_VERSION(5, 13, 0) <= LINUX_VERSION_CODE ++#if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE + static ssize_t device_api_show(struct mdev_type *mtype, + struct mdev_type_attribute *attr, char *buf) + #else +@@ -1450,7 +1450,7 @@ static struct mdev_parent_ops qat_vqat_vf_ops = { + .supported_type_groups = qat_vqat_vf_type_groups, + .create = adf_vdcm_vqat_create, + .remove = adf_vdcm_vqat_remove, +-#if KERNEL_VERSION(5, 15, 0) <= LINUX_VERSION_CODE ++#if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE + .open_device = adf_vdcm_vqat_open, + .close_device = adf_vdcm_vqat_release, + #else +@@ -1527,7 +1527,7 @@ struct adf_vdcm_vqat_type *adf_vdcm_vqat_type_by_id(enum vqat_type type_id) + return &adf_vqat_types[type_id]; + } + +-#if KERNEL_VERSION(5, 13, 0) <= LINUX_VERSION_CODE ++#if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE + static struct adf_vdcm_vqat_type *adf_vdcm_lookup_vqat_type(struct device *dev, + struct mdev_type *mtype) + { diff --git a/1001-bugfix-split-qat-vdcm-module.patch b/1001-bugfix-split-qat-vdcm-module.patch new file mode 100644 index 0000000000000000000000000000000000000000..daa0233dee4ee7adca1bfca1f8a6ef14519af1eb --- /dev/null +++ b/1001-bugfix-split-qat-vdcm-module.patch @@ -0,0 +1,102 @@ +From 283fa83620686579aba4035b3c1b5df6bc21cf06 Mon Sep 17 00:00:00 2001 +From: Hao Xiang +Date: Mon, 10 Oct 2022 20:23:36 +0800 +Subject: [PATCH] qat_4xxx: split qat_4xxx module with qat_vdcm module + +Remove qat_4xxx module dependency on qat_vdcm module by looking up +adf_vdcm_register_vqat_parent/adf_vdcm_unregister_vqat_parent function +symbols dynamically. + +Signed-off-by: Hao Xiang +--- + quickassist/build_system/build_files/qat_service | 2 ++ + .../qat/drivers/crypto/qat/qat_4xxx/adf_drv.c | 32 +++++++++++++++++----- + 2 files changed, 27 insertions(+), 7 deletions(-) + +diff --git a/quickassist/build_system/build_files/qat_service b/quickassist/build_system/build_files/qat_service +index 3c00a24..2c2e95e 100755 +--- a/quickassist/build_system/build_files/qat_service ++++ b/quickassist/build_system/build_files/qat_service +@@ -241,6 +241,7 @@ case $1 in + sleep 20 + fi + if [ $num4xxxDevicesPF != 0 ];then ++ lsmod | grep qat_vdcm >/dev/null 2>&1 || modprobe qat_vdcm + lsmod | grep qat_4xxx >/dev/null 2>&1 || modprobe qat_4xxx + fi + if [ `lsmod | grep "usdm_drv" | wc -l` == "0" ]; then +@@ -352,6 +353,7 @@ case $1 in + modprobe -q -r qat_d15xx + modprobe -q -r qat_c4xxx + modprobe -q -r qat_4xxx ++ modprobe -q -r qat_vdcm + modprobe -q -r qat_vqat + modprobe -q -r usdm_drv + modprobe -q -r intel_qat +diff --git a/quickassist/qat/drivers/crypto/qat/qat_4xxx/adf_drv.c b/quickassist/qat/drivers/crypto/qat/qat_4xxx/adf_drv.c +index 3d97831..309c8fe 100644 +--- a/quickassist/qat/drivers/crypto/qat/qat_4xxx/adf_drv.c ++++ b/quickassist/qat/drivers/crypto/qat/qat_4xxx/adf_drv.c +@@ -16,6 +16,7 @@ + #include + #include + #include ++#include + #ifdef CONFIG_CRYPTO_DEV_QAT_VDCM + #include + #endif +@@ -27,6 +28,12 @@ + #define ADF_SYSTEM_DEVICE(device_id) \ + {PCI_DEVICE(PCI_VENDOR_ID_INTEL, device_id)} + ++#ifdef CONFIG_CRYPTO_DEV_QAT_VDCM ++#include ++struct adf_vdcm_ctx_blk * (*adf_vdcm_register_vqat_parent_func)(struct adf_accel_dev *accel_dev,int total, enum vqat_type types[]); ++void (*adf_vdcm_unregister_vqat_parent_func)(struct adf_vdcm_ctx_blk *vdcm, struct adf_accel_dev *accel_dev); ++#endif ++ + static const struct pci_device_id adf_pci_tbl[] = { + ADF_SYSTEM_DEVICE(ADF_4XXX_PCI_DEVICE_ID), + ADF_SYSTEM_DEVICE(ADF_401XX_PCI_DEVICE_ID), +@@ -268,11 +275,16 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) + goto out_err_dev_stop; + + #ifdef CONFIG_CRYPTO_DEV_QAT_VDCM +- accel_dev->vdcm = adf_vdcm_register_vqat_parent(accel_dev, +- ARRAY_SIZE(vqat_types), +- vqat_types); +- if (!accel_dev->vdcm) +- goto out_err_dev_stop; ++ adf_vdcm_register_vqat_parent_func = (void *)kallsyms_lookup_name("adf_vdcm_register_vqat_parent"); ++ if (adf_vdcm_register_vqat_parent_func) { ++ accel_dev->vdcm = adf_vdcm_register_vqat_parent_func(accel_dev, ++ ARRAY_SIZE(vqat_types), ++ vqat_types); ++ if (!accel_dev->vdcm) ++ goto out_err_dev_stop; ++ } else { ++ pr_err("QAT: Function adf_vdcm_register_vqat_parent symbol not found\n"); ++ } + #endif + return ret; + +@@ -300,8 +312,14 @@ static void adf_remove(struct pci_dev *pdev) + } + #ifdef CONFIG_CRYPTO_DEV_QAT_VDCM + if (accel_dev->vdcm) { +- adf_vdcm_unregister_vqat_parent(accel_dev->vdcm, accel_dev); +- accel_dev->vdcm = NULL; ++ adf_vdcm_unregister_vqat_parent_func = (void *)kallsyms_lookup_name("adf_vdcm_unregister_vqat_parent"); ++ if (adf_vdcm_unregister_vqat_parent_func) { ++ adf_vdcm_unregister_vqat_parent_func(accel_dev->vdcm, accel_dev); ++ accel_dev->vdcm = NULL; ++ } else { ++ pr_err("QAT: Function adf_vdcm_unregister_vqat_parent symbol not found\n"); ++ return; ++ } + } + #endif + adf_dev_stop(accel_dev); +-- +1.8.3.1 + diff --git a/1002-bugfix-crash-of-rmmod-vdcm.patch b/1002-bugfix-crash-of-rmmod-vdcm.patch new file mode 100644 index 0000000000000000000000000000000000000000..6a92bc058f265aae4d445b3bc8c219f30908a3a4 --- /dev/null +++ b/1002-bugfix-crash-of-rmmod-vdcm.patch @@ -0,0 +1,46 @@ +From a4d3b2b9d12e98ead5daafcbd476baf23c7f0eed Mon Sep 17 00:00:00 2001 +From: Xuchun Shang +Date: Tue, 25 Oct 2022 15:28:59 +0800 +Subject: [PATCH] src: fix crash when rmmod qat_vdcm + +Signed-off-by: Xuchun Shang +--- + quickassist/qat/drivers/crypto/qat/qat_4xxx/adf_drv.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/quickassist/qat/drivers/crypto/qat/qat_4xxx/adf_drv.c b/quickassist/qat/drivers/crypto/qat/qat_4xxx/adf_drv.c +index 309c8fe..e683efb 100644 +--- a/quickassist/qat/drivers/crypto/qat/qat_4xxx/adf_drv.c ++++ b/quickassist/qat/drivers/crypto/qat/qat_4xxx/adf_drv.c +@@ -32,6 +32,7 @@ + #include + struct adf_vdcm_ctx_blk * (*adf_vdcm_register_vqat_parent_func)(struct adf_accel_dev *accel_dev,int total, enum vqat_type types[]); + void (*adf_vdcm_unregister_vqat_parent_func)(struct adf_vdcm_ctx_blk *vdcm, struct adf_accel_dev *accel_dev); ++struct module *vdcm_mod; + #endif + + static const struct pci_device_id adf_pci_tbl[] = { +@@ -275,6 +276,11 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) + goto out_err_dev_stop; + + #ifdef CONFIG_CRYPTO_DEV_QAT_VDCM ++ if (vdcm_mod == NULL) ++ vdcm_mod = find_module("qat_vdcm"); ++ if (vdcm_mod != NULL) { ++ try_module_get(vdcm_mod); ++ } + adf_vdcm_register_vqat_parent_func = (void *)kallsyms_lookup_name("adf_vdcm_register_vqat_parent"); + if (adf_vdcm_register_vqat_parent_func) { + accel_dev->vdcm = adf_vdcm_register_vqat_parent_func(accel_dev, +@@ -316,6 +322,8 @@ static void adf_remove(struct pci_dev *pdev) + if (adf_vdcm_unregister_vqat_parent_func) { + adf_vdcm_unregister_vqat_parent_func(accel_dev->vdcm, accel_dev); + accel_dev->vdcm = NULL; ++ if (vdcm_mod != NULL) ++ module_put(vdcm_mod); + } else { + pr_err("QAT: Function adf_vdcm_unregister_vqat_parent symbol not found\n"); + return; +-- +2.27.0 + diff --git a/1003-src-fix-warning-when-compiling.patch b/1003-src-fix-warning-when-compiling.patch new file mode 100644 index 0000000000000000000000000000000000000000..5227594ff51eecde2754766cec725abd595ab410 --- /dev/null +++ b/1003-src-fix-warning-when-compiling.patch @@ -0,0 +1,42 @@ +From ee295f3a0d5a9b6f6a219d4d34adc84e6b9be170 Mon Sep 17 00:00:00 2001 +From: Xuchun Shang +Date: Tue, 29 Nov 2022 11:32:10 +0800 +Subject: [PATCH] src: fix warning when compiling + +The dev->deviceName is an array which will never be null. + +Signed-off-by: Xuchun Shang +--- + .../lookaside/access_layer/src/common/ctrl/sal_compression.c | 2 +- + quickassist/lookaside/access_layer/src/common/ctrl/sal_crypto.c | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/quickassist/lookaside/access_layer/src/common/ctrl/sal_compression.c b/quickassist/lookaside/access_layer/src/common/ctrl/sal_compression.c +index 88f4fdb..ed37178 100644 +--- a/quickassist/lookaside/access_layer/src/common/ctrl/sal_compression.c ++++ b/quickassist/lookaside/access_layer/src/common/ctrl/sal_compression.c +@@ -1671,7 +1671,7 @@ CpaStatus cpaDcInstanceGetInfo2(const CpaInstanceHandle instanceHandle, + pInstanceInfo2->isOffloaded = CPA_TRUE; + /* Get the instance name and part name from the config file */ + dev = icp_adf_getAccelDevByAccelId(pCompressionService->pkgID); +- if (NULL == dev || NULL == dev->deviceName) ++ if (NULL == dev) + { + LAC_LOG_ERROR("Can not find device for the instance\n"); + LAC_OS_BZERO(pInstanceInfo2, sizeof(CpaInstanceInfo2)); +diff --git a/quickassist/lookaside/access_layer/src/common/ctrl/sal_crypto.c b/quickassist/lookaside/access_layer/src/common/ctrl/sal_crypto.c +index 64dea7b..1404595 100644 +--- a/quickassist/lookaside/access_layer/src/common/ctrl/sal_crypto.c ++++ b/quickassist/lookaside/access_layer/src/common/ctrl/sal_crypto.c +@@ -2480,7 +2480,7 @@ CpaStatus cpaCyInstanceGetInfo2(const CpaInstanceHandle instanceHandle_in, + + /* Get the instance name and part name*/ + dev = icp_adf_getAccelDevByAccelId(pCryptoService->pkgID); +- if (NULL == dev || NULL == dev->deviceName) ++ if (NULL == dev) + { + LAC_LOG_ERROR("Can not find device for the instance\n"); + LAC_OS_BZERO(pInstanceInfo2, sizeof(CpaInstanceInfo2)); +-- +2.37.3 + diff --git a/intel-QAT20-L.0.9.4-00004.tar.gz b/intel-QAT20-L.0.9.4-00004.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..c5cfde7515a54a4da8ed6568441fef072d89b1a3 Binary files /dev/null and b/intel-QAT20-L.0.9.4-00004.tar.gz differ diff --git a/intel-QAT20.spec b/intel-QAT20.spec new file mode 100644 index 0000000000000000000000000000000000000000..905d001485f6438435be9e40ea38a67633809af6 --- /dev/null +++ b/intel-QAT20.spec @@ -0,0 +1,242 @@ +%define anolis_release 9 +%define debug_package %{nil} +%global kernel_version %(rpm -qa kernel-devel | sed -e 's/kernel-devel-//g') +%define QAT_release 00004 + +Summary: QAT package(Library and sample application) +Name: intel-QAT20 +Version: L.0.9.4 +Release: %{QAT_release}.%{anolis_release}%{dist} +Group: QAT/Base +License: BSD and (BSD or GPLv2) +Source: %{name}-%{version}-%{QAT_release}.tar.gz +Patch1000: 1000-bugfix-support-5.10.patch +Patch1001: 1001-bugfix-split-qat-vdcm-module.patch +Patch1002: 1002-bugfix-crash-of-rmmod-vdcm.patch +Patch1003: 1003-src-fix-warning-when-compiling.patch + +BuildRequires: gcc gcc-c++ make systemd-devel openssl-devel zlib-devel yasm +BuildRequires: libudev-devel >= 1.47 +BuildRequires: kernel-devel >= 5.10.112 +BuildRequires: kernel-core >= 5.10.112 +BuildRequires: boost-devel +Requires: kmod-%{name}-driver >= %{version} +ExclusiveArch: x86_64 + +%description +Intel(R) QuickAssist Technology user space library and sample application Linux +version %{version} + +%prep +%autosetup -c %{name}-%{version} -p1 + +%build +unset ICP_ROOT ICP_ARCH_USER ICP_BUILDSYSTEM_PATH ICP_BUILD_OUTPUT ICP_ENV_DIR ICP_TOOLS_TARGET +%configure +%make_build +%make_build samples + +%pre +groupadd -f qat + +%install +rm -rf %{buildroot} +mkdir -p %{buildroot}/etc/init.d +mkdir -p %{buildroot}/etc/udev/rules.d +mkdir -p %{buildroot}/%{_libdir} +mkdir -p %{buildroot}%{_sbindir} +mkdir -p %{buildroot}/usr/bin/QAT +mkdir -p %{buildroot}/usr/bin/QAT/build +mkdir -p %{buildroot}/lib/firmware +MODPATH=drivers/crypto/qat +KERNEL_VER=%{kernel_version} +SRCMODDIR=${RPM_BUILD_DIR}/%{name}-%{version}/quickassist/qat/${MODPATH} +DSTMODDIR=%{buildroot}/lib/modules/${KERNEL_VER}/updates/${MODPATH} +mkdir -p %{buildroot}/lib/modules/${KERNEL_VER}/kernel +mkdir -p ${DSTMODDIR}/qat_common/ +mkdir -p ${DSTMODDIR}/qat_4xxx/ +mkdir -p ${DSTMODDIR}/qat_4xxxvf/ +mkdir -p ${DSTMODDIR}/qat_vqat/ +/usr/bin/install -D -m 750 quickassist/build_system/build_files/qat_service %{buildroot}/etc/init.d +/usr/bin/install -D -m 664 quickassist/build_system/build_files/qat.service %{buildroot}//usr/bin/QAT/build +/usr/bin/install -D -m 750 build/adf_ctl %{buildroot}%{_sbindir} +/usr/bin/install -D -m 750 build/vqat_ctl %{buildroot}%{_sbindir} +/usr/bin/install -D -m 755 build/cpa_sample_code %{buildroot}/usr/bin +/usr/bin/install -D -m 755 build/libusdm_drv_s.so %{buildroot}/%{_libdir} +/usr/bin/install -D -m 755 build/libqat_s.so %{buildroot}/%{_libdir} +/usr/bin/install -D -m 750 build/qat_4xxx.bin %{buildroot}/lib/firmware +/usr/bin/install -D -m 750 build/qat_4xxx_mmp.bin %{buildroot}/lib/firmware + +/usr/bin/install -D -m 666 build/4xxx_template.conf %{buildroot}/usr/bin/QAT/build +/usr/bin/install -D -m 666 build/4xxxvf_dev0.conf.vm %{buildroot}/usr/bin/QAT/build +/usr/bin/install -D -m 666 build/vqat-adi_dev0.conf.sym %{buildroot}/usr/bin/QAT/build +/usr/bin/install -D -m 666 build/vqat-adi_dev0.conf.asym %{buildroot}/usr/bin/QAT/build +/usr/bin/install -D -m 666 build/vqat-adi_dev0.conf.dc %{buildroot}/usr/bin/QAT/build +/usr/bin/install -D -m 755 config_vqat.sh %{buildroot}/usr/bin/QAT/ +/usr/bin/install -D -m 755 generate_conf_files.sh %{buildroot}/usr/bin/QAT/ + +%clean +rm -rf $RPM_BUILD_ROOT + +%verifyscript + +%files +/etc/init.d/qat_service +%{_sbindir}/adf_ctl +%{_sbindir}/vqat_ctl +/usr/bin/cpa_sample_code +/usr/bin/QAT/ +%{_libdir}/libusdm_drv_s.so +%{_libdir}/libqat_s.so +/lib/firmware/qat_4xxx.bin +/lib/firmware/qat_4xxx_mmp.bin + +%post +MV=/usr/bin/mv +ECHO=/usr/bin/echo +CP=/usr/bin/cp +SLEEP=/usr/bin/sleep +INSTALL=/usr/bin/install +ICP_ROOT=/usr/bin/QAT/ +QAT_SERVICE_PATH=/etc/init.d/ +HUGE_PAGE_DIR=/dev/hugepages/qat +SYSTEMD_SYSTEM_UNIT_DIR=`pkg-config --variable=systemdsystemunitdir systemd` +SYSTEMD_UNIT_FILE_PATH=${ICP_ROOT}/build +SYSTEMD_UNIT_FILE=qat.service +INTEL_VENDORID="8086" +QAT_4XXX_DEVICE_NUMBER="4940" +QAT_4XXX_DEVICE_NUMBER_VM="4941" +VQAT_DEVICE_NUMBER="0da5" +QAT_4XXX_NUM_VFS=16 +DEVICES="${QAT_4XXX_DEVICE_NUMBER} ${QAT_4XXX_DEVICE_NUMBER_VM} ${VQAT_DEVICE_NUMBER}" +num4xxxDevicesP=`lspci -n | egrep -c "${INTEL_VENDORID}:${QAT_4XXX_DEVICE_NUMBER}"` +num4xxxDevicesV=`lspci -n | egrep -c "${INTEL_VENDORID}:${QAT_4XXX_DEVICE_NUMBER_VM}"` +numVQATDevices=`lspci -n | egrep -c "${INTEL_VENDORID}:${VQAT_DEVICE_NUMBER}"` + +if [ -e ${QAT_SERVICE_PATH}/qat_service -a -e "/dev/qat_adf_ctl" ]; then + until ${QAT_SERVICE_PATH}/qat_service shutdown + do + ${SLEEP} 1 + done +fi +groupadd -f qat +if [ ! -d /etc/qat_conf_backup ]; then + mkdir /etc/qat_conf_backup +fi +${MV} /etc/4xxx*.conf /etc/qat_conf_backup/ 2>/dev/null +${MV} /etc/4xxxvf*.conf /etc/qat_conf_backup/ 2>/dev/null +${MV} /etc/vqat*.conf /etc/qat_conf_backup/ 2>/dev/null + +if [ "${num4xxxDevicesP}" -gt "0" ];then + ${ICP_ROOT}/generate_conf_files.sh -n ${num4xxxDevicesP} -f ${ICP_ROOT}/build/4xxx_template.conf -o /etc/ + if [ -e "/etc/default/qat" ];then + . /etc/default/qat + if [ -n "${SRIOV_ENABLE}" ];then + if [ "${SRIOV_ENABLE}" -eq "1" ]; then + num4xxxDevicesV=$((${QAT_4XXX_NUM_VFS} * ${num4xxxDevicesP})) + fi + fi + else + echo "#Remove comment on next line to enable sriov" > /etc/default/qat + echo "#SRIOV_ENABLE=1" >> /etc/default/qat + fi +fi + +if [ "${num4xxxDevicesV}" -gt "0" ];then + for (( dev=0; dev<${num4xxxDevicesV}; dev++ ));do + ${INSTALL} -D -m 640 ${ICP_ROOT}/build/4xxxvf_dev0.conf.vm /etc/4xxxvf_dev${dev}.conf + done + echo "SRIOV_ENABLE=1" > /etc/default/qat +fi + +if [ "${numVQATDevices}" -gt "0" ];then + ${ICP_ROOT}/config_vqat.sh + echo "SRIOV_ENABLE=1" > /etc/default/qat +fi + +echo 'KERNEL=="qat_adf_ctl" MODE="0660" GROUP="qat"' > /etc/udev/rules.d/00-qat.rules +echo 'KERNEL=="qat_dev_processes" MODE="0660" GROUP="qat"' >> /etc/udev/rules.d/00-qat.rules +echo 'KERNEL=="usdm_drv" MODE="0660" GROUP="qat"' >> /etc/udev/rules.d/00-qat.rules +echo 'ACTION=="add", DEVPATH=="/module/usdm_drv" SUBSYSTEM=="module" RUN+="/bin/mkdir' ${HUGE_PAGE_DIR}\" >> /etc/udev/rules.d/00-qat.rules +echo 'ACTION=="add", DEVPATH=="/module/usdm_drv" SUBSYSTEM=="module" RUN+="/bin/chgrp qat' ${HUGE_PAGE_DIR}\" >> /etc/udev/rules.d/00-qat.rules +echo 'ACTION=="add", DEVPATH=="/module/usdm_drv" SUBSYSTEM=="module" RUN+="/bin/chmod 0770' ${HUGE_PAGE_DIR}\" >> /etc/udev/rules.d/00-qat.rules +echo 'ACTION=="remove", DEVPATH=="/module/usdm_drv" SUBSYSTEM=="module" RUN+="/bin/rmdir' ${HUGE_PAGE_DIR}\" >> /etc/udev/rules.d/00-qat.rules +for dev in $DEVICES; do + echo 'KERNEL=="uio*", ATTRS{vendor}=="0x'`echo ${INTEL_VENDORID} | tr -d \"`'", ATTRS{device}=="0x'`echo ${dev} | tr -d \"`'" MODE="0660" GROUP="qat"' >> /etc/udev/rules.d/00-qat.rules +done + +if [ $(echo `uname -r` | grep -i tinyos) ]; then + if [ -e ${QAT_SERVICE_PATH}/qat_service ]; then + ${ECHO} "Disable QAT service" + systemctl disable qat + systemctl daemon-reload + fi +else + if [ -e /usr/bin/systemctl ]; then + if [ "${SYSTEMD_SYSTEM_UNIT_DIR}" == "" ]; then + ${ECHO} "Could not find path to place systemd unit file. Using /usr/lib/systemd/system by default" + fi + ${CP} -f ${SYSTEMD_UNIT_FILE_PATH}/${SYSTEMD_UNIT_FILE} ${SYSTEMD_SYSTEM_UNIT_DIR} + systemctl enable qat + systemctl daemon-reload + elif [ -e /sbin/chkconfig ] ; then + chkconfig --add qat_service; + elif [ -e %{_sbindir}/update-rc.d ]; then + update-rc.d qat_service defaults + fi + + ${ECHO} "Starting QAT service" + /etc/init.d/qat_service start +fi + +%preun +QAT_SERVICE_PATH=/etc/init.d/ +ECHO=/usr/bin/echo +RM=/usr/bin/rm +${ECHO} "Stopping QAT service" +if [ -e ${QAT_SERVICE_PATH}/qat_service ]; then + until ${QAT_SERVICE_PATH}/qat_service shutdown + do + sleep 1 + done + if [ -e /usr/bin/systemctl ]; then + systemctl stop qat + systemctl disable qat + systemctl daemon-reload + elif [ -e /sbin/chkconfig ]; then \ + chkconfig --del qat_service; \ + elif [ -e %{_sbindir}/update-rc.d ]; then \ + update-rc.d -f qat_service remove; \ + fi +fi +${RM} -rf /etc/udev/rules.d/00-qat.rules /etc/default/qat + +%changelog +* Tue Nov 29 2022 Xuchun Shang - 0.9.4-00004.9 +- Fix compiler warning + +* Tue Nov 15 2022 Xuchun Shang - 0.9.4-00004.8 +- Remove QAT driver + +* Wed Nov 09 2022 Hao Xiang - 0.9.4-00004.7 +- Get current kernel version by executing uname + +* Tue Oct 25 2022 Xuchun Shang - 0.9.4-00004.6 +- Fix kernel crash when rmmod qat_vdcm + +* Fri Oct 21 2022 Xuchun Shang - 0.9.4-00004.5 +- Stop QAT service in tinyos by default + +* Tue Oct 18 2022 Xuchun Shang - 0.9.4-00004.4 +- Fix bug in dc_sample_event_notif which leads to kernel crash + +* Thu Oct 13 2022 Hao Xiang - 0.9.4-00004.3 +- Split qat_vdcm module with qat_4xxx module + +* Mon Sep 30 2022 Xin Zeng - 0.9.4-00004.2 +- Split kernel driver and library into separate packages + +* Tue Aug 30 2022 Xin Zeng - 0.9.4-00004.1 +- Initial version of the package + +