It's super-awkward to have to define a macro to use MFF_LOG_REGS; this makes more sense.
Signed-off-by: Ben Pfaff <b...@ovn.org> --- ovn/controller/lflow.c | 17 +++++------------ ovn/controller/physical.c | 6 +++--- ovn/lib/logical-fields.h | 15 +++------------ 3 files changed, 11 insertions(+), 27 deletions(-) diff --git a/ovn/controller/lflow.c b/ovn/controller/lflow.c index fda10eb..9eb92c8 100644 --- a/ovn/controller/lflow.c +++ b/ovn/controller/lflow.c @@ -52,15 +52,6 @@ lflow_reset_processing(void) physical_reset_processing(); } -static void -add_logical_register(struct shash *symtab, enum mf_field_id id) -{ - char name[8]; - - snprintf(name, sizeof name, "reg%d", id - MFF_REG0); - expr_symtab_add_field(symtab, name, id, NULL, false); -} - void lflow_init(void) { @@ -74,9 +65,11 @@ lflow_init(void) expr_symtab_add_string(&symtab, "outport", MFF_LOG_OUTPORT, NULL); /* Logical registers. */ -#define MFF_LOG_REG(ID) add_logical_register(&symtab, ID); - MFF_LOG_REGS; -#undef MFF_LOG_REG + for (int i = 0; i < MFF_N_LOG_REGS; i++) { + char *name = xasprintf("reg%d", i); + expr_symtab_add_field(&symtab, name, MFF_LOG_REG0 + i, NULL, false); + free(name); + } expr_symtab_add_field(&symtab, "xxreg0", MFF_XXREG0, NULL, false); expr_symtab_add_field(&symtab, "xxreg1", MFF_XXREG1, NULL, false); diff --git a/ovn/controller/physical.c b/ovn/controller/physical.c index 15d4e00..589b053 100644 --- a/ovn/controller/physical.c +++ b/ovn/controller/physical.c @@ -908,9 +908,9 @@ physical_run(struct controller_ctx *ctx, enum mf_field_id mff_ovn_geneve, * registers (for consistent behavior with packets that get tunneled). */ match_init_catchall(&match); ofpbuf_clear(&ofpacts); -#define MFF_LOG_REG(ID) put_load(0, ID, 0, 32, &ofpacts); - MFF_LOG_REGS; -#undef MFF_LOG_REGS + for (int i = 0; i < MFF_N_LOG_REGS; i++) { + put_load(0, MFF_REG0 + i, 0, 32, &ofpacts); + } put_resubmit(OFTABLE_LOG_EGRESS_PIPELINE, &ofpacts); ofctrl_add_flow(OFTABLE_CHECK_LOOPBACK, 0, &match, &ofpacts, hc_uuid); diff --git a/ovn/lib/logical-fields.h b/ovn/lib/logical-fields.h index 94b3995..c8e3f07 100644 --- a/ovn/lib/logical-fields.h +++ b/ovn/lib/logical-fields.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2015 Nicira, Inc. +/* Copyright (c) 2015, 2016 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,16 +45,7 @@ enum { /* Logical registers. * * Make sure these don't overlap with the logical fields! */ -#define MFF_LOG_REGS \ - MFF_LOG_REG(MFF_REG0) \ - MFF_LOG_REG(MFF_REG1) \ - MFF_LOG_REG(MFF_REG2) \ - MFF_LOG_REG(MFF_REG3) \ - MFF_LOG_REG(MFF_REG4) \ - MFF_LOG_REG(MFF_REG5) \ - MFF_LOG_REG(MFF_REG6) \ - MFF_LOG_REG(MFF_REG7) \ - MFF_LOG_REG(MFF_REG8) \ - MFF_LOG_REG(MFF_REG9) +#define MFF_LOG_REG0 MFF_REG0 +#define MFF_N_LOG_REGS 10 #endif /* ovn/lib/logical-fields.h */ -- 2.1.3 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev