When attached to a high-speed device, report a more appropriate
authorHasso Tepper <hasso@dragonflybsd.org>
Wed, 2 Jan 2008 10:43:28 +0000 (10:43 +0000)
committerHasso Tepper <hasso@dragonflybsd.org>
Wed, 2 Jan 2008 10:43:28 +0000 (10:43 +0000)
base transfer speed to CAM. The actual value used (40MB/s) is fairly
arbitrary, but assumes the same 33% overhead as was implied by the
1MB/s figure we used for USB1 devices.

Obtained-from: FreeBSD

sys/dev/usbmisc/umass/umass.c

index 7e2be47..8bc241d 100644 (file)
@@ -26,7 +26,7 @@
  *
  * $NetBSD: umass.c,v 1.28 2000/04/02 23:46:53 augustss Exp $
  * $FreeBSD: src/sys/dev/usb/umass.c,v 1.96 2003/12/19 12:19:11 sanpei Exp $
- * $DragonFly: src/sys/dev/usbmisc/umass/umass.c,v 1.32 2008/01/02 10:31:53 hasso Exp $
+ * $DragonFly: src/sys/dev/usbmisc/umass/umass.c,v 1.33 2008/01/02 10:43:28 hasso Exp $
  */
 
 /*
@@ -158,7 +158,9 @@ SYSCTL_INT(_hw_usb_umass, OID_AUTO, debug, CTLFLAG_RW,
 #define DEVNAME_SIM    "umass-sim"
 
 #define UMASS_MAX_TRANSFER_SIZE                65536
-#define UMASS_DEFAULT_TRANSFER_SPEED   1000
+/* Approximate maximum transfer speeds (assumes 33% overhead). */
+#define UMASS_FULL_TRANSFER_SPEED      1000
+#define UMASS_HIGH_TRANSFER_SPEED      40000
 #define UMASS_FLOPPY_TRANSFER_SPEED    20
 
 #define UMASS_TIMEOUT                  5000 /* msecs */
@@ -2514,9 +2516,15 @@ umass_cam_action(struct cam_sim *sim, union ccb *ccb)
                        cpi->max_lun = 0;
                } else {
                        if (sc->quirks & FLOPPY_SPEED) {
-                           cpi->base_transfer_speed = UMASS_FLOPPY_TRANSFER_SPEED;
+                               cpi->base_transfer_speed =
+                                   UMASS_FLOPPY_TRANSFER_SPEED;
+                       } else if (usbd_get_speed(sc->sc_udev) ==
+                           USB_SPEED_HIGH) {
+                               cpi->base_transfer_speed =
+                                   UMASS_HIGH_TRANSFER_SPEED;
                        } else {
-                           cpi->base_transfer_speed = UMASS_DEFAULT_TRANSFER_SPEED;
+                               cpi->base_transfer_speed =
+                                   UMASS_FULL_TRANSFER_SPEED;
                        }
                        cpi->max_lun = sc->maxlun;
                }