blob: 46f031e0afc607dea5225e8c0f33c9dbe92aa619 [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 {
Hank Janssen8a046022010-12-06 12:26:45 -080056 enum storvsc_request_type type;
57 u32 host;
58 u32 bus;
59 u32 target_id;
60 u32 lun_id;
61 u8 *cdb;
62 u32 cdb_len;
63 u32 status;
64 u32 bytes_xfer;
Hank Janssenab057782009-07-13 15:19:28 -070065
Hank Janssen8a046022010-12-06 12:26:45 -080066 unsigned char *sense_buffer;
67 u32 sense_buffer_size;
Hank Janssenab057782009-07-13 15:19:28 -070068
Hank Janssen8a046022010-12-06 12:26:45 -080069 void *context;
Hank Janssenab057782009-07-13 15:19:28 -070070
Hank Janssen8a046022010-12-06 12:26:45 -080071 void (*on_io_completion)(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 */
Hank Janssen8a046022010-12-06 12:26:45 -080074 void *extension;
Hank Janssenab057782009-07-13 15:19:28 -070075
Hank Janssen8a046022010-12-06 12:26:45 -080076 struct hv_multipage_buffer data_buffer;
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! */
Hank Janssen8a046022010-12-06 12:26:45 -080083 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) */
Hank Janssen8a046022010-12-06 12:26:45 -080086 u32 ring_buffer_size;
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 */
Hank Janssen8a046022010-12-06 12:26:45 -080089 u32 request_ext_size;
Hank Janssenab057782009-07-13 15:19:28 -070090
Bill Pemberton454f18a2009-07-27 16:47:24 -040091 /* Maximum # of requests in flight per channel/device */
Hank Janssen8a046022010-12-06 12:26:45 -080092 u32 max_outstanding_req_per_channel;
Hank Janssenab057782009-07-13 15:19:28 -070093
Bill Pemberton454f18a2009-07-27 16:47:24 -040094 /* Specific to this driver */
Hank Janssen8a046022010-12-06 12:26:45 -080095 int (*on_io_request)(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 {
Hank Janssen8a046022010-12-06 12:26:45 -0800100 unsigned int port_number;
101 unsigned char path_id;
102 unsigned char target_id;
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);
Hank Janssen8a046022010-12-06 12:26:45 -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_ */