Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1 | /* |
| 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 Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 27 | /* The L2 output feature configuration, a per-interface struct */ |
| 28 | typedef struct |
| 29 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 30 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 31 | /* |
| 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 Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 36 | vtr_config_t input_vtr; |
| 37 | vtr_config_t output_vtr; |
Pavel Kotucek | 95300d1 | 2016-08-26 16:11:36 +0200 | [diff] [blame] | 38 | ptr_config_t input_pbb_vtr; |
| 39 | ptr_config_t output_pbb_vtr; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 40 | |
Eyal Bari | 78cfeb4 | 2018-08-22 17:02:46 +0300 | [diff] [blame] | 41 | u32 feature_bitmap; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 42 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 43 | /* split horizon group */ |
| 44 | u8 shg; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 45 | |
Pavel Kotucek | 95300d1 | 2016-08-26 16:11:36 +0200 | [diff] [blame] | 46 | /* flag for output vtr operation */ |
| 47 | u8 out_vtr_flag; |
| 48 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 49 | } l2_output_config_t; |
| 50 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 51 | typedef 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 Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 59 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 60 | /* |
| 61 | * array of next node index for each output feature, indexed |
| 62 | * by l2output_feat_t. Used to determine next feature node. |
| 63 | */ |
John Lo | beb0b2e | 2017-07-22 00:21:36 -0400 | [diff] [blame] | 64 | u32 l2_out_feat_next[32]; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 65 | |
| 66 | /* config vector indexed by sw_if_index */ |
| 67 | l2_output_config_t *configs; |
| 68 | |
| 69 | /* Convenience variables */ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 70 | vlib_main_t *vlib_main; |
| 71 | vnet_main_t *vnet_main; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 72 | } l2output_main_t; |
| 73 | |
Dave Wallace | 71612d6 | 2017-10-24 01:32:41 -0400 | [diff] [blame] | 74 | extern l2output_main_t l2output_main; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 75 | |
Eyal Bari | 001fd40 | 2017-07-16 09:34:53 +0300 | [diff] [blame] | 76 | extern vlib_node_registration_t l2output_node; |
| 77 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 78 | /* L2 output features */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 79 | |
Eyal Bari | 001fd40 | 2017-07-16 09:34:53 +0300 | [diff] [blame] | 80 | /* Mappings from feature ID to graph node name in reverse order */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 81 | #define foreach_l2output_feat \ |
Andrew Yourtchenko | cc40565 | 2017-03-03 13:11:30 +0000 | [diff] [blame] | 82 | _(OUTPUT, "interface-output") \ |
Eyal Bari | 001fd40 | 2017-07-16 09:34:53 +0300 | [diff] [blame] | 83 | _(SPAN, "span-l2-output") \ |
Neale Ranns | 25b0494 | 2018-04-04 09:34:50 -0700 | [diff] [blame] | 84 | _(GBP_POLICY, "gbp-policy") \ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 85 | _(CFM, "feature-bitmap-drop") \ |
| 86 | _(QOS, "feature-bitmap-drop") \ |
| 87 | _(ACL, "l2-output-acl") \ |
| 88 | _(L2PT, "feature-bitmap-drop") \ |
| 89 | _(EFP_FILTER, "l2-efp-filter") \ |
| 90 | _(IPIW, "feature-bitmap-drop") \ |
| 91 | _(STP_BLOCKED, "feature-bitmap-drop") \ |
| 92 | _(LINESTATUS_DOWN, "feature-bitmap-drop") \ |
Dave Barach | b84a3e5 | 2016-08-30 17:01:52 -0400 | [diff] [blame] | 93 | _(OUTPUT_CLASSIFY, "l2-output-classify") \ |
Andrew Yourtchenko | a23cade | 2018-10-06 09:18:00 +0200 | [diff] [blame] | 94 | _(OUTPUT_FEAT_ARC, "l2-output-feat-arc") \ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 95 | _(XCRW, "l2-xcrw") |
| 96 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 97 | /* Feature bitmap positions */ |
| 98 | typedef enum |
| 99 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 100 | #define _(sym,str) L2OUTPUT_FEAT_##sym##_BIT, |
| 101 | foreach_l2output_feat |
| 102 | #undef _ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 103 | L2OUTPUT_N_FEAT, |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 104 | } l2output_feat_t; |
| 105 | |
Eyal Bari | 001fd40 | 2017-07-16 09:34:53 +0300 | [diff] [blame] | 106 | STATIC_ASSERT (L2OUTPUT_N_FEAT <= 32, "too many l2 output features"); |
| 107 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 108 | /* Feature bit masks */ |
| 109 | typedef enum |
| 110 | { |
Neale Ranns | a117958 | 2018-10-24 02:31:51 -0700 | [diff] [blame] | 111 | L2OUTPUT_FEAT_NONE = 0, |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 112 | #define _(sym,str) L2OUTPUT_FEAT_##sym = (1<<L2OUTPUT_FEAT_##sym##_BIT), |
| 113 | foreach_l2output_feat |
| 114 | #undef _ |
| 115 | } l2output_feat_masks_t; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 116 | |
John Lo | 3ef822e | 2016-06-07 09:14:07 -0400 | [diff] [blame] | 117 | #define foreach_l2output_error \ |
| 118 | _(L2OUTPUT, "L2 output packets") \ |
| 119 | _(EFP_DROP, "L2 EFP filter pre-rewrite drops") \ |
| 120 | _(VTR_DROP, "L2 output tag rewrite drops") \ |
| 121 | _(SHG_DROP, "L2 split horizon drops") \ |
Damjan Marion | b113658 | 2016-09-22 16:37:29 +0200 | [diff] [blame] | 122 | _(DROP, "L2 output drops") \ |
John Lo | b2fd6cb | 2017-07-12 19:56:45 -0400 | [diff] [blame] | 123 | _(MAPPING_DROP, "L2 Output interface not valid") |
John Lo | 3ef822e | 2016-06-07 09:14:07 -0400 | [diff] [blame] | 124 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 125 | typedef enum |
| 126 | { |
John Lo | 3ef822e | 2016-06-07 09:14:07 -0400 | [diff] [blame] | 127 | L2OUTPUT_NEXT_DROP, |
John Lo | 0fc9bc1 | 2016-10-27 11:17:02 -0400 | [diff] [blame] | 128 | L2OUTPUT_NEXT_BAD_INTF, |
John Lo | 3ef822e | 2016-06-07 09:14:07 -0400 | [diff] [blame] | 129 | L2OUTPUT_N_NEXT, |
| 130 | } l2output_next_t; |
| 131 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 132 | typedef enum |
| 133 | { |
John Lo | 3ef822e | 2016-06-07 09:14:07 -0400 | [diff] [blame] | 134 | #define _(sym,str) L2OUTPUT_ERROR_##sym, |
| 135 | foreach_l2output_error |
| 136 | #undef _ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 137 | L2OUTPUT_N_ERROR, |
John Lo | 3ef822e | 2016-06-07 09:14:07 -0400 | [diff] [blame] | 138 | } l2output_error_t; |
| 139 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 140 | /* Return an array of strings containing graph node names of each feature */ |
| 141 | char **l2output_get_feat_names (void); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 142 | |
Eyal Bari | 942402b | 2017-07-26 11:57:04 +0300 | [diff] [blame] | 143 | /* arg0 - u32 feature_bitmap */ |
| 144 | u8 *format_l2_output_features (u8 * s, va_list * args); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 145 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 146 | /** |
| 147 | * The next set of functions is for use by output feature graph nodes. |
| 148 | * When the last bit has been cleared from the output feature bitmap, |
| 149 | * the next node is the output graph node for the TX sw_if_index. |
| 150 | * These functions help the feature nodes get that node index. |
| 151 | */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 152 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 153 | /* Create a mapping to the output graph node for the given sw_if_index */ |
John Lo | b2fd6cb | 2017-07-12 19:56:45 -0400 | [diff] [blame] | 154 | void l2output_create_output_node_mapping (vlib_main_t * vlib_main, |
| 155 | vnet_main_t * vnet_main, |
| 156 | u32 sw_if_index); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 157 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 158 | /** Get a pointer to the config for the given interface */ |
| 159 | l2_output_config_t *l2output_intf_config (u32 sw_if_index); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 160 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 161 | /** Enable (or disable) the feature in the bitmap for the given interface */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 162 | void l2output_intf_bitmap_enable (u32 sw_if_index, |
Neale Ranns | a117958 | 2018-10-24 02:31:51 -0700 | [diff] [blame] | 163 | l2output_feat_masks_t feature_bitmap, |
| 164 | u32 enable); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 165 | |
| 166 | #endif |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 167 | |
| 168 | /* |
| 169 | * fd.io coding-style-patch-verification: ON |
| 170 | * |
| 171 | * Local Variables: |
| 172 | * eval: (c-set-style "gnu") |
| 173 | * End: |
| 174 | */ |