FD.io VPP  v18.07-34-g55fbdb9
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 {
38 
39 typedef struct generic_session_
40 {
41  svm_fifo_t *rx_fifo; /**< rx fifo */
42  svm_fifo_t *tx_fifo; /**< tx fifo */
43  session_type_t session_type; /**< session type */
44  volatile u8 session_state; /**< session state */
45  u32 session_index; /**< index in owning pool */
47 
48 typedef struct _stream_session_t
49 {
50  /** fifo pointers. Once allocated, these do not move */
51  svm_fifo_t *server_rx_fifo;
52  svm_fifo_t *server_tx_fifo;
53 
54  /** Type */
56 
57  /** State */
58  volatile u8 session_state;
59 
60  /** Session index in per_thread pool */
62 
63  /** stream server pool index */
64  u32 app_index;
65 
66  u8 thread_index;
67 
68  /** To avoid n**2 "one event per frame" check */
69  u8 enqueue_epoch;
70 
71  /** svm segment index where fifos were allocated */
72  u32 svm_segment_index;
73 
74  /** Transport specific */
75  u32 connection_index;
76 
77  union
78  {
79  /** Parent listener session if the result of an accept */
80  u32 listener_index;
81  /** Opaque, for general use */
82  u32 opaque;
83  };
84 
87 
88 typedef struct local_session_
89 {
90  /** fifo pointers. Once allocated, these do not move */
93 
94  /** Type */
96 
97  /** State */
98  volatile u8 session_state;
99 
100  /** Session index */
102 
103  /** Server index */
105 
106  /** Segment index where fifos were allocated */
108 
110 
111  /** Port for connection */
113 
114  /** Has transport embedded when listener not purely local */
117 
118  /**
119  * Client data
120  */
123 
126 
129 
130 #define foreach_session_endpoint_fields \
131  foreach_transport_connection_fields \
132  _(u8, transport_proto) \
133 
134 typedef struct _session_endpoint
135 {
136 #define _(type, name) type name;
138 #undef _
140 
141 typedef struct _session_endpoint_extended
142 {
143 #define _(type, name) type name;
145 #undef _
146  u32 app_index;
147  u32 opaque;
148  u8 *hostname;
150 
151 #define SESSION_IP46_ZERO \
152 { \
153  .ip6 = { \
154  { 0, 0, }, \
155  }, \
156 }
157 #define SESSION_ENDPOINT_NULL \
158 { \
159  .sw_if_index = ENDPOINT_INVALID_INDEX, \
160  .ip = SESSION_IP46_ZERO, \
161  .fib_index = ENDPOINT_INVALID_INDEX, \
162  .is_ip4 = 0, \
163  .port = 0, \
164  .transport_proto = 0, \
165 }
166 #define SESSION_ENDPOINT_EXT_NULL \
167 { \
168  .sw_if_index = ENDPOINT_INVALID_INDEX, \
169  .ip = SESSION_IP46_ZERO, \
170  .fib_index = ENDPOINT_INVALID_INDEX, \
171  .is_ip4 = 0, \
172  .port = 0, \
173  .transport_proto = 0, \
174  .app_index = ENDPOINT_INVALID_INDEX, \
175  .opaque = ENDPOINT_INVALID_INDEX, \
176  .hostname = 0, \
177 }
178 
179 #define session_endpoint_to_transport(_sep) ((transport_endpoint_t *)_sep)
180 
183 {
184  return sep->is_ip4 ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6;
185 }
186 
187 #endif /* SRC_VNET_SESSION_STREAM_SESSION_H_ */
188 
189 /*
190  * fd.io coding-style-patch-verification: ON
191  *
192  * Local Variables:
193  * eval: (c-set-style "gnu")
194  * End:
195  */
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:63
unsigned long u64
Definition: types.h:89
u32 client_index
Client data.
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:92
u32 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 session_index
index in owning pool
#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
u32 app_index
Server index.