]> git.proxmox.com Git - ovs.git/blob - ovn/lib/extend-table.h
ovn-controller: Initial use of incremental engine - quiet mode.
[ovs.git] / ovn / lib / extend-table.h
1 /*
2 * Copyright (c) 2017 DtDream Technology Co.,Ltd.
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 EXTEND_TABLE_H
18 #define EXTEND_TABLE_H 1
19
20 #define MAX_EXT_TABLE_ID 65535
21 #define EXT_TABLE_ID_INVALID 0
22
23 #include "openvswitch/hmap.h"
24 #include "openvswitch/list.h"
25 #include "openvswitch/uuid.h"
26
27 /* Used to manage expansion tables associated with Flow table,
28 * such as the Group Table or Meter Table. */
29 struct ovn_extend_table {
30 unsigned long *table_ids; /* Used as a bitmap with value set
31 * for allocated group ids in either
32 * desired or existing. */
33 struct hmap desired;
34 struct hmap existing;
35 };
36
37 struct ovn_extend_table_info {
38 struct hmap_node hmap_node;
39 char *name; /* Name for the table entity. */
40 struct uuid lflow_uuid;
41 uint32_t table_id;
42 bool new_table_id; /* 'True' if 'table_id' was reserved from
43 * ovn_extend_table's 'table_ids' bitmap. */
44 };
45
46 void ovn_extend_table_init(struct ovn_extend_table *);
47
48 void ovn_extend_table_destroy(struct ovn_extend_table *);
49
50 struct ovn_extend_table_info *ovn_extend_table_lookup(
51 struct hmap *, const struct ovn_extend_table_info *);
52
53 void ovn_extend_table_clear(struct ovn_extend_table *, bool);
54
55 void ovn_extend_table_remove_existing(struct ovn_extend_table *,
56 struct ovn_extend_table_info *);
57
58 void ovn_extend_table_remove_desired(struct ovn_extend_table *,
59 const struct uuid *lflow_uuid);
60
61 /* Copy the contents of desired to existing. */
62 void ovn_extend_table_sync(struct ovn_extend_table *);
63
64 uint32_t ovn_extend_table_assign_id(struct ovn_extend_table *,
65 const char *name,
66 struct uuid lflow_uuid);
67
68 /* Iterates 'DESIRED' through all of the 'ovn_extend_table_info's in
69 * 'TABLE'->desired that are not in 'TABLE'->existing. (The loop body
70 * presumably adds them.) */
71 #define EXTEND_TABLE_FOR_EACH_UNINSTALLED(DESIRED, TABLE) \
72 HMAP_FOR_EACH (DESIRED, hmap_node, &(TABLE)->desired) \
73 if (!ovn_extend_table_lookup(&(TABLE)->existing, DESIRED))
74
75 /* Iterates 'EXISTING' through all of the 'ovn_extend_table_info's in
76 * 'TABLE'->existing that are not in 'TABLE'->desired. (The loop body
77 * presumably removes them.) */
78 #define EXTEND_TABLE_FOR_EACH_INSTALLED(EXISTING, NEXT, TABLE) \
79 HMAP_FOR_EACH_SAFE (EXISTING, NEXT, hmap_node, &(TABLE)->existing) \
80 if (!ovn_extend_table_lookup(&(TABLE)->desired, EXISTING))
81
82 #endif /* ovn/lib/extend-table.h */