5 #ifndef __RTE_RED_H_INCLUDED__ 6 #define __RTE_RED_H_INCLUDED__ 26 #define RTE_RED_SCALING 10 27 #define RTE_RED_S (1 << 22) 28 #define RTE_RED_MAX_TH_MAX 1023 29 #define RTE_RED_WQ_LOG2_MIN 1 30 #define RTE_RED_WQ_LOG2_MAX 12 31 #define RTE_RED_MAXP_INV_MIN 1 32 #define RTE_RED_MAXP_INV_MAX 255 33 #define RTE_RED_2POW16 (1<<16) 34 #define RTE_RED_INT16_NBITS (sizeof(uint16_t) * CHAR_BIT) 35 #define RTE_RED_WQ_LOG2_NUM (RTE_RED_WQ_LOG2_MAX - RTE_RED_WQ_LOG2_MIN + 1) 42 extern uint32_t rte_red_rand_seed;
43 extern uint16_t rte_red_log2_1_minus_Wq[RTE_RED_WQ_LOG2_NUM];
44 extern uint16_t rte_red_pow2_frac_inv[16];
120 static inline uint32_t
123 rte_red_rand_seed = (214013 * rte_red_rand_seed) + 2531011;
124 return rte_red_rand_seed >> 10;
137 static inline uint16_t
181 return (uint16_t) ((rte_red_pow2_frac_inv[f] + (1 << (n - 1))) >> n);
205 uint64_t time_diff = 0, m = 0;
207 RTE_ASSERT(red_cfg != NULL);
208 RTE_ASSERT(red != NULL);
216 time_diff = time - red->
q_time;
283 uint32_t pa_num_count = 0;
287 pa_num_count = red->
count * pa_num;
289 if (red_cfg->
pa_const <= pa_num_count)
292 pa_den = red_cfg->
pa_const - pa_num_count;
295 if (
unlikely((rte_red_rand_val % pa_den) < pa_num)) {
322 RTE_ASSERT(red_cfg != NULL);
323 RTE_ASSERT(red != NULL);
385 RTE_ASSERT(red_cfg != NULL);
386 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