aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2021-03-26 13:06:13 +0100
committerDamjan Marion <damarion@cisco.com>2021-03-26 16:33:21 +0100
commit6ffb7c61899eb782416cbd2f117042a583f189f7 (patch)
treef6bd132d53b0aded6b235d13200dba2864afc7d8 /src/vnet
parent83f13e45bcd4b1018aa29bb6f32324c32f3a11a8 (diff)
vlib: introduce vlib_get_main_by_index(), vlib_get_n_threads()
Type: improvement Change-Id: If3da7d4338470912f37ff1794620418d928fb77f Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/crypto/cli.c4
-rw-r--r--src/vnet/crypto/crypto.c17
-rw-r--r--src/vnet/crypto/crypto.h2
-rw-r--r--src/vnet/crypto/node.c5
-rw-r--r--src/vnet/interface/runtime.c9
-rw-r--r--src/vnet/interface/rx_queue_funcs.h2
-rw-r--r--src/vnet/session/application.c2
-rw-r--r--src/vnet/session/session.c2
-rw-r--r--src/vnet/session/session_debug.c2
-rw-r--r--src/vnet/session/session_node.c2
-rw-r--r--src/vnet/tcp/tcp.c2
-rw-r--r--src/vnet/unix/gdb_funcs.c4
12 files changed, 28 insertions, 25 deletions
diff --git a/src/vnet/crypto/cli.c b/src/vnet/crypto/cli.c
index d9635dd06d8..a6098a18e11 100644
--- a/src/vnet/crypto/cli.c
+++ b/src/vnet/crypto/cli.c
@@ -331,8 +331,8 @@ show_crypto_async_status_command_fn (vlib_main_t * vm,
for (i = skip_master; i < tm->n_vlib_mains; i++)
{
- vlib_node_state_t state =
- vlib_node_get_state (vlib_mains[i], cm->crypto_node_index);
+ vlib_node_state_t state = vlib_node_get_state (
+ vlib_get_main_by_index (i), cm->crypto_node_index);
if (state == VLIB_NODE_STATE_POLLING)
vlib_cli_output (vm, "threadId: %-6d POLLING", i);
if (state == VLIB_NODE_STATE_INTERRUPT)
diff --git a/src/vnet/crypto/crypto.c b/src/vnet/crypto/crypto.c
index 9d8504781a5..2ce1b895eb2 100644
--- a/src/vnet/crypto/crypto.c
+++ b/src/vnet/crypto/crypto.c
@@ -477,9 +477,9 @@ crypto_dispatch_enable_disable (int is_enable)
if (state_change)
for (i = skip_master; i < tm->n_vlib_mains; i++)
{
- if (state !=
- vlib_node_get_state (vlib_mains[i], cm->crypto_node_index))
- vlib_node_set_state (vlib_mains[i], cm->crypto_node_index, state);
+ vlib_main_t *ovm = vlib_get_main_by_index (i);
+ if (state != vlib_node_get_state (ovm, cm->crypto_node_index))
+ vlib_node_set_state (ovm, cm->crypto_node_index, state);
}
return 0;
}
@@ -587,9 +587,9 @@ vnet_crypto_request_async_mode (int is_enable)
if (state_change)
for (i = skip_master; i < tm->n_vlib_mains; i++)
{
- if (state !=
- vlib_node_get_state (vlib_mains[i], cm->crypto_node_index))
- vlib_node_set_state (vlib_mains[i], cm->crypto_node_index, state);
+ vlib_main_t *ovm = vlib_get_main_by_index (i);
+ if (state != vlib_node_get_state (ovm, cm->crypto_node_index))
+ vlib_node_set_state (ovm, cm->crypto_node_index, state);
}
if (is_enable)
@@ -623,8 +623,9 @@ vnet_crypto_set_async_dispatch_mode (u8 mode)
for (i = skip_master; i < tm->n_vlib_mains; i++)
{
- if (state != vlib_node_get_state (vlib_mains[i], cm->crypto_node_index))
- vlib_node_set_state (vlib_mains[i], cm->crypto_node_index, state);
+ vlib_main_t *ovm = vlib_get_main_by_index (i);
+ if (state != vlib_node_get_state (ovm, cm->crypto_node_index))
+ vlib_node_set_state (ovm, cm->crypto_node_index, state);
}
}
diff --git a/src/vnet/crypto/crypto.h b/src/vnet/crypto/crypto.h
index 127731866db..670be69fd4f 100644
--- a/src/vnet/crypto/crypto.h
+++ b/src/vnet/crypto/crypto.h
@@ -583,7 +583,7 @@ vnet_crypto_async_submit_open_frame (vlib_main_t * vm,
if (cm->dispatch_mode == VNET_CRYPTO_ASYNC_DISPATCH_INTERRUPT)
{
for (; i < tm->n_vlib_mains; i++)
- vlib_node_set_interrupt_pending (vlib_mains[i],
+ vlib_node_set_interrupt_pending (vlib_get_main_by_index (i),
cm->crypto_node_index);
}
}
diff --git a/src/vnet/crypto/node.c b/src/vnet/crypto/node.c
index e1186f49c0a..7f34ec10fff 100644
--- a/src/vnet/crypto/node.c
+++ b/src/vnet/crypto/node.c
@@ -138,8 +138,9 @@ crypto_dequeue_frame (vlib_main_t * vm, vlib_node_runtime_t * node,
if (cm->dispatch_mode == VNET_CRYPTO_ASYNC_DISPATCH_INTERRUPT
&& n_elts > 0)
{
- vlib_node_set_interrupt_pending (vlib_mains[enqueue_thread_idx],
- cm->crypto_node_index);
+ vlib_node_set_interrupt_pending (
+ vlib_get_main_by_index (enqueue_thread_idx),
+ cm->crypto_node_index);
}
n_elts = 0;
diff --git a/src/vnet/interface/runtime.c b/src/vnet/interface/runtime.c
index c7631272d00..20ac51f5b29 100644
--- a/src/vnet/interface/runtime.c
+++ b/src/vnet/interface/runtime.c
@@ -63,7 +63,7 @@ vnet_hw_if_update_runtime_data (vnet_main_t *vnm, u32 hw_if_index)
vnet_hw_if_rx_queue_t *rxq;
vnet_hw_if_rxq_poll_vector_t *pv, **d = 0;
vlib_node_state_t *per_thread_node_state = 0;
- u32 n_threads = vec_len (vlib_mains);
+ u32 n_threads = vlib_get_n_threads ();
u16 *per_thread_node_adaptive = 0;
int something_changed = 0;
clib_bitmap_t *pending_int = 0;
@@ -133,10 +133,11 @@ vnet_hw_if_update_runtime_data (vnet_main_t *vnm, u32 hw_if_index)
* unnecesary barrier */
for (int i = 0; i < n_threads; i++)
{
+ vlib_main_t *ovm = vlib_get_main_by_index (i);
vlib_node_state_t old_state;
vec_sort_with_function (d[i], poll_data_sort);
- old_state = vlib_node_get_state (vlib_mains[i], node_index);
+ old_state = vlib_node_get_state (ovm, node_index);
if (per_thread_node_state[i] != old_state)
{
something_changed = 1;
@@ -150,7 +151,7 @@ vnet_hw_if_update_runtime_data (vnet_main_t *vnm, u32 hw_if_index)
if (something_changed == 0)
{
vnet_hw_if_rx_node_runtime_t *rt;
- rt = vlib_node_get_runtime_data (vlib_mains[i], node_index);
+ rt = vlib_node_get_runtime_data (ovm, node_index);
if (vec_len (rt->rxq_poll_vector) != vec_len (d[i]))
something_changed = 1;
else if (memcmp (d[i], rt->rxq_poll_vector,
@@ -178,7 +179,7 @@ vnet_hw_if_update_runtime_data (vnet_main_t *vnm, u32 hw_if_index)
for (int i = 0; i < n_threads; i++)
{
- vlib_main_t *vm = vlib_mains[i];
+ vlib_main_t *vm = vlib_get_main_by_index (i);
vnet_hw_if_rx_node_runtime_t *rt;
rt = vlib_node_get_runtime_data (vm, node_index);
pv = rt->rxq_poll_vector;
diff --git a/src/vnet/interface/rx_queue_funcs.h b/src/vnet/interface/rx_queue_funcs.h
index c36263ea02b..e1e6c33988a 100644
--- a/src/vnet/interface/rx_queue_funcs.h
+++ b/src/vnet/interface/rx_queue_funcs.h
@@ -53,7 +53,7 @@ vnet_hw_if_rx_queue_set_int_pending (vnet_main_t *vnm, u32 queue_index)
{
vnet_hw_if_rx_queue_t *rxq = vnet_hw_if_get_rx_queue (vnm, queue_index);
vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, rxq->hw_if_index);
- vlib_main_t *vm = vlib_mains[rxq->thread_index];
+ vlib_main_t *vm = vlib_get_main_by_index (rxq->thread_index);
vnet_hw_if_rx_node_runtime_t *rt;
if (PREDICT_FALSE (rxq->mode != VNET_HW_IF_RX_MODE_INTERRUPT &&
rxq->mode != VNET_HW_IF_RX_MODE_ADAPTIVE))
diff --git a/src/vnet/session/application.c b/src/vnet/session/application.c
index 906a73e9d79..eb8a7169d8a 100644
--- a/src/vnet/session/application.c
+++ b/src/vnet/session/application.c
@@ -1553,7 +1553,7 @@ appliction_format_all_app_mq (vlib_main_t * vm)
application_t *app;
int i, n_threads;
- n_threads = vec_len (vlib_mains);
+ n_threads = vlib_get_n_threads ();
for (i = 0; i < n_threads; i++)
{
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c
index b7c1702dcf4..469ec0ed529 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -1689,7 +1689,7 @@ session_manager_main_enable (vlib_main_t * vm)
wrk->ctrl_head = clib_llist_make_head (wrk->event_elts, evt_list);
wrk->new_head = clib_llist_make_head (wrk->event_elts, evt_list);
wrk->old_head = clib_llist_make_head (wrk->event_elts, evt_list);
- wrk->vm = vlib_mains[i];
+ wrk->vm = vlib_get_main_by_index (i);
wrk->last_vlib_time = vlib_time_now (vm);
wrk->last_vlib_us_time = wrk->last_vlib_time * CLIB_US_TIME_FREQ;
vec_validate (wrk->session_to_enqueue, smm->last_transport_proto_type);
diff --git a/src/vnet/session/session_debug.c b/src/vnet/session/session_debug.c
index c042e9e53db..349d1ec9b46 100644
--- a/src/vnet/session/session_debug.c
+++ b/src/vnet/session/session_debug.c
@@ -120,7 +120,7 @@ session_debug_init (void)
void
dump_thread_0_event_queue (void)
{
- vlib_main_t *vm = &vlib_global_main;
+ vlib_main_t *vm = vlib_get_first_main ();
u32 my_thread_index = vm->thread_index;
session_event_t _e, *e = &_e;
svm_msg_q_shared_queue_t *sq;
diff --git a/src/vnet/session/session_node.c b/src/vnet/session/session_node.c
index 7ceb9ea1f10..ccf93cbbf61 100644
--- a/src/vnet/session/session_node.c
+++ b/src/vnet/session/session_node.c
@@ -1534,7 +1534,7 @@ VLIB_REGISTER_NODE (session_queue_node) =
static clib_error_t *
session_queue_exit (vlib_main_t * vm)
{
- if (vec_len (vlib_mains) < 2)
+ if (vlib_get_n_threads () < 2)
return 0;
/*
diff --git a/src/vnet/tcp/tcp.c b/src/vnet/tcp/tcp.c
index 161b8ef25a2..72161ec8e17 100644
--- a/src/vnet/tcp/tcp.c
+++ b/src/vnet/tcp/tcp.c
@@ -1330,7 +1330,7 @@ tcp_main_enable (vlib_main_t * vm)
vec_reset_length (wrk->pending_deq_acked);
vec_reset_length (wrk->pending_disconnects);
vec_reset_length (wrk->pending_resets);
- wrk->vm = vlib_mains[thread];
+ wrk->vm = vlib_get_main_by_index (thread);
wrk->max_timers_per_loop = 10;
if (thread > 0)
diff --git a/src/vnet/unix/gdb_funcs.c b/src/vnet/unix/gdb_funcs.c
index fc61c54f82f..ce8db3a8ae3 100644
--- a/src/vnet/unix/gdb_funcs.c
+++ b/src/vnet/unix/gdb_funcs.c
@@ -272,8 +272,8 @@ gdb_show_traces ()
goto done;
}
- s = format (s, "Packet %d\n%U\n\n", i + 1,
- format_vlib_trace, vlib_mains[0], traces[i]);
+ s = format (s, "Packet %d\n%U\n\n", i + 1, format_vlib_trace,
+ vlib_get_first_main (), traces[i]);
}
done: