From patchwork Mon Nov 16 00:27:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 325176 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_HEADER_CTYPE_ONLY, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, T_TVD_MIME_NO_HEADERS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A1F0C63697 for ; Mon, 16 Nov 2020 00:28:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F200622314 for ; Mon, 16 Nov 2020 00:28:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="SadjDcwA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728160AbgKPA2N (ORCPT ); Sun, 15 Nov 2020 19:28:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726311AbgKPA2M (ORCPT ); Sun, 15 Nov 2020 19:28:12 -0500 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 50295C0613CF for ; Sun, 15 Nov 2020 16:28:12 -0800 (PST) Received: by mail-pf1-x42a.google.com with SMTP id 131so1454792pfb.9 for ; Sun, 15 Nov 2020 16:28:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6rPe1iq7+fcLr9VBmsv3jn5BZ44p0yB9+/X5hPyBzIo=; b=SadjDcwADYRK5IZFsAVcAItSo8LlEk0K3GIyIVfmM5Uj+gFXFnmWthk6uUluTDRmce SXwmz6SgMTS03JUh4HsXFKogsI/WUK0id2aQFAbI1SiNzTqVaJD8cdTmHbE+/Jp0JgoG CT9f7hUCC+FbdJmnsUAOieWkfS0OxCE504VV8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6rPe1iq7+fcLr9VBmsv3jn5BZ44p0yB9+/X5hPyBzIo=; b=Y7PTn+bEYbqZRP1j4D6JKuByZjNqS3RfxcjtgW1URnLhekXkjPll6mrymgRuPzYtZO tN9TfLo1p8xT1D635YoEURENfYXyvwitljnGHFCZ+0uB9krjK/VPgeWch9zhE6EkWfi5 agan14lvBhyNXs42cO/Pxfp8ExOIClaufKwcEZtPcHjtR8osvFJ+tQgV21iN0JJU8fVA 9nD+DmGOhhYz1ey8EDAV6f6PBGE2g4hK4NC+FHfzW4J01TcFgFwS51w43e7P7K79q81W FGM3HnnD0yMc92yzaqn+4PaoREGbWRSP5KptpXobId6gq691TRv7hSHWp3zflS6RBAKV xl5Q== X-Gm-Message-State: AOAM533d0aYImLMZCZ+BSYAL3SRrmY56tKg4TGlRVHPeR1kGLkE4By33 +wyZC9qSeoTxmBFbJGYFMRwM/vmAeZjyCw== X-Google-Smtp-Source: ABdhPJy6axevHbK/ZUVkylS6spqU8S0yQcAXodhtWYOJh0dfmzHIWM8jKoQl5uK3EoRtfBq1fWALHQ== X-Received: by 2002:a62:db03:0:b029:196:45d6:9bb3 with SMTP id f3-20020a62db030000b029019645d69bb3mr3460203pfg.74.1605486491604; Sun, 15 Nov 2020 16:28:11 -0800 (PST) Received: from localhost.swdvt.lab.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id i19sm2942563pgk.44.2020.11.15.16.28.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Nov 2020 16:28:11 -0800 (PST) From: Michael Chan To: kuba@kernel.org Cc: netdev@vger.kernel.org, gospo@broadcom.com Subject: [PATCH net 1/4] bnxt_en: read EEPROM A2h address using page 0 Date: Sun, 15 Nov 2020 19:27:49 -0500 Message-Id: <1605486472-28156-2-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1605486472-28156-1-git-send-email-michael.chan@broadcom.com> References: <1605486472-28156-1-git-send-email-michael.chan@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Edwin Peer The module eeprom address range returned by bnxt_get_module_eeprom() should be 256 bytes of A0h address space, the lower half of the A2h address space, and page 0 for the upper half of the A2h address space. Fix the firmware call by passing page_number 0 for the A2h slave address space. Fixes: 42ee18fe4ca2 ("bnxt_en: Add Support for ETHTOOL_GMODULEINFO and ETHTOOL_GMODULEEEPRO") Signed-off-by: Edwin Peer Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 53687bc7fcf5..f133ea5674cb 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -2997,7 +2997,7 @@ static int bnxt_get_module_eeprom(struct net_device *dev, /* Read A2 portion of the EEPROM */ if (length) { start -= ETH_MODULE_SFF_8436_LEN; - rc = bnxt_read_sfp_module_eeprom_info(bp, I2C_DEV_ADDR_A2, 1, + rc = bnxt_read_sfp_module_eeprom_info(bp, I2C_DEV_ADDR_A2, 0, start, length, data); } return rc; From patchwork Mon Nov 16 00:27:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 325175 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_HEADER_CTYPE_ONLY, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, T_TVD_MIME_NO_HEADERS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05A40C63699 for ; Mon, 16 Nov 2020 00:28:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7AB7522314 for ; Mon, 16 Nov 2020 00:28:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="AYUqGN7x" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728262AbgKPA2T (ORCPT ); Sun, 15 Nov 2020 19:28:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726311AbgKPA2S (ORCPT ); Sun, 15 Nov 2020 19:28:18 -0500 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47DB3C0613CF for ; Sun, 15 Nov 2020 16:28:18 -0800 (PST) Received: by mail-pg1-x541.google.com with SMTP id j19so4605883pgg.5 for ; Sun, 15 Nov 2020 16:28:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ay7zhmBkaHC5Ra+dBoVCVWdhN2ITDGmxmdv79eXwAgE=; b=AYUqGN7xNocwgnOwvymhC1iT3Cz1qCr7v9sl/J/fLYaiFdKhCEhyCYAr+B1y1Ki+hW DMCs3dc9/1+Oyazuu640E3p3g0qi2rZvP6xbbaloD9hF87mVAwmhFChnIARCVHjBjr4b 1tPvMZGVPA9EWEUuGR98btJUYk2dPmubuSVXQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ay7zhmBkaHC5Ra+dBoVCVWdhN2ITDGmxmdv79eXwAgE=; b=KLz0JT9hNT9kmcGvs4dCrCiW9kmN2xaTXoPya0oFVLYJtsUJIWC1lmiFna1oJgXZrr Bwt8a/DXYpqsA9MwODJka3v1PpbHpeY2DHKcSW4IaYqeDIQraGEq5oBJpg4pYXdouG1z IsCCcFwtuC60fxI+ruUA9RFCLlmyPH89WyeL69NZIsnEwMQD0/U4yXOtZZh38FM7R2/w 6qYNyF2rSbZdXzUr+l7RlaFCC3P8paXnfyrMv/VYTMxMU+hI5ZQc8HNusupmJ7Ia9zfY h+Xc4115xg4wTj6AukKoH1wv/IczoqERbuUN//8OKcHfeB90FzfpfMdGIEmfe7z71G6u zsVQ== X-Gm-Message-State: AOAM530hEjldI+530MAiNIxVS+nwajfk2Dox4z1Zkg0pmyGl3eMFUiuc svVJ3j3tfBM2liCqMFuqUD3GWvPoM83Zag== X-Google-Smtp-Source: ABdhPJxRsVJmovsamKluv3durcCbKYX/i1N9dz6LMWfraqLLD/h4MgFRjXr9tlgyK7xizDsx0Juc+Q== X-Received: by 2002:a17:90b:1642:: with SMTP id il2mr12094688pjb.81.1605486497601; Sun, 15 Nov 2020 16:28:17 -0800 (PST) Received: from localhost.swdvt.lab.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id i19sm2942563pgk.44.2020.11.15.16.28.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Nov 2020 16:28:17 -0800 (PST) From: Michael Chan To: kuba@kernel.org Cc: netdev@vger.kernel.org, gospo@broadcom.com Subject: [PATCH net 3/4] bnxt_en: Fix counter overflow logic. Date: Sun, 15 Nov 2020 19:27:51 -0500 Message-Id: <1605486472-28156-4-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1605486472-28156-1-git-send-email-michael.chan@broadcom.com> References: <1605486472-28156-1-git-send-email-michael.chan@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org bnxt_add_one_ctr() adds a hardware counter to a software counter and adjusts for the hardware counter wraparound against the mask. The logic assumes that the hardware counter is always smaller than or equal to the mask. This assumption is mostly correct. But in some cases if the firmware is older and does not provide the accurate mask, the driver can use a mask that is smaller than the actual hardware mask. This can cause some extra carry bits to be added to the software counter, resulting in counters that far exceed the actual value. Fix it by masking the hardware counter with the mask passed into bnxt_add_one_ctr(). Fixes: fea6b3335527 ("bnxt_en: Accumulate all counters.") Reviewed-by: Vasundhara Volam Reviewed-by: Pavan Chebbi Reviewed-by: Edwin Peer Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 448e1ba762ee..7c21aaa8b9af 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -7758,6 +7758,7 @@ static void bnxt_add_one_ctr(u64 hw, u64 *sw, u64 mask) { u64 sw_tmp; + hw &= mask; sw_tmp = (*sw & ~mask) | hw; if (hw < (*sw & mask)) sw_tmp += mask + 1;