blob: 8505a1c5f9ee6bab72259539fa0d1c845fbba1c9 [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
Greg Kroah-Hartman447fc672010-05-05 22:43:02 -070028#include "vmbus_api.h"
Hank Janssenab057782009-07-13 15:19:28 -070029
Bill Pemberton454f18a2009-07-27 16:47:24 -040030/* Defines */
Hank Janssen15dd1c92010-08-05 19:30:31 +000031#define STORVSC_RING_BUFFER_SIZE (20*PAGE_SIZE)
Greg Kroah-Hartman9bcd7862009-08-28 16:19:17 -070032#define BLKVSC_RING_BUFFER_SIZE (20*PAGE_SIZE)
Hank Janssenab057782009-07-13 15:19:28 -070033
Hank Janssen15dd1c92010-08-05 19:30:31 +000034#define STORVSC_MAX_IO_REQUESTS 128
Hank Janssenab057782009-07-13 15:19:28 -070035
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/* Matches Windows-end */
Greg Kroah-Hartman9f0c7d22009-08-28 16:20:07 -070049enum storvsc_request_type{
Hank Janssenab057782009-07-13 15:19:28 -070050 WRITE_TYPE,
51 READ_TYPE,
52 UNKNOWN_TYPE,
Greg Kroah-Hartman9f0c7d22009-08-28 16:20:07 -070053};
Hank Janssenab057782009-07-13 15:19:28 -070054
Nicolas Palix0b3f6832009-07-29 14:10:19 +020055struct hv_storvsc_request {
Greg Kroah-Hartman9f0c7d22009-08-28 16:20:07 -070056 enum storvsc_request_type Type;
Greg Kroah-Hartman9bcd7862009-08-28 16:19:17 -070057 u32 Host;
58 u32 Bus;
59 u32 TargetId;
60 u32 LunId;
61 u8 *Cdb;
62 u32 CdbLen;
63 u32 Status;
64 u32 BytesXfer;
Hank Janssenab057782009-07-13 15:19:28 -070065
Greg Kroah-Hartman9bcd7862009-08-28 16:19:17 -070066 unsigned char *SenseBuffer;
67 u32 SenseBufferSize;
Hank Janssenab057782009-07-13 15:19:28 -070068
Greg Kroah-Hartman9bcd7862009-08-28 16:19:17 -070069 void *Context;
Hank Janssenab057782009-07-13 15:19:28 -070070
Greg Kroah-Hartmanf25c7492009-09-02 11:28:55 -070071 void (*OnIOCompletion)(struct hv_storvsc_request *Request);
Hank Janssenab057782009-07-13 15:19:28 -070072
Bill Pemberton454f18a2009-07-27 16:47:24 -040073 /* This points to the memory after DataBuffer */
Greg Kroah-Hartman9bcd7862009-08-28 16:19:17 -070074 void *Extension;
Hank Janssenab057782009-07-13 15:19:28 -070075
Greg Kroah-Hartmanee3d7dd2009-08-20 12:17:36 -070076 struct hv_multipage_buffer DataBuffer;
Nicolas Palix0b3f6832009-07-29 14:10:19 +020077};
Hank Janssenab057782009-07-13 15:19:28 -070078
Bill Pemberton454f18a2009-07-27 16:47:24 -040079/* Represents the block vsc driver */
Greg Kroah-Hartman9f0c7d22009-08-28 16:20:07 -070080struct storvsc_driver_object {
Greg Kroah-Hartman9bcd7862009-08-28 16:19:17 -070081 /* Must be the first field */
82 /* Which is a bug FIXME! */
83 struct hv_driver Base;
Hank Janssenab057782009-07-13 15:19:28 -070084
Bill Pemberton454f18a2009-07-27 16:47:24 -040085 /* Set by caller (in bytes) */
Greg Kroah-Hartman9bcd7862009-08-28 16:19:17 -070086 u32 RingBufferSize;
Hank Janssenab057782009-07-13 15:19:28 -070087
Bill Pemberton454f18a2009-07-27 16:47:24 -040088 /* Allocate this much private extension for each I/O request */
Greg Kroah-Hartman9bcd7862009-08-28 16:19:17 -070089 u32 RequestExtSize;
Hank Janssenab057782009-07-13 15:19:28 -070090
Bill Pemberton454f18a2009-07-27 16:47:24 -040091 /* Maximum # of requests in flight per channel/device */
Greg Kroah-Hartman9bcd7862009-08-28 16:19:17 -070092 u32 MaxOutstandingRequestsPerChannel;
Hank Janssenab057782009-07-13 15:19:28 -070093
Bill Pemberton454f18a2009-07-27 16:47:24 -040094 /* Specific to this driver */
Greg Kroah-Hartmanf25c7492009-09-02 11:28:55 -070095 int (*OnIORequest)(struct hv_device *Device,
96 struct hv_storvsc_request *Request);
Greg Kroah-Hartman9f0c7d22009-08-28 16:20:07 -070097};
Hank Janssenab057782009-07-13 15:19:28 -070098
Greg Kroah-Hartman9f0c7d22009-08-28 16:20:07 -070099struct storvsc_device_info {
Greg Kroah-Hartman9bcd7862009-08-28 16:19:17 -0700100 unsigned int PortNumber;
101 unsigned char PathId;
102 unsigned char TargetId;
Greg Kroah-Hartman9f0c7d22009-08-28 16:20:07 -0700103};
Hank Janssenab057782009-07-13 15:19:28 -0700104
Bill Pemberton454f18a2009-07-27 16:47:24 -0400105/* Interface */
Greg Kroah-Hartman9bcd7862009-08-28 16:19:17 -0700106int StorVscInitialize(struct hv_driver *driver);
Greg Kroah-Hartman354b0a62010-01-08 10:24:26 -0800107int StorVscOnHostReset(struct hv_device *Device);
Greg Kroah-Hartman9bcd7862009-08-28 16:19:17 -0700108int BlkVscInitialize(struct hv_driver *driver);
Bill Pemberton454f18a2009-07-27 16:47:24 -0400109
Bill Pemberton454f18a2009-07-27 16:47:24 -0400110#endif /* _STORVSC_API_H_ */