@@ -32,6 +32,12 @@ struct crypto_bm_alg_ops {
int (*create_req)(struct crypto_bm_base *base, u32 idx);
void (*release_req)(struct crypto_bm_base *base, u32 idx);
int (*perf)(struct crypto_bm_thread_data *data);
+ void (*help)(void);
+};
+
+struct crypto_bm_mp_info {
+ const char *mp;
+ const char *help_info;
};
struct {
@@ -51,6 +57,9 @@ struct {
#define threadnum_desc "Testing thread number, one 'crypto_tfm' per thread. 0/1 (default 1 thread), 2(2 threads) ..."
#define time_desc "Testing time, the unit is second, 0/1 (default 1 s), 2(2 s) ..."
#define run_desc "Start/stop all the tests based on the configuration, 0(default, not run, stop), or run"
+#define help_desc "Some help information. Echo a module parameter can get the info " \
+ "of module parameter. Cat 'help' directly can get the help "\
+ "information provided by 'algtype'."
static atomic_t benchmark_status;
@@ -75,11 +84,47 @@ static struct crypto_bm_alg_ops benchmark_ops[] = {
.create_req = crypto_bm_create_req_comp,
.release_req = crypto_bm_release_req_comp,
.perf = crypto_bm_perf_comp,
+ .help = crypto_bm_help_comp,
}, {
/* sentinel */
}
};
+static struct crypto_bm_mp_info modules_help[] = {
+ {
+ .mp = "algorithm",
+ .help_info = "Please input a crypto supported algorithm name.\n"
+ "The algorithm name can be found on /proc/crypto.",
+ }, {
+ .mp = "algtype",
+ .help_info = "Please input a valid value to choose algorithm class.\n"
+ "0: CRYPTO_BM_COMP",
+ }, {
+ .mp = "inputsize",
+ .help_info = "Please input a valid value as testing input size.",
+ }, {
+ .mp = "loop",
+ .help_info = "Please input the send loop times.",
+ }, {
+ .mp = "numamask",
+ .help_info = "Please input a bitmap as testing numa nodes.",
+ }, {
+ .mp = "optype",
+ .help_info = "Please input a valid value for testing operation.\n"
+ "Can get the algorithm type support optype by cat 'help'."
+ }, {
+ .mp = "reqnum",
+ .help_info = "Please input a valid value for per thread request number.",
+ }, {
+ .mp = "threadnum",
+ .help_info = "Please input a valid value for creating threads.\n"
+ "One thread will create a crypto_tfm.",
+ }, {
+ .mp = "time",
+ .help_info = "Please input a valid value for testing time.",
+ }
+};
+
static int crypto_bm_algorithm_param_set(const char *val, const struct kernel_param *kp)
{
char *s = strstrip((char *)val);
@@ -103,6 +148,40 @@ static const struct kernel_param_ops alg_ops = {
module_param_cb(algorithm, &alg_ops, &benchmark_attrs.algorithm, 0644);
MODULE_PARM_DESC(algorithm, algorithm_desc);
+static int crypto_bm_help_param_set(const char *val, const struct kernel_param *kp)
+{
+ int size = ARRAY_SIZE(modules_help);
+ char *s = strstrip((char *)val);
+ int i;
+
+ for (i = 0; i < size; i++) {
+ if (!strcmp(s, modules_help[i].mp))
+ pr_err("%s\n", modules_help[i].help_info);
+ }
+
+ return 0;
+}
+
+static int crypto_bm_help_param_get(char *val, const struct kernel_param *kp)
+{
+ u32 idx = benchmark_attrs.algtype;
+
+ if (idx >= CRYPTO_BM_ALG_MAX)
+ return -EINVAL;
+
+ benchmark_ops[idx].help();
+
+ return 0;
+}
+
+static const struct kernel_param_ops help_ops = {
+ .set = crypto_bm_help_param_set,
+ .get = crypto_bm_help_param_get,
+};
+
+module_param_cb(help, &help_ops, NULL, 0644);
+MODULE_PARM_DESC(help, help_desc);
+
static int crypto_bm_numamask_param_set(const char *val, const struct kernel_param *kp)
{
if (atomic_read(&benchmark_status))
@@ -423,3 +423,13 @@ int crypto_bm_perf_comp(struct crypto_bm_thread_data *data)
return ret;
}
+
+void crypto_bm_help_comp(void)
+{
+ pr_err("Welcome to use the crypto benchmark to test compress algorithm!\n"
+ "There ars some different moduel parameters requirement:\n"
+ "optype: 0 for compression, 1 for decompression\n"
+ "inputsize: for compression, the inputsize is src_len,\n"
+ " for decompression, the inputsize is dst_len, and the src_len will depend on the data compression ratio.\n"
+ );
+}
@@ -14,5 +14,6 @@ void crypto_bm_release_tfm_comp(struct crypto_bm_base *base, u32 idx);
int crypto_bm_create_req_comp(struct crypto_bm_base *base, u32 idx);
void crypto_bm_release_req_comp(struct crypto_bm_base *base, u32 idx);
int crypto_bm_perf_comp(struct crypto_bm_thread_data *data);
+void crypto_bm_help_comp(void);
#endif
Add a new module parameters 'help' to make users understand the benchmark module parameters. And due to the algorithms have different notes, add a new callback 'help' to show the differences. Signed-off-by: Yang Shen <shenyang39@huawei.com> --- crypto/benchmark/benchmark.c | 79 ++++++++++++++++++++++++++++++++++++ crypto/benchmark/bm_comp.c | 10 +++++ crypto/benchmark/bm_comp.h | 1 + 3 files changed, 90 insertions(+)