pipeline: add new SWX pipeline type
authorCristian Dumitrescu <cristian.dumitrescu@intel.com>
Thu, 1 Oct 2020 10:19:29 +0000 (11:19 +0100)
committerDavid Marchand <david.marchand@redhat.com>
Thu, 1 Oct 2020 16:43:06 +0000 (18:43 +0200)
Add new improved Software Switch (SWX) pipeline type that supports
dynamically-defined packet headers, meta-data, actions and pipelines.
Actions and pipelines are defined through instructions.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
doc/api/doxy-api-index.md
lib/librte_pipeline/meson.build
lib/librte_pipeline/rte_pipeline_version.map
lib/librte_pipeline/rte_swx_pipeline.c [new file with mode: 0644]
lib/librte_pipeline/rte_swx_pipeline.h [new file with mode: 0644]

index b855a8f..a522e47 100644 (file)
@@ -166,6 +166,8 @@ The public API headers are grouped by topics:
   * [pipeline]         (@ref rte_pipeline.h)
     [port_in_action]   (@ref rte_port_in_action.h)
     [table_action]     (@ref rte_table_action.h)
+  * SWX pipeline:
+    [pipeline]         (@ref rte_swx_pipeline.h)
   * [graph]            (@ref rte_graph.h):
     [graph_worker]     (@ref rte_graph_worker.h)
   * graph_nodes:
index d70b1a0..880c2b2 100644 (file)
@@ -1,6 +1,12 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-sources = files('rte_pipeline.c', 'rte_port_in_action.c', 'rte_table_action.c')
-headers = files('rte_pipeline.h', 'rte_port_in_action.h', 'rte_table_action.h')
+sources = files('rte_pipeline.c',
+       'rte_port_in_action.c',
+       'rte_table_action.c',
+       'rte_swx_pipeline.c',)
+headers = files('rte_pipeline.h',
+       'rte_port_in_action.h',
+       'rte_table_action.h',
+       'rte_swx_pipeline.h',)
 deps += ['port', 'table', 'meter', 'sched', 'cryptodev']
index 9ed80eb..2b0650a 100644 (file)
@@ -31,6 +31,7 @@ DPDK_21 {
 EXPERIMENTAL {
        global:
 
+       # added in 18.05
        rte_port_in_action_apply;
        rte_port_in_action_create;
        rte_port_in_action_free;
@@ -50,9 +51,16 @@ EXPERIMENTAL {
        rte_table_action_profile_create;
        rte_table_action_profile_free;
        rte_table_action_profile_freeze;
-       rte_table_action_table_params_get;
        rte_table_action_stats_read;
+       rte_table_action_table_params_get;
        rte_table_action_time_read;
        rte_table_action_ttl_read;
+
+       # added in 18.11
        rte_table_action_crypto_sym_session_get;
+
+       # added in 20.11
+       rte_swx_pipeline_build;
+       rte_swx_pipeline_config;
+       rte_swx_pipeline_free;
 };
diff --git a/lib/librte_pipeline/rte_swx_pipeline.c b/lib/librte_pipeline/rte_swx_pipeline.c
new file mode 100644 (file)
index 0000000..2319d45
--- /dev/null
@@ -0,0 +1,70 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Intel Corporation
+ */
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include <rte_common.h>
+
+#include "rte_swx_pipeline.h"
+
+#define CHECK(condition, err_code)                                             \
+do {                                                                           \
+       if (!(condition))                                                      \
+               return -(err_code);                                            \
+} while (0)
+
+#define CHECK_NAME(name, err_code)                                             \
+       CHECK((name) && (name)[0], err_code)
+
+/*
+ * Pipeline.
+ */
+struct rte_swx_pipeline {
+       int build_done;
+       int numa_node;
+};
+
+
+/*
+ * Pipeline.
+ */
+int
+rte_swx_pipeline_config(struct rte_swx_pipeline **p, int numa_node)
+{
+       struct rte_swx_pipeline *pipeline;
+
+       /* Check input parameters. */
+       CHECK(p, EINVAL);
+
+       /* Memory allocation. */
+       pipeline = calloc(1, sizeof(struct rte_swx_pipeline));
+       CHECK(pipeline, ENOMEM);
+
+       /* Initialization. */
+       pipeline->numa_node = numa_node;
+
+       *p = pipeline;
+       return 0;
+}
+
+void
+rte_swx_pipeline_free(struct rte_swx_pipeline *p)
+{
+       if (!p)
+               return;
+
+       free(p);
+}
+
+int
+rte_swx_pipeline_build(struct rte_swx_pipeline *p)
+{
+       CHECK(p, EINVAL);
+       CHECK(p->build_done == 0, EEXIST);
+
+       p->build_done = 1;
+       return 0;
+}
diff --git a/lib/librte_pipeline/rte_swx_pipeline.h b/lib/librte_pipeline/rte_swx_pipeline.h
new file mode 100644 (file)
index 0000000..ded26a4
--- /dev/null
@@ -0,0 +1,79 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Intel Corporation
+ */
+#ifndef __INCLUDE_RTE_SWX_PIPELINE_H__
+#define __INCLUDE_RTE_SWX_PIPELINE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file
+ * RTE SWX Pipeline
+ */
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include <rte_compat.h>
+
+/*
+ * Pipeline setup and operation
+ */
+
+/** Pipeline opaque data structure. */
+struct rte_swx_pipeline;
+
+/**
+ * Pipeline configure
+ *
+ * @param[out] p
+ *   Pipeline handle. Must point to valid memory. Contains valid pipeline handle
+ *   when the function returns successfully.
+ * @param[in] numa_node
+ *   Non-Uniform Memory Access (NUMA) node.
+ * @return
+ *   0 on success or the following error codes otherwise:
+ *   -EINVAL: Invalid argument;
+ *   -ENOMEM: Not enough space/cannot allocate memory.
+ */
+__rte_experimental
+int
+rte_swx_pipeline_config(struct rte_swx_pipeline **p,
+                       int numa_node);
+
+/**
+ * Pipeline build
+ *
+ * Once called, the pipeline build operation marks the end of pipeline
+ * configuration. At this point, all the internal data structures needed to run
+ * the pipeline are built.
+ *
+ * @param[in] p
+ *   Pipeline handle.
+ * @return
+ *   0 on success or the following error codes otherwise:
+ *   -EINVAL: Invalid argument;
+ *   -ENOMEM: Not enough space/cannot allocate memory;
+ *   -EEXIST: Pipeline was already built successfully.
+ */
+__rte_experimental
+int
+rte_swx_pipeline_build(struct rte_swx_pipeline *p);
+
+/**
+ * Pipeline free
+ *
+ * @param[in] p
+ *   Pipeline handle.
+ */
+__rte_experimental
+void
+rte_swx_pipeline_free(struct rte_swx_pipeline *p);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif