void *oldheap;
u32 *lock;
int rv;
+ u64 memory_size;
- ssvmp->ssvm_size = 32 << 20; /*$$$$$ CONFIG PARAM */
+ memory_size = sm->memory_size;
+ if (memory_size == 0)
+ memory_size = STAT_SEGMENT_DEFAULT_SIZE;
+
+ ssvmp->ssvm_size = memory_size;
ssvmp->i_am_master = 1;
ssvmp->my_pid = getpid ();
ssvmp->name = format (0, "/stats%c", 0);
sm->last_runtime_ptr = (scalar_data + 2);
sm->last_runtime_stats_clear_ptr = (scalar_data + 3);
- name = format (0, "vector_rate%c", 0);
+ name = format (0, "/sys/vector_rate%c", 0);
ep = clib_mem_alloc (sizeof (*ep));
ep->type = STAT_DIR_TYPE_SCALAR_POINTER;
ep->value = sm->vector_rate_ptr;
hash_set_mem (sm->counter_vector_by_name, name, ep);
- name = format (0, "input_rate%c", 0);
+ name = format (0, "/sys/input_rate%c", 0);
ep = clib_mem_alloc (sizeof (*ep));
ep->type = STAT_DIR_TYPE_SCALAR_POINTER;
ep->value = sm->input_rate_ptr;
hash_set_mem (sm->counter_vector_by_name, name, ep);
- name = format (0, "last_update%c", 0);
+ name = format (0, "/sys/last_update%c", 0);
ep = clib_mem_alloc (sizeof (*ep));
ep->type = STAT_DIR_TYPE_SCALAR_POINTER;
ep->value = sm->last_runtime_ptr;
hash_set_mem (sm->counter_vector_by_name, name, ep);
- name = format (0, "last_stats_clear%c", 0);
+ name = format (0, "/sys/last_stats_clear%c", 0);
ep = clib_mem_alloc (sizeof (*ep));
ep->type = STAT_DIR_TYPE_SCALAR_POINTER;
ep->value = sm->last_runtime_stats_clear_ptr;
sm->last_runtime_stats_clear_ptr[0] =
vm->node_main.time_last_runtime_stats_clear;
- update_serialized_nodes (sm);
+ if (sm->serialize_nodes)
+ update_serialized_nodes (sm);
+}
+
+static clib_error_t *
+statseg_config (vlib_main_t * vm, unformat_input_t * input)
+{
+ stats_main_t *sm = &stats_main;
+ uword ms;
+
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (input, "size %U", unformat_memory_size, &sm->memory_size))
+ ;
+ else if (unformat (input, "serialize-nodes on"))
+ sm->serialize_nodes = 1;
+ else if (unformat (input, "serialize-nodes off"))
+ sm->serialize_nodes = 0;
+ else
+ return clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, input);
+ }
+
+ return 0;
}
+VLIB_EARLY_CONFIG_FUNCTION (statseg_config, "statseg");
/*
* fd.io coding-style-patch-verification: ON