DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] bitmap: add scan init at given position
@ 2023-04-14  8:39 Volodymyr Fialko
  2023-06-01 15:26 ` Thomas Monjalon
  2023-06-13 15:40 ` [PATCH v2] bitmap: add scan from offset function Volodymyr Fialko
  0 siblings, 2 replies; 25+ messages in thread
From: Volodymyr Fialko @ 2023-04-14  8:39 UTC (permalink / raw)
  To: dev, Cristian Dumitrescu; +Cc: jerinj, anoobj, Volodymyr Fialko

Currently, in the case when we search for a bit set after a particular
value, the bitmap has to be scanned from the beginning and
rte_bitmap_scan() has to be called multiple times until we hit the value.

Add a new __rte_bitmap_scan_init_at() function to initialize scan state at
the given position, this will allow getting the next bit set after some
value within one rte_bitmap_scan() call.

Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
---
 app/test/test_bitmap.c       | 23 +++++++++++++++++++++++
 lib/eal/include/rte_bitmap.h | 22 ++++++++++++++++++++++
 2 files changed, 45 insertions(+)

diff --git a/app/test/test_bitmap.c b/app/test/test_bitmap.c
index e9c61590ae..69ff7262f3 100644
--- a/app/test/test_bitmap.c
+++ b/app/test/test_bitmap.c
@@ -71,6 +71,29 @@ test_bitmap_scan_operations(struct rte_bitmap *bmp)
 		return TEST_FAILED;
 	}
 
+	/* Scan reset with count check. */
+	__rte_bitmap_scan_init_at(bmp, pos + RTE_BITMAP_SLAB_BIT_SIZE);
+	if (!rte_bitmap_scan(bmp, &pos, &out_slab)) {
+		printf("Failed to get slab from bitmap.\n");
+		return TEST_FAILED;
+	}
+
+	if (slab2_magic != out_slab) {
+		printf("Scan init at operation failed.\n");
+		return TEST_FAILED;
+	}
+
+	__rte_bitmap_scan_init_at(bmp, pos + 2 * RTE_BITMAP_SLAB_BIT_SIZE);
+	if (!rte_bitmap_scan(bmp, &pos, &out_slab)) {
+		printf("Failed to get slab from bitmap.\n");
+		return TEST_FAILED;
+	}
+
+	if (slab1_magic != out_slab) {
+		printf("Scan init at operation failed.\n");
+		return TEST_FAILED;
+	}
+
 	/* Test scan when a cline is half full */
 	rte_bitmap_reset(bmp);
 	for (i = 0; i < MAX_BITS; i++)
diff --git a/lib/eal/include/rte_bitmap.h b/lib/eal/include/rte_bitmap.h
index 27ee3d18a4..54a986aa8f 100644
--- a/lib/eal/include/rte_bitmap.h
+++ b/lib/eal/include/rte_bitmap.h
@@ -137,6 +137,28 @@ __rte_bitmap_scan_init(struct rte_bitmap *bmp)
 	bmp->go2 = 0;
 }
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
+ * Bitmap initialize internal scan pointers at the given position for the scan function.
+ * @see rte_bitmap_scan()
+ *
+ * @param bmp
+ *   Handle to bitmap instance
+ * @param pos
+ *   Bit position to start scan
+ */
+__rte_experimental
+static inline void
+__rte_bitmap_scan_init_at(struct rte_bitmap *bmp, uint32_t pos)
+{
+	bmp->index1 = pos >> (RTE_BITMAP_SLAB_BIT_SIZE_LOG2 + RTE_BITMAP_CL_BIT_SIZE_LOG2);
+	bmp->offset1 = (pos >> RTE_BITMAP_CL_BIT_SIZE_LOG2) & RTE_BITMAP_SLAB_BIT_MASK;
+	bmp->index2 = pos >> RTE_BITMAP_SLAB_BIT_SIZE_LOG2;
+	bmp->go2 = 1;
+}
+
 /**
  * Bitmap memory footprint calculation
  *
-- 
2.34.1


^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2024-10-10  9:08 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-14  8:39 [PATCH] bitmap: add scan init at given position Volodymyr Fialko
2023-06-01 15:26 ` Thomas Monjalon
2023-06-08 14:20   ` Dumitrescu, Cristian
2023-06-08 14:50     ` Bruce Richardson
2023-06-12 10:58     ` Volodymyr Fialko
2023-06-13 15:40 ` [PATCH v2] bitmap: add scan from offset function Volodymyr Fialko
2023-06-19 11:30   ` Dumitrescu, Cristian
2023-06-21 10:01   ` [PATCH v3] " Volodymyr Fialko
2023-06-21 10:37     ` Dumitrescu, Cristian
2023-06-22 17:44     ` Thomas Monjalon
2023-06-23 12:40       ` Dumitrescu, Cristian
2023-07-03 10:56         ` Volodymyr Fialko
2023-07-03 11:51           ` Thomas Monjalon
2023-07-03 12:02             ` [EXT] " Volodymyr Fialko
2023-07-03 12:17               ` Thomas Monjalon
2023-07-03  9:31     ` [PATCH v4] " Volodymyr Fialko
2023-07-03 10:54       ` Dumitrescu, Cristian
2023-07-03 12:39       ` [PATCH v5] " Volodymyr Fialko
2023-07-03 13:01         ` Dumitrescu, Cristian
2024-07-03 11:27         ` Volodymyr Fialko
2024-07-03 12:50         ` Thomas Monjalon
2024-07-03 13:42           ` Volodymyr Fialko
2024-07-03 15:55             ` Thomas Monjalon
2024-10-04  3:04         ` Stephen Hemminger
2024-10-10  9:08           ` [EXTERNAL] " Volodymyr Fialko

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).