New api in order to get max entries of connection table is added.
[vpp.git] / src / plugins / acl / hash_lookup_types.h
1 /*
2  *------------------------------------------------------------------
3  * Copyright (c) 2017 Cisco and/or its affiliates.
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
18 #ifndef _ACL_HASH_LOOKUP_TYPES_H_
19 #define _ACL_HASH_LOOKUP_TYPES_H_
20
21 #include "types.h"
22
23 /* The structure representing the single entry with hash representation */
24 typedef struct {
25   fa_5tuple_t match;
26   /* these two entries refer to the original ACL# and rule# within that ACL */
27   u32 acl_index;
28   u32 ace_index;
29
30   u32 base_mask_type_index;
31
32   u8 action;
33 } hash_ace_info_t;
34
35 /*
36  * The structure holding the information necessary for the hash-based ACL operation
37  */
38 typedef struct {
39   /* hash ACL applied on these lookup contexts */
40   u32 *lc_index_list;
41   hash_ace_info_t *rules;
42   /* a boolean flag set when the hash acl info is initialized */
43   int hash_acl_exists;
44 } hash_acl_info_t;
45
46
47 typedef struct {
48   acl_rule_t rule;
49   u32 acl_index;
50   u32 ace_index;
51   u32 acl_position;
52   u32 applied_entry_index;
53 } collision_match_rule_t;
54
55 typedef struct {
56   /* original non-compiled ACL */
57   u32 acl_index;
58   u32 ace_index;
59   /* the index of the hash_ace_info_t */
60   u32 hash_ace_info_index;
61   /* applied mask type index */
62   u32 mask_type_index;
63   /*
64    * in case of the same key having multiple entries,
65    * this holds the index of the next entry.
66    */
67   u32 next_applied_entry_index;
68   /*
69    * previous entry in the list of the chained ones,
70    * if ~0 then this is entry in the hash.
71    */
72   u32 prev_applied_entry_index;
73   /*
74    * chain tail, if this is the first entry
75    */
76   u32 tail_applied_entry_index;
77   /*
78    * Collision rule vector for matching - set only on head entry
79    */
80   collision_match_rule_t *colliding_rules;
81   /*
82    * number of hits on this entry
83    */
84   u64 hitcount;
85   /*
86    * acl position in vector of ACLs within lookup context
87    */
88   u32 acl_position;
89   /*
90    * Action of this applied ACE
91    */
92   u8 action;
93 } applied_hash_ace_entry_t;
94
95 typedef struct {
96
97    /* applied ACLs so we can track them independently from main ACL module */
98    u32 *applied_acls;
99 } applied_hash_acl_info_t;
100
101
102 typedef union {
103   u64 as_u64;
104   struct {
105     u32 applied_entry_index;
106     u16 reserved_u16;
107     u8 reserved_u8;
108     u8 reserved_flags:8;
109   };
110 } hash_acl_lookup_value_t;
111
112
113 typedef struct {
114    u32 mask_type_index;
115    /* first rule # for this mask */
116    u32 first_rule_index;
117    /* Debug Information */
118    u32 num_entries;
119    u32 max_collisions;
120 } hash_applied_mask_info_t;
121
122
123 #define CT_ASSERT_EQUAL(name, x,y) typedef int assert_ ## name ## _compile_time_assertion_failed[((x) == (y))-1]
124
125 CT_ASSERT_EQUAL(hash_acl_lookup_value_t_is_u64, sizeof(hash_acl_lookup_value_t), sizeof(u64));
126
127 #undef CT_ASSERT_EQUAL
128
129 #endif