From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 081A7A0544; Fri, 2 Sep 2022 19:20:39 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D9EBC40693; Fri, 2 Sep 2022 19:20:38 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id 4C7C040685 for ; Fri, 2 Sep 2022 19:20:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662139237; x=1693675237; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Iuumtv9X8Vd5gSSWqd92ZiUxOgzAH2mlBxYvTd/mMDY=; b=jRXWM8d6yXc0kMzF/7Y7Be9TIKYP0uiG/nYIM4d+POaxcu2+GHaMnZLG mGRBLRNm9RG6Y3v8eZLS0eIDvyvyzxBkqDvg5ybpPgUAKjn8df3zVL7Lh 02NBO4/2WyZsyJbC4a7xy5oiCc4OoBGrvovoQO+rG22LaBmFPJd/4VKVm HWXjvUFoP8OakAGUm5RGaeFrdkGi6scFcmksAiXZML0mT4eXHUUbC0swO dfx4bOCZzwDyI0O775TRVosD9ScXv6qrHnGyLTYGXhAtc+StxHOIp9DuZ GK2J9r2aX6Y38DcTdYoJ5F3Er9NN6g30NzqH+9BXGTnYFfROGx7k8zxxK Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10458"; a="279043509" X-IronPort-AV: E=Sophos;i="5.93,283,1654585200"; d="scan'208";a="279043509" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Sep 2022 10:20:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,283,1654585200"; d="scan'208";a="788726700" Received: from silpixa00399499.ir.intel.com (HELO silpixa00399499.ger.corp.intel.com) ([10.237.223.138]) by orsmga005.jf.intel.com with ESMTP; 02 Sep 2022 10:20:35 -0700 From: Herakliusz Lipiec To: dev@dpdk.org Cc: anatoly.burakov@intel.com, reshma.pattan@intel.com, bruce.richardson@intel.com, Herakliusz Lipiec Subject: [PATCH v2] net/ring: add monitor callback Date: Fri, 2 Sep 2022 18:25:21 +0100 Message-Id: <20220902172521.3293866-1-herakliusz.lipiec@intel.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220803142845.2221915-1-herakliusz.lipiec@intel.com> References: <20220803142845.2221915-1-herakliusz.lipiec@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Currently ring pmd does not support ``rte_power_monitor`` api. This patch adds support by adding monitor callback that is called whenever we enter sleep state and need to check if it is time to wake up. Signed-off-by: Herakliusz Lipiec Acked-by: Bruce Richardson --- v2: - changed umonitor references to monitor as this is how it appears in dpdk api - fixed coding style issues --- drivers/net/ring/rte_eth_ring.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c index cfb81da5fe..1050c22777 100644 --- a/drivers/net/ring/rte_eth_ring.c +++ b/drivers/net/ring/rte_eth_ring.c @@ -284,6 +284,29 @@ eth_dev_close(struct rte_eth_dev *dev) return ret; } +static int ring_monitor_callback(const uint64_t value, + const uint64_t arg[RTE_POWER_MONITOR_OPAQUE_SZ]) +{ + /* Check if the head pointer has changed */ + return value != arg[0]; +} + +static int +eth_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc) +{ + struct rte_ring *rng = ((struct ring_queue *)rx_queue)->rng; + + /* + * Monitor ring head since if head moves + * there are packets to transmit + */ + pmc->addr = &rng->prod.head; + pmc->size = sizeof(rng->prod.head); + pmc->opaque[0] = rng->prod.head; + pmc->fn = ring_monitor_callback; + return 0; +} + static const struct eth_dev_ops ops = { .dev_close = eth_dev_close, .dev_start = eth_dev_start, @@ -303,6 +326,7 @@ static const struct eth_dev_ops ops = { .promiscuous_disable = eth_promiscuous_disable, .allmulticast_enable = eth_allmulticast_enable, .allmulticast_disable = eth_allmulticast_disable, + .get_monitor_addr = eth_get_monitor_addr, }; static int -- 2.36.1