STATS: Separate socket for fd exchange.
[vpp.git] / src / vpp / stats / stats.h
index 3d30e37..3b6f781 100644 (file)
 #include <vnet/mfib/mfib_table.h>
 #include <vlib/unix/unix.h>
 #include <vlibmemory/api.h>
-#include <vlibmemory/unix_shared_memory_queue.h>
 #include <vlibapi/api_helper_macros.h>
+#include <svm/queue.h>
+#include <svm/ssvm.h>
+
+/* Default socket to exchange segment fd */
+#define STAT_SEGMENT_SOCKET_FILE "/run/vpp/stats.sock"
 
 typedef struct
 {
@@ -51,30 +55,6 @@ typedef CLIB_PACKED (struct
 }) ip4_route_t;
 /* *INDENT-ON* */
 
-/* see interface.api */
-typedef struct
-{
-  u32 sw_if_index;
-  u64 drop;
-  u64 punt;
-  u64 rx_ip4;
-  u64 rx_ip6;
-  u64 rx_no_buffer;
-  u64 rx_miss;
-  u64 rx_error;
-  u64 tx_error;
-  u64 rx_mpls;
-} vnet_simple_counter_t;
-
-typedef struct
-{
-  u32 sw_if_index;
-  u64 rx_packets;                      /**< packet counter */
-  u64 rx_bytes;                        /**< byte counter  */
-  u64 tx_packets;                      /**< packet counter */
-  u64 tx_bytes;                        /**< byte counter  */
-} vnet_combined_counter_t;
-
 typedef struct
 {
   ip6_address_t address;
@@ -181,6 +161,31 @@ typedef struct
   vpe_client_stats_registration_t **regs_tmp;
   vpe_client_registration_t **clients_tmp;
 
+  /* statistics segment */
+  ssvm_private_t stat_segment;
+  uword *counter_vector_by_name;
+  clib_spinlock_t *stat_segment_lockp;
+  clib_socket_t *socket;
+  u8 *socket_name;
+
+  /* Pointers to scalar stats maintained by the stat thread */
+  f64 *input_rate_ptr;
+  f64 *last_runtime_ptr;
+  f64 *last_runtime_stats_clear_ptr;
+  f64 *vector_rate_ptr;
+  u64 last_input_packets;
+
+  /* Pointers to vector stats maintained by the stat thread */
+  u8 *serialized_nodes;
+  vlib_main_t **stat_vms;
+  vlib_node_t ***node_dups;
+
+  f64 *vectors_per_node;
+  f64 *vector_rate_in;
+  f64 *vector_rate_out;
+  f64 *vector_rate_drop;
+  f64 *vector_rate_punt;
+
   /* convenience */
   vlib_main_t *vlib_main;
   vnet_main_t *vnet_main;
@@ -190,6 +195,28 @@ typedef struct
 
 extern stats_main_t stats_main;
 
+#define STAT_SEGMENT_OPAQUE_LOCK       0
+#define STAT_SEGMENT_OPAQUE_DIR                1
+#define STAT_SEGMENT_OPAQUE_EPOCH      2
+
+typedef enum
+{
+  STAT_DIR_TYPE_ILLEGAL = 0,
+  STAT_DIR_TYPE_SCALAR_POINTER,
+  STAT_DIR_TYPE_VECTOR_POINTER,
+  STAT_DIR_TYPE_COUNTER_VECTOR,
+  STAT_DIR_TYPE_ERROR_INDEX,
+  STAT_DIR_TYPE_SERIALIZED_NODES,
+} stat_directory_type_t;
+
+typedef struct
+{
+  stat_directory_type_t type;
+  void *value;
+} stat_segment_directory_entry_t;
+
+void do_stat_segment_updates (stats_main_t * sm);
+
 #endif /* __included_stats_h__ */
 
 /*