From patchwork Tue Dec 12 00:51:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13488257 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="P/w+Tobs" 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 17F6DB3 for ; Mon, 11 Dec 2023 16:51:47 -0800 (PST) Received: by mail-qt1-x831.google.com with SMTP id d75a77b69052e-425baafa3c3so18275941cf.0 for ; Mon, 11 Dec 2023 16:51:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1702342306; x=1702947106; 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=VNAhbz/3JFmavnnVl0fxEttHYiHJ/95LJZIsp5PVOsQ=; b=P/w+TobszbxurpzIB+Pen93+TjCR00Ggbj6Rj55aPTDrKPT3NDXtiKPIq4IGxKWkXC 7tB7YHZMXnxka8t/Z7+Qtn4V0/nqd8wKImjNUHFBrX4bBBpzAKyhVJY6u7W5q4xSRhnC wTD5vl8lFNmvFNYVYX8LZgQjQQPmpkKvmvAdA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702342306; x=1702947106; 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=VNAhbz/3JFmavnnVl0fxEttHYiHJ/95LJZIsp5PVOsQ=; b=kYMmKtMFI6nDdXj0oX9gLBMwHf9s4hPt7c8WMnJqwxhCDZiG9Kh6NZnIVpiP625M/0 LVUvlVyEvGRk3Ay0MZIVtH5+sd8beNyMiQD3ibHi+QqkWMBGVMzmbL8aF4Ul4+JIJctm cY9qOkEmqvgMxB9xEfNbmArmNJClUqw3fybfVh/rw/+Mz0b1b67Ix574snQ+bQX3bIVm YXLRT92TbEfsBv2gfkG4DoCunSC4VLLkHVIOIlQHG8gl+mJuqCt/0o0JFrx+Fwv0pT6F gg6+QmBShgf0Alf/qh3L4TzhxWyPyprWblfo9eEGMdhsMgxKMk+RN33CuOG21jrBmLVl KM9w== X-Gm-Message-State: AOJu0YxuNdqzm4kHuAbCyUNslXAHsT7UDx8uGp+qTvtew2iNb3++wPih j9rlCYyAhetZ9mVFsiERC0WMYA== X-Google-Smtp-Source: AGHT+IEwxJmur6f7NI72c3kkQJ9GSly4tL9h2ePK9SjEhaQZBhIYMobDvdbrC2Z65OWP1WrJXh8QJg== X-Received: by 2002:a05:622a:5c8:b0:425:9ddf:2bc8 with SMTP id d8-20020a05622a05c800b004259ddf2bc8mr8400458qtb.135.1702342306116; Mon, 11 Dec 2023 16:51:46 -0800 (PST) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id r5-20020ac87945000000b00423ea1b31b3sm3619664qtt.66.2023.12.11.16.51.44 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Dec 2023 16:51:45 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, gospo@broadcom.com, Somnath Kotur Subject: [PATCH net-next 02/13] bnxt_en: Fix AGG ring check logic in bnxt_check_rings() Date: Mon, 11 Dec 2023 16:51:11 -0800 Message-Id: <20231212005122.2401-3-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20231212005122.2401-1-michael.chan@broadcom.com> References: <20231212005122.2401-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: Somnath Kotur _bnxt_get_max_rings() that is invoked in bnxt_check_rings() already accounts for the AGG ring(s) and gives a max value based on that. Increasing for AGG rings before calling _bnxt_get_max_rings() will result in checking for twice the number of rings than required and it can fail. Fix it by adjusting for AGG rings after calling _bnxt_get_max_rings(). Fixes: f5b29c6afe36 ("bnxt_en: Add helper to get the number of CP rings required for TX rings") Signed-off-by: Somnath Kotur Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 7afbbc71f92f..114beaa95e78 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -12724,14 +12724,14 @@ int bnxt_check_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs, if (tcs) tx_sets = tcs; - if (bp->flags & BNXT_FLAG_AGG_RINGS) - rx_rings <<= 1; - _bnxt_get_max_rings(bp, &max_rx, &max_tx, &max_cp); if (max_rx < rx_rings) return -ENOMEM; + if (bp->flags & BNXT_FLAG_AGG_RINGS) + rx_rings <<= 1; + tx_rings_needed = tx * tx_sets + tx_xdp; if (max_tx < tx_rings_needed) return -ENOMEM;