blob: 184187ff8797bb36eff46c67f1756cc36f87e478 [file] [log] [blame]
Ed Warnickecb9cada2015-12-08 15:45:58 -07001/*
2 * Copyright (c) 2015 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
Dave Barachb84a3e52016-08-30 17:01:52 -040016#ifndef __included_vnet_l2_input_classify_h__
17#define __included_vnet_l2_input_classify_h__
Ed Warnickecb9cada2015-12-08 15:45:58 -070018
19#include <vlib/vlib.h>
20#include <vnet/vnet.h>
21#include <vnet/pg/pg.h>
22#include <vnet/ethernet/ethernet.h>
23#include <vnet/ethernet/packet.h>
24#include <vnet/ip/ip_packet.h>
25#include <vnet/ip/ip4_packet.h>
26#include <vnet/ip/ip6_packet.h>
27#include <vlib/cli.h>
28#include <vnet/l2/l2_input.h>
Dave Barachb84a3e52016-08-30 17:01:52 -040029#include <vnet/l2/l2_output.h>
Ed Warnickecb9cada2015-12-08 15:45:58 -070030#include <vnet/l2/feat_bitmap.h>
31#include <vppinfra/error.h>
32#include <vppinfra/hash.h>
33#include <vppinfra/cache.h>
34
35#include <vnet/classify/vnet_classify.h>
36
Dave Barach97d8dc22016-08-15 15:31:15 -040037typedef enum
38{
Dave Barachb84a3e52016-08-30 17:01:52 -040039 L2_INPUT_CLASSIFY_NEXT_DROP,
40 L2_INPUT_CLASSIFY_NEXT_ETHERNET_INPUT,
41 L2_INPUT_CLASSIFY_NEXT_IP4_INPUT,
42 L2_INPUT_CLASSIFY_NEXT_IP6_INPUT,
43 L2_INPUT_CLASSIFY_NEXT_LI,
44 L2_INPUT_CLASSIFY_N_NEXT,
45} l2_input_classify_next_t;
Ed Warnickecb9cada2015-12-08 15:45:58 -070046
Dave Barach97d8dc22016-08-15 15:31:15 -040047typedef enum
48{
Dave Barachb84a3e52016-08-30 17:01:52 -040049 L2_INPUT_CLASSIFY_TABLE_IP4,
50 L2_INPUT_CLASSIFY_TABLE_IP6,
51 L2_INPUT_CLASSIFY_TABLE_OTHER,
52 L2_INPUT_CLASSIFY_N_TABLES,
53} l2_input_classify_table_id_t;
Ed Warnickecb9cada2015-12-08 15:45:58 -070054
Dave Barachb84a3e52016-08-30 17:01:52 -040055typedef enum
Dave Barach97d8dc22016-08-15 15:31:15 -040056{
Dave Barachb84a3e52016-08-30 17:01:52 -040057 L2_OUTPUT_CLASSIFY_NEXT_DROP,
58 L2_OUTPUT_CLASSIFY_N_NEXT,
59} l2_output_classify_next_t;
Ed Warnickecb9cada2015-12-08 15:45:58 -070060
Dave Barachb84a3e52016-08-30 17:01:52 -040061typedef enum
62{
63 L2_OUTPUT_CLASSIFY_TABLE_IP4,
64 L2_OUTPUT_CLASSIFY_TABLE_IP6,
65 L2_OUTPUT_CLASSIFY_TABLE_OTHER,
66 L2_OUTPUT_CLASSIFY_N_TABLES,
67} l2_output_classify_table_id_t;
68
69typedef struct _l2_classify_main
70{
Dave Barach97d8dc22016-08-15 15:31:15 -040071 /* Next nodes for each feature */
Ed Warnickecb9cada2015-12-08 15:45:58 -070072 u32 feat_next_node_index[32];
73
74 /* Per-address-family classifier table vectors */
Dave Barachb84a3e52016-08-30 17:01:52 -040075 u32 *classify_table_index_by_sw_if_index[L2_INPUT_CLASSIFY_N_TABLES];
76
77 /* Next nodes for features and output interfaces */
78 l2_output_next_nodes_st next_nodes;
Ed Warnickecb9cada2015-12-08 15:45:58 -070079
80 /* convenience variables */
Dave Barach97d8dc22016-08-15 15:31:15 -040081 vlib_main_t *vlib_main;
82 vnet_main_t *vnet_main;
83 vnet_classify_main_t *vnet_classify_main;
Dave Barachb84a3e52016-08-30 17:01:52 -040084} l2_input_classify_main_t;
Ed Warnickecb9cada2015-12-08 15:45:58 -070085
Dave Barachb84a3e52016-08-30 17:01:52 -040086typedef struct _l2_classify_main l2_output_classify_main_t;
Ed Warnickecb9cada2015-12-08 15:45:58 -070087
Dave Barachb84a3e52016-08-30 17:01:52 -040088extern l2_input_classify_main_t l2_input_classify_main;
89extern vlib_node_registration_t l2_input_classify_node;
Ed Warnickecb9cada2015-12-08 15:45:58 -070090
Dave Barachb84a3e52016-08-30 17:01:52 -040091extern l2_output_classify_main_t l2_output_classify_main;
92extern vlib_node_registration_t l2_output_classify_node;
Ed Warnickecb9cada2015-12-08 15:45:58 -070093
Dave Barachb84a3e52016-08-30 17:01:52 -040094void vnet_l2_input_classify_enable_disable (u32 sw_if_index,
95 int enable_disable);
Ed Warnickecb9cada2015-12-08 15:45:58 -070096
Dave Barachb84a3e52016-08-30 17:01:52 -040097int vnet_l2_input_classify_set_tables (u32 sw_if_index, u32 ip4_table_index,
98 u32 ip6_table_index,
99 u32 other_table_index);
100
101void vnet_l2_output_classify_enable_disable (u32 sw_if_index,
102 int enable_disable);
103
104int vnet_l2_output_classify_set_tables (u32 sw_if_index, u32 ip4_table_index,
105 u32 ip6_table_index,
106 u32 other_table_index);
107
108#endif /* __included_vnet_l2_input_classify_h__ */
Dave Barach97d8dc22016-08-15 15:31:15 -0400109
110/*
111 * fd.io coding-style-patch-verification: ON
112 *
113 * Local Variables:
114 * eval: (c-set-style "gnu")
115 * End:
116 */