1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation
5 #ifndef _VHOST_NET_USER_H
6 #define _VHOST_NET_USER_H
9 #include <linux/types.h>
10 #include <linux/ioctl.h>
12 #include "../virtio_pci.h"
13 #include "../virtio_logs.h"
14 #include "../virtqueue.h"
16 struct vhost_vring_state
{
21 struct vhost_vring_file
{
26 struct vhost_vring_addr
{
31 /* Whether log address is valid. If set enables logging. */
32 #define VHOST_VRING_F_LOG 0
34 /* Start of array of descriptors (virtually contiguous) */
35 uint64_t desc_user_addr
;
36 /* Used structure address. Must be 32 bit aligned */
37 uint64_t used_user_addr
;
38 /* Available structure address. Must be 16 bit aligned */
39 uint64_t avail_user_addr
;
40 /* Logging support. */
41 /* Log writes to used structure, at offset calculated from specified
42 * address. Address must be 32 bit aligned.
44 uint64_t log_guest_addr
;
47 enum vhost_user_request
{
49 VHOST_USER_GET_FEATURES
= 1,
50 VHOST_USER_SET_FEATURES
= 2,
51 VHOST_USER_SET_OWNER
= 3,
52 VHOST_USER_RESET_OWNER
= 4,
53 VHOST_USER_SET_MEM_TABLE
= 5,
54 VHOST_USER_SET_LOG_BASE
= 6,
55 VHOST_USER_SET_LOG_FD
= 7,
56 VHOST_USER_SET_VRING_NUM
= 8,
57 VHOST_USER_SET_VRING_ADDR
= 9,
58 VHOST_USER_SET_VRING_BASE
= 10,
59 VHOST_USER_GET_VRING_BASE
= 11,
60 VHOST_USER_SET_VRING_KICK
= 12,
61 VHOST_USER_SET_VRING_CALL
= 13,
62 VHOST_USER_SET_VRING_ERR
= 14,
63 VHOST_USER_GET_PROTOCOL_FEATURES
= 15,
64 VHOST_USER_SET_PROTOCOL_FEATURES
= 16,
65 VHOST_USER_GET_QUEUE_NUM
= 17,
66 VHOST_USER_SET_VRING_ENABLE
= 18,
70 const char * const vhost_msg_strings
[VHOST_USER_MAX
];
72 struct vhost_memory_region
{
73 uint64_t guest_phys_addr
;
74 uint64_t memory_size
; /* bytes */
75 uint64_t userspace_addr
;
79 struct virtio_user_dev
;
81 struct virtio_user_backend_ops
{
82 int (*setup
)(struct virtio_user_dev
*dev
);
83 int (*send_request
)(struct virtio_user_dev
*dev
,
84 enum vhost_user_request req
,
86 int (*enable_qp
)(struct virtio_user_dev
*dev
,
91 struct virtio_user_backend_ops ops_user
;
92 struct virtio_user_backend_ops ops_kernel
;