Support packets in flight
[samplevnf.git] / VNFs / DPPD-PROX / stats_port.h
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 #ifndef _STATS_PORT_H_
18 #define _STATS_PORT_H_
19
20 #include <inttypes.h>
21
22 enum PKT_SIZE_BIN {
23         PKT_SIZE_64,
24         PKT_SIZE_65,
25         PKT_SIZE_128,
26         PKT_SIZE_256,
27         PKT_SIZE_512,
28         PKT_SIZE_1024,
29         PKT_SIZE_1522,
30         PKT_SIZE_COUNT,
31 };
32
33 struct port_stats_sample {
34         uint64_t tsc;
35         uint64_t no_mbufs;
36         uint64_t ierrors;
37         uint64_t imissed;
38         uint64_t oerrors;
39         uint64_t rx_tot;
40         uint64_t tx_tot;
41         uint64_t rx_bytes;
42         uint64_t tx_bytes;
43         uint64_t tx_pkt_size[PKT_SIZE_COUNT];
44 };
45
46 struct port_stats {
47         struct port_stats_sample sample[2];
48 };
49
50 struct get_port_stats {
51         uint64_t no_mbufs_diff;
52         uint64_t ierrors_diff;
53         uint64_t imissed_diff;
54         uint64_t rx_bytes_diff;
55         uint64_t tx_bytes_diff;
56         uint64_t rx_pkts_diff;
57         uint64_t tx_pkts_diff;
58         uint64_t rx_tot;
59         uint64_t tx_tot;
60         uint64_t no_mbufs_tot;
61         uint64_t ierrors_tot;
62         uint64_t imissed_tot;
63         uint64_t last_tsc;
64         uint64_t prev_tsc;
65 };
66
67 int stats_port(uint8_t port_id, struct get_port_stats *ps);
68 void stats_port_init(void);
69 void stats_port_reset(void);
70 void stats_port_update(void);
71 uint64_t stats_port_get_ierrors(void);
72 uint64_t stats_port_get_imissed(void);
73 uint64_t stats_port_get_rx_packets(void);
74 uint64_t stats_port_get_tx_packets(void);
75
76 int stats_get_n_ports(void);
77 struct port_stats_sample *stats_get_port_stats_sample(uint32_t port_id, int l);
78
79 #endif /* _STATS_PORT_H_ */