Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ pkginclude_HEADERS = include/wd.h include/wd_internal.h include/wd_cipher.h incl
include/wd_udma.h include/wd_join_gather.h \
include/wd_bmm.h

nobase_pkginclude_HEADERS = v1/wd.h v1/wd_cipher.h v1/wd_aead.h v1/uacce.h v1/wd_dh.h \
v1/wd_digest.h v1/wd_rsa.h v1/wd_bmm.h
nobase_pkginclude_HEADERS=v1/wd.h v1/wd_cipher.h v1/wd_aead.h v1/wd_dh.h v1/wd_digest.h \
v1/wd_rsa.h v1/wd_bmm.h v1/wd_ecc.h v1/wd_comp.h

lib_LTLIBRARIES=libwd.la libwd_comp.la libwd_crypto.la libwd_dae.la libwd_udma.la

Expand Down Expand Up @@ -120,20 +120,20 @@ if WD_STATIC_DRV
AM_CFLAGS += -DWD_STATIC_DRV -fPIC
AM_CFLAGS += -DWD_NO_LOG

libwd_la_LIBADD = $(libwd_la_OBJECTS) -ldl -lnuma
libwd_la_LIBADD = $(libwd_la_OBJECTS) -ldl -lnuma -lpthread -lrt

libwd_comp_la_LIBADD = $(libwd_la_OBJECTS) -ldl -lnuma
libwd_comp_la_LIBADD = $(libwd_la_OBJECTS) -ldl -lnuma -lpthread
libwd_comp_la_DEPENDENCIES = libwd.la

libhisi_zip_la_LIBADD = -ldl
libhisi_zip_la_LIBADD = -ldl -lpthread

libwd_crypto_la_LIBADD = -lwd -ldl -lnuma -lm -lpthread
libwd_crypto_la_LIBADD = -lwd -ldl -lnuma -lpthread
libwd_crypto_la_DEPENDENCIES = libwd.la

libwd_udma_la_LIBADD = $(libwd_la_OBJECTS) -ldl -lnuma -lm -lpthread
libwd_udma_la_DEPENDENCIES = libwd.la

libwd_dae_la_LIBADD = $(libwd_la_OBJECTS) -ldl -lnuma
libwd_dae_la_LIBADD = $(libwd_la_OBJECTS) -ldl -lnuma -lm -lpthread
libwd_dae_la_DEPENDENCIES = libwd.la

libhisi_sec_la_LIBADD = $(libwd_la_OBJECTS) $(libwd_crypto_la_OBJECTS)
Expand Down Expand Up @@ -164,19 +164,19 @@ UADK_V1_SYMBOL= -Wl,--version-script,$(top_srcdir)/v1/libwd.map
libwd_la_LDFLAGS=$(UADK_VERSION) $(UADK_WD_SYMBOL) $(UADK_V1_SYMBOL)
libwd_la_LIBADD= -ldl -lnuma

libwd_comp_la_LIBADD= -lwd -ldl -lnuma
libwd_comp_la_LDFLAGS=$(UADK_VERSION) $(UADK_COMP_SYMBOL) -lpthread
libwd_comp_la_LIBADD= -lwd -ldl -lnuma -lpthread
libwd_comp_la_LDFLAGS=$(UADK_VERSION) $(UADK_COMP_SYMBOL)
libwd_comp_la_DEPENDENCIES= libwd.la

libwd_crypto_la_LIBADD= -lwd -ldl -lnuma
libwd_crypto_la_LDFLAGS=$(UADK_VERSION) $(UADK_CRYPTO_SYMBOL) -lpthread
libwd_crypto_la_LIBADD= -lwd -ldl -lnuma -lpthread
libwd_crypto_la_LDFLAGS=$(UADK_VERSION) $(UADK_CRYPTO_SYMBOL)
libwd_crypto_la_DEPENDENCIES= libwd.la

libwd_udma_la_LIBADD= -lwd -ldl -lnuma -lm -lpthread
libwd_udma_la_LDFLAGS=$(UADK_VERSION) $(UADK_DAE_SYMBOL)
libwd_udma_la_DEPENDENCIES= libwd.la

libwd_dae_la_LIBADD= -lwd -ldl -lnuma -lm
libwd_dae_la_LIBADD= -lwd -ldl -lnuma -lm -lpthread
libwd_dae_la_LDFLAGS=$(UADK_VERSION) $(UADK_DAE_SYMBOL)
libwd_dae_la_DEPENDENCIES= libwd.la

Expand Down
7 changes: 0 additions & 7 deletions docs/wd_environment_variable
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ offer process level WD configures.
1. WD environment variables define
==================================

WD_<alg>_ASYNC_POLL_EN
----------------------

Define if enble polling threads in WD. WD_<alg>_ASYNC_POLL_EN=1 means enable
polling threads in WD, otherwise caller should poll finished request by
WD APIs.

WD_COMP_CTX_NUM
-----------------

Expand Down
3 changes: 2 additions & 1 deletion include/wd_aead.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ void wd_aead_ctx_num_uninit(void);
* @type: operation type.
* @mode: 0: sync mode, 1: async mode
* @num: return ctx num.
* @is_enable return enable inner poll flag.
* @is_enable: return enable inner poll flag, inner poll is not
* supported, and is_enable will always be 0.
*
* If the current algorithm library does not require the type parameter,
* the type parameter is invalid. The function returns 0 to indicate that
Expand Down
3 changes: 2 additions & 1 deletion include/wd_cipher.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ void wd_cipher_ctx_num_uninit(void);
* @type: operation type.
* @mode: 0: sync mode, 1: async mode
* @num: return ctx num.
* @is_enable return enable inner poll flag.
* @is_enable: return enable inner poll flag, inner poll is not
* supported, and is_enable will always be 0.
*/
int wd_cipher_get_env_param(__u32 node, __u32 type, __u32 mode,
__u32 *num, __u8 *is_enable);
Expand Down
3 changes: 2 additions & 1 deletion include/wd_comp.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ void wd_comp_ctx_num_uninit(void);
* @type: operation type.
* @mode: 0: sync mode, 1: async mode
* @num: return ctx num.
* @is_enable return enable inner poll flag.
* @is_enable: return enable inner poll flag, inner poll is not
* supported, and is_enable will always be 0.
*
* If the current algorithm library does not require the type parameter,
* the type parameter is invalid. The function returns 0 to indicate that
Expand Down
3 changes: 2 additions & 1 deletion include/wd_digest.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ void wd_digest_ctx_num_uninit(void);
* @type: operation type.
* @mode: 0: sync mode, 1: async mode
* @num: return ctx num.
* @is_enable return enable inner poll flag.
* @is_enable: return enable inner poll flag, inner poll is not
* supported, and is_enable will always be 0.
*/
int wd_digest_get_env_param(__u32 node, __u32 type, __u32 mode,
__u32 *num, __u8 *is_enable);
Expand Down
3 changes: 2 additions & 1 deletion include/wd_ecc.h
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,8 @@ void wd_ecc_ctx_num_uninit(void);
* @type: operation type.
* @mode: 0: sync mode, 1: async mode
* @num: return ctx num.
* @is_enable return enable inner poll flag.
* @is_enable: return enable inner poll flag, inner poll is not
* supported, and is_enable will always be 0.
*/
int wd_ecc_get_env_param(__u32 node, __u32 type, __u32 mode,
__u32 *num, __u8 *is_enable);
Expand Down
3 changes: 2 additions & 1 deletion include/wd_rsa.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ void wd_rsa_ctx_num_uninit(void);
* @type: operation type.
* @mode: 0: sync mode, 1: async mode
* @num: return ctx num.
* @is_enable return enable inner poll flag.
* @is_enable: return enable inner poll flag, inner poll is not
* supported, and is_enable will always be 0.
*/
int wd_rsa_get_env_param(__u32 node, __u32 type, __u32 mode,
__u32 *num, __u8 *is_enable);
Expand Down
41 changes: 4 additions & 37 deletions include/wd_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ extern "C" {
for ((i) = 0, (config_numa) = (config)->config_per_numa; \
(i) < (config)->numa_num; (config_numa)++, (i)++)

#define COMP_ALG "comp"
#define CTX_COMP_ALG "zlib-comp gzip-comp deflate-comp lz77_zstd-comp lz4-comp lz77_only-comp"
#define CTX_DECOMP_ALG "zlib-decomp gzip-decomp deflate-decomp lz77_zstd-decomp lz4-decomp lz77_only-decomp"

enum wd_status {
WD_UNINIT,
WD_INITING,
Expand Down Expand Up @@ -78,16 +82,10 @@ struct wd_env_config_per_numa {
/* Resource begin */
struct uacce_dev *dev;
int dev_num;
/* This can be made statically currently */
unsigned long async_poll_num;
void *async_task_queue_array;
};

struct wd_env_config {
struct wd_env_config_per_numa *config_per_numa;
/* Let's make it as a gobal config, not per numa */
bool enable_internal_poll;

/* resource config */
struct wd_sched *sched;
bool internal_sched;
Expand Down Expand Up @@ -270,28 +268,6 @@ int wd_check_datalist(struct wd_datalist *head, __u64 size);
*/
int wd_parse_ctx_num(struct wd_env_config *config, const char *s);

/*
* wd_parse_async_poll_en() - Parse async polling thread related environment
* variable and store it.
* @config: Pointer of wd_env_config which is used to store environment
* variable information.
* @s: Related environment variable string.
*
* More information, please see docs/wd_environment_variable.
*/
int wd_parse_async_poll_en(struct wd_env_config *config, const char *s);

/*
* wd_parse_async_poll_num() - Parse async polling thread related environment
* variable and store it.
* @config: Pointer of wd_env_config which is used to store environment
* variable information.
* @s: Related environment variable string.
*
* More information, please see docs/wd_environment_variable.
*/
int wd_parse_async_poll_num(struct wd_env_config *config, const char *s);

/*
* wd_alg_env_init() - Init wd algorithm environment variable configurations.
* This is a help function which can be used by specific
Expand Down Expand Up @@ -320,15 +296,6 @@ int wd_alg_env_init(struct wd_env_config *env_config,
void wd_alg_env_uninit(struct wd_env_config *env_config,
const struct wd_alg_ops *ops);

/*
* wd_add_task_to_async_queue() - Add an async request to its related async
* task queue.
* @config: Pointer of wd_env_config which is used to store environment
* variable information.
* @idx: Index of ctx in config.
*/
int wd_add_task_to_async_queue(struct wd_env_config *config, __u32 idx);

/*
* dump_env_info() - dump wd algorithm ctx info.
* @config: Pointer of wd_env_config which is used to store environment
Expand Down
2 changes: 0 additions & 2 deletions test/sanity_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,6 @@ run_zip_test_v2()
return 0
fi
export WD_COMP_CTX_NUM="sync-comp:4@0,sync-decomp:4@0,async-comp:4@0,async-decomp:4@0"
export WD_COMP_ASYNC_POLL_EN=1
export WD_COMP_ASYNC_POLL_NUM="4@0"
# test without environment variables
# limit test text file in 8MB
rm -fr /tmp/textfile
Expand Down
9 changes: 8 additions & 1 deletion uadk_tool/benchmark/zip_uadk_benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -803,12 +803,19 @@ static void free_uadk_bd_pool(void)
static int init_uadk_rsv_pool(struct acc_option *option)
{
struct wd_mempool_setup pool_setup;
char *alg = option->algclass;
char alg[CRYPTO_MAX_ALG_NAME];
u32 insize = g_pktlen;
handle_t h_ctx;
u32 outsize;
int i, j;

if (option->optype == 1)
snprintf(alg, CRYPTO_MAX_ALG_NAME - 1, "%s-decomp",
option->algclass);
else
snprintf(alg, CRYPTO_MAX_ALG_NAME - 1, "%s-comp",
option->algclass);

h_ctx = wd_find_ctx(alg);
if (!h_ctx) {
ZIP_TST_PRT("failed to find a ctx for alg: %s\n", option->algname);
Expand Down
26 changes: 17 additions & 9 deletions v1/drv/hisi_zip_udrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <sys/eventfd.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <time.h>
#include "v1/wd_util.h"
#include "v1/wd_comp.h"
#include "v1/wd_cipher.h"
Expand Down Expand Up @@ -132,21 +133,27 @@ struct zip_fill_sqe_ops {
void (*fill_sqe_hw_info)(void *ssqe, struct wcrypto_comp_msg *msg);
};

static unsigned int g_err_print_enable = 1;
static timer_t g_timerid;
static sig_atomic_t g_err_print_enable = 1;

static void zip_err_print_alarm_end(int sig)
static void zip_err_print_alarm_end(union sigval sv)
{
if (sig == SIGALRM) {
g_err_print_enable = 1;
alarm(0);
}
timer_delete(g_timerid);
g_err_print_enable = 1;
}

static void zip_err_print_time_start(void)
{
g_err_print_enable = 0;
signal(SIGALRM, zip_err_print_alarm_end);
alarm(PRINT_TIME_INTERVAL);
struct itimerspec its = {0};
struct sigevent sev = {0};

sev.sigev_notify = SIGEV_THREAD;
sev.sigev_notify_function = zip_err_print_alarm_end;
sev.sigev_value.sival_ptr = &g_timerid;
timer_create(CLOCK_REALTIME, &sev, &g_timerid);

its.it_value.tv_sec = PRINT_TIME_INTERVAL;
timer_settime(g_timerid, 0, &its, NULL);
}

static void zip_err_bd_print(__u16 ctx_st, __u32 status, __u32 type)
Expand All @@ -155,6 +162,7 @@ static void zip_err_bd_print(__u16 ctx_st, __u32 status, __u32 type)
WD_ERR("bad status(ctx_st=0x%x, s=0x%x, t=%u)\n",
ctx_st, status, type);
} else if (g_err_print_enable == 1) {
g_err_print_enable = 0;
WD_ERR("bad status(ctx_st=0x%x, s=0x%x, t=%u)\n",
ctx_st, status, type);
zip_err_print_time_start();
Expand Down
2 changes: 1 addition & 1 deletion v1/wd.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <poll.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/poll.h>
#include <sys/types.h>
#include <unistd.h>

Expand Down
2 changes: 1 addition & 1 deletion v1/wd_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void wd_free_id(__u8 *buf, __u32 size, __u32 id, __u32 id_max)
int wd_init_cookie_pool(struct wd_cookie_pool *pool,
__u32 cookies_size, __u32 cookies_num)
{
__u64 total_size = cookies_size * cookies_num;
__u64 total_size = (__u64)cookies_size * cookies_num;

pool->cookies = calloc(1, total_size + cookies_num);
if (!pool->cookies)
Expand Down
27 changes: 9 additions & 18 deletions wd_aead.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,7 @@ static void cleanup_session(struct wd_aead_sess *sess)
sess->mm_ops.free(sess->mm_ops.usr, sess->ckey);
sess->mm_ops.free(sess->mm_ops.usr, sess->akey);

if (sess)
free(sess);
free(sess);
}

static int wd_aead_sess_eops_init(struct wd_aead_sess *sess)
Expand Down Expand Up @@ -960,9 +959,6 @@ int wd_do_aead_async(handle_t h_sess, struct wd_aead_req *req)
}

wd_dfx_msg_cnt(config, WD_CTX_CNT_NUM, idx);
ret = wd_add_task_to_async_queue(&wd_aead_env_config, idx);
if (ret)
goto fail_with_msg;

return 0;

Expand Down Expand Up @@ -1042,15 +1038,10 @@ int wd_aead_poll(__u32 expt, __u32 *count)
return sched->poll_policy(h_ctx, expt, count);
}

static const struct wd_config_variable table[] = {
{ .name = "WD_AEAD_CTX_NUM",
.def_val = "sync:2@0,async:2@0",
.parse_fn = wd_parse_ctx_num
},
{ .name = "WD_AEAD_ASYNC_POLL_EN",
.def_val = "0",
.parse_fn = wd_parse_async_poll_en
}
static const struct wd_config_variable table = {
.name = "WD_AEAD_CTX_NUM",
.def_val = "sync:2@0,async:2@0",
.parse_fn = wd_parse_ctx_num
};

static const struct wd_alg_ops wd_aead_ops = {
Expand All @@ -1065,8 +1056,8 @@ int wd_aead_env_init(struct wd_sched *sched)
{
wd_aead_env_config.sched = sched;

return wd_alg_env_init(&wd_aead_env_config, table,
&wd_aead_ops, ARRAY_SIZE(table), NULL);
return wd_alg_env_init(&wd_aead_env_config, &table,
&wd_aead_ops, 1, NULL);
}

void wd_aead_env_uninit(void)
Expand All @@ -1083,8 +1074,8 @@ int wd_aead_ctx_num_init(__u32 node, __u32 type, __u32 num, __u8 mode)
if (ret)
return ret;

return wd_alg_env_init(&wd_aead_env_config, table,
&wd_aead_ops, ARRAY_SIZE(table), &ctx_attr);
return wd_alg_env_init(&wd_aead_env_config, &table,
&wd_aead_ops, 1, &ctx_attr);
}

void wd_aead_ctx_num_uninit(void)
Expand Down
Loading
Loading