f0c4e6341cc57cbadd936c6636986c8f0d0e046c
[cascardo/ovs.git] / ovn / controller / ovn-controller.h
1 /* Copyright (c) 2015, 2016 Nicira, Inc.
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16
17 #ifndef OVN_CONTROLLER_H
18 #define OVN_CONTROLLER_H 1
19
20 #include "simap.h"
21 #include "ovn/lib/ovn-sb-idl.h"
22
23 /* Linux supports a maximum of 64K zones, which seems like a fine default. */
24 #define MAX_CT_ZONES 65535
25
26 struct controller_ctx {
27     struct ovsdb_idl *ovnsb_idl;
28     struct ovsdb_idl_txn *ovnsb_idl_txn;
29
30     struct ovsdb_idl *ovs_idl;
31     struct ovsdb_idl_txn *ovs_idl_txn;
32 };
33
34 /* Contains hmap_node whose hash values are the tunnel_key of datapaths
35  * with at least one local port binding. It also stores the port binding of
36  * "localnet" port if such a port exists on the datapath, which indicates
37  * physical network should be used for inter-chassis communication through
38  * the localnet port */
39 struct local_datapath {
40     struct hmap_node hmap_node;
41     struct hmap_node uuid_hmap_node;
42     const struct uuid *uuid;
43     char *logical_port;
44     const struct sbrec_port_binding *localnet_port;
45 };
46
47 struct local_datapath *get_local_datapath(const struct hmap *,
48                                           uint32_t tunnel_key);
49
50 /* Contains hmap_node whose hash values are the tunnel_key of datapaths
51  * with at least one logical patch port binding. */
52 struct patched_datapath {
53     struct hmap_node hmap_node;
54     bool local; /* 'True' if the datapath is for gateway router. */
55     const struct sbrec_port_binding *port_binding;
56 };
57
58 struct patched_datapath *get_patched_datapath(const struct hmap *,
59                                               uint32_t tunnel_key);
60
61 const struct ovsrec_bridge *get_bridge(struct ovsdb_idl *,
62                                        const char *br_name);
63
64 const struct sbrec_chassis *get_chassis(struct ovsdb_idl *,
65                                         const char *chassis_id);
66
67 /* Must be a bit-field ordered from most-preferred (higher number) to
68  * least-preferred (lower number). */
69 enum chassis_tunnel_type {
70     GENEVE = 1 << 2,
71     STT    = 1 << 1,
72     VXLAN  = 1 << 0
73 };
74
75 uint32_t get_tunnel_type(const char *name);
76
77
78 #endif /* ovn/ovn-controller.h */