FD.io VPP  v18.04-17-g3a0d853
Vector Packet Processing
stream_session.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 
16 #ifndef SRC_VNET_SESSION_STREAM_SESSION_H_
17 #define SRC_VNET_SESSION_STREAM_SESSION_H_
18 
19 #include <vnet/vnet.h>
20 #include <svm/svm_fifo.h>
21 #include <vnet/session/transport.h>
22 
24 
25 /*
26  * Application session state
27  */
28 typedef enum
29 {
38 
39 /* TODO convert to macro once cleanup completed */
40 typedef struct app_session_
41 {
42  /** fifo pointers. Once allocated, these do not move */
45 
46  /** Type */
48 
49  /** State */
50  volatile u8 session_state;
51 
52  /** Session index in owning pool */
54 
55  /** Application index */
58 
59 typedef struct _stream_session_t
60 {
61  /** fifo pointers. Once allocated, these do not move */
64 
65  /** Type */
67 
68  /** State */
69  volatile u8 session_state;
70 
71  /** Session index in per_thread pool */
73 
74  /** stream server pool index */
75  u32 app_index;
76 
77  u8 thread_index;
78 
79  /** To avoid n**2 "one event per frame" check */
80  u8 enqueue_epoch;
81 
82  /** svm segment index where fifos were allocated */
83  u32 svm_segment_index;
84 
85  /** Transport specific */
86  u32 connection_index;
87 
88  union
89  {
90  /** Parent listener session if the result of an accept */
91  u32 listener_index;
92  /** Opaque, for general use */
93  u32 opaque;
94  };
95 
98 
99 typedef struct local_session_
100 {
101  /** fifo pointers. Once allocated, these do not move */
104 
105  /** Type */
107 
108  /** State */
109  volatile u8 session_state;
110 
111  /** Session index */
113 
114  /** Server index */
116 
117  /** Segment index where fifos were allocated */
119 
121 
122  /** Port for connection */
124 
125  /** Has transport embedded when listener not purely local */
128 
129  /**
130  * Client data
131  */
134 
137 
140 
141 #define foreach_session_endpoint_fields \
142  foreach_transport_connection_fields \
143  _(u8, transport_proto) \
144 
145 typedef struct _session_endpoint
146 {
147 #define _(type, name) type name;
149 #undef _
151 
152 typedef struct _session_endpoint_extended
153 {
154 #define _(type, name) type name;
156 #undef _
157  u32 app_index;
158  u32 opaque;
159  u8 *hostname;
161 
162 #define SESSION_IP46_ZERO \
163 { \
164  .ip6 = { \
165  { 0, 0, }, \
166  }, \
167 }
168 #define SESSION_ENDPOINT_NULL \
169 { \
170  .sw_if_index = ENDPOINT_INVALID_INDEX, \
171  .ip = SESSION_IP46_ZERO, \
172  .fib_index = ENDPOINT_INVALID_INDEX, \
173  .is_ip4 = 0, \
174  .port = 0, \
175  .transport_proto = 0, \
176 }
177 #define SESSION_ENDPOINT_EXT_NULL \
178 { \
179  .sw_if_index = ENDPOINT_INVALID_INDEX, \
180  .ip = SESSION_IP46_ZERO, \
181  .fib_index = ENDPOINT_INVALID_INDEX, \
182  .is_ip4 = 0, \
183  .port = 0, \
184  .transport_proto = 0, \
185  .app_index = ENDPOINT_INVALID_INDEX, \
186  .opaque = ENDPOINT_INVALID_INDEX, \
187  .hostname = 0, \
188 }
189 
190 #define session_endpoint_to_transport(_sep) ((transport_endpoint_t *)_sep)
191 
194 {
195  return sep->is_ip4 ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6;
196 }
197 
198 #endif /* SRC_VNET_SESSION_STREAM_SESSION_H_ */
199 
200 /*
201  * fd.io coding-style-patch-verification: ON
202  *
203  * Local Variables:
204  * eval: (c-set-style "gnu")
205  * End:
206  */
session_type_t listener_session_type
Has transport embedded when listener not purely local.
struct app_session_ app_session_t
u8 pad[3]
log2 (size of the packing page block)
Definition: bihash_doc.h:61
#define CLIB_CACHE_LINE_ALIGN_MARK(mark)
Definition: cache.h:60
u32 client_index
Client data.
svm_fifo_t * server_tx_fifo
u32 session_index
Session index in owning pool.
u32 app_index
Application index.
struct _svm_fifo svm_fifo_t
stream_session_state_t
#define always_inline
Definition: clib.h:92
u32 transport_listener_index
struct local_session_ local_session_t
session_type_t session_type
Type.
unsigned long u64
Definition: types.h:89
struct _stream_session_t stream_session_t
session_type_t session_type
Type.
struct _session_endpoint session_endpoint_t
svm_fifo_t * server_rx_fifo
fifo pointers.
svm_fifo_t * server_rx_fifo
fifo pointers.
u32 svm_segment_index
Segment index where fifos were allocated.
volatile u8 session_state
State.
u16 port
Port for connection.
unsigned int u32
Definition: types.h:88
#define foreach_session_endpoint_fields
u8 session_type_t
volatile u8 session_state
State.
static u8 session_endpoint_fib_proto(session_endpoint_t *sep)
unsigned short u16
Definition: types.h:57
unsigned char u8
Definition: types.h:56
u32 session_index
Session index.
svm_fifo_t * server_tx_fifo
struct _session_endpoint_extended session_endpoint_extended_t
u32 app_index
Server index.