]> git.proxmox.com Git - ovs.git/blame - ovn/lib/extend-table.h
ovn-controller: Initial use of incremental engine - quiet mode.
[ovs.git] / ovn / lib / extend-table.h
CommitLineData
ad35c0c5
GL
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
ad35c0c5
GL
23#include "openvswitch/hmap.h"
24#include "openvswitch/list.h"
0bd4d85c 25#include "openvswitch/uuid.h"
ad35c0c5
GL
26
27/* Used to manage expansion tables associated with Flow table,
28 * such as the Group Table or Meter Table. */
29struct 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
37struct ovn_extend_table_info {
38 struct hmap_node hmap_node;
2df707a0 39 char *name; /* Name for the table entity. */
0bd4d85c 40 struct uuid lflow_uuid;
ad35c0c5
GL
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
46void ovn_extend_table_init(struct ovn_extend_table *);
47
48void ovn_extend_table_destroy(struct ovn_extend_table *);
49
50struct ovn_extend_table_info *ovn_extend_table_lookup(
51 struct hmap *, const struct ovn_extend_table_info *);
52
53void ovn_extend_table_clear(struct ovn_extend_table *, bool);
54
0bd4d85c
HZ
55void ovn_extend_table_remove_existing(struct ovn_extend_table *,
56 struct ovn_extend_table_info *);
ad35c0c5 57
0bd4d85c
HZ
58void ovn_extend_table_remove_desired(struct ovn_extend_table *,
59 const struct uuid *lflow_uuid);
60
61/* Copy the contents of desired to existing. */
62void ovn_extend_table_sync(struct ovn_extend_table *);
ad35c0c5
GL
63
64uint32_t ovn_extend_table_assign_id(struct ovn_extend_table *,
0bd4d85c
HZ
65 const char *name,
66 struct uuid lflow_uuid);
ad35c0c5
GL
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 */