examples/guest_cli: fix hardcoded lcoreid

Message ID 20190328112841.13848-1-marcinx.hajkowski@intel.com
State Changes Requested, archived
Delegated to: Thomas Monjalon
Headers show
Series
  • examples/guest_cli: fix hardcoded lcoreid
Related show

Checks

Context Check Description
ci/intel-Performance-Testing success Performance Testing PASS
ci/mellanox-Performance-Testing fail Performance Testing issues
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Hajkowski March 28, 2019, 11:28 a.m.
From: Marcin Hajkowski <marcinx.hajkowski@intel.com>

In current implementation lcoreid 1 is used regardless
of currently available cores. This change introduce dynamic
core selection for sending policy.

Fixes: d191f08533 ("examples/guest_cli: add send policy to host")
Cc: stable@dpdk.org

Signed-off-by: Marcin Hajkowski <marcinx.hajkowski@intel.com>
---
 .../vm_power_manager/guest_cli/vm_power_cli_guest.c    | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

Pattan, Reshma April 1, 2019, 4:09 p.m. | #1
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Hajkowski
> +	if (lcore_id == RTE_MAX_LCORE)
> +		return -1;

This check is already performed by rte_power_guest_channel_send_msg(). So it would be redundant here.

Thanks,
Reshma

Patch

diff --git a/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c b/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c
index 2d9e7689a..bd3cee904 100644
--- a/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c
+++ b/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c
@@ -188,8 +188,16 @@  static inline int
 send_policy(struct channel_packet *pkt)
 {
 	int ret;
+	unsigned int lcore_id;
 
-	ret = rte_power_guest_channel_send_msg(pkt, 1);
+	/* Get first enabled lcore. */
+	lcore_id = rte_get_next_lcore(-1,
+			0,
+			0);
+	if (lcore_id == RTE_MAX_LCORE)
+		return -1;
+
+	ret = rte_power_guest_channel_send_msg(pkt, lcore_id);
 	if (ret == 0)
 		return 1;
 	RTE_LOG(DEBUG, POWER, "Error sending message: %s\n",