From patchwork Wed Sep 28 00:58:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 12991532 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 4D5F3C07E9D for ; Wed, 28 Sep 2022 00:59:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231956AbiI1A7a (ORCPT ); Tue, 27 Sep 2022 20:59:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232160AbiI1A70 (ORCPT ); Tue, 27 Sep 2022 20:59:26 -0400 Received: from mail-qv1-xf34.google.com (mail-qv1-xf34.google.com [IPv6:2607:f8b0:4864:20::f34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54523145C9E for ; Tue, 27 Sep 2022 17:59:18 -0700 (PDT) Received: by mail-qv1-xf34.google.com with SMTP id m18so1553905qvo.12 for ; Tue, 27 Sep 2022 17:59:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date; bh=Jqre7UhNBJ37BjZRGQKkWEW/PpKIQbfiwLd1B/ywfoo=; b=EoOMN607QRu3IpSVmMDvODv7uAsH8aeb5ZTFkStAlDGJaEawMqWZOxN3Hdy1pXdlag plw4sDp2tU9z/C9IKTiO/r7XD1XrJnNr+nWo3VA0cXPv3uLSYanS7aslw2UXMe2uy8WZ kbaS2pHnzxTgbuAH7vWG5P5u28aGicuDQcxbQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date; bh=Jqre7UhNBJ37BjZRGQKkWEW/PpKIQbfiwLd1B/ywfoo=; b=bKbA+emB76wYXqrOuXVcfpLWR76Lzzu/DV5pojJDFdJ5FcKeZ2kXaQJ9+lvNTMZpqA 0EwQKz/8hccdvs3ytMm4Ogz3SL3jwotw7/62pFtpLFu+8/QH1Fw5sSEskheX+CDnNIPN v4Fc+Lye1aaI9E1szRnmuK1kc7fSA+LfJJBMFWsduGZYw27bIk+AX89ZX+bPVHVnjc3B NENJwip9saKctpk40kM/81U/BymdtvUT3q4j59MQ7hPGSYsrFPfenRmwr2aDXC69rwRV t88FD9+TOP6j3wteGli11wEhBlaSP1uzAO0dWXELCw9dNzQW8XDP9bpUrBJCPhurd983 r/9Q== X-Gm-Message-State: ACrzQf22SdqLwhmuSLlSvJgxoKaVG0ScLzJeBZI/dIoSSm+/kccsWrqy hedzmAOlUHrcW79NYAwCO8ZE4A== X-Google-Smtp-Source: AMsMyM6qdJUeYOvz96Imbt00MEuXd/cQu917Rm91b+ti1o09mSLMg98MV0b0470YGxUfcw7HwKUkRA== X-Received: by 2002:a05:6214:20e5:b0:4aa:b01f:471f with SMTP id 5-20020a05621420e500b004aab01f471fmr23729401qvk.38.1664326757161; Tue, 27 Sep 2022 17:59:17 -0700 (PDT) Received: from localhost.swdvt.lab.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id i11-20020a05620a248b00b006cbb8ca04f8sm2078668qkn.40.2022.09.27.17.59.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Sep 2022 17:59:16 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, kuba@kernel.org, edumazet@google.com, pabeni@redhat.com, gospo@broadcom.com, vikas.gupta@broadcom.com Subject: [PATCH net-next 4/6] bnxt_en: Refactor bnxt_get_module_info() Date: Tue, 27 Sep 2022 20:58:42 -0400 Message-Id: <1664326724-1415-5-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1664326724-1415-1-git-send-email-michael.chan@broadcom.com> References: <1664326724-1415-1-git-send-email-michael.chan@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Vikas Gupta Add bnxt_module_status_check() helper to check if we can proceed to read module eeprom data. This helper will be used in the next patch when adding get_module_eeprom_by_page(). Signed-off-by: Vikas Gupta Signed-off-by: Michael Chan --- .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 1c8a92fa2f2c..379afa670494 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -3184,25 +3184,34 @@ static int bnxt_read_sfp_module_eeprom_info(struct bnxt *bp, u16 i2c_addr, return rc; } -static int bnxt_get_module_info(struct net_device *dev, - struct ethtool_modinfo *modinfo) +static int bnxt_module_status_check(struct bnxt *bp) { - u8 data[SFF_DIAG_SUPPORT_OFFSET + 1]; - struct bnxt *bp = netdev_priv(dev); - int rc; - /* No point in going further if phy status indicates * module is not inserted or if it is powered down or * if it is of type 10GBase-T */ if (bp->link_info.module_status > - PORT_PHY_QCFG_RESP_MODULE_STATUS_WARNINGMSG) + PORT_PHY_QCFG_RESP_MODULE_STATUS_WARNINGMSG) return -EOPNOTSUPP; /* This feature is not supported in older firmware versions */ if (bp->hwrm_spec_code < 0x10202) return -EOPNOTSUPP; + return 0; +} + +static int bnxt_get_module_info(struct net_device *dev, + struct ethtool_modinfo *modinfo) +{ + u8 data[SFF_DIAG_SUPPORT_OFFSET + 1]; + struct bnxt *bp = netdev_priv(dev); + int rc; + + rc = bnxt_module_status_check(bp); + if (rc) + return rc; + rc = bnxt_read_sfp_module_eeprom_info(bp, I2C_DEV_ADDR_A0, 0, 0, false, 0, SFF_DIAG_SUPPORT_OFFSET + 1, data);