+VLOG_DEFINE_THIS_MODULE(coverage);
+
+/* The coverage counters. */
+static struct coverage_counter **coverage_counters = NULL;
+static size_t n_coverage_counters = 0;
+static size_t allocated_coverage_counters = 0;
+
+static struct ovs_mutex coverage_mutex = OVS_MUTEX_INITIALIZER;
+
+DEFINE_STATIC_PER_THREAD_DATA(long long int, coverage_clear_time, LLONG_MIN);
+static long long int coverage_run_time = LLONG_MIN;
+
+/* Index counter used to compute the moving average array's index. */
+static unsigned int idx_count = 0;
+
+static void coverage_read(struct svec *);
+static unsigned int coverage_array_sum(const unsigned int *arr,
+ const unsigned int len);
+
+/* Registers a coverage counter with the coverage core */
+void
+coverage_counter_register(struct coverage_counter* counter)
+{
+ if (n_coverage_counters >= allocated_coverage_counters) {
+ coverage_counters = x2nrealloc(coverage_counters,
+ &allocated_coverage_counters,
+ sizeof(struct coverage_counter*));
+ }
+ coverage_counters[n_coverage_counters++] = counter;
+}
+
+static void
+coverage_unixctl_show(struct unixctl_conn *conn, int argc OVS_UNUSED,
+ const char *argv[] OVS_UNUSED, void *aux OVS_UNUSED)
+{
+ struct svec lines;
+ char *reply;
+
+ svec_init(&lines);
+ coverage_read(&lines);
+ reply = svec_join(&lines, "\n", "\n");
+ unixctl_command_reply(conn, reply);
+ free(reply);
+ svec_destroy(&lines);
+}
+
+void
+coverage_init(void)
+{
+ unixctl_command_register("coverage/show", "", 0, 0,
+ coverage_unixctl_show, NULL);
+}