5#ifndef __RTE_RED_H_INCLUDED__
6#define __RTE_RED_H_INCLUDED__
25#define RTE_RED_SCALING 10
26#define RTE_RED_S (1 << 22)
27#define RTE_RED_MAX_TH_MAX 1023
28#define RTE_RED_WQ_LOG2_MIN 1
29#define RTE_RED_WQ_LOG2_MAX 12
30#define RTE_RED_MAXP_INV_MIN 1
31#define RTE_RED_MAXP_INV_MAX 255
32#define RTE_RED_2POW16 (1<<16)
33#define RTE_RED_INT16_NBITS (sizeof(uint16_t) * CHAR_BIT)
34#define RTE_RED_WQ_LOG2_NUM (RTE_RED_WQ_LOG2_MAX - RTE_RED_WQ_LOG2_MIN + 1)
41extern uint32_t rte_red_rand_seed;
42extern uint16_t rte_red_log2_1_minus_Wq[RTE_RED_WQ_LOG2_NUM];
43extern uint16_t rte_red_pow2_frac_inv[16];
104 const uint16_t wq_log2,
105 const uint16_t min_th,
106 const uint16_t max_th,
107 const uint16_t maxp_inv);
119static inline uint32_t
122 rte_red_rand_seed = (214013 * rte_red_rand_seed) + 2531011;
123 return rte_red_rand_seed >> 10;
136static inline uint16_t
180 return (uint16_t) ((rte_red_pow2_frac_inv[f] + (1 << (n - 1))) >> n);
204 uint64_t time_diff = 0, m = 0;
206 RTE_ASSERT(red_cfg != NULL);
207 RTE_ASSERT(red != NULL);
215 time_diff = time - red->
q_time;
282 uint32_t pa_num_count = 0;
286 pa_num_count = red->
count * pa_num;
288 if (red_cfg->
pa_const <= pa_num_count)
291 pa_den = red_cfg->
pa_const - pa_num_count;
321 RTE_ASSERT(red_cfg != NULL);
322 RTE_ASSERT(red != NULL);
384 RTE_ASSERT(red_cfg != NULL);
385 RTE_ASSERT(red != NULL);
static uint16_t __rte_red_calc_qempty_factor(uint8_t wq_log2, uint16_t m)
calculate factor to scale average queue size when queue becomes empty
#define RTE_RED_WQ_LOG2_MIN
int rte_red_config_init(struct rte_red_config *red_cfg, const uint16_t wq_log2, const uint16_t min_th, const uint16_t max_th, const uint16_t maxp_inv)
Configures a single RED configuration parameter structure.
static int rte_red_enqueue_nonempty(const struct rte_red_config *red_cfg, struct rte_red *red, const unsigned q)
Decides if new packet should be enqueued or dropped in queue non-empty case.
static int rte_red_enqueue_empty(const struct rte_red_config *red_cfg, struct rte_red *red, const uint64_t time)
Updates queue average in condition when queue is empty.
static uint32_t rte_fast_rand(void)
Generate random number for RED.
static int rte_red_enqueue(const struct rte_red_config *red_cfg, struct rte_red *red, const unsigned q, const uint64_t time)
Decides if new packet should be enqueued or dropped Updates run time data based on new queue size val...
uint32_t rte_red_rand_val
static int __rte_red_drop(const struct rte_red_config *red_cfg, struct rte_red *red)
make a decision to drop or enqueue a packet based on mark probability criteria
static void rte_red_mark_queue_empty(struct rte_red *red, const uint64_t time)
Callback to records time that queue became empty.
int rte_red_rt_data_init(struct rte_red *red)
Initialises run-time data.