Support packets in flight
[samplevnf.git] / VNFs / DPPD-PROX / stats_irq.h
1 /*
2 // Copyright (c) 2010-2018 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 #ifndef _STATS_IRQ_H_
18 #define _STATS_IRQ_H_
19
20 #include <inttypes.h>
21
22 #include "clock.h"
23
24 #define IRQ_BUCKETS_COUNT      13
25
26 extern int last_stat;
27
28 // irq_rt_stats is updated real time by handle_irq. It contains total stats, from beginning
29 // It cannot be reset to 0, as the reset would be done by another core
30 struct irq_rt_stats {
31         uint64_t max_irq;
32         uint64_t irq[IRQ_BUCKETS_COUNT];
33 };
34
35 // irq_sample is updated by irq_update - as sampling of irq_rt_stats
36 // There is usually one sample per second; two samples in total
37 struct irq_sample {
38         uint64_t tsc;
39         uint64_t max_irq;
40         uint64_t irq[IRQ_BUCKETS_COUNT];
41 };
42
43 // Those are the total stats; there can be reset
44 // They are obtained by adding samples
45 struct irq_task_stats {
46         uint8_t lcore_id;
47         uint8_t task_id;
48         uint64_t max_irq;
49         uint64_t irq[IRQ_BUCKETS_COUNT];
50         struct irq_sample sample[2];
51         struct irq_rt_stats *stats;
52 };
53
54 extern uint64_t irq_bucket_maxtime_cycles[IRQ_BUCKETS_COUNT];
55 extern uint64_t irq_bucket_maxtime_micro[];
56
57 void stats_irq_reset(void);
58 void stats_irq_post_proc(void);
59 void stats_irq_update(void);
60 void stats_irq_init(void);
61 int stats_get_n_irq_tasks(void);
62
63 struct irq_sample *get_irq_sample(uint32_t task_id, int last);
64 struct irq_sample *get_irq_sample_by_core_task(uint32_t lcore_id, uint32_t task_id, int last);
65 uint64_t get_max_irq_stats(uint8_t task_id);
66 uint64_t get_irq_stats(uint8_t task_id, int bucket_id);
67 uint64_t get_max_irq_stats_by_core_task(uint8_t lcore_id, uint8_t task_id);
68 uint64_t get_irq_stats_by_core_task(uint8_t lcore_id, uint8_t task_id, int bucket_id);
69 void get_irq_buckets_by_core_task(char *buf, uint8_t lcore_id, uint8_t irq_task_id);
70
71 #endif /* _STATS_IRQ_H_ */