40 memset (&a, 0,
sizeof (a));
204 u8 fifo_usage = fifo_in_use * 100 / fifo_size;
211 if (seg_usage < pm->low_watermark && fifo_usage > 50)
212 update_size = fifo_in_use;
213 else if (seg_usage < pm->high_watermark && fifo_usage > 80)
214 update_size = fifo_in_use;
216 update_size =
clib_min (update_size, sm->max_fifo_size - fifo_size);
225 update_size = (bytes / 2);
227 ASSERT (fifo_size >= 4096);
228 update_size =
clib_min (update_size, fifo_size - 4096);
311 u32 ao_thread_index = ao_tx_fifo->master_thread_index;
312 u32 ao_session_index = ao_tx_fifo->master_session_index;
326 u32 max_dequeue, proxy_index;
327 int actual_transfer __attribute__ ((unused));
332 ASSERT (rx_fifo->master_thread_index == thread_index);
333 ASSERT (tx_fifo->master_thread_index == thread_index);
342 max_dequeue, pm->
rx_buf[thread_index]);
356 a->api_context = proxy_index;
537 u8 thread_index = proxy_tx_fifo->master_thread_index;
538 u32 session_index = proxy_tx_fifo->master_session_index;
621 u32 segment_size = 512 << 20;
628 a->name =
format (0,
"proxy-server");
667 a->name =
format (0,
"proxy-active-open");
681 | APP_OPTIONS_FLAGS_IS_PROXY;
719 for (i = 0; i < num_threads; i++)
738 for (i = 0; i < num_threads; i++)
755 char *default_server_uri =
"tcp://0.0.0.0/23";
756 char *default_client_uri =
"tcp://6.0.2.2/23";
775 if (
unformat (input,
"fifo-size %U",
778 else if (
unformat (input,
"max-fifo-size %U",
781 else if (
unformat (input,
"high-watermark %d", &tmp32))
783 else if (
unformat (input,
"low-watermark %d", &tmp32))
789 else if (
unformat (input,
"private-segment-count %d",
792 else if (
unformat (input,
"private-segment-size %U",
795 if (tmp64 >= 0x100000000ULL)
797 (0,
"private segment size %lld (%llu) too large", tmp64, tmp64);
811 clib_warning (
"No server-uri provided, Using default: %s",
817 clib_warning (
"No client-uri provided, Using default: %s",
839 .path =
"test proxy server",
840 .short_help =
"test proxy server [server-uri <tcp://ip/port>]" 841 "[client-uri <tcp://ip/port>][fifo-size <nn>[k|m]]" 842 "[max-fifo-size <nn>[k|m]][high-watermark <nn>]" 843 "[low-watermark <nn>][rcv-buf-size <nn>][prealloc-fifos <nn>]" 844 "[private-segment-size <mem>][private-segment-count <nn>]",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
#define hash_set(h, key, value)
u32 max_fifo_size
max fifo size
u32 private_segment_count
Number of private fifo segs.
volatile int ao_disconnected
#define hash_unset(h, key)
static void svm_fifo_set_size(svm_fifo_t *f, u32 size)
struct _vnet_connect_args vnet_connect_args_t
fifo_segment_t * segment_manager_get_segment(segment_manager_t *sm, u32 segment_index)
Reads a segment from the segment manager's pool without lock.
#define pool_get_zero(P, E)
Allocate an object E from a pool P and zero it.
static u32 svm_fifo_size(svm_fifo_t *f)
u32 session_index
Index in thread pool where session was allocated.
static int proxy_accept_callback(session_t *s)
static svm_msg_q_t * session_main_get_vpp_event_queue(u32 thread_index)
static void proxy_reset_callback(session_t *s)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
transport_connection_t * session_get_transport(session_t *s)
svm_fifo_t * rx_fifo
Pointers to rx/tx buffers.
u8 fifo_segment_get_mem_usage(fifo_segment_t *fs)
static int active_open_rx_callback(session_t *s)
static_always_inline void clib_spinlock_unlock_if_init(clib_spinlock_t *p)
static clib_error_t * proxy_server_create_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
struct _tcp_connection tcp_connection_t
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
void session_send_rpc_evt_to_thread(u32 thread_index, void *fp, void *rpc_args)
int svm_fifo_peek(svm_fifo_t *f, u32 offset, u32 len, u8 *dst)
Peek data from fifo.
uword * proxy_session_by_server_handle
static u32 svm_fifo_max_enqueue(svm_fifo_t *f)
void(* session_reset_callback)(session_t *s)
Notify app that session was reset.
struct _vnet_bind_args_t vnet_listen_args_t
static int active_open_create_callback(session_t *s)
svm_fifo_t * server_rx_fifo
static session_handle_t session_handle(session_t *s)
#define clib_memcpy(d, s, n)
enum session_ft_action_ session_ft_action_t
u8 prealloc_fifos
Request fifo preallocation.
u32 fifo_size
initial fifo size
#define VLIB_INIT_FUNCTION(x)
struct _vnet_disconnect_args_t vnet_disconnect_args_t
static u32 svm_fifo_max_dequeue_cons(svm_fifo_t *f)
Fifo max bytes to dequeue optimized for consumer.
static session_cb_vft_t proxy_session_cb_vft
#define clib_error_return(e, args...)
void vl_api_rpc_call_main_thread(void *fp, u8 *data, u32 data_length)
session_handle_t vpp_active_open_handle
u32 server_app_index
server app index
static proxy_session_t * proxy_get_active_open(proxy_main_t *pm, session_handle_t handle)
int session_send_io_evt_to_thread(svm_fifo_t *f, session_evt_type_t evt_type)
volatile int active_open_establishing
static int proxy_connected_callback(u32 app_index, u32 api_context, session_t *s, session_error_t err)
#define SESSION_INVALID_HANDLE
struct _vnet_app_attach_args_t vnet_app_attach_args_t
static void clib_spinlock_init(clib_spinlock_t *p)
static int proxy_tx_callback(session_t *proxy_s)
session_handle_t vpp_server_handle
clib_error_t * proxy_main_init(vlib_main_t *vm)
static int common_fifo_tuning_callback(session_t *s, svm_fifo_t *f, session_ft_action_t act, u32 bytes)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
proxy_session_t * sessions
Session pool, shared.
void tcp_send_ack(tcp_connection_t *tc)
static session_t * session_get_from_handle(session_handle_t handle)
static void active_open_disconnect_callback(session_t *s)
static void proxy_cb_fn(void *data, u32 data_len)
#define pool_put(P, E)
Free an object E in pool P.
u8 low_watermark
low watermark (%)
static int proxy_server_create(vlib_main_t *vm)
static u32 svm_fifo_max_dequeue_prod(svm_fifo_t *f)
Fifo max bytes to dequeue optimized for producer.
clib_error_t * vnet_session_enable_disable(vlib_main_t *vm, u8 is_en)
int vnet_application_attach(vnet_app_attach_args_t *a)
Attach application to vpp.
static u8 svm_fifo_set_event(svm_fifo_t *f)
Set fifo event flag.
svm_msg_q_t ** active_open_event_queue
u32 active_open_client_index
active open API client handle
static_always_inline uword vlib_get_thread_index(void)
sll srl srl sll sra u16x4 i
#define vec_free(V)
Free vector's memory (no header).
static int active_open_connected_callback(u32 app_index, u32 opaque, session_t *s, session_error_t err)
#define clib_warning(format, args...)
u32 server_client_index
server API client handle
struct _transport_connection transport_connection_t
static void proxy_call_main_thread(vnet_connect_args_t *a)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
static void active_open_reset_callback(session_t *s)
volatile int po_disconnected
static void proxy_session_free(proxy_session_t *ps)
svm_msg_q_t ** server_event_queue
per-thread vectors
#define VLIB_CLI_COMMAND(x,...)
u32 active_open_app_index
active open index after attach
#define hash_create(elts, value_bytes)
#define uword_to_pointer(u, type)
static int proxy_server_attach()
uword * proxy_session_by_active_open_handle
static int proxy_rx_callback(session_t *s)
u8 ** rx_buf
intermediate rx buffers
static proxy_session_t * proxy_get_passive_open(proxy_main_t *pm, session_handle_t handle)
static void svm_fifo_add_want_deq_ntf(svm_fifo_t *f, u8 ntf_type)
Set specific want notification flag.
clib_spinlock_t sessions_lock
static uword pointer_to_uword(const void *p)
u8 thread_index
Index of the thread that allocated the session.
u32 private_segment_size
size of private fifo segs
static int active_open_attach(void)
u8 high_watermark
high watermark (%)
svm_fifo_t * server_tx_fifo
static void proxy_disconnect_callback(session_t *s)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
volatile u8 session_state
State in session layer state machine.
int vnet_bind_uri(vnet_listen_args_t *a)
int vnet_disconnect_session(vnet_disconnect_args_t *a)
struct _segment_manager segment_manager_t
segment_manager_t * segment_manager_get(u32 index)
static void proxy_force_ack(void *handlep)
int session_send_io_evt_to_thread_custom(void *data, u32 thread_index, session_evt_type_t evt_type)
static void proxy_try_close_session(session_t *s, int is_active_open)
static int proxy_add_segment_callback(u32 client_index, u64 segment_handle)
static struct option options[]
static int proxy_server_listen()
static vlib_thread_main_t * vlib_get_thread_main()
static u32 vlib_num_workers()
enum session_error_ session_error_t
static session_cb_vft_t active_open_clients
static int active_open_tx_callback(session_t *ao_s)
int(* session_accept_callback)(session_t *new_session)
Notify server of newly accepted session.
static void proxy_try_delete_session(session_t *s, u8 is_active_open)
int vnet_connect_uri(vnet_connect_args_t *a)
struct _svm_fifo svm_fifo_t
static_always_inline void clib_spinlock_lock_if_init(clib_spinlock_t *p)
static void active_open_cleanup_callback(session_t *s, session_cleanup_ntf_t ntf)
void svm_fifo_init_ooo_lookup(svm_fifo_t *f, u8 ooo_type)
Initialize rbtrees used for ooo lookups.
static void proxy_cleanup_callback(session_t *s, session_cleanup_ntf_t ntf)