From patchwork Tue Feb 20 23:03:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13564711 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-yb1-f182.google.com (mail-yb1-f182.google.com [209.85.219.182]) (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 C4468154BEB for ; Tue, 20 Feb 2024 23:03:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708470233; cv=none; b=lRVYXk8v8+omjPXfBgBbyw9FEIn9JZcLtuAkVBCLvIXTQ0Xj9Z7FWgxOFEalGZiZiwvj9TbCjX97aS+XhC+yTkcc4syTR5leU5cP9mOU8hvzbBFUx5oP0DoPXoNkiMLpf6CQ3AuHgyRhO1yQ7mGi7rxJnEwuSz+xVKhVGHmp43E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708470233; c=relaxed/simple; bh=K2ZxQGOKFoVwBigXBNNB0oarH2oloNtEBTIfumQRd6U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=gQWWcKZXCCx4+PCizPUPYQwe85iltSejtDgtVvtbPzRjekBhALnR9IHryHXCt6xWPI/oylolLLywmqsUecnHWaiqPEmPO2Fm0KD3IGNS8KaUHTOunrK5T2CMCY13FzQGN+GUWxRNIj0R6A7irc6y5HM/KqWOrpXtynCoLqjJ8i4= 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=FxIj7TI5; arc=none smtp.client-ip=209.85.219.182 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="FxIj7TI5" Received: by mail-yb1-f182.google.com with SMTP id 3f1490d57ef6-dcbc6a6808fso6345040276.2 for ; Tue, 20 Feb 2024 15:03:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1708470231; x=1709075031; 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=7/Fc9vmsbXajGioCEefOFYBTI6iVy3rXK2F9RPnhsUc=; b=FxIj7TI5XncFGW2tOKHCvEjcdD7cZHb1wsMdKHKp4VT+LwdKuQ/wiCIhYkSlJhK88e XegI9ZPj3Aokzggpf2BHpiyNCKM6qmbUDkgJmLlUys3ishY34GSHA40/kNsxHgjKWdOK Mw5H8tKg8gTYkM1SigdMlSXMDgxXDK+/eKKxo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708470231; x=1709075031; 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=7/Fc9vmsbXajGioCEefOFYBTI6iVy3rXK2F9RPnhsUc=; b=tjsJb+Y0ztTPXceAkkNIOHozL4l60q0KuEJZNPUPvpiaJCyvRh6Cb25foQ3/a2JOFl NHNqbNcxTvHu8tqHCjRdv6CofrqJVlx8bclF2oeZYiddayMmGAgyjCG8hQvzUiLqGXap XaNuHWtnR9njYVR1JJPjFDq/D8YbEyTIHSbQN0oJnXEBaFhINLWhNu2rVlHBZEL5OK/c orxDL41MnRKThyxUbRT5ft7/tNavndNHAiBsaBbuk+0SB51ZnlWGHadAsWuEBX8CHrZJ yDO5KIPo6UMizw3OCOLPXDY/pzTmsIiQ06V9d7TU2vOPMkwNLl7lpz/6ChsmK91QwNWS AskQ== X-Gm-Message-State: AOJu0Yx5zk9ExtWzTSKM+bClK3oCvWZ8bkgbq3Q7Ys/0BI283CIFz8xZ GiF4i7NTWwI6FDAXk7GUH64HUmCraZwRaXQxEZK2jvB26aIFO+OwaHVsjUxGzw== X-Google-Smtp-Source: AGHT+IG62W1YD046gVtxD3mo77GAi29pMW0jLBKtMXZtOQtkVT+Aidn4r1ByHLaeRlDBUHpXsYwgJQ== X-Received: by 2002:a25:8247:0:b0:dcd:38f9:f78 with SMTP id d7-20020a258247000000b00dcd38f90f78mr15547722ybn.29.1708470230689; Tue, 20 Feb 2024 15:03:50 -0800 (PST) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id g10-20020ae9e10a000000b00785d7dda9easm3797966qkm.28.2024.02.20.15.03.49 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Feb 2024 15:03:50 -0800 (PST) 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, Venkat Duvvuru Subject: [PATCH net-next 05/10] bnxt_en: Add bnxt_get_total_vnics() to calculate number of VNICs Date: Tue, 20 Feb 2024 15:03:12 -0800 Message-Id: <20240220230317.96341-6-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20240220230317.96341-1-michael.chan@broadcom.com> References: <20240220230317.96341-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 From: Venkat Duvvuru Refactor the code by adding a new function to calculate the number of required VNICs. This is used in multiple places when reserving or checking resources. Reviewed-by: Pavan Chebbi Signed-off-by: Venkat Duvvuru Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 28 ++++++++++++++--------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 71ac165dfb52..95af3cd7dba0 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -7308,13 +7308,22 @@ static void bnxt_check_rss_tbl_no_rmgr(struct bnxt *bp) } } +static int bnxt_get_total_vnics(struct bnxt *bp, int rx_rings) +{ + if (bp->flags & BNXT_FLAG_RFS) { + if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) + return rx_rings + 1; + } + return 1; +} + static bool bnxt_need_reserve_rings(struct bnxt *bp) { struct bnxt_hw_resc *hw_resc = &bp->hw_resc; int cp = bnxt_cp_rings_in_use(bp); int nq = bnxt_nq_rings_in_use(bp); int rx = bp->rx_nr_rings, stat; - int vnic = 1, grp = rx; + int vnic, grp = rx; if (hw_resc->resv_tx_rings != bp->tx_nr_rings && bp->hwrm_spec_code >= 0x10601) @@ -7329,9 +7338,9 @@ static bool bnxt_need_reserve_rings(struct bnxt *bp) bnxt_check_rss_tbl_no_rmgr(bp); return false; } - if ((bp->flags & BNXT_FLAG_RFS) && - !(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) - vnic = rx + 1; + + vnic = bnxt_get_total_vnics(bp, rx); + if (bp->flags & BNXT_FLAG_AGG_RINGS) rx <<= 1; stat = bnxt_get_func_stat_ctxs(bp); @@ -7382,13 +7391,13 @@ static int __bnxt_reserve_rings(struct bnxt *bp) hwr.cp = bnxt_nq_rings_in_use(bp); hwr.tx = bp->tx_nr_rings; hwr.rx = bp->rx_nr_rings; - hwr.vnic = 1; if (bp->flags & BNXT_FLAG_SHARED_RINGS) sh = true; if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) hwr.cp_p5 = hwr.rx + hwr.tx; - else if (bp->flags & BNXT_FLAG_RFS) - hwr.vnic = hwr.rx + 1; + + hwr.vnic = bnxt_get_total_vnics(bp, hwr.rx); + if (bp->flags & BNXT_FLAG_AGG_RINGS) hwr.rx <<= 1; hwr.grp = bp->rx_nr_rings; @@ -13326,10 +13335,7 @@ int bnxt_check_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs, if (max_tx < hwr.tx) return -ENOMEM; - hwr.vnic = 1; - if ((bp->flags & (BNXT_FLAG_RFS | BNXT_FLAG_CHIP_P5_PLUS)) == - BNXT_FLAG_RFS) - hwr.vnic += rx; + hwr.vnic = bnxt_get_total_vnics(bp, rx); tx_cp = __bnxt_num_tx_to_cp(bp, hwr.tx, tx_sets, tx_xdp); hwr.cp = sh ? max_t(int, tx_cp, rx) : tx_cp + rx;