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