X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvlib%2Fcounter.h;h=04ab83769cce163eacb860e858f9317731594749;hb=ddba67054a587c9c8c504b2b115530b6cff89cbe;hp=7c9094727e2e2a003b5c458b4c91001654cee7a4;hpb=a568a19b2956ed8b94b11c2ef041412473dc8442;p=vpp.git diff --git a/src/vlib/counter.h b/src/vlib/counter.h index 7c9094727e2..04ab83769cc 100644 --- a/src/vlib/counter.h +++ b/src/vlib/counter.h @@ -84,6 +84,25 @@ vlib_increment_simple_counter (vlib_simple_counter_main_t * cm, my_counters[index] += increment; } +/** Decrement a simple counter + @param cm - (vlib_simple_counter_main_t *) simple counter main pointer + @param thread_index - (u32) the current cpu index + @param index - (u32) index of the counter to increment + @param increment - (u64) quantitiy remove from the counter value +*/ +always_inline void +vlib_decrement_simple_counter (vlib_simple_counter_main_t * cm, + u32 thread_index, u32 index, u64 decrement) +{ + counter_t *my_counters; + + my_counters = cm->counters[thread_index]; + + ASSERT (my_counters[index] >= decrement); + + my_counters[index] -= decrement; +} + /** Set a simple counter @param cm - (vlib_simple_counter_main_t *) simple counter main pointer @param thread_index - (u32) the current cpu index @@ -314,6 +333,9 @@ void vlib_free_simple_counter (vlib_simple_counter_main_t * cm); void vlib_validate_combined_counter (vlib_combined_counter_main_t * cm, u32 index); +int vlib_validate_combined_counter_will_expand + (vlib_combined_counter_main_t * cm, u32 index); + void vlib_free_combined_counter (vlib_combined_counter_main_t * cm); /** Obtain the number of simple or combined counters allocated.