summaryrefslogtreecommitdiff
path: root/ovsdb
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2018-06-07 14:22:33 -0700
committerBen Pfaff <blp@ovn.org>2018-06-11 15:05:12 -0700
commit0eb1e37c141d72e2cac0a988982160185e011c92 (patch)
tree709b589173004b7bbe3902b9450f7bdde7bb77c2 /ovsdb
parent83293ddf93b49f0d38399063f6454569359f6cef (diff)
downloadopenvswitch-0eb1e37c141d72e2cac0a988982160185e011c92.tar.gz
ovn-controller: Pass around pointers to individual tables.
We're working to make ovn-controller compute more incrementally, to reduce CPU usage. To make it easier to keep track of dependencies, it makes sense to pass around pointers to fine-grained resources instead of an entire database at a time. This commit introduces a way to pass individual tables around and starts using that feature in ovn-controller. CC: Han Zhou <zhouhan@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Han Zhou <hzhou8@ebay.com>
Diffstat (limited to 'ovsdb')
-rwxr-xr-xovsdb/ovsdb-idlc.in27
1 files changed, 27 insertions, 0 deletions
diff --git a/ovsdb/ovsdb-idlc.in b/ovsdb/ovsdb-idlc.in
index 80715dfea..5a675ebba 100755
--- a/ovsdb/ovsdb-idlc.in
+++ b/ovsdb/ovsdb-idlc.in
@@ -238,6 +238,18 @@ extern "C" {
print("\nextern struct ovsdb_idl_column %s_columns[%s_N_COLUMNS];" % (structName, structName.upper()))
print('''
+const struct %(s)s_table *%(s)s_table_get(const struct ovsdb_idl *);
+const struct %(s)s *%(s)s_table_first(const struct %(s)s_table *);
+
+#define %(S)s_TABLE_FOR_EACH(ROW, TABLE) \\
+ for ((ROW) = %(s)s_table_first(TABLE); \\
+ (ROW); \\
+ (ROW) = %(s)s_next(ROW))
+#define %(S)s_TABLE_FOR_EACH_SAFE(ROW, NEXT, TABLE) \\
+ for ((ROW) = %(s)s_table_first(TABLE); \\
+ (ROW) ? ((NEXT) = %(s)s_next(ROW), 1) : 0; \\
+ (ROW) = (NEXT))
+
const struct %(s)s *%(s)s_get_for_uuid(const struct ovsdb_idl *, const struct uuid *);
const struct %(s)s *%(s)s_first(const struct ovsdb_idl *);
const struct %(s)s *%(s)s_next(const struct %(s)s *);
@@ -435,6 +447,21 @@ static struct %(s)s *
print(" ")
print("/* %s table. */" % (tableName))
+ print('''
+const struct %(s)s_table *
+%(s)s_table_get(const struct ovsdb_idl *idl)
+{
+ return (const struct %(s)s_table *) idl;
+}
+
+const struct %(s)s *
+%(s)s_table_first(const struct %(s)s_table *table)
+{
+ const struct ovsdb_idl *idl = (const struct ovsdb_idl *) table;
+ return %(s)s_first(idl);
+}
+''' % {'s': structName})
+
# Parse functions.
for columnName, column in sorted_columns(table):
if 'parse' in column.extensions: