common/cnxk: allow building for generic arm64
[dpdk.git] / examples / vhost_blk / blk_spec.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019 Intel Corporation
3  */
4
5 #ifndef _BLK_SPEC_H
6 #define _BLK_SPEC_H
7
8 #include <stdint.h>
9
10 #ifndef VHOST_USER_MEMORY_MAX_NREGIONS
11 #define VHOST_USER_MEMORY_MAX_NREGIONS          8
12 #endif
13
14 #ifndef VHOST_USER_MAX_CONFIG_SIZE
15 #define VHOST_USER_MAX_CONFIG_SIZE              256
16 #endif
17
18 #ifndef VHOST_USER_PROTOCOL_F_CONFIG
19 #define VHOST_USER_PROTOCOL_F_CONFIG            9
20 #endif
21
22 #ifndef VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD
23 #define VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD    12
24 #endif
25
26 #define VIRTIO_BLK_ID_BYTES     20      /* ID string length */
27
28 #define VIRTIO_BLK_T_IN                 0
29 #define VIRTIO_BLK_T_OUT                1
30 #define VIRTIO_BLK_T_FLUSH              4
31 #define VIRTIO_BLK_T_GET_ID             8
32 #define VIRTIO_BLK_T_DISCARD            11
33 #define VIRTIO_BLK_T_WRITE_ZEROES       13
34
35 #define VIRTIO_BLK_S_OK                 0
36 #define VIRTIO_BLK_S_IOERR              1
37 #define VIRTIO_BLK_S_UNSUPP             2
38
39 enum vhost_user_request {
40         VHOST_USER_NONE = 0,
41         VHOST_USER_GET_FEATURES = 1,
42         VHOST_USER_SET_FEATURES = 2,
43         VHOST_USER_SET_OWNER = 3,
44         VHOST_USER_RESET_OWNER = 4,
45         VHOST_USER_SET_MEM_TABLE = 5,
46         VHOST_USER_SET_LOG_BASE = 6,
47         VHOST_USER_SET_LOG_FD = 7,
48         VHOST_USER_SET_VRING_NUM = 8,
49         VHOST_USER_SET_VRING_ADDR = 9,
50         VHOST_USER_SET_VRING_BASE = 10,
51         VHOST_USER_GET_VRING_BASE = 11,
52         VHOST_USER_SET_VRING_KICK = 12,
53         VHOST_USER_SET_VRING_CALL = 13,
54         VHOST_USER_SET_VRING_ERR = 14,
55         VHOST_USER_GET_PROTOCOL_FEATURES = 15,
56         VHOST_USER_SET_PROTOCOL_FEATURES = 16,
57         VHOST_USER_GET_QUEUE_NUM = 17,
58         VHOST_USER_SET_VRING_ENABLE = 18,
59 };
60
61 /** Get/set config msg payload */
62 struct vhost_user_config {
63         uint32_t offset;
64         uint32_t size;
65         uint32_t flags;
66         uint8_t region[VHOST_USER_MAX_CONFIG_SIZE];
67 };
68
69 /** Fixed-size vhost_memory struct */
70 struct vhost_memory_padded {
71         uint32_t nregions;
72         uint32_t padding;
73         struct vhost_memory_region regions[VHOST_USER_MEMORY_MAX_NREGIONS];
74 };
75
76 struct vhost_user_msg {
77         enum vhost_user_request request;
78
79 #define VHOST_USER_VERSION_MASK     0x3
80 #define VHOST_USER_REPLY_MASK       (0x1 << 2)
81         uint32_t flags;
82         uint32_t size; /**< the following payload size */
83         union {
84 #define VHOST_USER_VRING_IDX_MASK   0xff
85 #define VHOST_USER_VRING_NOFD_MASK  (0x1 << 8)
86                 uint64_t u64;
87                 struct vhost_vring_state state;
88                 struct vhost_vring_addr addr;
89                 struct vhost_memory_padded memory;
90                 struct vhost_user_config cfg;
91         } payload;
92 } __rte_packed;
93
94 #endif