lists.linaro.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
List overview
Download
Acc
October 2023
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
acc@lists.linaro.org
2 participants
2 discussions
Start a n
N
ew thread
[PATCH 0/4] uadk: add new mode for cipher and digest
by Weili Qian
Add new mode for cipher and digest Weili Qian (4): uadk/cipher: support sm4-xts GB standard. uadk/v1/cipher: support sm4-xts GB standard uadk/v1/digest: support new AES mode algs uadk/v1: fix long hash state issue drv/hisi_sec.c | 8 ++- include/wd_cipher.h | 3 + v1/drv/hisi_sec_udrv.c | 146 ++++++++++++++++++++++++++++++----------- v1/wd_cipher.c | 3 +- v1/wd_cipher.h | 5 ++ v1/wd_digest.c | 69 +++++++++++++++++-- v1/wd_digest.h | 24 +++++-- v1/wd_util.c | 2 +- wd_alg.c | 3 + wd_cipher.c | 9 +-- 10 files changed, 216 insertions(+), 56 deletions(-) -- 2.33.0
1 year, 1 month
1
4
0
0
[PATCH 01/11 v2] uadk_engine: cleanup code style of async functions
by Zhiqi Song
Cleanup the return value and judgment code style of async mode functions. Signed-off-by: Zhiqi Song <songzhiqi1(a)huawei.com> --- src/uadk_async.c | 132 +++++++++++++++++++++++------------------------ src/uadk_async.h | 3 ++ 2 files changed, 68 insertions(+), 67 deletions(-) diff --git a/src/uadk_async.c b/src/uadk_async.c index 9251238..3462d67 100644 --- a/src/uadk_async.c +++ b/src/uadk_async.c @@ -48,67 +48,65 @@ static void async_fd_cleanup(ASYNC_WAIT_CTX *ctx, const void *key, int async_setup_async_event_notification(struct async_op *op) { ASYNC_WAIT_CTX *waitctx; + void *custom = NULL; OSSL_ASYNC_FD efd; - void *custom; memset(op, 0, sizeof(struct async_op)); + op->job = ASYNC_get_current_job(); - if (op->job == NULL) - return 1; + if (!op->job) + return DO_SYNC; waitctx = ASYNC_get_wait_ctx(op->job); - if (waitctx == NULL) - return 0; + if (!waitctx) + return UADK_E_FAIL; - if (ASYNC_WAIT_CTX_get_fd(waitctx, engine_uadk_id, - &efd, &custom) == 0) { + if (!ASYNC_WAIT_CTX_get_fd(waitctx, engine_uadk_id, &efd, &custom)) { efd = eventfd(0, EFD_NONBLOCK); if (efd == -1) - return 0; + return UADK_E_FAIL; - if (ASYNC_WAIT_CTX_set_wait_fd(waitctx, engine_uadk_id, efd, - custom, async_fd_cleanup) == 0) { + if (!ASYNC_WAIT_CTX_set_wait_fd(waitctx, engine_uadk_id, efd, + custom, async_fd_cleanup)) { async_fd_cleanup(waitctx, engine_uadk_id, efd, NULL); - return 0; + return UADK_E_FAIL; } } - return 1; + return UADK_E_SUCCESS; } int async_clear_async_event_notification(void) { - ASYNC_JOB *job; ASYNC_WAIT_CTX *waitctx; + void *custom = NULL; OSSL_ASYNC_FD efd; size_t num_add_fds; size_t num_del_fds; - void *custom = NULL; + ASYNC_JOB *job; job = ASYNC_get_current_job(); - if (job == NULL) - return 0; + if (!job) + return UADK_E_FAIL; waitctx = ASYNC_get_wait_ctx(job); - if (waitctx == NULL) - return 0; + if (!waitctx) + return UADK_E_FAIL; - if (ASYNC_WAIT_CTX_get_changed_fds(waitctx, NULL, &num_add_fds, - NULL, &num_del_fds) == 0) - return 0; + if (!ASYNC_WAIT_CTX_get_changed_fds(waitctx, NULL, &num_add_fds, NULL, &num_del_fds)) + return UADK_E_FAIL; if (num_add_fds > 0) { - if (ASYNC_WAIT_CTX_get_fd(waitctx, engine_uadk_id, - &efd, &custom) == 0) - return 0; + if (!ASYNC_WAIT_CTX_get_fd(waitctx, engine_uadk_id, &efd, &custom)) + return UADK_E_FAIL; async_fd_cleanup(waitctx, engine_uadk_id, efd, NULL); - if (ASYNC_WAIT_CTX_clear_fd(waitctx, engine_uadk_id) == 0) - return 0; + if (!ASYNC_WAIT_CTX_clear_fd(waitctx, engine_uadk_id)) + return UADK_E_FAIL; } - return 1; + return UADK_E_SUCCESS; } static void async_poll_task_free(void) @@ -120,11 +118,11 @@ static void async_poll_task_free(void) uadk_e_set_async_poll_state(DISABLE_ASYNC_POLLING); error = pthread_mutex_lock(&poll_queue.async_task_mutex); - if (error != 0) + if (error) return; task = poll_queue.head; - if (task != NULL) + if (task) OPENSSL_free(task); poll_queue.head = NULL; @@ -143,13 +141,13 @@ static int async_get_poll_task(int *id) while (!poll_queue.status[idx]) { idx = (idx + 1) % ASYNC_QUEUE_TASK_NUM; if (cnt++ == ASYNC_QUEUE_TASK_NUM) - return 0; + return UADK_E_FAIL; } *id = idx; poll_queue.rid = (idx + 1) % ASYNC_QUEUE_TASK_NUM; - return 1; + return UADK_E_SUCCESS; } static struct async_poll_task *async_get_queue_task(void) @@ -158,11 +156,11 @@ static struct async_poll_task *async_get_queue_task(void) struct async_poll_task *task_queue; int idx, ret; - if (pthread_mutex_lock(&poll_queue.async_task_mutex) != 0) + if (pthread_mutex_lock(&poll_queue.async_task_mutex)) return NULL; ret = async_get_poll_task(&idx); - if (!ret) + if (ret == UADK_E_FAIL) goto err; task_queue = poll_queue.head; @@ -170,10 +168,10 @@ static struct async_poll_task *async_get_queue_task(void) poll_queue.is_recv = 0; err: - if (pthread_mutex_unlock(&poll_queue.async_task_mutex) != 0) + if (pthread_mutex_unlock(&poll_queue.async_task_mutex)) return NULL; - if (cur_task && cur_task->op == NULL) + if (cur_task && !cur_task->op) return NULL; return cur_task; @@ -181,7 +179,7 @@ err: void async_free_poll_task(int id, bool is_cb) { - if (pthread_mutex_lock(&poll_queue.async_task_mutex) != 0) + if (pthread_mutex_lock(&poll_queue.async_task_mutex)) return; poll_queue.status[id] = 0; @@ -189,7 +187,7 @@ void async_free_poll_task(int id, bool is_cb) if (is_cb) poll_queue.is_recv = 1; - if (pthread_mutex_unlock(&poll_queue.async_task_mutex) != 0) + if (pthread_mutex_unlock(&poll_queue.async_task_mutex)) return; (void)sem_post(&poll_queue.empty_sem); @@ -202,17 +200,17 @@ int async_get_free_task(int *id) int idx, ret; int cnt = 0; - if (sem_wait(&poll_queue.empty_sem) != 0) - return 0; + if (sem_wait(&poll_queue.empty_sem)) + return UADK_E_FAIL; - if (pthread_mutex_lock(&poll_queue.async_task_mutex) != 0) - return 0; + if (pthread_mutex_lock(&poll_queue.async_task_mutex)) + return UADK_E_FAIL; idx = poll_queue.sid; while (poll_queue.status[idx]) { idx = (idx + 1) % ASYNC_QUEUE_TASK_NUM; if (cnt++ == ASYNC_QUEUE_TASK_NUM) { - ret = 0; + ret = UADK_E_FAIL; goto out; } } @@ -223,16 +221,16 @@ int async_get_free_task(int *id) task_queue = poll_queue.head; task = &task_queue[idx]; if (!task) { - ret = 0; + ret = UADK_E_FAIL; goto out; } task->op = NULL; - ret = 1; + ret = UADK_E_SUCCESS; out: - if (pthread_mutex_unlock(&poll_queue.async_task_mutex) != 0) - return 0; + if (pthread_mutex_unlock(&poll_queue.async_task_mutex)) + return UADK_E_FAIL; return ret; } @@ -246,7 +244,7 @@ static int async_add_poll_task(void *ctx, struct async_op *op, enum task_type ty task_queue = poll_queue.head; task = &task_queue[id]; if (!task) - return 0; + return UADK_E_FAIL; task->ctx = ctx; task->type = type; @@ -254,9 +252,9 @@ static int async_add_poll_task(void *ctx, struct async_op *op, enum task_type ty ret = sem_post(&poll_queue.full_sem); if (ret) - return 0; + return UADK_E_FAIL; - return 1; + return UADK_E_SUCCESS; } int async_pause_job(void *ctx, struct async_op *op, enum task_type type, int id) @@ -268,19 +266,19 @@ int async_pause_job(void *ctx, struct async_op *op, enum task_type type, int id) int ret; ret = async_add_poll_task(ctx, op, type, id); - if (ret == 0) + if (ret == UADK_E_FAIL) return ret; waitctx = ASYNC_get_wait_ctx((ASYNC_JOB *)op->job); - if (waitctx == NULL) - return 0; + if (!waitctx) + return UADK_E_FAIL; do { - if (ASYNC_pause_job() == 0) - return 0; + if (!ASYNC_pause_job()) + return UADK_E_FAIL; ret = ASYNC_WAIT_CTX_get_fd(waitctx, engine_uadk_id, &efd, &custom); - if (ret <= 0) + if (ret == UADK_E_FAIL) continue; if (read(efd, &buf, sizeof(uint64_t)) == -1) { @@ -298,13 +296,13 @@ int async_wake_job(ASYNC_JOB *job) { ASYNC_WAIT_CTX *waitctx; OSSL_ASYNC_FD efd; - void *custom; uint64_t buf = 1; + void *custom; int ret; waitctx = ASYNC_get_wait_ctx(job); - if (waitctx == NULL) - return 0; + if (!waitctx) + return UADK_E_FAIL; ret = ASYNC_WAIT_CTX_get_fd(waitctx, engine_uadk_id, &efd, &custom); if (ret > 0) { @@ -332,7 +330,7 @@ static void *async_poll_process_func(void *args) int ret, idx; while (uadk_e_get_async_poll_state()) { - if (sem_wait(&poll_queue.full_sem) != 0) { + if (sem_wait(&poll_queue.full_sem)) { if (errno == EINTR) { /* sem_wait is interrupted by interrupt, continue */ continue; @@ -340,7 +338,7 @@ static void *async_poll_process_func(void *args) } task = async_get_queue_task(); - if (task == NULL) { + if (!task) { (void)sem_post(&poll_queue.full_sem); usleep(1); continue; @@ -368,19 +366,19 @@ int async_module_init(void) memset(&poll_queue, 0, sizeof(struct async_poll_queue)); if (pthread_mutex_init(&(poll_queue.async_task_mutex), NULL) < 0) - return 0; + return UADK_E_FAIL; poll_queue.head = malloc(sizeof(struct async_poll_task) * ASYNC_QUEUE_TASK_NUM); - if (poll_queue.head == NULL) - return 0; + if (!poll_queue.head) + return UADK_E_FAIL; memset(poll_queue.head, 0, sizeof(struct async_poll_task) * ASYNC_QUEUE_TASK_NUM); - if (sem_init(&poll_queue.empty_sem, 0, ASYNC_QUEUE_TASK_NUM) != 0) + if (sem_init(&poll_queue.empty_sem, 0, ASYNC_QUEUE_TASK_NUM)) goto err; - if (sem_init(&poll_queue.full_sem, 0, 0) != 0) + if (sem_init(&poll_queue.full_sem, 0, 0)) goto err; uadk_e_set_async_poll_state(ENABLE_ASYNC_POLLING); @@ -393,9 +391,9 @@ int async_module_init(void) poll_queue.thread_id = thread_id; OPENSSL_atexit(async_poll_task_free); - return 1; + return UADK_E_SUCCESS; err: async_poll_task_free(); - return 0; + return UADK_E_FAIL; } diff --git a/src/uadk_async.h b/src/uadk_async.h index 7e75951..8c26777 100644 --- a/src/uadk_async.h +++ b/src/uadk_async.h @@ -22,6 +22,9 @@ #include <openssl/async.h> #define ASYNC_QUEUE_TASK_NUM 1024 +#define UADK_E_SUCCESS 1 +#define UADK_E_FAIL 0 +#define DO_SYNC 1 struct async_op { ASYNC_JOB *job; -- 2.30.0
1 year, 2 months
1
0
0
0
← Newer
1
Older →
Jump to page:
1
Results per page:
10
25
50
100
200