diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/acl/dataplane_node.c | 2 | ||||
-rw-r--r-- | src/plugins/acl/sess_mgmt_node.c | 11 | ||||
-rw-r--r-- | src/plugins/acl/session_inlines.h | 2 | ||||
-rw-r--r-- | src/plugins/dpdk/cryptodev/cryptodev_dp_api.c | 2 | ||||
-rw-r--r-- | src/plugins/flowprobe/flowprobe.c | 6 | ||||
-rw-r--r-- | src/plugins/hs_apps/echo_client.c | 2 | ||||
-rw-r--r-- | src/plugins/hs_apps/http_server.c | 2 | ||||
-rw-r--r-- | src/plugins/mdata/mdata.c | 13 | ||||
-rw-r--r-- | src/plugins/memif/device.c | 2 | ||||
-rw-r--r-- | src/plugins/memif/memif.c | 4 | ||||
-rw-r--r-- | src/plugins/memif/private.h | 2 | ||||
-rw-r--r-- | src/plugins/nat/lib/ipfix_logging.c | 12 | ||||
-rw-r--r-- | src/plugins/nat/nat44-ei/nat44_ei_ha.c | 8 | ||||
-rw-r--r-- | src/plugins/nat/nat64/nat64.c | 8 | ||||
-rw-r--r-- | src/plugins/nat/pnat/tests/pnat_test.c | 8 | ||||
-rw-r--r-- | src/plugins/nsim/nsim.c | 2 | ||||
-rw-r--r-- | src/plugins/perfmon/perfmon.c | 16 | ||||
-rw-r--r-- | src/plugins/tracedump/tracedump.c | 9 |
18 files changed, 57 insertions, 54 deletions
diff --git a/src/plugins/acl/dataplane_node.c b/src/plugins/acl/dataplane_node.c index 77aaa0e4402..25fa4e9410b 100644 --- a/src/plugins/acl/dataplane_node.c +++ b/src/plugins/acl/dataplane_node.c @@ -418,7 +418,7 @@ acl_fa_inner_node_fn (vlib_main_t * vm, { trace_bitmap |= 0x80000000; } - ASSERT (f_sess_id.thread_index < vec_len (vlib_mains)); + ASSERT (f_sess_id.thread_index < vlib_get_n_threads ()); b[0]->error = no_error_existing_session; acl_check_needed = 0; pkts_exist_session += 1; diff --git a/src/plugins/acl/sess_mgmt_node.c b/src/plugins/acl/sess_mgmt_node.c index ea969274052..3fc4f5e1982 100644 --- a/src/plugins/acl/sess_mgmt_node.c +++ b/src/plugins/acl/sess_mgmt_node.c @@ -361,8 +361,9 @@ send_one_worker_interrupt (vlib_main_t * vm, acl_main_t * am, if (!pw->interrupt_is_pending) { pw->interrupt_is_pending = 1; - vlib_node_set_interrupt_pending (vlib_mains[thread_index], - acl_fa_worker_session_cleaner_process_node.index); + vlib_node_set_interrupt_pending ( + vlib_get_main_by_index (thread_index), + acl_fa_worker_session_cleaner_process_node.index); elog_acl_maybe_trace_X1 (am, "send_one_worker_interrupt: send interrupt to worker %u", "i4", ((u32) thread_index)); @@ -560,7 +561,7 @@ send_interrupts_to_workers (vlib_main_t * vm, acl_main_t * am) { int i; /* Can't use vec_len(am->per_worker_data) since the threads might not have come up yet; */ - int n_threads = vec_len (vlib_mains); + int n_threads = vlib_get_n_threads (); for (i = 0; i < n_threads; i++) { send_one_worker_interrupt (vm, am, i); @@ -600,7 +601,7 @@ acl_fa_session_cleaner_process (vlib_main_t * vm, vlib_node_runtime_t * rt, * * Also, while we are at it, calculate the earliest we need to wake up. */ - for (ti = 0; ti < vec_len (vlib_mains); ti++) + for (ti = 0; ti < vlib_get_n_threads (); ti++) { if (ti >= vec_len (am->per_worker_data)) { @@ -746,7 +747,7 @@ acl_fa_session_cleaner_process (vlib_main_t * vm, vlib_node_runtime_t * rt, /* now wait till they all complete */ acl_log_info ("CLEANER mains len: %u per-worker len: %d", - vec_len (vlib_mains), + vlib_get_n_threads (), vec_len (am->per_worker_data)); vec_foreach (pw0, am->per_worker_data) { diff --git a/src/plugins/acl/session_inlines.h b/src/plugins/acl/session_inlines.h index 7a8b7cecd5e..edc8a7057ee 100644 --- a/src/plugins/acl/session_inlines.h +++ b/src/plugins/acl/session_inlines.h @@ -466,7 +466,7 @@ acl_fa_can_add_session (acl_main_t * am, int is_input, u32 sw_if_index) { u64 curr_sess_count; curr_sess_count = am->fa_session_total_adds - am->fa_session_total_dels; - return (curr_sess_count + vec_len (vlib_mains) < + return (curr_sess_count + vlib_get_n_threads () < am->fa_conn_table_max_entries); } diff --git a/src/plugins/dpdk/cryptodev/cryptodev_dp_api.c b/src/plugins/dpdk/cryptodev/cryptodev_dp_api.c index 054e45d7464..81f386c5c22 100644 --- a/src/plugins/dpdk/cryptodev/cryptodev_dp_api.c +++ b/src/plugins/dpdk/cryptodev/cryptodev_dp_api.c @@ -1735,7 +1735,7 @@ dpdk_cryptodev_init (vlib_main_t * vm) for (i = skip_master; i < tm->n_vlib_mains; i++) { ptd = cmt->per_thread_data + i; - numa = vlib_mains[i]->numa_node; + numa = vlib_get_main_by_index (i)->numa_node; ptd->aad_buf = rte_zmalloc_socket (0, CRYPTODEV_NB_CRYPTO_OPS * CRYPTODEV_MAX_AAD_SIZE, diff --git a/src/plugins/flowprobe/flowprobe.c b/src/plugins/flowprobe/flowprobe.c index 37abcfc5ce0..2a32fbf027f 100644 --- a/src/plugins/flowprobe/flowprobe.c +++ b/src/plugins/flowprobe/flowprobe.c @@ -1041,13 +1041,13 @@ timer_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f) vec_reset_length (event_data); int i; - if (vec_len (vlib_mains) == 0) + if (vlib_get_n_threads () == 0) vec_add1 (worker_vms, vm); else { - for (i = 0; i < vec_len (vlib_mains); i++) + for (i = 0; i < vlib_get_n_threads (); i++) { - worker_vm = vlib_mains[i]; + worker_vm = vlib_get_main_by_index (i); if (worker_vm) vec_add1 (worker_vms, worker_vm); } diff --git a/src/plugins/hs_apps/echo_client.c b/src/plugins/hs_apps/echo_client.c index 9da7bc5fd4b..4680ae2f8d1 100644 --- a/src/plugins/hs_apps/echo_client.c +++ b/src/plugins/hs_apps/echo_client.c @@ -940,7 +940,7 @@ echo_clients_command_fn (vlib_main_t * vm, /* Turn on the builtin client input nodes */ for (i = 0; i < thread_main->n_vlib_mains; i++) - vlib_node_set_state (vlib_mains[i], echo_clients_node.index, + vlib_node_set_state (vlib_get_main_by_index (i), echo_clients_node.index, VLIB_NODE_STATE_POLLING); if (preallocate_sessions) diff --git a/src/plugins/hs_apps/http_server.c b/src/plugins/hs_apps/http_server.c index e1674d5d2f1..72e3f3230b1 100644 --- a/src/plugins/hs_apps/http_server.c +++ b/src/plugins/hs_apps/http_server.c @@ -209,7 +209,7 @@ static void http_process_free (http_server_args * args) { vlib_node_runtime_t *rt; - vlib_main_t *vm = &vlib_global_main; + vlib_main_t *vm = vlib_get_first_main (); http_server_main_t *hsm = &http_server_main; vlib_node_t *n; u32 node_index; diff --git a/src/plugins/mdata/mdata.c b/src/plugins/mdata/mdata.c index f74564eb33c..69622960c39 100644 --- a/src/plugins/mdata/mdata.c +++ b/src/plugins/mdata/mdata.c @@ -147,20 +147,21 @@ mdata_enable_disable (mdata_main_t * mmp, int enable_disable) if (vec_len (mmp->before_per_thread) == 0) { mdata_none.node_index = ~0; - vec_validate (mmp->before_per_thread, vec_len (vlib_mains) - 1); + vec_validate (mmp->before_per_thread, vlib_get_n_threads () - 1); } /* Reset the per-node accumulator, see vec_validate_init_empty above */ vec_reset_length (mmp->modifies); - for (i = 0; i < vec_len (vlib_mains); i++) + for (i = 0; i < vlib_get_n_threads (); i++) { - if (vlib_mains[i] == 0) + vlib_main_t *ovm = vlib_get_main_by_index (i); + if (ovm == 0) continue; - clib_callback_data_enable_disable - (&vlib_mains[i]->vlib_node_runtime_perf_callbacks, - mdata_trace_callback, enable_disable); + clib_callback_data_enable_disable ( + &ovm->vlib_node_runtime_perf_callbacks, mdata_trace_callback, + enable_disable); } return rv; diff --git a/src/plugins/memif/device.c b/src/plugins/memif/device.c index 9debf2be204..101c3f79426 100644 --- a/src/plugins/memif/device.c +++ b/src/plugins/memif/device.c @@ -413,7 +413,7 @@ VNET_DEVICE_CLASS_TX_FN (memif_device_class) (vlib_main_t * vm, thread_index); u8 tx_queues = vec_len (mif->tx_queues); - if (tx_queues < vec_len (vlib_mains)) + if (tx_queues < vlib_get_n_threads ()) { ASSERT (tx_queues > 0); mq = vec_elt_at_index (mif->tx_queues, thread_index % tx_queues); diff --git a/src/plugins/memif/memif.c b/src/plugins/memif/memif.c index 80cd9026c83..31a34cc18e6 100644 --- a/src/plugins/memif/memif.c +++ b/src/plugins/memif/memif.c @@ -306,8 +306,8 @@ memif_connect (memif_if_t * mif) mq->int_clib_file_index); } ti = vnet_hw_if_get_rx_queue_thread_index (vnm, qi); - mq->buffer_pool_index = - vlib_buffer_pool_get_default_for_numa (vm, vlib_mains[ti]->numa_node); + mq->buffer_pool_index = vlib_buffer_pool_get_default_for_numa ( + vm, vlib_get_main_by_index (ti)->numa_node); rv = vnet_hw_if_set_rx_queue_mode (vnm, qi, VNET_HW_IF_RX_MODE_DEFAULT); vnet_hw_if_update_runtime_data (vnm, mif->hw_if_index); diff --git a/src/plugins/memif/private.h b/src/plugins/memif/private.h index a53aca5a823..22b2ab8a6d2 100644 --- a/src/plugins/memif/private.h +++ b/src/plugins/memif/private.h @@ -24,7 +24,7 @@ #define MEMIF_DEFAULT_TX_QUEUES 1 #define MEMIF_DEFAULT_BUFFER_SIZE 2048 -#define MEMIF_MAX_M2S_RING (vec_len (vlib_mains)) +#define MEMIF_MAX_M2S_RING (vlib_get_n_threads ()) #define MEMIF_MAX_S2M_RING 256 #define MEMIF_MAX_REGION 256 #define MEMIF_MAX_LOG2_RING_SIZE 14 diff --git a/src/plugins/nat/lib/ipfix_logging.c b/src/plugins/nat/lib/ipfix_logging.c index d4ede6bdd95..38a2cc9931b 100644 --- a/src/plugins/nat/lib/ipfix_logging.c +++ b/src/plugins/nat/lib/ipfix_logging.c @@ -1288,12 +1288,12 @@ nat_ipfix_flush_from_main (void) if (PREDICT_FALSE (!silm->worker_vms)) { - for (i = 1; i < vec_len (vlib_mains); i++) - { - worker_vm = vlib_mains[i]; - if (worker_vm) - vec_add1 (silm->worker_vms, worker_vm); - } + for (i = 1; i < vlib_get_n_threads (); i++) + { + worker_vm = vlib_get_main_by_index (i); + if (worker_vm) + vec_add1 (silm->worker_vms, worker_vm); + } } /* Trigger flush for each worker thread */ diff --git a/src/plugins/nat/nat44-ei/nat44_ei_ha.c b/src/plugins/nat/nat44-ei/nat44_ei_ha.c index ca99efcf8ca..3d634dc61f2 100644 --- a/src/plugins/nat/nat44-ei/nat44_ei_ha.c +++ b/src/plugins/nat/nat44-ei/nat44_ei_ha.c @@ -711,7 +711,7 @@ nat_ha_send (vlib_frame_t * f, vlib_buffer_t * b, u8 is_resync, nat_ha_message_header_t *h; ip4_header_t *ip; udp_header_t *udp; - vlib_main_t *vm = vlib_mains[thread_index]; + vlib_main_t *vm = vlib_get_main_by_index (thread_index); ip = vlib_buffer_get_current (b); udp = ip4_next_header (ip); @@ -737,7 +737,7 @@ nat_ha_event_add (nat_ha_event_t * event, u8 do_flush, u32 thread_index, nat44_ei_main_t *nm = &nat44_ei_main; nat_ha_main_t *ha = &nat_ha_main; nat_ha_per_thread_data_t *td = &ha->per_thread_data[thread_index]; - vlib_main_t *vm = vlib_mains[thread_index]; + vlib_main_t *vm = vlib_get_main_by_index (thread_index); vlib_buffer_t *b = 0; vlib_frame_t *f; u32 bi = ~0, offset; @@ -967,12 +967,12 @@ nat_ha_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f) vlib_process_wait_for_event_or_clock (vm, 1.0); event_type = vlib_process_get_events (vm, &event_data); vec_reset_length (event_data); - for (ti = 0; ti < vec_len (vlib_mains); ti++) + for (ti = 0; ti < vlib_get_n_threads (); ti++) { if (ti >= vec_len (ha->per_thread_data)) continue; - vlib_node_set_interrupt_pending (vlib_mains[ti], + vlib_node_set_interrupt_pending (vlib_get_main_by_index (ti), nat_ha_worker_node.index); } } diff --git a/src/plugins/nat/nat64/nat64.c b/src/plugins/nat/nat64/nat64.c index 6e5ceecb76f..1c1cdfba3fb 100644 --- a/src/plugins/nat/nat64/nat64.c +++ b/src/plugins/nat/nat64/nat64.c @@ -998,7 +998,7 @@ nat64_add_del_static_bib_entry (ip6_address_t * in_addr, static_bib->is_add = is_add; static_bib->thread_index = thread_index; static_bib->done = 0; - worker_vm = vlib_mains[thread_index]; + worker_vm = vlib_get_main_by_index (thread_index); if (worker_vm) vlib_node_set_interrupt_pending (worker_vm, nat64_static_bib_worker_node.index); @@ -1452,13 +1452,13 @@ nat64_expire_walk_fn (vlib_main_t * vm, vlib_node_runtime_t * rt, int i; uword event_type, *event_data = 0; - if (vec_len (vlib_mains) == 0) + if (vlib_get_n_threads () == 0) vec_add1 (worker_vms, vm); else { - for (i = 0; i < vec_len (vlib_mains); i++) + for (i = 0; i < vlib_get_n_threads (); i++) { - worker_vm = vlib_mains[i]; + worker_vm = vlib_get_main_by_index (i); if (worker_vm) vec_add1 (worker_vms, worker_vm); } diff --git a/src/plugins/nat/pnat/tests/pnat_test.c b/src/plugins/nat/pnat/tests/pnat_test.c index ab55e7ef49d..fd91ab2f88a 100644 --- a/src/plugins/nat/pnat/tests/pnat_test.c +++ b/src/plugins/nat/pnat/tests/pnat_test.c @@ -347,7 +347,7 @@ extern vlib_node_registration_t pnat_input_node; static void test_table(test_t *t, int no_tests) { // walk through table of tests int i; - vlib_main_t *vm = &vlib_global_main; + vlib_main_t *vm = vlib_get_first_main(); /* Generate packet data */ for (i = 0; i < no_tests; i++) { @@ -376,7 +376,7 @@ static void test_table(test_t *t, int no_tests) { void test_performance(void) { pnat_main_t *pm = &pnat_main; int i; - vlib_main_t *vm = &vlib_global_main; + vlib_main_t *vm = vlib_get_first_main(); for (i = 0; i < sizeof(rules) / sizeof(rules[0]); i++) { add_translation(&rules[i]); @@ -505,7 +505,7 @@ void test_api(void) { void test_checksum(void) { int i; - vlib_main_t *vm = &vlib_global_main; + vlib_main_t *vm = vlib_get_first_main(); pnat_main_t *pm = &pnat_main; test_t test = { @@ -559,7 +559,7 @@ int main(int argc, char **argv) { clib_mem_init(0, 3ULL << 30); - vlib_main_t *vm = &vlib_global_main; + vlib_main_t *vm = vlib_get_first_main(); buffers_vector = buffer_init(buffers_vector, 256); diff --git a/src/plugins/nsim/nsim.c b/src/plugins/nsim/nsim.c index 00bf84ed152..272067382d8 100644 --- a/src/plugins/nsim/nsim.c +++ b/src/plugins/nsim/nsim.c @@ -215,7 +215,7 @@ nsim_configure (nsim_main_t * nsm, f64 bandwidth, f64 delay, f64 packet_size, i = (!nsm->poll_main_thread && num_workers) ? 1 : 0; for (; i < num_workers + 1; i++) { - vlib_main_t *this_vm = vlib_mains[i]; + vlib_main_t *this_vm = vlib_get_main_by_index (i); vlib_node_set_state (this_vm, nsim_input_node.index, VLIB_NODE_STATE_POLLING); diff --git a/src/plugins/perfmon/perfmon.c b/src/plugins/perfmon/perfmon.c index 7a69d454fd0..316e7a5d60a 100644 --- a/src/plugins/perfmon/perfmon.c +++ b/src/plugins/perfmon/perfmon.c @@ -48,8 +48,8 @@ perfmon_reset (vlib_main_t *vm) uword page_size = clib_mem_get_page_size (); if (pm->is_running) - for (int i = 0; i < vec_len (vlib_mains); i++) - vlib_node_set_dispatch_wrapper (vlib_mains[i], 0); + for (int i = 0; i < vlib_get_n_threads (); i++) + vlib_node_set_dispatch_wrapper (vlib_get_main_by_index (i), 0); for (int i = 0; i < vec_len (pm->fds_to_close); i++) close (pm->fds_to_close[i]); @@ -104,7 +104,7 @@ perfmon_set (vlib_main_t *vm, perfmon_bundle_t *b) { vec_add2 (pm->default_instance_type, it, 1); it->name = is_node ? "Thread/Node" : "Thread"; - for (int i = 0; i < vec_len (vlib_mains); i++) + for (int i = 0; i < vlib_get_n_threads (); i++) { vlib_worker_thread_t *w = vlib_worker_threads + i; perfmon_instance_t *in; @@ -114,7 +114,7 @@ perfmon_set (vlib_main_t *vm, perfmon_bundle_t *b) in->name = (char *) format (0, "%s (%u)%c", w->name, i, 0); } if (is_node) - vec_validate (pm->thread_runtimes, vec_len (vlib_mains) - 1); + vec_validate (pm->thread_runtimes, vlib_get_n_threads () - 1); } else { @@ -234,8 +234,8 @@ perfmon_start (vlib_main_t *vm) } if (pm->active_bundle->type == PERFMON_BUNDLE_TYPE_NODE) { - for (int i = 0; i < vec_len (vlib_mains); i++) - vlib_node_set_dispatch_wrapper (vlib_mains[i], + for (int i = 0; i < vlib_get_n_threads (); i++) + vlib_node_set_dispatch_wrapper (vlib_get_main_by_index (i), perfmon_dispatch_wrapper); } pm->sample_time = vlib_time_now (vm); @@ -254,8 +254,8 @@ perfmon_stop (vlib_main_t *vm) if (pm->active_bundle->type == PERFMON_BUNDLE_TYPE_NODE) { - for (int i = 0; i < vec_len (vlib_mains); i++) - vlib_node_set_dispatch_wrapper (vlib_mains[i], 0); + for (int i = 0; i < vlib_get_n_threads (); i++) + vlib_node_set_dispatch_wrapper (vlib_get_main_by_index (i), 0); } for (int i = 0; i < n_groups; i++) diff --git a/src/plugins/tracedump/tracedump.c b/src/plugins/tracedump/tracedump.c index ab86ef987e2..7c83ba25dc9 100644 --- a/src/plugins/tracedump/tracedump.c +++ b/src/plugins/tracedump/tracedump.c @@ -224,10 +224,10 @@ vl_api_trace_dump_t_handler (vl_api_trace_dump_t * mp) if (vec_len (client_trace_cache) == 0 && (iterator_thread_id != ~0 || iterator_position != ~0)) { - vlib_worker_thread_barrier_sync (&vlib_global_main); + vlib_worker_thread_barrier_sync (vlib_get_first_main ()); /* Make a slot for each worker thread */ - vec_validate (client_trace_cache, vec_len (vlib_mains) - 1); + vec_validate (client_trace_cache, vlib_get_n_threads () - 1); i = 0; /* *INDENT-OFF* */ @@ -250,7 +250,7 @@ vl_api_trace_dump_t_handler (vl_api_trace_dump_t * mp) i++; })); /* *INDENT-ON* */ - vlib_worker_thread_barrier_release (&vlib_global_main); + vlib_worker_thread_barrier_release (vlib_get_first_main ()); } /* Save the cache, one way or the other */ @@ -268,7 +268,8 @@ vl_api_trace_dump_t_handler (vl_api_trace_dump_t * mp) vec_reset_length (s); - s = format (s, "%U", format_vlib_trace, &vlib_global_main, th[0]); + s = + format (s, "%U", format_vlib_trace, vlib_get_first_main (), th[0]); dmp = vl_msg_api_alloc (sizeof (*dmp) + vec_len (s)); dmp->_vl_msg_id = |