#define SERVER_STATE_OPEN (STATE_ACCEPT|STATE_CLOSE_ON_EMPTY)
#define CLIENT_STATE_OPEN (STATE_CONNECT|STATE_CLOSE_ON_EMPTY)
+#define STATE_OPEN (SERVER_STATE_OPEN | CLIENT_STATE_OPEN)
typedef struct epoll_event vppcom_epoll_event_t;
ip46_address_t ip46;
} vppcom_ip46_t;
+typedef struct vcl_session_msg
+{
+ u32 next;
+ union
+ {
+ session_accepted_msg_t accepted_msg;
+ };
+} vcl_session_msg_t;
+
enum
{
VCL_SESS_ATTR_SERVER,
u32 wait_cont_idx;
vppcom_epoll_t vep;
int libc_epfd;
- u64 client_queue_address;
+ svm_msg_q_t *our_evt_q;
u64 options[16];
vce_event_handler_reg_t *poll_reg;
+ vcl_session_msg_t *accept_evts_fifo;
#if VCL_ELOG
elog_track_t elog_track;
#endif
u8 app_scope_global;
u8 *namespace_id;
u64 namespace_secret;
+ u8 use_mq_eventfd;
f64 app_timeout;
f64 session_timeout;
f64 accept_timeout;
u32 event_ring_size;
char *event_log_path;
u8 *vpp_api_filename;
+ u8 *vpp_api_socket_name;
} vppcom_cfg_t;
void vppcom_cfg (vppcom_cfg_t * vcl_cfg);
+typedef struct vcl_cut_through_registration_
+{
+ svm_msg_q_t *mq;
+ svm_msg_q_t *peer_mq;
+ u32 sid;
+ u32 epoll_evt_conn_index; /*< mq evt connection index part of
+ the mqs evtfd epoll (if used) */
+} vcl_cut_through_registration_t;
+
+typedef struct vcl_mq_evt_conn_
+{
+ svm_msg_q_t *mq;
+ int mq_fd;
+} vcl_mq_evt_conn_t;
+
typedef struct vppcom_main_t_
{
u8 init;
clib_spinlock_t sessions_lockp;
vcl_session_t *sessions;
+ /** Message queues epoll fd. Initialized only if using mqs with eventfds */
+ int mqs_epfd;
+
+ /** Pool of event message queue event connections */
+ vcl_mq_evt_conn_t *mq_evt_conns;
+
+ /** Per worker buffer for receiving mq epoll events */
+ struct epoll_event *mq_events;
+
/* Hash table for disconnect processing */
uword *session_index_by_vpp_handles;
clib_bitmap_t *ex_bitmap;
/* Our event queue */
- svm_queue_t *app_event_queue;
+ svm_msg_q_t *app_event_queue;
+
+ svm_msg_q_t **vpp_event_queues;
/* unique segment name counter */
u32 unique_segment_index;
/* IO thread */
vppcom_session_io_thread_t session_io_thread;
+ /* pool of ctrl msgs */
+ vcl_session_msg_t *ctrl_evt_pool;
+
+ /** Pool of cut through registrations */
+ vcl_cut_through_registration_t *cut_through_registrations;
+
+ /** Lock for accessing ct registration pool */
+ clib_spinlock_t ct_registration_lock;
+
+ /** Cut-through registration by mq address hash table */
+ uword *ct_registration_by_mq;
+
+ svm_msg_q_msg_t *mq_msg_vector;
+
+ /** Flag indicating that a new segment is being mounted */
+ volatile u32 mounting_segment;
+
#ifdef VCL_ELOG
/* VPP Event-logger */
elog_main_t elog_main;
#define VCL_EVENTS_UNLOCK() \
clib_spinlock_unlock (&(vcm->event_thread.events_lockp))
+#define VCL_INVALID_SESSION_INDEX ((u32)~0)
+
+static inline vcl_session_t *
+vcl_session_alloc (void)
+{
+ vcl_session_t *s;
+ pool_get (vcm->sessions, s);
+ memset (s, 0, sizeof (*s));
+ return s;
+}
+
+static inline void
+vcl_session_free (vcl_session_t * s)
+{
+ pool_put (vcm->sessions, s);
+}
+
+static inline vcl_session_t *
+vcl_session_get (u32 session_index)
+{
+ if (pool_is_free_index (vcm->sessions, session_index))
+ return 0;
+ return pool_elt_at_index (vcm->sessions, session_index);
+}
+
+static inline u32
+vcl_session_index (vcl_session_t * s)
+{
+ return (s - vcm->sessions);
+}
+
+static inline vcl_session_t *
+vcl_session_get_w_handle (u64 handle)
+{
+ uword *p;
+ if ((p = hash_get (vcm->session_index_by_vpp_handles, handle)))
+ return vcl_session_get ((u32) p[0]);
+ return 0;
+}
+
+static inline u32
+vcl_session_get_index_from_handle (u64 handle)
+{
+ uword *p;
+ if ((p = hash_get (vcm->session_index_by_vpp_handles, handle)))
+ return p[0];
+ return VCL_INVALID_SESSION_INDEX;
+}
+
+static inline u8
+vcl_session_is_ct (vcl_session_t * s)
+{
+ return (s->our_evt_q != 0);
+}
+
static inline int
vppcom_session_at_index (u32 session_index, vcl_session_t * volatile *sess)
{
const char *vppcom_session_state_str (session_state_t state);
+/*
+ * Helpers
+ */
+vcl_cut_through_registration_t *vcl_ct_registration_lock_and_alloc (void);
+void vcl_ct_registration_del (vcl_cut_through_registration_t * ctr);
+u32 vcl_ct_registration_index (vcl_cut_through_registration_t * ctr);
+void vcl_ct_registration_unlock (void);
+vcl_cut_through_registration_t *vcl_ct_registration_get (u32 ctr_index);
+vcl_cut_through_registration_t *vcl_ct_registration_lock_and_lookup (uword);
+void vcl_ct_registration_lookup_add (uword mq_addr, u32 ctr_index);
+void vcl_ct_registration_lookup_del (uword mq_addr);
+vcl_mq_evt_conn_t *vcl_mq_evt_conn_alloc (void);
+u32 vcl_mq_evt_conn_index (vcl_mq_evt_conn_t * mqc);
+vcl_mq_evt_conn_t *vcl_mq_evt_conn_get (u32 mq_conn_idx);
+int vcl_mq_epoll_add_evfd (svm_msg_q_t * mq);
+int vcl_mq_epoll_del_evfd (u32 mqc_index);
+
/*
* VCL Binary API
*/
u32 vcl_max_nsid_len (void);
+u8 *format_api_error (u8 * s, va_list * args);
+
#endif /* SRC_VCL_VCL_PRIVATE_H_ */
/*