diff options
-rw-r--r-- | drivers/staging/hv/BlkVsc.c | 106 |
1 files changed, 51 insertions, 55 deletions
diff --git a/drivers/staging/hv/BlkVsc.c b/drivers/staging/hv/BlkVsc.c index d433d8c444f..2f54a93f90b 100644 --- a/drivers/staging/hv/BlkVsc.c +++ b/drivers/staging/hv/BlkVsc.c | |||
@@ -19,95 +19,91 @@ | |||
19 | * Hank Janssen <hjanssen@microsoft.com> | 19 | * Hank Janssen <hjanssen@microsoft.com> |
20 | * | 20 | * |
21 | */ | 21 | */ |
22 | |||
23 | #include <linux/kernel.h> | 22 | #include <linux/kernel.h> |
24 | #include <linux/mm.h> | 23 | #include <linux/mm.h> |
25 | #include "osd.h" | 24 | #include "osd.h" |
26 | #include "StorVsc.c" | 25 | #include "StorVsc.c" |
27 | 26 | ||
28 | static const char* gBlkDriverName="blkvsc"; | 27 | static const char *gBlkDriverName = "blkvsc"; |
29 | 28 | ||
30 | /* {32412632-86cb-44a2-9b5c-50d1417354f5} */ | 29 | /* {32412632-86cb-44a2-9b5c-50d1417354f5} */ |
31 | static const struct hv_guid gBlkVscDeviceType={ | 30 | static const struct hv_guid gBlkVscDeviceType = { |
32 | .data = { | 31 | .data = { |
33 | 0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44, | 32 | 0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44, |
34 | 0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5 | 33 | 0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5 |
35 | } | 34 | } |
36 | }; | 35 | }; |
37 | 36 | ||
38 | /* Static routines */ | 37 | static int BlkVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo) |
39 | static int | ||
40 | BlkVscOnDeviceAdd( | ||
41 | struct hv_device *Device, | ||
42 | void *AdditionalInfo | ||
43 | ); | ||
44 | |||
45 | |||
46 | int | ||
47 | BlkVscInitialize( | ||
48 | struct hv_driver *Driver | ||
49 | ) | ||
50 | { | 38 | { |
51 | struct storvsc_driver_object *storDriver = (struct storvsc_driver_object *)Driver; | 39 | struct storvsc_device_info *deviceInfo; |
52 | int ret=0; | 40 | int ret = 0; |
53 | 41 | ||
54 | DPRINT_ENTER(BLKVSC); | 42 | DPRINT_ENTER(BLKVSC); |
55 | 43 | ||
56 | /* Make sure we are at least 2 pages since 1 page is used for control */ | 44 | deviceInfo = (struct storvsc_device_info *)AdditionalInfo; |
57 | ASSERT(storDriver->RingBufferSize >= (PAGE_SIZE << 1)); | ||
58 | |||
59 | Driver->name = gBlkDriverName; | ||
60 | memcpy(&Driver->deviceType, &gBlkVscDeviceType, sizeof(struct hv_guid)); | ||
61 | |||
62 | storDriver->RequestExtSize = sizeof(STORVSC_REQUEST_EXTENSION); | ||
63 | /* Divide the ring buffer data size (which is 1 page less than the ring buffer size since that page is reserved for the ring buffer indices) */ | ||
64 | /* by the max request size (which is VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER + struct vstor_packet + u64) */ | ||
65 | storDriver->MaxOutstandingRequestsPerChannel = | ||
66 | ((storDriver->RingBufferSize - PAGE_SIZE) / ALIGN_UP(MAX_MULTIPAGE_BUFFER_PACKET + sizeof(struct vstor_packet) + sizeof(u64),sizeof(u64))); | ||
67 | 45 | ||
68 | DPRINT_INFO(BLKVSC, "max io outstd %u", storDriver->MaxOutstandingRequestsPerChannel); | 46 | ret = StorVscOnDeviceAdd(Device, AdditionalInfo); |
47 | if (ret != 0) { | ||
48 | DPRINT_EXIT(BLKVSC); | ||
49 | return ret; | ||
50 | } | ||
69 | 51 | ||
70 | /* Setup the dispatch table */ | 52 | /* |
71 | storDriver->Base.OnDeviceAdd = BlkVscOnDeviceAdd; | 53 | * We need to use the device instance guid to set the path and target |
72 | storDriver->Base.OnDeviceRemove = StorVscOnDeviceRemove; | 54 | * id. For IDE devices, the device instance id is formatted as |
73 | storDriver->Base.OnCleanup = StorVscOnCleanup; | 55 | * <bus id> * - <device id> - 8899 - 000000000000. |
56 | */ | ||
57 | deviceInfo->PathId = Device->deviceInstance.data[3] << 24 | | ||
58 | Device->deviceInstance.data[2] << 16 | | ||
59 | Device->deviceInstance.data[1] << 8 | | ||
60 | Device->deviceInstance.data[0]; | ||
74 | 61 | ||
75 | storDriver->OnIORequest = StorVscOnIORequest; | 62 | deviceInfo->TargetId = Device->deviceInstance.data[5] << 8 | |
63 | Device->deviceInstance.data[4]; | ||
76 | 64 | ||
77 | DPRINT_EXIT(BLKVSC); | 65 | DPRINT_EXIT(BLKVSC); |
78 | 66 | ||
79 | return ret; | 67 | return ret; |
80 | } | 68 | } |
81 | 69 | ||
82 | static int | 70 | int BlkVscInitialize(struct hv_driver *Driver) |
83 | BlkVscOnDeviceAdd( | ||
84 | struct hv_device *Device, | ||
85 | void *AdditionalInfo | ||
86 | ) | ||
87 | { | 71 | { |
88 | int ret=0; | 72 | struct storvsc_driver_object *storDriver; |
89 | struct storvsc_device_info *deviceInfo = (struct storvsc_device_info *)AdditionalInfo; | 73 | int ret = 0; |
90 | 74 | ||
91 | DPRINT_ENTER(BLKVSC); | 75 | DPRINT_ENTER(BLKVSC); |
92 | 76 | ||
93 | ret = StorVscOnDeviceAdd(Device, AdditionalInfo); | 77 | storDriver = (struct storvsc_driver_object *)Driver; |
94 | 78 | ||
95 | if (ret != 0) | 79 | /* Make sure we are at least 2 pages since 1 page is used for control */ |
96 | { | 80 | ASSERT(storDriver->RingBufferSize >= (PAGE_SIZE << 1)); |
97 | DPRINT_EXIT(BLKVSC); | ||
98 | 81 | ||
99 | return ret; | 82 | Driver->name = gBlkDriverName; |
100 | } | 83 | memcpy(&Driver->deviceType, &gBlkVscDeviceType, sizeof(struct hv_guid)); |
101 | 84 | ||
102 | /* We need to use the device instance guid to set the path and target id. For IDE devices, the */ | 85 | storDriver->RequestExtSize = sizeof(STORVSC_REQUEST_EXTENSION); |
103 | /* device instance id is formatted as <bus id> - <device id> - 8899 - 000000000000. */ | ||
104 | deviceInfo->PathId = Device->deviceInstance.data[3] << 24 | | ||
105 | Device->deviceInstance.data[2] << 16 | | ||
106 | Device->deviceInstance.data[1] << 8 | | ||
107 | Device->deviceInstance.data[0]; | ||
108 | 86 | ||
109 | deviceInfo->TargetId = Device->deviceInstance.data[5] << 8 | | 87 | /* |
110 | Device->deviceInstance.data[4]; | 88 | * Divide the ring buffer data size (which is 1 page less than the ring |
89 | * buffer size since that page is reserved for the ring buffer indices) | ||
90 | * by the max request size (which is | ||
91 | * VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER + struct vstor_packet + u64) | ||
92 | */ | ||
93 | storDriver->MaxOutstandingRequestsPerChannel = | ||
94 | ((storDriver->RingBufferSize - PAGE_SIZE) / | ||
95 | ALIGN_UP(MAX_MULTIPAGE_BUFFER_PACKET + | ||
96 | sizeof(struct vstor_packet) + sizeof(u64), | ||
97 | sizeof(u64))); | ||
98 | |||
99 | DPRINT_INFO(BLKVSC, "max io outstd %u", | ||
100 | storDriver->MaxOutstandingRequestsPerChannel); | ||
101 | |||
102 | /* Setup the dispatch table */ | ||
103 | storDriver->Base.OnDeviceAdd = BlkVscOnDeviceAdd; | ||
104 | storDriver->Base.OnDeviceRemove = StorVscOnDeviceRemove; | ||
105 | storDriver->Base.OnCleanup = StorVscOnCleanup; | ||
106 | storDriver->OnIORequest = StorVscOnIORequest; | ||
111 | 107 | ||
112 | DPRINT_EXIT(BLKVSC); | 108 | DPRINT_EXIT(BLKVSC); |
113 | 109 | ||