X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fvm_power_manager%2Fchannel_manager.h;h=e55376fcdbb153c9e3b42eeca83491c3d8836391;hb=4ad736ce03d22e917f7de16fd4ba24d9b49edce9;hp=872ec614086ebd4ab4298d03f42a9bd81e1efc28;hpb=3998e2a07220844d3f3c17f76a781ced3efe0de0;p=dpdk.git diff --git a/examples/vm_power_manager/channel_manager.h b/examples/vm_power_manager/channel_manager.h index 872ec61408..e55376fcdb 100644 --- a/examples/vm_power_manager/channel_manager.h +++ b/examples/vm_power_manager/channel_manager.h @@ -10,34 +10,23 @@ extern "C" { #endif #include -#include +#include #include - -/* Maximum number of CPUs */ -#define CHANNEL_CMDS_MAX_CPUS 64 -#if CHANNEL_CMDS_MAX_CPUS > 64 -#error Maximum number of cores is 64, overflow is guaranteed to \ - cause problems with VM Power Management -#endif +#include /* Maximum name length including '\0' terminator */ #define CHANNEL_MGR_MAX_NAME_LEN 64 -/* Maximum number of channels to each Virtual Machine */ -#define CHANNEL_MGR_MAX_CHANNELS 64 - /* Hypervisor Path for libvirt(qemu/KVM) */ #define CHANNEL_MGR_DEFAULT_HV_PATH "qemu:///system" /* File socket directory */ #define CHANNEL_MGR_SOCKET_PATH "/tmp/powermonitor/" -#ifndef UNIX_PATH_MAX -struct sockaddr_un _sockaddr_un; -#define UNIX_PATH_MAX sizeof(_sockaddr_un.sun_path) -#endif +/* FIFO file name template */ +#define CHANNEL_MGR_FIFO_PATTERN_NAME "fifo" -#define MAX_VMS 4 +#define MAX_CLIENTS 64 #define MAX_VCPUS 20 @@ -47,13 +36,20 @@ struct libvirt_vm_info { uint8_t num_cpus; }; -struct libvirt_vm_info lvm_info[MAX_VMS]; +extern struct libvirt_vm_info lvm_info[MAX_CLIENTS]; /* Communication Channel Status */ enum channel_status { CHANNEL_MGR_CHANNEL_DISCONNECTED = 0, CHANNEL_MGR_CHANNEL_CONNECTED, CHANNEL_MGR_CHANNEL_DISABLED, CHANNEL_MGR_CHANNEL_PROCESSING}; +/* Communication Channel Type */ +enum channel_type { + CHANNEL_TYPE_BINARY = 0, + CHANNEL_TYPE_INI, + CHANNEL_TYPE_JSON +}; + /* VM libvirt(qemu/KVM) connection status */ enum vm_status { CHANNEL_MGR_VM_INACTIVE = 0, CHANNEL_MGR_VM_ACTIVE}; @@ -66,6 +62,7 @@ struct channel_info { volatile uint32_t status; /**< Connection status(enum channel_status) */ int fd; /**< AF_UNIX socket fd */ unsigned channel_num; /**< CHANNEL_MGR_SOCKET_PATH/.channel_num */ + enum channel_type type; /**< Binary, ini, json, etc. */ void *priv_info; /**< Pointer to private info, do not modify */ }; @@ -74,10 +71,11 @@ struct channel_info { struct vm_info { char name[CHANNEL_MGR_MAX_NAME_LEN]; /**< VM name */ enum vm_status status; /**< libvirt status */ - uint64_t pcpu_mask[CHANNEL_CMDS_MAX_CPUS]; /**< pCPU mask for each vCPU */ + uint16_t pcpu_map[RTE_MAX_LCORE]; /**< pCPU map to vCPU */ unsigned num_vcpus; /**< number of vCPUS */ - struct channel_info channels[CHANNEL_MGR_MAX_CHANNELS]; /**< Array of channel_info */ + struct channel_info channels[RTE_MAX_LCORE]; /**< channel_info array */ unsigned num_channels; /**< Number of channels */ + int allow_query; /**< is query allowed */ }; /** @@ -107,8 +105,7 @@ int channel_manager_init(const char *path); void channel_manager_exit(void); /** - * Get the Physical CPU mask for VM lcore channel(vcpu), result is assigned to - * core_mask. + * Get the Physical CPU for VM lcore channel(vcpu). * It is not thread-safe. * * @param chan_info @@ -122,10 +119,10 @@ void channel_manager_exit(void); * - 0 on error. * - >0 on success. */ -uint64_t get_pcpus_mask(struct channel_info *chan_info, unsigned vcpu); +uint16_t get_pcpu(struct channel_info *chan_info, unsigned int vcpu); /** - * Set the Physical CPU mask for the specified vCPU. + * Set the Physical CPU for the specified vCPU. * It is not thread-safe. * * @param name @@ -134,33 +131,31 @@ uint64_t get_pcpus_mask(struct channel_info *chan_info, unsigned vcpu); * @param vcpu * The virtual CPU to set. * - * @param core_mask - * The core mask of the physical CPU(s) to bind the vCPU + * @param core_num + * The core number of the physical CPU(s) to bind the vCPU * * @return * - 0 on success. * - Negative on error. */ -int set_pcpus_mask(char *vm_name, unsigned vcpu, uint64_t core_mask); +int set_pcpu(char *vm_name, unsigned int vcpu, unsigned int pcpu); /** - * Set the Physical CPU for the specified vCPU. - * It is not thread-safe. + * Allow or disallow queries for specified VM. + * It is thread-safe. * * @param name - * Virtual Machine name to lookup - * - * @param vcpu - * The virtual CPU to set. + * Virtual Machine name to lookup. * - * @param core_num - * The core number of the physical CPU(s) to bind the vCPU + * @param allow_query + * Query status to be set. * * @return * - 0 on success. * - Negative on error. */ -int set_pcpu(char *vm_name, unsigned vcpu, unsigned core_num); +int set_query_status(char *vm_name, bool allow_query); + /** * Add a VM as specified by name to the Channel Manager. The name must * correspond to a valid libvirt domain name. @@ -226,6 +221,15 @@ int add_all_channels(const char *vm_name); int add_channels(const char *vm_name, unsigned *channel_list, unsigned num_channels); +/** + * Set up fifos by which host applications can send command an policies + * through a fifo to the vm_power_manager + * + * @return + * - 0 for success + */ +int add_host_channels(void); + /** * Remove a channel definition from the channel manager. This must only be * called from the channel monitor thread.