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