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