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 #define VHOST_USER_PROTOCOL_F_INBAND_NOTIFICATIONS 14
17 /* Vring state index masks */
18 #define VHOST_USER_VRING_INDEX_MASK 0xff
19 #define VHOST_USER_VRING_POLL_MASK BIT(8)
21 /* Supported version */
22 #define VHOST_USER_VERSION 1
23 /* Supported transport features */
24 #define VHOST_USER_SUPPORTED_F BIT_ULL(VHOST_USER_F_PROTOCOL_FEATURES)
25 /* Supported protocol features */
26 #define VHOST_USER_SUPPORTED_PROTOCOL_F (BIT_ULL(VHOST_USER_PROTOCOL_F_REPLY_ACK) | \
27 BIT_ULL(VHOST_USER_PROTOCOL_F_SLAVE_REQ) | \
28 BIT_ULL(VHOST_USER_PROTOCOL_F_CONFIG) | \
29 BIT_ULL(VHOST_USER_PROTOCOL_F_INBAND_NOTIFICATIONS))
31 enum vhost_user_request
{
32 VHOST_USER_GET_FEATURES
= 1,
33 VHOST_USER_SET_FEATURES
= 2,
34 VHOST_USER_SET_OWNER
= 3,
35 VHOST_USER_RESET_OWNER
= 4,
36 VHOST_USER_SET_MEM_TABLE
= 5,
37 VHOST_USER_SET_LOG_BASE
= 6,
38 VHOST_USER_SET_LOG_FD
= 7,
39 VHOST_USER_SET_VRING_NUM
= 8,
40 VHOST_USER_SET_VRING_ADDR
= 9,
41 VHOST_USER_SET_VRING_BASE
= 10,
42 VHOST_USER_GET_VRING_BASE
= 11,
43 VHOST_USER_SET_VRING_KICK
= 12,
44 VHOST_USER_SET_VRING_CALL
= 13,
45 VHOST_USER_SET_VRING_ERR
= 14,
46 VHOST_USER_GET_PROTOCOL_FEATURES
= 15,
47 VHOST_USER_SET_PROTOCOL_FEATURES
= 16,
48 VHOST_USER_GET_QUEUE_NUM
= 17,
49 VHOST_USER_SET_VRING_ENABLE
= 18,
50 VHOST_USER_SEND_RARP
= 19,
51 VHOST_USER_NET_SEND_MTU
= 20,
52 VHOST_USER_SET_SLAVE_REQ_FD
= 21,
53 VHOST_USER_IOTLB_MSG
= 22,
54 VHOST_USER_SET_VRING_ENDIAN
= 23,
55 VHOST_USER_GET_CONFIG
= 24,
56 VHOST_USER_SET_CONFIG
= 25,
57 VHOST_USER_VRING_KICK
= 35,
60 enum vhost_user_slave_request
{
61 VHOST_USER_SLAVE_IOTLB_MSG
= 1,
62 VHOST_USER_SLAVE_CONFIG_CHANGE_MSG
= 2,
63 VHOST_USER_SLAVE_VRING_HOST_NOTIFIER_MSG
= 3,
64 VHOST_USER_SLAVE_VRING_CALL
= 4,
67 struct vhost_user_header
{
69 * Use enum vhost_user_request for outgoing messages,
70 * uses enum vhost_user_slave_request for incoming ones.
77 struct vhost_user_config
{
81 u8 payload
[]; /* Variable length */
84 struct vhost_user_vring_state
{
89 struct vhost_user_vring_addr
{
92 u64 desc
, used
, avail
, log
;
95 struct vhost_user_mem_region
{
102 struct vhost_user_mem_regions
{
105 struct vhost_user_mem_region regions
[2]; /* Currently supporting 2 */
108 union vhost_user_payload
{
110 struct vhost_user_config config
;
111 struct vhost_user_vring_state vring_state
;
112 struct vhost_user_vring_addr vring_addr
;
113 struct vhost_user_mem_regions mem_regions
;
116 struct vhost_user_msg
{
117 struct vhost_user_header header
;
118 union vhost_user_payload payload
;