blob: 201f5e195a4c2b765a51d3e452f8f1cedee8df88 [file] [log] [blame]
Ed Warnickecb9cada2015-12-08 15:45:58 -07001/*
2 * l2_output.h : layer 2 output packet processing
3 *
4 * Copyright (c) 2013 Cisco and/or its affiliates.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef included_vnet_l2_output_h
19#define included_vnet_l2_output_h
20
21#include <vlib/vlib.h>
22#include <vnet/vnet.h>
23#include <vnet/l2/feat_bitmap.h>
24#include <vnet/l2/l2_vtr.h>
25
26
Dave Barach97d8dc22016-08-15 15:31:15 -040027/* The L2 output feature configuration, a per-interface struct */
28typedef struct
29{
Ed Warnickecb9cada2015-12-08 15:45:58 -070030
Dave Barach97d8dc22016-08-15 15:31:15 -040031 /*
32 * vlan tag rewrite for ingress and egress
33 * ingress vtr is located here because the same config data is used for
34 * the egress EFP filter check
35 */
Ed Warnickecb9cada2015-12-08 15:45:58 -070036 vtr_config_t input_vtr;
37 vtr_config_t output_vtr;
Pavel Kotucek95300d12016-08-26 16:11:36 +020038 ptr_config_t input_pbb_vtr;
39 ptr_config_t output_pbb_vtr;
Ed Warnickecb9cada2015-12-08 15:45:58 -070040
Eyal Bari78cfeb42018-08-22 17:02:46 +030041 u32 feature_bitmap;
Ed Warnickecb9cada2015-12-08 15:45:58 -070042
Dave Barach97d8dc22016-08-15 15:31:15 -040043 /* split horizon group */
44 u8 shg;
Ed Warnickecb9cada2015-12-08 15:45:58 -070045
Pavel Kotucek95300d12016-08-26 16:11:36 +020046 /* flag for output vtr operation */
47 u8 out_vtr_flag;
48
Ed Warnickecb9cada2015-12-08 15:45:58 -070049} l2_output_config_t;
50
Dave Barach97d8dc22016-08-15 15:31:15 -040051typedef struct
52{
53 /*
54 * vector of output next node index, indexed by sw_if_index.
55 * used when all output features have been executed and the
56 * next nodes are the interface output nodes.
57 */
58 u32 *output_node_index_vec;
Ed Warnickecb9cada2015-12-08 15:45:58 -070059
Dave Barach97d8dc22016-08-15 15:31:15 -040060 /*
61 * array of next node index for each output feature, indexed
62 * by l2output_feat_t. Used to determine next feature node.
63 */
John Lobeb0b2e2017-07-22 00:21:36 -040064 u32 l2_out_feat_next[32];
Ed Warnickecb9cada2015-12-08 15:45:58 -070065
66 /* config vector indexed by sw_if_index */
67 l2_output_config_t *configs;
68
69 /* Convenience variables */
Dave Barach97d8dc22016-08-15 15:31:15 -040070 vlib_main_t *vlib_main;
71 vnet_main_t *vnet_main;
Ed Warnickecb9cada2015-12-08 15:45:58 -070072} l2output_main_t;
73
Dave Wallace71612d62017-10-24 01:32:41 -040074extern l2output_main_t l2output_main;
Ed Warnickecb9cada2015-12-08 15:45:58 -070075
Eyal Bari001fd402017-07-16 09:34:53 +030076extern vlib_node_registration_t l2output_node;
77
Dave Barach97d8dc22016-08-15 15:31:15 -040078/* L2 output features */
Ed Warnickecb9cada2015-12-08 15:45:58 -070079
Eyal Bari001fd402017-07-16 09:34:53 +030080/* Mappings from feature ID to graph node name in reverse order */
Ed Warnickecb9cada2015-12-08 15:45:58 -070081#define foreach_l2output_feat \
Andrew Yourtchenkocc405652017-03-03 13:11:30 +000082 _(OUTPUT, "interface-output") \
Eyal Bari001fd402017-07-16 09:34:53 +030083 _(SPAN, "span-l2-output") \
Ed Warnickecb9cada2015-12-08 15:45:58 -070084 _(CFM, "feature-bitmap-drop") \
85 _(QOS, "feature-bitmap-drop") \
86 _(ACL, "l2-output-acl") \
87 _(L2PT, "feature-bitmap-drop") \
88 _(EFP_FILTER, "l2-efp-filter") \
89 _(IPIW, "feature-bitmap-drop") \
90 _(STP_BLOCKED, "feature-bitmap-drop") \
91 _(LINESTATUS_DOWN, "feature-bitmap-drop") \
Dave Barachb84a3e52016-08-30 17:01:52 -040092 _(OUTPUT_CLASSIFY, "l2-output-classify") \
Andrew Yourtchenkoa23cade2018-10-06 09:18:00 +020093 _(OUTPUT_FEAT_ARC, "l2-output-feat-arc") \
Ed Warnickecb9cada2015-12-08 15:45:58 -070094 _(XCRW, "l2-xcrw")
95
Dave Barach97d8dc22016-08-15 15:31:15 -040096/* Feature bitmap positions */
97typedef enum
98{
Ed Warnickecb9cada2015-12-08 15:45:58 -070099#define _(sym,str) L2OUTPUT_FEAT_##sym##_BIT,
100 foreach_l2output_feat
101#undef _
Dave Barach97d8dc22016-08-15 15:31:15 -0400102 L2OUTPUT_N_FEAT,
Ed Warnickecb9cada2015-12-08 15:45:58 -0700103} l2output_feat_t;
104
Eyal Bari001fd402017-07-16 09:34:53 +0300105STATIC_ASSERT (L2OUTPUT_N_FEAT <= 32, "too many l2 output features");
106
Dave Barach97d8dc22016-08-15 15:31:15 -0400107/* Feature bit masks */
108typedef enum
109{
Neale Rannsa1179582018-10-24 02:31:51 -0700110 L2OUTPUT_FEAT_NONE = 0,
Ed Warnickecb9cada2015-12-08 15:45:58 -0700111#define _(sym,str) L2OUTPUT_FEAT_##sym = (1<<L2OUTPUT_FEAT_##sym##_BIT),
112 foreach_l2output_feat
113#undef _
114} l2output_feat_masks_t;
Dave Barach97d8dc22016-08-15 15:31:15 -0400115
John Lo3ef822e2016-06-07 09:14:07 -0400116#define foreach_l2output_error \
117_(L2OUTPUT, "L2 output packets") \
118_(EFP_DROP, "L2 EFP filter pre-rewrite drops") \
119_(VTR_DROP, "L2 output tag rewrite drops") \
120_(SHG_DROP, "L2 split horizon drops") \
Damjan Marionb1136582016-09-22 16:37:29 +0200121_(DROP, "L2 output drops") \
John Lob2fd6cb2017-07-12 19:56:45 -0400122_(MAPPING_DROP, "L2 Output interface not valid")
John Lo3ef822e2016-06-07 09:14:07 -0400123
Dave Barach97d8dc22016-08-15 15:31:15 -0400124typedef enum
125{
John Lo3ef822e2016-06-07 09:14:07 -0400126 L2OUTPUT_NEXT_DROP,
John Lo0fc9bc12016-10-27 11:17:02 -0400127 L2OUTPUT_NEXT_BAD_INTF,
John Lo3ef822e2016-06-07 09:14:07 -0400128 L2OUTPUT_N_NEXT,
129} l2output_next_t;
130
Dave Barach97d8dc22016-08-15 15:31:15 -0400131typedef enum
132{
John Lo3ef822e2016-06-07 09:14:07 -0400133#define _(sym,str) L2OUTPUT_ERROR_##sym,
134 foreach_l2output_error
135#undef _
Dave Barach97d8dc22016-08-15 15:31:15 -0400136 L2OUTPUT_N_ERROR,
John Lo3ef822e2016-06-07 09:14:07 -0400137} l2output_error_t;
138
Dave Barach97d8dc22016-08-15 15:31:15 -0400139/* Return an array of strings containing graph node names of each feature */
140char **l2output_get_feat_names (void);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700141
Neale Ranns5d9df1d2018-11-09 08:19:27 -0800142/* arg0 - u32 feature_bitmap, arg1 - u32 verbose */
Eyal Bari942402b2017-07-26 11:57:04 +0300143u8 *format_l2_output_features (u8 * s, va_list * args);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700144
Dave Barach97d8dc22016-08-15 15:31:15 -0400145/**
146 * The next set of functions is for use by output feature graph nodes.
147 * When the last bit has been cleared from the output feature bitmap,
148 * the next node is the output graph node for the TX sw_if_index.
149 * These functions help the feature nodes get that node index.
150 */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700151
Dave Barach97d8dc22016-08-15 15:31:15 -0400152/* Create a mapping to the output graph node for the given sw_if_index */
John Lob2fd6cb2017-07-12 19:56:45 -0400153void l2output_create_output_node_mapping (vlib_main_t * vlib_main,
154 vnet_main_t * vnet_main,
155 u32 sw_if_index);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700156
Dave Barach97d8dc22016-08-15 15:31:15 -0400157/** Get a pointer to the config for the given interface */
158l2_output_config_t *l2output_intf_config (u32 sw_if_index);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700159
Dave Barach97d8dc22016-08-15 15:31:15 -0400160/** Enable (or disable) the feature in the bitmap for the given interface */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700161void l2output_intf_bitmap_enable (u32 sw_if_index,
Neale Rannsa1179582018-10-24 02:31:51 -0700162 l2output_feat_masks_t feature_bitmap,
163 u32 enable);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700164
165#endif
Dave Barach97d8dc22016-08-15 15:31:15 -0400166
167/*
168 * fd.io coding-style-patch-verification: ON
169 *
170 * Local Variables:
171 * eval: (c-set-style "gnu")
172 * End:
173 */