Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/70664/?format=api
http://patchwork.dpdk.org/api/patches/70664/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/4b726f267b9d8c0d7bb1579fe6b2f4d640d75675.1590598121.git.anatoly.burakov@intel.com/", "project": { "id": 1, "url": "http://patchwork.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": "<4b726f267b9d8c0d7bb1579fe6b2f4d640d75675.1590598121.git.anatoly.burakov@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/4b726f267b9d8c0d7bb1579fe6b2f4d640d75675.1590598121.git.anatoly.burakov@intel.com", "date": "2020-05-27T17:02:02", "name": "[RFC,2/6] ethdev: add simple power management API", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "57f6ebb66ac55ea134d57e207e3ea3b02bc70b19", "submitter": { "id": 4, "url": "http://patchwork.dpdk.org/api/people/4/?format=api", "name": "Anatoly Burakov", "email": "anatoly.burakov@intel.com" }, "delegate": { "id": 1, "url": "http://patchwork.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/4b726f267b9d8c0d7bb1579fe6b2f4d640d75675.1590598121.git.anatoly.burakov@intel.com/mbox/", "series": [ { "id": 10259, "url": "http://patchwork.dpdk.org/api/series/10259/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=10259", "date": "2020-05-27T17:02:00", "name": "Power-optimized RX for Ethernet devices", "version": 1, "mbox": "http://patchwork.dpdk.org/series/10259/mbox/" } ], "comments": "http://patchwork.dpdk.org/api/patches/70664/comments/", "check": "warning", "checks": "http://patchwork.dpdk.org/api/patches/70664/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 354C9A00BE;\n\tWed, 27 May 2020 19:02:47 +0200 (CEST)", "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id DB9641DAFA;\n\tWed, 27 May 2020 19:02:21 +0200 (CEST)", "from mga01.intel.com (mga01.intel.com [192.55.52.88])\n by dpdk.org (Postfix) with ESMTP id B98671DAE9\n for <dev@dpdk.org>; Wed, 27 May 2020 19:02:16 +0200 (CEST)", "from orsmga005.jf.intel.com ([10.7.209.41])\n by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 27 May 2020 10:02:13 -0700", "from silpixa00399498.ir.intel.com (HELO\n silpixa00399498.ger.corp.intel.com) ([10.237.222.52])\n by orsmga005.jf.intel.com with ESMTP; 27 May 2020 10:02:02 -0700" ], "IronPort-SDR": [ "\n 0L7Q2oGFJ/CT9D4tMgZIfDjyuFQCR2uJnLXueZrC3VPUykN3kABfGlOYrlm+8yYr74AlRC8sHh\n CbxoiLFnYPtA==", "\n nLk3INkBLVHIouRQWspOEG/AI74httpkiGeCO1zEcbBu2Aksx3OjMvb5pvgVf3mQ+4BN9W4182\n LW964qDcuyGw==" ], "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.73,442,1583222400\"; d=\"scan'208\";a=\"442595973\"", "From": "Anatoly Burakov <anatoly.burakov@intel.com>", "To": "dev@dpdk.org", "Cc": "Thomas Monjalon <thomas@monjalon.net>,\n Ferruh Yigit <ferruh.yigit@intel.com>,\n Andrew Rybchenko <arybchenko@solarflare.com>, Ray Kinsella <mdr@ashroe.eu>,\n Neil Horman <nhorman@tuxdriver.com>, david.hunt@intel.com,\n liang.j.ma@intel.com", "Date": "Wed, 27 May 2020 18:02:02 +0100", "Message-Id": "\n <4b726f267b9d8c0d7bb1579fe6b2f4d640d75675.1590598121.git.anatoly.burakov@intel.com>", "X-Mailer": "git-send-email 2.17.1", "In-Reply-To": [ "<cover.1590598121.git.anatoly.burakov@intel.com>", "<cover.1590598121.git.anatoly.burakov@intel.com>" ], "References": [ "<cover.1590598121.git.anatoly.burakov@intel.com>", "<cover.1590598121.git.anatoly.burakov@intel.com>" ], "Subject": "[dpdk-dev] [RFC 2/6] ethdev: add simple power management API", "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": "Add a simple on/off switch that will enable saving power when no\npackets are arriving. It is based on counting the number of empty\npolls and, when the number reaches a certain threshold, entering an\narchitecture-defined optimized power state that will either wait\nuntil a TSC timestamp expires, or when packets arrive.\n\nThis API is limited to 1 core 1 queue use case as there is no\ncoordination between queues/cores in ethdev.\n\nThe TSC timestamp is automatically calculated using current link\nspeed and RX descriptor ring size, such that the sleep time is\nnot longer than it would take for a NIC to fill its entire RX\ndescriptor ring.\n\nSigned-off-by: Liang J. Ma <liang.j.ma@intel.com>\nSigned-off-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n lib/librte_ethdev/rte_ethdev.c | 39 +++++++++++++\n lib/librte_ethdev/rte_ethdev.h | 70 ++++++++++++++++++++++++\n lib/librte_ethdev/rte_ethdev_core.h | 41 +++++++++++++-\n lib/librte_ethdev/rte_ethdev_version.map | 4 ++\n 4 files changed, 152 insertions(+), 2 deletions(-)", "diff": "diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c\nindex 8e10a6fc36..0be5ecfc11 100644\n--- a/lib/librte_ethdev/rte_ethdev.c\n+++ b/lib/librte_ethdev/rte_ethdev.c\n@@ -16,6 +16,7 @@\n #include <netinet/in.h>\n \n #include <rte_byteorder.h>\n+#include <rte_cpuflags.h>\n #include <rte_log.h>\n #include <rte_debug.h>\n #include <rte_interrupts.h>\n@@ -5053,6 +5054,44 @@ rte_eth_dev_pool_ops_supported(uint16_t port_id, const char *pool)\n \treturn (*dev->dev_ops->pool_ops_supported)(dev, pool);\n }\n \n+int\n+rte_eth_dev_power_mgmt_enable(uint16_t port_id)\n+{\n+\tstruct rte_eth_dev *dev;\n+\n+\tRTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);\n+\tdev = &rte_eth_devices[port_id];\n+\n+\tif (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_WAITPKG))\n+\t\treturn -ENOTSUP;\n+\n+\t/* allocate memory for empty poll stats */\n+\tdev->empty_poll_stats = rte_malloc_socket(NULL,\n+\t\tsizeof(struct rte_eth_ep_stat) * RTE_MAX_QUEUES_PER_PORT,\n+\t\t0, dev->data->numa_node);\n+\n+\tif (dev->empty_poll_stats == NULL)\n+\t\treturn -ENOMEM;\n+\n+\tdev->pwr_mgmt_state = RTE_ETH_DEV_POWER_MGMT_ENABLED;\n+\treturn 0;\n+}\n+\n+int\n+rte_eth_dev_power_mgmt_disable(uint16_t port_id)\n+{\n+\tstruct rte_eth_dev *dev;\n+\n+\tRTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);\n+\tdev = &rte_eth_devices[port_id];\n+\n+\t/* rte_free ignores NULL so safe to call without checks */\n+\trte_free(dev->empty_poll_stats);\n+\n+\tdev->pwr_mgmt_state = RTE_ETH_DEV_POWER_MGMT_DISABLED;\n+\treturn 0;\n+}\n+\n /**\n * A set of values to describe the possible states of a switch domain.\n */\ndiff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h\nindex a49242bcd2..b8318f7e91 100644\n--- a/lib/librte_ethdev/rte_ethdev.h\n+++ b/lib/librte_ethdev/rte_ethdev.h\n@@ -157,6 +157,7 @@ extern \"C\" {\n #include <rte_common.h>\n #include <rte_config.h>\n #include <rte_ether.h>\n+#include <rte_power_intrinsics.h>\n \n #include \"rte_ethdev_trace_fp.h\"\n #include \"rte_dev_info.h\"\n@@ -666,6 +667,7 @@ rte_eth_rss_hf_refine(uint64_t rss_hf)\n /** Maximum nb. of vlan per mirror rule */\n #define ETH_MIRROR_MAX_VLANS 64\n \n+#define ETH_EMPTYPOLL_MAX 512 /**< Empty poll number threshlold */\n #define ETH_MIRROR_VIRTUAL_POOL_UP 0x01 /**< Virtual Pool uplink Mirroring. */\n #define ETH_MIRROR_UPLINK_PORT 0x02 /**< Uplink Port Mirroring. */\n #define ETH_MIRROR_DOWNLINK_PORT 0x04 /**< Downlink Port Mirroring. */\n@@ -1490,6 +1492,16 @@ enum rte_eth_dev_state {\n \tRTE_ETH_DEV_REMOVED,\n };\n \n+/**\n+ * Possible power managment states of an ethdev port.\n+ */\n+enum rte_eth_dev_power_mgmt_state {\n+\t/** Device power management is disabled. */\n+\tRTE_ETH_DEV_POWER_MGMT_DISABLED = 0,\n+\t/** Device power management is enabled. */\n+\tRTE_ETH_DEV_POWER_MGMT_ENABLED\n+};\n+\n struct rte_eth_dev_sriov {\n \tuint8_t active; /**< SRIOV is active with 16, 32 or 64 pools */\n \tuint8_t nb_q_per_pool; /**< rx queue number per pool */\n@@ -4302,6 +4314,38 @@ __rte_experimental\n int rte_eth_dev_hairpin_capability_get(uint16_t port_id,\n \t\t\t\t struct rte_eth_hairpin_cap *cap);\n \n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice\n+ *\n+ * Enable device power management.\n+ *\n+ * @param port_id\n+ * The port identifier of the Ethernet device.\n+ *\n+ * @return\n+ * 0 on success\n+ * <0 on error\n+ */\n+__rte_experimental\n+int rte_eth_dev_power_mgmt_enable(uint16_t port_id);\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice\n+ *\n+ * Disable device power management.\n+ *\n+ * @param port_id\n+ * The port identifier of the Ethernet device.\n+ *\n+ * @return\n+ * 0 on success\n+ * <0 on error\n+ */\n+__rte_experimental\n+int rte_eth_dev_power_mgmt_disable(uint16_t port_id);\n+\n #include <rte_ethdev_core.h>\n \n /**\n@@ -4417,6 +4461,32 @@ rte_eth_rx_burst(uint16_t port_id, uint16_t queue_id,\n \t\t} while (cb != NULL);\n \t}\n #endif\n+\tif (dev->pwr_mgmt_state == RTE_ETH_DEV_POWER_MGMT_ENABLED) {\n+\t\tif (unlikely(nb_rx == 0)) {\n+\t\t\tdev->empty_poll_stats[queue_id].num++;\n+\t\t\tif (unlikely(dev->empty_poll_stats[queue_id].num >\n+\t\t\t\t\tETH_EMPTYPOLL_MAX)) {\n+\t\t\t\tvolatile void *target_addr;\n+\t\t\t\tuint64_t expected, mask;\n+\t\t\t\tint ret;\n+\n+\t\t\t\t/*\n+\t\t\t\t * get address of next descriptor in the RX\n+\t\t\t\t * ring for this queue, as well as expected\n+\t\t\t\t * value and a mask.\n+\t\t\t\t */\n+\t\t\t\tret = (*dev->dev_ops->next_rx_desc)\n+\t\t\t\t\t(dev->data->rx_queues[queue_id],\n+\t\t\t\t\t &target_addr, &expected, &mask);\n+\t\t\t\tif (ret == 0)\n+\t\t\t\t\t/* -1ULL is maximum value for TSC */\n+\t\t\t\t\trte_power_monitor(target_addr,\n+\t\t\t\t\t\t\t expected, mask,\n+\t\t\t\t\t\t\t 0, -1ULL);\n+\t\t\t}\n+\t\t} else\n+\t\t\tdev->empty_poll_stats[queue_id].num = 0;\n+\t}\n \n \trte_ethdev_trace_rx_burst(port_id, queue_id, (void **)rx_pkts, nb_rx);\n \treturn nb_rx;\ndiff --git a/lib/librte_ethdev/rte_ethdev_core.h b/lib/librte_ethdev/rte_ethdev_core.h\nindex 32407dd418..4e23d465f0 100644\n--- a/lib/librte_ethdev/rte_ethdev_core.h\n+++ b/lib/librte_ethdev/rte_ethdev_core.h\n@@ -603,6 +603,27 @@ typedef int (*eth_tx_hairpin_queue_setup_t)\n \t uint16_t nb_tx_desc,\n \t const struct rte_eth_hairpin_conf *hairpin_conf);\n \n+/**\n+ * @internal\n+ * Get the next RX ring descriptor address.\n+ *\n+ * @param rxq\n+ * ethdev queue pointer.\n+ * @param tail_desc_addr\n+ * the pointer point to descriptor address var.\n+ *\n+ * @return\n+ * Negative errno value on error, 0 on success.\n+ *\n+ * @retval 0\n+ * Success.\n+ * @retval -EINVAL\n+ * Failed to get descriptor address.\n+ */\n+typedef int (*eth_next_rx_desc_t)\n+\t(void *rxq, volatile void **tail_desc_addr,\n+\t uint64_t *expected, uint64_t *mask);\n+\n /**\n * @internal A structure containing the functions exported by an Ethernet driver.\n */\n@@ -752,6 +773,8 @@ struct eth_dev_ops {\n \t/**< Set up device RX hairpin queue. */\n \teth_tx_hairpin_queue_setup_t tx_hairpin_queue_setup;\n \t/**< Set up device TX hairpin queue. */\n+\teth_next_rx_desc_t next_rx_desc;\n+\t/**< Get next RX ring descriptor address. */\n };\n \n /**\n@@ -768,6 +791,14 @@ struct rte_eth_rxtx_callback {\n \tvoid *param;\n };\n \n+/**\n+ * @internal\n+ * Structure used to hold counters for empty poll\n+ */\n+struct rte_eth_ep_stat {\n+\tuint64_t num;\n+} __rte_cache_aligned;\n+\n /**\n * @internal\n * The generic data structure associated with each ethernet device.\n@@ -807,8 +838,14 @@ struct rte_eth_dev {\n \tenum rte_eth_dev_state state; /**< Flag indicating the port state */\n \tvoid *security_ctx; /**< Context for security ops */\n \n-\tuint64_t reserved_64s[4]; /**< Reserved for future fields */\n-\tvoid *reserved_ptrs[4]; /**< Reserved for future fields */\n+\t/**< Empty poll number */\n+\tenum rte_eth_dev_power_mgmt_state pwr_mgmt_state;\n+\tuint32_t reserved_32;\n+\tuint64_t reserved_64s[3]; /**< Reserved for future fields */\n+\n+\t/**< Flag indicating the port power state */\n+\tstruct rte_eth_ep_stat *empty_poll_stats;\n+\tvoid *reserved_ptrs[3]; /**< Reserved for future fields */\n } __rte_cache_aligned;\n \n struct rte_eth_dev_sriov;\ndiff --git a/lib/librte_ethdev/rte_ethdev_version.map b/lib/librte_ethdev/rte_ethdev_version.map\nindex 7155056045..141361823d 100644\n--- a/lib/librte_ethdev/rte_ethdev_version.map\n+++ b/lib/librte_ethdev/rte_ethdev_version.map\n@@ -241,4 +241,8 @@ EXPERIMENTAL {\n \t__rte_ethdev_trace_rx_burst;\n \t__rte_ethdev_trace_tx_burst;\n \trte_flow_get_aged_flows;\n+\n+\t# added in 20.08\n+\trte_eth_dev_power_mgmt_disable;\n+\trte_eth_dev_power_mgmt_enable;\n };\n", "prefixes": [ "RFC", "2/6" ] }{ "id": 70664, "url": "