get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/1253343/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 1253343,
    "url": "http://patchwork.ozlabs.org/api/patches/1253343/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20200312015818.1007882-6-jacob.e.keller@intel.com/",
    "project": {
        "id": 46,
        "url": "http://patchwork.ozlabs.org/api/projects/46/?format=api",
        "name": "Intel Wired Ethernet development",
        "link_name": "intel-wired-lan",
        "list_id": "intel-wired-lan.osuosl.org",
        "list_email": "intel-wired-lan@osuosl.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20200312015818.1007882-6-jacob.e.keller@intel.com>",
    "list_archive_url": null,
    "date": "2020-03-12T01:58:14",
    "name": "[v3,5/9] ice: implement full NVM read from ETHTOOL_GEEPROM",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "6d468ff11fa96e76ef7796652f25c2d389ee5571",
    "submitter": {
        "id": 9784,
        "url": "http://patchwork.ozlabs.org/api/people/9784/?format=api",
        "name": "Jacob Keller",
        "email": "jacob.e.keller@intel.com"
    },
    "delegate": {
        "id": 68,
        "url": "http://patchwork.ozlabs.org/api/users/68/?format=api",
        "username": "jtkirshe",
        "first_name": "Jeff",
        "last_name": "Kirsher",
        "email": "jeffrey.t.kirsher@intel.com"
    },
    "mbox": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20200312015818.1007882-6-jacob.e.keller@intel.com/mbox/",
    "series": [
        {
            "id": 163869,
            "url": "http://patchwork.ozlabs.org/api/series/163869/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=163869",
            "date": "2020-03-12T01:58:10",
            "name": "ice devlink support",
            "version": 3,
            "mbox": "http://patchwork.ozlabs.org/series/163869/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/1253343/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/1253343/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<intel-wired-lan-bounces@osuosl.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "intel-wired-lan@lists.osuosl.org"
        ],
        "Delivered-To": [
            "patchwork-incoming@bilbo.ozlabs.org",
            "intel-wired-lan@lists.osuosl.org"
        ],
        "Authentication-Results": [
            "ozlabs.org; spf=pass (sender SPF authorized)\n\tsmtp.mailfrom=osuosl.org (client-ip=140.211.166.138;\n\thelo=whitealder.osuosl.org;\n\tenvelope-from=intel-wired-lan-bounces@osuosl.org;\n\treceiver=<UNKNOWN>)",
            "ozlabs.org;\n\tdmarc=fail (p=none dis=none) header.from=intel.com"
        ],
        "Received": [
            "from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 48dBnN0sSFz9sSL\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 12 Mar 2020 12:58:32 +1100 (AEDT)",
            "from localhost (localhost [127.0.0.1])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 7961688ABA;\n\tThu, 12 Mar 2020 01:58:30 +0000 (UTC)",
            "from whitealder.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id WxK+kKMcHcY0; Thu, 12 Mar 2020 01:58:28 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 179E486CC5;\n\tThu, 12 Mar 2020 01:58:28 +0000 (UTC)",
            "from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137])\n\tby ash.osuosl.org (Postfix) with ESMTP id 537921BF473\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tThu, 12 Mar 2020 01:58:24 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id 50E1F863DD\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tThu, 12 Mar 2020 01:58:24 +0000 (UTC)",
            "from fraxinus.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id MGqG-jB0xlM7 for <intel-wired-lan@lists.osuosl.org>;\n\tThu, 12 Mar 2020 01:58:23 +0000 (UTC)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n\tby fraxinus.osuosl.org (Postfix) with ESMTPS id E398B86193\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tThu, 12 Mar 2020 01:58:22 +0000 (UTC)",
            "from orsmga008.jf.intel.com ([10.7.209.65])\n\tby orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t11 Mar 2020 18:58:22 -0700",
            "from jekeller-desk.amr.corp.intel.com ([10.166.241.33])\n\tby orsmga008.jf.intel.com with ESMTP; 11 Mar 2020 18:58:21 -0700"
        ],
        "X-Virus-Scanned": [
            "amavisd-new at osuosl.org",
            "amavisd-new at osuosl.org"
        ],
        "X-Greylist": "domain auto-whitelisted by SQLgrey-1.7.6",
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.70,543,1574150400\"; d=\"scan'208\";a=\"236656313\"",
        "From": "Jacob Keller <jacob.e.keller@intel.com>",
        "To": "Intel Wired LAN <intel-wired-lan@lists.osuosl.org>",
        "Date": "Wed, 11 Mar 2020 18:58:14 -0700",
        "Message-Id": "<20200312015818.1007882-6-jacob.e.keller@intel.com>",
        "X-Mailer": "git-send-email 2.24.1",
        "In-Reply-To": "<20200312015818.1007882-1-jacob.e.keller@intel.com>",
        "References": "<20200312015818.1007882-1-jacob.e.keller@intel.com>",
        "MIME-Version": "1.0",
        "Subject": "[Intel-wired-lan] [PATCH v3 5/9] ice: implement full NVM read from\n\tETHTOOL_GEEPROM",
        "X-BeenThere": "intel-wired-lan@osuosl.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "Intel Wired Ethernet Linux Kernel Driver Development\n\t<intel-wired-lan.osuosl.org>",
        "List-Unsubscribe": "<https://lists.osuosl.org/mailman/options/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=unsubscribe>",
        "List-Archive": "<http://lists.osuosl.org/pipermail/intel-wired-lan/>",
        "List-Post": "<mailto:intel-wired-lan@osuosl.org>",
        "List-Help": "<mailto:intel-wired-lan-request@osuosl.org?subject=help>",
        "List-Subscribe": "<https://lists.osuosl.org/mailman/listinfo/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=subscribe>",
        "Cc": "Jakub Kicinski <kuba@kernel.org>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "intel-wired-lan-bounces@osuosl.org",
        "Sender": "\"Intel-wired-lan\" <intel-wired-lan-bounces@osuosl.org>"
    },
    "content": "From: Jesse Brandeburg <jesse.brandeburg@intel.com>\n\nThe current implementation of .get_eeprom only enables reading from the\nShadow RAM portion of the NVM contents. Implement support for reading\nthe entire flash contents instead of only the initial portion contained\nin the Shadow RAM.\n\nA complete dump can take several seconds, but the ETHTOOL_GEEPROM ioctl\nis capable of reading only a limited portion at a time by specifying the\noffset and length to read.\n\nIn order to perform the reads directly, several functions are made non\nstatic. Additionally, the unused ice_read_sr_buf_aq and ice_read_sr_buf\nfunctions are removed.\n\nSigned-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>\nSigned-off-by: Jacob Keller <jacob.e.keller@intel.com>\n---\n drivers/net/ethernet/intel/ice/ice_common.h  |   3 -\n drivers/net/ethernet/intel/ice/ice_ethtool.c |  33 ++--\n drivers/net/ethernet/intel/ice/ice_nvm.c     | 150 +------------------\n drivers/net/ethernet/intel/ice/ice_nvm.h     |   4 +\n 4 files changed, 26 insertions(+), 164 deletions(-)",
    "diff": "diff --git a/drivers/net/ethernet/intel/ice/ice_common.h b/drivers/net/ethernet/intel/ice/ice_common.h\nindex 0885bdb5830c..ded704236643 100644\n--- a/drivers/net/ethernet/intel/ice/ice_common.h\n+++ b/drivers/net/ethernet/intel/ice/ice_common.h\n@@ -38,9 +38,6 @@ enum ice_status\n ice_alloc_hw_res(struct ice_hw *hw, u16 type, u16 num, bool btm, u16 *res);\n enum ice_status\n ice_free_hw_res(struct ice_hw *hw, u16 type, u16 num, u16 *res);\n-enum ice_status ice_init_nvm(struct ice_hw *hw);\n-enum ice_status\n-ice_read_sr_buf(struct ice_hw *hw, u16 offset, u16 *words, u16 *data);\n enum ice_status\n ice_aq_alloc_free_res(struct ice_hw *hw, u16 num_entries,\n \t\t      struct ice_aqc_alloc_free_res_elem *buf, u16 buf_size,\ndiff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c b/drivers/net/ethernet/intel/ice/ice_ethtool.c\nindex 75970bcfa6c0..593fb37bd59e 100644\n--- a/drivers/net/ethernet/intel/ice/ice_ethtool.c\n+++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c\n@@ -245,7 +245,7 @@ static int ice_get_eeprom_len(struct net_device *netdev)\n \tstruct ice_netdev_priv *np = netdev_priv(netdev);\n \tstruct ice_pf *pf = np->vsi->back;\n \n-\treturn (int)(pf->hw.nvm.sr_words * sizeof(u16));\n+\treturn (int)pf->hw.nvm.flash_size;\n }\n \n static int\n@@ -253,39 +253,46 @@ ice_get_eeprom(struct net_device *netdev, struct ethtool_eeprom *eeprom,\n \t       u8 *bytes)\n {\n \tstruct ice_netdev_priv *np = netdev_priv(netdev);\n-\tu16 first_word, last_word, nwords;\n \tstruct ice_vsi *vsi = np->vsi;\n \tstruct ice_pf *pf = vsi->back;\n \tstruct ice_hw *hw = &pf->hw;\n \tenum ice_status status;\n \tstruct device *dev;\n \tint ret = 0;\n-\tu16 *buf;\n+\tu8 *buf;\n \n \tdev = ice_pf_to_dev(pf);\n \n \teeprom->magic = hw->vendor_id | (hw->device_id << 16);\n+\tnetdev_dbg(netdev, \"GEEPROM cmd 0x%08x, offset 0x%08x, len 0x%08x\\n\",\n+\t\t   eeprom->cmd, eeprom->offset, eeprom->len);\n \n-\tfirst_word = eeprom->offset >> 1;\n-\tlast_word = (eeprom->offset + eeprom->len - 1) >> 1;\n-\tnwords = last_word - first_word + 1;\n-\n-\tbuf = devm_kcalloc(dev, nwords, sizeof(u16), GFP_KERNEL);\n+\tbuf = kzalloc(eeprom->len, GFP_KERNEL);\n \tif (!buf)\n \t\treturn -ENOMEM;\n \n-\tstatus = ice_read_sr_buf(hw, first_word, &nwords, buf);\n+\tstatus = ice_acquire_nvm(hw, ICE_RES_READ);\n \tif (status) {\n-\t\tdev_err(dev, \"ice_read_sr_buf failed, err %d aq_err %d\\n\",\n+\t\tdev_err(dev, \"ice_acquire_nvm failed, err %d aq_err %d\\n\",\n \t\t\tstatus, hw->adminq.sq_last_status);\n-\t\teeprom->len = sizeof(u16) * nwords;\n \t\tret = -EIO;\n \t\tgoto out;\n \t}\n \n-\tmemcpy(bytes, (u8 *)buf + (eeprom->offset & 1), eeprom->len);\n+\tstatus = ice_read_flat_nvm(hw, eeprom->offset, &eeprom->len, buf,\n+\t\t\t\t   false);\n+\tif (status) {\n+\t\tdev_err(dev, \"ice_read_flat_nvm failed, err %d aq_err %d\\n\",\n+\t\t\tstatus, hw->adminq.sq_last_status);\n+\t\tret = -EIO;\n+\t\tgoto release;\n+\t}\n+\n+\tmemcpy(bytes, buf, eeprom->len);\n+release:\n+\tice_release_nvm(hw);\n out:\n-\tdevm_kfree(dev, buf);\n+\tkfree(buf);\n \treturn ret;\n }\n \ndiff --git a/drivers/net/ethernet/intel/ice/ice_nvm.c b/drivers/net/ethernet/intel/ice/ice_nvm.c\nindex 4cdce0370963..08909d1c7cce 100644\n--- a/drivers/net/ethernet/intel/ice/ice_nvm.c\n+++ b/drivers/net/ethernet/intel/ice/ice_nvm.c\n@@ -107,70 +107,6 @@ ice_read_flat_nvm(struct ice_hw *hw, u32 offset, u32 *length, u8 *data,\n \treturn status;\n }\n \n-/**\n- * ice_check_sr_access_params - verify params for Shadow RAM R/W operations.\n- * @hw: pointer to the HW structure\n- * @offset: offset in words from module start\n- * @words: number of words to access\n- */\n-static enum ice_status\n-ice_check_sr_access_params(struct ice_hw *hw, u32 offset, u16 words)\n-{\n-\tif ((offset + words) > hw->nvm.sr_words) {\n-\t\tice_debug(hw, ICE_DBG_NVM,\n-\t\t\t  \"NVM error: offset beyond SR lmt.\\n\");\n-\t\treturn ICE_ERR_PARAM;\n-\t}\n-\n-\tif (words > ICE_SR_SECTOR_SIZE_IN_WORDS) {\n-\t\t/* We can access only up to 4KB (one sector), in one AQ write */\n-\t\tice_debug(hw, ICE_DBG_NVM,\n-\t\t\t  \"NVM error: tried to access %d words, limit is %d.\\n\",\n-\t\t\t  words, ICE_SR_SECTOR_SIZE_IN_WORDS);\n-\t\treturn ICE_ERR_PARAM;\n-\t}\n-\n-\tif (((offset + (words - 1)) / ICE_SR_SECTOR_SIZE_IN_WORDS) !=\n-\t    (offset / ICE_SR_SECTOR_SIZE_IN_WORDS)) {\n-\t\t/* A single access cannot spread over two sectors */\n-\t\tice_debug(hw, ICE_DBG_NVM,\n-\t\t\t  \"NVM error: cannot spread over two sectors.\\n\");\n-\t\treturn ICE_ERR_PARAM;\n-\t}\n-\n-\treturn 0;\n-}\n-\n-/**\n- * ice_read_sr_aq - Read Shadow RAM.\n- * @hw: pointer to the HW structure\n- * @offset: offset in words from module start\n- * @words: number of words to read\n- * @data: storage for the words read from Shadow RAM (Little Endian)\n- * @last_command: tells the AdminQ that this is the last command\n- *\n- * Reads 16-bit Little Endian word buffers from the Shadow RAM using the admin\n- * command.\n- */\n-static enum ice_status\n-ice_read_sr_aq(struct ice_hw *hw, u32 offset, u16 words, __le16 *data,\n-\t       bool last_command)\n-{\n-\tenum ice_status status;\n-\n-\tstatus = ice_check_sr_access_params(hw, offset, words);\n-\n-\t/* values in \"offset\" and \"words\" parameters are sized as words\n-\t * (16 bits) but ice_aq_read_nvm expects these values in bytes.\n-\t * So do this conversion while calling ice_aq_read_nvm.\n-\t */\n-\tif (!status)\n-\t\tstatus = ice_aq_read_nvm(hw, 0, 2 * offset, 2 * words, data,\n-\t\t\t\t\t last_command, true, NULL);\n-\n-\treturn status;\n-}\n-\n /**\n  * ice_read_sr_word_aq - Reads Shadow RAM via AQ\n  * @hw: pointer to the HW structure\n@@ -198,63 +134,6 @@ ice_read_sr_word_aq(struct ice_hw *hw, u16 offset, u16 *data)\n \treturn 0;\n }\n \n-/**\n- * ice_read_sr_buf_aq - Reads Shadow RAM buf via AQ\n- * @hw: pointer to the HW structure\n- * @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF)\n- * @words: (in) number of words to read; (out) number of words actually read\n- * @data: words read from the Shadow RAM\n- *\n- * Reads 16 bit words (data buf) from the SR using the ice_read_sr_aq\n- * method. Ownership of the NVM is taken before reading the buffer and later\n- * released.\n- */\n-static enum ice_status\n-ice_read_sr_buf_aq(struct ice_hw *hw, u16 offset, u16 *words, u16 *data)\n-{\n-\tenum ice_status status;\n-\tbool last_cmd = false;\n-\tu16 words_read = 0;\n-\tu16 i = 0;\n-\n-\tdo {\n-\t\tu16 read_size, off_w;\n-\n-\t\t/* Calculate number of bytes we should read in this step.\n-\t\t * It's not allowed to read more than one page at a time or\n-\t\t * to cross page boundaries.\n-\t\t */\n-\t\toff_w = offset % ICE_SR_SECTOR_SIZE_IN_WORDS;\n-\t\tread_size = off_w ?\n-\t\t\tmin_t(u16, *words,\n-\t\t\t      (ICE_SR_SECTOR_SIZE_IN_WORDS - off_w)) :\n-\t\t\tmin_t(u16, (*words - words_read),\n-\t\t\t      ICE_SR_SECTOR_SIZE_IN_WORDS);\n-\n-\t\t/* Check if this is last command, if so set proper flag */\n-\t\tif ((words_read + read_size) >= *words)\n-\t\t\tlast_cmd = true;\n-\n-\t\tstatus = ice_read_sr_aq(hw, offset, read_size,\n-\t\t\t\t\tdata + words_read, last_cmd);\n-\t\tif (status)\n-\t\t\tgoto read_nvm_buf_aq_exit;\n-\n-\t\t/* Increment counter for words already read and move offset to\n-\t\t * new read location\n-\t\t */\n-\t\twords_read += read_size;\n-\t\toffset += read_size;\n-\t} while (words_read < *words);\n-\n-\tfor (i = 0; i < *words; i++)\n-\t\tdata[i] = le16_to_cpu(((__force __le16 *)data)[i]);\n-\n-read_nvm_buf_aq_exit:\n-\t*words = words_read;\n-\treturn status;\n-}\n-\n /**\n  * ice_acquire_nvm - Generic request for acquiring the NVM ownership\n  * @hw: pointer to the HW structure\n@@ -262,7 +141,7 @@ ice_read_sr_buf_aq(struct ice_hw *hw, u16 offset, u16 *words, u16 *data)\n  *\n  * This function will request NVM ownership.\n  */\n-static enum ice_status\n+enum ice_status\n ice_acquire_nvm(struct ice_hw *hw, enum ice_aq_res_access_type access)\n {\n \tif (hw->nvm.blank_nvm_mode)\n@@ -277,7 +156,7 @@ ice_acquire_nvm(struct ice_hw *hw, enum ice_aq_res_access_type access)\n  *\n  * This function will release NVM ownership.\n  */\n-static void ice_release_nvm(struct ice_hw *hw)\n+void ice_release_nvm(struct ice_hw *hw)\n {\n \tif (hw->nvm.blank_nvm_mode)\n \t\treturn;\n@@ -514,31 +393,6 @@ enum ice_status ice_init_nvm(struct ice_hw *hw)\n \treturn 0;\n }\n \n-/**\n- * ice_read_sr_buf - Reads Shadow RAM buf and acquire lock if necessary\n- * @hw: pointer to the HW structure\n- * @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF)\n- * @words: (in) number of words to read; (out) number of words actually read\n- * @data: words read from the Shadow RAM\n- *\n- * Reads 16 bit words (data buf) from the SR using the ice_read_nvm_buf_aq\n- * method. The buf read is preceded by the NVM ownership take\n- * and followed by the release.\n- */\n-enum ice_status\n-ice_read_sr_buf(struct ice_hw *hw, u16 offset, u16 *words, u16 *data)\n-{\n-\tenum ice_status status;\n-\n-\tstatus = ice_acquire_nvm(hw, ICE_RES_READ);\n-\tif (!status) {\n-\t\tstatus = ice_read_sr_buf_aq(hw, offset, words, data);\n-\t\tice_release_nvm(hw);\n-\t}\n-\n-\treturn status;\n-}\n-\n /**\n  * ice_nvm_validate_checksum\n  * @hw: pointer to the HW struct\ndiff --git a/drivers/net/ethernet/intel/ice/ice_nvm.h b/drivers/net/ethernet/intel/ice/ice_nvm.h\nindex 4245ef988edf..7375f6b96919 100644\n--- a/drivers/net/ethernet/intel/ice/ice_nvm.h\n+++ b/drivers/net/ethernet/intel/ice/ice_nvm.h\n@@ -4,8 +4,12 @@\n #ifndef _ICE_NVM_H_\n #define _ICE_NVM_H_\n \n+enum ice_status\n+ice_acquire_nvm(struct ice_hw *hw, enum ice_aq_res_access_type access);\n+void ice_release_nvm(struct ice_hw *hw);\n enum ice_status\n ice_read_flat_nvm(struct ice_hw *hw, u32 offset, u32 *length, u8 *data,\n \t\t  bool read_shadow_ram);\n+enum ice_status ice_init_nvm(struct ice_hw *hw);\n enum ice_status ice_read_sr_word(struct ice_hw *hw, u16 offset, u16 *data);\n #endif /* _ICE_NVM_H_ */\n",
    "prefixes": [
        "v3",
        "5/9"
    ]
}