ethdev: include mbuf registration in Tx timestamp API
[dpdk.git] / lib / librte_bitratestats / rte_bitrate.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017 Intel Corporation
3  */
4
5 #ifndef _RTE_BITRATE_H_
6 #define _RTE_BITRATE_H_
7
8 #include <stdint.h>
9
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13
14 /**
15  *  Bitrate statistics data structure.
16  *  This data structure is intentionally opaque.
17  */
18 struct rte_stats_bitrates;
19
20
21 /**
22  * Allocate a bitrate statistics structure
23  *
24  * @return
25  *   - Pointer to structure on success
26  *   - NULL on error (zmalloc failure)
27  */
28 struct rte_stats_bitrates *rte_stats_bitrate_create(void);
29
30 /**
31  * Free bitrate statistics structure
32  *
33  * @param bitrate_data
34  *   Pointer allocated by rte_stats_bitrate_create()
35  */
36 __rte_experimental
37 void rte_stats_bitrate_free(struct rte_stats_bitrates *bitrate_data);
38
39 /**
40  * Register bitrate statistics with the metric library.
41  *
42  * @param bitrate_data
43  *   Pointer allocated by rte_stats_bitrate_create()
44  *
45  * @return
46  *   Zero on success
47  *   Negative on error
48  */
49 int rte_stats_bitrate_reg(struct rte_stats_bitrates *bitrate_data);
50
51
52 /**
53  * Calculate statistics for current time window. The period with which
54  * this function is called should be the intended sampling window width.
55  *
56  * @param bitrate_data
57  *   Bitrate statistics data pointer
58  *
59  * @param port_id
60  *   Port id to calculate statistics for
61  *
62  * @return
63  *  - Zero on success
64  *  - Negative value on error
65  */
66 int rte_stats_bitrate_calc(struct rte_stats_bitrates *bitrate_data,
67                            uint16_t port_id);
68
69 #ifdef __cplusplus
70 }
71 #endif
72
73 #endif /* _RTE_BITRATE_H_ */