From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9593BD66B87 for ; Thu, 18 Dec 2025 01:58:04 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 316E640A3C; Thu, 18 Dec 2025 01:58:04 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id cVH5f2LnK-fy; Thu, 18 Dec 2025 01:58:03 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 5F22440F75 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1766023083; bh=bQOfmftLH8KAfTXHZBw4TB9dKu3rPCHujQ+Dm7h606A=; h=From:To:Cc:Date:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=NgL9lUxPAMStrgd0tvm/1FlZfHh2ZLZMS4UQ2kPGcKX2E6o+HH0ujQOpaZT/Tkneb ZfovDTsFfJSeAZgPbfmKBis4A5BhSdIMjifIwL67chzQQwAD9R4BBiQ9q+Bs7t9sZ/ bV3gcPCVOfqLuFj9Gm8AIhkZA1CyiF6WeHE2cLKWuw5AR41TFKyVjtxGxOVLbHXEkI P0UX0bDMxITTStIsKC6jCVDLQiD4uAL5fq6M4pAKZf6+NuGIRsniyIi00VxqsGfTZZ pqzN3B0C3lcBRzuFeEa4FkdW7kr9ZOb8TY2c02tesc6fHVNn01KllQ7bS0waFT0ivi Z8W7HDOJKLCpg== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp4.osuosl.org (Postfix) with ESMTP id 5F22440F75; Thu, 18 Dec 2025 01:58:03 +0000 (UTC) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists1.osuosl.org (Postfix) with ESMTP id 76D582A2 for ; Thu, 18 Dec 2025 01:58:02 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 68A7B8248C for ; Thu, 18 Dec 2025 01:58:02 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id gcVQ6pNhgQn5 for ; Thu, 18 Dec 2025 01:58:01 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2607:f8b0:4864:20::b130; helo=mail-yx1-xb130.google.com; envelope-from=yury.norov@gmail.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp1.osuosl.org 7EFD582423 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 7EFD582423 Received: from mail-yx1-xb130.google.com (mail-yx1-xb130.google.com [IPv6:2607:f8b0:4864:20::b130]) by smtp1.osuosl.org (Postfix) with ESMTPS id 7EFD582423 for ; Thu, 18 Dec 2025 01:58:01 +0000 (UTC) Received: by mail-yx1-xb130.google.com with SMTP id 956f58d0204a3-6447743ce59so113778d50.0 for ; Wed, 17 Dec 2025 17:58:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766023080; x=1766627880; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=bQOfmftLH8K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9M7VYDo= X-Google-Smtp-Source: AGHT+IF7Lkwj0sSdZaNQ3dsB15WX1orUqF+lFaxr1wSODVAJtotITBD0kMje1L4hZ+gr1DxEnLMwlw== X-Received: by 2002:a05:690e:1407:b0:644:60d9:865a with SMTP id 956f58d0204a3-6455567d629mr14606696d50.93.1766023080117; Wed, 17 Dec 2025 17:58:00 -0800 (PST) Received: from localhost ([2601:346:0:79bd:52c0:aec0:bf15:a891]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-646636e86ccsm472527d50.5.2025.12.17.17.57.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Dec 2025 17:57:59 -0800 (PST) From: "Yury Norov (NVIDIA)" To: Tony Nguyen , Przemek Kitszel , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "Yury Norov (NVIDIA)" , "Loktionov, Aleksandr" Date: Wed, 17 Dec 2025 20:57:57 -0500 Message-ID: <20251218015758.682498-1-yury.norov@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766023080; x=1766627880; darn=lists.osuosl.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=bQOfmftLH8KAfTXHZBw4TB9dKu3rPCHujQ+Dm7h606A=; b=Z7YHdnpELUCpdwpTVWtLTICV6VtpvebCXRkg5Fopr1X1fy+Mxc/qeIc15KNY8IA7V0 RxI/TcXdPTr+r15ynPu0xcJiqJdwCwGdg/jwQ/7ZPrNmQQtmUt/Ka38CbTLK7vpW/IBM AXmdHb46RJjaxxcZ1YG5QnZ7vUtDASa+fnhA0unqvYw8+cByhAY5I/ozIsweb+Xk/rB2 eB2e5zQ5uKtIQ7eR4Yvz6ISN43RH0ZregZunVJM1q/tgJjtyH4DBabMk0cb84d6k1YTu rGBvP0RTBZNEnQmcr+CEsuu6Xx0lTILOIvNd+QTK9Su4ARDigu7ZMw5x60i5r+f9GzIq WsIw== X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; dmarc=pass (p=none dis=none) header.from=gmail.com X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Z7YHdnpE Subject: [Intel-wired-lan] [PATCH v2] i40e: drop useless bitmap_weight() call in i40e_set_rxfh_fields() X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" 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) --- v1: https://lore.kernel.org/all/20251216002852.334561-1-yury.norov@gmail.com/ v2: don't drop flow_id (Aleksandr). .../net/ethernet/intel/i40e/i40e_ethtool.c | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c index f2c2646ea298..e64880b6b047 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c +++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c @@ -3637,6 +3637,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); @@ -3720,20 +3721,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); -- 2.43.0