A data flow control method, PCIe controller and PCIe device
By configuring the maximum credit amount of the credit buffer according to the link delay of the sending device and periodically updating the credit limit, the buffer congestion problem caused by excessive P message data traffic in the PCIe connection is solved, and the data processing of the PCIe device is improved. performance.
Patent Information
- Application Number
- CN202080092657.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-01-15
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2040-01-15
AI Technical Summary
When the data flow of P packets in a PCIe connection is too large, the P buffer area will be congested and the processing performance of NP packets will be affected. It is difficult to effectively control the data flow with existing technology.
By configuring the maximum credit amount for the credit buffer according to the link delay of the sending device, adjusting the credit limit of the sending device, and periodically updating the credit limit to limit the number of messages sent, reduce the size of the buffer storage space and reduce congestion.
It effectively reduces the number of messages in the credit buffer area, reduces the impact on other message processing, and improves the processing performance of the PCIe device.
Smart Images

Figure CN114981789B
Abstract
Description
Technical Field
[0001] The present application relates to the field of PCIe technology, and in particular to a data flow control method, a PCIe controller and a PCIe device. Background Art
[0002] The peripheral component interface express (PCIe) interface is a widely used interface. Two PCIe devices with PCIe interfaces can be interconnected through the PCIe interface.
[0003] Generally speaking, a credit buffer area is configured in a PCIe device to coordinate the data flow transmitted between PCIe devices. Taking PCIe device A and PCIe device B interconnected through a PCIe interface as an example, the messages sent by PCIe device B to PCIe device A can be divided into non-post (NP) messages and post (P) messages. Among them, PCIe device A is respectively configured with a P buffer area for caching P messages and an NP buffer area for caching NP messages. Taking the P buffer area as an example, PCIe device A can periodically send indication information to PCIe device B based on the size of the P buffer area and the current cache status of the P buffer area to indicate the number of P messages that PCIe device B can send next, thereby realizing data flow control of P messages sent by PCIe device B.
[0004] However, when any type of data traffic sent by PCIe device B to PCIe device A is too large, it may affect the processing performance of PCIe device A for other types of messages. For example, when the data traffic of P messages is too large, the P messages may fill up the P buffer area. Since most PCIe devices A are currently configured with P buffer areas and NP buffer areas with larger storage spaces, when the data traffic of P messages is too large, there are more P messages congested in the P buffer area. Due to the PCIe order preservation requirements, in some scenarios, PCIe device A must process the P messages in the P buffer area before it can process the NP message. In view of the current solution, there will be more P messages congested in the P buffer area, which will increase the processing delay of PCIe device A for NP messages.
[0005] Therefore, the data flow control method in the current PCIe connection needs further research. Summary of the invention
[0006] The present application provides a data flow control method, a PCIe controller and a PCIe device, which are used to improve the message processing performance when congestion occurs in the credit buffer area of the PCIe controller.
[0007] In a first aspect, an embodiment of the present application provides a data flow control method, which can be applied to a PCIe device. In an embodiment of the present application, the PCIe device can be interconnected with at least one sending device through PCIe. Exemplarily, in this method, the PCIe device can configure a maximum credit corresponding to the first sending device for a first credit buffer according to the link delay corresponding to the first sending device. Among them, the first sending device can be any sending device interconnected with the PCIe device, the link delay corresponding to the first sending device can be the link delay between the above-mentioned PCIe device and the first sending device, and the first credit buffer can cache the credit buffer of the first message sent by the first sending device. In this method, the maximum credit configured for the first credit buffer is positively correlated with the link delay between the PCIe device and the first sending device. The PCIe device can then adjust the credit limit of the first sending device according to the maximum credit of the first credit buffer, and the credit limit can limit the number of first messages that the first sending device can send next.
[0008] In an embodiment of the present application, a PCIe device may include multiple credit buffers, and the multiple credit buffers may correspond to at least one sending device respectively, so that the PCIe device can transmit data with at least one sending device through PCIe interconnection. In an embodiment of the present application, the maximum credits of the multiple credit buffers may be the same or different, and the PCIe device may use the maximum credit of each credit buffer to adjust the data flow of the corresponding sending device. Taking the first credit buffer as an example, since the maximum credit of the first credit buffer is configured according to the link delay between the PCIe device and the first sending device, and the maximum credit is positively correlated with the link delay corresponding to the first sending device, if the link delay corresponding to the sending device is large, the maximum credit of the credit buffer corresponding to the sending device is large. If the link delay corresponding to the sending device is small, the maximum credit of the credit buffer corresponding to the sending device is small. The technical solution provided in the embodiment of the present application is used to reduce the storage space size for storing messages in each credit buffer. Therefore, when congestion occurs in the credit buffer, the number of congested messages in the credit buffer can be reduced, which is conducive to reducing the impact of congested messages on other messages.
[0009] Generally speaking, after the PCIe device establishes a physical connection with the first sending device and completes the handshake, it is necessary to initialize the credit limit of the first sending device first, and then adjust the credit limit of the first sending device according to the maximum credit amount of the first credit buffer after the initialization. Exemplarily, the PCIe device can send initialization indication information to the first sending device, and the initialization indication information can instruct the first sending device to configure the credit limit as the physical credit amount of the first credit buffer. The physical credit amount is obtained according to the storage space size of the first credit buffer.
[0010] After receiving the initialization indication information sent by the PCIe device, the first sending device can configure the credit limit as the physical credit amount of the first credit buffer according to the initialization indication information. Furthermore, the first sending device can send the first message to the PCIe device according to the credit limit.
[0011] In a possible implementation, when the PCIe device adjusts the credit limit of the first sending device according to the maximum credit amount of the first credit buffer, it can periodically adjust the credit limit of the first sending device. For example, the PCIe device receives the first message sent by the first sending device in a first cycle, and caches the first message to the first credit buffer, and the first cycle can be any update cycle of the credit limit; in the first cycle, the PCIe device can also obtain and process the first message from the first credit buffer in the order of reception. After the first cycle ends, the PCIe device can calculate the updated credit according to the current allocated credit CA and the first difference, wherein the current allocated credit can be obtained according to the physical credit amount of the first credit buffer and the number of the first messages currently processed, and the first difference can be obtained according to the physical credit amount of the first credit buffer minus the maximum credit amount; send first indication information to the first sending device, and the first indication information can indicate that the first sending device configures the credit limit as the updated credit.
[0012] After receiving the first indication information, the first sending device may update the current credit limit according to the first indication information. The first sending device may then determine the number of first messages that can continue to be sent in the next cycle, that is, the available credit amount, according to the updated credit limit and the current credit consumption CC of the first sending device. The current credit consumption CC of the first sending device may be obtained according to the number of first messages currently sent by the first sending device.
[0013] Specifically, the allocated credit can accumulate the number of processed first messages based on the physical credit amount; when the allocated credit reaches the maximum accumulated value, the allocated credit is reset to zero, and the number of processed messages continues to be accumulated from zero.
[0014] In view of this, when the PCIe device calculates the updated credit based on the current allocated credit CA and the first difference, if the current allocated credit is greater than the first difference, the updated credit is the difference obtained by subtracting the first difference from the allocated credit; if the current allocated credit is not greater than the first difference, the updated credit is the difference obtained by subtracting the first difference from the sum of the allocated credit and the maximum cumulative value.
[0015] After receiving the first indication information, the first sending device may update the credit limit to the updated credit indicated by the first indication information. Moreover, the first sending device may accumulate the number of first messages that have been sent through the credit consumption CC. Whenever the credit consumption CC accumulates to the maximum cumulative value, the first sending device may reset the credit consumption CC to zero and continue to accumulate from zero. When the first sending device calculates the available credit, if the current credit consumption CC is not greater than the updated credit limit, the first sending device may determine that the available credit is the difference between the updated credit limit and the credit consumption CC. If the current credit consumption CC is greater than the updated credit limit, the first sending device may determine that the available credit is the difference between the sum of the updated credit limit and the maximum cumulative value and the current credit consumption CC.
[0016] In a possible implementation, after the first cycle ends, the PCIe device may calculate the update credit according to the current allocated credit CA and the first difference after determining that the number of processed first messages is greater than the first difference.
[0017] If after the first cycle ends, the number of first messages processed by the PCIe device is not greater than the first difference, the PCIe device can send initialization indication information to the first sending device to configure the credit limit of the first sending device as the physical credit amount of the first credit buffer area through the initialization indication information.
[0018] The PCIe protocol stipulates that the credit limit of the sending device cannot be updated in a decreasing manner. By adopting the above updating method provided in the embodiment of the present application, it is possible to avoid reducing the credit limit of the first sending device, thus complying with the provisions of the PCIe protocol.
[0019] In one possible implementation, when the PCIe device configures the maximum credit amount for the first credit buffer area according to the link delay corresponding to the first sending device, it can configure the maximum credit amount for the first credit buffer area according to the link delay corresponding to the first sending device and the update period of the available credit amount, and the maximum credit amount can be positively correlated with the link delay and the update period, respectively.
[0020] In the process of data flow regulation, the storage space required in the first credit buffer is not only related to the link delay corresponding to the first sending device, but also to the update period of the credit limit of the first sending device. The above method is used to configure the maximum credit amount for the first credit buffer based on the link delay corresponding to the first sending device and the update period of the credit limit, which is conducive to reducing the size of the storage space in the first credit buffer while maintaining the reduced storage space to still meet the data flow regulation function of the first credit buffer.
[0021] For example, the maximum credit amount of the first credit buffer may satisfy the following formula:
[0022] D=(t+T)×I / L
[0023] Among them, D is the maximum credit amount of the first credit buffer area, t is the link delay corresponding to the first sending device, T is the update period of the available credit amount, I is the transmission bandwidth between the first sending device, and L is the typical message length between the first sending device.
[0024] The PCIe protocol discloses a calculation formula for the physical credit of the P buffer. The difference between this formula and the above formula is that the t used in the PCIe protocol represents the maximum value of the link delay in at least one sending device connected to the PCIe device, so that the P buffers corresponding to at least one sending device in the PCIe device have the same physical credit. On this basis, the embodiment of the present application obtains the maximum credit of the first credit buffer corresponding to the first sending device according to the above calculation. The maximum credit can be more accurately applied to the link delay corresponding to the first sending device, thereby being more conducive to maintaining the function of the first credit buffer to regulate the data flow of the first message sent by the first sending device.
[0025] In the embodiment of the present application, the PCIe device needs to configure the maximum credit amount for the first credit buffer area according to the link delay corresponding to the first sending device. In view of this, before configuring the maximum credit amount for the first credit buffer area, the PCIe device may also send a first instruction to the first sending device, and the first instruction may instruct the first sending device to feedback the corresponding first response; the PCIe device may calculate the link delay corresponding to the first sending device according to the time interval between the sending time point of the first instruction and the receiving time point of the above-mentioned first response.
[0026] Exemplarily, the first instruction may be a CFG0 instruction. After the first sending device receives the configuration message type 0 CFG0 instruction, the first sending device processes the CFG0 instruction more simply, so the first sending device responds to the CFG0 instruction more quickly, thereby obtaining a more accurate link delay through the CFG0 instruction.
[0027] In the embodiment of the present application, the first message has multiple types. For example, the first message may be a postal P message, and the first credit buffer may be a P buffer. For another example, the first message may be a non-postal NP message, and the first credit buffer may be a NP buffer.
[0028] In the second aspect, an embodiment of the present application provides a PCIe controller, which can be applied to a PCIe device. The technical effects of the corresponding scheme in the second aspect can refer to the technical effects that can be obtained by the corresponding scheme in the first aspect, and the repeated parts are not described in detail. Exemplarily, the PCIe controller provided in the embodiment of the present application may include a first credit buffer and a control circuit; wherein the first credit buffer can cache a first message sent by a first sending device, and the first sending device can be any sending device of at least one sending device interconnected with the PCIe device; the control circuit can configure a maximum credit amount for the first credit buffer according to the link delay corresponding to the first sending device, wherein the link delay corresponding to the first sending device is the link delay between the above-mentioned PCIe device and the first sending device, and the maximum credit amount of the first credit buffer can be positively correlated with the above-mentioned link delay; the control circuit can adjust the credit limit of the first sending device according to the maximum credit amount of the first credit buffer, and the credit limit can limit the number of first messages sent by the first sending device.
[0029] Generally speaking, after the PCIe device establishes a physical connection with the first sending device and completes the handshake, it is necessary to initialize the credit limit of the first sending device first, and then adjust the credit limit of the first sending device according to the maximum credit amount of the first credit buffer after the initialization. Exemplarily, the control circuit can also send initialization indication information to the first sending device, and the initialization indication information can instruct the first sending device to configure the credit limit as the physical credit amount of the first credit buffer, and the physical credit amount can be obtained according to the storage space size of the first credit buffer.
[0030] In one possible implementation, the control circuit is specifically used to: receive a first message sent by a first sending device within a first cycle, and cache the first message to the above-mentioned first credit cache area, and the first cycle can be any update cycle of the available credit amount; within the first cycle, the control circuit can also obtain and process the first message from the first credit cache area in sequence according to the order of reception; after the first cycle ends, the control circuit can calculate the updated credit based on the current allocated credit CA and the first difference, wherein the current allocated credit can be obtained based on the physical credit amount of the first credit cache area and the number of first messages currently processed, and the first difference can be obtained based on the physical credit amount of the first credit cache area minus the maximum credit amount; send a first indication message to the first sending device, and the first indication message can instruct the first sending device to configure the credit limit to update the credit.
[0031] Specifically, the allocated credit can accumulate the number of processed first messages based on the physical credit amount; when the allocated credit reaches the maximum accumulated value, the allocated credit is reset to zero, and the number of processed messages continues to be accumulated from zero.
[0032] In view of this, when the control circuit calculates the updated credit based on the current allocated credit CA and the first difference, if the current allocated credit is greater than the first difference, the updated credit is the difference obtained by subtracting the first difference from the allocated credit; if the current allocated credit is not greater than the first difference, the updated credit is the difference obtained by subtracting the first difference from the sum of the allocated credit and the maximum cumulative value.
[0033] In a possible implementation, after the first cycle ends, the control circuit may calculate the update credit according to the current allocated credit CA and the first difference after determining that the number of processed first messages is greater than the first difference.
[0034] After the first cycle ends, if the number of processed first messages is not greater than the first difference, the control circuit may send initialization indication information to the first sending device, and configure the credit limit of the first sending device to the physical credit amount of the first credit buffer area through the initialization indication information.
[0035] In one possible implementation, the control circuit may configure a maximum credit for the first credit buffer according to the link delay corresponding to the first sending device and the update period of the available credit, so that the maximum credit of the first credit buffer is positively correlated with the above-mentioned link delay and the above-mentioned update period, respectively.
[0036] Exemplarily, the maximum credit amount of the first credit buffer may satisfy the following formula:
[0037] D=(t+T)×I / L
[0038] Among them, D is the maximum credit amount of the first credit buffer area, t is the link delay corresponding to the first sending device, T is the update period of the available credit amount, I is the transmission bandwidth corresponding to the first sending device, and L is the typical message length between the first sending device.
[0039] In the embodiment of the present application, it is necessary to configure the maximum credit amount for the first credit buffer area according to the link delay corresponding to the first PCIe device. In view of this, the control circuit can also send a first instruction to the first sending device before configuring the maximum credit amount for the first credit buffer area, and the first instruction can instruct the sending device to feedback the corresponding first response; the control circuit can then calculate the link delay corresponding to the first sending device according to the time interval between the sending time point of the first instruction and the receiving time point of the first response.
[0040] Exemplarily, the first instruction may be a CFG0 instruction.
[0041] In the embodiment of the present application, the first message has multiple types. For example, the first message may be a postal P message, and the first credit buffer may be a P buffer. For another example, the first message may be a non-postal NP message, and the first credit buffer may be a NP buffer.
[0042] In a third aspect, an embodiment of the present application provides a PCIe device. The technical effects of the corresponding scheme in the third aspect can refer to the technical effects that can be obtained by the corresponding scheme in the first aspect, and the repeated parts are not described in detail. Exemplarily, the PCIe device can be a chip, a memory card, a graphics card, etc. Exemplarily, the PCIe device can include a PCIe controller as provided in any one of the second aspects above.
[0043] In a possible implementation, the PCIe device may further include a memory, and the PCIe controller may write or read data into or from the memory.
[0044] In a fourth aspect, an embodiment of the present application further provides a PCIe system, which may be an electronic device. The technical effects of the corresponding scheme in the fourth aspect may refer to the technical effects that can be obtained by the corresponding scheme in the first aspect, and the repeated parts are not described in detail. Exemplarily, the PCIe system may include multiple PCIe devices, wherein any PCIe device is interconnected with one or more other PCIe devices through a PCIe controller. Among the above multiple PCIe devices, there is at least one PCIe device that is a PCIe device as provided in the third aspect.
[0045] These and other aspects of the present application will become more clearly understood in the description of the following embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 A schematic diagram of a PCIe system architecture applicable to an embodiment of the present application;
[0047] Figure 2 A schematic diagram of a PCIe interconnect structure applicable to an embodiment of the present application;
[0048] Figure 3 A data flow control method;
[0049] Figure 4 A schematic diagram of a PCIe interconnection scenario;
[0050] Figure 5 A schematic diagram of another PCIe interconnection scenario;
[0051] Figure 6 A flow chart of a data flow control method provided in an embodiment of the present application;
[0052] Figure 7 A flow chart of a method for adjusting credit limit provided in an embodiment of the present application;
[0053] Figure 8 A schematic diagram of an application scenario provided for an embodiment of the present application. DETAILED DESCRIPTION
[0054] The embodiments of the present application will be described in detail below with reference to the accompanying drawings.
[0055] In modern electronic devices, peripheral component interface express (PCIe) is widely used as a key high-speed interconnect interface. Figure 1 The PCIe system architecture diagram applicable to the embodiment of the present application is exemplarily shown. The PCIe system can be a computer, a laptop, a smart phone, a tablet computer, etc., and the embodiment of the present application does not impose any restrictions on this. Figure 1 As shown, the PCIe system 100 generally includes a central processing unit (CPU), a root complex, a switch, an endpoint, and a bridge (PCIe-PCI bridge). In some scenarios, the root complex, the CPU, and the memory may also be integrated into the same chip, and the embodiments of the present application do not impose any restrictions on this.
[0056] Among them, the root complex can connect the CPU to the endpoint, such as Figure 1The endpoint 1 and the CPU are interconnected through the root complex. Generally speaking, the number of endpoints that can be directly connected to the root complex is limited. Therefore, a switch can also be set in the PCIe system to increase the number of endpoints in the PCIe system. Figure 1 As shown, the root complex is connected to the switch, and the switch is connected to endpoints 2 to 5 respectively, so the CPU can be interconnected with endpoints 1 to 5 respectively through the root complex and the switch. Among them, the endpoint is generally an expandable device, for example, the endpoint can be a network card, a sound card, a serial port card, a storage card, etc., and the embodiment of the present application does not impose any restrictions on this.
[0057] In addition, the PCIe system may also include a bridge. The bridge may connect the PCIe system 100 with other PCIe systems, and when the PCIe protocol supported by the other PCIe systems is the same as that supported by the PCIe system 100, the PCIe protocol supported by the other PCIe systems may be different from that supported by the PCIe system 100. Figure 1 When the PCIe systems shown are different, the bridge can also achieve compatibility between the two PCIe systems.
[0058] It should be understood that in a PCIe system, data transmission between a root complex and a switch, data transmission between a root complex and endpoint 1, data transmission between a root complex and a bridge, and data transmission between a switch and endpoints 2 to 5 respectively all follow the PCIe protocol. In order to simplify the description, the embodiments of the present application are described below with a PCIe device. Among them, a PCIe device can be a device in a PCIe system that follows the PCIe protocol for data transmission. For example, a root complex, a switch, endpoints 1 to 5, and a bridge can all be understood as a PCIe device.
[0059] A PCIe device includes a PCIe interface, which may also be referred to as a PCIe controller, and PCIe devices may be interconnected via the PCIe controller. A credit buffer is often provided in the PCIe controller of a PCIe device to regulate data flow between two PCIe devices.
[0060] by Figure 1 Taking the root complex and endpoint 1 in the example, generally speaking, the messages sent by endpoint 1 to the root complex can be divided into post messages (P) and non-post (NP). Among them, P messages do not require the root complex to feedback a response, such as write request messages are generally P messages. NP messages require the root complex to feedback a response, such as read request messages are generally NP messages.
[0061] like Figure 2As shown, a PCIe controller is provided in the root complex, and the PCIe controller includes a control circuit and a credit buffer corresponding to endpoint 1, and the credit buffer can buffer the message sent by endpoint 1. Specifically, the credit buffer corresponding to endpoint 1 includes a P buffer and an NP buffer, wherein the P buffer is used to buffer the P message sent by endpoint 1, and the NP buffer is used to buffer the NP message sent by endpoint 1. The control circuit can read and process the NP message from the NP buffer, and read and process the P message from the P buffer.
[0062] In addition, the PCIe controller can also dynamically adjust the data flow of endpoint 1 through the NP buffer and the P buffer. Specifically, the PCIe controller can adjust the data flow of endpoint 1 sending NP messages through the NP buffer, and adjust the data flow of endpoint 1 sending P messages through the P buffer.
[0063] Taking the P buffer as an example, assuming Figure 2 The depth of the P buffer shown is 2M (M is an integer greater than or equal to 1), which means that the P buffer can store up to 2M P messages. The NP buffer is the same and will not be described in detail. Figure 3 A data flow control method is exemplified. Figure 3 As shown, the root complex can dynamically adjust the data flow of the P message of endpoint 1 mainly through the following steps:
[0064] S301: The root complex sends an initialization indication message to endpoint 1, thereby initializing the credit limit of endpoint 1. Specifically, after the root complex and endpoint 1 establish a physical connection, a handshake can be performed. After the handshake is successful, the root complex can send an initialization indication message to endpoint 1. The initialization indication message can indicate credit allocation (CA). During initialization, the value of the current allocated credit CA of the root complex is generally 2M, the physical credit amount of the P buffer area, that is, the depth of the P buffer area. Generally speaking, the physical credit amount of the P buffer area is mainly determined by the storage space size of the P buffer area. Exemplarily, the physical credit amount of the P buffer area can be 2M.
[0065] S302: Endpoint 1 may configure a credit limit (CL) according to the initialization indication information, and send a P message according to the credit limit CL. Specifically, after receiving the initialization indication information, endpoint 1 may configure the credit limit CL to the allocated credit CA indicated by the initialization indication information, that is, the physical credit amount 2M of the P buffer area.
[0066] After that, endpoint 1 sends P messages to the root complex and records the number of P messages sent. After initialization, the credit limit CL of endpoint 1 is 2M. At this time, endpoint 1 can start sending P messages to the root complex and control the number of P messages it sends to not exceed 2M.
[0067] S303: After receiving the P message sent by endpoint 1, the root complex can store the P message in the P buffer area. In addition, the root complex can also read and process the P message from the P buffer area in the order in which it is received. For example, if the P message is a write request message, the root complex can write data to the memory according to the instruction of the P message (S303).
[0068] In the root complex, the allocation credit CA can accumulate the number of P messages processed by the root complex based on the physical credit of the physical P buffer area. Generally speaking, a maximum accumulation value that is unified with endpoint 1 is set in the root complex. When the allocation credit CA accumulates to the maximum accumulation value, the root complex can reset the allocation credit CA to zero and continue to accumulate the number of P messages processed from zero.
[0069] For example, the maximum cumulative value is 4M, and the allocated credit CA starts from 2M (physical credit) and accumulates the number of processed P messages. When the root complex has processed 2M P messages, the allocated credit CA accumulates to 4M. In this case, the allocated credit CA is reset to zero.
[0070] S304: The root complex sends update indication information to endpoint 1, thereby updating the credit limit CL of endpoint 1. Exemplarily, the root complex may periodically update the credit limit CL of endpoint 1, that is, periodically send update indication information to endpoint 1. Generally speaking, the update indication information may indicate to endpoint 1 the current allocated credit CA of the root complex.
[0071] S305: Endpoint 1 updates the credit limit CL according to the update indication information. Specifically, endpoint 1 may update the credit limit to the allocated credit CA indicated in the update indication information. Generally speaking, in the process of sending P messages, endpoint 1 may also record the number of P messages sent, and the number of P messages sent may also be represented by credit consumption (credit consumption, CC). Endpoint 1 may also reset the credit consumption CC to zero and start accumulation from zero again after the credit consumption CC reaches the above maximum cumulative value.
[0072] After updating the credit limit CL, endpoint 1 can calculate the number of P messages that can be sent next, that is, the available credit, according to the updated credit limit CL and the current credit consumption CC. Exemplarily, when endpoint 1 updates the credit limit CL according to the update indication information, there are at least the following two possibilities:
[0073] Possibility 1: If the updated credit limit CL is not less than the current credit consumption CC, endpoint 1 can determine that the available credit is the difference between the credit limit CL and the current credit consumption CC. For example, if the updated credit limit is 2M and the current credit consumption CC is 1.5M, endpoint 1 can determine that the available credit is 0.5M.
[0074] Possibility 2: If the updated credit limit CL is less than the current credit consumption CC, endpoint 1 can determine that the available credit is the sum of the credit limit CL and the above maximum cumulative value minus the difference between the current credit consumption CC. For example, if the maximum cumulative value is 3M, the updated credit limit is 0.5M, and the current credit consumption CC is 1.5M, endpoint 1 can determine that the available credit is 2M.
[0075] Then, endpoint 1 may continue to execute S302 to send P messages, and the number of P messages to be sent should not exceed the available credit amount.
[0076] The root complex and endpoint 1 execute S302 to S304 cyclically, thereby realizing dynamic adjustment of the data flow of the P message sent by endpoint 1. The dynamic adjustment of the data flow between other interconnected PCIe devices is similar to Figure 3 The process shown is the same and will not be described in detail.
[0077] pass Figure 1 It can be seen from the PCIe system architecture shown that a PCIe device can often be connected to one or more other PCIe devices. For ease of description, the embodiment of the present application uses a sending device to represent a PCIe device that sends data. It should be understood that the sending device in the embodiment of the present application is relative. For example, endpoint 1 can be a sending device of the root complex, that is, endpoint 1 can send data to the root complex, and the root complex can also be a sending device of endpoint 1, that is, the root complex can also send data to endpoint 1.
[0078] As PCIe application scenarios become more complex, the connection methods between PCIe devices and sending devices have also become more diverse. For example, a PCIe device can be connected to one or more sending devices. For another example, a PCIe device can be directly connected to any sending device, or can be indirectly connected through a forwarding device (such as a retimer). For another example, a PCIe device can be physically connected to any sending device in a shorter or longer manner. The above factors lead to many uncertainties in the link delay between the PCIe device and the sending device.
[0079] Taking the root complex as an example, the root complex can be interconnected with at least one sending device, and the root complex can include multiple credit buffers, which can correspond to the multiple sending devices respectively. Exemplarily, it is assumed that the root complex can be interconnected with N sending devices, and N is greater than or equal to 1. There are at least 2N credit buffers in the root complex, and each sending device can correspond to two of the credit buffers, of which one is a P buffer and the other is an NP buffer.
[0080] Another example Figure 5 As shown, the root complex includes a P buffer area RC1 corresponding to endpoint 1. Retimers retimer1 and retimer2 are set between the root complex and endpoint 1. Endpoint 1 can send a P message to retimer2, and retimer2 forwards the P message received from endpoint 1 to retimer1, and retimer1 then forwards the P message received from retimer2 to the root complex. After the root complex receives the P message forwarded by retimer1, it stores the P message in the P buffer area RC1 corresponding to endpoint 1. Although the signal jitter of the P message can be reduced after forwarding by retimer1 and retimer2, the link delay between endpoint 1 and the root complex is greatly prolonged.
[0081] Another example Figure 6 As shown, the root complex also includes a P buffer area RC2 corresponding to the switch. The root complex and the switch are connected through retimer3. The switch includes a P buffer area S2 corresponding to endpoint 2 and a P buffer area S3 corresponding to endpoint 3. The switch is connected to endpoint 2 and endpoint 3 respectively through retimer4. Taking endpoint 2 sending a P message to the root complex as an example, endpoint 2 can send the P message to retimer4, and retimer4 can forward the P message received from endpoint 2 to the switch. The switch can store the P message forwarded by retimer4 from endpoint 2 into P buffer area S2. The switch obtains P messages from P buffer area S2 in sequence according to the order in which the P messages are received and sends the P messages to retimer3. Retimer3 can then forward the P message received from the switch to the root complex. The root complex can store the P message received from retimer3 into P buffer area RC2. Among them, retimer3 increases the delay between the switch and the root complex, and retimer4 increases the delay between endpoint 2 and endpoint 3 and the switch respectively.
[0082] Generally speaking, the greater the link delay between the PCIe device and the sending device, the greater the depth of the credit buffer corresponding to the sending device in the PCIe device. Currently, in order to make the PCIe device compatible with different link delay scenarios, the credit buffer in the PCIe device is often configured with a larger physical credit amount, that is, a larger depth. For example Figure 1 For the root complex in FIG, assuming that the link delay between endpoint 1 and the root complex is the largest, the physical credit amount of each credit buffer in the root complex can be configured according to the link delay between endpoint 1 and the root complex.
[0083] However, although the data flow of the sending device can be adjusted through the credit buffer, congestion may still occur in the credit buffer. In particular, when the link delay between the PCIe device and the sending device is small, the credit buffer corresponding to the sending device in the PCIe device is more likely to be congested, which in turn affects the processing performance of other messages.
[0084] Taking P messages as an example, when congestion occurs in the P buffer, the P buffer will be full of P messages. Since the physical credit of the P buffer is currently large, when congestion occurs in the P buffer, a large number of P messages will be congested in the P buffer. Since the PCIe controller in the PCIe device needs to process the received messages in order, that is, process the messages in the order in which they are received, when the P buffer is congested, the NP messages stored in the NP buffer will be affected.
[0085] For example, endpoint 1 sends 2M+1 messages in sequence: P1 to P2M, NP1. Among them, P messages P1 to P2M are congested in the P cache area RC1 of the root complex, and NP message NP1 is cached in the NP cache area RC1 of the root complex ( Figure 4 (not shown in the figure). The root complex needs to process P1 to P2M in the P cache area RC1 before it can continue to process the NP message NP1 in the NP cache area RC1. Therefore, the processing delay of the NP message NP1 increases, and the processing performance of the root complex for the NP message is greatly affected.
[0086] In view of this, an embodiment of the present application provides a data flow control method, whereby a PCIe device can configure a maximum credit amount for a credit buffer area corresponding to each sending device in the PCIe device according to the link delay corresponding to each sending device, and adjust the credit limit CL of the sending device by the maximum credit amount. In the embodiment of the present application, the maximum credit amount of the credit buffer area is not greater than the physical credit amount of the credit buffer area, so the embodiment of the present application is conducive to reducing the number of messages cached when the credit buffer area is sending congested, thereby helping to reduce the impact on other messages.
[0087] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0088] In order to make the purpose, technical solution and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The specific operating method in the method embodiment can also be applied to the device embodiment or the system embodiment. It should be noted that in the description of the present application, "at least one" refers to one or more, wherein multiple refers to two or more. In view of this, "multiple" can also be understood as "at least two" in the embodiment of the present invention. "And / or" describes the association relationship of the associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / ", unless otherwise specified, generally indicates that the related objects before and after are in an "or" relationship. In addition, it should be understood that in the description of the present application, words such as "first" and "second" are only used to distinguish the purpose of description, and cannot be understood as indicating or implying relative importance, nor can they be understood as indicating or implying order.
[0089] Figure 6 The following is a flow chart of a data flow control method provided in an embodiment of the present application. The method can be applied to a PCIe device or a PCIe controller of a PCIe device to adjust the data flow of any sending device connected to the PCIe device. For ease of explanation, in the embodiment of the present application, PCIe device 1 represents the PCIe device that executes the method, and PCIe device 2 represents any sending device of PCIe device 1. Figure 6 As shown, it mainly includes the following steps:
[0090] S601: According to the link delay corresponding to the PCIe device 2, configure a maximum credit amount for the first credit buffer.
[0091] The link delay corresponding to the PCIe device 2 can be understood as the link delay between the PCIe device 1 and the PCIe device 2, and the first credit buffer area can be understood as a credit buffer area for caching the first message sent by the PCIe device 2. In the embodiment of the present application, the first message can be a P message, and the first credit buffer area can be a P buffer area corresponding to the PCIe device 2. The first message can also be an NP message, and the first credit buffer area can also be an NP buffer area corresponding to the PCIe device 2.
[0092] For ease of description, the embodiments of the present application are described below using P messages and P buffer areas as examples. The same is true for NP messages and NP buffer areas, which will not be described in detail.
[0093] In the embodiment of the present application, the maximum credit amount of the P buffer area is positively correlated with the link delay corresponding to the PCIe device 2. That is, the greater the link delay corresponding to the PCIe device 2, the greater the maximum credit amount of the P buffer area, and the smaller the link delay corresponding to the PCIe device 2, the smaller the maximum credit amount of the P buffer area.
[0094] Exemplarily, before executing S601, PCIe device 1 may also send a first instruction to PCIe device 2. The type of the first instruction may be an NP message. After receiving the first instruction, PCIe device 2 needs to feed back a first response corresponding to the first instruction to PCIe device 1. PCIe device 1 receives the first response, and then can calculate the link delay corresponding to PCIe device 2 according to the time point of sending the first instruction and the time interval between the time point of receiving the first response. With this implementation, no matter what kind of physical connection is used between PCIe device 2 and PCIe device 1, PCIe device 1 can obtain the link delay corresponding to PCIe device 2 more accurately.
[0095] In a possible implementation, the first instruction may be a configuration message type (CFG0) instruction. The CFG0 instruction is a relatively simple instruction. After receiving the CFG0 instruction, the PCIe device 2 can immediately feed back a response corresponding to the CFG0 instruction to the PCIe device 1 without performing a complicated processing process. Therefore, using the CFG0 instruction to measure the link delay corresponding to the PCIe device 2 can reduce the error caused by the processing process of the PCIe device 2, which is conducive to further improving the accuracy of the link delay obtained by the PCIe device 1.
[0096] It can be understood that although the endpoint cannot send the CFG0 instruction, the endpoint can obtain the link delay between it and other sending devices by sending other types of NP messages, which will not be described in detail in the embodiments of the present application.
[0097] by Figure 4 For example, assume that PCIe device 1 is the root complex and PCIe device 2 is endpoint 1. Then, the root complex can send a CFG0 instruction to retimer1. After retimer1 receives the CFG0 instruction sent by the root complex, it can forward the CFG0 instruction to retimer2. Retimer2 then forwards the CFG0 instruction to endpoint 1. After receiving the CFG0 instruction, endpoint 1 sends a response corresponding to the CFG0 instruction to retimer2. The response corresponding to the CFG0 instruction is forwarded to the root complex via retimer2 and retimer1, and the root complex can then calculate the link delay between it and endpoint 1.
[0098] It can be understood that when the PCIe device 1 and the PCIe device 2 are just physically connected, the PCIe device 1 is generally unable to determine the link delay corresponding to the PCIe device 2. In view of this, in a possible implementation, the PCIe device 1 can first initialize the credit limit CL of the PCIe device 2, that is, execute S301. After that, the PCIe device 1 can obtain the link delay corresponding to the PCIe device 2 through the first instruction. Furthermore, the PCIe device 1 can obtain the maximum credit amount of the P buffer area according to the link delay corresponding to the PCIe device 2, so that the credit limit CL of the PCIe device 2 can be adjusted according to the maximum credit amount of the P buffer area (the first credit buffer area).
[0099] It is understandable that PCIe device 1 may also use other methods to obtain the link delay corresponding to PCIe device 2. For example, when PCIe device 2 has obtained the link delay between itself and PCIe device 1, PCIe device 2 may also send the link delay to PCIe device 1. This embodiment of the application will not list them one by one.
[0100] like Figure 3 As shown, PCIe device 1 (root complex) can periodically update the credit limit CL of PCIe device 2 (endpoint 1). In view of this, in a possible implementation of the embodiment of the present application, PCIe device 1 can also configure a maximum credit amount for the P buffer area according to the link delay corresponding to PCIe device 2 and the update period of the credit limit CL, and the maximum credit amount is positively correlated with the link delay corresponding to PCIe device 2 and the update period of the credit limit CL.
[0101] In the process of data flow regulation, the size of the storage space required in the P buffer area is not only related to the link delay corresponding to the PCIe device 2, but also to the update period of the credit limit CL of the PCIe device 2. The embodiment of the present application reduces the size of the available storage space in the credit buffer area by using the maximum credit amount to regulate the data flow of the sending device. By adopting the above method, the maximum credit amount is configured for the P buffer area based on the link delay corresponding to the PCIe device 2 and the update period of the credit limit CL, which is conducive to reducing the size of the available storage space in the P buffer area while maintaining the reduced available storage space to still meet the data flow regulation function of the P buffer area.
[0102] For example, the maximum credit amount of the P buffer area may satisfy the following formula 1:
[0103] D=(t+T)×I / L(Formula 1)
[0104] Among them, D is the maximum credit amount of the P buffer area, t is the link delay corresponding to PCIe device 2, T is the update period of the credit limit CL, I is the transmission bandwidth between PCIe device 1 and PCIe device 2, and L is the typical message length between PCIe and PCIe device 2.
[0105] It can be understood that the PCIe protocol discloses a calculation formula for the physical credit of the P buffer area. The difference between this formula and formula 1 is that the t used in the PCIe protocol represents the maximum value of the link delay among the multiple sending devices connected to the PCIe device 1. In the PCIe device 1, the P buffer areas corresponding to the multiple sending devices respectively have the same physical credit. On this basis, the embodiment of the present application further defines the maximum credit. In a possible implementation, the multiple P buffer areas corresponding to the multiple sending devices in the PCIe device 1 can have the same physical credit, and the same or different maximum credits.
[0106] The maximum credit amount of the P buffer area corresponding to PCIe device 2 is calculated according to formula 1, and the maximum credit amount can be more accurately applied to the link delay corresponding to PCIe device 2, thereby facilitating maintaining the function of the P buffer area to regulate the data flow of the P message sent by PCIe device 2.
[0107] S602: According to the maximum credit amount of the first credit buffer, adjust the credit limit CL of the PCIe device 2. The credit limit CL can limit the number of P messages sent by the PCIe device 2.
[0108] Since the credit limit CL limits the number of P messages that the PCIe device 2 can send, the data flow of the P messages sent by the PCIe device 2 is not likely to be too large, that is, the function of regulating the data flow of the P messages sent by the PCIe device 2 is realized.
[0109] Next, a specific example is used to illustrate that the PCIe device 1 adjusts the credit limit CL of the PCIe device 2 . Figure 7 The following is a flow chart of a method for adjusting the credit limit CL provided in an embodiment of the present application. Figure 7 As shown, it mainly includes the following steps:
[0110] S701: PCIe device 1 sends initialization instruction information to PCIe device 2.
[0111] Exemplarily, after the PCIe device 1 establishes a physical connection with the PCIe device 2 and completes the handshake, the PCIe device 1 may send initialization information to the PCIe device 2, and the initialization information may respectively initialize the P buffer area and the NP buffer area in the PCIe device 2. Taking the P buffer area as an example, the value of the allocated credit CA in the initialization indication information may be the physical credit amount of the P buffer area, for example, the allocated credit CA may be 2M.
[0112] Since the credit limit CL of the NP buffer area has been initialized after S701 (the first instruction is an NP message), the PCIe device 1 can send the first instruction to the PCIe device 2 to determine the link delay between it and the PCIe device 2. The PCIe device 1 can then configure the maximum credit for the P buffer area corresponding to the PCIe device 2 according to the link delay corresponding to the PCIe device 2. The specific implementation of this process can refer to the above embodiment, which will not be repeated here.
[0113] S702: PCIe device 2 may configure credit limit CL as the physical credit of P buffer area according to initialization indication information. Specifically, PCIe device 2 may configure CL as the allocated credit CA indicated by initialization indication information, that is, the physical credit of P buffer area, for example, 2M.
[0114] S703: After configuring the credit limit CL to 2M, the PCIe device 2 can send a P message to the PICe device 1.
[0115] S704: After receiving the PC to P message, the PCIe device 1 may cache the P message to the P buffer area corresponding to the PCIe device 2. Furthermore, the PCIe device 1 reads and processes the P message from the P buffer area in sequence according to the order in which the P message is received. Generally speaking, the P message may be a write request message, so the processing of the P message by the PCIe device 1 mainly includes writing data into the storage space.
[0116] It should be noted that, depending on the specific implementation of the PCIe device 1, the storage space may be a storage space inside the PCIe device 1 or a storage space outside the PCIe device 1. For example, if the PCIe device 1 is a root complex, the storage space may be Figure 1 If the PCIe device 1 is any endpoint, the storage space may be the storage space inside the endpoint.
[0117] If PCIe device 1 is a switch, then when PCIe device 2 is a root complex, the storage space may be a P buffer area inside any endpoint of endpoints 2 to 5, that is, the switch forwards the P message sent by the root complex to any endpoint of endpoints 2 to 5. If PCIe device 2 is any endpoint of endpoints 2 to 5, the storage space may be a P buffer area in the root complex, that is, the switch forwards the P message sent by any endpoint of endpoints 2 to 5 to the root complex.
[0118] It can be seen that the embodiments of the present application can be applied to a variety of scenarios, and examples will not be given one by one.
[0119] When the current time point reaches the first update time point after initialization, that is, when the time interval between the current time point and the time point of sending the initialization indication information for the first time is the period duration of the update period of the credit limit CL, the PCIe device 1 can update the credit limit of the PCIe device 2 in at least the following two ways:
[0120] Method 1 for updating the credit limit of PCIe device 2:
[0121] When the current time point reaches the first update time point after initialization, the PCIe device 1 may have only processed a small number of P messages, that is, the number of P messages processed by the PCIe device 1 at this time may not have reached the first difference (the difference between the physical credit amount of the P cache area and the maximum credit amount).
[0122] In order to comply with the provisions of the PCIe protocol, in a possible implementation, the PCIe device 1 may further continue to execute S705: if the number of processed P messages is greater than the first difference, then continue to execute S706 and send the first indication information to the PCIe device 2. The allocated credit CA indicated by the first indication information may be obtained according to the above method 1. If the number of processed P messages is not greater than the first difference, then return to S701 and continue to send the initialization indication information to the PCIe device 2.
[0123] Next, the following situations are explained:
[0124] Case 1: If the number of processed P messages is not greater than the first difference, return to S701 and continue to send initialization indication information to PCIe device 2. After receiving the initialization indication information, PCIe device 2 can configure the credit limit CL as the physical credit amount of the P buffer area according to the initialization indication information, that is, 2M. Assuming that PCIe device 2 has currently sent 2 P messages, that is, the credit consumption CC is 2, PCIe device 2 can determine that the available credit amount is 2M-2.
[0125] It can be understood that when S705 is executed again next time, the number of P messages processed by PCIe device 1 may still be less than the first difference, and PCIe device 1 needs to execute S701 again to send initialization indication information to PCIe device 2. That is to say, as time goes by, PCIe device 1 may send initialization indication information to PCIe device 2 multiple times. Since the allocated credit CA indicated by each initialization indication information is 2M, the credit limit CL after each update is also 2M. However, the credit consumption CC of PCIe device 2 will gradually increase as time goes by. Since the credit limit CL is always maintained at 2M, the available credit of PCIe device 2 will gradually decrease. For example, after multiple update cycles, the credit limit CL of PCIe device 2 is still 2M, but at this time the credit consumption of PCIe device 2 is 0.5M, and PCIe device 2 can determine that the available credit is 1.5M.
[0126] Case 2: As the number of P messages processed by PCIe device 1 gradually increases, the number of P messages processed will gradually increase to be greater than the first difference. In this case, PCIe device 1 can stop sending initialization indication information to PCIe device 2 and execute S706 to send the first indication information to PCIe device 2.
[0127] For example, the first difference is 0.5 M. After multiple update cycles of the PCIe device 1, the PCIe device 1 has processed a total of 0.5 M+3 P messages since the first execution of S701. In this case, the PCIe device 1 may execute S706.
[0128] Specifically, the PCIe device 1 can calculate the updated credit according to the current allocated credit CA and the first difference, and instruct the PCIe device 2 to configure the credit limit CL as the updated credit through the first indication information. In the embodiment of the present application, when the PCIe device 1 calculates the updated credit, there are at least the following two situations:
[0129] Case 1: The current allocated credit CA is greater than the first difference. In this case, the PCIe device 1 can use the difference obtained by subtracting the first difference from the current allocated credit CA as the updated credit. For example, if the current allocated credit CA is 2M+0.5M+3 and the first difference is 0.5M, the PCIe device 1 can determine that the updated credit is 2M+3.
[0130] Case 2: The current allocated credit CA is not greater than the first difference. In this case, the PCIe device 1 can use the difference between the current allocated credit CA and the maximum cumulative value minus the first difference as the update credit. Specifically, the current allocated credit CA is not greater than the first difference, which often means that the current allocated credit CA has been reset to zero. Therefore, the difference between the allocated credit CA and the maximum cumulative value minus the first difference can be used as the update credit. For example, the current allocated credit CA is 0.3M, the maximum cumulative value is 4M, and the first difference is 0.5M. The PCIe device 1 can determine that the update credit is 3.8M.
[0131] S707: The PCIe device 2 updates the credit limit CL according to the first indication information.
[0132] Specifically, the PCIe device 2 may update the value of CL to the allocated credit CA indicated by the first indication information. The updating method of the PCIe device 2 may refer to S305, which will not be described in detail.
[0133] By adopting the above method, the update process of PCIe device 2 can comply with the provisions of PCIe protocol. At the same time, the available credit of PCIe device 2 is limited within the maximum credit of P buffer. For example, the number of P messages processed by PCIe device 1 is 0.5M+3, PCIe device 1 can update the credit limit of PCIe device 2 to 2M+3 through the first indication information. At this time, the credit consumption CC of PCIe device 2 is 0.5M+3 (it may also be greater than 0.5M+3), then PCIe device 2 can determine that the available credit is 1.5M.
[0134] After updating the first indication information, the PCIe device 2 can continue to send P messages according to the updated credit limit CL, that is, return to and execute S703. In the process of executing S703 again, the number of P messages sent by the PCIe device 2 cannot exceed 1.5M.
[0135] Method 2 for updating the credit limit of PCIe device 2:
[0136] When the current time point reaches the first update time point after initialization, that is, when the time interval between the current time point and the time point of sending the initialization indication information for the first time is the period length of the update period of the credit limit CL, the PCIe device 1 may also directly point to S706 to send the first indication information to the PCIe device 2. The specific implementation method may be the above-mentioned method 1, which will not be described in detail.
[0137] The method provided by the embodiment of the present application is beneficial to reducing the impact on NP messages when congestion occurs in the P cache area. For example, if the data flow of PCIe device 2 is adjusted according to the physical credit of the P cache area, PCIe device 2 continuously sends P1 to P2M, and NP1, wherein P1 to P2M is congested in the P cache area of PCIe device 1, then the processing of NP1 by PCIe device 1 will be delayed. If the technical solution provided by the embodiment of the present application is adopted, PCIe device 2 can continue to send NP1 after sending P1 to P1.5M. Even if P1 to P1.5M are sent in the P cache area, there are 1.5M caches in the P cache area at this time, and the number of P messages is greatly reduced, which is beneficial to shorten the processing delay of NP1.
[0138] It can be understood that the method provided in the embodiment of the present application can be applied to any PCIe device in a PCIe system. Figure 8 As shown, the root complex in the PCIe system includes a physical credit of 2M for the P cache area RC2 corresponding to the switch. Using the method provided in the embodiment of the present application, the maximum credit corresponding to the P cache area RC2 is 1.5M, which reduces the storage space used to cache P messages in the P cache area RC2.
[0139] Another example Figure 8 The switch includes a P buffer area S2 corresponding to endpoint 2 and a P buffer area S3 corresponding to endpoint 3. The physical credits of the P buffer area S2 and the P buffer area S3 are both 2M. Using the method provided in the embodiment of the present application, the maximum credits corresponding to the P buffer area S2 and the P buffer area S3 are both 1.5M, which reduces the storage space used to cache P messages in the P buffer area S2 and the P buffer area S3.
[0140] Other scenarios are similar and will not be listed one by one.
[0141] The above describes the embodiment of the present application from the perspective of the method embodiment. Based on the same technical concept, the embodiment of the present application also provides a PCIe controller. Figure 2 As shown, the PCIe controller includes a first buffer area and a control circuit, wherein the control circuit can execute any possible implementation of the above method embodiment.
[0142] Among them, the first credit buffer area can cache the first message sent by the first sending device, and the first sending device can be any sending device of at least one sending device interconnected with the PCIe device; the control circuit can configure the maximum credit amount for the first credit buffer area according to the link delay corresponding to the first sending device, wherein the link delay corresponding to the first sending device is the link delay between the above-mentioned PCIe device and the first sending device, and the maximum credit amount of the first credit buffer area can be positively correlated with the above-mentioned link delay; the control circuit can adjust the credit limit of the first sending device according to the maximum credit amount of the first credit buffer area, and the credit limit can limit the number of first messages sent by the first sending device.
[0143] Generally speaking, after the PCIe device establishes a physical connection with the first sending device and completes the handshake, it is necessary to initialize the credit limit of the first sending device first, and then adjust the credit limit of the first sending device according to the maximum credit amount of the first credit buffer after the initialization. Exemplarily, the control circuit can also send initialization indication information to the first sending device, and the initialization indication information can instruct the first sending device to configure the credit limit as the physical credit amount of the first credit buffer, and the physical credit amount can be obtained according to the storage space size of the first credit buffer.
[0144] In one possible implementation, the control circuit is specifically used to: receive a first message sent by a first sending device within a first cycle, and cache the first message to the above-mentioned first credit cache area, and the first cycle can be any update cycle of the available credit amount; within the first cycle, the control circuit can also obtain and process the first message from the first credit cache area in sequence according to the order of reception; after the first cycle ends, the control circuit can obtain the credit limit of the first sending device in the next update cycle based on the sum of the number of processed messages and the maximum credit amount, and send first indication information to the first sending device, and the first indication information can indicate the credit limit of the first sending device in the next update cycle.
[0145] In a possible implementation, after the first cycle ends, the control circuit may determine that the number of processed first messages is greater than the first difference, and then obtain the credit limit of the first sending device in the next update cycle according to the sum of the number of processed messages and the maximum credit amount. The first difference may be obtained by subtracting the maximum credit amount from the physical credit amount of the first credit buffer.
[0146] After the first cycle ends, if the number of processed first messages is not greater than the first difference, the control circuit may send initialization indication information to the first sending device, and configure the credit limit of the first sending device to the physical credit amount of the first credit buffer area through the initialization indication information.
[0147] Exemplarily, in the embodiment of the present application, the control circuit can obtain the credit limit of the first sending device in the next update cycle according to the sum of the number of processed messages and the maximum credit amount in at least the following manner:
[0148] When the sum of the number of processed messages and the maximum credit amount is not greater than the maximum cumulative value, the credit limit of the first sending device in the next update cycle is the sum of the number of processed messages and the maximum credit amount;
[0149] When the sum of the number of processed messages and the maximum credit is greater than the maximum cumulative value, the credit limit of the first sending device in the next update cycle is the remainder obtained by dividing the sum of the number of processed messages and the maximum credit by the maximum cumulative value.
[0150] In one possible implementation, the control circuit may configure a maximum credit for the first credit buffer according to the link delay corresponding to the first sending device and the update period of the available credit, so that the maximum credit of the first credit buffer is positively correlated with the above-mentioned link delay and the above-mentioned update period, respectively.
[0151] Exemplarily, the maximum credit amount of the first credit buffer may satisfy the following formula:
[0152] D=(t+T)×I / L
[0153] Among them, D is the maximum credit amount of the first credit buffer area, t is the link delay corresponding to the first sending device, T is the update period of the available credit amount, I is the transmission bandwidth corresponding to the first sending device, and L is the typical message length between the first sending device.
[0154] In the embodiment of the present application, it is necessary to configure the maximum credit amount for the first credit buffer area according to the link delay corresponding to the first PCIe device. In view of this, the control circuit can also send a first instruction to the first sending device before configuring the maximum credit amount for the first credit buffer area, and the first instruction can instruct the sending device to feedback the corresponding first response; the control circuit can then calculate the link delay corresponding to the first sending device according to the time interval between the sending time point of the first instruction and the receiving time point of the first response.
[0155] Exemplarily, the first instruction may be a CFG0 instruction.
[0156] In the embodiment of the present application, the first message has multiple types. For example, the first message may be a postal P message, and the first credit buffer may be a P buffer. For another example, the first message may be a non-postal NP message, and the first credit buffer may be a NP buffer.
[0157] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0158] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0159] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0160] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0161] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the scope of protection of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A data flow control method, It is characterized in that Applied to a PCIe device, wherein the PCIe device and at least one transmitting device are interconnected by PCIe, the method comprising: According to the link delay corresponding to the first sending device, a maximum credit amount is configured for the first credit buffer area, the link delay corresponding to the first sending device is the link delay between the PCIe device and the first sending device, the first credit buffer area is used to cache the first message sent by the first sending device, the maximum credit amount is positively correlated with the link delay, and the first sending device is any one of the at least one sending device; The credit limit of the first sending device is adjusted according to the maximum credit amount of the first credit buffer, where the credit limit is used to limit the number of the first messages sent by the first sending device.
2. The method according to claim 1, It is characterized in that Before configuring the maximum credit amount for the first credit buffer according to the link delay corresponding to the first sending device, the method further includes: Initialization indication information is sent to the first sending device, where the initialization indication information is used to instruct the first sending device to configure the credit limit as a physical credit amount of the first credit buffer area, where the physical credit amount is obtained according to a storage space size of the first credit buffer area.
3. The method according to claim 1, It is characterized in that According to the maximum credit amount of the first credit buffer, adjusting the credit limit of the first sending device includes: In a first period, receiving a first message sent by the first sending device, and buffering the first message into the first credit buffer area, wherein the first period is any update period of the credit limit; sequentially acquiring and processing the first messages from the first credit buffer area in a receiving order; After the first cycle ends, an updated credit is calculated according to a current allocated credit CA and a first difference, wherein the current allocated credit is obtained according to a physical credit amount of the first credit buffer and a number of first messages currently processed, and the first difference is obtained by subtracting the maximum credit amount from the physical credit amount of the first credit buffer; First indication information is sent to the first sending device, where the first indication information is used to instruct the first sending device to configure the credit limit as the updated credit.
4. The method according to claim 3, It is characterized in that The allocated credit is used to accumulate the number of processed first messages based on the physical credit amount; When the allocated credit reaches the maximum cumulative value, the allocated credit is reset to zero, and the number of processed messages continues to be accumulated from zero.
5. The method according to claim 4, It is characterized in that According to the current allocated credit CA and the first difference, the updated credit is calculated, including: If the current allocated credit is greater than the first difference, the updated credit is the difference obtained by subtracting the first difference from the allocated credit; If the current allocated credit is not greater than the first difference, the updated credit is the difference obtained by subtracting the first difference from the sum of the allocated credit and the maximum cumulative value.
6. The method according to any one of claims 3 to 5, It is characterized in that Before calculating the updated credit according to the current allocated credit CA and the first difference, the following is also included: It is determined that the number of processed first messages is greater than the first difference.
7. The method according to claim 6, It is characterized in that Also includes: After the first cycle ends, if the number of processed first messages is not greater than the first difference, initialization indication information is sent to the first sending device, and the initialization indication information is used to instruct the first sending device to configure the credit limit as the physical credit amount of the first credit buffer area.
8. The method according to any one of claims 3 to 5, It is characterized in that Configuring a maximum credit amount for the first credit buffer according to the link delay corresponding to the first sending device includes: The maximum credit amount is configured for the first credit buffer area according to the link delay corresponding to the first sending device and the update period of the credit limit, and the maximum credit amount is positively correlated with the link delay and the update period respectively.
9. The method according to claim 8, It is characterized in that The maximum credit amount of the first credit buffer area satisfies the following formula: D=(t+T)×I / L Among them, D is the maximum credit amount of the first credit buffer area, t is the link delay corresponding to the first sending device, T is the update period of the credit limit, I is the transmission bandwidth between the first sending device, and L is the typical message length between the first sending device.
10. The method according to any one of claims 1 to 5, It is characterized in that Before configuring the maximum credit amount for the first credit buffer according to the link delay corresponding to the first sending device, the method further includes: Sending a first instruction to the first sending device, where the first instruction is used to instruct the first sending device to feed back a corresponding first response; The link delay is calculated according to the time interval between the sending time point of the first instruction and the receiving time point of the first response.
11. The method according to claim 10, It is characterized in that The first instruction is a configuration message type CFG0 instruction.
12. The method according to any one of claims 1 to 5, It is characterized in that The first message is a postal P message, and the first credit buffer is a P buffer; or The first message is a non-postal NP message, and the first credit buffer area is an NP buffer area.
13. A PCIe controller, It is characterized in that Applied to a PCIe device, the PCIe device and at least one transmitting device are interconnected by PCIe, and the PCIe controller includes a first credit buffer area and a control circuit; The first credit buffer is used to buffer a first message sent by a first sending device, where the first sending device is any one of the at least one sending device; The control circuit is used for: According to the link delay corresponding to the first sending device, a maximum credit amount is configured for the first credit buffer area, the link delay corresponding to the first sending device is the link delay between the PCIe device and the first sending device, and the maximum credit amount is positively correlated with the link delay; The credit limit of the first sending device is adjusted according to the maximum credit amount of the first credit buffer, where the credit limit is used to limit the number of the first messages sent by the first sending device.
14. The PCIe controller according to claim 13, It is characterized in that The control circuit is also used for: Initialization indication information is sent to the first sending device, where the initialization indication information is used to instruct the first sending device to configure the credit limit as a physical credit amount of the first credit buffer area, where the physical credit amount is obtained according to a storage space size of the first credit buffer area.
15. The PCIe controller according to claim 13, It is characterized in that The control circuit is specifically used for: In a first period, receiving a first message sent by the first sending device, and buffering the first message into the first credit buffer area, wherein the first period is any update period of the credit limit; sequentially acquiring and processing the first messages from the first credit buffer area in a receiving order; After the first cycle ends, an updated credit is calculated according to a current allocated credit CA and a first difference, wherein the current allocated credit is obtained according to a physical credit amount of the first credit buffer and a number of first messages currently processed, and the first difference is obtained by subtracting the maximum credit amount from the physical credit amount of the first credit buffer; First indication information is sent to the first sending device, where the first indication information is used to instruct the first sending device to configure the credit limit as the updated credit.
16. The PCIe controller according to claim 15, It is characterized in that The allocated credit is used to accumulate the number of processed first messages based on the physical credit amount; When the allocated credit reaches the maximum cumulative value, the allocated credit is reset to zero, and the number of processed messages continues to be accumulated from zero.
17. The PCIe controller according to claim 16, It is characterized in that The control circuit is specifically used for: If the current allocated credit is greater than the first difference, the updated credit is the difference obtained by subtracting the first difference from the allocated credit; If the current allocated credit is not greater than the first difference, the updated credit is the difference obtained by subtracting the first difference from the sum of the allocated credit and the maximum cumulative value.
18. The PCIe controller according to any one of claims 15 to 17, It is characterized in that The control circuit is also used for: Before calculating the updated credit according to the current allocated credit CA and the first difference, it is determined that the number of processed first messages is greater than the first difference.
19. The PCIe controller according to claim 18, It is characterized in that The control circuit is also used for: After the first cycle ends, if the number of processed first messages is not greater than the first difference, initialization indication information is sent to the first sending device, and the initialization indication information is used to instruct the first sending device to configure the credit limit as the physical credit amount of the first credit buffer area.
20. The PCIe controller according to any one of claims 15 to 17, It is characterized in that The control circuit is specifically used for: The maximum credit amount is configured for the first credit buffer area according to the link delay corresponding to the first sending device and the update period of the credit limit, and the maximum credit amount is positively correlated with the link delay and the update period respectively.
21. The PCIe controller according to claim 20, It is characterized in that The maximum credit amount of the first credit buffer area satisfies the following formula: D=(t+T)×I / L Among them, D is the maximum credit amount of the first credit buffer area, t is the link delay corresponding to the first sending device, T is the update period of the credit limit, I is the transmission bandwidth between the first sending device, and L is the typical message length between the first sending device.
22. The PCIe controller according to any one of claims 13 to 17, It is characterized in that The control circuit is also used for: Sending a first instruction to the first sending device, where the first instruction is used to instruct the sending device to feed back a corresponding first response; The link delay is calculated according to the time interval between the sending time point of the first instruction and the receiving time point of the first response.
23. The PCIe controller according to claim 22, It is characterized in that The first instruction is a CFG0 instruction.
24. The PCIe controller according to any one of claims 13 to 17, It is characterized in that The first message is a P message, and the first credit buffer is a P buffer; or, The first message is an NP message, and the first credit buffer area is an NP buffer area.
25. A PCIe device, It is characterized in that Comprising a PCIe controller as claimed in any one of claims 13 to 24.
26. A PCIe system, It is characterized in that The method comprises a plurality of PCIe devices, wherein any PCIe device is interconnected with one or more other PCIe devices via a PCIe controller; Among the multiple PCIe devices, there is at least one PCIe device, which is the PCIe device as claimed in claim 25.
