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