DPDK  24.11.0-rc3
rte_jobstats.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2015 Intel Corporation
3  */
4 
5 #ifndef JOBSTATS_H_
6 #define JOBSTATS_H_
7 
8 #include <stdint.h>
9 
10 #include <rte_memory.h>
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 #define RTE_JOBSTATS_NAMESIZE 32
17 
18 /* Forward declarations. */
19 struct rte_jobstats_context;
20 struct rte_jobstats;
21 
32 typedef void (*rte_job_update_period_cb_t)(struct rte_jobstats *job,
33  int64_t job_result);
34 
35 struct __rte_cache_aligned rte_jobstats {
36  uint64_t period;
39  uint64_t min_period;
42  uint64_t max_period;
45  int64_t target;
48  rte_job_update_period_cb_t update_period_cb;
51  uint64_t exec_time;
54  uint64_t min_exec_time;
57  uint64_t max_exec_time;
60  uint64_t exec_cnt;
63  char name[RTE_JOBSTATS_NAMESIZE];
66  struct rte_jobstats_context *context;
68 };
69 
70 struct __rte_cache_aligned rte_jobstats_context {
76  uint64_t state_time;
77 
78  uint64_t loop_executed_jobs;
81  /* Statistics start. */
82 
83  uint64_t exec_time;
86  uint64_t min_exec_time;
89  uint64_t max_exec_time;
98  uint64_t management_time;
99 
100  uint64_t min_management_time;
103  uint64_t max_management_time;
106  uint64_t start_time;
109  uint64_t job_exec_cnt;
112  uint64_t loop_cnt;
114 };
115 
126 int
127 rte_jobstats_context_init(struct rte_jobstats_context *ctx);
128 
135 void
136 rte_jobstats_context_start(struct rte_jobstats_context *ctx);
137 
145 void
146 rte_jobstats_context_finish(struct rte_jobstats_context *ctx);
147 
154 void
155 rte_jobstats_context_reset(struct rte_jobstats_context *ctx);
156 
177 int
178 rte_jobstats_init(struct rte_jobstats *job, const char *name,
179  uint64_t min_period, uint64_t max_period, uint64_t initial_period,
180  int64_t target);
181 
191 void
192 rte_jobstats_set_target(struct rte_jobstats *job, int64_t target);
193 
206 int
207 rte_jobstats_start(struct rte_jobstats_context *ctx, struct rte_jobstats *job);
208 
220 int
221 rte_jobstats_abort(struct rte_jobstats *job);
222 
239 int
240 rte_jobstats_finish(struct rte_jobstats *job, int64_t job_value);
241 
252 void
253 rte_jobstats_set_period(struct rte_jobstats *job, uint64_t period,
254  uint8_t saturate);
264 void
265 rte_jobstats_set_min(struct rte_jobstats *job, uint64_t period);
275 void
276 rte_jobstats_set_max(struct rte_jobstats *job, uint64_t period);
277 
289 void
290 rte_jobstats_set_update_period_function(struct rte_jobstats *job,
291  rte_job_update_period_cb_t update_period_cb);
292 
299 void
300 rte_jobstats_reset(struct rte_jobstats *job);
301 
302 #ifdef __cplusplus
303 }
304 #endif
305 
306 #endif /* JOBSTATS_H_ */
#define __rte_cache_aligned
Definition: rte_common.h:627