]>
Commit | Line | Data |
---|---|---|
9f95a23c TL |
1 | /*- |
2 | * BSD LICENSE | |
3 | * | |
4 | * Copyright(c) 2010-2016 Intel Corporation. All rights reserved. | |
5 | * All rights reserved. | |
6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | |
10 | * | |
11 | * * Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | |
13 | * * Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in | |
15 | * the documentation and/or other materials provided with the | |
16 | * distribution. | |
17 | * * Neither the name of Intel Corporation nor the names of its | |
18 | * contributors may be used to endorse or promote products derived | |
19 | * from this software without specific prior written permission. | |
20 | * | |
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
32 | */ | |
33 | ||
34 | /** \file | |
35 | * Structures defined in the vhost-user specification | |
36 | */ | |
37 | ||
38 | #ifndef SPDK_VHOST_USER_H | |
39 | #define SPDK_VHOST_USER_H | |
40 | ||
41 | #include "spdk/stdinc.h" | |
42 | ||
43 | #include <linux/vhost.h> | |
44 | ||
45 | #ifndef VHOST_USER_MEMORY_MAX_NREGIONS | |
46 | #define VHOST_USER_MEMORY_MAX_NREGIONS 8 | |
47 | #endif | |
48 | ||
49 | #ifndef VHOST_USER_MAX_CONFIG_SIZE | |
50 | #define VHOST_USER_MAX_CONFIG_SIZE 256 | |
51 | #endif | |
52 | ||
53 | #ifndef VHOST_USER_PROTOCOL_F_MQ | |
54 | #define VHOST_USER_PROTOCOL_F_MQ 0 | |
55 | #endif | |
56 | ||
57 | #ifndef VHOST_USER_PROTOCOL_F_CONFIG | |
58 | #define VHOST_USER_PROTOCOL_F_CONFIG 9 | |
59 | #endif | |
60 | ||
f67539c2 TL |
61 | #ifndef VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD |
62 | #define VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD 12 | |
63 | #endif | |
64 | ||
65 | #ifndef VHOST_USER_F_PROTOCOL_FEATURES | |
66 | #define VHOST_USER_F_PROTOCOL_FEATURES 30 | |
67 | #endif | |
68 | ||
9f95a23c TL |
69 | enum vhost_user_request { |
70 | VHOST_USER_NONE = 0, | |
71 | VHOST_USER_GET_FEATURES = 1, | |
72 | VHOST_USER_SET_FEATURES = 2, | |
73 | VHOST_USER_SET_OWNER = 3, | |
74 | VHOST_USER_RESET_OWNER = 4, | |
75 | VHOST_USER_SET_MEM_TABLE = 5, | |
76 | VHOST_USER_SET_LOG_BASE = 6, | |
77 | VHOST_USER_SET_LOG_FD = 7, | |
78 | VHOST_USER_SET_VRING_NUM = 8, | |
79 | VHOST_USER_SET_VRING_ADDR = 9, | |
80 | VHOST_USER_SET_VRING_BASE = 10, | |
81 | VHOST_USER_GET_VRING_BASE = 11, | |
82 | VHOST_USER_SET_VRING_KICK = 12, | |
83 | VHOST_USER_SET_VRING_CALL = 13, | |
84 | VHOST_USER_SET_VRING_ERR = 14, | |
85 | VHOST_USER_GET_PROTOCOL_FEATURES = 15, | |
86 | VHOST_USER_SET_PROTOCOL_FEATURES = 16, | |
87 | VHOST_USER_GET_QUEUE_NUM = 17, | |
88 | VHOST_USER_SET_VRING_ENABLE = 18, | |
89 | VHOST_USER_SEND_RARP = 19, | |
90 | VHOST_USER_NET_SET_MTU = 20, | |
91 | VHOST_USER_SET_SLAVE_REQ_FD = 21, | |
92 | VHOST_USER_IOTLB_MSG = 22, | |
93 | VHOST_USER_GET_CONFIG = 24, | |
94 | VHOST_USER_SET_CONFIG = 25, | |
95 | VHOST_USER_CRYPTO_CREATE_SESS = 26, | |
96 | VHOST_USER_CRYPTO_CLOSE_SESS = 27, | |
97 | VHOST_USER_POSTCOPY_ADVISE = 28, | |
98 | VHOST_USER_POSTCOPY_LISTEN = 29, | |
99 | VHOST_USER_POSTCOPY_END = 30, | |
100 | VHOST_USER_MAX | |
101 | }; | |
102 | ||
103 | /** Get/set config msg payload */ | |
104 | struct vhost_user_config { | |
105 | uint32_t offset; | |
106 | uint32_t size; | |
107 | uint32_t flags; | |
108 | uint8_t region[VHOST_USER_MAX_CONFIG_SIZE]; | |
109 | }; | |
110 | ||
111 | /** Fixed-size vhost_memory struct */ | |
112 | struct vhost_memory_padded { | |
113 | uint32_t nregions; | |
114 | uint32_t padding; | |
115 | struct vhost_memory_region regions[VHOST_USER_MEMORY_MAX_NREGIONS]; | |
116 | }; | |
117 | ||
118 | struct vhost_user_msg { | |
119 | enum vhost_user_request request; | |
120 | ||
121 | #define VHOST_USER_VERSION_MASK 0x3 | |
122 | #define VHOST_USER_REPLY_MASK (0x1 << 2) | |
123 | uint32_t flags; | |
124 | uint32_t size; /**< the following payload size */ | |
125 | union { | |
126 | #define VHOST_USER_VRING_IDX_MASK 0xff | |
127 | #define VHOST_USER_VRING_NOFD_MASK (0x1 << 8) | |
128 | uint64_t u64; | |
129 | struct vhost_vring_state state; | |
130 | struct vhost_vring_addr addr; | |
131 | struct vhost_memory_padded memory; | |
132 | struct vhost_user_config cfg; | |
133 | } payload; | |
134 | } __attribute((packed)); | |
135 | ||
136 | #define VHOST_USER_HDR_SIZE offsetof(struct vhost_user_msg, payload.u64) | |
137 | #define VHOST_USER_PAYLOAD_SIZE \ | |
138 | (sizeof(struct vhost_user_msg) - VHOST_USER_HDR_SIZE) | |
139 | ||
140 | #endif /* SPDK_VHOST_USER_H */ |