2009-07-13 22:19:28 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Copyright (c) 2009, Microsoft Corporation.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
|
|
|
* Place - Suite 330, Boston, MA 02111-1307 USA.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Haiyang Zhang <haiyangz@microsoft.com>
|
|
|
|
* Hank Janssen <hjanssen@microsoft.com>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _STORVSC_API_H_
|
|
|
|
#define _STORVSC_API_H_
|
|
|
|
|
|
|
|
#include "VmbusApi.h"
|
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
|
|
|
|
/* Defines */
|
|
|
|
|
2009-07-13 22:19:28 +00:00
|
|
|
|
|
|
|
#define STORVSC_RING_BUFFER_SIZE 10*PAGE_SIZE
|
|
|
|
#define BLKVSC_RING_BUFFER_SIZE 20*PAGE_SIZE
|
|
|
|
|
|
|
|
#define STORVSC_MAX_IO_REQUESTS 64
|
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/*
|
|
|
|
* In Hyper-V, each port/path/target maps to 1 scsi host adapter. In
|
|
|
|
* reality, the path/target is not used (ie always set to 0) so our
|
|
|
|
* scsi host adapter essentially has 1 bus with 1 target that contains
|
|
|
|
* up to 256 luns.
|
|
|
|
*/
|
2009-07-13 22:19:28 +00:00
|
|
|
|
|
|
|
#define STORVSC_MAX_LUNS_PER_TARGET 64
|
|
|
|
#define STORVSC_MAX_TARGETS 1
|
|
|
|
#define STORVSC_MAX_CHANNELS 1
|
|
|
|
|
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* Fwd decl */
|
|
|
|
|
|
|
|
/* struct VMBUS_CHANNEL; */
|
2009-07-13 22:19:28 +00:00
|
|
|
typedef struct _STORVSC_REQUEST* PSTORVSC_REQUEST;
|
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
|
|
|
|
/* Data types */
|
|
|
|
|
2009-07-13 22:19:28 +00:00
|
|
|
typedef int (*PFN_ON_IO_REQUEST)(PDEVICE_OBJECT Device, PSTORVSC_REQUEST Request);
|
|
|
|
typedef void (*PFN_ON_IO_REQUEST_COMPLTN)(PSTORVSC_REQUEST Request);
|
|
|
|
|
|
|
|
typedef int (*PFN_ON_HOST_RESET)(PDEVICE_OBJECT Device);
|
|
|
|
typedef void (*PFN_ON_HOST_RESCAN)(PDEVICE_OBJECT Device);
|
|
|
|
|
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* Matches Windows-end */
|
2009-07-13 22:19:28 +00:00
|
|
|
typedef enum _STORVSC_REQUEST_TYPE{
|
|
|
|
WRITE_TYPE,
|
|
|
|
READ_TYPE,
|
|
|
|
UNKNOWN_TYPE,
|
|
|
|
} STORVSC_REQUEST_TYPE;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct _STORVSC_REQUEST {
|
|
|
|
STORVSC_REQUEST_TYPE Type;
|
2009-07-14 22:09:36 +00:00
|
|
|
u32 Host;
|
|
|
|
u32 Bus;
|
|
|
|
u32 TargetId;
|
|
|
|
u32 LunId;
|
2009-07-14 22:08:20 +00:00
|
|
|
u8 * Cdb;
|
2009-07-14 22:09:36 +00:00
|
|
|
u32 CdbLen;
|
|
|
|
u32 Status;
|
|
|
|
u32 BytesXfer;
|
2009-07-13 22:19:28 +00:00
|
|
|
|
2009-07-14 22:10:26 +00:00
|
|
|
unsigned char* SenseBuffer;
|
2009-07-14 22:09:36 +00:00
|
|
|
u32 SenseBufferSize;
|
2009-07-13 22:19:28 +00:00
|
|
|
|
2009-07-14 22:06:28 +00:00
|
|
|
void * Context;
|
2009-07-13 22:19:28 +00:00
|
|
|
|
|
|
|
PFN_ON_IO_REQUEST_COMPLTN OnIOCompletion;
|
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* This points to the memory after DataBuffer */
|
2009-07-14 22:06:28 +00:00
|
|
|
void * Extension;
|
2009-07-13 22:19:28 +00:00
|
|
|
|
|
|
|
MULTIPAGE_BUFFER DataBuffer;
|
|
|
|
} STORVSC_REQUEST;
|
|
|
|
|
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* Represents the block vsc driver */
|
2009-07-13 22:19:28 +00:00
|
|
|
typedef struct _STORVSC_DRIVER_OBJECT {
|
2009-07-27 20:47:24 +00:00
|
|
|
DRIVER_OBJECT Base; /* Must be the first field */
|
2009-07-13 22:19:28 +00:00
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* Set by caller (in bytes) */
|
2009-07-14 22:09:36 +00:00
|
|
|
u32 RingBufferSize;
|
2009-07-13 22:19:28 +00:00
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* Allocate this much private extension for each I/O request */
|
2009-07-14 22:09:36 +00:00
|
|
|
u32 RequestExtSize;
|
2009-07-13 22:19:28 +00:00
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* Maximum # of requests in flight per channel/device */
|
2009-07-14 22:09:36 +00:00
|
|
|
u32 MaxOutstandingRequestsPerChannel;
|
2009-07-13 22:19:28 +00:00
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* Set by the caller to allow us to re-enumerate the bus on the host */
|
2009-07-13 22:19:28 +00:00
|
|
|
PFN_ON_HOST_RESCAN OnHostRescan;
|
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
/* Specific to this driver */
|
2009-07-13 22:19:28 +00:00
|
|
|
PFN_ON_IO_REQUEST OnIORequest;
|
|
|
|
PFN_ON_HOST_RESET OnHostReset;
|
|
|
|
|
|
|
|
} STORVSC_DRIVER_OBJECT;
|
|
|
|
|
|
|
|
typedef struct _STORVSC_DEVICE_INFO {
|
2009-07-14 22:13:46 +00:00
|
|
|
unsigned int PortNumber;
|
2009-07-14 22:10:26 +00:00
|
|
|
unsigned char PathId;
|
|
|
|
unsigned char TargetId;
|
2009-07-13 22:19:28 +00:00
|
|
|
} STORVSC_DEVICE_INFO;
|
|
|
|
|
2009-07-27 20:47:24 +00:00
|
|
|
|
|
|
|
/* Interface */
|
|
|
|
|
2009-07-13 22:19:28 +00:00
|
|
|
int
|
|
|
|
StorVscInitialize(
|
|
|
|
DRIVER_OBJECT *Driver
|
|
|
|
);
|
|
|
|
|
|
|
|
int
|
|
|
|
BlkVscInitialize(
|
|
|
|
DRIVER_OBJECT *Driver
|
|
|
|
);
|
2009-07-27 20:47:24 +00:00
|
|
|
#endif /* _STORVSC_API_H_ */
|