blob: 5d72f299743649587390bebb21e7fbe85ee290d2 [file] [log] [blame]
Hank Janssenab057782009-07-13 15:19:28 -07001/*
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 Pemberton454f18a2009-07-27 16:47:24 -040030
31/* Defines */
32
Hank Janssenab057782009-07-13 15:19:28 -070033
34#define STORVSC_RING_BUFFER_SIZE 10*PAGE_SIZE
35#define BLKVSC_RING_BUFFER_SIZE 20*PAGE_SIZE
36
37#define STORVSC_MAX_IO_REQUESTS 64
38
Bill Pemberton454f18a2009-07-27 16:47:24 -040039/*
40 * In Hyper-V, each port/path/target maps to 1 scsi host adapter. In
41 * reality, the path/target is not used (ie always set to 0) so our
42 * scsi host adapter essentially has 1 bus with 1 target that contains
43 * up to 256 luns.
44 */
Hank Janssenab057782009-07-13 15:19:28 -070045
46#define STORVSC_MAX_LUNS_PER_TARGET 64
47#define STORVSC_MAX_TARGETS 1
48#define STORVSC_MAX_CHANNELS 1
49
50
Bill Pemberton454f18a2009-07-27 16:47:24 -040051/* Fwd decl */
52
53/* struct VMBUS_CHANNEL; */
Nicolas Palix0b3f6832009-07-29 14:10:19 +020054struct hv_storvsc_request;
Hank Janssenab057782009-07-13 15:19:28 -070055
Bill Pemberton454f18a2009-07-27 16:47:24 -040056
57/* Data types */
58
Nicolas Palix0b3f6832009-07-29 14:10:19 +020059typedef int (*PFN_ON_IO_REQUEST)(struct hv_device *Device, struct hv_storvsc_request *Request);
60typedef void (*PFN_ON_IO_REQUEST_COMPLTN)(struct hv_storvsc_request *Request);
Hank Janssenab057782009-07-13 15:19:28 -070061
Nicolas Palix3d3b5512009-07-28 17:32:53 +020062typedef int (*PFN_ON_HOST_RESET)(struct hv_device *Device);
63typedef void (*PFN_ON_HOST_RESCAN)(struct hv_device *Device);
Hank Janssenab057782009-07-13 15:19:28 -070064
65
Bill Pemberton454f18a2009-07-27 16:47:24 -040066/* Matches Windows-end */
Hank Janssenab057782009-07-13 15:19:28 -070067typedef enum _STORVSC_REQUEST_TYPE{
68 WRITE_TYPE,
69 READ_TYPE,
70 UNKNOWN_TYPE,
71} STORVSC_REQUEST_TYPE;
72
73
Nicolas Palix0b3f6832009-07-29 14:10:19 +020074struct hv_storvsc_request {
Hank Janssenab057782009-07-13 15:19:28 -070075 STORVSC_REQUEST_TYPE Type;
Greg Kroah-Hartman4d643112009-07-14 15:09:36 -070076 u32 Host;
77 u32 Bus;
78 u32 TargetId;
79 u32 LunId;
Greg Kroah-Hartman5654e932009-07-14 15:08:20 -070080 u8 * Cdb;
Greg Kroah-Hartman4d643112009-07-14 15:09:36 -070081 u32 CdbLen;
82 u32 Status;
83 u32 BytesXfer;
Hank Janssenab057782009-07-13 15:19:28 -070084
Greg Kroah-Hartman59471432009-07-14 15:10:26 -070085 unsigned char* SenseBuffer;
Greg Kroah-Hartman4d643112009-07-14 15:09:36 -070086 u32 SenseBufferSize;
Hank Janssenab057782009-07-13 15:19:28 -070087
Greg Kroah-Hartman8282c402009-07-14 15:06:28 -070088 void * Context;
Hank Janssenab057782009-07-13 15:19:28 -070089
90 PFN_ON_IO_REQUEST_COMPLTN OnIOCompletion;
91
Bill Pemberton454f18a2009-07-27 16:47:24 -040092 /* This points to the memory after DataBuffer */
Greg Kroah-Hartman8282c402009-07-14 15:06:28 -070093 void * Extension;
Hank Janssenab057782009-07-13 15:19:28 -070094
95 MULTIPAGE_BUFFER DataBuffer;
Nicolas Palix0b3f6832009-07-29 14:10:19 +020096};
Hank Janssenab057782009-07-13 15:19:28 -070097
98
Bill Pemberton454f18a2009-07-27 16:47:24 -040099/* Represents the block vsc driver */
Hank Janssenab057782009-07-13 15:19:28 -0700100typedef struct _STORVSC_DRIVER_OBJECT {
Nicolas Palix775ef252009-07-29 14:09:45 +0200101 struct hv_driver Base; /* Must be the first field */
Hank Janssenab057782009-07-13 15:19:28 -0700102
Bill Pemberton454f18a2009-07-27 16:47:24 -0400103 /* Set by caller (in bytes) */
Greg Kroah-Hartman4d643112009-07-14 15:09:36 -0700104 u32 RingBufferSize;
Hank Janssenab057782009-07-13 15:19:28 -0700105
Bill Pemberton454f18a2009-07-27 16:47:24 -0400106 /* Allocate this much private extension for each I/O request */
Greg Kroah-Hartman4d643112009-07-14 15:09:36 -0700107 u32 RequestExtSize;
Hank Janssenab057782009-07-13 15:19:28 -0700108
Bill Pemberton454f18a2009-07-27 16:47:24 -0400109 /* Maximum # of requests in flight per channel/device */
Greg Kroah-Hartman4d643112009-07-14 15:09:36 -0700110 u32 MaxOutstandingRequestsPerChannel;
Hank Janssenab057782009-07-13 15:19:28 -0700111
Bill Pemberton454f18a2009-07-27 16:47:24 -0400112 /* Set by the caller to allow us to re-enumerate the bus on the host */
Hank Janssenab057782009-07-13 15:19:28 -0700113 PFN_ON_HOST_RESCAN OnHostRescan;
114
Bill Pemberton454f18a2009-07-27 16:47:24 -0400115 /* Specific to this driver */
Hank Janssenab057782009-07-13 15:19:28 -0700116 PFN_ON_IO_REQUEST OnIORequest;
117 PFN_ON_HOST_RESET OnHostReset;
118
119} STORVSC_DRIVER_OBJECT;
120
121typedef struct _STORVSC_DEVICE_INFO {
Greg Kroah-Hartman3abcbc42009-07-14 15:13:46 -0700122 unsigned int PortNumber;
Greg Kroah-Hartman59471432009-07-14 15:10:26 -0700123 unsigned char PathId;
124 unsigned char TargetId;
Hank Janssenab057782009-07-13 15:19:28 -0700125} STORVSC_DEVICE_INFO;
126
Bill Pemberton454f18a2009-07-27 16:47:24 -0400127
128/* Interface */
129
Hank Janssenab057782009-07-13 15:19:28 -0700130int
131StorVscInitialize(
Nicolas Palix775ef252009-07-29 14:09:45 +0200132 struct hv_driver *Driver
Hank Janssenab057782009-07-13 15:19:28 -0700133 );
134
135int
136BlkVscInitialize(
Nicolas Palix775ef252009-07-29 14:09:45 +0200137 struct hv_driver *Driver
Hank Janssenab057782009-07-13 15:19:28 -0700138 );
Bill Pemberton454f18a2009-07-27 16:47:24 -0400139#endif /* _STORVSC_API_H_ */