]> git.proxmox.com Git - mirror_ovs.git/blame - lib/ovsdb-idl-provider.h
netdev-offload-tc: Use single 'once' variable for probing tc features
[mirror_ovs.git] / lib / ovsdb-idl-provider.h
CommitLineData
239fa5bb 1/* Copyright (c) 2009, 2010, 2011, 2012, 2016 Nicira, Inc.
93fe0264 2 * Copyright (C) 2016 Hewlett Packard Enterprise Development LP
c3bb4bd7
BP
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef OVSDB_IDL_PROVIDER_H
18#define OVSDB_IDL_PROVIDER_H 1
19
ee89ea7b 20#include "openvswitch/hmap.h"
b19bab5b 21#include "openvswitch/list.h"
c3bb4bd7 22#include "ovsdb-idl.h"
f199df26 23#include "ovsdb-map-op.h"
f1ab6e06 24#include "ovsdb-set-op.h"
c3bb4bd7 25#include "ovsdb-types.h"
ee89ea7b 26#include "openvswitch/shash.h"
c3bb4bd7
BP
27#include "uuid.h"
28
9131abe2
YHW
29#ifdef __cplusplus
30extern "C" {
31#endif
32
c1ac745c
BP
33/* A local copy of a row in an OVSDB table, replicated from an OVSDB server.
34 * This structure is used as a header for a larger structure that translates
35 * the "struct ovsdb_datum"s into easier-to-use forms, via the ->parse() and
36 * ->unparse functions in struct ovsdb_idl_column. (Those functions are
37 * generated automatically via ovsdb-idlc.)
38 *
39 * When no transaction is in progress:
40 *
4e0b4acc 41 * - 'old_datum' points to the data committed to the database and currently
c1ac745c
BP
42 * in the row.
43 *
4e0b4acc 44 * - 'new_datum == old_datum'.
c1ac745c
BP
45 *
46 * When a transaction is in progress, the situation is a little different. For
4e0b4acc
JS
47 * a row inserted in the transaction, 'old_datum' is NULL and 'new_datum'
48 * points to the row's initial contents. Otherwise:
c1ac745c 49 *
4e0b4acc
JS
50 * - 'old_datum' points to the data committed to the database and currently
51 * in the row. (This is the same as when no transaction is in progress.)
c1ac745c 52 *
4e0b4acc 53 * - If the transaction does not modify the row, 'new_datum == old_datum'.
c1ac745c 54 *
fa50ab0b
JS
55 * - If the transaction modifies the row, 'new_datum' points to the
56 * modified data.
c1ac745c 57 *
fa50ab0b 58 * - If the transaction deletes the row, 'new_datum' is NULL.
c1ac745c
BP
59 *
60 * Thus:
61 *
4e0b4acc
JS
62 * - 'old_datum' always points to committed data, except that it is NULL if
63 * the row is inserted within the current transaction.
c1ac745c 64 *
fa50ab0b
JS
65 * - 'new_datum' always points to the newest, possibly uncommitted version
66 * of the row's data, except that it is NULL if the row is deleted within
67 * the current transaction.
c1ac745c 68 */
c3bb4bd7
BP
69struct ovsdb_idl_row {
70 struct hmap_node hmap_node; /* In struct ovsdb_idl_table's 'rows'. */
71 struct uuid uuid; /* Row "_uuid" field. */
ca6ba700
TG
72 struct ovs_list src_arcs; /* Forward arcs (ovsdb_idl_arc.src_node). */
73 struct ovs_list dst_arcs; /* Backward arcs (ovsdb_idl_arc.dst_node). */
c3bb4bd7 74 struct ovsdb_idl_table *table; /* Containing table. */
4e0b4acc 75 struct ovsdb_datum *old_datum; /* Committed data (null if orphaned). */
72aeb243 76 bool parsed; /* Whether the row is parsed. */
475281c0
BP
77
78 /* Transactional data. */
fa50ab0b 79 struct ovsdb_datum *new_datum; /* Modified data (null to delete row). */
4e0b4acc 80 unsigned long int *prereqs; /* Bitmap of "old_datum" columns to verify. */
fa50ab0b 81 unsigned long int *written; /* Bitmap of "new_datum" columns to write. */
475281c0 82 struct hmap_node txn_node; /* Node in ovsdb_idl_txn's list. */
f199df26
EA
83 unsigned long int *map_op_written; /* Bitmap of columns pending map ops. */
84 struct map_op_list **map_op_lists; /* Per-column map operations. */
f1ab6e06
RM
85 unsigned long int *set_op_written; /* Bitmap of columns pending set ops. */
86 struct set_op_list **set_op_lists; /* Per-column set operations. */
932104f4 87
32d37ce8 88 /* Tracking data */
932104f4 89 unsigned int change_seqno[OVSDB_IDL_CHANGE_MAX];
32d37ce8
SA
90 struct ovs_list track_node; /* Rows modified/added/deleted by IDL */
91 unsigned long int *updated; /* Bitmap of columns updated by IDL */
72aeb243 92 struct ovsdb_datum *tracked_old_datum; /* Old deleted data. */
c3bb4bd7
BP
93};
94
95struct ovsdb_idl_column {
96 char *name;
97 struct ovsdb_type type;
c6e5d064 98 bool is_mutable;
01928c96 99 bool is_synthetic;
979821c0
BP
100 void (*parse)(struct ovsdb_idl_row *, const struct ovsdb_datum *);
101 void (*unparse)(struct ovsdb_idl_row *);
c3bb4bd7
BP
102};
103
104struct ovsdb_idl_table_class {
105 char *name;
c5f341ab 106 bool is_root;
25540a77 107 bool is_singleton;
c3bb4bd7
BP
108 const struct ovsdb_idl_column *columns;
109 size_t n_columns;
110 size_t allocation_size;
a699f614 111 void (*row_init)(struct ovsdb_idl_row *);
c3bb4bd7
BP
112};
113
114struct ovsdb_idl_table {
3eb14233 115 const struct ovsdb_idl_table_class *class_;
ef73f86c 116 unsigned char *modes; /* OVSDB_IDL_* bitmasks, indexed by column. */
cd26c1dc
AE
117 bool need_table; /* Monitor table even if no columns are selected
118 * for replication. */
c3bb4bd7
BP
119 struct shash columns; /* Contains "const struct ovsdb_idl_column *"s. */
120 struct hmap rows; /* Contains "struct ovsdb_idl_row"s. */
1456335d 121 struct ovsdb_idl_db *db; /* Containing db. */
932104f4 122 unsigned int change_seqno[OVSDB_IDL_CHANGE_MAX];
d14e007c 123 struct ovs_list indexes; /* Contains "struct ovsdb_idl_index"s */
932104f4 124 struct ovs_list track_list; /* Tracked rows (ovsdb_idl_row.track_node). */
ae25f8c8
DC
125 struct ovsdb_idl_condition *ack_cond; /* Last condition acked by the
126 * server. */
127 struct ovsdb_idl_condition *req_cond; /* Last condition requested to the
128 * server. */
129 struct ovsdb_idl_condition *new_cond; /* Latest condition set by the IDL
130 * client. */
c3bb4bd7
BP
131};
132
133struct ovsdb_idl_class {
9cb53f26 134 const char *database; /* <db-name> for this database. */
c3bb4bd7
BP
135 const struct ovsdb_idl_table_class *tables;
136 size_t n_tables;
137};
138
139struct ovsdb_idl_row *ovsdb_idl_get_row_arc(
140 struct ovsdb_idl_row *src,
012d3762 141 const struct ovsdb_idl_table_class *dst_table,
c3bb4bd7
BP
142 const struct uuid *dst_uuid);
143
475281c0
BP
144void ovsdb_idl_txn_verify(const struct ovsdb_idl_row *,
145 const struct ovsdb_idl_column *);
475281c0 146
76c91af9 147struct ovsdb_idl_txn *ovsdb_idl_txn_get(const struct ovsdb_idl_row *);
d14e007c
BP
148\f
149/* Index internals. */
150
151struct ovsdb_idl_index {
152 struct ovs_list node; /* In ->table->indexes. */
153 struct ovsdb_idl_table *table; /* The indexed table. */
154 struct ovsdb_idl_index_column *columns; /* The indexed columns. */
155 size_t n_columns;
156
157 /* Skiplist with pointers to rows. */
158 struct skiplist *skiplist;
159
160 /* True if a row in the index is being inserted or deleted. If true, the
161 search key is augmented with the UUID and address to discriminate
162 between entries with identical keys. */
163 bool ins_del;
164};
165
166int ovsdb_idl_index_compare(struct ovsdb_idl_index *,
167 const struct ovsdb_idl_row *a,
168 const struct ovsdb_idl_row *b);
169
170void ovsdb_idl_index_write(struct ovsdb_idl_row *,
171 const struct ovsdb_idl_column *,
172 struct ovsdb_datum *,
173 const struct ovsdb_idl_table_class *);
174struct ovsdb_idl_row *ovsdb_idl_index_init_row(struct ovsdb_idl_index *);
175void ovsdb_idl_index_destroy_row(const struct ovsdb_idl_row *);
76c91af9 176
9131abe2
YHW
177#ifdef __cplusplus
178}
179#endif
180
c3bb4bd7 181#endif /* ovsdb-idl-provider.h */