2 // Copyright (c) 2010-2017 Intel Corporation
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 #include <rte_cycles.h>
19 #include "prox_malloc.h"
22 #include "stats_port.h"
23 #include "stats_mempool.h"
24 #include "stats_ring.h"
25 #include "stats_l4gen.h"
26 #include "stats_latency.h"
27 #include "stats_global.h"
28 #include "stats_core.h"
29 #include "stats_task.h"
30 #include "stats_prio_task.h"
31 #include "stats_latency.h"
32 #include "stats_irq.h"
34 /* Stores all readed values from the cores, displaying is done afterwards because
35 displaying introduces overhead. If displaying was done right after the values
36 are read, inaccuracy is introduced for later cores */
37 int last_stat; /* 0 or 1 to track latest 2 measurements */
39 void stats_reset(void)
42 stats_prio_task_reset();
44 stats_latency_reset();
49 void stats_init(unsigned avg_start, unsigned duration)
53 stats_prio_task_init();
60 stats_global_init(avg_start, duration);
63 void stats_update(uint16_t flag_cons)
65 /* Keep track of last 2 measurements. */
66 last_stat = !last_stat;
68 if (flag_cons & STATS_CONS_F_TASKS)
71 if (flag_cons & STATS_CONS_F_PRIO_TASKS)
72 stats_prio_task_update();
74 if (flag_cons & STATS_CONS_F_LCORE)
77 if (flag_cons & STATS_CONS_F_PORTS)
80 if (flag_cons & STATS_CONS_F_MEMPOOLS)
81 stats_mempool_update();
83 if (flag_cons & STATS_CONS_F_LATENCY)
84 stats_latency_update();
86 if (flag_cons & STATS_CONS_F_L4GEN)
89 if (flag_cons & STATS_CONS_F_RINGS)
92 if (flag_cons & STATS_CONS_F_IRQ)
95 if (flag_cons & STATS_CONS_F_LCORE)
96 stats_lcore_post_proc();
98 if (flag_cons & STATS_CONS_F_TASKS)
99 stats_task_post_proc();
101 if (flag_cons & STATS_CONS_F_PRIO_TASKS)
102 stats_prio_task_post_proc();
104 if (flag_cons & STATS_CONS_F_GLOBAL)
105 stats_global_post_proc();
107 if (flag_cons & STATS_CONS_F_IRQ)
108 stats_irq_post_proc();