9290838
From 3c762eeef7dc242a00552bb9b3f05e0208765f84 Mon Sep 17 00:00:00 2001
c8dfc65
From: Gerd Hoffmann <kraxel@redhat.com>
c8dfc65
Date: Tue, 28 Aug 2012 17:29:15 +0200
5544c1b
Subject: [PATCH] usb-storage: usb3 support
c8dfc65
c8dfc65
Add usb3 descriptors to usb-storage, so it shows up as superspeed
c8dfc65
device when connected to xhci.
c8dfc65
c8dfc65
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
c8dfc65
---
c8dfc65
 hw/usb/dev-storage.c | 46 +++++++++++++++++++++++++++++++++++++++++++---
c8dfc65
 1 file changed, 43 insertions(+), 3 deletions(-)
c8dfc65
c8dfc65
diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
c8dfc65
index ff48d91..e732191 100644
c8dfc65
--- a/hw/usb/dev-storage.c
c8dfc65
+++ b/hw/usb/dev-storage.c
c8dfc65
@@ -78,6 +78,7 @@ enum {
c8dfc65
     STR_SERIALNUMBER,
c8dfc65
     STR_CONFIG_FULL,
c8dfc65
     STR_CONFIG_HIGH,
c8dfc65
+    STR_CONFIG_SUPER,
c8dfc65
 };
c8dfc65
 
c8dfc65
 static const USBDescStrings desc_strings = {
c8dfc65
@@ -86,6 +87,7 @@ static const USBDescStrings desc_strings = {
c8dfc65
     [STR_SERIALNUMBER] = "1",
c8dfc65
     [STR_CONFIG_FULL]  = "Full speed config (usb 1.1)",
c8dfc65
     [STR_CONFIG_HIGH]  = "High speed config (usb 2.0)",
c8dfc65
+    [STR_CONFIG_SUPER] = "Super speed config (usb 3.0)",
c8dfc65
 };
c8dfc65
 
c8dfc65
 static const USBDescIface desc_iface_full = {
c8dfc65
@@ -158,6 +160,43 @@ static const USBDescDevice desc_device_high = {
c8dfc65
     },
c8dfc65
 };
c8dfc65
 
c8dfc65
+static const USBDescIface desc_iface_super = {
c8dfc65
+    .bInterfaceNumber              = 0,
c8dfc65
+    .bNumEndpoints                 = 2,
c8dfc65
+    .bInterfaceClass               = USB_CLASS_MASS_STORAGE,
c8dfc65
+    .bInterfaceSubClass            = 0x06, /* SCSI */
c8dfc65
+    .bInterfaceProtocol            = 0x50, /* Bulk */
c8dfc65
+    .eps = (USBDescEndpoint[]) {
c8dfc65
+        {
c8dfc65
+            .bEndpointAddress      = USB_DIR_IN | 0x01,
c8dfc65
+            .bmAttributes          = USB_ENDPOINT_XFER_BULK,
c8dfc65
+            .wMaxPacketSize        = 1024,
c8dfc65
+            .bMaxBurst             = 15,
c8dfc65
+        },{
c8dfc65
+            .bEndpointAddress      = USB_DIR_OUT | 0x02,
c8dfc65
+            .bmAttributes          = USB_ENDPOINT_XFER_BULK,
c8dfc65
+            .wMaxPacketSize        = 1024,
c8dfc65
+            .bMaxBurst             = 15,
c8dfc65
+        },
c8dfc65
+    }
c8dfc65
+};
c8dfc65
+
c8dfc65
+static const USBDescDevice desc_device_super = {
c8dfc65
+    .bcdUSB                        = 0x0300,
c8dfc65
+    .bMaxPacketSize0               = 9,
c8dfc65
+    .bNumConfigurations            = 1,
c8dfc65
+    .confs = (USBDescConfig[]) {
c8dfc65
+        {
c8dfc65
+            .bNumInterfaces        = 1,
c8dfc65
+            .bConfigurationValue   = 1,
c8dfc65
+            .iConfiguration        = STR_CONFIG_SUPER,
c8dfc65
+            .bmAttributes          = 0xc0,
c8dfc65
+            .nif = 1,
c8dfc65
+            .ifs = &desc_iface_super,
c8dfc65
+        },
c8dfc65
+    },
c8dfc65
+};
c8dfc65
+
c8dfc65
 static const USBDesc desc = {
c8dfc65
     .id = {
c8dfc65
         .idVendor          = 0x46f4, /* CRC16() of "QEMU" */
c8dfc65
@@ -167,9 +206,10 @@ static const USBDesc desc = {
c8dfc65
         .iProduct          = STR_PRODUCT,
c8dfc65
         .iSerialNumber     = STR_SERIALNUMBER,
c8dfc65
     },
c8dfc65
-    .full = &desc_device_full,
c8dfc65
-    .high = &desc_device_high,
c8dfc65
-    .str  = desc_strings,
c8dfc65
+    .full  = &desc_device_full,
c8dfc65
+    .high  = &desc_device_high,
c8dfc65
+    .super = &desc_device_super,
c8dfc65
+    .str   = desc_strings,
c8dfc65
 };
c8dfc65
 
c8dfc65
 static void usb_msd_copy_data(MSDState *s, USBPacket *p)