From patchwork Mon Mar 25 22:28:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13603107 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-io1-f53.google.com (mail-io1-f53.google.com [209.85.166.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 762E483CBC for ; Mon, 25 Mar 2024 22:29:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711405784; cv=none; b=GFtiF48F0U2jGqSmYa4WNIIkagiMvs9yPfFam56S3H2HOV6WXczEZ7Ymikaz7tpy1KbSvyAAEsicJV036/dFUs6DQ34sjYumxqOZ2NLDF+EohBlF0dLgk/QPApNDdo6Lm7cnlCBOtumkduWgYi1CG3HuypMVuTlOxE7jsDN6HVE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711405784; c=relaxed/simple; bh=MMnBN1i9dwV7ghasfsHxDG4Y0phwAgnoqJctEeSBKY0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=mMoCCLJA9aJ1cobc0E7bstnQj0Cxe5p4kBGIEjRk7Bl7uiIjhWMY3yB6FraEzjIlGrNAR3tqW1fMOinzfgVx71CM6nWwjUCvJuk/Td8hVnMBXMIa+OV+g6jYuRxZNosxU5HyA/0QS3tjPexqpGsDizqGZ8s7Ib24coAc6Dm+/6I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=gZQnJNmR; arc=none smtp.client-ip=209.85.166.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="gZQnJNmR" Received: by mail-io1-f53.google.com with SMTP id ca18e2360f4ac-7d0262036afso187743439f.3 for ; Mon, 25 Mar 2024 15:29:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1711405781; x=1712010581; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=70X2p8/CCC99cQg9ybF1aYmssRhx7iuSQY4KOhXgDx0=; b=gZQnJNmRGY9cMkcx/PePUY2XOzmMWeyhGQ8yDdl5+ouRWblobE4Rf73ISkPSp2CCVq EN44ZYqw9aTMTG3El0HfpiKzPss3azXqC8Y2fkv4a7+i0Sd3QKwGbuBDWUo61wJYAZGu j3WVr2eImpV8wlViI7YGAoIVo4dsnkFBpQi+g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711405781; x=1712010581; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=70X2p8/CCC99cQg9ybF1aYmssRhx7iuSQY4KOhXgDx0=; b=eiJEW22UWN6XiZWdTz5LAIucgahWCNIZ2wNcZFdcdCsIIwF8HotOA8MTP6PmO4++IR qjX7yxVBIcDdwXS39m/RqxZDJvgibyJoaS108nADvatrknlj4A6lGttkg2MBJsQJlh1Q ECHBr4yuoAuI7QtcrE3+nATG7/Tpf00DuMoSvQV+nrReXleUIQ4MBmQnNcqbsau+L3q7 6a71sYxsoCpYwyvJCGLpHmePvgRbVbDsewBx6kZ4+F8mt3/fa+xuwsUYMQBJ6wfZ+tJ2 1ZGNtXTHhr1JxZnndQz1pl50/WhQ60fYpIR5RjD5ki8P2ABQT7SLfdwjOt5CGYf+QmG1 CMPg== X-Gm-Message-State: AOJu0YyWsvNA2DqFVPJq7kdG6KybWGWJWbEZFy71veZKBav9Nbuty43O OJLsNnkGn7BgMjG4poHPuu0s6szsTBI1bo58aKsEJLTQYym0cP2wevsJCA23zQ== X-Google-Smtp-Source: AGHT+IH1/DI5yogEHYPSalGhoJBwqY+mCax2aLoSXLfBuKqpnAhl+N04xTnc3EGoPPXBzkysge5GTg== X-Received: by 2002:a92:130b:0:b0:366:a611:f7c0 with SMTP id 11-20020a92130b000000b00366a611f7c0mr8919344ilt.0.1711405780930; Mon, 25 Mar 2024 15:29:40 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id t10-20020a63dd0a000000b005e438fe702dsm6301610pgg.65.2024.03.25.15.29.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Mar 2024 15:29:39 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com Subject: [PATCH net-next 07/12] bnxt_en: Simplify bnxt_rfs_capable() Date: Mon, 25 Mar 2024 15:28:57 -0700 Message-Id: <20240325222902.220712-8-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20240325222902.220712-1-michael.chan@broadcom.com> References: <20240325222902.220712-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org bnxt_rfs_capable() determines the number of VNICs and RSS_CTXs required to support aRFS and then reserves the resources. We already have functions bnxt_get_total_vnics() and bnxt_get_total_rss_ctxs() to do that. Simplify the code by calling these functions. It is also more correct to do the resource reservation after bnxt_can_reserve_rings() returns true. Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 80ccb5a54dae..e968684ccb1d 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -12479,28 +12479,19 @@ static bool bnxt_rfs_capable(struct bnxt *bp) struct bnxt_hw_rings hwr = {0}; int max_vnics, max_rss_ctxs; - hwr.rss_ctx = 1; - if (BNXT_SUPPORTS_NTUPLE_VNIC(bp)) { - /* 2 VNICS: default + Ntuple */ - hwr.vnic = 2; - hwr.rss_ctx = bnxt_get_nr_rss_ctxs(bp, bp->rx_nr_rings) * - hwr.vnic; - goto check_reserve_vnic; - } - if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) + if ((bp->flags & BNXT_FLAG_CHIP_P5_PLUS) && + !BNXT_SUPPORTS_NTUPLE_VNIC(bp)) return bnxt_rfs_supported(bp); + if (!(bp->flags & BNXT_FLAG_MSIX_CAP) || !bnxt_can_reserve_rings(bp) || !bp->rx_nr_rings) return false; - hwr.vnic = 1 + bp->rx_nr_rings; -check_reserve_vnic: + hwr.grp = bp->rx_nr_rings; + hwr.vnic = bnxt_get_total_vnics(bp, bp->rx_nr_rings); + hwr.rss_ctx = bnxt_get_total_rss_ctxs(bp, &hwr); max_vnics = bnxt_get_max_func_vnics(bp); max_rss_ctxs = bnxt_get_max_func_rss_ctxs(bp); - if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS) && - !(bp->rss_cap & BNXT_RSS_CAP_NEW_RSS_CAP)) - hwr.rss_ctx = hwr.vnic; - if (hwr.vnic > max_vnics || hwr.rss_ctx > max_rss_ctxs) { if (bp->rx_nr_rings > 1) netdev_warn(bp->dev,