blob: 2c0230c2869ca64c90e29ad2ebfdd12f072118f0 [file] [log] [blame]
Florin Coras1c710452017-10-17 00:03:13 -07001/*
Florin Coras288eaab2019-02-03 15:26:14 -08002 * Copyright (c) 2017-2019 Cisco and/or its affiliates.
Florin Coras1c710452017-10-17 00:03:13 -07003 * 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
Florin Corasc97a7392017-11-05 23:07:07 -080033#define MMA_TABLE_INVALID_INDEX ((u32)~0)
Florin Coras1c710452017-10-17 00:03:13 -070034
35typedef struct
36{
37 u64 as_u64[MMA_RT_TYPE / 8];
38} RTT (mma_mask_or_match);
39
40typedef struct
41{
42 u32 action_index;
43 u32 *next_indices;
Florin Coras1c710452017-10-17 00:03:13 -070044 RTT (mma_mask_or_match) mask;
45 RTT (mma_mask_or_match) match;
46 RTT (mma_mask_or_match) max_match;
Florin Coras1c710452017-10-17 00:03:13 -070047} RTT (mma_rule);
48
49typedef int (*RTT (rule_cmp_fn)) (RTT (mma_rule) * rule1,
50 RTT (mma_rule) * rule2);
51typedef struct
52{
53 /** Root for rules tree */
54 u32 root_index;
55
56 /** Rules pool */
57 RTT (mma_rule) * rules;
58
59 RTT (rule_cmp_fn) rule_cmp_fn;
60} RTT (mma_rules_table);
61
62u32
63RT (mma_table_lookup) (RTT (mma_rules_table) * srt,
64 RTT (mma_mask_or_match) * key, u32 rule_index);
65u32
66RT (mma_table_lookup_rule) (RTT (mma_rules_table) * srt,
67 RTT (mma_mask_or_match) * key, u32 rule_index);
68int
69RT (mma_table_add_rule) (RTT (mma_rules_table) * srt, RTT (mma_rule) * rule);
70int
71RT (mma_table_del_rule) (RTT (mma_rules_table) * srt,
72 RTT (mma_rule) * rule, u32 rule_index);
73RTT (mma_rule) *
74RT (mma_rules_table_rule_alloc) (RTT (mma_rules_table) * srt);
75RTT (mma_rule) *
76RT (session_rule_free) (RTT (mma_rules_table) * srt, RTT (mma_rule) * rule);
77RTT (mma_rule) *
78RT (mma_table_get_rule) (RTT (mma_rules_table) * srt, u32 srt_index);
79u32
Florin Corasc97a7392017-11-05 23:07:07 -080080RT (mma_rules_table_rule_index) (RTT (mma_rules_table) * srt,
81 RTT (mma_rule) * sr);
Florin Coras1c710452017-10-17 00:03:13 -070082#endif /* SRC_VNET_SESSION_MMA_TEMPLATE_H_ */
83
84/*
85 * fd.io coding-style-patch-verification: ON
86 *
87 * Local Variables:
88 * eval: (c-set-style "gnu")
89 * End:
90 */