DPDK patches and discussions
 help / color / mirror / Atom feed
From: Vivek Sharma <vivek.sharma@caviumnetworks.com>
To: dev@dpdk.org
Cc: cristian.dumitrescu@intel.com,
	Vivek Sharma <vivek.sharma@caviumnetworks.com>
Subject: [dpdk-dev] [PATCH 2/2] test/bitmap: implement reverse bitmap scan test
Date: Tue,  9 Oct 2018 13:24:59 +0530	[thread overview]
Message-ID: <1539071699-29963-3-git-send-email-vivek.sharma@caviumnetworks.com> (raw)
In-Reply-To: <1539071699-29963-1-git-send-email-vivek.sharma@caviumnetworks.com>

This patch implements support for testing bitmap reverse scan.
Bits in bitmap are changed to be an exact multiple of slab size.

Signed-off-by: Vivek Sharma <vivek.sharma@caviumnetworks.com>
---
Prerequisite:
* Note that this patchset is dependent on patch:
  'http://patches.dpdk.org/patch/45307/'

 test/test/test_bitmap.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 70 insertions(+), 1 deletion(-)

diff --git a/test/test/test_bitmap.c b/test/test/test_bitmap.c
index 95c5184..21a193b 100644
--- a/test/test/test_bitmap.c
+++ b/test/test/test_bitmap.c
@@ -11,7 +11,7 @@
 
 #include "test.h"
 
-#define MAX_BITS 1000
+#define MAX_BITS 1024
 
 static int
 test_bitmap_scan_operations(struct rte_bitmap *bmp)
@@ -74,6 +74,72 @@ test_bitmap_scan_operations(struct rte_bitmap *bmp)
 }
 
 static int
+test_bitmap_scan_reverse_operations(struct rte_bitmap *bmp)
+{
+	uint32_t pos = 0;
+	uint64_t slab1_magic = 0xBADC0FFEEBADF00D;
+	uint64_t slab2_magic = 0xFEEDDEADDEADF00D;
+	uint64_t out_slab = 0;
+
+	rte_bitmap_reset(bmp);
+
+	rte_bitmap_set_slab(bmp, MAX_BITS - RTE_BITMAP_SLAB_BIT_SIZE,
+			    slab2_magic);
+	rte_bitmap_set_slab(bmp, MAX_BITS - (2 * RTE_BITMAP_SLAB_BIT_SIZE),
+			    slab1_magic);
+
+	if (!rte_bitmap_scan_generic(bmp, &pos, &out_slab,
+				     RTE_BITMAP_REV_SCAN)) {
+		printf("Failed to get slab from bitmap.\n");
+		return TEST_FAILED;
+	}
+
+	if (slab2_magic != out_slab) {
+		printf("Scan operation sanity failed.\n");
+		return TEST_FAILED;
+	}
+
+	if (!rte_bitmap_scan_generic(bmp, &pos, &out_slab,
+				     RTE_BITMAP_REV_SCAN)) {
+		printf("Failed to get slab from bitmap.\n");
+		return TEST_FAILED;
+	}
+
+	if (slab1_magic != out_slab) {
+		printf("Scan operation sanity failed.\n");
+		return TEST_FAILED;
+	}
+
+	/* Wrap around */
+	if (!rte_bitmap_scan_generic(bmp, &pos, &out_slab,
+				     RTE_BITMAP_REV_SCAN)) {
+		printf("Failed to get slab from bitmap.\n");
+		return TEST_FAILED;
+	}
+
+	if (slab2_magic != out_slab) {
+		printf("Scan operation wrap around failed.\n");
+		return TEST_FAILED;
+	}
+
+	/* Scan reset check. */
+	__rte_bitmap_scan_init_generic(bmp, RTE_BITMAP_REV_SCAN);
+
+	if (!rte_bitmap_scan_generic(bmp, &pos, &out_slab,
+				     RTE_BITMAP_REV_SCAN)) {
+		printf("Failed to get slab from bitmap.\n");
+		return TEST_FAILED;
+	}
+
+	if (slab2_magic != out_slab) {
+		printf("Scan reset operation failed.\n");
+		return TEST_FAILED;
+	}
+
+	return TEST_SUCCESS;
+}
+
+static int
 test_bitmap_slab_set_get(struct rte_bitmap *bmp)
 {
 	uint32_t pos = 0;
@@ -176,6 +242,9 @@ test_bitmap(void)
 	if (test_bitmap_scan_operations(bmp) < 0)
 		return TEST_FAILED;
 
+	if (test_bitmap_scan_reverse_operations(bmp) < 0)
+		return TEST_FAILED;
+
 	rte_bitmap_free(bmp);
 	rte_free(mem);
 
-- 
2.7.4

  parent reply	other threads:[~2018-10-09  7:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-09  7:54 [dpdk-dev] [PATCH 0/2] eal/bitmap: support reverse bitmap scan Vivek Sharma
2018-10-09  7:54 ` [dpdk-dev] [PATCH 1/2] eal/bitmap: support bitmap reverse scanning Vivek Sharma
2018-10-09  7:54 ` Vivek Sharma [this message]
2023-06-12  2:23 ` [dpdk-dev] [PATCH 0/2] eal/bitmap: support reverse bitmap scan Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1539071699-29963-3-git-send-email-vivek.sharma@caviumnetworks.com \
    --to=vivek.sharma@caviumnetworks.com \
    --cc=cristian.dumitrescu@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).