1 /*
2  * Copyright (C) 2018-2022 Intel Corporation.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 /* This file provides common routines to interface with VBS-K kernel modules */
9 
10 #ifndef _VIRTIO_KERNEL_H_
11 #define _VIRTIO_KERNEL_H_
12 
13 #include "vbs_common_if.h"		/* data format between VBS-U & VBS-K */
14 
15 /**
16  * @brief APIs for virtio backend in kernel module
17  *
18  * @addtogroup acrn_virtio
19  * @{
20  */
21 
22 enum VBS_K_STATUS {
23 	VIRTIO_DEV_INITIAL = 1,		/* initial status */
24 	VIRTIO_DEV_PRE_INIT,		/* detected thru cmdline option */
25 	VIRTIO_DEV_INIT_FAILED,		/* init failed */
26 	VIRTIO_DEV_INIT_SUCCESS,	/* init success */
27 	VIRTIO_DEV_START_FAILED,	/* start failed */
28 	VIRTIO_DEV_STARTED,		/* start success */
29 };
30 
31 /* Return codes */
32 #define VIRTIO_SUCCESS				0
33 #define VIRTIO_ERROR_REENTER			1
34 #define VIRTIO_ERROR_FD_OPEN_FAILED		2
35 #define VIRTIO_ERROR_MEM_ALLOC_FAILED		3
36 #define VIRTIO_ERROR_START			4
37 #define VIRTIO_ERROR_GENERAL			5
38 
39 /* VBS-K common ops */
40 /**
41  * @brief Virtio kernel module reset.
42  *
43  * @param fd File descriptor representing virtio backend in kernel module.
44  *
45  * @return 0 on OK and non-zero on error.
46  */
47 int vbs_kernel_reset(int fd);
48 
49 /**
50  * @brief Virtio kernel module start.
51  *
52  * @param fd File descriptor representing virtio backend in kernel module.
53  * @param dev Pointer to struct vbs_dev_info.
54  * @param vqs Pointer to struct vbs_vqs_info.
55  *
56  * @return 0 on OK and non-zero on error.
57  */
58 int vbs_kernel_start(int fd, struct vbs_dev_info *dev,
59 		     struct vbs_vqs_info *vqs);
60 
61 /**
62  * @brief Virtio kernel module stop.
63  *
64  * @param fd File descriptor representing virtio backend in kernel module.
65  *
66  * @return 0 on OK and non-zero on error.
67  */
68 int vbs_kernel_stop(int fd);
69 
70 /**
71  * @}
72  */
73 #endif
74