From: Ben Pfaff Date: Sun, 18 Oct 2015 19:42:33 +0000 (-0700) Subject: logical-fields: New header for logical field assignments. X-Git-Tag: v2.12.3~6582 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=667e2b0b745436165889664cb78cc96c4c534d1c;p=mirror_ovs.git logical-fields: New header for logical field assignments. The original concept for "expr" and "actions" was that they should not need to know anything about the mapping between physical and logical fields, that instead everything should be provided via the symbol table. In practice this has proven difficult because a couple of actions need to know about logical fields. For now, it seems reasonable to put the logical field mapping into a header of its own. Later, maybe we'll figure out whether there's value in a less leaky abstraction. Signed-off-by: Ben Pfaff Acked-by: Justin Pettit --- diff --git a/ovn/controller/lflow.h b/ovn/controller/lflow.h index c3a92f60e..4a4fa8315 100644 --- a/ovn/controller/lflow.h +++ b/ovn/controller/lflow.h @@ -13,10 +13,11 @@ * limitations under the License. */ - #ifndef OVN_LFLOW_H #define OVN_LFLOW_H 1 +#include "ovn/lib/logical-fields.h" + /* Logical_Flow table translation to OpenFlow * ========================================== * @@ -54,25 +55,6 @@ struct uuid; /* The number of tables for the ingress and egress pipelines. */ #define LOG_PIPELINE_LEN 16 -/* Logical fields. - * - * These values are documented in ovn-architecture(7), please update the - * documentation if you change any of them. */ -#define MFF_LOG_DATAPATH MFF_METADATA /* Logical datapath (64 bits). */ -#define MFF_LOG_CT_ZONE MFF_REG5 /* Logical conntrack zone (32 bits). */ -#define MFF_LOG_INPORT MFF_REG6 /* Logical input port (32 bits). */ -#define MFF_LOG_OUTPORT MFF_REG7 /* Logical output port (32 bits). */ - -/* 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) - void lflow_init(void); void lflow_run(struct controller_ctx *, struct hmap *flow_table, const struct simap *ct_zones); diff --git a/ovn/lib/actions.c b/ovn/lib/actions.c index aebe5ce77..ccf97f047 100644 --- a/ovn/lib/actions.c +++ b/ovn/lib/actions.c @@ -22,6 +22,7 @@ #include "dynamic-string.h" #include "expr.h" #include "lex.h" +#include "logical-fields.h" #include "ofp-actions.h" #include "ofpbuf.h" #include "simap.h" @@ -200,8 +201,7 @@ emit_ct(struct action_context *ctx, bool recirc_next, bool commit) ct->recirc_table = NX_CT_RECIRC_NONE; } - /* xxx Should remove hard-coding reg5 if we refactor library. */ - ct->zone_src.field = mf_from_id(MFF_REG5); + ct->zone_src.field = mf_from_id(MFF_LOG_CT_ZONE); ct->zone_src.ofs = 0; ct->zone_src.n_bits = 16; diff --git a/ovn/lib/automake.mk b/ovn/lib/automake.mk index 078e2001f..9e0935290 100644 --- a/ovn/lib/automake.mk +++ b/ovn/lib/automake.mk @@ -9,7 +9,8 @@ ovn_lib_libovn_la_SOURCES = \ ovn/lib/expr.c \ ovn/lib/expr.h \ ovn/lib/lex.c \ - ovn/lib/lex.h + ovn/lib/lex.h \ + ovn/lib/logical-fields.h nodist_ovn_lib_libovn_la_SOURCES = \ ovn/lib/ovn-nb-idl.c \ ovn/lib/ovn-nb-idl.h \ diff --git a/ovn/lib/logical-fields.h b/ovn/lib/logical-fields.h new file mode 100644 index 000000000..41d42a5a8 --- /dev/null +++ b/ovn/lib/logical-fields.h @@ -0,0 +1,40 @@ +/* Copyright (c) 2015 Nicira, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OVN_LOGICAL_FIELDS_H +#define OVN_LOGICAL_FIELDS_H 1 + +#include "meta-flow.h" + +/* Logical fields. + * + * These values are documented in ovn-architecture(7), please update the + * documentation if you change any of them. */ +#define MFF_LOG_DATAPATH MFF_METADATA /* Logical datapath (64 bits). */ +#define MFF_LOG_CT_ZONE MFF_REG5 /* Logical conntrack zone (32 bits). */ +#define MFF_LOG_INPORT MFF_REG6 /* Logical input port (32 bits). */ +#define MFF_LOG_OUTPORT MFF_REG7 /* Logical output port (32 bits). */ + +/* 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) + +#endif /* ovn/lib/logical-fields.h */ diff --git a/ovn/ovn-architecture.7.xml b/ovn/ovn-architecture.7.xml index 0bf9337a8..343aa7e34 100644 --- a/ovn/ovn-architecture.7.xml +++ b/ovn/ovn-architecture.7.xml @@ -626,7 +626,7 @@ A field that denotes the logical datapath through which a packet is being processed. + ovn/lib/logical-fields.h. --> OVN uses the field that OpenFlow 1.1+ simply (and confusingly) calls ``metadata'' to store the logical datapath. (This field is passed across tunnels as part of the tunnel key.) @@ -638,7 +638,7 @@ A field that denotes the logical port from which the packet entered the logical datapath. + ovn/lib/logical-fields.h. --> OVN stores this in Nicira extension register number 6.

@@ -659,7 +659,7 @@ leave the logical datapath. This is initialized to 0 at the beginning of the logical ingress pipeline. + ovn/lib/logical-fields.h. --> OVN stores this in Nicira extension register number 7.