This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / include / xen / interface / io / blkif.h
1 /******************************************************************************
2  * blkif.h
3  * 
4  * Unified block-device I/O interface for Xen guest OSes.
5  * 
6  * Copyright (c) 2003-2004, Keir Fraser
7  */
8
9 #ifndef __XEN_PUBLIC_IO_BLKIF_H__
10 #define __XEN_PUBLIC_IO_BLKIF_H__
11
12 #include "ring.h"
13 #include "../grant_table.h"
14
15 /*
16  * Front->back notifications: When enqueuing a new request, sending a
17  * notification can be made conditional on req_event (i.e., the generic
18  * hold-off mechanism provided by the ring macros). Backends must set
19  * req_event appropriately (e.g., using RING_FINAL_CHECK_FOR_REQUESTS()).
20  * 
21  * Back->front notifications: When enqueuing a new response, sending a
22  * notification can be made conditional on rsp_event (i.e., the generic
23  * hold-off mechanism provided by the ring macros). Frontends must set
24  * rsp_event appropriately (e.g., using RING_FINAL_CHECK_FOR_RESPONSES()).
25  */
26
27 #ifndef blkif_vdev_t
28 #define blkif_vdev_t   uint16_t
29 #endif
30 #define blkif_sector_t uint64_t
31
32 #define BLKIF_OP_READ      0
33 #define BLKIF_OP_WRITE     1
34
35 /*
36  * Maximum scatter/gather segments per request.
37  * This is carefully chosen so that sizeof(blkif_ring_t) <= PAGE_SIZE.
38  * NB. This could be 12 if the ring indexes weren't stored in the same page.
39  */
40 #define BLKIF_MAX_SEGMENTS_PER_REQUEST 11
41
42 struct blkif_request {
43     uint8_t        operation;    /* BLKIF_OP_???                         */
44     uint8_t        nr_segments;  /* number of segments                   */
45     blkif_vdev_t   handle;       /* only for read/write requests         */
46     uint64_t       id;           /* private guest value, echoed in resp  */
47     blkif_sector_t sector_number;/* start sector idx on disk (r/w only)  */
48     struct blkif_request_segment {
49         grant_ref_t gref;        /* reference to I/O buffer frame        */
50         /* @first_sect: first sector in frame to transfer (inclusive).   */
51         /* @last_sect: last sector in frame to transfer (inclusive).     */
52         uint8_t     first_sect, last_sect;
53     } seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
54 };
55 typedef struct blkif_request blkif_request_t;
56
57 struct blkif_response {
58     uint64_t        id;              /* copied from request */
59     uint8_t         operation;       /* copied from request */
60     int16_t         status;          /* BLKIF_RSP_???       */
61 };
62 typedef struct blkif_response blkif_response_t;
63
64 #define BLKIF_RSP_ERROR  -1 /* non-specific 'error' */
65 #define BLKIF_RSP_OKAY    0 /* non-specific 'okay'  */
66
67 /*
68  * Generate blkif ring structures and types.
69  */
70
71 DEFINE_RING_TYPES(blkif, struct blkif_request, struct blkif_response);
72
73 #define VDISK_CDROM        0x1
74 #define VDISK_REMOVABLE    0x2
75 #define VDISK_READONLY     0x4
76
77 #endif /* __XEN_PUBLIC_IO_BLKIF_H__ */
78
79 /*
80  * Local variables:
81  * mode: C
82  * c-set-style: "BSD"
83  * c-basic-offset: 4
84  * tab-width: 4
85  * indent-tabs-mode: nil
86  * End:
87  */