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 8CE61A00C5; Wed, 3 Aug 2022 16:24:14 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3513140A7E; Wed, 3 Aug 2022 16:24:14 +0200 (CEST) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 0457B40141 for ; Wed, 3 Aug 2022 16:24:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659536653; x=1691072653; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=zrMBmkAYK6ZDf08IYD7yx1duDT4BCNtOpsaKsgV0fGI=; b=W/DxOGVWY5IEom7iy0xOwUmRh+wqBsJYPst27DRnTxKfbIMlj42Av+QT qWK/RCg9QreRqMyGh1gzkQBXXxt9IOM6iCu8DhOGy9RkfhF3MpkbG2haM g23aif0U7DLdWcl/4X3iUvVurbpaZinYzbMd5e+idSdHMt6wky+lxo3sv 1Dqm59VCgyB3y5iDKAr1mm+8Y+qQC5d91szwJfOOQaxHjiXLnseOvLBI2 SQqRXmx78j+5rttOVzCyQ8IqznfXbvPxXYIbA7YQMFvOQWhV4UyZN8rLS jbIGEkfGnpprAlwOJb5Gr1RMno9rp7Fi4CxFUU2BmINIGNW+3EivEoi3z A==; X-IronPort-AV: E=McAfee;i="6400,9594,10428"; a="351396406" X-IronPort-AV: E=Sophos;i="5.93,214,1654585200"; d="scan'208";a="351396406" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2022 07:24:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,214,1654585200"; d="scan'208";a="553340923" Received: from silpixa00399499.ir.intel.com (HELO silpixa00399499.ger.corp.intel.com) ([10.237.223.138]) by orsmga003.jf.intel.com with ESMTP; 03 Aug 2022 07:24:10 -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] net/ring: add umonitor callback Date: Wed, 3 Aug 2022 15:28:45 +0100 Message-Id: <20220803142845.2221915-1-herakliusz.lipiec@intel.com> X-Mailer: git-send-email 2.36.1 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 umonitor 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 --- drivers/net/ring/rte_eth_ring.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c index cfb81da5fe..1bb6b196cb 100644 --- a/drivers/net/ring/rte_eth_ring.c +++ b/drivers/net/ring/rte_eth_ring.c @@ -284,6 +284,28 @@ 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 +325,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