xref: /onnv-gate/usr/src/uts/common/io/usb/hcd/README (revision 7425:e4dbffd35ebc)
10Sstevel@tonic-gate#
20Sstevel@tonic-gate# CDDL HEADER START
30Sstevel@tonic-gate#
40Sstevel@tonic-gate# The contents of this file are subject to the terms of the
5*7425SGongtian.Zhao@Sun.COM# Common Development and Distribution License (the "License").
6*7425SGongtian.Zhao@Sun.COM# You may not use this file except in compliance with the License.
70Sstevel@tonic-gate#
80Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate# See the License for the specific language governing permissions
110Sstevel@tonic-gate# and limitations under the License.
120Sstevel@tonic-gate#
130Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate#
190Sstevel@tonic-gate# CDDL HEADER END
200Sstevel@tonic-gate#
210Sstevel@tonic-gate/*
22*7425SGongtian.Zhao@Sun.COM * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate * Use is subject to license terms.
240Sstevel@tonic-gate */
250Sstevel@tonic-gate
260Sstevel@tonic-gate
270Sstevel@tonic-gate			SOLARIS USB BANDWIDTH ANALYSIS
280Sstevel@tonic-gate
290Sstevel@tonic-gate1.Introduction
300Sstevel@tonic-gate
310Sstevel@tonic-gate  This document discuss the USB bandwidth allocation scheme, and the protocol
320Sstevel@tonic-gate  overheads used for both full and high speed host controller drivers. This
330Sstevel@tonic-gate  information is derived from the USB 2.0 specification, the "Bandwidth Analysis
340Sstevel@tonic-gate  Whitepaper" which is posted on www.usb.org, and other resources.
350Sstevel@tonic-gate
360Sstevel@tonic-gate  The target audience for this whitepaper are USB software & hardware designers
370Sstevel@tonic-gate  and engineers, and other interested people. The reader should be familiar with
380Sstevel@tonic-gate  the Universal Serial Bus Specification version 2.0, the OpenHCI Specification
390Sstevel@tonic-gate  1.0a and the Enhanced HCI Specification 1.0.
400Sstevel@tonic-gate
410Sstevel@tonic-gate2.Full speed bus
420Sstevel@tonic-gate
430Sstevel@tonic-gate  The following overheads, formulas and scheme are applicable both to full speed
440Sstevel@tonic-gate  host controllers and also to high speed hub Transaction Translators (TT),
450Sstevel@tonic-gate  which perform full/low speed transactions.
460Sstevel@tonic-gate
470Sstevel@tonic-gate  o Timing and data rate calculations
480Sstevel@tonic-gate
490Sstevel@tonic-gate    - Timing calculations
500Sstevel@tonic-gate
510Sstevel@tonic-gate      1 sec			1000 ms or 1000000000 ns
520Sstevel@tonic-gate      1 ms			1 frame
530Sstevel@tonic-gate
540Sstevel@tonic-gate    - Data rate calculations
550Sstevel@tonic-gate
560Sstevel@tonic-gate      1 ms			1500 bytes or 12000 bits (per  frame)
570Sstevel@tonic-gate      668 ns			1 byte or 8 bits
580Sstevel@tonic-gate
590Sstevel@tonic-gate      1 full speed bit time	83.54 ns
600Sstevel@tonic-gate
610Sstevel@tonic-gate  o Protocol Overheads and Bandwidth numbers
620Sstevel@tonic-gate
630Sstevel@tonic-gate    - Protocol Overheads
640Sstevel@tonic-gate
650Sstevel@tonic-gate      (Refer 5.11.3 section of USB2.0 specification & page 2 of USB Bandwidth
660Sstevel@tonic-gate       Analysis document)
670Sstevel@tonic-gate
680Sstevel@tonic-gate      Non Isochronous	  	9107 ns			14 bytes
690Sstevel@tonic-gate      Isochronous Output	6265 ns			10 bytes
700Sstevel@tonic-gate      Isochronous Input	        7268 ns			11 bytes
710Sstevel@tonic-gate      Low-speed overhead       64060 ns			97 bytes
720Sstevel@tonic-gate      Hub LS overhead*	         668 ns	 	 	 1 byte
730Sstevel@tonic-gate      SOF		        4010 ns 	 	 6 bytes
740Sstevel@tonic-gate      EOF		        2673 ns		 	 4 bytes
750Sstevel@tonic-gate
760Sstevel@tonic-gate      Host Delay*		Specific to hardware    18 bytes
770Sstevel@tonic-gate      Low-Speed clock*		Slower than Full speed	 8
780Sstevel@tonic-gate
790Sstevel@tonic-gate    - Bandwidth numbers
800Sstevel@tonic-gate
810Sstevel@tonic-gate      (Refer 7.3.5 section of OHCI specification 1.0a & page 2 of USB Bandwidth
820Sstevel@tonic-gate       Analysis document)
830Sstevel@tonic-gate
840Sstevel@tonic-gate      Maximum bandwidth available		      1500 bytes/frame
850Sstevel@tonic-gate      Maximum Non Periodic bandwidth	  	       197 bytes/frame
860Sstevel@tonic-gate      Maximum Periodic bandwidth		      1293 bytes/frame
870Sstevel@tonic-gate
880Sstevel@tonic-gate      NOTE:
890Sstevel@tonic-gate
900Sstevel@tonic-gate      1.Hub specific low speed overhead
910Sstevel@tonic-gate
920Sstevel@tonic-gate        The time provided by the Host Controller for hubs to enable Low Speed
930Sstevel@tonic-gate        ports. The minimum of 4 full speed bit time.
940Sstevel@tonic-gate
950Sstevel@tonic-gate        overhead = 2 x Hub_LS_Setup
960Sstevel@tonic-gate                 = 2 x (4 x 83.54) =  668.32 Nano seconds  = 1 byte.
970Sstevel@tonic-gate
980Sstevel@tonic-gate      2.Host delay will be specific to particular hardware. The following host
990Sstevel@tonic-gate        delay is for RIO USB OHCI host controller (Provided by Ken Ward - RIO
1000Sstevel@tonic-gate        USB hardware person). The following is just an example how to calculate
1010Sstevel@tonic-gate        "host delay" for given USB host controller implementation.
1020Sstevel@tonic-gate
1030Sstevel@tonic-gate        Ex: Assuming ED (Endpoint Descriptor)/TD's (Transfer Descriptor) are not
1040Sstevel@tonic-gate            streaming in Schizo (PCI bridge) and no cache hits for an ED or TD:
1050Sstevel@tonic-gate
1060Sstevel@tonic-gate            To read an ED or TD or data:
1070Sstevel@tonic-gate
1080Sstevel@tonic-gate            PCI_ARB_DELAY + PCI_ADDRESS + SCHIZO_RETRY
1090Sstevel@tonic-gate            PCI_ARB_DELAY + PCI_ADDRESS + SCHIZO_TRDY +
1100Sstevel@tonic-gate			DATA +  Core_overhead
1110Sstevel@tonic-gate
1120Sstevel@tonic-gate            Where,
1130Sstevel@tonic-gate
1140Sstevel@tonic-gate	    PCI_ARB_DELAY = 2000ns
1150Sstevel@tonic-gate	    PCI_ADDRESS = 30ns
1160Sstevel@tonic-gate	    SCHIZO RETRY = 60ns
1170Sstevel@tonic-gate	    SCHIZO TRDY = 60ns
1180Sstevel@tonic-gate	    DATA = 240ns (Always read 64 bytes ...)
1190Sstevel@tonic-gate	    Core Overhead =240 + 30 * (MPS/4) + 83.54 * (MPS/4) + 4 * 83.54
1200Sstevel@tonic-gate	    =  ~3400ns
1210Sstevel@tonic-gate
1220Sstevel@tonic-gate	    now multiply by 3 for ED+TD+DATA = 10200ns = ~128 bits or 16 bytes.
1230Sstevel@tonic-gate
1240Sstevel@tonic-gate	    This is probably on the optimistic side, only using 2us for the
1250Sstevel@tonic-gate	    PCI_ARB_DELAY.
1260Sstevel@tonic-gate
1270Sstevel@tonic-gate	If there is a USB cache hit, the time it takes for an ED or TD is:
1280Sstevel@tonic-gate
1290Sstevel@tonic-gate	CORE SYNC DELAY + CACHE_HIT CHECK + 30 * (MPS/4) + CORE OVERHEAD
1300Sstevel@tonic-gate
1310Sstevel@tonic-gate	240 + 30 + 120 + 1000ns ~ 1400ns , or ~ 2 bytes
1320Sstevel@tonic-gate
1330Sstevel@tonic-gate        Total Host delay will be 18 bytes.
1340Sstevel@tonic-gate
1350Sstevel@tonic-gate      3.The Low-Speed clock is eight times slower than full speed  i.e. 1/8th of
1360Sstevel@tonic-gate        the full speed.
1370Sstevel@tonic-gate
1380Sstevel@tonic-gate      4.For non-periodic transfers, reserve for at least one low-speed device
1390Sstevel@tonic-gate        transaction per frame. According to the USB Bandwidth Analysis white
1400Sstevel@tonic-gate        paper and also as per OHCI Specification 1.0a, section 7.3.5, page 123,
1410Sstevel@tonic-gate        one low-speed transaction takes  0x628h full speed bits (197 bytes),
1420Sstevel@tonic-gate        which comes to around 13% of USB frame time.
1430Sstevel@tonic-gate
1440Sstevel@tonic-gate     5. Maximum Periodic bandwidth is calculated using the following formula
1450Sstevel@tonic-gate
1460Sstevel@tonic-gate        Maximum Periodic bandwidth  = Maximum bandwidth available
1470Sstevel@tonic-gate        - SOF - EOF -  Maximum Non Periodic bandwidth.
1480Sstevel@tonic-gate
1490Sstevel@tonic-gate  o Bus Transaction Formulas
1500Sstevel@tonic-gate
1510Sstevel@tonic-gate    (Refer 5.11.3 section of USB2.0 specification)
1520Sstevel@tonic-gate
1530Sstevel@tonic-gate    - Full-Speed:
1540Sstevel@tonic-gate
1550Sstevel@tonic-gate      Protocol overhead + ((MaxPacketSize * 7) / 6 ) + Host_Delay
1560Sstevel@tonic-gate
1570Sstevel@tonic-gate    - Low-Speed:
1580Sstevel@tonic-gate
1590Sstevel@tonic-gate      Protocol overhead + Hub LS overhead +
1600Sstevel@tonic-gate		(Low-Speed clock  * ((MaxPacketSize * 7) / 6 )) + Host_Delay
1610Sstevel@tonic-gate
1620Sstevel@tonic-gate  o Periodic Schedule
1630Sstevel@tonic-gate
1640Sstevel@tonic-gate    The figure 5.5 in OHCI specification 1.0a gives you information on periodic
1650Sstevel@tonic-gate    scheduling, different polling intervals that are supported, & other details
1660Sstevel@tonic-gate    for the OHCI host controller.
1670Sstevel@tonic-gate
1680Sstevel@tonic-gate    - The host controller processes one interrupt endpoint descriptor list every
1690Sstevel@tonic-gate      frame. The lower five bits of the current frame number us  used as an
1700Sstevel@tonic-gate      index into an array of 32 interrupt endpoint descriptor lists or periodic
1710Sstevel@tonic-gate      frame lists found in the HCCA (Host controller communication area). This
1720Sstevel@tonic-gate      means each list is revisited once every 32ms. The host controller driver
1730Sstevel@tonic-gate      sets up the interrupt lists to visit any given endpoint descriptor in as
1740Sstevel@tonic-gate      many lists as necessary to provide the interrupt granularity required for
1750Sstevel@tonic-gate      that endpoint. See figure 5.5 in OHCI specification 1.0a.
1760Sstevel@tonic-gate
1770Sstevel@tonic-gate    - Isochronous endpoint descriptors are added at the end of 1ms interrupt
1780Sstevel@tonic-gate      endpoint descriptors.
1790Sstevel@tonic-gate
1800Sstevel@tonic-gate    - The host controller driver maintains an array of 32 frame bandwidth lists
1810Sstevel@tonic-gate      to save bandwidth allocated in each USB frame.
1820Sstevel@tonic-gate
1830Sstevel@tonic-gate      Please refer section 5.2.7.2 of OHCI specification 1.0a, page 61 for more
1840Sstevel@tonic-gate      details.
1850Sstevel@tonic-gate
1860Sstevel@tonic-gate  o Bandwidth Allocation Scheme
1870Sstevel@tonic-gate
1880Sstevel@tonic-gate    The OHCI host controller driver will go through the following steps to
1890Sstevel@tonic-gate    allocate bandwidth needed for  an interrupt or isochronous endpoint as
1900Sstevel@tonic-gate    follows
1910Sstevel@tonic-gate
1920Sstevel@tonic-gate    - Calculate the bandwidth required for the given endpoint using the bus
1930Sstevel@tonic-gate      transaction formula and protocol overhead calculations mentioned in
1940Sstevel@tonic-gate      previous section.
1950Sstevel@tonic-gate
1960Sstevel@tonic-gate    - Compare the bandwidth available in the least allocated frame list out of
1970Sstevel@tonic-gate      the 32 frame bandwidth lists, against the bandwidth required by this
1980Sstevel@tonic-gate      endpoint. If this exceeds the limit, then, an return error.
1990Sstevel@tonic-gate
2000Sstevel@tonic-gate    - Find out the static node to which the given endpoint needs to be linked
2010Sstevel@tonic-gate      so that it will be polled as per the required polling interval. This value
2020Sstevel@tonic-gate      varies based on polling interval and current bandwidth load on this
2030Sstevel@tonic-gate      schedule. See figure 5.5 in OHCI specification 1.0a.
2040Sstevel@tonic-gate
2050Sstevel@tonic-gate      Ex: If a polling interval is 4ms, then, the endpoint will be linked to one
2060Sstevel@tonic-gate          of the four static nodes (range 3-6) in the 4ms column of figure 5.5
2070Sstevel@tonic-gate          in OHCI specification 1.0a.
2080Sstevel@tonic-gate
2090Sstevel@tonic-gate    - Depending on the polling interval, we need to add the above calculated
2100Sstevel@tonic-gate      bandwidth to one or more frame bandwidth lists. Before adding, we need to
2110Sstevel@tonic-gate      double check the availability of bandwidth in those respective lists. If
2120Sstevel@tonic-gate      this exceeds the limit, then, return an error. Add this bandwidth to all
2130Sstevel@tonic-gate      the required frame bandwidth lists.
2140Sstevel@tonic-gate
2150Sstevel@tonic-gate      Ex: Assume a give polling interval of 4 and a static node value of 3.
2160Sstevel@tonic-gate          In this case, we need to add required bandwidth to 0,4,8,12,16,20,24,
2170Sstevel@tonic-gate          28 frame bandwidth lists.
2180Sstevel@tonic-gate
2190Sstevel@tonic-gate
2200Sstevel@tonic-gate3.High speed bus
2210Sstevel@tonic-gate
2220Sstevel@tonic-gate  o Timing and data rate calculations
2230Sstevel@tonic-gate
2240Sstevel@tonic-gate    - Timing calculations
2250Sstevel@tonic-gate
2260Sstevel@tonic-gate      1 sec			1000 ms
2270Sstevel@tonic-gate      125 us			1 uframe
2280Sstevel@tonic-gate      1 ms			1 frame or 8  uframes
2290Sstevel@tonic-gate
2300Sstevel@tonic-gate    - Data rate calculations
2310Sstevel@tonic-gate
2320Sstevel@tonic-gate      125 us			7500 bytes (per uframe)
2330Sstevel@tonic-gate      16.66 ns			1 byte or 8 bits
2340Sstevel@tonic-gate
2350Sstevel@tonic-gate      1 high speed bit time	2.083 ns
2360Sstevel@tonic-gate
2370Sstevel@tonic-gate  o Protocol Overheads and Bandwidth numbers
2380Sstevel@tonic-gate
2390Sstevel@tonic-gate    - Protocol Overheads
2400Sstevel@tonic-gate
2410Sstevel@tonic-gate      (Refer 5.11.3, 8.4.2.2 and 8.4.2.3 sections of USB2.0 specification)
2420Sstevel@tonic-gate
2430Sstevel@tonic-gate      Non Isochronous	  	917 ns			55 bytes
2440Sstevel@tonic-gate      Isochronous 		634 ns			38 bytes
2450Sstevel@tonic-gate
2460Sstevel@tonic-gate      Start split  overhead 	 67 ns		  	 4 bytes
2470Sstevel@tonic-gate      Complete split  overhead 	 67 ns		  	 4 bytes
2480Sstevel@tonic-gate
2490Sstevel@tonic-gate      SOF		  	200 ns			12 bytes
2500Sstevel@tonic-gate      EOF		       1667 ns 			70 bytes
2510Sstevel@tonic-gate
2520Sstevel@tonic-gate      Host Delay*		 Specific to hardware 	18 bytes
2530Sstevel@tonic-gate
2540Sstevel@tonic-gate    - Bandwidth numbers
2550Sstevel@tonic-gate
2560Sstevel@tonic-gate      (Refer 5.5.4 section of USB2.0 specification)
2570Sstevel@tonic-gate
2580Sstevel@tonic-gate      Maximum bandwidth available		      7500 bytes/uframe
2590Sstevel@tonic-gate      Maximum Non Periodic bandwidth*		      1500 bytes/uframe
2600Sstevel@tonic-gate      Maximum Periodic bandwidth*		      5918 bytes/uframe
2610Sstevel@tonic-gate
2620Sstevel@tonic-gate      NOTE:
2630Sstevel@tonic-gate
2640Sstevel@tonic-gate      1.Host delay will be specific to particular hardware.
2650Sstevel@tonic-gate
2660Sstevel@tonic-gate      2.As per USB 2.0 specification section 5.5.4, 20% of bus time is reserved
2670Sstevel@tonic-gate        for the non-periodic high-speed transfers, where as periodic high-speed
2680Sstevel@tonic-gate        transfers will get 80% of the bus time. In one micro-frame or 125us, we
2690Sstevel@tonic-gate        can transfer 7500 bytes or 60,000 bits. So 20% of 7500 is 1500 bytes.
2700Sstevel@tonic-gate
2710Sstevel@tonic-gate      3.Maximum Periodic bandwidth is calculated using the following formula
2720Sstevel@tonic-gate
2730Sstevel@tonic-gate        Maximum Periodic bandwidth  = Maximum bandwidth available
2740Sstevel@tonic-gate		- SOF - EOF -  Maximum Non Periodic bandwidth.
2750Sstevel@tonic-gate
2760Sstevel@tonic-gate  o Bus Transaction Formulas
2770Sstevel@tonic-gate
2780Sstevel@tonic-gate    (Refer 5.11.3 8.4.2.2 and 8.4.2.3 sections of USB2.0 specification)
2790Sstevel@tonic-gate
2800Sstevel@tonic-gate    - High-Speed (Non-Split transactions):
2810Sstevel@tonic-gate
2820Sstevel@tonic-gate      (Protocol overhead + ((MaxPacketSize * 7) / 6 ) +
2830Sstevel@tonic-gate		Host_Delay) x Number of transactions per micro-frame
2840Sstevel@tonic-gate
2850Sstevel@tonic-gate    - High-Speed (Split transaction - Device to Host):
2860Sstevel@tonic-gate
2870Sstevel@tonic-gate      Start Split transaction:
2880Sstevel@tonic-gate
2890Sstevel@tonic-gate      Protocol overhead  + Host_Delay + Start split overhead
2900Sstevel@tonic-gate
2910Sstevel@tonic-gate      Complete Split transaction:
2920Sstevel@tonic-gate
2930Sstevel@tonic-gate      Protocol overhead  + ((MaxPacketSize * 7) / 6 ) +
2940Sstevel@tonic-gate		Host_Delay + Complete split overhead
2950Sstevel@tonic-gate
2960Sstevel@tonic-gate    - High-Speed (Split transaction - Host to Device):
2970Sstevel@tonic-gate
2980Sstevel@tonic-gate      Start Split transaction:
2990Sstevel@tonic-gate
3000Sstevel@tonic-gate      Protocol overhead + ((MaxPacketSize * 7) / 6 ) +
3010Sstevel@tonic-gate		Host_Delay) + Start split overhead
3020Sstevel@tonic-gate
3030Sstevel@tonic-gate      Complete Split transaction:
3040Sstevel@tonic-gate
3050Sstevel@tonic-gate      Protocol overhead  + Host_Delay + Complete split overhead
3060Sstevel@tonic-gate
3070Sstevel@tonic-gate
3080Sstevel@tonic-gate  o Interrupt schedule or Start and Complete split masks
3090Sstevel@tonic-gate
3100Sstevel@tonic-gate    (Refer 3.6.2 & 4.12.2 sections of EHCI 1.0 specification)
3110Sstevel@tonic-gate
3120Sstevel@tonic-gate    - Interrupt schedule or Start split mask
3130Sstevel@tonic-gate
3140Sstevel@tonic-gate      This field  is used for for high, full and low speed usb device interrupt
3150Sstevel@tonic-gate      and isochronous endpoints. This will tell the host controller which micro-
3160Sstevel@tonic-gate      frame of a given usb frame to initiate a high speed interrupt and
3170Sstevel@tonic-gate      isochronous transaction. For full/low speed devices, it will tell when to
3180Sstevel@tonic-gate      initiate a "start split" transaction.
3190Sstevel@tonic-gate
3200Sstevel@tonic-gate	ehci_start_split_mask[15] = /* One byte field */
3210Sstevel@tonic-gate	/*
3220Sstevel@tonic-gate	 * For all low/full speed devices, and  for  high speed devices with
3230Sstevel@tonic-gate	 * a polling interval greater than or equal to 8us (125us).
3240Sstevel@tonic-gate	 */
3250Sstevel@tonic-gate	{0x01,	/*  00000001 */
3260Sstevel@tonic-gate	0x02,	/*  00000010 */
3270Sstevel@tonic-gate	0x04,	/*  00000100 */
3280Sstevel@tonic-gate	0x08,	/*  00001000 */
3290Sstevel@tonic-gate	0x10,	/*  00010000 */
3300Sstevel@tonic-gate	0x20,	/*  00100000 */
3310Sstevel@tonic-gate	0x40,	/*  01000000 */
3320Sstevel@tonic-gate	0x80,	/*  10000000 */
3330Sstevel@tonic-gate
3340Sstevel@tonic-gate	/* For high speed devices with a polling interval of 4us. */
3350Sstevel@tonic-gate	0x11,	/* 00010001 */
3360Sstevel@tonic-gate	0x22,	/* 00100010 */
3370Sstevel@tonic-gate	0x44,	/* 01000100 */
3380Sstevel@tonic-gate	0x88,	/* 10001000 */
3390Sstevel@tonic-gate
3400Sstevel@tonic-gate	/* For high speed devices with a polling interval of 2us. */
3410Sstevel@tonic-gate	0x55,	/* 01010101 */
3420Sstevel@tonic-gate	0xaa,	/* 10101010 */
3430Sstevel@tonic-gate
3440Sstevel@tonic-gate	/* For high speed devices with a polling interval of 1us. */
3450Sstevel@tonic-gate	0xff };	/* 11111111 */
3460Sstevel@tonic-gate
3470Sstevel@tonic-gate    - Complete split mask
3480Sstevel@tonic-gate
3490Sstevel@tonic-gate      This field is used only for full/low speed usb device interrupt and
3500Sstevel@tonic-gate      isochronous endpoints. It will tell the host controller which micro frame
3510Sstevel@tonic-gate      to initiate a "complete split" transaction. Complete split transactions
3520Sstevel@tonic-gate      can to be retried for up to 3 times. So bandwidth for complete split
3530Sstevel@tonic-gate      transaction is reserved in 3 consecutive micro frames
3540Sstevel@tonic-gate
3550Sstevel@tonic-gate	ehci_complete_split_mask[8] = /* One byte field */
3560Sstevel@tonic-gate	/* Only full/low speed devices */
3570Sstevel@tonic-gate	{0x0e,	/*  00001110 */
3580Sstevel@tonic-gate	0x1c,	/*  00011100 */
3590Sstevel@tonic-gate	0x38,	/*  00111000 */
3600Sstevel@tonic-gate	0x70,	/*  01110000 */
3610Sstevel@tonic-gate	0xe0,	/*  11100000 */
3620Sstevel@tonic-gate	Reserved ,	/*  Need FSTN feature  */
3630Sstevel@tonic-gate	Reserved ,	/*  Need FSTN feature  */
3640Sstevel@tonic-gate	Reserved};	/*  Need FSTN feature */
3650Sstevel@tonic-gate
3660Sstevel@tonic-gate  o Periodic Schedule
3670Sstevel@tonic-gate
3680Sstevel@tonic-gate    The figure 4.8 in EHCI specification gives you information on periodic
3690Sstevel@tonic-gate    scheduling, different polling intervals that are supported, and other
3700Sstevel@tonic-gate    details for the EHCI host controller.
3710Sstevel@tonic-gate
3720Sstevel@tonic-gate    - The high speed host controller can support 256, 512 or 1024 periodic frame
3730Sstevel@tonic-gate      lists. By default all host controllers will support 1024 frame lists. In
3740Sstevel@tonic-gate      our implementation, we support 1024 frame lists and we do this by first
3750Sstevel@tonic-gate      constructing 32 periodic frame lists and duplicating the same periodic
3760Sstevel@tonic-gate      frame lists for a total of 32 times. See figure 4.8 in EHCI specification.
3770Sstevel@tonic-gate
3780Sstevel@tonic-gate    - The host controller traverses the periodic schedule by constructing an
3790Sstevel@tonic-gate      array offset reference from the PERIODICLISTBASE & the FRINDEX registers.
3800Sstevel@tonic-gate      It fetches the element and begins traversing the graph of linked schedule
3810Sstevel@tonic-gate      data structure. See fig 4.8 in EHCI specification.
3820Sstevel@tonic-gate
3830Sstevel@tonic-gate    - The host controller processes one interrupt endpoint descriptor list every
3840Sstevel@tonic-gate      micro frame (125us). This means same list is revisited 8 times in a frame.
3850Sstevel@tonic-gate
3860Sstevel@tonic-gate    - The host controller driver sets up the interrupt lists to visit any given
3870Sstevel@tonic-gate      endpoint descriptor in as many lists as necessary to provide the interrupt
3880Sstevel@tonic-gate      granularity required for that endpoint.
3890Sstevel@tonic-gate
3900Sstevel@tonic-gate    - For isochronous transfers, we use only transfer descriptors but no
3910Sstevel@tonic-gate      endpoint descriptors as in OHCI. Transfer descriptors are added at the
3920Sstevel@tonic-gate      beginning of the periodic schedule.
3930Sstevel@tonic-gate
3940Sstevel@tonic-gate    - For EHCI, the bandwidth requirement is depends on the usb device speed
3950Sstevel@tonic-gate      i.e.
3960Sstevel@tonic-gate
3970Sstevel@tonic-gate      For a high speed usb device, you only need high speed bandwidth. For a
3980Sstevel@tonic-gate      full/low speed device connected through a high speed hub, you need both
3990Sstevel@tonic-gate      high speed bandwidth and TT (transaction translator) bandwidth.
4000Sstevel@tonic-gate
4010Sstevel@tonic-gate      High speed bandwidth information is saved in an EHCI data structure and TT
4020Sstevel@tonic-gate      bandwidth is saved in the high speed hub's usb device data structure. Each
4030Sstevel@tonic-gate      TT acts as a full speed host controller & its bandwidth allocation scheme
4040Sstevel@tonic-gate      overhead calculations and other details are similar to those of a full
4050Sstevel@tonic-gate      speed  host controller. Refer to the "Full speed bus" section for more
4060Sstevel@tonic-gate      details.
4070Sstevel@tonic-gate
4080Sstevel@tonic-gate    - The EHCI host controller driver maintains an array of 32 frame lists to
4090Sstevel@tonic-gate      store high speed bandwidth allocated in each  frame and also each frame
4100Sstevel@tonic-gate      list has eight micro frame lists, which saves bandwidth allocated in each
4110Sstevel@tonic-gate      micro frame of  that particular frame.
4120Sstevel@tonic-gate
4130Sstevel@tonic-gate  o Bandwidth Allocation Scheme
4140Sstevel@tonic-gate
4150Sstevel@tonic-gate    (Refer 3.6.2 & 4.12.2 sections of EHCI 1.0 specification)
4160Sstevel@tonic-gate
4170Sstevel@tonic-gate    High speed Non Split Transaction (for High speed devices only):
4180Sstevel@tonic-gate
4190Sstevel@tonic-gate    For a given high speed interrupt or isochronous endpoint, the EHCI host
4200Sstevel@tonic-gate    controller driver will go through the following steps to allocate
4210Sstevel@tonic-gate    bandwidth needed for this endpoint.
4220Sstevel@tonic-gate
4230Sstevel@tonic-gate    - Calculate the bandwidth required for given endpoint using the formula and
4240Sstevel@tonic-gate      overhead calculations mentioned in previous section.
4250Sstevel@tonic-gate
4260Sstevel@tonic-gate    - Compare the bandwidth available in the least allocated frame list out of
4270Sstevel@tonic-gate      the 32 frame lists against the bandwidth required by this endpoint. If
4280Sstevel@tonic-gate      this exceeds the limit, then, return an error.
4290Sstevel@tonic-gate
4300Sstevel@tonic-gate    - Map a given high speed endpoint's polling interval in micro seconds to an
4310Sstevel@tonic-gate      interrupt list path based on a millisecond value. For example, an endpoint
4320Sstevel@tonic-gate      with a polling interval of 16us will map to an interrupt list path of 2ms.
4330Sstevel@tonic-gate
4340Sstevel@tonic-gate    - Find out the static node to which the given endpoint needs to be linked
4350Sstevel@tonic-gate      so that it will be polled at its required polling interval. This varies
4360Sstevel@tonic-gate      based on polling interval and current bandwidth load on this schedule.
4370Sstevel@tonic-gate
4380Sstevel@tonic-gate      Ex: If a polling interval is 32us and its corresponding frame polling
4390Sstevel@tonic-gate          interval will be 4ms, then the endpoint will be linked to one of the
4400Sstevel@tonic-gate          four static nodes (range 3-6) in the 4ms column of figure 4.8 in EHCI
4410Sstevel@tonic-gate          specification.
4420Sstevel@tonic-gate
4430Sstevel@tonic-gate    - Depending on the polling interval, we need to add the above calculated
4440Sstevel@tonic-gate      bandwidth to one or more frame bandwidth lists, and also to one or more
4450Sstevel@tonic-gate      micro frame bandwidth lists for that particular frame bandwidth list.
4460Sstevel@tonic-gate      Before adding, we need to double check the availability of bandwidth in
4470Sstevel@tonic-gate      those respective lists. If needed bandwidth is not available, then,
4480Sstevel@tonic-gate      return an error. Otherwise add this bandwidth to all the required frame
4490Sstevel@tonic-gate      and micro frame lists.
4500Sstevel@tonic-gate
4510Sstevel@tonic-gate      Ex: Assume given endpoint's polling interval is 32us and static node value
4520Sstevel@tonic-gate          is 3. In this case, we need to add required bandwidth to 0,4,8,12,16,
4530Sstevel@tonic-gate          20,24,28 frame bandwidth lists and micro bandwidth information is
4540Sstevel@tonic-gate          saved using ehci_start_split_masks matrix. For this example, we need
4550Sstevel@tonic-gate          to use any one of the 15 entries to save micro frame bandwidth.
4560Sstevel@tonic-gate
4570Sstevel@tonic-gate      High speed split transactions (for full and low speed devices only):
4580Sstevel@tonic-gate
4590Sstevel@tonic-gate      For a given full/low speed interrupt or isochronous endpoint, we need both
4600Sstevel@tonic-gate      high speed and TT bandwidths. The TT bandwidth allocation is same as full
4610Sstevel@tonic-gate      speed bus bandwidth allocation. Please refer to the "full speed bus"
4620Sstevel@tonic-gate      bandwidth allocation section for more details.
4630Sstevel@tonic-gate
4640Sstevel@tonic-gate      The EHCI driver will go through the following steps to allocate high speed
4650Sstevel@tonic-gate      bandwidth needed for  this full/low speed endpoint.
4660Sstevel@tonic-gate
4670Sstevel@tonic-gate      - Calculate the bandwidth required for a given endpoint using the formula
4680Sstevel@tonic-gate        and overhead calculations mentioned in previous section. In this case,
4690Sstevel@tonic-gate        we need to calculate bandwidth needed both for Start and Complete start
4700Sstevel@tonic-gate        transactions separately.
4710Sstevel@tonic-gate
4720Sstevel@tonic-gate      - Compare the bandwidth available in the least allocated frame list out of
4730Sstevel@tonic-gate        32 frame lists against the bandwidth required by this endpoint. If this
4740Sstevel@tonic-gate        exceeds the limit, then, return an error.
4750Sstevel@tonic-gate
4760Sstevel@tonic-gate      - Find out the static node to which the given endpoint needs to be linked
4770Sstevel@tonic-gate        so that it will be polled as per the required polling interval. This
4780Sstevel@tonic-gate        value varies based on polling interval and current bandwidth load on
4790Sstevel@tonic-gate        this schedule.
4800Sstevel@tonic-gate
4810Sstevel@tonic-gate        Ex: If a polling interval is  4ms, then the endpoint will be linked to
4820Sstevel@tonic-gate            one of the four static nodes (range 3-6) in the 4ms column of figure
4830Sstevel@tonic-gate            4.8 in EHCI specification.
4840Sstevel@tonic-gate
4850Sstevel@tonic-gate      - Depending on the polling interval, we need to add the above calculated
4860Sstevel@tonic-gate        Start and Complete split transactions bandwidth to one or more frame
4870Sstevel@tonic-gate        bandwidth lists and also to one or more micro frame bandwidth lists for
4880Sstevel@tonic-gate        that particular frame bandwidth list. In this case, the Start split
4890Sstevel@tonic-gate        transaction needs bandwidth in one micro frame, where as the Complete
4900Sstevel@tonic-gate        split transaction needs bandwidth in next three subsequent micro frames
4910Sstevel@tonic-gate        of that particular frame or next frame. Before adding, we need to double
4920Sstevel@tonic-gate        check the availability of bandwidth in those respective lists. If needed
4930Sstevel@tonic-gate        bandwidth is not available, then, return an error. Otherwise add this
4940Sstevel@tonic-gate        bandwidth to all the required lists.
4950Sstevel@tonic-gate
4960Sstevel@tonic-gate        Ex: Assume give polling interval is 4ms and static node value is 3. In
4970Sstevel@tonic-gate            this case, we need to add required Start and Complete split
4980Sstevel@tonic-gate            bandwidth to the 0,4,8,12,16,20,24,28  frame bandwidth lists. The
4990Sstevel@tonic-gate            micro frame bandwidth lists is stored using ehci_start_split_mask &
5000Sstevel@tonic-gate            ehci_complete_split_mask matrices. In this case, we need to use any
5010Sstevel@tonic-gate            of the first 8 entries to save micro frame bandwidth.
5020Sstevel@tonic-gate
5030Sstevel@tonic-gate            Assume we found that the following micro frame bandwidth lists of
5040Sstevel@tonic-gate            0,4,8,12,16,20,24,28 frame lists can be used for this endpoint.
5050Sstevel@tonic-gate            It means, we need to initiate "start split transaction" in first
5060Sstevel@tonic-gate            micro frame of 0,4,8,12,16,20,24,28 frames.
5070Sstevel@tonic-gate
5080Sstevel@tonic-gate            Start split mask = 0x01,	/*  00000001 */
5090Sstevel@tonic-gate
5100Sstevel@tonic-gate            For this "start split mask",  the "complete split mask" should be
5110Sstevel@tonic-gate
5120Sstevel@tonic-gate	    Complete split mask = 0x0e, /*  00001110 */
5130Sstevel@tonic-gate
5140Sstevel@tonic-gate	    It means try "complete split transactions" in second, third or
5150Sstevel@tonic-gate            fourth micro frames of 0,4,8,12,16,20,24,28 frames.
5160Sstevel@tonic-gate
5170Sstevel@tonic-gate4.Reference
5180Sstevel@tonic-gate
5190Sstevel@tonic-gate  - USB2.0, OHCI and EHCI Specifications
5200Sstevel@tonic-gate
5210Sstevel@tonic-gate    http://www.usb.org/developers/docs
5220Sstevel@tonic-gate
5230Sstevel@tonic-gate  - USB bandwidth analysis from Intel
5240Sstevel@tonic-gate
5250Sstevel@tonic-gate    http://www.usb.org/developers/whitepapers
526