xref: /aosp_15_r20/external/crosvm/virtio_sys/src/vhost_ioctl.rs (revision bb4ee6a4ae7042d18b07a98463b9c8b875e44b39)
1 // Copyright 2023 The ChromiumOS Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 //! Linux vhost kernel bindings.
6 
7 use base::ioctl_io_nr;
8 use base::ioctl_ior_nr;
9 use base::ioctl_iow_nr;
10 use base::ioctl_iowr_nr;
11 
12 use crate::vhost;
13 
14 pub const VHOST: ::std::os::raw::c_uint = 0xaf;
15 
16 ioctl_ior_nr!(VHOST_GET_FEATURES, VHOST, 0x00, ::std::os::raw::c_ulonglong);
17 ioctl_iow_nr!(VHOST_SET_FEATURES, VHOST, 0x00, ::std::os::raw::c_ulonglong);
18 ioctl_io_nr!(VHOST_SET_OWNER, VHOST, 0x01);
19 ioctl_io_nr!(VHOST_RESET_OWNER, VHOST, 0x02);
20 ioctl_iow_nr!(VHOST_SET_MEM_TABLE, VHOST, 0x03, vhost::vhost_memory);
21 ioctl_iow_nr!(VHOST_SET_LOG_BASE, VHOST, 0x04, ::std::os::raw::c_ulonglong);
22 ioctl_iow_nr!(VHOST_SET_LOG_FD, VHOST, 0x07, ::std::os::raw::c_int);
23 ioctl_iow_nr!(VHOST_SET_VRING_NUM, VHOST, 0x10, vhost::vhost_vring_state);
24 ioctl_iow_nr!(VHOST_SET_VRING_ADDR, VHOST, 0x11, vhost::vhost_vring_addr);
25 ioctl_iow_nr!(VHOST_SET_VRING_BASE, VHOST, 0x12, vhost::vhost_vring_state);
26 ioctl_iowr_nr!(VHOST_GET_VRING_BASE, VHOST, 0x12, vhost::vhost_vring_state);
27 ioctl_iow_nr!(VHOST_SET_VRING_KICK, VHOST, 0x20, vhost::vhost_vring_file);
28 ioctl_iow_nr!(VHOST_SET_VRING_CALL, VHOST, 0x21, vhost::vhost_vring_file);
29 ioctl_iow_nr!(VHOST_SET_VRING_ERR, VHOST, 0x22, vhost::vhost_vring_file);
30 ioctl_iow_nr!(VHOST_NET_SET_BACKEND, VHOST, 0x30, vhost::vhost_vring_file);
31 ioctl_iow_nr!(
32     VHOST_SCSI_SET_ENDPOINT,
33     VHOST,
34     0x40,
35     vhost::vhost_scsi_target
36 );
37 ioctl_iow_nr!(
38     VHOST_SCSI_CLEAR_ENDPOINT,
39     VHOST,
40     0x41,
41     vhost::vhost_scsi_target
42 );
43 ioctl_iow_nr!(
44     VHOST_SCSI_GET_ABI_VERSION,
45     VHOST,
46     0x42,
47     ::std::os::raw::c_int
48 );
49 ioctl_iow_nr!(
50     VHOST_SCSI_SET_EVENTS_MISSED,
51     VHOST,
52     0x43,
53     ::std::os::raw::c_uint
54 );
55 ioctl_iow_nr!(
56     VHOST_SCSI_GET_EVENTS_MISSED,
57     VHOST,
58     0x44,
59     ::std::os::raw::c_uint
60 );
61 ioctl_iow_nr!(
62     VHOST_VSOCK_SET_GUEST_CID,
63     VHOST,
64     0x60,
65     ::std::os::raw::c_ulonglong
66 );
67 ioctl_iow_nr!(VHOST_VSOCK_SET_RUNNING, VHOST, 0x61, ::std::os::raw::c_int);
68