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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
15 #ifndef included_vnet_nsh_h
16 #define included_vnet_nsh_h
18 #include <vnet/vnet.h>
19 #include <vnet/nsh/nsh_packet.h>
20 #include <vnet/ip/ip4_packet.h>
24 /** Key for nsh_header_t entry: 24bit NSP 8bit NSI */
27 /** Key for nsh_header_t entry to map to. : 24bit NSP 8bit NSI
28 * This may be ~0 if next action is to decap to NSH next protocol
29 * Note the following heuristic:
30 * if nsp_nsi == mapped_nsp_nsi then use-case is like SFC SFF
31 * if nsp_nsi != mapped_nsp_nsi then use-case is like SFC SF
32 * Note: these are heuristics. Rules about NSI decrement are out of scope
36 /* vnet intfc sw_if_index */
46 } vnet_nsh_add_del_map_args_t;
51 } vnet_nsh_add_del_entry_args_t;
54 /* vector of nsh_header entry instances */
55 nsh_header_t *nsh_entries;
57 /* hash lookup nsh header by key: {u32: nsp_nsi} */
58 uword * nsh_entry_by_key;
60 /* vector of nsh_mappings */
61 nsh_map_t *nsh_mappings;
63 /* hash lookup nsh mapping by key: {u32: nsp_nsi} */
64 uword * nsh_mapping_by_key;
65 uword * nsh_mapping_by_mapped_key; // for use in NSHSFC
68 vlib_main_t * vlib_main;
69 vnet_main_t * vnet_main;
74 u8 * format_nsh_input_map_trace (u8 * s, va_list * args);
75 u8 * format_nsh_header_with_length (u8 * s, va_list * args);
77 /* Statistics (not really errors) */
78 #define foreach_nsh_input_error \
79 _(MAPPED, "NSH header found and mapped") \
80 _(NO_MAPPING, "no mapping for nsh key") \
81 _(INVALID_NEXT_PROTOCOL, "invalid next protocol") \
84 #define _(sym,str) NSH_INPUT_ERROR_##sym,
85 foreach_nsh_input_error
91 #define foreach_nsh_input_next \
92 _(DROP, "error-drop") \
93 _(ENCAP_GRE, "gre-input" ) \
94 _(ENCAP_VXLANGPE, "vxlan-gpe-encap" ) \
95 /* /\* TODO once moved to Project:NSH_SFC *\/ */
96 /* _(ENCAP_ETHERNET, "*** TX TO ETHERNET ***") \ */
97 /* _(DECAP_ETHERNET_LOOKUP, "ethernet-input" ) \ */
98 /* _(DECAP_IP4_INPUT, "ip4-input") \ */
99 /* _(DECAP_IP6_INPUT, "ip6-input" ) \ */
102 #define _(s,n) NSH_INPUT_NEXT_##s,
103 foreach_nsh_input_next
108 #endif /* included_vnet_nsh_h */