get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 1016219,
    "url": "http://patchwork.ozlabs.org/api/patches/1016219/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20181219180334.1104-6-anirudh.venkataramanan@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": "<20181219180334.1104-6-anirudh.venkataramanan@intel.com>",
    "list_archive_url": null,
    "date": "2018-12-19T18:03:24",
    "name": "[S10,05/15] ice: Implement support for normal get_eeprom[_len] ethtool ops",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "f4530ae84a4eface817d5497a39ecd2315d1a1e3",
    "submitter": {
        "id": 73601,
        "url": "http://patchwork.ozlabs.org/api/people/73601/?format=api",
        "name": "Anirudh Venkataramanan",
        "email": "anirudh.venkataramanan@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/20181219180334.1104-6-anirudh.venkataramanan@intel.com/mbox/",
    "series": [
        {
            "id": 82906,
            "url": "http://patchwork.ozlabs.org/api/series/82906/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=82906",
            "date": "2018-12-19T18:03:28",
            "name": "Feature updates for ice",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/82906/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/1016219/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/1016219/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;\n\tspf=pass (mailfrom) smtp.mailfrom=osuosl.org\n\t(client-ip=140.211.166.137; helo=fraxinus.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 fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137])\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 43KjSJ4ScWz9s3Z\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 20 Dec 2018 05:03:44 +1100 (AEDT)",
            "from localhost (localhost [127.0.0.1])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id 179DC85B25;\n\tWed, 19 Dec 2018 18:03:43 +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 Ljqyh-CFScMp; Wed, 19 Dec 2018 18:03:40 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id A730485C14;\n\tWed, 19 Dec 2018 18:03:39 +0000 (UTC)",
            "from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137])\n\tby ash.osuosl.org (Postfix) with ESMTP id 8B1F61C31CA\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 19 Dec 2018 18:03:37 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id 8742F85507\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 19 Dec 2018 18:03:37 +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 Obg91mOwNwDz for <intel-wired-lan@lists.osuosl.org>;\n\tWed, 19 Dec 2018 18:03:36 +0000 (UTC)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n\tby fraxinus.osuosl.org (Postfix) with ESMTPS id AE89C85B25\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 19 Dec 2018 18:03:36 +0000 (UTC)",
            "from fmsmga002.fm.intel.com ([10.253.24.26])\n\tby orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t19 Dec 2018 10:03:35 -0800",
            "from shasta.jf.intel.com ([10.166.241.11])\n\tby fmsmga002.fm.intel.com with ESMTP; 19 Dec 2018 10:03:35 -0800"
        ],
        "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.56,373,1539673200\"; d=\"scan'208\";a=\"127400075\"",
        "From": "Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>",
        "To": "intel-wired-lan@lists.osuosl.org",
        "Date": "Wed, 19 Dec 2018 10:03:24 -0800",
        "Message-Id": "<20181219180334.1104-6-anirudh.venkataramanan@intel.com>",
        "X-Mailer": "git-send-email 2.14.5",
        "In-Reply-To": "<20181219180334.1104-1-anirudh.venkataramanan@intel.com>",
        "References": "<20181219180334.1104-1-anirudh.venkataramanan@intel.com>",
        "Subject": "[Intel-wired-lan] [PATCH S10 05/15] ice: Implement support for\n\tnormal get_eeprom[_len] ethtool ops",
        "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>",
        "MIME-Version": "1.0",
        "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: Bruce Allan <bruce.w.allan@intel.com>\n\nAdd support for get_eeprom and get_eeprom_len ethtool ops\n\nSpecification states that PF software accesses NVM (shadow-ram) via AQ\ncommands (e.g. NVM Read, NVM Write) in the range 0x000000-0x00FFFF (64KB),\nso the get_eeprom_len op should return 64KB.  If additional regions of the\n16MB NVM must be read, another access method must be used.\n\nThe ethtool kernel code, by default, will ask for multiple page-size hunks\nof the NVM not to exceed the value returned by ice_get_eeprom_len().\nice_read_sr_buf() deals with arch page sizes different than 4KB.\n\nSigned-off-by: Bruce Allan <bruce.w.allan@intel.com>\nSigned-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>\n---\n[Anirudh Venkataramanan <anirudh.venkataramanan@intel.com> cleaned up commit message]\n---\n drivers/net/ethernet/intel/ice/ice_common.h  |  2 +\n drivers/net/ethernet/intel/ice/ice_ethtool.c | 51 ++++++++++++++++++\n drivers/net/ethernet/intel/ice/ice_nvm.c     | 81 ++++++++++++++++++++++++++++\n 3 files changed, 134 insertions(+)",
    "diff": "diff --git a/drivers/net/ethernet/intel/ice/ice_common.h b/drivers/net/ethernet/intel/ice/ice_common.h\nindex b86cfe540045..81c1bb77a9fc 100644\n--- a/drivers/net/ethernet/intel/ice/ice_common.h\n+++ b/drivers/net/ethernet/intel/ice/ice_common.h\n@@ -28,6 +28,8 @@ ice_acquire_res(struct ice_hw *hw, enum ice_aq_res_ids res,\n \t\tenum ice_aq_res_access_type access, u32 timeout);\n void ice_release_res(struct ice_hw *hw, enum ice_aq_res_ids res);\n enum ice_status ice_init_nvm(struct ice_hw *hw);\n+enum ice_status ice_read_sr_buf(struct ice_hw *hw, u16 offset, u16 *words,\n+\t\t\t\tu16 *data);\n enum ice_status\n ice_sq_send_cmd(struct ice_hw *hw, struct ice_ctl_q_info *cq,\n \t\tstruct ice_aq_desc *desc, void *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 6facb0a7eed4..2a0bcd460d23 100644\n--- a/drivers/net/ethernet/intel/ice/ice_ethtool.c\n+++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c\n@@ -203,6 +203,55 @@ static void ice_set_msglevel(struct net_device *netdev, u32 data)\n #endif /* !CONFIG_DYNAMIC_DEBUG */\n }\n \n+static int ice_get_eeprom_len(struct net_device *netdev)\n+{\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+}\n+\n+static int\n+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+\n+\tdev = &pf->pdev->dev;\n+\n+\teeprom->magic = hw->vendor_id | (hw->device_id << 16);\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+\tif (!buf)\n+\t\treturn -ENOMEM;\n+\n+\tstatus = ice_read_sr_buf(hw, first_word, &nwords, buf);\n+\tif (status) {\n+\t\tdev_err(dev, \"ice_read_sr_buf 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+out:\n+\tdevm_kfree(dev, buf);\n+\treturn ret;\n+}\n+\n static void ice_get_strings(struct net_device *netdev, u32 stringset, u8 *data)\n {\n \tstruct ice_netdev_priv *np = netdev_priv(netdev);\n@@ -1699,6 +1748,8 @@ static const struct ethtool_ops ice_ethtool_ops = {\n \t.get_msglevel           = ice_get_msglevel,\n \t.set_msglevel           = ice_set_msglevel,\n \t.get_link\t\t= ethtool_op_get_link,\n+\t.get_eeprom_len\t\t= ice_get_eeprom_len,\n+\t.get_eeprom\t\t= ice_get_eeprom,\n \t.get_strings\t\t= ice_get_strings,\n \t.set_phys_id\t\t= ice_set_phys_id,\n \t.get_ethtool_stats      = ice_get_ethtool_stats,\ndiff --git a/drivers/net/ethernet/intel/ice/ice_nvm.c b/drivers/net/ethernet/intel/ice/ice_nvm.c\nindex 3274c543283c..ce64cecdae9c 100644\n--- a/drivers/net/ethernet/intel/ice/ice_nvm.c\n+++ b/drivers/net/ethernet/intel/ice/ice_nvm.c\n@@ -124,6 +124,62 @@ ice_read_sr_word_aq(struct ice_hw *hw, u16 offset, u16 *data)\n \treturn status;\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(*words,\n+\t\t\t    (u16)(ICE_SR_SECTOR_SIZE_IN_WORDS - off_w)) :\n+\t\t\tmin((*words - words_read), 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(((__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@@ -234,3 +290,28 @@ enum ice_status ice_init_nvm(struct ice_hw *hw)\n \n \treturn status;\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",
    "prefixes": [
        "S10",
        "05/15"
    ]
}