xref: /linux/include/uapi/linux/virtio_vsock.h (revision 762f99f4f3cb41a775b5157dd761217beba65873)
106a8fc78SAsias He /*
206a8fc78SAsias He  * This header, excluding the #ifdef __KERNEL__ part, is BSD licensed so
306a8fc78SAsias He  * anyone can use the definitions to implement compatible drivers/servers:
406a8fc78SAsias He  *
506a8fc78SAsias He  *
606a8fc78SAsias He  * Redistribution and use in source and binary forms, with or without
706a8fc78SAsias He  * modification, are permitted provided that the following conditions
806a8fc78SAsias He  * are met:
906a8fc78SAsias He  * 1. Redistributions of source code must retain the above copyright
1006a8fc78SAsias He  *    notice, this list of conditions and the following disclaimer.
1106a8fc78SAsias He  * 2. Redistributions in binary form must reproduce the above copyright
1206a8fc78SAsias He  *    notice, this list of conditions and the following disclaimer in the
1306a8fc78SAsias He  *    documentation and/or other materials provided with the distribution.
1406a8fc78SAsias He  * 3. Neither the name of IBM nor the names of its contributors
1506a8fc78SAsias He  *    may be used to endorse or promote products derived from this software
1606a8fc78SAsias He  *    without specific prior written permission.
1706a8fc78SAsias He  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
1806a8fc78SAsias He  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1906a8fc78SAsias He  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2006a8fc78SAsias He  * ARE DISCLAIMED.  IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
2106a8fc78SAsias He  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2206a8fc78SAsias He  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2306a8fc78SAsias He  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2406a8fc78SAsias He  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2506a8fc78SAsias He  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2606a8fc78SAsias He  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2706a8fc78SAsias He  * SUCH DAMAGE.
2806a8fc78SAsias He  *
2906a8fc78SAsias He  * Copyright (C) Red Hat, Inc., 2013-2015
3006a8fc78SAsias He  * Copyright (C) Asias He <asias@redhat.com>, 2013
3106a8fc78SAsias He  * Copyright (C) Stefan Hajnoczi <stefanha@redhat.com>, 2015
3206a8fc78SAsias He  */
3306a8fc78SAsias He 
3406a8fc78SAsias He #ifndef _UAPI_LINUX_VIRTIO_VSOCK_H
3528ad5557SStefan Hajnoczi #define _UAPI_LINUX_VIRTIO_VSOCK_H
3606a8fc78SAsias He 
3706a8fc78SAsias He #include <linux/types.h>
3806a8fc78SAsias He #include <linux/virtio_ids.h>
3906a8fc78SAsias He #include <linux/virtio_config.h>
4006a8fc78SAsias He 
41f07b2a5bSArseny Krasnov /* The feature bitmap for virtio vsock */
42f07b2a5bSArseny Krasnov #define VIRTIO_VSOCK_F_SEQPACKET	1	/* SOCK_SEQPACKET supported */
43f07b2a5bSArseny Krasnov 
4406a8fc78SAsias He struct virtio_vsock_config {
4506a8fc78SAsias He 	__le64 guest_cid;
4606a8fc78SAsias He } __attribute__((packed));
4706a8fc78SAsias He 
4806a8fc78SAsias He enum virtio_vsock_event_id {
4906a8fc78SAsias He 	VIRTIO_VSOCK_EVENT_TRANSPORT_RESET = 0,
5006a8fc78SAsias He };
5106a8fc78SAsias He 
5206a8fc78SAsias He struct virtio_vsock_event {
5306a8fc78SAsias He 	__le32 id;
5406a8fc78SAsias He } __attribute__((packed));
5506a8fc78SAsias He 
5606a8fc78SAsias He struct virtio_vsock_hdr {
5706a8fc78SAsias He 	__le64	src_cid;
5806a8fc78SAsias He 	__le64	dst_cid;
5906a8fc78SAsias He 	__le32	src_port;
6006a8fc78SAsias He 	__le32	dst_port;
6106a8fc78SAsias He 	__le32	len;
6206a8fc78SAsias He 	__le16	type;		/* enum virtio_vsock_type */
6306a8fc78SAsias He 	__le16	op;		/* enum virtio_vsock_op */
6406a8fc78SAsias He 	__le32	flags;
6506a8fc78SAsias He 	__le32	buf_alloc;
6606a8fc78SAsias He 	__le32	fwd_cnt;
6706a8fc78SAsias He } __attribute__((packed));
6806a8fc78SAsias He 
6906a8fc78SAsias He enum virtio_vsock_type {
7006a8fc78SAsias He 	VIRTIO_VSOCK_TYPE_STREAM = 1,
71f07b2a5bSArseny Krasnov 	VIRTIO_VSOCK_TYPE_SEQPACKET = 2,
7206a8fc78SAsias He };
7306a8fc78SAsias He 
7406a8fc78SAsias He enum virtio_vsock_op {
7506a8fc78SAsias He 	VIRTIO_VSOCK_OP_INVALID = 0,
7606a8fc78SAsias He 
7706a8fc78SAsias He 	/* Connect operations */
7806a8fc78SAsias He 	VIRTIO_VSOCK_OP_REQUEST = 1,
7906a8fc78SAsias He 	VIRTIO_VSOCK_OP_RESPONSE = 2,
8006a8fc78SAsias He 	VIRTIO_VSOCK_OP_RST = 3,
8106a8fc78SAsias He 	VIRTIO_VSOCK_OP_SHUTDOWN = 4,
8206a8fc78SAsias He 
8306a8fc78SAsias He 	/* To send payload */
8406a8fc78SAsias He 	VIRTIO_VSOCK_OP_RW = 5,
8506a8fc78SAsias He 
8606a8fc78SAsias He 	/* Tell the peer our credit info */
8706a8fc78SAsias He 	VIRTIO_VSOCK_OP_CREDIT_UPDATE = 6,
8806a8fc78SAsias He 	/* Request the peer to send the credit info to us */
8906a8fc78SAsias He 	VIRTIO_VSOCK_OP_CREDIT_REQUEST = 7,
9006a8fc78SAsias He };
9106a8fc78SAsias He 
9206a8fc78SAsias He /* VIRTIO_VSOCK_OP_SHUTDOWN flags values */
9306a8fc78SAsias He enum virtio_vsock_shutdown {
9406a8fc78SAsias He 	VIRTIO_VSOCK_SHUTDOWN_RCV = 1,
9506a8fc78SAsias He 	VIRTIO_VSOCK_SHUTDOWN_SEND = 2,
9606a8fc78SAsias He };
9706a8fc78SAsias He 
98f07b2a5bSArseny Krasnov /* VIRTIO_VSOCK_OP_RW flags values */
99f07b2a5bSArseny Krasnov enum virtio_vsock_rw {
1009af8f106SArseny Krasnov 	VIRTIO_VSOCK_SEQ_EOM = 1,
101*41116599SArseny Krasnov 	VIRTIO_VSOCK_SEQ_EOR = 2,
102f07b2a5bSArseny Krasnov };
103f07b2a5bSArseny Krasnov 
10406a8fc78SAsias He #endif /* _UAPI_LINUX_VIRTIO_VSOCK_H */
105