FD.io VPP  v18.10-34-gcce845e
Vector Packet Processing
mma_template.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14 */
15 
16 #ifndef SRC_VNET_SESSION_MMA_TEMPLATE_H_
17 #define SRC_VNET_SESSION_MMA_TEMPLATE_H_
18 
19 #include <vppinfra/pool.h>
20 
21 #ifndef MMA_RT_TYPE
22 #error MMA_RT_TYPE not defined
23 #endif
24 
25 #define _rt(a,b) a##_##b
26 #define __rt(a, b) _rt(a,b)
27 #define RT(a) __rt(a, MMA_RT_TYPE)
28 
29 #define _rtt(a,b) a##_##b##_t
30 #define __rtt(a, b) _rtt(a,b)
31 #define RTT(a) __rtt(a, MMA_RT_TYPE)
32 
33 #define MMA_TABLE_INVALID_INDEX ((u32)~0)
34 
35 typedef struct
36 {
38 } RTT (mma_mask_or_match);
39 
40 typedef struct
41 {
44  /* *INDENT-OFF* */
45  RTT (mma_mask_or_match) mask;
46  RTT (mma_mask_or_match) match;
47  RTT (mma_mask_or_match) max_match;
48  /* *INDENT-ON* */
49 } RTT (mma_rule);
50 
51 typedef int (*RTT (rule_cmp_fn)) (RTT (mma_rule) * rule1,
52  RTT (mma_rule) * rule2);
53 typedef struct
54 {
55  /** Root for rules tree */
57 
58  /** Rules pool */
59  RTT (mma_rule) * rules;
60 
61  RTT (rule_cmp_fn) rule_cmp_fn;
62 } RTT (mma_rules_table);
63 
64 u32
65 RT (mma_table_lookup) (RTT (mma_rules_table) * srt,
66  RTT (mma_mask_or_match) * key, u32 rule_index);
67 u32
68 RT (mma_table_lookup_rule) (RTT (mma_rules_table) * srt,
69  RTT (mma_mask_or_match) * key, u32 rule_index);
70 int
71 RT (mma_table_add_rule) (RTT (mma_rules_table) * srt, RTT (mma_rule) * rule);
72 int
73 RT (mma_table_del_rule) (RTT (mma_rules_table) * srt,
74  RTT (mma_rule) * rule, u32 rule_index);
75 RTT (mma_rule) *
76 RT (mma_rules_table_rule_alloc) (RTT (mma_rules_table) * srt);
77 RTT (mma_rule) *
78 RT (session_rule_free) (RTT (mma_rules_table) * srt, RTT (mma_rule) * rule);
79 RTT (mma_rule) *
80 RT (mma_table_get_rule) (RTT (mma_rules_table) * srt, u32 srt_index);
81 u32
82 RT (mma_rules_table_rule_index) (RTT (mma_rules_table) * srt,
83  RTT (mma_rule) * sr);
84 #endif /* SRC_VNET_SESSION_MMA_TEMPLATE_H_ */
85 
86 /*
87  * fd.io coding-style-patch-verification: ON
88  *
89  * Local Variables:
90  * eval: (c-set-style "gnu")
91  * End:
92  */
u32 action_index
Definition: mma_template.h:42
u64 as_u64
Definition: bihash_doc.h:63
unsigned long u64
Definition: types.h:89
Fixed length block allocator.
#define MMA_RT_TYPE
Definition: mma_16.h:17
#define RTT(a)
Definition: mma_template.h:31
unsigned int u32
Definition: types.h:88
u32 root_index
Root for rules tree.
Definition: mma_template.h:56
u32 RT() mma_rules_table_rule_index(RTT(mma_rules_table)*srt, RTT(mma_rule)*sr)
Definition: mma_template.c:77
u32 RT() mma_table_lookup_rule(RTT(mma_rules_table)*srt, RTT(mma_mask_or_match)*key, u32 rule_index)
#define RT(a)
Definition: mma_template.h:27
u32 RT() mma_table_lookup(RTT(mma_rules_table)*srt, RTT(mma_mask_or_match)*key, u32 rule_index)
int RT() mma_table_del_rule(RTT(mma_rules_table)*srt, RTT(mma_rule)*rule, u32 rule_index)
int RT() mma_table_add_rule(RTT(mma_rules_table)*srt, RTT(mma_rule)*rule)
u32 * next_indices
Definition: mma_template.h:43