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: Anatoly Burakov 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 */