Integrate irq mode into PROX (support display and command line)
[samplevnf.git] / VNFs / DPPD-PROX / stats.c
1 /*
2 // Copyright (c) 2010-2017 Intel Corporation
3 //
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
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
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.
15 */
16
17 #include <rte_cycles.h>
18
19 #include "prox_malloc.h"
20 #include "prox_cfg.h"
21 #include "stats.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"
33
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 */
38
39 void stats_reset(void)
40 {
41         stats_task_reset();
42         stats_prio_task_reset();
43         stats_port_reset();
44         stats_latency_reset();
45         stats_irq_reset();
46         stats_global_reset();
47 }
48
49 void stats_init(unsigned avg_start, unsigned duration)
50 {
51         stats_lcore_init();
52         stats_task_init();
53         stats_prio_task_init();
54         stats_irq_init();
55         stats_port_init();
56         stats_mempool_init();
57         stats_latency_init();
58         stats_l4gen_init();
59         stats_ring_init();
60         stats_global_init(avg_start, duration);
61 }
62
63 void stats_update(uint16_t flag_cons)
64 {
65         /* Keep track of last 2 measurements. */
66         last_stat = !last_stat;
67
68         if (flag_cons & STATS_CONS_F_TASKS)
69                 stats_task_update();
70
71         if (flag_cons & STATS_CONS_F_PRIO_TASKS)
72                 stats_prio_task_update();
73
74         if (flag_cons & STATS_CONS_F_LCORE)
75                 stats_lcore_update();
76
77         if (flag_cons & STATS_CONS_F_PORTS)
78                 stats_port_update();
79
80         if (flag_cons & STATS_CONS_F_MEMPOOLS)
81                 stats_mempool_update();
82
83         if (flag_cons & STATS_CONS_F_LATENCY)
84                 stats_latency_update();
85
86         if (flag_cons & STATS_CONS_F_L4GEN)
87                 stats_l4gen_update();
88
89         if (flag_cons & STATS_CONS_F_RINGS)
90                 stats_ring_update();
91
92         if (flag_cons & STATS_CONS_F_IRQ)
93                 stats_irq_update();
94
95         if (flag_cons & STATS_CONS_F_LCORE)
96                 stats_lcore_post_proc();
97
98         if (flag_cons & STATS_CONS_F_TASKS)
99                 stats_task_post_proc();
100
101         if (flag_cons & STATS_CONS_F_PRIO_TASKS)
102                 stats_prio_task_post_proc();
103
104         if (flag_cons & STATS_CONS_F_GLOBAL)
105                 stats_global_post_proc();
106
107         if (flag_cons & STATS_CONS_F_IRQ)
108                 stats_irq_post_proc();
109 }