18 #ifndef included_vlib_mc_h 19 #define included_vlib_mc_h 26 #ifndef MC_EVENT_LOGGING 27 #define MC_EVENT_LOGGING 1 67 u32 global_sequence;}) mc_msg_master_assert_t;
79 #define foreach_mc_msg_type \ 81 _ (join_or_leave_request) \ 90 #define _(f) MC_MSG_TYPE_##f, 103 u8 is_join;}) mc_msg_join_or_leave_request_t;
149 u8 data[0];}) mc_msg_user_request_t;
168 u32 global_sequence;
u32 stream_index;
170 i32 seq_cmp_result;}) mc_msg_user_ack_t;
189 u32 stream_index;}) mc_msg_catchup_request_t;
206 u32 last_global_sequence_included;
210 u8 data[0];}) mc_msg_catchup_reply_t;
219 r->last_global_sequence_included =
225 typedef struct _mc_serialize_msg
236 u32 max_n_bytes_serialized;
245 struct _mc_serialize_msg *next_registration;
254 #define MC_SERIALIZE_MSG(x,...) \ 255 __VA_ARGS__ mc_serialize_msg_t x; \ 256 static void __mc_serialize_msg_registration_##x (void) \ 257 __attribute__((__constructor__)) ; \ 258 static void __mc_serialize_msg_registration_##x (void) \ 260 vlib_main_t * vm = vlib_get_main(); \ 261 x.next_registration = vm->mc_msg_registrations; \ 262 vm->mc_msg_registrations = &x; \ 264 __VA_ARGS__ mc_serialize_msg_t x 372 u8 * snapshot_vector,
373 u32 last_global_sequence_included);
377 u8 * snapshot_data,
u32 n_snapshot_data_bytes);
382 u8 * snapshot_data,
u32 n_snapshot_data_bytes);
389 #define foreach_mc_stream_state \ 392 _ (join_in_progress) \ 398 #define _(f) MC_STREAM_STATE_##f, 413 #define MC_STREAM_INDEX_INTERNAL 0 491 memset (s, 0,
sizeof (s[0]));
611 p->stats_last_clear = p->stats;
618 #define _(f) void mc_msg_##f##_handler (mc_main_t * mcm, mc_msg_##f##_t * msg, u32 buffer_index); 640 u32 multiple_messages_per_vlib_buffer,
645 u32 multiple_messages_per_vlib_buffer,
648 #define mc_serialize_stream(mc,si,msg,args...) \ 649 mc_serialize_internal((mc),(si),(0),(msg),(msg)->serialize,args) 651 #define mc_serialize(mc,msg,args...) \ 652 mc_serialize_internal((mc),(~0),(0),(msg),(msg)->serialize,args) 654 #define mc_serialize2(mc,add,msg,args...) \ 655 mc_serialize_internal((mc),(~0),(add),(msg),(msg)->serialize,args) static mc_stream_t * mc_stream_by_index(mc_main_t *m, u32 i)
u32 last_global_sequence_processed
mhash_t mastership_peer_index_by_id
sll srl srl sll sra u16x4 i
static void mc_stream_init(mc_stream_t *s)
void mc_main_init(mc_main_t *mcm, char *tag)
static uword mc_need_byte_swap(void)
static void mc_stream_free(mc_stream_t *s)
u64 user_requests_received
static void mc_byte_swap_msg_join_reply(mc_msg_join_reply_t *r)
vlib_one_time_waiting_process_t * procs_waiting_for_join_done
u32 last_sequence_received
void mc_stream_join_process_hold(void)
static u32 clib_byte_swap_u32(u32 x)
static void mc_byte_swap_msg_user_request(mc_msg_user_request_t *r)
#define CLIB_ARCH_IS_LITTLE_ENDIAN
mc_serialize_msg_t ** global_msgs
#define foreach_mc_stream_state
struct mc_main_t mc_main_t
static uword mc_max_message_size_in_bytes(mc_main_t *mcm)
static void mc_byte_swap_msg_catchup_reply(mc_msg_catchup_reply_t *r)
typedef CLIB_PACKED(struct{mc_peer_id_t peer_id;u32 global_sequence;}) mc_msg_master_assert_t
u32 relay_global_sequence
format_function_t format_mc_main
static word mc_serialize_n_bytes_left(mc_main_t *mcm, serialize_main_t *m)
uword * stream_msg_index_by_name
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
struct mc_stream_t mc_stream_t
mc_stream_config_t config
static i32 clib_byte_swap_i32(i32 x)
clib_error_t * mc_serialize_internal(mc_main_t *mc, u32 stream_index, u32 multiple_messages_per_vlib_buffer, mc_serialize_msg_t *msg,...)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
void unserialize_mc_stream(serialize_main_t *m, va_list *va)
mc_peer_id_t our_catchup_peer_id
uword * stream_index_by_name
uword * procs_waiting_for_stream_name_by_name
void mc_wait_for_stream_ready(mc_main_t *m, char *stream_name)
mc_mastership_peer_t * mastership_peers
static u32 serialize_vlib_buffer_n_bytes(serialize_main_t *m)
serialize_function_t unserialize_mc_main
foreach_mc_msg_type u32 mc_stream_join(mc_main_t *mcm, mc_stream_config_t *)
vlib_one_time_waiting_process_t * procs_waiting_for_open_window
uword mc_unserialize_message(mc_main_t *mcm, mc_stream_t *s, serialize_main_t *m)
uword * unacked_by_peer_bitmap
static void mc_byte_swap_msg_master_assert(mc_msg_master_assert_t *r)
void mc_stream_leave(mc_main_t *mcm, u32 stream_index)
f64 time_last_master_assert_received
mc_catchup_process_arg_t * catchup_process_args
static void mc_clear_stream_stats(mc_main_t *m)
void mc_enable_disable_mastership(mc_main_t *mcm, int we_can_be_master)
u32 mc_stream_send(mc_main_t *mcm, u32 stream_index, u32 buffer_index)
mc_peer_id_t our_ack_peer_id
static void catchup_send_fun(void *transport_main, uword opaque, u8 *data)
#define pool_free(p)
Free a pool.
The fine-grained event logger allows lightweight, thread-safe event logging at minimum cost...
void * mc_get_vlib_buffer(struct vlib_main_t *vm, u32 n_bytes, u32 *bi_return)
clib_error_t * serialize(serialize_main_t *m,...)
#define vec_free(V)
Free vector's memory (no header).
mhash_t elog_id_by_peer_id
static int mc_peer_id_compare(mc_peer_id_t a, mc_peer_id_t b)
mc_retry_t * retired_fifo
void mc_unserialize(mc_main_t *mcm, mc_stream_t *s, u32 buffer_index)
mc_stream_stats_t stats_last_clear
static void mc_byte_swap_msg_user_ack(mc_msg_user_ack_t *r)
static mc_stream_t * mc_stream_by_name(mc_main_t *m, char *name)
static void mhash_free(mhash_t *h)
mc_serialize_stream_msg_t * stream_msgs
clib_error_t * unserialize(serialize_main_t *m,...)
u32 we_can_be_relay_master
#define clib_fifo_free(f)
vlib_one_time_waiting_process_t ** procs_waiting_for_stream_name_pool
uword * global_msg_index_by_name
mc_relay_state_t relay_state
struct _mc_serialize_msg mc_serialize_msg_t
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
void( serialize_function_t)(serialize_main_t *m, va_list *va)
mc_stream_peer_stats_t stats_last_clear
uword * retry_index_by_local_sequence
static void mc_byte_swap_msg_join_or_leave_request(mc_msg_join_or_leave_request_t *r)
uword * elog_id_by_msg_name
mc_stream_and_buffer_t * mc_unserialize_stream_and_buffers
serialize_function_t serialize_mc_main
format_function_t * format_peer_id
clib_error_t * mc_serialize_va(mc_main_t *mc, u32 stream_index, u32 multiple_messages_per_vlib_buffer, mc_serialize_msg_t *msg, va_list *va)
#define vec_foreach(var, vec)
Vector iterator.
#define foreach_mc_msg_type
u32 * stream_msg_index_by_global_index
struct vlib_main_t * vlib_main
static mc_peer_id_t mc_byte_swap_peer_id(mc_peer_id_t i)
static uword catchup_request_fun(void *transport_main, u32 stream_index, mc_peer_id_t catchup_peer_id)
mc_stream_t * stream_vector
static void mc_byte_swap_msg_catchup_request(mc_msg_catchup_request_t *r)