DPDK 22.11.0-rc2
rte_power_empty_poll.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2018 Intel Corporation
3 */
4
5#ifndef _RTE_EMPTY_POLL_H
6#define _RTE_EMPTY_POLL_H
7
12#include <stdint.h>
13#include <stdbool.h>
14
15#include <rte_common.h>
16#include <rte_string_fns.h>
17#include <rte_timer.h>
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23#define NUM_FREQS RTE_MAX_LCORE_FREQS
24
25#define BINS_AV 4 /* Has to be ^2 */
26
27#define DROP (NUM_DIRECTIONS * NUM_DEVICES)
28
29#define NUM_PRIORITIES 2
30
31#define NUM_NODES 256 /* Max core number*/
32
33/* Processor Power State */
34enum freq_val {
35 LOW,
36 MED,
37 HGH,
38 NUM_FREQ = NUM_FREQS
39};
40
41
42/* Queue Polling State */
43enum queue_state {
44 TRAINING, /* NO TRAFFIC */
45 MED_NORMAL, /* MED */
46 HGH_BUSY, /* HIGH */
47 LOW_PURGE, /* LOW */
48};
49
50/* Queue Stats */
51struct freq_threshold {
52
53 uint64_t base_edpi;
54 bool trained;
55 uint32_t threshold_percent;
56 uint32_t cur_train_iter;
57};
58
59/* Each Worker Thread Empty Poll Stats */
60struct priority_worker {
61
62 /* Current dequeue and throughput counts */
63 /* These 2 are written to by the worker threads */
64 /* So keep them on their own cache line */
65 uint64_t empty_dequeues;
66 uint64_t num_dequeue_pkts;
67
68 enum queue_state queue_state;
69
70 uint64_t empty_dequeues_prev;
71
72 /* Used for training only */
73 struct freq_threshold thresh[NUM_FREQ];
74 enum freq_val cur_freq;
75
76 /* bucket arrays to calculate the averages */
77 /* edpi mean empty poll counter difference per interval */
78 uint64_t edpi_av[BINS_AV];
79 /* empty poll counter */
80 uint32_t ec;
81
82 uint32_t lcore_id;
83 uint32_t iter_counter;
84 uint32_t threshold_ctr;
85 uint32_t display_ctr;
86 uint8_t dev_id;
87
89
90
91struct stats_data {
92
93 struct priority_worker wrk_stats[NUM_NODES];
94
95 /* flag to stop rx threads processing packets until training over */
96 bool start_rx;
97
98};
99
100/* Empty Poll Parameters */
101struct ep_params {
102
103 /* Timer related stuff */
104 uint64_t interval_ticks;
105 uint32_t max_train_iter;
106
107 struct rte_timer timer0;
108 struct stats_data wrk_data;
109};
110
111
112/* Sample App Init information */
113struct ep_policy {
114
115 uint64_t med_base_edpi;
116 uint64_t hgh_base_edpi;
117
118 enum queue_state state;
119};
120
121
122
137__rte_experimental
138int
139rte_power_empty_poll_stat_init(struct ep_params **eptr, uint8_t *freq_tlb,
140 struct ep_policy *policy);
141
145__rte_experimental
146void
148
160__rte_experimental
161int
162rte_power_empty_poll_stat_update(unsigned int lcore_id);
163
176__rte_experimental
177int
178rte_power_poll_stat_update(unsigned int lcore_id, uint8_t nb_pkt);
179
189__rte_experimental
190uint64_t
191rte_power_empty_poll_stat_fetch(unsigned int lcore_id);
192
202__rte_experimental
203uint64_t
204rte_power_poll_stat_fetch(unsigned int lcore_id);
205
214__rte_experimental
215void
216rte_empty_poll_detection(struct rte_timer *tim, void *arg);
217
218#ifdef __cplusplus
219}
220#endif
221
222#endif
#define __rte_cache_aligned
Definition: rte_common.h:440
__rte_experimental uint64_t rte_power_empty_poll_stat_fetch(unsigned int lcore_id)
__rte_experimental void rte_empty_poll_detection(struct rte_timer *tim, void *arg)
__rte_experimental int rte_power_empty_poll_stat_update(unsigned int lcore_id)
__rte_experimental int rte_power_poll_stat_update(unsigned int lcore_id, uint8_t nb_pkt)
__rte_experimental int rte_power_empty_poll_stat_init(struct ep_params **eptr, uint8_t *freq_tlb, struct ep_policy *policy)
__rte_experimental uint64_t rte_power_poll_stat_fetch(unsigned int lcore_id)
__rte_experimental void rte_power_empty_poll_stat_free(void)