MCPcopy Create free account
hub / github.com/F-Stack/f-stack / __rte_red_drop

Function __rte_red_drop

dpdk/lib/sched/rte_red.h:273–298  ·  view source on GitHub ↗

* @brief make a decision to drop or enqueue a packet based on mark probability * criteria * * @param red_cfg [in] config pointer to structure defining RED parameters * @param red [in,out] data pointer to RED runtime data * * @return operation status * @retval 0 enqueue the packet * @retval 1 drop the packet */

Source from the content-addressed store, hash-verified

271 * @retval 1 drop the packet
272 */
273static inline int
274__rte_red_drop(const struct rte_red_config *red_cfg, struct rte_red *red)
275{
276 uint32_t pa_num = 0; /* numerator of drop-probability */
277 uint32_t pa_den = 0; /* denominator of drop-probability */
278 uint32_t pa_num_count = 0;
279
280 pa_num = (red->avg - red_cfg->min_th) >> (red_cfg->wq_log2);
281
282 pa_num_count = red->count * pa_num;
283
284 if (red_cfg->pa_const <= pa_num_count)
285 return 1;
286
287 pa_den = red_cfg->pa_const - pa_num_count;
288
289 /* If drop, generate and save random number to be used next time */
290 if (unlikely((rte_red_rand_val % pa_den) < pa_num)) {
291 rte_red_rand_val = rte_fast_rand();
292
293 return 1;
294 }
295
296 /* No drop */
297 return 0;
298}
299
300/**
301 * @brief Decides if new packet should be enqueued or dropped in queue non-empty case

Callers 1

rte_red_enqueue_nonemptyFunction · 0.85

Calls 1

rte_fast_randFunction · 0.85

Tested by

no test coverage detected