2 // Copyright (c) 2017 Intel Corporation
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 __INCLUDE_PIPELINE_VFW_H__
18 #define __INCLUDE_PIPELINE_VFW_H__
24 * Pipeline VFW Front End (FE).
25 * Runs on the Master pipeline, responsible for CLI commands.
31 #include "pipeline_vfw_be.h"
34 #include <json-c/json.h>
36 /* VFW IPV4 and IPV6 enable flags for debugging (Default both on) */
37 extern int vfw_ipv4_enabled;
38 extern int vfw_ipv6_enabled;
40 /* Number of VFW Rules, default 4 * 1024 */
41 extern uint32_t vfw_n_rules;
42 /* VFW Rule Table TRIE - 2 (Active, Standby Global table per ipv4, ipv6 */
43 extern void *vfw_rule_table_ipv4_active;
44 extern void *vfw_rule_table_ipv4_standby;
45 extern void *vfw_rule_table_ipv6_active;
46 extern void *vfw_rule_table_ipv6_standby;
48 #define active_rule_table 0
49 #define standby_rule_table 1
50 #define vfw_add_command 0
51 #define vfw_delete_command 1
52 #define IPV6_32BIT_LENGTH 4
55 * Add VFW rule to the VFW rule table.
56 * Rules are added standby table.
57 * Applyruleset command will activate the change.
58 * Both IPv4 and IPv6 rules can be added.
61 * A pointer to the VFW pipeline parameters.
63 * A pointer to the VFW rule to add.
65 * Priority of the VFW rule.
67 * Port ID of the VFW rule.
69 * Action ID of the VFW rule. Defined in Action Table.
72 * 0 on success, negative on error.
75 app_pipeline_vfw_add_rule(struct app_params *app,
76 struct pipeline_vfw_key *key,
78 uint32_t port_id, uint32_t action_id);
81 * Delete VFW rule from the VFW rule table.
82 * Rules deleted from standby tables.
83 * Applyruleset command will activate the change.
84 * Both IPv4 and IPv6 rules can be deleted.
87 * A pointer to the VFW pipeline parameters.
89 * A pointer to the VFW rule to delete.
92 * 0 on success, negative on error.
95 app_pipeline_vfw_delete_rule(struct app_params *app,
96 struct pipeline_vfw_key *key);
99 * Clear all VFW rules from the VFW rule table.
100 * Rules cleared from standby tables.
101 * Applyruleset command will activate the change.
102 * Both IPv4 and IPv6 rules will be cleared.
105 * A pointer to the VFW pipeline parameters.
108 * 0 on success, negative on error.
110 int app_pipeline_vfw_clearrules(struct app_params *app);
113 * Add Action to the Action table.
114 * Actions are added standby table.
115 * Applyruleset command will activate the change.
118 * A pointer to the VFW pipeline parameters.
120 * A pointer to the Action to add.
123 * 0 on success, negative on error.
126 app_pipeline_action_add(struct app_params *app,
127 struct pipeline_action_key *key);
130 * Delete Action from the Action table.
131 * Actions are deleted from the standby table.
132 * Applyruleset command will activate the change.
135 * A pointer to the VFW pipeline parameters.
137 * A pointer to the Action to delete.
140 * 0 on success, negative on error.
143 app_pipeline_action_delete(struct app_params *app,
144 struct pipeline_action_key *key);
146 extern struct pipeline_type pipeline_vfw;
148 #ifdef REST_API_SUPPORT
149 /* REST Api's defined here */
150 int vfw_rules_handler(struct mg_connection *conn, void *cbdata);
151 int vfw_load_rules_handler(struct mg_connection *conn, void *cbdata);
152 int vfw_clearrules_handler(struct mg_connection *conn, void *cbdata);
153 int vfw_stats_handler(struct mg_connection *conn, void *cbdata);
154 int vfw_clearstats_handler(__rte_unused struct mg_connection *conn,
155 __rte_unused void *cbdata);
156 int vfw_cmd_ver_handler(struct mg_connection *conn, __rte_unused void *cbdata);
157 void rest_api_vfw_init(struct mg_context *ctx, struct app_params *app);