uadk_engine/0049-uadk_prov_init-remove-engine_uadk_id.patch
2023-11-21 11:24:33 +08:00

199 lines
6.4 KiB
Diff

From 82144d6f4802aae3a562fbdb1e51c4d35e2b32b2 Mon Sep 17 00:00:00 2001
From: Zhangfei Gao <zhangfei.gao@linaro.org>
Date: Fri, 20 Oct 2023 07:53:45 +0000
Subject: [PATCH 49/63] uadk_prov_init: remove engine_uadk_id.
It looks strange to define engine_uadk_id in uadk_prov_init.c
ASYNC_WAIT_CTX_set_wait_fd and ASYNC_WAIT_CTX_get_fd does not need to
use engine_uadk_id as the key, only if the key is the same.
So define uadk_async_key in the file itself.
Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
---
src/uadk.h | 1 -
src/uadk_async.c | 17 +++++++++--------
src/uadk_engine_init.c | 2 +-
src/uadk_prov_init.c | 1 -
src/v1/async/async_event.c | 19 ++++++++++---------
5 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/src/uadk.h b/src/uadk.h
index 30c099f..5a98feb 100644
--- a/src/uadk.h
+++ b/src/uadk.h
@@ -28,7 +28,6 @@ enum {
HW_V3,
};
-extern const char *engine_uadk_id;
int uadk_e_bind_cipher(ENGINE *e);
void uadk_e_destroy_cipher(void);
int uadk_e_bind_digest(ENGINE *e);
diff --git a/src/uadk_async.c b/src/uadk_async.c
index c46976c..45f3918 100644
--- a/src/uadk_async.c
+++ b/src/uadk_async.c
@@ -24,6 +24,7 @@
#include "uadk.h"
#include "uadk_async.h"
+static const char *uadk_async_key = "uadk_async_key";
static struct async_poll_queue poll_queue;
static int g_uadk_e_keep_polling;
@@ -61,15 +62,15 @@ int async_setup_async_event_notification(struct async_op *op)
if (waitctx == NULL)
return 0;
- if (ASYNC_WAIT_CTX_get_fd(waitctx, engine_uadk_id,
+ if (ASYNC_WAIT_CTX_get_fd(waitctx, uadk_async_key,
&efd, &custom) == 0) {
efd = eventfd(0, EFD_NONBLOCK);
if (efd == -1)
return 0;
- if (ASYNC_WAIT_CTX_set_wait_fd(waitctx, engine_uadk_id, efd,
+ if (ASYNC_WAIT_CTX_set_wait_fd(waitctx, uadk_async_key, efd,
custom, async_fd_cleanup) == 0) {
- async_fd_cleanup(waitctx, engine_uadk_id, efd, NULL);
+ async_fd_cleanup(waitctx, uadk_async_key, efd, NULL);
return 0;
}
}
@@ -99,13 +100,13 @@ int async_clear_async_event_notification(void)
return 0;
if (num_add_fds > 0) {
- if (ASYNC_WAIT_CTX_get_fd(waitctx, engine_uadk_id,
+ if (ASYNC_WAIT_CTX_get_fd(waitctx, uadk_async_key,
&efd, &custom) == 0)
return 0;
- async_fd_cleanup(waitctx, engine_uadk_id, efd, NULL);
+ async_fd_cleanup(waitctx, uadk_async_key, efd, NULL);
- if (ASYNC_WAIT_CTX_clear_fd(waitctx, engine_uadk_id) == 0)
+ if (ASYNC_WAIT_CTX_clear_fd(waitctx, uadk_async_key) == 0)
return 0;
}
@@ -272,7 +273,7 @@ int async_pause_job(void *ctx, struct async_op *op, enum task_type type, int id)
if (ASYNC_pause_job() == 0)
return 0;
- ret = ASYNC_WAIT_CTX_get_fd(waitctx, engine_uadk_id, &efd, &custom);
+ ret = ASYNC_WAIT_CTX_get_fd(waitctx, uadk_async_key, &efd, &custom);
if (ret <= 0)
continue;
@@ -299,7 +300,7 @@ int async_wake_job(ASYNC_JOB *job)
if (waitctx == NULL)
return 0;
- ret = ASYNC_WAIT_CTX_get_fd(waitctx, engine_uadk_id, &efd, &custom);
+ ret = ASYNC_WAIT_CTX_get_fd(waitctx, uadk_async_key, &efd, &custom);
if (ret > 0) {
if (write(efd, &buf, sizeof(uint64_t)) == -1)
fprintf(stderr, "failed to write to fd: %d - error: %d\n", efd, errno);
diff --git a/src/uadk_engine_init.c b/src/uadk_engine_init.c
index e2aa392..cf54360 100644
--- a/src/uadk_engine_init.c
+++ b/src/uadk_engine_init.c
@@ -35,7 +35,7 @@
#define UADK_CMD_ENABLE_ECC_ENV (ENGINE_CMD_BASE + 4)
/* Constants used when creating the ENGINE */
-const char *engine_uadk_id = "uadk_engine";
+static const char *engine_uadk_id = "uadk_engine";
static const char *engine_uadk_name = "uadk hardware engine support";
static int uadk_cipher;
diff --git a/src/uadk_prov_init.c b/src/uadk_prov_init.c
index 2bde080..9b2c190 100644
--- a/src/uadk_prov_init.c
+++ b/src/uadk_prov_init.c
@@ -28,7 +28,6 @@
#include "uadk_async.h"
#include "uadk_prov.h"
-const char *engine_uadk_id = "uadk_provider";
static const char UADK_DEFAULT_PROPERTIES[] = "provider=uadk_provider";
static OSSL_PROVIDER *prov;
diff --git a/src/v1/async/async_event.c b/src/v1/async/async_event.c
index 245c269..c843bcf 100644
--- a/src/v1/async/async_event.c
+++ b/src/v1/async/async_event.c
@@ -35,7 +35,8 @@
#include "async_event.h"
#include "../utils/engine_log.h"
-#include "../../uadk.h"
+
+static const char *uadk_async_key = "uadk_async_key";
static void async_fd_cleanup(ASYNC_WAIT_CTX *ctx, const void *key, OSSL_ASYNC_FD readfd, void *custom)
{
@@ -66,7 +67,7 @@ int async_setup_async_event_notification_v1(int jobStatus)
return 0;
}
- if (ASYNC_WAIT_CTX_get_fd(waitctx, engine_uadk_id, &efd,
+ if (ASYNC_WAIT_CTX_get_fd(waitctx, uadk_async_key, &efd,
&custom) == 0) {
efd = eventfd(0, EFD_NONBLOCK);
if (efd == -1) {
@@ -74,10 +75,10 @@ int async_setup_async_event_notification_v1(int jobStatus)
return 0;
}
- if (ASYNC_WAIT_CTX_set_wait_fd(waitctx, engine_uadk_id, efd,
+ if (ASYNC_WAIT_CTX_set_wait_fd(waitctx, uadk_async_key, efd,
custom, async_fd_cleanup) == 0) {
US_ERR("set wait fd error.");
- async_fd_cleanup(waitctx, engine_uadk_id, efd, NULL);
+ async_fd_cleanup(waitctx, uadk_async_key, efd, NULL);
return 0;
}
}
@@ -111,14 +112,14 @@ int async_clear_async_event_notification_v1(void)
}
if (num_add_fds > 0) {
- if (ASYNC_WAIT_CTX_get_fd(waitctx, engine_uadk_id, &efd, &custom) == 0) {
+ if (ASYNC_WAIT_CTX_get_fd(waitctx, uadk_async_key, &efd, &custom) == 0) {
US_ERR("no fd.");
return 0;
}
- async_fd_cleanup(waitctx, engine_uadk_id, efd, NULL);
+ async_fd_cleanup(waitctx, uadk_async_key, efd, NULL);
- if (ASYNC_WAIT_CTX_clear_fd(waitctx, engine_uadk_id) == 0) {
+ if (ASYNC_WAIT_CTX_clear_fd(waitctx, uadk_async_key) == 0) {
US_ERR("clear fd error.");
return 0;
}
@@ -148,7 +149,7 @@ int async_pause_job_v1(volatile ASYNC_JOB *job, int jobStatus)
return ret;
}
- ret = ASYNC_WAIT_CTX_get_fd(waitctx, engine_uadk_id, &efd, &custom);
+ ret = ASYNC_WAIT_CTX_get_fd(waitctx, uadk_async_key, &efd, &custom);
if (ret > 0) {
if (read(efd, &buf, sizeof(uint64_t)) == -1) {
if (errno != EAGAIN)
@@ -178,7 +179,7 @@ int async_wake_job_v1(volatile ASYNC_JOB *job, int jobStatus)
return ret;
}
- ret = ASYNC_WAIT_CTX_get_fd(waitctx, engine_uadk_id, &efd, &custom);
+ ret = ASYNC_WAIT_CTX_get_fd(waitctx, uadk_async_key, &efd, &custom);
if (ret > 0) {
if (write(efd, &buf, sizeof(uint64_t)) == -1)
US_ERR("Failed to write to fd: %d - error: %d\n", efd, errno);
--
2.25.1