1/*
2 * pvcalls.h -- Xen PV Calls Protocol
3 *
4 * Refer to docs/misc/pvcalls.markdown for the specification
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *
24 * Copyright (C) 2017 Stefano Stabellini <stefano@aporeto.com>
25 */
26
27#ifndef __XEN_PUBLIC_IO_PVCALLS_H__
28#define __XEN_PUBLIC_IO_PVCALLS_H__
29
30#include "../grant_table.h"
31#include "ring.h"
32
33/*
34 * See docs/misc/pvcalls.markdown in xen.git for the full specification:
35 * https://xenbits.xen.org/docs/unstable/misc/pvcalls.html
36 */
37struct pvcalls_data_intf {
38    RING_IDX in_cons, in_prod, in_error;
39
40    uint8_t pad1[52];
41
42    RING_IDX out_cons, out_prod, out_error;
43
44    uint8_t pad2[52];
45
46    RING_IDX ring_order;
47    grant_ref_t ref[];
48};
49DEFINE_XEN_FLEX_RING(pvcalls);
50
51#define PVCALLS_SOCKET         0
52#define PVCALLS_CONNECT        1
53#define PVCALLS_RELEASE        2
54#define PVCALLS_BIND           3
55#define PVCALLS_LISTEN         4
56#define PVCALLS_ACCEPT         5
57#define PVCALLS_POLL           6
58
59struct xen_pvcalls_request {
60    uint32_t req_id; /* private to guest, echoed in response */
61    uint32_t cmd;    /* command to execute */
62    union {
63        struct xen_pvcalls_socket {
64            uint64_t id;
65            uint32_t domain;
66            uint32_t type;
67            uint32_t protocol;
68        } socket;
69        struct xen_pvcalls_connect {
70            uint64_t id;
71            uint8_t addr[28];
72            uint32_t len;
73            uint32_t flags;
74            grant_ref_t ref;
75            uint32_t evtchn;
76        } connect;
77        struct xen_pvcalls_release {
78            uint64_t id;
79            uint8_t reuse;
80        } release;
81        struct xen_pvcalls_bind {
82            uint64_t id;
83            uint8_t addr[28];
84            uint32_t len;
85        } bind;
86        struct xen_pvcalls_listen {
87            uint64_t id;
88            uint32_t backlog;
89        } listen;
90        struct xen_pvcalls_accept {
91            uint64_t id;
92            uint64_t id_new;
93            grant_ref_t ref;
94            uint32_t evtchn;
95        } accept;
96        struct xen_pvcalls_poll {
97            uint64_t id;
98        } poll;
99        /* dummy member to force sizeof(struct xen_pvcalls_request)
100         * to match across archs */
101        struct xen_pvcalls_dummy {
102            uint8_t dummy[56];
103        } dummy;
104    } u;
105};
106
107struct xen_pvcalls_response {
108    uint32_t req_id;
109    uint32_t cmd;
110    int32_t ret;
111    uint32_t pad;
112    union {
113        struct _xen_pvcalls_socket {
114            uint64_t id;
115        } socket;
116        struct _xen_pvcalls_connect {
117            uint64_t id;
118        } connect;
119        struct _xen_pvcalls_release {
120            uint64_t id;
121        } release;
122        struct _xen_pvcalls_bind {
123            uint64_t id;
124        } bind;
125        struct _xen_pvcalls_listen {
126            uint64_t id;
127        } listen;
128        struct _xen_pvcalls_accept {
129            uint64_t id;
130        } accept;
131        struct _xen_pvcalls_poll {
132            uint64_t id;
133        } poll;
134        struct _xen_pvcalls_dummy {
135            uint8_t dummy[8];
136        } dummy;
137    } u;
138};
139
140DEFINE_RING_TYPES(xen_pvcalls, struct xen_pvcalls_request,
141                  struct xen_pvcalls_response);
142
143#endif
144
145/*
146 * Local variables:
147 * mode: C
148 * c-file-style: "BSD"
149 * c-basic-offset: 4
150 * tab-width: 4
151 * indent-tabs-mode: nil
152 * End:
153 */
154