+ if (!freq_list && vcore_id >= RTE_POWER_MAX_VCPU_PER_VM)
+ return -1;
+
+ if (!info.allow_query)
+ return -1;
+
+ channel_pkt_freq_list.command = RTE_POWER_FREQ_LIST;
+ channel_pkt_freq_list.num_vcpu = info.num_vcpus;
+
+ if (freq_list) {
+ unsigned int i;
+ for (i = 0; i < info.num_vcpus; i++)
+ channel_pkt_freq_list.freq_list[i] =
+ power_manager_get_current_frequency(info.pcpu_map[i]);
+ } else {
+ channel_pkt_freq_list.freq_list[vcore_id] =
+ power_manager_get_current_frequency(info.pcpu_map[vcore_id]);
+ }
+
+ return write_binary_packet(&channel_pkt_freq_list,
+ sizeof(channel_pkt_freq_list),
+ chan_info);
+}
+
+static int
+send_capabilities(struct rte_power_channel_packet *pkt,
+ struct channel_info *chan_info,
+ bool list_requested)
+{
+ unsigned int vcore_id = pkt->resource_id;
+ struct rte_power_channel_packet_caps_list channel_pkt_caps_list;
+ struct vm_info info;
+ struct rte_power_core_capabilities caps;
+ int ret;
+
+ if (get_info_vm(pkt->vm_name, &info) != 0)
+ return -1;
+
+ if (!list_requested && vcore_id >= RTE_POWER_MAX_VCPU_PER_VM)
+ return -1;
+
+ if (!info.allow_query)
+ return -1;
+
+ channel_pkt_caps_list.command = RTE_POWER_CAPS_LIST;
+ channel_pkt_caps_list.num_vcpu = info.num_vcpus;
+
+ if (list_requested) {
+ unsigned int i;
+ for (i = 0; i < info.num_vcpus; i++) {
+ ret = rte_power_get_capabilities(info.pcpu_map[i],
+ &caps);
+ if (ret == 0) {
+ channel_pkt_caps_list.turbo[i] =
+ caps.turbo;
+ channel_pkt_caps_list.priority[i] =
+ caps.priority;
+ } else
+ return -1;
+
+ }
+ } else {
+ ret = rte_power_get_capabilities(info.pcpu_map[vcore_id],
+ &caps);
+ if (ret == 0) {
+ channel_pkt_caps_list.turbo[vcore_id] =
+ caps.turbo;
+ channel_pkt_caps_list.priority[vcore_id] =
+ caps.priority;
+ } else
+ return -1;
+ }
+
+ return write_binary_packet(&channel_pkt_caps_list,
+ sizeof(channel_pkt_caps_list),
+ chan_info);
+}
+
+static int
+send_ack_for_received_cmd(struct rte_power_channel_packet *pkt,
+ struct channel_info *chan_info,
+ uint32_t command)
+{
+ pkt->command = command;
+ return write_binary_packet(pkt,
+ sizeof(*pkt),
+ chan_info);
+}
+
+static int
+process_request(struct rte_power_channel_packet *pkt,
+ struct channel_info *chan_info)
+{
+ int ret;
+
+ if (chan_info == NULL)
+ return -1;