direct-io.hg

view xen/include/public/io/blkif.h @ 5649:fc4e10d0455a

Avoid repeated #define's in public headers.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Sat Jul 02 22:37:55 2005 +0000 (2005-07-02)
parents 2b6c1a809807
children ae51fa1d32b2 0db6a59abb95 1efe6f4163ee
line source
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 */
9 #ifndef __XEN_PUBLIC_IO_BLKIF_H__
10 #define __XEN_PUBLIC_IO_BLKIF_H__
12 #include "ring.h"
14 #ifndef blkif_vdev_t
15 #define blkif_vdev_t u16
16 #endif
17 #define blkif_sector_t u64
19 #define BLKIF_OP_READ 0
20 #define BLKIF_OP_WRITE 1
21 #define BLKIF_OP_PROBE 2
23 /* NB. Ring size must be small enough for sizeof(blkif_ring_t) <= PAGE_SIZE. */
24 #define BLKIF_RING_SIZE 64
26 /*
27 * Maximum scatter/gather segments per request.
28 * This is carefully chosen so that sizeof(blkif_ring_t) <= PAGE_SIZE.
29 * NB. This could be 12 if the ring indexes weren't stored in the same page.
30 */
31 #define BLKIF_MAX_SEGMENTS_PER_REQUEST 11
33 typedef struct blkif_request {
34 u8 operation; /* BLKIF_OP_??? */
35 u8 nr_segments; /* number of segments */
36 blkif_vdev_t device; /* only for read/write requests */
37 unsigned long id; /* private guest value, echoed in resp */
38 blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */
39 /* @f_a_s[2:0]=last_sect ; @f_a_s[5:3]=first_sect */
40 #ifdef CONFIG_XEN_BLKDEV_GRANT
41 /* @f_a_s[:16]= grant reference (16 bits) */
42 #else
43 /* @f_a_s[:12]=@frame: machine page frame number. */
44 #endif
45 /* @first_sect: first sector in frame to transfer (inclusive). */
46 /* @last_sect: last sector in frame to transfer (inclusive). */
47 unsigned long frame_and_sects[BLKIF_MAX_SEGMENTS_PER_REQUEST];
48 } blkif_request_t;
50 #define blkif_first_sect(_fas) (((_fas)>>3)&7)
51 #define blkif_last_sect(_fas) ((_fas)&7)
53 #ifdef CONFIG_XEN_BLKDEV_GRANT
54 #define blkif_gref_from_fas(_fas) ((_fas)>>16)
55 #endif
57 typedef struct blkif_response {
58 unsigned long id; /* copied from request */
59 u8 operation; /* copied from request */
60 s16 status; /* BLKIF_RSP_??? */
61 } blkif_response_t;
63 #define BLKIF_RSP_ERROR -1 /* non-specific 'error' */
64 #define BLKIF_RSP_OKAY 0 /* non-specific 'okay' */
66 /*
67 * Generate blkif ring structures and types.
68 */
70 DEFINE_RING_TYPES(blkif, blkif_request_t, blkif_response_t);
72 /*
73 * BLKIF_OP_PROBE:
74 * The request format for a probe request is constrained as follows:
75 * @operation == BLKIF_OP_PROBE
76 * @nr_segments == size of probe buffer in pages
77 * @device == unused (zero)
78 * @id == any value (echoed in response message)
79 * @sector_num == unused (zero)
80 * @frame_and_sects == list of page-sized buffers.
81 * (i.e., @first_sect == 0, @last_sect == 7).
82 *
83 * The response is a list of vdisk_t elements copied into the out-of-band
84 * probe buffer. On success the response status field contains the number
85 * of vdisk_t elements.
86 */
88 #define VDISK_CDROM 0x1
89 #define VDISK_REMOVABLE 0x2
90 #define VDISK_READONLY 0x4
92 typedef struct vdisk {
93 blkif_sector_t capacity; /* Size in terms of 512-byte sectors. */
94 blkif_vdev_t device; /* Device number (opaque 16 bit value). */
95 u16 info; /* Device type and flags (VDISK_*). */
96 u16 sector_size; /* Minimum alignment for requests. */
97 } vdisk_t; /* 16 bytes */
99 #endif /* __XEN_PUBLIC_IO_BLKIF_H__ */