From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756088Ab1DDWix (ORCPT ); Mon, 4 Apr 2011 18:38:53 -0400 Received: from p3plsmtps2ded03.prod.phx3.secureserver.net ([208.109.80.60]:33621 "HELO p3plsmtps2ded03-01.prod.phx3.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1755841Ab1DDWhB (ORCPT ); Mon, 4 Apr 2011 18:37:01 -0400 From: "K. Y. Srinivasan" To: gregkh@suse.de, linux-kernel@vger.kernel.org, devel@linuxdriverproject.org, virtualization@lists.osdl.org Cc: "K. Y. Srinivasan" , Haiyang Zhang , Hank Janssen Subject: [PATCH 21/22] Staging: hv: Introduce a function to map channel properties onto block device info Date: Mon, 4 Apr 2011 15:48:10 -0700 Message-Id: <1301957291-8035-21-git-send-email-kys@microsoft.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1301957291-8035-1-git-send-email-kys@microsoft.com> References: <1301957186-7853-1-git-send-email-kys@microsoft.com> <1301957291-8035-1-git-send-email-kys@microsoft.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation for removing the IDE details from the block driver, implement a function that maps channel properties to block device information. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Hank Janssen --- drivers/staging/hv/storvsc.c | 68 ++++++++++++++++++++++++++++++++++++++ drivers/staging/hv/storvsc_api.h | 10 +++++ 2 files changed, 78 insertions(+), 0 deletions(-) diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c index d7ce393..e2b3410 100644 --- a/drivers/staging/hv/storvsc.c +++ b/drivers/staging/hv/storvsc.c @@ -17,6 +17,8 @@ * Authors: * Haiyang Zhang * Hank Janssen + * + * 4/3/2011: K. Y. Srinivasan - Significant restructuring and cleanup. */ #include #include @@ -593,6 +595,72 @@ int stor_vsc_on_io_request(struct hv_device *device, } /* + * The channel properties uniquely specify how the device is to be + * presented to the guest. Map this information for use by the block + * driver. For Linux guests on Hyper-V, we emulate a scsi HBA in the guest + * (storvsc_drv) and so scsi devices in the guest are handled by + * native upper level Linux drivers. Consequently, Hyper-V + * block driver, while being a generic block driver, presently does not + * deal with anything other than devices that would need to be presented + * to the guest as an IDE disk. + * + * This function maps the channel properties as embedded in the input + * parameter device_info onto information necessary to register the + * corresponding block device. + * + * Currently, there is no way to stop the emulation of the block device + * on the host side. And so, to prevent the native IDE drivers in Linux + * from taking over these devices (to be managedby Hyper-V block + * driver), we will take over if need be the major of the IDE controllers. + * + */ + +int stor_vsc_get_major_info(struct storvsc_device_info *device_info, + struct storvsc_major_info *major_info) +{ + static bool ide0_registered; + static bool ide1_registered; + + /* + * For now we only support IDE disks. + */ + major_info->devname = "ide"; + major_info->diskname = "hd"; + + if (device_info->path_id) { + major_info->major = 22; + if (!ide1_registered) + major_info->do_register = true; + else { + major_info->do_register = false; + ide1_registered = true; + } + if (device_info->target_id) + major_info->index = 3; + else + major_info->index = 2; + + return 0; + } else { + major_info->major = 3; + if (!ide0_registered) + major_info->do_register = true; + else { + major_info->do_register = false; + ide0_registered = true; + } + if (device_info->target_id) + major_info->index = 1; + else + major_info->index = 0; + + return 0; + } + + return -ENODEV; +} + +/* * stor_vsc_on_cleanup - Perform any cleanup when the driver is removed */ void stor_vsc_on_cleanup(struct hv_driver *driver) diff --git a/drivers/staging/hv/storvsc_api.h b/drivers/staging/hv/storvsc_api.h index f6b7cde..630710d 100644 --- a/drivers/staging/hv/storvsc_api.h +++ b/drivers/staging/hv/storvsc_api.h @@ -91,6 +91,14 @@ struct storvsc_device_info { unsigned char target_id; }; +struct storvsc_major_info { + int major; + int index; + bool do_register; + char *devname; + char *diskname; +}; + /* A storvsc device is a device object that contains a vmbus channel */ struct storvsc_device { struct hv_device *device; @@ -154,5 +162,7 @@ int stor_vsc_on_io_request(struct hv_device *device, struct hv_storvsc_request *request); void stor_vsc_on_cleanup(struct hv_driver *driver); +int stor_vsc_get_major_info(struct storvsc_device_info *device_info, + struct storvsc_major_info *major_info); #endif /* _STORVSC_API_H_ */ -- 1.7.4.1