blkif.h revision 287802
1/******************************************************************************
2 * blkif.h
3 *
4 * Unified block-device I/O interface for Xen guest OSes.
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) 2003-2004, Keir Fraser
25 * Copyright (c) 2012, Spectra Logic Corporation
26 */
27
28#ifndef __XEN_PUBLIC_IO_BLKIF_H__
29#define __XEN_PUBLIC_IO_BLKIF_H__
30
31#include "ring.h"
32#include "../grant_table.h"
33
34/*
35 * Front->back notifications: When enqueuing a new request, sending a
36 * notification can be made conditional on req_event (i.e., the generic
37 * hold-off mechanism provided by the ring macros). Backends must set
38 * req_event appropriately (e.g., using RING_FINAL_CHECK_FOR_REQUESTS()).
39 *
40 * Back->front notifications: When enqueuing a new response, sending a
41 * notification can be made conditional on rsp_event (i.e., the generic
42 * hold-off mechanism provided by the ring macros). Frontends must set
43 * rsp_event appropriately (e.g., using RING_FINAL_CHECK_FOR_RESPONSES()).
44 */
45
46#ifndef blkif_vdev_t
47#define blkif_vdev_t   uint16_t
48#endif
49#define blkif_sector_t uint64_t
50
51/*
52 * Feature and Parameter Negotiation
53 * =================================
54 * The two halves of a Xen block driver utilize nodes within the XenStore to
55 * communicate capabilities and to negotiate operating parameters.  This
56 * section enumerates these nodes which reside in the respective front and
57 * backend portions of the XenStore, following the XenBus convention.
58 *
59 * All data in the XenStore is stored as strings.  Nodes specifying numeric
60 * values are encoded in decimal.  Integer value ranges listed below are
61 * expressed as fixed sized integer types capable of storing the conversion
62 * of a properly formatted node string, without loss of information.
63 *
64 * Any specified default value is in effect if the corresponding XenBus node
65 * is not present in the XenStore.
66 *
67 * XenStore nodes in sections marked "PRIVATE" are solely for use by the
68 * driver side whose XenBus tree contains them.
69 *
70 * XenStore nodes marked "DEPRECATED" in their notes section should only be
71 * used to provide interoperability with legacy implementations.
72 *
73 * See the XenBus state transition diagram below for details on when XenBus
74 * nodes must be published and when they can be queried.
75 *
76 *****************************************************************************
77 *                            Backend XenBus Nodes
78 *****************************************************************************
79 *
80 *------------------ Backend Device Identification (PRIVATE) ------------------
81 *
82 * mode
83 *      Values:         "r" (read only), "w" (writable)
84 *
85 *      The read or write access permissions to the backing store to be
86 *      granted to the frontend.
87 *
88 * params
89 *      Values:         string
90 *
91 *      Data used by the backend driver to locate and configure the backing
92 *      device.  The format and semantics of this data vary according to the
93 *      backing device in use and are outside the scope of this specification.
94 *
95 * type
96 *      Values:         "file", "phy", "tap"
97 *
98 *      The type of the backing device/object.
99 *
100 *
101 * direct-io-safe
102 *      Values:         0/1 (boolean)
103 *      Default Value:  0
104 *
105 *      The underlying storage is not affected by the direct IO memory
106 *      lifetime bug.  See:
107 *        http://lists.xen.org/archives/html/xen-devel/2012-12/msg01154.html
108 *
109 *      Therefore this option gives the backend permission to use
110 *      O_DIRECT, notwithstanding that bug.
111 *
112 *      That is, if this option is enabled, use of O_DIRECT is safe,
113 *      in circumstances where we would normally have avoided it as a
114 *      workaround for that bug.  This option is not relevant for all
115 *      backends, and even not necessarily supported for those for
116 *      which it is relevant.  A backend which knows that it is not
117 *      affected by the bug can ignore this option.
118 *
119 *      This option doesn't require a backend to use O_DIRECT, so it
120 *      should not be used to try to control the caching behaviour.
121 *
122 *--------------------------------- Features ---------------------------------
123 *
124 * feature-barrier
125 *      Values:         0/1 (boolean)
126 *      Default Value:  0
127 *
128 *      A value of "1" indicates that the backend can process requests
129 *      containing the BLKIF_OP_WRITE_BARRIER request opcode.  Requests
130 *      of this type may still be returned at any time with the
131 *      BLKIF_RSP_EOPNOTSUPP result code.
132 *
133 * feature-flush-cache
134 *      Values:         0/1 (boolean)
135 *      Default Value:  0
136 *
137 *      A value of "1" indicates that the backend can process requests
138 *      containing the BLKIF_OP_FLUSH_DISKCACHE request opcode.  Requests
139 *      of this type may still be returned at any time with the
140 *      BLKIF_RSP_EOPNOTSUPP result code.
141 *
142 * feature-discard
143 *      Values:         0/1 (boolean)
144 *      Default Value:  0
145 *
146 *      A value of "1" indicates that the backend can process requests
147 *      containing the BLKIF_OP_DISCARD request opcode.  Requests
148 *      of this type may still be returned at any time with the
149 *      BLKIF_RSP_EOPNOTSUPP result code.
150 *
151 * feature-persistent
152 *      Values:         0/1 (boolean)
153 *      Default Value:  0
154 *      Notes: 7
155 *
156 *      A value of "1" indicates that the backend can keep the grants used
157 *      by the frontend driver mapped, so the same set of grants should be
158 *      used in all transactions. The maximum number of grants the backend
159 *      can map persistently depends on the implementation, but ideally it
160 *      should be RING_SIZE * BLKIF_MAX_SEGMENTS_PER_REQUEST. Using this
161 *      feature the backend doesn't need to unmap each grant, preventing
162 *      costly TLB flushes. The backend driver should only map grants
163 *      persistently if the frontend supports it. If a backend driver chooses
164 *      to use the persistent protocol when the frontend doesn't support it,
165 *      it will probably hit the maximum number of persistently mapped grants
166 *      (due to the fact that the frontend won't be reusing the same grants),
167 *      and fall back to non-persistent mode. Backend implementations may
168 *      shrink or expand the number of persistently mapped grants without
169 *      notifying the frontend depending on memory constraints (this might
170 *      cause a performance degradation).
171 *
172 *      If a backend driver wants to limit the maximum number of persistently
173 *      mapped grants to a value less than RING_SIZE *
174 *      BLKIF_MAX_SEGMENTS_PER_REQUEST a LRU strategy should be used to
175 *      discard the grants that are less commonly used. Using a LRU in the
176 *      backend driver paired with a LIFO queue in the frontend will
177 *      allow us to have better performance in this scenario.
178 *
179 *----------------------- Request Transport Parameters ------------------------
180 *
181 * max-ring-page-order
182 *      Values:         <uint32_t>
183 *      Default Value:  0
184 *      Notes:          1, 3
185 *
186 *      The maximum supported size of the request ring buffer in units of
187 *      lb(machine pages). (e.g. 0 == 1 page,  1 = 2 pages, 2 == 4 pages,
188 *      etc.).
189 *
190 * max-ring-pages
191 *      Values:         <uint32_t>
192 *      Default Value:  1
193 *      Notes:          DEPRECATED, 2, 3
194 *
195 *      The maximum supported size of the request ring buffer in units of
196 *      machine pages.  The value must be a power of 2.
197 *
198 *------------------------- Backend Device Properties -------------------------
199 *
200 * discard-enable
201 *      Values:         0/1 (boolean)
202 *      Default Value:  1
203 *
204 *      This optional property, set by the toolstack, instructs the backend
205 *      to offer discard to the frontend. If the property is missing the
206 *      backend should offer discard if the backing storage actually supports
207 *      it. This optional property, set by the toolstack, requests that the
208 *      backend offer, or not offer, discard to the frontend.
209 *
210 * discard-alignment
211 *      Values:         <uint32_t>
212 *      Default Value:  0
213 *      Notes:          4, 5
214 *
215 *      The offset, in bytes from the beginning of the virtual block device,
216 *      to the first, addressable, discard extent on the underlying device.
217 *
218 * discard-granularity
219 *      Values:         <uint32_t>
220 *      Default Value:  <"sector-size">
221 *      Notes:          4
222 *
223 *      The size, in bytes, of the individually addressable discard extents
224 *      of the underlying device.
225 *
226 * discard-secure
227 *      Values:         0/1 (boolean)
228 *      Default Value:  0
229 *      Notes:          10
230 *
231 *      A value of "1" indicates that the backend can process BLKIF_OP_DISCARD
232 *      requests with the BLKIF_DISCARD_SECURE flag set.
233 *
234 * info
235 *      Values:         <uint32_t> (bitmap)
236 *
237 *      A collection of bit flags describing attributes of the backing
238 *      device.  The VDISK_* macros define the meaning of each bit
239 *      location.
240 *
241 * sector-size
242 *      Values:         <uint32_t>
243 *
244 *      The logical sector size, in bytes, of the backend device.
245 *
246 * physical-sector-size
247 *      Values:         <uint32_t>
248 *
249 *      The physical sector size, in bytes, of the backend device.
250 *
251 * sectors
252 *      Values:         <uint64_t>
253 *
254 *      The size of the backend device, expressed in units of its logical
255 *      sector size ("sector-size").
256 *
257 *****************************************************************************
258 *                            Frontend XenBus Nodes
259 *****************************************************************************
260 *
261 *----------------------- Request Transport Parameters -----------------------
262 *
263 * event-channel
264 *      Values:         <uint32_t>
265 *
266 *      The identifier of the Xen event channel used to signal activity
267 *      in the ring buffer.
268 *
269 * ring-ref
270 *      Values:         <uint32_t>
271 *      Notes:          6
272 *
273 *      The Xen grant reference granting permission for the backend to map
274 *      the sole page in a single page sized ring buffer.
275 *
276 * ring-ref%u
277 *      Values:         <uint32_t>
278 *      Notes:          6
279 *
280 *      For a frontend providing a multi-page ring, a "number of ring pages"
281 *      sized list of nodes, each containing a Xen grant reference granting
282 *      permission for the backend to map the page of the ring located
283 *      at page index "%u".  Page indexes are zero based.
284 *
285 * protocol
286 *      Values:         string (XEN_IO_PROTO_ABI_*)
287 *      Default Value:  XEN_IO_PROTO_ABI_NATIVE
288 *
289 *      The machine ABI rules governing the format of all ring request and
290 *      response structures.
291 *
292 * ring-page-order
293 *      Values:         <uint32_t>
294 *      Default Value:  0
295 *      Maximum Value:  MAX(ffs(max-ring-pages) - 1, max-ring-page-order)
296 *      Notes:          1, 3
297 *
298 *      The size of the frontend allocated request ring buffer in units
299 *      of lb(machine pages). (e.g. 0 == 1 page, 1 = 2 pages, 2 == 4 pages,
300 *      etc.).
301 *
302 * num-ring-pages
303 *      Values:         <uint32_t>
304 *      Default Value:  1
305 *      Maximum Value:  MAX(max-ring-pages,(0x1 << max-ring-page-order))
306 *      Notes:          DEPRECATED, 2, 3
307 *
308 *      The size of the frontend allocated request ring buffer in units of
309 *      machine pages.  The value must be a power of 2.
310 *
311 * feature-persistent
312 *      Values:         0/1 (boolean)
313 *      Default Value:  0
314 *      Notes: 7, 8, 9
315 *
316 *      A value of "1" indicates that the frontend will reuse the same grants
317 *      for all transactions, allowing the backend to map them with write
318 *      access (even when it should be read-only). If the frontend hits the
319 *      maximum number of allowed persistently mapped grants, it can fallback
320 *      to non persistent mode. This will cause a performance degradation,
321 *      since the the backend driver will still try to map those grants
322 *      persistently. Since the persistent grants protocol is compatible with
323 *      the previous protocol, a frontend driver can choose to work in
324 *      persistent mode even when the backend doesn't support it.
325 *
326 *      It is recommended that the frontend driver stores the persistently
327 *      mapped grants in a LIFO queue, so a subset of all persistently mapped
328 *      grants gets used commonly. This is done in case the backend driver
329 *      decides to limit the maximum number of persistently mapped grants
330 *      to a value less than RING_SIZE * BLKIF_MAX_SEGMENTS_PER_REQUEST.
331 *
332 *------------------------- Virtual Device Properties -------------------------
333 *
334 * device-type
335 *      Values:         "disk", "cdrom", "floppy", etc.
336 *
337 * virtual-device
338 *      Values:         <uint32_t>
339 *
340 *      A value indicating the physical device to virtualize within the
341 *      frontend's domain.  (e.g. "The first ATA disk", "The third SCSI
342 *      disk", etc.)
343 *
344 *      See docs/misc/vbd-interface.txt for details on the format of this
345 *      value.
346 *
347 * Notes
348 * -----
349 * (1) Multi-page ring buffer scheme first developed in the Citrix XenServer
350 *     PV drivers.
351 * (2) Multi-page ring buffer scheme first used in some RedHat distributions
352 *     including a distribution deployed on certain nodes of the Amazon
353 *     EC2 cluster.
354 * (3) Support for multi-page ring buffers was implemented independently,
355 *     in slightly different forms, by both Citrix and RedHat/Amazon.
356 *     For full interoperability, block front and backends should publish
357 *     identical ring parameters, adjusted for unit differences, to the
358 *     XenStore nodes used in both schemes.
359 * (4) Devices that support discard functionality may internally allocate space
360 *     (discardable extents) in units that are larger than the exported logical
361 *     block size. If the backing device has such discardable extents the
362 *     backend should provide both discard-granularity and discard-alignment.
363 *     Providing just one of the two may be considered an error by the frontend.
364 *     Backends supporting discard should include discard-granularity and
365 *     discard-alignment even if it supports discarding individual sectors.
366 *     Frontends should assume discard-alignment == 0 and discard-granularity
367 *     == sector size if these keys are missing.
368 * (5) The discard-alignment parameter allows a physical device to be
369 *     partitioned into virtual devices that do not necessarily begin or
370 *     end on a discardable extent boundary.
371 * (6) When there is only a single page allocated to the request ring,
372 *     'ring-ref' is used to communicate the grant reference for this
373 *     page to the backend.  When using a multi-page ring, the 'ring-ref'
374 *     node is not created.  Instead 'ring-ref0' - 'ring-refN' are used.
375 * (7) When using persistent grants data has to be copied from/to the page
376 *     where the grant is currently mapped. The overhead of doing this copy
377 *     however doesn't suppress the speed improvement of not having to unmap
378 *     the grants.
379 * (8) The frontend driver has to allow the backend driver to map all grants
380 *     with write access, even when they should be mapped read-only, since
381 *     further requests may reuse these grants and require write permissions.
382 * (9) Linux implementation doesn't have a limit on the maximum number of
383 *     grants that can be persistently mapped in the frontend driver, but
384 *     due to the frontent driver implementation it should never be bigger
385 *     than RING_SIZE * BLKIF_MAX_SEGMENTS_PER_REQUEST.
386 *(10) The discard-secure property may be present and will be set to 1 if the
387 *     backing device supports secure discard.
388 */
389
390/*
391 * STATE DIAGRAMS
392 *
393 *****************************************************************************
394 *                                   Startup                                 *
395 *****************************************************************************
396 *
397 * Tool stack creates front and back nodes with state XenbusStateInitialising.
398 *
399 * Front                                Back
400 * =================================    =====================================
401 * XenbusStateInitialising              XenbusStateInitialising
402 *  o Query virtual device               o Query backend device identification
403 *    properties.                          data.
404 *  o Setup OS device instance.          o Open and validate backend device.
405 *                                       o Publish backend features and
406 *                                         transport parameters.
407 *                                                      |
408 *                                                      |
409 *                                                      V
410 *                                      XenbusStateInitWait
411 *
412 * o Query backend features and
413 *   transport parameters.
414 * o Allocate and initialize the
415 *   request ring.
416 * o Publish transport parameters
417 *   that will be in effect during
418 *   this connection.
419 *              |
420 *              |
421 *              V
422 * XenbusStateInitialised
423 *
424 *                                       o Query frontend transport parameters.
425 *                                       o Connect to the request ring and
426 *                                         event channel.
427 *                                       o Publish backend device properties.
428 *                                                      |
429 *                                                      |
430 *                                                      V
431 *                                      XenbusStateConnected
432 *
433 *  o Query backend device properties.
434 *  o Finalize OS virtual device
435 *    instance.
436 *              |
437 *              |
438 *              V
439 * XenbusStateConnected
440 *
441 * Note: Drivers that do not support any optional features, or the negotiation
442 *       of transport parameters, can skip certain states in the state machine:
443 *
444 *       o A frontend may transition to XenbusStateInitialised without
445 *         waiting for the backend to enter XenbusStateInitWait.  In this
446 *         case, default transport parameters are in effect and any
447 *         transport parameters published by the frontend must contain
448 *         their default values.
449 *
450 *       o A backend may transition to XenbusStateInitialised, bypassing
451 *         XenbusStateInitWait, without waiting for the frontend to first
452 *         enter the XenbusStateInitialised state.  In this case, default
453 *         transport parameters are in effect and any transport parameters
454 *         published by the backend must contain their default values.
455 *
456 *       Drivers that support optional features and/or transport parameter
457 *       negotiation must tolerate these additional state transition paths.
458 *       In general this means performing the work of any skipped state
459 *       transition, if it has not already been performed, in addition to the
460 *       work associated with entry into the current state.
461 */
462
463/*
464 * REQUEST CODES.
465 */
466#define BLKIF_OP_READ              0
467#define BLKIF_OP_WRITE             1
468/*
469 * All writes issued prior to a request with the BLKIF_OP_WRITE_BARRIER
470 * operation code ("barrier request") must be completed prior to the
471 * execution of the barrier request.  All writes issued after the barrier
472 * request must not execute until after the completion of the barrier request.
473 *
474 * Optional.  See "feature-barrier" XenBus node documentation above.
475 */
476#define BLKIF_OP_WRITE_BARRIER     2
477/*
478 * Commit any uncommitted contents of the backing device's volatile cache
479 * to stable storage.
480 *
481 * Optional.  See "feature-flush-cache" XenBus node documentation above.
482 */
483#define BLKIF_OP_FLUSH_DISKCACHE   3
484/*
485 * Used in SLES sources for device specific command packet
486 * contained within the request. Reserved for that purpose.
487 */
488#define BLKIF_OP_RESERVED_1        4
489/*
490 * Indicate to the backend device that a region of storage is no longer in
491 * use, and may be discarded at any time without impact to the client.  If
492 * the BLKIF_DISCARD_SECURE flag is set on the request, all copies of the
493 * discarded region on the device must be rendered unrecoverable before the
494 * command returns.
495 *
496 * This operation is analogous to performing a trim (ATA) or unmap (SCSI),
497 * command on a native device.
498 *
499 * More information about trim/unmap operations can be found at:
500 * http://t13.org/Documents/UploadedDocuments/docs2008/
501 *     e07154r6-Data_Set_Management_Proposal_for_ATA-ACS2.doc
502 * http://www.seagate.com/staticfiles/support/disc/manuals/
503 *     Interface%20manuals/100293068c.pdf
504 *
505 * Optional.  See "feature-discard", "discard-alignment",
506 * "discard-granularity", and "discard-secure" in the XenBus node
507 * documentation above.
508 */
509#define BLKIF_OP_DISCARD           5
510
511/*
512 * Recognized if "feature-max-indirect-segments" in present in the backend
513 * xenbus info. The "feature-max-indirect-segments" node contains the maximum
514 * number of segments allowed by the backend per request. If the node is
515 * present, the frontend might use blkif_request_indirect structs in order to
516 * issue requests with more than BLKIF_MAX_SEGMENTS_PER_REQUEST (11). The
517 * maximum number of indirect segments is fixed by the backend, but the
518 * frontend can issue requests with any number of indirect segments as long as
519 * it's less than the number provided by the backend. The indirect_grefs field
520 * in blkif_request_indirect should be filled by the frontend with the
521 * grant references of the pages that are holding the indirect segments.
522 * These pages are filled with an array of blkif_request_segment that hold the
523 * information about the segments. The number of indirect pages to use is
524 * determined by the number of segments an indirect request contains. Every
525 * indirect page can contain a maximum of
526 * (PAGE_SIZE / sizeof(struct blkif_request_segment)) segments, so to
527 * calculate the number of indirect pages to use we have to do
528 * ceil(indirect_segments / (PAGE_SIZE / sizeof(struct blkif_request_segment))).
529 *
530 * If a backend does not recognize BLKIF_OP_INDIRECT, it should *not*
531 * create the "feature-max-indirect-segments" node!
532 */
533#define BLKIF_OP_INDIRECT          6
534
535/*
536 * Maximum scatter/gather segments per request.
537 * This is carefully chosen so that sizeof(blkif_ring_t) <= PAGE_SIZE.
538 * NB. This could be 12 if the ring indexes weren't stored in the same page.
539 */
540#define BLKIF_MAX_SEGMENTS_PER_REQUEST 11
541
542/*
543 * Maximum number of indirect pages to use per request.
544 */
545#define BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST 8
546
547/*
548 * NB. first_sect and last_sect in blkif_request_segment, as well as
549 * sector_number in blkif_request, are always expressed in 512-byte units.
550 * However they must be properly aligned to the real sector size of the
551 * physical disk, which is reported in the "physical-sector-size" node in
552 * the backend xenbus info. Also the xenbus "sectors" node is expressed in
553 * 512-byte units.
554 */
555struct blkif_request_segment {
556    grant_ref_t gref;        /* reference to I/O buffer frame        */
557    /* @first_sect: first sector in frame to transfer (inclusive).   */
558    /* @last_sect: last sector in frame to transfer (inclusive).     */
559    uint8_t     first_sect, last_sect;
560};
561typedef struct blkif_request_segment blkif_request_segment_t;
562
563/*
564 * Starting ring element for any I/O request.
565 */
566struct blkif_request {
567    uint8_t        operation;    /* BLKIF_OP_???                         */
568    uint8_t        nr_segments;  /* number of segments                   */
569    blkif_vdev_t   handle;       /* only for read/write requests         */
570    uint64_t       id;           /* private guest value, echoed in resp  */
571    blkif_sector_t sector_number;/* start sector idx on disk (r/w only)  */
572    blkif_request_segment_t seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
573};
574typedef struct blkif_request blkif_request_t;
575
576/*
577 * Cast to this structure when blkif_request.operation == BLKIF_OP_DISCARD
578 * sizeof(struct blkif_request_discard) <= sizeof(struct blkif_request)
579 */
580struct blkif_request_discard {
581    uint8_t        operation;    /* BLKIF_OP_DISCARD                     */
582    uint8_t        flag;         /* BLKIF_DISCARD_SECURE or zero         */
583#define BLKIF_DISCARD_SECURE (1<<0)  /* ignored if discard-secure=0      */
584    blkif_vdev_t   handle;       /* same as for read/write requests      */
585    uint64_t       id;           /* private guest value, echoed in resp  */
586    blkif_sector_t sector_number;/* start sector idx on disk             */
587    uint64_t       nr_sectors;   /* number of contiguous sectors to discard*/
588};
589typedef struct blkif_request_discard blkif_request_discard_t;
590
591struct blkif_request_indirect {
592    uint8_t        operation;    /* BLKIF_OP_INDIRECT                    */
593    uint8_t        indirect_op;  /* BLKIF_OP_{READ/WRITE}                */
594    uint16_t       nr_segments;  /* number of segments                   */
595    uint64_t       id;           /* private guest value, echoed in resp  */
596    blkif_sector_t sector_number;/* start sector idx on disk (r/w only)  */
597    blkif_vdev_t   handle;       /* same as for read/write requests      */
598    grant_ref_t    indirect_grefs[BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST];
599#ifdef __i386__
600    uint64_t       pad;          /* Make it 64 byte aligned on i386      */
601#endif
602};
603typedef struct blkif_request_indirect blkif_request_indirect_t;
604
605struct blkif_response {
606    uint64_t        id;              /* copied from request */
607    uint8_t         operation;       /* copied from request */
608    int16_t         status;          /* BLKIF_RSP_???       */
609};
610typedef struct blkif_response blkif_response_t;
611
612/*
613 * STATUS RETURN CODES.
614 */
615 /* Operation not supported (only happens on barrier writes). */
616#define BLKIF_RSP_EOPNOTSUPP  -2
617 /* Operation failed for some unspecified reason (-EIO). */
618#define BLKIF_RSP_ERROR       -1
619 /* Operation completed successfully. */
620#define BLKIF_RSP_OKAY         0
621
622/*
623 * Generate blkif ring structures and types.
624 */
625DEFINE_RING_TYPES(blkif, struct blkif_request, struct blkif_response);
626
627#define VDISK_CDROM        0x1
628#define VDISK_REMOVABLE    0x2
629#define VDISK_READONLY     0x4
630
631#endif /* __XEN_PUBLIC_IO_BLKIF_H__ */
632
633/*
634 * Local variables:
635 * mode: C
636 * c-file-style: "BSD"
637 * c-basic-offset: 4
638 * tab-width: 4
639 * indent-tabs-mode: nil
640 * End:
641 */
642