FD.io VPP  v19.04.2-12-g66b1689
Vector Packet Processing
dslite.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 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_dslite_h__
16 #define __included_dslite_h__
17 
18 #include <vppinfra/bihash_8_8.h>
19 #include <vppinfra/bihash_16_8.h>
20 #include <vppinfra/bihash_24_8.h>
21 #include <nat/nat.h>
22 
23 typedef struct
24 {
25  union
26  {
27  struct
28  {
34  };
35  u64 as_u64[3];
36  };
38 
39 /* *INDENT-OFF* */
40 typedef CLIB_PACKED (struct
41 {
42  snat_session_key_t out2in;
43  dslite_session_key_t in2out;
44  u32 per_b4_index;
45  u32 per_b4_list_head_index;
46  f64 last_heard;
47  u64 total_bytes;
48  u32 total_pkts;
49 }) dslite_session_t;
50 /* *INDENT-ON* */
51 
52 typedef struct
53 {
57 } dslite_b4_t;
58 
59 typedef struct
60 {
61  /* Main lookup tables */
62  clib_bihash_8_8_t out2in;
63  clib_bihash_24_8_t in2out;
64 
65  /* Find a B4 */
66  clib_bihash_16_8_t b4_hash;
67 
68  /* B4 pool */
70 
71  /* Session pool */
72  dslite_session_t *sessions;
73 
74  /* Pool of doubly-linked list elements */
77 
78 typedef struct
79 {
89 
90  /* counters/gauges */
93 
94  /* node index */
98 
99  /* If set then the DSLite component behaves as CPE/B4
100  * otherwise it behaves as AFTR */
102 } dslite_main_t;
103 
104 typedef struct
105 {
109 
110 typedef struct
111 {
114 
115 #define foreach_dslite_error \
116 _(IN2OUT, "valid in2out DS-Lite packets") \
117 _(OUT2IN, "valid out2in DS-Lite packets") \
118 _(CE_ENCAP, "valid CE encap DS-Lite packets") \
119 _(CE_DECAP, "valid CE decap DS-Lite packets") \
120 _(NO_TRANSLATION, "no translation") \
121 _(BAD_IP6_PROTOCOL, "bad ip6 protocol") \
122 _(OUT_OF_PORTS, "out of ports") \
123 _(UNSUPPORTED_PROTOCOL, "unsupported protocol") \
124 _(BAD_ICMP_TYPE, "unsupported icmp type") \
125 _(UNKNOWN, "unknown")
126 
127 typedef enum
128 {
129 #define _(sym,str) DSLITE_ERROR_##sym,
131 #undef _
134 
141 
142 void dslite_init (vlib_main_t * vm);
143 void dslite_set_ce (dslite_main_t * dm, u8 set);
149  u8 is_add);
150 u8 *format_dslite_trace (u8 * s, va_list * args);
151 u8 *format_dslite_ce_trace (u8 * s, va_list * args);
152 
153 #endif /* __included_dslite_h__ */
154 
155 /*
156  * fd.io coding-style-patch-verification: ON
157  *
158  * Local Variables:
159  * eval: (c-set-style "gnu")
160  * End:
161  */
int dslite_set_b4_ip6_addr(dslite_main_t *dm, ip6_address_t *addr)
Definition: dslite.c:143
u16 port_per_thread
Definition: dslite.h:88
u64 as_u64
Definition: bihash_doc.h:63
ip4_address_t aftr_ip4_addr
Definition: dslite.h:81
unsigned long u64
Definition: types.h:89
vlib_node_registration_t dslite_in2out_slowpath_node
(constructor) VLIB_REGISTER_NODE (dslite_in2out_slowpath_node)
int dslite_set_aftr_ip4_addr(dslite_main_t *dm, ip4_address_t *addr)
Definition: dslite.c:136
u32 session_index
Definition: dslite.h:107
clib_bihash_16_8_t b4_hash
Definition: dslite.h:66
vhost_vring_addr_t addr
Definition: vhost_user.h:121
unsigned char u8
Definition: types.h:56
double f64
Definition: types.h:142
void dslite_init(vlib_main_t *vm)
Definition: dslite.c:22
u32 first_worker_index
Definition: dslite.h:87
u8 * format_dslite_trace(u8 *s, va_list *args)
Definition: dslite.c:241
ip6_address_t b4_ip6_addr
Definition: dslite.h:82
ip6_address_t addr
Definition: dslite.h:54
u32 num_workers
Definition: dslite.h:86
unsigned int u32
Definition: types.h:88
A collection of simple counters.
Definition: counter.h:57
dlist_elt_t * list_pool
Definition: dslite.h:75
void dslite_set_ce(dslite_main_t *dm, u8 set)
Definition: dslite.c:94
clib_bihash_8_8_t out2in
Definition: dslite.h:62
vlib_node_registration_t dslite_out2in_node
(constructor) VLIB_REGISTER_NODE (dslite_out2in_node)
u32 dslite_in2out_slowpath_node_index
Definition: dslite.h:96
unsigned short u16
Definition: types.h:57
snat_address_t * addr_pool
Definition: dslite.h:85
int dslite_set_aftr_ip6_addr(dslite_main_t *dm, ip6_address_t *addr)
Definition: dslite.c:100
ip6_address_t aftr_ip6_addr
Definition: dslite.h:80
vlib_main_t * vm
Definition: buffer.c:312
ip4_address_t b4_ip4_addr
Definition: dslite.h:83
typedef CLIB_PACKED(struct{snat_session_key_t out2in;dslite_session_key_t in2out;u32 per_b4_index;u32 per_b4_list_head_index;f64 last_heard;u64 total_bytes;u32 total_pkts;}) dslite_session_t
vlib_node_registration_t dslite_ce_encap_node
(constructor) VLIB_REGISTER_NODE (dslite_ce_encap_node)
u32 nsessions
Definition: dslite.h:56
u8 * format_dslite_ce_trace(u8 *s, va_list *args)
Definition: dslite.c:254
u8 is_add
Definition: ipsec_gre.api:36
int dslite_add_del_pool_addr(dslite_main_t *dm, ip4_address_t *addr, u8 is_add)
Definition: dslite.c:188
vlib_simple_counter_main_t total_b4s
Definition: dslite.h:91
int dslite_set_b4_ip4_addr(dslite_main_t *dm, ip4_address_t *addr)
Definition: dslite.c:173
dslite_b4_t * b4s
Definition: dslite.h:69
dslite_per_thread_data_t * per_thread_data
Definition: dslite.h:84
struct _vlib_node_registration vlib_node_registration_t
u32 next_index
Definition: dslite.h:106
dslite_error_t
Definition: dslite.h:127
vlib_simple_counter_main_t total_sessions
Definition: dslite.h:92
dslite_main_t dslite_main
Definition: dslite.c:19
ip6_address_t softwire_id
Definition: dslite.h:29
dslite_session_t * sessions
Definition: dslite.h:72
#define foreach_dslite_error
Definition: dslite.h:115
clib_bihash_24_8_t in2out
Definition: dslite.h:63
u32 dslite_out2in_node_index
Definition: dslite.h:97
u32 sessions_per_b4_list_head_index
Definition: dslite.h:55
vlib_node_registration_t dslite_in2out_node
(constructor) VLIB_REGISTER_NODE (dslite_in2out_node)
u32 dslite_in2out_node_index
Definition: dslite.h:95
ip4_address_t addr
Definition: dslite.h:30
vlib_node_registration_t dslite_ce_decap_node
(constructor) VLIB_REGISTER_NODE (dslite_ce_decap_node)