From patchwork Sun Oct 25 11:10:10 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadim Rozenfeld X-Patchwork-Id: 55742 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n9PBASf6004199 for ; Sun, 25 Oct 2009 11:10:28 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753273AbZJYLKW (ORCPT ); Sun, 25 Oct 2009 07:10:22 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753166AbZJYLKV (ORCPT ); Sun, 25 Oct 2009 07:10:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:9220 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752819AbZJYLKU (ORCPT ); Sun, 25 Oct 2009 07:10:20 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9PBAPcp007441 for ; Sun, 25 Oct 2009 07:10:25 -0400 Received: from localhost.localdomain (vpn-10-20.str.redhat.com [10.32.10.20]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9PBACMA021348 for ; Sun, 25 Oct 2009 07:10:13 -0400 Message-ID: <4AE43212.1040604@redhat.com> Date: Sun, 25 Oct 2009 13:10:10 +0200 From: Vadim Rozenfeld User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.4pre) Gecko/20091014 Fedora/3.0-2.8.b4.fc11 Thunderbird/3.0b4 MIME-Version: 1.0 To: kvm@vger.kernel.org Subject: [PATCH] viostor driver. Code cleanup. Getting rid of the Registry stuff. X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/viostor/virtio_stor.c b/viostor/virtio_stor.c index d528ca9..e4acaa0 100644 --- a/viostor/virtio_stor.c +++ b/viostor/virtio_stor.c @@ -19,13 +19,6 @@ ULONG RhelDbgLevel = TRACE_LEVEL_NONE; BOOLEAN IsCrashDumpMode; -UNICODE_STRING ViostorServicePathUnicode = - RTL_CONSTANT_STRING(VIOSTOR_SERVICE_NAME); - -UNICODE_STRING MaxTransferSizeUnicode = - RTL_CONSTANT_STRING(MAX_TRANSFER_SIZE); - - BOOLEAN VirtIoHwInitialize( IN PVOID DeviceExtension @@ -98,12 +91,6 @@ CompleteSRB( IN PSCSI_REQUEST_BLOCK Srb ); -BOOLEAN -GetMaxTransferSize( - IN PVOID DeviceExtension - ); - - ULONG DriverEntry( IN PVOID DriverObject, @@ -292,32 +279,16 @@ VirtIoFindAdapter( vq_sz = (sizeof(struct vring_virtqueue) + sizeof(PVOID) * pageNum); if(adaptExt->dump_mode) { - adaptExt->breaks_number = 8; - adaptExt->queue_depth = 4; + ConfigInfo->NumberOfPhysicalBreaks = 8; } else { - if(GetMaxTransferSize(DeviceExtension)) { - adaptExt->breaks_number = (adaptExt->transfer_size / 4); - if(pageNum<= (adaptExt->breaks_number * 4)) { - adaptExt->breaks_number = (pageNum / 4); - } - adaptExt->breaks_number = min(adaptExt->breaks_number, 64); - adaptExt->breaks_number = max(adaptExt->breaks_number, 1); - adaptExt->queue_depth = (pageNum / adaptExt->breaks_number) - 1; - adaptExt->queue_depth = max(adaptExt->queue_depth, 1); - } else { - adaptExt->breaks_number = (pageNum / 2); - adaptExt->breaks_number = min(adaptExt->breaks_number, 8); - adaptExt->breaks_number = max(adaptExt->breaks_number, 1); - adaptExt->queue_depth = 4; - } + ConfigInfo->NumberOfPhysicalBreaks = 16; } - ConfigInfo->NumberOfPhysicalBreaks = adaptExt->breaks_number; - ConfigInfo->MaximumTransferLength - = ConfigInfo->NumberOfPhysicalBreaks * PAGE_SIZE; + ConfigInfo->MaximumTransferLength = ConfigInfo->NumberOfPhysicalBreaks * PAGE_SIZE; + adaptExt->queue_depth = pageNum / ConfigInfo->NumberOfPhysicalBreaks - 1; RhelDbgPrint(TRACE_LEVEL_INFORMATION, ("breaks_number = %x queue_depth = %x\n", - adaptExt->breaks_number, + ConfigInfo->NumberOfPhysicalBreaks, adaptExt->queue_depth)); ptr = (ULONG_PTR)ScsiPortGetUncachedExtension(DeviceExtension, ConfigInfo, (PAGE_SIZE + vr_sz + vq_sz)); @@ -1000,67 +971,3 @@ CompleteSRB( Srb->Lun); #endif } - -BOOLEAN -GetMaxTransferSize( - IN PVOID DeviceExtension - ) -{ - - NTSTATUS status; - OBJECT_ATTRIBUTES oa; - HANDLE keyHandle; - RHEL_ULONG_VALUE_PARTIAL_INFO ulongValueInfo; - ULONG ulongValueLength; - PADAPTER_EXTENSION adaptExt; - - adaptExt = (PADAPTER_EXTENSION)DeviceExtension; - - InitializeObjectAttributes(&oa, -&ViostorServicePathUnicode, - OBJ_CASE_INSENSITIVE, - NULL, - NULL); - - status = ZwOpenKey(&keyHandle, - KEY_READ, -&oa); - - if (!NT_SUCCESS(status)) { - RhelDbgPrint(TRACE_LEVEL_ERROR, - ("ReadRegistryValues: Failed to open services key! 0x%x\n", - status)); - return FALSE; - } - - status = ZwQueryValueKey(keyHandle, -&MaxTransferSizeUnicode, - KeyValuePartialInformation, -&ulongValueInfo, - sizeof(ulongValueInfo), -&ulongValueLength); - - if (!NT_SUCCESS(status)) { - RhelDbgPrint(TRACE_LEVEL_ERROR, - ("ReadRegistryValues: Failed to query %wZ value! 0x%x\n", -&MaxTransferSizeUnicode, status)); - ZwClose(keyHandle); - return FALSE; - } - - ASSERT(ulongValueInfo.PartialInfo.Type == REG_SZ); - - switch(*ulongValueInfo.PartialInfo.Data) { - case '0' : adaptExt->transfer_size = 64; break; - case '1' : adaptExt->transfer_size = 128; break; - case '2' : adaptExt->transfer_size = 256; break; - default : adaptExt->transfer_size = 64; break; - } - - RhelDbgPrint(TRACE_LEVEL_INFORMATION, - ("%wZ set to %d\n",&MaxTransferSizeUnicode, - adaptExt->transfer_size)); - - ZwClose(keyHandle); - return TRUE; -} diff --git a/viostor/virtio_stor.h b/viostor/virtio_stor.h index 999405b..1c0dbb6 100644 --- a/viostor/virtio_stor.h +++ b/viostor/virtio_stor.h @@ -50,10 +50,6 @@ typedef struct VirtIOBufferDescriptor VIO_SG, *PVIO_SG; #define VIRTIO_MAX_SG (3+MAX_PHYS_SEGMENTS) #define IO_PORT_LENGTH 0x40 -#define VIOSTOR_SERVICE_NAME L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\Viostor\\Parameters\\MaxTransferSize" -#define MAX_TRANSFER_SIZE L"default" - - #pragma pack(1) typedef struct virtio_blk_config { /* The capacity (in 512-byte sectors). */ @@ -94,19 +90,12 @@ typedef struct virtio_blk_req { VIO_SG sg[VIRTIO_MAX_SG]; }blk_req, *pblk_req; -typedef struct _RHEL_ULONG_VALUE_PARTIAL_INFO { - KEY_VALUE_PARTIAL_INFORMATION PartialInfo; - UCHAR Buffer[8]; -}RHEL_ULONG_VALUE_PARTIAL_INFO, *PRHEL_ULONG_VALUE_PARTIAL_INFO; - typedef struct _ADAPTER_EXTENSION { ULONG_PTR device_base; virtio_pci_vq_info pci_vq_info; vring_virtqueue* virtqueue; INQUIRYDATA inquiry_data; blk_config info; - ULONG breaks_number; - ULONG transfer_size; ULONG queue_depth; BOOLEAN dump_mode; }ADAPTER_EXTENSION, *PADAPTER_EXTENSION; diff --git a/viostor/wlh.inf b/viostor/wlh.inf index 8c64191..aae425a 100644 --- a/viostor/wlh.inf +++ b/viostor/wlh.inf @@ -85,14 +85,6 @@ HKR,,TypesSupported,%REG_DWORD%,7 [pnpsafe_pci_addreg] HKR, "Parameters\PnpInterface", "5", %REG_DWORD%, 0x00000001 HKR, "Parameters", "BusType", %REG_DWORD%, 0x00000001 -;HKR, "Parameters", "MaxTransferSize", %REG_DWORD%, 0x0000040 - -HKR, "Parameters\MaxTransferSize", ParamDesc, 0, "Maximum Transfer Size" -HKR, "Parameters\MaxTransferSize", type, 0, "enum" -HKR, "Parameters\MaxTransferSize", default, 0, "0" -HKR, "Parameters\MaxTransferSize\enum", "0", 0, "64 KB" -HKR, "Parameters\MaxTransferSize\enum", "1", 0, "128 KB" -HKR, "Parameters\MaxTransferSize\enum", "2", 0, "256 KB" [Strings] ; diff --git a/viostor/wnet.inf b/viostor/wnet.inf index 8c64191..aae425a 100644 --- a/viostor/wnet.inf +++ b/viostor/wnet.inf @@ -85,14 +85,6 @@ HKR,,TypesSupported,%REG_DWORD%,7 [pnpsafe_pci_addreg] HKR, "Parameters\PnpInterface", "5", %REG_DWORD%, 0x00000001 HKR, "Parameters", "BusType", %REG_DWORD%, 0x00000001 -;HKR, "Parameters", "MaxTransferSize", %REG_DWORD%, 0x0000040 - -HKR, "Parameters\MaxTransferSize", ParamDesc, 0, "Maximum Transfer Size" -HKR, "Parameters\MaxTransferSize", type, 0, "enum" -HKR, "Parameters\MaxTransferSize", default, 0, "0" -HKR, "Parameters\MaxTransferSize\enum", "0", 0, "64 KB" -HKR, "Parameters\MaxTransferSize\enum", "1", 0, "128 KB" -HKR, "Parameters\MaxTransferSize\enum", "2", 0, "256 KB" [Strings] ;