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"
13 #define FD_PATH "/dev/virtio-ports/virtio.serial.port.poweragent"
15 static struct rte_power_channel_packet pkt[RTE_MAX_LCORE];
18 power_kvm_vm_check_supported(void)
20 return guest_channel_host_check_exists(FD_PATH);
24 power_kvm_vm_init(unsigned int lcore_id)
26 if (lcore_id >= RTE_MAX_LCORE) {
27 RTE_LOG(ERR, POWER, "Core(%u) is out of range 0...%d\n",
28 lcore_id, RTE_MAX_LCORE-1);
31 pkt[lcore_id].command = RTE_POWER_CPU_POWER;
32 pkt[lcore_id].resource_id = lcore_id;
33 return guest_channel_host_connect(FD_PATH, lcore_id);
37 power_kvm_vm_exit(unsigned int lcore_id)
39 guest_channel_host_disconnect(lcore_id);
44 power_kvm_vm_freqs(__rte_unused unsigned int lcore_id,
45 __rte_unused uint32_t *freqs,
46 __rte_unused uint32_t num)
48 RTE_LOG(ERR, POWER, "rte_power_freqs is not implemented "
49 "for Virtual Machine Power Management\n");
54 power_kvm_vm_get_freq(__rte_unused unsigned int lcore_id)
56 RTE_LOG(ERR, POWER, "rte_power_get_freq is not implemented "
57 "for Virtual Machine Power Management\n");
62 power_kvm_vm_set_freq(__rte_unused unsigned int lcore_id,
63 __rte_unused uint32_t index)
65 RTE_LOG(ERR, POWER, "rte_power_set_freq is not implemented "
66 "for Virtual Machine Power Management\n");
71 send_msg(unsigned int lcore_id, uint32_t scale_direction)
75 if (lcore_id >= RTE_MAX_LCORE) {
76 RTE_LOG(ERR, POWER, "Core(%u) is out of range 0...%d\n",
77 lcore_id, RTE_MAX_LCORE-1);
80 pkt[lcore_id].unit = scale_direction;
81 ret = guest_channel_send_msg(&pkt[lcore_id], lcore_id);
84 RTE_LOG(DEBUG, POWER, "Error sending message: %s\n",
85 ret > 0 ? strerror(ret) : "channel not connected");
90 power_kvm_vm_freq_up(unsigned int lcore_id)
92 return send_msg(lcore_id, RTE_POWER_SCALE_UP);
96 power_kvm_vm_freq_down(unsigned int lcore_id)
98 return send_msg(lcore_id, RTE_POWER_SCALE_DOWN);
102 power_kvm_vm_freq_max(unsigned int lcore_id)
104 return send_msg(lcore_id, RTE_POWER_SCALE_MAX);
108 power_kvm_vm_freq_min(unsigned int lcore_id)
110 return send_msg(lcore_id, RTE_POWER_SCALE_MIN);
114 power_kvm_vm_turbo_status(__rte_unused unsigned int lcore_id)
116 RTE_LOG(ERR, POWER, "rte_power_turbo_status is not implemented for Virtual Machine Power Management\n");
121 power_kvm_vm_enable_turbo(unsigned int lcore_id)
123 return send_msg(lcore_id, RTE_POWER_ENABLE_TURBO);
127 power_kvm_vm_disable_turbo(unsigned int lcore_id)
129 return send_msg(lcore_id, RTE_POWER_DISABLE_TURBO);
132 struct rte_power_core_capabilities;
133 int power_kvm_vm_get_capabilities(__rte_unused unsigned int lcore_id,
134 __rte_unused struct rte_power_core_capabilities *caps)
136 RTE_LOG(ERR, POWER, "rte_power_get_capabilities is not implemented for Virtual Machine Power Management\n");