summaryrefslogtreecommitdiff
path: root/examples/ip_pipeline/cli.c
diff options
context:
space:
mode:
authorJasvinder Singh <jasvinder.singh@intel.com>2018-03-29 19:31:51 +0100
committerCristian Dumitrescu <cristian.dumitrescu@intel.com>2018-04-05 19:00:17 +0200
commit32e5d9b154cbeefa5b444f8360dd33fecf523680 (patch)
treece48c495bb4eb1f3ddab580b23f692e7c01e859a /examples/ip_pipeline/cli.c
parenta8bd581de3975b5d7ad95afd227e5d889765680e (diff)
downloaddpdk-32e5d9b154cbeefa5b444f8360dd33fecf523680.zip
dpdk-32e5d9b154cbeefa5b444f8360dd33fecf523680.tar.gz
dpdk-32e5d9b154cbeefa5b444f8360dd33fecf523680.tar.xz
examples/ip_pipeline: add enable and disable commands
Add commands to enable and disable the pipeline on the thread. Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com> Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com> Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
Diffstat (limited to 'examples/ip_pipeline/cli.c')
-rw-r--r--examples/ip_pipeline/cli.c102
1 files changed, 102 insertions, 0 deletions
diff --git a/examples/ip_pipeline/cli.c b/examples/ip_pipeline/cli.c
index e96f3a6..2032563 100644
--- a/examples/ip_pipeline/cli.c
+++ b/examples/ip_pipeline/cli.c
@@ -17,6 +17,7 @@
#include "pipeline.h"
#include "swq.h"
#include "tap.h"
+#include "thread.h"
#include "tmgr.h"
#ifndef CMD_MAX_TOKENS
@@ -1936,6 +1937,91 @@ cmd_pipeline_port_in_table(char **tokens,
}
}
+/**
+ * thread <thread_id> pipeline <pipeline_name> enable
+ */
+static void
+cmd_thread_pipeline_enable(char **tokens,
+ uint32_t n_tokens,
+ char *out,
+ size_t out_size)
+{
+ char *pipeline_name;
+ uint32_t thread_id;
+ int status;
+
+ if (n_tokens != 5) {
+ snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+ return;
+ }
+
+ if (parser_read_uint32(&thread_id, tokens[1]) != 0) {
+ snprintf(out, out_size, MSG_ARG_INVALID, "thread_id");
+ return;
+ }
+
+ if (strcmp(tokens[2], "pipeline") != 0) {
+ snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pipeline");
+ return;
+ }
+
+ pipeline_name = tokens[3];
+
+ if (strcmp(tokens[4], "enable") != 0) {
+ snprintf(out, out_size, MSG_ARG_NOT_FOUND, "enable");
+ return;
+ }
+
+ status = thread_pipeline_enable(thread_id, pipeline_name);
+ if (status) {
+ snprintf(out, out_size, MSG_CMD_FAIL, "thread pipeline enable");
+ return;
+ }
+}
+
+/**
+ * thread <thread_id> pipeline <pipeline_name> disable
+ */
+static void
+cmd_thread_pipeline_disable(char **tokens,
+ uint32_t n_tokens,
+ char *out,
+ size_t out_size)
+{
+ char *pipeline_name;
+ uint32_t thread_id;
+ int status;
+
+ if (n_tokens != 5) {
+ snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+ return;
+ }
+
+ if (parser_read_uint32(&thread_id, tokens[1]) != 0) {
+ snprintf(out, out_size, MSG_ARG_INVALID, "thread_id");
+ return;
+ }
+
+ if (strcmp(tokens[2], "pipeline") != 0) {
+ snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pipeline");
+ return;
+ }
+
+ pipeline_name = tokens[3];
+
+ if (strcmp(tokens[4], "disable") != 0) {
+ snprintf(out, out_size, MSG_ARG_NOT_FOUND, "disable");
+ return;
+ }
+
+ status = thread_pipeline_disable(thread_id, pipeline_name);
+ if (status) {
+ snprintf(out, out_size, MSG_CMD_FAIL,
+ "thread pipeline disable");
+ return;
+ }
+}
+
void
cli_process(char *in, char *out, size_t out_size)
{
@@ -2064,6 +2150,22 @@ cli_process(char *in, char *out, size_t out_size)
}
}
+ if (strcmp(tokens[0], "thread") == 0) {
+ if ((n_tokens >= 5) &&
+ (strcmp(tokens[4], "enable") == 0)) {
+ cmd_thread_pipeline_enable(tokens, n_tokens,
+ out, out_size);
+ return;
+ }
+
+ if ((n_tokens >= 5) &&
+ (strcmp(tokens[4], "disable") == 0)) {
+ cmd_thread_pipeline_disable(tokens, n_tokens,
+ out, out_size);
+ return;
+ }
+ }
+
snprintf(out, out_size, MSG_CMD_UNKNOWN, tokens[0]);
}