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 "vmbus_api.h" 29 30/* Defines */ 31#define STORVSC_RING_BUFFER_SIZE (20*PAGE_SIZE) 32#define BLKVSC_RING_BUFFER_SIZE (20*PAGE_SIZE) 33 34#define STORVSC_MAX_IO_REQUESTS 128 35 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 */ 42#define STORVSC_MAX_LUNS_PER_TARGET 64 43#define STORVSC_MAX_TARGETS 1 44#define STORVSC_MAX_CHANNELS 1 45 46struct hv_storvsc_request; 47 48/* Matches Windows-end */ 49enum storvsc_request_type{ 50 WRITE_TYPE, 51 READ_TYPE, 52 UNKNOWN_TYPE, 53}; 54 55struct hv_storvsc_request { 56 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; 65 66 unsigned char *sense_buffer; 67 u32 sense_buffer_size; 68 69 void *context; 70 71 void (*on_io_completion)(struct hv_storvsc_request *request); 72 73 /* This points to the memory after DataBuffer */ 74 void *extension; 75 76 struct hv_multipage_buffer data_buffer; 77}; 78 79/* Represents the block vsc driver */ 80struct storvsc_driver_object { 81 /* Must be the first field */ 82 /* Which is a bug FIXME! */ 83 struct hv_driver base; 84 85 /* Set by caller (in bytes) */ 86 u32 ring_buffer_size; 87 88 /* Allocate this much private extension for each I/O request */ 89 u32 request_ext_size; 90 91 /* Maximum # of requests in flight per channel/device */ 92 u32 max_outstanding_req_per_channel; 93 94 /* Specific to this driver */ 95 int (*on_io_request)(struct hv_device *device, 96 struct hv_storvsc_request *request); 97}; 98 99struct storvsc_device_info { 100 unsigned int port_number; 101 unsigned char path_id; 102 unsigned char target_id; 103}; 104 105/* Interface */ 106int stor_vsc_initialize(struct hv_driver *driver); 107int stor_vsc_on_host_reset(struct hv_device *device); 108int blk_vsc_initialize(struct hv_driver *driver); 109 110#endif /* _STORVSC_API_H_ */ 111