1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2010-2014 Intel Corporation 3 */ 4 5 #ifndef CHANNEL_MONITOR_H_ 6 #define CHANNEL_MONITOR_H_ 7 8 #include <rte_power_cpufreq.h> 9 #include <rte_power_guest_channel.h> 10 11 #include "channel_manager.h" 12 13 struct core_share { 14 unsigned int pcpu; 15 /* 16 * 1 CORE SHARE 17 * 0 NOT SHARED 18 */ 19 int status; 20 }; 21 22 struct policy { 23 struct rte_power_channel_packet pkt; 24 uint32_t pfid[RTE_POWER_MAX_VFS]; 25 uint32_t port[RTE_POWER_MAX_VFS]; 26 unsigned int enabled; 27 struct core_share core_share[RTE_POWER_MAX_VCPU_PER_VM]; 28 }; 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 /** 35 * Setup the Channel Monitor resources required to initialize epoll. 36 * Must be called first before calling other functions. 37 * 38 * @return 39 * - 0 on success. 40 * - Negative on error. 41 */ 42 int channel_monitor_init(void); 43 44 /** 45 * Run the channel monitor, loops forever on epoll_wait. 46 * 47 * 48 * @return 49 * None 50 */ 51 void run_channel_monitor(void); 52 53 /** 54 * Exit the Channel Monitor, exiting the epoll_wait loop and events processing. 55 * 56 * @return 57 * - 0 on success. 58 * - Negative on error. 59 */ 60 void channel_monitor_exit(void); 61 62 /** 63 * Add an open channel to monitor via epoll. A pointer to struct channel_info 64 * will be registered with epoll for event processing. 65 * It is thread-safe. 66 * 67 * @param chan_info 68 * Pointer to struct channel_info pointer. 69 * 70 * @return 71 * - 0 on success. 72 * - Negative on error. 73 */ 74 int add_channel_to_monitor(struct channel_info **chan_info); 75 76 /** 77 * Remove a previously added channel from epoll control. 78 * 79 * @param chan_info 80 * Pointer to struct channel_info. 81 * 82 * @return 83 * - 0 on success. 84 * - Negative on error. 85 */ 86 int remove_channel_from_monitor(struct channel_info *chan_info); 87 88 #ifdef __cplusplus 89 } 90 #endif 91 92 93 #endif /* CHANNEL_MONITOR_H_ */ 94