1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
13 #include <sys/types.h>
14 #include <sys/epoll.h>
15 #include <sys/queue.h>
17 #include <sys/socket.h>
18 #include <sys/select.h>
22 #pragma message "Jansson dev libs unavailable, not including JSON parsing"
24 #include <rte_string_fns.h>
26 #include <rte_memory.h>
27 #include <rte_malloc.h>
28 #include <rte_atomic.h>
29 #include <rte_cycles.h>
30 #include <rte_ethdev.h>
31 #include <rte_pmd_i40e.h>
33 #include <libvirt/libvirt.h>
34 #include "channel_monitor.h"
35 #include "channel_commands.h"
36 #include "channel_manager.h"
37 #include "power_manager.h"
38 #include "oob_monitor.h"
40 #define RTE_LOGTYPE_CHANNEL_MONITOR RTE_LOGTYPE_USER1
42 #define MAX_EVENTS 256
44 uint64_t vsi_pkt_count_prev[384];
45 uint64_t rdtsc_prev[384];
46 #define MAX_JSON_STRING_LEN 1024
47 char json_data[MAX_JSON_STRING_LEN];
49 double time_period_ms = 1;
50 static volatile unsigned run_loop = 1;
51 static int global_event_fd;
52 static unsigned int policy_is_set;
53 static struct epoll_event *global_events_list;
54 static struct policy policies[RTE_MAX_LCORE];
59 struct rte_ether_addr addr;
64 str_to_ether_addr(const char *a, struct rte_ether_addr *ether_addr)
68 unsigned long o[RTE_ETHER_ADDR_LEN];
73 o[i] = strtoul(a, &end, 16);
74 if (errno != 0 || end == a || (end[0] != ':' && end[0] != 0))
77 } while (++i != RTE_DIM(o) / sizeof(o[0]) && end[0] != 0);
79 /* Junk at the end of line */
83 /* Support the format XX:XX:XX:XX:XX:XX */
84 if (i == RTE_ETHER_ADDR_LEN) {
88 ether_addr->addr_bytes[i] = (uint8_t)o[i];
90 /* Support the format XXXX:XXXX:XXXX */
91 } else if (i == RTE_ETHER_ADDR_LEN / 2) {
93 if (o[i] > UINT16_MAX)
95 ether_addr->addr_bytes[i * 2] =
97 ether_addr->addr_bytes[i * 2 + 1] =
98 (uint8_t)(o[i] & 0xff);
108 set_policy_mac(struct channel_packet *pkt, int idx, char *mac)
113 /* Use port MAC address as the vfid */
114 ret = str_to_ether_addr(mac, &pfid.addr);
117 RTE_LOG(ERR, CHANNEL_MONITOR,
118 "Invalid mac address received in JSON\n");
123 printf("Received MAC Address: %02" PRIx8 ":%02" PRIx8 ":%02" PRIx8 ":"
124 "%02" PRIx8 ":%02" PRIx8 ":%02" PRIx8 "\n",
125 pfid.addr.addr_bytes[0], pfid.addr.addr_bytes[1],
126 pfid.addr.addr_bytes[2], pfid.addr.addr_bytes[3],
127 pfid.addr.addr_bytes[4], pfid.addr.addr_bytes[5]);
129 pkt->vfid[idx] = pfid.pfid;
134 get_resource_name_from_chn_path(const char *channel_path)
138 substr = strstr(channel_path, CHANNEL_MGR_FIFO_PATTERN_NAME);
144 get_resource_id_from_vmname(const char *vm_name)
152 while (vm_name[off] != '\0') {
153 if (isdigit(vm_name[off]))
157 result = atoi(&vm_name[off]);
158 if ((result == 0) && (vm_name[off] != '0'))
165 parse_json_to_pkt(json_t *element, struct channel_packet *pkt,
173 memset(pkt, 0, sizeof(struct channel_packet));
175 pkt->nb_mac_to_monitor = 0;
176 pkt->t_boost_status.tbEnabled = false;
178 pkt->policy_to_use = TIME;
179 pkt->command = PKT_POLICY;
180 pkt->core_type = CORE_TYPE_PHYSICAL;
182 if (vm_name == NULL) {
183 RTE_LOG(ERR, CHANNEL_MONITOR,
184 "vm_name is NULL, request rejected !\n");
188 json_object_foreach(element, key, value) {
189 if (!strcmp(key, "policy")) {
190 /* Recurse in to get the contents of profile */
191 ret = parse_json_to_pkt(value, pkt, vm_name);
194 } else if (!strcmp(key, "instruction")) {
195 /* Recurse in to get the contents of instruction */
196 ret = parse_json_to_pkt(value, pkt, vm_name);
199 } else if (!strcmp(key, "command")) {
201 strlcpy(command, json_string_value(value), 32);
202 if (!strcmp(command, "power")) {
203 pkt->command = CPU_POWER;
204 } else if (!strcmp(command, "create")) {
205 pkt->command = PKT_POLICY;
206 } else if (!strcmp(command, "destroy")) {
207 pkt->command = PKT_POLICY_REMOVE;
209 RTE_LOG(ERR, CHANNEL_MONITOR,
210 "Invalid command received in JSON\n");
213 } else if (!strcmp(key, "policy_type")) {
215 strlcpy(command, json_string_value(value), 32);
216 if (!strcmp(command, "TIME")) {
217 pkt->policy_to_use = TIME;
218 } else if (!strcmp(command, "TRAFFIC")) {
219 pkt->policy_to_use = TRAFFIC;
220 } else if (!strcmp(command, "WORKLOAD")) {
221 pkt->policy_to_use = WORKLOAD;
222 } else if (!strcmp(command, "BRANCH_RATIO")) {
223 pkt->policy_to_use = BRANCH_RATIO;
225 RTE_LOG(ERR, CHANNEL_MONITOR,
226 "Wrong policy_type received in JSON\n");
229 } else if (!strcmp(key, "workload")) {
231 strlcpy(command, json_string_value(value), 32);
232 if (!strcmp(command, "HIGH")) {
233 pkt->workload = HIGH;
234 } else if (!strcmp(command, "MEDIUM")) {
235 pkt->workload = MEDIUM;
236 } else if (!strcmp(command, "LOW")) {
239 RTE_LOG(ERR, CHANNEL_MONITOR,
240 "Wrong workload received in JSON\n");
243 } else if (!strcmp(key, "busy_hours")) {
245 size_t size = json_array_size(value);
247 for (i = 0; i < size; i++) {
248 int hour = (int)json_integer_value(
249 json_array_get(value, i));
250 pkt->timer_policy.busy_hours[i] = hour;
252 } else if (!strcmp(key, "quiet_hours")) {
254 size_t size = json_array_size(value);
256 for (i = 0; i < size; i++) {
257 int hour = (int)json_integer_value(
258 json_array_get(value, i));
259 pkt->timer_policy.quiet_hours[i] = hour;
261 } else if (!strcmp(key, "mac_list")) {
263 size_t size = json_array_size(value);
265 for (i = 0; i < size; i++) {
268 json_string_value(json_array_get(value, i)),
270 set_policy_mac(pkt, i, mac);
272 pkt->nb_mac_to_monitor = size;
273 } else if (!strcmp(key, "avg_packet_thresh")) {
274 pkt->traffic_policy.avg_max_packet_thresh =
275 (uint32_t)json_integer_value(value);
276 } else if (!strcmp(key, "max_packet_thresh")) {
277 pkt->traffic_policy.max_max_packet_thresh =
278 (uint32_t)json_integer_value(value);
279 } else if (!strcmp(key, "unit")) {
281 strlcpy(unit, json_string_value(value), 32);
282 if (!strcmp(unit, "SCALE_UP")) {
283 pkt->unit = CPU_POWER_SCALE_UP;
284 } else if (!strcmp(unit, "SCALE_DOWN")) {
285 pkt->unit = CPU_POWER_SCALE_DOWN;
286 } else if (!strcmp(unit, "SCALE_MAX")) {
287 pkt->unit = CPU_POWER_SCALE_MAX;
288 } else if (!strcmp(unit, "SCALE_MIN")) {
289 pkt->unit = CPU_POWER_SCALE_MIN;
290 } else if (!strcmp(unit, "ENABLE_TURBO")) {
291 pkt->unit = CPU_POWER_ENABLE_TURBO;
292 } else if (!strcmp(unit, "DISABLE_TURBO")) {
293 pkt->unit = CPU_POWER_DISABLE_TURBO;
295 RTE_LOG(ERR, CHANNEL_MONITOR,
296 "Invalid command received in JSON\n");
300 RTE_LOG(ERR, CHANNEL_MONITOR,
301 "Unknown key received in JSON string: %s\n",
305 resource_id = get_resource_id_from_vmname(vm_name);
306 if (resource_id < 0) {
307 RTE_LOG(ERR, CHANNEL_MONITOR,
308 "Could not get resource_id from vm_name:%s\n",
312 strlcpy(pkt->vm_name, vm_name, VM_MAX_NAME_SZ);
313 pkt->resource_id = resource_id;
319 void channel_monitor_exit(void)
322 rte_free(global_events_list);
326 core_share(int pNo, int z, int x, int t)
328 if (policies[pNo].core_share[z].pcpu == lvm_info[x].pcpus[t]) {
329 if (strcmp(policies[pNo].pkt.vm_name,
330 lvm_info[x].vm_name) != 0) {
331 policies[pNo].core_share[z].status = 1;
332 power_manager_scale_core_max(
333 policies[pNo].core_share[z].pcpu);
339 core_share_status(int pNo)
342 int noVms = 0, noVcpus = 0, z, x, t;
344 get_all_vm(&noVms, &noVcpus);
346 /* Reset Core Share Status. */
347 for (z = 0; z < noVcpus; z++)
348 policies[pNo].core_share[z].status = 0;
350 /* Foreach vcpu in a policy. */
351 for (z = 0; z < policies[pNo].pkt.num_vcpu; z++) {
352 /* Foreach VM on the platform. */
353 for (x = 0; x < noVms; x++) {
354 /* Foreach vcpu of VMs on platform. */
355 for (t = 0; t < lvm_info[x].num_cpus; t++)
356 core_share(pNo, z, x, t);
363 pcpu_monitor(struct policy *pol, struct core_info *ci, int pcpu, int count)
367 if (pol->pkt.policy_to_use == BRANCH_RATIO) {
368 ci->cd[pcpu].oob_enabled = 1;
369 ret = add_core_to_monitor(pcpu);
371 RTE_LOG(INFO, CHANNEL_MONITOR,
372 "Monitoring pcpu %d OOB for %s\n",
373 pcpu, pol->pkt.vm_name);
375 RTE_LOG(ERR, CHANNEL_MONITOR,
376 "Error monitoring pcpu %d OOB for %s\n",
377 pcpu, pol->pkt.vm_name);
380 pol->core_share[count].pcpu = pcpu;
381 RTE_LOG(INFO, CHANNEL_MONITOR,
382 "Monitoring pcpu %d for %s\n",
383 pcpu, pol->pkt.vm_name);
389 get_pcpu_to_control(struct policy *pol)
392 /* Convert vcpu to pcpu. */
395 struct core_info *ci;
397 ci = get_core_info();
399 RTE_LOG(DEBUG, CHANNEL_MONITOR,
400 "Looking for pcpu for %s\n", pol->pkt.vm_name);
403 * So now that we're handling virtual and physical cores, we need to
404 * differenciate between them when adding them to the branch monitor.
405 * Virtual cores need to be converted to physical cores.
407 if (pol->pkt.core_type == CORE_TYPE_VIRTUAL) {
409 * If the cores in the policy are virtual, we need to map them
410 * to physical core. We look up the vm info and use that for
413 get_info_vm(pol->pkt.vm_name, &info);
414 for (count = 0; count < pol->pkt.num_vcpu; count++) {
415 pcpu = info.pcpu_map[pol->pkt.vcpu_to_control[count]];
416 pcpu_monitor(pol, ci, pcpu, count);
420 * If the cores in the policy are physical, we just use
421 * those core id's directly.
423 for (count = 0; count < pol->pkt.num_vcpu; count++) {
424 pcpu = pol->pkt.vcpu_to_control[count];
425 pcpu_monitor(pol, ci, pcpu, count);
431 get_pfid(struct policy *pol)
436 for (i = 0; i < pol->pkt.nb_mac_to_monitor; i++) {
438 RTE_ETH_FOREACH_DEV(x) {
439 ret = rte_pmd_i40e_query_vfid_by_mac(x,
440 (struct rte_ether_addr *)&(pol->pkt.vfid[i]));
441 if (ret != -EINVAL) {
446 if (ret == -EINVAL || ret == -ENOTSUP || ret == ENODEV) {
447 RTE_LOG(INFO, CHANNEL_MONITOR,
448 "Error with Policy. MAC not found on "
459 update_policy(struct channel_packet *pkt)
462 unsigned int updated = 0;
466 RTE_LOG(INFO, CHANNEL_MONITOR,
467 "Applying policy for %s\n", pkt->vm_name);
469 for (i = 0; i < RTE_DIM(policies); i++) {
470 if (strcmp(policies[i].pkt.vm_name, pkt->vm_name) == 0) {
471 /* Copy the contents of *pkt into the policy.pkt */
472 policies[i].pkt = *pkt;
473 get_pcpu_to_control(&policies[i]);
474 /* Check Eth dev only for Traffic policy */
475 if (policies[i].pkt.policy_to_use == TRAFFIC) {
476 if (get_pfid(&policies[i]) < 0) {
481 core_share_status(i);
482 policies[i].enabled = 1;
487 for (i = 0; i < RTE_DIM(policies); i++) {
488 if (policies[i].enabled == 0) {
489 policies[i].pkt = *pkt;
490 get_pcpu_to_control(&policies[i]);
491 /* Check Eth dev only for Traffic policy */
492 if (policies[i].pkt.policy_to_use == TRAFFIC) {
493 if (get_pfid(&policies[i]) < 0) {
498 core_share_status(i);
499 policies[i].enabled = 1;
508 remove_policy(struct channel_packet *pkt __rte_unused)
513 * Disabling the policy is simply a case of setting
516 for (i = 0; i < RTE_DIM(policies); i++) {
517 if (strcmp(policies[i].pkt.vm_name, pkt->vm_name) == 0) {
518 policies[i].enabled = 0;
526 get_pkt_diff(struct policy *pol)
529 uint64_t vsi_pkt_count,
531 vsi_pkt_count_prev_total = 0;
532 double rdtsc_curr, rdtsc_diff, diff;
534 struct rte_eth_stats vf_stats;
536 for (x = 0; x < pol->pkt.nb_mac_to_monitor; x++) {
539 if (rte_pmd_i40e_get_vf_stats(x, pol->pfid[x], &vf_stats) == 0)
540 vsi_pkt_count = vf_stats.ipackets;
544 vsi_pkt_total += vsi_pkt_count;
546 vsi_pkt_count_prev_total += vsi_pkt_count_prev[pol->pfid[x]];
547 vsi_pkt_count_prev[pol->pfid[x]] = vsi_pkt_count;
550 rdtsc_curr = rte_rdtsc_precise();
551 rdtsc_diff = rdtsc_curr - rdtsc_prev[pol->pfid[x-1]];
552 rdtsc_prev[pol->pfid[x-1]] = rdtsc_curr;
554 diff = (vsi_pkt_total - vsi_pkt_count_prev_total) *
555 ((double)rte_get_tsc_hz() / rdtsc_diff);
561 apply_traffic_profile(struct policy *pol)
567 diff = get_pkt_diff(pol);
569 if (diff >= (pol->pkt.traffic_policy.max_max_packet_thresh)) {
570 for (count = 0; count < pol->pkt.num_vcpu; count++) {
571 if (pol->core_share[count].status != 1)
572 power_manager_scale_core_max(
573 pol->core_share[count].pcpu);
575 } else if (diff >= (pol->pkt.traffic_policy.avg_max_packet_thresh)) {
576 for (count = 0; count < pol->pkt.num_vcpu; count++) {
577 if (pol->core_share[count].status != 1)
578 power_manager_scale_core_med(
579 pol->core_share[count].pcpu);
581 } else if (diff < (pol->pkt.traffic_policy.avg_max_packet_thresh)) {
582 for (count = 0; count < pol->pkt.num_vcpu; count++) {
583 if (pol->core_share[count].status != 1)
584 power_manager_scale_core_min(
585 pol->core_share[count].pcpu);
591 apply_time_profile(struct policy *pol)
597 char time_string[40];
599 /* Obtain the time of day, and convert it to a tm struct. */
600 gettimeofday(&tv, NULL);
601 ptm = localtime(&tv.tv_sec);
602 /* Format the date and time, down to a single second. */
603 strftime(time_string, sizeof(time_string), "%Y-%m-%d %H:%M:%S", ptm);
605 for (x = 0; x < HOURS; x++) {
607 if (ptm->tm_hour == pol->pkt.timer_policy.busy_hours[x]) {
608 for (count = 0; count < pol->pkt.num_vcpu; count++) {
609 if (pol->core_share[count].status != 1) {
610 power_manager_scale_core_max(
611 pol->core_share[count].pcpu);
615 } else if (ptm->tm_hour ==
616 pol->pkt.timer_policy.quiet_hours[x]) {
617 for (count = 0; count < pol->pkt.num_vcpu; count++) {
618 if (pol->core_share[count].status != 1) {
619 power_manager_scale_core_min(
620 pol->core_share[count].pcpu);
624 } else if (ptm->tm_hour ==
625 pol->pkt.timer_policy.hours_to_use_traffic_profile[x]) {
626 apply_traffic_profile(pol);
633 apply_workload_profile(struct policy *pol)
638 if (pol->pkt.workload == HIGH) {
639 for (count = 0; count < pol->pkt.num_vcpu; count++) {
640 if (pol->core_share[count].status != 1)
641 power_manager_scale_core_max(
642 pol->core_share[count].pcpu);
644 } else if (pol->pkt.workload == MEDIUM) {
645 for (count = 0; count < pol->pkt.num_vcpu; count++) {
646 if (pol->core_share[count].status != 1)
647 power_manager_scale_core_med(
648 pol->core_share[count].pcpu);
650 } else if (pol->pkt.workload == LOW) {
651 for (count = 0; count < pol->pkt.num_vcpu; count++) {
652 if (pol->core_share[count].status != 1)
653 power_manager_scale_core_min(
654 pol->core_share[count].pcpu);
660 apply_policy(struct policy *pol)
663 struct channel_packet *pkt = &pol->pkt;
665 /*Check policy to use*/
666 if (pkt->policy_to_use == TRAFFIC)
667 apply_traffic_profile(pol);
668 else if (pkt->policy_to_use == TIME)
669 apply_time_profile(pol);
670 else if (pkt->policy_to_use == WORKLOAD)
671 apply_workload_profile(pol);
675 process_request(struct channel_packet *pkt, struct channel_info *chan_info)
679 if (chan_info == NULL)
682 if (rte_atomic32_cmpset(&(chan_info->status), CHANNEL_MGR_CHANNEL_CONNECTED,
683 CHANNEL_MGR_CHANNEL_PROCESSING) == 0)
686 if (pkt->command == CPU_POWER) {
687 unsigned int core_num;
689 if (pkt->core_type == CORE_TYPE_VIRTUAL)
690 core_num = get_pcpu(chan_info, pkt->resource_id);
692 core_num = pkt->resource_id;
694 RTE_LOG(DEBUG, CHANNEL_MONITOR, "Processing requested cmd for cpu:%d\n",
698 case(CPU_POWER_SCALE_MIN):
699 power_manager_scale_core_min(core_num);
701 case(CPU_POWER_SCALE_MAX):
702 power_manager_scale_core_max(core_num);
704 case(CPU_POWER_SCALE_DOWN):
705 power_manager_scale_core_down(core_num);
707 case(CPU_POWER_SCALE_UP):
708 power_manager_scale_core_up(core_num);
710 case(CPU_POWER_ENABLE_TURBO):
711 power_manager_enable_turbo_core(core_num);
713 case(CPU_POWER_DISABLE_TURBO):
714 power_manager_disable_turbo_core(core_num);
721 if (pkt->command == PKT_POLICY) {
722 RTE_LOG(INFO, CHANNEL_MONITOR, "Processing policy request %s\n",
728 if (pkt->command == PKT_POLICY_REMOVE) {
729 ret = remove_policy(pkt);
731 RTE_LOG(INFO, CHANNEL_MONITOR,
732 "Removed policy %s\n", pkt->vm_name);
734 RTE_LOG(INFO, CHANNEL_MONITOR,
735 "Policy %s does not exist\n", pkt->vm_name);
739 * Return is not checked as channel status may have been set to DISABLED
740 * from management thread
742 rte_atomic32_cmpset(&(chan_info->status), CHANNEL_MGR_CHANNEL_PROCESSING,
743 CHANNEL_MGR_CHANNEL_CONNECTED);
749 add_channel_to_monitor(struct channel_info **chan_info)
751 struct channel_info *info = *chan_info;
752 struct epoll_event event;
754 event.events = EPOLLIN;
755 event.data.ptr = info;
756 if (epoll_ctl(global_event_fd, EPOLL_CTL_ADD, info->fd, &event) < 0) {
757 RTE_LOG(ERR, CHANNEL_MONITOR, "Unable to add channel '%s' "
758 "to epoll\n", info->channel_path);
761 RTE_LOG(ERR, CHANNEL_MONITOR, "Added channel '%s' "
762 "to monitor\n", info->channel_path);
767 remove_channel_from_monitor(struct channel_info *chan_info)
769 if (epoll_ctl(global_event_fd, EPOLL_CTL_DEL,
770 chan_info->fd, NULL) < 0) {
771 RTE_LOG(ERR, CHANNEL_MONITOR, "Unable to remove channel '%s' "
772 "from epoll\n", chan_info->channel_path);
779 channel_monitor_init(void)
781 global_event_fd = epoll_create1(0);
782 if (global_event_fd == 0) {
783 RTE_LOG(ERR, CHANNEL_MONITOR,
784 "Error creating epoll context with error %s\n",
788 global_events_list = rte_malloc("epoll_events",
789 sizeof(*global_events_list)
790 * MAX_EVENTS, RTE_CACHE_LINE_SIZE);
791 if (global_events_list == NULL) {
792 RTE_LOG(ERR, CHANNEL_MONITOR, "Unable to rte_malloc for "
800 read_binary_packet(struct channel_info *chan_info)
802 struct channel_packet pkt;
804 int buffer_len = sizeof(pkt);
805 int n_bytes, err = 0;
807 while (buffer_len > 0) {
808 n_bytes = read(chan_info->fd,
810 if (n_bytes == buffer_len)
814 RTE_LOG(DEBUG, CHANNEL_MONITOR,
816 "channel '%s' read: %s\n",
817 chan_info->channel_path,
819 remove_channel(&chan_info);
822 buffer = (char *)buffer + n_bytes;
823 buffer_len -= n_bytes;
826 process_request(&pkt, chan_info);
831 read_json_packet(struct channel_info *chan_info)
833 struct channel_packet pkt;
837 const char *resource_name;
842 /* read opening brace to closing brace */
847 n_bytes = read(chan_info->fd, &json_data[idx], 1);
850 if (json_data[idx] == '{')
852 if (json_data[idx] == '}')
854 if ((indent > 0) || (idx > 0))
858 if (idx >= MAX_JSON_STRING_LEN-1)
860 } while (indent > 0);
862 json_data[idx] = '\0';
864 if (strlen(json_data) == 0)
867 printf("got [%s]\n", json_data);
869 root = json_loads(json_data, 0, &error);
872 resource_name = get_resource_name_from_chn_path(
873 chan_info->channel_path);
875 * Because our data is now in the json
876 * object, we can overwrite the pkt
877 * with a channel_packet struct, using
878 * parse_json_to_pkt()
880 ret = parse_json_to_pkt(root, &pkt, resource_name);
883 RTE_LOG(ERR, CHANNEL_MONITOR,
884 "Error validating JSON profile data\n");
887 start = strstr(pkt.vm_name,
888 CHANNEL_MGR_FIFO_PATTERN_NAME);
890 /* move past pattern to start of fifo id */
891 start += strlen(CHANNEL_MGR_FIFO_PATTERN_NAME);
894 n = (uint32_t)strtoul(start, &end, 10);
896 if (end[0] == '\0') {
897 /* Add core id to core list */
899 pkt.vcpu_to_control[0] = n;
900 process_request(&pkt, chan_info);
902 RTE_LOG(ERR, CHANNEL_MONITOR,
903 "Cannot extract core id from fifo name\n");
906 process_request(&pkt, chan_info);
909 RTE_LOG(ERR, CHANNEL_MONITOR,
910 "JSON error on line %d: %s\n",
911 error.line, error.text);
913 } while (n_bytes > 0);
918 run_channel_monitor(void)
923 n_events = epoll_wait(global_event_fd, global_events_list,
927 for (i = 0; i < n_events; i++) {
928 struct channel_info *chan_info = (struct channel_info *)
929 global_events_list[i].data.ptr;
930 if ((global_events_list[i].events & EPOLLERR) ||
931 (global_events_list[i].events & EPOLLHUP)) {
932 RTE_LOG(INFO, CHANNEL_MONITOR,
933 "Remote closed connection for "
935 chan_info->channel_path);
936 remove_channel(&chan_info);
939 if (global_events_list[i].events & EPOLLIN) {
941 switch (chan_info->type) {
942 case CHANNEL_TYPE_BINARY:
943 read_binary_packet(chan_info);
946 case CHANNEL_TYPE_JSON:
947 read_json_packet(chan_info);
955 rte_delay_us(time_period_ms*1000);
959 for (j = 0; j < RTE_DIM(policies); j++) {
960 if (policies[j].enabled == 1)
961 apply_policy(&policies[j]);