Lines Matching full:bitmap

38 /* Define the size of the bitmap chunk */
48 /* Number of bits per bitmap chunk */
65 static inline bool ice_is_bit_set_internal(u16 nr, const ice_bitmap_t *bitmap)
67 return !!(*bitmap & BIT(nr));
83 static inline void ice_clear_bit_internal(u16 nr, ice_bitmap_t *bitmap)
85 *bitmap &= ~BIT(nr);
88 static inline void ice_set_bit_internal(u16 nr, ice_bitmap_t *bitmap)
90 *bitmap |= BIT(nr);
94 ice_bitmap_t *bitmap)
96 if (ice_is_bit_set_internal(nr, bitmap)) {
97 ice_clear_bit_internal(nr, bitmap);
103 static inline bool ice_test_and_set_bit_internal(u16 nr, ice_bitmap_t *bitmap)
105 if (ice_is_bit_set_internal(nr, bitmap))
108 ice_set_bit_internal(nr, bitmap);
113 * ice_is_bit_set - Check state of a bit in a bitmap
114 * @bitmap: the bitmap to check
117 * Returns true if bit nr of bitmap is set. False otherwise. Assumes that nr
118 * is less than the size of the bitmap.
120 static inline bool ice_is_bit_set(const ice_bitmap_t *bitmap, u16 nr)
123 &bitmap[BIT_CHUNK(nr)]);
127 * ice_clear_bit - Clear a bit in a bitmap
128 * @bitmap: the bitmap to change
131 * Clears the bit nr in bitmap. Assumes that nr is less than the size of the
132 * bitmap.
134 static inline void ice_clear_bit(u16 nr, ice_bitmap_t *bitmap)
136 ice_clear_bit_internal(BIT_IN_CHUNK(nr), &bitmap[BIT_CHUNK(nr)]);
140 * ice_set_bit - Set a bit in a bitmap
141 * @bitmap: the bitmap to change
144 * Sets the bit nr in bitmap. Assumes that nr is less than the size of the
145 * bitmap.
147 static inline void ice_set_bit(u16 nr, ice_bitmap_t *bitmap)
149 ice_set_bit_internal(BIT_IN_CHUNK(nr), &bitmap[BIT_CHUNK(nr)]);
155 * @bitmap: the bitmap to change
157 * Check and clear the bit nr in bitmap. Assumes that nr is less than the size
158 * of the bitmap.
161 ice_test_and_clear_bit(u16 nr, ice_bitmap_t *bitmap)
164 &bitmap[BIT_CHUNK(nr)]);
170 * @bitmap: the bitmap to change
172 * Check and set the bit nr in bitmap. Assumes that nr is less than the size of
173 * the bitmap.
176 ice_test_and_set_bit(u16 nr, ice_bitmap_t *bitmap)
179 &bitmap[BIT_CHUNK(nr)]);
182 /* ice_zero_bitmap - set bits of bitmap to zero.
183 * @bmp: bitmap to set zeros
186 * Set all of the bits in a bitmap to zero. Note that this function assumes it
198 * ice_and_bitmap - bitwise AND 2 bitmaps and store result in dst bitmap
199 * @dst: Destination bitmap that receive the result of the operation
200 * @bmp1: The first bitmap to intersect
201 * @bmp2: The second bitmap to intersect wit the first
205 * and stores the result to "dst" bitmap. The "dst" bitmap must be of the same
223 /* We want to take care not to modify any bits outside of the bitmap
224 * size, even in the destination bitmap. Thus, we won't directly
225 * assign the last bitmap, but instead use a bitmask to ensure we only
237 * ice_or_bitmap - bitwise OR 2 bitmaps and store result in dst bitmap
238 * @dst: Destination bitmap that receive the result of the operation
239 * @bmp1: The first bitmap to intersect
240 * @bmp2: The second bitmap to intersect wit the first
244 * and stores the result to "dst" bitmap. The "dst" bitmap must be of the same
268 * ice_xor_bitmap - bitwise XOR 2 bitmaps and store result in dst bitmap
269 * @dst: Destination bitmap that receive the result of the operation
270 * @bmp1: The first bitmap of XOR operation
271 * @bmp2: The second bitmap to XOR with the first
275 * and stores the result to "dst" bitmap. The "dst" bitmap must be of the same
299 * ice_andnot_bitmap - bitwise ANDNOT 2 bitmaps and result in dst bitmap
300 * @dst: Destination bitmap that receive the result of the operation
301 * @bmp1: The first bitmap of ANDNOT operation
302 * @bmp2: The second bitmap to ANDNOT operation
306 * size, and stores the result to "dst" bitmap. The "dst" bitmap must be of the
330 * ice_find_next_bit - Find the index of the next set bit of a bitmap
331 * @bitmap: the bitmap to scan
332 * @size: the size in bits of the bitmap
335 * Scans the bitmap and returns the index of the first set bit which is equal
339 ice_find_next_bit(const ice_bitmap_t *bitmap, u16 size, u16 offset)
350 if (bitmap[i] != 0) {
354 if (ice_is_bit_set(bitmap, off + j))
361 if (bitmap[i] != 0) {
365 if (ice_is_bit_set(bitmap, off + j))
374 * ice_find_first_bit - Find the index of the first set bit of a bitmap
375 * @bitmap: the bitmap to scan
376 * @size: the size in bits of the bitmap
378 * Scans the bitmap and returns the index of the first set bit. Will return
381 static inline u16 ice_find_first_bit(const ice_bitmap_t *bitmap, u16 size)
383 return ice_find_next_bit(bitmap, size, 0);
392 * ice_is_any_bit_set - Return true of any bit in the bitmap is set
393 * @bitmap: the bitmap to check
394 * @size: the size of the bitmap
397 * bitmap size.
399 static inline bool ice_is_any_bit_set(ice_bitmap_t *bitmap, u16 size)
401 return ice_find_first_bit(bitmap, size) < size;
406 * @dst: bitmap destination
407 * @src: bitmap to copy from
410 * This function copy bitmap from src to dst. Note that this function assumes
411 * it is operating on a bitmap declared using ice_declare_bitmap. It will copy
421 * ice_bitmap_set - set a number of bits in bitmap from a starting position
422 * @dst: bitmap destination
426 * This function sets bits in a bitmap from pos to (pos + num_bits) - 1.
427 * Note that this function assumes it is operating on a bitmap declared using
440 * ice_bitmap_hweight - hamming weight of bitmap
441 * @bm: bitmap pointer
442 * @size: size of bitmap (in bits)
444 * This function determines the number of set bits in a bitmap.
445 * Note that this function assumes it is operating on a bitmap declared using
464 * @bmp1: the bitmap to compare
465 * @bmp2: the bitmap to compare with bmp1
490 * ice_bitmap_from_array32 - copies u32 array source into bitmap destination
491 * @dst: the destination bitmap
493 * @size: size of the bitmap (in bits)
495 * This function copies the src bitmap stored in an u32 array into the dst
496 * bitmap stored as an ice_bitmap_t.
504 /* clear bitmap so we only have to set when iterating */