git: d79312b82ef2 - stable/15 - if_bnxt: add bitmap search/test-and-set helpers

From: Kevin Bowling <kbowling_at_FreeBSD.org>
Date: Thu, 29 Oct 2026 23:37:28 UTC
The branch stable/15 has been updated by kbowling:

URL: https://cgit.FreeBSD.org/src/commit/?id=d79312b82ef20c5769ccede55ffe0a409c35a09c

commit d79312b82ef20c5769ccede55ffe0a409c35a09c
Author:     Sumit Saxena <sumit.saxena@broadcom.com>
AuthorDate: 2026-07-29 12:14:27 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2026-10-29 23:25:50 +0000

    if_bnxt: add bitmap search/test-and-set helpers
    
    Add bitmap search/test-and-set helpers the kTLS
    key-context ID allocator needs; bitstring.h has no equivalent
    primitives.
    
    Reviewed by:    gallatin
    Sponsored by:   Broadcom Inc.
    Differential Revision:  https://reviews.freebsd.org/D58605
    
    (cherry picked from commit aef2db6fac2329bfd553f8db9c87b34dccdb33ac)
---
 sys/dev/bnxt/bnxt_en/bnxt.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/sys/dev/bnxt/bnxt_en/bnxt.h b/sys/dev/bnxt/bnxt_en/bnxt.h
index 3d0d63eb2244..baaf6f8209b2 100644
--- a/sys/dev/bnxt/bnxt_en/bnxt.h
+++ b/sys/dev/bnxt/bnxt_en/bnxt.h
@@ -1590,4 +1590,24 @@ writel_fbsd(struct bnxt_softc *bp, u32 reg_off, u8 bar_idx, u32 val)
 		panic("%s: invalid bar_idx %u", __func__, bar_idx);
 	}
 }
+
+/* Non-atomic test-and-set; caller must hold the lock serializing bmap.
+ * bitstring.h has no equivalent primitive. */
+static inline int
+bnxt_test_and_set_bit_nonatomic(int nr, bitstr_t *bmap)
+{
+	if (bit_test(bmap, nr))
+		return (1);
+	bit_set(bmap, nr);
+	return (0);
+}
+
+static inline int
+bnxt_test_and_clear_bit_nonatomic(int nr, bitstr_t *bmap)
+{
+	if (!bit_test(bmap, nr))
+		return (0);
+	bit_clear(bmap, nr);
+	return (1);
+}
 #endif /* _BNXT_H */