1 /************************************************************************** 2 * 3 * Copyright (C) 2015 Red Hat Inc. 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be included 13 * in all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 21 * OTHER DEALINGS IN THE SOFTWARE. 22 * 23 **************************************************************************/ 24 25 #ifndef VTEST_PROTOCOL 26 #define VTEST_PROTOCOL 27 28 #define VTEST_DEFAULT_SOCKET_NAME "/tmp/.virgl_test" 29 30 #ifdef VIRGL_RENDERER_UNSTABLE_APIS 31 #define VTEST_PROTOCOL_VERSION 3 32 #else 33 #define VTEST_PROTOCOL_VERSION 2 34 #endif 35 36 /* 32-bit length field */ 37 /* 32-bit cmd field */ 38 #define VTEST_HDR_SIZE 2 39 #define VTEST_CMD_LEN 0 /* length of data */ 40 #define VTEST_CMD_ID 1 41 #define VTEST_CMD_DATA_START 2 42 43 /* vtest cmds */ 44 #define VCMD_GET_CAPS 1 45 46 #define VCMD_RESOURCE_CREATE 2 47 #define VCMD_RESOURCE_UNREF 3 48 49 #define VCMD_TRANSFER_GET 4 50 #define VCMD_TRANSFER_PUT 5 51 52 #define VCMD_SUBMIT_CMD 6 53 54 #define VCMD_RESOURCE_BUSY_WAIT 7 55 56 /* pass the process cmd line for debugging */ 57 #define VCMD_CREATE_RENDERER 8 58 59 #define VCMD_GET_CAPS2 9 60 /* get caps */ 61 /* 0 length cmd */ 62 /* resp VCMD_GET_CAPS + caps */ 63 64 #define VCMD_PING_PROTOCOL_VERSION 10 65 66 #define VCMD_PROTOCOL_VERSION 11 67 68 /* since protocol version 2 */ 69 #define VCMD_RESOURCE_CREATE2 12 70 #define VCMD_TRANSFER_GET2 13 71 #define VCMD_TRANSFER_PUT2 14 72 73 #ifdef VIRGL_RENDERER_UNSTABLE_APIS 74 /* since protocol version 3 */ 75 #define VCMD_GET_PARAM 15 76 #define VCMD_GET_CAPSET 16 77 #define VCMD_CONTEXT_INIT 17 78 #define VCMD_RESOURCE_CREATE_BLOB 18 79 #define VCMD_SYNC_CREATE 19 80 #define VCMD_SYNC_UNREF 20 81 #define VCMD_SYNC_READ 21 82 #define VCMD_SYNC_WRITE 22 83 #define VCMD_SYNC_WAIT 23 84 #define VCMD_SUBMIT_CMD2 24 85 #endif /* VIRGL_RENDERER_UNSTABLE_APIS */ 86 87 #define VCMD_RES_CREATE_SIZE 10 88 #define VCMD_RES_CREATE_RES_HANDLE 0 /* must be 0 since protocol version 3 */ 89 #define VCMD_RES_CREATE_TARGET 1 90 #define VCMD_RES_CREATE_FORMAT 2 91 #define VCMD_RES_CREATE_BIND 3 92 #define VCMD_RES_CREATE_WIDTH 4 93 #define VCMD_RES_CREATE_HEIGHT 5 94 #define VCMD_RES_CREATE_DEPTH 6 95 #define VCMD_RES_CREATE_ARRAY_SIZE 7 96 #define VCMD_RES_CREATE_LAST_LEVEL 8 97 #define VCMD_RES_CREATE_NR_SAMPLES 9 98 /* resp res_id since protocol version 3 */ 99 100 #define VCMD_RES_CREATE2_SIZE 11 101 #define VCMD_RES_CREATE2_RES_HANDLE 0 /* must be 0 since protocol version 3 */ 102 #define VCMD_RES_CREATE2_TARGET 1 103 #define VCMD_RES_CREATE2_FORMAT 2 104 #define VCMD_RES_CREATE2_BIND 3 105 #define VCMD_RES_CREATE2_WIDTH 4 106 #define VCMD_RES_CREATE2_HEIGHT 5 107 #define VCMD_RES_CREATE2_DEPTH 6 108 #define VCMD_RES_CREATE2_ARRAY_SIZE 7 109 #define VCMD_RES_CREATE2_LAST_LEVEL 8 110 #define VCMD_RES_CREATE2_NR_SAMPLES 9 111 #define VCMD_RES_CREATE2_DATA_SIZE 10 112 /* resp res_id since protocol version 3, and fd if data_size >0 */ 113 114 #define VCMD_RES_UNREF_SIZE 1 115 #define VCMD_RES_UNREF_RES_HANDLE 0 116 117 #define VCMD_TRANSFER_HDR_SIZE 11 118 #define VCMD_TRANSFER_RES_HANDLE 0 119 #define VCMD_TRANSFER_LEVEL 1 120 #define VCMD_TRANSFER_STRIDE 2 121 #define VCMD_TRANSFER_LAYER_STRIDE 3 122 #define VCMD_TRANSFER_X 4 123 #define VCMD_TRANSFER_Y 5 124 #define VCMD_TRANSFER_Z 6 125 #define VCMD_TRANSFER_WIDTH 7 126 #define VCMD_TRANSFER_HEIGHT 8 127 #define VCMD_TRANSFER_DEPTH 9 128 #define VCMD_TRANSFER_DATA_SIZE 10 129 130 #define VCMD_TRANSFER2_HDR_SIZE 10 131 #define VCMD_TRANSFER2_RES_HANDLE 0 132 #define VCMD_TRANSFER2_LEVEL 1 133 #define VCMD_TRANSFER2_X 2 134 #define VCMD_TRANSFER2_Y 3 135 #define VCMD_TRANSFER2_Z 4 136 #define VCMD_TRANSFER2_WIDTH 5 137 #define VCMD_TRANSFER2_HEIGHT 6 138 #define VCMD_TRANSFER2_DEPTH 7 139 #define VCMD_TRANSFER2_DATA_SIZE 8 140 #define VCMD_TRANSFER2_OFFSET 9 141 142 #define VCMD_BUSY_WAIT_FLAG_WAIT 1 143 144 #define VCMD_BUSY_WAIT_SIZE 2 145 #define VCMD_BUSY_WAIT_HANDLE 0 146 #define VCMD_BUSY_WAIT_FLAGS 1 147 148 #define VCMD_PING_PROTOCOL_VERSION_SIZE 0 149 150 #define VCMD_PROTOCOL_VERSION_SIZE 1 151 #define VCMD_PROTOCOL_VERSION_VERSION 0 152 153 #ifdef VIRGL_RENDERER_UNSTABLE_APIS 154 155 enum vcmd_param { 156 VCMD_PARAM_MAX_SYNC_QUEUE_COUNT = 1, 157 }; 158 #define VCMD_GET_PARAM_SIZE 1 159 #define VCMD_GET_PARAM_PARAM 0 160 /* resp param validity and value */ 161 162 #define VCMD_GET_CAPSET_SIZE 2 163 #define VCMD_GET_CAPSET_ID 0 164 #define VCMD_GET_CAPSET_VERSION 1 165 /* resp capset validity and contents */ 166 167 #define VCMD_CONTEXT_INIT_SIZE 1 168 #define VCMD_CONTEXT_INIT_CAPSET_ID 0 169 170 enum vcmd_blob_type { 171 VCMD_BLOB_TYPE_GUEST = 1, 172 VCMD_BLOB_TYPE_HOST3D = 2, 173 VCMD_BLOB_TYPE_HOST3D_GUEST = 3, 174 }; 175 176 enum vcmd_blob_flag { 177 VCMD_BLOB_FLAG_MAPPABLE = 1 << 0, 178 VCMD_BLOB_FLAG_SHAREABLE = 1 << 1, 179 VCMD_BLOB_FLAG_CROSS_DEVICE = 1 << 2, 180 }; 181 182 #define VCMD_RES_CREATE_BLOB_SIZE 6 183 #define VCMD_RES_CREATE_BLOB_TYPE 0 184 #define VCMD_RES_CREATE_BLOB_FLAGS 1 185 #define VCMD_RES_CREATE_BLOB_SIZE_LO 2 186 #define VCMD_RES_CREATE_BLOB_SIZE_HI 3 187 #define VCMD_RES_CREATE_BLOB_ID_LO 4 188 #define VCMD_RES_CREATE_BLOB_ID_HI 5 189 /* resp res_id and mmap'able fd */ 190 191 #define VCMD_SYNC_CREATE_SIZE 2 192 #define VCMD_SYNC_CREATE_VALUE_LO 0 193 #define VCMD_SYNC_CREATE_VALUE_HI 1 194 /* resp sync id */ 195 196 #define VCMD_SYNC_UNREF_SIZE 1 197 #define VCMD_SYNC_UNREF_ID 0 198 199 #define VCMD_SYNC_READ_SIZE 1 200 #define VCMD_SYNC_READ_ID 0 201 /* resp sync value */ 202 203 #define VCMD_SYNC_WRITE_SIZE 3 204 #define VCMD_SYNC_WRITE_ID 0 205 #define VCMD_SYNC_WRITE_VALUE_LO 1 206 #define VCMD_SYNC_WRITE_VALUE_HI 2 207 208 enum vcmd_sync_wait_flag { 209 VCMD_SYNC_WAIT_FLAG_ANY = 1 << 0, 210 }; 211 #define VCMD_SYNC_WAIT_SIZE(count) (2 + 3 * count) 212 #define VCMD_SYNC_WAIT_FLAGS 0 213 #define VCMD_SYNC_WAIT_TIMEOUT 1 214 #define VCMD_SYNC_WAIT_ID(n) (2 + 3 * (n) + 0) 215 #define VCMD_SYNC_WAIT_VALUE_LO(n) (2 + 3 * (n) + 1) 216 #define VCMD_SYNC_WAIT_VALUE_HI(n) (2 + 3 * (n) + 2) 217 /* resp poll'able fd */ 218 219 enum vcmd_submit_cmd2_flag { 220 VCMD_SUBMIT_CMD2_FLAG_SYNC_QUEUE = 1 << 0, 221 }; 222 223 struct vcmd_submit_cmd2_batch { 224 uint32_t flags; 225 226 uint32_t cmd_offset; 227 uint32_t cmd_size; 228 229 /* sync_count pairs of (id, val) starting at sync_offset */ 230 uint32_t sync_offset; 231 uint32_t sync_count; 232 233 /* ignored unless VCMD_SUBMIT_CMD2_FLAG_SYNC_QUEUE is set */ 234 uint32_t sync_queue_index; 235 uint64_t sync_queue_id; 236 }; 237 #define VCMD_SUBMIT_CMD2_BATCH_COUNT 0 238 #define VCMD_SUBMIT_CMD2_BATCH_FLAGS(n) (1 + 8 * (n) + 0) 239 #define VCMD_SUBMIT_CMD2_BATCH_CMD_OFFSET(n) (1 + 8 * (n) + 1) 240 #define VCMD_SUBMIT_CMD2_BATCH_CMD_SIZE(n) (1 + 8 * (n) + 2) 241 #define VCMD_SUBMIT_CMD2_BATCH_SYNC_OFFSET(n) (1 + 8 * (n) + 3) 242 #define VCMD_SUBMIT_CMD2_BATCH_SYNC_COUNT(n) (1 + 8 * (n) + 4) 243 #define VCMD_SUBMIT_CMD2_BATCH_SYNC_QUEUE_INDEX(n) (1 + 8 * (n) + 5) 244 #define VCMD_SUBMIT_CMD2_BATCH_SYNC_QUEUE_ID_LO(n) (1 + 8 * (n) + 6) 245 #define VCMD_SUBMIT_CMD2_BATCH_SYNC_QUEUE_ID_HI(n) (1 + 8 * (n) + 7) 246 247 #endif /* VIRGL_RENDERER_UNSTABLE_APIS */ 248 249 #endif /* VTEST_PROTOCOL */ 250