vppcom_epoll_t vep;
int libc_epfd;
svm_msg_q_t *our_evt_q;
- u32 ct_registration;
u64 options[16];
vce_event_handler_reg_t *poll_reg;
vcl_session_msg_t *accept_evts_fifo;
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;
u32 debug;
int main_cpu;
- /* FIFO for accepted connections - used in epoll/select */
- clib_spinlock_t session_fifo_lockp;
- u32 *client_session_index_fifo;
-
/* vpp input queue */
svm_queue_t *vl_input_queue;
/* API client handle */
u32 my_client_index;
/* Session pool */
- 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;
/* Our event queue */
svm_msg_q_t *app_event_queue;
+ svm_msg_q_t **vpp_event_queues;
+
/* unique segment name counter */
u32 unique_segment_index;
/** 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;
extern vppcom_main_t *vcm;
-#define VCL_SESSION_LOCK_AND_GET(I, S) \
-do { \
- clib_spinlock_lock (&vcm->sessions_lockp); \
- rv = vppcom_session_at_index (I, S); \
- if (PREDICT_FALSE (rv)) \
- { \
- clib_spinlock_unlock (&vcm->sessions_lockp); \
- clib_warning ("VCL<%d>: ERROR: Invalid ##I (%u)!", \
- getpid (), I); \
- goto done; \
- } \
-} while (0)
-
-#define VCL_SESSION_LOCK() clib_spinlock_lock (&(vcm->sessions_lockp))
-#define VCL_SESSION_UNLOCK() clib_spinlock_unlock (&(vcm->sessions_lockp))
-
-#define VCL_IO_SESSIONS_LOCK() \
- clib_spinlock_lock (&(vcm->session_io_thread.io_sessions_lockp))
-#define VCL_IO_SESSIONS_UNLOCK() \
- clib_spinlock_unlock (&(vcm->session_io_thread.io_sessions_lockp))
-
-#define VCL_ACCEPT_FIFO_LOCK() clib_spinlock_lock (&(vcm->session_fifo_lockp))
-#define VCL_ACCEPT_FIFO_UNLOCK() \
- clib_spinlock_unlock (&(vcm->session_fifo_lockp))
-
-#define VCL_EVENTS_LOCK() \
- clib_spinlock_lock (&(vcm->event_thread.events_lockp))
-#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)
{
return VCL_INVALID_SESSION_INDEX;
}
-static inline int
-vppcom_session_at_index (u32 session_index, vcl_session_t * volatile *sess)
+static inline u8
+vcl_session_is_ct (vcl_session_t * s)
{
- /* Assumes that caller has acquired spinlock: vcm->sessions_lockp */
- if (PREDICT_FALSE ((session_index == ~0) ||
- pool_is_free_index (vcm->sessions, session_index)))
- {
- clib_warning ("VCL<%d>: invalid session, sid (%u) has been closed!",
- getpid (), session_index);
- return VPPCOM_EBADFD;
- }
- *sess = pool_elt_at_index (vcm->sessions, session_index);
- return VPPCOM_OK;
+ return (s->our_evt_q != 0);
}
static inline void
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
*/