Adjust the header file inclusion logic to ensure that the data structures used internally are not exposed to the outside world.
Also, remove unused header file wd_common.h
Signed-off-by: liulongfang liulongfang@huawei.com --- Makefile.am | 2 +- drv/hisi_qm_udrv.c | 1 + include/hisi_qm_udrv.h | 3 +-- include/wd.h | 17 +++++++++++++---- include/wd_aead.h | 1 - include/wd_alg_common.h | 10 ++++------ include/wd_common.h | 23 ----------------------- include/wd_dh.h | 4 ---- include/wd_rsa.h | 3 --- wd.c | 1 - 10 files changed, 20 insertions(+), 45 deletions(-) delete mode 100644 include/wd_common.h
diff --git a/Makefile.am b/Makefile.am index c4957bc..4ef5c2c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -33,7 +33,7 @@ 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_common.h include/wd_ecc.h include/wd_sched.h + include/wd_ecc.h include/wd_sched.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 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 <sys/mman.h>
#include "hisi_qm_udrv.h" +#include "wd_util.h"
#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 <linux/types.h>
#include "config.h" -#include "wd.h" -#include "wd_alg_common.h" +#include "wd_util.h"
#ifdef __cplusplus extern "C" { diff --git a/include/wd.h b/include/wd.h index facd992..e102fe2 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
+/* 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, ...);
#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))
-enum wcrypto_type { +enum wd_buff_type { + WD_FLAT_BUF, + WD_SGL_BUF, +}; + +enum wd_alg_type { WD_CIPHER, WD_DIGEST, WD_AEAD, @@ -136,9 +148,6 @@ struct wd_dev_mask { unsigned int magic; };
-#define handle_t uintptr_t -typedef struct wd_dev_mask wd_dev_mask_t; - #if defined(__AARCH64_CMODEL_SMALL__) && __AARCH64_CMODEL_SMALL__ #define dsb(opt) { asm volatile("dsb " #opt : : : "memory"); } #define rmb() dsb(ld) /* read fence */ 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
#include <dlfcn.h> -#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..56539cc 100644 --- a/include/wd_alg_common.h +++ b/include/wd_alg_common.h @@ -10,17 +10,15 @@ #include <pthread.h> #include <stdbool.h> #include "wd.h" -#include "wd_common.h"
#ifdef __cplusplus extern "C" { #endif
-/* 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))
-#define BYTE_BITS_SHIFT 3 #define BITS_TO_BYTES(bits) (((bits) + 7) >> 3) #define BYTES_TO_BITS(bytes) ((bytes) << 3)
@@ -110,7 +108,7 @@ struct wd_ctx_config_internal { * 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 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
-#define BYTE_BITS 8 -#define BYTE_BITS_SHIFT 3 -#define GET_NEGATIVE(val) (0 - (val)) - typedef void (*wd_dh_cb_t)(void *cb_param);
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
-#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))
typedef void (*wd_rsa_cb_t)(void *cb_param);
diff --git a/wd.c b/wd.c index 9eb69d2..629c0df 100644 --- a/wd.c +++ b/wd.c @@ -18,7 +18,6 @@ #include <numa.h> #include <sched.h>
-#include "wd_alg_common.h" #include "wd.h"
#define SYS_CLASS_DIR "/sys/class/uacce"