blob: 2deefbda73b1072144960e7dcdc247075dd0a5a8 [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/* Defines */
Greg Kroah-Hartman9bcd7862009-08-28 16:19:17 -070031#define STORVSC_RING_BUFFER_SIZE (10*PAGE_SIZE)
32#define BLKVSC_RING_BUFFER_SIZE (20*PAGE_SIZE)
Hank Janssenab057782009-07-13 15:19:28 -070033
34#define STORVSC_MAX_IO_REQUESTS 64
35
Bill Pemberton454f18a2009-07-27 16:47:24 -040036/*
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 Janssenab057782009-07-13 15:19:28 -070042#define STORVSC_MAX_LUNS_PER_TARGET 64
Greg Kroah-Hartman9bcd7862009-08-28 16:19:17 -070043#define STORVSC_MAX_TARGETS 1
Hank Janssenab057782009-07-13 15:19:28 -070044#define STORVSC_MAX_CHANNELS 1
45
Nicolas Palix0b3f6832009-07-29 14:10:19 +020046struct hv_storvsc_request;
Hank Janssenab057782009-07-13 15:19:28 -070047
Bill Pemberton454f18a2009-07-27 16:47:24 -040048/* Data types */
Greg Kroah-Hartman9bcd7862009-08-28 16:19:17 -070049typedef int (*PFN_ON_IO_REQUEST)(struct hv_device *Device,
50 struct hv_storvsc_request *Request);
Nicolas Palix0b3f6832009-07-29 14:10:19 +020051typedef void (*PFN_ON_IO_REQUEST_COMPLTN)(struct hv_storvsc_request *Request);
Hank Janssenab057782009-07-13 15:19:28 -070052
Nicolas Palix3d3b5512009-07-28 17:32:53 +020053typedef int (*PFN_ON_HOST_RESET)(struct hv_device *Device);
54typedef void (*PFN_ON_HOST_RESCAN)(struct hv_device *Device);
Hank Janssenab057782009-07-13 15:19:28 -070055
Bill Pemberton454f18a2009-07-27 16:47:24 -040056/* Matches Windows-end */
Hank Janssenab057782009-07-13 15:19:28 -070057typedef enum _STORVSC_REQUEST_TYPE{
58 WRITE_TYPE,
59 READ_TYPE,
60 UNKNOWN_TYPE,
61} STORVSC_REQUEST_TYPE;
62
Nicolas Palix0b3f6832009-07-29 14:10:19 +020063struct hv_storvsc_request {
Greg Kroah-Hartman9bcd7862009-08-28 16:19:17 -070064 STORVSC_REQUEST_TYPE Type;
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 Janssenab057782009-07-13 15:19:28 -070073
Greg Kroah-Hartman9bcd7862009-08-28 16:19:17 -070074 unsigned char *SenseBuffer;
75 u32 SenseBufferSize;
Hank Janssenab057782009-07-13 15:19:28 -070076
Greg Kroah-Hartman9bcd7862009-08-28 16:19:17 -070077 void *Context;
Hank Janssenab057782009-07-13 15:19:28 -070078
Greg Kroah-Hartman9bcd7862009-08-28 16:19:17 -070079 PFN_ON_IO_REQUEST_COMPLTN OnIOCompletion;
Hank Janssenab057782009-07-13 15:19:28 -070080
Bill Pemberton454f18a2009-07-27 16:47:24 -040081 /* This points to the memory after DataBuffer */
Greg Kroah-Hartman9bcd7862009-08-28 16:19:17 -070082 void *Extension;
Hank Janssenab057782009-07-13 15:19:28 -070083
Greg Kroah-Hartmanee3d7dd2009-08-20 12:17:36 -070084 struct hv_multipage_buffer DataBuffer;
Nicolas Palix0b3f6832009-07-29 14:10:19 +020085};
Hank Janssenab057782009-07-13 15:19:28 -070086
Bill Pemberton454f18a2009-07-27 16:47:24 -040087/* Represents the block vsc driver */
Hank Janssenab057782009-07-13 15:19:28 -070088typedef struct _STORVSC_DRIVER_OBJECT {
Greg Kroah-Hartman9bcd7862009-08-28 16:19:17 -070089 /* Must be the first field */
90 /* Which is a bug FIXME! */
91 struct hv_driver Base;
Hank Janssenab057782009-07-13 15:19:28 -070092
Bill Pemberton454f18a2009-07-27 16:47:24 -040093 /* Set by caller (in bytes) */
Greg Kroah-Hartman9bcd7862009-08-28 16:19:17 -070094 u32 RingBufferSize;
Hank Janssenab057782009-07-13 15:19:28 -070095
Bill Pemberton454f18a2009-07-27 16:47:24 -040096 /* Allocate this much private extension for each I/O request */
Greg Kroah-Hartman9bcd7862009-08-28 16:19:17 -070097 u32 RequestExtSize;
Hank Janssenab057782009-07-13 15:19:28 -070098
Bill Pemberton454f18a2009-07-27 16:47:24 -040099 /* Maximum # of requests in flight per channel/device */
Greg Kroah-Hartman9bcd7862009-08-28 16:19:17 -0700100 u32 MaxOutstandingRequestsPerChannel;
Hank Janssenab057782009-07-13 15:19:28 -0700101
Bill Pemberton454f18a2009-07-27 16:47:24 -0400102 /* Set by the caller to allow us to re-enumerate the bus on the host */
Greg Kroah-Hartman9bcd7862009-08-28 16:19:17 -0700103 PFN_ON_HOST_RESCAN OnHostRescan;
Hank Janssenab057782009-07-13 15:19:28 -0700104
Bill Pemberton454f18a2009-07-27 16:47:24 -0400105 /* Specific to this driver */
Greg Kroah-Hartman9bcd7862009-08-28 16:19:17 -0700106 PFN_ON_IO_REQUEST OnIORequest;
107 PFN_ON_HOST_RESET OnHostReset;
Hank Janssenab057782009-07-13 15:19:28 -0700108} STORVSC_DRIVER_OBJECT;
109
110typedef struct _STORVSC_DEVICE_INFO {
Greg Kroah-Hartman9bcd7862009-08-28 16:19:17 -0700111 unsigned int PortNumber;
112 unsigned char PathId;
113 unsigned char TargetId;
Hank Janssenab057782009-07-13 15:19:28 -0700114} STORVSC_DEVICE_INFO;
115
Bill Pemberton454f18a2009-07-27 16:47:24 -0400116/* Interface */
Greg Kroah-Hartman9bcd7862009-08-28 16:19:17 -0700117int StorVscInitialize(struct hv_driver *driver);
118int BlkVscInitialize(struct hv_driver *driver);
Bill Pemberton454f18a2009-07-27 16:47:24 -0400119
Bill Pemberton454f18a2009-07-27 16:47:24 -0400120#endif /* _STORVSC_API_H_ */