mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-05-28 18:04:23 +00:00
dm: add a new page for asyncio
asyncio is a new mechanism in ACRN, which is special for these devices which need high IO performance. ACRN hypervisor would process the IO request from User VM in an async mode. Just like the original IOReq shared page, the devicemodel also create a page for fastio requests. As the asyncio use the ioeventfd, so the reuqests are handled in kernel, devicemodel only need to provide the page. Tracked-On: #8209 Signed-off-by: Conghui <conghui.chen@intel.com> Acked-by: Wang, Yu1 <yu1.wang@intel.com>
This commit is contained in:
parent
17f94605f0
commit
0f599e8d56
@ -116,6 +116,7 @@ static cpuset_t cpumask;
|
||||
static void vm_loop(struct vmctx *ctx);
|
||||
|
||||
static char io_request_page[4096] __aligned(4096);
|
||||
static char asyncio_page[4096] __aligned(4096);
|
||||
|
||||
static struct acrn_io_request *ioreq_buf =
|
||||
(struct acrn_io_request *)&io_request_page;
|
||||
@ -835,6 +836,23 @@ static struct option long_options[] = {
|
||||
|
||||
static char optstr[] = "AhYvE:k:r:B:s:m:l:U:G:i:";
|
||||
|
||||
int
|
||||
vm_init_asyncio(struct vmctx *ctx, uint64_t base)
|
||||
{
|
||||
struct shared_buf *sbuf = (struct shared_buf *)base;
|
||||
|
||||
sbuf->magic = SBUF_MAGIC;
|
||||
sbuf->ele_size = sizeof(uint64_t);
|
||||
sbuf->ele_num = (4096 - SBUF_HEAD_SIZE) / sbuf->ele_size;
|
||||
sbuf->size = sbuf->ele_size * sbuf->ele_num;
|
||||
/* set flag to 0 to make sure not overrun! */
|
||||
sbuf->flags = 0;
|
||||
sbuf->overrun_cnt = 0;
|
||||
sbuf->head = 0;
|
||||
sbuf->tail = 0;
|
||||
return vm_setup_sbuf(ctx, ACRN_ASYNCIO, base);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
@ -1093,6 +1111,12 @@ main(int argc, char *argv[])
|
||||
goto fail;
|
||||
}
|
||||
|
||||
pr_notice("vm setup asyncio page\n");
|
||||
error = vm_init_asyncio(ctx, (uint64_t)asyncio_page);
|
||||
if (error) {
|
||||
pr_warn("ASYNIO capability is not supported by kernel or hyperviosr!\n");
|
||||
}
|
||||
|
||||
pr_notice("vm_setup_memory: size=0x%lx\n", memsize);
|
||||
error = vm_setup_memory(ctx, memsize);
|
||||
if (error) {
|
||||
|
@ -294,6 +294,25 @@ vm_destroy(struct vmctx *ctx)
|
||||
devfd = -1;
|
||||
}
|
||||
|
||||
int
|
||||
vm_setup_sbuf(struct vmctx *ctx, uint32_t sbuf_id, uint64_t base)
|
||||
{
|
||||
int error;
|
||||
struct acrn_sbuf sbuf_param;
|
||||
|
||||
bzero(&sbuf_param, sizeof(sbuf_param));
|
||||
sbuf_param.sbuf_id = sbuf_id;
|
||||
sbuf_param.base = base;
|
||||
|
||||
error = ioctl(ctx->fd, ACRN_IOCTL_SETUP_SBUF, &sbuf_param);
|
||||
|
||||
if (error) {
|
||||
pr_err("ACRN_IOCTL_SBUF_PAGE ioctl() returned an error: %s\n", errormsg(errno));
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
int
|
||||
vm_parse_memsize(const char *optarg, size_t *ret_memsize)
|
||||
{
|
||||
|
@ -107,6 +107,8 @@
|
||||
_IOW(ACRN_IOCTL_TYPE, 0x41, struct acrn_vm_memmap)
|
||||
#define ACRN_IOCTL_UNSET_MEMSEG \
|
||||
_IOW(ACRN_IOCTL_TYPE, 0x42, struct acrn_vm_memmap)
|
||||
#define ACRN_IOCTL_SETUP_SBUF \
|
||||
_IOW(ACRN_IOCTL_TYPE, 0x43, struct acrn_sbuf)
|
||||
|
||||
/* PCI assignment*/
|
||||
#define ACRN_IOCTL_SET_PTDEV_INTR \
|
||||
@ -246,4 +248,14 @@ struct acrn_irqfd {
|
||||
/** MSI interrupt to be injected */
|
||||
struct acrn_msi_entry msi;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief data structure to register a share buffer by ioctl
|
||||
*/
|
||||
struct acrn_sbuf {
|
||||
/** Type of the sbuf. */
|
||||
uint32_t sbuf_id;
|
||||
/** Base address of the sbuf. */
|
||||
uint64_t base;
|
||||
};
|
||||
#endif /* VHM_IOCTL_DEFS_H */
|
||||
|
@ -107,6 +107,7 @@ int vm_create_ioreq_client(struct vmctx *ctx);
|
||||
int vm_destroy_ioreq_client(struct vmctx *ctx);
|
||||
int vm_attach_ioreq_client(struct vmctx *ctx);
|
||||
int vm_notify_request_done(struct vmctx *ctx, int vcpu);
|
||||
int vm_setup_sbuf(struct vmctx *ctx, uint32_t sbuf_type, uint64_t base);
|
||||
void vm_clear_ioreq(struct vmctx *ctx);
|
||||
const char *vm_state_to_str(enum vm_suspend_how idx);
|
||||
void vm_set_suspend_mode(enum vm_suspend_how how);
|
||||
|
Loading…
Reference in New Issue
Block a user