From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from sesbmg23.ericsson.net (sesbmg23.ericsson.net [193.180.251.37]) by dpdk.org (Postfix) with ESMTP id 919BE2C54 for ; Mon, 8 Apr 2019 14:31:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/relaxed; q=dns/txt; i=@ericsson.com; t=1554726691; x=1557318691; h=From:Sender:Reply-To:Subject:Date:Message-ID:To:CC:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=3sFXeMrF3salHKItoY3zpReR9fRWB0UTFSJaZHyUXpI=; b=CqbS9UXYrbhp9Y9ni6QmkG3U4szFvfZis8h4Cs2eg3sI5dMBIPUjWXbuNWk3lqya LpfyXh9UNu9ijE62WHTf7pLy74suIQW9qii+rMuF0LFwrIZ8w+ojd5JxGkqEEYsi OJCUZg4nfoyc8JPpZAICxyz492/4hsVt+Nr+o0+kNrQ=; X-AuditID: c1b4fb25-91c349e000001b0f-25-5cab3f23a5ae Received: from ESESBMB502.ericsson.se (Unknown_Domain [153.88.183.115]) by sesbmg23.ericsson.net (Symantec Mail Security) with SMTP id 76.FA.06927.32F3BAC5; Mon, 8 Apr 2019 14:31:31 +0200 (CEST) Received: from ESESBMB502.ericsson.se (153.88.183.169) by ESESBMB502.ericsson.se (153.88.183.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Mon, 8 Apr 2019 14:30:47 +0200 Received: from selio1a020.lmera.ericsson.se (153.88.183.153) by smtp.internal.ericsson.com (153.88.183.185) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Mon, 8 Apr 2019 14:30:46 +0200 Received: from breslau.lmera.ericsson.se (breslau.lmera.ericsson.se [150.132.109.241]) by selio1a020.lmera.ericsson.se (8.15.1+Sun/8.15.1) with ESMTP id x38CUjiF011282; Mon, 8 Apr 2019 14:30:47 +0200 (CEST) From: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= To: CC: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= Date: Mon, 8 Apr 2019 14:30:28 +0200 Message-ID: <20190408123029.6701-2-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190408123029.6701-1-mattias.ronnblom@ericsson.com> References: <20190405135030.09c5291a@shemminger-XPS-13-9360> <20190408123029.6701-1-mattias.ronnblom@ericsson.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrMLMWRmVeSWpSXmKPExsUyM2J7sa6y/eoYg1en+C3efdrO5MDo8WvB UtYAxigum5TUnMyy1CJ9uwSujOuX9rEV7BSo+Na5maWB8Q1vFyMHh4SAicSFmTxdjFwcQgJH GSUmbjzKBOF8ZZS4fWEGK4RzgVFi0qwWZgjnEqPE/F/z2bsYOTnYBDwlJr/rZgGxRQSEJJZ+ vAwWZxZwl3j/aDkTiC0sYCgxdfM9VhCbRUBFYvn0XSwgq3kFHCV+tOWBhCUE5CVWbzjADGJz CjhJNJ6+CGYLCZRITJ+yAGwkr4CgxMmZT1ggxmtKtG7/DbVKXqJ562yoei2J+0u+ME9gFJqF pGUWkpZZSFoWMDKvYhQtTi1Oyk03MtZLLcpMLi7Oz9PLSy3ZxAgM2oNbfqvuYLz8xvEQowAH oxIP7xmj1TFCrIllxZW5hxglOJiVRHh3Tl0VI8SbklhZlVqUH19UmpNafIhRmoNFSZz3j5Bg jJBAemJJanZqakFqEUyWiYNTqoGRRcp5y2qna6w2B9zy17FN75/P9CniReByiyPqZh6Z2yvM 81REE26ruk9STrq24GWHM/Nz4S9/A3bPDMvN7xSxSq+ed9+yp+oS/7kgbsGeQoY1d74zBrsX F2w5e0O1Oc89zzLphts907jL3boTzpTZn2SPCrnwofrDthc3ZBL9czdfmlnb81OJpTgj0VCL uag4EQDN6DyyVgIAAA== Subject: [dpdk-dev] [RFC 2/3] Add 32-bit version of rte_rand X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Apr 2019 12:31:31 -0000 Signed-off-by: Mattias Rönnblom --- lib/librte_eal/common/include/rte_random.h | 15 +++++++++++---- lib/librte_eal/common/rte_random.c | 10 ++++++++++ lib/librte_eal/rte_eal_version.map | 1 + 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/librte_eal/common/include/rte_random.h b/lib/librte_eal/common/include/rte_random.h index bca85a672..a96fc7f96 100644 --- a/lib/librte_eal/common/include/rte_random.h +++ b/lib/librte_eal/common/include/rte_random.h @@ -35,11 +35,18 @@ void rte_srand(uint64_t seedval); /** - * Get a pseudo-random value. + * Generates a 32-bit pseudo-random number. * - * This function generates pseudo-random numbers using the linear - * congruential algorithm and 48-bit integer arithmetic, called twice - * to generate a 64-bit value. + * If called from lcore threads, this function is thread-safe. + * + * @return + * A pseudo-random value between 0 and (1<<32)-1. + */ +uint32_t +rte_rand32(void); + +/** + * Generates a 64-bit pseudo-random number. * * If called from lcore threads, this function is thread-safe. * diff --git a/lib/librte_eal/common/rte_random.c b/lib/librte_eal/common/rte_random.c index b8fb7006e..c6dac2fc7 100644 --- a/lib/librte_eal/common/rte_random.c +++ b/lib/librte_eal/common/rte_random.c @@ -83,6 +83,16 @@ struct rte_rand_state *__rte_rand_get_state(void) return &rand_states[lcore_id]; } +uint32_t __rte_experimental +rte_rand32(void) +{ + struct rte_rand_state *state; + + state = __rte_rand_get_state(); + + return __rte_rand32(state); +} + uint64_t __rte_experimental rte_rand(void) { diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map index 0d60668fa..027a22fe5 100644 --- a/lib/librte_eal/rte_eal_version.map +++ b/lib/librte_eal/rte_eal_version.map @@ -366,6 +366,7 @@ EXPERIMENTAL { rte_mp_request_async; rte_mp_sendmsg; rte_option_register; + rte_rand32; rte_rand; rte_realloc_socket; rte_service_lcore_attr_get; -- 2.17.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id F12B8A0096 for ; Mon, 8 Apr 2019 14:31:32 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B92A25424; Mon, 8 Apr 2019 14:31:32 +0200 (CEST) Received: from sesbmg23.ericsson.net (sesbmg23.ericsson.net [193.180.251.37]) by dpdk.org (Postfix) with ESMTP id 919BE2C54 for ; Mon, 8 Apr 2019 14:31:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/relaxed; q=dns/txt; i=@ericsson.com; t=1554726691; x=1557318691; h=From:Sender:Reply-To:Subject:Date:Message-ID:To:CC:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=3sFXeMrF3salHKItoY3zpReR9fRWB0UTFSJaZHyUXpI=; b=CqbS9UXYrbhp9Y9ni6QmkG3U4szFvfZis8h4Cs2eg3sI5dMBIPUjWXbuNWk3lqya LpfyXh9UNu9ijE62WHTf7pLy74suIQW9qii+rMuF0LFwrIZ8w+ojd5JxGkqEEYsi OJCUZg4nfoyc8JPpZAICxyz492/4hsVt+Nr+o0+kNrQ=; X-AuditID: c1b4fb25-91c349e000001b0f-25-5cab3f23a5ae Received: from ESESBMB502.ericsson.se (Unknown_Domain [153.88.183.115]) by sesbmg23.ericsson.net (Symantec Mail Security) with SMTP id 76.FA.06927.32F3BAC5; Mon, 8 Apr 2019 14:31:31 +0200 (CEST) Received: from ESESBMB502.ericsson.se (153.88.183.169) by ESESBMB502.ericsson.se (153.88.183.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Mon, 8 Apr 2019 14:30:47 +0200 Received: from selio1a020.lmera.ericsson.se (153.88.183.153) by smtp.internal.ericsson.com (153.88.183.185) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Mon, 8 Apr 2019 14:30:46 +0200 Received: from breslau.lmera.ericsson.se (breslau.lmera.ericsson.se [150.132.109.241]) by selio1a020.lmera.ericsson.se (8.15.1+Sun/8.15.1) with ESMTP id x38CUjiF011282; Mon, 8 Apr 2019 14:30:47 +0200 (CEST) From: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= To: CC: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= Date: Mon, 8 Apr 2019 14:30:28 +0200 Message-ID: <20190408123029.6701-2-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190408123029.6701-1-mattias.ronnblom@ericsson.com> References: <20190405135030.09c5291a@shemminger-XPS-13-9360> <20190408123029.6701-1-mattias.ronnblom@ericsson.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrMLMWRmVeSWpSXmKPExsUyM2J7sa6y/eoYg1en+C3efdrO5MDo8WvB UtYAxigum5TUnMyy1CJ9uwSujOuX9rEV7BSo+Na5maWB8Q1vFyMHh4SAicSFmTxdjFwcQgJH GSUmbjzKBOF8ZZS4fWEGK4RzgVFi0qwWZgjnEqPE/F/z2bsYOTnYBDwlJr/rZgGxRQSEJJZ+ vAwWZxZwl3j/aDkTiC0sYCgxdfM9VhCbRUBFYvn0XSwgq3kFHCV+tOWBhCUE5CVWbzjADGJz CjhJNJ6+CGYLCZRITJ+yAGwkr4CgxMmZT1ggxmtKtG7/DbVKXqJ562yoei2J+0u+ME9gFJqF pGUWkpZZSFoWMDKvYhQtTi1Oyk03MtZLLcpMLi7Oz9PLSy3ZxAgM2oNbfqvuYLz8xvEQowAH oxIP7xmj1TFCrIllxZW5hxglOJiVRHh3Tl0VI8SbklhZlVqUH19UmpNafIhRmoNFSZz3j5Bg jJBAemJJanZqakFqEUyWiYNTqoGRRcp5y2qna6w2B9zy17FN75/P9CniReByiyPqZh6Z2yvM 81REE26ruk9STrq24GWHM/Nz4S9/A3bPDMvN7xSxSq+ed9+yp+oS/7kgbsGeQoY1d74zBrsX F2w5e0O1Oc89zzLphts907jL3boTzpTZn2SPCrnwofrDthc3ZBL9czdfmlnb81OJpTgj0VCL uag4EQDN6DyyVgIAAA== Subject: [dpdk-dev] [RFC 2/3] Add 32-bit version of rte_rand X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Message-ID: <20190408123028.GgMU3KbCAeRQWeyF_jM5IIDfhlfjVqh8nAb0CsQW2kI@z> Signed-off-by: Mattias Rönnblom --- lib/librte_eal/common/include/rte_random.h | 15 +++++++++++---- lib/librte_eal/common/rte_random.c | 10 ++++++++++ lib/librte_eal/rte_eal_version.map | 1 + 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/librte_eal/common/include/rte_random.h b/lib/librte_eal/common/include/rte_random.h index bca85a672..a96fc7f96 100644 --- a/lib/librte_eal/common/include/rte_random.h +++ b/lib/librte_eal/common/include/rte_random.h @@ -35,11 +35,18 @@ void rte_srand(uint64_t seedval); /** - * Get a pseudo-random value. + * Generates a 32-bit pseudo-random number. * - * This function generates pseudo-random numbers using the linear - * congruential algorithm and 48-bit integer arithmetic, called twice - * to generate a 64-bit value. + * If called from lcore threads, this function is thread-safe. + * + * @return + * A pseudo-random value between 0 and (1<<32)-1. + */ +uint32_t +rte_rand32(void); + +/** + * Generates a 64-bit pseudo-random number. * * If called from lcore threads, this function is thread-safe. * diff --git a/lib/librte_eal/common/rte_random.c b/lib/librte_eal/common/rte_random.c index b8fb7006e..c6dac2fc7 100644 --- a/lib/librte_eal/common/rte_random.c +++ b/lib/librte_eal/common/rte_random.c @@ -83,6 +83,16 @@ struct rte_rand_state *__rte_rand_get_state(void) return &rand_states[lcore_id]; } +uint32_t __rte_experimental +rte_rand32(void) +{ + struct rte_rand_state *state; + + state = __rte_rand_get_state(); + + return __rte_rand32(state); +} + uint64_t __rte_experimental rte_rand(void) { diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map index 0d60668fa..027a22fe5 100644 --- a/lib/librte_eal/rte_eal_version.map +++ b/lib/librte_eal/rte_eal_version.map @@ -366,6 +366,7 @@ EXPERIMENTAL { rte_mp_request_async; rte_mp_sendmsg; rte_option_register; + rte_rand32; rte_rand; rte_realloc_socket; rte_service_lcore_attr_get; -- 2.17.1