[v2] net/ring: add monitor callback

Message ID 20220902172521.3293866-1-herakliusz.lipiec@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Andrew Rybchenko
Headers
Series [v2] net/ring: add monitor callback |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS

Commit Message

Herakliusz Lipiec Sept. 2, 2022, 5:25 p.m. UTC
  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 <herakliusz.lipiec@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>

---
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(+)
  

Comments

Andrew Rybchenko Oct. 4, 2022, 3:12 p.m. UTC | #1
On 9/2/22 20:25, Herakliusz Lipiec wrote:
> 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 <herakliusz.lipiec@intel.com>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>

Applied to dpdk-next-net/main, thanks.
  

Patch

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