FD.io VPP  v18.10-34-gcce845e
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 {
39 
40 typedef struct generic_session_
41 {
42  svm_fifo_t *rx_fifo; /**< rx fifo */
43  svm_fifo_t *tx_fifo; /**< tx fifo */
44  session_type_t session_type; /**< session type */
45  volatile u8 session_state; /**< session state */
46  u32 session_index; /**< index in owning pool */
48 
49 typedef struct _stream_session_t
50 {
51  /** fifo pointers. Once allocated, these do not move */
52  svm_fifo_t *server_rx_fifo;
53  svm_fifo_t *server_tx_fifo;
54 
55  /** Type */
57 
58  /** State */
59  volatile u8 session_state;
60 
61  /** Session index in per_thread pool */
63 
64  /** App worker pool index */
65  u32 app_wrk_index;
66 
67  u8 thread_index;
68 
69  /** To avoid n**2 "one event per frame" check */
70  u64 enqueue_epoch;
71 
72  /** svm segment index where fifos were allocated */
73  u32 svm_segment_index;
74 
75  /** Transport specific */
76  u32 connection_index;
77 
78  union
79  {
80  /** Parent listener session if the result of an accept */
81  u32 listener_index;
82 
83  /** Application index if a listener */
84  u32 app_index;
85  };
86 
87  union
88  {
89  /** Transport app index for apps acting as transports */
90  u32 t_app_index;
91 
92  /** Index in listener app's listener db */
93  u32 listener_db_index;
94 
95  /** Opaque, for general use */
96  u32 opaque;
97  };
98 
101 
102 typedef struct local_session_
103 {
104  /** fifo pointers. Once allocated, these do not move */
107 
108  /** Type */
110 
111  /** State */
112  volatile u8 session_state;
113 
114  /** Session index */
116 
117  /** Server index */
119 
120  /** Port for connection. Overlaps thread_index/enqueue_epoch */
122 
123  /** Partly overlaps enqueue_epoch */
124  u8 pad_epoch[7];
125 
126  /** Segment index where fifos were allocated */
128 
129  /** Transport listener index. Overlaps connection index */
131 
132  union
133  {
136  };
137 
139 
140  /** Has transport embedded when listener not purely local */
142 
143  /**
144  * Client data
145  */
148 
151 
154 
155 #define foreach_session_endpoint_fields \
156  foreach_transport_connection_fields \
157  _(u8, transport_proto) \
158 
159 typedef struct _session_endpoint
160 {
161 #define _(type, name) type name;
163 #undef _
165 
166 typedef struct _session_endpoint_extended
167 {
168 #define _(type, name) type name;
170 #undef _
171  u32 app_wrk_index;
172  u32 opaque;
173  u8 *hostname;
175 
176 #define SESSION_IP46_ZERO \
177 { \
178  .ip6 = { \
179  { 0, 0, }, \
180  }, \
181 }
182 #define SESSION_ENDPOINT_NULL \
183 { \
184  .sw_if_index = ENDPOINT_INVALID_INDEX, \
185  .ip = SESSION_IP46_ZERO, \
186  .fib_index = ENDPOINT_INVALID_INDEX, \
187  .is_ip4 = 0, \
188  .port = 0, \
189  .transport_proto = 0, \
190 }
191 #define SESSION_ENDPOINT_EXT_NULL \
192 { \
193  .sw_if_index = ENDPOINT_INVALID_INDEX, \
194  .ip = SESSION_IP46_ZERO, \
195  .fib_index = ENDPOINT_INVALID_INDEX, \
196  .is_ip4 = 0, \
197  .port = 0, \
198  .transport_proto = 0, \
199  .app_wrk_index = ENDPOINT_INVALID_INDEX, \
200  .opaque = ENDPOINT_INVALID_INDEX, \
201  .hostname = 0, \
202 }
203 
204 #define session_endpoint_to_transport(_sep) ((transport_endpoint_t *)_sep)
205 
208 {
209  return sep->is_ip4 ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6;
210 }
211 
212 #endif /* SRC_VNET_SESSION_STREAM_SESSION_H_ */
213 
214 /*
215  * fd.io coding-style-patch-verification: ON
216  *
217  * Local Variables:
218  * eval: (c-set-style "gnu")
219  * End:
220  */
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:94
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 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
struct _session_endpoint_extended session_endpoint_extended_t