From 6e119eddd0fafc1df4474ca9c56ed07a30bb257d Mon Sep 17 00:00:00 2001 From: Guiding Li Date: Thu, 12 Oct 2023 17:22:44 +0800 Subject: [PATCH] libmetal: set ept address loop++ in bitmap CPU0 CPU1 create_ept1:addr1 create_ept1 OK <====== msg1 OK <====== msg2 OK <====== msg3 msg4 <====== msg4 on the virtioqueue close_ept1 close_ept1 create_ept2:addr1 create_ept1 (same addr with ept1) msg4 ept2 recv ept1 msg ERROR <====== Signed-off-by: Guiding Li --- lib/utilities.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/utilities.h b/lib/utilities.h index 6b592e01..74a90148 100644 --- a/lib/utilities.h +++ b/lib/utilities.h @@ -140,6 +140,19 @@ metal_bitmap_next_clear_bit(unsigned long *bitmap, unsigned int start, return bit; } +static inline unsigned int +metal_bitmap_loopnext_clear_bit(unsigned long *bitmap, unsigned int start, + unsigned int max) +{ + unsigned int bit; + + for (bit = start; + bit < max + start && !metal_bitmap_is_bit_clear(bitmap, bit % max); + bit++) + ; + return bit % max; +} + #define metal_bitmap_for_each_clear_bit(bitmap, bit, max) \ for ((bit) = metal_bitmap_next_clear_bit((bitmap), 0, (max)); \ (bit) < (max); \