1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* Vhost-user protocol */
4 #ifndef __VHOST_USER_H__
5 #define __VHOST_USER_H__
8 #define VHOST_USER_FLAG_REPLY BIT(2)
9 #define VHOST_USER_FLAG_NEED_REPLY BIT(3)
11 #define VHOST_USER_F_PROTOCOL_FEATURES 30
12 /* Protocol feature bits */
13 #define VHOST_USER_PROTOCOL_F_REPLY_ACK 3
14 #define VHOST_USER_PROTOCOL_F_SLAVE_REQ 5
15 #define VHOST_USER_PROTOCOL_F_CONFIG 9
16 /* Vring state index masks */
17 #define VHOST_USER_VRING_INDEX_MASK 0xff
18 #define VHOST_USER_VRING_POLL_MASK BIT(8)
20 /* Supported version */
21 #define VHOST_USER_VERSION 1
22 /* Supported transport features */
23 #define VHOST_USER_SUPPORTED_F BIT_ULL(VHOST_USER_F_PROTOCOL_FEATURES)
24 /* Supported protocol features */
25 #define VHOST_USER_SUPPORTED_PROTOCOL_F (BIT_ULL(VHOST_USER_PROTOCOL_F_REPLY_ACK) | \
26 BIT_ULL(VHOST_USER_PROTOCOL_F_SLAVE_REQ) | \
27 BIT_ULL(VHOST_USER_PROTOCOL_F_CONFIG))
29 enum vhost_user_request
{
30 VHOST_USER_GET_FEATURES
= 1,
31 VHOST_USER_SET_FEATURES
= 2,
32 VHOST_USER_SET_OWNER
= 3,
33 VHOST_USER_RESET_OWNER
= 4,
34 VHOST_USER_SET_MEM_TABLE
= 5,
35 VHOST_USER_SET_LOG_BASE
= 6,
36 VHOST_USER_SET_LOG_FD
= 7,
37 VHOST_USER_SET_VRING_NUM
= 8,
38 VHOST_USER_SET_VRING_ADDR
= 9,
39 VHOST_USER_SET_VRING_BASE
= 10,
40 VHOST_USER_GET_VRING_BASE
= 11,
41 VHOST_USER_SET_VRING_KICK
= 12,
42 VHOST_USER_SET_VRING_CALL
= 13,
43 VHOST_USER_SET_VRING_ERR
= 14,
44 VHOST_USER_GET_PROTOCOL_FEATURES
= 15,
45 VHOST_USER_SET_PROTOCOL_FEATURES
= 16,
46 VHOST_USER_GET_QUEUE_NUM
= 17,
47 VHOST_USER_SET_VRING_ENABLE
= 18,
48 VHOST_USER_SEND_RARP
= 19,
49 VHOST_USER_NET_SEND_MTU
= 20,
50 VHOST_USER_SET_SLAVE_REQ_FD
= 21,
51 VHOST_USER_IOTLB_MSG
= 22,
52 VHOST_USER_SET_VRING_ENDIAN
= 23,
53 VHOST_USER_GET_CONFIG
= 24,
54 VHOST_USER_SET_CONFIG
= 25,
57 enum vhost_user_slave_request
{
58 VHOST_USER_SLAVE_IOTLB_MSG
= 1,
59 VHOST_USER_SLAVE_CONFIG_CHANGE_MSG
= 2,
60 VHOST_USER_SLAVE_VRING_HOST_NOTIFIER_MSG
= 3,
63 struct vhost_user_header
{
65 * Use enum vhost_user_request for outgoing messages,
66 * uses enum vhost_user_slave_request for incoming ones.
73 struct vhost_user_config
{
77 u8 payload
[0]; /* Variable length */
80 struct vhost_user_vring_state
{
85 struct vhost_user_vring_addr
{
88 u64 desc
, used
, avail
, log
;
91 struct vhost_user_mem_region
{
98 struct vhost_user_mem_regions
{
101 struct vhost_user_mem_region regions
[2]; /* Currently supporting 2 */
104 union vhost_user_payload
{
106 struct vhost_user_config config
;
107 struct vhost_user_vring_state vring_state
;
108 struct vhost_user_vring_addr vring_addr
;
109 struct vhost_user_mem_regions mem_regions
;
112 struct vhost_user_msg
{
113 struct vhost_user_header header
;
114 union vhost_user_payload payload
;