]> git.droids-corp.org - dpdk.git/commitdiff
sched: fix floating point math
authorStephen Hemminger <stephen@networkplumber.org>
Thu, 26 May 2022 20:26:53 +0000 (13:26 -0700)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 22 Jun 2022 09:11:48 +0000 (11:11 +0200)
The function rte_pie_drop was attempting to do a random probability
drop, but because of incorrect usage of fixed point divide
it would always return 1.

Change to use new rte_drand() instead.

Fixes: 44c730b0e379 ("sched: add PIE based congestion management")
Cc: stable@dpdk.org
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Jasvinder Singh <jasvinder.singh@intel.com>
lib/sched/rte_pie.h

index 3e2c1ef4672111a808d803d880ad87df63af97b6..528f2ea878e84653ff814efdd064d08ec390643d 100644 (file)
@@ -217,7 +217,6 @@ __rte_experimental
 _rte_pie_drop(const struct rte_pie_config *pie_cfg,
        struct rte_pie *pie)
 {
-       uint64_t rand_value;
        uint64_t qdelay = pie_cfg->qdelay_ref / 2;
 
        /* PIE is active but the queue is not congested: return 0 */
@@ -240,9 +239,7 @@ _rte_pie_drop(const struct rte_pie_config *pie_cfg,
        if (pie->accu_prob >= 8.5)
                return 1;
 
-       rand_value = rte_rand()/RTE_RAND_MAX;
-
-       if ((double)rand_value < pie->drop_prob) {
+       if (rte_drand() < pie->drop_prob) {
                pie->accu_prob = 0;
                return 1;
        }