From patchwork Fri Dec 8 00:16: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: 13484497 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="X7UycMfw" Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61B7E19B1 for ; Thu, 7 Dec 2023 16:17:24 -0800 (PST) Received: by mail-oi1-x233.google.com with SMTP id 5614622812f47-3b9e2a014e8so684591b6e.2 for ; Thu, 07 Dec 2023 16:17:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1701994643; x=1702599443; 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=JvX8Mi5E9qyRoOEzQhxDkamqPpxWTtH+S0fBbrqPiIY=; b=X7UycMfwjqZdR7yuTfxadKFIy3HM8IKYmLDEn2siQz4nR3twmBsVvCdtRIhTGCzrCi uvT2yzP/4c/ITCKEYI1z0vfqOHDKTQ+yUEPfbgplCT6TFQVxyKL0d4RRB0rGp+IqdYSe KzFAiKBwcaj2r+9W2lRMHrE/Rjksze4ohA2l0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701994643; x=1702599443; 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=JvX8Mi5E9qyRoOEzQhxDkamqPpxWTtH+S0fBbrqPiIY=; b=pGycFMB/ZeS82/v2iJE4D/lFobdhFzJX1UnAuhFj9J7xzCIJi0Qx1+iPQU9lPYu4Uo Q1Qpa0FWhoK9hFVVhVsj3hSWGa9+stTz9oJYIpeUNFQAsNm958aNaHTOePeqVWY071OI GzoFZfs3wZxjmy64x99hlWq2xR4BrnbQcdaj8D+JD4KBqnz3tdh2/STkhDNy6s6VQ8uD vHeVyLXvsoPArAZjRUcZ/Bg3CRge23grZLIuywVeRBebi7W41BlsW6Qm4a/9KL/YDsyM 4YH1dDgmee2iMG9ZZwz1SaBOswlSVWTsdc6eEQ8J/qbXPRHqtu1ybANR+me/eC7O9FU3 2j8Q== X-Gm-Message-State: AOJu0Yzc1xHd3WvQAURVa59LqYBI2wK1kLL5r2tZnTDVsvPh5DvYPmVP pyUDPuJF8CqzeRjGCyth3HS5cg== X-Google-Smtp-Source: AGHT+IGtIkUBV4lA54YeUh6j3rLXdE+u58lfNcWYuUV0mjDvgBkimLuKpm3dFV8f6sL6Vo5bWkrnuw== X-Received: by 2002:a05:6358:720d:b0:170:5ca3:af41 with SMTP id h13-20020a056358720d00b001705ca3af41mr4439677rwa.1.1701994643151; Thu, 07 Dec 2023 16:17:23 -0800 (PST) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id o4-20020a056a0015c400b006cdd369e3d0sm356493pfu.201.2023.12.07.16.17.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2023 16:17:22 -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 , Kalesh AP , Ajit Khaparde , Andy Gospodarek Subject: [PATCH net v3 1/4] bnxt_en: Clear resource reservation during resume Date: Thu, 7 Dec 2023 16:16:55 -0800 Message-Id: <20231208001658.14230-2-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20231208001658.14230-1-michael.chan@broadcom.com> References: <20231208001658.14230-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 We are issuing HWRM_FUNC_RESET cmd to reset the device including all reserved resources, but not clearing the reservations within the driver struct. As a result, when the driver re-initializes as part of resume, it believes that there is no need to do any resource reservation and goes ahead and tries to allocate rings which will eventually fail beyond a certain number pre-reserved by the firmware. Fixes: 674f50a5b026 ("bnxt_en: Implement new method to reserve rings.") Reviewed-by: Kalesh AP Reviewed-by: Ajit Khaparde Reviewed-by: Andy Gospodarek Signed-off-by: Somnath Kotur Signed-off-by: Michael Chan --- v3: Fix Fixes tag. v2: Fix typo in SoB tag. --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index d0359b569afe..72f2fc983940 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -13940,6 +13940,8 @@ static int bnxt_resume(struct device *device) if (rc) goto resume_exit; + bnxt_clear_reservations(bp, true); + if (bnxt_hwrm_func_drv_rgtr(bp, NULL, 0, false)) { rc = -ENODEV; goto resume_exit; From patchwork Fri Dec 8 00:16:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13484498 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="g8HP4mby" Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 805C019AF for ; Thu, 7 Dec 2023 16:17:26 -0800 (PST) Received: by mail-ot1-x335.google.com with SMTP id 46e09a7af769-6d9e49ea4bdso307967a34.2 for ; Thu, 07 Dec 2023 16:17:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1701994645; x=1702599445; 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=QPRFq3+2Q3Zal6GslCEmGg2pbRuDnfnW024J8m0KcAg=; b=g8HP4mbyYsoMJxZqWdUOu7RWnitCHhEiHqXDdq+S5ZkCpiyc8/sSjTRGX0VJmFyS6j FCV0IscNCZczmsyB9AI72EFF7CennwKGL6zU+BUMUVPYHetygIsiBDaoncX79Nghx2wR 9JhfZkgZGFtnyJffa7lOAv0yAuJSAIiW3oJog= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701994645; x=1702599445; 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=QPRFq3+2Q3Zal6GslCEmGg2pbRuDnfnW024J8m0KcAg=; b=rx7qfq03d1lC5ocslFmJ5qAUbMpTZBrxmZkpwgC1jRNYfZfAo/OOEKKxMdEWqm20v3 U/Gl5Z9YsN0dlSnjuNpmIOKOFx0xHOGQLvA3mXgNrAjse3R0/d8u+9AT4T1VKgZe+teo iJ9PQyMdb2L50CBnTcJvW+n8NjYUzugmfOd+jsGfMksKekIwC+9uXtfc6IKT0YmRkA3U RtUqd+ECePXnhDa3G2IQlSz04E5ak2aDoKCiC2dAFcPvGOhGOtJfJn3G98GNdt6TOJZP JsJv1zHw6yowBQdJqyVs2V+PYCY1JYFQjwTZemqEQRlfU8bHwnXVHIpufPV49kDz5cPD 3RkQ== X-Gm-Message-State: AOJu0YzLWiBU/VmGQDKp91OEZgg4u+W0WSRK7BUzUul14tsJM4n9wiNz 4cXso6Ki1nGypxI6z6KcIQ1+tg== X-Google-Smtp-Source: AGHT+IHjV+p1ItDpLNX2tazbMP+jg94WqdLl5wK9kCQUsihXQ/miSpnq7lXN+gCH7MkgTbKULDm1Pg== X-Received: by 2002:a05:6358:93a3:b0:170:17eb:1de with SMTP id h35-20020a05635893a300b0017017eb01demr3337849rwb.33.1701994645039; Thu, 07 Dec 2023 16:17:25 -0800 (PST) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id o4-20020a056a0015c400b006cdd369e3d0sm356493pfu.201.2023.12.07.16.17.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2023 16:17:24 -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, Sreekanth Reddy , Somnath Kotur , Andy Gospodarek , Vikas Gupta Subject: [PATCH net v3 2/4] bnxt_en: Fix skb recycling logic in bnxt_deliver_skb() Date: Thu, 7 Dec 2023 16:16:56 -0800 Message-Id: <20231208001658.14230-3-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20231208001658.14230-1-michael.chan@broadcom.com> References: <20231208001658.14230-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: Sreekanth Reddy Receive SKBs can go through the VF-rep path or the normal path. skb_mark_for_recycle() is only called for the normal path. Fix it to do it for both paths to fix possible stalled page pool shutdown errors. Fixes: 86b05508f775 ("bnxt_en: Use the unified RX page pool buffers for XDP and non-XDP") Reviewed-by: Somnath Kotur Reviewed-by: Andy Gospodarek Reviewed-by: Vikas Gupta Signed-off-by: Sreekanth Reddy Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 72f2fc983940..b4a5311bdeb5 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -1748,13 +1748,14 @@ static void bnxt_tpa_agg(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, static void bnxt_deliver_skb(struct bnxt *bp, struct bnxt_napi *bnapi, struct sk_buff *skb) { + skb_mark_for_recycle(skb); + if (skb->dev != bp->dev) { /* this packet belongs to a vf-rep */ bnxt_vf_rep_rx(bp, skb); return; } skb_record_rx_queue(skb, bnapi->index); - skb_mark_for_recycle(skb); napi_gro_receive(&bnapi->napi, skb); } From patchwork Fri Dec 8 00:16:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13484499 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="MF1XSYFb" Received: from mail-oo1-xc33.google.com (mail-oo1-xc33.google.com [IPv6:2607:f8b0:4864:20::c33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B48819A6 for ; Thu, 7 Dec 2023 16:17:28 -0800 (PST) Received: by mail-oo1-xc33.google.com with SMTP id 006d021491bc7-59063f8455eso737920eaf.3 for ; Thu, 07 Dec 2023 16:17:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1701994647; x=1702599447; 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=SdEmXiUuGSvk53hT7HIMfcR2WNZz4YIJetYDUMOmDbs=; b=MF1XSYFbFt+ZkgH962RdZzqox07ZLOPIuVcWK2B8VQj/BpCzsc+ZGVUXT1WrHN7MS7 1412dG1FETZWSLyunW+Z4ZrApXw/XThsYqz9DeT6Mgc6n3KdLeQGdf8gtedB813rJCul kl1Kp6FzfVvFJf90YKi6KpyNTuQFskkLETT/w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701994647; x=1702599447; 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=SdEmXiUuGSvk53hT7HIMfcR2WNZz4YIJetYDUMOmDbs=; b=X15XWMDk6cAmdN8PDordGkBt2ThORwHihUDe5MUdE+W1mlMNPFWzh6FGGBUp6AxYEW +VWi68y5A8yt65YfwFPWf0mtLiNhmyFEUUyRrUkZTkhp1qVs/gAWEwwYwKOoReRmGpKD jYFxDR5SNDZ75z2lNEcjJrPdhGbSqFsq5aLsJ9Z8PrFVeBuIzDOuPFFGfUFTRuKuf44E inV1ASxyOcKrSrS3w27kJ4aPl3zhCkhgYZV4RLCN/853YIa2Anes2MHmcG13vALjo6oF 4HChgNHVC/gAx9KpavWPHFLR+1SjVRlDQnHYW9hSB1vU9JYh7MccgCYyL8Gn2TvZOgst NoaA== X-Gm-Message-State: AOJu0Yx2bPKz1dGnV+YxdTRCaGMK9ZVOE92Anyxj01O3/gLfAPRYwnsu asdHDE2Uv9Er5b/zjnSt/xSFoA== X-Google-Smtp-Source: AGHT+IFo6lCv6S3pDnlc9JNgBsXUZ9BSaVmZFNvKmlH1xdp5oPy+XpAqJOfQMuaIGkaZQG555ID5fQ== X-Received: by 2002:a05:6358:882c:b0:170:17eb:203e with SMTP id hv44-20020a056358882c00b0017017eb203emr3848445rwb.39.1701994647050; Thu, 07 Dec 2023 16:17:27 -0800 (PST) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id o4-20020a056a0015c400b006cdd369e3d0sm356493pfu.201.2023.12.07.16.17.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2023 16:17:25 -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, Kalesh AP , Andy Gospodarek , Vikas Gupta , Somnath Kotur Subject: [PATCH net v3 3/4] bnxt_en: Fix wrong return value check in bnxt_close_nic() Date: Thu, 7 Dec 2023 16:16:57 -0800 Message-Id: <20231208001658.14230-4-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20231208001658.14230-1-michael.chan@broadcom.com> References: <20231208001658.14230-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: Kalesh AP The wait_event_interruptible_timeout() function returns 0 if the timeout elapsed, -ERESTARTSYS if it was interrupted by a signal, and the remaining jiffies otherwise if the condition evaluated to true before the timeout elapsed. Driver should have checked for zero return value instead of a positive value. MChan: Print a warning for -ERESTARTSYS. The close operation will proceed anyway when wait_event_interruptible_timeout() returns for any reason. Since we do the close no matter what, we should not return this error code to the caller. Change bnxt_close_nic() to a void function and remove all error handling from some of the callers. Fixes: c0c050c58d84 ("bnxt_en: New Broadcom ethernet driver.") Reviewed-by: Andy Gospodarek Reviewed-by: Vikas Gupta Reviewed-by: Somnath Kotur Signed-off-by: Kalesh AP Signed-off-by: Michael Chan --- v3: Log a warning for -ERESTARTSYS and do not return error code to caller. v2: Add missing SoB tag. --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 13 +++++++------ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 +- .../net/ethernet/broadcom/bnxt/bnxt_devlink.c | 11 ++--------- .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 19 ++++--------------- drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 5 ++--- 5 files changed, 16 insertions(+), 34 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index b4a5311bdeb5..aa1f5b776b5a 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -10732,10 +10732,8 @@ static void __bnxt_close_nic(struct bnxt *bp, bool irq_re_init, bnxt_free_mem(bp, irq_re_init); } -int bnxt_close_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init) +void bnxt_close_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init) { - int rc = 0; - if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { /* If we get here, it means firmware reset is in progress * while we are trying to close. We can safely proceed with @@ -10750,15 +10748,18 @@ int bnxt_close_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init) #ifdef CONFIG_BNXT_SRIOV if (bp->sriov_cfg) { + int rc; + rc = wait_event_interruptible_timeout(bp->sriov_cfg_wait, !bp->sriov_cfg, BNXT_SRIOV_CFG_WAIT_TMO); - if (rc) - netdev_warn(bp->dev, "timeout waiting for SRIOV config operation to complete!\n"); + if (!rc) + netdev_warn(bp->dev, "timeout waiting for SRIOV config operation to complete, proceeding to close!\n"); + else if (rc < 0) + netdev_warn(bp->dev, "SRIOV config operation interrupted, proceeding to close!\n"); } #endif __bnxt_close_nic(bp, irq_re_init, link_re_init); - return rc; } static int bnxt_close(struct net_device *dev) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index e702dbc3e6b1..0488b0466015 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -2375,7 +2375,7 @@ int bnxt_open_nic(struct bnxt *, bool, bool); int bnxt_half_open_nic(struct bnxt *bp); void bnxt_half_close_nic(struct bnxt *bp); void bnxt_reenable_sriov(struct bnxt *bp); -int bnxt_close_nic(struct bnxt *, bool, bool); +void bnxt_close_nic(struct bnxt *, bool, bool); void bnxt_get_ring_err_stats(struct bnxt *bp, struct bnxt_total_ring_err_stats *stats); int bnxt_dbg_hwrm_rd_reg(struct bnxt *bp, u32 reg_off, u16 num_words, diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c index f302dac56599..89809f1b129c 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c @@ -449,15 +449,8 @@ static int bnxt_dl_reload_down(struct devlink *dl, bool netns_change, return -ENODEV; } bnxt_ulp_stop(bp); - if (netif_running(bp->dev)) { - rc = bnxt_close_nic(bp, true, true); - if (rc) { - NL_SET_ERR_MSG_MOD(extack, "Failed to close"); - dev_close(bp->dev); - rtnl_unlock(); - break; - } - } + if (netif_running(bp->dev)) + bnxt_close_nic(bp, true, true); bnxt_vf_reps_free(bp); rc = bnxt_hwrm_func_drv_unrgtr(bp); if (rc) { diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index f3f384773ac0..5f67a7f94e7d 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -165,9 +165,8 @@ static int bnxt_set_coalesce(struct net_device *dev, reset_coalesce: if (test_bit(BNXT_STATE_OPEN, &bp->state)) { if (update_stats) { - rc = bnxt_close_nic(bp, true, false); - if (!rc) - rc = bnxt_open_nic(bp, true, false); + bnxt_close_nic(bp, true, false); + rc = bnxt_open_nic(bp, true, false); } else { rc = bnxt_hwrm_set_coal(bp); } @@ -972,12 +971,7 @@ static int bnxt_set_channels(struct net_device *dev, * before PF unload */ } - rc = bnxt_close_nic(bp, true, false); - if (rc) { - netdev_err(bp->dev, "Set channel failure rc :%x\n", - rc); - return rc; - } + bnxt_close_nic(bp, true, false); } if (sh) { @@ -4042,12 +4036,7 @@ static void bnxt_self_test(struct net_device *dev, struct ethtool_test *etest, bnxt_run_fw_tests(bp, test_mask, &test_results); } else { bnxt_ulp_stop(bp); - rc = bnxt_close_nic(bp, true, false); - if (rc) { - etest->flags |= ETH_TEST_FL_FAILED; - bnxt_ulp_start(bp, rc); - return; - } + bnxt_close_nic(bp, true, false); bnxt_run_fw_tests(bp, test_mask, &test_results); buf[BNXT_MACLPBK_TEST_IDX] = 1; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c index f3886710e778..6e3da3362bd6 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c @@ -521,9 +521,8 @@ static int bnxt_hwrm_ptp_cfg(struct bnxt *bp) if (netif_running(bp->dev)) { if (ptp->rx_filter == HWTSTAMP_FILTER_ALL) { - rc = bnxt_close_nic(bp, false, false); - if (!rc) - rc = bnxt_open_nic(bp, false, false); + bnxt_close_nic(bp, false, false); + rc = bnxt_open_nic(bp, false, false); } else { bnxt_ptp_cfg_tstamp_filters(bp); } From patchwork Fri Dec 8 00:16:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13484500 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="aOsXQtc0" Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD13B19BB for ; Thu, 7 Dec 2023 16:17:29 -0800 (PST) Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-6ceb2501f1bso1011385b3a.0 for ; Thu, 07 Dec 2023 16:17:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1701994649; x=1702599449; 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=JPUIM/SWTOd4abqKXMlSgtSF9VmXa011aEIRqhAxGo0=; b=aOsXQtc0Wu6lQR003eTk/vN9oTPiC+KeDivTqr1JS78DYgZiko/OjN7ErIO4eJCf/I uaoSRC+nDN3lUXtT0A6g2XdAepgdLwGNCglzRfVujiylRFmEaF+OCFZf9QJmOSk/PD2O HXB6dxYCuypR5Snb9Tqk3jAUMu9vQNWguc0Qs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701994649; x=1702599449; 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=JPUIM/SWTOd4abqKXMlSgtSF9VmXa011aEIRqhAxGo0=; b=qkANzMb0GbfvxZ8PA1hp60Hh0baTiPpc7o+FNUw/zJi2TJxBinBCubO2XdqvAqqpmG 2VfkngXDXsQsH3ysGMaOsACFSXb2ImpEeuqnYUzH78SmBpKdJXapj9dNhecx4PCIFoMA M3nG0Btwn7Cl/g5Pgl12mXGkyhag8hZkmN0K7qT3slm2d9QEYUpJTo4HuYwdMKD7xjdL KPRp1AZELlSNJm6tuW8w2Kl4sAlj4BgWH+m4r/TCK61jfiJ14ol3v/3EypLQJvgj0csq WHXCidAwtU1VH8D+2QSSh5kigVcJfj+BJnVBl2029EWqfFBLJVwtYs54Tz1JfuqHvsP7 5JSQ== X-Gm-Message-State: AOJu0YzvweB883rohRE6V/lIcMmgsiRahRCMSChD8XnwmjuUaLvt73eq az77mEmjVVC3YBQunIPVxWGe0g== X-Google-Smtp-Source: AGHT+IGht+/qKPlYplffNFnN4EHKFvEVUDPqqGYa1714U92mo1EIo6IlT1N59atTy/1kptLeaR/K6w== X-Received: by 2002:a05:6a00:1806:b0:6cd:d53c:f5ea with SMTP id y6-20020a056a00180600b006cdd53cf5eamr4256416pfa.6.1701994648988; Thu, 07 Dec 2023 16:17:28 -0800 (PST) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id o4-20020a056a0015c400b006cdd369e3d0sm356493pfu.201.2023.12.07.16.17.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2023 16:17:27 -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, Andy Gospodarek , Pavan Chebbi Subject: [PATCH net v3 4/4] bnxt_en: Fix HWTSTAMP_FILTER_ALL packet timestamp logic Date: Thu, 7 Dec 2023 16:16:58 -0800 Message-Id: <20231208001658.14230-5-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20231208001658.14230-1-michael.chan@broadcom.com> References: <20231208001658.14230-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 When the chip is configured to timestamp all receive packets, the timestamp in the RX completion is only valid if the metadata present flag is not set for packets received on the wire. In addition, internal loopback packets will never have a valid timestamp and the timestamp field will always be zero. We must exclude any 0 value in the timestamp field because there is no way to determine if it is a loopback packet or not. Add a new function bnxt_rx_ts_valid() to check for all timestamp valid conditions. Fixes: 66ed81dcedc6 ("bnxt_en: Enable packet timestamping for all RX packets") Reviewed-by: Andy Gospodarek Reviewed-by: Pavan Chebbi Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 20 +++++++++++++++++--- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 8 +++++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index aa1f5b776b5a..579eebb6fc56 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -1759,6 +1759,21 @@ static void bnxt_deliver_skb(struct bnxt *bp, struct bnxt_napi *bnapi, napi_gro_receive(&bnapi->napi, skb); } +static bool bnxt_rx_ts_valid(struct bnxt *bp, u32 flags, + struct rx_cmp_ext *rxcmp1, u32 *cmpl_ts) +{ + u32 ts = le32_to_cpu(rxcmp1->rx_cmp_timestamp); + + if (BNXT_PTP_RX_TS_VALID(flags)) + goto ts_valid; + if (!bp->ptp_all_rx_tstamp || !ts || !BNXT_ALL_RX_TS_VALID(flags)) + return false; + +ts_valid: + *cmpl_ts = ts; + return true; +} + /* returns the following: * 1 - 1 packet successfully received * 0 - successful TPA_START, packet not completed yet @@ -1784,6 +1799,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, struct sk_buff *skb; struct xdp_buff xdp; u32 flags, misc; + u32 cmpl_ts; void *data; int rc = 0; @@ -2006,10 +2022,8 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, } } - if (unlikely((flags & RX_CMP_FLAGS_ITYPES_MASK) == - RX_CMP_FLAGS_ITYPE_PTP_W_TS) || bp->ptp_all_rx_tstamp) { + if (bnxt_rx_ts_valid(bp, flags, rxcmp1, &cmpl_ts)) { if (bp->flags & BNXT_FLAG_CHIP_P5) { - u32 cmpl_ts = le32_to_cpu(rxcmp1->rx_cmp_timestamp); u64 ns, ts; if (!bnxt_get_rx_ts_p5(bp, &ts, cmpl_ts)) { diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 0488b0466015..a7d7b09ea162 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -161,7 +161,7 @@ struct rx_cmp { #define RX_CMP_FLAGS_ERROR (1 << 6) #define RX_CMP_FLAGS_PLACEMENT (7 << 7) #define RX_CMP_FLAGS_RSS_VALID (1 << 10) - #define RX_CMP_FLAGS_UNUSED (1 << 11) + #define RX_CMP_FLAGS_PKT_METADATA_PRESENT (1 << 11) #define RX_CMP_FLAGS_ITYPES_SHIFT 12 #define RX_CMP_FLAGS_ITYPES_MASK 0xf000 #define RX_CMP_FLAGS_ITYPE_UNKNOWN (0 << 12) @@ -188,6 +188,12 @@ struct rx_cmp { __le32 rx_cmp_rss_hash; }; +#define BNXT_PTP_RX_TS_VALID(flags) \ + (((flags) & RX_CMP_FLAGS_ITYPES_MASK) == RX_CMP_FLAGS_ITYPE_PTP_W_TS) + +#define BNXT_ALL_RX_TS_VALID(flags) \ + !((flags) & RX_CMP_FLAGS_PKT_METADATA_PRESENT) + #define RX_CMP_HASH_VALID(rxcmp) \ ((rxcmp)->rx_cmp_len_flags_type & cpu_to_le32(RX_CMP_FLAGS_RSS_VALID))