Skip to content

Commit

Permalink
uadk: add heterogeneous computing capabilities to UADK driver
Browse files Browse the repository at this point in the history
Add heterogeneous computing functions to the soft and hard computing
drivers of UADK. Adapt the drivers to ensure that different devices
can perform heterogeneous computing at the same time and provide
acceleration functions.

In order to ensure normal compilation, some drivers have been
processed with hac mode, and can be compiled directly through UADK_MK.SH

Signed-off-by: Longfang Liu <[email protected]>
  • Loading branch information
Longfang Liu committed Oct 8, 2024
1 parent 827d974 commit 1d1314e
Show file tree
Hide file tree
Showing 12 changed files with 170 additions and 157 deletions.
139 changes: 40 additions & 99 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
ACLOCAL_AMFLAGS = -I m4 -I./include
AUTOMAKE_OPTIONS = foreign subdir-objects
AM_CFLAGS=-Wall -Werror -fno-strict-aliasing -I$(top_srcdir)/include
AM_CFLAGS+=-fPIC -fPIE -pie -fstack-protector-strong -D_FORTIFY_SOURCE=2 \
-O2 -ftrapv -Wl,-z,relro,-z,now -Wl,-s
CLEANFILES =
AM_CFLAGS = -std=gnu11 -Wall -Werror -Wextra -Wno-unused-parameter -Wfloat-equal -I$(top_srcdir)/include
AM_CFLAGS += -g -O0 -fno-omit-frame-pointer -fPIC -fPIE -pie -fstack-protector-strong -ftrapv

if WITH_LOG_FILE
AM_CFLAGS+=-DWITH_LOG_FILE=\"$(with_log_file)\"
Expand All @@ -22,77 +20,40 @@ endif # WITH_LOG_FILE
# y = minor
# z = revision
MAJOR = 2
MINOR = 7
REVISION = 0
MINOR = 3
REVISION = 22
UADK_VERSION = -version-number ${MAJOR}:${MINOR}:${REVISION}

DAY = 6
MONTH = June
YEAR = 2024
DAY = 7
MONTH = Mar
YEAR = 2022
AM_CFLAGS+= -DUADK_VERSION_NUMBER="\"UADK version: ${MAJOR}.${MINOR}.${REVISION}\""
AM_CFLAGS+= -DUADK_RELEASED_TIME="\"Released ${MONTH} ${DAY}, ${YEAR}\""

pkginclude_HEADERS = include/wd.h include/wd_cipher.h include/wd_aead.h \
include/wd_comp.h include/wd_dh.h include/wd_digest.h \
include/wd_rsa.h include/uacce.h include/wd_alg_common.h \
include/wd_ecc.h include/wd_sched.h include/wd_alg.h \
include/wd_zlibwrapper.h include/wd_dae.h include/wd_agg.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

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

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

libwd_la_SOURCES=wd.c wd_mempool.c 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 \
v1/wd_comp.c v1/wd_comp.h \
v1/wd_cipher.c v1/wd_cipher.h \
v1/wd_digest.c v1/wd_digest.h \
v1/wd_util.c v1/wd_util.h \
v1/wd_bmm.c v1/wd_bmm.h \
v1/wd_ecc.c v1/wd_ecc.h \
v1/wd_sgl.c v1/wd_sgl.h \
v1/drv/hisi_qm_udrv.c v1/drv/hisi_qm_udrv.h \
v1/drv/hisi_zip_udrv.c v1/drv/hisi_zip_udrv.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

libwd_dae_la_SOURCES=wd_dae.h wd_agg.h wd_agg_drv.h wd_agg.c \
wd_util.c wd_util.h wd_sched.c wd_sched.h wd.c wd.h
include_HEADERS = include/wd.h include/wd_cipher.h include/wd_comp.h \
include/uacce.h include/wd_alg_common.h \
include/wd_sched.h include/wd_alg.h

lib_LTLIBRARIES=libwd.la libwd_comp.la libwd_crypto.la libhisi_zip.la \
libisa_ce.la libisa_sve.la libhisi_sec.la

libwd_la_SOURCES=wd.c wd_mempool.c wd.h wd_alg.c wd_alg.h

libwd_comp_la_SOURCES=wd_comp.c wd_comp.h wd_comp_drv.h wd_util.c wd_util.h \
wd_sched.c wd_sched.h wd.c wd.h wd_zlibwrapper.c
wd_sched.c wd_sched.h wd.c wd.h \
wd_zlibwrapper.c wd_zlibwrapper.h

libhisi_zip_la_SOURCES=drv/hisi_comp.c hisi_comp.h drv/hisi_qm_udrv.c \
hisi_qm_udrv.h wd_comp_drv.h

libwd_crypto_la_SOURCES=wd_cipher.c wd_cipher.h wd_cipher_drv.h \
wd_aead.c wd_aead.h wd_aead_drv.h \
wd_rsa.c wd_rsa.h wd_rsa_drv.h \
wd_dh.c wd_dh.h wd_dh_drv.h \
wd_ecc.c wd_ecc.h wd_ecc_drv.h \
wd_digest.c wd_digest.h wd_digest_drv.h \
wd_util.c wd_util.h \
wd_sched.c wd_sched.h \
wd.c wd.h

libhisi_sec_la_SOURCES=drv/hisi_sec.c drv/hisi_qm_udrv.c \
lib/crypto/aes.c lib/crypto/galois.c \
hisi_qm_udrv.h wd_cipher_drv.h wd_aead_drv.h aes.h galois.h

libhisi_hpre_la_SOURCES=drv/hisi_hpre.c drv/hisi_qm_udrv.c \
hisi_qm_udrv.h

libisa_ce_la_SOURCES=arm_arch_ce.h drv/isa_ce_sm3.c drv/isa_ce_sm3_armv8.S isa_ce_sm3.h \
libisa_ce_la_SOURCES=arm_arch_ce.h wd_cipher_drv.h drv/isa_ce_sm3.c \
drv/isa_ce_sm3_armv8.S isa_ce_sm3.h \
drv/isa_ce_sm4.c drv/isa_ce_sm4_armv8.S drv/isa_ce_sm4.h

libisa_sve_la_SOURCES=drv/hash_mb/hash_mb.c wd_digest_drv.h drv/hash_mb/hash_mb.h \
Expand All @@ -101,75 +62,55 @@ libisa_sve_la_SOURCES=drv/hash_mb/hash_mb.c wd_digest_drv.h drv/hash_mb/hash_mb.
drv/hash_mb/md5_sve_common.S drv/hash_mb/md5_mb_asimd_x1.S \
drv/hash_mb/md5_mb_asimd_x4.S drv/hash_mb/md5_mb_sve.S

libhisi_dae_la_SOURCES=drv/hisi_dae.c drv/hisi_qm_udrv.c \
hisi_qm_udrv.h
libhisi_sec_la_SOURCES=drv/hisi_sec.c drv/hisi_qm_udrv.c \
hisi_qm_udrv.h wd_cipher_drv.h \
lib/crypto/aes.c lib/crypto/galois.c aes.h galois.h

if WD_STATIC_DRV
AM_CFLAGS += -DWD_STATIC_DRV -fPIC
AM_CFLAGS += -DWD_STATIC_DRV
AM_CFLAGS += -DWD_NO_LOG

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

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

libhisi_zip_la_LIBADD = -ldl
libhisi_zip_la_LIBADD = -ldl -lpthread

libwd_crypto_la_LIBADD = $(libwd_la_OBJECTS) -ldl -lnuma
libwd_crypto_la_LIBADD = $(libwd_la_OBJECTS) -ldl -lnuma -lm -lpthread
libwd_crypto_la_DEPENDENCIES = libwd.la

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

libhisi_sec_la_LIBADD = $(libwd_la_OBJECTS) $(libwd_crypto_la_OBJECTS)
libhisi_sec_la_DEPENDENCIES = libwd.la libwd_crypto.la

libhisi_hpre_la_LIBADD = $(libwd_la_OBJECTS) $(libwd_crypto_la_OBJECTS)
libhisi_hpre_la_DEPENDENCIES = libwd.la libwd_crypto.la

libisa_ce_la_LIBADD = $(libwd_la_OBJECTS) $(libwd_crypto_la_OBJECTS)
libisa_ce_la_DEPENDENCIES = libwd.la libwd_crypto.la

libisa_sve_la_LIBADD = $(libwd_la_OBJECTS) $(libwd_crypto_la_OBJECTS)
libisa_sve_la_DEPENDENCIES = libwd.la libwd_crypto.la

libhisi_dae_la_LIBADD = $(libwd_la_OBJECTS) $(libwd_dae_la_OBJECTS)
libhisi_dae_la_DEPENDENCIES = libwd.la libwd_dae.la
libhisi_sec_la_LIBADD = $(libwd_la_OBJECTS) $(libwd_crypto_la_OBJECTS) $(libisa_ce_la_OBJECTS) $(libisa_sve_la_OBJECTS)
libhisi_sec_la_DEPENDENCIES = libwd.la libwd_crypto.la libisa_ce.la libisa_sve.la

else
UADK_WD_SYMBOL= -Wl,--version-script,$(top_srcdir)/libwd.map
UADK_CRYPTO_SYMBOL= -Wl,--version-script,$(top_srcdir)/libwd_crypto.map
UADK_DAE_SYMBOL= -Wl,--version-script,$(top_srcdir)/libwd_dae.map
#UADK_DAE_SYMBOL= -Wl,--version-script,$(top_srcdir)/libwd_dae.map
UADK_COMP_SYMBOL= -Wl,--version-script,$(top_srcdir)/libwd_comp.map
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_la_LIBADD= -lnuma

libwd_comp_la_LIBADD= -lwd -ldl -lnuma
libwd_comp_la_LDFLAGS=$(UADK_VERSION) $(UADK_COMP_SYMBOL) -lpthread
libwd_comp_la_LIBADD= -lwd -ldl -lpthread -lnuma
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 -lm -lpthread
libwd_crypto_la_LDFLAGS=$(UADK_VERSION) $(UADK_CRYPTO_SYMBOL)
libwd_crypto_la_DEPENDENCIES= libwd.la

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

libhisi_zip_la_LIBADD= -lwd -ldl -lwd_comp
libhisi_zip_la_LDFLAGS=$(UADK_VERSION)
libhisi_zip_la_DEPENDENCIES= libwd.la libwd_comp.la

libhisi_sec_la_LIBADD= -lwd -lwd_crypto
libhisi_sec_la_LDFLAGS=$(UADK_VERSION)
libhisi_sec_la_DEPENDENCIES= libwd.la libwd_crypto.la

libhisi_hpre_la_LIBADD= -lwd -lwd_crypto
libhisi_hpre_la_LDFLAGS=$(UADK_VERSION)
libhisi_hpre_la_DEPENDENCIES= libwd.la libwd_crypto.la

libisa_ce_la_LIBADD= -lwd -lwd_crypto
libisa_ce_la_LDFLAGS=$(UADK_VERSION)
libisa_ce_la_DEPENDENCIES= libwd.la libwd_crypto.la
Expand All @@ -178,14 +119,14 @@ libisa_sve_la_LIBADD= -lwd -lwd_crypto
libisa_sve_la_LDFLAGS=$(UADK_VERSION)
libisa_sve_la_DEPENDENCIES= libwd.la libwd_crypto.la

libhisi_dae_la_LIBADD= -lwd -lwd_dae
libhisi_dae_la_LDFLAGS=$(UADK_VERSION)
libhisi_dae_la_DEPENDENCIES= libwd.la libwd_dae.la
libhisi_sec_la_LIBADD= -lwd -lwd_crypto
libhisi_sec_la_LDFLAGS=$(UADK_VERSION)
libhisi_sec_la_DEPENDENCIES= libwd.la libwd_crypto.la

endif # WD_STATIC_DRV

pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = lib/libwd_crypto.pc lib/libwd_comp.pc lib/libwd.pc
CLEANFILES += $(pkgconfig_DATA)

SUBDIRS=. test v1/test uadk_tool sample
#SUBDIRS=. test v1/test uadk_tool sample
SUBDIRS=. uadk_tool
8 changes: 8 additions & 0 deletions drv/hash_mb/hash_mb.c
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,11 @@ static struct wd_alg_driver hash_mb_driver[] = {
GEN_HASH_ALG_DRIVER("md5"),
};

#ifdef WD_STATIC_DRV
void hash_mb_probe(void)
#else
static void __attribute__((constructor)) hash_mb_probe(void)
#endif
{
unsigned long auxval = getauxval(AT_HWCAP);
size_t alg_num = ARRAY_SIZE(hash_mb_driver);
Expand All @@ -837,7 +841,11 @@ static void __attribute__((constructor)) hash_mb_probe(void)
}
}

#ifdef WD_STATIC_DRV
void hash_mb_remove(void)
#else
static void __attribute__((destructor)) hash_mb_remove(void)
#endif
{
unsigned long auxval = getauxval(AT_HWCAP);
size_t alg_num = ARRAY_SIZE(hash_mb_driver);
Expand Down
3 changes: 3 additions & 0 deletions drv/hash_mb/hash_mb.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ void md5_mb_asimd_x4(struct hash_job *job1, struct hash_job *job2,
void md5_mb_asimd_x1(struct hash_job *job, int len);
int md5_mb_sve_max_lanes(void);

void hash_mb_probe(void);
void hash_mb_remove(void);

#ifdef __cplusplus
}
#endif
Expand Down
2 changes: 2 additions & 0 deletions drv/hisi_comp.c
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,8 @@ static int hisi_zip_init(void *conf, void *priv)
memcpy(&zip_ctx->config, config, sizeof(struct wd_ctx_config_internal));
/* allocate qp for each context */
for (i = 0; i < config->ctx_num; i++) {
if (config->ctxs[i].ctx_type != UADK_CTX_HW)
continue;
h_ctx = config->ctxs[i].ctx;
qm_priv.sqe_size = sizeof(struct hisi_zip_sqe);
qm_priv.op_type = config->ctxs[i].op_type;
Expand Down
Loading

0 comments on commit 1d1314e

Please sign in to comment.