diff mbox series

[12/21] net/softnic: add pipeline build CLI command

Message ID 20220804165839.1074817-13-cristian.dumitrescu@intel.com (mailing list archive)
State Superseded
Delegated to: Andrew Rybchenko
Headers show
Series net/softnic: replace the legacy pipeline with SWX pipeline | expand

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Dumitrescu, Cristian Aug. 4, 2022, 4:58 p.m. UTC
Add CLI command for pipeline build.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Signed-off-by: Yogesh Jangra <yogesh.jangra@intel.com>
---
 drivers/net/softnic/rte_eth_softnic_cli.c | 66 +++++++++++++++++++++++
 1 file changed, 66 insertions(+)
diff mbox series

Patch

diff --git a/drivers/net/softnic/rte_eth_softnic_cli.c b/drivers/net/softnic/rte_eth_softnic_cli.c
index 9dc26d9f06..a814257229 100644
--- a/drivers/net/softnic/rte_eth_softnic_cli.c
+++ b/drivers/net/softnic/rte_eth_softnic_cli.c
@@ -367,6 +367,67 @@  cmd_softnic_pipeline_libbuild(struct pmd_internals *softnic __rte_unused,
 	free(buffer);
 }
 
+/**
+ * pipeline <pipeline_name> build lib <lib_file> io <iospec_file> numa <numa_node>
+ */
+static void
+cmd_softnic_pipeline_build(struct pmd_internals *softnic,
+	char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	struct pipeline *p = NULL;
+	char *pipeline_name, *lib_file_name, *iospec_file_name;
+	uint32_t numa_node = 0;
+
+	/* Parsing. */
+	if (n_tokens != 9) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	pipeline_name = tokens[1];
+
+	if (strcmp(tokens[2], "build")) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "build");
+		return;
+	}
+
+	if (strcmp(tokens[3], "lib")) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "lib");
+		return;
+	}
+
+	lib_file_name = tokens[4];
+
+	if (strcmp(tokens[5], "io")) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "io");
+		return;
+	}
+
+	iospec_file_name = tokens[6];
+
+	if (strcmp(tokens[7], "numa")) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "numa");
+		return;
+	}
+
+	if (parser_read_uint32(&numa_node, tokens[8])) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "numa_node");
+		return;
+	}
+
+	/* Pipeline create. */
+	p = softnic_pipeline_create(softnic,
+				    pipeline_name,
+				    lib_file_name,
+				    iospec_file_name,
+				    (int)numa_node);
+	if (!p)
+		snprintf(out, out_size, "Pipeline creation failed.\n");
+}
+
 /**
  * thread <thread_id> pipeline <pipeline_name> enable [ period <timer_period_ms> ]
  */
@@ -506,6 +567,11 @@  softnic_cli_process(char *in, char *out, size_t out_size, void *arg)
 			cmd_softnic_pipeline_libbuild(softnic, tokens, n_tokens, out, out_size);
 			return;
 		}
+
+		if ((n_tokens >= 3) && !strcmp(tokens[2], "build")) {
+			cmd_softnic_pipeline_build(softnic, tokens, n_tokens, out, out_size);
+			return;
+		}
 	}
 
 	if (strcmp(tokens[0], "thread") == 0) {