From patchwork Tue May 10 15:47:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12845203 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 B2145C43217 for ; Tue, 10 May 2022 15:48:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346632AbiEJPwt (ORCPT ); Tue, 10 May 2022 11:52:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347250AbiEJPwI (ORCPT ); Tue, 10 May 2022 11:52:08 -0400 Received: from mail-qt1-x830.google.com (mail-qt1-x830.google.com [IPv6:2607:f8b0:4864:20::830]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D6FE24595; Tue, 10 May 2022 08:48:09 -0700 (PDT) Received: by mail-qt1-x830.google.com with SMTP id y3so13831177qtn.8; Tue, 10 May 2022 08:48:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YR9pn4jX9oEu9ZPj21v5YqSNSABltP6KazwK0dihI+g=; b=b+d37BcnOOtc833JitSGOc7x3f2L3AE7Nf10xKLmhD4GjDgpUtUBGSvKNjCXlWoFqv 6YzrP02ahLFBG32O0Ws+15xbHp+dOeXdYG4mz3m054dW6mc4c722EwbQ9AzX+mLaIQv4 ESgLOi0yiR8EipW8HUqp/tAQoath61KrpL7EIRFe5NTmTAK+1Wzc8MkJakAmihyXNKk5 JQYymdcaGhZgnIVlvXS6OESpD7BDWVMQKKwcNHxjWTXNIQ5ryfnwS9lOEAZIo6T+A9Gz ivAvlL2bGWw2ECqmb0qWK6tD/Dbpw/VQMsOwfpB+0Bvitw4WH0kczgxf39JrhdgbNJbK YL4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YR9pn4jX9oEu9ZPj21v5YqSNSABltP6KazwK0dihI+g=; b=tzOHQMEfD0xji+InY5WoyEFQgqewNXy9B4MV+MjS8OeAgnry3O8zqzmSJHDWHReZx4 CUmsMWv8mlRc35E6zytTWh1LfizfgHSoJcUdFBVNQOx4t/YC0fqfZxVgmQwgrFOhlJ/F StD/ie14Rog2kDuvEMUzWuAZuRTu8O77VyDyGTeLxw/3mKyGjN81o4UXUTj/9RM2YECD iXejwkQNgy1O9q+1hKi9iV9w10OBbRgrfgh8mlKY1d2jHkrO+5QRVFN61h7O4bXEq0ef s6D3uHatuHHQAK5Rdn1z11GJF/1/GBpeDOXlnnMk2TLzjaA3mzELPjdxks1u3MxX1VHS 9jRg== X-Gm-Message-State: AOAM532CYAcfP/bkUWh99K6ZBcyGYSNM7PDr58Jf6ZizJhrRil6S6Ijl ZrESImBNpoNWybekJbpgw1s= X-Google-Smtp-Source: ABdhPJxFRmHP4o+KUAcl9Gzd3ONFTDwlKHVokPABxu3iBRg8vfeqO1O6Qd5Jeytf8QvM2mlUZTuU5Q== X-Received: by 2002:a05:622a:1213:b0:2f3:a79a:2ccc with SMTP id y19-20020a05622a121300b002f3a79a2cccmr20009701qtx.376.1652197688440; Tue, 10 May 2022 08:48:08 -0700 (PDT) Received: from localhost ([98.242.65.84]) by smtp.gmail.com with ESMTPSA id h191-20020a379ec8000000b0069fc347ef5dsm8578128qke.74.2022.05.10.08.48.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 08:48:08 -0700 (PDT) From: Yury Norov To: Andy Shevchenko , David Laight , Greg Kroah-Hartman , Joe Perches , Julia Lawall , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , Nicholas Piggin , Nicolas Palix , Peter Zijlstra , Rasmus Villemoes , Matti Vaittinen , linux-kernel@vger.kernel.org Cc: Yury Norov , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Leon Romanovsky , Paolo Abeni , Saeed Mahameed , netdev@vger.kernel.org, linux-rdma@vger.kernel.org Subject: [PATCH 10/22] net/mlx5e: simplify mlx5e_set_fecparam() Date: Tue, 10 May 2022 08:47:38 -0700 Message-Id: <20220510154750.212913-11-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220510154750.212913-1-yury.norov@gmail.com> References: <20220510154750.212913-1-yury.norov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org mlx5e_set_fecparam() used bitmap API to handle fecparam->fec. This is a bad practice because ->fec is not a bitmap - it's an u32 mask. The code wants to prevent user from passing ->fec with many modes enables. For this purpose it's better to use MANY_BITS() macro, which allows to avoid converting u32 to bitmap. CC: David S. Miller CC: Eric Dumazet CC: Jakub Kicinski CC: Leon Romanovsky CC: Paolo Abeni CC: Saeed Mahameed CC: netdev@vger.kernel.org CC: linux-rdma@vger.kernel.org CC: linux-kernel@vger.kernel.org Signed-off-by: Yury Norov --- drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c index 6e80585d731f..316cb72c4cc8 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c @@ -1664,13 +1664,11 @@ static int mlx5e_set_fecparam(struct net_device *netdev, { struct mlx5e_priv *priv = netdev_priv(netdev); struct mlx5_core_dev *mdev = priv->mdev; - unsigned long fec_bitmap; u16 fec_policy = 0; int mode; int err; - bitmap_from_arr32(&fec_bitmap, &fecparam->fec, sizeof(fecparam->fec) * BITS_PER_BYTE); - if (bitmap_weight(&fec_bitmap, ETHTOOL_FEC_LLRS_BIT + 1) > 1) + if (MANY_BITS(fecparam->fec)) return -EOPNOTSUPP; for (mode = 0; mode < ARRAY_SIZE(pplm_fec_2_ethtool); mode++) { From patchwork Tue May 10 15:47:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12845204 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 7B2DEC433EF for ; Tue, 10 May 2022 15:49:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346677AbiEJPxG (ORCPT ); Tue, 10 May 2022 11:53:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347267AbiEJPwN (ORCPT ); Tue, 10 May 2022 11:52:13 -0400 Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3D8B27FE4; Tue, 10 May 2022 08:48:15 -0700 (PDT) Received: by mail-qt1-x82b.google.com with SMTP id fu47so13827619qtb.5; Tue, 10 May 2022 08:48:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Yb/F6YFHx8jMmT8NzFo+iYOEgGU08YViXeElbI3tjgc=; b=MMnXS3xA1tmydR2qCDMamehnHI5FTZPQnT0YdSBT4isID4m9dejiQqAVaASciKXh2t uNvjLP9M1SpNR4L9suFWs2GB3zj0kW6tIw+HGOGD0qgwx94I6AWsORwzqjwEJ0Yw8Lon SHAjLcmqVRiNW8qsl5AfmJNSQJxIMdeX/5OhcZCWobvLe1G4TOlSiS1f4gQUkC3AyewE s/5zKTm6e85HXpPxzZGWWHF7kuC8kNjOOFMOLzuI6valozkPvbjyLJR/echRLonbSXes Vef44tpvYg2wXOOhFuE8RU0X4TxNWG/udFq3Emz7Cl/FRJe4tXgux0zhuZj3kBgh3jZD 9N3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Yb/F6YFHx8jMmT8NzFo+iYOEgGU08YViXeElbI3tjgc=; b=76KRrIAfArRUp4oHOH+q8Q1eCGeF4C0taImlIGbukwMIGyjKwxuWpkklPgrT/kuhc5 yJPlwBiUUp3BfXD23HIutJPzok2gMTbXuAj4TuMCfatte54JKnaTs071rCvslAIwfiXs GjRWKXwZFo9LmnbeHU8EjetkITZw7XCvp42ZLbB3JLqyzZzL1+DB9cnrgumfFfx3XEFu 81YqUvKwGGgrNZyCzo6JE1EVaALx3h+bAiMXJl4CHM1eEt9COp5aKE8QD4F5RSCIpWXf x+OskF7rVUhA5bp/XIPd8YDkylrloaraa3kfMW70URozjbjLZN88Y0WDdn4hP1GoV2s2 ZjHQ== X-Gm-Message-State: AOAM530b7Dwz3XLIq9adoT9BAqCT1884OEYOjet/Y45Lk+w3lWs23hnH poNcC8IgoVBlCZE81XbzsAg= X-Google-Smtp-Source: ABdhPJwV70hoAcYnRzaFrPNRGD//htdKIyrvhMG9B5O5rgnhDgAUf7COuLmQzmUbet3XQOUvrJCg2A== X-Received: by 2002:a05:622a:93:b0:2f3:c4ef:6c71 with SMTP id o19-20020a05622a009300b002f3c4ef6c71mr19568082qtw.505.1652197694757; Tue, 10 May 2022 08:48:14 -0700 (PDT) Received: from localhost ([98.242.65.84]) by smtp.gmail.com with ESMTPSA id c2-20020ac80542000000b002f39b99f67bsm9312717qth.21.2022.05.10.08.48.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 08:48:14 -0700 (PDT) From: Yury Norov To: Andy Shevchenko , David Laight , Greg Kroah-Hartman , Joe Perches , Julia Lawall , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , Nicholas Piggin , Nicolas Palix , Peter Zijlstra , Rasmus Villemoes , Matti Vaittinen , linux-kernel@vger.kernel.org Cc: Yury Norov , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Leon Romanovsky , Paolo Abeni , Saeed Mahameed , netdev@vger.kernel.org, linux-rdma@vger.kernel.org Subject: [PATCH 15/22] net/mlx5: use cpumask_weight_gt() in irq_pool_request_irq() Date: Tue, 10 May 2022 08:47:43 -0700 Message-Id: <20220510154750.212913-16-yury.norov@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220510154750.212913-1-yury.norov@gmail.com> References: <20220510154750.212913-1-yury.norov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org cpumask_weight_gt() is more efficient because it may stop traversing cpumask depending on condition. CC: David S. Miller CC: Eric Dumazet CC: Jakub Kicinski CC: Leon Romanovsky CC: Paolo Abeni CC: Saeed Mahameed CC: netdev@vger.kernel.org CC: linux-rdma@vger.kernel.org CC: linux-kernel@vger.kernel.org Signed-off-by: Yury Norov --- drivers/net/ethernet/mellanox/mlx5/core/irq_affinity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/irq_affinity.c b/drivers/net/ethernet/mellanox/mlx5/core/irq_affinity.c index 380a208ab137..d57f804ee934 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/irq_affinity.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/irq_affinity.c @@ -58,7 +58,7 @@ irq_pool_request_irq(struct mlx5_irq_pool *pool, const struct cpumask *req_mask) if (err) return ERR_PTR(err); if (pool->irqs_per_cpu) { - if (cpumask_weight(req_mask) > 1) + if (cpumask_weight_gt(req_mask, 1)) /* if req_mask contain more then one CPU, set the least loadad CPU * of req_mask */