03/07/2023 14:39, 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_from_offset() function to initialize scan
> state at the given offset and perform scan, this will allow getting
> the next set bit after certain offset within one scan call.
> 
> Signed-off-by: Volodymyr Fialko <vfia...@marvell.com>
> ---
> v2:
>  - added rte_bitmap_scan_from_offset
> v3:
>  - added note for internal use only for init_at function
> v4:
>  - marked init_at function as __rte_internal
> v5:
>  - removed __rte_internal due to build errors

What was the build error?

You should not add an internal function in the public header file.
At least, it should be experimental.


> --- a/lib/eal/include/rte_bitmap.h
> +++ b/lib/eal/include/rte_bitmap.h
> +/**
> + * Bitmap initialize internal scan pointers at the given position for the 
> scan function.
> + *
> + * Note: for private/internal use, for public:
> + * @see rte_bitmap_scan_from_offset()
> + *
> + * @param bmp
> + *   Handle to bitmap instance
> + * @param pos
> + *   Bit position to start scan
> + */
> +static inline void
> +__rte_bitmap_scan_init_at(struct rte_bitmap *bmp, uint32_t pos)
> +{
> +     uint64_t *slab1;
> +
> +     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;
> +     slab1 = bmp->array1 + bmp->index1;
> +     bmp->go2 = *slab1 & (1llu << bmp->offset1);
> +}



Reply via email to