}
}
-void *vlib_stats_push_heap (void) __attribute__ ((weak));
+void *vlib_stats_push_heap (void *) __attribute__ ((weak));
void *
-vlib_stats_push_heap (void)
+vlib_stats_push_heap (void *unused)
{
return 0;
};
-void vlib_stats_pop_heap (void *, void *, int) __attribute__ ((weak));
+void vlib_stats_pop_heap (void *, void *, u32, int) __attribute__ ((weak));
void
-vlib_stats_pop_heap (void *notused, void *notused2, int type)
+vlib_stats_pop_heap (void *notused, void *notused2, u32 i, int type)
{
};
{
vlib_thread_main_t *tm = vlib_get_thread_main ();
int i;
- void *oldheap = vlib_stats_push_heap ();
+ void *oldheap = vlib_stats_push_heap (cm->counters);
vec_validate (cm->counters, tm->n_vlib_mains - 1);
for (i = 0; i < tm->n_vlib_mains; i++)
vec_validate_aligned (cm->counters[i], index, CLIB_CACHE_LINE_BYTES);
- vlib_stats_pop_heap (cm, oldheap,
+ vlib_stats_pop_heap (cm, oldheap, index,
2 /* STAT_DIR_TYPE_COUNTER_VECTOR_SIMPLE */ );
}
{
vlib_thread_main_t *tm = vlib_get_thread_main ();
int i;
- void *oldheap = vlib_stats_push_heap ();
+ void *oldheap = vlib_stats_push_heap (cm->counters);
vec_validate (cm->counters, tm->n_vlib_mains - 1);
for (i = 0; i < tm->n_vlib_mains; i++)
vec_validate_aligned (cm->counters[i], index, CLIB_CACHE_LINE_BYTES);
- vlib_stats_pop_heap (cm, oldheap,
+ vlib_stats_pop_heap (cm, oldheap, index,
3 /*STAT_DIR_TYPE_COUNTER_VECTOR_COMBINED */ );
}
* Change heap to the stats shared memory segment
*/
void *
-vlib_stats_push_heap (void)
+vlib_stats_push_heap (void *old)
{
stat_segment_main_t *sm = &stat_segment_main;
+ sm->last = old;
ASSERT (sm && sm->shared_header);
return clib_mem_set_heap (sm->heap);
}
}
void
-vlib_stats_pop_heap (void *cm_arg, void *oldheap, stat_directory_type_t type)
+vlib_stats_pop_heap (void *cm_arg, void *oldheap, u32 cindex,
+ stat_directory_type_t type)
{
vlib_simple_counter_main_t *cm = (vlib_simple_counter_main_t *) cm_arg;
stat_segment_main_t *sm = &stat_segment_main;
/* Update the 2nd dimension offset vector */
int i;
vec_validate (offset_vector, vec_len (cm->counters) - 1);
- for (i = 0; i < vec_len (cm->counters); i++)
- offset_vector[i] = stat_segment_offset (shared_header, cm->counters[i]);
+
+ if (sm->last != offset_vector)
+ {
+ for (i = 0; i < vec_len (cm->counters); i++)
+ offset_vector[i] =
+ stat_segment_offset (shared_header, cm->counters[i]);
+ }
+ else
+ offset_vector[cindex] =
+ stat_segment_offset (shared_header, cm->counters[cindex]);
+
ep->offset_vector = stat_segment_offset (shared_header, offset_vector);
sm->directory_vector[vector_index].offset =
stat_segment_offset (shared_header, cm->counters);
ASSERT (shared_header);
- oldheap = vlib_stats_push_heap ();
+ oldheap = vlib_stats_push_heap (NULL);
vlib_stat_segment_lock ();
memset (&e, 0, sizeof (e));
stat_segment_main_t *sm = &stat_segment_main;
stat_segment_shared_header_t *shared_header = sm->shared_header;
- void *oldheap = vlib_stats_push_heap ();
+ void *oldheap = vlib_stats_push_heap (sm->interfaces);
vlib_stat_segment_lock ();
vec_validate (sm->interfaces, sw_if_index);
ep->offset_vector) : 0;
vec_validate (offset_vector, vec_len (sm->interfaces) - 1);
- for (i = 0; i < vec_len (sm->interfaces); i++)
+
+ if (sm->last != sm->interfaces)
+ {
+ /* the interface vector moved, so need to recalulate the offset array */
+ for (i = 0; i < vec_len (sm->interfaces); i++)
+ {
+ offset_vector[i] =
+ sm->interfaces[i] ? stat_segment_offset (shared_header,
+ sm->interfaces[i]) : 0;
+ }
+ }
+ else
{
- offset_vector[i] =
- sm->interfaces[i] ? stat_segment_offset (shared_header,
- sm->interfaces[i]) : 0;
+ offset_vector[sw_if_index] =
+ sm->interfaces[sw_if_index] ?
+ stat_segment_offset (shared_header, sm->interfaces[sw_if_index]) : 0;
}
ep->offset_vector = stat_segment_offset (shared_header, offset_vector);