aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vnet/api_errno.h28
-rw-r--r--src/vnet/bfd/bfd_cli.c16
-rw-r--r--src/vpp/stats/stats.api22
-rw-r--r--src/vpp/stats/stats.c79
4 files changed, 126 insertions, 19 deletions
diff --git a/src/vnet/api_errno.h b/src/vnet/api_errno.h
index 8c509d7a411..f928e0d8aa4 100644
--- a/src/vnet/api_errno.h
+++ b/src/vnet/api_errno.h
@@ -15,6 +15,10 @@
#ifndef included_vnet_api_errno_h
#define included_vnet_api_errno_h
+#include <stdarg.h>
+#include <vppinfra/types.h>
+#include <vppinfra/format.h>
+
#define foreach_vnet_api_error \
_(UNSPECIFIED, -1, "Unspecified Error") \
_(INVALID_SW_IF_INDEX, -2, "Invalid sw_if_index") \
@@ -147,6 +151,30 @@ typedef enum
VNET_API_N_ERROR,
} vnet_api_error_t;
+/* *INDENT-OFF* */
+static inline u8 *
+format_vnet_api_errno (u8 * s, va_list * args)
+{
+ vnet_api_error_t api_error = va_arg (*args, vnet_api_error_t);
+#ifdef _
+#undef _
+#endif
+#define _(a, b, c) \
+ case b: \
+ s = format (s, "%s", c); \
+ break;
+ switch (api_error)
+ {
+ foreach_vnet_api_error
+ default:
+ s = format (s, "UNKNOWN");
+ break;
+ }
+ return s;
+#undef _
+}
+/* *INDENT-ON* */
+
#endif /* included_vnet_api_errno_h */
/*
diff --git a/src/vnet/bfd/bfd_cli.c b/src/vnet/bfd/bfd_cli.c
index 33492ca8500..cab20a65b0b 100644
--- a/src/vnet/bfd/bfd_cli.c
+++ b/src/vnet/bfd/bfd_cli.c
@@ -218,22 +218,6 @@ VLIB_CLI_COMMAND (show_bfd_command, static) = {
};
/* *INDENT-ON* */
-static u8 *
-format_vnet_api_errno (u8 * s, va_list * args)
-{
- vnet_api_error_t api_error = va_arg (*args, vnet_api_error_t);
-#define _(a, b, c) \
- case b: \
- s = format (s, "%s", c); \
- break;
- switch (api_error)
- {
- foreach_vnet_api_error default:s = format (s, "UNKNOWN");
- break;
- }
- return s;
-}
-
static clib_error_t *
bfd_cli_key_add (vlib_main_t * vm, unformat_input_t * input,
CLIB_UNUSED (vlib_cli_command_t * lmd))
diff --git a/src/vpp/stats/stats.api b/src/vpp/stats/stats.api
index 2913d242d19..79816dbe83e 100644
--- a/src/vpp/stats/stats.api
+++ b/src/vpp/stats/stats.api
@@ -414,6 +414,28 @@ define vnet_get_summary_stats_reply
f64 vector_rate;
};
+/** \brief Get delay between polling statistics
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+*/
+define stats_get_poller_delay
+{
+ u32 client_index;
+ u32 context;
+};
+
+/** \brief Get delay between polling statistics reply
+ @param context - sender context, to match reply w/ request
+ @param retval - return code for request
+ @param delay - poller delay
+*/
+define stats_get_poller_delay_reply
+{
+ u32 context;
+ i32 retval;
+ u32 delay;
+};
+
/*
* Local Variables:
* eval: (c-set-style "gnu")
diff --git a/src/vpp/stats/stats.c b/src/vpp/stats/stats.c
index ef9f61bbf60..05950b6e5aa 100644
--- a/src/vpp/stats/stats.c
+++ b/src/vpp/stats/stats.c
@@ -62,7 +62,8 @@ _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
_(WANT_IP4_NBR_STATS, want_ip4_nbr_stats) \
_(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \
_(WANT_IP6_NBR_STATS, want_ip6_nbr_stats) \
-_(VNET_GET_SUMMARY_STATS, vnet_get_summary_stats)
+_(VNET_GET_SUMMARY_STATS, vnet_get_summary_stats) \
+_(STATS_GET_POLLER_DELAY, stats_get_poller_delay)
#define vl_msg_name_crc_list
@@ -2068,6 +2069,78 @@ again:
vl_msg_api_free (mp);
}
+int
+stats_set_poller_delay (u32 poller_delay_sec)
+{
+ stats_main_t *sm = &stats_main;
+ if (!poller_delay_sec)
+ {
+ return VNET_API_ERROR_INVALID_ARGUMENT;
+ }
+ else
+ {
+ sm->stats_poll_interval_in_seconds = poller_delay_sec;
+ return 0;
+ }
+}
+
+static clib_error_t *
+stats_config (vlib_main_t * vm, unformat_input_t * input)
+{
+ u32 sec;
+
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (input, "interval %u", &sec))
+ {
+ int rv = stats_set_poller_delay (sec);
+ if (rv)
+ {
+ return clib_error_return (0,
+ "`stats_set_poller_delay' API call failed, rv=%d:%U",
+ (int) rv, format_vnet_api_errno, rv);
+ }
+ return 0;
+ }
+ else
+ {
+ return clib_error_return (0, "unknown input '%U'",
+ format_unformat_error, input);
+ }
+ }
+ return 0;
+}
+
+/* stats { ... } configuration. */
+/*?
+ *
+ * @cfgcmd{interval, &lt;seconds&gt;}
+ * Configure stats poller delay to be @c seconds.
+ *
+?*/
+VLIB_CONFIG_FUNCTION (stats_config, "stats");
+
+static void
+ vl_api_stats_get_poller_delay_t_handler
+ (vl_api_stats_get_poller_delay_t * mp)
+{
+ stats_main_t *sm = &stats_main;
+ vl_api_registration_t *reg;
+ reg = vl_api_client_index_to_registration (mp->client_index);
+ if (!reg)
+ return;
+ vl_api_stats_get_poller_delay_reply_t *rmp;
+
+ rmp = vl_msg_api_alloc (sizeof (*rmp));
+ rmp->_vl_msg_id = ntohs (VL_API_WANT_PER_INTERFACE_SIMPLE_STATS_REPLY);
+ rmp->context = mp->context;
+ rmp->retval = 0;
+ rmp->delay = clib_host_to_net_u32 (sm->stats_poll_interval_in_seconds);
+
+ vl_api_send_msg (reg, (u8 *) rmp);
+
+}
+
static void
stats_thread_fn (void *arg)
{
@@ -2090,8 +2163,8 @@ stats_thread_fn (void *arg)
while (1)
{
- /* 10 second poll interval */
- ip46_fib_stats_delay (sm, 10 /* secs */ , 0 /* nsec */ );
+ ip46_fib_stats_delay (sm, sm->stats_poll_interval_in_seconds,
+ 0 /* nsec */ );
if (!(sm->enable_poller))
{