From: "K. Y. Srinivasan" <kys@microsoft.com>
To: gregkh@suse.de, linux-kernel@vger.kernel.org,
devel@linuxdriverproject.org, virtualization@lists.osdl.org,
ohering@suse.com, jbottomley@parallels.com, hch@infradead.org,
linux-scsi@vger.kernel.org
Cc: "K. Y. Srinivasan" <kys@microsoft.com>
Subject: [PATCH 10/15] Staging: hv: storvsc: Miscellaneous cleanup of storvsc driver
Date: Thu, 12 Jan 2012 12:38:03 -0800 [thread overview]
Message-ID: <1326400688-13544-10-git-send-email-kys@microsoft.com> (raw)
In-Reply-To: <1326400688-13544-1-git-send-email-kys@microsoft.com>
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: K. Y. Srinivasan <kys@microsoft.com>
---
drivers/staging/hv/storvsc_drv.c | 94 ++++++++++++++++----------------------
1 files changed, 39 insertions(+), 55 deletions(-)
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 0515707..da71294 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -43,32 +43,18 @@
#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_RING_BUFFER_SIZE (20*PAGE_SIZE)
-static int storvsc_ringbuffer_size = STORVSC_RING_BUFFER_SIZE;
+static int storvsc_ringbuffer_size = (20 * PAGE_SIZE);
module_param(storvsc_ringbuffer_size, int, S_IRUGO);
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
@@ -79,7 +65,6 @@ MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)");
#define VMSTOR_PROTOCOL_MINOR(VERSION_) (((VERSION_)) & 0xff)
#define VMSTOR_PROTOCOL_VERSION(MAJOR_, MINOR_) ((((MAJOR_) & 0xff) << 8) | \
(((MINOR_) & 0xff)))
-#define VMSTOR_INVALID_PROTOCOL_VERSION (-1)
/*
* Version history:
@@ -136,26 +121,26 @@ enum vstor_packet_operation {
#define MAX_DATA_BUF_LEN_WITH_PADDING 0x14
struct vmscsi_request {
- unsigned short length;
- unsigned char srb_status;
- unsigned char scsi_status;
+ u16 length;
+ u8 srb_status;
+ u8 scsi_status;
- unsigned char port_number;
- unsigned char path_id;
- unsigned char target_id;
- unsigned char lun;
+ u8 port_number;
+ u8 path_id;
+ u8 target_id;
+ u8 lun;
- unsigned char cdb_length;
- unsigned char sense_info_length;
- unsigned char data_in;
- unsigned char reserved;
+ u8 cdb_length;
+ u8 sense_info_length;
+ u8 data_in;
+ u8 reserved;
- unsigned int data_transfer_length;
+ u32 data_transfer_length;
union {
- unsigned char cdb[CDB16GENERIC_LENGTH];
- unsigned char sense_data[SENSE_BUFFER_SIZE];
- unsigned char reserved_array[MAX_DATA_BUF_LEN_WITH_PADDING];
+ u8 cdb[CDB16GENERIC_LENGTH];
+ u8 sense_data[SENSE_BUFFER_SIZE];
+ u8 reserved_array[MAX_DATA_BUF_LEN_WITH_PADDING];
};
} __attribute((packed));
@@ -165,18 +150,21 @@ struct vmscsi_request {
* properties of the channel.
*/
struct vmstorage_channel_properties {
- unsigned short protocol_version;
- unsigned char path_id;
- unsigned char target_id;
+ u16 protocol_version;
+ u8 path_id;
+ u8 target_id;
/* Note: port number is only really known on the client side */
- unsigned int port_number;
- unsigned int flags;
- unsigned int max_transfer_bytes;
+ u32 port_number;
+ u32 flags;
+ u32 max_transfer_bytes;
- /* This id is unique for each channel and will correspond with */
- /* vendor specific data in the inquirydata */
- unsigned long long unique_id;
+ /*
+ * This id is unique for each channel and will correspond with
+ * vendor specific data in the inquiry data.
+ */
+
+ u64 unique_id;
} __packed;
/* This structure is sent during the storage protocol negotiations. */
@@ -189,6 +177,7 @@ struct vmstorage_protocol_version {
* (See FILL_VMSTOR_REVISION macro above). Mismatch does not
* definitely indicate incompatibility--but it does indicate mismatched
* builds.
+ * This is only used on the windows side. Just set it to 0.
*/
unsigned short revision;
} __packed;
@@ -202,10 +191,10 @@ struct vstor_packet {
enum vstor_packet_operation operation;
/* Flags - see below for values */
- unsigned int flags;
+ u32 flags;
/* Status of the request returned from the server side. */
- unsigned int status;
+ u32 status;
/* Data payload area */
union {
@@ -232,11 +221,6 @@ struct vstor_packet {
#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
/*
@@ -252,7 +236,7 @@ struct vstor_packet {
/* Matches Windows-end */
enum storvsc_request_type {
- WRITE_TYPE,
+ WRITE_TYPE = 0,
READ_TYPE,
UNKNOWN_TYPE,
};
@@ -704,7 +688,7 @@ static int storvsc_channel_init(struct hv_device *device)
vstor_packet->flags = REQUEST_COMPLETION_FLAG;
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,
sizeof(struct vstor_packet),
--
1.7.4.1
next prev parent reply other threads:[~2012-01-12 20:38 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-12 20:37 [PATCH 0000/0015] Staging: hv: storvsc cleanup K. Y. Srinivasan
2012-01-12 20:37 ` [PATCH 01/15] Staging: hv: storvsc: Cleanup some comments K. Y. Srinivasan
2012-01-12 20:37 ` [PATCH 02/15] Staging: hv: storvsc: Cleanup storvsc_probe() K. Y. Srinivasan
2012-01-12 20:37 ` [PATCH 03/15] Staging: hv: storvsc: Cleanup storvsc_queuecommand() K. Y. Srinivasan
2012-01-12 20:37 ` [PATCH 04/15] Staging: hv: storvsc: Introduce defines for srb status codes K. Y. Srinivasan
2012-01-12 20:37 ` [PATCH 05/15] Staging:hv: storvsc: Cleanup storvsc_host_reset_handler() K. Y. Srinivasan
2012-01-12 20:37 ` [PATCH 06/15] Staging: hv: storvsc: Move and cleanup storvsc_remove() K. Y. Srinivasan
2012-01-12 20:38 ` [PATCH 07/15] Staging: hv: storvsc: Add a comment to explain life-cycle management K. Y. Srinivasan
2012-01-12 20:38 ` [PATCH 08/15] Staging: hv: storvsc: Get rid of the on_io_completion in hv_storvsc_request K. Y. Srinivasan
2012-01-12 20:38 ` [PATCH 09/15] Staging: hv: storvsc: Rename the context field " K. Y. Srinivasan
2012-01-12 20:38 ` K. Y. Srinivasan [this message]
2012-01-12 20:38 ` [PATCH 11/15] Staging: hv: storvsc: Cleanup the code for generating protocol version K. Y. Srinivasan
2012-01-12 20:38 ` [PATCH 12/15] Staging: hv: storvsc: Cleanup some protocol related constants K. Y. Srinivasan
2012-01-12 20:38 ` [PATCH 13/15] Staging: hv: storvsc: Get rid of some unused defines K. Y. Srinivasan
2012-01-12 20:38 ` [PATCH 14/15] Staging: hv: storvsc: Consolidate the request structure K. Y. Srinivasan
2012-01-12 20:38 ` [PATCH 15/15] Staging: hv: storvsc: Consolidate all the wire protocol definitions K. Y. Srinivasan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1326400688-13544-10-git-send-email-kys@microsoft.com \
--to=kys@microsoft.com \
--cc=devel@linuxdriverproject.org \
--cc=gregkh@suse.de \
--cc=hch@infradead.org \
--cc=jbottomley@parallels.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=ohering@suse.com \
--cc=virtualization@lists.osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox