net/bnxt: truflow enhance bitalloc utility
PATCH 1/1 net/bnxt: truflow enhance bitalloc utility
From: Joey Zhong <[email protected]>
Add ba_find_prev_inuse() and ba_find_prev_inuse_free(), the backward-searching counterparts of the existing ba_find_next_inuse() and ba_find_next_inuse_free(). The new helpers walk the multi-level bitalloc tree from a given index down towards index 0, using ba_fls() to locate the highest in-use bit at or below the starting position, mirroring the forward-search helpers which use ba_ffs() to locate the lowest in-use bit at or above the starting position.
Signed-off-by Joey Zhong <[email protected]>
Signed-off-by Manish Kurup <[email protected]>
--- .mailmap | 1 + drivers/net/bnxt/tf_core/bitalloc.c | 81 +++++++++++++++++++++++++++++ drivers/net/bnxt/tf_core/bitalloc.h | 14 +++++ 3 files changed, 96 insertions(+)
.mailmap +1 -0
@@ -785,6 +785,7 @@ Job Abraham <[email protected]> Jochen Behrens <[email protected]> <[email protected]> Joel Kavanagh <[email protected]> Joey Xing <[email protected]> +Joey Zhong <[email protected]> Johan Faltstrom <[email protected]> Johan Källström <[email protected]> Johan Samuelsson <[email protected]>
drivers/net/bnxt/tf_core/bitalloc.c +81 -0
84 lines not on this page · raw message
drivers/net/bnxt/tf_core/bitalloc.h +14 -0
@@ -106,6 +106,20 @@ int ba_find_next_inuse(struct bitalloc *pool, int idx);*/ int ba_find_next_inuse_free (struct bitalloc *pool,int idx); +/** +* Find prev index that is in use, start checking at index 'idx' +* +* Returns prev index that is in use on success, or +* -1 if no in use index is found +*/ +int ba_find_prev_inuse (struct bitalloc *pool,int idx); + +/** +* Variant of ba_find_prev_inuse that also frees the prev in use index, +* same return codes as ba_find_prev_inuse +*/ +int ba_find_prev_inuse_free (struct bitalloc *pool,int idx); +/** * Multiple freeing of the same index has no negative side effects, * but will return -1. returns -1 on failure, 0 on success.
Signature · 1 line
2.31.1