aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/xen-blkback/common.h
diff options
context:
space:
mode:
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2011-10-12 12:12:36 -0400
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2011-11-18 13:27:59 -0500
commit97e36834f5a106459ab1b290e663a4eb6264639e (patch)
tree39e4843998cb7f75b94d80f27e4b11ffb3662f28 /drivers/block/xen-blkback/common.h
parentcfcfc9eca2bcbd26a8e206baeb005b055dbf8e37 (diff)
xen/blk[front|back]: Squash blkif_request_rw and blkif_request_discard together
In a union type structure to deal with the overlapping attributes in a easier manner. Suggested-by: Ian Campbell <Ian.Campbell@citrix.com> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'drivers/block/xen-blkback/common.h')
-rw-r--r--drivers/block/xen-blkback/common.h64
1 files changed, 36 insertions, 28 deletions
diff --git a/drivers/block/xen-blkback/common.h b/drivers/block/xen-blkback/common.h
index dfb1b3a43a5d..dbfe7b3b0737 100644
--- a/drivers/block/xen-blkback/common.h
+++ b/drivers/block/xen-blkback/common.h
@@ -60,58 +60,66 @@ struct blkif_common_response {
60 char dummy; 60 char dummy;
61}; 61};
62 62
63/* i386 protocol version */
64#pragma pack(push, 4)
65
66struct blkif_x86_32_request_rw { 63struct blkif_x86_32_request_rw {
64 uint8_t nr_segments; /* number of segments */
65 blkif_vdev_t handle; /* only for read/write requests */
66 uint64_t id; /* private guest value, echoed in resp */
67 blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */ 67 blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */
68 struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST]; 68 struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
69}; 69} __attribute__((__packed__));
70 70
71struct blkif_x86_32_request_discard { 71struct blkif_x86_32_request_discard {
72 uint8_t nr_segments; /* number of segments */
73 blkif_vdev_t _pad1; /* was "handle" for read/write requests */
74 uint64_t id; /* private guest value, echoed in resp */
72 blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */ 75 blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */
73 uint64_t nr_sectors; 76 uint64_t nr_sectors;
74}; 77} __attribute__((__packed__));
75 78
76struct blkif_x86_32_request { 79struct blkif_x86_32_request {
77 uint8_t operation; /* BLKIF_OP_??? */ 80 uint8_t operation; /* BLKIF_OP_??? */
78 uint8_t nr_segments; /* number of segments */
79 blkif_vdev_t handle; /* only for read/write requests */
80 uint64_t id; /* private guest value, echoed in resp */
81 union { 81 union {
82 struct blkif_x86_32_request_rw rw; 82 struct blkif_x86_32_request_rw rw;
83 struct blkif_x86_32_request_discard discard; 83 struct blkif_x86_32_request_discard discard;
84 } u; 84 } u;
85}; 85} __attribute__((__packed__));
86
87/* i386 protocol version */
88#pragma pack(push, 4)
86struct blkif_x86_32_response { 89struct blkif_x86_32_response {
87 uint64_t id; /* copied from request */ 90 uint64_t id; /* copied from request */
88 uint8_t operation; /* copied from request */ 91 uint8_t operation; /* copied from request */
89 int16_t status; /* BLKIF_RSP_??? */ 92 int16_t status; /* BLKIF_RSP_??? */
90}; 93};
91#pragma pack(pop) 94#pragma pack(pop)
92
93/* x86_64 protocol version */ 95/* x86_64 protocol version */
94 96
95struct blkif_x86_64_request_rw { 97struct blkif_x86_64_request_rw {
98 uint8_t nr_segments; /* number of segments */
99 blkif_vdev_t handle; /* only for read/write requests */
100 uint32_t _pad1; /* offsetof(blkif_reqest..,u.rw.id)==8 */
101 uint64_t id;
96 blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */ 102 blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */
97 struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST]; 103 struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
98}; 104} __attribute__((__packed__));
99 105
100struct blkif_x86_64_request_discard { 106struct blkif_x86_64_request_discard {
107 uint8_t nr_segments; /* number of segments */
108 blkif_vdev_t _pad1; /* was "handle" for read/write requests */
109 uint32_t _pad2; /* offsetof(blkif_..,u.discard.id)==8 */
110 uint64_t id;
101 blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */ 111 blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */
102 uint64_t nr_sectors; 112 uint64_t nr_sectors;
103}; 113} __attribute__((__packed__));
104 114
105struct blkif_x86_64_request { 115struct blkif_x86_64_request {
106 uint8_t operation; /* BLKIF_OP_??? */ 116 uint8_t operation; /* BLKIF_OP_??? */
107 uint8_t nr_segments; /* number of segments */
108 blkif_vdev_t handle; /* only for read/write requests */
109 uint64_t __attribute__((__aligned__(8))) id;
110 union { 117 union {
111 struct blkif_x86_64_request_rw rw; 118 struct blkif_x86_64_request_rw rw;
112 struct blkif_x86_64_request_discard discard; 119 struct blkif_x86_64_request_discard discard;
113 } u; 120 } u;
114}; 121} __attribute__((__packed__));
122
115struct blkif_x86_64_response { 123struct blkif_x86_64_response {
116 uint64_t __attribute__((__aligned__(8))) id; 124 uint64_t __attribute__((__aligned__(8))) id;
117 uint8_t operation; /* copied from request */ 125 uint8_t operation; /* copied from request */
@@ -237,18 +245,18 @@ static inline void blkif_get_x86_32_req(struct blkif_request *dst,
237{ 245{
238 int i, n = BLKIF_MAX_SEGMENTS_PER_REQUEST; 246 int i, n = BLKIF_MAX_SEGMENTS_PER_REQUEST;
239 dst->operation = src->operation; 247 dst->operation = src->operation;
240 dst->nr_segments = src->nr_segments;
241 dst->handle = src->handle;
242 dst->id = src->id;
243 switch (src->operation) { 248 switch (src->operation) {
244 case BLKIF_OP_READ: 249 case BLKIF_OP_READ:
245 case BLKIF_OP_WRITE: 250 case BLKIF_OP_WRITE:
246 case BLKIF_OP_WRITE_BARRIER: 251 case BLKIF_OP_WRITE_BARRIER:
247 case BLKIF_OP_FLUSH_DISKCACHE: 252 case BLKIF_OP_FLUSH_DISKCACHE:
253 dst->u.rw.nr_segments = src->u.rw.nr_segments;
254 dst->u.rw.handle = src->u.rw.handle;
255 dst->u.rw.id = src->u.rw.id;
248 dst->u.rw.sector_number = src->u.rw.sector_number; 256 dst->u.rw.sector_number = src->u.rw.sector_number;
249 barrier(); 257 barrier();
250 if (n > dst->nr_segments) 258 if (n > dst->u.rw.nr_segments)
251 n = dst->nr_segments; 259 n = dst->u.rw.nr_segments;
252 for (i = 0; i < n; i++) 260 for (i = 0; i < n; i++)
253 dst->u.rw.seg[i] = src->u.rw.seg[i]; 261 dst->u.rw.seg[i] = src->u.rw.seg[i];
254 break; 262 break;
@@ -266,18 +274,18 @@ static inline void blkif_get_x86_64_req(struct blkif_request *dst,
266{ 274{
267 int i, n = BLKIF_MAX_SEGMENTS_PER_REQUEST; 275 int i, n = BLKIF_MAX_SEGMENTS_PER_REQUEST;
268 dst->operation = src->operation; 276 dst->operation = src->operation;
269 dst->nr_segments = src->nr_segments;
270 dst->handle = src->handle;
271 dst->id = src->id;
272 switch (src->operation) { 277 switch (src->operation) {
273 case BLKIF_OP_READ: 278 case BLKIF_OP_READ:
274 case BLKIF_OP_WRITE: 279 case BLKIF_OP_WRITE:
275 case BLKIF_OP_WRITE_BARRIER: 280 case BLKIF_OP_WRITE_BARRIER:
276 case BLKIF_OP_FLUSH_DISKCACHE: 281 case BLKIF_OP_FLUSH_DISKCACHE:
282 dst->u.rw.nr_segments = src->u.rw.nr_segments;
283 dst->u.rw.handle = src->u.rw.handle;
284 dst->u.rw.id = src->u.rw.id;
277 dst->u.rw.sector_number = src->u.rw.sector_number; 285 dst->u.rw.sector_number = src->u.rw.sector_number;
278 barrier(); 286 barrier();
279 if (n > dst->nr_segments) 287 if (n > dst->u.rw.nr_segments)
280 n = dst->nr_segments; 288 n = dst->u.rw.nr_segments;
281 for (i = 0; i < n; i++) 289 for (i = 0; i < n; i++)
282 dst->u.rw.seg[i] = src->u.rw.seg[i]; 290 dst->u.rw.seg[i] = src->u.rw.seg[i];
283 break; 291 break;