From patchwork Tue May 11 15:31:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Burakov, Anatoly" X-Patchwork-Id: 93167 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 80E9DA0A0E; Tue, 11 May 2021 17:33:04 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F044D40140; Tue, 11 May 2021 17:33:03 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id D5D364003E for ; Tue, 11 May 2021 17:33:01 +0200 (CEST) IronPort-SDR: yXnGKI1J5QDsTXUTYn3PVhU6TlzRmjFpBCmvdlozZ4POMv6Tan/Zj9vjX1vCUWFCj60SlLi1kW rXgwxCT0VGmA== X-IronPort-AV: E=McAfee;i="6200,9189,9981"; a="284963186" X-IronPort-AV: E=Sophos;i="5.82,291,1613462400"; d="scan'208";a="284963186" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 08:32:54 -0700 IronPort-SDR: kCDzsfgU+vQtlwT1ihtasP4pfeB3JEJUFl1SZi4xR0bESP3eboz0T5FRpGFyUDPTbl6dpwCh7J uBssmBkXbfKg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,291,1613462400"; d="scan'208";a="471162521" Received: from silpixa00399498.ir.intel.com (HELO silpixa00399498.ger.corp.intel.com) ([10.237.223.81]) by orsmga001.jf.intel.com with ESMTP; 11 May 2021 08:31:59 -0700 From: Anatoly Burakov To: dev@dpdk.org, Timothy McDaniel , Beilei Xing , Jingjing Wu , Qiming Yang , Qi Zhang , Haiyue Wang , Matan Azrad , Shahaf Shuler , Viacheslav Ovsiienko , Bruce Richardson , Konstantin Ananyev Cc: ciara.loftus@intel.com Date: Tue, 11 May 2021 15:31:52 +0000 Message-Id: <819ef1ace187365a615d3383e54579e3d9fb216e.1620747068.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [dpdk-dev] [21.08 PATCH v1 1/2] power: invert the monitor check X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Previously, the semantics of power monitor were such that we were checking current value against the expected value, and if they matched, then the sleep was aborted. This is somewhat inflexible, because it only allowed us to check for a specific value. We can reverse the check, and instead have monitor sleep to be aborted if the expected value *doesn't* match what's in memory. This allows us to both implement all currently implemented driver code, as well as support more use cases which don't easily map to previous semantics (such as waiting on writes to AF_XDP counter value). This commit also adjusts all current driver implementations to match the new semantics. Signed-off-by: Anatoly Burakov Acked-by: Timothy McDaniel --- drivers/event/dlb2/dlb2.c | 2 +- drivers/net/i40e/i40e_rxtx.c | 2 +- drivers/net/iavf/iavf_rxtx.c | 2 +- drivers/net/ice/ice_rxtx.c | 2 +- drivers/net/ixgbe/ixgbe_rxtx.c | 2 +- drivers/net/mlx5/mlx5_rx.c | 2 +- lib/eal/include/generic/rte_power_intrinsics.h | 8 ++++---- lib/eal/x86/rte_power_intrinsics.c | 4 ++-- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/event/dlb2/dlb2.c b/drivers/event/dlb2/dlb2.c index 3570678b9e..5701bbb8ab 100644 --- a/drivers/event/dlb2/dlb2.c +++ b/drivers/event/dlb2/dlb2.c @@ -3188,7 +3188,7 @@ dlb2_dequeue_wait(struct dlb2_eventdev *dlb2, &cq_base[qm_port->cq_idx]; monitor_addr++; /* cq_gen bit is in second 64bit location */ - if (qm_port->gen_bit) + if (!qm_port->gen_bit) expected_value = qe_mask.raw_qe[1]; else expected_value = 0; diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c index 02cf5e787c..4617ae914a 100644 --- a/drivers/net/i40e/i40e_rxtx.c +++ b/drivers/net/i40e/i40e_rxtx.c @@ -88,7 +88,7 @@ i40e_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc) * we expect the DD bit to be set to 1 if this descriptor was already * written to. */ - pmc->val = rte_cpu_to_le_64(1 << I40E_RX_DESC_STATUS_DD_SHIFT); + pmc->val = 0; pmc->mask = rte_cpu_to_le_64(1 << I40E_RX_DESC_STATUS_DD_SHIFT); /* registers are 64-bit */ diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c index 87f7eebc65..d8d9cc860c 100644 --- a/drivers/net/iavf/iavf_rxtx.c +++ b/drivers/net/iavf/iavf_rxtx.c @@ -73,7 +73,7 @@ iavf_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc) * we expect the DD bit to be set to 1 if this descriptor was already * written to. */ - pmc->val = rte_cpu_to_le_64(1 << IAVF_RX_DESC_STATUS_DD_SHIFT); + pmc->val = 0; pmc->mask = rte_cpu_to_le_64(1 << IAVF_RX_DESC_STATUS_DD_SHIFT); /* registers are 64-bit */ diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c index 92fbbc18da..4e349bfa3f 100644 --- a/drivers/net/ice/ice_rxtx.c +++ b/drivers/net/ice/ice_rxtx.c @@ -43,7 +43,7 @@ ice_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc) * we expect the DD bit to be set to 1 if this descriptor was already * written to. */ - pmc->val = rte_cpu_to_le_16(1 << ICE_RX_FLEX_DESC_STATUS0_DD_S); + pmc->val = 0; pmc->mask = rte_cpu_to_le_16(1 << ICE_RX_FLEX_DESC_STATUS0_DD_S); /* register is 16-bit */ diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c index d69f36e977..2793718171 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx.c +++ b/drivers/net/ixgbe/ixgbe_rxtx.c @@ -1385,7 +1385,7 @@ ixgbe_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc) * we expect the DD bit to be set to 1 if this descriptor was already * written to. */ - pmc->val = rte_cpu_to_le_32(IXGBE_RXDADV_STAT_DD); + pmc->val = 0; pmc->mask = rte_cpu_to_le_32(IXGBE_RXDADV_STAT_DD); /* the registers are 32-bit */ diff --git a/drivers/net/mlx5/mlx5_rx.c b/drivers/net/mlx5/mlx5_rx.c index 6cd71a44eb..3cbbe5bf59 100644 --- a/drivers/net/mlx5/mlx5_rx.c +++ b/drivers/net/mlx5/mlx5_rx.c @@ -282,7 +282,7 @@ int mlx5_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc) return -rte_errno; } pmc->addr = &cqe->op_own; - pmc->val = !!idx; + pmc->val = !idx; pmc->mask = MLX5_CQE_OWNER_MASK; pmc->size = sizeof(uint8_t); return 0; diff --git a/lib/eal/include/generic/rte_power_intrinsics.h b/lib/eal/include/generic/rte_power_intrinsics.h index dddca3d41c..28c481a8d2 100644 --- a/lib/eal/include/generic/rte_power_intrinsics.h +++ b/lib/eal/include/generic/rte_power_intrinsics.h @@ -45,10 +45,10 @@ struct rte_power_monitor_cond { * Additionally, an expected value (`pmc->val`), mask (`pmc->mask`), and data * size (`pmc->size`) are provided in the `pmc` power monitoring condition. If * the mask is non-zero, the current value pointed to by the `pmc->addr` pointer - * will be read and compared against the expected value, and if they match, the - * entering of optimized power state will be aborted. This is intended to - * prevent the CPU from entering optimized power state and waiting on a write - * that has already happened by the time this API is called. + * will be read and compared against the expected value, and if they do not + * match, the entering of optimized power state will be aborted. This is + * intended to prevent the CPU from entering optimized power state and waiting + * on a write that has already happened by the time this API is called. * * @warning It is responsibility of the user to check if this function is * supported at runtime using `rte_cpu_get_intrinsics_support()` API call. diff --git a/lib/eal/x86/rte_power_intrinsics.c b/lib/eal/x86/rte_power_intrinsics.c index 39ea9fdecd..7f0588d70e 100644 --- a/lib/eal/x86/rte_power_intrinsics.c +++ b/lib/eal/x86/rte_power_intrinsics.c @@ -116,8 +116,8 @@ rte_power_monitor(const struct rte_power_monitor_cond *pmc, pmc->addr, pmc->size); const uint64_t masked = cur_value & pmc->mask; - /* if the masked value is already matching, abort */ - if (masked == pmc->val) + /* if the masked value is not matching, abort */ + if (masked != pmc->val) goto end; } From patchwork Tue May 11 15:31:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Burakov, Anatoly" X-Patchwork-Id: 93168 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 70338A0A0E; Tue, 11 May 2021 17:33:16 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5F008410E9; Tue, 11 May 2021 17:33:16 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 320B54003E for ; Tue, 11 May 2021 17:33:14 +0200 (CEST) IronPort-SDR: VY/cOy1Sg3lZmWdP9J9cY6/GLWUV331YUS+9YYDOTtBVyahF9o8o/gUsXZAQK6OXfdDCcK7LTW d3FjLDWxSYcQ== X-IronPort-AV: E=McAfee;i="6200,9189,9981"; a="199523980" X-IronPort-AV: E=Sophos;i="5.82,291,1613462400"; d="scan'208";a="199523980" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 08:33:10 -0700 IronPort-SDR: 5rdoI6KC2wzHYJsiiBQvpzt2o50Z1wOH9RfpLGgRKhLjPKxjnw5l+VWfRAaGjGumN09hGvEt2h dsufRt7V+erw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,291,1613462400"; d="scan'208";a="471162608" Received: from silpixa00399498.ir.intel.com (HELO silpixa00399498.ger.corp.intel.com) ([10.237.223.81]) by orsmga001.jf.intel.com with ESMTP; 11 May 2021 08:32:57 -0700 From: Anatoly Burakov To: dev@dpdk.org, Ciara Loftus , Qi Zhang Date: Tue, 11 May 2021 15:31:53 +0000 Message-Id: <9dabec2f673cbf733a958a23a9769802e9adf852.1620747068.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <819ef1ace187365a615d3383e54579e3d9fb216e.1620747068.git.anatoly.burakov@intel.com> References: <819ef1ace187365a615d3383e54579e3d9fb216e.1620747068.git.anatoly.burakov@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [21.08 PATCH v1 2/2] net/af_xdp: add power monitor support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Implement support for .get_monitor_addr in AF_XDP driver. Signed-off-by: Anatoly Burakov --- drivers/net/af_xdp/rte_eth_af_xdp.c | 52 ++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c index 0c91a40c4a..a4b4a4b75d 100644 --- a/drivers/net/af_xdp/rte_eth_af_xdp.c +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c @@ -37,6 +37,7 @@ #include #include #include +#include #include "compat.h" @@ -778,6 +779,26 @@ eth_dev_configure(struct rte_eth_dev *dev) return 0; } +static int +eth_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc) +{ + struct pkt_rx_queue *rxq = rx_queue; + unsigned int *prod = rxq->fq.producer; + const uint32_t cur_val = rxq->fq.cached_prod; /* use cached value */ + + /* watch for changes in producer ring */ + pmc->addr = (void*)prod; + + /* store current value */ + pmc->val = cur_val; + pmc->mask = (uint32_t)~0; /* mask entire uint32_t value */ + + /* AF_XDP producer ring index is 32-bit */ + pmc->size = sizeof(uint32_t); + + return 0; +} + static int eth_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) { @@ -1423,21 +1444,22 @@ eth_dev_promiscuous_disable(struct rte_eth_dev *dev) } static const struct eth_dev_ops ops = { - .dev_start = eth_dev_start, - .dev_stop = eth_dev_stop, - .dev_close = eth_dev_close, - .dev_configure = eth_dev_configure, - .dev_infos_get = eth_dev_info, - .mtu_set = eth_dev_mtu_set, - .promiscuous_enable = eth_dev_promiscuous_enable, - .promiscuous_disable = eth_dev_promiscuous_disable, - .rx_queue_setup = eth_rx_queue_setup, - .tx_queue_setup = eth_tx_queue_setup, - .rx_queue_release = eth_queue_release, - .tx_queue_release = eth_queue_release, - .link_update = eth_link_update, - .stats_get = eth_stats_get, - .stats_reset = eth_stats_reset, + .dev_start = eth_dev_start, + .dev_stop = eth_dev_stop, + .dev_close = eth_dev_close, + .dev_configure = eth_dev_configure, + .dev_infos_get = eth_dev_info, + .mtu_set = eth_dev_mtu_set, + .promiscuous_enable = eth_dev_promiscuous_enable, + .promiscuous_disable = eth_dev_promiscuous_disable, + .rx_queue_setup = eth_rx_queue_setup, + .tx_queue_setup = eth_tx_queue_setup, + .rx_queue_release = eth_queue_release, + .tx_queue_release = eth_queue_release, + .link_update = eth_link_update, + .stats_get = eth_stats_get, + .stats_reset = eth_stats_reset, + .get_monitor_addr = eth_get_monitor_addr }; /** parse busy_budget argument */