Linux virtualization list
 help / color / mirror / Atom feed
From: "K. Y. Srinivasan" <kys@microsoft.com>
To: gregkh@suse.de, linux-kernel@vger.kernel.org,
	devel@linuxdriverproject.org, virtualization@lists.osdl.org
Cc: "K. Y. Srinivasan" <kys@microsoft.com>,
	Haiyang Zhang <haiyangz@microsoft.com>,
	Hank Janssen <hjanssen@microsoft.com>
Subject: [PATCH 10/16] Staging: hv: Move the contents of blkvsc.c to blkvsc_drv.c
Date: Wed, 23 Mar 2011 10:50:28 -0700	[thread overview]
Message-ID: <1300902635-1347-10-git-send-email-kys@microsoft.com> (raw)
In-Reply-To: <1300902635-1347-1-git-send-email-kys@microsoft.com>

In preparation for getting rid of the file blkvsc.c, move its contents
to the appropriate file.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
 drivers/staging/hv/Makefile     |    2 +-
 drivers/staging/hv/blkvsc_drv.c |   79 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 80 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/Makefile b/drivers/staging/hv/Makefile
index a733154..3004674 100644
--- a/drivers/staging/hv/Makefile
+++ b/drivers/staging/hv/Makefile
@@ -9,6 +9,6 @@ hv_vmbus-y := vmbus_drv.o \
 		 hv.o connection.o channel.o \
 		 channel_mgmt.o ring_buffer.o
 hv_storvsc-y := storvsc_drv.o storvsc.o
-hv_blkvsc-y := blkvsc_drv.o blkvsc.o storvsc.o
+hv_blkvsc-y := blkvsc_drv.o  storvsc.o
 hv_netvsc-y := netvsc_drv.o netvsc.o rndis_filter.o
 hv_utils-y := hv_util.o hv_kvp.o
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 6e02f1b..1d602a1 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -116,6 +116,85 @@ struct block_device_context {
 };
 
 
+static const char *g_blk_driver_name = "blkvsc";
+
+/* {32412632-86cb-44a2-9b5c-50d1417354f5} */
+static const struct hv_guid g_blk_device_type = {
+	.data = {
+		0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
+		0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
+	}
+};
+
+static int blk_vsc_on_device_add(struct hv_device *device,
+				void *additional_info)
+{
+	struct storvsc_device_info *device_info;
+	int ret = 0;
+
+	device_info = (struct storvsc_device_info *)additional_info;
+
+	ret = stor_vsc_on_device_add(device, additional_info);
+	if (ret != 0)
+		return ret;
+
+	/*
+	 * We need to use the device instance guid to set the path and target
+	 * id. For IDE devices, the device instance id is formatted as
+	 * <bus id> * - <device id> - 8899 - 000000000000.
+	 */
+	device_info->path_id = device->dev_instance.data[3] << 24 |
+			     device->dev_instance.data[2] << 16 |
+			     device->dev_instance.data[1] << 8  |
+			     device->dev_instance.data[0];
+
+	device_info->target_id = device->dev_instance.data[5] << 8 |
+			       device->dev_instance.data[4];
+
+	return ret;
+}
+
+
+int blk_vsc_initialize(struct hv_driver *driver)
+{
+	struct storvsc_driver_object *stor_driver;
+	int ret = 0;
+
+	stor_driver = (struct storvsc_driver_object *)driver;
+
+	/* Make sure we are at least 2 pages since 1 page is used for control */
+	/* ASSERT(stor_driver->RingBufferSize >= (PAGE_SIZE << 1)); */
+
+	driver->name = g_blk_driver_name;
+	memcpy(&driver->dev_type, &g_blk_device_type, sizeof(struct hv_guid));
+
+	stor_driver->request_ext_size =
+	sizeof(struct storvsc_request_extension);
+
+	/*
+	 * Divide the ring buffer data size (which is 1 page less than the ring
+	 * buffer size since that page is reserved for the ring buffer indices)
+	 * by the max request size (which is
+	 * vmbus_channel_packet_multipage_buffer + struct vstor_packet + u64)
+	 */
+	stor_driver->max_outstanding_req_per_channel =
+		((stor_driver->ring_buffer_size - PAGE_SIZE) /
+		  ALIGN(MAX_MULTIPAGE_BUFFER_PACKET +
+			   sizeof(struct vstor_packet) + sizeof(u64),
+			   sizeof(u64)));
+
+	DPRINT_INFO(BLKVSC, "max io outstd %u",
+		    stor_driver->max_outstanding_req_per_channel);
+
+	/* Setup the dispatch table */
+	stor_driver->base.dev_add = blk_vsc_on_device_add;
+	stor_driver->base.dev_rm = stor_vsc_on_device_remove;
+	stor_driver->base.cleanup = stor_vsc_on_cleanup;
+	stor_driver->on_io_request = stor_vsc_on_io_request;
+
+	return ret;
+}
+
 /* Static decl */
 static DEFINE_MUTEX(blkvsc_mutex);
 static int blkvsc_probe(struct device *dev);
-- 
1.7.4.1

  parent reply	other threads:[~2011-03-23 17:50 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-23 17:48 [PATCH 00/16] Staging: hv: Cleanup storage drivers - Phase I K. Y. Srinivasan
2011-03-23 17:50 ` [PATCH 01/16] Staging: hv: Add the inclusion guard for vstorage.h K. Y. Srinivasan
2011-03-23 17:50   ` [PATCH 02/16] Staging: hv: Move the definition of struct storvsc_request_extension K. Y. Srinivasan
2011-03-23 17:50   ` [PATCH 03/16] Staging: hv: Move the definition of struct storvsc_device K. Y. Srinivasan
2011-03-23 17:50   ` [PATCH 04/16] Staging: hv: Cleanup " K. Y. Srinivasan
2011-03-23 17:50   ` [PATCH 05/16] Staging: hv: Get rid of the include of storvsc.c from blkvsc.c K. Y. Srinivasan
2011-03-23 17:50   ` [PATCH 06/16] Staging: hv: Get rid of dead code in storvsc.c K. Y. Srinivasan
2011-03-23 17:50   ` [PATCH 07/16] Staging: hv: Move the definition of stor_vsc_initialize() K. Y. Srinivasan
2011-03-23 17:50   ` [PATCH 08/16] Staging: hv: Make the function stor_vsc_initialize() static K. Y. Srinivasan
2011-03-23 17:50   ` [PATCH 09/16] Staging: hv: Cleanup the initialization of storvsc driver K. Y. Srinivasan
2011-03-23 17:50   ` K. Y. Srinivasan [this message]
2011-03-23 17:50   ` [PATCH 11/16] Staging: hv: Get rid of the file blkvsc.c K. Y. Srinivasan
2011-03-23 17:50   ` [PATCH 12/16] Staging: hv: Cleanup initialization of blkvsc driver K. Y. Srinivasan
2011-03-23 17:50   ` [PATCH 13/16] Staging: hv: Move the definition of the function get_stor_device() K. Y. Srinivasan
2011-03-23 17:50   ` [PATCH 14/16] Staging: hv: Move the definition of the function put_stor_device() K. Y. Srinivasan
2011-03-23 17:50   ` [PATCH 15/16] Staging: hv: Move the definition of the function stor_vsc_on_host_reset() K. Y. Srinivasan
2011-03-23 17:50   ` [PATCH 16/16] Staging: hv: Make the function stor_vsc_on_host_reset() static K. Y. Srinivasan
2011-04-05  4:28   ` [PATCH 01/16] Staging: hv: Add the inclusion guard for vstorage.h Greg KH
2011-04-05  4:29     ` Greg KH

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=1300902635-1347-10-git-send-email-kys@microsoft.com \
    --to=kys@microsoft.com \
    --cc=devel@linuxdriverproject.org \
    --cc=gregkh@suse.de \
    --cc=haiyangz@microsoft.com \
    --cc=hjanssen@microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --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