Mohsin Kazmi | a7a2281 | 2020-08-31 17:17:16 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015 Cisco and/or its affiliates. |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at: |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. |
| 14 | */ |
| 15 | #ifndef __VIRTIO_VHOST_STD_H__ |
| 16 | #define __VIRTIO_VHOST_STD_H__ |
| 17 | |
| 18 | typedef struct |
| 19 | { |
| 20 | u64 guest_phys_addr; |
| 21 | u64 memory_size; |
| 22 | u64 userspace_addr; |
| 23 | u64 mmap_offset; |
| 24 | } vhost_memory_region_t; |
| 25 | |
| 26 | typedef struct |
| 27 | { |
| 28 | u32 nregions; |
| 29 | u32 padding; |
| 30 | vhost_memory_region_t regions[0]; |
| 31 | } vhost_memory_t; |
| 32 | |
| 33 | typedef struct |
| 34 | { |
| 35 | u32 index; |
| 36 | u32 num; |
| 37 | } vhost_vring_state_t; |
| 38 | |
| 39 | typedef struct |
| 40 | { |
| 41 | u32 index; |
| 42 | int fd; |
| 43 | } vhost_vring_file_t; |
| 44 | |
| 45 | typedef struct |
| 46 | { |
| 47 | u32 index; |
| 48 | u32 flags; |
| 49 | u64 desc_user_addr; |
| 50 | u64 used_user_addr; |
| 51 | u64 avail_user_addr; |
| 52 | u64 log_guest_addr; |
| 53 | } vhost_vring_addr_t; |
| 54 | |
| 55 | typedef struct |
| 56 | { |
| 57 | u64 size; |
| 58 | u64 offset; |
| 59 | } vhost_user_log_t; |
| 60 | |
| 61 | /* vhost kernel ioctls */ |
| 62 | #define VHOST_VIRTIO 0xAF |
| 63 | #define VHOST_GET_FEATURES _IOR(VHOST_VIRTIO, 0x00, u64) |
| 64 | #define VHOST_SET_FEATURES _IOW(VHOST_VIRTIO, 0x00, u64) |
| 65 | #define VHOST_SET_OWNER _IO(VHOST_VIRTIO, 0x01) |
| 66 | #define VHOST_RESET_OWNER _IO(VHOST_VIRTIO, 0x02) |
| 67 | #define VHOST_SET_MEM_TABLE _IOW(VHOST_VIRTIO, 0x03, vhost_memory_t) |
| 68 | #define VHOST_SET_LOG_BASE _IOW(VHOST_VIRTIO, 0x04, u64) |
| 69 | #define VHOST_SET_LOG_FD _IOW(VHOST_VIRTIO, 0x07, int) |
| 70 | #define VHOST_SET_VRING_NUM _IOW(VHOST_VIRTIO, 0x10, vhost_vring_state_t) |
| 71 | #define VHOST_SET_VRING_ADDR _IOW(VHOST_VIRTIO, 0x11, vhost_vring_addr_t) |
| 72 | #define VHOST_SET_VRING_BASE _IOW(VHOST_VIRTIO, 0x12, vhost_vring_state_t) |
| 73 | #define VHOST_GET_VRING_BASE _IOWR(VHOST_VIRTIO, 0x12, vhost_vring_state_t) |
| 74 | #define VHOST_SET_VRING_KICK _IOW(VHOST_VIRTIO, 0x20, vhost_vring_file_t) |
| 75 | #define VHOST_SET_VRING_CALL _IOW(VHOST_VIRTIO, 0x21, vhost_vring_file_t) |
| 76 | #define VHOST_SET_VRING_ERR _IOW(VHOST_VIRTIO, 0x22, vhost_vring_file_t) |
| 77 | #define VHOST_NET_SET_BACKEND _IOW(VHOST_VIRTIO, 0x30, vhost_vring_file_t) |
| 78 | |
| 79 | #endif |
| 80 | |
| 81 | /* |
| 82 | * fd.io coding-style-patch-verification: ON |
| 83 | * |
| 84 | * Local Variables: |
| 85 | * eval: (c-set-style "gnu") |
| 86 | * End: |
| 87 | */ |