1dbdfea92SCornelia Huck /*
2dbdfea92SCornelia Huck  * This header, excluding the #ifdef __KERNEL__ part, is BSD licensed so
3dbdfea92SCornelia Huck  * anyone can use the definitions to implement compatible drivers/servers:
4dbdfea92SCornelia Huck  *
5dbdfea92SCornelia Huck  *
6dbdfea92SCornelia Huck  * Redistribution and use in source and binary forms, with or without
7dbdfea92SCornelia Huck  * modification, are permitted provided that the following conditions
8dbdfea92SCornelia Huck  * are met:
9dbdfea92SCornelia Huck  * 1. Redistributions of source code must retain the above copyright
10dbdfea92SCornelia Huck  *    notice, this list of conditions and the following disclaimer.
11dbdfea92SCornelia Huck  * 2. Redistributions in binary form must reproduce the above copyright
12dbdfea92SCornelia Huck  *    notice, this list of conditions and the following disclaimer in the
13dbdfea92SCornelia Huck  *    documentation and/or other materials provided with the distribution.
14dbdfea92SCornelia Huck  * 3. Neither the name of IBM nor the names of its contributors
15dbdfea92SCornelia Huck  *    may be used to endorse or promote products derived from this software
16dbdfea92SCornelia Huck  *    without specific prior written permission.
17dbdfea92SCornelia Huck  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
18dbdfea92SCornelia Huck  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19dbdfea92SCornelia Huck  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20dbdfea92SCornelia Huck  * ARE DISCLAIMED.  IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
21dbdfea92SCornelia Huck  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22dbdfea92SCornelia Huck  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23dbdfea92SCornelia Huck  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24dbdfea92SCornelia Huck  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25dbdfea92SCornelia Huck  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26dbdfea92SCornelia Huck  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27dbdfea92SCornelia Huck  * SUCH DAMAGE.
28dbdfea92SCornelia Huck  *
29dbdfea92SCornelia Huck  * Copyright (C) Red Hat, Inc., 2013-2015
30dbdfea92SCornelia Huck  * Copyright (C) Asias He <asias@redhat.com>, 2013
31dbdfea92SCornelia Huck  * Copyright (C) Stefan Hajnoczi <stefanha@redhat.com>, 2015
32dbdfea92SCornelia Huck  */
33dbdfea92SCornelia Huck 
34dbdfea92SCornelia Huck #ifndef _LINUX_VIRTIO_VSOCK_H
35dbdfea92SCornelia Huck #define _LINUX_VIRTIO_VSOCK_H
36dbdfea92SCornelia Huck 
37dbdfea92SCornelia Huck #include "standard-headers/linux/types.h"
38dbdfea92SCornelia Huck #include "standard-headers/linux/virtio_ids.h"
39dbdfea92SCornelia Huck #include "standard-headers/linux/virtio_config.h"
40dbdfea92SCornelia Huck 
41*327d4b7fSBharata B Rao /* The feature bitmap for virtio vsock */
42*327d4b7fSBharata B Rao #define VIRTIO_VSOCK_F_SEQPACKET	1	/* SOCK_SEQPACKET supported */
43*327d4b7fSBharata B Rao 
44dbdfea92SCornelia Huck struct virtio_vsock_config {
45dbdfea92SCornelia Huck 	uint64_t guest_cid;
46dbdfea92SCornelia Huck } QEMU_PACKED;
47dbdfea92SCornelia Huck 
48dbdfea92SCornelia Huck enum virtio_vsock_event_id {
49dbdfea92SCornelia Huck 	VIRTIO_VSOCK_EVENT_TRANSPORT_RESET = 0,
50dbdfea92SCornelia Huck };
51dbdfea92SCornelia Huck 
52dbdfea92SCornelia Huck struct virtio_vsock_event {
53dbdfea92SCornelia Huck 	uint32_t id;
54dbdfea92SCornelia Huck } QEMU_PACKED;
55dbdfea92SCornelia Huck 
56dbdfea92SCornelia Huck struct virtio_vsock_hdr {
57dbdfea92SCornelia Huck 	uint64_t	src_cid;
58dbdfea92SCornelia Huck 	uint64_t	dst_cid;
59dbdfea92SCornelia Huck 	uint32_t	src_port;
60dbdfea92SCornelia Huck 	uint32_t	dst_port;
61dbdfea92SCornelia Huck 	uint32_t	len;
62dbdfea92SCornelia Huck 	uint16_t	type;		/* enum virtio_vsock_type */
63dbdfea92SCornelia Huck 	uint16_t	op;		/* enum virtio_vsock_op */
64dbdfea92SCornelia Huck 	uint32_t	flags;
65dbdfea92SCornelia Huck 	uint32_t	buf_alloc;
66dbdfea92SCornelia Huck 	uint32_t	fwd_cnt;
67dbdfea92SCornelia Huck } QEMU_PACKED;
68dbdfea92SCornelia Huck 
69dbdfea92SCornelia Huck enum virtio_vsock_type {
70dbdfea92SCornelia Huck 	VIRTIO_VSOCK_TYPE_STREAM = 1,
71*327d4b7fSBharata B Rao 	VIRTIO_VSOCK_TYPE_SEQPACKET = 2,
72dbdfea92SCornelia Huck };
73dbdfea92SCornelia Huck 
74dbdfea92SCornelia Huck enum virtio_vsock_op {
75dbdfea92SCornelia Huck 	VIRTIO_VSOCK_OP_INVALID = 0,
76dbdfea92SCornelia Huck 
77dbdfea92SCornelia Huck 	/* Connect operations */
78dbdfea92SCornelia Huck 	VIRTIO_VSOCK_OP_REQUEST = 1,
79dbdfea92SCornelia Huck 	VIRTIO_VSOCK_OP_RESPONSE = 2,
80dbdfea92SCornelia Huck 	VIRTIO_VSOCK_OP_RST = 3,
81dbdfea92SCornelia Huck 	VIRTIO_VSOCK_OP_SHUTDOWN = 4,
82dbdfea92SCornelia Huck 
83dbdfea92SCornelia Huck 	/* To send payload */
84dbdfea92SCornelia Huck 	VIRTIO_VSOCK_OP_RW = 5,
85dbdfea92SCornelia Huck 
86dbdfea92SCornelia Huck 	/* Tell the peer our credit info */
87dbdfea92SCornelia Huck 	VIRTIO_VSOCK_OP_CREDIT_UPDATE = 6,
88dbdfea92SCornelia Huck 	/* Request the peer to send the credit info to us */
89dbdfea92SCornelia Huck 	VIRTIO_VSOCK_OP_CREDIT_REQUEST = 7,
90dbdfea92SCornelia Huck };
91dbdfea92SCornelia Huck 
92dbdfea92SCornelia Huck /* VIRTIO_VSOCK_OP_SHUTDOWN flags values */
93dbdfea92SCornelia Huck enum virtio_vsock_shutdown {
94dbdfea92SCornelia Huck 	VIRTIO_VSOCK_SHUTDOWN_RCV = 1,
95dbdfea92SCornelia Huck 	VIRTIO_VSOCK_SHUTDOWN_SEND = 2,
96dbdfea92SCornelia Huck };
97dbdfea92SCornelia Huck 
98*327d4b7fSBharata B Rao /* VIRTIO_VSOCK_OP_RW flags values */
99*327d4b7fSBharata B Rao enum virtio_vsock_rw {
100*327d4b7fSBharata B Rao 	VIRTIO_VSOCK_SEQ_EOR = 1,
101*327d4b7fSBharata B Rao };
102*327d4b7fSBharata B Rao 
103dbdfea92SCornelia Huck #endif /* _LINUX_VIRTIO_VSOCK_H */
104