FD.io VPP  v19.01.3-6-g70449b9b9
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 <svm/svm_fifo.h>
20 #include <vnet/session/transport.h>
21 
23 
24 /*
25  * Application session state
26  */
27 typedef enum
28 {
41 
42 typedef struct generic_session_
43 {
44  svm_fifo_t *rx_fifo; /**< rx fifo */
45  svm_fifo_t *tx_fifo; /**< tx fifo */
46  session_type_t session_type; /**< session type */
47  volatile u8 session_state; /**< session state */
48  u32 session_index; /**< index in owning pool */
50 
51 typedef struct _stream_session_t
52 {
53  /** fifo pointers. Once allocated, these do not move */
54  svm_fifo_t *server_rx_fifo;
55  svm_fifo_t *server_tx_fifo;
56 
57  /** Type */
59 
60  /** State */
61  volatile u8 session_state;
62 
63  /** Session index in per_thread pool */
65 
66  /** App worker pool index */
67  u32 app_wrk_index;
68 
69  u8 thread_index;
70 
71  /** To avoid n**2 "one event per frame" check */
72  u64 enqueue_epoch;
73 
74  /** svm segment index where fifos were allocated */
75  u32 svm_segment_index;
76 
77  /** Transport specific */
78  u32 connection_index;
79 
80  union
81  {
82  /** Parent listener session if the result of an accept */
83  u32 listener_index;
84 
85  /** Application index if a listener */
86  u32 app_index;
87  };
88 
89  union
90  {
91  /** Transport app index for apps acting as transports */
92  u32 t_app_index;
93 
94  /** Index in listener app's listener db */
95  u32 listener_db_index;
96 
97  /** Opaque, for general use */
98  u32 opaque;
99  };
100 
103 
104 typedef struct local_session_
105 {
106  /** fifo pointers. Once allocated, these do not move */
109 
110  /** Type */
112 
113  /** State */
114  volatile u8 session_state;
115 
116  /** Session index */
118 
119  /** Server index */
121 
122  /** Port for connection. Overlaps thread_index/enqueue_epoch */
124 
125  /** Partly overlaps enqueue_epoch */
126  u8 pad_epoch[7];
127 
128  /** Segment index where fifos were allocated */
130 
131  /** Transport listener index. Overlaps connection index */
133 
134  union
135  {
138  };
139 
141 
142  /** Has transport embedded when listener not purely local */
144 
145  /**
146  * Client data
147  */
150 
153 
156 
157 #define foreach_session_endpoint_fields \
158  foreach_transport_endpoint_cfg_fields \
159  _(u8, transport_proto) \
160 
161 typedef struct _session_endpoint
162 {
163 #define _(type, name) type name;
165 #undef _
167 
168 typedef struct _session_endpoint_cfg
169 {
170 #define _(type, name) type name;
172 #undef _
173  u32 app_wrk_index;
174  u32 opaque;
175  u8 *hostname;
177 
178 #define SESSION_IP46_ZERO \
179 { \
180  .ip6 = { \
181  { 0, 0, }, \
182  }, \
183 }
184 
185 #define TRANSPORT_ENDPOINT_NULL \
186 { \
187  .sw_if_index = ENDPOINT_INVALID_INDEX, \
188  .ip = SESSION_IP46_ZERO, \
189  .fib_index = ENDPOINT_INVALID_INDEX, \
190  .is_ip4 = 0, \
191  .port = 0, \
192 }
193 #define SESSION_ENDPOINT_NULL \
194 { \
195  .sw_if_index = ENDPOINT_INVALID_INDEX, \
196  .ip = SESSION_IP46_ZERO, \
197  .fib_index = ENDPOINT_INVALID_INDEX, \
198  .is_ip4 = 0, \
199  .port = 0, \
200  .peer = TRANSPORT_ENDPOINT_NULL, \
201  .transport_proto = 0, \
202 }
203 #define SESSION_ENDPOINT_CFG_NULL \
204 { \
205  .sw_if_index = ENDPOINT_INVALID_INDEX, \
206  .ip = SESSION_IP46_ZERO, \
207  .fib_index = ENDPOINT_INVALID_INDEX, \
208  .is_ip4 = 0, \
209  .port = 0, \
210  .peer = TRANSPORT_ENDPOINT_NULL, \
211  .transport_proto = 0, \
212  .app_wrk_index = ENDPOINT_INVALID_INDEX, \
213  .opaque = ENDPOINT_INVALID_INDEX, \
214  .hostname = 0, \
215 }
216 
217 #define session_endpoint_to_transport(_sep) ((transport_endpoint_t *)_sep)
218 #define session_endpoint_to_transport_cfg(_sep) \
219  ((transport_endpoint_cfg_t *)_sep)
220 
223 {
224  return sep->is_ip4 ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6;
225 }
226 
227 #endif /* SRC_VNET_SESSION_STREAM_SESSION_H_ */
228 
229 /*
230  * fd.io coding-style-patch-verification: ON
231  *
232  * Local Variables:
233  * eval: (c-set-style "gnu")
234  * End:
235  */
session_type_t listener_session_type
Has transport embedded when listener not purely local.
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
unsigned long u64
Definition: types.h:89
svm_fifo_t * server_tx_fifo
svm_fifo_t * rx_fifo
rx fifo
struct generic_session_ generic_session_t
unsigned char u8
Definition: types.h:56
struct _svm_fifo svm_fifo_t
volatile u8 session_state
session state
stream_session_state_t
#define always_inline
Definition: clib.h:98
u32 transport_listener_index
Transport listener index.
struct local_session_ local_session_t
session_type_t session_type
Type.
unsigned int u32
Definition: types.h:88
struct _stream_session_t stream_session_t
struct _session_endpoint_cfg session_endpoint_cfg_t
struct _session_endpoint session_endpoint_t
svm_fifo_t * server_rx_fifo
fifo pointers.
unsigned short u16
Definition: types.h:57
u32 svm_segment_index
Segment index where fifos were allocated.
volatile u8 session_state
State.
u16 port
Port for connection.
u32 app_wrk_index
Server index.
u32 session_index
index in owning pool
u32 client_wrk_index
Client data.
#define foreach_session_endpoint_fields
u8 session_type_t
static u8 session_endpoint_fib_proto(session_endpoint_t *sep)
session_type_t session_type
session type
u32 session_index
Session index.
svm_fifo_t * tx_fifo
tx fifo