1 /* $NetBSD: xenring.h,v 1.4 2019/04/07 12:23:54 bouyer Exp $ */ 2 3 /* 4 * Glue goop for xbd ring request/response protocol structures. 5 * 6 * These are used only from __XEN_INTERFACE_VERSION__ >= 0x00030201 7 * prior to which they were part of the public XEN api. 8 */ 9 10 #ifndef _XEN_RING_H 11 #define _XEN_RING_H 12 13 #if (__XEN_INTERFACE_VERSION__ >= 0x00030201) && \ 14 (__XEN_INTERFACE_VERSION < 0x00030208) 15 16 #include <xen/include/public/io/ring.h> 17 18 /* 19 * Undo namespace damage from xen/include/public/io/ring.h 20 * The proper fix is to get upstream to stop assuming that all OSs use 21 * mb(), rmb(), wmb(). 22 */ 23 #undef xen_mb 24 #undef xen_rmb 25 #undef xen_wmb 26 27 #define xen_mb() membar_sync() 28 #define xen_rmb() membar_producer() 29 #define xen_wmb() membar_consumer() 30 31 /* 32 * Define ring types. These were previously part of the public API. 33 * Not anymore. 34 */ 35 /* i386 requests/responses */ 36 struct blkif_x86_32_request { 37 uint8_t operation; /* BLKIF_OP_??? */ 38 uint8_t nr_segments; /* number of segments */ 39 blkif_vdev_t handle; /* only for read/write requests */ 40 uint64_t id; /* private guest value, echoed in resp */ 41 blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */ 42 struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST]; 43 } __packed; 44 typedef struct blkif_x86_32_request blkif_x86_32_request_t; 45 46 struct blkif_x86_32_response { 47 uint64_t id; /* copied from request */ 48 uint8_t operation; /* copied from request */ 49 uint8_t _pad; 50 int16_t status; /* BLKIF_RSP_??? */ 51 } __packed; 52 typedef struct blkif_x86_32_response blkif_x86_32_response_t; 53 54 /* amd64-type requests/responses (always used in frontends ) */ 55 56 struct blkif_x86_64_request { 57 uint8_t operation; /* BLKIF_OP_??? */ 58 uint8_t nr_segments; /* number of segments */ 59 blkif_vdev_t handle; /* only for read/write requests */ 60 uint64_t __attribute__((__aligned__(8))) id;/* private guest value, echoed in resp */ 61 blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */ 62 struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST]; 63 }; 64 typedef struct blkif_x86_64_request blkif_x86_64_request_t; 65 66 struct blkif_x86_64_response { 67 uint64_t __attribute__((__aligned__(8))) id; /* copied from request */ 68 uint8_t operation; /* copied from request */ 69 int16_t status; /* BLKIF_RSP_??? */ 70 }; 71 typedef struct blkif_x86_64_response blkif_x86_64_response_t; 72 73 DEFINE_RING_TYPES(blkif_x86_32, struct blkif_x86_32_request, struct blkif_x86_32_response); 74 DEFINE_RING_TYPES(blkif_x86_64, struct blkif_x86_64_request, struct blkif_x86_64_response); 75 76 union blkif_back_ring_proto { 77 blkif_back_ring_t ring_n; /* native/common members */ 78 blkif_x86_32_back_ring_t ring_32; 79 blkif_x86_64_back_ring_t ring_64; 80 }; 81 typedef union blkif_back_ring_proto blkif_back_ring_proto_t; 82 83 #endif /* __XEN_INTERFACE_VERSION__ */ 84 85 #endif /* _XEN_RING_H_ */ 86