From patchwork Thu Feb 10 22:48:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12742552 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01160C433F5 for ; Thu, 10 Feb 2022 22:54:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345302AbiBJWyD (ORCPT ); Thu, 10 Feb 2022 17:54:03 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:42640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238083AbiBJWyB (ORCPT ); Thu, 10 Feb 2022 17:54:01 -0500 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AD0F55A4; Thu, 10 Feb 2022 14:54:02 -0800 (PST) Received: by mail-io1-xd2d.google.com with SMTP id h7so9358264iof.3; Thu, 10 Feb 2022 14:54:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=VUKtrHLt0fjPmTgGEZzFREYA4A6F0kdoS7SyUvKa0qA=; b=O4LOqpJXDQnBxYPr0uj95YnMfkewxiGbbQ/CJY8h9XDEPOvDjwh5qXW6DLwNj/4efC P5rQp/xAmEmeII8/061Ts7JTt7EVmLB+11xoYOuxl7Aj0qEYkDOLJXycZvl5sufYs5DF 4vgFdiDGtrUyNKnS0E80RAJT2kAGsFDMrBOB59uXItyZqs3bPTBgtjGn6yYWYd71QIEW 8KOtB1BJ6WgWf06cjSV8ERv8TMMgsw5f8McINFBn9SGaJ/oPcElXl8/Qyis/NPO2ABMh WOFjIQmst1HJnqh3/u46Cy212ZQva5eXTTBHPDZw+ohS/wXIhQ4nIa2v1/cyXJNuAQAX FndA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VUKtrHLt0fjPmTgGEZzFREYA4A6F0kdoS7SyUvKa0qA=; b=ChNSB6q5ku8zlDdlNMr7s6ZV4KdXrcvnRGXcNXTUii0pJwXgivl1Ag29XMp9HHeYQn teG2SSycs0FxW6k+SJZvPBwY0YOnT33z6or8FFwz+l+Fl9A7vdiTIjAd67bBxJBxzzOF D1g5u65zm4HSUw7PolBbfrja/d6FPUjxfLN6A8tmZOGcSzRBLYl2xIPlyijjeNf3+MfH wazvh9dMghQFf9xfgBJLW+5hbqVFGtLqog9IqCCt9jbv94fQRZGnWVAwKLWhX1pQkaOc uNBHynbqVVnoLIoCbOaaJ5JOOpy66LRYwYpf4hiORQtMuvwWSz3wr6X4ivc2bEqSusHP jA+g== X-Gm-Message-State: AOAM530oEcxM0DdC/p7UYeWBrAYcCcFWtZliBpATdg8cqsPBWLHXQqrg i2GqOUZX8dmSWqOY1ENYTh4= X-Google-Smtp-Source: ABdhPJzaRpwSbO6X1WBTl+WfBx/q4TwWiCIEqIJ9Q6DkzZZR70REkK2F4cQiJwbzEUceoLbWMe36Mg== X-Received: by 2002:a02:cd0a:: with SMTP id g10mr5229490jaq.223.1644533641691; Thu, 10 Feb 2022 14:54:01 -0800 (PST) Received: from localhost ([12.28.44.171]) by smtp.gmail.com with ESMTPSA id a15sm6591675ilq.24.2022.02.10.14.54.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 14:54:01 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?utf-8?b?TWljaGHFgiBNaXJvc8WC?= =?utf-8?b?YXc=?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Florian Fainelli , Andrew Lunn , Vivien Didelot , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Subject: [PATCH 01/49] net: dsa: don't use bitmap_weight() in b53_arl_read() Date: Thu, 10 Feb 2022 14:48:45 -0800 Message-Id: <20220210224933.379149-2-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220210224933.379149-1-yury.norov@gmail.com> References: <20220210224933.379149-1-yury.norov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Don't call bitmap_weight() if the following code can get by without it. Signed-off-by: Yury Norov Acked-by: Florian Fainelli --- drivers/net/dsa/b53/b53_common.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c index a3b98992f180..d99813bf3cdd 100644 --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c @@ -1620,12 +1620,8 @@ static int b53_arl_read(struct b53_device *dev, u64 mac, return 0; } - if (bitmap_weight(free_bins, dev->num_arl_bins) == 0) - return -ENOSPC; - *idx = find_first_bit(free_bins, dev->num_arl_bins); - - return -ENOENT; + return *idx >= dev->num_arl_bins ? -ENOSPC : -ENOENT; } static int b53_arl_op(struct b53_device *dev, int op, int port, From patchwork Thu Feb 10 22:48:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12742553 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE0F4C433F5 for ; Thu, 10 Feb 2022 22:56:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345338AbiBJW4Q (ORCPT ); Thu, 10 Feb 2022 17:56:16 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:44046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344698AbiBJW4P (ORCPT ); Thu, 10 Feb 2022 17:56:15 -0500 Received: from mail-qv1-xf31.google.com (mail-qv1-xf31.google.com [IPv6:2607:f8b0:4864:20::f31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D213A55A4; Thu, 10 Feb 2022 14:56:15 -0800 (PST) Received: by mail-qv1-xf31.google.com with SMTP id a28so6647069qvb.10; Thu, 10 Feb 2022 14:56:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=U+3vkzFEGdGmmOjt1hV/DkqJX2a2lDje4tkvz+fEZaQ=; b=MFInfE/srC1pPDAgWjrnrRsQPNZIeBeOJeGNEpcwJWUHy5BMVWL1fOMhBwZlPtHJ7U 5+f1DO4pOifTAEDBOPhFoA/C+0OyKnEvmniHExfoa6cTBor9+2wvjUlLQzfxqeEybm6x qfWlqqfDBqMeSdLtUXEtDSRryd+N7lu01bXnLYqvyo4/FLvUFyU4wZhtVt6jvLtVSECd cOuSyWxl738PHxvFhnUvNoeVKQigAJ6KajAfW0lsUfEAMrvkcq+FyMbshLeXQjStCI0k b6MEWuwYm17L7/+dtp8iAPjFhhLX/TUU5rfVoBX6mQtu/ioNLZ9o8CSaMO4yQWr5+vEO SLPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=U+3vkzFEGdGmmOjt1hV/DkqJX2a2lDje4tkvz+fEZaQ=; b=Jij3xI+ZDRGhCfg92+HwenrtsDp8cz0RK+VUAyv6qf6609SToArghho8x0sizok/hi j404Z9aBc/thtlUg8Lkfxk67SVdeH33PnTTGA0908QTNTe0/YD2mR8NK8tYBHDESMpgf 6/2eTwb/BQq7ZPpiX47I3V0gZEAGKbenDXLRUTJD1/2sfKKdc3igknFedJRbzDPwD/P+ ZrFM+KM8QH2xzOIkN/ySfTGJ+vcRbrC9/w3mRUvxGPm6xR+YT7THNCFLM3vEgUO4TAQr 17+HvrO4E36IUrRuRvhRliZn0hR7mS7WjWAOdXYu8bQqlEFjbN1otsUYukp6kmv5PX6J 9tJA== X-Gm-Message-State: AOAM530AVFC6wCWZ0bXL5zqjOdP8QaPnmzsG9edPF4Xdc17gv/fH1fd6 g0YP8GOdRykwNegTR40ORao= X-Google-Smtp-Source: ABdhPJwtwRaFQJWdH3kBC2E+PysWAfr7+FtW7sdEitaMsJ++lw+fh4m6p8FaQrmqF1WnluhFWEb7Zw== X-Received: by 2002:a05:6214:401c:: with SMTP id kd28mr2551247qvb.111.1644533774923; Thu, 10 Feb 2022 14:56:14 -0800 (PST) Received: from localhost ([12.28.44.171]) by smtp.gmail.com with ESMTPSA id g17sm9045729qkl.122.2022.02.10.14.56.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 14:56:14 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?utf-8?b?TWljaGHFgiBNaXJvc8WC?= =?utf-8?b?YXc=?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Florian Fainelli , "David S . Miller " , Jakub Kicinski , bcm-kernel-feedback-list@broadcom.com, netdev@vger.kernel.org Subject: [PATCH 02/49] net: systemport: don't use bitmap_weight() in bcm_sysport_rule_set() Date: Thu, 10 Feb 2022 14:48:46 -0800 Message-Id: <20220210224933.379149-3-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220210224933.379149-1-yury.norov@gmail.com> References: <20220210224933.379149-1-yury.norov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Don't call bitmap_weight() if the following code can get by without it. Signed-off-by: Yury Norov Acked-by: Florian Fainelli --- drivers/net/ethernet/broadcom/bcmsysport.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c index 60dde29974bf..5284a5c961db 100644 --- a/drivers/net/ethernet/broadcom/bcmsysport.c +++ b/drivers/net/ethernet/broadcom/bcmsysport.c @@ -2180,13 +2180,9 @@ static int bcm_sysport_rule_set(struct bcm_sysport_priv *priv, if (nfc->fs.ring_cookie != RX_CLS_FLOW_WAKE) return -EOPNOTSUPP; - /* All filters are already in use, we cannot match more rules */ - if (bitmap_weight(priv->filters, RXCHK_BRCM_TAG_MAX) == - RXCHK_BRCM_TAG_MAX) - return -ENOSPC; - index = find_first_zero_bit(priv->filters, RXCHK_BRCM_TAG_MAX); if (index >= RXCHK_BRCM_TAG_MAX) + /* All filters are already in use, we cannot match more rules */ return -ENOSPC; /* Location is the classification ID, and index is the position From patchwork Thu Feb 10 22:48:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12742556 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC5AEC433EF for ; Thu, 10 Feb 2022 23:02:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345208AbiBJXC4 (ORCPT ); Thu, 10 Feb 2022 18:02:56 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:55246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345039AbiBJXCy (ORCPT ); Thu, 10 Feb 2022 18:02:54 -0500 Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E0CD1107; Thu, 10 Feb 2022 15:02:54 -0800 (PST) Received: by mail-il1-x12f.google.com with SMTP id m8so5613457ilg.7; Thu, 10 Feb 2022 15:02:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=x5y11i0zdnz/BX0MaBmAp+uRfUX2Rak/fHPY7uFI9V0=; b=CSDL1Vj/nWsuuxYBwx/1wZqFN7bmDSB+ohNjATtPUS/FmhKwM8U3HzQsAuHa9fxhdw 4Jz3dKN1fN/o+4qihImxLWv+8hHfE0gxZLyEK1R//WED6Y4hZewiadnqdFSpUy5z0lxd lmW8scFb12dfcMOtEH2AdhXB3ZaHAM6AzRoLsapN1LJb1Ng2nN7e6DuYgJSNhKBPQv37 Za/uaPxa9OZzjDClHWB4tE9R4ub2sYccHlPLr9lZL9ZjugJwdvgdi67a+QlwHiDQXNF8 gufo35FdLMxm4rYABpmBVhdRWQxoj1egoyHZJzvxhzdCt+PUML3+Uln5r0OWfgGCDVoa uptw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=x5y11i0zdnz/BX0MaBmAp+uRfUX2Rak/fHPY7uFI9V0=; b=1xg0xXMb9MCzKdp6ToWjUCV87e1WFC+7uyVu5Mc9AQ7v/YDo+F07OB1lZ6U0A9BXDr UxODn5JZ4LBwCrmND86/C4fiyyJ2rtSCXtH9eFoX/Whcdszza8w+y/RO1bkfeIS8pV+d Tnx2whCGX1aVfAwKihEp9ZCmqP64FFA+WtEgrX8MreEF+zLULxoj1ewBUa70qknnq/Lb xD+nGMSvQspGkHvPSbFHisFOVNivj8ShitbcKv3FgtOUeoewtaqlpSS+22weWT4xZ5K3 mTu3UXMp5njuvZNuR1zfOIEd0bmKj1OtIB7WaBSIIRw4kRtkbEeuM9HvRRxDZl3NDalJ K2tg== X-Gm-Message-State: AOAM5324b9HOfdIcdOoYESoY3tImeMnEzwgTZTb/LrKem461CNyn2moO 6Zm9ENFA6LidaM06OHfPpow= X-Google-Smtp-Source: ABdhPJzPA3K644w+KPqoBt0nZGj9yYw0gW84+vIzUuBQFk1Yiwg2zu/FkqSM3NWQY8+eYGjQJPYgSw== X-Received: by 2002:a05:6e02:1090:: with SMTP id r16mr5059802ilj.183.1644534173993; Thu, 10 Feb 2022 15:02:53 -0800 (PST) Received: from localhost ([12.28.44.171]) by smtp.gmail.com with ESMTPSA id d12sm11567868ilv.42.2022.02.10.15.02.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 15:02:53 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?utf-8?b?TWljaGHFgiBNaXJvc8WC?= =?utf-8?b?YXc=?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Ariel Elior , Manish Chopra , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Subject: [RFC PATCH 05/49] qed: rework qed_rdma_bmap_free() Date: Thu, 10 Feb 2022 14:48:49 -0800 Message-Id: <20220210224933.379149-6-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220210224933.379149-1-yury.norov@gmail.com> References: <20220210224933.379149-1-yury.norov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC qed_rdma_bmap_free() is mostly an opencoded version of printk("%*pb"). Using %*pb format simplifies the code, and helps to avoid inefficient usage of bitmap_weight(). While here, reorganize logic to avoid calculating bmap weight if check is false. Signed-off-by: Yury Norov Reviewed-by: Andy Shevchenko --- This is RFC because it changes lines printing format to bitmap %*pb. If it hurts userspace, it's better to drop the patch. drivers/net/ethernet/qlogic/qed/qed_rdma.c | 45 +++++++--------------- 1 file changed, 14 insertions(+), 31 deletions(-) diff --git a/drivers/net/ethernet/qlogic/qed/qed_rdma.c b/drivers/net/ethernet/qlogic/qed/qed_rdma.c index 23b668de4640..f4c04af9d4dd 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_rdma.c +++ b/drivers/net/ethernet/qlogic/qed/qed_rdma.c @@ -319,44 +319,27 @@ static int qed_rdma_alloc(struct qed_hwfn *p_hwfn) void qed_rdma_bmap_free(struct qed_hwfn *p_hwfn, struct qed_bmap *bmap, bool check) { - int weight = bitmap_weight(bmap->bitmap, bmap->max_count); - int last_line = bmap->max_count / (64 * 8); - int last_item = last_line * 8 + - DIV_ROUND_UP(bmap->max_count % (64 * 8), 64); - u64 *pmap = (u64 *)bmap->bitmap; - int line, item, offset; - u8 str_last_line[200] = { 0 }; - - if (!weight || !check) + unsigned int bit, weight, nbits; + unsigned long *b; + + if (!check) + goto end; + + weight = bitmap_weight(bmap->bitmap, bmap->max_count); + if (!weight) goto end; DP_NOTICE(p_hwfn, "%s bitmap not free - size=%d, weight=%d, 512 bits per line\n", bmap->name, bmap->max_count, weight); - /* print aligned non-zero lines, if any */ - for (item = 0, line = 0; line < last_line; line++, item += 8) - if (bitmap_weight((unsigned long *)&pmap[item], 64 * 8)) + for (bit = 0; bit < bmap->max_count; bit += 512) { + b = bmap->bitmap + BITS_TO_LONGS(bit); + nbits = min(bmap->max_count - bit, 512); + + if (!bitmap_empty(b, nbits)) DP_NOTICE(p_hwfn, - "line 0x%04x: 0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx\n", - line, - pmap[item], - pmap[item + 1], - pmap[item + 2], - pmap[item + 3], - pmap[item + 4], - pmap[item + 5], - pmap[item + 6], pmap[item + 7]); - - /* print last unaligned non-zero line, if any */ - if ((bmap->max_count % (64 * 8)) && - (bitmap_weight((unsigned long *)&pmap[item], - bmap->max_count - item * 64))) { - offset = sprintf(str_last_line, "line 0x%04x: ", line); - for (; item < last_item; item++) - offset += sprintf(str_last_line + offset, - "0x%016llx ", pmap[item]); - DP_NOTICE(p_hwfn, "%s\n", str_last_line); + "line 0x%04x: %*pb\n", bit / 512, nbits, b); } end: From patchwork Thu Feb 10 22:48:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12742567 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DF43C433EF for ; Thu, 10 Feb 2022 23:11:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345497AbiBJXLp (ORCPT ); Thu, 10 Feb 2022 18:11:45 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:60500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242400AbiBJXLp (ORCPT ); Thu, 10 Feb 2022 18:11:45 -0500 Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99D415F45; Thu, 10 Feb 2022 15:11:45 -0800 (PST) Received: by mail-qt1-x831.google.com with SMTP id x5so7142207qtw.10; Thu, 10 Feb 2022 15:11:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ZBdSYHCr3USYo6W485UfRkjDE4guUfBuyMH5Mb4JqDU=; b=noirHY6GF4V4i8t+uu5JZQoNb9aCpruRdnEm1zuUkGMxjiGL/QA+2jJvW5q696QSYt ArH2xdXNKzx5VAWJf1ZbXj6Kin8p6qbXiG8tHG5RXG6uOggXjgywln0c3VNSq7sLigyy z7NvvKNREN8owyh9M01OFt2t8EjXllkRx7rL32xroe+PX7EzcvAgPKIArIqn+8ZjlOOK BwiWD5bNNWfkAbLL7OZzG+zIgoGXfWQmbCHioMYE/Hixd6D2RclBD1TwsJtxlKfyxR1a 3Iql8/K0PmZQ89a+14GQBXllOV38XKrUISn4vaAL9wPTv2tPQ/awzdPhwhPpDuTRlRvK fafA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZBdSYHCr3USYo6W485UfRkjDE4guUfBuyMH5Mb4JqDU=; b=T/ArRcZvgshtDP5falXRVxZIoXaUH3aibUQH7mteOqyVjtM888YPFuSl+n4AR1dAAY 0y8G9wD7pgV0mnfRErAWxNap014CmfLCG468+8YuH0ge3XLIXaQCC4z3eKZ8pvWT+bhn fauyjpfMGvN5o+h9opSRZ5mcdZz3KTV2ToQeFBSmvxo5Qh8gb7NZD5M0Yx743qPgNcIo KXKhenNcsIM2T19WbOEjNvnXPP2olxlRGlGmEUpJAGsENAfV3k3KhM6EJhsP2Bpf4jnE C8H9zUKkQ0iigpx6f3mor0+r4OGlTps+KUMLVcV6oluLPyHbUhxAUNEfZai9v2EJ6fc/ fH2w== X-Gm-Message-State: AOAM530mccGS8+RQAR+VBqiWOmDy6BA4CM2eQsStI65ra4Gb/OagNf4y GLGnXvNBObXrlJGSB1BSFEU= X-Google-Smtp-Source: ABdhPJyRNHJTVVPj+RR6tyohLG29mySY3xnZq28upNS8nrO1spe/OPmQyWpzHExT/NjogD+tlz2nxw== X-Received: by 2002:a05:622a:349:: with SMTP id r9mr6655005qtw.37.1644534704732; Thu, 10 Feb 2022 15:11:44 -0800 (PST) Received: from localhost ([12.28.44.171]) by smtp.gmail.com with ESMTPSA id h5sm11242509qti.95.2022.02.10.15.11.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 15:11:44 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?utf-8?b?TWljaGHFgiBNaXJvc8WC?= =?utf-8?b?YXc=?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Jakub Kicinski , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org Subject: [PATCH 09/49] ice: replace bitmap_weight with bitmap_empty Date: Thu, 10 Feb 2022 14:48:53 -0800 Message-Id: <20220210224933.379149-10-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220210224933.379149-1-yury.norov@gmail.com> References: <20220210224933.379149-1-yury.norov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The ice_vf_has_no_qs_ena() calls bitmap_weight() to check if any bit of a given bitmap is set. It's better to use bitmap_empty() in that case because bitmap_empty() stops traversing the bitmap as soon as it finds first set bit, while bitmap_weight() counts all bits unconditionally. Signed-off-by: Yury Norov --- drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c index 39b80124d282..9a86eeb6e3f2 100644 --- a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c @@ -267,8 +267,8 @@ ice_set_pfe_link(struct ice_vf *vf, struct virtchnl_pf_event *pfe, */ static bool ice_vf_has_no_qs_ena(struct ice_vf *vf) { - return (!bitmap_weight(vf->rxq_ena, ICE_MAX_RSS_QS_PER_VF) && - !bitmap_weight(vf->txq_ena, ICE_MAX_RSS_QS_PER_VF)); + return bitmap_empty(vf->rxq_ena, ICE_MAX_RSS_QS_PER_VF) && + bitmap_empty(vf->txq_ena, ICE_MAX_RSS_QS_PER_VF); } /** From patchwork Thu Feb 10 22:48:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12742571 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CFD97C433F5 for ; Thu, 10 Feb 2022 23:14:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345468AbiBJXN7 (ORCPT ); Thu, 10 Feb 2022 18:13:59 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:33480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243041AbiBJXN6 (ORCPT ); Thu, 10 Feb 2022 18:13:58 -0500 Received: from mail-qt1-x82f.google.com (mail-qt1-x82f.google.com [IPv6:2607:f8b0:4864:20::82f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BF2555A4; Thu, 10 Feb 2022 15:13:58 -0800 (PST) Received: by mail-qt1-x82f.google.com with SMTP id j12so7208355qtr.2; Thu, 10 Feb 2022 15:13:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=7FL52FrXNIHTozrcS4UAHCYMPxTzl2RTxQeoy1tQzZU=; b=AGBuTbR1DDTmbip/u/WZx2mNt0jPGvuO3BycAp6q2VmWJ1XpinqhZGjzxMYykQs1+h 9ZwK9nV2Hza30UOMDXrLFK15LOSULvD7ZjJxE9dsXejT1uWe+NyRJMgTaXeV1WmNgel9 eLii97p7+4ojaqGef/1vF3/S8W8Rgtj6O0GJTl0T6A2RIPF7e9C9EPh0fpAZj0VOPEjo nwjqptD59NnDlqInCC5Xcz7zI6Zdwo+X80xnVSm9eNlJ/x+5G4Rsb0PAvF1FL5QnrdSm ZkZCUR0Del2ERA0vC9l/qhTmRfA93zM+A7aiM1dWPj88KXvNexP7raFIi+zqIMF7LFdx 3osA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7FL52FrXNIHTozrcS4UAHCYMPxTzl2RTxQeoy1tQzZU=; b=roIilZ70b7b4OqHEr5LH/sdm2zdzv0llS/qx3vWCE0K5Q9r3vv0NaQoOtCTRaEDDcp MD4zKXl9cbFqiiSIcQsplDZB/8G7DdgX1g/qpecw0cyQHRmOsoHKZ/Wmn0QAz2l249DV tuRCi97OKpi9JeJFxCMVSrIulbqgB5mjbhWDQ9g7WSwIr5jkhTpqIIpnht0/Ix5b45ph Wg8Llp1KK6nyMAW3mk+nkTh/nw0B71xDLmCW6xB4943bAMKjSasGBk7rGbGGolXDsQH+ xSpuq8cl+A8obCygamYOiRVJheSsmjFjy/oIPhKRZnLH5/r1MGfx9tzeCsro0kTabTXP Xlhw== X-Gm-Message-State: AOAM532xIJDxukIp8LSDs4D3h68EkPIZ7NwbP+Th7W9KdVq/wPeorcHm 7PpA8HcXgTZPxLPH5da9SVc= X-Google-Smtp-Source: ABdhPJyziDNVK4gHlSQTL8oiGDJLo7w3dJcb5KZC+Jm81CQxXWEXD3+ANBnrP6vi6uDJfSyzoSW4VA== X-Received: by 2002:ac8:7d16:: with SMTP id g22mr6640405qtb.180.1644534837689; Thu, 10 Feb 2022 15:13:57 -0800 (PST) Received: from localhost ([12.28.44.171]) by smtp.gmail.com with ESMTPSA id u6sm10751221qki.136.2022.02.10.15.13.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 15:13:57 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?utf-8?b?TWljaGHFgiBNaXJvc8WC?= =?utf-8?b?YXc=?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Subject: [PATCH 10/49] octeontx2-pf: replace bitmap_weight with bitmap_empty where appropriate Date: Thu, 10 Feb 2022 14:48:54 -0800 Message-Id: <20220210224933.379149-11-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220210224933.379149-1-yury.norov@gmail.com> References: <20220210224933.379149-1-yury.norov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org In some places, octeontx2 code calls bitmap_weight() to check if any bit of a given bitmap is set. It's better to use bitmap_empty() in that case because bitmap_empty() stops traversing the bitmap as soon as it finds first set bit, while bitmap_weight() counts all bits unconditionally. Signed-off-by: Yury Norov --- drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c | 4 ++-- drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c index 77a13fb555fb..80b2d64b4136 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c @@ -353,7 +353,7 @@ int otx2_add_macfilter(struct net_device *netdev, const u8 *mac) { struct otx2_nic *pf = netdev_priv(netdev); - if (bitmap_weight(&pf->flow_cfg->dmacflt_bmap, + if (!bitmap_empty(&pf->flow_cfg->dmacflt_bmap, pf->flow_cfg->dmacflt_max_flows)) netdev_warn(netdev, "Add %pM to CGX/RPM DMAC filters list as well\n", @@ -436,7 +436,7 @@ int otx2_get_maxflows(struct otx2_flow_config *flow_cfg) return 0; if (flow_cfg->nr_flows == flow_cfg->max_flows || - bitmap_weight(&flow_cfg->dmacflt_bmap, + !bitmap_empty(&flow_cfg->dmacflt_bmap, flow_cfg->dmacflt_max_flows)) return flow_cfg->max_flows + flow_cfg->dmacflt_max_flows; else diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c index 86c1c2f77bd7..0f671df46694 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c @@ -1120,7 +1120,7 @@ static int otx2_cgx_config_loopback(struct otx2_nic *pf, bool enable) struct msg_req *msg; int err; - if (enable && bitmap_weight(&pf->flow_cfg->dmacflt_bmap, + if (enable && !bitmap_empty(&pf->flow_cfg->dmacflt_bmap, pf->flow_cfg->dmacflt_max_flows)) netdev_warn(pf->netdev, "CGX/RPM internal loopback might not work as DMAC filters are active\n"); From patchwork Thu Feb 10 22:48:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12742572 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D529AC433EF for ; Thu, 10 Feb 2022 23:16:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345563AbiBJXQM (ORCPT ); Thu, 10 Feb 2022 18:16:12 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:35036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345568AbiBJXQL (ORCPT ); Thu, 10 Feb 2022 18:16:11 -0500 Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FD305F57; Thu, 10 Feb 2022 15:16:11 -0800 (PST) Received: by mail-il1-x129.google.com with SMTP id f13so5648145ilq.5; Thu, 10 Feb 2022 15:16:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=h1925twPT3iSM3qheWQhZ9lCv/Q+dhcPfdo+0L9UR6M=; b=FmZrCbIuuWKcUa6zV5OkwYnsnhTEUlIwU3u7B4rFa9iv9rogxDfUrkC8iT50ElDrDJ V/LzmYUzN4KTICqQQrjcvGO0wHklus09GVJUy44lN8vcaxmXjobi8Dr6/6a6Gheo1UIf 6ZVGk/RUan0TW8dFSwWVwH57oqfIjLrfKcmhzfFRgYG7Twbk86HqrSoSWZt8ZFX533Cn 4V8AlTRgOg62gIynVCyufSHpgzhDihN3Mipttmzn2Ub5dY+etr1IqCTmeJOPXe8QvPRv rAcqxTsM6XK/RIMsgAA5tCXqxJdSESyW1TcRBcT5YER/neKAsTtsfzTPBB0ie0DRQnPO wGmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=h1925twPT3iSM3qheWQhZ9lCv/Q+dhcPfdo+0L9UR6M=; b=xc+wZTL5Y5Oflh9zNZPBoY6OYGuFSESO3dv8YR3uxcVM7JL5c1Zusz3D2C3V3xE5Wi DUjMdcSbCwQm584d8PjLAlU0Mg8Ob+V0XrRk11GkOTFH+IUjmNHVtrh2lwQjFdbf4GvV iKIIMXxa6u07vmFVWecMge0KCzPX2Qu5N+cjOMrYFOt5VZoBTZu0DKr6YWFS4AjLZZLD 78GaLfxS++vel5Zx0b/yxLT7mXMbDaNQ+ffLbFmd1zbWC7aXY82tXdxGVYeYdljFmHgI SKrbh5Fiv10G6xbz7kTKk8zXtDvrRkIbiVTr5wafXqhW5BfbIAFslwPRgCWbArz6Kgzk 9pfw== X-Gm-Message-State: AOAM530psnUwDkBWscs5LlQomuZ4JSN4fYB0rKCB0GLP3uLyM/3g8aMs gYWJynspUenhlykVV3DL2VM= X-Google-Smtp-Source: ABdhPJwNz15I7lWfFObm7DT3E8n4zBq2XHpU9H/Y5oNqt2y0xQ5ILb07o8ZNPvUbz9qZoJ7yYmpd8Q== X-Received: by 2002:a05:6e02:144d:: with SMTP id p13mr5306936ilo.47.1644534970739; Thu, 10 Feb 2022 15:16:10 -0800 (PST) Received: from localhost ([12.28.44.171]) by smtp.gmail.com with ESMTPSA id h3sm11666270ild.11.2022.02.10.15.16.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 15:16:10 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?utf-8?b?TWljaGHFgiBNaXJvc8WC?= =?utf-8?b?YXc=?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Ariel Elior , Manish Chopra , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Subject: [PATCH 11/49] qed: replace bitmap_weight with bitmap_empty in qed_roce_stop() Date: Thu, 10 Feb 2022 14:48:55 -0800 Message-Id: <20220210224933.379149-12-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220210224933.379149-1-yury.norov@gmail.com> References: <20220210224933.379149-1-yury.norov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org qed_roce_stop() calls bitmap_weight() to check if any bit of a given bitmap is set. We can do it more efficiently with bitmap_empty() because bitmap_empty() stops traversing the bitmap as soon as it finds first set bit, while bitmap_weight() counts all bits unconditionally. Signed-off-by: Yury Norov --- drivers/net/ethernet/qlogic/qed/qed_roce.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/qlogic/qed/qed_roce.c b/drivers/net/ethernet/qlogic/qed/qed_roce.c index 071b4aeaddf2..134ecfca96a3 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_roce.c +++ b/drivers/net/ethernet/qlogic/qed/qed_roce.c @@ -76,7 +76,7 @@ void qed_roce_stop(struct qed_hwfn *p_hwfn) * We delay for a short while if an async destroy QP is still expected. * Beyond the added delay we clear the bitmap anyway. */ - while (bitmap_weight(rcid_map->bitmap, rcid_map->max_count)) { + while (!bitmap_empty(rcid_map->bitmap, rcid_map->max_count)) { /* If the HW device is during recovery, all resources are * immediately reset without receiving a per-cid indication * from HW. In this case we don't expect the cid bitmap to be From patchwork Thu Feb 10 22:49:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12742601 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14265C433F5 for ; Thu, 10 Feb 2022 23:53:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345898AbiBJXxm (ORCPT ); Thu, 10 Feb 2022 18:53:42 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:54724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240464AbiBJXxl (ORCPT ); Thu, 10 Feb 2022 18:53:41 -0500 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0831D5F75; Thu, 10 Feb 2022 15:53:42 -0800 (PST) Received: by mail-io1-xd30.google.com with SMTP id q204so9473512iod.8; Thu, 10 Feb 2022 15:53:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=dlcn0c8FYc7DODG7QrUeh/RDtAB+I+F4Kdfoio51FaI=; b=pT8V02cRnyvge4g/jEw/vfDpSCJQ6mG8f5/2aDrsolSd6MEJ2MeTditvg5HTS3jTiY WtGZZX0/SoKQZhzIgkP9n0Dcpz+r0Ry6EqlDS1ADj+r+2ulVo+sw3mWYm6spJo0j4izv N1Ts5gZLSbXcfXixzzF1vDOzXCcZZGoO1De22gzUYl4uxS93hxyIA0QHPiwWxW7NznE1 lewNaZm3nBzJFJx6tYvobMi78QVigZ22b58D/vnMuMkpRkUzPV6fqocJUenoiOeZYDlQ W543WAQd+q0/+WonyRm+lCqOpJHOTkjXAKKjvaVnXKxFWTPxKbP0S6V7BC0ngGjwAxig dinw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dlcn0c8FYc7DODG7QrUeh/RDtAB+I+F4Kdfoio51FaI=; b=3A6NIwIeavoUYipRWjuzK5wDwLiStp3ujhMBqkbMCPiFG2V1zHwhxY5wL+EGKT0/vM ekStjIW8QaWB7flsLaAq6TiLJpgtyEHRDRnrow64mvjGxxXzg2yyIwLgOZWiwlayXUW1 Y2hrDRA3+yncT6Ip1zF7G+yGNrT1/lqphYY7ybP2zkEPIiL/wICxzhlnY2WPk9D6Fcn3 DCnrcauleYcUKIsdDpVHGmvRxtb2ve61bRcEHFliF/nPKOrL7fG2KOG5/mDgOvqQFxXC zNTIe9OKSk2xoYNQyciNnGg0Jvi5NWE88C5zLegXeY6xx8fLScAeQP0V1/9hwm3UjZRq mT+Q== X-Gm-Message-State: AOAM531XCfY+wDmFG2PImSr9TRASQNlQg6DQ3lWygVqdoYJb+MglgtYV MH+A6fjHm8frxgfWu4r2a64= X-Google-Smtp-Source: ABdhPJy1cnRyAEVSz8FK6oisjYTOYyOW5apveqRHtmqXfgAdrv7GPswYZO2OmUFJkYqdisR1K1A0IQ== X-Received: by 2002:a05:6602:2c8d:: with SMTP id i13mr5215640iow.181.1644537221384; Thu, 10 Feb 2022 15:53:41 -0800 (PST) Received: from localhost ([12.28.44.171]) by smtp.gmail.com with ESMTPSA id e17sm11144879ilm.67.2022.02.10.15.53.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 15:53:41 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?utf-8?b?TWljaGHFgiBNaXJvc8WC?= =?utf-8?b?YXc=?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Jakub Kicinski , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org Subject: [PATCH 28/49] iio: replace bitmap_weight() with bitmap_weight_{eq,gt} where appropriate Date: Thu, 10 Feb 2022 14:49:12 -0800 Message-Id: <20220210224933.379149-29-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220210224933.379149-1-yury.norov@gmail.com> References: <20220210224933.379149-1-yury.norov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org drivers/iio calls bitmap_weight() to compare the weight of bitmap with a given number. We can do it more efficiently with bitmap_weight_eq because conditional bitmap_weight may stop traversing the bitmap earlier, as soon as condition is (or can't be) met. Signed-off-by: Yury Norov --- drivers/iio/industrialio-trigger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c index f504ed351b3e..98c54022fecf 100644 --- a/drivers/iio/industrialio-trigger.c +++ b/drivers/iio/industrialio-trigger.c @@ -331,7 +331,7 @@ int iio_trigger_detach_poll_func(struct iio_trigger *trig, { struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(pf->indio_dev); bool no_other_users = - bitmap_weight(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER) == 1; + bitmap_weight_eq(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER, 1); int ret = 0; if (trig->ops && trig->ops->set_trigger_state && no_other_users) { From patchwork Thu Feb 10 22:49:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12742602 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F6CEC433EF for ; Thu, 10 Feb 2022 23:58:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345969AbiBJX6G (ORCPT ); Thu, 10 Feb 2022 18:58:06 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:57454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345964AbiBJX6F (ORCPT ); Thu, 10 Feb 2022 18:58:05 -0500 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 354723AF; Thu, 10 Feb 2022 15:58:06 -0800 (PST) Received: by mail-io1-xd29.google.com with SMTP id c188so9480085iof.6; Thu, 10 Feb 2022 15:58:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=wCe8l6BzIf39UXY71HrtaLDcF4n6vO18YFKJdpw4cXQ=; b=fI2SwxxZTVMqpxGhquBSWDyfIQ9U9DsAgpF9gRFwhpoAula9Vdzc1QlFVFHC1U6hwI ABtDL5EahVrOMWQOjSc1cxNHQioV9menjUMsuOH/Cnz8hecA97jxN6sPuk95u7nVfkQV v9wtNrSgpkd8oKfTH9OUi7v/x70ZavMozIl54AC5RULi2izx6U5HggOLYqF4OGCV8xvC S2cFxQ+81wUoSrp358Cp/BnH7gOLObY9fktA/0i7ZL+H0LeU4Gh8hM6p7+fRhxCwSkx6 mo4eV4AeXA5Mg/ksXKxD2Mw7++3/aR12BIxW+0jlVA0zfkk45kSAnE0jXh1mlQ8+k9e9 HVjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wCe8l6BzIf39UXY71HrtaLDcF4n6vO18YFKJdpw4cXQ=; b=vOoOGJkTXl1/xJAci7WVAv8LPEgWzHzOUoeu+uu+6AUAe/we+WIt278IVZddlc/BfE w42Noycd7YAaNw/nGfBFjnVtr17Lfo5re7NQByJPGO41uuXS/+5MLvlloQ9ZRu7d3Afw n8tDWxUDtbIbdDoxyK+sckpgdUI3Ez+ygeuhFyAQB/j8ys1XeeBwDeHuhZY0xnlrjBB3 JECbe6MRTradiW6PNfa1303aMTpw6YruLgHZj65xTgXOg572vOxHzBTSShFOstMEFnqJ 3JLAHisLYOGEiJ+QFm9V+O0u6Rvy6tAHRVU4TrLYYLNkhDvS4cDZAwOepfw9Uc6XGgxw 2YhA== X-Gm-Message-State: AOAM533H8A67IBTF9xr0wqatuIj3UO0xWQEkWCweRHfXiv+8YVKd0TZx 4wkr3xP1fP+i42Q5pXuFUj0= X-Google-Smtp-Source: ABdhPJyy7xzUjWAsxQE/FjXnUixngXgx0pMBOB0uizulIEe8wbp5Hbd+lionqAo02gVkXrx+e9ndLw== X-Received: by 2002:a05:6602:492:: with SMTP id y18mr4939747iov.95.1644537485609; Thu, 10 Feb 2022 15:58:05 -0800 (PST) Received: from localhost ([12.28.44.171]) by smtp.gmail.com with ESMTPSA id t6sm12773865iov.39.2022.02.10.15.58.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 15:58:05 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?utf-8?b?TWljaGHFgiBNaXJvc8WC?= =?utf-8?b?YXc=?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Jakub Kicinski , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org Subject: [PATCH 30/49] ixgbe: replace bitmap_weight with bitmap_weight_eq Date: Thu, 10 Feb 2022 14:49:14 -0800 Message-Id: <20220210224933.379149-31-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220210224933.379149-1-yury.norov@gmail.com> References: <20220210224933.379149-1-yury.norov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org ixgbe_disable_sriov calls bitmap_weight() to compare the weight of bitmap with a given number. We can do it more efficiently with bitmap_weight_eq because conditional bitmap_weight may stop traversing the bitmap earlier, as soon as condition is (or can't be) met. Signed-off-by: Yury Norov --- drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c index 214a38de3f41..35297d8a488b 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c @@ -246,7 +246,7 @@ int ixgbe_disable_sriov(struct ixgbe_adapter *adapter) #endif /* Disable VMDq flag so device will be set in VM mode */ - if (bitmap_weight(adapter->fwd_bitmask, adapter->num_rx_pools) == 1) { + if (bitmap_weight_eq(adapter->fwd_bitmask, adapter->num_rx_pools, 1)) { adapter->flags &= ~IXGBE_FLAG_VMDQ_ENABLED; adapter->flags &= ~IXGBE_FLAG_SRIOV_ENABLED; rss = min_t(int, ixgbe_max_rss_indices(adapter), From patchwork Thu Feb 10 22:49:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12742604 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2EE38C433F5 for ; Fri, 11 Feb 2022 00:00:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345977AbiBKAAR (ORCPT ); Thu, 10 Feb 2022 19:00:17 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:58564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344855AbiBKAAQ (ORCPT ); Thu, 10 Feb 2022 19:00:16 -0500 Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41E2DB43; Thu, 10 Feb 2022 16:00:17 -0800 (PST) Received: by mail-io1-xd36.google.com with SMTP id c188so9484478iof.6; Thu, 10 Feb 2022 16:00:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=1VzDs/UF8yNYolinMWkkLgNxpJN0NuoP4WS4+Lqu0sA=; b=m35rj5AcGg4ZoO/CaQ6n0yBhN80NZMhAZaAYPc5oQ5QLdbRk6Sl/E8joLQn53J4ff3 2Q4sVyUWGAiW9X/8aoIfgolVHBX39NTLvrHb/NT1sL9Ckw7tjAj0TA2/Mf+TMPFdlKhe E/D2qMjz7iKjdcFKzXN01mzzHTOMC7ys6tQ7P5WAjTgXg7NNG67Tn7WARC/UTrpPNLu/ p53LCn/B4zYErDdyOIsWeNVIQlH5nblQtYEZAqvmI6fWAjalLCk1MiS0Wix4HmyL1m/7 /fcQYKq/1C0EpHDZ+djamC1YqlAZ5ps0Tw7cMdqna9BtQRZ1tlLH8EZAZlG8OgZ/vokz YQJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1VzDs/UF8yNYolinMWkkLgNxpJN0NuoP4WS4+Lqu0sA=; b=Zju7Ck6xu/Agr/t93XDt/4p8c391UDeERVDtbVb1tJjcGC7sgrXgMDveebI62ab3FP /uxWwEZbHK225FEIMli81Er4Tb5NViHt2o2iwqVJ7i0eac2n3WsOkyVjeWtv5jcBBmEy TBBDNVA6ZR/w4CyGTESsBaxdhRU3kxU4C8/lhFIldDI51TqTY5xLgM/CzExItbfWt8vT G8t1fYe6wVMurzAr0+v7muJcFHebKIYutWIxSQUVXBx6lvwtgTqnhntnwAJeCEm1ucbz YbwCTV9Yq8k+QGpEw/JlQ9TPYGgswfwlkJ1y4wC9QgqnVkrLHQznUAJHD5xNQtaPHAW0 dubA== X-Gm-Message-State: AOAM5339rAB14H7Dix/65hY4Ud1PKg2/L08m6wwnTyGFRGYC7gRMVMh7 VC1TgxGF7m8fTKwn/pCewcw= X-Google-Smtp-Source: ABdhPJxIsukjl91lmQIP9KGBjssEZgccEFXHxU6BJidUIyqZB50gNcturaZWfIbyxXDkBQagwZ6erQ== X-Received: by 2002:a05:6602:148c:: with SMTP id a12mr5156955iow.139.1644537616646; Thu, 10 Feb 2022 16:00:16 -0800 (PST) Received: from localhost ([12.28.44.171]) by smtp.gmail.com with ESMTPSA id x1sm11412699ilc.34.2022.02.10.16.00.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 16:00:16 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?utf-8?b?TWljaGHFgiBNaXJvc8WC?= =?utf-8?b?YXc=?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Subject: [PATCH 31/49] octeontx2-pf: replace bitmap_weight with bitmap_weight_{eq,gt} Date: Thu, 10 Feb 2022 14:49:15 -0800 Message-Id: <20220210224933.379149-32-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220210224933.379149-1-yury.norov@gmail.com> References: <20220210224933.379149-1-yury.norov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org OcteonTX2 code calls bitmap_weight() to compare the weight of bitmap with a given number. We can do it more efficiently with bitmap_weight_{eq,gt} because conditional bitmap_weight may stop traversing the bitmap earlier, as soon as condition is (or can't be) met. Signed-off-by: Yury Norov --- drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 2 +- drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c index abe5267210ef..152890066c2a 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c @@ -287,7 +287,7 @@ static int otx2_set_channels(struct net_device *dev, if (!channel->rx_count || !channel->tx_count) return -EINVAL; - if (bitmap_weight(&pfvf->rq_bmap, pfvf->hw.rx_queues) > 1) { + if (bitmap_weight_gt(&pfvf->rq_bmap, pfvf->hw.rx_queues, 1)) { netdev_err(dev, "Receive queues are in use by TC police action\n"); return -EINVAL; diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c index 80b2d64b4136..55c899a6fcdd 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c @@ -1170,8 +1170,8 @@ int otx2_remove_flow(struct otx2_nic *pfvf, u32 location) * interface mac address and configure CGX/RPM block in * promiscuous mode */ - if (bitmap_weight(&flow_cfg->dmacflt_bmap, - flow_cfg->dmacflt_max_flows) == 1) + if (bitmap_weight_eq(&flow_cfg->dmacflt_bmap, + flow_cfg->dmacflt_max_flows, 1)) otx2_update_rem_pfmac(pfvf, DMAC_ADDR_DEL); } else { err = otx2_remove_flow_msg(pfvf, flow->entry, false); From patchwork Thu Feb 10 22:49:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12742605 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10378C433EF for ; Fri, 11 Feb 2022 00:02:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346004AbiBKACa (ORCPT ); Thu, 10 Feb 2022 19:02:30 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:59596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345998AbiBKAC3 (ORCPT ); Thu, 10 Feb 2022 19:02:29 -0500 Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08AE6B49; Thu, 10 Feb 2022 16:02:29 -0800 (PST) Received: by mail-qk1-x736.google.com with SMTP id b35so6675716qkp.6; Thu, 10 Feb 2022 16:02:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=cn+lM1AC6Wl058uCalgabTDXoS6RKyQ5ezmTj8hWjqc=; b=U6qybxVNUPg6wMb4Z1IQgNBqT6xW3REYN2Sr/6brQlQsYt6MN0rdzndRhY1bqgcIWj OZEYlaAmP8rhkhwL1v4h50e+w6DKaqK9b4jaDwjxi5J36Nc8nm2KlHJLlSZwqQqN+5AF /GvIdafVgN6DI7iM+8CdPZkYFoz5OtGlCZVRLCCtDwlWHbgPn+wRceAoy1u8/10XPAzW wvwf5sEWsyipP+Co2Us5jJL2qnVCGyhvB+ZAO/LNGkYi16RuhSY5ggC/sSl6UXWNLU5Z eihuxa2wdkytxpqfsQb/fee3IDvquaqQLoOT1wwVQDnXPrO2W4G3b2ti2V7k65li737J woHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cn+lM1AC6Wl058uCalgabTDXoS6RKyQ5ezmTj8hWjqc=; b=SOE4InXr0B3zXPEu0BO79aJYHaK2IPeykdVUW/aZ+jsB7jmdONl/ZmkJvKxCtJXKwv pmK4Bei2IJw5oBTKrd950eYK8bpOkocDq5N4RbOwtDJPpNPQUNZM4HPwtUTPWWIf4Ufd dwqDuyT68h4P2ADEkb7P+clmBC/0F16mcfiDNrZzkMCpVTI5EFrRKWNH1QBlzQa6OyYi fa80CV+TMelQukb4z/BJfF/sIqCgPPGFHz8cbGlMPIDjn08liA2ecdFvTevklUBISf8x ZHYTL2U0ascm+XG+vtlpELBgJZNmi3ghaXaXl0LCodoD6FnE2hf46WGYbNHrvQJm1uDd KxXg== X-Gm-Message-State: AOAM530dLb+2hZBKtiul7XPWewLhJrWLHUojayNrJUMbS8yOUrHXE4bd zYonHBSl22tsKtWaYuVrJbc= X-Google-Smtp-Source: ABdhPJz6x7E7rMj/rklw9RICLxkRDsShVMv05ry/VIWiG39qkYPi6XHc0xmgoCevif80B9SyBk8Vpw== X-Received: by 2002:a05:620a:11ad:: with SMTP id c13mr5210841qkk.541.1644537748044; Thu, 10 Feb 2022 16:02:28 -0800 (PST) Received: from localhost ([12.28.44.171]) by smtp.gmail.com with ESMTPSA id r2sm12006233qta.15.2022.02.10.16.02.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 16:02:27 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?utf-8?b?TWljaGHFgiBNaXJvc8WC?= =?utf-8?b?YXc=?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Subject: [PATCH 32/49] mlx4: replace bitmap_weight with bitmap_weight_{eq,gt,ge,lt,le} Date: Thu, 10 Feb 2022 14:49:16 -0800 Message-Id: <20220210224933.379149-33-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220210224933.379149-1-yury.norov@gmail.com> References: <20220210224933.379149-1-yury.norov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Mellanox code uses bitmap_weight() to compare the weight of bitmap with a given number. We can do it more efficiently with bitmap_weight_{eq, ...} because conditional bitmap_weight may stop traversing the bitmap earlier, as soon as condition is (or can't be) met. Signed-off-by: Yury Norov --- drivers/net/ethernet/mellanox/mlx4/cmd.c | 10 +++------- drivers/net/ethernet/mellanox/mlx4/eq.c | 4 ++-- drivers/net/ethernet/mellanox/mlx4/fw.c | 4 ++-- drivers/net/ethernet/mellanox/mlx4/main.c | 2 +- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c index c56d2194cbfc..5bca0c68f00a 100644 --- a/drivers/net/ethernet/mellanox/mlx4/cmd.c +++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c @@ -2792,9 +2792,8 @@ int mlx4_slave_convert_port(struct mlx4_dev *dev, int slave, int port) { unsigned n; struct mlx4_active_ports actv_ports = mlx4_get_active_ports(dev, slave); - unsigned m = bitmap_weight(actv_ports.ports, dev->caps.num_ports); - if (port <= 0 || port > m) + if (port <= 0 || bitmap_weight_lt(actv_ports.ports, dev->caps.num_ports, port)) return -EINVAL; n = find_first_bit(actv_ports.ports, dev->caps.num_ports); @@ -3404,10 +3403,6 @@ int mlx4_vf_set_enable_smi_admin(struct mlx4_dev *dev, int slave, int port, struct mlx4_priv *priv = mlx4_priv(dev); struct mlx4_active_ports actv_ports = mlx4_get_active_ports( &priv->dev, slave); - int min_port = find_first_bit(actv_ports.ports, - priv->dev.caps.num_ports) + 1; - int max_port = min_port - 1 + - bitmap_weight(actv_ports.ports, priv->dev.caps.num_ports); if (slave == mlx4_master_func_num(dev)) return 0; @@ -3417,7 +3412,8 @@ int mlx4_vf_set_enable_smi_admin(struct mlx4_dev *dev, int slave, int port, enabled < 0 || enabled > 1) return -EINVAL; - if (min_port == max_port && dev->caps.num_ports > 1) { + if (dev->caps.num_ports > 1 && + bitmap_weight_eq(actv_ports.ports, priv->dev.caps.num_ports, 1)) { mlx4_info(dev, "SMI access disallowed for single ported VFs\n"); return -EPROTONOSUPPORT; } diff --git a/drivers/net/ethernet/mellanox/mlx4/eq.c b/drivers/net/ethernet/mellanox/mlx4/eq.c index 414e390e6b48..0c09432ff389 100644 --- a/drivers/net/ethernet/mellanox/mlx4/eq.c +++ b/drivers/net/ethernet/mellanox/mlx4/eq.c @@ -1435,8 +1435,8 @@ int mlx4_is_eq_shared(struct mlx4_dev *dev, int vector) if (vector <= 0 || (vector >= dev->caps.num_comp_vectors + 1)) return -EINVAL; - return !!(bitmap_weight(priv->eq_table.eq[vector].actv_ports.ports, - dev->caps.num_ports) > 1); + return bitmap_weight_gt(priv->eq_table.eq[vector].actv_ports.ports, + dev->caps.num_ports, 1); } EXPORT_SYMBOL(mlx4_is_eq_shared); diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.c b/drivers/net/ethernet/mellanox/mlx4/fw.c index 42c96c9d7fb1..855aae326ccb 100644 --- a/drivers/net/ethernet/mellanox/mlx4/fw.c +++ b/drivers/net/ethernet/mellanox/mlx4/fw.c @@ -1300,8 +1300,8 @@ int mlx4_QUERY_DEV_CAP_wrapper(struct mlx4_dev *dev, int slave, actv_ports = mlx4_get_active_ports(dev, slave); first_port = find_first_bit(actv_ports.ports, dev->caps.num_ports); for (slave_port = 0, real_port = first_port; - real_port < first_port + - bitmap_weight(actv_ports.ports, dev->caps.num_ports); + bitmap_weight_gt(actv_ports.ports, dev->caps.num_ports, + real_port - first_port); ++real_port, ++slave_port) { if (flags & (MLX4_DEV_CAP_FLAG_WOL_PORT1 << real_port)) flags |= MLX4_DEV_CAP_FLAG_WOL_PORT1 << slave_port; diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c index b187c210d4d6..cfbaa7ac712f 100644 --- a/drivers/net/ethernet/mellanox/mlx4/main.c +++ b/drivers/net/ethernet/mellanox/mlx4/main.c @@ -1383,7 +1383,7 @@ static int mlx4_mf_bond(struct mlx4_dev *dev) dev->persist->num_vfs + 1); /* only single port vfs are allowed */ - if (bitmap_weight(slaves_port_1_2, dev->persist->num_vfs + 1) > 1) { + if (bitmap_weight_gt(slaves_port_1_2, dev->persist->num_vfs + 1, 1)) { mlx4_warn(dev, "HA mode unsupported for dual ported VFs\n"); return -EINVAL; }