提交 c649114a 编写于 作者: K K. Y. Srinivasan 提交者: Greg Kroah-Hartman

Staging: hv: storvsc: Miscellaneous cleanup of storvsc driver

Miscellaneous cleanup of storvsc driver - get rid of unnecessary defines and
use fixed size types for structures used for communication with the host.
Signed-off-by: NK. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 93a1bf4d
...@@ -43,32 +43,18 @@ ...@@ -43,32 +43,18 @@
#include <scsi/scsi_dbg.h> #include <scsi/scsi_dbg.h>
/*
* We setup a mempool to allocate request structures for this driver
* on a per-lun basis. The following define specifies the number of
* elements in the pool.
*/
#define STORVSC_MIN_BUF_NR 64 #define STORVSC_MIN_BUF_NR 64
#define STORVSC_RING_BUFFER_SIZE (20*PAGE_SIZE) static int storvsc_ringbuffer_size = (20 * PAGE_SIZE);
static int storvsc_ringbuffer_size = STORVSC_RING_BUFFER_SIZE;
module_param(storvsc_ringbuffer_size, int, S_IRUGO); module_param(storvsc_ringbuffer_size, int, S_IRUGO);
MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)"); MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)");
/*
* To alert the user that structure sizes may be mismatched even though the
* protocol versions match.
*/
#define REVISION_STRING(REVISION_) #REVISION_
#define FILL_VMSTOR_REVISION(RESULT_LVALUE_) \
do { \
char *revision_string \
= REVISION_STRING($Rev : 6 $) + 6; \
RESULT_LVALUE_ = 0; \
while (*revision_string >= '0' \
&& *revision_string <= '9') { \
RESULT_LVALUE_ *= 10; \
RESULT_LVALUE_ += *revision_string - '0'; \
revision_string++; \
} \
} while (0)
/* /*
* Major/minor macros. Minor version is in LSB, meaning that earlier flat * Major/minor macros. Minor version is in LSB, meaning that earlier flat
...@@ -79,7 +65,6 @@ MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)"); ...@@ -79,7 +65,6 @@ MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)");
#define VMSTOR_PROTOCOL_MINOR(VERSION_) (((VERSION_)) & 0xff) #define VMSTOR_PROTOCOL_MINOR(VERSION_) (((VERSION_)) & 0xff)
#define VMSTOR_PROTOCOL_VERSION(MAJOR_, MINOR_) ((((MAJOR_) & 0xff) << 8) | \ #define VMSTOR_PROTOCOL_VERSION(MAJOR_, MINOR_) ((((MAJOR_) & 0xff) << 8) | \
(((MINOR_) & 0xff))) (((MINOR_) & 0xff)))
#define VMSTOR_INVALID_PROTOCOL_VERSION (-1)
/* /*
* Version history: * Version history:
...@@ -136,26 +121,26 @@ enum vstor_packet_operation { ...@@ -136,26 +121,26 @@ enum vstor_packet_operation {
#define MAX_DATA_BUF_LEN_WITH_PADDING 0x14 #define MAX_DATA_BUF_LEN_WITH_PADDING 0x14
struct vmscsi_request { struct vmscsi_request {
unsigned short length; u16 length;
unsigned char srb_status; u8 srb_status;
unsigned char scsi_status; u8 scsi_status;
unsigned char port_number; u8 port_number;
unsigned char path_id; u8 path_id;
unsigned char target_id; u8 target_id;
unsigned char lun; u8 lun;
unsigned char cdb_length; u8 cdb_length;
unsigned char sense_info_length; u8 sense_info_length;
unsigned char data_in; u8 data_in;
unsigned char reserved; u8 reserved;
unsigned int data_transfer_length; u32 data_transfer_length;
union { union {
unsigned char cdb[CDB16GENERIC_LENGTH]; u8 cdb[CDB16GENERIC_LENGTH];
unsigned char sense_data[SENSE_BUFFER_SIZE]; u8 sense_data[SENSE_BUFFER_SIZE];
unsigned char reserved_array[MAX_DATA_BUF_LEN_WITH_PADDING]; u8 reserved_array[MAX_DATA_BUF_LEN_WITH_PADDING];
}; };
} __attribute((packed)); } __attribute((packed));
...@@ -165,18 +150,21 @@ struct vmscsi_request { ...@@ -165,18 +150,21 @@ struct vmscsi_request {
* properties of the channel. * properties of the channel.
*/ */
struct vmstorage_channel_properties { struct vmstorage_channel_properties {
unsigned short protocol_version; u16 protocol_version;
unsigned char path_id; u8 path_id;
unsigned char target_id; u8 target_id;
/* Note: port number is only really known on the client side */ /* Note: port number is only really known on the client side */
unsigned int port_number; u32 port_number;
unsigned int flags; u32 flags;
unsigned int max_transfer_bytes; u32 max_transfer_bytes;
/* This id is unique for each channel and will correspond with */ /*
/* vendor specific data in the inquirydata */ * This id is unique for each channel and will correspond with
unsigned long long unique_id; * vendor specific data in the inquiry data.
*/
u64 unique_id;
} __packed; } __packed;
/* This structure is sent during the storage protocol negotiations. */ /* This structure is sent during the storage protocol negotiations. */
...@@ -189,6 +177,7 @@ struct vmstorage_protocol_version { ...@@ -189,6 +177,7 @@ struct vmstorage_protocol_version {
* (See FILL_VMSTOR_REVISION macro above). Mismatch does not * (See FILL_VMSTOR_REVISION macro above). Mismatch does not
* definitely indicate incompatibility--but it does indicate mismatched * definitely indicate incompatibility--but it does indicate mismatched
* builds. * builds.
* This is only used on the windows side. Just set it to 0.
*/ */
unsigned short revision; unsigned short revision;
} __packed; } __packed;
...@@ -202,10 +191,10 @@ struct vstor_packet { ...@@ -202,10 +191,10 @@ struct vstor_packet {
enum vstor_packet_operation operation; enum vstor_packet_operation operation;
/* Flags - see below for values */ /* Flags - see below for values */
unsigned int flags; u32 flags;
/* Status of the request returned from the server side. */ /* Status of the request returned from the server side. */
unsigned int status; u32 status;
/* Data payload area */ /* Data payload area */
union { union {
...@@ -232,11 +221,6 @@ struct vstor_packet { ...@@ -232,11 +221,6 @@ struct vstor_packet {
#define REQUEST_COMPLETION_FLAG 0x1 #define REQUEST_COMPLETION_FLAG 0x1
/* This is the set of flags that the vsc can set in any packets it sends */
#define VSC_LEGAL_FLAGS (REQUEST_COMPLETION_FLAG)
#define STORVSC_MAX_IO_REQUESTS 128 #define STORVSC_MAX_IO_REQUESTS 128
/* /*
...@@ -252,7 +236,7 @@ struct vstor_packet { ...@@ -252,7 +236,7 @@ struct vstor_packet {
/* Matches Windows-end */ /* Matches Windows-end */
enum storvsc_request_type { enum storvsc_request_type {
WRITE_TYPE, WRITE_TYPE = 0,
READ_TYPE, READ_TYPE,
UNKNOWN_TYPE, UNKNOWN_TYPE,
}; };
...@@ -704,7 +688,7 @@ static int storvsc_channel_init(struct hv_device *device) ...@@ -704,7 +688,7 @@ static int storvsc_channel_init(struct hv_device *device)
vstor_packet->flags = REQUEST_COMPLETION_FLAG; vstor_packet->flags = REQUEST_COMPLETION_FLAG;
vstor_packet->version.major_minor = VMSTOR_PROTOCOL_VERSION_CURRENT; vstor_packet->version.major_minor = VMSTOR_PROTOCOL_VERSION_CURRENT;
FILL_VMSTOR_REVISION(vstor_packet->version.revision); vstor_packet->version.revision = 0;
ret = vmbus_sendpacket(device->channel, vstor_packet, ret = vmbus_sendpacket(device->channel, vstor_packet,
sizeof(struct vstor_packet), sizeof(struct vstor_packet),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册