X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fsession%2Fsession_types.h;h=9a5bc7688086d0db24899879494b171f6246981b;hb=26dd6de91b4d36ac04154c7eb6339684db6684a0;hp=efa3dea950c622aed59fd68a0cb15b8979c9c742;hpb=8a140616a5bab477817e7ed59afe6b01bd3d2f3a;p=vpp.git diff --git a/src/vnet/session/session_types.h b/src/vnet/session/session_types.h index efa3dea950c..9a5bc768808 100644 --- a/src/vnet/session/session_types.h +++ b/src/vnet/session/session_types.h @@ -19,8 +19,8 @@ #include #include -#define SESSION_LOCAL_HANDLE_PREFIX 0x7FFFFFFF -#define SESSION_LISTENER_PREFIX 0x5FFFFFFF +#define SESSION_INVALID_INDEX ((u32)~0) +#define SESSION_INVALID_HANDLE ((u64)~0) #define foreach_session_endpoint_fields \ foreach_transport_endpoint_cfg_fields \ @@ -41,7 +41,9 @@ typedef struct _session_endpoint_cfg u32 app_wrk_index; u32 opaque; u32 ns_index; + u8 original_tp; u8 *hostname; + u64 parent_handle; } session_endpoint_cfg_t; #define SESSION_IP46_ZERO \ @@ -81,6 +83,7 @@ typedef struct _session_endpoint_cfg .app_wrk_index = ENDPOINT_INVALID_INDEX, \ .opaque = ENDPOINT_INVALID_INDEX, \ .hostname = 0, \ + .parent_handle = SESSION_INVALID_HANDLE \ } #define session_endpoint_to_transport(_sep) ((transport_endpoint_t *)_sep) @@ -109,8 +112,14 @@ session_endpoint_is_zero (session_endpoint_t * sep) typedef u8 session_type_t; typedef u64 session_handle_t; +typedef enum +{ + SESSION_CLEANUP_TRANSPORT, + SESSION_CLEANUP_SESSION, +} session_cleanup_ntf_t; + /* - * Application session state + * Session states */ typedef enum { @@ -122,71 +131,62 @@ typedef enum SESSION_STATE_OPENED, SESSION_STATE_TRANSPORT_CLOSING, SESSION_STATE_CLOSING, - SESSION_STATE_CLOSED_WAITING, + SESSION_STATE_APP_CLOSED, SESSION_STATE_TRANSPORT_CLOSED, + SESSION_STATE_TRANSPORT_DELETED, SESSION_STATE_CLOSED, SESSION_STATE_N_STATES, } session_state_t; -typedef struct generic_session_ +typedef enum session_flags_ { - svm_fifo_t *rx_fifo; /**< rx fifo */ - svm_fifo_t *tx_fifo; /**< tx fifo */ - session_type_t session_type; /**< session type */ - volatile u8 session_state; /**< session state */ - u32 session_index; /**< index in owning pool */ -} generic_session_t; + SESSION_F_RX_EVT = 1, + SESSION_F_PROXY = (1 << 1), + SESSION_F_CUSTOM_TX = (1 << 2), +} session_flags_t; typedef struct session_ { - /** fifo pointers. Once allocated, these do not move */ + /** Pointers to rx/tx buffers. Once allocated, these do not move */ svm_fifo_t *rx_fifo; svm_fifo_t *tx_fifo; - /** Type */ + /** Type built from transport and network protocol types */ session_type_t session_type; - /** State */ + /** State in session layer state machine. See @ref session_state_t */ volatile u8 session_state; - /** Session index in per_thread pool */ + /** Index in thread pool where session was allocated */ u32 session_index; - /** App worker pool index */ + /** Index of the app worker that owns the session */ u32 app_wrk_index; + /** Index of the thread that allocated the session */ u8 thread_index; - /** To avoid n**2 "one event per frame" check */ - u64 enqueue_epoch; - - /** svm segment index where fifos were allocated */ - u32 svm_segment_index; + /** Session flags. See @ref session_flags_t */ + u32 flags; - /** Transport specific */ + /** Index of the transport connection associated to the session */ u32 connection_index; - union - { - /** Parent listener session if the result of an accept */ - u32 listener_index; - - /** Application index if a listener */ - u32 app_index; - }; + /** Index of application that owns the listener. Set only if a listener */ + u32 app_index; union { - /** Transport app index for apps acting as transports */ - u32 t_app_index; + /** Parent listener session index if the result of an accept */ + session_handle_t listener_handle; - /** App listener index */ + /** App listener index in app's listener pool if a listener */ u32 al_index; - - /** Opaque, for general use */ - u32 opaque; }; + /** Opaque, for general use */ + u32 opaque; + CLIB_CACHE_LINE_ALIGN_MARK (pad); } session_t; @@ -275,123 +275,17 @@ session_parse_handle (session_handle_t handle, u32 * index, *thread_index = session_thread_from_handle (handle); } -always_inline u8 -session_handle_is_local (session_handle_t handle) -{ - if ((handle >> 32) == SESSION_LOCAL_HANDLE_PREFIX) - return 1; - return 0; -} - -typedef struct local_session_ -{ - /** fifo pointers. Once allocated, these do not move */ - svm_fifo_t *rx_fifo; - svm_fifo_t *tx_fifo; - - /** Type */ - session_type_t session_type; - - /** State */ - volatile u8 session_state; - - /** Session index */ - u32 session_index; - - /** Server index */ - u32 app_wrk_index; - - /** Port for connection. Overlaps thread_index/enqueue_epoch */ - u16 port; - - /** Partly overlaps enqueue_epoch */ - u8 pad_epoch[7]; - - /** Segment index where fifos were allocated */ - u32 svm_segment_index; - - /** Transport listener index. Overlaps connection index */ - u32 transport_listener_index; - - union - { - u32 listener_index; - u32 app_index; - }; - - u32 al_index; - - /** Has transport embedded when listener not purely local */ - session_type_t listener_session_type; - - /** - * Client data - */ - u32 client_wrk_index; - u32 client_opaque; - - u64 server_evt_q; - u64 client_evt_q; - - CLIB_CACHE_LINE_ALIGN_MARK (pad); -} local_session_t; - -always_inline u32 -local_session_id (local_session_t * ls) -{ - ASSERT (ls->session_index < (2 << 16)); - u32 app_or_wrk_index; - - if (ls->session_state == SESSION_STATE_LISTENING) - { - ASSERT (ls->app_index < (2 << 16)); - app_or_wrk_index = ls->app_index; - } - else - { - ASSERT (ls->app_wrk_index < (2 << 16)); - app_or_wrk_index = ls->app_wrk_index; - } - - return ((u32) app_or_wrk_index << 16 | (u32) ls->session_index); -} - -always_inline void -local_session_parse_id (u32 ls_id, u32 * app_or_wrk, u32 * session_index) -{ - *app_or_wrk = ls_id >> 16; - *session_index = ls_id & 0xFF; -} - -always_inline void -local_session_parse_handle (session_handle_t handle, u32 * app_or_wrk_index, - u32 * session_index) -{ - u32 bottom; - ASSERT ((handle >> 32) == SESSION_LOCAL_HANDLE_PREFIX); - bottom = (handle & 0xFFFFFFFF); - local_session_parse_id (bottom, app_or_wrk_index, session_index); -} - -always_inline session_handle_t -application_local_session_handle (local_session_t * ls) -{ - return ((u64) SESSION_LOCAL_HANDLE_PREFIX << 32) - | (u64) local_session_id (ls); -} - typedef enum { - FIFO_EVENT_APP_RX, - SESSION_IO_EVT_CT_RX, - FIFO_EVENT_APP_TX, - SESSION_IO_EVT_CT_TX, + SESSION_IO_EVT_RX, + SESSION_IO_EVT_TX, SESSION_IO_EVT_TX_FLUSH, - FIFO_EVENT_DISCONNECT, - FIFO_EVENT_BUILTIN_RX, - FIFO_EVENT_BUILTIN_TX, - FIFO_EVENT_RPC, + SESSION_IO_EVT_BUILTIN_RX, + SESSION_IO_EVT_BUILTIN_TX, + SESSION_CTRL_EVT_RPC, + SESSION_CTRL_EVT_CLOSE, SESSION_CTRL_EVT_BOUND, + SESSION_CTRL_EVT_UNLISTEN_REPLY, SESSION_CTRL_EVT_ACCEPTED, SESSION_CTRL_EVT_ACCEPTED_REPLY, SESSION_CTRL_EVT_CONNECTED, @@ -405,25 +299,12 @@ typedef enum SESSION_CTRL_EVT_WORKER_UPDATE_REPLY, } session_evt_type_t; -static inline const char * -fifo_event_type_str (session_evt_type_t et) -{ - switch (et) - { - case FIFO_EVENT_APP_RX: - return "FIFO_EVENT_APP_RX"; - case FIFO_EVENT_APP_TX: - return "FIFO_EVENT_APP_TX"; - case FIFO_EVENT_DISCONNECT: - return "FIFO_EVENT_DISCONNECT"; - case FIFO_EVENT_BUILTIN_RX: - return "FIFO_EVENT_BUILTIN_RX"; - case FIFO_EVENT_RPC: - return "FIFO_EVENT_RPC"; - default: - return "UNKNOWN FIFO EVENT"; - } -} +/* Deprecated and will be removed. Use types above */ +#define FIFO_EVENT_APP_RX SESSION_IO_EVT_RX +#define FIFO_EVENT_APP_TX SESSION_IO_EVT_TX +#define FIFO_EVENT_DISCONNECT SESSION_CTRL_EVT_CLOSE +#define FIFO_EVENT_BUILTIN_RX SESSION_IO_EVT_BUILTIN_RX +#define FIFO_EVENT_BUILTIN_TX SESSION_IO_EVT_BUILTIN_TX typedef enum { @@ -438,14 +319,13 @@ typedef struct void *arg; } session_rpc_args_t; -/* *INDENT-OFF* */ typedef struct { u8 event_type; u8 postponed; union { - svm_fifo_t *fifo; + u32 session_index; session_handle_t session_handle; session_rpc_args_t rpc_args; struct @@ -454,7 +334,6 @@ typedef struct }; }; } __clib_packed session_event_t; -/* *INDENT-ON* */ #define SESSION_MSG_NULL { } @@ -464,8 +343,7 @@ typedef struct session_dgram_pre_hdr_ u32 data_offset; } session_dgram_pre_hdr_t; -/* *INDENT-OFF* */ -typedef CLIB_PACKED (struct session_dgram_header_ +typedef struct session_dgram_header_ { u32 data_length; u32 data_offset; @@ -474,8 +352,7 @@ typedef CLIB_PACKED (struct session_dgram_header_ u16 rmt_port; u16 lcl_port; u8 is_ip4; -}) session_dgram_hdr_t; -/* *INDENT-ON* */ +} __clib_packed session_dgram_hdr_t; #define SESSION_CONN_ID_LEN 37 #define SESSION_CONN_HDR_LEN 45