Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp909422pxy; Thu, 22 Apr 2021 17:02:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwx2mLjlPl6XgCMOeYVJTWTsn9Z+8ELM+Gk7wLLeOvDmCdDnC0Itrjg5ce6z/VmvximANy8 X-Received: by 2002:aa7:c3d8:: with SMTP id l24mr1156771edr.319.1619136146116; Thu, 22 Apr 2021 17:02:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619136146; cv=none; d=google.com; s=arc-20160816; b=xx0CIsl3I9Wzv5X65tFezP+W4A6Y0nPuKHtFyv9hTEH5ME6Z9a8j8cR0HJPVu8KZRg atsAQbeaGDFAyreAlRUhNvm8t8nrlOFmBLpGzfL9B445ynoWNKJFVTZwh71esrq5NvRN 2YW5NYUdWXBOPg/AFgITOxo1N5IStp1iQ7lnitLXMhV3TGJZCfThzu5J9PRZE/fGpC0q PPFFyN4vH8UhVrqgT0GrfMpN14JLQPnfRq1qaE9UgMEzWiHW3d3VfV95VP4qx+bxdU5q pG/yKBl810aVYqz0kh5OhAQJSy47VEhwRhGHsxVRTv3YYybod9euBNnVEBT1Ksa9QC0c NBVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=t8dKHGBCmHD9gD0RbJEfB/SuhXgwn7Gf5zPPUk5At7o=; b=EK01SiG0/bL+gIGQLnuOkLyhH9krOHf4f5BIhFCugUD/tOs+PkpqoDwzpF7ayvb863 IgooEbOoZUX3Jz8+Tb4tZiWnSmyYPFvrKknZUaH7kCQfsPSDaVkUj7ICaSBcIVATAlVB jKsLlN5HGT2deZ9VYSLX8aStXHG6wImWvRTIg86cxV5cb4dg08j3FQ1RmTplJvBcSpU5 jtHeh3OgZ50aVzYoTrPPAC2MmldQ9aBPmPUgBdfMTzWafdW6aRyey3RnvU7ZnMjdPzXO Z2f3BopbpCFlhaRCgyKTlf4i19+brdv6Rqauqpzun1jVImcjtdUv06LBeDlQl03c/HxM YD+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p25si4514875ejc.571.2021.04.22.17.02.02; Thu, 22 Apr 2021 17:02:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237141AbhDWABn (ORCPT + 99 others); Thu, 22 Apr 2021 20:01:43 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:17391 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235569AbhDWABn (ORCPT ); Thu, 22 Apr 2021 20:01:43 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4FRDsl4mgRzlZ7c; Fri, 23 Apr 2021 07:59:07 +0800 (CST) Received: from A190218597.china.huawei.com (10.47.31.136) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.498.0; Fri, 23 Apr 2021 08:00:56 +0800 From: Salil Mehta To: , CC: , , , , , Subject: [PATCH V3 net] ice: Re-organizes reqstd/avail {R,T}XQ check/code for efficiency Date: Fri, 23 Apr 2021 01:00:18 +0100 Message-ID: <20210423000018.20244-1-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.47.31.136] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If user has explicitly requested the number of {R,T}XQs, then it is unnecessary to get the count of already available {R,T}XQs from the PF avail_{r,t}xqs bitmap. This value will get overridden by user specified value in any case. Re-organize this code for improving the flow, readability and efficiency. This scope of improvement was found during the review of the ICE driver code. Fixes: 87324e747fde ("ice: Implement ethtool ops for channels") Cc: intel-wired-lan@lists.osuosl.org Tested-by: Tony Brelinski Signed-off-by: Salil Mehta --- Change: V2->V3 (*) Addressed some comments from Paul Menzel Link: https://lkml.org/lkml/2021/4/21/136 V1->V2 (*) Fixed the comments from Anthony Nguyen(Intel) Link: https://lkml.org/lkml/2021/4/12/1997 --- drivers/net/ethernet/intel/ice/ice_lib.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c index d13c7fc8fb0a..d77133d6baa7 100644 --- a/drivers/net/ethernet/intel/ice/ice_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_lib.c @@ -161,12 +161,13 @@ static void ice_vsi_set_num_qs(struct ice_vsi *vsi, u16 vf_id) switch (vsi->type) { case ICE_VSI_PF: - vsi->alloc_txq = min3(pf->num_lan_msix, - ice_get_avail_txq_count(pf), - (u16)num_online_cpus()); if (vsi->req_txq) { vsi->alloc_txq = vsi->req_txq; vsi->num_txq = vsi->req_txq; + } else { + vsi->alloc_txq = min3(pf->num_lan_msix, + ice_get_avail_txq_count(pf), + (u16)num_online_cpus()); } pf->num_lan_tx = vsi->alloc_txq; @@ -175,12 +176,13 @@ static void ice_vsi_set_num_qs(struct ice_vsi *vsi, u16 vf_id) if (!test_bit(ICE_FLAG_RSS_ENA, pf->flags)) { vsi->alloc_rxq = 1; } else { - vsi->alloc_rxq = min3(pf->num_lan_msix, - ice_get_avail_rxq_count(pf), - (u16)num_online_cpus()); if (vsi->req_rxq) { vsi->alloc_rxq = vsi->req_rxq; vsi->num_rxq = vsi->req_rxq; + } else { + vsi->alloc_rxq = min3(pf->num_lan_msix, + ice_get_avail_rxq_count(pf), + (u16)num_online_cpus()); } } -- 2.17.1