Hank Janssen | ab05778 | 2009-07-13 15:19:28 -0700 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Copyright (c) 2009, Microsoft Corporation. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms and conditions of the GNU General Public License, |
| 7 | * version 2, as published by the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 12 | * more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License along with |
| 15 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
| 16 | * Place - Suite 330, Boston, MA 02111-1307 USA. |
| 17 | * |
| 18 | * Authors: |
| 19 | * Haiyang Zhang <haiyangz@microsoft.com> |
| 20 | * Hank Janssen <hjanssen@microsoft.com> |
| 21 | * |
| 22 | */ |
| 23 | |
| 24 | |
| 25 | #ifndef _STORVSC_API_H_ |
| 26 | #define _STORVSC_API_H_ |
| 27 | |
| 28 | #include "VmbusApi.h" |
| 29 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 30 | /* Defines */ |
Greg Kroah-Hartman | 9bcd786 | 2009-08-28 16:19:17 -0700 | [diff] [blame] | 31 | #define STORVSC_RING_BUFFER_SIZE (10*PAGE_SIZE) |
| 32 | #define BLKVSC_RING_BUFFER_SIZE (20*PAGE_SIZE) |
Hank Janssen | ab05778 | 2009-07-13 15:19:28 -0700 | [diff] [blame] | 33 | |
| 34 | #define STORVSC_MAX_IO_REQUESTS 64 |
| 35 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 36 | /* |
| 37 | * In Hyper-V, each port/path/target maps to 1 scsi host adapter. In |
| 38 | * reality, the path/target is not used (ie always set to 0) so our |
| 39 | * scsi host adapter essentially has 1 bus with 1 target that contains |
| 40 | * up to 256 luns. |
| 41 | */ |
Hank Janssen | ab05778 | 2009-07-13 15:19:28 -0700 | [diff] [blame] | 42 | #define STORVSC_MAX_LUNS_PER_TARGET 64 |
Greg Kroah-Hartman | 9bcd786 | 2009-08-28 16:19:17 -0700 | [diff] [blame] | 43 | #define STORVSC_MAX_TARGETS 1 |
Hank Janssen | ab05778 | 2009-07-13 15:19:28 -0700 | [diff] [blame] | 44 | #define STORVSC_MAX_CHANNELS 1 |
| 45 | |
Nicolas Palix | 0b3f683 | 2009-07-29 14:10:19 +0200 | [diff] [blame] | 46 | struct hv_storvsc_request; |
Hank Janssen | ab05778 | 2009-07-13 15:19:28 -0700 | [diff] [blame] | 47 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 48 | /* Data types */ |
Greg Kroah-Hartman | 9bcd786 | 2009-08-28 16:19:17 -0700 | [diff] [blame] | 49 | typedef int (*PFN_ON_IO_REQUEST)(struct hv_device *Device, |
| 50 | struct hv_storvsc_request *Request); |
Nicolas Palix | 0b3f683 | 2009-07-29 14:10:19 +0200 | [diff] [blame] | 51 | typedef void (*PFN_ON_IO_REQUEST_COMPLTN)(struct hv_storvsc_request *Request); |
Hank Janssen | ab05778 | 2009-07-13 15:19:28 -0700 | [diff] [blame] | 52 | |
Nicolas Palix | 3d3b551 | 2009-07-28 17:32:53 +0200 | [diff] [blame] | 53 | typedef int (*PFN_ON_HOST_RESET)(struct hv_device *Device); |
| 54 | typedef void (*PFN_ON_HOST_RESCAN)(struct hv_device *Device); |
Hank Janssen | ab05778 | 2009-07-13 15:19:28 -0700 | [diff] [blame] | 55 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 56 | /* Matches Windows-end */ |
Greg Kroah-Hartman | 9f0c7d2 | 2009-08-28 16:20:07 -0700 | [diff] [blame^] | 57 | enum storvsc_request_type{ |
Hank Janssen | ab05778 | 2009-07-13 15:19:28 -0700 | [diff] [blame] | 58 | WRITE_TYPE, |
| 59 | READ_TYPE, |
| 60 | UNKNOWN_TYPE, |
Greg Kroah-Hartman | 9f0c7d2 | 2009-08-28 16:20:07 -0700 | [diff] [blame^] | 61 | }; |
Hank Janssen | ab05778 | 2009-07-13 15:19:28 -0700 | [diff] [blame] | 62 | |
Nicolas Palix | 0b3f683 | 2009-07-29 14:10:19 +0200 | [diff] [blame] | 63 | struct hv_storvsc_request { |
Greg Kroah-Hartman | 9f0c7d2 | 2009-08-28 16:20:07 -0700 | [diff] [blame^] | 64 | enum storvsc_request_type Type; |
Greg Kroah-Hartman | 9bcd786 | 2009-08-28 16:19:17 -0700 | [diff] [blame] | 65 | u32 Host; |
| 66 | u32 Bus; |
| 67 | u32 TargetId; |
| 68 | u32 LunId; |
| 69 | u8 *Cdb; |
| 70 | u32 CdbLen; |
| 71 | u32 Status; |
| 72 | u32 BytesXfer; |
Hank Janssen | ab05778 | 2009-07-13 15:19:28 -0700 | [diff] [blame] | 73 | |
Greg Kroah-Hartman | 9bcd786 | 2009-08-28 16:19:17 -0700 | [diff] [blame] | 74 | unsigned char *SenseBuffer; |
| 75 | u32 SenseBufferSize; |
Hank Janssen | ab05778 | 2009-07-13 15:19:28 -0700 | [diff] [blame] | 76 | |
Greg Kroah-Hartman | 9bcd786 | 2009-08-28 16:19:17 -0700 | [diff] [blame] | 77 | void *Context; |
Hank Janssen | ab05778 | 2009-07-13 15:19:28 -0700 | [diff] [blame] | 78 | |
Greg Kroah-Hartman | 9bcd786 | 2009-08-28 16:19:17 -0700 | [diff] [blame] | 79 | PFN_ON_IO_REQUEST_COMPLTN OnIOCompletion; |
Hank Janssen | ab05778 | 2009-07-13 15:19:28 -0700 | [diff] [blame] | 80 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 81 | /* This points to the memory after DataBuffer */ |
Greg Kroah-Hartman | 9bcd786 | 2009-08-28 16:19:17 -0700 | [diff] [blame] | 82 | void *Extension; |
Hank Janssen | ab05778 | 2009-07-13 15:19:28 -0700 | [diff] [blame] | 83 | |
Greg Kroah-Hartman | ee3d7dd | 2009-08-20 12:17:36 -0700 | [diff] [blame] | 84 | struct hv_multipage_buffer DataBuffer; |
Nicolas Palix | 0b3f683 | 2009-07-29 14:10:19 +0200 | [diff] [blame] | 85 | }; |
Hank Janssen | ab05778 | 2009-07-13 15:19:28 -0700 | [diff] [blame] | 86 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 87 | /* Represents the block vsc driver */ |
Greg Kroah-Hartman | 9f0c7d2 | 2009-08-28 16:20:07 -0700 | [diff] [blame^] | 88 | struct storvsc_driver_object { |
Greg Kroah-Hartman | 9bcd786 | 2009-08-28 16:19:17 -0700 | [diff] [blame] | 89 | /* Must be the first field */ |
| 90 | /* Which is a bug FIXME! */ |
| 91 | struct hv_driver Base; |
Hank Janssen | ab05778 | 2009-07-13 15:19:28 -0700 | [diff] [blame] | 92 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 93 | /* Set by caller (in bytes) */ |
Greg Kroah-Hartman | 9bcd786 | 2009-08-28 16:19:17 -0700 | [diff] [blame] | 94 | u32 RingBufferSize; |
Hank Janssen | ab05778 | 2009-07-13 15:19:28 -0700 | [diff] [blame] | 95 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 96 | /* Allocate this much private extension for each I/O request */ |
Greg Kroah-Hartman | 9bcd786 | 2009-08-28 16:19:17 -0700 | [diff] [blame] | 97 | u32 RequestExtSize; |
Hank Janssen | ab05778 | 2009-07-13 15:19:28 -0700 | [diff] [blame] | 98 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 99 | /* Maximum # of requests in flight per channel/device */ |
Greg Kroah-Hartman | 9bcd786 | 2009-08-28 16:19:17 -0700 | [diff] [blame] | 100 | u32 MaxOutstandingRequestsPerChannel; |
Hank Janssen | ab05778 | 2009-07-13 15:19:28 -0700 | [diff] [blame] | 101 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 102 | /* Set by the caller to allow us to re-enumerate the bus on the host */ |
Greg Kroah-Hartman | 9bcd786 | 2009-08-28 16:19:17 -0700 | [diff] [blame] | 103 | PFN_ON_HOST_RESCAN OnHostRescan; |
Hank Janssen | ab05778 | 2009-07-13 15:19:28 -0700 | [diff] [blame] | 104 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 105 | /* Specific to this driver */ |
Greg Kroah-Hartman | 9bcd786 | 2009-08-28 16:19:17 -0700 | [diff] [blame] | 106 | PFN_ON_IO_REQUEST OnIORequest; |
| 107 | PFN_ON_HOST_RESET OnHostReset; |
Greg Kroah-Hartman | 9f0c7d2 | 2009-08-28 16:20:07 -0700 | [diff] [blame^] | 108 | }; |
Hank Janssen | ab05778 | 2009-07-13 15:19:28 -0700 | [diff] [blame] | 109 | |
Greg Kroah-Hartman | 9f0c7d2 | 2009-08-28 16:20:07 -0700 | [diff] [blame^] | 110 | struct storvsc_device_info { |
Greg Kroah-Hartman | 9bcd786 | 2009-08-28 16:19:17 -0700 | [diff] [blame] | 111 | unsigned int PortNumber; |
| 112 | unsigned char PathId; |
| 113 | unsigned char TargetId; |
Greg Kroah-Hartman | 9f0c7d2 | 2009-08-28 16:20:07 -0700 | [diff] [blame^] | 114 | }; |
Hank Janssen | ab05778 | 2009-07-13 15:19:28 -0700 | [diff] [blame] | 115 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 116 | /* Interface */ |
Greg Kroah-Hartman | 9bcd786 | 2009-08-28 16:19:17 -0700 | [diff] [blame] | 117 | int StorVscInitialize(struct hv_driver *driver); |
| 118 | int BlkVscInitialize(struct hv_driver *driver); |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 119 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 120 | #endif /* _STORVSC_API_H_ */ |