No assembly language is required as glibc version >= 2.32. This
is because the later glibc version has updated this optimization.
Signed-off-by: Kai Ye <yekai13(a)huawei.com>
---
src/uadk_utils.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/uadk_utils.c b/src/uadk_utils.c
index 2b34b3a..ec12e67 100644
--- a/src/uadk_utils.c
+++ b/src/uadk_utils.c
@@ -14,9 +14,12 @@
* limitations under the License.
*
*/
+#include <gnu/libc-version.h>
#include "uadk_utils.h"
-#define UADK_MEM_IMPROVE_THRESHOLD 1024
+#define GLIBC_MAIN 2U
+#define GLIBC_MINOR 32U
+#define UADK_MEM_IMPROVE_THRESHOLD 1024U
static void *memcpy_large(void *dstpp, const void *srcpp, size_t len)
{
@@ -56,7 +59,9 @@ static void *memcpy_large(void *dstpp, const void *srcpp, size_t len)
void *uadk_memcpy(void *dstpp, const void *srcpp, size_t len)
{
- if (len >= UADK_MEM_IMPROVE_THRESHOLD)
+ /* No assembly language is required as glibc version >= 2.32 */
+ if (((__GLIBC__ == GLIBC_MAIN && __GLIBC_MINOR__ < GLIBC_MINOR) ||
+ __GLIBC__ < GLIBC_MAIN) && len >= UADK_MEM_IMPROVE_THRESHOLD)
return memcpy_large(dstpp, srcpp, len);
else
return memcpy(dstpp, srcpp, len);
--
2.33.0
1
0
Hello everyone,
openEuler Acclib SIG组的交流例会
举行时间:北京时间,每周三上午,11点~12点
会议链接:https://linaro-org.zoom.us/j/91879279131
欢迎感兴趣接入参与。
可通过邮件申报议题。
邮件列表:acc(a)openeuler.xn--org,openeuler-sd3u001d022a450ktlybqi2b.
Thanks.
Hao Fang
1
0
Use the following rules to unify the print format:
1. failed to do sth.
2. invalid: sth is NULL.
Signed-off-by: Kai Ye <yekai13(a)huawei.com>
---
drv/hisi_sec.c | 20 ++++++++++----------
wd_aead.c | 12 ++++++------
wd_cipher.c | 20 ++++++++++----------
wd_digest.c | 10 +++++-----
4 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/drv/hisi_sec.c b/drv/hisi_sec.c
index 16fcb5f..aa86a6b 100644
--- a/drv/hisi_sec.c
+++ b/drv/hisi_sec.c
@@ -703,7 +703,7 @@ static void parse_cipher_bd2(struct hisi_sec_sqe *sqe,
done = sqe->type2.done_flag & SEC_DONE_MASK;
if (done != SEC_HW_TASK_DONE || sqe->type2.error_type) {
- WD_ERR("SEC BD %s fail! done=0x%x, etype=0x%x\n", "cipher",
+ WD_ERR("failed to parse cipher BD2! done=0x%x, etype=0x%x\n",
done, sqe->type2.error_type);
recv_msg->result = WD_IN_EPARA;
} else {
@@ -927,7 +927,7 @@ int hisi_sec_cipher_send(handle_t ctx, struct wd_cipher_msg *msg)
int ret;
if (!msg) {
- WD_ERR("input cipher msg is NULL!\n");
+ WD_ERR("invalid: input cipher msg is NULL!\n");
return -WD_EINVAL;
}
@@ -1130,7 +1130,7 @@ int hisi_sec_cipher_send_v3(handle_t ctx, struct wd_cipher_msg *msg)
int ret;
if (!msg) {
- WD_ERR("input cipher msg is NULL!\n");
+ WD_ERR("invalid: input cipher msg is NULL!\n");
return -WD_EINVAL;
}
@@ -1175,7 +1175,7 @@ static void parse_cipher_bd3(struct hisi_sec_sqe3 *sqe,
done = sqe->done_flag & SEC_DONE_MASK;
if (done != SEC_HW_TASK_DONE || sqe->error_type) {
- WD_ERR("SEC BD3 %s fail! done=0x%x, etype=0x%x\n", "cipher",
+ WD_ERR("failed to parse cipher BD3! done=0x%x, etype=0x%x\n",
done, sqe->error_type);
recv_msg->result = WD_IN_EPARA;
} else {
@@ -1278,7 +1278,7 @@ static void parse_digest_bd2(struct hisi_sec_sqe *sqe,
done = sqe->type2.done_flag & SEC_DONE_MASK;
if (done != SEC_HW_TASK_DONE || sqe->type2.error_type) {
- WD_ERR("SEC BD %s fail! done=0x%x, etype=0x%x\n", "digest",
+ WD_ERR("failed to parse digest BD2! done=0x%x, etype=0x%x\n",
done, sqe->type2.error_type);
recv_msg->result = WD_IN_EPARA;
} else {
@@ -1354,7 +1354,7 @@ int hisi_sec_digest_send(handle_t ctx, struct wd_digest_msg *msg)
int ret;
if (!msg) {
- WD_ERR("input digest msg is NULL!\n");
+ WD_ERR("invalid: input digest msg is NULL!\n");
return -WD_EINVAL;
}
@@ -1510,7 +1510,7 @@ int hisi_sec_digest_send_v3(handle_t ctx, struct wd_digest_msg *msg)
int ret;
if (!msg) {
- WD_ERR("input digest msg is NULL!\n");
+ WD_ERR("invalid: input digest msg is NULL!\n");
return -WD_EINVAL;
}
@@ -1578,7 +1578,7 @@ static void parse_digest_bd3(struct hisi_sec_sqe3 *sqe,
done = sqe->done_flag & SEC_DONE_MASK;
if (done != SEC_HW_TASK_DONE || sqe->error_type) {
- WD_ERR("SEC BD3 %s fail! done=0x%x, etype=0x%x\n", "digest",
+ WD_ERR("failed to parse digest BD3! done=0x%x, etype=0x%x\n",
done, sqe->error_type);
recv_msg->result = WD_IN_EPARA;
} else {
@@ -1927,7 +1927,7 @@ static void parse_aead_bd2(struct hisi_sec_sqe *sqe,
icv = (sqe->type2.done_flag & SEC_ICV_MASK) >> 1;
if (done != SEC_HW_TASK_DONE || sqe->type2.error_type ||
icv == SEC_HW_ICV_ERR) {
- WD_ERR("SEC BD aead fail! done=0x%x, etype=0x%x, icv=0x%x\n",
+ WD_ERR("failed to parse aead BD2! done=0x%x, etype=0x%x, icv=0x%x\n",
done, sqe->type2.error_type, icv);
recv_msg->result = WD_IN_EPARA;
} else {
@@ -2195,7 +2195,7 @@ static void parse_aead_bd3(struct hisi_sec_sqe3 *sqe,
icv = (sqe->done_flag & SEC_ICV_MASK) >> 1;
if (done != SEC_HW_TASK_DONE || sqe->error_type ||
icv == SEC_HW_ICV_ERR) {
- WD_ERR("SEC BD3 aead fail! done=0x%x, etype=0x%x, icv=0x%x\n",
+ WD_ERR("failed to parse aead BD3! done=0x%x, etype=0x%x, icv=0x%x\n",
done, sqe->error_type, icv);
recv_msg->result = WD_IN_EPARA;
} else {
diff --git a/wd_aead.c b/wd_aead.c
index a78f152..7a33d4e 100644
--- a/wd_aead.c
+++ b/wd_aead.c
@@ -63,14 +63,14 @@ static void wd_aead_set_static_drv(void)
{
wd_aead_setting.driver = wd_aead_get_driver();
if (!wd_aead_setting.driver)
- WD_ERR("fail to get driver\n");
+ WD_ERR("failed to get driver!\n");
}
#else
static void __attribute__((constructor)) wd_aead_open_driver(void)
{
wd_aead_setting.dlhandle = dlopen("libhisi_sec.so", RTLD_NOW);
if (!wd_aead_setting.dlhandle)
- WD_ERR("failed to open libhisi_sec.so\n");
+ WD_ERR("failed to open libhisi_sec.so!\n");
}
static void __attribute__((destructor)) wd_aead_close_driver(void)
@@ -344,7 +344,7 @@ static int aead_param_check(struct wd_aead_sess *sess,
int ret;
if (unlikely(!sess || !req)) {
- WD_ERR("aead input sess or req is NULL.\n");
+ WD_ERR("invalid: aead input sess or req is NULL!\n");
return -WD_EINVAL;
}
@@ -393,7 +393,7 @@ static int aead_param_check(struct wd_aead_sess *sess,
static int aead_init_check(struct wd_ctx_config *config, struct wd_sched *sched)
{
if (!config || !config->ctxs || !config->ctxs[0].ctx || !sched) {
- WD_ERR("wd aead config or sched is NULL!\n");
+ WD_ERR("invalid: wd aead config or sched is NULL!\n");
return -WD_EINVAL;
}
@@ -593,7 +593,7 @@ int wd_do_aead_async(handle_t h_sess, struct wd_aead_req *req)
return -WD_EINVAL;
if (unlikely(!req->cb)) {
- WD_ERR("aead input req cb is NULL.\n");
+ WD_ERR("invalid: aead input req cb is NULL!\n");
return -WD_EINVAL;
}
@@ -646,7 +646,7 @@ int wd_aead_poll_ctx(__u32 idx, __u32 expt, __u32 *count)
int ret;
if (!count) {
- WD_ERR("aead poll ctx input param is NULL!\n");
+ WD_ERR("invalid: aead poll ctx input param is NULL!\n");
return -WD_EINVAL;
}
diff --git a/wd_cipher.c b/wd_cipher.c
index 8daac0f..374b05e 100644
--- a/wd_cipher.c
+++ b/wd_cipher.c
@@ -75,14 +75,14 @@ static void wd_cipher_set_static_drv(void)
{
wd_cipher_setting.driver = wd_cipher_get_driver();
if (!wd_cipher_setting.driver)
- WD_ERR("fail to get driver\n");
+ WD_ERR("failed to get driver!\n");
}
#else
static void __attribute__((constructor)) wd_cipher_open_driver(void)
{
wd_cipher_setting.dlhandle = dlopen("libhisi_sec.so", RTLD_NOW);
if (!wd_cipher_setting.dlhandle)
- WD_ERR("fail to open libhisi_sec.so\n");
+ WD_ERR("failed to open libhisi_sec.so!\n");
}
static void __attribute__((destructor)) wd_cipher_close_driver(void)
@@ -158,7 +158,7 @@ static int cipher_init_check(struct wd_ctx_config *config,
struct wd_sched *sched)
{
if (!config || !config->ctxs || !config->ctxs[0].ctx || !sched) {
- WD_ERR("wd cipher config or sched is NULL!\n");
+ WD_ERR("invalid: wd cipher config or sched is NULL!\n");
return -WD_EINVAL;
}
@@ -177,7 +177,7 @@ int wd_cipher_set_key(handle_t h_sess, const __u8 *key, __u32 key_len)
int ret;
if (!key || !sess) {
- WD_ERR("cipher set key input param err!\n");
+ WD_ERR("invalid: cipher set key input param err!\n");
return -WD_EINVAL;
}
@@ -205,13 +205,13 @@ handle_t wd_cipher_alloc_sess(struct wd_cipher_sess_setup *setup)
struct wd_cipher_sess *sess = NULL;
if (unlikely(!setup)) {
- WD_ERR("cipher input setup is NULL!\n");
+ WD_ERR("invalid: cipher input setup is NULL!\n");
return (handle_t)0;
}
sess = malloc(sizeof(struct wd_cipher_sess));
if (!sess) {
- WD_ERR("fail to alloc session memory!\n");
+ WD_ERR("failed to alloc session memory!\n");
return (handle_t)0;
}
memset(sess, 0, sizeof(struct wd_cipher_sess));
@@ -235,7 +235,7 @@ void wd_cipher_free_sess(handle_t h_sess)
struct wd_cipher_sess *sess = (struct wd_cipher_sess *)h_sess;
if (unlikely(!sess)) {
- WD_ERR("cipher input h_sess is NULL!\n");
+ WD_ERR("invalid: cipher input h_sess is NULL!\n");
return;
}
@@ -386,12 +386,12 @@ static int wd_cipher_check_params(handle_t h_sess,
int ret = 0;
if (unlikely(!h_sess || !req)) {
- WD_ERR("cipher input sess or req is NULL!\n");
+ WD_ERR("invalid: cipher input sess or req is NULL!\n");
return -WD_EINVAL;
}
if (unlikely(mode == CTX_MODE_ASYNC && !req->cb)) {
- WD_ERR("cipher req cb is NULL!\n");
+ WD_ERR("invalid: cipher req cb is NULL!\n");
return -WD_EINVAL;
}
@@ -560,7 +560,7 @@ int wd_cipher_poll_ctx(__u32 idx, __u32 expt, __u32 *count)
int ret;
if (unlikely(!count)) {
- WD_ERR("wd cipher poll ctx input param is NULL!\n");
+ WD_ERR("invalid: cipher poll ctx input param is NULL!\n");
return -WD_EINVAL;
}
diff --git a/wd_digest.c b/wd_digest.c
index f4d0075..c5030d0 100644
--- a/wd_digest.c
+++ b/wd_digest.c
@@ -62,7 +62,7 @@ static void wd_digest_set_static_drv(void)
{
wd_digest_setting.driver = wd_digest_get_driver();
if (!wd_digest_setting.driver)
- WD_ERR("fail to get driver\n");
+ WD_ERR("failed to get driver!\n");
}
#else
static void __attribute__((constructor)) wd_digest_open_driver(void)
@@ -70,7 +70,7 @@ static void __attribute__((constructor)) wd_digest_open_driver(void)
/* Fix me: vendor driver should be put in /usr/lib/wd/ */
wd_digest_setting.dlhandle = dlopen("libhisi_sec.so", RTLD_NOW);
if (!wd_digest_setting.dlhandle)
- WD_ERR("fail to open libhisi_sec.so\n");
+ WD_ERR("failed to open libhisi_sec.so!\n");
}
static void __attribute__((destructor)) wd_digest_close_driver(void)
@@ -251,7 +251,7 @@ static int digest_param_check(struct wd_digest_sess *sess,
int ret;
if (unlikely(!sess || !req)) {
- WD_ERR("digest input sess or req is NULL.\n");
+ WD_ERR("invalid: digest input sess or req is NULL!\n");
return -WD_EINVAL;
}
@@ -397,7 +397,7 @@ int wd_do_digest_async(handle_t h_sess, struct wd_digest_req *req)
return -WD_EINVAL;
if (unlikely(!req->cb)) {
- WD_ERR("digest input req cb is NULL.\n");
+ WD_ERR("invalid: digest input req cb is NULL!\n");
return -WD_EINVAL;
}
@@ -450,7 +450,7 @@ int wd_digest_poll_ctx(__u32 idx, __u32 expt, __u32 *count)
int ret;
if (unlikely(!count)) {
- WD_ERR("digest count is NULL.\n");
+ WD_ERR("invalid: digest poll ctx input param is NULL!\n");
return -WD_EINVAL;
}
--
2.33.0
1
0
------------------ Original ------------------
From: "Jason Gunthorpe" <iommu(a)lists.linux-foundation.org>;
Date: Sat, Mar 19, 2022 01:27 AM
To:
Cc: "Jean-Philippe Brucker"<jean-philippe(a)linaro.org>;"Chaitanya Kulkarni"<chaitanyak(a)nvidia.com>;"kvm"<kvm(a)vger.kernel.org>;"Michael S. Tsirkin"<mst(a)redhat.com>;"Jason Wang"<jasowang(a)redhat.com>;"Cornelia Huck"<cohuck(a)redhat.com>;"Niklas Schnelle"<schnelle(a)linux.ibm.com>;"iommu"<iommu(a)lists.linux-foundation.org>;"Daniel Jordan"<daniel.m.jordan(a)oracle.com>;"Kevin Tian"<kevin.tian(a)intel.com>;"Alex Williamson"<alex.williamson(a)redhat.com>;"Joao Martins"<joao.m.martins(a)oracle.com>;"David Gibson"<david(a)gibson.dropbear.id.au>;
Subject: [PATCH RFC 00/12] IOMMUFD Generic interface
iommufd is the user API to control the IOMMU subsystem as it relates to
managing IO page tables that point at user space memory.
It takes over from drivers/vfio/vfio_iommu_type1.c (aka the VFIO
container) which is the VFIO specific interface for a similar idea.
We see a broad need for extended features, some being highly IOMMU device
specific:
- Binding iommu_domain's to PASID/SSID
- Userspace page tables, for ARM, x86 and S390
- Kernel bypass'd invalidation of user page tables
- Re-use of the KVM page table in the IOMMU
- Dirty page tracking in the IOMMU
- Runtime Increase/Decrease of IOPTE size
- PRI support with faults resolved in userspace
As well as a need to access these features beyond just VFIO, VDPA for
instance, but other classes of accelerator HW are touching on these areas
now too.
The v1 series proposed re-using the VFIO type 1 data structure, however it
was suggested that if we are doing this big update then we should also
come with a data structure that solves the limitations that VFIO type1
has. Notably this addresses:
- Multiple IOAS/'containers' and multiple domains inside a single FD
- Single-pin operation no matter how many domains and containers use
a page
- A fine grained locking scheme supporting user managed concurrency for
multi-threaded map/unmap
- A pre-registration mechanism to optimize vIOMMU use cases by
pre-pinning pages
- Extended ioctl API that can manage these new objects and exposes
domains directly to user space
- domains are sharable between subsystems, eg VFIO and VDPA
The bulk of this code is a new data structure design to track how the
IOVAs are mapped to PFNs.
iommufd intends to be general and consumable by any driver that wants to
DMA to userspace. From a driver perspective it can largely be dropped in
in-place of iommu_attach_device() and provides a uniform full feature set
to all consumers.
As this is a larger project this series is the first step. This series
provides the iommfd "generic interface" which is designed to be suitable
for applications like DPDK and VMM flows that are not optimized to
specific HW scenarios. It is close to being a drop in replacement for the
existing VFIO type 1.
This is part two of three for an initial sequence:
- Move IOMMU Group security into the iommu layer
https://lore.kernel.org/linux-iommu/20220218005521.172832-1-baolu.lu@linux.…
* Generic IOMMUFD implementation
- VFIO ability to consume IOMMUFD
An early exploration of this is available here:
https://github.com/luxis1999/iommufd/commits/iommufd-v5.17-rc6
Various parts of the above extended features are in WIP stages currently
to define how their IOCTL interface should work.
At this point, using the draft VFIO series, unmodified qemu has been
tested to operate using iommufd on x86 and ARM systems.
Several people have contributed directly to this work: Eric Auger, Kevin
Tian, Lu Baolu, Nicolin Chen, Yi L Liu. Many more have participated in the
discussions that lead here, and provided ideas. Thanks to all!
This is on github: https://github.com/jgunthorpe/linux/commits/iommufd
# S390 in-kernel page table walker
Cc: Niklas Schnelle <schnelle(a)linux.ibm.com>
Cc: Matthew Rosato <mjrosato(a)linux.ibm.com>
# AMD Dirty page tracking
Cc: Joao Martins <joao.m.martins(a)oracle.com>
# ARM SMMU Dirty page tracking
Cc: Keqian Zhu <zhukeqian1(a)huawei.com>
Cc: Shameerali Kolothum Thodi <shameerali.kolothum.thodi(a)huawei.com>
# ARM SMMU nesting
Cc: Eric Auger <eric.auger(a)redhat.com>
Cc: Jean-Philippe Brucker <jean-philippe(a)linaro.org>
# Map/unmap performance
Cc: Daniel Jordan <daniel.m.jordan(a)oracle.com>
# VDPA
Cc: "Michael S. Tsirkin" <mst(a)redhat.com>
Cc: Jason Wang <jasowang(a)redhat.com>
# Power
Cc: David Gibson <david(a)gibson.dropbear.id.au>
# vfio
Cc: Alex Williamson <alex.williamson(a)redhat.com>
Cc: Cornelia Huck <cohuck(a)redhat.com>
Cc: kvm(a)vger.kernel.org
# iommu
Cc: iommu(a)lists.linux-foundation.org
# Collaborators
Cc: "Chaitanya Kulkarni" <chaitanyak(a)nvidia.com>
Cc: Nicolin Chen <nicolinc(a)nvidia.com>
Cc: Lu Baolu <baolu.lu(a)linux.intel.com>
Cc: Kevin Tian <kevin.tian(a)intel.com>
Cc: Yi Liu <yi.l.liu(a)intel.com>
Signed-off-by: Jason Gunthorpe <jgg(a)nvidia.com>
Jason Gunthorpe (11):
interval-tree: Add a utility to iterate over spans in an interval tree
iommufd: File descriptor, context, kconfig and makefiles
kernel/user: Allow user::locked_vm to be usable for iommufd
iommufd: PFN handling for iopt_pages
iommufd: Algorithms for PFN storage
iommufd: Data structure to provide IOVA to PFN mapping
iommufd: IOCTLs for the io_pagetable
iommufd: Add a HW pagetable object
iommufd: Add kAPI toward external drivers
iommufd: vfio container FD ioctl compatibility
iommufd: Add a selftest
Kevin Tian (1):
iommufd: Overview documentation
Documentation/userspace-api/index.rst | 1 +
.../userspace-api/ioctl/ioctl-number.rst | 1 +
Documentation/userspace-api/iommufd.rst | 224 +++
MAINTAINERS | 10 +
drivers/iommu/Kconfig | 1 +
drivers/iommu/Makefile | 2 +-
drivers/iommu/iommufd/Kconfig | 22 +
drivers/iommu/iommufd/Makefile | 13 +
drivers/iommu/iommufd/device.c | 274 ++++
drivers/iommu/iommufd/hw_pagetable.c | 142 ++
drivers/iommu/iommufd/io_pagetable.c | 890 +++++++++++
drivers/iommu/iommufd/io_pagetable.h | 170 +++
drivers/iommu/iommufd/ioas.c | 252 ++++
drivers/iommu/iommufd/iommufd_private.h | 231 +++
drivers/iommu/iommufd/iommufd_test.h | 65 +
drivers/iommu/iommufd/main.c | 346 +++++
drivers/iommu/iommufd/pages.c | 1321 +++++++++++++++++
drivers/iommu/iommufd/selftest.c | 495 ++++++
drivers/iommu/iommufd/vfio_compat.c | 401 +++++
include/linux/interval_tree.h | 41 +
include/linux/iommufd.h | 50 +
include/linux/sched/user.h | 2 +-
include/uapi/linux/iommufd.h | 223 +++
kernel/user.c | 1 +
lib/interval_tree.c | 98 ++
tools/testing/selftests/Makefile | 1 +
tools/testing/selftests/iommu/.gitignore | 2 +
tools/testing/selftests/iommu/Makefile | 11 +
tools/testing/selftests/iommu/config | 2 +
tools/testing/selftests/iommu/iommufd.c | 1225 +++++++++++++++
30 files changed, 6515 insertions(+), 2 deletions(-)
create mode 100644 Documentation/userspace-api/iommufd.rst
create mode 100644 drivers/iommu/iommufd/Kconfig
create mode 100644 drivers/iommu/iommufd/Makefile
create mode 100644 drivers/iommu/iommufd/device.c
create mode 100644 drivers/iommu/iommufd/hw_pagetable.c
create mode 100644 drivers/iommu/iommufd/io_pagetable.c
create mode 100644 drivers/iommu/iommufd/io_pagetable.h
create mode 100644 drivers/iommu/iommufd/ioas.c
create mode 100644 drivers/iommu/iommufd/iommufd_private.h
create mode 100644 drivers/iommu/iommufd/iommufd_test.h
create mode 100644 drivers/iommu/iommufd/main.c
create mode 100644 drivers/iommu/iommufd/pages.c
create mode 100644 drivers/iommu/iommufd/selftest.c
create mode 100644 drivers/iommu/iommufd/vfio_compat.c
create mode 100644 include/linux/iommufd.h
create mode 100644 include/uapi/linux/iommufd.h
create mode 100644 tools/testing/selftests/iommu/.gitignore
create mode 100644 tools/testing/selftests/iommu/Makefile
create mode 100644 tools/testing/selftests/iommu/config
create mode 100644 tools/testing/selftests/iommu/iommufd.c
base-commit: d1c716ed82a6bf4c35ba7be3741b9362e84cd722
--
2.35.1
_______________________________________________
iommu mailing list
iommu(a)lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
1
0
Includes:
1. Remove redundant judgment conditions.
2. Remove redundant function parameters.
3. Remove the redundant operation in soft RSA keygen method.
4. Use more efficient BN memory allocation method, and add
judgment of the results.
Signed-off-by: Zhiqi Song <songzhiqi1(a)huawei.com>
---
src/uadk_rsa.c | 331 ++++++++++++++++++++++---------------------------
1 file changed, 148 insertions(+), 183 deletions(-)
diff --git a/src/uadk_rsa.c b/src/uadk_rsa.c
index 1488b98..821cb78 100644
--- a/src/uadk_rsa.c
+++ b/src/uadk_rsa.c
@@ -143,7 +143,7 @@ enum {
static int rsa_check_bit_useful(const int bits, int flen)
{
- if (!flen && flen > bits)
+ if (flen > bits)
return SOFT;
if (bits < RSA_MIN_MODULUS_BITS)
@@ -411,8 +411,8 @@ static int get_rsa_prime_param(struct rsa_prime_param *param, BN_CTX *ctx)
return UADK_E_SUCCESS;
end:
- fprintf(stderr, "failed to malloc params\n");
- return UADK_E_FAIL;
+ fprintf(stderr, "failed to allocate rsa prime params\n");
+ return -ENOMEM;
}
static int rsa_primes_gen(int bits, BIGNUM *e_pub, BIGNUM *p,
@@ -433,13 +433,11 @@ static int rsa_primes_gen(int bits, BIGNUM *e_pub, BIGNUM *p,
BN_CTX_start(ctx);
param = OPENSSL_zalloc(sizeof(struct rsa_prime_param));
- if (!param) {
- fprintf(stderr, "failed to malloc rsa prime param\n");
+ if (!param)
goto free_ctx;
- }
ret = get_rsa_prime_param(param, ctx);
- if (!ret)
+ if (ret != UADK_E_SUCCESS)
goto free_param;
/* Divide bits into 'primes' pieces evenly */
@@ -624,9 +622,10 @@ static int rsa_get_sign_res(int padding, BIGNUM *to_bn, const BIGNUM *n,
return UADK_E_SUCCESS;
}
-static int rsa_get_verify_res(int padding, BIGNUM *to_bn, const BIGNUM *n,
- BIGNUM *ret_bn)
+static int rsa_get_verify_res(int padding, const BIGNUM *n, BIGNUM *ret_bn)
{
+ BIGNUM *to_bn = NULL;
+
if ((padding == RSA_X931_PADDING) && ((bn_get_words(ret_bn)[0] & 0xf)
!= 0x0c)) {
if (!BN_sub(to_bn, n, ret_bn))
@@ -840,6 +839,7 @@ static struct uadk_rsa_sess *rsa_new_eng_session(RSA *rsa)
rsa_sess = OPENSSL_malloc(sizeof(struct uadk_rsa_sess));
if (!rsa_sess)
return NULL;
+
memset(rsa_sess, 0, sizeof(struct uadk_rsa_sess));
rsa_sess->alg = rsa;
rsa_sess->is_prikey_ready = UN_SET;
@@ -971,23 +971,44 @@ static int rsa_get_keygen_param(struct wd_rsa_req *req,
struct rsa_keygen_param_bn *bn_param)
{
struct wd_rsa_kg_out *out = (struct wd_rsa_kg_out *)req->dst;
+ struct wd_dtb wd_d, wd_n, wd_qinv, wd_dq, wd_dp;
+ BIGNUM *dmp1, *dmq1, *iqmp, *n, *d;
unsigned int key_bits, key_size;
- BIGNUM *dmp1 = BN_new();
- BIGNUM *dmq1 = BN_new();
- BIGNUM *iqmp = BN_new();
- BIGNUM *n = BN_new();
- BIGNUM *d = BN_new();
- struct wd_dtb wd_d;
- struct wd_dtb wd_n;
- struct wd_dtb wd_qinv;
- struct wd_dtb wd_dq;
- struct wd_dtb wd_dp;
+ BN_CTX *bn_ctx;
key_bits = wd_rsa_get_key_bits(ctx);
+ if (!key_bits)
+ return UADK_E_FAIL;
+
key_size = key_bits >> BIT_BYTES_SHIFT;
wd_rsa_get_kg_out_params(out, &wd_d, &wd_n);
wd_rsa_get_kg_out_crt_params(out, &wd_qinv, &wd_dq, &wd_dp);
+ bn_ctx = BN_CTX_new();
+ if (!bn_ctx)
+ return UADK_E_FAIL;
+
+ BN_CTX_start(bn_ctx);
+ dmp1 = BN_CTX_get(bn_ctx);
+ if (!dmp1)
+ goto free_bn_ctx;
+
+ dmq1 = BN_CTX_get(bn_ctx);
+ if (!dmq1)
+ goto free_bn_ctx;
+
+ iqmp = BN_CTX_get(bn_ctx);
+ if (!iqmp)
+ goto free_bn_ctx;
+
+ n = BN_CTX_get(bn_ctx);
+ if (!n)
+ goto free_bn_ctx;
+
+ d = BN_CTX_get(bn_ctx);
+ if (!d)
+ goto free_bn_ctx;
+
BN_bin2bn((unsigned char *)wd_d.data, key_size, d);
BN_bin2bn((unsigned char *)wd_n.data, key_size, n);
BN_bin2bn((unsigned char *)wd_qinv.data, wd_qinv.dsize, iqmp);
@@ -997,16 +1018,13 @@ static int rsa_get_keygen_param(struct wd_rsa_req *req,
if (!(RSA_set0_key(rsa, n, bn_param->e, d) &&
RSA_set0_factors(rsa, bn_param->p, bn_param->q) &&
RSA_set0_crt_params(rsa, dmp1, dmq1, iqmp)))
- goto bn_free;
+ goto free_bn_ctx;
return UADK_E_SUCCESS;
-bn_free:
- BN_clear_free(dmp1);
- BN_clear_free(dmq1);
- BN_clear_free(iqmp);
- BN_clear_free(n);
- BN_clear_free(d);
+free_bn_ctx:
+ BN_CTX_end(bn_ctx);
+ BN_CTX_free(bn_ctx);
return UADK_E_FAIL;
}
@@ -1093,20 +1111,11 @@ err:
static int uadk_e_soft_rsa_keygen(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb)
{
- const RSA_METHOD *default_meth = RSA_PKCS1_OpenSSL();
int ret;
- if (!default_meth) {
- fprintf(stderr, "failed to get soft method.\n");
- return UADK_E_FAIL;
- }
-
UNUSED(cb);
- RSA_set_method(rsa, default_meth);
ret = RSA_generate_key_ex(rsa, bits, e, NULL);
- RSA_set_method(rsa, rsa_hw_meth);
-
return ret;
}
@@ -1131,7 +1140,7 @@ static int rsa_fill_keygen_data(struct uadk_rsa_sess *rsa_sess,
return UADK_E_FAIL;
wd_rsa_get_crt_prikey_params(key_pair->prikey, NULL, NULL, NULL,
- &keygen_param->wd_q, &keygen_param->wd_p);
+ &keygen_param->wd_q, &keygen_param->wd_p);
if (!keygen_param->wd_q || !keygen_param->wd_p)
return UADK_E_FAIL;
@@ -1170,9 +1179,11 @@ static int rsa_keygen_param_alloc(struct rsa_keygen_param **keygen_param,
struct rsa_keygen_param_bn **keygen_bn_param,
struct rsa_keypair **key_pair)
{
+ BN_CTX *bn_ctx;
+
*keygen_param = OPENSSL_malloc(sizeof(struct rsa_keygen_param));
if (!(*keygen_param))
- return -ENOMEM;
+ goto err;
*keygen_bn_param = (struct rsa_keygen_param_bn *)
OPENSSL_malloc(sizeof(struct rsa_keygen_param_bn));
@@ -1183,16 +1194,35 @@ static int rsa_keygen_param_alloc(struct rsa_keygen_param **keygen_param,
if (!(*key_pair))
goto free_keygen_bn_param;
- (*keygen_bn_param)->e = BN_new();
- (*keygen_bn_param)->p = BN_new();
- (*keygen_bn_param)->q = BN_new();
+ bn_ctx = BN_CTX_new();
+ if (!bn_ctx)
+ goto free_key_pair;
+
+ BN_CTX_start(bn_ctx);
+ (*keygen_bn_param)->e = BN_CTX_get(bn_ctx);
+ if (!(*keygen_bn_param)->e)
+ goto free_bn_ctx;
+
+ (*keygen_bn_param)->p = BN_CTX_get(bn_ctx);
+ if (!(*keygen_bn_param)->p)
+ goto free_bn_ctx;
+
+ (*keygen_bn_param)->q = BN_CTX_get(bn_ctx);
+ if (!(*keygen_bn_param)->q)
+ goto free_bn_ctx;
return UADK_E_SUCCESS;
+free_bn_ctx:
+ BN_CTX_end(bn_ctx);
+ BN_CTX_free(bn_ctx);
+free_key_pair:
+ OPENSSL_free(*key_pair);
free_keygen_bn_param:
OPENSSL_free(*keygen_bn_param);
free_keygen_param:
OPENSSL_free(*keygen_param);
+err:
return -ENOMEM;
}
@@ -1236,81 +1266,56 @@ static void rsa_pkey_param_free(struct rsa_pubkey_param **pub,
}
static int rsa_create_pub_bn_ctx(RSA *rsa, struct rsa_pubkey_param *pub,
- BN_CTX **bn_ctx, unsigned char **from_buf)
+ unsigned char **from_buf, int *num_bytes)
{
- BIGNUM *ret_bn;
- int num_bytes;
-
RSA_get0_key(rsa, &pub->n, &pub->e, NULL);
-
- *bn_ctx = BN_CTX_new();
- if (!(*bn_ctx))
+ if (!(pub->n) || !(pub->e))
return UADK_E_FAIL;
- BN_CTX_start(*bn_ctx);
- ret_bn = BN_CTX_get(*bn_ctx);
- if (!ret_bn)
- goto err;
-
- num_bytes = BN_num_bytes(pub->n);
- if (!num_bytes)
- goto err;
+ *num_bytes = BN_num_bytes(pub->n);
+ if (!(*num_bytes))
+ return UADK_E_FAIL;
- *from_buf = OPENSSL_malloc(num_bytes);
+ *from_buf = OPENSSL_malloc(*num_bytes);
if (!(*from_buf))
- goto err;
+ return -ENOMEM;
return UADK_E_SUCCESS;
-
-err:
- BN_CTX_free(*bn_ctx);
- return UADK_E_FAIL;
}
-static void rsa_free_pub_bn_ctx(BN_CTX **bn_ctx, unsigned char **from_buf)
+static void rsa_free_pub_bn_ctx(unsigned char **from_buf)
{
- BN_CTX_free(*bn_ctx);
-
OPENSSL_free(*from_buf);
}
static int rsa_create_pri_bn_ctx(RSA *rsa, struct rsa_prikey_param *pri,
- BN_CTX **bn_ctx, unsigned char **from_buf)
+ unsigned char **from_buf, int *num_bytes)
{
- BIGNUM *ret_bn;
- int num_bytes;
-
RSA_get0_key(rsa, &pri->n, &pri->e, &pri->d);
- RSA_get0_factors(rsa, &pri->p, &pri->q);
- RSA_get0_crt_params(rsa, &pri->dmp1, &pri->dmq1, &pri->iqmp);
+ if (!(pri->n) || !(pri->e) || !(pri->d))
+ return UADK_E_FAIL;
- *bn_ctx = BN_CTX_new();
- if (!(*bn_ctx))
+ RSA_get0_factors(rsa, &pri->p, &pri->q);
+ if (!(pri->p) || !(pri->q))
return UADK_E_FAIL;
- BN_CTX_start(*bn_ctx);
- ret_bn = BN_CTX_get(*bn_ctx);
- if (!ret_bn)
- goto err;
+ RSA_get0_crt_params(rsa, &pri->dmp1, &pri->dmq1, &pri->iqmp);
+ if (!(pri->dmp1) || !(pri->dmq1) || !(pri->iqmp))
+ return UADK_E_FAIL;
- num_bytes = BN_num_bytes(pri->n);
- if (!num_bytes)
- goto err;
+ *num_bytes = BN_num_bytes(pri->n);
+ if (!(*num_bytes))
+ return UADK_E_FAIL;
- *from_buf = OPENSSL_malloc(num_bytes);
+ *from_buf = OPENSSL_malloc(*num_bytes);
if (!(*from_buf))
- goto err;
+ return -ENOMEM;
return UADK_E_SUCCESS;
-err:
- BN_CTX_free(*bn_ctx);
- return UADK_E_FAIL;
}
-static void rsa_free_pri_bn_ctx(BN_CTX **bn_ctx, unsigned char **from_buf)
+static void rsa_free_pri_bn_ctx(unsigned char **from_buf)
{
- BN_CTX_free(*bn_ctx);
-
OPENSSL_free(*from_buf);
}
@@ -1318,14 +1323,13 @@ static int uadk_e_rsa_keygen(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb)
{
struct rsa_keygen_param *keygen_param = NULL;
struct rsa_keygen_param_bn *bn_param = NULL;
+ struct uadk_rsa_sess *rsa_sess = NULL;
struct rsa_keypair *key_pair = NULL;
- struct uadk_rsa_sess *rsa_sess;
int is_crt = 1;
- int key_size;
int ret;
- key_size = rsa_check_bit_useful(bits, 0);
- if (!key_size || key_size == SOFT)
+ ret = rsa_check_bit_useful(bits, 0);
+ if (!ret || ret == SOFT)
goto exe_soft;
ret = uadk_e_rsa_init();
@@ -1388,14 +1392,11 @@ exe_soft:
static int uadk_e_rsa_public_encrypt(int flen, const unsigned char *from,
unsigned char *to, RSA *rsa, int padding)
{
+ struct uadk_rsa_sess *rsa_sess = NULL;
struct rsa_pubkey_param *pub = NULL;
- struct uadk_rsa_sess *rsa_sess;
unsigned char *from_buf = NULL;
+ int num_bytes, is_crt, ret;
BIGNUM *ret_bn = NULL;
- BN_CTX *bn_ctx = NULL;
- int num_bytes;
- int is_crt;
- int ret;
ret = check_rsa_input_para(flen, from, to, rsa);
if (!ret || ret == SOFT)
@@ -1417,18 +1418,12 @@ static int uadk_e_rsa_public_encrypt(int flen, const unsigned char *from,
goto free_pkey;
}
- ret = rsa_create_pub_bn_ctx(rsa, pub, &bn_ctx, &from_buf);
- if (!ret) {
+ ret = rsa_create_pub_bn_ctx(rsa, pub, &from_buf, &num_bytes);
+ if (ret <= 0 || flen > num_bytes) {
ret = UADK_DO_SOFT;
goto free_sess;
}
- num_bytes = BN_num_bytes(pub->n);
- if (flen > num_bytes) {
- ret = UADK_DO_SOFT;
- goto free_buf;
- }
-
ret = add_rsa_pubenc_padding(flen, from, from_buf, num_bytes, padding);
if (!ret) {
ret = UADK_DO_SOFT;
@@ -1448,7 +1443,7 @@ static int uadk_e_rsa_public_encrypt(int flen, const unsigned char *from,
}
ret_bn = BN_bin2bn((const unsigned char *)rsa_sess->req.dst,
- rsa_sess->req.dst_bytes, ret_bn);
+ rsa_sess->req.dst_bytes, NULL);
if (!ret_bn) {
ret = UADK_DO_SOFT;
goto free_buf;
@@ -1457,11 +1452,13 @@ static int uadk_e_rsa_public_encrypt(int flen, const unsigned char *from,
ret = BN_bn2binpad(ret_bn, to, num_bytes);
if (ret == -1) {
ret = UADK_DO_SOFT;
- goto free_buf;
+ goto free_bn;
}
+free_bn:
+ BN_free(ret_bn);
free_buf:
- rsa_free_pub_bn_ctx(&bn_ctx, &from_buf);
+ rsa_free_pub_bn_ctx(&from_buf);
free_sess:
rsa_free_eng_session(rsa_sess);
free_pkey:
@@ -1480,11 +1477,8 @@ static int uadk_e_rsa_private_decrypt(int flen, const unsigned char *from,
struct rsa_prikey_param *pri = NULL;
unsigned char *from_buf = NULL;
struct uadk_rsa_sess *rsa_sess;
+ int num_bytes, len, ret;
BIGNUM *ret_bn = NULL;
- BN_CTX *bn_ctx = NULL;
- int num_bytes;
- int ret;
- int len;
ret = check_rsa_input_para(flen, from, to, rsa);
if (!ret || ret == SOFT)
@@ -1506,18 +1500,12 @@ static int uadk_e_rsa_private_decrypt(int flen, const unsigned char *from,
goto free_pkey;
}
- ret = rsa_create_pri_bn_ctx(rsa, pri, &bn_ctx, &from_buf);
- if (!ret) {
+ ret = rsa_create_pri_bn_ctx(rsa, pri, &from_buf, &num_bytes);
+ if (ret <= 0 || flen > num_bytes) {
ret = UADK_DO_SOFT;
goto free_sess;
}
- num_bytes = BN_num_bytes(pri->n);
- if (flen > num_bytes) {
- ret = UADK_DO_SOFT;
- goto free_buf;
- }
-
ret = rsa_fill_prikey(rsa, rsa_sess, pri, from_buf, to);
if (!ret) {
ret = UADK_DO_SOFT;
@@ -1533,7 +1521,7 @@ static int uadk_e_rsa_private_decrypt(int flen, const unsigned char *from,
}
ret_bn = BN_bin2bn((const unsigned char *)rsa_sess->req.dst,
- rsa_sess->req.dst_bytes, ret_bn);
+ rsa_sess->req.dst_bytes, NULL);
if (!ret_bn) {
ret = UADK_DO_SOFT;
goto free_buf;
@@ -1542,17 +1530,19 @@ static int uadk_e_rsa_private_decrypt(int flen, const unsigned char *from,
len = BN_bn2binpad(ret_bn, from_buf, num_bytes);
if (!len) {
ret = UADK_DO_SOFT;
- goto free_buf;
+ goto free_bn;
}
ret = check_rsa_pridec_padding(to, num_bytes, from_buf, len, padding);
if (!ret) {
ret = UADK_DO_SOFT;
- goto free_buf;
+ goto free_bn;
}
+free_bn:
+ BN_free(ret_bn);
free_buf:
- rsa_free_pri_bn_ctx(&bn_ctx, &from_buf);
+ rsa_free_pri_bn_ctx(&from_buf);
free_sess:
rsa_free_eng_session(rsa_sess);
free_pkey:
@@ -1568,14 +1558,13 @@ exe_soft:
static int uadk_e_rsa_private_sign(int flen, const unsigned char *from,
unsigned char *to, RSA *rsa, int padding)
{
+ struct uadk_rsa_sess *rsa_sess = NULL;
struct rsa_prikey_param *pri = NULL;
- struct uadk_rsa_sess *rsa_sess;
unsigned char *from_buf = NULL;
- BIGNUM *to_bn, *ret_bn;
- BN_CTX *bn_ctx = NULL;
+ BIGNUM *ret_bn = NULL;
+ BIGNUM *to_bn = NULL;
BIGNUM *res = NULL;
- int num_bytes;
- int ret;
+ int num_bytes, ret;
ret = check_rsa_input_para(flen, from, to, rsa);
if (!ret || ret == SOFT)
@@ -1597,36 +1586,18 @@ static int uadk_e_rsa_private_sign(int flen, const unsigned char *from,
goto free_pkey;
}
- ret = rsa_create_pri_bn_ctx(rsa, pri, &bn_ctx, &from_buf);
- if (!ret) {
+ ret = rsa_create_pri_bn_ctx(rsa, pri, &from_buf, &num_bytes);
+ if (ret <= 0 || flen > num_bytes) {
ret = UADK_DO_SOFT;
goto free_sess;
}
- to_bn = BN_CTX_get(bn_ctx);
- if (!to_bn) {
- ret = UADK_DO_SOFT;
- goto free_buf;
- }
-
- num_bytes = BN_num_bytes(pri->n);
- if (flen > num_bytes) {
- ret = UADK_DO_SOFT;
- goto free_buf;
- }
-
ret = add_rsa_prienc_padding(flen, from, from_buf, num_bytes, padding);
if (!ret) {
ret = UADK_DO_SOFT;
goto free_buf;
}
- ret_bn = BN_bin2bn(from_buf, num_bytes, to_bn);
- if (!ret_bn) {
- ret = UADK_DO_SOFT;
- goto free_buf;
- }
-
ret = rsa_fill_prikey(rsa, rsa_sess, pri, from_buf, to);
if (!ret) {
ret = UADK_DO_SOFT;
@@ -1639,24 +1610,33 @@ static int uadk_e_rsa_private_sign(int flen, const unsigned char *from,
goto free_buf;
}
- ret_bn = NULL;
ret_bn = BN_bin2bn((const unsigned char *)rsa_sess->req.dst,
- rsa_sess->req.dst_bytes, ret_bn);
+ rsa_sess->req.dst_bytes, NULL);
if (!ret_bn) {
ret = UADK_DO_SOFT;
goto free_buf;
}
+ to_bn = BN_bin2bn(from_buf, num_bytes, NULL);
+ if (!to_bn) {
+ ret = UADK_DO_SOFT;
+ goto free_ret_bn;
+ }
+
ret = rsa_get_sign_res(padding, to_bn, pri->n, ret_bn, &res);
if (!ret) {
ret = UADK_DO_SOFT;
- goto free_buf;
+ goto free_to_bn;
}
ret = BN_bn2binpad(res, to, num_bytes);
+free_to_bn:
+ BN_free(to_bn);
+free_ret_bn:
+ BN_free(ret_bn);
free_buf:
- rsa_free_pri_bn_ctx(&bn_ctx, &from_buf);
+ rsa_free_pri_bn_ctx(&from_buf);
free_sess:
rsa_free_eng_session(rsa_sess);
free_pkey:
@@ -1672,15 +1652,11 @@ exe_soft:
static int uadk_e_rsa_public_verify(int flen, const unsigned char *from,
unsigned char *to, RSA *rsa, int padding)
{
- struct uadk_rsa_sess *rsa_sess;
+ struct uadk_rsa_sess *rsa_sess = NULL;
+ struct rsa_pubkey_param *pub = NULL;
+ int num_bytes, is_crt, len, ret;
unsigned char *from_buf = NULL;
- struct rsa_pubkey_param *pub;
- BIGNUM *ret_bn, *to_bn;
- BN_CTX *bn_ctx = NULL;
- int num_bytes;
- int is_crt;
- int ret;
- int len;
+ BIGNUM *ret_bn = NULL;
ret = check_rsa_input_para(flen, from, to, rsa);
if (!ret)
@@ -1704,25 +1680,12 @@ static int uadk_e_rsa_public_verify(int flen, const unsigned char *from,
goto free_pkey;
}
- ret = rsa_create_pub_bn_ctx(rsa, pub, &bn_ctx, &from_buf);
- if (!ret) {
+ ret = rsa_create_pub_bn_ctx(rsa, pub, &from_buf, &num_bytes);
+ if (ret <= 0 || flen > num_bytes) {
ret = UADK_DO_SOFT;
goto free_sess;
}
- to_bn = BN_CTX_get(bn_ctx);
- if (!to_bn) {
- ret = UADK_DO_SOFT;
- goto free_buf;
- }
-
- num_bytes = BN_num_bytes(pub->n);
- ret_bn = BN_bin2bn(from_buf, num_bytes, to_bn);
- if (!ret_bn) {
- ret = UADK_DO_SOFT;
- goto free_buf;
- }
-
ret = rsa_fill_pubkey(pub, rsa_sess, from_buf, to);
if (!ret) {
ret = UADK_DO_SOFT;
@@ -1736,34 +1699,35 @@ static int uadk_e_rsa_public_verify(int flen, const unsigned char *from,
goto free_buf;
}
- ret_bn = NULL;
ret_bn = BN_bin2bn((const unsigned char *)rsa_sess->req.dst,
- rsa_sess->req.dst_bytes, ret_bn);
+ rsa_sess->req.dst_bytes, NULL);
if (!ret_bn) {
ret = UADK_DO_SOFT;
goto free_buf;
}
- ret = rsa_get_verify_res(padding, to_bn, pub->n, ret_bn);
+ ret = rsa_get_verify_res(padding, pub->n, ret_bn);
if (!ret) {
ret = UADK_DO_SOFT;
- goto free_buf;
+ goto free_bn;
}
len = BN_bn2binpad(ret_bn, from_buf, num_bytes);
if (!len) {
ret = UADK_DO_SOFT;
- goto free_buf;
+ goto free_bn;
}
ret = check_rsa_pubdec_padding(to, num_bytes, from_buf, len, padding);
if (!ret) {
ret = UADK_DO_SOFT;
- goto free_buf;
+ goto free_bn;
}
+free_bn:
+ BN_free(ret_bn);
free_buf:
- rsa_free_pub_bn_ctx(&bn_ctx, &from_buf);
+ rsa_free_pub_bn_ctx(&from_buf);
free_sess:
rsa_free_eng_session(rsa_sess);
free_pkey:
@@ -1786,7 +1750,7 @@ static RSA_METHOD *uadk_e_get_rsa_sw_methods(void)
(void)RSA_meth_set_priv_enc(rsa_sw_meth, RSA_meth_get_priv_enc(meth));
(void)RSA_meth_set_pub_dec(rsa_sw_meth, RSA_meth_get_pub_dec(meth));
(void)RSA_meth_set_priv_dec(rsa_sw_meth, RSA_meth_get_priv_dec(meth));
- (void)RSA_meth_set_keygen(rsa_sw_meth, RSA_meth_get_keygen(meth));
+ (void)RSA_meth_set_keygen(rsa_sw_meth, uadk_e_soft_rsa_keygen);
(void)RSA_meth_set_mod_exp(rsa_sw_meth, RSA_meth_get_mod_exp(meth));
(void)RSA_meth_set_bn_mod_exp(rsa_sw_meth,
RSA_meth_get_bn_mod_exp(meth));
@@ -1798,6 +1762,7 @@ static RSA_METHOD *uadk_e_get_rsa_hw_methods(void)
{
if (rsa_hw_meth)
return rsa_hw_meth;
+
rsa_hw_meth = RSA_meth_new("uadk hardware rsa method", 0);
if (!rsa_hw_meth) {
fprintf(stderr, "failed to allocate rsa hardware method\n");
--
2.33.0
1
0
From: Wenkai Lin <linwenkai6(a)hisilicon.com>
wd_parse_epoll_en is used to parse epoll enable flag
from environment variable, it's return value is stored
in global variable of each process.
When uadk works in synchronize mode, it will check the
global variable and decide whether to use wd_ctx_wait.
HPRE algorithm(ecc, rsa, dh) is also support epoll wait now.
Signed-off-by: Wenkai Lin <linwenkai6(a)hisilicon.com>
---
docs/wd_environment_variable | 5 +++
drv/hisi_comp.c | 5 +--
drv/hisi_hpre.c | 3 ++
drv/hisi_qm_udrv.c | 21 ++-----------
drv/hisi_sec.c | 15 ++-------
include/drv/wd_aead_drv.h | 2 --
include/drv/wd_cipher_drv.h | 2 --
include/drv/wd_comp_drv.h | 2 --
include/drv/wd_digest_drv.h | 2 --
include/hisi_qm_udrv.h | 4 +--
include/wd_alg_common.h | 2 ++
include/wd_util.h | 9 ++++++
wd_aead.c | 24 ++++++---------
wd_cipher.c | 24 ++++++---------
wd_comp.c | 27 ++++++++--------
wd_dh.c | 24 +++++++++------
wd_digest.c | 25 +++++++--------
wd_ecc.c | 24 +++++++++------
wd_rsa.c | 24 +++++++++------
wd_sched.c | 2 +-
wd_util.c | 60 ++++++++++++++++++++++++++++--------
21 files changed, 165 insertions(+), 141 deletions(-)
diff --git a/docs/wd_environment_variable b/docs/wd_environment_variable
index 3ada5fb..8ac2da7 100644
--- a/docs/wd_environment_variable
+++ b/docs/wd_environment_variable
@@ -47,6 +47,11 @@ WD_<alg>_ASYNC_POLL_NUM
WD_<alg>_ASYNC_POLL_NUM=2@0,4@2 means to configure 2 async polling threads in
node0, and 4 polling threads in node2.
+WD_<alg>_EPOLL_EN
+ Define if wd_do_<alg>_sync enable wd_ctx_wait in WD. WD_<alg>_EPOLL_EN=1
+ means enable wd_ctx_wait in WD, driver will wait to receive the package until
+ hardware is done with package, otherwise driver will try to receive the package
+ directly after the package is sent.
2. User model
=============
diff --git a/drv/hisi_comp.c b/drv/hisi_comp.c
index 841ae03..43c8688 100644
--- a/drv/hisi_comp.c
+++ b/drv/hisi_comp.c
@@ -779,6 +779,9 @@ static int hisi_zip_init(struct wd_ctx_config_internal *config, void *priv)
qm_priv.sqe_size = sizeof(struct hisi_zip_sqe);
qm_priv.op_type = config->ctxs[i].op_type;
qm_priv.qp_mode = config->ctxs[i].ctx_mode;
+ /* Setting the epoll en to 0 for ASYNC ctx */
+ qm_priv.epoll_en = (qm_priv.qp_mode == CTX_MODE_SYNC) ?
+ config->epoll_en : 0;
qm_priv.idx = i;
h_qp = hisi_qm_alloc_qp(&qm_priv, h_ctx);
if (unlikely(!h_qp))
@@ -882,8 +885,6 @@ static int hisi_zip_comp_send(handle_t ctx, struct wd_comp_msg *msg, void *priv)
return ret;
}
- hisi_qm_enable_interrupt(ctx, msg->is_polled);
-
return 0;
}
diff --git a/drv/hisi_hpre.c b/drv/hisi_hpre.c
index 018fe5b..f0ec540 100644
--- a/drv/hisi_hpre.c
+++ b/drv/hisi_hpre.c
@@ -465,6 +465,9 @@ static int hpre_init(struct wd_ctx_config_internal *config, void *priv, const ch
for (i = 0; i < config->ctx_num; i++) {
h_ctx = config->ctxs[i].ctx;
qm_priv.qp_mode = config->ctxs[i].ctx_mode;
+ /* Setting the epoll en to 0 for ASYNC ctx */
+ qm_priv.epoll_en = (qm_priv.qp_mode == CTX_MODE_SYNC) ?
+ config->epoll_en : 0;
qm_priv.idx = i;
h_qp = hisi_qm_alloc_qp(&qm_priv, h_ctx);
if (!h_qp) {
diff --git a/drv/hisi_qm_udrv.c b/drv/hisi_qm_udrv.c
index be06570..2c0d87c 100644
--- a/drv/hisi_qm_udrv.c
+++ b/drv/hisi_qm_udrv.c
@@ -309,6 +309,7 @@ static int hisi_qm_setup_info(struct hisi_qp *qp, struct hisi_qm_priv *config)
}
q_info->qp_mode = config->qp_mode;
+ q_info->epoll_en = config->epoll_en;
q_info->idx = config->idx;
q_info->sqe_size = config->sqe_size;
q_info->cqc_phase = 1;
@@ -479,7 +480,7 @@ static int hisi_qm_recv_single(struct hisi_qm_queue_info *q_info, void *resp)
i++;
}
- q_info->db(q_info, QM_DBELL_CMD_CQ, i, 0);
+ q_info->db(q_info, QM_DBELL_CMD_CQ, i, q_info->epoll_en);
/* only support one thread poll one queue, so no need protect */
q_info->cq_head_index = i;
@@ -919,21 +920,3 @@ __u32 hisi_qm_get_list_size(struct wd_datalist *start_node,
return lits_size;
}
-
-void hisi_qm_enable_interrupt(handle_t ctx, __u8 enable)
-{
- struct hisi_qm_queue_info *q_info;
- struct hisi_qp *qp;
- handle_t h_qp;
-
- if (!enable)
- return;
-
- h_qp = (handle_t)wd_ctx_get_priv(ctx);
- qp = (struct hisi_qp *)h_qp;
- q_info = &qp->q_info;
-
- pthread_spin_lock(&q_info->lock);
- q_info->db(q_info, QM_DBELL_CMD_CQ, q_info->cq_head_index, 1);
- pthread_spin_unlock(&q_info->lock);
-}
diff --git a/drv/hisi_sec.c b/drv/hisi_sec.c
index aa86a6b..0732cdc 100644
--- a/drv/hisi_sec.c
+++ b/drv/hisi_sec.c
@@ -959,8 +959,6 @@ int hisi_sec_cipher_send(handle_t ctx, struct wd_cipher_msg *msg)
return ret;
}
- hisi_qm_enable_interrupt(ctx, msg->is_polled);
-
return 0;
}
@@ -1162,8 +1160,6 @@ int hisi_sec_cipher_send_v3(handle_t ctx, struct wd_cipher_msg *msg)
return ret;
}
- hisi_qm_enable_interrupt(ctx, msg->is_polled);
-
return 0;
}
@@ -1403,8 +1399,6 @@ int hisi_sec_digest_send(handle_t ctx, struct wd_digest_msg *msg)
goto put_sgl;
}
- hisi_qm_enable_interrupt(ctx, msg->is_polled);
-
return 0;
put_sgl:
@@ -1560,8 +1554,6 @@ int hisi_sec_digest_send_v3(handle_t ctx, struct wd_digest_msg *msg)
goto put_sgl;
}
- hisi_qm_enable_interrupt(ctx, msg->is_polled);
-
return 0;
put_sgl:
@@ -1913,8 +1905,6 @@ int hisi_sec_aead_send(handle_t ctx, struct wd_aead_msg *msg)
return ret;
}
- hisi_qm_enable_interrupt(ctx, msg->is_polled);
-
return 0;
}
@@ -2181,8 +2171,6 @@ int hisi_sec_aead_send_v3(handle_t ctx, struct wd_aead_msg *msg)
return ret;
}
- hisi_qm_enable_interrupt(ctx, msg->is_polled);
-
return 0;
}
@@ -2285,6 +2273,9 @@ int hisi_sec_init(struct wd_ctx_config_internal *config, void *priv)
/* setting the type is 0 for sqc_type */
qm_priv.op_type = 0;
qm_priv.qp_mode = config->ctxs[i].ctx_mode;
+ /* Setting the epoll en to 0 for ASYNC ctx */
+ qm_priv.epoll_en = (qm_priv.qp_mode == CTX_MODE_SYNC) ?
+ config->epoll_en : 0;
qm_priv.idx = i;
h_qp = hisi_qm_alloc_qp(&qm_priv, h_ctx);
if (!h_qp)
diff --git a/include/drv/wd_aead_drv.h b/include/drv/wd_aead_drv.h
index 78a5673..137e70a 100644
--- a/include/drv/wd_aead_drv.h
+++ b/include/drv/wd_aead_drv.h
@@ -31,8 +31,6 @@ struct wd_aead_msg {
__u8 data_fmt;
/* Operation result, denoted by WD error code */
__u8 result;
- /* epoll flag */
- __u8 is_polled;
/* in bytes */
__u32 in_bytes;
diff --git a/include/drv/wd_cipher_drv.h b/include/drv/wd_cipher_drv.h
index e649869..87b77d3 100644
--- a/include/drv/wd_cipher_drv.h
+++ b/include/drv/wd_cipher_drv.h
@@ -28,8 +28,6 @@ struct wd_cipher_msg {
__u8 data_fmt;
/* Operation result, denoted by WD error code */
__u8 result;
- /* epoll flag */
- __u8 is_polled;
/* Key bytes */
__u16 key_bytes;
diff --git a/include/drv/wd_comp_drv.h b/include/drv/wd_comp_drv.h
index 8146a50..73403b5 100644
--- a/include/drv/wd_comp_drv.h
+++ b/include/drv/wd_comp_drv.h
@@ -50,8 +50,6 @@ struct wd_comp_msg {
__u32 checksum;
/* Request identifier */
__u32 tag;
- /* Epoll flag */
- __u8 is_polled;
};
struct wd_comp_driver {
diff --git a/include/drv/wd_digest_drv.h b/include/drv/wd_digest_drv.h
index fdde772..6907bc5 100644
--- a/include/drv/wd_digest_drv.h
+++ b/include/drv/wd_digest_drv.h
@@ -27,8 +27,6 @@ struct wd_digest_msg {
__u8 data_fmt;
/* Operation result, denoted by WD error code */
__u8 result;
- /* epoll flag */
- __u8 is_polled;
/* user identifier: struct wcrypto_cb_tag */
__u64 usr_data;
diff --git a/include/hisi_qm_udrv.h b/include/hisi_qm_udrv.h
index 707d0e3..43f42d9 100644
--- a/include/hisi_qm_udrv.h
+++ b/include/hisi_qm_udrv.h
@@ -47,6 +47,7 @@ struct hisi_qm_priv {
__u16 op_type;
/* index of ctxs */
__u32 idx;
+ int epoll_en;
};
struct hisi_qm_queue_info {
@@ -71,6 +72,7 @@ struct hisi_qm_queue_info {
bool cqc_phase;
pthread_spinlock_t lock;
unsigned long region_size[UACCE_QFRT_MAX];
+ int epoll_en;
};
struct hisi_qp {
@@ -182,8 +184,6 @@ int hisi_qm_get_free_sqe_num(handle_t h_qp);
__u32 hisi_qm_get_list_size(struct wd_datalist *start_node,
struct wd_datalist *end_node);
-void hisi_qm_enable_interrupt(handle_t ctx, __u8 enable);
-
#ifdef __cplusplus
}
#endif
diff --git a/include/wd_alg_common.h b/include/wd_alg_common.h
index 94336f0..0affa96 100644
--- a/include/wd_alg_common.h
+++ b/include/wd_alg_common.h
@@ -27,6 +27,7 @@ extern "C" {
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#define MAX_STR_LEN 256
#define CTX_TYPE_INVALID 9999
+#define POLL_TIME 1000
enum wd_ctx_mode {
CTX_MODE_SYNC = 0,
@@ -74,6 +75,7 @@ struct wd_ctx_config_internal {
struct wd_ctx_internal *ctxs;
void *priv;
int pid;
+ int epoll_en;
};
/**
diff --git a/include/wd_util.h b/include/wd_util.h
index 2d3c1e4..73ba96a 100644
--- a/include/wd_util.h
+++ b/include/wd_util.h
@@ -314,6 +314,15 @@ int wd_set_ctx_attr(struct wd_ctx_attr *ctx_attr,
*/
int wd_check_ctx(struct wd_ctx_config_internal *config, __u8 mode, __u32 idx);
+/**
+ * wd_get_epoll_en() - Get epoll enable value from environment variable.
+ * @var_name: Environment variable name string.
+ *
+ * Return environment variable value, if the value is not 0 or 1,
+ * return -WD_EINVAL instead.
+ */
+int wd_get_epoll_en(const char *var_name);
+
#ifdef __cplusplus
}
#endif
diff --git a/wd_aead.c b/wd_aead.c
index 74047b5..f1bde0a 100644
--- a/wd_aead.c
+++ b/wd_aead.c
@@ -21,8 +21,6 @@
#define WD_POOL_MAX_ENTRIES 1024
#define MAX_RETRY_COUNTS 200000000
-#define POLL_SIZE 70000
-#define POLL_TIME 1000
static int g_aead_mac_len[WD_DIGEST_TYPE_MAX] = {
WD_DIGEST_SM3_LEN, WD_DIGEST_MD5_LEN, WD_DIGEST_SHA1_LEN,
@@ -414,17 +412,19 @@ int wd_aead_init(struct wd_ctx_config *config, struct wd_sched *sched)
if (ret)
return ret;
+ ret = wd_get_epoll_en("WD_AEAD_EPOLL_EN");
+ if (ret < 0)
+ return ret;
+
+ wd_aead_setting.config.epoll_en = ret;
+
ret = wd_init_ctx_config(&wd_aead_setting.config, config);
- if (ret) {
- WD_ERR("failed to set config, ret = %d\n", ret);
+ if (ret)
return ret;
- }
ret = wd_init_sched(&wd_aead_setting.sched, sched);
- if (ret < 0) {
- WD_ERR("failed to set sched, ret = %d\n", ret);
+ if (ret < 0)
goto out;
- }
/* set driver */
#ifdef WD_STATIC_DRV
@@ -435,10 +435,8 @@ int wd_aead_init(struct wd_ctx_config *config, struct wd_sched *sched)
ret = wd_init_async_request_pool(&wd_aead_setting.pool,
config->ctx_num, WD_POOL_MAX_ENTRIES,
sizeof(struct wd_aead_msg));
- if (ret < 0) {
- WD_ERR("failed to init aead aysnc request pool.\n");
+ if (ret < 0)
goto out_sched;
- }
/* init ctx related resources in specific driver */
priv = calloc(1, wd_aead_setting.driver->drv_ctx_size);
@@ -525,7 +523,7 @@ static int send_recv_sync(struct wd_ctx_internal *ctx,
}
do {
- if (msg->is_polled) {
+ if (wd_aead_setting.config.epoll_en) {
ret = wd_ctx_wait(ctx->ctx, POLL_TIME);
if (unlikely(ret < 0))
WD_ERR("wd aead ctx wait timeout(%d)!\n", ret);
@@ -563,7 +561,6 @@ int wd_do_aead_sync(handle_t h_sess, struct wd_aead_req *req)
memset(&msg, 0, sizeof(struct wd_aead_msg));
fill_request_msg(&msg, req, sess);
- msg.is_polled = (req->in_bytes >= POLL_SIZE);
req->state = 0;
idx = wd_aead_setting.sched.pick_next_ctx(
@@ -616,7 +613,6 @@ int wd_do_aead_async(handle_t h_sess, struct wd_aead_req *req)
fill_request_msg(msg, req, sess);
msg->tag = msg_id;
- msg->is_polled = 0;
ret = wd_aead_setting.driver->aead_send(ctx->ctx, msg);
if (unlikely(ret < 0)) {
diff --git a/wd_cipher.c b/wd_cipher.c
index 563eece..9b7b150 100644
--- a/wd_cipher.c
+++ b/wd_cipher.c
@@ -22,8 +22,6 @@
#define DES_WEAK_KEY_NUM 16
#define MAX_RETRY_COUNTS 200000000
-#define POLL_SIZE 100000
-#define POLL_TIME 1000
static const unsigned char des_weak_keys[DES_WEAK_KEY_NUM][DES_KEY_SIZE] = {
/* weak keys */
@@ -255,17 +253,19 @@ int wd_cipher_init(struct wd_ctx_config *config, struct wd_sched *sched)
if (ret)
return ret;
+ ret = wd_get_epoll_en("WD_CIPHER_EPOLL_EN");
+ if (ret < 0)
+ return ret;
+
+ wd_cipher_setting.config.epoll_en = ret;
+
ret = wd_init_ctx_config(&wd_cipher_setting.config, config);
- if (ret < 0) {
- WD_ERR("failed to set config, ret = %d!\n", ret);
+ if (ret < 0)
return ret;
- }
ret = wd_init_sched(&wd_cipher_setting.sched, sched);
- if (ret < 0) {
- WD_ERR("failed to set sched, ret = %d!\n", ret);
+ if (ret < 0)
goto out;
- }
#ifdef WD_STATIC_DRV
/* set driver */
@@ -276,10 +276,8 @@ int wd_cipher_init(struct wd_ctx_config *config, struct wd_sched *sched)
ret = wd_init_async_request_pool(&wd_cipher_setting.pool,
config->ctx_num, WD_POOL_MAX_ENTRIES,
sizeof(struct wd_cipher_msg));
- if (ret < 0) {
- WD_ERR("failed to init req pool, ret = %d!\n", ret);
+ if (ret < 0)
goto out_sched;
- }
/* init ctx related resources in specific driver */
priv = calloc(1, wd_cipher_setting.driver->drv_ctx_size);
@@ -436,7 +434,7 @@ static int send_recv_sync(struct wd_ctx_internal *ctx,
}
do {
- if (msg->is_polled) {
+ if (wd_cipher_setting.config.epoll_en) {
ret = wd_ctx_wait(ctx->ctx, POLL_TIME);
if (unlikely(ret < 0))
WD_ERR("wd cipher ctx wait timeout(%d)!\n", ret);
@@ -476,7 +474,6 @@ int wd_do_cipher_sync(handle_t h_sess, struct wd_cipher_req *req)
memset(&msg, 0, sizeof(struct wd_cipher_msg));
fill_request_msg(&msg, req, sess);
- msg.is_polled = (req->in_bytes >= POLL_SIZE);
req->state = 0;
idx = wd_cipher_setting.sched.pick_next_ctx(
@@ -526,7 +523,6 @@ int wd_do_cipher_async(handle_t h_sess, struct wd_cipher_req *req)
fill_request_msg(msg, req, sess);
msg->tag = msg_id;
- msg->is_polled = 0;
ret = wd_cipher_setting.driver->cipher_send(ctx->ctx, msg);
if (unlikely(ret < 0)) {
diff --git a/wd_comp.c b/wd_comp.c
index 9a71dfc..1f6324c 100644
--- a/wd_comp.c
+++ b/wd_comp.c
@@ -22,8 +22,6 @@
#define HW_CTX_SIZE (64 * 1024)
#define STREAM_CHUNK (128 * 1024)
-#define POLL_SIZE 250000
-#define POLL_TIME 1000
#define swap_byte(x) \
((((x) & 0x000000ff) << 24) | \
@@ -97,16 +95,19 @@ int wd_comp_init(struct wd_ctx_config *config, struct wd_sched *sched)
return -WD_EINVAL;
}
+ ret = wd_get_epoll_en("WD_COMP_EPOLL_EN");
+ if (ret < 0)
+ return ret;
+
+ wd_comp_setting.config.epoll_en = ret;
+
ret = wd_init_ctx_config(&wd_comp_setting.config, config);
- if (ret < 0) {
- WD_ERR("failed to set config, ret = %d!\n", ret);
+ if (ret < 0)
return ret;
- }
+
ret = wd_init_sched(&wd_comp_setting.sched, sched);
- if (ret < 0) {
- WD_ERR("failed to set sched, ret = %d!\n", ret);
+ if (ret < 0)
goto out;
- }
/*
* Fix me: ctx could be passed into wd_comp_set_static_drv to help to
* choose static compiled vendor driver. For dynamic vendor driver,
@@ -125,10 +126,9 @@ int wd_comp_init(struct wd_ctx_config *config, struct wd_sched *sched)
ret = wd_init_async_request_pool(&wd_comp_setting.pool,
config->ctx_num, WD_POOL_MAX_ENTRIES,
sizeof(struct wd_comp_msg));
- if (ret < 0) {
- WD_ERR("failed to init req pool, ret = %d!\n", ret);
+ if (ret < 0)
goto out_sched;
- }
+
/* init ctx related resources in specific driver */
priv = calloc(1, wd_comp_setting.driver->drv_ctx_size);
if (!priv) {
@@ -429,7 +429,7 @@ static int wd_comp_sync_job(struct wd_comp_sess *sess,
}
do {
- if (msg->is_polled) {
+ if (config->epoll_en) {
ret = wd_ctx_wait(ctx->ctx, POLL_TIME);
if (unlikely(ret < 0))
WD_ERR("wd ctx wait timeout, ret = %d!\n", ret);
@@ -472,7 +472,6 @@ int wd_do_comp_sync(handle_t h_sess, struct wd_comp_req *req)
fill_comp_msg(sess, &msg, req);
msg.ctx_buf = sess->ctx_buf;
- msg.is_polled = (req->src_len >= POLL_SIZE);
msg.stream_mode = WD_COMP_STATELESS;
ret = wd_comp_sync_job(sess, req, &msg);
@@ -643,7 +642,6 @@ int wd_do_comp_strm(handle_t h_sess, struct wd_comp_req *req)
/* fill true flag */
msg.req.last = req->last;
msg.stream_mode = WD_COMP_STATEFUL;
- msg.is_polled = (req->src_len >= POLL_SIZE);
src_len = req->src_len;
@@ -701,7 +699,6 @@ int wd_do_comp_async(handle_t h_sess, struct wd_comp_req *req)
fill_comp_msg(sess, msg, req);
msg->tag = tag;
msg->stream_mode = WD_COMP_STATELESS;
- msg->is_polled = 0;
pthread_spin_lock(&ctx->lock);
diff --git a/wd_dh.c b/wd_dh.c
index c0d3e00..b9dd075 100644
--- a/wd_dh.c
+++ b/wd_dh.c
@@ -101,17 +101,19 @@ int wd_dh_init(struct wd_ctx_config *config, struct wd_sched *sched)
if (param_check(config, sched))
return -WD_EINVAL;
+ ret = wd_get_epoll_en("WD_DH_EPOLL_EN");
+ if (ret < 0)
+ return ret;
+
+ wd_dh_setting.config.epoll_en = ret;
+
ret = wd_init_ctx_config(&wd_dh_setting.config, config);
- if (ret) {
- WD_ERR("failed to initialize ctx config, ret = %d!\n", ret);
+ if (ret)
return ret;
- }
ret = wd_init_sched(&wd_dh_setting.sched, sched);
- if (ret) {
- WD_ERR("failed to initialize sched, ret = %d!\n", ret);
+ if (ret)
goto out;
- }
#ifdef WD_STATIC_DRV
wd_dh_set_static_drv();
@@ -121,10 +123,8 @@ int wd_dh_init(struct wd_ctx_config *config, struct wd_sched *sched)
ret = wd_init_async_request_pool(&wd_dh_setting.pool,
config->ctx_num, WD_POOL_MAX_ENTRIES,
sizeof(struct wd_dh_msg));
- if (ret) {
- WD_ERR("failed to initialize async req pool, ret = %d!\n", ret);
+ if (ret)
goto out_sched;
- }
/* initialize ctx related resources in specific driver */
priv = calloc(1, wd_dh_setting.driver->drv_ctx_size);
@@ -236,6 +236,12 @@ static int dh_recv_sync(handle_t ctx, struct wd_dh_msg *msg)
int ret;
do {
+ if (wd_dh_setting.config.epoll_en) {
+ ret = wd_ctx_wait(ctx, POLL_TIME);
+ if (ret < 0)
+ WD_ERR("wd ctx wait timeout(%d)!\n", ret);
+ }
+
ret = wd_dh_setting.driver->recv(ctx, msg);
if (ret == -WD_EAGAIN) {
if (rx_cnt++ >= DH_RECV_MAX_CNT) {
diff --git a/wd_digest.c b/wd_digest.c
index 0ddc074..44b86c4 100644
--- a/wd_digest.c
+++ b/wd_digest.c
@@ -19,8 +19,6 @@
#define DES_WEAK_KEY_NUM 4
#define MAX_RETRY_COUNTS 200000000
-#define POLL_SIZE 100000
-#define POLL_TIME 1000
static int g_digest_mac_len[WD_DIGEST_TYPE_MAX] = {
WD_DIGEST_SM3_LEN, WD_DIGEST_MD5_LEN, WD_DIGEST_SHA1_LEN,
@@ -28,6 +26,7 @@ static int g_digest_mac_len[WD_DIGEST_TYPE_MAX] = {
WD_DIGEST_SHA384_LEN, WD_DIGEST_SHA512_LEN,
WD_DIGEST_SHA512_224_LEN, WD_DIGEST_SHA512_256_LEN
};
+
struct wd_digest_setting {
struct wd_ctx_config_internal config;
struct wd_sched sched;
@@ -175,17 +174,19 @@ int wd_digest_init(struct wd_ctx_config *config, struct wd_sched *sched)
if (ret)
return ret;
+ ret = wd_get_epoll_en("WD_DIGEST_EPOLL_EN");
+ if (ret < 0)
+ return ret;
+
+ wd_digest_setting.config.epoll_en = ret;
+
ret = wd_init_ctx_config(&wd_digest_setting.config, config);
- if (ret < 0) {
- WD_ERR("failed to set config, ret = %d!\n", ret);
+ if (ret < 0)
return ret;
- }
ret = wd_init_sched(&wd_digest_setting.sched, sched);
- if (ret < 0) {
- WD_ERR("failed to set sched, ret = %d!\n", ret);
+ if (ret < 0)
goto out;
- }
/* set driver */
#ifdef WD_STATIC_DRV
@@ -196,10 +197,8 @@ int wd_digest_init(struct wd_ctx_config *config, struct wd_sched *sched)
ret = wd_init_async_request_pool(&wd_digest_setting.pool,
config->ctx_num, WD_POOL_MAX_ENTRIES,
sizeof(struct wd_digest_msg));
- if (ret < 0) {
- WD_ERR("failed to init req pool, ret = %d!\n", ret);
+ if (ret < 0)
goto out_sched;
- }
/* init ctx related resources in specific driver */
priv = calloc(1, wd_digest_setting.driver->drv_ctx_size);
@@ -322,7 +321,7 @@ static int send_recv_sync(struct wd_ctx_internal *ctx, struct wd_digest_sess *ds
}
do {
- if (msg->is_polled) {
+ if (wd_digest_setting.config.epoll_en) {
ret = wd_ctx_wait(ctx->ctx, POLL_TIME);
if (unlikely(ret < 0))
WD_ERR("wd digest ctx wait timeout(%d)!\n", ret);
@@ -367,7 +366,6 @@ int wd_do_digest_sync(handle_t h_sess, struct wd_digest_req *req)
memset(&msg, 0, sizeof(struct wd_digest_msg));
fill_request_msg(&msg, req, dsess);
- msg.is_polled = (req->in_bytes >= POLL_SIZE);
req->state = 0;
idx = wd_digest_setting.sched.pick_next_ctx(
@@ -420,7 +418,6 @@ int wd_do_digest_async(handle_t h_sess, struct wd_digest_req *req)
fill_request_msg(msg, req, dsess);
msg->tag = msg_id;
- msg->is_polled = 0;
ret = wd_digest_setting.driver->digest_send(ctx->ctx, msg);
if (unlikely(ret < 0)) {
diff --git a/wd_ecc.c b/wd_ecc.c
index af62b9a..bebe2e5 100644
--- a/wd_ecc.c
+++ b/wd_ecc.c
@@ -155,17 +155,19 @@ int wd_ecc_init(struct wd_ctx_config *config, struct wd_sched *sched)
if (init_param_check(config, sched))
return -WD_EINVAL;
+ ret = wd_get_epoll_en("WD_ECC_EPOLL_EN");
+ if (ret < 0)
+ return ret;
+
+ wd_ecc_setting.config.epoll_en = ret;
+
ret = wd_init_ctx_config(&wd_ecc_setting.config, config);
- if (ret < 0) {
- WD_ERR("failed to set config, ret = %d!\n", ret);
+ if (ret < 0)
return ret;
- }
ret = wd_init_sched(&wd_ecc_setting.sched, sched);
- if (ret < 0) {
- WD_ERR("failed to set sched, ret = %d!\n", ret);
+ if (ret < 0)
goto out;
- }
#ifdef WD_STATIC_DRV
wd_ecc_set_static_drv();
@@ -175,10 +177,8 @@ int wd_ecc_init(struct wd_ctx_config *config, struct wd_sched *sched)
ret = wd_init_async_request_pool(&wd_ecc_setting.pool,
config->ctx_num, WD_POOL_MAX_ENTRIES,
sizeof(struct wd_ecc_msg));
- if (ret < 0) {
- WD_ERR("failed to initialize async req pool, ret = %d!\n", ret);
+ if (ret < 0)
goto out_sched;
- }
/* initialize ctx related resources in specific driver */
priv = calloc(1, wd_ecc_setting.driver->drv_ctx_size);
@@ -1413,6 +1413,12 @@ static int ecc_send(handle_t ctx, struct wd_ecc_msg *msg)
int ret;
do {
+ if (wd_ecc_setting.config.epoll_en) {
+ ret = wd_ctx_wait(ctx, POLL_TIME);
+ if (ret < 0)
+ WD_ERR("wd ctx wait timeout(%d)!\n", ret);
+ }
+
ret = wd_ecc_setting.driver->send(ctx, msg);
if (ret == -WD_EBUSY) {
if (tx_cnt++ >= ECC_RESEND_CNT) {
diff --git a/wd_rsa.c b/wd_rsa.c
index 8371475..1eec345 100644
--- a/wd_rsa.c
+++ b/wd_rsa.c
@@ -141,17 +141,19 @@ int wd_rsa_init(struct wd_ctx_config *config, struct wd_sched *sched)
if (param_check(config, sched))
return -WD_EINVAL;
+ ret = wd_get_epoll_en("WD_RSA_EPOLL_EN");
+ if (ret < 0)
+ return ret;
+
+ wd_rsa_setting.config.epoll_en = ret;
+
ret = wd_init_ctx_config(&wd_rsa_setting.config, config);
- if (ret < 0) {
- WD_ERR("failed to set config, ret = %d!\n", ret);
+ if (ret < 0)
return ret;
- }
ret = wd_init_sched(&wd_rsa_setting.sched, sched);
- if (ret < 0) {
- WD_ERR("failed to set sched, ret = %d!\n", ret);
+ if (ret < 0)
goto out;
- }
#ifdef WD_STATIC_DRV
wd_rsa_set_static_drv();
@@ -161,10 +163,8 @@ int wd_rsa_init(struct wd_ctx_config *config, struct wd_sched *sched)
ret = wd_init_async_request_pool(&wd_rsa_setting.pool,
config->ctx_num, WD_POOL_MAX_ENTRIES,
sizeof(struct wd_rsa_msg));
- if (ret < 0) {
- WD_ERR("failed to initialize async req pool, ret = %d!\n", ret);
+ if (ret < 0)
goto out_sched;
- }
/* initialize ctx related resources in specific driver */
priv = calloc(1, wd_rsa_setting.driver->drv_ctx_size);
@@ -296,6 +296,12 @@ static int rsa_recv_sync(handle_t ctx, struct wd_rsa_msg *msg)
int ret;
do {
+ if (wd_rsa_setting.config.epoll_en) {
+ ret = wd_ctx_wait(ctx, POLL_TIME);
+ if (ret < 0)
+ WD_ERR("wd ctx wait timeout(%d)!\n", ret);
+ }
+
ret = wd_rsa_setting.driver->recv(ctx, msg);
if (ret == -WD_EAGAIN) {
if (rx_cnt++ >= RSA_RECV_MAX_CNT) {
diff --git a/wd_sched.c b/wd_sched.c
index 9b1998c..dfd390b 100644
--- a/wd_sched.c
+++ b/wd_sched.c
@@ -213,7 +213,7 @@ static int session_sched_poll_policy(handle_t sched_ctx,
}
if (ctx->numa_num > NUMA_NUM_NODES) {
- WD_ERR("invalid: ctx's numa number is %d!\n", ctx->numa_num);
+ WD_ERR("invalid: ctx's numa number is %u!\n", ctx->numa_num);
return -WD_EINVAL;
}
diff --git a/wd_util.c b/wd_util.c
index 0638893..11d436d 100644
--- a/wd_util.c
+++ b/wd_util.c
@@ -85,8 +85,10 @@ int wd_init_ctx_config(struct wd_ctx_config_internal *in,
}
ctxs = calloc(1, cfg->ctx_num * sizeof(struct wd_ctx_internal));
- if (!ctxs)
+ if (!ctxs) {
+ WD_ERR("failed to alloc memory for internal ctxs!\n");
return -WD_ENOMEM;
+ }
for (i = 0; i < cfg->ctx_num; i++) {
if (!cfg->ctxs[i].ctx) {
@@ -115,8 +117,10 @@ int wd_init_ctx_config(struct wd_ctx_config_internal *in,
int wd_init_sched(struct wd_sched *in, struct wd_sched *from)
{
if (!from->name || !from->sched_init ||
- !from->pick_next_ctx || !from->poll_policy)
+ !from->pick_next_ctx || !from->poll_policy) {
+ WD_ERR("invalid: member of wd_sched is NULL!\n");
return -WD_EINVAL;
+ }
in->h_sched_ctx = from->h_sched_ctx;
in->name = strdup(from->name);
@@ -170,13 +174,16 @@ void wd_memset_zero(void *data, __u32 size)
static int init_msg_pool(struct msg_pool *pool, __u32 msg_num, __u32 msg_size)
{
pool->msgs = calloc(1, msg_num * msg_size);
- if (!pool->msgs)
+ if (!pool->msgs) {
+ WD_ERR("failed to alloc memory for msgs arrary of msg pool!\n");
return -WD_ENOMEM;
+ }
pool->used = calloc(1, msg_num * sizeof(int));
if (!pool->used) {
free(pool->msgs);
pool->msgs = NULL;
+ WD_ERR("failed to alloc memory for used arrary of msg pool!\n");
return -WD_ENOMEM;
}
@@ -204,8 +211,10 @@ int wd_init_async_request_pool(struct wd_async_msg_pool *pool, __u32 pool_num,
pool->pool_num = pool_num;
pool->pools = calloc(1, pool->pool_num * sizeof(struct msg_pool));
- if (!pool->pools)
+ if (!pool->pools) {
+ WD_ERR("failed to alloc memory for async msg pools!\n");
return -WD_ENOMEM;
+ }
for (i = 0; i < pool->pool_num; i++) {
ret = init_msg_pool(&pool->pools[i], msg_num, msg_size);
@@ -510,27 +519,33 @@ static int is_number(const char *str)
return 1;
}
-/* 1 enable, 0 disable, others error */
-int wd_parse_async_poll_en(struct wd_env_config *config, const char *s)
+static int str_to_bool(const char *s, bool *target)
{
int tmp;
- if (!is_number(s)) {
- WD_ERR("invalid: async poll en flag is %s!\n", s);
+ if (!is_number(s))
return -WD_EINVAL;
- }
tmp = strtol(s, NULL, 10);
- if (tmp != 0 && tmp != 1) {
- WD_ERR("invalid: async poll en flag is not 0 or 1!\n");
+ if (tmp != 0 && tmp != 1)
return -WD_EINVAL;
- }
- config->enable_internal_poll = tmp;
+ *target = tmp;
return 0;
}
+int wd_parse_async_poll_en(struct wd_env_config *config, const char *s)
+{
+ int ret;
+
+ ret = str_to_bool(s, &config->enable_internal_poll);
+ if (ret)
+ WD_ERR("parse async poll enable flag(%s) failed!\n", s);
+
+ return ret;
+}
+
static int parse_num_on_numa(const char *s, int *num, int *node)
{
char *sep, *start, *left;
@@ -1588,3 +1603,22 @@ int wd_check_ctx(struct wd_ctx_config_internal *config, __u8 mode, __u32 idx)
return 0;
}
+
+int wd_get_epoll_en(const char *var_name)
+{
+ bool epoll_en = false;
+ const char *s;
+ int ret;
+
+ s = secure_getenv(var_name);
+ if (!s || !strlen(s))
+ return 0;
+
+ ret = str_to_bool(s, &epoll_en);
+ if (ret) {
+ WD_ERR("failed to parse %s environment variable!\n", var_name);
+ return ret;
+ }
+
+ return epoll_en;
+}
--
2.24.0
1
0
From: Wenkai Lin <linwenkai6(a)hisilicon.com>
wd_parse_epoll_en is used to parse epoll enable flag
from environment variable, it's return value is stored
in global variable of each process.
When uadk works in synchronize mode, it will check the
global variable and decide whether to use wd_ctx_wait.
HPRE algorithm(ecc, rsa, dh) is also support epoll wait now.
Signed-off-by: Wenkai Lin <linwenkai6(a)hisilicon.com>
---
docs/wd_environment_variable | 5 +++
drv/hisi_comp.c | 5 +--
drv/hisi_hpre.c | 3 ++
drv/hisi_qm_udrv.c | 21 ++-----------
drv/hisi_sec.c | 15 ++-------
include/drv/wd_aead_drv.h | 2 --
include/drv/wd_cipher_drv.h | 2 --
include/drv/wd_comp_drv.h | 2 --
include/drv/wd_digest_drv.h | 2 --
include/hisi_qm_udrv.h | 4 +--
include/wd_alg_common.h | 2 ++
include/wd_util.h | 9 ++++++
wd_aead.c | 24 ++++++---------
wd_cipher.c | 24 ++++++---------
wd_comp.c | 27 ++++++++--------
wd_dh.c | 24 +++++++++------
wd_digest.c | 25 +++++++--------
wd_ecc.c | 24 +++++++++------
wd_rsa.c | 24 +++++++++------
wd_sched.c | 2 +-
wd_util.c | 60 ++++++++++++++++++++++++++++--------
21 files changed, 165 insertions(+), 141 deletions(-)
diff --git a/docs/wd_environment_variable b/docs/wd_environment_variable
index 3ada5fb..8ac2da7 100644
--- a/docs/wd_environment_variable
+++ b/docs/wd_environment_variable
@@ -47,6 +47,11 @@ WD_<alg>_ASYNC_POLL_NUM
WD_<alg>_ASYNC_POLL_NUM=2@0,4@2 means to configure 2 async polling threads in
node0, and 4 polling threads in node2.
+WD_<alg>_EPOLL_EN
+ Define if wd_do_<alg>_sync enable wd_ctx_wait in WD. WD_<alg>_EPOLL_EN=1
+ means enable wd_ctx_wait in WD, driver will wait to receive the package until
+ hardware is done with package, otherwise driver will try to receive the package
+ directly after the package is sent.
2. User model
=============
diff --git a/drv/hisi_comp.c b/drv/hisi_comp.c
index 841ae03..43c8688 100644
--- a/drv/hisi_comp.c
+++ b/drv/hisi_comp.c
@@ -779,6 +779,9 @@ static int hisi_zip_init(struct wd_ctx_config_internal *config, void *priv)
qm_priv.sqe_size = sizeof(struct hisi_zip_sqe);
qm_priv.op_type = config->ctxs[i].op_type;
qm_priv.qp_mode = config->ctxs[i].ctx_mode;
+ /* Setting the epoll en to 0 for ASYNC ctx */
+ qm_priv.epoll_en = (qm_priv.qp_mode == CTX_MODE_SYNC) ?
+ config->epoll_en : 0;
qm_priv.idx = i;
h_qp = hisi_qm_alloc_qp(&qm_priv, h_ctx);
if (unlikely(!h_qp))
@@ -882,8 +885,6 @@ static int hisi_zip_comp_send(handle_t ctx, struct wd_comp_msg *msg, void *priv)
return ret;
}
- hisi_qm_enable_interrupt(ctx, msg->is_polled);
-
return 0;
}
diff --git a/drv/hisi_hpre.c b/drv/hisi_hpre.c
index 018fe5b..f0ec540 100644
--- a/drv/hisi_hpre.c
+++ b/drv/hisi_hpre.c
@@ -465,6 +465,9 @@ static int hpre_init(struct wd_ctx_config_internal *config, void *priv, const ch
for (i = 0; i < config->ctx_num; i++) {
h_ctx = config->ctxs[i].ctx;
qm_priv.qp_mode = config->ctxs[i].ctx_mode;
+ /* Setting the epoll en to 0 for ASYNC ctx */
+ qm_priv.epoll_en = (qm_priv.qp_mode == CTX_MODE_SYNC) ?
+ config->epoll_en : 0;
qm_priv.idx = i;
h_qp = hisi_qm_alloc_qp(&qm_priv, h_ctx);
if (!h_qp) {
diff --git a/drv/hisi_qm_udrv.c b/drv/hisi_qm_udrv.c
index be06570..2c0d87c 100644
--- a/drv/hisi_qm_udrv.c
+++ b/drv/hisi_qm_udrv.c
@@ -309,6 +309,7 @@ static int hisi_qm_setup_info(struct hisi_qp *qp, struct hisi_qm_priv *config)
}
q_info->qp_mode = config->qp_mode;
+ q_info->epoll_en = config->epoll_en;
q_info->idx = config->idx;
q_info->sqe_size = config->sqe_size;
q_info->cqc_phase = 1;
@@ -479,7 +480,7 @@ static int hisi_qm_recv_single(struct hisi_qm_queue_info *q_info, void *resp)
i++;
}
- q_info->db(q_info, QM_DBELL_CMD_CQ, i, 0);
+ q_info->db(q_info, QM_DBELL_CMD_CQ, i, q_info->epoll_en);
/* only support one thread poll one queue, so no need protect */
q_info->cq_head_index = i;
@@ -919,21 +920,3 @@ __u32 hisi_qm_get_list_size(struct wd_datalist *start_node,
return lits_size;
}
-
-void hisi_qm_enable_interrupt(handle_t ctx, __u8 enable)
-{
- struct hisi_qm_queue_info *q_info;
- struct hisi_qp *qp;
- handle_t h_qp;
-
- if (!enable)
- return;
-
- h_qp = (handle_t)wd_ctx_get_priv(ctx);
- qp = (struct hisi_qp *)h_qp;
- q_info = &qp->q_info;
-
- pthread_spin_lock(&q_info->lock);
- q_info->db(q_info, QM_DBELL_CMD_CQ, q_info->cq_head_index, 1);
- pthread_spin_unlock(&q_info->lock);
-}
diff --git a/drv/hisi_sec.c b/drv/hisi_sec.c
index aa86a6b..0732cdc 100644
--- a/drv/hisi_sec.c
+++ b/drv/hisi_sec.c
@@ -959,8 +959,6 @@ int hisi_sec_cipher_send(handle_t ctx, struct wd_cipher_msg *msg)
return ret;
}
- hisi_qm_enable_interrupt(ctx, msg->is_polled);
-
return 0;
}
@@ -1162,8 +1160,6 @@ int hisi_sec_cipher_send_v3(handle_t ctx, struct wd_cipher_msg *msg)
return ret;
}
- hisi_qm_enable_interrupt(ctx, msg->is_polled);
-
return 0;
}
@@ -1403,8 +1399,6 @@ int hisi_sec_digest_send(handle_t ctx, struct wd_digest_msg *msg)
goto put_sgl;
}
- hisi_qm_enable_interrupt(ctx, msg->is_polled);
-
return 0;
put_sgl:
@@ -1560,8 +1554,6 @@ int hisi_sec_digest_send_v3(handle_t ctx, struct wd_digest_msg *msg)
goto put_sgl;
}
- hisi_qm_enable_interrupt(ctx, msg->is_polled);
-
return 0;
put_sgl:
@@ -1913,8 +1905,6 @@ int hisi_sec_aead_send(handle_t ctx, struct wd_aead_msg *msg)
return ret;
}
- hisi_qm_enable_interrupt(ctx, msg->is_polled);
-
return 0;
}
@@ -2181,8 +2171,6 @@ int hisi_sec_aead_send_v3(handle_t ctx, struct wd_aead_msg *msg)
return ret;
}
- hisi_qm_enable_interrupt(ctx, msg->is_polled);
-
return 0;
}
@@ -2285,6 +2273,9 @@ int hisi_sec_init(struct wd_ctx_config_internal *config, void *priv)
/* setting the type is 0 for sqc_type */
qm_priv.op_type = 0;
qm_priv.qp_mode = config->ctxs[i].ctx_mode;
+ /* Setting the epoll en to 0 for ASYNC ctx */
+ qm_priv.epoll_en = (qm_priv.qp_mode == CTX_MODE_SYNC) ?
+ config->epoll_en : 0;
qm_priv.idx = i;
h_qp = hisi_qm_alloc_qp(&qm_priv, h_ctx);
if (!h_qp)
diff --git a/include/drv/wd_aead_drv.h b/include/drv/wd_aead_drv.h
index 78a5673..137e70a 100644
--- a/include/drv/wd_aead_drv.h
+++ b/include/drv/wd_aead_drv.h
@@ -31,8 +31,6 @@ struct wd_aead_msg {
__u8 data_fmt;
/* Operation result, denoted by WD error code */
__u8 result;
- /* epoll flag */
- __u8 is_polled;
/* in bytes */
__u32 in_bytes;
diff --git a/include/drv/wd_cipher_drv.h b/include/drv/wd_cipher_drv.h
index e649869..87b77d3 100644
--- a/include/drv/wd_cipher_drv.h
+++ b/include/drv/wd_cipher_drv.h
@@ -28,8 +28,6 @@ struct wd_cipher_msg {
__u8 data_fmt;
/* Operation result, denoted by WD error code */
__u8 result;
- /* epoll flag */
- __u8 is_polled;
/* Key bytes */
__u16 key_bytes;
diff --git a/include/drv/wd_comp_drv.h b/include/drv/wd_comp_drv.h
index 8146a50..73403b5 100644
--- a/include/drv/wd_comp_drv.h
+++ b/include/drv/wd_comp_drv.h
@@ -50,8 +50,6 @@ struct wd_comp_msg {
__u32 checksum;
/* Request identifier */
__u32 tag;
- /* Epoll flag */
- __u8 is_polled;
};
struct wd_comp_driver {
diff --git a/include/drv/wd_digest_drv.h b/include/drv/wd_digest_drv.h
index fdde772..6907bc5 100644
--- a/include/drv/wd_digest_drv.h
+++ b/include/drv/wd_digest_drv.h
@@ -27,8 +27,6 @@ struct wd_digest_msg {
__u8 data_fmt;
/* Operation result, denoted by WD error code */
__u8 result;
- /* epoll flag */
- __u8 is_polled;
/* user identifier: struct wcrypto_cb_tag */
__u64 usr_data;
diff --git a/include/hisi_qm_udrv.h b/include/hisi_qm_udrv.h
index 707d0e3..43f42d9 100644
--- a/include/hisi_qm_udrv.h
+++ b/include/hisi_qm_udrv.h
@@ -47,6 +47,7 @@ struct hisi_qm_priv {
__u16 op_type;
/* index of ctxs */
__u32 idx;
+ int epoll_en;
};
struct hisi_qm_queue_info {
@@ -71,6 +72,7 @@ struct hisi_qm_queue_info {
bool cqc_phase;
pthread_spinlock_t lock;
unsigned long region_size[UACCE_QFRT_MAX];
+ int epoll_en;
};
struct hisi_qp {
@@ -182,8 +184,6 @@ int hisi_qm_get_free_sqe_num(handle_t h_qp);
__u32 hisi_qm_get_list_size(struct wd_datalist *start_node,
struct wd_datalist *end_node);
-void hisi_qm_enable_interrupt(handle_t ctx, __u8 enable);
-
#ifdef __cplusplus
}
#endif
diff --git a/include/wd_alg_common.h b/include/wd_alg_common.h
index 94336f0..0affa96 100644
--- a/include/wd_alg_common.h
+++ b/include/wd_alg_common.h
@@ -27,6 +27,7 @@ extern "C" {
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#define MAX_STR_LEN 256
#define CTX_TYPE_INVALID 9999
+#define POLL_TIME 1000
enum wd_ctx_mode {
CTX_MODE_SYNC = 0,
@@ -74,6 +75,7 @@ struct wd_ctx_config_internal {
struct wd_ctx_internal *ctxs;
void *priv;
int pid;
+ int epoll_en;
};
/**
diff --git a/include/wd_util.h b/include/wd_util.h
index 2d3c1e4..73ba96a 100644
--- a/include/wd_util.h
+++ b/include/wd_util.h
@@ -314,6 +314,15 @@ int wd_set_ctx_attr(struct wd_ctx_attr *ctx_attr,
*/
int wd_check_ctx(struct wd_ctx_config_internal *config, __u8 mode, __u32 idx);
+/**
+ * wd_get_epoll_en() - Get epoll enable value from environment variable.
+ * @var_name: Environment variable name string.
+ *
+ * Return environment variable value, if the value is not 0 or 1,
+ * return -WD_EINVAL instead.
+ */
+int wd_get_epoll_en(const char *var_name);
+
#ifdef __cplusplus
}
#endif
diff --git a/wd_aead.c b/wd_aead.c
index 74047b5..f1bde0a 100644
--- a/wd_aead.c
+++ b/wd_aead.c
@@ -21,8 +21,6 @@
#define WD_POOL_MAX_ENTRIES 1024
#define MAX_RETRY_COUNTS 200000000
-#define POLL_SIZE 70000
-#define POLL_TIME 1000
static int g_aead_mac_len[WD_DIGEST_TYPE_MAX] = {
WD_DIGEST_SM3_LEN, WD_DIGEST_MD5_LEN, WD_DIGEST_SHA1_LEN,
@@ -414,17 +412,19 @@ int wd_aead_init(struct wd_ctx_config *config, struct wd_sched *sched)
if (ret)
return ret;
+ ret = wd_get_epoll_en("WD_AEAD_EPOLL_EN");
+ if (ret < 0)
+ return ret;
+
+ wd_aead_setting.config.epoll_en = ret;
+
ret = wd_init_ctx_config(&wd_aead_setting.config, config);
- if (ret) {
- WD_ERR("failed to set config, ret = %d\n", ret);
+ if (ret)
return ret;
- }
ret = wd_init_sched(&wd_aead_setting.sched, sched);
- if (ret < 0) {
- WD_ERR("failed to set sched, ret = %d\n", ret);
+ if (ret < 0)
goto out;
- }
/* set driver */
#ifdef WD_STATIC_DRV
@@ -435,10 +435,8 @@ int wd_aead_init(struct wd_ctx_config *config, struct wd_sched *sched)
ret = wd_init_async_request_pool(&wd_aead_setting.pool,
config->ctx_num, WD_POOL_MAX_ENTRIES,
sizeof(struct wd_aead_msg));
- if (ret < 0) {
- WD_ERR("failed to init aead aysnc request pool.\n");
+ if (ret < 0)
goto out_sched;
- }
/* init ctx related resources in specific driver */
priv = calloc(1, wd_aead_setting.driver->drv_ctx_size);
@@ -525,7 +523,7 @@ static int send_recv_sync(struct wd_ctx_internal *ctx,
}
do {
- if (msg->is_polled) {
+ if (wd_aead_setting.config.epoll_en) {
ret = wd_ctx_wait(ctx->ctx, POLL_TIME);
if (unlikely(ret < 0))
WD_ERR("wd aead ctx wait timeout(%d)!\n", ret);
@@ -563,7 +561,6 @@ int wd_do_aead_sync(handle_t h_sess, struct wd_aead_req *req)
memset(&msg, 0, sizeof(struct wd_aead_msg));
fill_request_msg(&msg, req, sess);
- msg.is_polled = (req->in_bytes >= POLL_SIZE);
req->state = 0;
idx = wd_aead_setting.sched.pick_next_ctx(
@@ -616,7 +613,6 @@ int wd_do_aead_async(handle_t h_sess, struct wd_aead_req *req)
fill_request_msg(msg, req, sess);
msg->tag = msg_id;
- msg->is_polled = 0;
ret = wd_aead_setting.driver->aead_send(ctx->ctx, msg);
if (unlikely(ret < 0)) {
diff --git a/wd_cipher.c b/wd_cipher.c
index 563eece..9b7b150 100644
--- a/wd_cipher.c
+++ b/wd_cipher.c
@@ -22,8 +22,6 @@
#define DES_WEAK_KEY_NUM 16
#define MAX_RETRY_COUNTS 200000000
-#define POLL_SIZE 100000
-#define POLL_TIME 1000
static const unsigned char des_weak_keys[DES_WEAK_KEY_NUM][DES_KEY_SIZE] = {
/* weak keys */
@@ -255,17 +253,19 @@ int wd_cipher_init(struct wd_ctx_config *config, struct wd_sched *sched)
if (ret)
return ret;
+ ret = wd_get_epoll_en("WD_CIPHER_EPOLL_EN");
+ if (ret < 0)
+ return ret;
+
+ wd_cipher_setting.config.epoll_en = ret;
+
ret = wd_init_ctx_config(&wd_cipher_setting.config, config);
- if (ret < 0) {
- WD_ERR("failed to set config, ret = %d!\n", ret);
+ if (ret < 0)
return ret;
- }
ret = wd_init_sched(&wd_cipher_setting.sched, sched);
- if (ret < 0) {
- WD_ERR("failed to set sched, ret = %d!\n", ret);
+ if (ret < 0)
goto out;
- }
#ifdef WD_STATIC_DRV
/* set driver */
@@ -276,10 +276,8 @@ int wd_cipher_init(struct wd_ctx_config *config, struct wd_sched *sched)
ret = wd_init_async_request_pool(&wd_cipher_setting.pool,
config->ctx_num, WD_POOL_MAX_ENTRIES,
sizeof(struct wd_cipher_msg));
- if (ret < 0) {
- WD_ERR("failed to init req pool, ret = %d!\n", ret);
+ if (ret < 0)
goto out_sched;
- }
/* init ctx related resources in specific driver */
priv = calloc(1, wd_cipher_setting.driver->drv_ctx_size);
@@ -436,7 +434,7 @@ static int send_recv_sync(struct wd_ctx_internal *ctx,
}
do {
- if (msg->is_polled) {
+ if (wd_cipher_setting.config.epoll_en) {
ret = wd_ctx_wait(ctx->ctx, POLL_TIME);
if (unlikely(ret < 0))
WD_ERR("wd cipher ctx wait timeout(%d)!\n", ret);
@@ -476,7 +474,6 @@ int wd_do_cipher_sync(handle_t h_sess, struct wd_cipher_req *req)
memset(&msg, 0, sizeof(struct wd_cipher_msg));
fill_request_msg(&msg, req, sess);
- msg.is_polled = (req->in_bytes >= POLL_SIZE);
req->state = 0;
idx = wd_cipher_setting.sched.pick_next_ctx(
@@ -526,7 +523,6 @@ int wd_do_cipher_async(handle_t h_sess, struct wd_cipher_req *req)
fill_request_msg(msg, req, sess);
msg->tag = msg_id;
- msg->is_polled = 0;
ret = wd_cipher_setting.driver->cipher_send(ctx->ctx, msg);
if (unlikely(ret < 0)) {
diff --git a/wd_comp.c b/wd_comp.c
index 9a71dfc..1f6324c 100644
--- a/wd_comp.c
+++ b/wd_comp.c
@@ -22,8 +22,6 @@
#define HW_CTX_SIZE (64 * 1024)
#define STREAM_CHUNK (128 * 1024)
-#define POLL_SIZE 250000
-#define POLL_TIME 1000
#define swap_byte(x) \
((((x) & 0x000000ff) << 24) | \
@@ -97,16 +95,19 @@ int wd_comp_init(struct wd_ctx_config *config, struct wd_sched *sched)
return -WD_EINVAL;
}
+ ret = wd_get_epoll_en("WD_COMP_EPOLL_EN");
+ if (ret < 0)
+ return ret;
+
+ wd_comp_setting.config.epoll_en = ret;
+
ret = wd_init_ctx_config(&wd_comp_setting.config, config);
- if (ret < 0) {
- WD_ERR("failed to set config, ret = %d!\n", ret);
+ if (ret < 0)
return ret;
- }
+
ret = wd_init_sched(&wd_comp_setting.sched, sched);
- if (ret < 0) {
- WD_ERR("failed to set sched, ret = %d!\n", ret);
+ if (ret < 0)
goto out;
- }
/*
* Fix me: ctx could be passed into wd_comp_set_static_drv to help to
* choose static compiled vendor driver. For dynamic vendor driver,
@@ -125,10 +126,9 @@ int wd_comp_init(struct wd_ctx_config *config, struct wd_sched *sched)
ret = wd_init_async_request_pool(&wd_comp_setting.pool,
config->ctx_num, WD_POOL_MAX_ENTRIES,
sizeof(struct wd_comp_msg));
- if (ret < 0) {
- WD_ERR("failed to init req pool, ret = %d!\n", ret);
+ if (ret < 0)
goto out_sched;
- }
+
/* init ctx related resources in specific driver */
priv = calloc(1, wd_comp_setting.driver->drv_ctx_size);
if (!priv) {
@@ -429,7 +429,7 @@ static int wd_comp_sync_job(struct wd_comp_sess *sess,
}
do {
- if (msg->is_polled) {
+ if (config->epoll_en) {
ret = wd_ctx_wait(ctx->ctx, POLL_TIME);
if (unlikely(ret < 0))
WD_ERR("wd ctx wait timeout, ret = %d!\n", ret);
@@ -472,7 +472,6 @@ int wd_do_comp_sync(handle_t h_sess, struct wd_comp_req *req)
fill_comp_msg(sess, &msg, req);
msg.ctx_buf = sess->ctx_buf;
- msg.is_polled = (req->src_len >= POLL_SIZE);
msg.stream_mode = WD_COMP_STATELESS;
ret = wd_comp_sync_job(sess, req, &msg);
@@ -643,7 +642,6 @@ int wd_do_comp_strm(handle_t h_sess, struct wd_comp_req *req)
/* fill true flag */
msg.req.last = req->last;
msg.stream_mode = WD_COMP_STATEFUL;
- msg.is_polled = (req->src_len >= POLL_SIZE);
src_len = req->src_len;
@@ -701,7 +699,6 @@ int wd_do_comp_async(handle_t h_sess, struct wd_comp_req *req)
fill_comp_msg(sess, msg, req);
msg->tag = tag;
msg->stream_mode = WD_COMP_STATELESS;
- msg->is_polled = 0;
pthread_spin_lock(&ctx->lock);
diff --git a/wd_dh.c b/wd_dh.c
index c0d3e00..b9dd075 100644
--- a/wd_dh.c
+++ b/wd_dh.c
@@ -101,17 +101,19 @@ int wd_dh_init(struct wd_ctx_config *config, struct wd_sched *sched)
if (param_check(config, sched))
return -WD_EINVAL;
+ ret = wd_get_epoll_en("WD_DH_EPOLL_EN");
+ if (ret < 0)
+ return ret;
+
+ wd_dh_setting.config.epoll_en = ret;
+
ret = wd_init_ctx_config(&wd_dh_setting.config, config);
- if (ret) {
- WD_ERR("failed to initialize ctx config, ret = %d!\n", ret);
+ if (ret)
return ret;
- }
ret = wd_init_sched(&wd_dh_setting.sched, sched);
- if (ret) {
- WD_ERR("failed to initialize sched, ret = %d!\n", ret);
+ if (ret)
goto out;
- }
#ifdef WD_STATIC_DRV
wd_dh_set_static_drv();
@@ -121,10 +123,8 @@ int wd_dh_init(struct wd_ctx_config *config, struct wd_sched *sched)
ret = wd_init_async_request_pool(&wd_dh_setting.pool,
config->ctx_num, WD_POOL_MAX_ENTRIES,
sizeof(struct wd_dh_msg));
- if (ret) {
- WD_ERR("failed to initialize async req pool, ret = %d!\n", ret);
+ if (ret)
goto out_sched;
- }
/* initialize ctx related resources in specific driver */
priv = calloc(1, wd_dh_setting.driver->drv_ctx_size);
@@ -236,6 +236,12 @@ static int dh_recv_sync(handle_t ctx, struct wd_dh_msg *msg)
int ret;
do {
+ if (wd_dh_setting.config.epoll_en) {
+ ret = wd_ctx_wait(ctx, POLL_TIME);
+ if (ret < 0)
+ WD_ERR("wd ctx wait timeout(%d)!\n", ret);
+ }
+
ret = wd_dh_setting.driver->recv(ctx, msg);
if (ret == -WD_EAGAIN) {
if (rx_cnt++ >= DH_RECV_MAX_CNT) {
diff --git a/wd_digest.c b/wd_digest.c
index 0ddc074..44b86c4 100644
--- a/wd_digest.c
+++ b/wd_digest.c
@@ -19,8 +19,6 @@
#define DES_WEAK_KEY_NUM 4
#define MAX_RETRY_COUNTS 200000000
-#define POLL_SIZE 100000
-#define POLL_TIME 1000
static int g_digest_mac_len[WD_DIGEST_TYPE_MAX] = {
WD_DIGEST_SM3_LEN, WD_DIGEST_MD5_LEN, WD_DIGEST_SHA1_LEN,
@@ -28,6 +26,7 @@ static int g_digest_mac_len[WD_DIGEST_TYPE_MAX] = {
WD_DIGEST_SHA384_LEN, WD_DIGEST_SHA512_LEN,
WD_DIGEST_SHA512_224_LEN, WD_DIGEST_SHA512_256_LEN
};
+
struct wd_digest_setting {
struct wd_ctx_config_internal config;
struct wd_sched sched;
@@ -175,17 +174,19 @@ int wd_digest_init(struct wd_ctx_config *config, struct wd_sched *sched)
if (ret)
return ret;
+ ret = wd_get_epoll_en("WD_DIGEST_EPOLL_EN");
+ if (ret < 0)
+ return ret;
+
+ wd_digest_setting.config.epoll_en = ret;
+
ret = wd_init_ctx_config(&wd_digest_setting.config, config);
- if (ret < 0) {
- WD_ERR("failed to set config, ret = %d!\n", ret);
+ if (ret < 0)
return ret;
- }
ret = wd_init_sched(&wd_digest_setting.sched, sched);
- if (ret < 0) {
- WD_ERR("failed to set sched, ret = %d!\n", ret);
+ if (ret < 0)
goto out;
- }
/* set driver */
#ifdef WD_STATIC_DRV
@@ -196,10 +197,8 @@ int wd_digest_init(struct wd_ctx_config *config, struct wd_sched *sched)
ret = wd_init_async_request_pool(&wd_digest_setting.pool,
config->ctx_num, WD_POOL_MAX_ENTRIES,
sizeof(struct wd_digest_msg));
- if (ret < 0) {
- WD_ERR("failed to init req pool, ret = %d!\n", ret);
+ if (ret < 0)
goto out_sched;
- }
/* init ctx related resources in specific driver */
priv = calloc(1, wd_digest_setting.driver->drv_ctx_size);
@@ -322,7 +321,7 @@ static int send_recv_sync(struct wd_ctx_internal *ctx, struct wd_digest_sess *ds
}
do {
- if (msg->is_polled) {
+ if (wd_digest_setting.config.epoll_en) {
ret = wd_ctx_wait(ctx->ctx, POLL_TIME);
if (unlikely(ret < 0))
WD_ERR("wd digest ctx wait timeout(%d)!\n", ret);
@@ -367,7 +366,6 @@ int wd_do_digest_sync(handle_t h_sess, struct wd_digest_req *req)
memset(&msg, 0, sizeof(struct wd_digest_msg));
fill_request_msg(&msg, req, dsess);
- msg.is_polled = (req->in_bytes >= POLL_SIZE);
req->state = 0;
idx = wd_digest_setting.sched.pick_next_ctx(
@@ -420,7 +418,6 @@ int wd_do_digest_async(handle_t h_sess, struct wd_digest_req *req)
fill_request_msg(msg, req, dsess);
msg->tag = msg_id;
- msg->is_polled = 0;
ret = wd_digest_setting.driver->digest_send(ctx->ctx, msg);
if (unlikely(ret < 0)) {
diff --git a/wd_ecc.c b/wd_ecc.c
index af62b9a..bebe2e5 100644
--- a/wd_ecc.c
+++ b/wd_ecc.c
@@ -155,17 +155,19 @@ int wd_ecc_init(struct wd_ctx_config *config, struct wd_sched *sched)
if (init_param_check(config, sched))
return -WD_EINVAL;
+ ret = wd_get_epoll_en("WD_ECC_EPOLL_EN");
+ if (ret < 0)
+ return ret;
+
+ wd_ecc_setting.config.epoll_en = ret;
+
ret = wd_init_ctx_config(&wd_ecc_setting.config, config);
- if (ret < 0) {
- WD_ERR("failed to set config, ret = %d!\n", ret);
+ if (ret < 0)
return ret;
- }
ret = wd_init_sched(&wd_ecc_setting.sched, sched);
- if (ret < 0) {
- WD_ERR("failed to set sched, ret = %d!\n", ret);
+ if (ret < 0)
goto out;
- }
#ifdef WD_STATIC_DRV
wd_ecc_set_static_drv();
@@ -175,10 +177,8 @@ int wd_ecc_init(struct wd_ctx_config *config, struct wd_sched *sched)
ret = wd_init_async_request_pool(&wd_ecc_setting.pool,
config->ctx_num, WD_POOL_MAX_ENTRIES,
sizeof(struct wd_ecc_msg));
- if (ret < 0) {
- WD_ERR("failed to initialize async req pool, ret = %d!\n", ret);
+ if (ret < 0)
goto out_sched;
- }
/* initialize ctx related resources in specific driver */
priv = calloc(1, wd_ecc_setting.driver->drv_ctx_size);
@@ -1413,6 +1413,12 @@ static int ecc_send(handle_t ctx, struct wd_ecc_msg *msg)
int ret;
do {
+ if (wd_ecc_setting.config.epoll_en) {
+ ret = wd_ctx_wait(ctx, POLL_TIME);
+ if (ret < 0)
+ WD_ERR("wd ctx wait timeout(%d)!\n", ret);
+ }
+
ret = wd_ecc_setting.driver->send(ctx, msg);
if (ret == -WD_EBUSY) {
if (tx_cnt++ >= ECC_RESEND_CNT) {
diff --git a/wd_rsa.c b/wd_rsa.c
index 8371475..1eec345 100644
--- a/wd_rsa.c
+++ b/wd_rsa.c
@@ -141,17 +141,19 @@ int wd_rsa_init(struct wd_ctx_config *config, struct wd_sched *sched)
if (param_check(config, sched))
return -WD_EINVAL;
+ ret = wd_get_epoll_en("WD_RSA_EPOLL_EN");
+ if (ret < 0)
+ return ret;
+
+ wd_rsa_setting.config.epoll_en = ret;
+
ret = wd_init_ctx_config(&wd_rsa_setting.config, config);
- if (ret < 0) {
- WD_ERR("failed to set config, ret = %d!\n", ret);
+ if (ret < 0)
return ret;
- }
ret = wd_init_sched(&wd_rsa_setting.sched, sched);
- if (ret < 0) {
- WD_ERR("failed to set sched, ret = %d!\n", ret);
+ if (ret < 0)
goto out;
- }
#ifdef WD_STATIC_DRV
wd_rsa_set_static_drv();
@@ -161,10 +163,8 @@ int wd_rsa_init(struct wd_ctx_config *config, struct wd_sched *sched)
ret = wd_init_async_request_pool(&wd_rsa_setting.pool,
config->ctx_num, WD_POOL_MAX_ENTRIES,
sizeof(struct wd_rsa_msg));
- if (ret < 0) {
- WD_ERR("failed to initialize async req pool, ret = %d!\n", ret);
+ if (ret < 0)
goto out_sched;
- }
/* initialize ctx related resources in specific driver */
priv = calloc(1, wd_rsa_setting.driver->drv_ctx_size);
@@ -296,6 +296,12 @@ static int rsa_recv_sync(handle_t ctx, struct wd_rsa_msg *msg)
int ret;
do {
+ if (wd_rsa_setting.config.epoll_en) {
+ ret = wd_ctx_wait(ctx, POLL_TIME);
+ if (ret < 0)
+ WD_ERR("wd ctx wait timeout(%d)!\n", ret);
+ }
+
ret = wd_rsa_setting.driver->recv(ctx, msg);
if (ret == -WD_EAGAIN) {
if (rx_cnt++ >= RSA_RECV_MAX_CNT) {
diff --git a/wd_sched.c b/wd_sched.c
index 9b1998c..dfd390b 100644
--- a/wd_sched.c
+++ b/wd_sched.c
@@ -213,7 +213,7 @@ static int session_sched_poll_policy(handle_t sched_ctx,
}
if (ctx->numa_num > NUMA_NUM_NODES) {
- WD_ERR("invalid: ctx's numa number is %d!\n", ctx->numa_num);
+ WD_ERR("invalid: ctx's numa number is %u!\n", ctx->numa_num);
return -WD_EINVAL;
}
diff --git a/wd_util.c b/wd_util.c
index 0638893..11d436d 100644
--- a/wd_util.c
+++ b/wd_util.c
@@ -85,8 +85,10 @@ int wd_init_ctx_config(struct wd_ctx_config_internal *in,
}
ctxs = calloc(1, cfg->ctx_num * sizeof(struct wd_ctx_internal));
- if (!ctxs)
+ if (!ctxs) {
+ WD_ERR("failed to alloc memory for internal ctxs!\n");
return -WD_ENOMEM;
+ }
for (i = 0; i < cfg->ctx_num; i++) {
if (!cfg->ctxs[i].ctx) {
@@ -115,8 +117,10 @@ int wd_init_ctx_config(struct wd_ctx_config_internal *in,
int wd_init_sched(struct wd_sched *in, struct wd_sched *from)
{
if (!from->name || !from->sched_init ||
- !from->pick_next_ctx || !from->poll_policy)
+ !from->pick_next_ctx || !from->poll_policy) {
+ WD_ERR("invalid: member of wd_sched is NULL!\n");
return -WD_EINVAL;
+ }
in->h_sched_ctx = from->h_sched_ctx;
in->name = strdup(from->name);
@@ -170,13 +174,16 @@ void wd_memset_zero(void *data, __u32 size)
static int init_msg_pool(struct msg_pool *pool, __u32 msg_num, __u32 msg_size)
{
pool->msgs = calloc(1, msg_num * msg_size);
- if (!pool->msgs)
+ if (!pool->msgs) {
+ WD_ERR("failed to alloc memory for msgs arrary of msg pool!\n");
return -WD_ENOMEM;
+ }
pool->used = calloc(1, msg_num * sizeof(int));
if (!pool->used) {
free(pool->msgs);
pool->msgs = NULL;
+ WD_ERR("failed to alloc memory for used arrary of msg pool!\n");
return -WD_ENOMEM;
}
@@ -204,8 +211,10 @@ int wd_init_async_request_pool(struct wd_async_msg_pool *pool, __u32 pool_num,
pool->pool_num = pool_num;
pool->pools = calloc(1, pool->pool_num * sizeof(struct msg_pool));
- if (!pool->pools)
+ if (!pool->pools) {
+ WD_ERR("failed to alloc memory for async msg pools!\n");
return -WD_ENOMEM;
+ }
for (i = 0; i < pool->pool_num; i++) {
ret = init_msg_pool(&pool->pools[i], msg_num, msg_size);
@@ -510,27 +519,33 @@ static int is_number(const char *str)
return 1;
}
-/* 1 enable, 0 disable, others error */
-int wd_parse_async_poll_en(struct wd_env_config *config, const char *s)
+static int str_to_bool(const char *s, bool *target)
{
int tmp;
- if (!is_number(s)) {
- WD_ERR("invalid: async poll en flag is %s!\n", s);
+ if (!is_number(s))
return -WD_EINVAL;
- }
tmp = strtol(s, NULL, 10);
- if (tmp != 0 && tmp != 1) {
- WD_ERR("invalid: async poll en flag is not 0 or 1!\n");
+ if (tmp != 0 && tmp != 1)
return -WD_EINVAL;
- }
- config->enable_internal_poll = tmp;
+ *target = tmp;
return 0;
}
+int wd_parse_async_poll_en(struct wd_env_config *config, const char *s)
+{
+ int ret;
+
+ ret = str_to_bool(s, &config->enable_internal_poll);
+ if (ret)
+ WD_ERR("parse async poll enable flag(%s) failed!\n", s);
+
+ return ret;
+}
+
static int parse_num_on_numa(const char *s, int *num, int *node)
{
char *sep, *start, *left;
@@ -1588,3 +1603,22 @@ int wd_check_ctx(struct wd_ctx_config_internal *config, __u8 mode, __u32 idx)
return 0;
}
+
+int wd_get_epoll_en(const char *var_name)
+{
+ bool epoll_en = false;
+ const char *s;
+ int ret;
+
+ s = secure_getenv(var_name);
+ if (!s || !strlen(s))
+ return 0;
+
+ ret = str_to_bool(s, &epoll_en);
+ if (ret) {
+ WD_ERR("failed to parse %s environment variable!\n", var_name);
+ return ret;
+ }
+
+ return epoll_en;
+}
--
2.24.0
1
0

Fwd: [PATCH v4 00/32] KVM: s390: enable zPCI for interpretive execution
by zhangfei.gao@foxmail.com 16 Mar '22
by zhangfei.gao@foxmail.com 16 Mar '22
16 Mar '22
-------- Forwarded Message --------
Subject: [PATCH v4 00/32] KVM: s390: enable zPCI for interpretive
execution
Date: Mon, 14 Mar 2022 15:44:19 -0400
From: Matthew Rosato <mjrosato(a)linux.ibm.com>
To: linux-s390(a)vger.kernel.org
CC: kvm(a)vger.kernel.org, david(a)redhat.com, thuth(a)redhat.com,
linux-kernel(a)vger.kernel.org, vneethv(a)linux.ibm.com,
agordeev(a)linux.ibm.com, imbrenda(a)linux.ibm.com, will(a)kernel.org,
frankja(a)linux.ibm.com, corbet(a)lwn.net, linux-doc(a)vger.kernel.org,
pasic(a)linux.ibm.com, jgg(a)nvidia.com, gerald.schaefer(a)linux.ibm.com,
borntraeger(a)linux.ibm.com, farman(a)linux.ibm.com, gor(a)linux.ibm.com,
schnelle(a)linux.ibm.com, hca(a)linux.ibm.com, alex.williamson(a)redhat.com,
freude(a)linux.ibm.com, pmorel(a)linux.ibm.com, cohuck(a)redhat.com,
oberpar(a)linux.ibm.com, iommu(a)lists.linux-foundation.org,
svens(a)linux.ibm.com, pbonzini(a)redhat.com
Note: A few patches in this series are dependent on Baolu's IOMMU domain
ops split, which is currently in the next branch of linux-iommu. This
series applies on top:
https://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git
Enable interpretive execution of zPCI instructions + adapter interruption
forwarding for s390x KVM vfio-pci. This is done by introducing a new IOMMU
domain for s390x (KVM-managed), indicating via vfio that this IOMMU domain
should be used instead of the default, with subsequent management of the
hardware assists being handled via a new KVM ioctl for zPCI management.
By allowing intepretation of zPCI instructions and firmware delivery of
interrupts to guests, we can significantly reduce the frequency of guest
SIE exits for zPCI. We then see additional gains by handling a hot-path
instruction that can still intercept to the hypervisor (RPCIT) directly
in kvm via the new IOMMU domain, whose map operations update the host
DMA table with pinned guest entries over the specified range.
From the perspective of guest configuration, you passthrough zPCI devices
in the same manner as before, with intepretation support being used by
default if available in kernel+qemu.
Will reply with a link to the associated QEMU series.
Changelog v3->v4:
v3:
https://lore.kernel.org/kvm/20220204211536.321475-1-mjrosato@linux.ibm.com/
- Significant overhaul of the userspace API. Remove all vfio device
feature ioctls. Remove CONFIG_VFIO_PCI_ZDEV, this is once again always
built with vfio-pci for s390; IS_ENABLED checks can instead look at
CONFIG_VFIO_PCI. Most earlier patches in the series could maintain
their reviews, but some needed to be removed due to required code
changes.
- Instead use a KVM ioctl for zPCI management. The API is very similar
to the feature ioctls used in the prior series, with an additional step
to create an association between an iommu domain + KVM + zPCI device.
- Introduce a new iommu domain ops type for s390-iommu, to be used when
KVM manages the IOMMU instead of in response to VFIO mapping ioctls -
Add a iommu method for specifying the type of domain to allocate
- Add a new type to vfio_iommu_type1 (KVM-owned) to trigger the allocation
of the KVM-owned IOMMU domain when zPCI interpretation is requested.
In this case, the KVM-owned type is specified on VFIO_SET_IOMMU. - Wire
the RPCIT intercepts into the new IOMMU domain via the kernel
IOMMU API - Remove a bunch of unnecessary symbol externs, make the
associated
functions static
- Now that we keep a list of zPCI associated with a given KVM, we can do
fh lookup on this list vs the list of all zPCI on the host. We only
need to do a host-wide fh lookup during the initial device<->KVM
association.
Matthew Rosato (32):
s390/sclp: detect the zPCI load/store interpretation facility
s390/sclp: detect the AISII facility
s390/sclp: detect the AENI facility
s390/sclp: detect the AISI facility
s390/airq: pass more TPI info to airq handlers
s390/airq: allow for airq structure that uses an input vector
s390/pci: externalize the SIC operation controls and routine
s390/pci: stash associated GISA designation
s390/pci: export some routines related to RPCIT processing
s390/pci: stash dtsm and maxstbl
s390/pci: add helper function to find device by handle
s390/pci: get SHM information from list pci
s390/pci: return status from zpci_refresh_trans
iommu: introduce iommu_domain_alloc_type and the KVM type
vfio: introduce KVM-owned IOMMU type
vfio-pci/zdev: add function handle to clp base capability
KVM: s390: pci: add basic kvm_zdev structure
iommu/s390: add support for IOMMU_DOMAIN_KVM
KVM: s390: pci: do initial setup for AEN interpretation
KVM: s390: pci: enable host forwarding of Adapter Event Notifications
KVM: s390: mechanism to enable guest zPCI Interpretation
KVM: s390: pci: routines for (dis)associating zPCI devices with a KVM
KVM: s390: pci: provide routines for enabling/disabling interpretation
KVM: s390: pci: provide routines for enabling/disabling interrupt
forwarding
KVM: s390: pci: provide routines for enabling/disabling IOAT assist
KVM: s390: pci: handle refresh of PCI translations
KVM: s390: intercept the rpcit instruction
KVM: s390: add KVM_S390_ZPCI_OP to manage guest zPCI devices
vfio-pci/zdev: add DTSM to clp group capability
KVM: s390: introduce CPU feature for zPCI Interpretation
MAINTAINERS: additional files related kvm s390 pci passthrough
MAINTAINERS: update s390 IOMMU entry
Documentation/virt/kvm/api.rst | 60 +++
MAINTAINERS | 4 +-
arch/s390/include/asm/airq.h | 7 +-
arch/s390/include/asm/kvm_host.h | 7 +
arch/s390/include/asm/kvm_pci.h | 40 ++
arch/s390/include/asm/pci.h | 12 +
arch/s390/include/asm/pci_clp.h | 11 +-
arch/s390/include/asm/pci_dma.h | 3 +
arch/s390/include/asm/pci_insn.h | 31 +-
arch/s390/include/asm/sclp.h | 4 +
arch/s390/include/asm/tpi.h | 13 +
arch/s390/include/uapi/asm/kvm.h | 1 +
arch/s390/kvm/Makefile | 1 +
arch/s390/kvm/interrupt.c | 95 +++-
arch/s390/kvm/kvm-s390.c | 90 +++-
arch/s390/kvm/kvm-s390.h | 10 +
arch/s390/kvm/pci.c | 833 +++++++++++++++++++++++++++++++
arch/s390/kvm/pci.h | 63 +++
arch/s390/kvm/priv.c | 46 ++
arch/s390/pci/pci.c | 31 ++
arch/s390/pci/pci_clp.c | 28 +-
arch/s390/pci/pci_dma.c | 7 +-
arch/s390/pci/pci_insn.c | 15 +-
arch/s390/pci/pci_irq.c | 48 +-
drivers/iommu/Kconfig | 8 +
drivers/iommu/Makefile | 1 +
drivers/iommu/iommu.c | 7 +
drivers/iommu/s390-iommu.c | 53 +-
drivers/iommu/s390-iommu.h | 53 ++
drivers/iommu/s390-kvm-iommu.c | 469 +++++++++++++++++
drivers/s390/char/sclp_early.c | 4 +
drivers/s390/cio/airq.c | 12 +-
drivers/s390/cio/qdio_thinint.c | 6 +-
drivers/s390/crypto/ap_bus.c | 9 +-
drivers/s390/virtio/virtio_ccw.c | 6 +-
drivers/vfio/pci/vfio_pci_zdev.c | 17 +-
drivers/vfio/vfio_iommu_type1.c | 12 +-
include/linux/iommu.h | 12 +
include/uapi/linux/kvm.h | 43 ++
include/uapi/linux/vfio.h | 6 +
include/uapi/linux/vfio_zdev.h | 6 +
41 files changed, 2090 insertions(+), 94 deletions(-)
create mode 100644 arch/s390/include/asm/kvm_pci.h
create mode 100644 arch/s390/kvm/pci.c
create mode 100644 arch/s390/kvm/pci.h
create mode 100644 drivers/iommu/s390-iommu.h
create mode 100644 drivers/iommu/s390-kvm-iommu.c
--
2.27.0
_______________________________________________
iommu mailing list
iommu(a)lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
1
0
From: Weili Qian <qianweili(a)huawei.com>
When the function executes successfully,
the returned size is not used, so "WD_SUCCESS"
is returned directly.
Signed-off-by: Weili Qian <qianweili(a)huawei.com>
---
drv/hisi_hpre.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/drv/hisi_hpre.c b/drv/hisi_hpre.c
index b6c80203..d0a579e6 100644
--- a/drv/hisi_hpre.c
+++ b/drv/hisi_hpre.c
@@ -221,8 +221,7 @@ static int fill_rsa_crt_prikey2(struct wd_rsa_prikey *prikey,
*data = wd_dq->data;
- return (int)(wd_dq->bsize + wd_qinv->bsize + wd_p->bsize +
- wd_q->bsize + wd_dp->bsize);
+ return WD_SUCCESS;
}
static int fill_rsa_prikey1(struct wd_rsa_prikey *prikey, void **data)
@@ -243,7 +242,7 @@ static int fill_rsa_prikey1(struct wd_rsa_prikey *prikey, void **data)
*data = wd_d->data;
- return (int)(wd_n->bsize + wd_d->bsize);
+ return WD_SUCCESS;
}
static int fill_rsa_pubkey(struct wd_rsa_pubkey *pubkey, void **data)
@@ -264,7 +263,7 @@ static int fill_rsa_pubkey(struct wd_rsa_pubkey *pubkey, void **data)
return ret;
*data = wd_e->data;
- return (int)(wd_n->bsize + wd_e->bsize);
+ return WD_SUCCESS;
}
static int fill_rsa_genkey_in(struct wd_rsa_kg_in *genkey)
@@ -383,17 +382,17 @@ static int rsa_prepare_key(struct wd_rsa_msg *msg,
if (req->op_type == WD_RSA_SIGN) {
if (hw_msg->alg == HPRE_ALG_NC_CRT) {
ret = fill_rsa_crt_prikey2((void *)msg->key, &data);
- if (ret <= 0)
+ if (ret)
return ret;
} else {
ret = fill_rsa_prikey1((void *)msg->key, &data);
- if (ret < 0)
+ if (ret)
return ret;
hw_msg->alg = HPRE_ALG_NC_NCRT;
}
} else if (req->op_type == WD_RSA_VERIFY) {
ret = fill_rsa_pubkey((void *)msg->key, &data);
- if (ret < 0)
+ if (ret)
return ret;
hw_msg->alg = HPRE_ALG_NC_NCRT;
} else if (req->op_type == WD_RSA_GENKEY) {
--
2.33.0
1
0
From: Kai Ye <yekai13(a)huawei.com>
Unify print format with following rules:
1. failed to do sth.
2. invalid: sth is NULL.
Signed-off-by: Kai Ye <yekai13(a)huawei.com>
---
drv/hisi_sec.c | 20 ++++++++++----------
wd_aead.c | 12 ++++++------
wd_cipher.c | 20 ++++++++++----------
wd_digest.c | 10 +++++-----
4 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/drv/hisi_sec.c b/drv/hisi_sec.c
index 16fcb5f..aa86a6b 100644
--- a/drv/hisi_sec.c
+++ b/drv/hisi_sec.c
@@ -703,7 +703,7 @@ static void parse_cipher_bd2(struct hisi_sec_sqe *sqe,
done = sqe->type2.done_flag & SEC_DONE_MASK;
if (done != SEC_HW_TASK_DONE || sqe->type2.error_type) {
- WD_ERR("SEC BD %s fail! done=0x%x, etype=0x%x\n", "cipher",
+ WD_ERR("failed to parse cipher BD2! done=0x%x, etype=0x%x\n",
done, sqe->type2.error_type);
recv_msg->result = WD_IN_EPARA;
} else {
@@ -927,7 +927,7 @@ int hisi_sec_cipher_send(handle_t ctx, struct wd_cipher_msg *msg)
int ret;
if (!msg) {
- WD_ERR("input cipher msg is NULL!\n");
+ WD_ERR("invalid: input cipher msg is NULL!\n");
return -WD_EINVAL;
}
@@ -1130,7 +1130,7 @@ int hisi_sec_cipher_send_v3(handle_t ctx, struct wd_cipher_msg *msg)
int ret;
if (!msg) {
- WD_ERR("input cipher msg is NULL!\n");
+ WD_ERR("invalid: input cipher msg is NULL!\n");
return -WD_EINVAL;
}
@@ -1175,7 +1175,7 @@ static void parse_cipher_bd3(struct hisi_sec_sqe3 *sqe,
done = sqe->done_flag & SEC_DONE_MASK;
if (done != SEC_HW_TASK_DONE || sqe->error_type) {
- WD_ERR("SEC BD3 %s fail! done=0x%x, etype=0x%x\n", "cipher",
+ WD_ERR("failed to parse cipher BD3! done=0x%x, etype=0x%x\n",
done, sqe->error_type);
recv_msg->result = WD_IN_EPARA;
} else {
@@ -1278,7 +1278,7 @@ static void parse_digest_bd2(struct hisi_sec_sqe *sqe,
done = sqe->type2.done_flag & SEC_DONE_MASK;
if (done != SEC_HW_TASK_DONE || sqe->type2.error_type) {
- WD_ERR("SEC BD %s fail! done=0x%x, etype=0x%x\n", "digest",
+ WD_ERR("failed to parse digest BD2! done=0x%x, etype=0x%x\n",
done, sqe->type2.error_type);
recv_msg->result = WD_IN_EPARA;
} else {
@@ -1354,7 +1354,7 @@ int hisi_sec_digest_send(handle_t ctx, struct wd_digest_msg *msg)
int ret;
if (!msg) {
- WD_ERR("input digest msg is NULL!\n");
+ WD_ERR("invalid: input digest msg is NULL!\n");
return -WD_EINVAL;
}
@@ -1510,7 +1510,7 @@ int hisi_sec_digest_send_v3(handle_t ctx, struct wd_digest_msg *msg)
int ret;
if (!msg) {
- WD_ERR("input digest msg is NULL!\n");
+ WD_ERR("invalid: input digest msg is NULL!\n");
return -WD_EINVAL;
}
@@ -1578,7 +1578,7 @@ static void parse_digest_bd3(struct hisi_sec_sqe3 *sqe,
done = sqe->done_flag & SEC_DONE_MASK;
if (done != SEC_HW_TASK_DONE || sqe->error_type) {
- WD_ERR("SEC BD3 %s fail! done=0x%x, etype=0x%x\n", "digest",
+ WD_ERR("failed to parse digest BD3! done=0x%x, etype=0x%x\n",
done, sqe->error_type);
recv_msg->result = WD_IN_EPARA;
} else {
@@ -1927,7 +1927,7 @@ static void parse_aead_bd2(struct hisi_sec_sqe *sqe,
icv = (sqe->type2.done_flag & SEC_ICV_MASK) >> 1;
if (done != SEC_HW_TASK_DONE || sqe->type2.error_type ||
icv == SEC_HW_ICV_ERR) {
- WD_ERR("SEC BD aead fail! done=0x%x, etype=0x%x, icv=0x%x\n",
+ WD_ERR("failed to parse aead BD2! done=0x%x, etype=0x%x, icv=0x%x\n",
done, sqe->type2.error_type, icv);
recv_msg->result = WD_IN_EPARA;
} else {
@@ -2195,7 +2195,7 @@ static void parse_aead_bd3(struct hisi_sec_sqe3 *sqe,
icv = (sqe->done_flag & SEC_ICV_MASK) >> 1;
if (done != SEC_HW_TASK_DONE || sqe->error_type ||
icv == SEC_HW_ICV_ERR) {
- WD_ERR("SEC BD3 aead fail! done=0x%x, etype=0x%x, icv=0x%x\n",
+ WD_ERR("failed to parse aead BD3! done=0x%x, etype=0x%x, icv=0x%x\n",
done, sqe->error_type, icv);
recv_msg->result = WD_IN_EPARA;
} else {
diff --git a/wd_aead.c b/wd_aead.c
index 7df8e80..74047b5 100644
--- a/wd_aead.c
+++ b/wd_aead.c
@@ -63,14 +63,14 @@ static void wd_aead_set_static_drv(void)
{
wd_aead_setting.driver = wd_aead_get_driver();
if (!wd_aead_setting.driver)
- WD_ERR("fail to get driver\n");
+ WD_ERR("failed to get driver!\n");
}
#else
static void __attribute__((constructor)) wd_aead_open_driver(void)
{
wd_aead_setting.dlhandle = dlopen("libhisi_sec.so", RTLD_NOW);
if (!wd_aead_setting.dlhandle)
- WD_ERR("failed to open libhisi_sec.so\n");
+ WD_ERR("failed to open libhisi_sec.so!\n");
}
static void __attribute__((destructor)) wd_aead_close_driver(void)
@@ -344,7 +344,7 @@ static int aead_param_check(struct wd_aead_sess *sess,
int ret;
if (unlikely(!sess || !req)) {
- WD_ERR("aead input sess or req is NULL.\n");
+ WD_ERR("invalid: aead input sess or req is NULL!\n");
return -WD_EINVAL;
}
@@ -393,7 +393,7 @@ static int aead_param_check(struct wd_aead_sess *sess,
static int aead_init_check(struct wd_ctx_config *config, struct wd_sched *sched)
{
if (!config || !config->ctxs || !config->ctxs[0].ctx || !sched) {
- WD_ERR("wd aead config or sched is NULL!\n");
+ WD_ERR("invalid: wd aead config or sched is NULL!\n");
return -WD_EINVAL;
}
@@ -594,7 +594,7 @@ int wd_do_aead_async(handle_t h_sess, struct wd_aead_req *req)
return -WD_EINVAL;
if (unlikely(!req->cb)) {
- WD_ERR("aead input req cb is NULL.\n");
+ WD_ERR("invalid: aead input req cb is NULL!\n");
return -WD_EINVAL;
}
@@ -647,7 +647,7 @@ int wd_aead_poll_ctx(__u32 idx, __u32 expt, __u32 *count)
int ret;
if (!count) {
- WD_ERR("aead poll ctx input param is NULL!\n");
+ WD_ERR("invalid: aead poll ctx input param is NULL!\n");
return -WD_EINVAL;
}
diff --git a/wd_cipher.c b/wd_cipher.c
index afd8c4d..3a9b323 100644
--- a/wd_cipher.c
+++ b/wd_cipher.c
@@ -75,14 +75,14 @@ static void wd_cipher_set_static_drv(void)
{
wd_cipher_setting.driver = wd_cipher_get_driver();
if (!wd_cipher_setting.driver)
- WD_ERR("fail to get driver\n");
+ WD_ERR("failed to get driver!\n");
}
#else
static void __attribute__((constructor)) wd_cipher_open_driver(void)
{
wd_cipher_setting.dlhandle = dlopen("libhisi_sec.so", RTLD_NOW);
if (!wd_cipher_setting.dlhandle)
- WD_ERR("fail to open libhisi_sec.so\n");
+ WD_ERR("failed to open libhisi_sec.so!\n");
}
static void __attribute__((destructor)) wd_cipher_close_driver(void)
@@ -158,7 +158,7 @@ static int cipher_init_check(struct wd_ctx_config *config,
struct wd_sched *sched)
{
if (!config || !config->ctxs || !config->ctxs[0].ctx || !sched) {
- WD_ERR("wd cipher config or sched is NULL!\n");
+ WD_ERR("invalid: wd cipher config or sched is NULL!\n");
return -WD_EINVAL;
}
@@ -177,7 +177,7 @@ int wd_cipher_set_key(handle_t h_sess, const __u8 *key, __u32 key_len)
int ret;
if (!key || !sess) {
- WD_ERR("cipher set key input param err!\n");
+ WD_ERR("invalid: cipher set key input param err!\n");
return -WD_EINVAL;
}
@@ -205,13 +205,13 @@ handle_t wd_cipher_alloc_sess(struct wd_cipher_sess_setup *setup)
struct wd_cipher_sess *sess = NULL;
if (unlikely(!setup)) {
- WD_ERR("cipher input setup is NULL!\n");
+ WD_ERR("invalid: cipher input setup is NULL!\n");
return (handle_t)0;
}
sess = malloc(sizeof(struct wd_cipher_sess));
if (!sess) {
- WD_ERR("fail to alloc session memory!\n");
+ WD_ERR("failed to alloc session memory!\n");
return (handle_t)0;
}
memset(sess, 0, sizeof(struct wd_cipher_sess));
@@ -235,7 +235,7 @@ void wd_cipher_free_sess(handle_t h_sess)
struct wd_cipher_sess *sess = (struct wd_cipher_sess *)h_sess;
if (unlikely(!sess)) {
- WD_ERR("cipher input h_sess is NULL!\n");
+ WD_ERR("invalid: cipher input h_sess is NULL!\n");
return;
}
@@ -387,12 +387,12 @@ static int wd_cipher_check_params(handle_t h_sess,
int ret = 0;
if (unlikely(!h_sess || !req)) {
- WD_ERR("cipher input sess or req is NULL!\n");
+ WD_ERR("invalid: cipher input sess or req is NULL!\n");
return -WD_EINVAL;
}
if (unlikely(mode == CTX_MODE_ASYNC && !req->cb)) {
- WD_ERR("cipher req cb is NULL!\n");
+ WD_ERR("invalid: cipher req cb is NULL!\n");
return -WD_EINVAL;
}
@@ -561,7 +561,7 @@ int wd_cipher_poll_ctx(__u32 idx, __u32 expt, __u32 *count)
int ret;
if (unlikely(!count)) {
- WD_ERR("wd cipher poll ctx input param is NULL!\n");
+ WD_ERR("invalid: cipher poll ctx input param is NULL!\n");
return -WD_EINVAL;
}
diff --git a/wd_digest.c b/wd_digest.c
index fb29746..0ddc074 100644
--- a/wd_digest.c
+++ b/wd_digest.c
@@ -62,7 +62,7 @@ static void wd_digest_set_static_drv(void)
{
wd_digest_setting.driver = wd_digest_get_driver();
if (!wd_digest_setting.driver)
- WD_ERR("fail to get driver\n");
+ WD_ERR("failed to get driver!\n");
}
#else
static void __attribute__((constructor)) wd_digest_open_driver(void)
@@ -70,7 +70,7 @@ static void __attribute__((constructor)) wd_digest_open_driver(void)
/* Fix me: vendor driver should be put in /usr/lib/wd/ */
wd_digest_setting.dlhandle = dlopen("libhisi_sec.so", RTLD_NOW);
if (!wd_digest_setting.dlhandle)
- WD_ERR("fail to open libhisi_sec.so\n");
+ WD_ERR("failed to open libhisi_sec.so!\n");
}
static void __attribute__((destructor)) wd_digest_close_driver(void)
@@ -252,7 +252,7 @@ static int digest_param_check(struct wd_digest_sess *sess,
int ret;
if (unlikely(!sess || !req)) {
- WD_ERR("digest input sess or req is NULL.\n");
+ WD_ERR("invalid: digest input sess or req is NULL!\n");
return -WD_EINVAL;
}
@@ -398,7 +398,7 @@ int wd_do_digest_async(handle_t h_sess, struct wd_digest_req *req)
return -WD_EINVAL;
if (unlikely(!req->cb)) {
- WD_ERR("digest input req cb is NULL.\n");
+ WD_ERR("invalid: digest input req cb is NULL!\n");
return -WD_EINVAL;
}
@@ -451,7 +451,7 @@ int wd_digest_poll_ctx(__u32 idx, __u32 expt, __u32 *count)
int ret;
if (unlikely(!count)) {
- WD_ERR("digest count is NULL.\n");
+ WD_ERR("invalid: digest poll ctx input param is NULL!\n");
return -WD_EINVAL;
}
--
2.24.0
1
8