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