Skip to content

Commit 263bdf6

Browse files
jsun26inteljren1
authored andcommitted
DM: add vmm interface to get px data
The interface will be used to interact with VHM service via IOCTL. Signed-off-by: Victor Sun <victor.sun@intel.com> Acked-by: Kevin Tian <kevin.tian@intel.com>
1 parent ec1cbbb commit 263bdf6

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed

devicemodel/core/vmmapi.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,3 +720,9 @@ vm_get_device_fd(struct vmctx *ctx)
720720
{
721721
return ctx->fd;
722722
}
723+
724+
int
725+
vm_get_cpu_state(struct vmctx *ctx, void *state_buf)
726+
{
727+
return ioctl(ctx->fd, IC_PM_GET_CPU_STATE, state_buf);
728+
}

devicemodel/include/public/acrn_common.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,39 @@ struct acrn_vm_pci_msix_remap {
302302
*/
303303
#define GUEST_CFG_OFFSET 0xd0000
304304

305+
/**
306+
* @brief Info The power state data of a VCPU.
307+
*
308+
*/
309+
struct cpu_px_data {
310+
uint64_t core_frequency; /* megahertz */
311+
uint64_t power; /* milliWatts */
312+
uint64_t transition_latency; /* microseconds */
313+
uint64_t bus_master_latency; /* microseconds */
314+
uint64_t control; /* control value */
315+
uint64_t status; /* success indicator */
316+
} __attribute__((aligned(8)));
317+
318+
/**
319+
* @brief Info PM command from DM/VHM.
320+
*
321+
* The command would specify request type(i.e. get px count or data) for
322+
* specific VM and specific VCPU with specific state number.like P(n).
323+
*/
324+
#define PMCMD_VMID_MASK 0xff000000
325+
#define PMCMD_VCPUID_MASK 0x00ff0000
326+
#define PMCMD_STATE_NUM_MASK 0x0000ff00
327+
#define PMCMD_TYPE_MASK 0x000000ff
328+
329+
#define PMCMD_VMID_SHIFT 24
330+
#define PMCMD_VCPUID_SHIFT 16
331+
#define PMCMD_STATE_NUM_SHIFT 8
332+
333+
enum pm_cmd_type {
334+
PMCMD_GET_PX_CNT,
335+
PMCMD_GET_PX_DATA,
336+
};
337+
305338
/**
306339
* @}
307340
*/

devicemodel/include/public/vhm_ioctl_defs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@
101101
#define IC_SET_PTDEV_INTR_INFO _IC_ID(IC_ID, IC_ID_PCI_BASE + 0x03)
102102
#define IC_RESET_PTDEV_INTR_INFO _IC_ID(IC_ID, IC_ID_PCI_BASE + 0x04)
103103

104+
/* Power management */
105+
#define IC_ID_PM_BASE 0x60UL
106+
#define IC_PM_GET_CPU_STATE _IC_ID(IC_ID, IC_ID_PM_BASE + 0x00)
107+
104108
/**
105109
* struct vm_memseg - memory segment info for guest
106110
*

devicemodel/include/vmmapi.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,7 @@ int vm_set_ptdev_intx_info(struct vmctx *ctx, uint16_t virt_bdf,
147147
int vm_reset_ptdev_intx_info(struct vmctx *ctx, int virt_pin, bool pic_pin);
148148

149149
int vm_create_vcpu(struct vmctx *ctx, int vcpu_id);
150+
151+
int vm_get_cpu_state(struct vmctx *ctx, void *state_buf);
152+
150153
#endif /* _VMMAPI_H_ */

0 commit comments

Comments
 (0)