The branch main has been updated by dougm:

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

commit b70247df0ba43a97fb4b06bbc85163a3ecaf08a5
Author:     Doug Moore <do...@freebsd.org>
AuthorDate: 2024-08-12 21:04:32 +0000
Commit:     Doug Moore <do...@freebsd.org>
CommitDate: 2024-08-12 21:04:32 +0000

    axgbe: use bit_foreach
    
    bitstring.h includes a definition of bit_foreach, for iterating over
    the set bits of a bitstring. axgbe implements its own version of this
    for bitstrings. Drop it, and use the bitstring method.
    
    Reviewed by:    des
    Differential Revision:  https://reviews.freebsd.org/D46037
---
 sys/dev/axgbe/xgbe-dev.c   |  7 +++--
 sys/dev/axgbe/xgbe_osdep.h | 66 ----------------------------------------------
 2 files changed, 3 insertions(+), 70 deletions(-)

diff --git a/sys/dev/axgbe/xgbe-dev.c b/sys/dev/axgbe/xgbe-dev.c
index 39d0dab144a2..3a7d683ea5a9 100644
--- a/sys/dev/axgbe/xgbe-dev.c
+++ b/sys/dev/axgbe/xgbe-dev.c
@@ -826,7 +826,7 @@ static int
 xgbe_update_vlan_hash_table(struct xgbe_prv_data *pdata)
 {
        uint32_t crc;
-       uint16_t vid;
+       size_t vid;
        uint16_t vlan_hash_table = 0;
        __le16 vid_le = 0;
 
@@ -834,14 +834,13 @@ xgbe_update_vlan_hash_table(struct xgbe_prv_data *pdata)
            XGMAC_IOREAD(pdata, MAC_VLANHTR));
  
        /* Generate the VLAN Hash Table value */
-       for_each_set_bit(vid, pdata->active_vlans, VLAN_NVID) {
-
+       bit_foreach(pdata->active_vlans, VLAN_NVID, vid) {
                /* Get the CRC32 value of the VLAN ID */
                vid_le = cpu_to_le16(vid);
                crc = bitrev32(~xgbe_vid_crc32_le(vid_le)) >> 28;
 
                vlan_hash_table |= (1 << crc);
-               axgbe_printf(1, "%s: vid 0x%x vid_le 0x%x crc 0x%x "
+               axgbe_printf(1, "%s: vid 0x%lx vid_le 0x%x crc 0x%x "
                    "vlan_hash_table 0x%x\n", __func__, vid, vid_le, crc,
                    vlan_hash_table);
        }
diff --git a/sys/dev/axgbe/xgbe_osdep.h b/sys/dev/axgbe/xgbe_osdep.h
index 1f0359657dcd..40c1607b20e3 100644
--- a/sys/dev/axgbe/xgbe_osdep.h
+++ b/sys/dev/axgbe/xgbe_osdep.h
@@ -56,11 +56,6 @@ typedef uint32_t __le32;
 #define        le32_to_cpu(x)          htole32(x)
 #define cpu_to_le16(x)         htole16(x)
 
-#define for_each_set_bit(bit, addr, size) \
-       for ((bit) = find_first_bit((addr), (size));            \
-            (bit) < (size);                                    \
-            (bit) = find_next_bit((addr), (size), (bit) + 1))
-
 typedef struct mtx spinlock_t;
 
 static inline void
@@ -241,65 +236,4 @@ get_bitmask_order(unsigned int count)
        return (order); /* We could be slightly more clever with -1 here... */
 }
 
-static inline unsigned long
-find_next_bit(const unsigned long *addr, unsigned long size, unsigned long 
offset)
-{
-       long mask;
-       int offs;
-       int bit;
-       int pos;
-
-       if (offset >= size)
-               return (size);
-       pos = offset / BITS_PER_LONG;
-       offs = offset % BITS_PER_LONG;
-       bit = BITS_PER_LONG * pos;
-       addr += pos;
-       if (offs) {
-               mask = (*addr) & ~BITMAP_LAST_WORD_MASK(offs);
-               if (mask)
-                       return (bit + __ffsl(mask));
-               if (size - bit <= BITS_PER_LONG)
-                       return (size);
-               bit += BITS_PER_LONG;
-               addr++;
-       }
-       for (size -= bit; size >= BITS_PER_LONG;
-           size -= BITS_PER_LONG, bit += BITS_PER_LONG, addr++) {
-               if (*addr == 0)
-                       continue;
-               return (bit + __ffsl(*addr));
-       }
-       if (size) {
-               mask = (*addr) & BITMAP_LAST_WORD_MASK(size);
-               if (mask)
-                       bit += __ffsl(mask);
-               else
-                       bit += size;
-       }
-       return (bit);
-}
-
-static inline unsigned long
-find_first_bit(const unsigned long *addr, unsigned long size)
-{
-        long mask;
-        int bit;
-
-        for (bit = 0; size >= BITS_PER_LONG;
-            size -= BITS_PER_LONG, bit += BITS_PER_LONG, addr++) {
-                if (*addr == 0)
-                        continue;
-                return (bit + __ffsl(*addr));
-        }
-        if (size) {
-                mask = (*addr) & BITMAP_LAST_WORD_MASK(size);
-                if (mask)
-                        bit += __ffsl(mask);
-                else
-                        bit += size;
-        }
-        return (bit);
-}
-
 #endif /* _XGBE_OSDEP_H_ */

Reply via email to