diff options
author | Florin Coras <fcoras@cisco.com> | 2020-10-19 20:51:36 -0700 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2020-10-20 17:49:41 +0000 |
commit | ac422d6430060c003f70191c9a12466c29dab7e7 (patch) | |
tree | 6ed0a22bba0049dc66fb9f5e77fbd6a6b7a7f360 /src/vcl/vcl_private.h | |
parent | 2531d50101991011fb1c7755d48f11b41f092628 (diff) |
vcl: more session struct cleanup
Type: improvement
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I8e466e789c860caaa55f67095a57fc6ab670f32b
Diffstat (limited to 'src/vcl/vcl_private.h')
-rw-r--r-- | src/vcl/vcl_private.h | 67 |
1 files changed, 35 insertions, 32 deletions
diff --git a/src/vcl/vcl_private.h b/src/vcl/vcl_private.h index 017da4e5088..c82de1aea60 100644 --- a/src/vcl/vcl_private.h +++ b/src/vcl/vcl_private.h @@ -131,56 +131,41 @@ typedef enum VCL_SESS_ATTR_MAX } vppcom_session_attr_t; -#define VCL_SESS_ATTR_SET(ATTR, VAL) \ -do { \ - (ATTR) |= 1 << (VAL); \ - } while (0) - -#define VCL_SESS_ATTR_CLR(ATTR, VAL) \ -do { \ - (ATTR) &= ~(1 << (VAL)); \ - } while (0) - -#define VCL_SESS_ATTR_TEST(ATTR, VAL) \ - ((ATTR) & (1 << (VAL)) ? 1 : 0) - typedef enum vcl_session_flags_ { VCL_SESSION_F_CONNECTED = 1 << 0, VCL_SESSION_F_IS_VEP = 1 << 1, VCL_SESSION_F_IS_VEP_SESSION = 1 << 2, + VCL_SESSION_F_HAS_RX_EVT = 1 << 3, } __clib_packed vcl_session_flags_t; -typedef struct +typedef struct vcl_session_ { CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); + #define _(type, name) type name; foreach_app_session_field #undef _ - u32 sndbuf_size; // VPP-TBD: Hack until support setsockopt(SO_SNDBUF) - u32 rcvbuf_size; // VPP-TBD: Hack until support setsockopt(SO_RCVBUF) - u32 user_mss; // VPP-TBD: Hack until support setsockopt(TCP_MAXSEG) - u64 vpp_handle; - u32 vpp_thread_index; + vcl_session_flags_t flags; /**< see @ref vcl_session_flags_t */ + u32 rx_bytes_pending; /**< bytes rx-ed as segs but not yet freed */ svm_fifo_t *ct_rx_fifo; svm_fifo_t *ct_tx_fifo; + vcl_session_msg_t *accept_evts_fifo; - /* Socket configuration state */ - vcl_session_flags_t flags; - /* VCL session index of the listening session (if any) */ - u32 listener_index; - /* Accepted sessions on this listener */ - int n_accepted_sessions; - u8 has_rx_evt; - u32 attr; + u64 vpp_handle; + u32 vpp_thread_index; + u32 listener_index; /**< index of parent listener (if any) */ + int n_accepted_sessions; /**< sessions accepted by this listener */ + u32 attributes; /**< see @ref vppcom_session_attr_t */ u64 parent_handle; - vppcom_epoll_t vep; int libc_epfd; - svm_msg_q_t *our_evt_q; - vcl_session_msg_t *accept_evts_fifo; - /** bytes delivered as segment but not yet freed */ - u32 rx_bytes_pending; + vppcom_epoll_t vep; + + u32 sndbuf_size; // VPP-TBD: Hack until support setsockopt(SO_SNDBUF) + u32 rcvbuf_size; // VPP-TBD: Hack until support setsockopt(SO_RCVBUF) + u32 user_mss; // VPP-TBD: Hack until support setsockopt(TCP_MAXSEG) + #if VCL_ELOG elog_track_t elog_track; #endif @@ -619,6 +604,24 @@ vcl_proto_is_dgram (uint8_t proto) return proto == VPPCOM_PROTO_UDP; } +static inline u8 +vcl_session_has_attr (vcl_session_t * s, u8 attr) +{ + return (s->attributes & (1 << attr)) ? 1 : 0; +} + +static inline void +vcl_session_set_attr (vcl_session_t * s, u8 attr) +{ + s->attributes |= 1 << attr; +} + +static inline void +vcl_session_clear_attr (vcl_session_t * s, u8 attr) +{ + s->attributes &= ~(1 << attr); +} + /* * Helpers */ |