From patchwork Wed May 25 20:31:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 111862 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E01BEA0548; Wed, 25 May 2022 22:31:34 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8C18C4113D; Wed, 25 May 2022 22:31:32 +0200 (CEST) Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by mails.dpdk.org (Postfix) with ESMTP id BEBB240151 for ; Wed, 25 May 2022 22:31:28 +0200 (CEST) Received: by mail-pl1-f178.google.com with SMTP id w3so12921338plp.13 for ; Wed, 25 May 2022 13:31:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YxFnp0rRgQYyfqp65dse6vScTgorFYwN1jd8CQlKeIo=; b=KFrLIJRFquEDC0yQfesMrVw5GJqm9upzDEVlmRJx2KlVORgJp3B3jjKdg8YJkzxnXz v9isUz8ALesJU11ZpEW9JMWKzlB4czslqEbr8roskBsJoQEX6Wd9Alg2cZXU/jcYyV2f ZCZAo1FjuSbc4rP7uF+PQ+SU6nTLNZV5e4w/Pi1Go1ydpurDMUQ0YuYI14i0aNrp08wm bQdPhmGrLkXErgczMJtT+6Zew+KNsfZ7MbxmC67lkvvHhN/0U/bJe30SC4oUye8j5EqX vHUryxK3DdCgBWxmlAnc2p+6Br3zzoVHvtMeaei2o3St34vBR4A32ZWFB9B1OU+oMzU1 uwGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YxFnp0rRgQYyfqp65dse6vScTgorFYwN1jd8CQlKeIo=; b=rtPT0T7+v7w3TON/pM10W98h3lpCbqHY7NQPqRqa8Gz4djHHq4yMbMTCaEcOgKMS6Z xVtUomBpvZsEOvgW1NocpIrMOHB2BnvYfUnyQ8nAu22D9rG2H9UGNue4b1uzHBFmVGcr tDuP8FH1bCYtY73b/T0fI2APZXusDRx/u5EO3NzRl3Grt14AxAPtBFa6FzPySz8p2Q8L IpDv2k0JQQK2J6RttSZ6VuTKV4HJ1Vjub5ozGSnNAaOjUfCv/8LPbiE289LrAUkZ1YoY 4yj3XMgnBqtiIwhynmGOm/934wddLutAeaNDtkjkp+refB30ntTccgsWKwFgPkmZxI0T gasg== X-Gm-Message-State: AOAM530gO8SS/kyJR/cDZDgYebPp+P8TQASpVQ8kBKBlgtEfuNy0Wuiw S2lf2jowaCTw5P6XnSox2wtsBENMRL4oNA== X-Google-Smtp-Source: ABdhPJwNRX+F4CJi+MkLK97uwU8fdEMWSt9ddOHlql2Ea+SJDFQaLMiPTvr/4I8CHzSgpQBRdwBE2A== X-Received: by 2002:a17:90a:d3c7:b0:1e0:d55e:35eb with SMTP id d7-20020a17090ad3c700b001e0d55e35ebmr200515pjw.105.1653510687722; Wed, 25 May 2022 13:31:27 -0700 (PDT) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id a26-20020a62d41a000000b0050dc7628176sm11766091pfh.80.2022.05.25.13.31.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 May 2022 13:31:26 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , =?utf-8?q?Mattias_R?= =?utf-8?q?=C3=B6nnblom?= , Ray Kinsella Subject: [PATCH v4 1/3] random: add rte_drand() function Date: Wed, 25 May 2022 13:31:21 -0700 Message-Id: <20220525203123.277180-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220525203123.277180-1-stephen@networkplumber.org> References: <20220524184623.480646-1-stephen@networkplumber.org> <20220525203123.277180-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The PIE code and other applications can benefit from having a fast way to get a random floating point value. This new function is equivalent to drand() in the standard library. Signed-off-by: Stephen Hemminger Acked-by: Ray Kinsella --- app/test/test_rand_perf.c | 7 +++++ doc/guides/rel_notes/release_22_07.rst | 5 ++++ lib/eal/common/rte_random.c | 41 ++++++++++++++++++++++++++ lib/eal/include/rte_random.h | 18 +++++++++++ lib/eal/meson.build | 3 ++ lib/eal/version.map | 1 + 6 files changed, 75 insertions(+) diff --git a/app/test/test_rand_perf.c b/app/test/test_rand_perf.c index fe797ebfa1ca..26fb1d9a586e 100644 --- a/app/test/test_rand_perf.c +++ b/app/test/test_rand_perf.c @@ -20,6 +20,7 @@ static volatile uint64_t vsum; enum rand_type { rand_type_64, + rand_type_float, rand_type_bounded_best_case, rand_type_bounded_worst_case }; @@ -30,6 +31,8 @@ rand_type_desc(enum rand_type rand_type) switch (rand_type) { case rand_type_64: return "Full 64-bit [rte_rand()]"; + case rand_type_float: + return "Floating point [rte_drand()]"; case rand_type_bounded_best_case: return "Bounded average best-case [rte_rand_max()]"; case rand_type_bounded_worst_case: @@ -55,6 +58,9 @@ test_rand_perf_type(enum rand_type rand_type) case rand_type_64: sum += rte_rand(); break; + case rand_type_float: + sum += 1000. * rte_drand(); + break; case rand_type_bounded_best_case: sum += rte_rand_max(BEST_CASE_BOUND); break; @@ -83,6 +89,7 @@ test_rand_perf(void) printf("Pseudo-random number generation latencies:\n"); test_rand_perf_type(rand_type_64); + test_rand_perf_type(rand_type_float); test_rand_perf_type(rand_type_bounded_best_case); test_rand_perf_type(rand_type_bounded_worst_case); diff --git a/doc/guides/rel_notes/release_22_07.rst b/doc/guides/rel_notes/release_22_07.rst index e49cacecefd4..b131ea577226 100644 --- a/doc/guides/rel_notes/release_22_07.rst +++ b/doc/guides/rel_notes/release_22_07.rst @@ -104,6 +104,11 @@ New Features * ``RTE_EVENT_QUEUE_ATTR_WEIGHT`` * ``RTE_EVENT_QUEUE_ATTR_AFFINITY`` +* ** Added function get random floating point number.** + + Added the function ``rte_drand()`` to provide a pseudo-random + floating point number. + Removed Items ------------- diff --git a/lib/eal/common/rte_random.c b/lib/eal/common/rte_random.c index 4535cc980cec..3dc3484ee655 100644 --- a/lib/eal/common/rte_random.c +++ b/lib/eal/common/rte_random.c @@ -6,6 +6,9 @@ #include #endif #include +#ifdef RTE_LIBEAL_USE_IEEE754 +#include +#endif #include #include @@ -173,6 +176,44 @@ rte_rand_max(uint64_t upper_bound) return res; } +double +rte_drand(void) +{ + struct rte_rand_state *state = __rte_rand_get_state(); + uint64_t rand64 = __rte_rand_lfsr258(state); +#ifdef RTE_LIBEAL_USE_IEEE754 + union ieee754_double u = { + .ieee = { + .negative = 0, + .exponent = IEEE754_DOUBLE_BIAS, + }, + }; + + /* Take 64 bit random value and put it into the mantissa + * This uses direct access to IEEE format to avoid doing + * any direct floating point math here. + */ + u.ieee.mantissa0 = rand64 >> 32; + u.ieee.mantissa1 = rand64; + + return u.d - 1.0; +#else + /* Slower method requiring floating point divide + * + * The double mantissa only has 53 bits, so we uniformly mask off the + * high 11 bits and then floating-point divide by 2^53 to achieve a + * result in [0, 1). + * + * We are not allowed to emit 1.0, so denom must be one greater than + * the possible range of the preceeding step. + */ + static const uint64_t denom = (uint64_t)1 << 53; + + rand64 &= denom - 1; + return (double)rand64 / denom; +#endif +} + static uint64_t __rte_random_initial_seed(void) { diff --git a/lib/eal/include/rte_random.h b/lib/eal/include/rte_random.h index 29f5f1325a30..f6541c2b0f08 100644 --- a/lib/eal/include/rte_random.h +++ b/lib/eal/include/rte_random.h @@ -65,6 +65,24 @@ rte_rand(void); uint64_t rte_rand_max(uint64_t upper_bound); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Generates a pseudo-random floating point number. + * + * This function returns a nonnegative double-precision floating random + * number uniformly distributed over the interval [0.0, 1.0). + * + * The generator is not cryptographically secure. + * If called from lcore threads, this function is thread-safe. + * + * @return + * A pseudo-random value between 0 and 1.0. + */ +__rte_experimental +double rte_drand(void); + #ifdef __cplusplus } #endif diff --git a/lib/eal/meson.build b/lib/eal/meson.build index 056beb946119..e50524901c98 100644 --- a/lib/eal/meson.build +++ b/lib/eal/meson.build @@ -32,3 +32,6 @@ endif if cc.has_function('getentropy', prefix : '#include ') cflags += '-DRTE_LIBEAL_USE_GETENTROPY' endif +if cc.has_header_symbol('ieee754.h', 'union ieee754_double') + cflags += '-DRTE_LIBEAL_USE_IEEE754' +endif diff --git a/lib/eal/version.map b/lib/eal/version.map index d49e30bd042f..cfbade9a33e9 100644 --- a/lib/eal/version.map +++ b/lib/eal/version.map @@ -422,6 +422,7 @@ EXPERIMENTAL { rte_intr_type_set; # added in 22.07 + rte_drand; rte_thread_get_affinity_by_id; rte_thread_self; rte_thread_set_affinity_by_id; From patchwork Wed May 25 20:31:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 111863 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 52D2FA0548; Wed, 25 May 2022 22:31:41 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6CA0742685; Wed, 25 May 2022 22:31:33 +0200 (CEST) Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by mails.dpdk.org (Postfix) with ESMTP id AD2F941133 for ; Wed, 25 May 2022 22:31:30 +0200 (CEST) Received: by mail-pj1-f45.google.com with SMTP id u12-20020a17090a1d4c00b001df78c7c209so2638530pju.1 for ; Wed, 25 May 2022 13:31:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RAzbMDFiIwiPJhzEkWWAkxxdDj6dwlxR+qdCBT14VP0=; b=7q4BKYZax0zAc1PKz3ycbAtlpXPBCJQQBFm2jultHw+4/j4OvRd9d0yZduKjuu88o0 7gYoVk5OkQuws8sXLlCAlhDipccw2bsUXg7lKpfidBeAJBQ6uTuNfXKFb+rtawNoqYXN q7Z2nnrN+0r+r63tS/n9+8Z7fBbCTp5rW1KSYM00RONYTzs8VrfVpl6epeVrZkLhFMQL B7qq6xKQq3bhoZkbF8gaVoTmMe71+GdlOZAxoR/usvhz/Rx5yu/etWdfY+x/O3A1aa5U n2xlDr+BylVcTvVKfQAOQq8C/QFszoCkJEpCC9HdlxByIEPsIJaOQ78VyanQ0fEkz+AW HlqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RAzbMDFiIwiPJhzEkWWAkxxdDj6dwlxR+qdCBT14VP0=; b=ELCf9aPb+FSIXVzFiCxEZoN4i24vp3WLDLZsP0ziCf6+p+xMtwHpgVumAHGBRVFqZW 2CvfBufyH1LtRvTiNhpbf/oXmpWyofYXkVxjEh6pakQKqWdFQH/MG09VyKNYx51Eoc5p rIs0olaD3FcopBjx9OVqDvUrGH5uKoSKGy4WLyXdbNphSQm2jK7v0Yfmae9dK4PE8Uix 62S/mQyk8SyQ71C7R2Si+BR2ZkXkvHTkfuNb5wFGsFxGL12KKKzuugsbZCRhnso9wKZ1 hfgFr/1mxzgalPPZwQTz3i8dpqYTFTiZm+vTvD6GhweizW2u5ZY9CC/XsmGVYORqFpam pblA== X-Gm-Message-State: AOAM530HZP7SFOqDrPM+qs73QXDNNStOuoKM0YDZUN0Jwi13yr6H57AL PDIUQbmp9dEt1Gf1ZNXI46dmrlWQL8vt8Q== X-Google-Smtp-Source: ABdhPJxbKw7lYC51NSCOW8Td9UVYiYj3+GsnyE9Ild+OxDZ7RZW/DK97lIKFFCivjNOS/BHbSow05A== X-Received: by 2002:a17:902:c952:b0:162:14b6:3179 with SMTP id i18-20020a170902c95200b0016214b63179mr19730122pla.7.1653510689267; Wed, 25 May 2022 13:31:29 -0700 (PDT) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id a26-20020a62d41a000000b0050dc7628176sm11766091pfh.80.2022.05.25.13.31.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 May 2022 13:31:28 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Cristian Dumitrescu , Jasvinder Singh , Wojciech Liguzinski Subject: [PATCH v4 2/3] rte_pie: remove unnecessary floating point Date: Wed, 25 May 2022 13:31:22 -0700 Message-Id: <20220525203123.277180-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220525203123.277180-1-stephen@networkplumber.org> References: <20220524184623.480646-1-stephen@networkplumber.org> <20220525203123.277180-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The qdelay variable is derived from and compared to 64 bit value so it doesn't have to be floating point. Fixes: 44c730b0e379 ("sched: add PIE based congestion management") Signed-off-by: Stephen Hemminger --- lib/sched/rte_pie.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sched/rte_pie.h b/lib/sched/rte_pie.h index 02a987f54ad1..3e2c1ef46721 100644 --- a/lib/sched/rte_pie.h +++ b/lib/sched/rte_pie.h @@ -218,7 +218,7 @@ _rte_pie_drop(const struct rte_pie_config *pie_cfg, struct rte_pie *pie) { uint64_t rand_value; - double qdelay = pie_cfg->qdelay_ref * 0.5; + uint64_t qdelay = pie_cfg->qdelay_ref / 2; /* PIE is active but the queue is not congested: return 0 */ if (((pie->qdelay_old < qdelay) && (pie->drop_prob < 0.2)) || From patchwork Wed May 25 20:31:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 111864 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 155D5A0548; Wed, 25 May 2022 22:31:48 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5B74A427F6; Wed, 25 May 2022 22:31:34 +0200 (CEST) Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by mails.dpdk.org (Postfix) with ESMTP id E99B441181 for ; Wed, 25 May 2022 22:31:32 +0200 (CEST) Received: by mail-pj1-f53.google.com with SMTP id z11so10896879pjc.3 for ; Wed, 25 May 2022 13:31:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dn470I1AAXYIPllkE0iKbl8OtBnx1LYxnn0mwkxAqPY=; b=pt5bGAWkj0QijlG84ovOj5K0Y8srt1NVBywu1UEESoDZX/iH9ce+fUnxjIcL9Ft4yz pXzmMJ31oAgosu0ANfKZ/9DGEHY2Te65SJmxzrqHeD0NtDO2BF8ftGvK281CW5e8e9mT yviPr2P6qMDw672E9tSq28wFKhExZ+e+2dW020bnNMzaaJhA02NnV6+70KjoZzwC0FIM V7DlOTjp7RYtU2RxWKZdxIixhEX92Mogzid2xIT8bUt97Ih7EoXGGzHeWX0YqFj/yHSN leAfkMiHSUmKCqLJpS3taGVUycdetxy/zsmSwvfvVKjYuJSqBcoTKWw+mezNYeIUpf8q apfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dn470I1AAXYIPllkE0iKbl8OtBnx1LYxnn0mwkxAqPY=; b=jxvgpQoZ9LCZUH6WBcyEr5YwrgMJ8kJ0ilAQqa/oUJo3GHXpbNa+sr86OC3PmTuNP3 L8liTjrSJ/C0r/ONK/J/1ZB1N0gF2ZaUBEWfeYQKXgAi8mOg1Df7HNkwV8mO1SlrFLA1 8CdxAqwtG+8P8AJmziXyuD/gOQtPQFweJRSs1Ji8NC9jPb93y5rUhf9POAg6C3Fg03DT m55pWEJKXYFHA5cnchY1oDFfIskzX6ifdqWxXnvsVOwLwNiM5qSfReWnLTKeSO5wsBfW 7IdGgZoftVhQy8g2iw0LWZL+NrYv40VYU2lR5nLfSFlzNqRO/YM8p52I5muleOrm9q81 C/BA== X-Gm-Message-State: AOAM530erhOn0ZCevABvsn1NCSuOoiBqB+/lNy7E5JRa8kNleaxQJT53 X1uppCrR2zdUbYwhimmQzuHksPfv37310A== X-Google-Smtp-Source: ABdhPJwaAJ+E2/qXp/K/44DKRnUV9bYuqelahWL+HvKKbvowd95XMjget++idPz4dNWr4/glw+E9fA== X-Received: by 2002:a17:903:32cc:b0:161:9539:fd49 with SMTP id i12-20020a17090332cc00b001619539fd49mr35105272plr.117.1653510690811; Wed, 25 May 2022 13:31:30 -0700 (PDT) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id a26-20020a62d41a000000b0050dc7628176sm11766091pfh.80.2022.05.25.13.31.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 May 2022 13:31:30 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Cristian Dumitrescu , Jasvinder Singh , Wojciech Liguzinski Subject: [PATCH v4 3/3] rte_pie: fix incorrect floating point math Date: Wed, 25 May 2022 13:31:23 -0700 Message-Id: <20220525203123.277180-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220525203123.277180-1-stephen@networkplumber.org> References: <20220524184623.480646-1-stephen@networkplumber.org> <20220525203123.277180-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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") Signed-off-by: Stephen Hemminger --- lib/sched/rte_pie.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/sched/rte_pie.h b/lib/sched/rte_pie.h index 3e2c1ef46721..528f2ea878e8 100644 --- a/lib/sched/rte_pie.h +++ b/lib/sched/rte_pie.h @@ -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; }