From patchwork Tue Dec 5 23:44:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13480873 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="D4i3uEp4" Received: from mail-qk1-x735.google.com (mail-qk1-x735.google.com [IPv6:2607:f8b0:4864:20::735]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B62AD122 for ; Tue, 5 Dec 2023 15:44:27 -0800 (PST) Received: by mail-qk1-x735.google.com with SMTP id af79cd13be357-77f0b3f1618so157475085a.0 for ; Tue, 05 Dec 2023 15:44:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1701819867; x=1702424667; 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=B8+UIis1C5FIRofcy9HcTllt1lZGjE1cFQ9qpFZJGBk=; b=D4i3uEp4lwtoReJw9K3fLmzPqNwAGr9tol/mtf2oJkx4wPXVRMlPy7yZrb4Y6aSoAX HpZGnurHFFU3OuKuh7AQKfw7DCWy2fVNoaiEWjks8kVVx0q+s3CZC/7nE4vbams/zt9I AEaNjQObroYNKQWq0FbSFS4vKOwNO+xi5R1DI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701819867; x=1702424667; 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=B8+UIis1C5FIRofcy9HcTllt1lZGjE1cFQ9qpFZJGBk=; b=NB1iBCO2U3I+/DMRRYb/1XsAelbKwF0ytRK3n3eKKQGSnIRJMWUlLhRIRi+00mRklt 1QzECIl27P8/Qc8fLlCzQNNkkw0fEhm9HpKCSLJKj87OxagRRihu9dIMRRZOnMhcZOlL MB9kke/srP6zzAKSMqH78FnFvrd3Gpz1ErmhE5bwPQSWtm9U08pEaChxQ1grKGeBT+QD mGWYyfTPFgATaRP0mzMci3YR3/7ffx4+7zMb2hdNWFgiyfHr/13l6MIJInWazvPc+L+H m6Aas+wPgBK4eS1z/lk9kfB8PYAnkA6gK+qI+bDv9yp/d5fVi/DqTbjE76oskeQZh0cp QLYA== X-Gm-Message-State: AOJu0YwYvCZU2i/1tVPKdWJcqQA3e7oou/BLtELYNzHNeiOTzTYoPa5p 9PVg8Lr9MfqJKw0xouAwgiEtMA== X-Google-Smtp-Source: AGHT+IGziAF7ABxS7rE9xBOjsevHQOeFca1H0gE+Kw+AA7qjF0UuA0sRTyjJOpWlynhpodjgKSi8KA== X-Received: by 2002:a05:620a:3724:b0:77b:dd1d:2afb with SMTP id de36-20020a05620a372400b0077bdd1d2afbmr37128qkb.65.1701819866357; Tue, 05 Dec 2023 15:44:26 -0800 (PST) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id y15-20020a37e30f000000b007788bb0ab8esm5450429qki.19.2023.12.05.15.44.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Dec 2023 15:44: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, Somnath Kotur , Kalesh AP , Ajit Khaparde , Andy Gospodarek , Michael Chan Subject: [PATCH net 1/4] bnxt_en: Clear resource reservation during resume Date: Tue, 5 Dec 2023 15:44:01 -0800 Message-Id: <20231205234404.17501-2-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20231205234404.17501-1-michael.chan@broadcom.com> References: <20231205234404.17501-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: b4c66425771d ("bnxt_en: refactor bnxt_cancel_reservations()") Reviewed-by: Kalesh AP Reviewed-by: Ajit Khaparde Reviewed-by: Andy Gospodarek Signed-off-by: Somnath Kotur Signed-off-by: Michael Chan --- 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 Tue Dec 5 23:44:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13480874 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="HLZE+tSw" Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 816ED18B for ; Tue, 5 Dec 2023 15:44:29 -0800 (PST) Received: by mail-qk1-x730.google.com with SMTP id af79cd13be357-77d6b28aa9aso417415485a.3 for ; Tue, 05 Dec 2023 15:44:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1701819868; x=1702424668; 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=3v7nQAZ/o1oMxvh2SOa6aPUCXJcA8Pml3tMPIXUrIlk=; b=HLZE+tSw3z4jol7w9CWO6cJYFn1m2NF6adOGY2R2mdhlvixcVNMCYZczaL4lnilC2F VIxYBbUWEmRinumw/ZN2RMH18GNrtFllSWmxCGM1Gnb4DWBUnFBw3mdCaZi3fTIetzvI BjUdg03X2flIfJQ6nxV3eAxfj3nXKwMWSxTxU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701819868; x=1702424668; 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=3v7nQAZ/o1oMxvh2SOa6aPUCXJcA8Pml3tMPIXUrIlk=; b=Vm0/3e2o0jZbazm7VxCqmxN2YrFumhXsQpIY6QuzUblwkGBihCybl6ic9YmZAwj0zw RfiQFy0jgxzbeU6BqoiKUmSwhrnWMuOg4HOBUrNsKo6iPHRv2NqXt9u+51QpBg493C/6 wccLhsObvuw1vquYtLbbx2eIreo+urFUhtlrn0OJv/GLdLQv7KiWxgy4/3LG9XDpAzlL ddW9JttjwD4+WPj4JnyZQFeImcQub4mOA6LKE9dOOl0ExP5pNpbbDzEHqPw+yefgZ3zh MX9I0qXM2iMfeeZ9m13qh8sxK2a6HcNJLkPhiKfU76jMQYEzEBZgzku4faNveYaqxw/q llxQ== X-Gm-Message-State: AOJu0Yx/l87E95J3uXau7R88AbnazZYjjhpLXY1BZvPsJnqCLSJP4BRM oKdZgD/8hg2zIWYnmy5bbR+Pqg== X-Google-Smtp-Source: AGHT+IE3AEZa0WV3P/5uVm+s0T9ygp/kY5lhS4rgqO8AzMR9AjgZSn+lMZ5ZWjX5firQAqBFzKZIRQ== X-Received: by 2002:a05:620a:3951:b0:76d:2725:f36f with SMTP id qs17-20020a05620a395100b0076d2725f36fmr61966qkn.71.1701819868156; Tue, 05 Dec 2023 15:44:28 -0800 (PST) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id y15-20020a37e30f000000b007788bb0ab8esm5450429qki.19.2023.12.05.15.44.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Dec 2023 15:44: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, Sreekanth Reddy , Somnath Kotur , Andy Gospodarek , Vikas Gupta Subject: [PATCH net 2/4] bnxt_en: Fix skb recycling logic in bnxt_deliver_skb() Date: Tue, 5 Dec 2023 15:44:02 -0800 Message-Id: <20231205234404.17501-3-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20231205234404.17501-1-michael.chan@broadcom.com> References: <20231205234404.17501-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 Tue Dec 5 23:44:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13480875 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="GhkdEygR" Received: from mail-qk1-x732.google.com (mail-qk1-x732.google.com [IPv6:2607:f8b0:4864:20::732]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F4015122 for ; Tue, 5 Dec 2023 15:44:30 -0800 (PST) Received: by mail-qk1-x732.google.com with SMTP id af79cd13be357-77dc38b4e8dso389575085a.1 for ; Tue, 05 Dec 2023 15:44:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1701819870; x=1702424670; 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=BVUP3329gDTZt2+fwubl676AsKn766XC9PIt3X96WHY=; b=GhkdEygRp9IbaXE/qK1lOrsJM9VHFYILWYnnB5lSLjwbn5y/IFH5bDy5GfTcsGJjgf qTLWnUOBDi4aWlRNIWr00U0UJd5fGA+kSguiAD6QvPH9ID0PjUAW7Bld5nnu1XTCVimb tLo6EsNdDA2tVPs0XYnVrk6PF5+YFUdaDlnV8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701819870; x=1702424670; 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=BVUP3329gDTZt2+fwubl676AsKn766XC9PIt3X96WHY=; b=VIRZicypSHfg504Oe5R4spwKvfS9iWAg34Pcj1z3S7Ct3ICHKl0DBPpBWJqcwN8Sce k4mUArfl4uMBAqxnqvvZ+cI9/ZhYJt96ZpACyDtIgNzPs58Dq7KP7suABz/GT/a7+v6H gJgiaKskt73vzs0eeGlL2LPgPJ2+MGzGrm1TA/51N6BlsQsh8NtWslNlejTT8x0jbziZ VGJ0Qtrfac8769eMqPW0QsB3CKgo0hXYsplEiGld97ypFl13DB6tS3SHul9sR+OfgflG vfAVaqe+LdBbOcglyc0BAKS8ykdaycvgquqosJLM0+ZfHUWdmljXP7U83++V3A5C0pAo JEJg== X-Gm-Message-State: AOJu0Yy2Hn95NbRbtYRg8NI4MM+xOGSNqMv4IO9WpYwQjSrvHQ/7vNam 9MBr0kWuRth+XQKEfhrjjzsQmdLcQA3L8mxeR8U= X-Google-Smtp-Source: AGHT+IHTC42IcgQQZgQbi0I0XjsvZ+aeGjtc6bj5lgymEF9L8LuyguDT2uZeVAdIDoQbtQy4kCXNOA== X-Received: by 2002:a05:620a:120a:b0:77d:99a2:7450 with SMTP id u10-20020a05620a120a00b0077d99a27450mr65578qkj.28.1701819869848; Tue, 05 Dec 2023 15:44:29 -0800 (PST) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id y15-20020a37e30f000000b007788bb0ab8esm5450429qki.19.2023.12.05.15.44.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Dec 2023 15:44:29 -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 , Vikas Gupta , Somnath Kotur Subject: [PATCH net 3/4] bnxt_en: Fix wrong return value check in bnxt_close_nic() Date: Tue, 5 Dec 2023 15:44:03 -0800 Message-Id: <20231205234404.17501-4-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20231205234404.17501-1-michael.chan@broadcom.com> References: <20231205234404.17501-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. Fixes: c0c050c58d84 ("bnxt_en: New Broadcom ethernet driver.") Reviewed-by: Vikas Gupta Reviewed-by: Somnath Kotur Signed-off-by: Kalesh AP --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index b4a5311bdeb5..16b7cf6b01a4 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -10753,7 +10753,7 @@ int bnxt_close_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init) rc = wait_event_interruptible_timeout(bp->sriov_cfg_wait, !bp->sriov_cfg, BNXT_SRIOV_CFG_WAIT_TMO); - if (rc) + if (!rc) netdev_warn(bp->dev, "timeout waiting for SRIOV config operation to complete!\n"); } #endif From patchwork Tue Dec 5 23:44:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13480876 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="M8H3jtUv" Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7250518F for ; Tue, 5 Dec 2023 15:44:32 -0800 (PST) Received: by mail-oi1-x22e.google.com with SMTP id 5614622812f47-3b8b0b75445so2985857b6e.1 for ; Tue, 05 Dec 2023 15:44:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1701819872; x=1702424672; 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=hW8MgRradIV0Ywg57qCnG0TDgOYGr7awXQnEN+WL/k4=; b=M8H3jtUvpwHrAPQ6yAXjXgQkrpLTQVclZh87aIJN1ixy5lel1swBmfGl5Xs+qGLJ6o p4dYH4hxlPqUrGnbDRNr4g2oWzP6ol+BMgX3pGQ2+/EkG4dZ/fdI1iFsfrTZJcfHV6Vm 3kYhPjNVNIhSK/lT09BJFI4uevS2z/eCh9CWA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701819872; x=1702424672; 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=hW8MgRradIV0Ywg57qCnG0TDgOYGr7awXQnEN+WL/k4=; b=FTlrpvlHBstBxN2znOu50+AAVyGY/DXoDKnVxuS0cGc8HXDp8XRh6Cvq1N+kfoykt1 WuHGC1YU2A6quBZohM3r+cDjAW0eF4pWPNMkdAdeDpau+W3ZyXPJPoaDSbEiaFgkpyeV +uqP7mrHdet8ZI8/7ls5rCeYctZbzdmvQmOBQkOFwOBiAuPY6+DkqfzV1tyDzwLiPBMX T4kCe3SBkVs2kuP6dYmcoRnZAbUUdPlvmEqf3wHVX7lIE5OBrRyO4/MpJtJmj1gR+WW4 TNLAqoPUnvKBAwz/qectMZDCqg0yfDeZ9u070I43d9o4Glg/+nmvOF8RpaYZgE7UkBpa HC3g== X-Gm-Message-State: AOJu0Yy07wIQ05EYI1TTr8Z/bRQtqDdNpPmdlcTdt4M1KSR2i5crOV94 oONIO0De4vHH7uGhfLerzJnT1Q== X-Google-Smtp-Source: AGHT+IEIk4lcAK1oYzKM3DrZrBmVkMQ4k7v4goz89KJtd5rcw7kK0t/c6G4cl7W5r5qlu+Dk6pmGmQ== X-Received: by 2002:a05:6808:1401:b0:3b5:6599:ce4c with SMTP id w1-20020a056808140100b003b56599ce4cmr56161oiv.57.1701819871547; Tue, 05 Dec 2023 15:44:31 -0800 (PST) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id y15-20020a37e30f000000b007788bb0ab8esm5450429qki.19.2023.12.05.15.44.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Dec 2023 15:44:30 -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 4/4] bnxt_en: Fix HWTSTAMP_FILTER_ALL packet timestamp logic Date: Tue, 5 Dec 2023 15:44:04 -0800 Message-Id: <20231205234404.17501-5-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20231205234404.17501-1-michael.chan@broadcom.com> References: <20231205234404.17501-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 16b7cf6b01a4..55ac281a9b06 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 e702dbc3e6b1..5b570058e1c9 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))