120 lines
2.7 KiB
Diff
120 lines
2.7 KiB
Diff
From d5c95ee9c68f6be540805a14d1743bf05c712574 Mon Sep 17 00:00:00 2001
|
|
From: Longfang Liu <liulongfang@huawei.com>
|
|
Date: Sat, 7 Jan 2023 16:09:00 +0800
|
|
Subject: [PATCH 08/28] uadk: added ability to query supported algorithms
|
|
|
|
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: Longfang Liu <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 e102fe2..21af7ff 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)
|
|
@@ -578,6 +579,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 4f75113..b6286b5 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;
|
|
+}
|
|
+
|
|
--
|
|
2.25.1
|
|
|