Lay the foundation to generate C code for the pipeline: C functions
for actions and custom instructions are generated, built as shared
object library and loaded into the pipeline.
Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
return 0;
}
+static int
+pipeline_compile(struct rte_swx_pipeline *p);
+
int
rte_swx_pipeline_build(struct rte_swx_pipeline *p)
{
goto error;
p->build_done = 1;
+
+ pipeline_compile(p);
+
return 0;
error:
return 0;
}
+
+/*
+ * Pipeline compilation.
+ */
+static int
+pipeline_codegen(struct rte_swx_pipeline *p)
+{
+ FILE *f = NULL;
+
+ if (!p)
+ return -EINVAL;
+
+ /* Create the .c file. */
+ f = fopen("/tmp/pipeline.c", "w");
+ if (!f)
+ return -EIO;
+
+ /* Include the .h file. */
+ fprintf(f, "#include \"rte_swx_pipeline_internal.h\"\n");
+
+ /* Close the .c file. */
+ fclose(f);
+
+ return 0;
+}
+
+static int
+pipeline_compile(struct rte_swx_pipeline *p)
+{
+ int status = 0;
+
+ /* Code generation. */
+ status = pipeline_codegen(p);
+ if (status)
+ return status;
+
+ return status;
+}