]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
i40e: drop useless bitmap_weight() call in i40e_set_rxfh_fields()
authorYury Norov (NVIDIA) <yury.norov@gmail.com>
Thu, 18 Dec 2025 01:57:57 +0000 (20:57 -0500)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Tue, 3 Mar 2026 16:56:05 +0000 (08:56 -0800)
bitmap_weight() is O(N) and useless here, because the following
for_each_set_bit() returns immediately in case of empty flow_pctypes.

Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Tested-by: Rinitha S <sx.rinitha@intel.com> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/i40e/i40e_ethtool.c

index 8c27f7ba4adc57f792afacb98e4adb01791937b1..3da9ec49cc7457281a006d2def9166f8ff4b5aef 100644 (file)
@@ -3624,6 +3624,7 @@ static int i40e_set_rxfh_fields(struct net_device *netdev,
                   ((u64)i40e_read_rx_ctl(hw, I40E_PFQF_HENA(1)) << 32);
        DECLARE_BITMAP(flow_pctypes, FLOW_PCTYPES_SIZE);
        u64 i_set, i_setc;
+       u8 flow_id;
 
        bitmap_zero(flow_pctypes, FLOW_PCTYPES_SIZE);
 
@@ -3707,20 +3708,14 @@ static int i40e_set_rxfh_fields(struct net_device *netdev,
                return -EINVAL;
        }
 
-       if (bitmap_weight(flow_pctypes, FLOW_PCTYPES_SIZE)) {
-               u8 flow_id;
+       for_each_set_bit(flow_id, flow_pctypes, FLOW_PCTYPES_SIZE) {
+               i_setc = (u64)i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(0, flow_id)) |
+                        ((u64)i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(1, flow_id)) << 32);
+               i_set = i40e_get_rss_hash_bits(&pf->hw, nfc, i_setc);
 
-               for_each_set_bit(flow_id, flow_pctypes, FLOW_PCTYPES_SIZE) {
-                       i_setc = (u64)i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(0, flow_id)) |
-                                ((u64)i40e_read_rx_ctl(hw, I40E_GLQF_HASH_INSET(1, flow_id)) << 32);
-                       i_set = i40e_get_rss_hash_bits(&pf->hw, nfc, i_setc);
-
-                       i40e_write_rx_ctl(hw, I40E_GLQF_HASH_INSET(0, flow_id),
-                                         (u32)i_set);
-                       i40e_write_rx_ctl(hw, I40E_GLQF_HASH_INSET(1, flow_id),
-                                         (u32)(i_set >> 32));
-                       hena |= BIT_ULL(flow_id);
-               }
+               i40e_write_rx_ctl(hw, I40E_GLQF_HASH_INSET(0, flow_id), (u32)i_set);
+               i40e_write_rx_ctl(hw, I40E_GLQF_HASH_INSET(1, flow_id), (u32)(i_set >> 32));
+               hena |= BIT_ULL(flow_id);
        }
 
        i40e_write_rx_ctl(hw, I40E_PFQF_HENA(0), (u32)hena);