1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
9 #include "rte_power_guest_channel.h"
10 #include "guest_channel.h"
11 #include "power_kvm_vm.h"
12 #include "power_common.h"
14 #define FD_PATH "/dev/virtio-ports/virtio.serial.port.poweragent"
16 static struct rte_power_channel_packet pkt[RTE_MAX_LCORE];
19 power_kvm_vm_check_supported(void)
21 return guest_channel_host_check_exists(FD_PATH);
25 power_kvm_vm_init(unsigned int lcore_id)
27 if (lcore_id >= RTE_MAX_LCORE) {
28 RTE_LOG(ERR, POWER, "Core(%u) is out of range 0...%d\n",
29 lcore_id, RTE_MAX_LCORE-1);
32 pkt[lcore_id].command = RTE_POWER_CPU_POWER;
33 pkt[lcore_id].resource_id = lcore_id;
34 return guest_channel_host_connect(FD_PATH, lcore_id);
38 power_kvm_vm_exit(unsigned int lcore_id)
40 guest_channel_host_disconnect(lcore_id);
45 power_kvm_vm_freqs(__rte_unused unsigned int lcore_id,
46 __rte_unused uint32_t *freqs,
47 __rte_unused uint32_t num)
49 RTE_LOG(ERR, POWER, "rte_power_freqs is not implemented "
50 "for Virtual Machine Power Management\n");
55 power_kvm_vm_get_freq(__rte_unused unsigned int lcore_id)
57 RTE_LOG(ERR, POWER, "rte_power_get_freq is not implemented "
58 "for Virtual Machine Power Management\n");
63 power_kvm_vm_set_freq(__rte_unused unsigned int lcore_id,
64 __rte_unused uint32_t index)
66 RTE_LOG(ERR, POWER, "rte_power_set_freq is not implemented "
67 "for Virtual Machine Power Management\n");
72 send_msg(unsigned int lcore_id, uint32_t scale_direction)
76 if (lcore_id >= RTE_MAX_LCORE) {
77 RTE_LOG(ERR, POWER, "Core(%u) is out of range 0...%d\n",
78 lcore_id, RTE_MAX_LCORE-1);
81 pkt[lcore_id].unit = scale_direction;
82 ret = guest_channel_send_msg(&pkt[lcore_id], lcore_id);
85 RTE_LOG(DEBUG, POWER, "Error sending message: %s\n",
86 ret > 0 ? strerror(ret) : "channel not connected");
91 power_kvm_vm_freq_up(unsigned int lcore_id)
93 return send_msg(lcore_id, RTE_POWER_SCALE_UP);
97 power_kvm_vm_freq_down(unsigned int lcore_id)
99 return send_msg(lcore_id, RTE_POWER_SCALE_DOWN);
103 power_kvm_vm_freq_max(unsigned int lcore_id)
105 return send_msg(lcore_id, RTE_POWER_SCALE_MAX);
109 power_kvm_vm_freq_min(unsigned int lcore_id)
111 return send_msg(lcore_id, RTE_POWER_SCALE_MIN);
115 power_kvm_vm_turbo_status(__rte_unused unsigned int lcore_id)
117 RTE_LOG(ERR, POWER, "rte_power_turbo_status is not implemented for Virtual Machine Power Management\n");
122 power_kvm_vm_enable_turbo(unsigned int lcore_id)
124 return send_msg(lcore_id, RTE_POWER_ENABLE_TURBO);
128 power_kvm_vm_disable_turbo(unsigned int lcore_id)
130 return send_msg(lcore_id, RTE_POWER_DISABLE_TURBO);
133 struct rte_power_core_capabilities;
134 int power_kvm_vm_get_capabilities(__rte_unused unsigned int lcore_id,
135 __rte_unused struct rte_power_core_capabilities *caps)
137 RTE_LOG(ERR, POWER, "rte_power_get_capabilities is not implemented for Virtual Machine Power Management\n");