From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) by dpdk.org (Postfix) with ESMTP id 42FE32B92 for ; Mon, 19 Nov 2018 13:25:45 +0100 (CET) Received: by mail-wm1-f54.google.com with SMTP id g131so4719124wmg.3 for ; Mon, 19 Nov 2018 04:25:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2QVNkkyZndmT0tPq4ufV4zPK0zFYspaDyOfKeT9SIek=; b=sW7bQM+MFd76F49t2JkIL5mdCOa2Ui2omOmm2xPEI3/wTr5HFyWjfKTmlg0mBzzBhp smGBZm+xsBq/llnBTcgohTueRKZ+M80f18iENBIk5G1hGHY/41K/f5R1Sk3OAEekuTEa ttf1Y07WqwAoObwvH62OPbBFtuQxmDxW8zRyjP3nTEvSGYrf+7rMC9mT0+m5U5lnN69z Epmv8aRMuhcbU4Y85pgHttNWBSaksHcXVh04CGl7ES5peG3+rRtJncfnmq1Gpz6W0zcj lW5AfV6m+JqRP2/uWaALfPaKJXAbk3Z7QIoE13qCNcvAUA5LNPFK0NCcRg12enQgAlFP /1+Q== X-Gm-Message-State: AGRZ1gLt7haGKRJTYnrJvX4gUu79wMwsfW2m+A7EJUEsE87wjbX3PTRy qMyA38thdi28UZ3kqdr5n7M= X-Google-Smtp-Source: AFSGD/X/VwQB5uQ6x7jn6fMaHRivzdDBPqhEKcGRnoJCvfIKvuIqNAeHmaaAjNpEeTf+7h5pLEnU2g== X-Received: by 2002:a1c:3c1:: with SMTP id 184-v6mr6789922wmd.90.1542630344636; Mon, 19 Nov 2018 04:25:44 -0800 (PST) Received: from localhost ([2a01:4b00:f419:6f00:8361:8946:ba2b:d556]) by smtp.gmail.com with ESMTPSA id z3-v6sm23293144wma.6.2018.11.19.04.25.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 19 Nov 2018 04:25:43 -0800 (PST) From: Luca Boccassi To: Jerin Jacob Cc: dpdk stable Date: Mon, 19 Nov 2018 12:25:18 +0000 Message-Id: <20181119122538.14207-1-bluca@debian.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181108180111.25873-1-bluca@debian.org> References: <20181108180111.25873-1-bluca@debian.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'eal: introduce rte version of fls' has been queued to LTS release 16.11.9 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Nov 2018 12:25:45 -0000 Hi, FYI, your patch has been queued to LTS release 16.11.9 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/21/18. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. If the code is different (ie: not only metadata diffs), due for example to a change in context or macro names, please double check it. Note that this patch has been cherry-picked to allow the backporting of Fixes: 5d08fecdd39f ("eal: fix build") Thanks. Luca Boccassi --- >>From 35072ede1f49874059f563c0b2be8e1d8f56691b Mon Sep 17 00:00:00 2001 From: Jerin Jacob Date: Wed, 7 Nov 2018 06:59:03 +0000 Subject: [PATCH] eal: introduce rte version of fls [ upstream commit 3a6f2c50b9dc27a958af87d7ca9533b51a36477b ] The function returns the last (most-significant) bit set. Added unit testcase to verify rte_fls_u32(). Signed-off-by: Jerin Jacob --- app/test/test_common.c | 32 ++++++++++++++++++++++ lib/librte_eal/common/include/rte_common.h | 17 ++++++++++++ 2 files changed, 49 insertions(+) diff --git a/app/test/test_common.c b/app/test/test_common.c index 8effa2f9e..afd2b99f9 100644 --- a/app/test/test_common.c +++ b/app/test/test_common.c @@ -158,6 +158,37 @@ test_align(void) return 0; } +static int +test_fls(void) +{ + struct fls_test_vector { + uint32_t arg; + int rc; + }; + int expected, rc; + uint32_t i, arg; + + const struct fls_test_vector test[] = { + {0x0, 0}, + {0x1, 1}, + {0x4000, 15}, + {0x80000000, 32}, + }; + + for (i = 0; i < RTE_DIM(test); i++) { + arg = test[i].arg; + rc = rte_fls_u32(arg); + expected = test[i].rc; + if (rc != expected) { + printf("Wrong rte_fls_u32(0x%x) rc=%d, expected=%d\n", + arg, rc, expected); + return TEST_FAILED; + } + } + + return 0; +} + static int test_common(void) { @@ -165,6 +196,7 @@ test_common(void) ret |= test_align(); ret |= test_macros(0); ret |= test_misc(); + ret |= test_fls(); return ret; } diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h index f5e2f8861..9ae584717 100644 --- a/lib/librte_eal/common/include/rte_common.h +++ b/lib/librte_eal/common/include/rte_common.h @@ -326,6 +326,23 @@ rte_bsf32(uint32_t v) return (uint32_t)__builtin_ctz(v); } +/** + * Return the last (most-significant) bit set. + * + * @note The last (most significant) bit is at position 32. + * @note rte_fls_u32(0) = 0, rte_fls_u32(1) = 1, rte_fls_u32(0x80000000) = 32 + * + * @param x + * The input parameter. + * @return + * The last (most-significant) bit set, or 0 if the input is 0. + */ +static inline int +rte_fls_u32(uint32_t x) +{ + return (x == 0) ? 0 : 32 - __builtin_clz(x); +} + #ifndef offsetof /** Return the offset of a field in a structure. */ #define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER) -- 2.19.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2018-11-19 12:15:18.168290468 +0000 +++ 0002-eal-introduce-rte-version-of-fls.patch 2018-11-19 12:15:18.067611434 +0000 @@ -1,52 +1,24 @@ -From 3a6f2c50b9dc27a958af87d7ca9533b51a36477b Mon Sep 17 00:00:00 2001 +From 35072ede1f49874059f563c0b2be8e1d8f56691b Mon Sep 17 00:00:00 2001 From: Jerin Jacob Date: Wed, 7 Nov 2018 06:59:03 +0000 Subject: [PATCH] eal: introduce rte version of fls +[ upstream commit 3a6f2c50b9dc27a958af87d7ca9533b51a36477b ] + The function returns the last (most-significant) bit set. Added unit testcase to verify rte_fls_u32(). Signed-off-by: Jerin Jacob --- - lib/librte_eal/common/include/rte_common.h | 19 +++++++++++++ - test/test/test_common.c | 32 ++++++++++++++++++++++ - 2 files changed, 51 insertions(+) + app/test/test_common.c | 32 ++++++++++++++++++++++ + lib/librte_eal/common/include/rte_common.h | 17 ++++++++++++ + 2 files changed, 49 insertions(+) -diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h -index cba7bbc1d..87f0f6302 100644 ---- a/lib/librte_eal/common/include/rte_common.h -+++ b/lib/librte_eal/common/include/rte_common.h -@@ -473,6 +473,25 @@ rte_log2_u32(uint32_t v) - return rte_bsf32(v); - } - -+ -+/** -+ * Return the last (most-significant) bit set. -+ * -+ * @note The last (most significant) bit is at position 32. -+ * @note rte_fls_u32(0) = 0, rte_fls_u32(1) = 1, rte_fls_u32(0x80000000) = 32 -+ * -+ * @param x -+ * The input parameter. -+ * @return -+ * The last (most-significant) bit set, or 0 if the input is 0. -+ */ -+static inline int -+rte_fls_u32(uint32_t x) -+{ -+ return (x == 0) ? 0 : 32 - __builtin_clz(x); -+} -+ -+ - #ifndef offsetof - /** Return the offset of a field in a structure. */ - #define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER) -diff --git a/test/test/test_common.c b/test/test/test_common.c -index 7a67e458e..c6d17baae 100644 ---- a/test/test/test_common.c -+++ b/test/test/test_common.c -@@ -188,6 +188,37 @@ test_log2(void) +diff --git a/app/test/test_common.c b/app/test/test_common.c +index 8effa2f9e..afd2b99f9 100644 +--- a/app/test/test_common.c ++++ b/app/test/test_common.c +@@ -158,6 +158,37 @@ test_align(void) return 0; } @@ -84,14 +56,42 @@ static int test_common(void) { -@@ -196,6 +227,7 @@ test_common(void) +@@ -165,6 +196,7 @@ test_common(void) + ret |= test_align(); ret |= test_macros(0); ret |= test_misc(); - ret |= test_log2(); + ret |= test_fls(); return ret; } +diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h +index f5e2f8861..9ae584717 100644 +--- a/lib/librte_eal/common/include/rte_common.h ++++ b/lib/librte_eal/common/include/rte_common.h +@@ -326,6 +326,23 @@ rte_bsf32(uint32_t v) + return (uint32_t)__builtin_ctz(v); + } + ++/** ++ * Return the last (most-significant) bit set. ++ * ++ * @note The last (most significant) bit is at position 32. ++ * @note rte_fls_u32(0) = 0, rte_fls_u32(1) = 1, rte_fls_u32(0x80000000) = 32 ++ * ++ * @param x ++ * The input parameter. ++ * @return ++ * The last (most-significant) bit set, or 0 if the input is 0. ++ */ ++static inline int ++rte_fls_u32(uint32_t x) ++{ ++ return (x == 0) ? 0 : 32 - __builtin_clz(x); ++} ++ + #ifndef offsetof + /** Return the offset of a field in a structure. */ + #define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER) -- 2.19.1