get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 64479,
    "url": "http://patches.dpdk.org/api/patches/64479/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200113023949.26718-16-xiaolong.ye@intel.com/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20200113023949.26718-16-xiaolong.ye@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20200113023949.26718-16-xiaolong.ye@intel.com",
    "date": "2020-01-13T02:39:27",
    "name": "[v4,15/36] net/i40e/base: add reading LPI counters",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "6cb696e628bd9828d7b638ffc957e8a239927be8",
    "submitter": {
        "id": 1120,
        "url": "http://patches.dpdk.org/api/people/1120/?format=api",
        "name": "Xiaolong Ye",
        "email": "xiaolong.ye@intel.com"
    },
    "delegate": {
        "id": 31221,
        "url": "http://patches.dpdk.org/api/users/31221/?format=api",
        "username": "yexl",
        "first_name": "xiaolong",
        "last_name": "ye",
        "email": "xiaolong.ye@intel.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20200113023949.26718-16-xiaolong.ye@intel.com/mbox/",
    "series": [
        {
            "id": 8064,
            "url": "http://patches.dpdk.org/api/series/8064/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=8064",
            "date": "2020-01-13T02:39:12",
            "name": "update for i40e base code",
            "version": 4,
            "mbox": "http://patches.dpdk.org/series/8064/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/64479/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/64479/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id CA28FA04F0;\n\tMon, 13 Jan 2020 03:49:23 +0100 (CET)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 730DA1D5D8;\n\tMon, 13 Jan 2020 03:47:45 +0100 (CET)",
            "from mga01.intel.com (mga01.intel.com [192.55.52.88])\n by dpdk.org (Postfix) with ESMTP id 502AB1D5A9\n for <dev@dpdk.org>; Mon, 13 Jan 2020 03:47:21 +0100 (CET)",
            "from fmsmga003.fm.intel.com ([10.253.24.29])\n by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n 12 Jan 2020 18:47:21 -0800",
            "from dpdk_yexl_af_xdp.sh.intel.com ([10.67.119.206])\n by FMSMGA003.fm.intel.com with ESMTP; 12 Jan 2020 18:47:20 -0800"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.69,427,1571727600\"; d=\"scan'208\";a=\"272916356\"",
        "From": "Xiaolong Ye <xiaolong.ye@intel.com>",
        "To": "Beilei Xing <beilei.xing@intel.com>,\n\tQi Zhang <qi.z.zhang@intel.com>",
        "Cc": "dev@dpdk.org, Xiaolong Ye <xiaolong.ye@intel.com>,\n Piotr Pietruszewski <piotr.pietruszewski@intel.com>",
        "Date": "Mon, 13 Jan 2020 10:39:27 +0800",
        "Message-Id": "<20200113023949.26718-16-xiaolong.ye@intel.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20200113023949.26718-1-xiaolong.ye@intel.com>",
        "References": "<20191202074935.97629-1-xiaolong.ye@intel.com>\n <20200113023949.26718-1-xiaolong.ye@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v4 15/36] net/i40e/base: add reading LPI counters",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "This change introduces new function i40e_get_lpi_counters() reading\nLow Power Idle (LPI) mode counters from Energy Efficient Ethernet (EEE)\nstatistics. Since reading EEE statistics requires running DNL script,\nfunction i40e_aq_run_phy_activity() able to run it, was implemented.\n\ni40e_lpi_stat_update() was introduced as helper function for retrieving\nLPI counters' values relative to given offsets.\n\nThis change also fixes order of fields in struct\ni40e_aqc_run_phy_activity and introduces union in the struct\nproviding more descriptive names of fields depending on usage\n(command or response).\n\nSigned-off-by: Piotr Pietruszewski <piotr.pietruszewski@intel.com>\nSigned-off-by: Xiaolong Ye <xiaolong.ye@intel.com>\n---\n drivers/net/i40e/base/i40e_adminq_cmd.h |  29 ++++--\n drivers/net/i40e/base/i40e_common.c     | 130 ++++++++++++++++++++++++\n drivers/net/i40e/base/i40e_prototype.h  |  10 ++\n 3 files changed, 163 insertions(+), 6 deletions(-)",
    "diff": "diff --git a/drivers/net/i40e/base/i40e_adminq_cmd.h b/drivers/net/i40e/base/i40e_adminq_cmd.h\nindex 2bd8f81f9..d718c7326 100644\n--- a/drivers/net/i40e/base/i40e_adminq_cmd.h\n+++ b/drivers/net/i40e/base/i40e_adminq_cmd.h\n@@ -2272,15 +2272,32 @@ enum i40e_aq_phy_reg_type {\n \tI40E_AQC_PHY_REG_EXERNAL_MODULE\t= 0x3\n };\n \n+#pragma pack(1)\n /* Run PHY Activity (0x0626) */\n struct i40e_aqc_run_phy_activity {\n-\t__le16  activity_id;\n-\tu8      flags;\n-\tu8      reserved1;\n-\t__le32  control;\n-\t__le32  data;\n-\tu8      reserved2[4];\n+\tu8\tcmd_flags;\n+\t__le16\tactivity_id;\n+#define I40E_AQ_RUN_PHY_ACT_ID_USR_DFND\t\t\t0x10\n+\tu8\treserved;\n+\tunion {\n+\t\tstruct {\n+\t\t\t__le32  dnl_opcode;\n+#define I40E_AQ_RUN_PHY_ACT_DNL_OPCODE_GET_EEE_STAT_DUR\t0x801a\n+#define I40E_AQ_RUN_PHY_ACT_DNL_OPCODE_GET_EEE_STAT\t0x801b\n+#define I40E_AQ_RUN_PHY_ACT_DNL_OPCODE_GET_EEE_DUR\t0x1801b\n+\t\t\t__le32  data;\n+\t\t\tu8\treserved2[4];\n+\t\t} cmd;\n+\t\tstruct {\n+\t\t\t__le32\tcmd_status;\n+#define I40E_AQ_RUN_PHY_ACT_CMD_STAT_SUCC\t\t0x4\n+#define I40E_AQ_RUN_PHY_ACT_CMD_STAT_MASK\t\t0xFFFF\n+\t\t\t__le32\tdata0;\n+\t\t\t__le32\tdata1;\n+\t\t} resp;\n+\t} params;\n };\n+#pragma pack()\n \n I40E_CHECK_CMD_LENGTH(i40e_aqc_run_phy_activity);\n \ndiff --git a/drivers/net/i40e/base/i40e_common.c b/drivers/net/i40e/base/i40e_common.c\nindex e0028ac4d..9d76b6824 100644\n--- a/drivers/net/i40e/base/i40e_common.c\n+++ b/drivers/net/i40e/base/i40e_common.c\n@@ -7027,6 +7027,91 @@ enum i40e_status_code i40e_get_phy_lpi_status(struct i40e_hw *hw,\n \treturn ret;\n }\n \n+/**\n+ * i40e_get_lpi_counters - read LPI counters from EEE statistics\n+ * @hw: pointer to the hw struct\n+ * @tx_counter: pointer to memory for TX LPI counter\n+ * @rx_counter: pointer to memory for RX LPI counter\n+ * @is_clear:   returns true if counters are clear after read\n+ *\n+ * Read Low Power Idle (LPI) mode counters from Energy Efficient\n+ * Ethernet (EEE) statistics.\n+ **/\n+enum i40e_status_code i40e_get_lpi_counters(struct i40e_hw *hw,\n+\t\t\t\t\t    u32 *tx_counter, u32 *rx_counter,\n+\t\t\t\t\t    bool *is_clear)\n+{\n+\t/* only X710-T*L requires special handling of counters\n+\t * for other devices we just read the MAC registers\n+\t */\n+\tif (hw->device_id == I40E_DEV_ID_10G_BASE_T_BC &&\n+\t    hw->phy.link_info.link_speed != I40E_LINK_SPEED_1GB) {\n+\t\tenum i40e_status_code retval;\n+\t\tu32 cmd_status = 0;\n+\n+\t\t*is_clear = false;\n+\t\tretval = i40e_aq_run_phy_activity(hw,\n+\t\t\t\tI40E_AQ_RUN_PHY_ACT_ID_USR_DFND,\n+\t\t\t\tI40E_AQ_RUN_PHY_ACT_DNL_OPCODE_GET_EEE_STAT,\n+\t\t\t\t&cmd_status, tx_counter, rx_counter, NULL);\n+\n+\t\tif (cmd_status != I40E_AQ_RUN_PHY_ACT_CMD_STAT_SUCC)\n+\t\t\tretval = I40E_ERR_ADMIN_QUEUE_ERROR;\n+\n+\t\treturn retval;\n+\t}\n+\n+\t*is_clear = true;\n+\t*tx_counter = rd32(hw, I40E_PRTPM_TLPIC);\n+\t*rx_counter = rd32(hw, I40E_PRTPM_RLPIC);\n+\n+\treturn I40E_SUCCESS;\n+}\n+\n+/**\n+ * i40e_lpi_stat_update - update LPI counters with values relative to offset\n+ * @hw: pointer to the hw struct\n+ * @offset_loaded: flag indicating need of writing current value to offset\n+ * @tx_offset: pointer to offset of TX LPI counter\n+ * @tx_stat: pointer to value of TX LPI counter\n+ * @rx_offset: pointer to offset of RX LPI counter\n+ * @rx_stat: pointer to value of RX LPI counter\n+ *\n+ * Update Low Power Idle (LPI) mode counters while having regard to passed\n+ * offsets.\n+ **/\n+enum i40e_status_code i40e_lpi_stat_update(struct i40e_hw *hw,\n+\t\t\t\t\t   bool offset_loaded, u64 *tx_offset,\n+\t\t\t\t\t   u64 *tx_stat, u64 *rx_offset,\n+\t\t\t\t\t   u64 *rx_stat)\n+{\n+\tenum i40e_status_code retval;\n+\tu32 tx_counter, rx_counter;\n+\tbool is_clear;\n+\n+\tretval = i40e_get_lpi_counters(hw, &tx_counter, &rx_counter, &is_clear);\n+\tif (retval)\n+\t\tgoto err;\n+\n+\tif (is_clear) {\n+\t\t*tx_stat += tx_counter;\n+\t\t*rx_stat += rx_counter;\n+\t} else {\n+\t\tif (!offset_loaded) {\n+\t\t\t*tx_offset = tx_counter;\n+\t\t\t*rx_offset = rx_counter;\n+\t\t}\n+\n+\t\t*tx_stat = (tx_counter >= *tx_offset) ?\n+\t\t\t(u32)(tx_counter - *tx_offset) :\n+\t\t\t(u32)((tx_counter + BIT_ULL(32)) - *tx_offset);\n+\t\t*rx_stat = (rx_counter >= *rx_offset) ?\n+\t\t\t(u32)(rx_counter - *rx_offset) :\n+\t\t\t(u32)((rx_counter + BIT_ULL(32)) - *rx_offset);\n+\t}\n+err:\n+\treturn retval;\n+}\n \n /**\n  * i40e_aq_rx_ctl_read_register - use FW to read from an Rx control register\n@@ -7233,6 +7318,51 @@ enum i40e_status_code i40e_aq_get_phy_register(struct i40e_hw *hw,\n }\n \n #endif /* PF_DRIVER */\n+/**\n+ * i40e_aq_run_phy_activity\n+ * @hw: pointer to the hw struct\n+ * @activity_id: ID of DNL activity to run\n+ * @dnl_opcode: opcode passed to DNL script\n+ * @cmd_status: pointer to memory to write return value of DNL script\n+ * @data0: pointer to memory for first 4 bytes of data returned by DNL script\n+ * @data1: pointer to memory for last 4 bytes of data returned by DNL script\n+ * @cmd_details: pointer to command details structure or NULL\n+ *\n+ * Run DNL admin command.\n+ **/\n+enum i40e_status_code\n+i40e_aq_run_phy_activity(struct i40e_hw *hw, u16 activity_id, u32 dnl_opcode,\n+\t\t\t u32 *cmd_status, u32 *data0, u32 *data1,\n+\t\t\t struct i40e_asq_cmd_details *cmd_details)\n+{\n+\tstruct i40e_aqc_run_phy_activity *cmd;\n+\tenum i40e_status_code retval;\n+\tstruct i40e_aq_desc desc;\n+\n+\tcmd = (struct i40e_aqc_run_phy_activity *)&desc.params.raw;\n+\n+\tif (!cmd_status || !data0 || !data1) {\n+\t\tretval = I40E_ERR_PARAM;\n+\t\tgoto err;\n+\t}\n+\n+\ti40e_fill_default_direct_cmd_desc(&desc,\n+\t\t\t\t\t  i40e_aqc_opc_run_phy_activity);\n+\n+\tcmd->activity_id = CPU_TO_LE16(activity_id);\n+\tcmd->params.cmd.dnl_opcode = CPU_TO_LE32(dnl_opcode);\n+\n+\tretval = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);\n+\tif (retval)\n+\t\tgoto err;\n+\n+\t*cmd_status = LE32_TO_CPU(cmd->params.resp.cmd_status);\n+\t*data0 = LE32_TO_CPU(cmd->params.resp.data0);\n+\t*data1 = LE32_TO_CPU(cmd->params.resp.data1);\n+err:\n+\treturn retval;\n+}\n+\n #ifdef VF_DRIVER\n \n /**\ndiff --git a/drivers/net/i40e/base/i40e_prototype.h b/drivers/net/i40e/base/i40e_prototype.h\nindex c6c45eb5a..748a7a275 100644\n--- a/drivers/net/i40e/base/i40e_prototype.h\n+++ b/drivers/net/i40e/base/i40e_prototype.h\n@@ -76,6 +76,12 @@ enum i40e_status_code i40e_blink_phy_link_led(struct i40e_hw *hw,\n \n enum i40e_status_code i40e_get_phy_lpi_status(struct i40e_hw *hw,\n \t\t\t\t\t      struct i40e_hw_port_stats *stats);\n+enum i40e_status_code i40e_get_lpi_counters(struct i40e_hw *hw, u32 *tx_counter,\n+\t\t\t\t\t    u32 *rx_counter, bool *is_clear);\n+enum i40e_status_code i40e_lpi_stat_update(struct i40e_hw *hw,\n+\t\t\t\t\t   bool offset_loaded, u64 *tx_offset,\n+\t\t\t\t\t   u64 *tx_stat, u64 *rx_offset,\n+\t\t\t\t\t   u64 *rx_stat);\n /* admin send queue commands */\n \n enum i40e_status_code i40e_aq_get_firmware_version(struct i40e_hw *hw,\n@@ -550,6 +556,10 @@ enum i40e_status_code i40e_aq_get_phy_register(struct i40e_hw *hw,\n \t\t\t\tu8 phy_select, u8 dev_addr, bool page_change,\n \t\t\t\tu32 reg_addr, u32 *reg_val,\n \t\t\t\tstruct i40e_asq_cmd_details *cmd_details);\n+enum i40e_status_code\n+i40e_aq_run_phy_activity(struct i40e_hw *hw, u16 activity_id, u32 opcode,\n+\t\t\t u32 *cmd_status, u32 *data0, u32 *data1,\n+\t\t\t struct i40e_asq_cmd_details *cmd_details);\n \n enum i40e_status_code i40e_aq_set_arp_proxy_config(struct i40e_hw *hw,\n \t\t\tstruct i40e_aqc_arp_proxy_data *proxy_config,\n",
    "prefixes": [
        "v4",
        "15/36"
    ]
}