Home | History | Annotate | Line # | Download | only in include
      1  1.8  riastrad /* $NetBSD: xenring.h,v 1.8 2024/07/16 22:44:38 riastradh Exp $ */
      2  1.1    cherry 
      3  1.1    cherry /*
      4  1.1    cherry  * Glue goop for xbd ring request/response protocol structures.
      5  1.1    cherry  *
      6  1.1    cherry  * These are used only from __XEN_INTERFACE_VERSION__ >= 0x00030201
      7  1.1    cherry  * prior to which they were part of the public XEN api.
      8  1.1    cherry  */
      9  1.1    cherry 
     10  1.1    cherry #ifndef _XEN_RING_H
     11  1.1    cherry #define _XEN_RING_H
     12  1.1    cherry 
     13  1.3    cherry #if (__XEN_INTERFACE_VERSION__ >= 0x00030201) && \
     14  1.2    cherry 	(__XEN_INTERFACE_VERSION < 0x00030208)
     15  1.1    cherry 
     16  1.1    cherry #include <xen/include/public/io/ring.h>
     17  1.1    cherry 
     18  1.2    cherry /*
     19  1.2    cherry  * Undo namespace damage from xen/include/public/io/ring.h
     20  1.2    cherry  * The proper fix is to get upstream to stop assuming that all OSs use
     21  1.2    cherry  * mb(), rmb(), wmb().
     22  1.2    cherry  */
     23  1.2    cherry #undef xen_mb
     24  1.2    cherry #undef xen_rmb
     25  1.2    cherry #undef xen_wmb
     26  1.2    cherry 
     27  1.8  riastrad void xen_mb(void);
     28  1.7  riastrad #define xen_rmb() membar_acquire()
     29  1.7  riastrad #define xen_wmb() membar_release()
     30  1.2    cherry 
     31  1.2    cherry /*
     32  1.2    cherry  * Define ring types. These were previously part of the public API.
     33  1.2    cherry  * Not anymore.
     34  1.2    cherry  */
     35  1.4    bouyer /* i386 requests/responses */
     36  1.4    bouyer struct blkif_x86_32_request {
     37  1.4    bouyer     uint8_t        operation;    /* BLKIF_OP_???                         */
     38  1.4    bouyer     uint8_t        nr_segments;  /* number of segments                   */
     39  1.4    bouyer     blkif_vdev_t   handle;       /* only for read/write requests         */
     40  1.4    bouyer     uint64_t       id;           /* private guest value, echoed in resp  */
     41  1.4    bouyer     blkif_sector_t sector_number;/* start sector idx on disk (r/w only)  */
     42  1.4    bouyer     struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
     43  1.4    bouyer } __packed;
     44  1.4    bouyer typedef struct blkif_x86_32_request blkif_x86_32_request_t;
     45  1.4    bouyer 
     46  1.4    bouyer struct blkif_x86_32_response {
     47  1.4    bouyer     uint64_t        id;              /* copied from request */
     48  1.4    bouyer     uint8_t         operation;       /* copied from request */
     49  1.4    bouyer     uint8_t         _pad;
     50  1.4    bouyer     int16_t         status;          /* BLKIF_RSP_???       */
     51  1.4    bouyer } __packed;
     52  1.4    bouyer typedef struct blkif_x86_32_response blkif_x86_32_response_t;
     53  1.4    bouyer 
     54  1.5  jdolecek struct blkif_x86_32_request_indirect {
     55  1.5  jdolecek     uint8_t        operation;    /* BLKIF_OP_INDIRECT                    */
     56  1.5  jdolecek     uint8_t        indirect_op;  /* BLKIF_OP_{READ/WRITE}                */
     57  1.5  jdolecek     uint16_t       nr_segments;  /* number of segments                   */
     58  1.5  jdolecek     uint64_t       id;		 /* private guest value, echoed in resp  */
     59  1.5  jdolecek     blkif_sector_t sector_number;/* start sector idx on disk (r/w only)  */
     60  1.5  jdolecek     blkif_vdev_t   handle;       /* only for read/write requests         */
     61  1.5  jdolecek     uint16_t	   _pad2;
     62  1.5  jdolecek     grant_ref_t    indirect_grefs[BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST];
     63  1.5  jdolecek     uint64_t       _pad3;	 /* make it 64 byte aligned */
     64  1.5  jdolecek } __packed;
     65  1.5  jdolecek typedef struct blkif_x86_32_request_indirect blkif_x86_32_request_indirect_t;
     66  1.5  jdolecek 
     67  1.4    bouyer /* amd64-type requests/responses (always used in frontends ) */
     68  1.4    bouyer 
     69  1.4    bouyer struct blkif_x86_64_request {
     70  1.4    bouyer     uint8_t        operation;    /* BLKIF_OP_???                         */
     71  1.4    bouyer     uint8_t        nr_segments;  /* number of segments                   */
     72  1.4    bouyer     blkif_vdev_t   handle;       /* only for read/write requests         */
     73  1.4    bouyer     uint64_t __attribute__((__aligned__(8))) id;/* private guest value, echoed in resp  */
     74  1.4    bouyer     blkif_sector_t sector_number;/* start sector idx on disk (r/w only)  */
     75  1.4    bouyer     struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
     76  1.4    bouyer };
     77  1.4    bouyer typedef struct blkif_x86_64_request blkif_x86_64_request_t;
     78  1.1    cherry 
     79  1.4    bouyer struct blkif_x86_64_response {
     80  1.4    bouyer     uint64_t __attribute__((__aligned__(8))) id; /* copied from request */
     81  1.4    bouyer     uint8_t         operation;       /* copied from request */
     82  1.4    bouyer     int16_t         status;          /* BLKIF_RSP_???       */
     83  1.4    bouyer };
     84  1.4    bouyer typedef struct blkif_x86_64_response blkif_x86_64_response_t;
     85  1.1    cherry 
     86  1.5  jdolecek struct blkif_x86_64_request_indirect {
     87  1.5  jdolecek     uint8_t        operation;    /* BLKIF_OP_INDIRECT                    */
     88  1.5  jdolecek     uint8_t        indirect_op;  /* BLKIF_OP_{READ/WRITE}                */
     89  1.5  jdolecek     uint16_t       nr_segments;  /* number of segments                   */
     90  1.5  jdolecek     uint32_t       _pad1;
     91  1.5  jdolecek     uint64_t       id;           /* private guest value, echoed in resp  */
     92  1.5  jdolecek     blkif_sector_t sector_number;/* start sector idx on disk (r/w only)  */
     93  1.5  jdolecek     blkif_vdev_t   handle;       /* only for read/write requests         */
     94  1.5  jdolecek     uint16_t	   _pad2;
     95  1.5  jdolecek     grant_ref_t    indirect_grefs[BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST];
     96  1.5  jdolecek     uint32_t       _pad3;	 /* make it 64 byte aligned */
     97  1.5  jdolecek } __packed;
     98  1.5  jdolecek typedef struct blkif_x86_64_request_indirect blkif_x86_64_request_indirect_t;
     99  1.5  jdolecek 
    100  1.5  jdolecek CTASSERT(sizeof(struct blkif_x86_32_request_indirect)
    101  1.5  jdolecek 	== sizeof(struct blkif_x86_64_request_indirect));
    102  1.5  jdolecek CTASSERT(sizeof(struct blkif_request_indirect)
    103  1.5  jdolecek 	== sizeof(struct blkif_x86_64_request_indirect));
    104  1.5  jdolecek 
    105  1.4    bouyer DEFINE_RING_TYPES(blkif_x86_32, struct blkif_x86_32_request, struct blkif_x86_32_response);
    106  1.4    bouyer DEFINE_RING_TYPES(blkif_x86_64, struct blkif_x86_64_request, struct blkif_x86_64_response);
    107  1.1    cherry 
    108  1.1    cherry union blkif_back_ring_proto {
    109  1.1    cherry 	blkif_back_ring_t ring_n; /* native/common members */
    110  1.1    cherry 	blkif_x86_32_back_ring_t ring_32;
    111  1.1    cherry 	blkif_x86_64_back_ring_t ring_64;
    112  1.1    cherry };
    113  1.1    cherry typedef union blkif_back_ring_proto blkif_back_ring_proto_t;
    114  1.1    cherry 
    115  1.2    cherry #endif /* __XEN_INTERFACE_VERSION__ */
    116  1.2    cherry 
    117  1.1    cherry #endif /* _XEN_RING_H_ */
    118