3b1b25f0581a4b458632807afd36d6174b7e9779
[samplevnf.git] / VNFs / vFW / pipeline / pipeline_vfw.h
1 /*
2 // Copyright (c) 2017 Intel Corporation
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 __INCLUDE_PIPELINE_VFW_H__
18 #define __INCLUDE_PIPELINE_VFW_H__
19
20 /**
21  * @file
22  * Pipeline VFW FE.
23  *
24  * Pipeline VFW Front End (FE).
25  * Runs on the Master pipeline, responsible for CLI commands.
26  *
27  */
28
29 #include "pipeline.h"
30 #include "app.h"
31 #include "pipeline_vfw_be.h"
32
33 /* VFW IPV4 and IPV6 enable flags for debugging (Default both on) */
34 extern int vfw_ipv4_enabled;
35 extern int vfw_ipv6_enabled;
36
37 /* Number of VFW Rules, default 4 * 1024 */
38 extern uint32_t vfw_n_rules;
39 /* VFW Rule Table TRIE - 2 (Active, Standby Global table per ipv4, ipv6 */
40 extern void *vfw_rule_table_ipv4_active;
41 extern void *vfw_rule_table_ipv4_standby;
42 extern void *vfw_rule_table_ipv6_active;
43 extern void *vfw_rule_table_ipv6_standby;
44
45 #define active_rule_table       0
46 #define standby_rule_table       1
47 #define vfw_add_command              0
48 #define vfw_delete_command       1
49 #define IPV6_32BIT_LENGTH       4
50
51 /**
52  * Add VFW rule to the VFW rule table.
53  * Rules are added standby table.
54  * Applyruleset command will activate the change.
55  * Both IPv4 and IPv6 rules can be added.
56  *
57  * @param app
58  *  A pointer to the VFW pipeline parameters.
59  * @param key
60  *  A pointer to the VFW rule to add.
61  * @param priority
62  *  Priority of the VFW rule.
63  * @param port_id
64  *  Port ID of the VFW rule.
65  * @param action_id
66  *  Action ID of the VFW rule. Defined in Action Table.
67  *
68  * @return
69  *  0 on success, negative on error.
70  */
71 int
72 app_pipeline_vfw_add_rule(struct app_params *app,
73                           struct pipeline_vfw_key *key,
74                           uint32_t priority,
75                           uint32_t port_id, uint32_t action_id);
76
77 /**
78  * Delete VFW rule from the VFW rule table.
79  * Rules deleted from standby tables.
80  * Applyruleset command will activate the change.
81  * Both IPv4 and IPv6 rules can be deleted.
82  *
83  * @param app
84  *  A pointer to the VFW pipeline parameters.
85  * @param key
86  *  A pointer to the VFW rule to delete.
87  *
88  * @return
89  *  0 on success, negative on error.
90  */
91 int
92 app_pipeline_vfw_delete_rule(struct app_params *app,
93                             struct pipeline_vfw_key *key);
94
95 /**
96  * Clear all VFW rules from the VFW rule table.
97  * Rules cleared from standby tables.
98  * Applyruleset command will activate the change.
99  * Both IPv4 and IPv6 rules will be cleared.
100  *
101  * @param app
102  *  A pointer to the VFW pipeline parameters.
103  *
104  * @return
105  *  0 on success, negative on error.
106  */
107 int app_pipeline_vfw_clearrules(struct app_params *app);
108
109 /**
110  * Add Action to the Action table.
111  * Actions are added standby table.
112  * Applyruleset command will activate the change.
113  *
114  * @param app
115  *  A pointer to the VFW pipeline parameters.
116  * @param key
117  *  A pointer to the Action to add.
118  *
119  * @return
120  *  0 on success, negative on error.
121  */
122 int
123 app_pipeline_action_add(struct app_params *app,
124                      struct pipeline_action_key *key);
125
126 /**
127  * Delete Action from the Action table.
128  * Actions are deleted from the standby table.
129  * Applyruleset command will activate the change.
130  *
131  * @param app
132  *  A pointer to the VFW pipeline parameters.
133  * @param key
134  *  A pointer to the Action to delete.
135  *
136  * @return
137  *  0 on success, negative on error.
138  */
139 int
140 app_pipeline_action_delete(struct app_params *app,
141                         struct pipeline_action_key *key);
142
143 extern struct pipeline_type pipeline_vfw;
144
145 #endif