DPDK  18.11.11
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 #include <rte_memcpy.h>
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 #define RTE_JOBSTATS_NAMESIZE 32
18 
19 /* Forward declarations. */
20 struct rte_jobstats_context;
21 struct rte_jobstats;
22 
33 typedef void (*rte_job_update_period_cb_t)(struct rte_jobstats *job,
34  int64_t job_result);
35 
36 struct rte_jobstats {
37  uint64_t period;
40  uint64_t min_period;
43  uint64_t max_period;
46  int64_t target;
49  rte_job_update_period_cb_t update_period_cb;
52  uint64_t exec_time;
55  uint64_t min_exec_time;
58  uint64_t max_exec_time;
61  uint64_t exec_cnt;
64  char name[RTE_JOBSTATS_NAMESIZE];
67  struct rte_jobstats_context *context;
70 
71 struct rte_jobstats_context {
77  uint64_t state_time;
78 
79  uint64_t loop_executed_jobs;
82  /* Statistics start. */
83 
84  uint64_t exec_time;
87  uint64_t min_exec_time;
90  uint64_t max_exec_time;
99  uint64_t management_time;
100 
101  uint64_t min_management_time;
104  uint64_t max_management_time;
107  uint64_t start_time;
110  uint64_t job_exec_cnt;
113  uint64_t loop_cnt;
116 
127 int
128 rte_jobstats_context_init(struct rte_jobstats_context *ctx);
129 
136 void
137 rte_jobstats_context_start(struct rte_jobstats_context *ctx);
138 
146 void
147 rte_jobstats_context_finish(struct rte_jobstats_context *ctx);
148 
155 void
156 rte_jobstats_context_reset(struct rte_jobstats_context *ctx);
157 
178 int
179 rte_jobstats_init(struct rte_jobstats *job, const char *name,
180  uint64_t min_period, uint64_t max_period, uint64_t initial_period,
181  int64_t target);
182 
192 void
193 rte_jobstats_set_target(struct rte_jobstats *job, int64_t target);
194 
207 int
208 rte_jobstats_start(struct rte_jobstats_context *ctx, struct rte_jobstats *job);
209 
221 int
222 rte_jobstats_abort(struct rte_jobstats *job);
223 
240 int
241 rte_jobstats_finish(struct rte_jobstats *job, int64_t job_value);
242 
253 void
254 rte_jobstats_set_period(struct rte_jobstats *job, uint64_t period,
255  uint8_t saturate);
265 void
266 rte_jobstats_set_min(struct rte_jobstats *job, uint64_t period);
276 void
277 rte_jobstats_set_max(struct rte_jobstats *job, uint64_t period);
278 
290 void
291 rte_jobstats_set_update_period_function(struct rte_jobstats *job,
292  rte_job_update_period_cb_t update_period_cb);
293 
300 void
301 rte_jobstats_reset(struct rte_jobstats *job);
302 
303 #ifdef __cplusplus
304 }
305 #endif
306 
307 #endif /* JOBSTATS_H_ */
#define __rte_cache_aligned
Definition: rte_memory.h:66