summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vpp-api/client/stat_client.c23
-rw-r--r--src/vpp-api/client/stat_client.h2
-rw-r--r--src/vpp/app/vpp_get_stats.c9
-rw-r--r--src/vpp/stats/stat_segment.c60
-rw-r--r--src/vpp/stats/stat_segment.h22
5 files changed, 105 insertions, 11 deletions
diff --git a/src/vpp-api/client/stat_client.c b/src/vpp-api/client/stat_client.c
index 2cf53d5d0af..25a37f76da8 100644
--- a/src/vpp-api/client/stat_client.c
+++ b/src/vpp-api/client/stat_client.c
@@ -252,8 +252,29 @@ copy_data (stat_segment_directory_entry_t * ep, stat_client_main_t * sm)
result.error_value = error_base[ep->index];
break;
+ case STAT_DIR_TYPE_NAME_VECTOR:
+ if (ep->offset == 0)
+ return result;
+ uint8_t **name_vector =
+ stat_segment_pointer (sm->shared_header, ep->offset);
+ result.name_vector = vec_dup (name_vector);
+ offset_vector =
+ stat_segment_pointer (sm->shared_header, ep->offset_vector);
+ for (i = 0; i < vec_len (name_vector); i++)
+ {
+ if (offset_vector[i])
+ {
+ u8 *name =
+ stat_segment_pointer (sm->shared_header, offset_vector[i]);
+ result.name_vector[i] = vec_dup (name);
+ }
+ else
+ result.name_vector[i] = 0;
+ }
+ break;
+
default:
- fprintf (stderr, "Unknown type: %d", ep->type);
+ fprintf (stderr, "Unknown type: %d\n", ep->type);
}
return result;
}
diff --git a/src/vpp-api/client/stat_client.h b/src/vpp-api/client/stat_client.h
index 89f6fe53ea4..23087abe749 100644
--- a/src/vpp-api/client/stat_client.h
+++ b/src/vpp-api/client/stat_client.h
@@ -28,6 +28,7 @@ typedef enum
STAT_DIR_TYPE_COUNTER_VECTOR_SIMPLE,
STAT_DIR_TYPE_COUNTER_VECTOR_COMBINED,
STAT_DIR_TYPE_ERROR_INDEX,
+ STAT_DIR_TYPE_NAME_VECTOR,
} stat_directory_type_t;
/* Default socket to exchange segment fd */
@@ -45,6 +46,7 @@ typedef struct
uint64_t error_value;
counter_t **simple_counter_vec;
vlib_counter_t **combined_counter_vec;
+ uint8_t **name_vector;
};
} stat_segment_data_t;
diff --git a/src/vpp/app/vpp_get_stats.c b/src/vpp/app/vpp_get_stats.c
index 1c1298e2afd..1d878029dda 100644
--- a/src/vpp/app/vpp_get_stats.c
+++ b/src/vpp/app/vpp_get_stats.c
@@ -220,6 +220,15 @@ reconnect:
fformat (stdout, "%.2f %s\n", res[i].scalar_value, res[i].name);
break;
+ case STAT_DIR_TYPE_NAME_VECTOR:
+ if (res[i].name_vector == 0)
+ continue;
+ for (k = 0; k < vec_len (res[i].name_vector); k++)
+ if (res[i].name_vector[k])
+ fformat (stdout, "[%d]: %s %s\n", k, res[i].name_vector[k],
+ res[i].name);
+ break;
+
default:
;
}
diff --git a/src/vpp/stats/stat_segment.c b/src/vpp/stats/stat_segment.c
index ca78a103522..aa32aede3a5 100644
--- a/src/vpp/stats/stat_segment.c
+++ b/src/vpp/stats/stat_segment.c
@@ -268,7 +268,7 @@ vlib_map_stat_segment_init (void)
/* Scalar stats and node counters */
vec_validate (sm->directory_vector, STAT_COUNTERS - 1);
#define _(E,t,n,p) \
- strcpy(sm->directory_vector[STAT_COUNTER_##E].name, "/sys" #p "/" #n); \
+ strcpy(sm->directory_vector[STAT_COUNTER_##E].name, #p "/" #n); \
sm->directory_vector[STAT_COUNTER_##E].type = STAT_DIR_TYPE_##t;
foreach_stat_segment_counter_name
#undef _
@@ -686,8 +686,66 @@ statseg_config (vlib_main_t * vm, unformat_input_t * input)
return 0;
}
+static clib_error_t *
+statseg_sw_interface_add_del (vnet_main_t * vnm, u32 sw_if_index, u32 is_add)
+{
+ stat_segment_main_t *sm = &stat_segment_main;
+ stat_segment_shared_header_t *shared_header = sm->shared_header;
+
+ void *oldheap = vlib_stats_push_heap ();
+ vlib_stat_segment_lock ();
+
+ vec_validate (sm->interfaces, sw_if_index);
+ if (is_add)
+ {
+ vnet_sw_interface_t *si = vnet_get_sw_interface (vnm, sw_if_index);
+ vnet_sw_interface_t *si_sup =
+ vnet_get_sup_sw_interface (vnm, si->sw_if_index);
+ vnet_hw_interface_t *hi_sup;
+
+ ASSERT (si_sup->type == VNET_SW_INTERFACE_TYPE_HARDWARE);
+ hi_sup = vnet_get_hw_interface (vnm, si_sup->hw_if_index);
+
+ u8 *s = 0;
+ s = format (s, "%v", hi_sup->name);
+ if (si->type != VNET_SW_INTERFACE_TYPE_HARDWARE)
+ s = format (s, ".%d", si->sub.id);
+ s = format (s, "%c", 0);
+ sm->interfaces[sw_if_index] = s;
+ }
+ else
+ {
+ vec_free (sm->interfaces[sw_if_index]);
+ sm->interfaces[sw_if_index] = 0;
+ }
+
+ stat_segment_directory_entry_t *ep;
+ ep = &sm->directory_vector[STAT_COUNTER_INTERFACE_NAMES];
+ ep->offset = stat_segment_offset (shared_header, sm->interfaces);
+
+ int i;
+ u64 *offset_vector =
+ ep->offset_vector ? stat_segment_pointer (shared_header,
+ ep->offset_vector) : 0;
+
+ vec_validate (offset_vector, vec_len (sm->interfaces) - 1);
+ for (i = 0; i < vec_len (sm->interfaces); i++)
+ {
+ offset_vector[i] =
+ sm->interfaces[i] ? stat_segment_offset (shared_header,
+ sm->interfaces[i]) : 0;
+ }
+ ep->offset_vector = stat_segment_offset (shared_header, offset_vector);
+
+ vlib_stat_segment_unlock ();
+ clib_mem_set_heap (oldheap);
+
+ return 0;
+}
+
VLIB_INIT_FUNCTION (statseg_init);
VLIB_EARLY_CONFIG_FUNCTION (statseg_config, "statseg");
+VNET_SW_INTERFACE_ADD_DEL_FUNCTION (statseg_sw_interface_add_del);
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (stat_segment_collector, static) =
diff --git a/src/vpp/stats/stat_segment.h b/src/vpp/stats/stat_segment.h
index fb450f38f53..917b512aecb 100644
--- a/src/vpp/stats/stat_segment.h
+++ b/src/vpp/stats/stat_segment.h
@@ -32,19 +32,21 @@ typedef enum
STAT_COUNTER_NODE_VECTORS,
STAT_COUNTER_NODE_CALLS,
STAT_COUNTER_NODE_SUSPENDS,
+ STAT_COUNTER_INTERFACE_NAMES,
STAT_COUNTERS
} stat_segment_counter_t;
#define foreach_stat_segment_counter_name \
- _(VECTOR_RATE, SCALAR_INDEX, vector_rate,) \
- _(INPUT_RATE, SCALAR_INDEX, input_rate,) \
- _(LAST_UPDATE, SCALAR_INDEX, last_update,) \
- _(LAST_STATS_CLEAR, SCALAR_INDEX, last_stats_clear,) \
- _(HEARTBEAT, SCALAR_INDEX, heartbeat,) \
- _(NODE_CLOCKS, COUNTER_VECTOR_SIMPLE, clocks, /node) \
- _(NODE_VECTORS, COUNTER_VECTOR_SIMPLE, vectors, /node) \
- _(NODE_CALLS, COUNTER_VECTOR_SIMPLE, calls, /node) \
- _(NODE_SUSPENDS, COUNTER_VECTOR_SIMPLE, suspends, /node)
+ _(VECTOR_RATE, SCALAR_INDEX, vector_rate, /sys) \
+ _(INPUT_RATE, SCALAR_INDEX, input_rate, /sys) \
+ _(LAST_UPDATE, SCALAR_INDEX, last_update, /sys) \
+ _(LAST_STATS_CLEAR, SCALAR_INDEX, last_stats_clear, /sys) \
+ _(HEARTBEAT, SCALAR_INDEX, heartbeat, /sys) \
+ _(NODE_CLOCKS, COUNTER_VECTOR_SIMPLE, clocks, /sys/node) \
+ _(NODE_VECTORS, COUNTER_VECTOR_SIMPLE, vectors, /sys/node) \
+ _(NODE_CALLS, COUNTER_VECTOR_SIMPLE, calls, /sys/node) \
+ _(NODE_SUSPENDS, COUNTER_VECTOR_SIMPLE, suspends, /sys/node) \
+ _(INTERFACE_NAMES, NAME_VECTOR, names, /if)
typedef struct
{
@@ -101,6 +103,8 @@ typedef struct
/* statistics segment */
uword *directory_vector_by_name;
stat_segment_directory_entry_t *directory_vector;
+ u8 **interfaces;
+
clib_spinlock_t *stat_segment_lockp;
clib_socket_t *socket;
u8 *socket_name;