session: API cleanup
[vpp.git] / src / vlib / counter.h
index fe5279a..292e137 100644 (file)
@@ -40,6 +40,8 @@
 #ifndef included_vlib_counter_h
 #define included_vlib_counter_h
 
+#include <vlib/counter_types.h>
+
 /** \file
 
     Optimized thread-safe counters.
@@ -50,9 +52,6 @@
     The idea is to drastically eliminate atomic operations.
 */
 
-/** 64bit counters */
-typedef u64 counter_t;
-
 /** A collection of simple counters */
 
 typedef struct
@@ -85,6 +84,22 @@ vlib_increment_simple_counter (vlib_simple_counter_main_t * cm,
   my_counters[index] += increment;
 }
 
+/** Set 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 value - (u64) quantitiy to set to the counter
+*/
+always_inline void
+vlib_set_simple_counter (vlib_simple_counter_main_t * cm,
+                        u32 thread_index, u32 index, u64 value)
+{
+  counter_t *my_counters;
+
+  my_counters = cm->counters[thread_index];
+  my_counters[index] = value;
+}
+
 /** Get the value of a simple counter
     Scrapes the entire set of per-thread counters. Innacurate unless
     worker threads which might increment the counter are
@@ -135,14 +150,6 @@ vlib_zero_simple_counter (vlib_simple_counter_main_t * cm, u32 index)
     }
 }
 
-/** Combined counter to hold both packets and byte differences.
- */
-typedef struct
-{
-  counter_t packets;                   /**< packet counter */
-  counter_t bytes;                     /**< byte counter  */
-} vlib_counter_t;
-
 /** Add two combined counters, results in the first counter
     @param [in,out] a - (vlib_counter_t *) dst counter
     @param b - (vlib_counter_t *) src counter
@@ -316,11 +323,6 @@ void vlib_validate_combined_counter (vlib_combined_counter_main_t * cm,
 */
 #define vlib_counter_len(cm) vec_len((cm)->maxi)
 
-serialize_function_t serialize_vlib_simple_counter_main,
-  unserialize_vlib_simple_counter_main;
-serialize_function_t serialize_vlib_combined_counter_main,
-  unserialize_vlib_combined_counter_main;
-
 #endif /* included_vlib_counter_h */
 
 /*