FD.io VPP  v17.04-9-g99c0734
Vector Packet Processing
mpls.h
Go to the documentation of this file.
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_vnet_mpls_h
16 #define included_vnet_mpls_h
17 
18 #include <vnet/vnet.h>
19 #include <vnet/mpls/packet.h>
20 #include <vnet/mpls/mpls_types.h>
21 #include <vnet/ip/ip4_packet.h>
22 #include <vnet/ethernet/ethernet.h>
23 #include <vnet/fib/fib_node.h>
24 #include <vnet/adj/adj.h>
25 
26 typedef enum {
27 #define mpls_error(n,s) MPLS_ERROR_##n,
28 #include <vnet/mpls/error.def>
29 #undef mpls_error
31 } mpls_error_t;
32 
33 #define MPLS_FIB_DEFAULT_TABLE_ID 0
34 
35 /**
36  * Type exposure is to allow the DP fast/inlined access
37  */
38 #define MPLS_FIB_KEY_SIZE 21
39 #define MPLS_FIB_DB_SIZE (1 << (MPLS_FIB_KEY_SIZE-1))
40 
41 typedef struct mpls_fib_t_
42 {
43  /**
44  * A hash table of entries. 21 bit key
45  * Hash table for reduced memory footprint
46  */
48 
49  /**
50  * The load-balance indeices keyed by 21 bit label+eos bit.
51  * A flat array for maximum lookup performace.
52  */
54 } mpls_fib_t;
55 
56 /**
57  * @brief Definition of a callback for receiving MPLS interface state change
58  * notifications
59  */
60 typedef void (*mpls_interface_state_change_callback_t)(u32 sw_if_index,
61  u32 is_enable);
62 
63 typedef struct {
64  /* MPLS FIB index for each software interface */
66 
67  /** A pool of all the MPLS FIBs */
68  struct fib_table_t_ *fibs;
69 
70  /** A hash table to lookup the mpls_fib by table ID */
72 
73  /* Feature arc indices */
76 
77  /* IP4 enabled count by software interface */
79 
80  /* convenience */
83 } mpls_main_t;
84 
85 extern mpls_main_t mpls_main;
86 
88 
93 
97 
98 /* Parse mpls protocol as 0xXXXX or protocol name.
99  In either host or network byte order. */
104 
105 /* Parse mpls header. */
108 
110  u32 sw_if_index,
111  u8 is_enable);
112 
113 u8 mpls_sw_interface_is_enabled (u32 sw_if_index);
114 
115 int mpls_fib_reset_labels (u32 fib_id);
116 
117 int
118 mpls_dest_cmp(void * a1, void * a2);
119 
120 int
121 mpls_fib_index_cmp(void * a1, void * a2);
122 
123 int
124 mpls_label_cmp(void * a1, void * a2);
125 
126 #endif /* included_vnet_mpls_h */
struct mpls_fib_t_ mpls_fib_t
uword( unformat_function_t)(unformat_input_t *input, va_list *args)
Definition: format.h:231
format_function_t format_mpls_header
Definition: mpls.h:92
u8 input_feature_arc_index
Definition: mpls.h:74
int mpls_label_cmp(void *a1, void *a2)
Definition: mpls.c:191
void mpls_sw_interface_enable_disable(mpls_main_t *mm, u32 sw_if_index, u8 is_enable)
Definition: interface.c:38
u32 * fib_index_by_sw_if_index
Definition: mpls.h:65
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
Definition: dpo.h:41
struct _vlib_node_registration vlib_node_registration_t
u8 *( format_function_t)(u8 *s, va_list *args)
Definition: format.h:48
unformat_function_t unformat_mpls_unicast_label
Definition: mpls.h:103
u8 * mpls_enabled_by_sw_if_index
Definition: mpls.h:78
format_function_t format_mpls_unicast_header_net_byte_order
Definition: mpls.h:90
void(* mpls_interface_state_change_callback_t)(u32 sw_if_index, u32 is_enable)
Definition of a callback for receiving MPLS interface state change notifications. ...
Definition: mpls.h:60
vlib_node_registration_t mpls_midchain_node
(constructor) VLIB_REGISTER_NODE (mpls_midchain_node)
Definition: mpls_output.c:358
u8 output_feature_arc_index
Definition: mpls.h:75
format_function_t format_mpls_eos_bit
Definition: mpls.h:89
mpls_error_t
Definition: mpls.h:26
int mpls_fib_reset_labels(u32 fib_id)
Definition: mpls.c:493
#define MPLS_FIB_DB_SIZE
Definition: mpls.h:39
vlib_node_registration_t mpls_input_node
(constructor) VLIB_REGISTER_NODE (mpls_input_node)
Definition: mpls_input.c:255
vnet_main_t * vnet_main
Definition: mpls.h:82
mpls_main_t mpls_main
Definition: mpls.c:25
struct fib_table_t_ * fibs
A pool of all the MPLS FIBs.
Definition: mpls.h:68
int mpls_fib_index_cmp(void *a1, void *a2)
Definition: mpls.c:182
unformat_function_t unformat_mpls_protocol_net_byte_order
Definition: mpls.h:101
vlib_main_t * vm
Definition: buffer.c:276
unformat_function_t unformat_mpls_header
Definition: mpls.h:106
unformat_function_t unformat_mpls_protocol_host_byte_order
Definition: mpls.h:100
unformat_function_t unformat_pg_mpls_header
Definition: mpls.h:107
clib_error_t * mpls_feature_init(vlib_main_t *vm)
uword * mf_entries
A hash table of entries.
Definition: mpls.h:47
unsigned int u32
Definition: types.h:88
u8 mpls_sw_interface_is_enabled(u32 sw_if_index)
Definition: interface.c:27
format_function_t format_mpls_unicast_label
Definition: mpls.h:91
u64 uword
Definition: types.h:112
unsigned char u8
Definition: types.h:56
vlib_main_t * vlib_main
Definition: mpls.h:81
unformat_function_t unformat_mpls_label_net_byte_order
Definition: mpls.h:102
index_t mf_lbs[MPLS_FIB_DB_SIZE]
The load-balance indeices keyed by 21 bit label+eos bit.
Definition: mpls.h:53
uword * fib_index_by_table_id
A hash table to lookup the mpls_fib by table ID.
Definition: mpls.h:71
vlib_node_registration_t mpls_output_node
(constructor) VLIB_REGISTER_NODE (mpls_output_node)
Definition: mpls_output.c:330
int mpls_dest_cmp(void *a1, void *a2)
Definition: mpls.c:173
A protocol Independent FIB table.
Definition: fib_table.h:29