5 #ifndef __RTE_RED_H_INCLUDED__ 6 #define __RTE_RED_H_INCLUDED__ 23 #define RTE_RED_SCALING 10 24 #define RTE_RED_S (1 << 22) 25 #define RTE_RED_MAX_TH_MAX 1023 26 #define RTE_RED_WQ_LOG2_MIN 1 27 #define RTE_RED_WQ_LOG2_MAX 12 28 #define RTE_RED_MAXP_INV_MIN 1 29 #define RTE_RED_MAXP_INV_MAX 255 30 #define RTE_RED_2POW16 (1<<16) 31 #define RTE_RED_INT16_NBITS (sizeof(uint16_t) * CHAR_BIT) 32 #define RTE_RED_WQ_LOG2_NUM (RTE_RED_WQ_LOG2_MAX - RTE_RED_WQ_LOG2_MIN + 1) 38 extern uint32_t rte_red_rand_seed;
39 extern uint16_t rte_red_log2_1_minus_Wq[RTE_RED_WQ_LOG2_NUM];
40 extern uint16_t rte_red_pow2_frac_inv[16];
115 static inline uint32_t
118 rte_red_rand_seed = (214013 * rte_red_rand_seed) + 2531011;
119 return rte_red_rand_seed >> 10;
132 static inline uint16_t
176 return (uint16_t) ((rte_red_pow2_frac_inv[f] + (1 << (n - 1))) >> n);
200 uint64_t time_diff = 0, m = 0;
202 RTE_ASSERT(red_cfg != NULL);
203 RTE_ASSERT(red != NULL);
211 time_diff = time - red->
q_time;
278 uint32_t pa_num_count = 0;
282 pa_num_count = red->
count * pa_num;
284 if (red_cfg->
pa_const <= pa_num_count)
287 pa_den = red_cfg->
pa_const - pa_num_count;
290 if (
unlikely((rte_red_rand_val % pa_den) < pa_num)) {
317 RTE_ASSERT(red_cfg != NULL);
318 RTE_ASSERT(red != NULL);
380 RTE_ASSERT(red_cfg != NULL);
381 RTE_ASSERT(red != NULL);
static void rte_red_mark_queue_empty(struct rte_red *red, const uint64_t time)
Callback to records time that queue became empty.
static uint32_t rte_fast_rand(void)
Generate random number for RED.
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
uint32_t rte_red_rand_val
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_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 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
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(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...
int rte_red_rt_data_init(struct rte_red *red)
Initialises run-time data.
#define RTE_RED_WQ_LOG2_MIN