From patchwork Thu Dec 9 12:30:26 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 74945 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A5DE1B7080 for ; Fri, 10 Dec 2010 04:10:17 +1100 (EST) Received: from localhost ([127.0.0.1]:36749 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQk0T-0006zp-Pv for incoming@patchwork.ozlabs.org; Thu, 09 Dec 2010 12:10:13 -0500 Received: from [140.186.70.92] (port=50062 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQfeR-0001di-5Q for qemu-devel@nongnu.org; Thu, 09 Dec 2010 07:31:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PQfeO-0005Ne-B5 for qemu-devel@nongnu.org; Thu, 09 Dec 2010 07:31:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33252) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PQfeO-0005NL-43 for qemu-devel@nongnu.org; Thu, 09 Dec 2010 07:31:08 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oB9CV7dN026483 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 9 Dec 2010 07:31:07 -0500 Received: from rincewind.home.kraxel.org (vpn1-4-138.ams2.redhat.com [10.36.4.138]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oB9CV1Gt007886; Thu, 9 Dec 2010 07:31:05 -0500 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 789324523E; Thu, 9 Dec 2010 13:30:29 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 9 Dec 2010 13:30:26 +0100 Message-Id: <1291897827-11424-24-git-send-email-kraxel@redhat.com> In-Reply-To: <1291897827-11424-1-git-send-email-kraxel@redhat.com> References: <1291897827-11424-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 23/24] usb storage: high speed support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add high speed support to the usb mass storage device. With this patch applied the linux kernel recognises the usb storage device as highspeed capable device and suggests to connect it to a highspeed port instead of the uhci. Tested with both uhci and (not-yet submitted) ehci. Signed-off-by: Gerd Hoffmann --- hw/usb-msd.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 46 insertions(+), 5 deletions(-) diff --git a/hw/usb-msd.c b/hw/usb-msd.c index 74e657e..7b8189f 100644 --- a/hw/usb-msd.c +++ b/hw/usb-msd.c @@ -77,15 +77,19 @@ enum { STR_MANUFACTURER = 1, STR_PRODUCT, STR_SERIALNUMBER, + STR_CONFIG_FULL, + STR_CONFIG_HIGH, }; static const USBDescStrings desc_strings = { [STR_MANUFACTURER] = "QEMU " QEMU_VERSION, [STR_PRODUCT] = "QEMU USB HARDDRIVE", [STR_SERIALNUMBER] = "1", + [STR_CONFIG_FULL] = "Full speed config (usb 1.1)", + [STR_CONFIG_HIGH] = "High speed config (usb 2.0)", }; -static const USBDescIface desc_iface0 = { +static const USBDescIface desc_iface_full = { .bInterfaceNumber = 0, .bNumEndpoints = 2, .bInterfaceClass = USB_CLASS_MASS_STORAGE, @@ -104,16 +108,51 @@ static const USBDescIface desc_iface0 = { } }; -static const USBDescDevice desc_device = { - .bcdUSB = 0x0100, +static const USBDescDevice desc_device_full = { + .bcdUSB = 0x0200, .bMaxPacketSize0 = 8, .bNumConfigurations = 1, .confs = (USBDescConfig[]) { { .bNumInterfaces = 1, .bConfigurationValue = 1, + .iConfiguration = STR_CONFIG_FULL, .bmAttributes = 0xc0, - .ifs = &desc_iface0, + .ifs = &desc_iface_full, + }, + }, +}; + +static const USBDescIface desc_iface_high = { + .bInterfaceNumber = 0, + .bNumEndpoints = 2, + .bInterfaceClass = USB_CLASS_MASS_STORAGE, + .bInterfaceSubClass = 0x06, /* SCSI */ + .bInterfaceProtocol = 0x50, /* Bulk */ + .eps = (USBDescEndpoint[]) { + { + .bEndpointAddress = USB_DIR_IN | 0x01, + .bmAttributes = USB_ENDPOINT_XFER_BULK, + .wMaxPacketSize = 512, + },{ + .bEndpointAddress = USB_DIR_OUT | 0x02, + .bmAttributes = USB_ENDPOINT_XFER_BULK, + .wMaxPacketSize = 512, + }, + } +}; + +static const USBDescDevice desc_device_high = { + .bcdUSB = 0x0200, + .bMaxPacketSize0 = 64, + .bNumConfigurations = 1, + .confs = (USBDescConfig[]) { + { + .bNumInterfaces = 1, + .bConfigurationValue = 1, + .iConfiguration = STR_CONFIG_HIGH, + .bmAttributes = 0xc0, + .ifs = &desc_iface_high, }, }, }; @@ -127,7 +166,8 @@ static const USBDesc desc = { .iProduct = STR_PRODUCT, .iSerialNumber = STR_SERIALNUMBER, }, - .full = &desc_device, + .full = &desc_device_full, + .high = &desc_device_high, .str = desc_strings, }; @@ -558,6 +598,7 @@ static struct USBDeviceInfo msd_info = { .usb_desc = &desc, .init = usb_msd_initfn, .handle_packet = usb_generic_handle_packet, + .handle_attach = usb_desc_attach, .handle_reset = usb_msd_handle_reset, .handle_control = usb_msd_handle_control, .handle_data = usb_msd_handle_data,