diff options
author | 2016-10-12 05:54:09 -0700 | |
---|---|---|
committer | 2016-12-09 06:15:02 +0000 | |
commit | 6d403a013276f095e542c9b6281db96354fa6f07 (patch) | |
tree | 3954b21a8fe2bb789d42f6f6234344d39c4e1e4d /plugins/ioam-plugin/ioam/export/ioam_export_thread.c | |
parent | c9b20bc7a5399fd1e7bf2d33e7c4f1f08ef1c1e4 (diff) |
VPP-470: Introduce VxLAN-GPE as transport for iOAM.
See Jira ticket for more details
- New plugins created to (a) Add VxLAN-GPE as transport (b) Provide export infra for
VxLAN-GPE.
Change-Id: Ife50c7434f53d17a4783062310f73d063d53494c
Signed-off-by: Vengada Govindan <venggovi@cisco.com>
Diffstat (limited to 'plugins/ioam-plugin/ioam/export/ioam_export_thread.c')
-rw-r--r-- | plugins/ioam-plugin/ioam/export/ioam_export_thread.c | 112 |
1 files changed, 4 insertions, 108 deletions
diff --git a/plugins/ioam-plugin/ioam/export/ioam_export_thread.c b/plugins/ioam-plugin/ioam/export/ioam_export_thread.c index e64b0bfb..d2eb2009 100644 --- a/plugins/ioam-plugin/ioam/export/ioam_export_thread.c +++ b/plugins/ioam-plugin/ioam/export/ioam_export_thread.c @@ -17,121 +17,17 @@ */ #include <vnet/api_errno.h> #include <vppinfra/pool.h> -#include "ioam_export.h" +#include <ioam/export-common/ioam_export.h> static vlib_node_registration_t ioam_export_process_node; -#define EXPORT_TIMEOUT (20.0) -#define THREAD_PERIOD (30.0) static uword ioam_export_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f) { - ioam_export_main_t *em = &ioam_export_main; - f64 now; - f64 timeout = 30.0; - uword event_type; - uword *event_data = 0; - int i; - ioam_export_buffer_t *eb = 0, *new_eb = 0; - u32 *vec_buffer_indices = 0; - u32 *vec_buffer_to_be_sent = 0; - u32 *thread_index = 0; - u32 new_pool_index = 0; - - em->export_process_node_index = ioam_export_process_node.index; - /* Wait for Godot... */ - vlib_process_wait_for_event_or_clock (vm, 1e9); - event_type = vlib_process_get_events (vm, &event_data); - if (event_type != 1) - clib_warning ("bogus kickoff event received, %d", event_type); - vec_reset_length (event_data); - - while (1) - { - vlib_process_wait_for_event_or_clock (vm, timeout); - event_type = vlib_process_get_events (vm, &event_data); - switch (event_type) - { - case 2: /* Stop and Wait for kickoff again */ - timeout = 1e9; - break; - case 1: /* kickoff : Check for unsent buffers */ - timeout = THREAD_PERIOD; - break; - case ~0: /* timeout */ - break; - } - vec_reset_length (event_data); - now = vlib_time_now (vm); - /* - * Create buffers for threads that are not active enough - * to send out the export records - */ - for (i = 0; i < vec_len (em->buffer_per_thread); i++) - { - /* If the worker thread is processing export records ignore further checks */ - if (*em->lockp[i] == 1) - continue; - eb = pool_elt_at_index (em->buffer_pool, em->buffer_per_thread[i]); - if (eb->records_in_this_buffer > 0 && now > (eb->touched_at + EXPORT_TIMEOUT)) - { - pool_get_aligned (em->buffer_pool, new_eb, - CLIB_CACHE_LINE_BYTES); - memset (new_eb, 0, sizeof (*new_eb)); - if (ioam_export_init_buffer (vm, new_eb) == 1) - { - new_pool_index = new_eb - em->buffer_pool; - vec_add (vec_buffer_indices, &new_pool_index, 1); - vec_add (vec_buffer_to_be_sent, &em->buffer_per_thread[i], - 1); - vec_add (thread_index, &i, 1); - } - else - { - pool_put (em->buffer_pool, new_eb); - /*Give up */ - goto CLEANUP; - } - } - } - if (vec_len (thread_index) != 0) - { - /* - * Now swap the buffers out - */ - for (i = 0; i < vec_len (thread_index); i++) - { - while (__sync_lock_test_and_set (em->lockp[thread_index[i]], 1)) - ; - em->buffer_per_thread[thread_index[i]] = - vec_pop (vec_buffer_indices); - *em->lockp[thread_index[i]] = 0; - } - - /* Send the buffers */ - for (i = 0; i < vec_len (vec_buffer_to_be_sent); i++) - { - eb = - pool_elt_at_index (em->buffer_pool, vec_buffer_to_be_sent[i]); - ioam_export_send_buffer (vm, eb); - pool_put (em->buffer_pool, eb); - } - } - - CLEANUP: - /* Free any leftover/unused buffers and everything that was allocated */ - for (i = 0; i < vec_len (vec_buffer_indices); i++) - { - new_eb = pool_elt_at_index (em->buffer_pool, vec_buffer_indices[i]); - vlib_buffer_free (vm, &new_eb->buffer_index, 1); - pool_put (em->buffer_pool, new_eb); - } - vec_free (vec_buffer_indices); - vec_free (vec_buffer_to_be_sent); - vec_free (thread_index); - } - return 0; /* not so much */ + return (ioam_export_process_common(&ioam_export_main, + vm, rt, f, + ioam_export_process_node.index)); } VLIB_REGISTER_NODE (ioam_export_process_node, static) = |