|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
72 s =
format (s,
"%s", short_name);
83 u32 conn_index = va_arg (*args,
u32);
85 u32 verbose = va_arg (*args,
u32);
97 if (tc && verbose > 1)
119 s = (tp_vft->format_listener) (s, args);
127 u32 ho_index = va_arg (*args,
u32);
134 s =
format (s,
"%U", tp_vft->format_half_open, ho_index);
143 if (strlen (str) >
vec_len (input->buffer) - input->index)
146 for (
i = 0;
i < strlen (str);
i++)
148 if (input->buffer[
i + input->index] != str[
i])
159 u8 longest_match = 0, match;
160 char *str, *str_match = 0;
166 str = tp_vft->transport_options.name;
171 match = strlen (str);
172 if (match > longest_match)
175 longest_match = match;
195 s =
format (s,
"%s\n", tp_vft->transport_options.name);
207 kv.
key[0] =
ip->as_u64[0];
208 kv.
key[1] =
ip->as_u64[1];
211 rv = clib_bihash_search_inline_24_8 (ht, &kv);
224 kv.
key[0] = te->ip.as_u64[0];
225 kv.
key[1] = te->ip.as_u64[1];
229 clib_bihash_add_del_24_8 (ht, &kv, 1);
238 kv.
key[0] = te->ip.as_u64[0];
239 kv.
key[1] = te->ip.as_u64[1];
242 clib_bihash_add_del_24_8 (ht, &kv, 0);
292 return tp_vfts[tp].transport_options.service_type;
298 return tp_vfts[tp].transport_options.tx_type;
311 tp_vfts[tp].cleanup_ho (conn_index);
317 return tp_vfts[tp].connect (tep);
346 return tp_vfts[tp].start_listen (session_index, tep);
352 return tp_vfts[tp].stop_listen (conn_index);
367 tep->port = tc->lcl_port;
368 tep->is_ip4 = tc->is_ip4;
373 tep->port = tc->rmt_port;
374 tep->is_ip4 = tc->is_ip4;
384 if (
tp_vfts[tp].get_transport_endpoint)
399 if (
tp_vfts[tp].get_transport_listener_endpoint)
400 tp_vfts[tp].get_transport_listener_endpoint (conn_index, tep, is_lcl);
420 #define PORT_MASK ((1 << 16)- 1)
446 clib_net_to_host_u16 (
port));
480 clib_net_to_host_u16 (
port));
495 u16 min = 1024, max = 65535;
505 for (tries = 0; tries < limit; tries++)
537 return SESSION_E_NOIP;
538 addr->ip4.as_u32 =
ip4->as_u32;
545 return SESSION_E_NOIP;
554 ip46_address_t *lcl_addr)
564 prefix.fp_len = rmt->is_ip4 ? 32 : 128;
571 return SESSION_E_NOROUTE;
575 return SESSION_E_NOINTF;
584 ip46_address_t * lcl_addr,
u16 * lcl_port)
594 if (
ip_is_zero (&rmt_cfg->peer.ip, rmt_cfg->peer.is_ip4))
605 sizeof (rmt_cfg->peer.ip));
611 if (rmt_cfg->peer.port == 0)
615 return SESSION_E_NOPORT;
620 port = clib_net_to_host_u16 (rmt_cfg->peer.port);
625 return SESSION_E_PORTINUSE;
638 s =
format (s,
"%u us", t);
652 diff =
now - pacer->last_update;
653 s =
format (s,
"rate %lu bucket %ld t/p %.3f last_update %U burst %u",
654 pacer->bytes_per_sec, pacer->bucket, pacer->tokens_per_period,
662 u64 n_periods = (time_now - pacer->last_update);
665 if ((inc = (
f32) n_periods * pacer->tokens_per_period) > 10)
667 pacer->last_update = time_now;
668 pacer->bucket =
clib_min (pacer->bucket + inc, pacer->max_burst);
671 return pacer->bucket > 0 ? pacer->max_burst : 0;
677 pacer->bucket -= bytes;
686 ASSERT (rate_bytes_per_sec != 0);
687 pacer->bytes_per_sec = rate_bytes_per_sec;
710 return pacer->bytes_per_sec;
716 pacer->last_update = time_now;
717 pacer->bucket = bucket;
722 u64 rate_bytes_per_sec,
u32 start_bucket,
740 u64 rate_bytes_per_sec,
745 initial_bucket, 1e6);
820 if (vft->update_time)
832 (vft->enable) (
vm, is_en);
static clib_time_type_t transport_seconds_per_loop(u32 thread_index)
transport_proto_vft_t * tp_vfts
Per-type vector of transport protocol virtual function tables.
static void clib_spinlock_init(clib_spinlock_t *p)
void transport_connection_tx_pacer_reset(transport_connection_t *tc, u64 rate_bytes_per_sec, u32 start_bucket, clib_us_time_t rtt)
void transport_cleanup(transport_proto_t tp, u32 conn_index, u8 thread_index)
static u8 svm_fifo_set_event(svm_fifo_t *f)
Set fifo event flag.
int transport_alloc_local_endpoint(u8 proto, transport_endpoint_cfg_t *rmt_cfg, ip46_address_t *lcl_addr, u16 *lcl_port)
void sesssion_reschedule_tx(transport_connection_t *tc)
enum session_error_ session_error_t
static void spacer_reset(spacer_t *pacer, clib_us_time_t time_now, u64 bucket)
transport_tx_fn_type_t transport_protocol_tx_fn_type(transport_proto_t tp)
static clib_spinlock_t local_endpoints_lock
transport_proto_vft_t * transport_protocol_get_vft(transport_proto_t transport_proto)
Get transport virtual function table.
void transport_connection_tx_pacer_update(transport_connection_t *tc, u64 bytes_per_sec, clib_us_time_t rtt)
Update tx pacer pacing rate.
u8 transport_protocol_is_cl(transport_proto_t tp)
static void svm_fifo_unset_event(svm_fifo_t *f)
Unset fifo event flag.
static_always_inline void clib_spinlock_lock_if_init(clib_spinlock_t *p)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
#define CLIB_US_TIME_FREQ
static void session_wrk_update_time(session_worker_t *wrk, f64 now)
void transport_update_time(clib_time_type_t time_now, u8 thread_index)
#define clib_atomic_add_fetch(a, b)
u32 local_endpoints_table_memory
Transport table (preallocation) size parameters.
void transport_connection_tx_pacer_init(transport_connection_t *tc, u64 rate_bytes_per_sec, u32 initial_bucket)
Initialize tx pacer for connection.
u8 * format_transport_pacer(u8 *s, va_list *args)
static u8 transport_connection_is_tx_paced(transport_connection_t *tc)
Check if transport connection is paced.
enum transport_service_type_ transport_service_type_t
#define FIB_NODE_INDEX_INVALID
u32 transport_stop_listen(transport_proto_t tp, u32 conn_index)
struct _transport_proto_vft transport_proto_vft_t
void session_register_transport(transport_proto_t transport_proto, const transport_proto_vft_t *vft, u8 is_ip4, u32 output_node)
Initialize session layer for given transport proto and ip version.
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
void transport_connection_reschedule(transport_connection_t *tc)
int transport_alloc_local_port(u8 proto, ip46_address_t *ip)
Allocate local port and add if successful add entry to local endpoint table to mark the pair as used.
fib_node_index_t fib_table_lookup(u32 fib_index, const fib_prefix_t *prefix)
Perfom a longest prefix match in the non-forwarding table.
void transport_reset(transport_proto_t tp, u32 conn_index, u8 thread_index)
struct _transport_connection transport_connection_t
void transport_connection_tx_pacer_update_bytes(transport_connection_t *tc, u32 bytes)
static transport_endpoint_table_t local_endpoints_table
u32 transport_cl_thread
Thread for cl and ho that rely on cl allocs.
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
#define pool_put_index(p, i)
Free pool element with given index.
u32 transport_connection_tx_pacer_burst(transport_connection_t *tc)
Get tx pacer max burst.
u64 transport_connection_tx_pacer_rate(transport_connection_t *tc)
Get tx pacer current rate.
static void spacer_update_bucket(spacer_t *pacer, u32 bytes)
static u32 random_u32(u32 *seed)
32-bit random number generator
enum transport_dequeue_type_ transport_tx_fn_type_t
void * ip_interface_get_first_ip(u32 sw_if_index, u8 is_ip4)
svm_fifo_t * rx_fifo
Pointers to rx/tx buffers.
transport_proto_t session_add_transport_proto(void)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static session_main_t * vnet_get_session_main()
uword unformat_transport_proto(unformat_input_t *input, va_list *args)
void transport_connection_tx_pacer_reset_bucket(transport_connection_t *tc, u32 bucket)
Reset tx pacer bucket.
static void spacer_set_pace_rate(spacer_t *pacer, u64 rate_bytes_per_sec, clib_us_time_t rtt, clib_time_type_t sec_per_loop)
#define ENDPOINT_INVALID_INDEX
void transport_init(void)
static_always_inline uword vlib_get_thread_index(void)
int transport_connect(transport_proto_t tp, transport_endpoint_cfg_t *tep)
static u32 port_allocator_seed
u32 fib_node_index_t
A typedef of a node index.
void transport_fifos_init_ooo(transport_connection_t *tc)
static u8 unformat_transport_str_match(unformat_input_t *input, const char *str)
static u32 spacer_max_burst(spacer_t *pacer, clib_us_time_t time_now)
static u32 transport_max_tx_dequeue(transport_connection_t *tc)
static session_error_t transport_find_local_ip_for_remote(u32 *sw_if_index, transport_endpoint_t *rmt, ip46_address_t *lcl_addr)
@ TRANSPORT_CONNECTION_F_IS_TX_PACED
void transport_register_protocol(transport_proto_t transport_proto, const transport_proto_vft_t *vft, fib_protocol_t fib_proto, u32 output_node)
Register transport virtual function table.
u32 transport_endpoint_lookup(transport_endpoint_table_t *ht, u8 proto, ip46_address_t *ip, u16 port)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
u32 fib_entry_get_resolving_interface(fib_node_index_t entry_index)
void transport_get_endpoint(transport_proto_t tp, u32 conn_index, u32 thread_index, transport_endpoint_t *tep, u8 is_lcl)
static session_t * session_get(u32 si, u32 thread_index)
void transport_cleanup_half_open(transport_proto_t tp, u32 conn_index)
void transport_get_listener_endpoint(transport_proto_t tp, u32 conn_index, transport_endpoint_t *tep, u8 is_lcl)
void transport_update_pacer_time(u32 thread_index, clib_time_type_t now)
Request pacer time update.
void svm_fifo_init_ooo_lookup(svm_fifo_t *f, u8 ooo_type)
Initialize rbtrees used for ooo lookups.
clib_bihash_24_8_t transport_endpoint_table_t
#define clib_atomic_sub_fetch(a, b)
u8 * format_transport_half_open_connection(u8 *s, va_list *args)
void transport_share_local_endpoint(u8 proto, ip46_address_t *lcl_ip, u16 port)
static local_endpoint_t * transport_endpoint_new(void)
description fragment has unexpected format
struct local_endpoint_ local_endpoint_t
u32 transport_start_listen(transport_proto_t tp, u32 session_index, transport_endpoint_t *tep)
void transport_close(transport_proto_t tp, u32 conn_index, u8 thread_index)
u8 * format_transport_listen_connection(u8 *s, va_list *args)
transport_proto_t transport_register_new_protocol(const transport_proto_vft_t *vft, fib_protocol_t fib_proto, u32 output_node)
enum _transport_proto transport_proto_t
u8 * format_transport_connection(u8 *s, va_list *args)
#define vec_foreach(var, vec)
Vector iterator.
void transport_endpoint_table_del(transport_endpoint_table_t *ht, u8 proto, transport_endpoint_t *te)
static local_endpoint_t * local_endpoints
#define TRANSPORT_PACER_MAX_BURST
transport_service_type_t transport_protocol_service_type(transport_proto_t tp)
#define TRANSPORT_PACER_MIN_BURST
static void transport_endpoint_mark_used(u8 proto, ip46_address_t *ip, u16 port)
void transport_enable_disable(vlib_main_t *vm, u8 is_en)
@ TRANSPORT_SERVICE_CL
connectionless service
void transport_endpoint_cleanup(u8 proto, ip46_address_t *lcl_ip, u16 port)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
#define clib_clamp(x, lo, hi)
static transport_connection_t * transport_get_connection(transport_proto_t tp, u32 conn_index, u8 thread_index)
#define pool_get_zero(P, E)
Allocate an object E from a pool P and zero it.
u8 * format_transport_proto(u8 *s, va_list *args)
void transport_connection_update_tx_bytes(transport_connection_t *tc, u32 bytes)
Update tx bytes for paced transport connection.
u8 * format_clib_us_time(u8 *s, va_list *args)
u32 local_endpoints_table_buckets
u8 * format_transport_protos(u8 *s, va_list *args)
int transport_connection_attribute(transport_proto_t tp, u32 conn_index, u8 thread_index, u8 is_get, transport_endpt_attr_t *attr)
#define TRANSPORT_PACER_BURSTS_PER_RTT
static transport_connection_t * transport_get_listener(transport_proto_t tp, u32 conn_index)
static_always_inline void clib_spinlock_unlock_if_init(clib_spinlock_t *p)
void transport_endpoint_del(u32 tepi)
static u64 clib_cpu_time_now(void)
static vlib_thread_main_t * vlib_get_thread_main()
u8 * format_transport_proto_short(u8 *s, va_list *args)
static u32 svm_fifo_max_dequeue_cons(svm_fifo_t *f)
Fifo max bytes to dequeue optimized for consumer.
vl_api_interface_index_t sw_if_index
void transport_half_close(transport_proto_t tp, u32 conn_index, u8 thread_index)
static clib_us_time_t transport_us_time_now(u32 thread_index)
@ TRANSPORT_CONNECTION_F_DESCHED
Connection descheduled by the session layer.
static void default_get_transport_endpoint(transport_connection_t *tc, transport_endpoint_t *tep, u8 is_lcl)
static session_worker_t * session_main_get_worker(u32 thread_index)
Aggregate type for a prefix.
#define CLIB_US_TIME_PERIOD
static session_error_t transport_get_interface_ip(u32 sw_if_index, u8 is_ip4, ip46_address_t *addr)
void transport_endpoint_table_add(transport_endpoint_table_t *ht, u8 proto, transport_endpoint_t *te, u32 value)
static u64 spacer_pace_rate(spacer_t *pacer)
u8 ip_is_zero(ip46_address_t *ip46_address, u8 is_ip4)