]> git.proxmox.com Git - mirror_ovs.git/blob - lib/ovsdb-idl-provider.h
ovn-controller: Handle physical changes correctly
[mirror_ovs.git] / lib / ovsdb-idl-provider.h
1 /* Copyright (c) 2009, 2010, 2011, 2012 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 #ifndef OVSDB_IDL_PROVIDER_H
17 #define OVSDB_IDL_PROVIDER_H 1
18
19 #include "hmap.h"
20 #include "openvswitch/list.h"
21 #include "ovsdb-idl.h"
22 #include "ovsdb-map-op.h"
23 #include "ovsdb-types.h"
24 #include "shash.h"
25 #include "uuid.h"
26
27 struct ovsdb_idl_row {
28 struct hmap_node hmap_node; /* In struct ovsdb_idl_table's 'rows'. */
29 struct uuid uuid; /* Row "_uuid" field. */
30 struct ovs_list src_arcs; /* Forward arcs (ovsdb_idl_arc.src_node). */
31 struct ovs_list dst_arcs; /* Backward arcs (ovsdb_idl_arc.dst_node). */
32 struct ovsdb_idl_table *table; /* Containing table. */
33 struct ovsdb_datum *old; /* Committed data (null if orphaned). */
34
35 /* Transactional data. */
36 struct ovsdb_datum *new; /* Modified data (null to delete row). */
37 unsigned long int *prereqs; /* Bitmap of columns to verify in "old". */
38 unsigned long int *written; /* Bitmap of columns from "new" to write. */
39 struct hmap_node txn_node; /* Node in ovsdb_idl_txn's list. */
40 unsigned long int *map_op_written; /* Bitmap of columns pending map ops. */
41 struct map_op_list **map_op_lists; /* Per-column map operations. */
42
43 /* Tracking data */
44 unsigned int change_seqno[OVSDB_IDL_CHANGE_MAX];
45 struct ovs_list track_node; /* Rows modified/added/deleted by IDL */
46 unsigned long int *updated; /* Bitmap of columns updated by IDL */
47 };
48
49 struct ovsdb_idl_column {
50 char *name;
51 struct ovsdb_type type;
52 bool mutable;
53 void (*parse)(struct ovsdb_idl_row *, const struct ovsdb_datum *);
54 void (*unparse)(struct ovsdb_idl_row *);
55 };
56
57 struct ovsdb_idl_table_class {
58 char *name;
59 bool is_root;
60 const struct ovsdb_idl_column *columns;
61 size_t n_columns;
62 size_t allocation_size;
63 void (*row_init)(struct ovsdb_idl_row *);
64 };
65
66 struct ovsdb_idl_table {
67 const struct ovsdb_idl_table_class *class;
68 unsigned char *modes; /* OVSDB_IDL_* bitmasks, indexed by column. */
69 bool need_table; /* Monitor table even if no columns are selected
70 * for replication. */
71 struct shash columns; /* Contains "const struct ovsdb_idl_column *"s. */
72 struct hmap rows; /* Contains "struct ovsdb_idl_row"s. */
73 struct ovsdb_idl *idl; /* Containing idl. */
74 unsigned int change_seqno[OVSDB_IDL_CHANGE_MAX];
75 struct ovs_list track_list; /* Tracked rows (ovsdb_idl_row.track_node). */
76 struct ovsdb_idl_condition condition;
77 bool cond_changed;
78 };
79
80 struct ovsdb_idl_class {
81 const char *database; /* <db-name> for this database. */
82 const struct ovsdb_idl_table_class *tables;
83 size_t n_tables;
84 };
85
86 struct ovsdb_idl_row *ovsdb_idl_get_row_arc(
87 struct ovsdb_idl_row *src,
88 struct ovsdb_idl_table_class *dst_table,
89 const struct uuid *dst_uuid);
90
91 void ovsdb_idl_txn_verify(const struct ovsdb_idl_row *,
92 const struct ovsdb_idl_column *);
93
94 struct ovsdb_idl_txn *ovsdb_idl_txn_get(const struct ovsdb_idl_row *);
95
96 #endif /* ovsdb-idl-provider.h */