summaryrefslogtreecommitdiff
path: root/vswitchd
diff options
context:
space:
mode:
authorMichal Weglicki <michalx.weglicki@intel.com>2018-01-09 07:55:37 +0000
committerBen Pfaff <blp@ovn.org>2018-01-10 15:29:13 -0800
commit971f4b394c6e8480300494787fe919869ff3886c (patch)
tree8dfa01877f05fbc46ebcc85d3c62f3c06e820ad0 /vswitchd
parentcd32509e4af4f9f7a002a6a5c137718f2173c538 (diff)
downloadopenvswitch-971f4b394c6e8480300494787fe919869ff3886c.tar.gz
netdev: Custom statistics.
- New get_custom_stats interface function is added to netdev. It allows particular netdev implementation to expose custom counters in dictionary format (counter name/counter value). - New statistics are retrieved using experimenter code and are printed as a result to ofctl dump-ports. - New counters are available for OpenFlow 1.4+. - New statistics are printed to output via ofctl only if those are present in reply message. - New statistics definition is added to include/openflow/intel-ext.h. - Custom statistics are implemented only for dpdk-physical port type. - DPDK-physical implementation uses xstats to collect statistics. Only dropped and error counters are exposed. Co-authored-by: Ben Pfaff <blp@ovn.org> Signed-off-by: Ben Pfaff <blp@ovn.org> Signed-off-by: Michal Weglicki <michalx.weglicki@intel.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'vswitchd')
-rw-r--r--vswitchd/bridge.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 27ee50646..d80da1cdd 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -2347,6 +2347,11 @@ iface_refresh_cfm_stats(struct iface *iface)
static void
iface_refresh_stats(struct iface *iface)
{
+ struct netdev_custom_stats custom_stats;
+ struct netdev_stats stats;
+ int n;
+ uint32_t i, counters_size;
+
#define IFACE_STATS \
IFACE_STAT(rx_packets, "rx_packets") \
IFACE_STAT(tx_packets, "tx_packets") \
@@ -2385,16 +2390,17 @@ iface_refresh_stats(struct iface *iface)
#define IFACE_STAT(MEMBER, NAME) + 1
enum { N_IFACE_STATS = IFACE_STATS };
#undef IFACE_STAT
- int64_t values[N_IFACE_STATS];
- const char *keys[N_IFACE_STATS];
- int n;
-
- struct netdev_stats stats;
if (iface_is_synthetic(iface)) {
return;
}
+ netdev_get_custom_stats(iface->netdev, &custom_stats);
+
+ counters_size = custom_stats.size + N_IFACE_STATS;
+ int64_t *values = xmalloc(counters_size * sizeof(int64_t));
+ const char **keys = xmalloc(counters_size * sizeof(char *));
+
/* Intentionally ignore return value, since errors will set 'stats' to
* all-1s, and we will deal with that correctly below. */
netdev_get_stats(iface->netdev, &stats);
@@ -2409,10 +2415,23 @@ iface_refresh_stats(struct iface *iface)
}
IFACE_STATS;
#undef IFACE_STAT
- ovs_assert(n <= N_IFACE_STATS);
+
+ /* Copy custom statistics into keys[] and values[]. */
+ if (custom_stats.size && custom_stats.counters) {
+ for (i = 0 ; i < custom_stats.size ; i++) {
+ values[n] = custom_stats.counters[i].value;
+ keys[n] = custom_stats.counters[i].name;
+ n++;
+ }
+ }
+
+ ovs_assert(n <= counters_size);
ovsrec_interface_set_statistics(iface->cfg, keys, values, n);
#undef IFACE_STATS
+
+ free(values);
+ free(keys);
}
static void