在 2022/11/24 15:43, liulongfang 写道:
After the driver dynamic loading function is added, the corresponding function of querying all algorithms supported on the current UADK is added.
Signed-off-by: liulongfang liulongfang@huawei.com
include/wd.h | 12 +++++++++++ wd.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 67 insertions(+), 1 deletion(-)
diff --git a/include/wd.h b/include/wd.h index 136d661..f2b7c06 100644 --- a/include/wd.h +++ b/include/wd.h @@ -29,6 +29,7 @@ extern "C" { #define LINUX_PRTDIR_SIZE 2 #define WD_CTX_CNT_NUM 1024 #define WD_IPC_KEY 0x500011 +#define CRYPTO_MAX_ALG_NAME 128 /* Required compiler attributes */ #define likely(x) __builtin_expect(!!(x), 1) @@ -618,6 +619,17 @@ bool wd_need_debug(void); */ bool wd_need_info(void); +struct wd_capability {
- char alg_name[CRYPTO_MAX_ALG_NAME];
- char drv_name[CRYPTO_MAX_ALG_NAME];
- int priority;
- struct wd_capability *next;
+};
+struct wd_capability *wd_get_alg_cap(void); +void wd_release_alg_cap(struct wd_capability *head);
- #ifdef __cplusplus } #endif
diff --git a/wd.c b/wd.c index 629c0df..c882c1f 100644 --- a/wd.c +++ b/wd.c @@ -19,7 +19,7 @@ #include <sched.h> #include "wd.h"
+#include "wd_alg.h" #define SYS_CLASS_DIR "/sys/class/uacce" enum UADK_LOG_LEVEL { @@ -882,3 +882,57 @@ char *wd_ctx_get_dev_name(handle_t h_ctx) return ctx->dev_name; }
+void wd_release_alg_cap(struct wd_capability *head) +{
- struct wd_capability *cap_pnext = head;
- struct wd_capability *cap_node = NULL;
- while (cap_pnext) {
cap_node = cap_pnext;
cap_pnext = cap_pnext->next;
free(cap_node);
- }
- if (head)
free(head);
+}
+struct wd_capability *wd_get_alg_cap(void) +{
- struct wd_alg_list *head = wd_get_alg_head();
- struct wd_alg_list *pnext = head->next;
- struct wd_capability *cap_head = NULL;
- struct wd_capability *cap_node = NULL;
- struct wd_capability *cap_pnext = NULL;
- int i = 0;
- while (pnext) {
cap_node = calloc(1, sizeof(struct wd_capability));
if (!cap_head) {
WD_ERR("fail to alloc wd capability head\n");
goto alloc_err;
}
strcpy(cap_node->alg_name, pnext->alg_name);
strcpy(cap_node->drv_name, pnext->drv_name);
cap_node->priority = pnext->priority;
cap_node->next = NULL;
cap_pnext->next = cap_node;
cap_pnext = cap_node;
pnext = pnext->next;
if (i == 0) {
cap_head = cap_node;
cap_pnext = cap_head;
}
i++;
- }
- return cap_head;
+alloc_err:
- wd_release_alg_cap(cap_head);
- return NULL;
+}
I just guess these functions just for dfx, and called by uadk_tool. Suggest add complete dfx series later.
These functions need move to wd alg.