mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-20 20:53:46 +00:00
ACRN: DM: Expose the vhost kernel ioctrl API
The patch expose the vhost kernel ioctrl API and remove the virtio_net operation functions to the virtio_net code module. Tracked-On: #7456 Signed-off-by: Liu Long <long.liu@linux.intel.com> Reviewed-by: Conghui <conghui.chen@intel.com> Acked-by: Wang, Yu1 <yu1.wang@intel.com>
This commit is contained in:
parent
3afb222d90
commit
231f986bd9
@ -31,7 +31,7 @@ static int vhost_debug;
|
||||
do { if (vhost_debug) pr_dbg(LOG_TAG fmt, ##args); } while (0)
|
||||
#define WPRINTF(fmt, args...) pr_err(LOG_TAG fmt, ##args)
|
||||
|
||||
static inline
|
||||
inline
|
||||
int vhost_kernel_ioctl(struct vhost_dev *vdev,
|
||||
unsigned long int request,
|
||||
void *arg)
|
||||
@ -154,13 +154,6 @@ vhost_kernel_reset_device(struct vhost_dev *vdev)
|
||||
return vhost_kernel_ioctl(vdev, VHOST_RESET_OWNER, NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
vhost_kernel_net_set_backend(struct vhost_dev *vdev,
|
||||
struct vhost_vring_file *file)
|
||||
{
|
||||
return vhost_kernel_ioctl(vdev, VHOST_NET_SET_BACKEND, file);
|
||||
}
|
||||
|
||||
static int
|
||||
vhost_eventfd_test_and_clear(int fd)
|
||||
{
|
||||
@ -772,39 +765,3 @@ vhost_dev_stop(struct vhost_dev *vdev)
|
||||
vdev->started = false;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief set backend fd of vhost net.
|
||||
*
|
||||
* This interface is called to set the backend fd (for example tap fd)
|
||||
* to vhost.
|
||||
*
|
||||
* @param vdev Pointer to struct vhost_dev.
|
||||
* @param backend_fd fd of backend (for example tap fd).
|
||||
*
|
||||
* @return 0 on success and -1 on failure.
|
||||
*/
|
||||
int
|
||||
vhost_net_set_backend(struct vhost_dev *vdev, int backend_fd)
|
||||
{
|
||||
struct vhost_vring_file file;
|
||||
int rc, i;
|
||||
|
||||
file.fd = backend_fd;
|
||||
for (i = 0; i < vdev->nvqs; i++) {
|
||||
file.index = i;
|
||||
rc = vhost_kernel_net_set_backend(vdev, &file);
|
||||
if (rc < 0)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
return 0;
|
||||
fail:
|
||||
file.fd = -1;
|
||||
while (--i >= 0) {
|
||||
file.index = i;
|
||||
vhost_kernel_net_set_backend(vdev, &file);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include <net/if.h>
|
||||
#include <linux/if_tun.h>
|
||||
#include <sys/socket.h>
|
||||
#include <linux/vhost.h>
|
||||
|
||||
#include "dm.h"
|
||||
#include "pci_core.h"
|
||||
@ -76,8 +77,6 @@
|
||||
#define VIRTIO_NET_F_CTRL_VLAN (1 << 19) /* control channel VLAN filtering */
|
||||
#define VIRTIO_NET_F_GUEST_ANNOUNCE \
|
||||
(1 << 21) /* guest can send gratuitous pkts */
|
||||
#define VHOST_NET_F_VIRTIO_NET_HDR \
|
||||
(1 << 27) /* vhost provides virtio_net_hdr */
|
||||
|
||||
#define VIRTIO_NET_S_HOSTCAPS \
|
||||
(VIRTIO_NET_F_MAC | VIRTIO_NET_F_MRG_RXBUF | VIRTIO_NET_F_STATUS | \
|
||||
@ -202,6 +201,38 @@ static struct virtio_ops virtio_net_ops = {
|
||||
virtio_net_set_status, /* called on guest set status */
|
||||
};
|
||||
|
||||
static int
|
||||
vhost_kernel_net_set_backend(struct vhost_dev *vdev,
|
||||
struct vhost_vring_file *file)
|
||||
{
|
||||
return vhost_kernel_ioctl(vdev, VHOST_NET_SET_BACKEND, file);
|
||||
}
|
||||
|
||||
int
|
||||
vhost_net_set_backend(struct vhost_dev *vdev, int backend_fd)
|
||||
{
|
||||
struct vhost_vring_file file;
|
||||
int rc, i;
|
||||
|
||||
file.fd = backend_fd;
|
||||
for (i = 0; i < vdev->nvqs; i++) {
|
||||
file.index = i;
|
||||
rc = vhost_kernel_net_set_backend(vdev, &file);
|
||||
if (rc < 0)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
return 0;
|
||||
fail:
|
||||
file.fd = -1;
|
||||
while (--i >= 0) {
|
||||
file.index = i;
|
||||
vhost_kernel_net_set_backend(vdev, &file);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static struct ether_addr *
|
||||
ether_aton(const char *a, struct ether_addr *e)
|
||||
{
|
||||
|
@ -132,19 +132,15 @@ int vhost_dev_start(struct vhost_dev *vdev);
|
||||
int vhost_dev_stop(struct vhost_dev *vdev);
|
||||
|
||||
/**
|
||||
* @brief set backend fd of vhost net.
|
||||
* @brief vhost kernel dev ioctrl function
|
||||
*
|
||||
* This interface is called to set the backend fd (for example tap fd)
|
||||
* to vhost.
|
||||
* This interface is used to operation the vhost dev kernel.
|
||||
*
|
||||
* @param vdev Pointer to struct vhost_dev.
|
||||
* @param backend_fd fd of backend (for example tap fd).
|
||||
* @param vdev Pointer to struct vhost_dev
|
||||
* @param The request to vhost kernel
|
||||
* @param The arguments of vhost kernel operation
|
||||
*
|
||||
* @return 0 on success and -1 on failure.
|
||||
*/
|
||||
int vhost_net_set_backend(struct vhost_dev *vdev, int backend_fd);
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @return 0 on success and -1 on failure
|
||||
*/
|
||||
int vhost_kernel_ioctl(struct vhost_dev *vdev, unsigned long int request, void *arg);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user