Universal serial bus host controller and control method thereof

A USB host controller is provided. The USB host controller is capable of communicating with multiple USB apparatuses having endpoints and sends a request to a first endpoint. The USB host controller includes a first storage and a first control unit. The first control unit stores endpoint information from the first endpoint into the first storage when the first endpoint issues an unready transaction packet in response to the request. The unready transaction packet indicates that the first endpoint is not ready.

CROSS REFERENCE TO RELATED APPLICATIONS

This Application claims priority of China Patent Application No. 200910205377.X, filed on Oct. 21, 2009, the entirety of which is incorporated by reference herein.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The invention relates to an NRDY/ERDY mechanism for a universal serial bus (USB) 3.0 protocol, and more particularly to a USB host controller and a control method thereof based on a USB 3.0 protocol which can reduce the time for processing NRDY response and EDRY requests, thereby enhancing the performance of the USB host controller.

2. Description of the Related Art

Currently, there is a universal serial bus (USB) 3.0 protocol. In the USB 3.0 protocol, an NRDY (unready, or not ready)/ERDY (endpoint ready) mechanism is defined.FIG. 1shows a conventional USB host controller using a NRDY/ERDY mechanism. As shown inFIG. 1, a USB host controller100is coupled to an external system memory300and communicates with at least one USB apparatus through a USB bus (USB apparatus200). The USB apparatus200includes one or more endpoints201-1,201-2. . .201-n.

When the USB host controller100sends a request (for example, an input (IN) request or an output (OUT) request) to the one or more endpoints (for example, the endpoint201-1), if the endpoint201-1is not ready to send/receive the requested IN/OUT data, the endpoint201-1sends an NRDY response (that is, an NRDY transaction packet) to indicate that the endpoint, temporarily, has not sent/received and can not send/receive the requested IN/OUT data. When the endpoint201-1is ready to send/receive the requested IN/OUT data, the endpoint201-1sends an ERDY request (that is, an ERDY transaction packet) to the USB host controller100, so that the USB host controller100re-performs the corresponding transaction which was not performed previously.

However, one of drawbacks for the above described USB host controller is:

In the USB host controller, there is a buffer with a fixed size for temporarily storing various transaction packets from the USB apparatus. For example, inFIG. 1, an SS link Rx4header queue buffer101is disposed in the USB host controller100and is configured to temporarily store transaction packets from all of the USB apparatuses which communicate with the USB host controller. The buffer101is configured to contain four transaction packets at most. However, according to the above description, when the conventional USB host controller processes one ERDY transaction packet, a long response time is required due to a complicated process. Thus, if a multitude of USB apparatuses send ERDY transaction packets to the USB host controller at the same time, the buffer101may be in a full state, so that the USB host controller would be impeded when re-arranging transaction of respective endpoints according to received ERDY transaction packets.

Thus, it is desired to provide a USB host controller and a control method which can reduce the time required for dealing with EDRY transaction packets, thereby enhancing the performance of the USB host controller.

BRIEF SUMMARY OF THE INVENTION

The invention provides a USB host controller and a control method for the USB host controller. When the USB host controller receives an NRDY response, required storage time for the NRDY information is reduced. Moreover, when the USB host controller receives an ERDY transaction packet, the time of searching for matched NRDY information is reduced, thereby avoiding the SS link Rx4header queue buffer in a full state and enhancing the performance of the USB host controller.

In one aspect of the invention, an exemplary embodiment of a USB host controller is provided. The USB host controller is capable of communicating with multiple USB apparatuses having endpoints and sends a request to a first endpoint. The USB host controller includes a first storage and a first control unit. The first control unit stores endpoint information from the first endpoint into the first storage when the first endpoint issues an unready transaction packet in response to the request, wherein the unready transaction packet indicates that the first endpoint is not ready.

In another aspect of the invention, an exemplary embodiment of a USB host controller is provided. The USB host controller is capable of communicating with multiple USB apparatuses having endpoints and sends a request to a first endpoint. The USB host controller includes a first storage and a first control unit. The first control unit stores endpoint information from the first endpoint into the first storage when the first endpoint issues an unready transaction packet in response to the request. When the USB host controller receives a ready transaction packet from a second endpoint, the first control unit checks whether there is endpoint information in the first storage that matches the ready transaction packet. If there is a match, the first control unit sends a request to the second endpoint. The unready transaction packet indicates that the first endpoint is not ready.

In further another aspect of the invention, an exemplary embodiment of a control method for a USB host controller is provided. The USB host controller includes a first storage and is capable of communicating with multiple USB apparatuses having endpoints. The control method includes sending a request to a first endpoint and storing endpoint information from the first endpoint into the first storage when the first endpoint issues an unready transaction packet in response to the request. The unready transaction packet indicates that the first endpoint is not ready.

According to the above exemplary embodiments, the first storage is disposed on the inside of the USB host controller. The USB host controller stores endpoint information on NRDY response into the first storage instead of storing it into an external system memory, thereby reducing required storage time for the endpoint information. Afterward, when receiving an ERDY request, the USB host controller first accesses the first storage in the USB host controller to look for the matched information. If there is a match, the required time to respond to the ERDY request is reduced, the complex process of accessing the external system memory can be prevented, the possibility that the SS link Rx4header queue buffer in a full state is lowered, and the performance of the USB host controller is enhanced.

DETAILED DESCRIPTION OF THE INVENTION

FIG. 2shows an exemplary embodiment of a USB host controller. Note that the USB host controller shown inFIG. 2is one part of a USB host controller based on the USB 3.0 protocol and the xHCI protocol, which is related to the conception of the invention.

As shown inFIG. 2, a USB host controller400is coupled to an external system memory300and communicates with a USB apparatus200through a USB. The USB apparatus200includes one or more endpoints201-1,201-2. . .201-3. Note that one or more USB apparatuses may communicate with the USB host controller400, and, however,FIG. 2shows only one USB apparatus200for clarity.

The USB host controller400includes a transaction manager401, a schedule manager402, and an SS link Rx4header queue buffer403. The schedule manager402includes a periodic/asynchronous (abbreviated to async) controller4021, an NERDY controller4022, and a second buffer4023. In the embodiment, the second buffer4023is a scratchpad buffer.

The transaction manager401is configured to manage transaction related to the USB apparatus200, for example, the transaction manager401sends a request to one endpoint (for example, the endpoint201-1) of the USB apparatus200and receives responses/requests from the endpoint. The sent requests can be an input request or an output request. The received responses/requests from the endpoint may be NRDY responses or ERDY requests. Moreover, when the schedule manager402detects that an NRDY address table is completely allocated (that is, all entries in the NRDY address table are not empty), the transaction manager401responds to the commands from the schedule manager402and stops sending transactions, to the endpoints of all of the USB apparatuses communicating with the USB host controller400.

As described above, when the endpoint201-1receives an IN/OUT data request from the USB host controller400, if the endpoint201-1is busy or is not ready to send/receive the requested IN/OUT data due to certain reasons, the endpoint201-1sends an NRDY transaction packet to serve as a response to the request. The NRDY transaction packet includes NRDY information of the endpoint201-1. The NRDY information includes a slot identification (SlotID) for identifying the USB apparatus200which the endpoint201-1belongs to, a device context index (DCI) for identifying the endpoint201-1in the USB apparatus200, a device address of the USB apparatus200, a endpoint number of the endpoint201-1, and direction for indicating that the request inducing the NRDY transaction packet is an input request (reading request) or an output request (writing request).

The periodic/async controller4021sends a request, which indicates that the NRDY information of the NRDY transaction packet is to be stored into the NRDY address table, to the NERDY controller4022. The NRDY address table will be described later. Moreover, when the USB host controller400receives the NRDY transaction packet from the endpoint201-1, the USB host controller400interrupts the data transaction between the USB host controller400and the endpoint201-1. After the USB host controller400receives an ERDY transaction packet from the endpoint201-1, the USB host controller sends a request and continuously performs data transaction to the endpoint201-1. Thus, after receiving the NRDY transaction packet from the endpoint201-1, the periodic/async controller4021indicates that the NRDY response position of the endpoint201-1is to be stored or updated into the second buffer4023. In the embodiment, the NRDY response position includes information of DCI and SlotID for a derived endpoint. Thus, when the USB host controller400receives an ERDY transaction packet from the endpoint201-1, a corresponding entry (NRDY information) of the NRDY address table may be found by matching Direction, Endpoint Number, and Device Address. Then, according to the corresponding NRDY response position obtained from the SlotID and DCI of the corresponding entry, a request is sent to the derived endpoint. Note that the periodic/async controller4021inFIG. 2is a single element. In other embodiments, however, the periodic/async controller4021can be divided into a periodic controller and an async controller, and the periodic controller or the async controller can perform the above functions.

The NERDY controller4022includes a control unit40221and an NRDY address buffer40222(first buffer40222).

The NRDY address buffer40222is configured to store NRDY information; that is the endpoint information of the endpoint201-1. Specifically, an NRDY address table can be stored in the NRDY address buffer40222, and there is a plurality of entries in the NRDY address table to store the NRDY information. In the embodiment, the NRDY address table includes 32 entries, and each entry has 26 bits for storing the NRDY information retrieved from one NRDY transaction packet. A format of one entry in the NRDY address table is shown inFIG. 3. The lengths and significance of fields in the format are shown in Table 1.

TABLE 1BitsFieldsDescription4:0DCIFor identifying the endpoint in the USB apparatus.The DCI field and the SlotID field are used toaddress the data structure of the endpoint in thesecond buffer 4023 (such as the NRDY responseposition).12:5SlotIDFor identifying the USB apparatus. The SlotID fieldand the DCI field are used to address the datastructure of the endpoint in the second buffer 4023(such as the NRDY response position).19:13DeviceThe device address of the USB apparatusaddress23:20EndpointThe number of the endpoints in the USB apparatusnumber24DA direction bit indicates that the request inducing theNRDY transaction packet is an input request or anoutput request.25VA valid bit. If the V field is set to “1”, the NRDYinformation in the corresponding entry is valid; ifthe V field is set to “0”, the corresponding entry isempty.

When the NERDY controller4022receives a request to store NRDY information sent by the periodic/async controller4021, the control unit40221stores the NRDY information of the endpoint201-1into an empty entry of the NRDY address table, and sets the bit “V” to “1”. Then, the control unit40221checks whether the NRDY address table is completely allocated; that is, the control unit40221checks whether there is no empty entry in the NRDY address table. If the NRDY address table is completely allocated, the control unit40221sends a command to the transaction manager401to indicate that the transaction has stopped from being sent to all of the USB apparatuses communicating with the USB host controller400. After the transaction manager401receives the command, and stops sending transactions. On the contrary, if the NRDY address table is not completely allocated, the control unit40221can continuously process other transactions.

Each when receiving an NRDY transaction packet from the endpoint in the USB apparatus, the USB host controller performs the above process and stores the corresponding NRDY information into an entry of the NRDY address table in the NRDY address buffer40222, and a NRDY response position is stored or updated in the second buffer4023.

As described above, after one endpoint sends an NRDY transaction packet, if the endpoint is ready and is capable of sending/receiving the request IN/OUT data, the endpoint sends an ERDY request (an ERDY transaction packet) to the USB host controller400. The ERDY transaction packet includes a device address of the USB apparatus which the endpoint belongs to, an endpoint number of the endpoint, direction for indicating that the request inducing the ERDY transaction packet is an input request or an output request, and other information.

The transaction manager401receives the ERDY transaction packet and sends it to the schedule manager402. Then, the control unit40221accesses the NRDY address buffer40222. The control unit40221further compares the device address, the endpoint number, and the direction with the valid NRDY information of the corresponding fields in the NRDY address table, respectively, to confirm whether the NRDY address table has stored the NRDY information matching the ERDY transaction packet.

If there is matched NRDY information in the NRDY address table, the control unit40221reads the NRDY information and releases the corresponding entry which is storing the NRDY information. Then, the control unit40221fetches NRDY response position of an endpoint which is stored previously from the second buffer4023according to the fields “SlotID” and “DCI” in the matched entry. Thus, the transaction manager401sends requests to the derived endpoint for subsequent data transactions.

The SS link Rx4header queue buffer403is similar to the SS link Rx4header queue buffer101inFIG. 1. The SS link Rx4header queue buffer403is configured to temporarily store the requests from all the USB apparatus communicating with the USB host controller. In the embodiment, the SS link Rx4header queue buffer403is configured to contain four ERDY requests at most.

As shown inFIG. 2, an NRDY address buffer40222is disposed on the inside of the USB host controller. The USB host controller stores the NRDY information on the NRDY transaction packets from the endpoints into the NRDY address buffer instead of storing it into an external system memory, thereby reducing required storage time for the NRDY information. Afterward, when receiving an ERDY request, the USB host controller first accesses the NRDY address buffer in the USB host controller to look for the matched information. If there is a match, the required time to respond to the ERDY request is reduced, and the possibility that the SS link Rx4header queue buffer in a full state is lowered.

In the above description, the NRDY address buffer40222is disposed in the NERDY controller4022, however, the NRDY address buffer40222may be disposed in any position in the USB host controller.

In the following, the process when an NRDY transaction packet is received will be described with reference toFIG. 4.FIG. 4is a flow chart of the process.

In Step S501, after the USB host controller400sends a request to one endpoint in the USB apparatus200(the endpoint201-1), the transaction manager401receives an NRDY transaction packet from the endpoint201-1. Flow then proceeds to Step S502.

In Step S502, the periodic/async controller4021sends a request, which indicates that NRDY information on the NRDY transaction packet from the endpoint201-1is to be stored into the NRDY address table, to the NERDY controller4022. As described above, the NRDY information includes DCI, SlotID, a device address, an endpoint number, and direction. Flow then proceeds to Step S503.

In Step S503, the periodic/async controller4021indicates that the NRDY response position of the endpoint is to be stored or updated into the second buffer4023. Flow then proceeds to Step S504.

In Step S504, with response to the storing request sent from the periodic/async controller4021, the control unit40221in the NERDY controller4022stores the NRDY information on the NRDY transaction packet into one entry of the NRDY address table in the NRDY address buffer40222. The formats of the NRDY address table and the entries of the NRDY address table are described previously inFIG. 3and Table 1. Flow then proceeds to Step S505.

In Step S505, the control unit40221checks whether the NRDY address table is completely allocated. If the NRDY address table is completely allocated (no empty entry), the control unit40221sends a command to the transaction manager401to indicate that the transaction has stopped from being sent to all of the USB apparatuses communicating with the USB host controller400in Step S506. After receiving the command, the transaction manager401stops sending transactions to prevent the NRDY address table from overflowing. In this condition, the transaction manager401performs other transactions until one entry of the NRDY address table is released. Moreover, when the control unit40221determines that the NRDY address table is not completely allocated in Step S505, the transaction manager401continuously performs other transactions.

Step S505and Step S506are performed to prevent the NRDY address table from overflowing. However, if the size of the NRDY address buffer is large enough, Step S505and Step S506can be omitted. Moreover, Step S502and Step S503can be performed at the same time, or Step S503can be performed prior to Step S502.

By storing NRDY information into the NRDY address buffer40222in the USB host controller, the time required for storing the NRDY information can be greatly reduced, thereby enhancing the performance of the USB host controller.

In the following, the process when an ERDY transaction packet is received will be described with referring toFIG. 5.FIG. 5is a flow chart of the process.

In Step S601, the transaction manager401receives an ERDY transaction packet from one endpoint (the endpoint201-1) in the USB apparatus. As described above, the ERDY transaction packet includes a device address of the USB apparatus200, an endpoint number of the endpoint201-1, direction for indicating that the request inducing the ERDY transaction packet is an input request or an output request, and other information. Flow then proceeds to Step S602.

In Step S602, the control unit40221in the NERDY controller4022accesses the NRDY address buffer40222and determines whether the ERDY information on the ERDY transaction packet matches valid NRDY information in the NRDY address table. Specifically, the control unit40221compares the device address, endpoint number, and direction on the ERDY transaction packet with the valid NRDY information of the corresponding fields in the NRDY address table respectively. Then, in Step S603, the control unit40221determines whether there is NRDY information which matches with the ERDY transaction packet. Flow then proceeds to Step S603.

In Step S603, If there is no match, the determination means that the USB host controller400does not receives any NRDY response previously send from the endpoint201-1or that the USB host controller400does not previously send any request to the endpoint201-1. Thus, in Step S604, the control unit40221reports the error to the endpoint201-1, and then the process is completed. On the contrary, if there is a match, the control unit40221reads the NRDY information and releases the corresponding entry which stores the NRDY information in Step S605. In the embodiment, the control unit40221deletes the NRDY information stored in the matched entry. Then, in Step S606, the control unit40221fetches the NRDY response position which is stored previously from the second buffer4023according to the fields “SlotID” and “DCI” in the matched entry for a derived endpoint.

In Step S607, the transaction manager401sends the request to the derived endpoint for subsequent data transactions. Then, the process is completed.

During the process, requests received by the USB host controller from other endpoints are stored into the SS link Rx4header queue buffer403temporarily.

According to the embodiment, the NRDY address buffer40222is disposed on the inside of the USB host controller. When receiving an ERDY request, the USB host controller first accesses the NRDY address buffer in the USB host controller to look for the matched NRDY information. If there is a match, the time required for searching the matched NRDY information, and the complex process of accessing the external system memory can be eliminated, thereby accelerating the speed of responding to the ERDY request and avoiding the SS link Rx4header queue buffer being in a full state.

According to the embodiment, when there is a match, the response time of the USB host controller for sending request to the derived endpoint is at microsecond level which is extremely quick than that when there is a match in an external system memory (the response time is at milliseconds level).