aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/udp
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2022-10-24 18:59:06 -0700
committerDave Barach <openvpp@barachs.net>2022-10-25 17:19:03 +0000
commit4c89b189b2c712894764837a78e0a532bfe7e12f (patch)
tree77b1a6dec9032e2a826f09e3a3a2df075ff720cb /src/vnet/udp
parent1c29dfb7bbdddc3cdf8e2ed42c9d33f568466f7a (diff)
udp: use new wrk context for connections
Type: improvement Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: I9c4050f96c310f1e6eb2cae8d908c44968526c3c
Diffstat (limited to 'src/vnet/udp')
-rw-r--r--src/vnet/udp/udp.c13
-rw-r--r--src/vnet/udp/udp.h24
2 files changed, 19 insertions, 18 deletions
diff --git a/src/vnet/udp/udp.c b/src/vnet/udp/udp.c
index 5e4b29f25f6..e6ee9d8b37d 100644
--- a/src/vnet/udp/udp.c
+++ b/src/vnet/udp/udp.c
@@ -92,14 +92,13 @@ udp_connection_share_port (u16 lcl_port, u8 is_ip4)
udp_connection_t *
udp_connection_alloc (u32 thread_index)
{
- udp_main_t *um = &udp_main;
+ udp_worker_t *wrk = udp_worker_get (thread_index);
udp_connection_t *uc;
- pool_get_aligned_safe (um->connections[thread_index], uc,
- CLIB_CACHE_LINE_BYTES);
+ pool_get_aligned_safe (wrk->connections, uc, CLIB_CACHE_LINE_BYTES);
clib_memset (uc, 0, sizeof (*uc));
- uc->c_c_index = uc - um->connections[thread_index];
+ uc->c_c_index = uc - wrk->connections;
uc->c_thread_index = thread_index;
uc->c_proto = TRANSPORT_PROTO_UDP;
return uc;
@@ -108,11 +107,12 @@ udp_connection_alloc (u32 thread_index)
void
udp_connection_free (udp_connection_t * uc)
{
- u32 thread_index = uc->c_thread_index;
+ udp_worker_t *wrk = udp_worker_get (uc->c_thread_index);
+
clib_spinlock_free (&uc->rx_lock);
if (CLIB_DEBUG)
clib_memset (uc, 0xFA, sizeof (*uc));
- pool_put (udp_main.connections[thread_index], uc);
+ pool_put (wrk->connections, uc);
}
static void
@@ -548,7 +548,6 @@ udp_init (vlib_main_t * vm)
*/
num_threads = 1 /* main thread */ + tm->n_threads;
- vec_validate (um->connections, num_threads - 1);
vec_validate (um->wrk, num_threads - 1);
um->local_to_input_edge[UDP_IP4] =
diff --git a/src/vnet/udp/udp.h b/src/vnet/udp/udp.h
index ee71e365a84..71035248a5c 100644
--- a/src/vnet/udp/udp.h
+++ b/src/vnet/udp/udp.h
@@ -119,6 +119,7 @@ typedef enum
typedef struct udp_worker_
{
+ udp_connection_t *connections;
u32 *pending_cleanups;
} udp_worker_t;
@@ -141,10 +142,9 @@ typedef struct
u32 local_to_input_edge[N_UDP_AF];
/*
- * Per-worker thread udp connection pools used with session layer
+ * UDP transport layer per-thread context
*/
- udp_connection_t **connections;
udp_worker_t *wrk;
udp_connection_t *listener_pool;
@@ -166,12 +166,20 @@ extern vlib_node_registration_t udp6_output_node;
void udp_add_dst_port (udp_main_t * um, udp_dst_port_t dst_port,
char *dst_port_name, u8 is_ip4);
+always_inline udp_worker_t *
+udp_worker_get (u32 thread_index)
+{
+ return vec_elt_at_index (udp_main.wrk, thread_index);
+}
+
always_inline udp_connection_t *
udp_connection_get (u32 conn_index, u32 thread_index)
{
- if (pool_is_free_index (udp_main.connections[thread_index], conn_index))
+ udp_worker_t *wrk = udp_worker_get (thread_index);
+
+ if (pool_is_free_index (wrk->connections, conn_index))
return 0;
- return pool_elt_at_index (udp_main.connections[thread_index], conn_index);
+ return pool_elt_at_index (wrk->connections, conn_index);
}
always_inline udp_connection_t *
@@ -192,12 +200,6 @@ udp_connection_from_transport (transport_connection_t * tc)
return ((udp_connection_t *) tc);
}
-always_inline udp_worker_t *
-udp_worker_get (u32 thread_index)
-{
- return vec_elt_at_index (udp_main.wrk, thread_index);
-}
-
void udp_connection_free (udp_connection_t * uc);
udp_connection_t *udp_connection_alloc (u32 thread_index);
@@ -210,7 +212,7 @@ udp_connection_clone_safe (u32 connection_index, u32 thread_index)
new_c = udp_connection_alloc (current_thread_index);
new_index = new_c->c_c_index;
/* Connection pool always realloced with barrier */
- old_c = udp_main.connections[thread_index] + connection_index;
+ old_c = udp_main.wrk[thread_index].connections + connection_index;
clib_memcpy_fast (new_c, old_c, sizeof (*new_c));
old_c->flags |= UDP_CONN_F_MIGRATED;
new_c->c_thread_index = current_thread_index;