Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1 | /* |
| 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 | #ifndef __included_l2_xcrw_h__ |
| 16 | #define __included_l2_xcrw_h__ |
| 17 | |
| 18 | #include <vlib/vlib.h> |
| 19 | #include <vnet/vnet.h> |
| 20 | #include <vnet/pg/pg.h> |
| 21 | #include <vppinfra/error.h> |
| 22 | #include <vnet/ip/ip.h> |
| 23 | #include <vnet/l2/l2_input.h> |
| 24 | #include <vnet/l2/l2_output.h> |
| 25 | #include <vnet/api_errno.h> |
| 26 | #include <vnet/ethernet/ethernet.h> |
| 27 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 28 | typedef struct |
| 29 | { |
| 30 | /* |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 31 | * Let: rewrite_header.sw_if_index = tx_fib_index or ~0. |
| 32 | * rewrite_header.next_index = L2_XCRW_NEXT_XXX |
| 33 | */ |
Klement Sekera | 7dbf9a1 | 2019-11-21 10:31:03 +0000 | [diff] [blame^] | 34 | VNET_DECLARE_REWRITE; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 35 | } l2_xcrw_adjacency_t; |
| 36 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 37 | typedef struct |
| 38 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 39 | /* L2 interface */ |
| 40 | u32 l2_sw_if_index; |
| 41 | |
| 42 | /* Tunnel interface */ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 43 | u32 tunnel_sw_if_index; /* This field remains set in freed pool elts */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 44 | |
| 45 | } l2_xcrw_tunnel_t; |
| 46 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 47 | typedef struct |
| 48 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 49 | u32 cached_next_index; |
| 50 | |
| 51 | /* Vector of cross-connect rewrites */ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 52 | l2_xcrw_adjacency_t *adj_by_sw_if_index; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 53 | |
| 54 | /* Pool of xcrw tunnels */ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 55 | l2_xcrw_tunnel_t *tunnels; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 56 | |
| 57 | /* Tunnel index by tunnel sw_if_index */ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 58 | uword *tunnel_index_by_l2_sw_if_index; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 59 | |
| 60 | /* convenience variables */ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 61 | vlib_main_t *vlib_main; |
| 62 | vnet_main_t *vnet_main; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 63 | } l2_xcrw_main_t; |
| 64 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 65 | typedef enum |
| 66 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 67 | L2_XCRW_NEXT_DROP, |
| 68 | L2_XCRW_N_NEXT, |
| 69 | } l2_xcrw_next_t; |
| 70 | |
| 71 | #define foreach_l2_xcrw_error \ |
| 72 | _(DROP, "Packets dropped") \ |
| 73 | _(FWD, "Packets forwarded") |
| 74 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 75 | typedef enum |
| 76 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 77 | #define _(sym,str) L2_XCRW_ERROR_##sym, |
| 78 | foreach_l2_xcrw_error |
| 79 | #undef _ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 80 | L2_XCRW_N_ERROR, |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 81 | } l2_xcrw_error_t; |
| 82 | |
Filip Tehlar | 44f0f71 | 2019-03-11 04:26:37 -0700 | [diff] [blame] | 83 | extern vlib_node_registration_t l2_xcrw_node; |
| 84 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 85 | #endif /* __included_l2_xcrw_h__ */ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 86 | |
| 87 | /* |
| 88 | * fd.io coding-style-patch-verification: ON |
| 89 | * |
| 90 | * Local Variables: |
| 91 | * eval: (c-set-style "gnu") |
| 92 | * End: |
| 93 | */ |