]>
git.proxmox.com Git - ovs.git/blob - ovn/lib/extend-table.h
2 * Copyright (c) 2017 DtDream Technology Co.,Ltd.
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:
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef EXTEND_TABLE_H
18 #define EXTEND_TABLE_H 1
20 #define MAX_EXT_TABLE_ID 65535
21 #define EXT_TABLE_ID_INVALID 0
23 #include "openvswitch/hmap.h"
24 #include "openvswitch/list.h"
25 #include "openvswitch/uuid.h"
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. */
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
;
42 bool new_table_id
; /* 'True' if 'table_id' was reserved from
43 * ovn_extend_table's 'table_ids' bitmap. */
46 void ovn_extend_table_init(struct ovn_extend_table
*);
48 void ovn_extend_table_destroy(struct ovn_extend_table
*);
50 struct ovn_extend_table_info
*ovn_extend_table_lookup(
51 struct hmap
*, const struct ovn_extend_table_info
*);
53 void ovn_extend_table_clear(struct ovn_extend_table
*, bool);
55 void ovn_extend_table_remove_existing(struct ovn_extend_table
*,
56 struct ovn_extend_table_info
*);
58 void ovn_extend_table_remove_desired(struct ovn_extend_table
*,
59 const struct uuid
*lflow_uuid
);
61 /* Copy the contents of desired to existing. */
62 void ovn_extend_table_sync(struct ovn_extend_table
*);
64 uint32_t ovn_extend_table_assign_id(struct ovn_extend_table
*,
66 struct uuid lflow_uuid
);
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))
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))
82 #endif /* ovn/lib/extend-table.h */