From: Weili Qian <qianweili@huawei.com> Supports obtaining the device's bandwidth utilization. For usage details, refer to "uadk_tool dfx --help". Signed-off-by: Weili Qian <qianweili@huawei.com> --- uadk_tool/benchmark/zip_wd_benchmark.c | 6 ++ uadk_tool/dfx/uadk_dfx.c | 84 ++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) diff --git a/uadk_tool/benchmark/zip_wd_benchmark.c b/uadk_tool/benchmark/zip_wd_benchmark.c index 8388fd0..8b66da1 100644 --- a/uadk_tool/benchmark/zip_wd_benchmark.c +++ b/uadk_tool/benchmark/zip_wd_benchmark.c @@ -22,6 +22,8 @@ #define CHUNK_SIZE (128 * 1024) #define MAX_UNRECV_PACKET_NUM 2 #define MAX_POOL_CREATE_FAIL_TIME 10 +#define MIN_CTX_BUF_SIZE 65536 +#define STREAM_MODE_TYPE 2 #define __ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask)) #define ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a)-1) @@ -323,6 +325,10 @@ static int init_zip_wd_queue(struct acc_option *options) else outsize = g_pktlen * DECOMP_LEN_RATE; + /* Stream mode block size should bigger than 64K */ + if (options->optype >= STREAM_MODE_TYPE && outsize < MIN_CTX_BUF_SIZE) + outsize = MIN_CTX_BUF_SIZE; + g_thread_queue.bd_res = malloc(g_thread_num * sizeof(struct thread_bd_res)); if (!g_thread_queue.bd_res) { ZIP_TST_PRT("malloc thread res memory fail!\n"); diff --git a/uadk_tool/dfx/uadk_dfx.c b/uadk_tool/dfx/uadk_dfx.c index a344082..e1b3adf 100644 --- a/uadk_tool/dfx/uadk_dfx.c +++ b/uadk_tool/dfx/uadk_dfx.c @@ -17,6 +17,12 @@ #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #define PRIVILEGE_FLAG 0666 +enum dfx_usage_type { + DISPLAY_DEVICE = 0, + DISPLAY_ALG_NAME, + DISPLAY_OP_TYPE +}; + struct uadk_env_var { const char *module; const char *alg; @@ -37,6 +43,7 @@ enum dfx_op_type { DISPLAY_DIR, DISPLAY_ENV, DISPLAY_COUNT, + DISPLAY_USAGE, DISPLAY_HELP, }; @@ -177,6 +184,77 @@ static void uadk_exe_path(void) printf("exe path: %s\n", dir); } +static void uadk_dev_usage_read(int argc, char *argv[]) +{ + char device[MAX_DEV_NAME_LEN] = "hisi_sec2-0"; + char alg_name[MAX_ATTR_STR_SIZE] = "cipher"; + struct uacce_dev_list *tmp = NULL; + struct uacce_dev_list *list; + struct uacce_dev *dev = NULL; + int option_index = 0; + int op_type = 0, ret; + char *dev_name; + int opt; + + static struct option long_options[] = { + {"device", required_argument, 0, DISPLAY_DEVICE}, + {"alg_name", required_argument, 0, DISPLAY_ALG_NAME}, + {"op_type", required_argument, 0, DISPLAY_OP_TYPE}, + {0, 0, 0, 0} + }; + + while (1) { + opt = getopt_long(argc, argv, "", long_options, &option_index); + if (opt == -1) + break; + + switch (opt) { + case DISPLAY_DEVICE: + strcpy(device, optarg); + break; + case DISPLAY_ALG_NAME: + strcpy(alg_name, optarg); + break; + case DISPLAY_OP_TYPE: + op_type = strtol(optarg, NULL, 0); + break; + default: + printf("bad input parameter, exit!\n"); + return; + } + } + + list = wd_get_accel_list(alg_name); + if (!list) { + printf("no device support alg_name %s, exit!\n", alg_name); + return; + } + + for (tmp = list; tmp != NULL; tmp = tmp->next) { + dev_name = strrchr(tmp->dev->dev_root, '/') + 1; + if (!strcmp(dev_name, device)) { + dev = tmp->dev; + break; + } + } + + if (!dev) { + printf("no device name is %s, exit!\n", device); + goto free_list; + } + + ret = wd_get_dev_usage(dev, alg_name, op_type); + if (ret < 0) { + printf("failed to get usage ret %d!\n", ret); + goto free_list; + } + + printf("%s %s op type %d usage is %d\n", device, alg_name, op_type, ret); + +free_list: + wd_free_list_accels(list); +} + void print_dfx_help(void) { printf("NAME\n"); @@ -186,11 +264,13 @@ void print_dfx_help(void) printf(" uadk_tool dfx [--dir] = Show library dir\n"); printf(" uadk_tool dfx [--env] = Show environment variables\n"); printf(" uadk_tool dfx [--count] = Show the ctx message count\n"); + printf(" uadk_tool dfx [--usage] = Show the device bandwidth utilization\n"); printf(" uadk_tool dfx [--help] = usage\n"); printf("Example\n"); printf(" uadk_tool dfx --version\n"); printf(" uadk_tool dfx --env sec\n"); printf(" uadk_tool dfx --count\n"); + printf(" uadk_tool dfx --usage --device hisi_sec2-0 --alg cipher --op_type 0\n"); } void dfx_cmd_parse(int argc, char *argv[]) @@ -205,6 +285,7 @@ void dfx_cmd_parse(int argc, char *argv[]) {"dir", no_argument, 0, DISPLAY_DIR}, {"env", required_argument, 0, DISPLAY_ENV}, {"count", no_argument, 0, DISPLAY_COUNT}, + {"usage", no_argument, 0, DISPLAY_USAGE}, {"help", no_argument, 0, DISPLAY_HELP}, {0, 0, 0, 0} }; @@ -234,6 +315,9 @@ void dfx_cmd_parse(int argc, char *argv[]) case DISPLAY_COUNT: uadk_shared_read(); break; + case DISPLAY_USAGE: + uadk_dev_usage_read(argc, argv); + return; case DISPLAY_HELP: print_dfx_help(); break; -- 2.33.0