From patchwork Sun Aug 22 13:48:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 12451451 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=-14.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 6B28BC4338F for ; Sun, 22 Aug 2021 14:01:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4720C61207 for ; Sun, 22 Aug 2021 14:01:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232043AbhHVOCE (ORCPT ); Sun, 22 Aug 2021 10:02:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230495AbhHVOCE (ORCPT ); Sun, 22 Aug 2021 10:02:04 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FE21C061575; Sun, 22 Aug 2021 07:01:23 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id d26so1625241wrc.0; Sun, 22 Aug 2021 07:01:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Euz0E6isscBYyFQ42pM4Z2EOYe57hCAo87czLinH3tQ=; b=Ku7NYMjn9nIwgb2ynMqcuTcWBtHsvWS2W57WhgpdY7Z4cL+aUN2DyL3RcNwP9ZKoLP ibLcGD0I/IRefzks/kJyucgsHGK9S2R7cFW3jiW2uU44uXOulsd76cmwk7CyF+rILsTN ONHjh3vcoQmrwMl9tJ4YoEZJt4qJr5/Hzv48lYjX8vhmIZojU1F0hkFTXV231HJmcaMj 1CcH28LUJdpqvOxvC/ZhkJVj+au958joOU4vUS0PFAhPiPaLGxaQYyrgoe+tbKmT0GUA 9eB1RnZEjXfBmnzh9cLfkGM+TyEf06yczr9N3SSq4R7GEazFqS5fCc/lEtlcoasH7Uyf vRKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Euz0E6isscBYyFQ42pM4Z2EOYe57hCAo87czLinH3tQ=; b=lf4nr76hQ6ufSzwBAPDdUJI/j9SZOtdBBcLGKcOJl0IpPC+cW2MK6ILctwprpZnaSy aRP1Aa2WQt1U20UvqIRxd3tRkifnt554FzkD+LczqmZJTmXVWcWyus3f2sOpte54fh23 j8a5eSYpHZ5OLald1S2w9NQc30jiR2HiheC5MMlTpt4ALKK2ACS65baNgJZ4wFXhnIf9 5kn+XeOkeNVQf0QSAmNxbFdfQSM03bRzb5Lou2pa2CxuM+YlV6tCkPUZhwFftck5pM0R dGqth4s+qsM/UNnzAzOQaIb73VQPCWcH0mMhctkcS7di+dp2jVlPrOT9pNAVM2Ppy1So v0pA== X-Gm-Message-State: AOAM533rwLq3wcuLiNVU9ejFnCvoR4Y4clInvTFN8NgGdbhd3txgme7C 92gWX8UzM9f9CrFsqFdFsbCvNBseJyBTEw== X-Google-Smtp-Source: ABdhPJxsxqZLYUrdIsPO90PZWWoJEriPEnNBkC+1jahdkQlcQTd45SQhdMkwHyALbQl9HWEmfTsHlA== X-Received: by 2002:a5d:6381:: with SMTP id p1mr9133141wru.310.1629640881263; Sun, 22 Aug 2021 07:01:21 -0700 (PDT) Received: from ?IPv6:2003:ea:8f08:4500:fc53:5e22:f926:c43b? (p200300ea8f084500fc535e22f926c43b.dip0.t-ipconnect.de. [2003:ea:8f08:4500:fc53:5e22:f926:c43b]) by smtp.googlemail.com with ESMTPSA id w14sm11818452wrt.23.2021.08.22.07.01.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 22 Aug 2021 07:01:20 -0700 (PDT) Subject: [PATCH 01/12] sfc: falcon: Read VPD with pci_vpd_alloc() From: Heiner Kallweit To: Bjorn Helgaas , Edward Cree , Martin Habets , Jakub Kicinski , David Miller Cc: "linux-pci@vger.kernel.org" , SCSI development list , "netdev@vger.kernel.org" References: <1ca29408-7bc7-4da5-59c7-87893c9e0442@gmail.com> Message-ID: <2a8d069e-9516-50d8-6520-2614222c8f5f@gmail.com> Date: Sun, 22 Aug 2021 15:48:33 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <1ca29408-7bc7-4da5-59c7-87893c9e0442@gmail.com> Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This is the same as 5119e20facfa "sfc: Read VPD with pci_vpd_alloc()", just for the falcon chip version. Signed-off-by: Heiner Kallweit Reported-by: kernel test robot --- drivers/net/ethernet/sfc/falcon/efx.c | 30 +++++++++++++-------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/sfc/falcon/efx.c b/drivers/net/ethernet/sfc/falcon/efx.c index c177ea0f3..5ab1e863d 100644 --- a/drivers/net/ethernet/sfc/falcon/efx.c +++ b/drivers/net/ethernet/sfc/falcon/efx.c @@ -2780,22 +2780,18 @@ static void ef4_pci_remove(struct pci_dev *pci_dev) }; /* NIC VPD information - * Called during probe to display the part number of the - * installed NIC. VPD is potentially very large but this should - * always appear within the first 512 bytes. + * Called during probe to display the part number of the installed NIC. */ -#define SFC_VPD_LEN 512 static void ef4_probe_vpd_strings(struct ef4_nic *efx) { struct pci_dev *dev = efx->pci_dev; - char vpd_data[SFC_VPD_LEN]; - ssize_t vpd_size; int ro_start, ro_size, i, j; + unsigned int vpd_size; + u8 *vpd_data; - /* Get the vpd data from the device */ - vpd_size = pci_read_vpd(dev, 0, sizeof(vpd_data), vpd_data); - if (vpd_size <= 0) { - netif_err(efx, drv, efx->net_dev, "Unable to read VPD\n"); + vpd_data = pci_vpd_alloc(dev, &vpd_size); + if (IS_ERR(vpd_data)) { + pci_warn(dev, "Unable to read VPD\n"); return; } @@ -2803,7 +2799,7 @@ static void ef4_probe_vpd_strings(struct ef4_nic *efx) ro_start = pci_vpd_find_tag(vpd_data, vpd_size, PCI_VPD_LRDT_RO_DATA); if (ro_start < 0) { netif_err(efx, drv, efx->net_dev, "VPD Read-only not found\n"); - return; + goto out; } ro_size = pci_vpd_lrdt_size(&vpd_data[ro_start]); @@ -2816,14 +2812,14 @@ static void ef4_probe_vpd_strings(struct ef4_nic *efx) i = pci_vpd_find_info_keyword(vpd_data, i, j, "PN"); if (i < 0) { netif_err(efx, drv, efx->net_dev, "Part number not found\n"); - return; + goto out; } j = pci_vpd_info_field_size(&vpd_data[i]); i += PCI_VPD_INFO_FLD_HDR_SIZE; if (i + j > vpd_size) { netif_err(efx, drv, efx->net_dev, "Incomplete part number\n"); - return; + goto out; } netif_info(efx, drv, efx->net_dev, @@ -2834,21 +2830,23 @@ static void ef4_probe_vpd_strings(struct ef4_nic *efx) i = pci_vpd_find_info_keyword(vpd_data, i, j, "SN"); if (i < 0) { netif_err(efx, drv, efx->net_dev, "Serial number not found\n"); - return; + goto out; } j = pci_vpd_info_field_size(&vpd_data[i]); i += PCI_VPD_INFO_FLD_HDR_SIZE; if (i + j > vpd_size) { netif_err(efx, drv, efx->net_dev, "Incomplete serial number\n"); - return; + goto out; } efx->vpd_sn = kmalloc(j + 1, GFP_KERNEL); if (!efx->vpd_sn) - return; + goto out; snprintf(efx->vpd_sn, j + 1, "%s", &vpd_data[i]); +out: + kfree(vpd_data); } From patchwork Sun Aug 22 13:49:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 12451453 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=-14.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 44104C4320E for ; Sun, 22 Aug 2021 14:01:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 21E4761357 for ; Sun, 22 Aug 2021 14:01:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232471AbhHVOCG (ORCPT ); Sun, 22 Aug 2021 10:02:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232398AbhHVOCF (ORCPT ); Sun, 22 Aug 2021 10:02:05 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2744EC061575; Sun, 22 Aug 2021 07:01:24 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id w21-20020a7bc1150000b02902e69ba66ce6so9005694wmi.1; Sun, 22 Aug 2021 07:01:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=qsOp9qT56v4HmRyiUQT77z85goMAUjXgZo93KXhkEYA=; b=IyLT4e7/dWmqfV0jybUvZnJERhpUoDwkkNjo6/RnkQe5nFKxdbrwRVdXUOIazugdGp Ko+LdQy66agMlJkBzUeA99s96wAncLcTsE+MJv39+b0oP9eCXUiVb+L36XJPKEX98yFW LHKpD64cXHtWDPfsYSGQAos8eojqUTemhvqH+dpYXwfwk59ypDHzdv1ukfpatkDVgzUc OvF5A46J9/KmT4rA2B+ko8VpungezGGPX5/Tw/q6smTLH5e45wWsjM9EbvFa79kp1Zqw POz6qyrL2JyAOAtdxry28ePOv9/i/yp4DMrligMBUEudO/ROXoScEkyYzDYubTznPbdR EZDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=qsOp9qT56v4HmRyiUQT77z85goMAUjXgZo93KXhkEYA=; b=TJ3H90PkffuK9dem8WLEN7TovftMg59UYujrGyxx702bZBJdEY7qOEJVGxq0ASRl+G GIVdo1jRhLT7WGqPpZ39h04ICKs5zVZQ96LhW1WvniN+iXBWNziTQrkB/aendpD0+4ff /BI2FXHP7nS5K33/OXAJmq8kjIulNB3T45nZLHhXT3azpAkhV6Bcky7a0bNc9c394DFs sAeSppcdcnW1MpXLvigw/EoTiwc0TqMz2nW+mqGKewilBXUiQAw0PsIrR1L8GgGu+qr7 v1wGD3pbdbUbR955Pe8Ht/JB7ifikbTwIAOX6qMPgIcYPp82N/alirhRazQoldYM/+dC Rwew== X-Gm-Message-State: AOAM530nyR7bbLd41jA9Y6fQwC8f9biJ7CX15erF/9jxkI/5osnyDnAH nO9d/O/nqJDptYnhRMXWfo58lDzZVpr/yA== X-Google-Smtp-Source: ABdhPJzhl8aVEl4lGyc7HUcO/xSXSeD//dwoam8H5WTnKFFNg44w73jOrjRLo4qQmDcKz5yTFW/BzQ== X-Received: by 2002:a05:600c:3792:: with SMTP id o18mr6174780wmr.27.1629640882523; Sun, 22 Aug 2021 07:01:22 -0700 (PDT) Received: from ?IPv6:2003:ea:8f08:4500:fc53:5e22:f926:c43b? (p200300ea8f084500fc535e22f926c43b.dip0.t-ipconnect.de. [2003:ea:8f08:4500:fc53:5e22:f926:c43b]) by smtp.googlemail.com with ESMTPSA id d7sm12362542wrs.39.2021.08.22.07.01.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 22 Aug 2021 07:01:22 -0700 (PDT) Subject: [PATCH 02/12] sfc: falcon: Search VPD with pci_vpd_find_ro_info_keyword() From: Heiner Kallweit To: Bjorn Helgaas , Edward Cree , Martin Habets , Jakub Kicinski , David Miller Cc: "linux-pci@vger.kernel.org" , SCSI development list , "netdev@vger.kernel.org" References: <1ca29408-7bc7-4da5-59c7-87893c9e0442@gmail.com> Message-ID: <898282a1-13bd-17bc-2e9a-d3dcd336b46c@gmail.com> Date: Sun, 22 Aug 2021 15:49:36 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <1ca29408-7bc7-4da5-59c7-87893c9e0442@gmail.com> Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This is the same as 37838aa437c7 "sfc: Search VPD with pci_vpd_find_ro_info_keyword()", just for the falcon chip version. Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/sfc/falcon/efx.c | 65 ++++++--------------------- 1 file changed, 14 insertions(+), 51 deletions(-) diff --git a/drivers/net/ethernet/sfc/falcon/efx.c b/drivers/net/ethernet/sfc/falcon/efx.c index 5ab1e863d..423bdf812 100644 --- a/drivers/net/ethernet/sfc/falcon/efx.c +++ b/drivers/net/ethernet/sfc/falcon/efx.c @@ -2785,9 +2785,9 @@ static void ef4_pci_remove(struct pci_dev *pci_dev) static void ef4_probe_vpd_strings(struct ef4_nic *efx) { struct pci_dev *dev = efx->pci_dev; - int ro_start, ro_size, i, j; - unsigned int vpd_size; + unsigned int vpd_size, kw_len; u8 *vpd_data; + int start; vpd_data = pci_vpd_alloc(dev, &vpd_size); if (IS_ERR(vpd_data)) { @@ -2795,57 +2795,20 @@ static void ef4_probe_vpd_strings(struct ef4_nic *efx) return; } - /* Get the Read only section */ - ro_start = pci_vpd_find_tag(vpd_data, vpd_size, PCI_VPD_LRDT_RO_DATA); - if (ro_start < 0) { - netif_err(efx, drv, efx->net_dev, "VPD Read-only not found\n"); - goto out; - } - - ro_size = pci_vpd_lrdt_size(&vpd_data[ro_start]); - j = ro_size; - i = ro_start + PCI_VPD_LRDT_TAG_SIZE; - if (i + j > vpd_size) - j = vpd_size - i; - - /* Get the Part number */ - i = pci_vpd_find_info_keyword(vpd_data, i, j, "PN"); - if (i < 0) { - netif_err(efx, drv, efx->net_dev, "Part number not found\n"); - goto out; - } - - j = pci_vpd_info_field_size(&vpd_data[i]); - i += PCI_VPD_INFO_FLD_HDR_SIZE; - if (i + j > vpd_size) { - netif_err(efx, drv, efx->net_dev, "Incomplete part number\n"); - goto out; - } - - netif_info(efx, drv, efx->net_dev, - "Part Number : %.*s\n", j, &vpd_data[i]); - - i = ro_start + PCI_VPD_LRDT_TAG_SIZE; - j = ro_size; - i = pci_vpd_find_info_keyword(vpd_data, i, j, "SN"); - if (i < 0) { - netif_err(efx, drv, efx->net_dev, "Serial number not found\n"); - goto out; - } - - j = pci_vpd_info_field_size(&vpd_data[i]); - i += PCI_VPD_INFO_FLD_HDR_SIZE; - if (i + j > vpd_size) { - netif_err(efx, drv, efx->net_dev, "Incomplete serial number\n"); - goto out; - } + start = pci_vpd_find_ro_info_keyword(vpd_data, vpd_size, + PCI_VPD_RO_KEYWORD_PARTNO, &kw_len); + if (start < 0) + pci_warn(dev, "Part number not found or incomplete\n"); + else + pci_info(dev, "Part Number : %.*s\n", kw_len, vpd_data + start); - efx->vpd_sn = kmalloc(j + 1, GFP_KERNEL); - if (!efx->vpd_sn) - goto out; + start = pci_vpd_find_ro_info_keyword(vpd_data, vpd_size, + PCI_VPD_RO_KEYWORD_SERIALNO, &kw_len); + if (start < 0) + pci_warn(dev, "Serial number not found or incomplete\n"); + else + efx->vpd_sn = kmemdup_nul(vpd_data + start, kw_len, GFP_KERNEL); - snprintf(efx->vpd_sn, j + 1, "%s", &vpd_data[i]); -out: kfree(vpd_data); } From patchwork Sun Aug 22 13:50:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 12451455 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=-14.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 28C28C43214 for ; Sun, 22 Aug 2021 14:01:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1300861207 for ; Sun, 22 Aug 2021 14:01:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233155AbhHVOCJ (ORCPT ); Sun, 22 Aug 2021 10:02:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232503AbhHVOCG (ORCPT ); Sun, 22 Aug 2021 10:02:06 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F7BFC061575; Sun, 22 Aug 2021 07:01:25 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id x12so21920138wrr.11; Sun, 22 Aug 2021 07:01:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=CpBIYdrsUs68KAyEiAlWKUwUStL3DPn+RhHbfb4DLQg=; b=fA2gLRGoLtDgyz1NUzccwk5dA4tCnsI12ztmJcxdy+Fm8mBQM3oN5kDbeyyfaNyLDx lR6k7NuSmFzaIjj1MLYA+7NxpAIx2XoCik5m7D9NnRagMtnssMnfhlpD0TGWwVagMFga IBbz0tuc+3yLW5jOxra7gheaG6bkWfbGberxwzSDcGyIkMFnk1XbTC7FPn1i4pgftjVF 1JlvH0BMVcHhocrfWEf3icfXY8J7mXCnLsWMTfdlceLn3udla/09Xw3rffQsIQxhKDin 1ut9JqGiw4DzJl/bxlxTNDh20dFGCM9lTzKYwlT1q9YPREM8y1yiW8/5umok9PT6EiGe sq2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=CpBIYdrsUs68KAyEiAlWKUwUStL3DPn+RhHbfb4DLQg=; b=uGhgnbFr4n7ffWxmcomyNHKxCYUoWTsM8Lwu4LcDVwh6axXS+lAJhOUIKJxT+wJerT jczvxDfvt5wfLXhAuEMbMHord0udpGzCeP0cIcfNpdlSUI3j9Wx/94/7omkbgghU9rAE M0J9g6NEl2ZiX/FTq9EHS4cXxXhTFaQvayJQ/DDBM7fNGk8/Up2RPXYnIkrchv32QTv4 YyqySgN/GTGJ0kUlGuao0tuDZRldf2Jd2ZCdjyavYgc6sR46HXYO/5ngRiJdZsnSFss4 W1X9O0p7NfH4g64DL8RHYTMONQnyDOgcjtDeKFUnaVB9uEHfVlfLPm19mKR4/jH1DNEq i/aw== X-Gm-Message-State: AOAM533nWzeOMKlZ1VRzQmH66BTv2BG+3noDzIHAx7SgszFtLkTcB6ws kmxUajcBww6aLoZT+1HGG5EcIA5LrG/sHg== X-Google-Smtp-Source: ABdhPJyay3Lq6dztsuisnUsCmirevaSytLHSZh6xzltwhCab4KrKj6kBMHi4GfP0a/Fqrsqjuv65+g== X-Received: by 2002:a5d:51c6:: with SMTP id n6mr8852259wrv.370.1629640883695; Sun, 22 Aug 2021 07:01:23 -0700 (PDT) Received: from ?IPv6:2003:ea:8f08:4500:fc53:5e22:f926:c43b? (p200300ea8f084500fc535e22f926c43b.dip0.t-ipconnect.de. [2003:ea:8f08:4500:fc53:5e22:f926:c43b]) by smtp.googlemail.com with ESMTPSA id m16sm641870wmq.8.2021.08.22.07.01.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 22 Aug 2021 07:01:23 -0700 (PDT) Subject: [PATCH 03/12] bnx2: Search VPD with pci_vpd_find_ro_info_keyword() From: Heiner Kallweit To: Bjorn Helgaas , Rasesh Mody , GR-Linux-NIC-Dev@marvell.com, Jakub Kicinski , David Miller Cc: "linux-pci@vger.kernel.org" , SCSI development list , "netdev@vger.kernel.org" References: <1ca29408-7bc7-4da5-59c7-87893c9e0442@gmail.com> Message-ID: <7ca2b8b5-4c94-f644-1d80-b2ffb8df2d05@gmail.com> Date: Sun, 22 Aug 2021 15:50:50 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <1ca29408-7bc7-4da5-59c7-87893c9e0442@gmail.com> Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Use pci_vpd_find_ro_info_keyword() to search for keywords in VPD to simplify the code. Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/broadcom/bnx2.c | 33 +++++++--------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c index 89ee1c0e9..de1a60a95 100644 --- a/drivers/net/ethernet/broadcom/bnx2.c +++ b/drivers/net/ethernet/broadcom/bnx2.c @@ -8033,9 +8033,9 @@ bnx2_get_pci_speed(struct bnx2 *bp) static void bnx2_read_vpd_fw_ver(struct bnx2 *bp) { + unsigned int len; int rc, i, j; u8 *data; - unsigned int block_end, rosize, len; #define BNX2_VPD_NVRAM_OFFSET 0x300 #define BNX2_VPD_LEN 128 @@ -8057,38 +8057,21 @@ bnx2_read_vpd_fw_ver(struct bnx2 *bp) data[i + 3] = data[i + BNX2_VPD_LEN]; } - i = pci_vpd_find_tag(data, BNX2_VPD_LEN, PCI_VPD_LRDT_RO_DATA); - if (i < 0) - goto vpd_done; - - rosize = pci_vpd_lrdt_size(&data[i]); - i += PCI_VPD_LRDT_TAG_SIZE; - block_end = i + rosize; - - if (block_end > BNX2_VPD_LEN) - goto vpd_done; - - j = pci_vpd_find_info_keyword(data, i, rosize, - PCI_VPD_RO_KEYWORD_MFR_ID); + j = pci_vpd_find_ro_info_keyword(data, BNX2_VPD_LEN, + PCI_VPD_RO_KEYWORD_MFR_ID, &len); if (j < 0) goto vpd_done; - len = pci_vpd_info_field_size(&data[j]); - - j += PCI_VPD_INFO_FLD_HDR_SIZE; - if (j + len > block_end || len != 4 || - memcmp(&data[j], "1028", 4)) + if (len != 4 || memcmp(&data[j], "1028", 4)) goto vpd_done; - j = pci_vpd_find_info_keyword(data, i, rosize, - PCI_VPD_RO_KEYWORD_VENDOR0); + j = pci_vpd_find_ro_info_keyword(data, BNX2_VPD_LEN, + PCI_VPD_RO_KEYWORD_VENDOR0, + &len); if (j < 0) goto vpd_done; - len = pci_vpd_info_field_size(&data[j]); - - j += PCI_VPD_INFO_FLD_HDR_SIZE; - if (j + len > block_end || len > BNX2_MAX_VER_SLEN) + if (len > BNX2_MAX_VER_SLEN) goto vpd_done; memcpy(bp->fw_version, &data[j], len); From patchwork Sun Aug 22 13:52:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 12451457 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=-14.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 5130BC4338F for ; Sun, 22 Aug 2021 14:01:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 37ADB6126A for ; Sun, 22 Aug 2021 14:01:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233167AbhHVOCK (ORCPT ); Sun, 22 Aug 2021 10:02:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232791AbhHVOCH (ORCPT ); Sun, 22 Aug 2021 10:02:07 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E288C061756; Sun, 22 Aug 2021 07:01:26 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id k8so21969406wrn.3; Sun, 22 Aug 2021 07:01:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=69OYe9tROd3vXXnhUMU2DDb1J6uc6lcFtD6g0FYBe9o=; b=loDZL3yDasHCEoYfQOwAoMH6LusUl/iTl9I8gl+M2A2LUT4fnGNZ/YrngCVGP7uRdV Gattc73fzDLtCzW/jjwcEbo5HTK+guXwHIKyvlJpJb/D0hooJq0lSBk2/JGPPxlNMdH7 HwlmPZDRIp1spurh9ReQSAhc0CTiV8xQgdFalL1M1aFVrAH+LPnlgbuHLWXMDMep8v4o NjmXMrDmOhorccbXStmOpHUhv743yVZei+LfHQ2PH/3P7jPatdoMhkWnvF9d++WFchoB 2HmQTTuAOHJc5Mjajmyg5ybfSNCG4rRxwNqUlRYmTf/bYLT2YxpiX36hz9skqJ1qjv03 F7kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=69OYe9tROd3vXXnhUMU2DDb1J6uc6lcFtD6g0FYBe9o=; b=cOLqrw4p5427ZglzydQAS6ocb9dCl5RSVBTaBWW6CTtJVxyVKQbQFbylnYOPwQ1Zoo c87HPpa0dB2h4TVa2aj0vCLVfLtgQYFWuA6IVe7wARrOb93Lh6NjA9CT18sz4FSILE5o R6ExdyqA/hgORj9k1kRHFj8O09JVW2pJYugkc8wYyurtML1uJoZK0eXN7YDwEvwtE+Xg GsePWXKNnbaRvFYao2o9j5sy5zaJ5aguZjBNa069A76YuQFUgtDxkUyGVYCoXjAGxLk9 dRjwf4oPLgyvj5tSv+nnxmTc0JqWJSQziwsbw3Pd6j2RQlQrVPAjHt+xrFYVuHKhhBN+ zUlg== X-Gm-Message-State: AOAM531bb4EIvwd5I1N8Mscj06VIromdvBo+1+aK8xVrVDg6fjk9anI1 BS6+0owKPy2DPe4N6FXkt2k41sWasu4sMw== X-Google-Smtp-Source: ABdhPJyIK5Ebc6yicAPcW76i5P1gkw0vuBCxEf/WqTLVvVInH6ty65SP9yFNraKXLnfRjkfgvxYSkw== X-Received: by 2002:a5d:6483:: with SMTP id o3mr8801278wri.197.1629640884832; Sun, 22 Aug 2021 07:01:24 -0700 (PDT) Received: from ?IPv6:2003:ea:8f08:4500:fc53:5e22:f926:c43b? (p200300ea8f084500fc535e22f926c43b.dip0.t-ipconnect.de. [2003:ea:8f08:4500:fc53:5e22:f926:c43b]) by smtp.googlemail.com with ESMTPSA id o14sm12033206wrw.17.2021.08.22.07.01.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 22 Aug 2021 07:01:24 -0700 (PDT) Subject: [PATCH 04/12] bnx2: Replace open-coded version with swab32s() From: Heiner Kallweit To: Bjorn Helgaas , Rasesh Mody , GR-Linux-NIC-Dev@marvell.com, Jakub Kicinski , David Miller Cc: "linux-pci@vger.kernel.org" , SCSI development list , "netdev@vger.kernel.org" References: <1ca29408-7bc7-4da5-59c7-87893c9e0442@gmail.com> Message-ID: Date: Sun, 22 Aug 2021 15:52:01 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <1ca29408-7bc7-4da5-59c7-87893c9e0442@gmail.com> Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Use swab32s() instead of open-coding it. Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/broadcom/bnx2.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c index de1a60a95..599fc1436 100644 --- a/drivers/net/ethernet/broadcom/bnx2.c +++ b/drivers/net/ethernet/broadcom/bnx2.c @@ -8041,21 +8041,16 @@ bnx2_read_vpd_fw_ver(struct bnx2 *bp) #define BNX2_VPD_LEN 128 #define BNX2_MAX_VER_SLEN 30 - data = kmalloc(256, GFP_KERNEL); + data = kmalloc(BNX2_VPD_LEN, GFP_KERNEL); if (!data) return; - rc = bnx2_nvram_read(bp, BNX2_VPD_NVRAM_OFFSET, data + BNX2_VPD_LEN, - BNX2_VPD_LEN); + rc = bnx2_nvram_read(bp, BNX2_VPD_NVRAM_OFFSET, data, BNX2_VPD_LEN); if (rc) goto vpd_done; - for (i = 0; i < BNX2_VPD_LEN; i += 4) { - data[i] = data[i + BNX2_VPD_LEN + 3]; - data[i + 1] = data[i + BNX2_VPD_LEN + 2]; - data[i + 2] = data[i + BNX2_VPD_LEN + 1]; - data[i + 3] = data[i + BNX2_VPD_LEN]; - } + for (i = 0; i < BNX2_VPD_LEN; i += 4) + swab32s((u32 *)&data[i]); j = pci_vpd_find_ro_info_keyword(data, BNX2_VPD_LEN, PCI_VPD_RO_KEYWORD_MFR_ID, &len); From patchwork Sun Aug 22 14:01:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 12451459 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=-14.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 C49EDC4320A for ; Sun, 22 Aug 2021 14:01:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B145961207 for ; Sun, 22 Aug 2021 14:01:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233485AbhHVOCg (ORCPT ); Sun, 22 Aug 2021 10:02:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233244AbhHVOCX (ORCPT ); Sun, 22 Aug 2021 10:02:23 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95FEFC0613A4; Sun, 22 Aug 2021 07:01:36 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id j14-20020a1c230e000000b002e748b9a48bso648127wmj.0; Sun, 22 Aug 2021 07:01:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=cPtBI3PPGT+heXyTSOuBF8IkDPXmrhhweQDoLCyexsc=; b=uVg9Sku+7jGd+hrHzOD4hcHcYfiKMNT22+2nhv+9ANAVaMxiRnoh6YNMKgCBI0tuTv x12IcIENjQiQ3TClltNoBhp5A2koeXlVbvBmfTTIiQrAhL5yicxCcJYIgdEenlgy2SKD B88fr9VHJ6W8eLEQFUT8zJaWlLIZKjc/L5Ccr2EBIG0tTOeXBPnNxypB5SlMhaGqk/2k 7/k4VEs0CGpq6vaJEJjjOIJ9PMNxRPV7V6YZWFKx5Kov58O8M0PZpweW3PYy5hiPiJbO cjpIkrQOZ8k2lSVcyRMP7fUu4rEXnMQ32iobbn6PZWaJx9YonRaOFuN1p4Pxbmv0aauD GfOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=cPtBI3PPGT+heXyTSOuBF8IkDPXmrhhweQDoLCyexsc=; b=SBJhUA5QYrdfaBC2u8hRAXO0hJNq66nB1ohN82N9wx4Kz6mPfrF0FHLkwpVLTFXSXN zaC4Yb1+tUf8et71DrcSRuNlEef8kbJGP1ia4eGdWr95xqGHYbHUdQMliSn7xIfcotcF tkhTzfIpxdy4vyxOYDkEU+vHjjMOnrku8iI39M8Q3N9S+FdeKOYx+8WnwGOBZ5CPeii/ rCtRDJ9MsqF3ABu/k2ZzoIO7dVfz4f1CVrmjIUzfGo/TGUgrlEnY2SLIvf3rNB0XBubm X7Je+2L4ZEw6L+7Cz0zAqQlY1lN/ObDhPIwt8fKg2i1eRcYp70b7LL3CzrL5/lVGhY8R b3wQ== X-Gm-Message-State: AOAM533mje3hUtr4WRZwQYmkhkkriXzkSEeFCvCvWoh4sESk2lItGlI9 YZMRhpYnl9Ktx7FjTMoUDewJVyH57TMVpw== X-Google-Smtp-Source: ABdhPJw7D1EYz8upsbDaCCTTIx2ihJoyPOIdRANdv35WHlosxJ2aoQY2Wb4ZnNUPQDUrFnaIj0IXgg== X-Received: by 2002:a05:600c:35d2:: with SMTP id r18mr12354668wmq.116.1629640894947; Sun, 22 Aug 2021 07:01:34 -0700 (PDT) Received: from ?IPv6:2003:ea:8f08:4500:fc53:5e22:f926:c43b? (p200300ea8f084500fc535e22f926c43b.dip0.t-ipconnect.de. [2003:ea:8f08:4500:fc53:5e22:f926:c43b]) by smtp.googlemail.com with ESMTPSA id o14sm12033580wrw.17.2021.08.22.07.01.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 22 Aug 2021 07:01:34 -0700 (PDT) Subject: [PATCH 12/12] scsi: cxlflash: Search VPD with pci_vpd_find_ro_info_keyword() From: Heiner Kallweit To: Bjorn Helgaas , "Manoj N. Kumar" , "Matthew R. Ochs" , Uma Krishnan , "James E.J. Bottomley" , "Martin K. Petersen" Cc: "linux-pci@vger.kernel.org" , SCSI development list References: <1ca29408-7bc7-4da5-59c7-87893c9e0442@gmail.com> Message-ID: Date: Sun, 22 Aug 2021 16:01:08 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <1ca29408-7bc7-4da5-59c7-87893c9e0442@gmail.com> Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Use pci_vpd_find_ro_info_keyword() to search for keywords in VPD to simplify the code. Signed-off-by: Heiner Kallweit --- drivers/scsi/cxlflash/main.c | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index 2f1894588..b2730e859 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -1629,8 +1629,8 @@ static int read_vpd(struct cxlflash_cfg *cfg, u64 wwpn[]) { struct device *dev = &cfg->dev->dev; struct pci_dev *pdev = cfg->dev; - int rc = 0; - int ro_start, ro_size, i, j, k; + int i, k, rc = 0; + unsigned int kw_size; ssize_t vpd_size; char vpd_data[CXLFLASH_VPD_LEN]; char tmp_buf[WWPN_BUF_LEN] = { 0 }; @@ -1648,24 +1648,6 @@ static int read_vpd(struct cxlflash_cfg *cfg, u64 wwpn[]) goto out; } - /* Get the read only section offset */ - ro_start = pci_vpd_find_tag(vpd_data, vpd_size, PCI_VPD_LRDT_RO_DATA); - if (unlikely(ro_start < 0)) { - dev_err(dev, "%s: VPD Read-only data not found\n", __func__); - rc = -ENODEV; - goto out; - } - - /* Get the read only section size, cap when extends beyond read VPD */ - ro_size = pci_vpd_lrdt_size(&vpd_data[ro_start]); - j = ro_size; - i = ro_start + PCI_VPD_LRDT_TAG_SIZE; - if (unlikely((i + j) > vpd_size)) { - dev_dbg(dev, "%s: Might need to read more VPD (%d > %ld)\n", - __func__, (i + j), vpd_size); - ro_size = vpd_size - i; - } - /* * Find the offset of the WWPN tag within the read only * VPD data and validate the found field (partials are @@ -1681,11 +1663,9 @@ static int read_vpd(struct cxlflash_cfg *cfg, u64 wwpn[]) * ports programmed and operate in an undefined state. */ for (k = 0; k < cfg->num_fc_ports; k++) { - j = ro_size; - i = ro_start + PCI_VPD_LRDT_TAG_SIZE; - - i = pci_vpd_find_info_keyword(vpd_data, i, j, wwpn_vpd_tags[k]); - if (i < 0) { + i = pci_vpd_find_ro_info_keyword(vpd_data, vpd_size, + wwpn_vpd_tags[k], &kw_size); + if (i == -ENOENT) { if (wwpn_vpd_required) dev_err(dev, "%s: Port %d WWPN not found\n", __func__, k); @@ -1693,9 +1673,7 @@ static int read_vpd(struct cxlflash_cfg *cfg, u64 wwpn[]) continue; } - j = pci_vpd_info_field_size(&vpd_data[i]); - i += PCI_VPD_INFO_FLD_HDR_SIZE; - if (unlikely((i + j > vpd_size) || (j != WWPN_LEN))) { + if (i < 0 || kw_size != WWPN_LEN) { dev_err(dev, "%s: Port %d WWPN incomplete or bad VPD\n", __func__, k); rc = -ENODEV;