Add CLI command for the configuration of crypto devices.

Signed-off-by: Cristian Dumitrescu <cristian.dumitre...@intel.com>
Signed-off-by: Kamalakannan R <kamalakanna...@intel.com>
---
 examples/pipeline/cli.c | 63 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c
index 37fc6f9551..47c1adf772 100644
--- a/examples/pipeline/cli.c
+++ b/examples/pipeline/cli.c
@@ -521,6 +521,58 @@ cmd_ring(char **tokens,
        }
 }
 
+static const char cmd_cryptodev_help[] =
+"cryptodev <cryptodev_name> queues <n_queue_pairs> qsize <queue_size>\n";
+
+static void
+cmd_cryptodev(char **tokens,
+             uint32_t n_tokens,
+             char *out,
+             size_t out_size,
+             void *obj __rte_unused)
+{
+       struct cryptodev_params params;
+       char *cryptodev_name;
+       int status;
+
+       if (n_tokens != 6) {
+               snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+               return;
+       }
+
+       if (strcmp(tokens[0], "cryptodev")) {
+               snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cryptodev");
+               return;
+       }
+
+       cryptodev_name = tokens[1];
+
+       if (strcmp(tokens[2], "queues")) {
+               snprintf(out, out_size, MSG_ARG_NOT_FOUND, "queues");
+               return;
+       }
+
+       if (parser_read_uint32(&params.n_queue_pairs, tokens[3])) {
+               snprintf(out, out_size, MSG_ARG_INVALID, "n_queue_pairs");
+               return;
+       }
+
+       if (strcmp(tokens[4], "qsize")) {
+               snprintf(out, out_size, MSG_ARG_NOT_FOUND, "qsize");
+               return;
+       }
+
+
+       if (parser_read_uint32(&params.queue_size, tokens[5])) {
+               snprintf(out, out_size, MSG_ARG_INVALID, "queue_size");
+               return;
+       }
+
+       status = cryptodev_config(cryptodev_name, &params);
+       if (status)
+               snprintf(out, out_size, "Crypto device configuration failed 
(%d).\n", status);
+}
+
 static const char cmd_pipeline_codegen_help[] =
 "pipeline codegen <spec_file> <code_file>\n";
 
@@ -2990,6 +3042,7 @@ cmd_help(char **tokens,
                        "\tethdev\n"
                        "\tethdev show\n"
                        "\tring\n"
+                       "\tcryptodev\n"
                        "\tpipeline codegen\n"
                        "\tpipeline libbuild\n"
                        "\tpipeline build\n"
@@ -3041,6 +3094,11 @@ cmd_help(char **tokens,
                return;
        }
 
+       if (!strcmp(tokens[0], "cryptodev")) {
+               snprintf(out, out_size, "\n%s\n", cmd_cryptodev_help);
+               return;
+       }
+
        if ((strcmp(tokens[0], "pipeline") == 0) &&
                (n_tokens == 2) && (strcmp(tokens[1], "codegen") == 0)) {
                snprintf(out, out_size, "\n%s\n", cmd_pipeline_codegen_help);
@@ -3296,6 +3354,11 @@ cli_process(char *in, char *out, size_t out_size, void 
*obj)
                return;
        }
 
+       if (!strcmp(tokens[0], "cryptodev")) {
+               cmd_cryptodev(tokens, n_tokens, out, out_size, obj);
+               return;
+       }
+
        if (strcmp(tokens[0], "pipeline") == 0) {
                if ((n_tokens >= 3) &&
                        (strcmp(tokens[1], "codegen") == 0)) {
-- 
2.34.1

Reply via email to