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