From fanghao11@huawei.com Fri Nov 25 03:01:19 2022 From: "fanghao (A)" To: acc@lists.linaro.org Subject: [Acc] Re: [PATCH v5 2/2] uadk: adjust header file include logic Date: Fri, 25 Nov 2022 10:42:21 +0800 Message-ID: In-Reply-To: <20221123100536.3210788-3-liulongfang@huawei.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6261030882587694275==" --===============6261030882587694275== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable =E5=9C=A8 2022/11/23 18:05, liulongfang =E5=86=99=E9=81=93: > Adjust the header file inclusion logic to ensure that the data > structures used internally are not exposed to the outside world. >=20 > Clarify the file relationship diagram of UADK, follow-up UADK > framework evolution, continue to ensure that the logic of the > basic file inclusion relationship is reasonable. >=20 > Also, remove unused header file wd_common.h >=20 > Signed-off-by: liulongfang > --- > Makefile.am | 2 +- > docs/uadk_file_relationship.svg | 40 ++++++++++++++++++++ > drv/hisi_qm_udrv.c | 1 + > include/hisi_qm_udrv.h | 3 +- > include/wd.h | 55 +++++++++++++++++++++++++-- > include/wd_aead.h | 1 - > include/wd_alg_common.h | 66 ++------------------------------- > include/wd_common.h | 23 ------------ > include/wd_dh.h | 4 -- > include/wd_rsa.h | 3 -- > include/wd_util.h | 16 ++++++++ > wd.c | 1 - > 12 files changed, 115 insertions(+), 100 deletions(-) > create mode 100644 docs/uadk_file_relationship.svg > delete mode 100644 include/wd_common.h >=20 > diff --git a/Makefile.am b/Makefile.am > index c4957bc..4ef5c2c 100644 > --- a/Makefile.am > +++ b/Makefile.am > @@ -33,7 +33,7 @@ AM_CFLAGS+=3D -DUADK_RELEASED_TIME=3D"\"Released ${MONTH}= ${DAY}, ${YEAR}\"" > pkginclude_HEADERS =3D 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_common.h include/wd_ecc.h include/wd_sched.h > + include/wd_ecc.h include/wd_sched.h > =20 > nobase_pkginclude_HEADERS =3D v1/wd.h v1/wd_cipher.h v1/wd_aead.h v1/uacc= e.h v1/wd_dh.h \ > v1/wd_digest.h v1/wd_rsa.h v1/wd_bmm.h > diff --git a/docs/uadk_file_relationship.svg b/docs/uadk_file_relationship.= svg > new file mode 100644 > index 0000000..4a958ef > --- /dev/null > +++ b/docs/uadk_file_relationship.svg > @@ -0,0 +1,40 @@ > + >=20 > + >=20 > +wd.h >=20 > +wd_util.h >=20 > +wd.c >=20 > +wd_alg_common.h >=20 > +wd_util.c= >=20 > +wd_sched.h >=20 > +wd_sched.c >=20 > +wd_aead.c >=20 > +wd_cipher.c<= /g> >=20 > +wd_digest.c<= /g> >=20 > +wd_comp.c >=20 > +wd_rsa.c= >=20 > +wd_dh.c<= g id=3D"shape19" transform=3D"translate(1600.65,1803.38)"> >=20 > +wd_ecc.c= >=20 > +wd_mempool.c<= /g> >=20 > +wd_aead.h >=20 > +wd_aead_drv.h >=20 > +wd_cipher.h<= /g> >=20 > +wd_cipher_drv.h >=20 > +wd_digest.h<= /g> >=20 > +wd_digest_drv.h >=20 > +wd_comp.h >=20 > +wd_comp_drv.h >=20 > +config.h= >=20 > +wd_rsa_drv.h= >=20 > +wd_dh.h<= g id=3D"shape41" transform=3D"matrix(0.99,0.11,-0.11,0.99,1331,1675)"> >=20 > +wd_dh_drv.h<= /g> >=20 > +wd_ecc.h= >=20 > +wd_ecc_drv.h= >=20 > +wd_ecc_curve.h= = >=20 > +hisi_qm_udrv.h >=20 > +hisi_qm_udrv.c >=20 > +uacce.h<= g id=3D"shape71" transform=3D"translate(1429.04,818.15)"> >=20 > +hisi_comp.c<= /g> >=20 > +hisi_sec.c >=20 > +hisi_hpre.c<= /g><= g id=3D"shape82" transform=3D"matrix(-0.99,0.14,-0.14,-0.99,914.2,1675)"> >=20 > +wd_rsa.h= <= g id=3D"shape94" transform=3D"translate(853.41,1315.37)"> > \ No newline at end of file > diff --git a/drv/hisi_qm_udrv.c b/drv/hisi_qm_udrv.c > index 6647840..a3b5dc1 100644 > --- a/drv/hisi_qm_udrv.c > +++ b/drv/hisi_qm_udrv.c > @@ -8,6 +8,7 @@ > #include > =20 > #include "hisi_qm_udrv.h" > +#include "wd_util.h" > =20 > #define QM_DBELL_CMD_SQ 0 > #define QM_DBELL_CMD_CQ 1 > diff --git a/include/hisi_qm_udrv.h b/include/hisi_qm_udrv.h > index dda320d..32f8183 100644 > --- a/include/hisi_qm_udrv.h > +++ b/include/hisi_qm_udrv.h > @@ -10,8 +10,7 @@ > #include > =20 > #include "config.h" > -#include "wd.h" > -#include "wd_alg_common.h" > +#include "wd_util.h" > =20 > #ifdef __cplusplus > extern "C" { > diff --git a/include/wd.h b/include/wd.h > index facd992..136d661 100644 > --- a/include/wd.h > +++ b/include/wd.h > @@ -30,6 +30,13 @@ extern "C" { > #define WD_CTX_CNT_NUM 1024 > #define WD_IPC_KEY 0x500011 > =20 > +/* Required compiler attributes */ > +#define likely(x) __builtin_expect(!!(x), 1) > +#define unlikely(x) __builtin_expect(!!(x), 0) > + > +#define handle_t uintptr_t > +typedef struct wd_dev_mask wd_dev_mask_t; > + > typedef void (*wd_log)(const char *format, ...); > =20 > #ifndef WD_NO_LOG > @@ -91,7 +98,12 @@ typedef void (*wd_log)(const char *format, ...); > #define WD_IS_ERR(h) ((uintptr_t)(h) > \ > (uintptr_t)(-1000)) > =20 > -enum wcrypto_type { > +enum wd_buff_type { > + WD_FLAT_BUF, > + WD_SGL_BUF, > +}; > + > +enum wd_alg_type { > WD_CIPHER, > WD_DIGEST, > WD_AEAD, > @@ -136,8 +148,11 @@ struct wd_dev_mask { > unsigned int magic; > }; > =20 > -#define handle_t uintptr_t > -typedef struct wd_dev_mask wd_dev_mask_t; > +struct wd_datalist { > + void *data; > + __u32 len; > + struct wd_datalist *next; > +}; > =20 > #if defined(__AARCH64_CMODEL_SMALL__) && __AARCH64_CMODEL_SMALL__ > #define dsb(opt) { asm volatile("dsb " #opt : : : "memory"); } > @@ -190,6 +205,40 @@ static inline long WD_PTR_ERR(const void *ptr) > return (long)ptr; > } > =20 > +enum wd_ctx_mode { > + CTX_MODE_SYNC =3D 0, > + CTX_MODE_ASYNC, > + CTX_MODE_MAX, > +}; > + > +/** > + * struct wd_ctx - Define one ctx and related type. > + * @ctx: The ctx itself. > + * @op_type: Define the operation type of this specific ctx. > + * e.g. 0: compression; 1: decompression. > + * @ctx_mode: Define this ctx is used for synchronization of asynchroniz= ation > + * 1: synchronization; 0: asynchronization; > + */ > +struct wd_ctx { > + handle_t ctx; > + __u8 op_type; > + __u8 ctx_mode; > +}; > + > +/** > + * struct wd_ctx_config - Define a ctx set and its related attributes, whi= ch > + * will be used in the scope of current process. > + * @ctx_num: The ctx number in below ctx array. > + * @ctxs: Point to a ctx array, length is above ctx_num. > + * @priv: The attributes of ctx defined by user, which is used by user > + * defined scheduler. > + */ > +struct wd_ctx_config { > + __u32 ctx_num; > + struct wd_ctx *ctxs; > + void *priv; > +}; > + > /** > * wd_request_ctx() - Request a communication context from a device. > * @dev: Indicate one device. > diff --git a/include/wd_aead.h b/include/wd_aead.h > index 47c496f..ba7d062 100644 > --- a/include/wd_aead.h > +++ b/include/wd_aead.h > @@ -8,7 +8,6 @@ > #define __WD_AEAD_H > =20 > #include > -#include "config.h" > #include "wd_alg_common.h" > #include "wd_cipher.h" > #include "wd_digest.h" > diff --git a/include/wd_alg_common.h b/include/wd_alg_common.h > index 96e908f..7a9b739 100644 > --- a/include/wd_alg_common.h > +++ b/include/wd_alg_common.h > @@ -10,17 +10,15 @@ > #include > #include > #include "wd.h" > -#include "wd_common.h" > =20 > #ifdef __cplusplus > extern "C" { > #endif > =20 > -/* Required compiler attributes */ > -#define likely(x) __builtin_expect(!!(x), 1) > -#define unlikely(x) __builtin_expect(!!(x), 0) > +#define BYTE_BITS 8 > +#define BYTE_BITS_SHIFT 3 > +#define GET_NEGATIVE(val) (0 - (val)) > =20 > -#define BYTE_BITS_SHIFT 3 > #define BITS_TO_BYTES(bits) (((bits) + 7) >> 3) > #define BYTES_TO_BITS(bytes) ((bytes) << 3) > =20 > @@ -29,40 +27,6 @@ extern "C" { > #define CTX_TYPE_INVALID 9999 > #define POLL_TIME 1000 > =20 > -enum wd_ctx_mode { > - CTX_MODE_SYNC =3D 0, > - CTX_MODE_ASYNC, > - CTX_MODE_MAX, > -}; > - > -/** > - * struct wd_ctx - Define one ctx and related type. > - * @ctx: The ctx itself. > - * @op_type: Define the operation type of this specific ctx. > - * e.g. 0: compression; 1: decompression. > - * @ctx_mode: Define this ctx is used for synchronization of asynchroniz= ation > - * 1: synchronization; 0: asynchronization; > - */ > -struct wd_ctx { > - handle_t ctx; > - __u8 op_type; > - __u8 ctx_mode; > -}; > - > -/** > - * struct wd_ctx_config - Define a ctx set and its related attributes, whi= ch > - * will be used in the scope of current process. > - * @ctx_num: The ctx number in below ctx array. > - * @ctxs: Point to a ctx array, length is above ctx_num. > - * @priv: The attributes of ctx defined by user, which is used by user > - * defined scheduler. > - */ > -struct wd_ctx_config { > - __u32 ctx_num; > - struct wd_ctx *ctxs; > - void *priv; > -}; > - > /** > * struct wd_ctx_nums - Define the ctx sets numbers. > * @sync_ctx_num: The ctx numbers which are used for sync mode for each > @@ -90,27 +54,11 @@ struct wd_ctx_params { > struct bitmask *bmp; > }; > =20 > -struct wd_ctx_internal { > - handle_t ctx; > - __u8 op_type; > - __u8 ctx_mode; > - pthread_spinlock_t lock; > -}; > - > -struct wd_ctx_config_internal { > - __u32 ctx_num; > - struct wd_ctx_internal *ctxs; > - void *priv; > - int pid; > - bool epoll_en; > - unsigned long *msg_cnt; > -}; > - > /** > * struct wd_comp_sched - Define a scheduler. > * @name: Name of this scheduler. > * @sched_policy: Method for scheduler to perform scheduling > - * @sched_init: inited the scheduler input parameters. > + * @sched_init: inited the scheduler input parameters. > * @pick_next_ctx: Pick the proper ctx which a request will be sent to. > * config points to the ctx config; sched_ctx points to > * scheduler context; req points to the request. Return > @@ -131,12 +79,6 @@ struct wd_sched { > handle_t h_sched_ctx; > }; > =20 > -struct wd_datalist { > - void *data; > - __u32 len; > - struct wd_datalist *next; > -}; > - most of these define better remain in here, not move to wd.h. > #ifdef __cplusplus > } > #endif > diff --git a/include/wd_common.h b/include/wd_common.h > deleted file mode 100644 > index 91dd066..0000000 > --- a/include/wd_common.h > +++ /dev/null > @@ -1,23 +0,0 @@ > -// SPDX-License-Identifier: Apache-2.0 > -/* > - * Copyright 2020-2021 Huawei Technologies Co.,Ltd. All rights reserved. > - * Copyright 2020-2021 Linaro ltd. > - */ > - > -#ifndef __WD_COMMON_H > -#define __WD_COMMON_H > - > -#ifdef __cplusplus > -extern "C" { > -#endif > - > -enum wd_buff_type { > - WD_FLAT_BUF, > - WD_SGL_BUF, > -}; > - > -#ifdef __cplusplus > -} > -#endif > - > -#endif /* __WD_COMMON_H */ > diff --git a/include/wd_dh.h b/include/wd_dh.h > index 1c72228..3912680 100644 > --- a/include/wd_dh.h > +++ b/include/wd_dh.h > @@ -15,10 +15,6 @@ > extern "C" { > #endif > =20 > -#define BYTE_BITS 8 > -#define BYTE_BITS_SHIFT 3 > -#define GET_NEGATIVE(val) (0 - (val)) > - > typedef void (*wd_dh_cb_t)(void *cb_param); > =20 > enum wd_dh_op_type { > diff --git a/include/wd_rsa.h b/include/wd_rsa.h > index 70e3b05..e16171f 100644 > --- a/include/wd_rsa.h > +++ b/include/wd_rsa.h > @@ -15,13 +15,10 @@ > extern "C" { > #endif > =20 > -#define BYTE_BITS 8 > -#define BYTE_BITS_SHIFT 3 > #define CRT_PARAMS_SZ(key_size) ((5 * (key_size)) >> 1) > #define CRT_GEN_PARAMS_SZ(key_size) ((7 * (key_size)) >> 1) > #define GEN_PARAMS_SZ(key_size) ((key_size) << 1) > #define CRT_PARAM_SZ(key_size) ((key_size) >> 1) > -#define GET_NEGATIVE(val) (0 - (val)) > =20 > typedef void (*wd_rsa_cb_t)(void *cb_param); > =20 > diff --git a/include/wd_util.h b/include/wd_util.h > index d4b2814..9b581d4 100644 > --- a/include/wd_util.h > +++ b/include/wd_util.h > @@ -19,6 +19,22 @@ > extern "C" { > #endif > =20 > +struct wd_ctx_internal { > + handle_t ctx; > + __u8 op_type; > + __u8 ctx_mode; > + pthread_spinlock_t lock; > +}; > + > +struct wd_ctx_config_internal { > + __u32 ctx_num; > + struct wd_ctx_internal *ctxs; > + void *priv; > + int pid; > + bool epoll_en; > + unsigned long *msg_cnt; > +}; > + > #define FOREACH_NUMA(i, config, config_numa) \ > for ((i) =3D 0, (config_numa) =3D (config)->config_per_numa; \ > (i) < (config)->numa_num; (config_numa)++, (i)++) > diff --git a/wd.c b/wd.c > index 9eb69d2..629c0df 100644 > --- a/wd.c > +++ b/wd.c > @@ -18,7 +18,6 @@ > #include > #include > =20 > -#include "wd_alg_common.h" > #include "wd.h" > =20 > #define SYS_CLASS_DIR "/sys/class/uacce" --===============6261030882587694275==--