blob: b7f7e3be93643d4ec742cd73376bbe074666153e [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#ifndef __included_l2_xcrw_h__
16#define __included_l2_xcrw_h__
17
18#include <vlib/vlib.h>
19#include <vnet/vnet.h>
Ed Warnickecb9cada2015-12-08 15:45:58 -070020#include <vppinfra/error.h>
21#include <vnet/ip/ip.h>
22#include <vnet/l2/l2_input.h>
23#include <vnet/l2/l2_output.h>
24#include <vnet/api_errno.h>
25#include <vnet/ethernet/ethernet.h>
26
Dave Barach97d8dc22016-08-15 15:31:15 -040027typedef struct
28{
29 /*
Ed Warnickecb9cada2015-12-08 15:45:58 -070030 * Let: rewrite_header.sw_if_index = tx_fib_index or ~0.
31 * rewrite_header.next_index = L2_XCRW_NEXT_XXX
32 */
Klement Sekera7dbf9a12019-11-21 10:31:03 +000033 VNET_DECLARE_REWRITE;
Ed Warnickecb9cada2015-12-08 15:45:58 -070034} l2_xcrw_adjacency_t;
35
Dave Barach97d8dc22016-08-15 15:31:15 -040036typedef struct
37{
Ed Warnickecb9cada2015-12-08 15:45:58 -070038 /* L2 interface */
39 u32 l2_sw_if_index;
40
41 /* Tunnel interface */
Dave Barach97d8dc22016-08-15 15:31:15 -040042 u32 tunnel_sw_if_index; /* This field remains set in freed pool elts */
Ed Warnickecb9cada2015-12-08 15:45:58 -070043
44} l2_xcrw_tunnel_t;
45
Dave Barach97d8dc22016-08-15 15:31:15 -040046typedef struct
47{
Ed Warnickecb9cada2015-12-08 15:45:58 -070048 u32 cached_next_index;
49
50 /* Vector of cross-connect rewrites */
Dave Barach97d8dc22016-08-15 15:31:15 -040051 l2_xcrw_adjacency_t *adj_by_sw_if_index;
Ed Warnickecb9cada2015-12-08 15:45:58 -070052
53 /* Pool of xcrw tunnels */
Dave Barach97d8dc22016-08-15 15:31:15 -040054 l2_xcrw_tunnel_t *tunnels;
Ed Warnickecb9cada2015-12-08 15:45:58 -070055
56 /* Tunnel index by tunnel sw_if_index */
Dave Barach97d8dc22016-08-15 15:31:15 -040057 uword *tunnel_index_by_l2_sw_if_index;
Ed Warnickecb9cada2015-12-08 15:45:58 -070058
59 /* convenience variables */
Dave Barach97d8dc22016-08-15 15:31:15 -040060 vlib_main_t *vlib_main;
61 vnet_main_t *vnet_main;
Ed Warnickecb9cada2015-12-08 15:45:58 -070062} l2_xcrw_main_t;
63
Dave Barach97d8dc22016-08-15 15:31:15 -040064typedef enum
65{
Ed Warnickecb9cada2015-12-08 15:45:58 -070066 L2_XCRW_NEXT_DROP,
67 L2_XCRW_N_NEXT,
68} l2_xcrw_next_t;
69
70#define foreach_l2_xcrw_error \
71_(DROP, "Packets dropped") \
72_(FWD, "Packets forwarded")
73
Dave Barach97d8dc22016-08-15 15:31:15 -040074typedef enum
75{
Ed Warnickecb9cada2015-12-08 15:45:58 -070076#define _(sym,str) L2_XCRW_ERROR_##sym,
77 foreach_l2_xcrw_error
78#undef _
Dave Barach97d8dc22016-08-15 15:31:15 -040079 L2_XCRW_N_ERROR,
Ed Warnickecb9cada2015-12-08 15:45:58 -070080} l2_xcrw_error_t;
81
Filip Tehlar44f0f712019-03-11 04:26:37 -070082extern vlib_node_registration_t l2_xcrw_node;
83
Ed Warnickecb9cada2015-12-08 15:45:58 -070084#endif /* __included_l2_xcrw_h__ */
Dave Barach97d8dc22016-08-15 15:31:15 -040085
86/*
87 * fd.io coding-style-patch-verification: ON
88 *
89 * Local Variables:
90 * eval: (c-set-style "gnu")
91 * End:
92 */