From nobody Mon Aug 12 21:05:59 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WjRrR3HCdz5T9Hh; Mon, 12 Aug 2024 21:05:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WjRrR2Sxrz4Txf; Mon, 12 Aug 2024 21:05:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1723496759; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Zzy7aJ+bjR9GL/sXGbtcaJkOu0ne6S29NmAskV61KJA=; b=jVSk8dLap+PhrxC1hfE4DiZsa2YJ6xwhbXwBXi8RHGyVwBkHikOt6YBPnU6X/4TjH42wlx Bb2wyRplISgJSGD1Lbf+qRqglw7b7KwpmbHWpTK+Bx68vzwCMGppktB1+xt9blnSFf+09Z tEJPBJdqVIBM+qtOKK+15GsrKbSFETYLRtjgDYrygNvgpbYjfC4YTm+3xqe6kkimoAZSAp KNxs/U/oKE0oLET0wF/MkkGsTcot/AYluyEX1wl1aHLkOSuB6OowkRS7aDndBFNMdTqGbQ R3KtH092IkFZ2W/NqGPNyYsHQzl8FkGYagFR+WfuplebDwMFEkFouCEqqeNDQA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1723496759; a=rsa-sha256; cv=none; b=LkKtxjB9wvDW39oARvky+2crGSh3R0FOgg91HJwjeSHpVbxuqsS8n16WRobajF9RSn1ipS tEt/+ES8+CwsbIbF/sWgm3qrFSDnBsLxVly7BouDhdvFXofvr5hv8AKEDUPJv1RMAx1ng+ 9V9VAeRMUr7cju83FEaLCq7t+fWFa6CE3YAjkafupluACVr7UcMZectqda0SRlleVA6Ar3 bRVo7U/nx9Rf2B93Hdt3o7QJhUjjqnFI2Nvgi68/KxvGnmZOY9F0x600GkzHp3llsUlcHq giOs68pyBWq7v/Bhw8ZMV17afrjDq4GQrgL6cYLgrPrnpnojmGUfXBiKh3Nu1g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1723496759; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Zzy7aJ+bjR9GL/sXGbtcaJkOu0ne6S29NmAskV61KJA=; b=bkeM/ExfilGt0xXNzfTQufF0TEv3W/NFGPBUyNUO1nv1DsRi9mMIfpfeGXisNpu1PmBUUM XM9AZrSIoxndbbodEFeUz0JkNQbDkJIQhnDCLpVi3rfVqpPmK9nYVj+J7sBbU8S9zgokXa subiNyohaAeV/k+ddR2n17qenmEuLdKCxmJPQqH4drXIjGyBSE2cnObU9fIK4VbpQmSbg3 NxgyqtRKZYDOLKVSpTN27b7yMc6HISgAwbnlNclaQwdTdB997QI9DSc+dWyF2lmZJgfmkw XBBbCJirSu447Ra5yUTckZnY7EqpV21jVzSfSxI+4ecscbEBYCmq3s7EJWDhEw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4WjRrR1yRVzk2j; Mon, 12 Aug 2024 21:05:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 47CL5xLC069621; Mon, 12 Aug 2024 21:05:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47CL5xGF069618; Mon, 12 Aug 2024 21:05:59 GMT (envelope-from git) Date: Mon, 12 Aug 2024 21:05:59 GMT Message-Id: <202408122105.47CL5xGF069618@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Doug Moore Subject: git: b70247df0ba4 - main - axgbe: use bit_foreach List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dougm X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b70247df0ba43a97fb4b06bbc85163a3ecaf08a5 Auto-Submitted: auto-generated The branch main has been updated by dougm: URL: https://cgit.FreeBSD.org/src/commit/?id=b70247df0ba43a97fb4b06bbc85163a3ecaf08a5 commit b70247df0ba43a97fb4b06bbc85163a3ecaf08a5 Author: Doug Moore AuthorDate: 2024-08-12 21:04:32 +0000 Commit: Doug Moore 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_ */