Acc
Threads by month
- ----- 2026 -----
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 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
- October
- September
- August
- July
- June
- May
- April
- March
- February
- 1 participants
- 411 discussions
From: Weili Qian <qianweili(a)huawei.com>
The trng module is not required. Therefore, remove the trng module code.
Signed-off-by: Weili Qian <qianweili(a)huawei.com>
Signed-off-by: Qi Tao <taoqi10(a)huawei.com>
---
Makefile.am | 6 +-
configure.ac | 1 -
uadk_tool/Makefile.am | 1 -
uadk_tool/benchmark/trng_wd_benchmark.c | 333 ------------
uadk_tool/benchmark/trng_wd_benchmark.h | 7 -
uadk_tool/benchmark/uadk_benchmark.c | 15 -
uadk_tool/benchmark/uadk_benchmark.h | 1 -
v1/drv/hisi_rng_udrv.c | 167 ------
v1/drv/hisi_rng_udrv.h | 40 --
v1/libwd.map | 5 -
v1/test/Makefile.am | 1 -
v1/test/hisi_trng_test/Makefile.am | 20 -
v1/test/hisi_trng_test/test_hisi_trngk.c | 155 ------
v1/test/hisi_trng_test/test_hisi_trngp.c | 137 -----
v1/test/hisi_trng_test/test_hisi_trngu.c | 624 -----------------------
v1/wd.h | 2 +-
v1/wd_adapter.c | 7 -
v1/wd_rng.c | 296 -----------
v1/wd_rng.h | 76 ---
19 files changed, 3 insertions(+), 1891 deletions(-)
delete mode 100644 uadk_tool/benchmark/trng_wd_benchmark.c
delete mode 100644 uadk_tool/benchmark/trng_wd_benchmark.h
delete mode 100644 v1/drv/hisi_rng_udrv.c
delete mode 100644 v1/drv/hisi_rng_udrv.h
delete mode 100644 v1/test/hisi_trng_test/Makefile.am
delete mode 100755 v1/test/hisi_trng_test/test_hisi_trngk.c
delete mode 100644 v1/test/hisi_trng_test/test_hisi_trngp.c
delete mode 100755 v1/test/hisi_trng_test/test_hisi_trngu.c
delete mode 100644 v1/wd_rng.c
delete mode 100644 v1/wd_rng.h
diff --git a/Makefile.am b/Makefile.am
index d1a5953..7749613 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -49,9 +49,8 @@ uadk_driversdir=$(libdir)/uadk
uadk_drivers_LTLIBRARIES=libhisi_sec.la libhisi_hpre.la libhisi_zip.la \
libisa_ce.la libisa_sve.la libhisi_dae.la libhisi_udma.la
-libwd_la_SOURCES=wd.c wd_mempool.c wd_bmm.c wd_bmm.h wd.h wd_alg.c wd_alg.h \
+libwd_la_SOURCES=wd.c wd_mempool.c wd_bmm.c wd_bmm.h wd.h wd_alg.c wd_alg.h \
v1/wd.c v1/wd.h v1/wd_adapter.c v1/wd_adapter.h \
- v1/wd_rng.c v1/wd_rng.h \
v1/wd_rsa.c v1/wd_rsa.h \
v1/wd_aead.c v1/wd_aead.h \
v1/wd_dh.c v1/wd_dh.h \
@@ -68,8 +67,7 @@ libwd_la_SOURCES=wd.c wd_mempool.c wd_bmm.c wd_bmm.h wd.h wd_alg.c wd_alg.h \
v1/drv/hisi_zip_udrv.c v1/drv/hisi_zip_udrv.h \
v1/drv/hisi_zip_huf.c v1/drv/hisi_zip_huf.h \
v1/drv/hisi_hpre_udrv.c v1/drv/hisi_hpre_udrv.h \
- v1/drv/hisi_sec_udrv.c v1/drv/hisi_sec_udrv.h \
- v1/drv/hisi_rng_udrv.c v1/drv/hisi_rng_udrv.h
+ v1/drv/hisi_sec_udrv.c v1/drv/hisi_sec_udrv.h
libwd_udma_la_SOURCES=wd_udma.h wd_udma_drv.h wd_udma.c \
wd_util.c wd_util.h wd_sched.c wd_sched.h wd.c wd.h
diff --git a/configure.ac b/configure.ac
index 95c9f67..eb5a211 100644
--- a/configure.ac
+++ b/configure.ac
@@ -109,7 +109,6 @@ AC_CONFIG_FILES([Makefile
v1/test/bmm_test/Makefile
v1/test/test_mm/Makefile
v1/test/hisi_hpre_test/Makefile
- v1/test/hisi_trng_test/Makefile
v1/test/hisi_sec_test/Makefile
v1/test/hisi_sec_test_sgl/Makefile
v1/test/hisi_zip_test/Makefile
diff --git a/uadk_tool/Makefile.am b/uadk_tool/Makefile.am
index 86b3064..9a1703d 100644
--- a/uadk_tool/Makefile.am
+++ b/uadk_tool/Makefile.am
@@ -17,7 +17,6 @@ uadk_tool_SOURCES=uadk_tool.c dfx/uadk_dfx.c dfx/uadk_dfx.h \
benchmark/hpre_wd_benchmark.c hpre_wd_benchmark.h \
benchmark/zip_uadk_benchmark.c benchmark/zip_uadk_benchmark.h \
benchmark/zip_wd_benchmark.c benchmark/zip_wd_benchmark.h \
- benchmark/trng_wd_benchmark.c benchmark/trng_wd_benchmark.h \
test/uadk_test.c test/uadk_test.h \
test/test_sec.c test/test_sec.h test/sec_template_tv.h
diff --git a/uadk_tool/benchmark/trng_wd_benchmark.c b/uadk_tool/benchmark/trng_wd_benchmark.c
deleted file mode 100644
index 2f058d4..0000000
--- a/uadk_tool/benchmark/trng_wd_benchmark.c
+++ /dev/null
@@ -1,333 +0,0 @@
-/* SPDX-License-Identifier: Apache-2.0 */
-
-#include <numa.h>
-#include "uadk_benchmark.h"
-
-#include "trng_wd_benchmark.h"
-#include "v1/wd.h"
-#include "v1/wd_rng.h"
-
-struct thread_bd_res {
- struct wd_queue *queue;
- void *out;
- __u32 in_bytes;
-};
-
-struct thread_queue_res {
- struct thread_bd_res *bd_res;
-};
-
-struct wd_thread_res {
- u32 td_id;
- u32 pollid;
-};
-
-struct trng_async_tag {
- void *ctx;
- int optype;
-};
-
-static unsigned int g_thread_num;
-static struct thread_queue_res g_thread_queue;
-
-static int init_trng_wd_queue(struct acc_option *options)
-{
- int i, ret;
-
- g_thread_queue.bd_res = malloc(g_thread_num * sizeof(struct thread_bd_res));
- if (!g_thread_queue.bd_res) {
- printf("failed to malloc thread res memory!\n");
- return -ENOMEM;
- }
-
- for (i = 0; i < g_thread_num; i++) {
- g_thread_queue.bd_res[i].queue = malloc(sizeof(struct wd_queue));
- if (!g_thread_queue.bd_res[i].queue) {
- ret = -ENOMEM;
- goto free_mem;
- }
-
- g_thread_queue.bd_res[i].queue->capa.alg = options->algclass;
- /* nodemask need to be clean */
- g_thread_queue.bd_res[i].queue->node_mask = 0x0;
- memset(g_thread_queue.bd_res[i].queue->dev_path, 0x0, PATH_STR_SIZE);
- if (strlen(options->device) != 0) {
- ret = snprintf(g_thread_queue.bd_res[i].queue->dev_path,
- PATH_STR_SIZE, "%s", options->device);
- if (ret < 0) {
- WD_ERR("failed to copy dev file path!\n");
- return -WD_EINVAL;
- }
- }
-
- g_thread_queue.bd_res[i].in_bytes = options->pktlen;
- g_thread_queue.bd_res[i].out = malloc(options->pktlen);
- if (!g_thread_queue.bd_res[i].queue) {
- free(g_thread_queue.bd_res[i].queue);
- ret = -ENOMEM;
- goto free_mem;
- }
-
- ret = wd_request_queue(g_thread_queue.bd_res[i].queue);
- if (ret) {
- printf("failed to request queue %d, ret = %d!\n", i, ret);
- free(g_thread_queue.bd_res[i].out);
- free(g_thread_queue.bd_res[i].queue);
- goto free_mem;
- }
- }
-
- return 0;
-
-free_mem:
- for (i = i - 1; i >= 0; i--) {
- wd_release_queue(g_thread_queue.bd_res[i].queue);
- free(g_thread_queue.bd_res[i].out);
- free(g_thread_queue.bd_res[i].queue);
- }
-
- free(g_thread_queue.bd_res);
- return ret;
-}
-
-static void uninit_trng_wd_queue(void)
-{
- int j;
-
- for (j = 0; j < g_thread_num; j++) {
- wd_release_queue(g_thread_queue.bd_res[j].queue);
- free(g_thread_queue.bd_res[j].out);
- free(g_thread_queue.bd_res[j].queue);
- }
-
- free(g_thread_queue.bd_res);
-}
-
-static void *trng_wd_sync_run(void *arg)
-{
- struct wd_thread_res *pdata = (struct wd_thread_res *)arg;
- struct wcrypto_rng_ctx_setup trng_setup;
- struct wcrypto_rng_op_data opdata;
- struct wd_queue *queue;
- void *ctx = NULL;
- u32 count = 0;
- int ret;
-
- queue = g_thread_queue.bd_res[pdata->td_id].queue;
- ctx = wcrypto_create_rng_ctx(queue, &trng_setup);
- if (!ctx)
- return NULL;
-
- memset(&opdata, 0, sizeof(opdata));
- opdata.in_bytes = g_thread_queue.bd_res[pdata->td_id].in_bytes;
- opdata.out = g_thread_queue.bd_res[pdata->td_id].out;
- opdata.op_type = WCRYPTO_TRNG_GEN;
-
- do {
- ret = wcrypto_do_rng(ctx, &opdata, NULL);
- if (ret) {
- printf("failed to do rng task, ret: %d\n", ret);
- goto ctx_release;
- }
-
- count++;
- if (get_run_state() == 0)
- break;
- } while (true);
-
-ctx_release:
- wcrypto_del_rng_ctx(ctx);
- add_recv_data(count, opdata.in_bytes);
-
- return NULL;
-}
-
-static void trng_wd_sync_threads(void)
-{
- struct wd_thread_res threads_args[THREADS_NUM];
- pthread_t tdid[THREADS_NUM];
- int i, ret;
-
- for (i = 0; i < g_thread_num; i++) {
- threads_args[i].td_id = i;
- ret = pthread_create(&tdid[i], NULL, trng_wd_sync_run, &threads_args[i]);
- if (ret) {
- printf("failed to create sync thread!\n");
- return;
- }
- }
-
- /* join thread */
- for (i = 0; i < g_thread_num; i++) {
- ret = pthread_join(tdid[i], NULL);
- if (ret) {
- printf("failed to join sync thread!\n");
- return;
- }
- }
-}
-
-void *wd_trng_poll(void *data)
-{
- struct wd_thread_res *pdata = (struct wd_thread_res *)data;
- struct wd_queue *queue;
- u32 last_time = 2; // poll need one more recv time
- u32 count = 0;
- u32 in_bytes;
- int recv;
-
- in_bytes = g_thread_queue.bd_res[pdata->pollid].in_bytes;
- queue = g_thread_queue.bd_res[pdata->pollid].queue;
-
- while (last_time) {
- recv = wcrypto_rng_poll(queue, ACC_QUEUE_SIZE);
- if (recv < 0) {
- printf("failed to recv bd, ret: %d!\n", recv);
- goto recv_error;
- }
- count += recv;
-
- if (get_run_state() == 0)
- last_time--;
- }
-
-recv_error:
- add_recv_data(count, in_bytes);
-
- return NULL;
-}
-
-static void *trng_async_cb(const void *msg, void *tag)
-{
- return NULL;
-}
-
-static void *wd_trng_async_run(void *arg)
-{
- struct wd_thread_res *pdata = (struct wd_thread_res *)arg;
- struct wcrypto_rng_ctx_setup trng_setup;
- struct wcrypto_rng_op_data opdata;
- struct trng_async_tag *tag = NULL;
- struct wd_queue *queue;
- void *ctx = NULL;
- int ret, i;
-
- memset(&opdata, 0, sizeof(opdata));
-
- queue = g_thread_queue.bd_res[pdata->td_id].queue;
- trng_setup.cb = (void *)trng_async_cb;
-
- ctx = wcrypto_create_rng_ctx(queue, &trng_setup);
- if (!ctx)
- return NULL;
-
- opdata.in_bytes = g_thread_queue.bd_res[pdata->td_id].in_bytes;
- opdata.out = g_thread_queue.bd_res[pdata->td_id].out;
- opdata.op_type = WCRYPTO_TRNG_GEN;
-
- tag = malloc(sizeof(*tag) * MAX_POOL_LENTH);
- if (!tag) {
- printf("failed to malloc dh tag!\n");
- goto free_ctx;
- }
- tag->ctx = ctx;
-
- do {
- ret = wcrypto_do_rng(ctx, &opdata, tag);
- if (ret && ret != -WD_EBUSY) {
- printf("failed to send trng task, ret = %d!\n", ret);
- break;
- }
-
- if (get_run_state() == 0)
- break;
- } while (true);
-
- /* Release memory after all tasks are complete. */
- i = 0;
- while (get_recv_time() != g_thread_num) {
- if (i++ >= MAX_TRY_CNT) {
- printf("failed to wait poll thread finish!\n");
- break;
- }
-
- usleep(SEND_USLEEP);
- }
-
- if (tag)
- free(tag);
-free_ctx:
- wcrypto_del_rng_ctx(ctx);
- add_send_complete();
-
- return NULL;
-}
-
-static void trng_wd_async_threads(void)
-{
- struct wd_thread_res threads_args[THREADS_NUM];
- pthread_t tdid[THREADS_NUM];
- pthread_t pollid[THREADS_NUM];
- int i, ret;
-
- for (i = 0; i < g_thread_num; i++) {
- threads_args[i].pollid = i;
- /* poll thread */
- ret = pthread_create(&pollid[i], NULL, wd_trng_poll, &threads_args[i]);
- if (ret) {
- printf("failed to create poll thread!\n");
- return;
- }
- }
-
- for (i = 0; i < g_thread_num; i++) {
- threads_args[i].td_id = i;
- ret = pthread_create(&tdid[i], NULL, wd_trng_async_run, &threads_args[i]);
- if (ret) {
- printf("failed to create async thread!\n");
- return;
- }
- }
-
- /* join thread */
- for (i = 0; i < g_thread_num; i++) {
- ret = pthread_join(tdid[i], NULL);
- if (ret) {
- printf("failed to join async thread!\n");
- return;
- }
- }
-
- for (i = 0; i < g_thread_num; i++) {
- ret = pthread_join(pollid[i], NULL);
- if (ret) {
- printf("failed to join poll thread!\n");
- return;
- }
- }
-}
-
-int trng_wd_benchmark(struct acc_option *options)
-{
- u32 ptime;
- int ret;
-
- signal(SIGSEGV, segmentfault_handler);
- g_thread_num = options->threads;
-
- ret = init_trng_wd_queue(options);
- if (ret)
- return ret;
-
- get_pid_cpu_time(&ptime);
- time_start(options->times);
- if (options->syncmode)
- trng_wd_async_threads();
- else
- trng_wd_sync_threads();
- cal_perfermance_data(options, ptime);
-
- uninit_trng_wd_queue();
-
- return 0;
-}
diff --git a/uadk_tool/benchmark/trng_wd_benchmark.h b/uadk_tool/benchmark/trng_wd_benchmark.h
deleted file mode 100644
index 49453c8..0000000
--- a/uadk_tool/benchmark/trng_wd_benchmark.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* SPDX-License-Identifier: Apache-2.0 */
-
-#ifndef TRNG_WD_BENCHMARK_H
-#define TRNG_WD_BENCHMARK_H
-
-extern int trng_wd_benchmark(struct acc_option *options);
-#endif /* TRNG_WD_BENCHMARK_H */
diff --git a/uadk_tool/benchmark/uadk_benchmark.c b/uadk_tool/benchmark/uadk_benchmark.c
index fd64f6c..09e99e2 100644
--- a/uadk_tool/benchmark/uadk_benchmark.c
+++ b/uadk_tool/benchmark/uadk_benchmark.c
@@ -16,8 +16,6 @@
#include "zip_uadk_benchmark.h"
#include "zip_wd_benchmark.h"
-#include "trng_wd_benchmark.h"
-
#define TABLE_SPACE_SIZE 8
/*----------------------------------------head struct--------------------------------------------------------*/
@@ -157,7 +155,6 @@ static struct acc_alg_item alg_options[] = {
{"sha512", "sha512", SHA512_ALG},
{"sha512-224", "sha512-224", SHA512_224},
{"sha512-256", "sha512-256", SHA512_256},
- {"trng", "trng", TRNG},
{"", "", ALG_MAX}
};
@@ -463,11 +460,6 @@ static void parse_alg_param(struct acc_option *option)
option->acctype = HPRE_TYPE;
option->subtype = X448_TYPE;
break;
- case TRNG:
- snprintf(option->algclass, MAX_ALG_NAME, "%s", "trng");
- option->acctype = TRNG_TYPE;
- option->subtype = DEFAULT_TYPE;
- break;
default:
if (option->algtype <= RSA_4096_CRT) {
snprintf(option->algclass, MAX_ALG_NAME, "%s", "rsa");
@@ -596,13 +588,6 @@ static int benchmark_run(struct acc_option *option)
ret = zip_wd_benchmark(option);
}
break;
- case TRNG_TYPE:
- if (option->modetype == SVA_MODE)
- ACC_TST_PRT("TRNG not support sva mode..\n");
- else if (option->modetype == NOSVA_MODE)
- ret = trng_wd_benchmark(option);
-
- break;
}
return ret;
diff --git a/uadk_tool/benchmark/uadk_benchmark.h b/uadk_tool/benchmark/uadk_benchmark.h
index 9a0ad5e..83fd7fa 100644
--- a/uadk_tool/benchmark/uadk_benchmark.h
+++ b/uadk_tool/benchmark/uadk_benchmark.h
@@ -96,7 +96,6 @@ enum acc_type {
SEC_TYPE,
HPRE_TYPE,
ZIP_TYPE,
- TRNG_TYPE,
};
enum acc_init_type {
diff --git a/v1/drv/hisi_rng_udrv.c b/v1/drv/hisi_rng_udrv.c
deleted file mode 100644
index 605ef27..0000000
--- a/v1/drv/hisi_rng_udrv.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright 2018-2019 Huawei Technologies Co.,Ltd.All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <pthread.h>
-#include <sys/mman.h>
-#include <string.h>
-#include <stdint.h>
-#include <sys/epoll.h>
-#include <sys/eventfd.h>
-#include <sys/types.h>
-
-#include "hisi_rng_udrv.h"
-
-#define HISI_RNG_BYTES 4
-#define MAX_RETRY_COUNTS 8
-#define RNG_NUM_OFFSET 0x00F0
-
-int rng_init_queue(struct wd_queue *q)
-{
- struct q_info *qinfo = q->qinfo;
- struct rng_queue_info *info;
- int ret;
-
- info = calloc(1, sizeof(*info));
- if (!info) {
- WD_ERR("no mem!\n");
- return -ENOMEM;
- }
-
- ret = pthread_spin_init(&info->lock, PTHREAD_PROCESS_PRIVATE);
- if (ret) {
- free(info);
- WD_ERR("failed to init rng qinfo lock!\n");
- return ret;
- }
-
- qinfo->priv = info;
- info->mmio_base = wd_drv_mmap_qfr(q, WD_UACCE_QFRT_MMIO, 0);
- if (info->mmio_base == MAP_FAILED) {
- info->mmio_base = NULL;
- qinfo->priv = NULL;
- pthread_spin_destroy(&info->lock);
- free(info);
- WD_ERR("mmap trng mmio fail\n");
- return -ENOMEM;
- }
-
- return 0;
-}
-
-void rng_uninit_queue(struct wd_queue *q)
-{
- struct q_info *qinfo = q->qinfo;
- struct rng_queue_info *info = qinfo->priv;
-
- wd_drv_unmmap_qfr(q, info->mmio_base, WD_UACCE_QFRT_MMIO, 0);
-
- free(qinfo->priv);
- qinfo->priv = NULL;
- pthread_spin_destroy(&info->lock);
-}
-
-int rng_send(struct wd_queue *q, void **req, __u32 num)
-{
- struct q_info *qinfo = q->qinfo;
- struct rng_queue_info *info = qinfo->priv;
-
- pthread_spin_lock(&info->lock);
- if (!info->req_cache[info->send_idx]) {
- info->req_cache[info->send_idx] = req[0];
- info->send_idx++;
- pthread_spin_unlock(&info->lock);
- return 0;
- }
- pthread_spin_unlock(&info->lock);
-
- WD_ERR("queue is full!\n");
- return -WD_EBUSY;
-}
-
-static int rng_read(struct rng_queue_info *info, struct wcrypto_rng_msg *msg)
-{
- __u32 max = msg->in_bytes;
- __u32 currsize = 0;
- int recv_count = 0;
- __u32 val;
-
- do {
- val = wd_reg_read((void *)((uintptr_t)info->mmio_base +
- RNG_NUM_OFFSET));
- if (!val) {
- if (++recv_count > MAX_RETRY_COUNTS) {
- WD_ERR("read random data timeout\n");
- break;
- }
-
- usleep(1);
- continue;
- }
-
- recv_count = 0;
- if (max - currsize >= HISI_RNG_BYTES) {
- memcpy(msg->out + currsize, &val, HISI_RNG_BYTES);
- currsize += HISI_RNG_BYTES;
- if (currsize == max)
- break;
- continue;
- }
-
- memcpy(msg->out + currsize, &val, max - currsize);
- currsize = max;
- } while (currsize < max);
-
- return currsize;
-}
-
-int rng_recv(struct wd_queue *q, void **resp, __u32 num)
-{
- struct q_info *qinfo = q->qinfo;
- struct rng_queue_info *info = qinfo->priv;
- __u16 usr = (__u16)(uintptr_t)*resp;
- struct wcrypto_rng_msg *msg;
- struct wcrypto_cb_tag *tag;
- __u32 currsize = 0;
-
- pthread_spin_lock(&info->lock);
- msg = info->req_cache[info->recv_idx];
- if (!msg) {
- pthread_spin_unlock(&info->lock);
- return 0;
- }
-
- info->req_cache[info->recv_idx] = NULL;
- info->recv_idx++;
- pthread_spin_unlock(&info->lock);
-
- tag = (void *)(uintptr_t)msg->usr_tag;
- if (usr && tag->ctx_id != usr)
- return 0;
-
- currsize = rng_read(info, msg);
- if (!currsize) {
- WD_ERR("random data err!\n");
- return -WD_EINVAL;
- }
-
- msg->out_bytes = currsize;
- *resp = msg;
-
- return 1;
-}
diff --git a/v1/drv/hisi_rng_udrv.h b/v1/drv/hisi_rng_udrv.h
deleted file mode 100644
index 3efa10e..0000000
--- a/v1/drv/hisi_rng_udrv.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2018-2019 Huawei Technologies Co.,Ltd.All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __HISI_RNG_UDRV_H__
-#define __HISI_RNG_UDRV_H__
-
-#include <linux/types.h>
-#include "v1/wd.h"
-#include "v1/wd_util.h"
-#include "v1/wd_rng.h"
-
-#define TRNG_Q_DEPTH 256
-
-struct rng_queue_info {
- void *mmio_base;
- void *req_cache[TRNG_Q_DEPTH];
- __u8 send_idx;
- __u8 recv_idx;
- pthread_spinlock_t lock;
-};
-
-int rng_init_queue(struct wd_queue *q);
-void rng_uninit_queue(struct wd_queue *q);
-int rng_send(struct wd_queue *q, void **req, __u32 num);
-int rng_recv(struct wd_queue *q, void **resp, __u32 num);
-
-#endif
diff --git a/v1/libwd.map b/v1/libwd.map
index d53201b..6c54479 100644
--- a/v1/libwd.map
+++ b/v1/libwd.map
@@ -133,11 +133,6 @@ global:
wcrypto_rsa_poll;
wcrypto_del_rsa_ctx;
- wcrypto_create_rng_ctx;
- wcrypto_del_rng_ctx;
- wcrypto_do_rng;
- wcrypto_rng_poll;
-
wd_sglpool_create;
wd_sglpool_destroy;
wd_alloc_sgl;
diff --git a/v1/test/Makefile.am b/v1/test/Makefile.am
index bd41cfe..6cbf79f 100644
--- a/v1/test/Makefile.am
+++ b/v1/test/Makefile.am
@@ -7,7 +7,6 @@ SUBDIRS+=hisi_zip_test
endif
SUBDIRS+=hisi_zip_test_sgl
-SUBDIRS+=hisi_trng_test
if HAVE_CRYPTO
SUBDIRS+=hisi_hpre_test
diff --git a/v1/test/hisi_trng_test/Makefile.am b/v1/test/hisi_trng_test/Makefile.am
deleted file mode 100644
index b561585..0000000
--- a/v1/test/hisi_trng_test/Makefile.am
+++ /dev/null
@@ -1,20 +0,0 @@
-AM_CFLAGS=-Wall -Werror -O0 -fno-strict-aliasing -I$(top_srcdir)/include -I$(srcdir) -pthread
-
-if HAVE_CRYPTO
-bin_PROGRAMS=test_hisi_trngu_v1 test_hisi_trngk_v1 test_hisi_trngp_v1
-
-test_hisi_trngu_v1_SOURCES=test_hisi_trngu.c
-test_hisi_trngk_v1_SOURCES=test_hisi_trngk.c
-test_hisi_trngp_v1_SOURCES=test_hisi_trngp.c
-
-if WD_STATIC_DRV
-test_hisi_trngu_v1_LDADD=../../../.libs/libwd.la
-test_hisi_trngk_v1_LDADD=../../../.libs/libwd.la
-test_hisi_trngp_v1_LDADD=../../../.libs/libwd.la
-else
-test_hisi_trngu_v1_LDADD=../../../.libs/libwd.so
-test_hisi_trngk_v1_LDADD=../../../.libs/libwd.so
-test_hisi_trngp_v1_LDADD=../../../.libs/libwd.so
-endif
-
-endif
diff --git a/v1/test/hisi_trng_test/test_hisi_trngk.c b/v1/test/hisi_trng_test/test_hisi_trngk.c
deleted file mode 100755
index ae719e5..0000000
--- a/v1/test/hisi_trng_test/test_hisi_trngk.c
+++ /dev/null
@@ -1,155 +0,0 @@
-#include <assert.h>
-#include <stdio.h>
-#include <string.h>
-#include <fcntl.h>
-#define __USE_GNU
-#include <sched.h>
-#include <pthread.h>
-#include <sys/mman.h>
-#include <sys/time.h>
-#include <unistd.h>
-#include <getopt.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <semaphore.h>
-
-
-struct thread_info
-{
- pthread_t thread_id;
- unsigned int size;
- unsigned int num;
- int addr;
-
-};
-
-void *trng_thread(void *args)
-{
-
- int fd = -1;
- int fd_w = -1;
- int ret;
- unsigned int input;
- struct thread_info *tinfo = args;
- input = tinfo->size;
- unsigned int *data = (unsigned int*)malloc(sizeof(unsigned int) * input);
-
- if(!data)
- return NULL;
-
- if (tinfo->addr == 0){
-
-// printf("Now try to get %d bytes random number from /dev/hwrng.\n", input * 4);
- fd = open ("/dev/hwrng", O_RDONLY);
- }
- else if (tinfo->addr == 1){
-// printf("Now try to get %d bytes random number from /dev/random.\n", input * 4);
- fd = open ("/dev/random", O_RDONLY);
- }
-
- if (fd <0 ) {
- printf("can not open\n");
- return NULL;
- }
-
- fd_w = open ("/root/trng_file", O_WRONLY|O_CREAT|O_APPEND,0777);
- if (fd_w <0 ) {
- printf("can not open trng_file\n");
- return NULL;
- }
- memset(data, 0, sizeof(int) * input);
- ret = read(fd, data, input);
- if (ret < 0) {
- printf("read error %d\n", ret);
- return NULL;
- }
- ret =write(fd_w,data,input);
- if (ret < 0) {
- printf("write error %d\n", ret);
- return NULL;
- }
-
- close(fd);
- close(fd_w);
-
- return NULL;
-}
-
-
-void trng_test(int addr,int num,unsigned int si,int thread_num)
-{
-
- int i;
- void *ret = NULL;
- struct thread_info *tinfo;
- tinfo = calloc(thread_num, sizeof(struct thread_info));
-
- if (tinfo == NULL)
- {
- printf("calloc fail...\n");
- return;
- }
-
- for (i = 0; i<thread_num; ++i)
- {
- tinfo[i].thread_id = i;
- tinfo[i].addr = addr;
- tinfo[i].num = num;
- tinfo[i].size = si;
-
- if ((pthread_create(&tinfo[i].thread_id,NULL,trng_thread, (void *)&tinfo[i])) != 0)
- {
- return;
- }
- }
-
- for (i=0; i<thread_num; ++i)
- {
- if (pthread_join(tinfo[i].thread_id, &ret) != 0)
- {
- printf("thread is not exit....\n");
- return;
- }
- //printf("thread exit coid %d\n", (int *)ret);
- free(ret);
- }
- free(tinfo);
-}
-
-
-
-
-int main (int argc, char* argv[]) {
-
- int opt;
- int addr = 0, num = 0, thread_num = 0;
- unsigned int si = 0;
-
- while ((opt = getopt(argc, argv, "hri:p:s:")) != -1) {
- switch (opt) {
- case 'h':
- addr = 0;
- break;
- case 'r':
- addr = 1;
- break;
- case 'i':
- num = atoi(optarg);
- break;
- case 'p':
- thread_num = atoi(optarg);
- break;
- case 's':
- si = (unsigned int)atoi(optarg);
- break;
- default:
- break;
- }
- }
-
- trng_test(addr,num,si,thread_num);
-
- return 0;
-}
diff --git a/v1/test/hisi_trng_test/test_hisi_trngp.c b/v1/test/hisi_trng_test/test_hisi_trngp.c
deleted file mode 100644
index 2330b1e..0000000
--- a/v1/test/hisi_trng_test/test_hisi_trngp.c
+++ /dev/null
@@ -1,137 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <pthread.h>
-#include <unistd.h>
-
-static int input;
-static int thread_num;
-struct thread_info
-{
- pthread_t thread_id;
- unsigned int size;
- int num;
-};
-
-void *trng_thread(void *args)
-{
- int j;
- int fd = -1;
- int data;
- int ret;
- struct thread_info *tinfo = args;
- int si;
- int num;
- int size;
- int fd_w = -1;
- si = tinfo->size;
- num = tinfo->num;
- size=si/num;
- printf("Now try to get bytes random number from /dev/random.\n");
- fd = open("/dev/random", O_RDONLY);
- if (fd <0 ) {
- printf("can not open\n");
- return NULL;
- }
- for (j = 0; j< size; j++) {
- ret = read(fd, &data, 1);
- if (ret < 0) {
- printf("read error %d\n", ret);
- return NULL;
- }
-// else if (ret < 1)
-// goto rd_ag;
-// if (!data) {
-// printf("read data error!\n");
-// return data;
-// }
- printf("the read num:%x\n",data);
- }
- fd_w = open ("/root/trng_file", O_RDWR | O_CREAT |O_APPEND , 0777);
- if (fd_w <0 ) {
- printf("can not open trng_file\n");
- return NULL;
- }
- ret = write(fd_w,&data,size);
- if (ret < 0) {
- printf("write error %d\n", ret);
- return NULL;
- }
- close(fd);
- close(fd_w);
- return NULL;
-}
-
-void trng_test(int input,int thread_num)
-{
- int i;
- void *ret = NULL;
- struct thread_info *tinfo;
- tinfo = calloc(thread_num, sizeof(struct thread_info));
- if(tinfo == NULL)
- {
- printf("calloc fail...\n");
- return;
- }
- for(i = 0; i<thread_num; ++i)
- {
- tinfo[i].thread_id = i;
- tinfo[i].num=thread_num;
-// tinfo[i].addr = addr;
-// tinfo[i].num = num;
- tinfo[i].size = input;
- if((pthread_create(&tinfo[i].thread_id,NULL,trng_thread, (void *)&tinfo[i])) != 0)
- {
- return;
- }
- }
-
- for(i=0; i<thread_num; ++i)
- {
- if(pthread_join(tinfo[i].thread_id, &ret) != 0)
- {
- printf("thread is not exit....\n");
- return;
- }
-// printf("thread exit coid %d\n", (int *)ret);
- free(ret);
- }
- free(tinfo);
-}
-
-int main (int argc, char* argv[])
-{
- struct timeval start_tval, end_tval;
- float time,speed;
- int fd_f=-1;
- fd_f = open ("/root/trng_file", O_RDWR | O_CREAT |O_TRUNC, 0777);
- if (fd_f <0 ) {
- printf("can not open trng_file\n");
- return fd_f;
- }
- input = strtoul(argv[1], NULL, 10);
- if (input <= 0){
- printf("input error!\n");
- return -1;
- }
- thread_num = strtoul((char *)argv[2], NULL, 10);
- if (thread_num <= 0 || thread_num > 128) {
- printf("Invalid threads num:%d!\n",thread_num);
- printf("Now set threads num as 2\n");
- thread_num = 2;
- }
- gettimeofday(&start_tval, NULL);
- trng_test(input,thread_num);
- gettimeofday(&end_tval, NULL);
- time = (float)((end_tval.tv_sec - start_tval.tv_sec) * 1000000 +
- (end_tval.tv_usec - start_tval.tv_usec));
- speed = input/(time / 1000000);
- printf("read random speed: %0.0f time\n", time);
- printf("read random speed: %0.0f bytes/s\n", speed);
- close(fd_f);
- return 0;
-}
diff --git a/v1/test/hisi_trng_test/test_hisi_trngu.c b/v1/test/hisi_trng_test/test_hisi_trngu.c
deleted file mode 100755
index 86aa8a9..0000000
--- a/v1/test/hisi_trng_test/test_hisi_trngu.c
+++ /dev/null
@@ -1,624 +0,0 @@
-/*
- * Copyright 2019 Huawei Technologies Co.,Ltd.All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <fcntl.h>
-#define __USE_GNU
-#include <sched.h>
-#include <pthread.h>
-#include <sys/mman.h>
-#include <sys/types.h>
-#include <sys/syscall.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <unistd.h>
-#include <semaphore.h>
-
-#include "../../wd.h"
-#include "../../wd_rng.h"
-
-#define RNG_TST_PRT printf
-#define BN_ULONG unsigned long
-#define TEST_MAX_THRD 128
-#define MAX_TRY_TIMES 10000
-#define LOG_INTVL_NUM 8
-#define TEST_CNT 10
-
-static int q_num = 1;
-static int ctx_num_per_q = 1;
-
-enum alg_op_type {
- TRNG_GEN,
- TRNG_AGEN,
-};
-
-struct trng_user_tag_info {
- int pid;
- int thread_id;
-};
-
-struct test_trng_pthread_dt {
- int cpu_id;
- int thread_num;
- void *q;
-};
-
-static struct test_trng_pthread_dt test_thrds_data[TEST_MAX_THRD];
-static pthread_t system_test_thrds[TEST_MAX_THRD];
-static unsigned int g_input;
-
-
-static inline int _get_cpu_id(int thr, __u64 core_mask)
-{
- __u64 i;
- int cnt = 0;
-
- for (i = 1; i < 64; i++) {
- if (core_mask & (0x1ull << i)) {
- if (thr == cnt)
- return i;
- cnt++;
- }
- }
-
- return 0;
-}
-
-static inline int _get_one_bits(__u64 val)
-{
- int count = 0;
-
- while (val) {
- if (val % 2 == 1)
- count++;
- val = val / 2;
- }
-
- return count;
-}
-
-void *_trng_sys_test_thread(void *data)
-{
- int ret, cpuid, i = 0;
- struct test_trng_pthread_dt *pdata = data;
- struct wcrypto_rng_ctx_setup setup;
- struct wcrypto_rng_op_data opdata;
- int pid = getpid();
- int thread_id = (int)syscall(__NR_gettid);
- struct wd_queue *q;
- int *out_data;
- void *ctx = NULL;
- void *tag = NULL;
-
- cpu_set_t mask;
- CPU_ZERO(&mask);
- cpuid = pdata->cpu_id;
- q = pdata->q;
- CPU_SET(cpuid, &mask);
-
- if (cpuid) {
- ret = pthread_setaffinity_np(pthread_self(),
- sizeof(mask), &mask);
- if (ret < 0) {
- RNG_TST_PRT("Proc-%d, thrd-%d:set affinity fail!\n",
- pid, thread_id);
- return NULL;
- }
- RNG_TST_PRT("Proc-%d, thrd-%d bind to cpu-%d!\n",
- pid, thread_id, cpuid);
- }
-
- memset(&setup, 0, sizeof(setup));
- memset(&opdata, 0, sizeof(opdata));
- ctx = wcrypto_create_rng_ctx(q, &setup);
- if (!ctx) {
- RNG_TST_PRT("Proc-%d, %d-TD:create %s ctx fail!\n",
- pid, thread_id, q->capa.alg);
- ret = -EINVAL;
- goto fail_release;
- }
-
- out_data = malloc(g_input);
- if(!out_data) {
- RNG_TST_PRT("malloc out_data memory fail!\n");
- }
- RNG_TST_PRT("request queue fail5!\n");
-
- while (1) {
- opdata.in_bytes = g_input;
- opdata.out = out_data;
- ret = wcrypto_do_rng(ctx, &opdata, tag);
- if (ret < 0) {
- RNG_TST_PRT("Proc-%d, T-%d:trng %d fail!\n", pid, thread_id, i);
- goto fail_release;
- }
- RNG_TST_PRT("the read data size %d!\n", opdata.out_bytes);
- i++;
- }
-fail_release:
- if (opdata.out)
- free(opdata.out);
- if (ctx)
- wcrypto_del_rng_ctx(ctx);
- return NULL;
-}
-
-
-static int trng_sys_test(int thread_num, __u64 lcore_mask,
- __u64 hcore_mask)
-{
- int i, ret, cnt = 0, j;
- struct wd_queue *q;
- int h_cpuid, qidx;
-
- q = malloc(q_num * sizeof(struct wd_queue));
- if (!q) {
- RNG_TST_PRT("malloc q memory fail!\n");
- return -ENOMEM;
- }
- memset(q, 0, q_num * sizeof(struct wd_queue));
-
- for (j = 0; j < q_num; j++) {
- q[j].capa.alg = "trng";
- ret = wd_request_queue(&q[j]);
- if (ret) {
- RNG_TST_PRT("request queue %d fail!\n", j);
- return ret;
- }
- }
- RNG_TST_PRT("request queue fail!\n");
- if (_get_one_bits(lcore_mask) > 0)
- cnt = _get_one_bits(lcore_mask);
- else if (_get_one_bits(lcore_mask) == 0 &&
- _get_one_bits(hcore_mask) == 0)
- cnt = thread_num;
-
- for (i = 0; i < cnt; i++) {
- qidx = i / ctx_num_per_q;
- test_thrds_data[i].q = &q[qidx];
- test_thrds_data[i].thread_num = thread_num;
- test_thrds_data[i].cpu_id = _get_cpu_id(i, lcore_mask);
- ret = pthread_create(&system_test_thrds[i], NULL,
- _trng_sys_test_thread, &test_thrds_data[i]);
- if (ret) {
- RNG_TST_PRT("Create %dth thread fail!\n", i);
- return ret;
- }
- }
- RNG_TST_PRT("request queue fail2!\n");
- for (i = 0; i < thread_num - cnt; i++) {
- h_cpuid = _get_cpu_id(i, hcore_mask);
- if (h_cpuid > 0)
- h_cpuid += 64;
-
- qidx = (i + cnt) / ctx_num_per_q;
- test_thrds_data[i + cnt].q = &q[qidx];
- test_thrds_data[i + cnt].thread_num = thread_num;
- test_thrds_data[i + cnt].cpu_id = h_cpuid;
- ret = pthread_create(&system_test_thrds[i + cnt], NULL,
- _trng_sys_test_thread, &test_thrds_data[i + cnt]);
- if (ret) {
- RNG_TST_PRT("Create %dth thread fail!\n", i);
- return ret;
- }
- }
- RNG_TST_PRT("request queue fail3!\n");
- for (i = 0; i < thread_num; i++) {
- ret = pthread_join(system_test_thrds[i], NULL);
- if (ret) {
- RNG_TST_PRT("Join %dth thread fail!\n", i);
- return ret;
- }
- }
- free(q);
- return 0;
-}
-
-
-static void _trng_cb(const void *message, void *tag)
-{
- const struct wcrypto_rng_msg *msg = message;
- struct trng_user_tag_info* pSwData = (struct trng_user_tag_info*)tag;
- struct wcrypto_rng_op_data opdata;
- int pid, threadId;
-
- if (NULL == pSwData) {
- RNG_TST_PRT("pSwData NULL!\n");
- return;
- }
- memset(&opdata, 0, sizeof(opdata));
-
- opdata.out = (void *)msg->out;
- opdata.out_bytes = msg->out_bytes;
- pid = pSwData->pid;
- threadId = pSwData->thread_id;
- RNG_TST_PRT("Proc-%d, %d-TD trng\n", pid, threadId);
- RNG_TST_PRT("the random number size :%d\n", opdata.out_bytes);
-
- if (opdata.out)
- free(opdata.out);
-
- if (pSwData)
- free(pSwData);
-}
-
-static void *_trng_asys_test_thread(void *data)
-{
- int ret, cpuid;
- struct test_trng_pthread_dt *pdata = data;
- struct wd_queue *q = NULL;
- cpu_set_t mask;
- struct wcrypto_rng_ctx_setup setup;
- struct wcrypto_rng_ctx *ctx = NULL;
- struct trng_user_tag_info *tag = NULL;
- struct wcrypto_rng_op_data opdata;
- int pid = getpid();
- int thread_id = (int)syscall(__NR_gettid);
- int *out_data;
- int i = 0;
-
- CPU_ZERO(&mask);
- cpuid = pdata->cpu_id;
- q = (struct wd_queue *)pdata->q;
- CPU_SET(cpuid, &mask);
-
- if (!q) {
- RNG_TST_PRT("q null!\n");
- return NULL;
- }
- if (cpuid) {
- ret = pthread_setaffinity_np(pthread_self(),
- sizeof(mask), &mask);
- if (ret < 0) {
- RNG_TST_PRT("Proc-%d, thrd-%d:set affinity fail!\n",
- pid, thread_id);
- return NULL;
- }
- RNG_TST_PRT("Proc-%d, thrd-%d bind to cpu-%d!\n",
- pid, thread_id, cpuid);
- }
-
- q->capa.alg = "trng";
- memset(&setup, 0, sizeof(setup));
- memset(&opdata, 0, sizeof(opdata));
- setup.cb = _trng_cb;
- ctx = wcrypto_create_rng_ctx(q, &setup);
- if (!ctx) {
- RNG_TST_PRT("Proc-%d, %d-TD:create %s ctx fail!\n",
- pid, thread_id, q->capa.alg);
- goto fail_release;
- }
-
- while(1) {
- tag = malloc(sizeof(struct trng_user_tag_info));
- if (!tag) {
- RNG_TST_PRT("malloc tag fail!\n");
- goto fail_release;
- }
-
- tag->pid = pid;
- tag->thread_id = thread_id;
-
- out_data = malloc(g_input);
- if(!out_data) {
- RNG_TST_PRT("malloc fail\n");
- return 0;
- }
-
- opdata.in_bytes = g_input;
- opdata.out = out_data;
- try_again:
- ret = wcrypto_do_rng(ctx, &opdata, tag);
- if (ret == -WD_EBUSY) {
- usleep(100);
- goto try_again;
- } else if(ret) {
- RNG_TST_PRT("Proc-%d, T-%d:trng %d fail!\n", pid, thread_id, i);
- goto fail_release;
- }
- i++;
- }
-fail_release:
- wcrypto_del_rng_ctx(ctx);
- return NULL;
-}
-
-static void* _trng_async_poll_test_thread(void *data)
-{
- struct test_trng_pthread_dt *pdata = data;
- struct wd_queue *q = pdata->q;
- int ret, cpuid;
- int pid = getpid();
- cpu_set_t mask;
- int thread_id = (int)syscall(__NR_gettid);
-
- CPU_ZERO(&mask);
- cpuid = pdata->cpu_id;
- CPU_SET(cpuid, &mask);
- if (cpuid) {
- ret = pthread_setaffinity_np(pthread_self(), sizeof(mask), &mask);
- if (ret < 0) {
- RNG_TST_PRT("Proc-%d, thrd-%d:set affinity fail!\n",
- pid, thread_id);
- return NULL;
- }
- RNG_TST_PRT("Proc-%d, poll thrd-%d bind to cpu-%d!\n",
- pid, thread_id, cpuid);
- }
-
- while (1) {
- ret = wcrypto_rng_poll(q, 1);
- if (ret < 0) {
- break;
- }
- }
-
- return NULL;
-}
-
-static int trng_asys_test(int thread_num, __u64 lcore_mask, __u64 hcore_mask)
-{
- int i, ret, cnt = 0;
- struct wd_queue q;
- int h_cpuid;
-
- memset(&q, 0, sizeof(q));
-
- q.capa.alg = "trng";
- ret = wd_request_queue(&q);
- if (ret) {
- RNG_TST_PRT("request queue fail!\n");
- return ret;
- }
-
- if (_get_one_bits(lcore_mask) > 0)
- cnt = _get_one_bits(lcore_mask);
- else if (_get_one_bits(lcore_mask) == 0 &&
- _get_one_bits(hcore_mask) == 0)
- cnt = thread_num;
-
- test_thrds_data[0].q= &q;
- test_thrds_data[0].thread_num = 1;
- test_thrds_data[0].cpu_id = _get_cpu_id(0, lcore_mask);
- ret = pthread_create(&system_test_thrds[0], NULL,
- _trng_async_poll_test_thread, &test_thrds_data[0]);
- if (ret) {
- RNG_TST_PRT("Create poll thread fail!\n");
- return ret;
- }
-
- for (i = 1; i <= cnt; i++) {
- test_thrds_data[i].q = &q;
- test_thrds_data[i].thread_num = thread_num;
- test_thrds_data[i].cpu_id = _get_cpu_id(i, lcore_mask);
- ret = pthread_create(&system_test_thrds[i], NULL,
- _trng_asys_test_thread, &test_thrds_data[i]);
- if (ret) {
- RNG_TST_PRT("Create %dth thread fail!\n", i);
- return ret;
- }
- }
-
- for (i = 1; i <= thread_num - cnt; i++) {
- h_cpuid = _get_cpu_id(i, hcore_mask);
- if (h_cpuid > 0)
- h_cpuid += 64;
- test_thrds_data[i + cnt].q = &q;
- test_thrds_data[i + cnt].thread_num = thread_num;
- test_thrds_data[i + cnt].cpu_id = h_cpuid;
- ret = pthread_create(&system_test_thrds[i + cnt], NULL,
- _trng_asys_test_thread, &test_thrds_data[i + cnt]);
- if (ret) {
- RNG_TST_PRT("Create %dth thread fail!\n", i);
- return ret;
- }
- }
-
- for (i = 0; i < thread_num; i++) {
- ret = pthread_join(system_test_thrds[i], NULL);
- if (ret) {
- RNG_TST_PRT("Join %dth thread fail!\n", i);
- return ret;
- }
- }
-
- wd_release_queue(&q);
- return 0;
-
-}
-int main(int argc, char *argv[])
-{
- struct wcrypto_rng_ctx *ctx;
- struct wcrypto_rng_op_data opdata;
- struct wcrypto_rng_ctx_setup setup;
- enum alg_op_type alg_op_type = TRNG_GEN;
- int thread_num, bits;
- __u64 core_mask[2];
- struct wd_queue q;
- void *tag = NULL;
- int *data;
- int ret;
- int fd = -1;
- int fd_w = -1;
- if (!argv[1]) {
- RNG_TST_PRT("pls printf the size of the random data!\n");
- return -WD_EINVAL;
- }
- g_input = (unsigned int)strtoul(argv[1], NULL, 10);
- printf("g_input:%d\n",g_input);
- //if (g_input <= 0){
- // printf("input error!\n");
- // return -WD_EINVAL;
- //}
- if (argv[2]) {
- if(!strcmp(argv[2], "-system-gen")) {
- alg_op_type = TRNG_GEN;
- RNG_TST_PRT("Now doing system random number gen test!\n");
- } else if(!strcmp(argv[2], "-system-agen")) {
- alg_op_type = TRNG_AGEN;
- RNG_TST_PRT("Now doing system random number agen test!\n");
- }
-
- thread_num = strtoul((char *)argv[3], NULL, 10);
- if (thread_num <= 0 || thread_num > TEST_MAX_THRD) {
- RNG_TST_PRT("Invalid threads num:%d!\n",
- thread_num);
- RNG_TST_PRT("Now set threads num as 2\n");
- thread_num = 2;
- }
-
- if (strcmp(argv[4], "-c")) {
- RNG_TST_PRT("./test_hisi_trng --help get details\n");
- return -EINVAL;
- }
- if (argv[5][0] != '0' || argv[5][1] != 'x') {
- RNG_TST_PRT("Err:coremask should be hex!\n");
- return -EINVAL;
- }
-
- if (strlen(argv[5]) > 34) {
- RNG_TST_PRT("Warning: coremask is cut!\n");
- argv[5][34] = 0;
- }
-
- if (strlen(argv[5]) <= 18) {
- core_mask[0] = strtoull(argv[5], NULL, 16);
- if (core_mask[0] & 0x1) {
- RNG_TST_PRT("Warn:cannot bind to core 0,\n");
- RNG_TST_PRT("now run without binding\n");
- core_mask[0] = 0x0; /* no binding */
- }
- core_mask[1] = 0;
- } else {
- int offset = 0;
- char *temp;
-
- offset = strlen(argv[5]) - 16;
- core_mask[0] = strtoull(&argv[5][offset], NULL, 16);
- if (core_mask[0] & 0x1) {
- RNG_TST_PRT("Warn:cannot bind to core 0,\n");
- RNG_TST_PRT("now run without binding\n");
- core_mask[0] = 0x0; /* no binding */
- }
- temp = malloc(64);
- strcpy(temp, argv[5]);
- temp[offset] = 0;
- core_mask[1] = strtoull(temp, NULL, 16);
- free(temp);
- }
-
- bits = _get_one_bits(core_mask[0]);
- bits += _get_one_bits(core_mask[1]);
- if (thread_num > bits) {
- RNG_TST_PRT("Coremask not covers all thrds,\n");
- RNG_TST_PRT("Bind first %d thrds!\n", bits);
- } else if (thread_num < bits) {
- RNG_TST_PRT("Coremask overflow,\n");
- RNG_TST_PRT("Just try to bind all thrds!\n");
- }
-
- if (argv[6]) {
- ctx_num_per_q = strtoul(argv[6], NULL, 10);
- if (ctx_num_per_q <= 0) {
- RNG_TST_PRT("Invalid ctx num per queue:%s!\n",
- argv[6]);
- RNG_TST_PRT("Now ctx num per queue is set as 1!\n");
- ctx_num_per_q = 1;
- }
- } else {
- RNG_TST_PRT("Now ctx num per queue is set as 1!\n");
- ctx_num_per_q = 1;
- }
-
- q_num = (thread_num - 1) / ctx_num_per_q + 1;
-
- RNG_TST_PRT("Proc-%d: starts %d threads bind to %s\n",
- getpid(), thread_num, argv[5]);
- RNG_TST_PRT(" lcoremask=0x%llx, hcoremask=0x%llx\n",
- core_mask[0], core_mask[1]);
- if(alg_op_type == TRNG_GEN)
- return trng_sys_test(thread_num, core_mask[0],
- core_mask[1]);
-
- return trng_asys_test(thread_num, core_mask[0],
- core_mask[1]);
- }
-
- RNG_TST_PRT("Now try to get %d bytes random number.\n", g_input);
-
- data = malloc(g_input);
- if (!data) {
- RNG_TST_PRT("malloc data failed.\n");
- return -1;
- }
-
- memset((void *)&q, 0, sizeof(q));
- memset(&setup, 0, sizeof(setup));
- memset(&opdata, 0, sizeof(opdata));
-
- q.capa.alg = "trng";
- ret = wd_request_queue(&q);
- if (ret) {
- RNG_TST_PRT("request queue fail!\n");
- return ret;
- }
- ctx = wcrypto_create_rng_ctx(&q, &setup);
- if (!ctx) {
- ret = -ENOMEM;
- RNG_TST_PRT("create trng ctx fail!\n");
- goto release_q;
- }
-
- opdata.in_bytes = g_input;
- opdata.out = data;
- ret = wcrypto_do_rng(ctx, &opdata, tag);
- if (ret != 1) {
- RNG_TST_PRT("a wd_do_trng fail!\n");
- goto del_ctx;
- }
-
- RNG_TST_PRT("random_data size= %d.\n", opdata.out_bytes);
- fd_w = open ("/root/trng_file", O_RDWR|O_CREAT|O_TRUNC,0777);
- if (fd_w <0 ) {
- printf("can not open trng_file\n");
- return fd_w;
- }
- /*fd = open ("/dev/random", O_RDONLY);
- if (fd <0 ) {
- printf("can not open\n");
- return fd;
- }*/
- /*ret = read(fd, data, g_input);
- if (ret < 0) {
- printf("read error %d\n", ret);
- return ret;
- }*/
- ret = write(fd_w,opdata.out,opdata.out_bytes);
- if (ret < 0) {
- printf("write error %d\n", ret);
- return ret;
- }
- close(fd);
- close(fd_w);
-del_ctx:
- wcrypto_del_rng_ctx(ctx);
-
-release_q:
- wd_release_queue(&q);
- free(data);
- return ret;
-}
diff --git a/v1/wd.h b/v1/wd.h
index 0132e25..35dcf31 100644
--- a/v1/wd.h
+++ b/v1/wd.h
@@ -184,7 +184,7 @@ struct wd_capa {
* Other capabilities.
* 0~15 bits: number of cookies that the user wants to allocate.
* Optional, user can set value based on the number of requests and system memory,
- * 1~1024 is valid. If the value is not set or invalid, the default value 64 (rng is 256)
+ * 1~1024 is valid. If the value is not set or invalid, the default value 64
* is used to initialize cookies.
*/
__u32 flags;
diff --git a/v1/wd_adapter.c b/v1/wd_adapter.c
index 1c9f656..df5368d 100644
--- a/v1/wd_adapter.c
+++ b/v1/wd_adapter.c
@@ -20,7 +20,6 @@
#include "v1/wd_util.h"
#include "v1/drv/hisi_qm_udrv.h"
-#include "v1/drv/hisi_rng_udrv.h"
#include "v1/wd_adapter.h"
#define __ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask))
@@ -87,12 +86,6 @@ static const struct wd_drv_dio_if hw_dio_tbl[] = { {
.init_sgl = qm_init_hwsgl_mem,
.uninit_sgl = qm_uninit_hwsgl_mem,
.sgl_merge = qm_merge_hwsgl,
- }, {
- .hw_type = "hisi-trng-v2",
- .open = rng_init_queue,
- .close = rng_uninit_queue,
- .send = rng_send,
- .recv = rng_recv,
},
};
diff --git a/v1/wd_rng.c b/v1/wd_rng.c
deleted file mode 100644
index 7a89cd1..0000000
--- a/v1/wd_rng.c
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- * Copyright 2019 Huawei Technologies Co.,Ltd.All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-
-#include <sys/types.h>
-#include <sys/mman.h>
-
-#include "wd.h"
-#include "wd_util.h"
-#include "wd_rng.h"
-
-#define RNG_RESEND_CNT 8
-#define RNG_RECV_CNT 8
-#define WD_RNG_CTX_COOKIE_NUM 256
-
-struct wcrypto_rng_cookie {
- struct wcrypto_cb_tag tag;
- struct wcrypto_rng_msg msg;
-};
-
-struct wcrypto_rng_ctx {
- struct wd_cookie_pool pool;
- unsigned long ctx_id;
- struct wd_queue *q;
- struct wcrypto_rng_ctx_setup setup;
-};
-
-static int wcrypto_setup_qinfo(struct wcrypto_rng_ctx_setup *setup,
- struct wd_queue *q, __u32 *ctx_id)
-{
- struct q_info *qinfo;
- int ret = -WD_EINVAL;
-
- if (!q || !q->qinfo || !setup) {
- WD_ERR("input parameter err!\n");
- return ret;
- }
-
- if (strcmp(q->capa.alg, "trng")) {
- WD_ERR("algorithm mismatch!\n");
- return ret;
- }
- qinfo = q->qinfo;
- /* lock at ctx creating */
- wd_spinlock(&qinfo->qlock);
- if (qinfo->ctx_num >= WD_MAX_CTX_NUM) {
- WD_ERR("create too many trng ctx!\n");
- goto unlock;
- }
-
- ret = wd_alloc_id(qinfo->ctx_id, WD_MAX_CTX_NUM, ctx_id, 0,
- WD_MAX_CTX_NUM);
- if (ret) {
- WD_ERR("err: alloc ctx id fail!\n");
- goto unlock;
- }
- qinfo->ctx_num++;
- ret = WD_SUCCESS;
-unlock:
- wd_unspinlock(&qinfo->qlock);
- return ret;
-}
-
-void *wcrypto_create_rng_ctx(struct wd_queue *q,
- struct wcrypto_rng_ctx_setup *setup)
-{
- struct wcrypto_rng_cookie *cookie;
- struct wcrypto_rng_ctx *ctx;
- struct q_info *qinfo;
- __u32 cookies_num, i;
- __u32 ctx_id = 0;
- int ret;
-
- if (wcrypto_setup_qinfo(setup, q, &ctx_id))
- return NULL;
-
- ctx = calloc(1, sizeof(struct wcrypto_rng_ctx));
- if (!ctx) {
- WD_ERR("alloc ctx memory fail!\n");
- goto free_ctx_id;
- }
- memcpy(&ctx->setup, setup, sizeof(*setup));
- ctx->q = q;
- ctx->ctx_id = ctx_id + 1;
-
- cookies_num = wd_get_ctx_cookies_num(q->capa.flags, WD_RNG_CTX_COOKIE_NUM);
- ret = wd_init_cookie_pool(&ctx->pool,
- sizeof(struct wcrypto_rng_cookie), cookies_num);
- if (ret) {
- WD_ERR("fail to init cookie pool!\n");
- free(ctx);
- goto free_ctx_id;
- }
- for (i = 0; i < cookies_num; i++) {
- cookie = (void *)((uintptr_t)ctx->pool.cookies +
- i * ctx->pool.cookies_size);
- cookie->msg.alg_type = WCRYPTO_RNG;
- cookie->tag.ctx = ctx;
- cookie->tag.ctx_id = ctx->ctx_id;
- cookie->msg.usr_tag = (uintptr_t)&cookie->tag;
- }
-
- return ctx;
-
-free_ctx_id:
- qinfo = q->qinfo;
- wd_spinlock(&qinfo->qlock);
- qinfo->ctx_num--;
- wd_free_id(qinfo->ctx_id, WD_MAX_CTX_NUM, ctx_id, WD_MAX_CTX_NUM);
- wd_unspinlock(&qinfo->qlock);
-
- return NULL;
-}
-
-void wcrypto_del_rng_ctx(void *ctx)
-{
- struct wcrypto_rng_ctx *cx;
- struct q_info *qinfo;
-
- if (!ctx) {
- WD_ERR("delete trng ctx is NULL!\n");
- return;
- }
-
- cx = ctx;
- qinfo = cx->q->qinfo;
-
- wd_uninit_cookie_pool(&cx->pool);
- wd_spinlock(&qinfo->qlock);
- if (qinfo->ctx_num <= 0) {
- wd_unspinlock(&qinfo->qlock);
- WD_ERR("repeat delete trng ctx!\n");
- return;
- }
- qinfo->ctx_num--;
- wd_free_id(qinfo->ctx_id, WD_MAX_CTX_NUM, cx->ctx_id - 1,
- WD_MAX_CTX_NUM);
- wd_unspinlock(&qinfo->qlock);
-
- free(ctx);
-}
-
-int wcrypto_rng_poll(struct wd_queue *q, unsigned int num)
-{
- struct wcrypto_rng_msg *resp = NULL;
- struct wcrypto_rng_ctx *ctx;
- struct wcrypto_cb_tag *tag;
- unsigned int tmp = num;
- int count = 0;
- int ret;
-
- if (!q) {
- WD_ERR("%s(): input parameter err!\n", __func__);
- return -WD_EINVAL;
- }
-
- do {
- ret = wd_recv(q, (void **)&resp);
- if (!ret)
- break;
-
- if (ret < 0) {
- WD_ERR("recv err at trng poll!\n");
- return ret;
- }
-
- count++;
- tag = (void *)(uintptr_t)resp->usr_tag;
- ctx = tag->ctx;
- ctx->setup.cb(resp, tag->tag);
- wd_put_cookies(&ctx->pool, (void **)&tag, 1);
- resp = NULL;
- } while (--tmp);
-
- return count;
-}
-
-static int wcrypto_do_prepare(struct wcrypto_rng_cookie **cookie_addr,
- struct wcrypto_rng_op_data *opdata,
- struct wcrypto_rng_msg **req_addr,
- struct wcrypto_rng_ctx *ctxt,
- void *tag)
-{
- struct wcrypto_rng_cookie *cookie;
- struct wcrypto_rng_msg *req;
- int ret;
-
- if (unlikely(!ctxt || !opdata)) {
- WD_ERR("invalid: rng input parameter err!\n");
- return -WD_EINVAL;
- }
-
- if (unlikely((opdata->in_bytes && !opdata->out))) {
- WD_ERR("invalid: dst addr is NULL when in_bytes is non-zero!!\n");
- return -WD_EINVAL;
- }
-
- ret = wd_get_cookies(&ctxt->pool, (void **)&cookie, 1);
- if (ret)
- return ret;
-
- if (tag) {
- if (!ctxt->setup.cb) {
- WD_ERR("invalid: ctx call back is null!\n");
- wd_put_cookies(&ctxt->pool, (void **)&cookie, 1);
- return -WD_EINVAL;
- }
- cookie->tag.tag = tag;
- }
-
- req = &cookie->msg;
- req->in_bytes = opdata->in_bytes;
- req->out = opdata->out;
- *cookie_addr = cookie;
- *req_addr = req;
-
- return 0;
-}
-
-int wcrypto_do_rng(void *ctx, struct wcrypto_rng_op_data *opdata, void *tag)
-{
- struct wcrypto_rng_ctx *ctxt = ctx;
- struct wcrypto_rng_cookie *cookie;
- struct wcrypto_rng_msg *req;
- struct wcrypto_rng_msg *resp;
- uint32_t tx_cnt = 0;
- uint32_t rx_cnt = 0;
- int ret = 0;
-
- ret = wcrypto_do_prepare(&cookie, opdata, &req, ctxt, tag);
- if (ret)
- return ret;
-
- do {
- ret = wd_send(ctxt->q, req);
- if (!ret) {
- break;
- } else if (ret == -WD_EBUSY) {
- if (++tx_cnt > RNG_RESEND_CNT) {
- WD_ERR("do trng send cnt %u, exit!\n", tx_cnt);
- goto fail_with_cookie;
- }
-
- usleep(1);
- } else {
- WD_ERR("do rng wd_send err!\n");
- goto fail_with_cookie;
- }
- } while (true);
-
- if (tag)
- return ret;
-
- resp = (void *)(uintptr_t)ctxt->ctx_id;
-
- do {
- ret = wd_recv(ctxt->q, (void **)&resp);
- if (ret > 0) {
- break;
- } else if (!ret) {
- if (++rx_cnt > RNG_RECV_CNT) {
- WD_ERR("do trng recv cnt %u, exit!\n", rx_cnt);
- ret = -WD_ETIMEDOUT;
- goto fail_with_cookie;
- }
-
- usleep(1);
- } else {
- WD_ERR("do trng recv err!\n");
- goto fail_with_cookie;
- }
- } while (true);
-
- opdata->out_bytes = resp->out_bytes;
- ret = WD_SUCCESS;
-fail_with_cookie:
- wd_put_cookies(&ctxt->pool, (void **)&cookie, 1);
- return ret;
-}
diff --git a/v1/wd_rng.h b/v1/wd_rng.h
deleted file mode 100644
index fcde26d..0000000
--- a/v1/wd_rng.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2019 Huawei Technologies Co.,Ltd.All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __WD_RNG_H
-#define __WD_RNG_H
-
-#include "wd.h"
-#include "wd_digest.h"
-#include "wd_cipher.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct wcrypto_rng_ctx_setup {
- wcrypto_cb cb;
- __u16 data_fmt; /* Data format, denoted by enum wd_buff_type */
- enum wcrypto_type type; /* Please refer to the definition of enum */
- enum wcrypto_cipher_alg calg; /* DRBG cipher algorithm */
- enum wcrypto_cipher_mode cmode; /* DRBG cipher mode */
- enum wcrypto_digest_alg dalg; /* DRBG digest algorithm */
- enum wcrypto_digest_mode dmode; /* DRBG digest mode */
-};
-
-struct wcrypto_rng_msg {
- __u8 alg_type; /* Denoted by enum wcrypto_type */
- __u8 op_type; /* Denoted by enum wcrypto_rng_op_type */
- __u8 data_fmt; /* Data format, denoted by enum wd_buff_type */
- __u8 result; /* Data format, denoted by WD error code */
- __u8 *out; /* Result address */
- __u8 *in; /* Input address */
- __u32 out_bytes; /* output bytes */
- __u32 in_bytes; /* input bytes */
- __u64 usr_tag; /* user identifier */
-};
-
-enum wcrypto_rng_op_type {
- WCRYPTO_RNG_INVALID, /* Invalid RNG operational type */
- WCRYPTO_DRBG_RESEED, /* seed operation */
- WCRYPTO_DRBG_GEN, /* deterministic random number generation */
- WCRYPTO_TRNG_GEN, /* true random number generation */
-};
-
-struct wcrypto_rng_op_data {
- enum wcrypto_rng_op_type op_type;
- __u32 status; /* Operation result status */
- void *in; /* input */
- void *out; /* output */
- __u32 in_bytes; /* input bytes */
- __u32 out_bytes; /* output bytes */
-};
-
-void *wcrypto_create_rng_ctx(struct wd_queue *q,
- struct wcrypto_rng_ctx_setup *setup);
-void wcrypto_del_rng_ctx(void *ctx);
-int wcrypto_do_rng(void *ctx, struct wcrypto_rng_op_data *opdata, void *tag);
-int wcrypto_rng_poll(struct wd_queue *q, unsigned int num);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
--
2.33.0
1
0
From: Hao Fang <fanghao11(a)huawei.com>
add testcase for init2 just use cmd --init 2.
default or --init 1 for init interface.
Signed-off-by: Hao Fang <fanghao11(a)huawei.com>
---
uadk_tool/test/test_sec.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/uadk_tool/test/test_sec.c b/uadk_tool/test/test_sec.c
index 5b552fa..0a28db6 100644
--- a/uadk_tool/test/test_sec.c
+++ b/uadk_tool/test/test_sec.c
@@ -1483,6 +1483,14 @@ static int digest_init2(int type, int mode)
cparams.op_type_num = 1;
cparams.ctx_set_num = ctx_set_num;
+ cparams.bmp = numa_allocate_nodemask();
+ if (!cparams.bmp) {
+ WD_ERR("failed to create nodemask!\n");
+ ret = -WD_ENOMEM;
+ goto out_freectx;
+ }
+
+ numa_bitmask_setall(cparams.bmp);
if (mode == CTX_MODE_SYNC)
ctx_set_num->sync_ctx_num = g_ctxnum;
@@ -1494,7 +1502,13 @@ static int digest_init2(int type, int mode)
ret = wd_digest_init2("sm3", SCHED_POLICY_NONE, TASK_INSTR);
else
ret = wd_digest_init2_(digest_names[g_testalg], 0, 0, &cparams);
+ if (ret)
+ goto out_freebmp;
+
+out_freebmp:
+ numa_free_nodemask(cparams.bmp);
+out_freectx:
free(ctx_set_num);
return ret;
--
2.33.0
1
12
12 Feb '26
From: Weili Qian <qianweili(a)huawei.com>
Fix the compilation failure of wd_alg.h, error log likes:
wd_alg.h:121:9: error: unknown type name ‘__u8’.
And improve code portability by including linux/types.h
instead of asm/types.h.
Upstream: YES
Feature or Bugfix:Bugfix
AR: AR20230722287656
DTS: DTS2026012302441
Signed-off-by: Weili Qian <qianweili(a)huawei.com>
---
drv/hisi_comp.c | 2 +-
drv/hisi_comp_huf.c | 2 +-
drv/hisi_comp_huf.h | 2 +-
include/drv/wd_agg_drv.h | 2 +-
include/drv/wd_cipher_drv.h | 2 +-
include/drv/wd_comp_drv.h | 2 +-
include/drv/wd_dh_drv.h | 2 +-
include/drv/wd_ecc_drv.h | 2 +-
include/drv/wd_join_gather_drv.h | 2 +-
include/drv/wd_rsa_drv.h | 2 +-
include/drv/wd_udma_drv.h | 2 +-
include/wd.h | 6 ++----
include/wd_agg.h | 3 ++-
include/wd_alg.h | 1 +
include/wd_cipher.h | 3 ++-
include/wd_dae.h | 3 ++-
include/wd_join_gather.h | 3 ++-
include/wd_sched.h | 2 +-
include/wd_util.h | 2 +-
include/wd_zlibwrapper.h | 2 +-
20 files changed, 25 insertions(+), 22 deletions(-)
diff --git a/drv/hisi_comp.c b/drv/hisi_comp.c
index 6758c02..7c449e0 100644
--- a/drv/hisi_comp.c
+++ b/drv/hisi_comp.c
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
/* Copyright 2020-2021 Huawei Technologies Co.,Ltd. All rights reserved. */
-#include <asm/types.h>
+#include <linux/types.h>
#include "drv/wd_comp_drv.h"
#include "drv/hisi_comp_huf.h"
#include "hisi_qm_udrv.h"
diff --git a/drv/hisi_comp_huf.c b/drv/hisi_comp_huf.c
index 161fee4..c64c418 100644
--- a/drv/hisi_comp_huf.c
+++ b/drv/hisi_comp_huf.c
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
/* Copyright 2025 Huawei Technologies Co.,Ltd. All rights reserved. */
-#include <asm/types.h>
+#include <linux/types.h>
#include "drv/hisi_comp_huf.h"
#include "wd_util.h"
diff --git a/drv/hisi_comp_huf.h b/drv/hisi_comp_huf.h
index 6585b7a..dde0ff4 100644
--- a/drv/hisi_comp_huf.h
+++ b/drv/hisi_comp_huf.h
@@ -4,7 +4,7 @@
#ifndef __HISI_COMP_HUF_H
#define __HISI_COMP_HUF_H
-#include <asm/types.h>
+#include <linux/types.h>
#ifdef __cplusplus
extern "C" {
diff --git a/include/drv/wd_agg_drv.h b/include/drv/wd_agg_drv.h
index 978c2d3..b26b25d 100644
--- a/include/drv/wd_agg_drv.h
+++ b/include/drv/wd_agg_drv.h
@@ -6,7 +6,7 @@
#ifndef __WD_AGG_DRV_H
#define __WD_AGG_DRV_H
-#include <asm/types.h>
+#include <linux/types.h>
#include "wd_agg.h"
#include "wd_util.h"
diff --git a/include/drv/wd_cipher_drv.h b/include/drv/wd_cipher_drv.h
index c0be0c3..458a8d8 100644
--- a/include/drv/wd_cipher_drv.h
+++ b/include/drv/wd_cipher_drv.h
@@ -4,7 +4,7 @@
#ifndef __WD_CIPHER_DRV_H
#define __WD_CIPHER_DRV_H
-#include <asm/types.h>
+#include <linux/types.h>
#include "../wd_cipher.h"
#include "../wd_util.h"
diff --git a/include/drv/wd_comp_drv.h b/include/drv/wd_comp_drv.h
index 95f7fb7..2311d79 100644
--- a/include/drv/wd_comp_drv.h
+++ b/include/drv/wd_comp_drv.h
@@ -5,7 +5,7 @@
#define __WD_COMP_DRV_H
#include <pthread.h>
-#include <asm/types.h>
+#include <linux/types.h>
#include "../wd_comp.h"
#include "../wd_util.h"
diff --git a/include/drv/wd_dh_drv.h b/include/drv/wd_dh_drv.h
index d2a6157..a46aa90 100644
--- a/include/drv/wd_dh_drv.h
+++ b/include/drv/wd_dh_drv.h
@@ -4,7 +4,7 @@
#ifndef __WD_DH_DRV_H
#define __WD_DH_DRV_H
-#include <asm/types.h>
+#include <linux/types.h>
#include "../wd_dh.h"
#include "../wd_util.h"
diff --git a/include/drv/wd_ecc_drv.h b/include/drv/wd_ecc_drv.h
index b123a9b..48c422f 100644
--- a/include/drv/wd_ecc_drv.h
+++ b/include/drv/wd_ecc_drv.h
@@ -5,7 +5,7 @@
#define __WD_ECC_DRV_H
#include <stdint.h>
-#include <asm/types.h>
+#include <linux/types.h>
#include "../wd_ecc.h"
#include "../wd_util.h"
diff --git a/include/drv/wd_join_gather_drv.h b/include/drv/wd_join_gather_drv.h
index 80fb932..dbf4ee7 100644
--- a/include/drv/wd_join_gather_drv.h
+++ b/include/drv/wd_join_gather_drv.h
@@ -6,7 +6,7 @@
#ifndef __WD_JOIN_GATHER_DRV_H
#define __WD_JOIN_GATHER_DRV_H
-#include <asm/types.h>
+#include <linux/types.h>
#include "wd_join_gather.h"
#include "wd_util.h"
diff --git a/include/drv/wd_rsa_drv.h b/include/drv/wd_rsa_drv.h
index c12f3e0..728abdf 100644
--- a/include/drv/wd_rsa_drv.h
+++ b/include/drv/wd_rsa_drv.h
@@ -3,7 +3,7 @@
#ifndef __WD_RSA_DRV_H
#define __WD_RSA_DRV_H
-#include <asm/types.h>
+#include <linux/types.h>
#include "../wd_rsa.h"
#include "../wd_util.h"
diff --git a/include/drv/wd_udma_drv.h b/include/drv/wd_udma_drv.h
index c8028f7..8c5edea 100644
--- a/include/drv/wd_udma_drv.h
+++ b/include/drv/wd_udma_drv.h
@@ -4,7 +4,7 @@
#ifndef __WD_UDMA_DRV_H
#define __WD_UDMA_DRV_H
-#include <asm/types.h>
+#include <linux/types.h>
#include "../wd_udma.h"
#include "../wd_util.h"
diff --git a/include/wd.h b/include/wd.h
index 7e92e41..a468047 100644
--- a/include/wd.h
+++ b/include/wd.h
@@ -15,7 +15,8 @@
#include <string.h>
#include <syslog.h>
#include <unistd.h>
-#include <asm/types.h>
+#include <linux/types.h>
+
#include "uacce.h"
#ifdef __cplusplus
@@ -33,9 +34,6 @@ extern "C" {
#define CRYPTO_MAX_ALG_NAME 128
#define NUMA_NO_NODE (-1)
-typedef unsigned char __u8;
-typedef unsigned int __u32;
-typedef unsigned long long __u64;
/* Required compiler attributes */
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
diff --git a/include/wd_agg.h b/include/wd_agg.h
index fed08c5..b35c8c2 100644
--- a/include/wd_agg.h
+++ b/include/wd_agg.h
@@ -7,7 +7,8 @@
#define __WD_AGG_H
#include <dlfcn.h>
-#include <asm/types.h>
+#include <linux/types.h>
+
#include "wd_dae.h"
#ifdef __cplusplus
diff --git a/include/wd_alg.h b/include/wd_alg.h
index 7a3ae5f..18503ca 100644
--- a/include/wd_alg.h
+++ b/include/wd_alg.h
@@ -10,6 +10,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <unistd.h>
+#include <linux/types.h>
#ifdef __cplusplus
extern "C" {
diff --git a/include/wd_cipher.h b/include/wd_cipher.h
index 1d82eac..a6f8be1 100644
--- a/include/wd_cipher.h
+++ b/include/wd_cipher.h
@@ -8,7 +8,8 @@
#define __WD_CIPHER_H
#include <dlfcn.h>
-#include <asm/types.h>
+#include <linux/types.h>
+
#include "wd_alg_common.h"
#ifdef __cplusplus
diff --git a/include/wd_dae.h b/include/wd_dae.h
index 64f17dc..3d7463e 100644
--- a/include/wd_dae.h
+++ b/include/wd_dae.h
@@ -8,7 +8,8 @@
#include <dlfcn.h>
#include <stdbool.h>
-#include <asm/types.h>
+#include <linux/types.h>
+
#include "wd_alg_common.h"
#include "wd.h"
diff --git a/include/wd_join_gather.h b/include/wd_join_gather.h
index 4962ee3..44588b2 100644
--- a/include/wd_join_gather.h
+++ b/include/wd_join_gather.h
@@ -7,7 +7,8 @@
#define __WD_JOIN_GATHER_H
#include <dlfcn.h>
-#include <asm/types.h>
+#include <linux/types.h>
+
#include "wd_dae.h"
#ifdef __cplusplus
diff --git a/include/wd_sched.h b/include/wd_sched.h
index 949396e..5baecd3 100644
--- a/include/wd_sched.h
+++ b/include/wd_sched.h
@@ -6,7 +6,7 @@
#ifndef SCHED_SAMPLE_h
#define SCHED_SAMPLE_h
-#include <asm/types.h>
+#include <linux/types.h>
#include "wd_alg_common.h"
#ifdef __cplusplus
diff --git a/include/wd_util.h b/include/wd_util.h
index a337284..2abceec 100644
--- a/include/wd_util.h
+++ b/include/wd_util.h
@@ -11,7 +11,7 @@
#include <stdbool.h>
#include <sys/ipc.h>
#include <sys/shm.h>
-#include <asm/types.h>
+#include <linux/types.h>
#include "wd.h"
#include "wd_sched.h"
diff --git a/include/wd_zlibwrapper.h b/include/wd_zlibwrapper.h
index 978d1ed..80ba08f 100644
--- a/include/wd_zlibwrapper.h
+++ b/include/wd_zlibwrapper.h
@@ -6,7 +6,7 @@
#ifndef UADK_ZLIBWRAPPER_H
#define UADK_ZLIBWRAPPER_H
-#include <asm/types.h>
+#include <linux/types.h>
/*
* These APIs are used to replace the ZLIB library. So if you don't use them.
--
2.33.0
1
0
12 Feb '26
From: Weili Qian <qianweili(a)huawei.com>
Fix the compilation failure of wd_alg.h, error log likes:
wd_alg.h:121:9: error: unknown type name ‘__u8’.
And improve code portability by including linux/types.h
instead of asm/types.h.
Upstream: YES
Feature or Bugfix:Bugfix
AR: AR20230722287656
DTS: DTS2026012302441
Signed-off-by: Weili Qian <qianweili(a)huawei.com>
---
drv/hisi_comp.c | 2 +-
drv/hisi_comp_huf.c | 2 +-
drv/hisi_comp_huf.h | 2 +-
include/drv/wd_agg_drv.h | 2 +-
include/drv/wd_cipher_drv.h | 2 +-
include/drv/wd_comp_drv.h | 2 +-
include/drv/wd_dh_drv.h | 2 +-
include/drv/wd_ecc_drv.h | 2 +-
include/drv/wd_join_gather_drv.h | 2 +-
include/drv/wd_rsa_drv.h | 2 +-
include/drv/wd_udma_drv.h | 2 +-
include/wd.h | 6 ++----
include/wd_agg.h | 3 ++-
include/wd_alg.h | 1 +
include/wd_cipher.h | 3 ++-
include/wd_dae.h | 3 ++-
include/wd_join_gather.h | 3 ++-
include/wd_sched.h | 2 +-
include/wd_util.h | 2 +-
include/wd_zlibwrapper.h | 2 +-
20 files changed, 25 insertions(+), 22 deletions(-)
diff --git a/drv/hisi_comp.c b/drv/hisi_comp.c
index 6758c02..7c449e0 100644
--- a/drv/hisi_comp.c
+++ b/drv/hisi_comp.c
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
/* Copyright 2020-2021 Huawei Technologies Co.,Ltd. All rights reserved. */
-#include <asm/types.h>
+#include <linux/types.h>
#include "drv/wd_comp_drv.h"
#include "drv/hisi_comp_huf.h"
#include "hisi_qm_udrv.h"
diff --git a/drv/hisi_comp_huf.c b/drv/hisi_comp_huf.c
index 161fee4..c64c418 100644
--- a/drv/hisi_comp_huf.c
+++ b/drv/hisi_comp_huf.c
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
/* Copyright 2025 Huawei Technologies Co.,Ltd. All rights reserved. */
-#include <asm/types.h>
+#include <linux/types.h>
#include "drv/hisi_comp_huf.h"
#include "wd_util.h"
diff --git a/drv/hisi_comp_huf.h b/drv/hisi_comp_huf.h
index 6585b7a..dde0ff4 100644
--- a/drv/hisi_comp_huf.h
+++ b/drv/hisi_comp_huf.h
@@ -4,7 +4,7 @@
#ifndef __HISI_COMP_HUF_H
#define __HISI_COMP_HUF_H
-#include <asm/types.h>
+#include <linux/types.h>
#ifdef __cplusplus
extern "C" {
diff --git a/include/drv/wd_agg_drv.h b/include/drv/wd_agg_drv.h
index 978c2d3..b26b25d 100644
--- a/include/drv/wd_agg_drv.h
+++ b/include/drv/wd_agg_drv.h
@@ -6,7 +6,7 @@
#ifndef __WD_AGG_DRV_H
#define __WD_AGG_DRV_H
-#include <asm/types.h>
+#include <linux/types.h>
#include "wd_agg.h"
#include "wd_util.h"
diff --git a/include/drv/wd_cipher_drv.h b/include/drv/wd_cipher_drv.h
index c0be0c3..458a8d8 100644
--- a/include/drv/wd_cipher_drv.h
+++ b/include/drv/wd_cipher_drv.h
@@ -4,7 +4,7 @@
#ifndef __WD_CIPHER_DRV_H
#define __WD_CIPHER_DRV_H
-#include <asm/types.h>
+#include <linux/types.h>
#include "../wd_cipher.h"
#include "../wd_util.h"
diff --git a/include/drv/wd_comp_drv.h b/include/drv/wd_comp_drv.h
index 95f7fb7..2311d79 100644
--- a/include/drv/wd_comp_drv.h
+++ b/include/drv/wd_comp_drv.h
@@ -5,7 +5,7 @@
#define __WD_COMP_DRV_H
#include <pthread.h>
-#include <asm/types.h>
+#include <linux/types.h>
#include "../wd_comp.h"
#include "../wd_util.h"
diff --git a/include/drv/wd_dh_drv.h b/include/drv/wd_dh_drv.h
index d2a6157..a46aa90 100644
--- a/include/drv/wd_dh_drv.h
+++ b/include/drv/wd_dh_drv.h
@@ -4,7 +4,7 @@
#ifndef __WD_DH_DRV_H
#define __WD_DH_DRV_H
-#include <asm/types.h>
+#include <linux/types.h>
#include "../wd_dh.h"
#include "../wd_util.h"
diff --git a/include/drv/wd_ecc_drv.h b/include/drv/wd_ecc_drv.h
index b123a9b..48c422f 100644
--- a/include/drv/wd_ecc_drv.h
+++ b/include/drv/wd_ecc_drv.h
@@ -5,7 +5,7 @@
#define __WD_ECC_DRV_H
#include <stdint.h>
-#include <asm/types.h>
+#include <linux/types.h>
#include "../wd_ecc.h"
#include "../wd_util.h"
diff --git a/include/drv/wd_join_gather_drv.h b/include/drv/wd_join_gather_drv.h
index 80fb932..dbf4ee7 100644
--- a/include/drv/wd_join_gather_drv.h
+++ b/include/drv/wd_join_gather_drv.h
@@ -6,7 +6,7 @@
#ifndef __WD_JOIN_GATHER_DRV_H
#define __WD_JOIN_GATHER_DRV_H
-#include <asm/types.h>
+#include <linux/types.h>
#include "wd_join_gather.h"
#include "wd_util.h"
diff --git a/include/drv/wd_rsa_drv.h b/include/drv/wd_rsa_drv.h
index c12f3e0..728abdf 100644
--- a/include/drv/wd_rsa_drv.h
+++ b/include/drv/wd_rsa_drv.h
@@ -3,7 +3,7 @@
#ifndef __WD_RSA_DRV_H
#define __WD_RSA_DRV_H
-#include <asm/types.h>
+#include <linux/types.h>
#include "../wd_rsa.h"
#include "../wd_util.h"
diff --git a/include/drv/wd_udma_drv.h b/include/drv/wd_udma_drv.h
index c8028f7..8c5edea 100644
--- a/include/drv/wd_udma_drv.h
+++ b/include/drv/wd_udma_drv.h
@@ -4,7 +4,7 @@
#ifndef __WD_UDMA_DRV_H
#define __WD_UDMA_DRV_H
-#include <asm/types.h>
+#include <linux/types.h>
#include "../wd_udma.h"
#include "../wd_util.h"
diff --git a/include/wd.h b/include/wd.h
index 7e92e41..a468047 100644
--- a/include/wd.h
+++ b/include/wd.h
@@ -15,7 +15,8 @@
#include <string.h>
#include <syslog.h>
#include <unistd.h>
-#include <asm/types.h>
+#include <linux/types.h>
+
#include "uacce.h"
#ifdef __cplusplus
@@ -33,9 +34,6 @@ extern "C" {
#define CRYPTO_MAX_ALG_NAME 128
#define NUMA_NO_NODE (-1)
-typedef unsigned char __u8;
-typedef unsigned int __u32;
-typedef unsigned long long __u64;
/* Required compiler attributes */
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
diff --git a/include/wd_agg.h b/include/wd_agg.h
index fed08c5..b35c8c2 100644
--- a/include/wd_agg.h
+++ b/include/wd_agg.h
@@ -7,7 +7,8 @@
#define __WD_AGG_H
#include <dlfcn.h>
-#include <asm/types.h>
+#include <linux/types.h>
+
#include "wd_dae.h"
#ifdef __cplusplus
diff --git a/include/wd_alg.h b/include/wd_alg.h
index 7a3ae5f..18503ca 100644
--- a/include/wd_alg.h
+++ b/include/wd_alg.h
@@ -10,6 +10,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <unistd.h>
+#include <linux/types.h>
#ifdef __cplusplus
extern "C" {
diff --git a/include/wd_cipher.h b/include/wd_cipher.h
index 1d82eac..a6f8be1 100644
--- a/include/wd_cipher.h
+++ b/include/wd_cipher.h
@@ -8,7 +8,8 @@
#define __WD_CIPHER_H
#include <dlfcn.h>
-#include <asm/types.h>
+#include <linux/types.h>
+
#include "wd_alg_common.h"
#ifdef __cplusplus
diff --git a/include/wd_dae.h b/include/wd_dae.h
index 64f17dc..3d7463e 100644
--- a/include/wd_dae.h
+++ b/include/wd_dae.h
@@ -8,7 +8,8 @@
#include <dlfcn.h>
#include <stdbool.h>
-#include <asm/types.h>
+#include <linux/types.h>
+
#include "wd_alg_common.h"
#include "wd.h"
diff --git a/include/wd_join_gather.h b/include/wd_join_gather.h
index 4962ee3..44588b2 100644
--- a/include/wd_join_gather.h
+++ b/include/wd_join_gather.h
@@ -7,7 +7,8 @@
#define __WD_JOIN_GATHER_H
#include <dlfcn.h>
-#include <asm/types.h>
+#include <linux/types.h>
+
#include "wd_dae.h"
#ifdef __cplusplus
diff --git a/include/wd_sched.h b/include/wd_sched.h
index 949396e..5baecd3 100644
--- a/include/wd_sched.h
+++ b/include/wd_sched.h
@@ -6,7 +6,7 @@
#ifndef SCHED_SAMPLE_h
#define SCHED_SAMPLE_h
-#include <asm/types.h>
+#include <linux/types.h>
#include "wd_alg_common.h"
#ifdef __cplusplus
diff --git a/include/wd_util.h b/include/wd_util.h
index a337284..2abceec 100644
--- a/include/wd_util.h
+++ b/include/wd_util.h
@@ -11,7 +11,7 @@
#include <stdbool.h>
#include <sys/ipc.h>
#include <sys/shm.h>
-#include <asm/types.h>
+#include <linux/types.h>
#include "wd.h"
#include "wd_sched.h"
diff --git a/include/wd_zlibwrapper.h b/include/wd_zlibwrapper.h
index 978d1ed..80ba08f 100644
--- a/include/wd_zlibwrapper.h
+++ b/include/wd_zlibwrapper.h
@@ -6,7 +6,7 @@
#ifndef UADK_ZLIBWRAPPER_H
#define UADK_ZLIBWRAPPER_H
-#include <asm/types.h>
+#include <linux/types.h>
/*
* These APIs are used to replace the ZLIB library. So if you don't use them.
--
2.33.0
1
0
From: Weili Qian <qianweili(a)huawei.com>
Fix the compilation failure of wd_alg.h, error log likes:
wd_alg.h:121:9: error: unknown type name ‘__u8’.
And improve code portability by including linux/types.h
instead of asm/types.h.
Signed-off-by: Weili Qian <qianweili(a)huawei.com>
---
drv/hisi_comp.c | 2 +-
drv/hisi_comp_huf.c | 2 +-
drv/hisi_comp_huf.h | 2 +-
include/drv/wd_agg_drv.h | 2 +-
include/drv/wd_cipher_drv.h | 2 +-
include/drv/wd_comp_drv.h | 2 +-
include/drv/wd_dh_drv.h | 2 +-
include/drv/wd_ecc_drv.h | 2 +-
include/drv/wd_join_gather_drv.h | 2 +-
include/drv/wd_rsa_drv.h | 2 +-
include/drv/wd_udma_drv.h | 2 +-
include/wd.h | 6 ++----
include/wd_agg.h | 3 ++-
include/wd_alg.h | 1 +
include/wd_cipher.h | 3 ++-
include/wd_dae.h | 3 ++-
include/wd_join_gather.h | 3 ++-
include/wd_sched.h | 2 +-
include/wd_util.h | 2 +-
include/wd_zlibwrapper.h | 2 +-
20 files changed, 25 insertions(+), 22 deletions(-)
diff --git a/drv/hisi_comp.c b/drv/hisi_comp.c
index cf8d315..a6b2947 100644
--- a/drv/hisi_comp.c
+++ b/drv/hisi_comp.c
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
/* Copyright 2020-2021 Huawei Technologies Co.,Ltd. All rights reserved. */
-#include <asm/types.h>
+#include <linux/types.h>
#include "drv/wd_comp_drv.h"
#include "drv/hisi_comp_huf.h"
#include "hisi_qm_udrv.h"
diff --git a/drv/hisi_comp_huf.c b/drv/hisi_comp_huf.c
index 161fee4..c64c418 100644
--- a/drv/hisi_comp_huf.c
+++ b/drv/hisi_comp_huf.c
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
/* Copyright 2025 Huawei Technologies Co.,Ltd. All rights reserved. */
-#include <asm/types.h>
+#include <linux/types.h>
#include "drv/hisi_comp_huf.h"
#include "wd_util.h"
diff --git a/drv/hisi_comp_huf.h b/drv/hisi_comp_huf.h
index 6585b7a..dde0ff4 100644
--- a/drv/hisi_comp_huf.h
+++ b/drv/hisi_comp_huf.h
@@ -4,7 +4,7 @@
#ifndef __HISI_COMP_HUF_H
#define __HISI_COMP_HUF_H
-#include <asm/types.h>
+#include <linux/types.h>
#ifdef __cplusplus
extern "C" {
diff --git a/include/drv/wd_agg_drv.h b/include/drv/wd_agg_drv.h
index 978c2d3..b26b25d 100644
--- a/include/drv/wd_agg_drv.h
+++ b/include/drv/wd_agg_drv.h
@@ -6,7 +6,7 @@
#ifndef __WD_AGG_DRV_H
#define __WD_AGG_DRV_H
-#include <asm/types.h>
+#include <linux/types.h>
#include "wd_agg.h"
#include "wd_util.h"
diff --git a/include/drv/wd_cipher_drv.h b/include/drv/wd_cipher_drv.h
index c0be0c3..458a8d8 100644
--- a/include/drv/wd_cipher_drv.h
+++ b/include/drv/wd_cipher_drv.h
@@ -4,7 +4,7 @@
#ifndef __WD_CIPHER_DRV_H
#define __WD_CIPHER_DRV_H
-#include <asm/types.h>
+#include <linux/types.h>
#include "../wd_cipher.h"
#include "../wd_util.h"
diff --git a/include/drv/wd_comp_drv.h b/include/drv/wd_comp_drv.h
index 95f7fb7..2311d79 100644
--- a/include/drv/wd_comp_drv.h
+++ b/include/drv/wd_comp_drv.h
@@ -5,7 +5,7 @@
#define __WD_COMP_DRV_H
#include <pthread.h>
-#include <asm/types.h>
+#include <linux/types.h>
#include "../wd_comp.h"
#include "../wd_util.h"
diff --git a/include/drv/wd_dh_drv.h b/include/drv/wd_dh_drv.h
index d2a6157..a46aa90 100644
--- a/include/drv/wd_dh_drv.h
+++ b/include/drv/wd_dh_drv.h
@@ -4,7 +4,7 @@
#ifndef __WD_DH_DRV_H
#define __WD_DH_DRV_H
-#include <asm/types.h>
+#include <linux/types.h>
#include "../wd_dh.h"
#include "../wd_util.h"
diff --git a/include/drv/wd_ecc_drv.h b/include/drv/wd_ecc_drv.h
index b123a9b..48c422f 100644
--- a/include/drv/wd_ecc_drv.h
+++ b/include/drv/wd_ecc_drv.h
@@ -5,7 +5,7 @@
#define __WD_ECC_DRV_H
#include <stdint.h>
-#include <asm/types.h>
+#include <linux/types.h>
#include "../wd_ecc.h"
#include "../wd_util.h"
diff --git a/include/drv/wd_join_gather_drv.h b/include/drv/wd_join_gather_drv.h
index 80fb932..dbf4ee7 100644
--- a/include/drv/wd_join_gather_drv.h
+++ b/include/drv/wd_join_gather_drv.h
@@ -6,7 +6,7 @@
#ifndef __WD_JOIN_GATHER_DRV_H
#define __WD_JOIN_GATHER_DRV_H
-#include <asm/types.h>
+#include <linux/types.h>
#include "wd_join_gather.h"
#include "wd_util.h"
diff --git a/include/drv/wd_rsa_drv.h b/include/drv/wd_rsa_drv.h
index c12f3e0..728abdf 100644
--- a/include/drv/wd_rsa_drv.h
+++ b/include/drv/wd_rsa_drv.h
@@ -3,7 +3,7 @@
#ifndef __WD_RSA_DRV_H
#define __WD_RSA_DRV_H
-#include <asm/types.h>
+#include <linux/types.h>
#include "../wd_rsa.h"
#include "../wd_util.h"
diff --git a/include/drv/wd_udma_drv.h b/include/drv/wd_udma_drv.h
index c8028f7..8c5edea 100644
--- a/include/drv/wd_udma_drv.h
+++ b/include/drv/wd_udma_drv.h
@@ -4,7 +4,7 @@
#ifndef __WD_UDMA_DRV_H
#define __WD_UDMA_DRV_H
-#include <asm/types.h>
+#include <linux/types.h>
#include "../wd_udma.h"
#include "../wd_util.h"
diff --git a/include/wd.h b/include/wd.h
index 7e92e41..a468047 100644
--- a/include/wd.h
+++ b/include/wd.h
@@ -15,7 +15,8 @@
#include <string.h>
#include <syslog.h>
#include <unistd.h>
-#include <asm/types.h>
+#include <linux/types.h>
+
#include "uacce.h"
#ifdef __cplusplus
@@ -33,9 +34,6 @@ extern "C" {
#define CRYPTO_MAX_ALG_NAME 128
#define NUMA_NO_NODE (-1)
-typedef unsigned char __u8;
-typedef unsigned int __u32;
-typedef unsigned long long __u64;
/* Required compiler attributes */
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
diff --git a/include/wd_agg.h b/include/wd_agg.h
index fed08c5..b35c8c2 100644
--- a/include/wd_agg.h
+++ b/include/wd_agg.h
@@ -7,7 +7,8 @@
#define __WD_AGG_H
#include <dlfcn.h>
-#include <asm/types.h>
+#include <linux/types.h>
+
#include "wd_dae.h"
#ifdef __cplusplus
diff --git a/include/wd_alg.h b/include/wd_alg.h
index 7a3ae5f..18503ca 100644
--- a/include/wd_alg.h
+++ b/include/wd_alg.h
@@ -10,6 +10,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <unistd.h>
+#include <linux/types.h>
#ifdef __cplusplus
extern "C" {
diff --git a/include/wd_cipher.h b/include/wd_cipher.h
index 1d82eac..a6f8be1 100644
--- a/include/wd_cipher.h
+++ b/include/wd_cipher.h
@@ -8,7 +8,8 @@
#define __WD_CIPHER_H
#include <dlfcn.h>
-#include <asm/types.h>
+#include <linux/types.h>
+
#include "wd_alg_common.h"
#ifdef __cplusplus
diff --git a/include/wd_dae.h b/include/wd_dae.h
index 64f17dc..3d7463e 100644
--- a/include/wd_dae.h
+++ b/include/wd_dae.h
@@ -8,7 +8,8 @@
#include <dlfcn.h>
#include <stdbool.h>
-#include <asm/types.h>
+#include <linux/types.h>
+
#include "wd_alg_common.h"
#include "wd.h"
diff --git a/include/wd_join_gather.h b/include/wd_join_gather.h
index 4962ee3..44588b2 100644
--- a/include/wd_join_gather.h
+++ b/include/wd_join_gather.h
@@ -7,7 +7,8 @@
#define __WD_JOIN_GATHER_H
#include <dlfcn.h>
-#include <asm/types.h>
+#include <linux/types.h>
+
#include "wd_dae.h"
#ifdef __cplusplus
diff --git a/include/wd_sched.h b/include/wd_sched.h
index 949396e..5baecd3 100644
--- a/include/wd_sched.h
+++ b/include/wd_sched.h
@@ -6,7 +6,7 @@
#ifndef SCHED_SAMPLE_h
#define SCHED_SAMPLE_h
-#include <asm/types.h>
+#include <linux/types.h>
#include "wd_alg_common.h"
#ifdef __cplusplus
diff --git a/include/wd_util.h b/include/wd_util.h
index a337284..2abceec 100644
--- a/include/wd_util.h
+++ b/include/wd_util.h
@@ -11,7 +11,7 @@
#include <stdbool.h>
#include <sys/ipc.h>
#include <sys/shm.h>
-#include <asm/types.h>
+#include <linux/types.h>
#include "wd.h"
#include "wd_sched.h"
diff --git a/include/wd_zlibwrapper.h b/include/wd_zlibwrapper.h
index 978d1ed..80ba08f 100644
--- a/include/wd_zlibwrapper.h
+++ b/include/wd_zlibwrapper.h
@@ -6,7 +6,7 @@
#ifndef UADK_ZLIBWRAPPER_H
#define UADK_ZLIBWRAPPER_H
-#include <asm/types.h>
+#include <linux/types.h>
/*
* These APIs are used to replace the ZLIB library. So if you don't use them.
--
2.33.0
1
1
From: parm64 <parm64(a)huawei.com>
Weili Qian (9):
uadk_provider: set the default provider when initializing the uadk
provider
uadk_engine: release asynchronous resources before destroying
algorithm resources
uadk_provider: release asynchronous resources before destroying
algorithm resources
uadk_provider/sm2: move sm2 key generation into a separate file
uadk_provider/sm2: modify the return value of keygen
uadk_provider/sm2: remove unnecessary code
uadk_engine/ecc: remove unnecessary code
uadk_engine: fix compilation warnings
uadk_provider/sm2: split uadk_prov_sm2.c into 2 files
Zhushuai Yin (3):
uadk_provider: reduce lock scope during prov init to improve perf
uadk_engine: reduce lock scope during prov init to improve perf
uadk_provider: delete asynchronous redundancy declaration
lizhi (4):
uadk_provider: adapt uadk_provider with tls 1.3
uadk_provider: adapt rsa key management with pss padding mode
uadk_provider: adapt rsa pss key management with algorithm enable
configuration.
uadk_engine/ecc: fix memory leak in the ecx algorithm
src/Makefile.am | 4 +-
src/uadk_aead.c | 1 +
src/uadk_async.h | 1 -
src/uadk_cipher.c | 1 +
src/uadk_cipher_adapter.c | 2 +-
src/uadk_dh.c | 1 +
src/uadk_digest.c | 1 +
src/uadk_ec.c | 34 +-
src/uadk_ecx.c | 1 +
src/uadk_engine_init.c | 8 +-
src/uadk_pkey.c | 1 +
src/uadk_prov.h | 19 +-
src/uadk_prov_aead.c | 18 +-
src/uadk_prov_capabilities.c | 224 +++
src/uadk_prov_cipher.c | 70 +-
src/uadk_prov_dh.c | 66 +-
src/uadk_prov_digest.c | 18 +-
src/uadk_prov_ec_kmgmt.c | 19 +
src/uadk_prov_ecdh_exch.c | 33 +-
src/uadk_prov_ecx.c | 125 +-
src/uadk_prov_hmac.c | 24 +-
src/uadk_prov_init.c | 96 +-
src/uadk_prov_pkey.c | 14 +-
src/uadk_prov_pkey.h | 21 +-
src/uadk_prov_rsa.c | 14 +-
src/uadk_prov_rsa_enc.c | 34 +-
src/uadk_prov_rsa_kmgmt.c | 101 ++
src/uadk_prov_rsa_sign.c | 34 +-
src/uadk_prov_sm2.c | 3320 ----------------------------------
src/uadk_prov_sm2_enc.c | 860 +++++++++
src/uadk_prov_sm2_kmgmt.c | 505 ++++++
src/uadk_prov_sm2_sign.c | 1342 ++++++++++++++
src/uadk_rsa.c | 1 +
33 files changed, 3398 insertions(+), 3615 deletions(-)
create mode 100644 src/uadk_prov_capabilities.c
delete mode 100644 src/uadk_prov_sm2.c
create mode 100644 src/uadk_prov_sm2_enc.c
create mode 100644 src/uadk_prov_sm2_kmgmt.c
create mode 100644 src/uadk_prov_sm2_sign.c
--
2.43.0
1
16
From: Wenkai Lin <linwenkai6(a)hisilicon.com>
Adjusted the rehash descriptors counta_vld, agg_col_bit_map,
Agg_Oid, Agg_Out_Type, Col_Data_Type, and Col_Data_Info.
These descriptors are consistent with those generated by the
hash aggregation task. In addition, an extra 4 bytes are added
when calculating the row size to ensure that each hash table
contains 4 bytes of empty information.
Signed-off-by: Wenkai Lin <linwenkai6(a)hisilicon.com>
Signed-off-by: Zhushuai Yin <yinzhushuai(a)huawei.com>
---
drv/hisi_dae.c | 12 ++++++++----
drv/hisi_dae_join_gather.c | 7 +++++--
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/drv/hisi_dae.c b/drv/hisi_dae.c
index a6ee368..8fe6092 100644
--- a/drv/hisi_dae.c
+++ b/drv/hisi_dae.c
@@ -33,7 +33,6 @@
/* hash table */
#define HASH_TABLE_HEAD_TAIL_SIZE 8
-#define HASH_TABLE_EMPTY_SIZE 4
/* hash agg operations col max num */
#define DAE_AGG_COL_ALG_MAX_NUM 2
@@ -160,13 +159,18 @@ static void fill_hashagg_merge_output_order(struct dae_sqe *sqe, struct dae_ext_
{
struct hashagg_ctx *agg_ctx = msg->priv;
struct hashagg_col_data *cols_data = &agg_ctx->cols_data;
+ __u32 out_cols_num = cols_data->output_num;
struct hashagg_output_src *output_src;
__u32 offset = 0;
__u32 i;
- output_src = cols_data->rehash_output;
+ output_src = cols_data->normal_output;
+ if (cols_data->is_count_all) {
+ sqe->counta_vld = DAE_HASH_COUNT_ALL;
+ out_cols_num--;
+ }
- for (i = 0; i < cols_data->output_num; i++) {
+ for (i = 0; i < out_cols_num; i++) {
ext_sqe->out_from_in_idx |= (__u64)output_src[i].out_from_in_idx << offset;
ext_sqe->out_optype |= (__u64)output_src[i].out_optype << offset;
offset += DAE_COL_BIT_NUM;
@@ -370,7 +374,7 @@ static void fill_hashagg_merge_input_data(struct dae_sqe *sqe, struct dae_ext_sq
struct hashagg_ctx *agg_ctx = msg->priv;
struct hashagg_col_data *cols_data = &agg_ctx->cols_data;
- fill_hashagg_data_info(sqe, ext_sqe, cols_data->output_data, msg->agg_cols_num);
+ fill_hashagg_data_info(sqe, ext_sqe, cols_data->input_data, msg->agg_cols_num);
}
static void fill_hashagg_ext_addr(struct dae_sqe *sqe, struct dae_ext_sqe *ext_sqe,
diff --git a/drv/hisi_dae_join_gather.c b/drv/hisi_dae_join_gather.c
index 92fae1a..8c45f57 100644
--- a/drv/hisi_dae_join_gather.c
+++ b/drv/hisi_dae_join_gather.c
@@ -19,7 +19,7 @@
#define PROBE_INDEX_ROW_SIZE 4
/* align size */
-#define DAE_KEY_ALIGN_SIZE 8
+#define DAE_KEY_ALIGN_SIZE 4
#define DAE_BREAKPOINT_SIZE 81920
#define DAE_ADDR_INDEX_SHIFT 1
@@ -28,7 +28,6 @@
#define HASH_TABLE_INDEX_NUM 1
#define HASH_TABLE_MAX_INDEX_NUM 15
#define HASH_TABLE_INDEX_SIZE 12
-#define HASH_TABLE_EMPTY_SIZE 4
#define GATHER_ROW_BATCH_EMPTY_SIZE 4
/* DAE hardware protocol data */
@@ -173,6 +172,9 @@ static void fill_join_table_data(struct dae_sqe *sqe, struct dae_addr_list *addr
}
sqe->table_row_size = ctx->hash_table_row_size;
+ /* Initialize these fields for hardware check*/
+ sqe->src_table_width = ctx->table_data.table_width;
+ sqe->dst_table_width = ctx->table_data.table_width;
if (table_data_src) {
sqe->src_table_width = table_data_src->table_width;
@@ -814,6 +816,7 @@ static int join_get_table_rowsize(struct join_gather_col_data *cols_data,
for (i = 0; i < key_num; i++)
row_count_size += get_data_type_size(key_data[i].hw_type, 0);
+ row_count_size += HASH_TABLE_EMPTY_SIZE;
row_count_size = ALIGN(row_count_size, DAE_KEY_ALIGN_SIZE);
row_count_size += HASH_TABLE_HEAD_TAIL_SIZE +
cols_data->index_num * HASH_TABLE_INDEX_SIZE;
--
2.33.0
1
4
06 Jan '26
From: Zhushuai Yin <yinzhushuai(a)huawei.com>
Due to changes in chip specifications, the hash agg 8B and 16B operations
have been reduced from 9 columns to 8 columns,requiring the driver to be
adapted accordingly.
Signed-off-by: Zhushuai Yin <yinzhushuai(a)huawei.com>
---
drv/hisi_dae.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drv/hisi_dae.c b/drv/hisi_dae.c
index d7b34c2..a6ee368 100644
--- a/drv/hisi_dae.c
+++ b/drv/hisi_dae.c
@@ -673,7 +673,7 @@ static int agg_get_output_num(enum wd_dae_data_type type,
}
static int agg_output_num_check(struct wd_agg_col_info *agg_cols, __u32 cols_num,
- bool is_count_all, __u16 hw_type)
+ bool is_count_all)
{
__u32 size8 = 0, size16 = 0;
__u32 i, j, count_num;
@@ -691,8 +691,7 @@ static int agg_output_num_check(struct wd_agg_col_info *agg_cols, __u32 cols_num
if (is_count_all)
size8++;
- if (hw_type < HISI_QM_API_VER5_BASE &&
- (size8 > DAE_MAX_8B_COLS_NUM || size16 > DAE_MAX_16B_COLS_NUM)) {
+ if (size8 > DAE_MAX_8B_COLS_NUM || size16 > DAE_MAX_16B_COLS_NUM) {
WD_ERR("invalid: output col num 8B-16B %u-%u is more than support %d-%d !\n",
size8, size16, DAE_MAX_8B_COLS_NUM, DAE_MAX_16B_COLS_NUM);
return -WD_EINVAL;
@@ -708,7 +707,7 @@ static int agg_output_num_check(struct wd_agg_col_info *agg_cols, __u32 cols_num
return WD_SUCCESS;
}
-static int hashagg_init_param_check(struct wd_agg_sess_setup *setup, __u16 hw_type)
+static int hashagg_init_param_check(struct wd_agg_sess_setup *setup)
{
int ret;
@@ -735,7 +734,7 @@ static int hashagg_init_param_check(struct wd_agg_sess_setup *setup, __u16 hw_ty
return -WD_EINVAL;
return agg_output_num_check(setup->agg_cols_info, setup->agg_cols_num,
- setup->is_count_all, hw_type);
+ setup->is_count_all);
}
static int transfer_key_col_info(struct wd_key_col_info *key_cols,
@@ -1236,7 +1235,7 @@ static int hashagg_sess_priv_init(struct wd_alg_driver *drv,
h_qp = (handle_t)wd_ctx_get_priv(config->ctxs[0].ctx);
qp = (struct hisi_qp *)h_qp;
- ret = hashagg_init_param_check(setup, qp->q_info.hw_type);
+ ret = hashagg_init_param_check(setup);
if (ret)
return -WD_EINVAL;
--
2.33.0
1
0
06 Jan '26
From: Weili Qian <qianweili(a)huawei.com>
When looking up the corresponding driver by algorithm type,
since the driver does not save the algorithm type, it cannot
be directly obtained. Therefore, the algorithm type should be
saved during algorithm registration.
Signed-off-by: Weili Qian <qianweili(a)huawei.com>
---
include/wd_alg.h | 2 ++
libwd.map | 1 +
wd_alg.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++
wd_util.c | 94 ++++--------------------------------------------
4 files changed, 102 insertions(+), 87 deletions(-)
diff --git a/include/wd_alg.h b/include/wd_alg.h
index 5ff73ca..848bdf1 100644
--- a/include/wd_alg.h
+++ b/include/wd_alg.h
@@ -145,6 +145,7 @@ struct wd_alg_list {
struct wd_alg_driver *drv;
struct wd_alg_list *next;
+ char alg_type[ALG_NAME_SIZE];
};
/*
@@ -178,6 +179,7 @@ int wd_alg_driver_init(struct wd_alg_driver *drv, void *conf);
void wd_alg_driver_exit(struct wd_alg_driver *drv);
int wd_alg_driver_send(struct wd_alg_driver *drv, handle_t ctx, void *msg);
int wd_alg_driver_recv(struct wd_alg_driver *drv, handle_t ctx, void *msg);
+int wd_get_alg_type(const char *alg_name, char *alg_type);
struct wd_alg_list *wd_get_alg_head(void);
diff --git a/libwd.map b/libwd.map
index 90eb5c5..5d732d0 100644
--- a/libwd.map
+++ b/libwd.map
@@ -53,6 +53,7 @@ global:
wd_alg_driver_exit;
wd_alg_driver_send;
wd_alg_driver_recv;
+ wd_get_alg_type;
wd_find_ctx;
wd_get_dev_id;
diff --git a/wd_alg.c b/wd_alg.c
index 9c7c0fd..919483b 100644
--- a/wd_alg.c
+++ b/wd_alg.c
@@ -24,6 +24,97 @@ static struct wd_alg_list *alg_list_tail = &alg_list_head;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+struct acc_alg_item {
+ const char *name;
+ const char *algtype;
+};
+
+static struct acc_alg_item alg_options[] = {
+ {"zlib", "zlib"},
+ {"gzip", "gzip"},
+ {"deflate", "deflate"},
+ {"lz77_zstd", "lz77_zstd"},
+ {"lz4", "lz4"},
+ {"lz77_only", "lz77_only"},
+ {"hashagg", "hashagg"},
+ {"udma", "udma"},
+ {"hashjoin", "hashjoin"},
+ {"gather", "gather"},
+ {"join-gather", "hashjoin"},
+
+ {"rsa", "rsa"},
+ {"dh", "dh"},
+ {"ecdh", "ecdh"},
+ {"x25519", "x25519"},
+ {"x448", "x448"},
+ {"ecdsa", "ecdsa"},
+ {"sm2", "sm2"},
+
+ {"ecb(aes)", "cipher"},
+ {"cbc(aes)", "cipher"},
+ {"xts(aes)", "cipher"},
+ {"ofb(aes)", "cipher"},
+ {"cfb(aes)", "cipher"},
+ {"ctr(aes)", "cipher"},
+ {"cbc-cs1(aes)", "cipher"},
+ {"cbc-cs2(aes)", "cipher"},
+ {"cbc-cs3(aes)", "cipher"},
+ {"ecb(sm4)", "cipher"},
+ {"xts(sm4)", "cipher"},
+ {"cbc(sm4)", "cipher"},
+ {"ofb(sm4)", "cipher"},
+ {"cfb(sm4)", "cipher"},
+ {"ctr(sm4)", "cipher"},
+ {"cbc-cs1(sm4)", "cipher"},
+ {"cbc-cs2(sm4)", "cipher"},
+ {"cbc-cs3(sm4)", "cipher"},
+ {"ecb(des)", "cipher"},
+ {"cbc(des)", "cipher"},
+ {"ecb(des3_ede)", "cipher"},
+ {"cbc(des3_ede)", "cipher"},
+
+ {"ccm(aes)", "aead"},
+ {"gcm(aes)", "aead"},
+ {"ccm(sm4)", "aead"},
+ {"gcm(sm4)", "aead"},
+ {"authenc(generic,cbc(aes))", "aead"},
+ {"authenc(generic,cbc(sm4))", "aead"},
+
+ {"sm3", "digest"},
+ {"md5", "digest"},
+ {"sha1", "digest"},
+ {"sha256", "digest"},
+ {"sha224", "digest"},
+ {"sha384", "digest"},
+ {"sha512", "digest"},
+ {"sha512-224", "digest"},
+ {"sha512-256", "digest"},
+ {"cmac(aes)", "digest"},
+ {"gmac(aes)", "digest"},
+ {"xcbc-mac-96(aes)", "digest"},
+ {"xcbc-prf-128(aes)", "digest"},
+ {"", ""}
+};
+
+int wd_get_alg_type(const char *alg_name, char *alg_type)
+{
+ __u64 i;
+
+ if (!alg_name || !alg_type) {
+ WD_ERR("invalid: alg_name or alg_type is NULL!\n");
+ return -WD_EINVAL;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(alg_options); i++) {
+ if (strcmp(alg_name, alg_options[i].name) == 0) {
+ (void)strcpy(alg_type, alg_options[i].algtype);
+ return 0;
+ }
+ }
+
+ return -WD_EINVAL;
+}
+
static bool wd_check_accel_dev(const char *dev_name)
{
struct dirent *dev_dir;
@@ -182,6 +273,7 @@ int wd_alg_driver_register(struct wd_alg_driver *drv)
return -WD_ENOMEM;
}
+ (void)wd_get_alg_type(drv->alg_name, new_alg->alg_type);
strncpy(new_alg->alg_name, drv->alg_name, ALG_NAME_SIZE - 1);
strncpy(new_alg->drv_name, drv->drv_name, DEV_NAME_LEN - 1);
new_alg->priority = drv->priority;
diff --git a/wd_util.c b/wd_util.c
index 138a078..67a46a6 100644
--- a/wd_util.c
+++ b/wd_util.c
@@ -98,78 +98,6 @@ struct drv_lib_list {
struct drv_lib_list *next;
};
-struct acc_alg_item {
- const char *name;
- const char *algtype;
-};
-
-static struct acc_alg_item alg_options[] = {
- {"zlib", "zlib"},
- {"gzip", "gzip"},
- {"deflate", "deflate"},
- {"lz77_zstd", "lz77_zstd"},
- {"lz4", "lz4"},
- {"lz77_only", "lz77_only"},
- {"hashagg", "hashagg"},
- {"udma", "udma"},
- {"hashjoin", "hashjoin"},
- {"gather", "gather"},
- {"join-gather", "hashjoin"},
-
- {"rsa", "rsa"},
- {"dh", "dh"},
- {"ecdh", "ecdh"},
- {"x25519", "x25519"},
- {"x448", "x448"},
- {"ecdsa", "ecdsa"},
- {"sm2", "sm2"},
-
- {"ecb(aes)", "cipher"},
- {"cbc(aes)", "cipher"},
- {"xts(aes)", "cipher"},
- {"ofb(aes)", "cipher"},
- {"cfb(aes)", "cipher"},
- {"ctr(aes)", "cipher"},
- {"cbc-cs1(aes)", "cipher"},
- {"cbc-cs2(aes)", "cipher"},
- {"cbc-cs3(aes)", "cipher"},
- {"ecb(sm4)", "cipher"},
- {"xts(sm4)", "cipher"},
- {"cbc(sm4)", "cipher"},
- {"ofb(sm4)", "cipher"},
- {"cfb(sm4)", "cipher"},
- {"ctr(sm4)", "cipher"},
- {"cbc-cs1(sm4)", "cipher"},
- {"cbc-cs2(sm4)", "cipher"},
- {"cbc-cs3(sm4)", "cipher"},
- {"ecb(des)", "cipher"},
- {"cbc(des)", "cipher"},
- {"ecb(des3_ede)", "cipher"},
- {"cbc(des3_ede)", "cipher"},
-
- {"ccm(aes)", "aead"},
- {"gcm(aes)", "aead"},
- {"ccm(sm4)", "aead"},
- {"gcm(sm4)", "aead"},
- {"authenc(generic,cbc(aes))", "aead"},
- {"authenc(generic,cbc(sm4))", "aead"},
-
- {"sm3", "digest"},
- {"md5", "digest"},
- {"sha1", "digest"},
- {"sha256", "digest"},
- {"sha224", "digest"},
- {"sha384", "digest"},
- {"sha512", "digest"},
- {"sha512-224", "digest"},
- {"sha512-256", "digest"},
- {"cmac(aes)", "digest"},
- {"gmac(aes)", "digest"},
- {"xcbc-mac-96(aes)", "digest"},
- {"xcbc-prf-128(aes)", "digest"},
- {"", ""}
-};
-
static void *wd_internal_alloc(void *usr, size_t size)
{
if (size != 0)
@@ -2013,18 +1941,6 @@ int wd_init_param_check(struct wd_ctx_config *config, struct wd_sched *sched)
return 0;
}
-static void wd_get_alg_type(const char *alg_name, char *alg_type)
-{
- __u64 i;
-
- for (i = 0; i < ARRAY_SIZE(alg_options); i++) {
- if (strcmp(alg_name, alg_options[i].name) == 0) {
- (void)strcpy(alg_type, alg_options[i].algtype);
- break;
- }
- }
-}
-
static int wd_alg_init_fallback(struct wd_alg_driver *fb_driver)
{
if (!fb_driver->init) {
@@ -2175,7 +2091,7 @@ static int wd_env_set_ctx_nums(const char *alg_name, const char *name, const cha
char *left, *section, *start;
struct uacce_dev_list *list;
int is_comp;
- int ret = 0;
+ int ret;
/* COMP environment variable's format is different, mark it */
is_comp = strncmp(name, "WD_COMP_CTX_NUM", strlen(name)) ? 0 : 1;
@@ -2186,7 +2102,10 @@ static int wd_env_set_ctx_nums(const char *alg_name, const char *name, const cha
if (!start)
return -WD_ENOMEM;
- wd_get_alg_type(alg_name, alg_type);
+ ret = wd_get_alg_type(alg_name, alg_type);
+ if (ret)
+ return ret;
+
list = wd_get_accel_list(alg_type);
if (!list) {
WD_ERR("failed to get devices!\n");
@@ -3112,7 +3031,8 @@ int wd_alg_attrs_init(struct wd_init_attrs *attrs)
}
break;
case UADK_ALG_HW:
- wd_get_alg_type(alg, alg_type);
+ if (wd_get_alg_type(alg, alg_type))
+ return -WD_EINVAL;
(void)strcpy(attrs->alg, alg_type);
ctx_config = calloc(1, sizeof(*ctx_config));
--
2.33.0
1
4
您好!
sig-AccLib 邀请您参加 2025-12-24 11:00 召开的Zoom会议
会议主题:【2025/12/24 AccLIb SIG 双周例会 11:00 - 12:00】
会议链接:https://us06web.zoom.us/j/82679099901?pwd=rhb41PVIzL4V7ST8egX5bRqqq4Fag6.1
会议纪要:https://etherpad.openeuler.org/p/sig-AccLib-meetings
更多资讯尽在:https://www.openeuler.org/zh/
Hello!
sig-AccLib invites you to attend the Zoom conference will be held at 2025-12-24 11:00,
The subject of the conference is 【2025/12/24 AccLIb SIG 双周例会 11:00 - 12:00】
You can join the meeting at https://us06web.zoom.us/j/82679099901?pwd=rhb41PVIzL4V7ST8egX5bRqqq4Fag6.1
Add topics at https://etherpad.openeuler.org/p/sig-AccLib-meetings
More information: https://www.openeuler.org/en/
1
0