get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 1312346,
    "url": "http://patchwork.ozlabs.org/api/patches/1312346/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20200618184611.2641181-1-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": "<20200618184611.2641181-1-jacob.e.keller@intel.com>",
    "list_archive_url": null,
    "date": "2020-06-18T18:46:11",
    "name": "[v2] ice: implement snapshot for device capabilities",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "59c218a46ce69f4364b7a686e327fda9b9b35db1",
    "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/20200618184611.2641181-1-jacob.e.keller@intel.com/mbox/",
    "series": [
        {
            "id": 184344,
            "url": "http://patchwork.ozlabs.org/api/series/184344/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=184344",
            "date": "2020-06-18T18:46:11",
            "name": "[v2] ice: implement snapshot for device capabilities",
            "version": 2,
            "mbox": "http://patchwork.ozlabs.org/series/184344/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/1312346/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/1312346/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 spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org\n (client-ip=140.211.166.137; helo=fraxinus.osuosl.org;\n envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=<UNKNOWN>)",
            "ozlabs.org;\n dmarc=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 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 49nrW055lQz9sNR\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 19 Jun 2020 04:46:20 +1000 (AEST)",
            "from localhost (localhost [127.0.0.1])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id 7D7E487C93;\n\tThu, 18 Jun 2020 18:46:18 +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 cXwB1OvIQa6e; Thu, 18 Jun 2020 18:46:17 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id 7EC1987CA7;\n\tThu, 18 Jun 2020 18:46:17 +0000 (UTC)",
            "from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137])\n by ash.osuosl.org (Postfix) with ESMTP id 017471BF40B\n for <intel-wired-lan@lists.osuosl.org>; Thu, 18 Jun 2020 18:46:16 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n by fraxinus.osuosl.org (Postfix) with ESMTP id EC1CE87CA7\n for <intel-wired-lan@lists.osuosl.org>; Thu, 18 Jun 2020 18:46:15 +0000 (UTC)",
            "from fraxinus.osuosl.org ([127.0.0.1])\n by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n with ESMTP id z-kbNqRLbzKF for <intel-wired-lan@lists.osuosl.org>;\n Thu, 18 Jun 2020 18:46:15 +0000 (UTC)",
            "from mga09.intel.com (mga09.intel.com [134.134.136.24])\n by fraxinus.osuosl.org (Postfix) with ESMTPS id F0F2987C93\n for <intel-wired-lan@lists.osuosl.org>; Thu, 18 Jun 2020 18:46:14 +0000 (UTC)",
            "from fmsmga001.fm.intel.com ([10.253.24.23])\n by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 18 Jun 2020 11:46:14 -0700",
            "from jekeller-desk.amr.corp.intel.com ([10.166.241.33])\n by fmsmga001.fm.intel.com with ESMTP; 18 Jun 2020 11:46:13 -0700"
        ],
        "X-Virus-Scanned": [
            "amavisd-new at osuosl.org",
            "amavisd-new at osuosl.org"
        ],
        "X-Greylist": "domain auto-whitelisted by SQLgrey-1.7.6",
        "IronPort-SDR": [
            "\n E36/bHnYksyezq82Ct90VbIIz7W9gPB84gjNJXLpAtNFLUIGAsLbvKgNkhw/nPC/LAx0lzTVCG\n pXDKCrhdIHMQ==",
            "\n 7hw8/VdOvRQzorUBa27bJ0aAw6m0ghDldvgj/2aRQnZ30U90DUt8Ja1twzPsEoDm+vxwa52Ho0\n D8iL2YPAgIGw=="
        ],
        "X-IronPort-AV": [
            "E=McAfee;i=\"6000,8403,9656\"; a=\"144205750\"",
            "E=Sophos;i=\"5.75,252,1589266800\"; d=\"scan'208\";a=\"144205750\"",
            "E=Sophos;i=\"5.75,252,1589266800\"; d=\"scan'208\";a=\"383608413\""
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "From": "Jacob Keller <jacob.e.keller@intel.com>",
        "To": "Intel Wired LAN <intel-wired-lan@lists.osuosl.org>",
        "Date": "Thu, 18 Jun 2020 11:46:11 -0700",
        "Message-Id": "<20200618184611.2641181-1-jacob.e.keller@intel.com>",
        "X-Mailer": "git-send-email 2.25.2",
        "MIME-Version": "1.0",
        "Subject": "[Intel-wired-lan] [PATCH v2] ice: implement snapshot for device\n capabilities",
        "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 <intel-wired-lan.osuosl.org>",
        "List-Unsubscribe": "<https://lists.osuosl.org/mailman/options/intel-wired-lan>,\n <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 <mailto:intel-wired-lan-request@osuosl.org?subject=subscribe>",
        "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": "Add a new devlink region used for capturing a snapshot of the device\ncapabilities buffer which is reported by the firmware over the AdminQ.\nThis information can useful in debugging driver and firmware\ninteractions.\n\nSigned-off-by: Jacob Keller <jacob.e.keller@intel.com>\n---\nv2\n* Fixed ice_devlink_destroy_regions to properly release the new region\n\n drivers/net/ethernet/intel/ice/ice.h         |  1 +\n drivers/net/ethernet/intel/ice/ice_common.c  | 66 +++++++++++++++-----\n drivers/net/ethernet/intel/ice/ice_common.h  |  3 +\n drivers/net/ethernet/intel/ice/ice_devlink.c | 59 +++++++++++++++++\n 4 files changed, 115 insertions(+), 14 deletions(-)",
    "diff": "diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h\nindex a4cda8212e64..7486d010a619 100644\n--- a/drivers/net/ethernet/intel/ice/ice.h\n+++ b/drivers/net/ethernet/intel/ice/ice.h\n@@ -373,6 +373,7 @@ struct ice_pf {\n \tstruct devlink_port devlink_port;\n \n \tstruct devlink_region *nvm_region;\n+\tstruct devlink_region *devcaps_region;\n \n \t/* OS reserved IRQ details */\n \tstruct msix_entry *msix_entries;\ndiff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c\nindex bce0e1281168..e3cb7bd1ecab 100644\n--- a/drivers/net/ethernet/intel/ice/ice_common.c\n+++ b/drivers/net/ethernet/intel/ice/ice_common.c\n@@ -1823,20 +1823,27 @@ ice_parse_caps(struct ice_hw *hw, void *buf, u32 cap_count,\n }\n \n /**\n- * ice_aq_discover_caps - query function/device capabilities\n+ * ice_aq_list_caps - query function/device capabilities\n  * @hw: pointer to the HW struct\n- * @buf: a virtual buffer to hold the capabilities\n- * @buf_size: Size of the virtual buffer\n- * @cap_count: cap count needed if AQ err==ENOMEM\n- * @opc: capabilities type to discover - pass in the command opcode\n+ * @buf: a buffer to hold the capabilities\n+ * @buf_size: size of the buffer\n+ * @cap_count: if not NULL, set to the number of capabilities reported\n+ * @opc: capabilities type to discover, device or function\n  * @cd: pointer to command details structure or NULL\n  *\n- * Get the function(0x000a)/device(0x000b) capabilities description from\n- * the firmware.\n+ * Get the function (0x000A) or device (0x000B) capabilities description from\n+ * firmware and store it in the buffer.\n+ *\n+ * If the cap_count pointer is not NULL, then it is set to the number of\n+ * capabilities firmware will report. Note that if the buffer size is too\n+ * small, it is possible the command will return ICE_AQ_ERR_ENOMEM. The\n+ * cap_count will still be updated in this case. It is recommended that the\n+ * buffer size be set to ICE_AQ_MAX_BUF_LEN (the largest possible buffer that\n+ * firmware could return) to avoid this.\n  */\n-static enum ice_status\n-ice_aq_discover_caps(struct ice_hw *hw, void *buf, u16 buf_size, u32 *cap_count,\n-\t\t     enum ice_adminq_opc opc, struct ice_sq_cd *cd)\n+enum ice_status\n+ice_aq_list_caps(struct ice_hw *hw, void *buf, u16 buf_size, u32 *cap_count,\n+\t\t enum ice_adminq_opc opc, struct ice_sq_cd *cd)\n {\n \tstruct ice_aqc_list_caps *cmd;\n \tstruct ice_aq_desc desc;\n@@ -1849,12 +1856,43 @@ ice_aq_discover_caps(struct ice_hw *hw, void *buf, u16 buf_size, u32 *cap_count,\n \t\treturn ICE_ERR_PARAM;\n \n \tice_fill_dflt_direct_cmd_desc(&desc, opc);\n-\n \tstatus = ice_aq_send_cmd(hw, &desc, buf, buf_size, cd);\n-\tif (!status)\n-\t\tice_parse_caps(hw, buf, le32_to_cpu(cmd->count), opc);\n-\telse if (hw->adminq.sq_last_status == ICE_AQ_RC_ENOMEM)\n+\n+\tif (cap_count)\n \t\t*cap_count = le32_to_cpu(cmd->count);\n+\n+\treturn status;\n+}\n+\n+/**\n+ * ice_aq_discover_caps - query function/device capabilities\n+ * @hw: pointer to the HW struct\n+ * @buf: a virtual buffer to hold the capabilities\n+ * @buf_size: Size of the virtual buffer\n+ * @cap_count: cap count needed if AQ err==ENOMEM\n+ * @opc: capabilities type to discover - pass in the command opcode\n+ * @cd: pointer to command details structure or NULL\n+ *\n+ * Get the function(0x000a)/device(0x000b) capabilities description from\n+ * the firmware.\n+ *\n+ * NOTE: this function has the side effect of updating the hw->dev_caps or\n+ * hw->func_caps by way of calling ice_parse_caps.\n+ */\n+static enum ice_status\n+ice_aq_discover_caps(struct ice_hw *hw, void *buf, u16 buf_size, u32 *cap_count,\n+\t\t     enum ice_adminq_opc opc, struct ice_sq_cd *cd)\n+{\n+\tu32 local_cap_count = 0;\n+\tenum ice_status status;\n+\n+\tstatus = ice_aq_list_caps(hw, buf, buf_size, &local_cap_count,\n+\t\t\t\t  opc, cd);\n+\tif (!status)\n+\t\tice_parse_caps(hw, buf, local_cap_count, opc);\n+\telse if (hw->adminq.sq_last_status == ICE_AQ_RC_ENOMEM)\n+\t\t*cap_count = local_cap_count;\n+\n \treturn status;\n }\n \ndiff --git a/drivers/net/ethernet/intel/ice/ice_common.h b/drivers/net/ethernet/intel/ice/ice_common.h\nindex 9b9e50d2398b..e72529e9f022 100644\n--- a/drivers/net/ethernet/intel/ice/ice_common.h\n+++ b/drivers/net/ethernet/intel/ice/ice_common.h\n@@ -87,6 +87,9 @@ enum ice_status\n ice_aq_get_phy_caps(struct ice_port_info *pi, bool qual_mods, u8 report_mode,\n \t\t    struct ice_aqc_get_phy_caps_data *caps,\n \t\t    struct ice_sq_cd *cd);\n+enum ice_status\n+ice_aq_list_caps(struct ice_hw *hw, void *buf, u16 buf_size, u32 *cap_count,\n+\t\t enum ice_adminq_opc opc, struct ice_sq_cd *cd);\n void\n ice_update_phy_type(u64 *phy_type_low, u64 *phy_type_high,\n \t\t    u16 link_speeds_bitmap);\ndiff --git a/drivers/net/ethernet/intel/ice/ice_devlink.c b/drivers/net/ethernet/intel/ice/ice_devlink.c\nindex a73d06e06b5d..3ea470e8cfa2 100644\n--- a/drivers/net/ethernet/intel/ice/ice_devlink.c\n+++ b/drivers/net/ethernet/intel/ice/ice_devlink.c\n@@ -397,12 +397,60 @@ static int ice_devlink_nvm_snapshot(struct devlink *devlink,\n \treturn 0;\n }\n \n+/**\n+ * ice_devlink_devcaps_snapshot - Capture snapshot of device capabilities\n+ * @devlink: the devlink instance\n+ * @extack: extended ACK response structure\n+ * @data: on exit points to snapshot data buffer\n+ *\n+ * This function is called in response to the DEVLINK_CMD_REGION_TRIGGER for\n+ * the device-caps devlink region. It captures a snapshot of the device\n+ * capabilities reported by firmware.\n+ *\n+ * @returns zero on success, and updates the data pointer. Returns a non-zero\n+ * error code on failure.\n+ */\n+static int\n+ice_devlink_devcaps_snapshot(struct devlink *devlink,\n+\t\t\t     struct netlink_ext_ack *extack, u8 **data)\n+{\n+\tstruct ice_pf *pf = devlink_priv(devlink);\n+\tstruct device *dev = ice_pf_to_dev(pf);\n+\tstruct ice_hw *hw = &pf->hw;\n+\tenum ice_status status;\n+\tvoid *devcaps;\n+\n+\tdevcaps = vzalloc(ICE_AQ_MAX_BUF_LEN);\n+\tif (!devcaps)\n+\t\treturn -ENOMEM;\n+\n+\tstatus = ice_aq_list_caps(hw, devcaps, ICE_AQ_MAX_BUF_LEN, NULL,\n+\t\t\t\t  ice_aqc_opc_list_dev_caps, NULL);\n+\tif (status) {\n+\t\tdev_dbg(dev, \"ice_aq_list_caps: failed to read device capabilities, err %d aq_err %d\\n\",\n+\t\t\tstatus, hw->adminq.sq_last_status);\n+\t\tNL_SET_ERR_MSG_MOD(extack, \"Failed to read device capabilities\");\n+\t\tvfree(devcaps);\n+\t\treturn -EIO;\n+\t}\n+\n+\t*data = (u8 *)devcaps;\n+\n+\treturn 0;\n+}\n+\n static const struct devlink_region_ops ice_nvm_region_ops = {\n \t.name = \"nvm-flash\",\n \t.destructor = vfree,\n \t.snapshot = ice_devlink_nvm_snapshot,\n };\n \n+static const struct devlink_region_ops ice_devcaps_region_ops = {\n+\t.name = \"device-caps\",\n+\t.destructor = vfree,\n+\t.snapshot = ice_devlink_devcaps_snapshot,\n+};\n+\n /**\n  * ice_devlink_init_regions - Initialize devlink regions\n  * @pf: the PF device structure\n@@ -424,6 +472,15 @@ void ice_devlink_init_regions(struct ice_pf *pf)\n \t\t\tPTR_ERR(pf->nvm_region));\n \t\tpf->nvm_region = NULL;\n \t}\n+\n+\tpf->devcaps_region = devlink_region_create(devlink,\n+\t\t\t\t\t\t   &ice_devcaps_region_ops, 10,\n+\t\t\t\t\t\t   ICE_AQ_MAX_BUF_LEN);\n+\tif (IS_ERR(pf->devcaps_region)) {\n+\t\tdev_err(dev, \"failed to create device-caps devlink region, err %ld\\n\",\n+\t\t\tPTR_ERR(pf->devcaps_region));\n+\t\tpf->devcaps_region = NULL;\n+\t}\n }\n \n /**\n@@ -436,4 +493,6 @@ void ice_devlink_destroy_regions(struct ice_pf *pf)\n {\n \tif (pf->nvm_region)\n \t\tdevlink_region_destroy(pf->nvm_region);\n+\tif (pf->devcaps_region)\n+\t\tdevlink_region_destroy(pf->devcaps_region);\n }\n",
    "prefixes": [
        "v2"
    ]
}