xref: /dpdk/lib/bitratestats/rte_bitrate.h (revision 29fd052d)
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 void rte_stats_bitrate_free(struct rte_stats_bitrates *bitrate_data);
37 
38 /**
39  * Register bitrate statistics with the metric library.
40  *
41  * @param bitrate_data
42  *   Pointer allocated by rte_stats_bitrate_create()
43  *
44  * @return
45  *   Zero on success
46  *   Negative on error
47  */
48 int rte_stats_bitrate_reg(struct rte_stats_bitrates *bitrate_data);
49 
50 
51 /**
52  * Calculate statistics for current time window. The period with which
53  * this function is called should be the intended sampling window width.
54  *
55  * @param bitrate_data
56  *   Bitrate statistics data pointer
57  *
58  * @param port_id
59  *   Port id to calculate statistics for
60  *
61  * @return
62  *  - Zero on success
63  *  - Negative value on error
64  */
65 int rte_stats_bitrate_calc(struct rte_stats_bitrates *bitrate_data,
66 			   uint16_t port_id);
67 
68 #ifdef __cplusplus
69 }
70 #endif
71 
72 #endif /* _RTE_BITRATE_H_ */
73