/* Convert vcpu to pcpu. */
struct vm_info info;
int pcpu, count;
- uint64_t mask_u64b;
struct core_info *ci;
ci = get_core_info();
- RTE_LOG(INFO, CHANNEL_MONITOR,
+ RTE_LOG(DEBUG, CHANNEL_MONITOR,
"Looking for pcpu for %s\n", pol->pkt.vm_name);
/*
*/
get_info_vm(pol->pkt.vm_name, &info);
for (count = 0; count < pol->pkt.num_vcpu; count++) {
- mask_u64b =
- info.pcpu_mask[pol->pkt.vcpu_to_control[count]];
- for (pcpu = 0; mask_u64b;
- mask_u64b &= ~(1ULL << pcpu++)) {
- if ((mask_u64b >> pcpu) & 1)
- pcpu_monitor(pol, ci, pcpu, count);
- }
+ pcpu = info.pcpu_map[pol->pkt.vcpu_to_control[count]];
+ pcpu_monitor(pol, ci, pcpu, count);
}
} else {
/*
/* Copy the contents of *pkt into the policy.pkt */
policies[i].pkt = *pkt;
get_pcpu_to_control(&policies[i]);
- if (get_pfid(&policies[i]) == -1) {
+ if (get_pfid(&policies[i]) < 0) {
updated = 1;
break;
}
if (policies[i].enabled == 0) {
policies[i].pkt = *pkt;
get_pcpu_to_control(&policies[i]);
- if (get_pfid(&policies[i]) == -1)
+ if (get_pfid(&policies[i]) < 0)
break;
core_share_status(i);
policies[i].enabled = 1;
diff = get_pkt_diff(pol);
- RTE_LOG(INFO, CHANNEL_MONITOR, "Applying traffic profile\n");
-
if (diff >= (pol->pkt.traffic_policy.max_max_packet_thresh)) {
for (count = 0; count < pol->pkt.num_vcpu; count++) {
if (pol->core_share[count].status != 1)
if (pol->core_share[count].status != 1) {
power_manager_scale_core_max(
pol->core_share[count].pcpu);
- RTE_LOG(INFO, CHANNEL_MONITOR,
- "Scaling up core %d to max\n",
- pol->core_share[count].pcpu);
}
}
break;
if (pol->core_share[count].status != 1) {
power_manager_scale_core_min(
pol->core_share[count].pcpu);
- RTE_LOG(INFO, CHANNEL_MONITOR,
- "Scaling down core %d to min\n",
- pol->core_share[count].pcpu);
}
}
break;
static int
process_request(struct channel_packet *pkt, struct channel_info *chan_info)
{
- uint64_t core_mask;
+ int ret;
if (chan_info == NULL)
return -1;
- RTE_LOG(INFO, CHANNEL_MONITOR, "Processing Request %s\n", pkt->vm_name);
-
if (rte_atomic32_cmpset(&(chan_info->status), CHANNEL_MGR_CHANNEL_CONNECTED,
CHANNEL_MGR_CHANNEL_PROCESSING) == 0)
return -1;
if (pkt->command == CPU_POWER) {
- core_mask = get_pcpus_mask(chan_info, pkt->resource_id);
- if (core_mask == 0) {
- /*
- * Core mask will be 0 in the case where
- * hypervisor is not available so we're working in
- * the host, so use the core as the mask.
- */
- core_mask = 1ULL << pkt->resource_id;
- }
- if (__builtin_popcountll(core_mask) == 1) {
+ unsigned int core_num;
- unsigned core_num = __builtin_ffsll(core_mask) - 1;
+ if (pkt->core_type == CORE_TYPE_VIRTUAL)
+ core_num = get_pcpu(chan_info, pkt->resource_id);
+ else
+ core_num = pkt->resource_id;
- switch (pkt->unit) {
- case(CPU_POWER_SCALE_MIN):
- power_manager_scale_core_min(core_num);
- break;
- case(CPU_POWER_SCALE_MAX):
- power_manager_scale_core_max(core_num);
- break;
- case(CPU_POWER_SCALE_DOWN):
- power_manager_scale_core_down(core_num);
- break;
- case(CPU_POWER_SCALE_UP):
- power_manager_scale_core_up(core_num);
- break;
- case(CPU_POWER_ENABLE_TURBO):
- power_manager_enable_turbo_core(core_num);
- break;
- case(CPU_POWER_DISABLE_TURBO):
- power_manager_disable_turbo_core(core_num);
+ RTE_LOG(DEBUG, CHANNEL_MONITOR, "Processing requested cmd for cpu:%d\n",
+ core_num);
+
+ switch (pkt->unit) {
+ case(CPU_POWER_SCALE_MIN):
+ power_manager_scale_core_min(core_num);
break;
- default:
- break;
- }
- } else {
- switch (pkt->unit) {
- case(CPU_POWER_SCALE_MIN):
- power_manager_scale_mask_min(core_mask);
+ case(CPU_POWER_SCALE_MAX):
+ power_manager_scale_core_max(core_num);
break;
- case(CPU_POWER_SCALE_MAX):
- power_manager_scale_mask_max(core_mask);
+ case(CPU_POWER_SCALE_DOWN):
+ power_manager_scale_core_down(core_num);
break;
- case(CPU_POWER_SCALE_DOWN):
- power_manager_scale_mask_down(core_mask);
+ case(CPU_POWER_SCALE_UP):
+ power_manager_scale_core_up(core_num);
break;
- case(CPU_POWER_SCALE_UP):
- power_manager_scale_mask_up(core_mask);
+ case(CPU_POWER_ENABLE_TURBO):
+ power_manager_enable_turbo_core(core_num);
break;
- case(CPU_POWER_ENABLE_TURBO):
- power_manager_enable_turbo_mask(core_mask);
+ case(CPU_POWER_DISABLE_TURBO):
+ power_manager_disable_turbo_core(core_num);
break;
- case(CPU_POWER_DISABLE_TURBO):
- power_manager_disable_turbo_mask(core_mask);
+ default:
break;
- default:
- break;
- }
-
}
}
if (pkt->command == PKT_POLICY) {
- RTE_LOG(INFO, CHANNEL_MONITOR,
- "\nProcessing Policy request\n");
+ RTE_LOG(INFO, CHANNEL_MONITOR, "Processing policy request %s\n",
+ pkt->vm_name);
update_policy(pkt);
policy_is_set = 1;
}
if (pkt->command == PKT_POLICY_REMOVE) {
- RTE_LOG(INFO, CHANNEL_MONITOR,
- "Removing policy %s\n", pkt->vm_name);
- remove_policy(pkt);
+ ret = remove_policy(pkt);
+ if (ret == 0)
+ RTE_LOG(INFO, CHANNEL_MONITOR,
+ "Removed policy %s\n", pkt->vm_name);
+ else
+ RTE_LOG(INFO, CHANNEL_MONITOR,
+ "Policy %s does not exist\n", pkt->vm_name);
}
/*
buffer, buffer_len);
if (n_bytes == buffer_len)
break;
- if (n_bytes == -1) {
+ if (n_bytes < 0) {
err = errno;
RTE_LOG(DEBUG, CHANNEL_MONITOR,
"Received error on "
global_events_list[i].data.ptr;
if ((global_events_list[i].events & EPOLLERR) ||
(global_events_list[i].events & EPOLLHUP)) {
- RTE_LOG(DEBUG, CHANNEL_MONITOR, "Remote closed connection for "
+ RTE_LOG(INFO, CHANNEL_MONITOR,
+ "Remote closed connection for "
"channel '%s'\n",
chan_info->channel_path);
remove_channel(&chan_info);