X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fioam%2Fexport-common%2Fioam_export.h;h=f242ad7a788ae20a5804e85a3abaa51626c0d3f8;hb=2113c7f28b154df16af3637f67484971759a00a7;hp=672576ebded162a623143154ea348a663f2067ae;hpb=178cf493d009995b28fdf220f04c98860ff79a9b;p=vpp.git diff --git a/src/plugins/ioam/export-common/ioam_export.h b/src/plugins/ioam/export-common/ioam_export.h index 672576ebded..f242ad7a788 100644 --- a/src/plugins/ioam/export-common/ioam_export.h +++ b/src/plugins/ioam/export-common/ioam_export.h @@ -21,13 +21,15 @@ #include #include #include -#include +#include +#include #include #include #include #include #include +#include #include @@ -62,7 +64,7 @@ typedef struct /* Vector of per thread ioam_export_buffer_t to buffer pool index */ u32 *buffer_per_thread; /* Lock per thread to swap buffers between worker and timer process */ - volatile u32 **lockp; + clib_spinlock_t *lockp; /* time scale transform */ u32 unix_time_0; @@ -194,9 +196,7 @@ ioam_export_thread_buffer_init (ioam_export_main_t * em, vlib_main_t * vm) ioam_export_thread_buffer_free (em); return (-2); } - em->lockp[i] = clib_mem_alloc_aligned (CLIB_CACHE_LINE_BYTES, - CLIB_CACHE_LINE_BYTES); - clib_memset ((void *) em->lockp[i], 0, CLIB_CACHE_LINE_BYTES); + clib_spinlock_init (&em->lockp[i]); } return (1); } @@ -404,7 +404,7 @@ ioam_export_process_common (ioam_export_main_t * em, vlib_main_t * vm, 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) + if (CLIB_SPINLOCK_IS_LOCKED (&em->lockp[i])) continue; eb = pool_elt_at_index (em->buffer_pool, em->buffer_per_thread[i]); if (eb->records_in_this_buffer > 0 @@ -436,11 +436,10 @@ ioam_export_process_common (ioam_export_main_t * em, vlib_main_t * vm, */ for (i = 0; i < vec_len (thread_index); i++) { - while (clib_atomic_test_and_set (em->lockp[thread_index[i]])) - ; + clib_spinlock_lock (&em->lockp[thread_index[i]]); em->buffer_per_thread[thread_index[i]] = vec_pop (vec_buffer_indices); - clib_atomic_release (em->lockp[thread_index[i]]); + clib_spinlock_unlock (&em->lockp[thread_index[i]]); } /* Send the buffers */ @@ -479,7 +478,7 @@ do { \ from = vlib_frame_vector_args (F); \ n_left_from = (F)->n_vectors; \ next_index = (N)->cached_next_index; \ - while (clib_atomic_test_and_set ((EM)->lockp[(VM)->thread_index])); \ + clib_spinlock_lock (&(EM)->lockp[(VM)->thread_index]); \ my_buf = ioam_export_get_my_buffer (EM, (VM)->thread_index); \ my_buf->touched_at = vlib_time_now (VM); \ while (n_left_from > 0) \ @@ -622,7 +621,7 @@ do { \ } \ vlib_node_increment_counter (VM, export_node.index, \ EXPORT_ERROR_RECORDED, pkts_recorded); \ - *(EM)->lockp[(VM)->thread_index] = 0; \ + clib_spinlock_unlock (&(EM)->lockp[(VM)->thread_index]); \ } while(0) #endif /* __included_ioam_export_h__ */