Remove historical artifacts from vnet/buffer.h
[vpp.git] / vnet / vnet / buffer.h
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 /*
16  * vnet/buffer.h: vnet buffer flags
17  *
18  * Copyright (c) 2008 Eliot Dresselhaus
19  *
20  * Permission is hereby granted, free of charge, to any person obtaining
21  * a copy of this software and associated documentation files (the
22  * "Software"), to deal in the Software without restriction, including
23  * without limitation the rights to use, copy, modify, merge, publish,
24  * distribute, sublicense, and/or sell copies of the Software, and to
25  * permit persons to whom the Software is furnished to do so, subject to
26  * the following conditions:
27  *
28  * The above copyright notice and this permission notice shall be
29  * included in all copies or substantial portions of the Software.
30  *
31  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
32  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
33  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
34  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
35  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
36  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
37  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
38  */
39
40 #ifndef included_vnet_buffer_h
41 #define included_vnet_buffer_h
42
43 #include <vlib/vlib.h>
44
45 /* VLIB buffer flags for ip4/ip6 packets.  Set by input interfaces for ip4/ip6
46    tcp/udp packets with hardware computed checksums. */
47 #define LOG2_IP_BUFFER_L4_CHECKSUM_COMPUTED LOG2_VLIB_BUFFER_FLAG_USER(1)
48 #define LOG2_IP_BUFFER_L4_CHECKSUM_CORRECT  LOG2_VLIB_BUFFER_FLAG_USER(2)
49 #define IP_BUFFER_L4_CHECKSUM_COMPUTED (1 << LOG2_IP_BUFFER_L4_CHECKSUM_COMPUTED)
50 #define IP_BUFFER_L4_CHECKSUM_CORRECT  (1 << LOG2_IP_BUFFER_L4_CHECKSUM_CORRECT)
51
52 #define foreach_buffer_opaque_union_subtype     \
53 _(ethernet)                                     \
54 _(ip)                                           \
55 _(mcast)                                        \
56 _(swt)                                          \
57 _(l2)                                           \
58 _(l2t)                                          \
59 _(gre)                                          \
60 _(l2_classify)                                  \
61 _(io_handoff)                                   \
62 _(policer)                                      \
63 _(output_features)                              \
64 _(map)                                          \
65 _(map_t)                                        \
66 _(ip_frag)
67
68 /* 
69  * vnet stack buffer opaque array overlay structure.
70  * The vnet_buffer_opaque_t *must* be the same size as the
71  * vlib_buffer_t "opaque" structure member, 32 bytes.
72  *
73  * When adding a union type, please add a stanza to
74  * foreach_buffer_opaque_union_subtype (directly above).
75  * Code in vnet_interface_init(...) verifies the size
76  * of the union, and will announce any deviations in an
77  * impossible-to-miss manner.
78  */
79 typedef struct {
80   u32 sw_if_index[VLIB_N_RX_TX];
81
82   union {
83     /* Ethernet. */
84     struct {
85       /* Saved value of current header by ethernet-input. */
86       i32 start_of_ethernet_header;
87     } ethernet;
88
89     /* IP4/6 buffer opaque. */
90     struct {
91       /* Adjacency from destination IP address lookup [VLIB_TX].
92          Adjacency from source IP address lookup [VLIB_RX].
93          This gets set to ~0 until source lookup is performed. */
94       u32 adj_index[VLIB_N_RX_TX];
95
96       union {
97         struct {
98           /* Current configuration index. */
99           u32 current_config_index;
100
101           /* Flow hash value for this packet computed from IP src/dst address
102              protocol and ports. */
103           u32 flow_hash;
104
105           /* next protocol */
106           u32 save_protocol;
107         };
108
109         /* Alternate used for local TCP packets. */
110         struct {
111           u32 listener_index;
112
113           u32 established_connection_index;
114
115           u32 mini_connection_index;
116
117           u32 transmit_stamp;
118         } tcp;
119
120         /* ICMP */
121         struct {
122           u8 type;
123           u8 code;
124           u32 data;
125         } icmp;
126       };
127     } ip;
128
129     /* Multicast replication */
130     struct {
131       u32 pad[3];  
132       u32 mcast_group_index;
133       u32 mcast_current_index;
134       u32 original_free_list_index;
135     } mcast;
136
137     /* ip4-in-ip6 softwire termination, only valid there */
138     struct {
139       u8 swt_disable;
140       u32 mapping_index;
141     } swt;
142
143     /* l2 bridging path, only valid there */
144     struct {
145       u32 feature_bitmap;
146       u16 bd_index;       // bridge-domain index
147       u8  l2_len;         // ethernet header length
148       u8  shg;            // split-horizon group
149     } l2;
150
151     /* l2tpv3 softwire encap, only valid there */
152     struct {
153       u32 pad[4];               /* do not overlay w/ ip.adj_index[0,1] */
154       u8 next_index;
155       u32 session_index;
156     } l2t;
157
158     struct {
159       u32 src, dst;
160     } gre;
161
162     /* L2 classify */
163     struct {
164       u64 pad;
165       u32 opaque_index;
166       u32 table_index;
167       u64 hash;
168     } l2_classify;
169
170     /* IO - worker thread handoff */
171     struct {
172       u32 next_index;
173     } io_handoff;
174
175     /* vnet policer */
176     struct {
177       u32 pad[8 -VLIB_N_RX_TX -1];  /* to end of opaque */
178       u32 index;
179     } policer;
180
181     /* interface output features */
182     struct {
183       u32 ipsec_spd_index;
184       u32 ipsec_sad_index;
185       u32 unused[3];
186       u32 bitmap;
187     } output_features;
188
189     /* vcgn udp inside input, only valid there */
190     struct {
191       /* This part forms context of the packet. The structure should be
192        * exactly same as spp_ctx_t. Also this should be the first 
193        * element of this vcgn_uii structure.
194        */
195       /****** BEGIN spp_ctx_t section ***********************/
196       union { /* Roddick specific */
197         u32 roddick_info;
198         struct _tx_pkt_info  { /* Used by PI to PI communication for TX */
199           u32 uidb_index:16;       /* uidb_index to transmit */
200           u32  packet_type:2;   /* 1-IPv4, 2-Ipv6, - 0,3 - Unused */
201           u32  ipv4_defrag:1;   /* 0 - Normal, 1 - update first
202                                  * segment size
203                                  * (set by 6rd defrag node)
204                                  */
205
206           u32  dst_ip_port_idx:4;/* Index to dst_ip_port_table */
207           u32  from_node:4;
208           u32  calc_chksum:1;
209           u32  reserved:4;
210         } tx;
211         struct _rx_pkt_info { /* Used by PD / PI communication */
212           u32 uidb_index:16;    /* uidb_index received in packet */
213           u32  packet_type:2;   /* 1-IPv4, 2-Ipv6, - 0,3 - Unused */
214           u32  icmp_type:1;     /* 0-ICMP query type, 1-ICMP error type */
215           u32  protocol_type:2; /* 1-TCP, 2-UDP, 3-ICMP, 0 - Unused */
216           u32  ipv4_defrag:1;    /* 0 - Normal, 1 - update first
217                                   * segment size
218                                   * (set by 6rd defrag node)
219                                   */
220     
221           u32  direction:1;     /* 0-Outside, 1-Inside */
222           u32  frag:1;          /*IP fragment-1, Otherwise-0*/
223           u32  option:1;        /* 0-No IP option (v4) present, non-fragHdr
224                                  * option hdr present (v6)
225                                  */
226           u32  df_bit:1;        /* IPv4 DF bit copied here */
227           u32  reserved1:6;
228         } rx;
229       } ru;
230       /****** END  spp_ctx_t section ***********************/
231
232       union {
233         struct {
234           u32 ipv4;
235           u16 port;
236           u16 vrf;  //bit0-13:i/f, bit14-15:protocol
237         } k;
238
239         u64 key64;
240       } key;
241
242       u32 bucket;
243
244       u16 ovrf; /* Exit interface */
245       u8 frag_pkt;
246       u8 vcgn_unused1;
247     } vcgn_uii;
248
249     /* MAP */
250     struct {
251       u16 mtu;
252     } map;
253
254     /* MAP-T */
255     struct {
256       u32 map_domain_index;
257       struct {
258         u32 saddr, daddr;
259         u16 frag_offset;      //Fragmentation header offset
260         u16 l4_offset;        //L4 header overall offset
261         u8  l4_protocol;      //The final protocol number
262       } v6; //Used by ip6_map_t only
263       u16 checksum_offset;    //L4 checksum overall offset
264       u16 mtu;                //Exit MTU
265     } map_t;
266
267     /* IP Fragmentation */
268     struct {
269       u16 header_offset;
270       u16 mtu;
271       u8 next_index;
272       u8 flags;          //See ip_frag.h
273     } ip_frag;
274
275     /* COP - configurable junk filter(s) */
276     struct {
277         /* Current configuration index. */
278         u32 current_config_index;
279     } cop;
280
281     u32 unused[6];
282   };
283 } vnet_buffer_opaque_t;
284
285 #define vnet_buffer(b) ((vnet_buffer_opaque_t *) (b)->opaque)
286
287 /* Full cache line (64 bytes) of additional space */
288 typedef struct {
289   union {
290   };
291 } vnet_buffer_opaque2_t;
292
293
294
295 #endif /* included_vnet_buffer_h */