34 #ifndef __RTE_RED_H_INCLUDED__
35 #define __RTE_RED_H_INCLUDED__
55 #define RTE_RED_SCALING 10
56 #define RTE_RED_S (1 << 22)
57 #define RTE_RED_MAX_TH_MAX 1023
58 #define RTE_RED_WQ_LOG2_MIN 1
59 #define RTE_RED_WQ_LOG2_MAX 12
60 #define RTE_RED_MAXP_INV_MIN 1
61 #define RTE_RED_MAXP_INV_MAX 255
62 #define RTE_RED_2POW16 (1<<16)
63 #define RTE_RED_INT16_NBITS (sizeof(uint16_t) * CHAR_BIT)
64 #define RTE_RED_WQ_LOG2_NUM (RTE_RED_WQ_LOG2_MAX - RTE_RED_WQ_LOG2_MIN + 1)
68 #define RTE_RED_ASSERT(exp) \
70 rte_panic("line%d\tassert \"" #exp "\" failed\n", __LINE__); \
75 #define RTE_RED_ASSERT(exp) do { } while(0)
84 extern uint32_t rte_red_rand_seed;
85 extern uint16_t rte_red_log2_1_minus_Wq[RTE_RED_WQ_LOG2_NUM];
86 extern uint16_t rte_red_pow2_frac_inv[16];
147 const uint16_t wq_log2,
148 const uint16_t min_th,
149 const uint16_t max_th,
150 const uint16_t maxp_inv);
162 static inline uint32_t
165 rte_red_rand_seed = (214013 * rte_red_rand_seed) + 2531011;
166 return (rte_red_rand_seed >> 10);
179 static inline uint16_t
223 return (uint16_t) ((rte_red_pow2_frac_inv[f] + (1 << (n - 1))) >> n);
247 uint64_t time_diff = 0, m = 0;
249 RTE_RED_ASSERT(red_cfg != NULL);
250 RTE_RED_ASSERT(red != NULL);
258 time_diff = time - red->
q_time;
325 uint32_t pa_num_count = 0;
329 pa_num_count = red->
count * pa_num;
331 if (red_cfg->
pa_const <= pa_num_count)
334 pa_den = red_cfg->
pa_const - pa_num_count;
337 if (
unlikely((rte_red_rand_val % pa_den) < pa_num)) {
364 RTE_RED_ASSERT(red_cfg != NULL);
365 RTE_RED_ASSERT(red != NULL);
427 RTE_RED_ASSERT(red_cfg != NULL);
428 RTE_RED_ASSERT(red != NULL);