win-pvdrivers

view xenvbd_storport/xenvbd.h @ 1044:9f476ac2fbe1

Add proper support for vbd resize using unit attention.
author James Harper <james.harper@bendigoit.com.au>
date Mon Mar 04 14:26:41 2013 +1100 (2013-03-04)
parents 306c10cdcba1
children 0243e3b47f36
line source
1 /*
2 PV Drivers for Windows Xen HVM Domains
3 Copyright (C) 2007 James Harper
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
20 #if !defined(_XENVBD_H_)
21 #define _XENVBD_H_
23 #include <ntddk.h>
24 #include <wdm.h>
25 #include <initguid.h>
26 #define NTSTRSAFE_LIB
27 #include <ntstrsafe.h>
28 #include <storport.h>
29 #include <ntddscsi.h>
30 #include <ntdddisk.h>
31 #include <stdlib.h>
33 #define __DRIVER_NAME "XenVbd"
35 #include <xen_windows.h>
36 #include <xen_public.h>
37 #include <io/protocols.h>
38 #include <memory.h>
39 #include <event_channel.h>
40 #include <hvm/params.h>
41 #include <hvm/hvm_op.h>
42 #include <io/ring.h>
43 #include <io/blkif.h>
44 #include <io/xenbus.h>
46 #include "../xenvbd_common/common.h"
48 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
49 #define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, PAGE_SIZE)
51 #define SCSIOP_UNMAP 0x42
53 #define VPD_BLOCK_LIMITS 0xB0
55 #define MAX_SHADOW_ENTRIES 64
56 #define SHADOW_ID_ID_MASK 0x03FF /* maximum of 1024 requests - currently use a maximum of 64 though */
57 #define SHADOW_ID_DUMP_FLAG 0x8000 /* indicates the request was generated by dump mode */
59 #define SHADOW_ENTRIES min(MAX_SHADOW_ENTRIES, BLK_RING_SIZE)
61 /* if this is ever increased to more than 1 then we need a way of tracking it properly */
62 #define DUMP_MODE_UNALIGNED_PAGES 1 /* only for unaligned buffer use */
64 struct {
65 ULONG device_state;
66 KEVENT device_state_event;
67 STOR_DPC dpc;
68 PIO_WORKITEM disconnect_workitem;
69 PIO_WORKITEM connect_workitem;
70 blkif_shadow_t shadows[MAX_SHADOW_ENTRIES];
71 USHORT shadow_free_list[MAX_SHADOW_ENTRIES];
72 USHORT shadow_free;
73 USHORT shadow_min_free;
74 ULONG grant_tag;
75 PDEVICE_OBJECT pdo;
76 PDEVICE_OBJECT fdo;
77 XN_HANDLE handle;
78 evtchn_port_t event_channel;
79 blkif_front_ring_t ring;
80 blkif_sring_t *sring;
81 grant_ref_t sring_gref;
82 KEVENT backend_event;
83 ULONG backend_state;
84 UCHAR last_sense_key;
85 UCHAR last_additional_sense_code;
86 UCHAR last_additional_sense_code_qualifier;
87 BOOLEAN cac;
88 blkif_response_t tmp_rep;
89 XENVBD_DEVICETYPE device_type;
90 XENVBD_DEVICEMODE device_mode;
91 ULONG bytes_per_sector; /* 512 for disk, 2048 for CDROM) */
92 ULONG hw_bytes_per_sector; /* underlying hardware format, eg 4K */
93 ULONGLONG total_sectors;
94 ULONGLONG new_total_sectors;
95 CHAR serial_number[64];
96 ULONG feature_flush_cache;
97 ULONG feature_discard;
98 ULONG feature_barrier;
99 LIST_ENTRY srb_list;
100 BOOLEAN aligned_buffer_in_use;
101 STOR_POWER_ACTION power_action;
102 STOR_DEVICE_POWER_STATE power_state;
103 ULONG aligned_buffer_size;
104 PVOID aligned_buffer;
105 /*
106 ULONGLONG interrupts;
107 ULONGLONG aligned_requests;
108 ULONGLONG aligned_bytes;
109 ULONGLONG unaligned_requests;
110 ULONGLONG unaligned_bytes;
111 */
112 /* this is the size of the buffer to allocate at the end of DeviceExtenstion. It includes an extra PAGE_SIZE-1 bytes to assure that we can always align to PAGE_SIZE */
113 #define UNALIGNED_BUFFER_DATA_SIZE ((BLKIF_MAX_SEGMENTS_PER_REQUEST + 1) * PAGE_SIZE - 1)
114 #define UNALIGNED_BUFFER_DATA_SIZE_DUMP_MODE ((DUMP_MODE_UNALIGNED_PAGES + 1) * PAGE_SIZE - 1)
115 /* this has to be right at the end of DeviceExtension */
116 /* can't allocate too much data in dump mode so size DeviceExtensionSize accordingly */
117 UCHAR aligned_buffer_data[1];
118 } typedef XENVBD_DEVICE_DATA, *PXENVBD_DEVICE_DATA;
120 #endif