From patchwork Fri Feb 10 17:31:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13136048 X-Patchwork-Delegate: kuba@kernel.org 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 6D0C5C05027 for ; Fri, 10 Feb 2023 17:32:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232516AbjBJRcH (ORCPT ); Fri, 10 Feb 2023 12:32:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232400AbjBJRcG (ORCPT ); Fri, 10 Feb 2023 12:32:06 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E28B2007C for ; Fri, 10 Feb 2023 09:32:05 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id d8so5973597plr.10 for ; Fri, 10 Feb 2023 09:32:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dp08myP8B2/KMbbWW5a7mtQqVJBpZGUspESp3nck244=; b=eZgoipBpKq1jWtAg3yuLf/PNwtqFHYP45PJcUuoIoeeeMfODLdqHTEjlaQVyEUwzp1 hB0SerSeKQrsle7+fV5cGnpq8sm/WlehtOr+lsg9h3mFPkV4I/nvrs9NUWd+BQ22MwXE FXvF4wDtSZcjDfxnL22lKduzv+2pGesOB0U7I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dp08myP8B2/KMbbWW5a7mtQqVJBpZGUspESp3nck244=; b=3XdhzY/kcgzmTmDaJZoolS9/nPz2hVqMvAIDy2zMOCXN1YZn+Eecu2U4Sl0T6xhdab R9d5iNnuX17ZKGUEtaTYlGBwxLXGvYKccu3I3zG/U9eCvUCdmuVQAwuoRWhApwub/Izi f5+IS4+76kyhWeLwqJH8wNpWSGnuuj267D9DS0ll2Qn+6mnWp9AWAN27XaiIz2wN59YY KFrJ2X4E10nYmp2vMX+zLrg323BxtsNwMLsEBXmi3Xn1ndzXjDIx8N6jenOBn4CQwKe7 zvXCDy5APT7WJo37DVADGcy8nXc8zRrWVqRlxRr6EVYBHO6IcBpnt1HgPztMtjYJjl6C ZgPA== X-Gm-Message-State: AO0yUKU1fMi2hXC39cpbwyBKOMQNoGIje0QnYEX8cRYcyEhtWqnAEGO+ ZPllKRLaKShoZMwFx1REXvyP9w== X-Google-Smtp-Source: AK7set8LoC/ADl0qzeuPfu5b4sOBvdgeg1I7gVW4WXHV/TuLSY3ii+JZnWobzxHQjKpcjNlMHUSiDg== X-Received: by 2002:a17:902:ec89:b0:196:1c45:6fc8 with SMTP id x9-20020a170902ec8900b001961c456fc8mr18548844plg.60.1676050324191; Fri, 10 Feb 2023 09:32:04 -0800 (PST) Received: from localhost.swdvt.lab.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id g2-20020a170902c38200b00176b84eb29asm840988plg.301.2023.02.10.09.32.02 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Feb 2023 09:32:03 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, kuba@kernel.org, edumazet@google.com, pabeni@redhat.com, gospo@broadcom.com Subject: [PATCH net] bnxt_en: Fix mqprio and XDP ring checking logic Date: Fri, 10 Feb 2023 12:31:55 -0500 Message-Id: <1676050315-19381-1-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org In bnxt_reserve_rings(), there is logic to check that the number of TX rings reserved is enough to cover all the mqprio TCs, but it fails to account for the TX XDP rings. So the check will always fail if there are mqprio TCs and TX XDP rings. As a result, the driver always fails to initialize after the XDP program is attached and the device will be brought down. A subsequent ifconfig up will also fail because the number of TX rings is set to an inconsistent number. Fix the check to properly account for TX XDP rings. If the check fails, set the number of TX rings back to a consistent number after calling netdev_reset_tc(). Fixes: 674f50a5b026 ("bnxt_en: Implement new method to reserve rings.") Reviewed-by: Hongguang Gao Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 240a7e8a7652..6c32f5c427b5 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -9274,10 +9274,14 @@ int bnxt_reserve_rings(struct bnxt *bp, bool irq_re_init) netdev_err(bp->dev, "ring reservation/IRQ init failure rc: %d\n", rc); return rc; } - if (tcs && (bp->tx_nr_rings_per_tc * tcs != bp->tx_nr_rings)) { + if (tcs && (bp->tx_nr_rings_per_tc * tcs != + bp->tx_nr_rings - bp->tx_nr_rings_xdp)) { netdev_err(bp->dev, "tx ring reservation failure\n"); netdev_reset_tc(bp->dev); - bp->tx_nr_rings_per_tc = bp->tx_nr_rings; + if (bp->tx_nr_rings_xdp) + bp->tx_nr_rings_per_tc = bp->tx_nr_rings_xdp; + else + bp->tx_nr_rings_per_tc = bp->tx_nr_rings; return -ENOMEM; } return 0;