[ovs-dev] [PATCH ovn v5 14/15] pipeline: Add macros to map logical registers to MFF_REG6 and MFF_REG7.
Ben Pfaff
blp at nicira.com
Thu Apr 30 06:49:08 UTC 2015
This will allow upcoming code to refer to the logical inport and outport
by symbolic names.
Signed-off-by: Ben Pfaff <blp at nicira.com>
---
ovn/controller/pipeline.c | 29 +++++++++++++----------------
ovn/controller/pipeline.h | 4 ++++
2 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/ovn/controller/pipeline.c b/ovn/controller/pipeline.c
index 5013060..f0d5dee 100644
--- a/ovn/controller/pipeline.c
+++ b/ovn/controller/pipeline.c
@@ -41,24 +41,21 @@ symtab_init(void)
/* Reserve a pair of registers for the logical inport and outport. A full
* 32-bit register each is bigger than we need, but the expression code
* doesn't yet support string fields that occupy less than a full OXM. */
- expr_symtab_add_string(&symtab, "inport", MFF_REG6, NULL);
- expr_symtab_add_string(&symtab, "outport", MFF_REG7, NULL);
-
- /* Registers. We omit the registers that would otherwise overlap 'inport'
- * and 'outport'. */
- expr_symtab_add_field(&symtab, "xreg0", MFF_XREG0, NULL, false);
- expr_symtab_add_field(&symtab, "xreg1", MFF_XREG1, NULL, false);
- expr_symtab_add_field(&symtab, "xreg2", MFF_XREG2, NULL, false);
-
- expr_symtab_add_subfield(&symtab, "reg0", NULL, "xreg0[32..63]");
- expr_symtab_add_subfield(&symtab, "reg1", NULL, "xreg0[0..31]");
- expr_symtab_add_subfield(&symtab, "reg2", NULL, "xreg1[32..63]");
- expr_symtab_add_subfield(&symtab, "reg3", NULL, "xreg1[0..31]");
- expr_symtab_add_subfield(&symtab, "reg4", NULL, "xreg2[32..63]");
- expr_symtab_add_subfield(&symtab, "reg5", NULL, "xreg2[0..31]");
+ expr_symtab_add_string(&symtab, "inport", MFF_LOG_INPORT, NULL);
+ expr_symtab_add_string(&symtab, "outport", MFF_LOG_OUTPORT, NULL);
- /* Data fields. */
+ /* Registers. We omit the registers that would otherwise overlap the
+ * reserved fields. */
+ for (enum mf_field_id id = MFF_REG0; id < MFF_REG0 + FLOW_N_REGS; id++) {
+ if (id != MFF_LOG_INPORT && id != MFF_LOG_OUTPORT) {
+ char name[8];
+ snprintf(name, sizeof name, "reg%d", id - MFF_REG0);
+ expr_symtab_add_field(&symtab, name, id, NULL, false);
+ }
+ }
+
+ /* Data fields. */
expr_symtab_add_field(&symtab, "eth.src", MFF_ETH_SRC, NULL, false);
expr_symtab_add_field(&symtab, "eth.dst", MFF_ETH_DST, NULL, false);
expr_symtab_add_field(&symtab, "eth.type", MFF_ETH_TYPE, NULL, true);
diff --git a/ovn/controller/pipeline.h b/ovn/controller/pipeline.h
index d127bf5..a5ed51f 100644
--- a/ovn/controller/pipeline.h
+++ b/ovn/controller/pipeline.h
@@ -19,6 +19,10 @@
struct controller_ctx;
+/* Logical ports. */
+#define MFF_LOG_INPORT MFF_REG6 /* Logical input port. */
+#define MFF_LOG_OUTPORT MFF_REG7 /* Logical output port. */
+
void pipeline_init(struct controller_ctx *);
void pipeline_run(struct controller_ctx *);
void pipeline_destroy(struct controller_ctx *);
--
2.1.3
More information about the dev
mailing list