Data packet reordering method, device, equipment, chip and storage medium
By setting up a shared chain cache on the sending port of the multi-level switching network, and using the free pool linked list to cache and rearrange data packets in order, the problem of data packet disorder is solved, hardware costs and cache space usage are reduced, and data packet processing is realized. Correct transmission of sequence.
Patent Information
- Application Number
- CN202410815828.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-24
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2044-06-24
AI Technical Summary
When data packets are transmitted in a multi-level switching network, due to path diversity, data packets are out of order, resulting in data transmission errors. The existing technology requires a large number of caches for each receiving port to perform out-of-order rearrangement, resulting in high hardware costs.
Set up a shared chain cache on the sending port, cache and rearrange data packets in order through the free pool linked list, ensure the correct order of data packets, and allow multiple receiving ports to share the cache, reducing cache space usage.
It achieves the correct transmission of data packet sequence, while reducing the hardware cost and the usage of cache space, which is about 1/N of the original.
Smart Images

Figure CN118381775B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data transmission, and in particular to a method, device, equipment, chip and storage medium for rearranging data packets. Background Art
[0002] The multi-stage switching network architecture can be used to implement many-to-many data transmission between N receiving ports (also called source ports, input ports, etc.) and M sending ports (also called target ports, output ports, etc.).
[0003] However, when a receiving port transmits multiple data packets to a sending port, due to the diversity of paths in the multi-stage switching network, this may cause the data packets received by the sending port to be out of order, resulting in data transmission errors. Summary of the invention
[0004] In view of this, the present invention provides a method, device, equipment, chip and storage medium for reordering data packets to solve the problem of data packet disorder.
[0005] In a first aspect, the present invention provides a method for reordering a data packet, which is applied to a sending node of a multi-stage switching network, wherein the sending node includes at least one target sending port for sending a data packet externally, and the method includes:
[0006] Allocating a linked cache for reordering data packets to the target sending port; the linked cache includes a plurality of cache entries for caching data packets, and the cache entries initially belong to a free pool linked list;
[0007] Acquire a current data packet transmitted by a target receiving port through the multi-stage switching network; the target receiving port is a receiving port in the multi-stage switching network;
[0008] In the case where the current data packet is out of order, the current data packet is cached in a target cache entry assigned to the target receiving port; the target cache entry is a cache entry taken from the free pool linked list and used to cache unsent data packets in order;
[0009] After sending a previous data packet of the current data packet externally, taking out the current data packet from the corresponding target cache entry, and sending the current data packet externally;
[0010] The target cache entry used to cache the current data packet is recycled to the free pool linked list.
[0011] In a second aspect, the present invention provides a data packet reordering device, which is applied to a sending node of a multi-stage switching network, wherein the sending node includes at least one target sending port for sending data packets externally, and the device includes:
[0012] A preprocessing module, configured to allocate a linked cache for reordering data packets to the target sending port; the linked cache includes a plurality of cache entries for caching data packets, and the cache entries initially belong to a free pool linked list;
[0013] An acquisition module, used for acquiring a current data packet transmitted by a target receiving port through the multi-stage switching network; the target receiving port is a receiving port in the multi-stage switching network;
[0014] an out-of-order processing module, which, when the current data packet is out of order, caches the current data packet into a target cache entry assigned to the target receiving port; the target cache entry is a cache entry taken from the free pool linked list and used to cache unsent data packets in order;
[0015] A sending module, configured to fetch the current data packet from a corresponding target cache entry after sending a previous data packet of the current data packet externally, and send the current data packet externally;
[0016] The recycling module is used to recycle the target cache entry used to cache the current data packet to the free pool linked list.
[0017] In a third aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the data packet reordering method of the first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0018] In a fourth aspect, the present invention provides a switching chip, comprising: a plurality of receiving ports and a plurality of sending ports; the plurality of receiving ports and the plurality of sending ports are interconnected via a multi-stage switching network;
[0019] At least part of the sending ports are configured to send data packets externally according to the data packet reordering method of the first aspect or any corresponding embodiment thereof.
[0020] In a fifth aspect, the present invention provides a network device, comprising a switching chip as in the fourth aspect or any corresponding embodiment thereof.
[0021] In a sixth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the method for reordering data packets of the first aspect or any corresponding embodiment thereof.
[0022] The present invention sets a linked cache including a free pool linked list for a target sending port. When a data packet needs to be cached, the corresponding target cache entries are sequentially taken out from the free pool linked list, and the data packets are cached in sequence, so that the target sending port can send the data packets to the outside in sequence, ensuring that the order of the data packets is correct; and each receiving port can share and use the linked cache, which greatly reduces the usage of the cache space, which is about 1 / N of the original, and can reduce the hardware cost while ensuring correct data transmission. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the related technologies, the drawings required for use in the specific embodiments or the related technical descriptions will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0024] Figure 1 is a flow chart of a method for reordering data packets according to an embodiment of the present invention;
[0025] Figure 2 is a schematic diagram of a chain cache structure according to an embodiment of the present invention;
[0026] Figure 3 is another flow chart of a method for reordering data packets according to an embodiment of the present invention;
[0027] Figure 4 is a schematic diagram of a head pointer according to an embodiment of the present invention;
[0028] Figure 5 is a schematic diagram of a pointer queue according to an embodiment of the present invention;
[0029] Figure 6 is a schematic diagram of multiple linked lists in a linked cache according to an embodiment of the present invention;
[0030] Figure 7 is a schematic diagram of the correspondence between sequence numbers and pointer queues according to an embodiment of the present invention;
[0031] Figure 8 is a schematic diagram of maintaining a sequence number on a receiving port side according to an embodiment of the present invention;
[0032] Fig. 9 is a schematic diagram of a process of sending and responding to a data packet according to an embodiment of the present invention;
[0033] Fig.10 is a first schematic diagram of a target sending port data structure according to an embodiment of the present invention;
[0034] Fig.11 is a second schematic diagram of a target sending port data structure according to an embodiment of the present invention;
[0035] Fig.12 is a third schematic diagram of a target sending port data structure according to an embodiment of the present invention;
[0036] Fig.13 is a fourth schematic diagram of a target sending port data structure according to an embodiment of the present invention;
[0037] Fig.14 is a fifth schematic diagram of a target sending port data structure according to an embodiment of the present invention;
[0038] Fig.15 is a sixth schematic diagram of a target sending port data structure according to an embodiment of the present invention;
[0039] Fig.16 is a structural block diagram of a data packet reordering device according to an embodiment of the present invention;
[0040] Fig.17 is a schematic diagram of a topological structure of a switching chip according to an embodiment of the present invention;
[0041] Fig.18 is a schematic diagram of a fully connected sending port according to an embodiment of the present invention;
[0042] Fig.19 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0044] Multi-stage switching network architectures, such as CLOS network (a commonly used multi-stage switching network invented by Charles Clos and named after the inventor), Crossbar network, etc., can realize many-to-many data transmission between N receiving ports (source ports) and M sending ports (destination ports). Multiple devices can realize data transmission according to the multi-stage switching network architecture, or the multi-stage switching network architecture can also be applied to on-chip systems, such as switch chips.
[0045] Taking a CLOS network as an example, the CLOS network can realize data transmission between N receiving ports (eg, N=16) and M sending ports (eg, M=16), that is, each of the N receiving ports can send data received from the outside to any sending port.
[0046] One of the characteristics of CLOS network is the diversity of paths, that is, there are multiple paths from a receiving port to a sending port. This feature can prevent congestion, but it also brings disorder problems.
[0047] For example, a CLOS network is composed of three levels of nodes, which specifically include multiple first-level nodes, multiple second-level nodes and multiple third-level nodes; wherein each receiving port is connected to a first-level node; each of the first-level nodes is connected to all second-level nodes; each of the second-level nodes is connected to all third-level nodes; and the third-level nodes are connected to several sending ports.
[0048] For example, if receiving port 2 in the CLOS network needs to send a data packet to sending port 6. Specifically, receiving port 2 transmits data packets 1 and 2 to the CLOS network in sequence, but the two data packets pass through two different second-level nodes, resulting in the data packets being out of order when reaching the same third-level node (the third-level node is connected to sending port 6). The possible reason is that when data packet 1 arrives at a second-level node, the data path between the second-level node and the third-level node is transmitting other data packets, causing data packet 1 to wait. Finally, the third-level node receives data packet 2 first and sends it to sending port 6, and then receives data packet 1 and sends it to sending port 6, that is, sending port 6 receives data packet 2 first and then receives data packet 1.
[0049] Disorder is unacceptable in many data transmission protocols. The solution to this problem is, for example, to reorder the packets at the sending port. In general, to ensure that all packets transmitted by each receiving port can be reordered, N receiving buffers need to be set at each sending port. Each receiving buffer is used to sort the packets of one of the receiving ports.
[0050] Therefore, for a multi-stage switching network with N receiving ports and M transmitting ports, the entire network requires N×M caches. The size of each cache needs to be prepared according to the possible out-of-order depth in the worst case. From a hardware perspective, this approach requires a large cache capacity, resulting in high hardware costs.
[0051] The data packet reordering method provided in this embodiment sets a chain buffer for a sending port to be shared by multiple receiving ports, which can reduce the usage of buffer space while ensuring correct data transmission, thereby reducing hardware costs.
[0052] According to an embodiment of the present invention, an embodiment of a method for reordering data packets is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0053] In this embodiment, a method for rearranging data packets is provided, which is applied to a sending node of a multi-stage switching network, wherein the sending node includes at least one target sending port for sending data packets externally. Alternatively, the sending node may also be a node in a switching chip for sending data packets externally, which may include one or more sending ports.
[0054] Figure 1 is a flow chart of a method for reordering data packets according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps.
[0055] Step S101, allocating a linked cache for reordering data packets to a target sending port; the linked cache includes a plurality of cache entries for caching data packets, and the cache entries initially belong to a free pool linked list.
[0056] In this embodiment, the multi-stage switching network includes multiple sending ports. For a certain sending node, it may include one or more sending ports, and these sending ports can all be used as target sending ports; in other words, for any sending port in the multi-stage switching network, out-of-order rearrangement can be achieved according to the method provided in this embodiment. This embodiment is subsequently mainly described by one of the sending ports, that is, the out-of-order rearrangement of the data packets received by the target sending port is described.
[0057] For the target sending port, a chain structure cache, i.e., a chain cache, is pre-allocated thereto, through which the data packets received by the target sending port can be reordered; and, the chain cache is provided with a free pool mechanism, by which the chain cache can be shared by all receiving ports, thereby eliminating the need to set up a cache space for each receiving port.
[0058] Specifically, the chain cache includes multiple cache entries, that is, the chain cache has a certain cache depth; wherein, the chain cache includes L cache entries (L≥2), that is, the cache depth of the chain cache is L. Each cache entry is used to cache received data packets. For example, taking the example of receiving port 2 sending a data packet to sending port 6 via the CLOS network, the sending port 6 is the target sending port, and a corresponding chain cache is set for it. After the sending port 6 (i.e., the target sending port) receives the data packet 1 sent by the above-mentioned receiving port 2 via the CLOS network, the data packet 1 can be cached in the corresponding cache entry.
[0059] In addition, the chain cache is provided with a free pool, which includes a plurality of free cache entries, and the plurality of free cache entries are arranged in order to form a corresponding linked list, namely, the free pool linked list. As the name implies, the free cache entry is a cache entry that is currently in an idle state, namely, the free cache entry is not currently assigned to any receiving port to cache data packets transmitted by the receiving port. Initially, any cache entry in the chain cache is in an idle state, namely, any cache entry belongs to the free pool linked list.
[0060] For example, the cache entries may be sorted by a next pointer. Specifically, the cache entry includes a storage space for caching data packets and a next pointer, and the next pointer points to the next cache entry in the order.
[0061] Figure 2 A schematic diagram of a chain cache structure is shown, such as Figure 2 As shown, the chain cache includes L cache entries, each of which includes a storage space for caching data packets and a corresponding successor pointer. Using the successor pointer, multiple cache entries can be arranged in order.
[0062] For example, at the beginning, the entire linked cache can form a free pool linked list. One form of the free pool linked list can be found in Figure 2 As shown. Figure 2 As shown, if the addresses (i.e., pointers) of the L cache entries are 0, 1, 2, ..., L-1 in sequence, the next cache entry of the first cache entry is the second cache entry, and the address of the second cache entry is 1, then the successor pointer of the first cache entry can be set to 1. In addition, there is no next cache entry for the last cache entry in the free pool linked list, so its successor pointer is set to invalid, for example, the successor pointer of the last cache entry in the free pool linked list is null, or other values indicating invalidity.
[0063] Step S102, obtaining a current data packet transmitted by a target receiving port via a multi-stage switching network; the target receiving port is a receiving port in the multi-stage switching network.
[0064] In this embodiment, for a certain receiving port in the multi-stage switching network, if the receiving port transmits a certain data packet to the target sending port through the multi-stage switching network, the receiving port may be referred to as a "target receiving port". Moreover, after receiving the data packet, the target sending port may need to rearrange the data packet. For the convenience of description, the data packet currently received by the target sending port is referred to as a current data packet.
[0065] For example, taking the example of receiving port 2 sending a data packet to sending port 6 through the CLOS network, the target receiving port is receiving port 2, and the target sending port is sending port 6; when sending port 6 receives data packet 2, it can use data packet 2 as the current data packet to perform subsequent processing.
[0066] Step S103, in the case that the current data packet is out of order, the current data packet is cached into a target cache entry assigned to the target receiving port; the target cache entry is a cache entry taken from the free pool linked list and used to cache unsent data packets in order.
[0067] In this embodiment, after receiving the current data packet, the target sending port first determines whether the current data packet is out of order; for example, a data packet generally has a sequence number, and whether the sequence number of the received data packet is continuous can be determined to determine whether it is out of order. If the current data packet is not out of order, it does not need to be reordered, and the current data packet can be directly sent to the outside; if the current data packet is out of order, in this embodiment, the chain buffer is used to reorder the out-of-order current data packet.
[0068] Specifically, if the current data packet is out of order, the corresponding cache entry can be taken out from the free pool linked list. For the convenience of description, the taken out cache entry is called the "target cache entry", and the target cache entry is the cache entry assigned to the target receiving port, that is, the target cache entry is used to cache the data packet transmitted by the target receiving port. In addition, since the current data packet is out of order, it can be determined that the target sending port has not yet received other data packets before the current data packet, so there are multiple unsent data packets at this time (the current data packet is also an unsent data packet), so there are multiple target cache entries at this time.
[0069] Among them, multiple target cache entries are also arranged on demand, and are specifically arranged based on the order of the data packets that need to be cached (for example, the sequence of the data packets), so that multiple target cache entries can also form a linked list, and this embodiment refers to the linked list as a "target linked list". It can be understood that the target linked list includes one or more linked lists of target cache entries arranged in order, and the target linked list is used to implement the random reordering of the data transmitted by the target receiving port. In addition, when caching the current data packet, it is necessary to cache it to the corresponding target cache entry, which is based on the actual situation; for example, in some cases, the current data packet is cached to the last target cache entry in the target linked list.
[0070] For example, taking the example of receiving port 2 sending a data packet to sending port 6 through the CLOS network, if receiving port 2 sends data packet 1 and data packet 2 successively, and sending port 6 receives data packet 2 (the current data packet) first, then the sending port 6 can determine that data packet 2 is out of order; since there is data packet 1 before data packet 2, that is, for sending port 2, there are two unsent data packets (data packet 1 and data packet 2) at this time, so two cache entries can be taken out of the free pool linked list as target cache entries, and a corresponding target linked list is formed.
[0071] like Figure 2 As shown, the first cache entry and the second cache entry in the free pool linked list are used as target cache entries to form a target linked list; and the successor pointer of the last cache entry (i.e., the second cache entry) in the target linked list is also invalid to form an independent target linked list. It can be understood that in the target linked list, the first cache entry should be used to cache data packet 1, and the second cache entry should be used to cache data packet 2. After receiving data packet 2, the sending port 6 can cache the data packet 2 to the second cache entry and wait for sending; when receiving data packet 1 later, the data packet 1 is cached to the first cache entry.
[0072] Step S104, after sending the previous data packet of the current data packet to the outside, taking out the current data packet from the corresponding target cache entry, and sending the current data packet to the outside.
[0073] In this embodiment, for the above-mentioned out-of-order current data packet, after caching it into the corresponding target cache entry, the current data packet cannot be sent immediately; specifically, the current data packet can be sent only after the target sending port has sent the previous data packet of the current data packet. For example, taking the example of receiving port 2 sending a data packet to sending port 6 through the CLOS network, after sending port 6 receives data packet 2, it caches data packet 2 into the corresponding target cache entry; after receiving the previous data packet of data packet 2, i.e., data packet 1, the sending port 6 first sends data packet 1 outward, and after sending data packet 1 outward, it takes data packet 2 out from the corresponding target cache entry and sends data packet 2 outward.
[0074] When the target sending port receives the previous data packet, the previous data packet may also be used as a current data packet and rearranged according to the method provided in this embodiment. For example, the previous data packet may also be cached in the corresponding target cache entry, and then when the previous data packet can be sent, the previous data packet is taken out from the target cache entry and sent externally.
[0075] Step S105: Reclaim the target cache entry used to cache the current data packet to the free pool linked list.
[0076] In this embodiment, after the current data packet is sent externally, the target cache entry originally used to cache the current data packet is no longer assigned to the target receiving port, that is, the target cache entry is no longer used to cache the data packets transmitted by the target receiving port. Therefore, the target cache entry is recycled to the free pool linked list, that is, the target cache entry is taken out from the target linked list, and the target cache entry is recycled to the free pool linked list, so that the target cache entry can be reallocated to the target receiving port or other receiving ports to cache the corresponding data packets, thereby realizing the sharing of the chain cache among multiple receiving ports.
[0077] Limited by parameters such as the bandwidth of the sending port, the sending port has a maximum data volume Dmax that can be processed. In the traditional solution, for each sending port, N caches need to be set (N is the number of receiving ports), and the space size of each cache cannot be less than Dmax, and a total of N×Dmax cache space is required; in this embodiment, the chain cache can be allocated to any receiving port, and limited by bandwidth, etc., at a certain moment, no matter how many receiving ports are transmitting data to the target sending port, the maximum data volume that the target sending port can process is also Dmax, so the space size of the chain cache does not need to be less than Dmax, that is, only 1 / N of the original cache needs to be set for the target sending port.
[0078] The data packet reordering method provided in this embodiment sets a linked cache including a free pool linked list for the target sending port. When it is necessary to cache data packets, the corresponding target cache entries are taken out from the free pool linked list in order, and the data packets are cached in order, so that the target sending port can send data packets to the outside in order and ensure that the order of the data packets is correct; and each receiving port can share and use the linked cache, which greatly reduces the usage of the cache space, which is about 1 / N of the original space. While ensuring correct data transmission, it can reduce hardware costs.
[0079] In this embodiment, a method for reordering data packets is provided, which is applied to a sending node of a multi-stage switching network, such as Figure 3 As shown, the process includes the following steps.
[0080] Step S301, allocating a linked cache for reordering data packets to a target sending port; the linked cache includes a plurality of cache entries for caching data packets, and the cache entries initially belong to a free pool linked list.
[0081] For details, please see Figure 1 Step S101 of the illustrated embodiment will not be described in detail here.
[0082] In some optional implementations, the chain cache can be used Figure 2 The structure shown; and, in order to facilitate sharing of the chain buffer to multiple receiving ports, a corresponding head pointer and / or pointer queue may also be set, that is, the method may also include a process of setting a corresponding head pointer and / or pointer queue. Specifically, the process of setting the head pointer may refer to the following step A1, and the process of setting the pointer queue may refer to the following step A2.
[0083] Step A1, setting a free pool head pointer and head pointers of multiple receiving ports; wherein the free pool head pointer points to: the first cache entry of the free pool linked list; the head pointer of the receiving port points to: the first cache entry of the linked list composed of cache entries assigned to the receiving port in sequence in the linked cache. The cache entry assigned to the receiving port is used to cache data packets transmitted by the corresponding receiving port.
[0084] In this embodiment, in order to facilitate the positioning of the free pool linked list in the linked cache, a free pool head pointer is set, and the free pool head pointer points to the first cache entry in the free pool linked list, that is, the first cache entry in the queue composed of free cache entries arranged in order in the linked cache.
[0085] Furthermore, multiple head pointers of receiving ports can be set to simultaneously process data packets transmitted by multiple receiving ports; wherein, after the target sending port receives a data packet transmitted by a certain receiving port, a corresponding linked list can be established in the linked cache, and the head pointer of the receiving port points to the first cache entry of the linked list. For example, taking the above-mentioned target receiving port as an example, its head pointer is the first cache entry in the target linked list.
[0086] like Figure 2 As shown, initially, the entire linked cache is a free pool linked list, and the free pool head pointer points to the first cache entry, which can specifically be the address of the first cache entry, that is, the free pool head pointer is 0. For the head pointer of each receiving port, it can be invalid initially; or, if a cache entry is pre-allocated for each receiving port after the linked cache is created, the head pointer of the receiving port can also be the address of the pre-allocated cache entry.
[0087] Continue to see Figure 2 After the target sending port receives data packet 2, if the corresponding target linked list is created for the target receiving port, the head pointer of the target receiving port is updated to 0, and the free pool head pointer changes from 0 to 3.
[0088] In order to process data packets transmitted by all receiving ports at the same time, N receiving port head pointers are set for the target receiving port (N is the number of receiving ports); corresponding registers can be set to store the head pointers. Specifically, a first register can be set to store the free pool head pointer; and N second registers can be set, each of which is used to store the head pointer of the corresponding receiving port, that is, N+1 registers can be set. For an implementation method of setting multiple head pointers in this embodiment, please refer to Figure 4 shown.
[0089] The main function of these head pointers is to locate the corresponding linked list in the linked cache. The function of the head pointer is explained in detail later.
[0090] Step A2, multiple pointer queues are set; the pointer queues correspond to the receiving ports, and the pointer queues include multiple queue entries, and the queue entries can store pointers to a cache entry. In addition, the pointer queues are provided with a head position and a tail position, and the queue entries between the head position and the tail position are used to store pointers to the cache entries.
[0091] In this embodiment, in order to quickly locate the cache entry in the linked list (such as the target linked list mentioned above) assigned to the receiving port, this embodiment also sets multiple pointer queues, and the pointer queues record the position of each unsent data packet in the linked list. The pointer queue corresponds to the receiving port; for example, in order to meet the needs of all receiving ports, N pointer queues can be set, that is, the pointer queues correspond to the receiving ports one by one.
[0092] The pointer queue includes a plurality of queue entries, each of which is used to store a pointer to a cache entry, that is, the queue entry is used to store the address of a cache entry. Optionally, the queue depth of the pointer queue is not less than the cache depth of the linked cache; or, in other words, the number of queue entries in the pointer queue is not less than the number of linked entries in the linked cache. For example, the queue depth of the pointer queue is the same as the cache depth of the linked cache, both of which are L, that is, the pointer queue includes L queue entries.
[0093] Furthermore, at a certain moment, some queue entries in the pointer queue may not be necessary, and these queue entries do not need to store corresponding pointers; in this embodiment, by setting the head position and the tail position, it is indicated which queue entries in the pointer queue store pointers to cache entries. For example, in the pointer queue corresponding to the target receiving port (hereinafter referred to as the target pointer queue), the queue entries between the head position and the tail position are used to store pointers to the target cache entries. A head register and a position register can be set for each pointer queue, and the head register stores the head position, and the tail register stores the tail position.
[0094] In this embodiment, the area between the head position and the tail position is a valid area for storing corresponding pointers; wherein, the valid area may include the pointer at the tail position, or may not include the pointer at the tail position, which may be determined based on actual conditions; Figure 6 In the examples shown in , it is taken that the valid area does not include the pointer pointed to by the tail position of the queue.
[0095] In order to be able to use the pointer queue cyclically, the pointer queue is a circular queue, that is, in the pointer queue, the "next" queue entry of the last queue entry is the first queue entry in the pointer queue.
[0096] For example, a schematic diagram of N pointer queues set for N receiving ports can be seen in Figure 5 As shown in Figure 1. Among them, the pointer stored in each queue entry (such as Figure 5 Pointer 0, pointer 1, etc. in , can be the address of a cache entry.
[0097] In this embodiment, the chain cache, the head pointer and the pointer queue are combined to realize a shared cache with a reordering function in a simple and convenient manner. Among them, since the target sending port can send data packets transmitted by different receiving ports to the outside, the cache entries in the chain cache set for the target sending port may form various linked lists; in this case, the head pointer and the pointer queue are combined to locate the cache entries in each linked list more conveniently.
[0098] Figure 6 A schematic diagram showing multiple linked lists in a linked cache. Figure 6 As shown, if the target sending port currently receives data packets sent by receiving port 0 and receiving port 2, and needs to allocate corresponding target cache entries to the two. Assume that cache entry 1 (the second cache in the chain cache, whose address is 1) and cache entry 10 are allocated to receiving port 0, and the two form a linked list, namely "cache entry 1→cache entry 10". For the convenience of description, this linked list is called the first linked list. In addition, cache entry 2, cache entry 3 and cache entry 9 are allocated to receiving port 2, and the three can also form a linked list, namely "cache entry 2→cache entry 3→cache entry 9". For the convenience of description, this linked list is called the second linked list. The remaining cache entries (cache entry 0, cache entry 4, etc.) still belong to the free pool linked list, which can be expressed as "cache entry 0→cache entry 4→...→cache entry L-1".
[0099] Among them, the head pointer register of receiving port 0 records the first cache entry position of the first linked list, so the head pointer of receiving port 0 is 1. Similarly, the head pointer value of receiving port 2 is 2. The remaining receiving ports are not allocated space in the linked cache, so the head pointers are invalid. The free pool head pointer is the first cache entry position of the free pool linked list, and its value is 0.
[0100] Furthermore, the order of cache entries allocated to receiving port 0 is cache entry 1, cache entry 10, and cache entry 10 is the last entry, so the successor pointers of cache entry 1 and cache entry 10 are 10, invalid. At the same time, the pointer sequence 1, 10 is also saved in the pointer queue of receiving port 0, between the head position and the tail position. Figure 6 In the example, two pointers are saved to the positions of queue entry 1 and queue entry 2; at this time, the value in the head register is 1 (i.e., the head position is 1), and the value in the tail register is 3 (i.e., the tail position is 3). Similarly, the successor pointer of each cache entry in the second linked list and the value in the queue entry in the corresponding pointer queue can be determined. For details, see Figure 6 As shown, no further details are given here.
[0101] Step S302, obtaining a current data packet transmitted by a target receiving port via a multi-stage switching network; the target receiving port is a receiving port in the multi-stage switching network.
[0102] For details, please see Figure 1 Step S102 of the illustrated embodiment will not be described in detail here.
[0103] Step S303, determining whether the current data packet is out of order.
[0104] If the current data packet is not out of order, step S304 is executed; if the current data packet is out of order, step S305 is executed.
[0105] In some optional implementations, the data packets transmitted by the receiving port are provided with corresponding sequence numbers, that is, the current data packet includes the current sequence number set in sequence; and, on the target sending port side, a corresponding expected sequence number is set for each receiving port, and by judging the size relationship between the current sequence number and the corresponding expected sequence number, it can be determined whether the current data packet is out of sequence. Specifically, the above step S303 "judging whether the current data packet is out of sequence" can include the following steps B1 to B3.
[0106] Step B1, determine whether the current sequence number is the same as the expected sequence number of the target receiving port; the expected sequence number is the sequence number of the data packet to be sent externally this time, and the initial value of the expected sequence number is the minimum sequence number of the data packets transmitted by the target receiving port.
[0107] In this embodiment, the data packet transmitted by the receiving port includes a corresponding sequence number, which can follow the data packet through the multi-stage switching network and finally reach the target sending port. Each time the receiving port sends a data packet, the corresponding sequence number is increased in sequence, for example, the sequence number is increased by +1; when the sequence number reaches the set maximum value, the sequence number can be reset to the minimum initial value, for example, 0.
[0108] The target sending port side needs to record the sequence number of the data packet expected to be received, that is, the expected sequence number; for example, an "expected sequence number" register can be set, and the expected sequence number is stored and updated based on the expected sequence number register. Among them, the expected sequence number is the expected sequence number corresponding to the target receiving port, and the initial value of the expected sequence number is the minimum sequence number of the data packet transmitted by the target receiving port; for example, the sequence number of the data packet transmitted by the target receiving port starts from 0, and the expected sequence number is also initially 0.
[0109] The expected sequence number is used to indicate the sequence number of the data packet that needs to be sent externally this time. Specifically, after the target sending port sends a data packet externally, the sequence number of the next data packet of the data packet can be used as the new expected sequence number; for example, after the target sending port sends the current data packet, the sequence number next to the current sequence number can be used as the expected sequence number, so that the expected sequence number can indicate the sequence number of the data packet that needs to be sent externally this time.
[0110] The expected sequence number of the target receiving port can be increased in sequence based on the original expected sequence number. For example, if the sequence number is increased by +1, the expected sequence number can be increased by +1 after the data packet is sent.
[0111] Step B2: When the current sequence number is the same as the expected sequence number, determine that the current data packet is not out of order.
[0112] Step B3: When the current sequence number is different from the expected sequence number, it is determined that the current data packet is out of order.
[0113] In this embodiment, if the current sequence number is the same as the expected sequence number, it means that the sequence number of the data packet received at this time is correct, so the current sequence number is not out of sequence; on the contrary, if the current sequence number is different from the expected sequence number, the current sequence number is out of sequence, that is, the current data packet is out of sequence, and there are other data packets that have not been received at this time; and, the sequence number of the unreceived data packet is before the current sequence number of the current data packet, at this time the currently received packet should be saved in the corresponding target cache directory.
[0114] In general, the current sequence number will not be less than the expected sequence number (unless the sequence number of the data packet is reset due to reaching the maximum value); that is, if the current sequence number is greater than the expected sequence number, it is determined that the current data packet is out of order.
[0115] Step S304: When the current data packet is not out of order, the current data packet is sent to the outside.
[0116] In this embodiment, after the target sending port sends any data packet, the corresponding cache entry needs to be recycled to the free pool linked list. Therefore, after the above step S304, the subsequent step S307 is continued, that is, the step of recycling the target cache entry used for caching the current data packet to the free pool linked list is executed.
[0117] Step S305 , in the case that the current data packet is out of order, the current data packet is cached into a target cache entry assigned to the target receiving port; the target cache entry is a cache entry taken from the free pool linked list and used to cache unsent data packets in order.
[0118] For details, please see Figure 1 Step S103 of the illustrated embodiment will not be described in detail here.
[0119] In some optional embodiments, the method further includes steps C1 to C2.
[0120] Step C1, when the current data packets are out of order, determine whether more target cache entries need to be allocated to the target receiving port.
[0121] In this embodiment, if the current data packets transmitted by the target receiving port and received by the target sending port are out of order, it may be necessary to allocate more target cache entries to the target receiving port, that is, more cache entries need to be taken out from the free pool linked list. It is also possible that the target cache entries currently allocated to the target receiving port are sufficient, and there is no need to allocate more target cache entries to it.
[0122] Optionally, the current data packet includes a current sequence number set in sequence, and also records the maximum sequence number of the target receiving port, and uses the maximum sequence number to determine whether to continue to allocate cache entries. Specifically, the above step C1 "determining whether more target cache entries need to be allocated to the target receiving port" includes the following steps C11 to C12.
[0123] Step C11, determine whether the current sequence number is greater than the maximum sequence number of the target receiving port; the maximum sequence number is the largest sequence number in the received data packets, and the initial value of the maximum sequence number is similar to the initial value of the expected sequence number, which is the minimum sequence number of the data packets transmitted by the target receiving port.
[0124] Step C12: when the current sequence number is greater than the maximum sequence number, more target cache entries need to be allocated to the target receiving port; and the maximum sequence number is updated to the current sequence number.
[0125] In this embodiment, for the target sending port, a corresponding maximum sequence number is set in advance for the target receiving port; for example, a "maximum sequence number" register can be set for the target sending port, and the maximum sequence number of the target receiving port can be recorded by the maximum sequence number register. The maximum sequence number is the largest sequence number in the received data packets; for example, if the current sequence number of the current data packet is the largest, then after executing the above step C1, the current sequence number can be used as the new maximum sequence number.
[0126] Specifically, after receiving the current data packet including the current sequence number, if the current data packet is out of order (for example, the current sequence number is different from the expected sequence number), it is possible to continue to determine whether the current sequence number is greater than the corresponding maximum sequence number. If the current sequence number is greater than the maximum sequence number, it means that a data packet with a later sequence number has been received, that is, the current sequence number of the current data packet is later, and at this time, it is necessary to allocate corresponding target cache entries for the data packets from the maximum sequence number to the current sequence number; then, the maximum sequence number can be updated to the current sequence number to ensure that the maximum sequence number is the largest sequence number among the received data packets.
[0127] On the contrary, if the current sequence number is less than the maximum sequence number, it means that a target cache entry has been allocated for the data packet with the current sequence number before, and no more allocation is needed. At this time, the current data packet can be directly stored in the corresponding target cache entry.
[0128] For a target receiving port, its sequence number (including expected sequence number and maximum sequence number) corresponds to the corresponding pointer queue. The expected sequence number corresponds to the head position in the pointer queue, and the maximum sequence number corresponds to the position before the tail of the pointer queue. For details, see Figure 7 shown.
[0129] Optionally, after the target sending port sends a data packet, it can provide feedback to the target receiving port to inform the target receiving port which data packets have been successfully sent out. The sequence number of the data packet sent out this time can be used as the current response sequence number and fed back to the target receiving port. For example, after the current data packet is sent out based on the target sending port, the current sequence number of the current data packet can be used as the current response sequence number and the current response sequence number can be fed back to the target receiving port.
[0130] The target sending port can send a response packet for each data packet (each response packet corresponds to a response sequence number), or use one response packet to respond to multiple data packets. For example, when the target sending port receives data packets with sequence numbers 10 to 15, the target sending port can send six response packets, Ack10, Ack11, ..., Ack15, to the target receiving port in sequence, or only send Ack15 when receiving data packet 15, indicating that all data packets before sequence number 15 have been received.
[0131] In addition, optionally, on the receiving port side, the acknowledged sequence number and the sent sequence number can be recorded; the acknowledged sequence number is the maximum valid acknowledgement sequence number received, and the sent sequence number is the maximum sequence number of the data packet currently sent by the target receiving port (which is generally also the maximum sequence number recorded on the target sending port side); for example, a corresponding register can be set on the receiving port side to store the acknowledged sequence number and the sent sequence number. Among them, the sequence number between the acknowledged sequence number and the sent sequence number is the valid acknowledgement sequence number, and the interval between the two is the valid interval. For example, the schematic diagram of the sequence number maintenance on the receiving port side can be seen in Figure 8 shown.
[0132] For the target receiving port, if the target receiving port receives the response packet fed back by the target sending port, the response sequence number therein, i.e., the current response sequence number, can be determined, and it can be judged whether the current response sequence number is between the responded sequence number and the sent sequence number. In the case where the current response sequence number is between the responded sequence number and the sent sequence number, it can be determined that the current response sequence number is valid, and the responded sequence number can be updated to the current response sequence number; on the contrary, in the case where the current response sequence number is not between the responded sequence number and the sent sequence number, it can be determined that the current response signal is invalid, and the current response sequence number can be directly discarded.
[0133] In this embodiment, since the reply packet is also transmitted through a multi-stage switching network, the reply packet may also be out of order; however, the out of order does not affect the judgment result on the receiving port side. Specifically, if the receiving port first receives a reply packet with a larger reply sequence number, it can still be said that the sending port has already confirmed all the data packets before the reply sequence number, so the replied sequence number needs to be updated; if a smaller reply sequence number is received later due to the out of order, the reply sequence number has lost its reply value, so it can be directly discarded. Through this simple reply mechanism, a reliable reply can be achieved when both the data packet and the reply packet are out of order.
[0134] Fig. 9 A schematic diagram of the process of sending and responding to data packets is shown. Fig. 9 As shown in the figure, if at a certain moment, the expected sequence number of the target sending port side is 10, the maximum sequence number is 9, and then the target receiving port sends data packets with sequence numbers 10 to 14 in sequence; the update process of the expected sequence number, the maximum sequence number and the acknowledged sequence number can be found in detail. Fig. 9 shown.
[0135] Step C2, when more target cache entries need to be allocated to the target receiving port, determine the number k of cache entries that need to be allocated to the target receiving port, and use the first k cache entries in the free pool linked list as the target cache entries allocated to the target receiving port.
[0136] In this embodiment, if more target cache entries need to be allocated to the target receiving port, for example, if the current sequence number is greater than the maximum sequence number, the number k of cache entries required for the target receiving port is first determined. The number k of cache entries can be determined based on the difference between the current sequence number and the maximum sequence number. For example, the number k of cache entries = current sequence number - maximum sequence number + 1.
[0137] After determining the number k of cache entries, k cache entries can be selected from the free pool linked list as new target cache entries. In order to reduce the operation on the free pool linked list, in this embodiment, the first k cache entries in the free pool linked list are used as target cache entries allocated to the target receiving port.
[0138] Optionally, if the cache entry includes storage space and a successor pointer for caching data packets, the above step C2 "using the first k cache entries in the free pool linked list as target cache entries assigned to the target receiving port" may specifically include the following steps C21 to C22.
[0139] Step C21, starting from the current tail position of the target pointer queue, write the pointers of the first k cache entries in the free pool linked list for the k queue entries of the target pointer queue in sequence, and shift the tail position of the target pointer queue backward by k positions; the target pointer queue is a pointer queue corresponding to the target receiving port. As described above, the pointer queue corresponds to the receiving port, and the pointer queue includes multiple queue entries, and the queue entries can store pointers to a cache entry; and the pointer queue is provided with a head position and a tail position, and the queue entries between the head position and the tail position are used to store pointers to the cache entries.
[0140] Step C22: Update the successor pointer of the last cache entry in the first k cache entries to be invalid.
[0141] In this embodiment, in order to make the valid area in the target pointer queue consistent with the target cache entries, for the newly added target cache entries, it is necessary to record the addresses of these target cache entries in the corresponding queue entries in the target pointer queue, that is, it is necessary to write the addresses of the first k cache entries in the free pool linked list into the corresponding queue entries in sequence; wherein, since these target cache entries are newly added, it is necessary to start from the current tail position of the target pointer queue and write the addresses of the first k cache entries in sequence, so that if the target linked list currently exists, the first k cache entries can be linked to the tail of the target linked list.
[0142] The successor pointer of the last cache entry in the first k cache entries in the linked cache is updated to be invalid, so that the last cache entry in the first k cache entries is adjusted to be the last cache entry in the target linked list. Furthermore, if a target linked list has been previously allocated to the target receiving port, the successor pointer of the last target cache entry in the previous target linked list needs to be updated to point to the first cache entry in the first k cache entries.
[0143] In addition, optionally, when setting the free pool head pointer and the head pointers of multiple receiving ports, the above step C2 "using the first k cache entries in the free pool linked list as target cache entries assigned to the target receiving port" can also include the following steps C23 to C24.
[0144] Step C23, when a linked list is newly added for the target receiving port, the head pointer of the target receiving port is set as the head pointer of the free pool linked list.
[0145] Step C24, after removing the first k cache entries of the free pool linked list, update the free pool head pointer to: the pointer of the first cache entry of the free pool linked list after removing the first k cache entries.
[0146] In this embodiment, before removing the first k cache entries of the free pool linked list, that is, before changing the successor pointers of these k cache entries in the linked cache, if a target linked list is currently being added for the target receiving port, that is, the target linked list is being created from scratch at this time, then the head pointer of the target receiving port needs to be set to the successor pointer of the last cache entry of the free pool linked list; if a target linked list for the target receiving port already exists, then the head pointer of the target receiving port does not need to be modified.
[0147] And, after removing the first k cache entries from the free pool linked list, the free pool head pointer needs to be updated. Specifically, the free pool head pointer is updated to: the pointer of the first cache entry of the free pool linked list after removing the first k cache entries.
[0148] Furthermore, optionally, if it is determined based on the maximum sequence number whether more target cache entries need to be allocated to the target receiving port, the above step S305 "caching the current data packet into the target cache entry allocated to the target receiving port" may include the following steps D1 to D3.
[0149] Step D1, when the current sequence number is greater than the maximum sequence number, cache the current data packet to the last target cache entry.
[0150] Step D2, when the current sequence number is less than the maximum sequence number, determine the corresponding offset according to the difference between the current sequence number and the expected sequence number of the target receiving port; the expected sequence number is the sequence number of the data packet that needs to be sent out this time, and the initial value of the expected sequence number is the minimum sequence number of the data packets transmitted by the target receiving port.
[0151] Step D3, cache the current data packet to the target cache entry pointed to by the pointer in the valid queue entry; the valid queue entry is: the queue entry corresponding to the first position in the target pointer queue plus the offset.
[0152] In this embodiment, if the current sequence number is greater than the maximum sequence number, after allocating more target cache entries to the target receiving port, the current data packet is cached to the last target cache entry, that is, the current data packet is cached to the last target cache entry of the target linked list.
[0153] If the current sequence number is less than the maximum sequence number, the corresponding offset can be determined based on the difference between the current sequence number and the expected sequence number of the target receiving port; for example, the offset = current sequence number – expected sequence number. Afterwards, based on the first position and offset in the target pointer queue, the corresponding target cache entry in the target linked list can be quickly located, that is, the target cache entry can be located within one clock cycle, with high processing efficiency.
[0154] Specifically, the queue entry at the position corresponding to "queue head position + offset" is used as a valid queue entry, and the pointer stored in the valid queue entry is the address of the required target cache entry, so that the current data packet obtained at this time can be cached to the target cache entry.
[0155] Step S306, after sending the previous data packet of the current data packet to the outside, taking out the current data packet from the corresponding target cache entry, and sending the current data packet to the outside.
[0156] For details, please see Figure 1 Step S104 of the illustrated embodiment will not be described in detail here.
[0157] In some optional implementations, due to the possibility of disorder, each time after a data packet is sent outward through the target receiving port, it is necessary to continue to determine whether the data packet can be sent further. Specifically, the method further includes the following steps E1.
[0158] Step E1, after sending a data packet to the outside, the subsequent judgment operation is executed cyclically until there is no need to send a packet to the outside.
[0159] Among them, "sending a data packet externally" includes: sending the current data packet externally when it is not out of order (the above step S304), sending the current data packet externally when it is out of order (the above step S306), or sending the previous data packet of the current data packet externally (before the above step S306), etc. In addition, the "subsequent judgment operation" executed cyclically may include steps E11 to E14.
[0160] Step E11, determining whether there is a cached data packet in the next target cache entry; the next target cache entry is the next target cache entry of the target cache entry that cached the last data packet sent externally.
[0161] In this embodiment, for the convenience of description, the target cache entry to be processed in this round of subsequent judgment operation is called "next target cache entry", and the next target cache entry is specifically the next target cache entry of the target cache entry of the last externally sent data packet. For example, if the subsequent judgment operation is performed after the current data packet is sent externally, the "target cache entry of the last externally sent data packet" is the target cache entry for caching the current data packet.
[0162] Among them, when a data packet is cached to a corresponding target cache entry, the data packet can be marked as valid; thereafter, when judging whether there is a cached data packet in the next target cache entry, it can be simply and quickly determined whether there is a cached data packet by checking whether the flag bit of the data packet is valid.
[0163] Step E12: when there is no cached data packet in the next target cache entry, it is determined that there is no need to send the packet outward.
[0164] Step E13: if there is a cached data packet in the next target cache entry, take out the cached data packet from the next target cache entry and send the cached data packet to the outside.
[0165] Step E14, reclaiming the next target cache entry to the free pool linked list.
[0166] In this embodiment, if there is no cached data packet in the next target cache entry, in order to ensure that the target sending port sends packets in the correct order, no more packets can be sent out, that is, no packets need to be sent out at this time. At this time, the sequence number of the last packet sent out can be used as the current response sequence number and fed back to the target receiving port.
[0167] If there is a cached data packet in the next target cache entry, it means that the packet can continue to be sent. Therefore, similar to sending the current data packet externally, the cached data packet can be taken out from the next target cache entry and sent externally; and, similar to the subsequent step S307, the next target cache entry is also recycled to the free pool linked list.
[0168] Furthermore, optionally, in the case of setting a pointer queue, after sending a data packet externally, in addition to reclaiming the target cache entry, the pointer queue also needs to be updated. Specifically, the method further includes the following step E2.
[0169] Step E2, after sending the data packet, the head position of the target pointer queue is moved backward by one position; the target pointer queue is the pointer queue corresponding to the target receiving port. Specifically, in order to ensure that the pointer queue is consistent with the target linked list, after sending the data packet, in addition to recycling the target cache entry to the free pool linked list, the head position of the target pointer queue needs to be moved backward by one position.
[0170] Optionally, the above step E11 "determining whether there is a cached data packet in the next target cache entry" may include: taking out the head pointer from the head position of the updated target pointer queue, and determining whether there is a cached data packet in the target cache entry pointed to by the head pointer.
[0171] In this embodiment, as shown in the above step E2, after sending the data packet externally, the head position of the target pointer queue is updated, and then the corresponding pointer, i.e., the head pointer, can be taken out from the head position of the updated target pointer queue, and the head pointer points to the next target cache entry. The next target cache entry can be simply and quickly located using the updated target pointer queue.
[0172] Step S307: Reclaim the target cache entry used to cache the current data packet to the free pool linked list.
[0173] For details, please see Figure 1 Step S105 of the illustrated embodiment will not be described in detail here.
[0174] In some optional implementations, if the cache entry includes storage space and a successor pointer for caching data packets, the above step S307 "reclaiming the target cache entry for caching the current data packet to the free pool linked list" may include the following steps F1 to F2.
[0175] Step F1, updating the successor pointer of the last cache entry of the free pool linked list to point to the target cache entry for caching the current data packet.
[0176] Step F2: updating the successor pointer of the target cache entry for caching the current data packet to be invalid.
[0177] In this embodiment, in the process of reclaiming the target cache entry, the successor pointer of the last cache entry in the free pool linked list can be updated to point to the target cache entry used to cache the current data packet; and the successor pointer of the target cache entry used to cache the current data packet is updated to invalid, so that the target cache entry used to cache the current data packet can be linked to the end of the queue of the free pool linked list, thereby realizing the recycling of the target cache list.
[0178] Optionally, in the case of setting the head pointer, the above step F1 "updates the successor pointer of the last cache entry of the free pool linked list to point to the target cache entry for caching the current data packet" may include the following steps F11 to F12.
[0179] Step F11, updating the successor pointer of the last cache entry of the free pool linked list to the head pointer of the target receiving port.
[0180] Step F12: After that, the successor pointer of the cache entry pointed to by the head pointer of the target receiving port is used as the new head pointer of the target receiving port.
[0181] In this embodiment, the head pointer of the target receiving port originally points to the target cache entry corresponding to the currently sent data packet, so the successor pointer of the last cache entry of the free pool linked list can be updated to the head pointer of the target receiving port; and, in order to ensure that the head pointer of the target receiving port is correct, it is also necessary to update it to the successor pointer of the cache entry pointed to by the head pointer of the target receiving port. It can be understood that step F12 needs to be executed before the above step F2.
[0182] To facilitate the description of the working process of the chain cache, an embodiment is used below to illustrate the process of implementing the out-of-order reordering.
[0183] In this embodiment, the cache depth L of the chain cache of the target sending port is 5, and the receiving port 2 is taken as the target receiving port. At the initialization, the data structure of the target sending port can be seen in Fig.10 Since this embodiment only takes the transmission of data packets by the receiving port 2 as an example, only the pointer queue of the receiving port 2 is shown.
[0184] Receiving port 2 sends data packets 0, 1, and 2 to the multi-stage interactive network in sequence (the sequence numbers of the three data packets are 0, 1, and 2, respectively). Since the minimum sequence number of a data packet is 0, the expected sequence number and maximum sequence number of receiving port 2 are both 0 at the target sending port side.
[0185] If the target sending port receives data packet 2 first, that is, the current sequence number = 2; at this time, the current sequence number is not equal to the expected sequence number, and the current sequence number is greater than the maximum sequence number, so more target cache entries need to be allocated to the target receiving port. At this time, the maximum sequence number can be updated to the current sequence number, that is, the maximum sequence number = 2.
[0186] Furthermore, based on the above steps C2 and so on, it can be determined that the number of cache entries k=3, so the first three cache entries in the free pool linked list (i.e., the three cache entries with addresses 0, 1, and 2) are used as the target cache entries assigned to receiving port 2. As shown in the above steps C21 and C22, the pointer queue of receiving port 2 (i.e., the target pointer queue) is updated, and the successor pointer of the cache entry with address 2 is updated to be invalid, thereby generating the target linked list "cache entry 0→cache entry 1→cache entry 2" of receiving port 2. Furthermore, since a new linked list is added for receiving port 2 at this time, based on the above steps C23 and C24, the head pointer of receiving port 2 is updated to the head pointer of the free pool linked list, i.e., 0; and then the free pool head pointer is updated to the pointer of the first cache entry of the free pool linked list after removing these three cache entries, i.e., 3.
[0187] And, as shown in step D1, the data packet 2 can be cached to the last target cache entry, that is, cached to cache entry 2. At this time, the data structure of the target sending port can be seen in Fig.11 As shown, the expected sequence number at this time = 0, and the maximum sequence number = 2.
[0188] Afterwards, if the target sending port receives data packet 1 again, the current sequence number is still different from the expected sequence number, but the current sequence number is less than the maximum sequence number. Therefore, based on the above steps D2 and D3, it can be determined that data packet 1 is cached to cache entry 1; the successor pointer, head pointer, pointer queue, etc. remain unchanged. At this time, the data structure of the target sending port can be seen in Fig.12 As shown, the expected sequence number at this time = 0, and the maximum sequence number = 2.
[0189] Afterwards, if the target sending port receives data packet 0 again, the current sequence number is the same as the expected sequence number, so data packet 0 can be sent externally; wherein, data packet 0 can be cached to the corresponding target cache entry, i.e., cache entry 0, and then data packet 0 is taken out from cache entry 0 and sent externally. After the external transmission is successful, the expected sequence number can be added by 1, i.e., the expected sequence number = 1.
[0190] And, after the external transmission is successful, based on the above step E2, the head position of the pointer queue of the receiving port 2 is moved back one position; and the cache entry 0 needs to be recycled to the free pool linked list, and the recycling process is similar to the process of the above steps F1 to F2.
[0191] Specifically, when reclaiming cache entry 0, as shown in step F11 and step F12, the successor pointer of the last cache entry in the free pool linked list is updated to the head pointer of receiving port 2, that is, the successor pointer of cache entry 5 is updated from invalid to 0, and the head pointer of receiving port 2 is updated to the successor pointer of the cache entry it points to, that is, the successor pointer of cache entry 0, so the head pointer of receiving port 2 is updated to 1. Afterwards, based on step F2, the successor pointer of the target cache entry used to cache the last data packet sent out is updated to invalid, that is, the successor pointer of cache entry 0 is updated to invalid. At this time, the data structure of the target sending port can be seen in Fig.13 As shown, the expected sequence number at this time is 0, and the maximum sequence number is 2. At this time, there is no data packet 0 in cache entry 0. Fig.13 The figure is only for convenience in showing the cache location of packet 0.
[0192] Furthermore, after sending data packet 0 externally, it is necessary to determine whether it is necessary to send packets externally, that is, to perform a "subsequent determination operation". As shown in the above steps E11 to E14, the target cache entry for the last external data packet was cache entry 0, so the next target cache entry at this time is cache entry 1; since there is a cached data packet in cache entry 1, that is, data packet 1, it is necessary to take data packet 1 out of cache entry 1 and send data packet 1 externally. Furthermore, after sending data packet 1, similar to the sending of data packet 0 above, the corresponding successor pointer, head pointer and pointer queue are updated. At this time, the data structure of the target sending port can be seen in Fig.14 As shown, the expected sequence number at this time = 1, and the maximum sequence number = 2.
[0193] After sending data packet 1, the "subsequent judgment operation" is performed again. At this time, the next target cache entry is cache entry 2, so it is necessary to take data packet 2 from cache entry 2 and send it out. Similarly, the corresponding successor pointer, head pointer and pointer queue are updated. At this time, the data structure of the target sending port can be seen in Fig.15 As shown, the expected sequence number at this time = 2, and the maximum sequence number = 2.
[0194] In addition, optionally, in order to ensure that the chain buffer allocation of the target sending port does not overflow, this embodiment further provides a back pressure mechanism, which determines when to send a back pressure signal based on the maximum number of in-transit signals. Specifically, the back pressure mechanism includes the following steps G1 to G2.
[0195] Step G1, determining whether the cache space size of the free pool linked list is less than a target threshold; the target threshold is not less than the maximum amount of in-transit data corresponding to the target sending port.
[0196] In this embodiment, the maximum amount of in-transit data refers to the maximum amount of data that can exist in the multi-stage switching network due to the cache function of the network itself.
[0197] Optionally, the process of determining the maximum amount of in-transit data corresponding to the target sending port may include the following steps G11 to G13.
[0198] Step G11, setting the target sending port to stop receiving data packets from the multi-stage switching network. That is, in this case, the target sending port no longer receives any data from the multi-stage switching network.
[0199] Step G12, controlling at least part of the receiving ports to send data packets to the target sending ports until the multi-stage switching network cannot receive data packets from the receiving ports.
[0200] Step G13, counting the total amount of data sent by at least part of the receiving ports to the multi-stage switching network, and using the total amount of data as the maximum amount of in-transit data corresponding to the target sending port.
[0201] For example, all receiving ports can be controlled to send data packets to the target sending port. Since the target sending port does not receive data from the multi-stage switching network at this time, the data packets sent by these receiving ports can only be in the multi-stage switching network. If the multi-stage switching network cannot receive data packets from the receiving port, it means that the multi-stage switching network is saturated. At this time, the total amount of data sent by these receiving ports to the multi-stage switching network is counted. The total amount of data is the maximum amount of in-transit data corresponding to the target sending port, that is, the amount of data of all data packets that the multi-stage switching network can accommodate.
[0202] Step G2: When the cache space of the free pool linked list is less than the target threshold, a back pressure signal is sent to at least part of the receiving ports; the receiving ports receiving the back pressure signal stop sending data packets to the multi-stage switching network.
[0203] In this embodiment, the linked cache of each sending port must reserve a cache space that is not less than the maximum amount of in-transit data. Specifically, a target threshold that is not less than the maximum amount of in-transit data is set. If the cache space of the free pool linked list is greater than the target threshold, it means that the free space in the linked cache is sufficient; on the contrary, if the cache space of the free pool linked list is less than the target threshold, it is necessary to take a back pressure measure, that is, send a back pressure signal to at least some of the receiving ports.
[0204] For example, a back pressure signal may be sent to all receiving ports; or, a back pressure signal may be sent only to the receiving port that currently has a disorder problem, which may be determined based on actual conditions. The receiving port that receives the back pressure signal stops sending data packets to the multi-stage switching network, thereby stopping sending data packets to the target sending port.
[0205] After the target sending port sends the back pressure signal to the target receiving port, it can still continue to receive data packets from the multi-level interconnection network. In addition, if some cache entries are recycled to the free pool linked list, making the cache space of the free pool linked list greater than the target threshold (a larger threshold can also be taken to prevent frequent switching between normal and back pressure states), a release signal for releasing the back pressure signal is sent to the receiving port, so that the receiving port switches from the back pressure state to the normal state, so that the data packet can be sent to the multi-level interconnection network again.
[0206] The data packet reordering method provided in this embodiment uses a shared chain buffer for each sending port to sort the data packets sent by multiple receiving ports respectively, which can greatly reduce the usage of buffer space while ensuring correct data transmission, and can reduce hardware costs. Combined with the head pointer and the pointer queue, the chain buffer can be shared simply and conveniently for use by multiple receiving ports. The corresponding threshold is determined based on the maximum amount of in-transit data, so that back pressure can be accurately achieved to avoid overflow.
[0207] In this embodiment, a data packet reordering device is also provided, which is used to implement the above embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0208] This embodiment provides a data packet reordering device, which is applied to a sending node of a multi-stage switching network, wherein the sending node includes at least one target sending port for sending data packets externally. Fig.16 As shown, the device comprises:
[0209] The pre-processing module 1601 is used to allocate a linked cache for reordering data packets to the target sending port; the linked cache includes a plurality of cache entries for caching data packets, and the cache entries initially belong to a free pool linked list;
[0210] The acquisition module 1602 is used to acquire the current data packet transmitted by the target receiving port through the multi-stage switching network; the target receiving port is a receiving port in the multi-stage switching network;
[0211] The out-of-order processing module 1603 caches the current data packet to a target cache entry assigned to the target receiving port when the current data packet is out of order; the target cache entry is a cache entry taken from the free pool linked list and used to cache unsent data packets in order;
[0212] The sending module 1604 is used to fetch the current data packet from the corresponding target cache entry after sending the previous data packet of the current data packet externally, and send the current data packet externally;
[0213] The recycling module 1605 is used to recycle the target cache entry used to cache the current data packet to the free pool linked list.
[0214] In some optional implementations, the sending module 1604 is further configured to:
[0215] In the case that the current data packet is not out of order, the current data packet is sent externally, and then the recycling module 1605 executes the step of recycling the target cache entry used to cache the current data packet to the free pool linked list.
[0216] In some optional implementations, the sending module 1604 is further used to: after sending the data packet externally, cyclically perform subsequent judgment operations until there is no need to send the packet externally;
[0217] The subsequent judgment operation includes:
[0218] Determine whether there is a cached data packet in the next target cache entry; the next target cache entry is the next target cache entry of the target cache entry that caches the last data packet sent externally;
[0219] When there is no cached data packet in the next target cache entry, determining that there is no need to send the packet externally;
[0220] If there is a cached data packet in the next target cache entry, taking the cached data packet from the next target cache entry and sending the cached data packet externally;
[0221] The next target cache entry is recycled to the free pool linked list.
[0222] In some optional implementations, the preprocessing module 1601 is further used to: set a plurality of pointer queues; the pointer queues correspond to the receiving ports, and the pointer queues include a plurality of queue entries, and the queue entries can store a pointer to one of the cache entries; and the pointer queues are provided with a head position and a tail position, and the queue entries between the head position and the tail position are used to store pointers to the cache entries;
[0223] After sending the data packet externally, the head position of the target pointer queue is moved backward by one position; the target pointer queue is the pointer queue corresponding to the target receiving port.
[0224] In some optional embodiments, the sending module 1604 determines whether there is a cached data packet in the next target cache entry, including: taking out the head pointer from the head position of the updated target pointer queue, and determining whether there is a cached data packet in the target cache entry pointed to by the head pointer.
[0225] In some optional implementations, the cache entry includes a storage space for caching data packets and a successor pointer, the successor pointer pointing to the next cache entry in order;
[0226] The recycling module 1605 recycles the target cache entry used for caching the current data packet to the free pool linked list, including:
[0227] Update the successor pointer of the last cache entry of the free pool linked list to point to the target cache entry for caching the current data packet;
[0228] The successor pointer of the target cache entry used to cache the current data packet is updated to be invalid.
[0229] In some optional implementations, the preprocessing module 1601 is further used to: set a free pool head pointer and head pointers of multiple receiving ports; wherein the free pool head pointer points to: the first cache entry of the free pool linked list; the head pointer of the receiving port points to: the first cache entry of the linked list composed of cache entries assigned to the receiving port in the linked cache arranged in order;
[0230] The recycling module 1605 updates the successor pointer of the last cache entry of the free pool linked list to point to the target cache entry for caching the current data packet, including:
[0231] Updating the successor pointer of the last cache entry of the free pool linked list to the head pointer of the target receiving port;
[0232] Afterwards, the successor pointer of the cache entry pointed to by the head pointer of the target receiving port is used as a new head pointer of the target receiving port.
[0233] In some optional embodiments, the device further comprises a distribution module, which is used to:
[0234] In the case where the current data packets are out of order, determining whether more target cache entries need to be allocated to the target receiving port;
[0235] When more target cache entries need to be allocated to the target receiving port, the number k of cache entries required to be allocated to the target receiving port is determined, and the first k cache entries in the free pool linked list are used as target cache entries allocated to the target receiving port.
[0236] In some optional implementations, the cache entry includes a storage space for caching data packets and a successor pointer, the successor pointer pointing to the next cache entry in order;
[0237] The allocation module uses the first k cache entries in the free pool linked list as target cache entries allocated to the target receiving port, including:
[0238] Starting from the current tail position of the target pointer queue, write the pointers of the first k cache entries in the free pool linked list in sequence for the k queue entries of the target pointer queue, and shift the tail position of the target pointer queue backward by k positions; the target pointer queue is a pointer queue corresponding to the target receiving port; the pointer queue corresponds to the receiving port, and the pointer queue includes a plurality of queue entries, and the queue entries can store a pointer pointing to one of the cache entries; and the pointer queue is provided with a head position and a tail position, and the queue entries between the head position and the tail position are used to store pointers pointing to the cache entries;
[0239] The successor pointer of the last cache entry among the first k cache entries is updated to be invalid.
[0240] In some optional implementations, the preprocessing module 1601 is further used to:
[0241] A free pool head pointer and a plurality of receiving port head pointers are set; wherein the free pool head pointer points to: the first cache entry of the free pool linked list; the receiving port head pointer points to: the first cache entry of the linked list composed of cache entries allocated to the receiving port in the linked cache arranged in order;
[0242] In the case of adding a linked list for the target receiving port, setting the head pointer of the target receiving port as the head pointer of the free pool linked list;
[0243] After removing the first k cache entries of the free pool linked list, the free pool head pointer is updated to: a pointer to the first cache entry of the free pool linked list after removing the first k cache entries.
[0244] In some optional implementations, the current data packet includes a current sequence number set in sequence;
[0245] The allocation module determines whether more target cache entries need to be allocated to the target receiving port, including:
[0246] Determine whether the current sequence number is greater than the maximum sequence number of the target receiving port; the maximum sequence number is the largest sequence number of the received data packets, and the initial value of the maximum sequence number is the minimum sequence number of the data packets transmitted by the target receiving port;
[0247] In the case that the current sequence number is greater than the maximum sequence number, more target cache entries need to be allocated to the target receiving port; and the maximum sequence number is updated to the current sequence number.
[0248] In some optional implementations, the out-of-order processing module 1603 caches the current data packet to a target cache entry assigned to the target receiving port, including:
[0249] When the current sequence number is greater than the maximum sequence number, caching the current data packet to the last target cache entry;
[0250] In the case where the current sequence number is less than the maximum sequence number, the corresponding offset is determined according to the difference between the current sequence number and the expected sequence number of the target receiving port; the expected sequence number is the sequence number of the data packet to be sent externally this time, and the initial value of the expected sequence number is the minimum sequence number of the data packet transmitted by the target receiving port;
[0251] The current data packet is cached in a target cache entry pointed to by a pointer in a valid queue entry; the valid queue entry is: a queue entry corresponding to the first position in the target pointer queue plus the offset.
[0252] In some optional implementations, the current data packet includes a current sequence number set in sequence; and the device further includes a determination module, configured to:
[0253] Determine whether the current sequence number is the same as the expected sequence number of the target receiving port; the expected sequence number is the sequence number of the data packet to be sent externally this time, and the initial value of the expected sequence number is the minimum sequence number of the data packet transmitted by the target receiving port;
[0254] When the current sequence number is the same as the expected sequence number, determining that the current data packet is not out of order;
[0255] In a case where the current sequence number is different from the expected sequence number, it is determined that the current data packet is out of sequence.
[0256] In some optional embodiments, the device further comprises a feedback module, which is used to:
[0257] After sending the data packet externally, the sequence number of the data packet sent externally this time is used as the current response sequence number and fed back to the target receiving port.
[0258] In some optional embodiments, the device further comprises a back pressure module, which is used to:
[0259] Determine whether the cache space size of the free pool linked list is less than a target threshold; the target threshold is not less than the maximum amount of in-transit data corresponding to the target sending port;
[0260] When the cache space of the free pool linked list is less than the target threshold, a back pressure signal is sent to at least part of the receiving ports; the receiving ports receiving the back pressure signal stop sending data packets to the multi-stage switching network.
[0261] In some optional implementations, the maximum amount of in-transit data corresponding to the target sending port is determined by:
[0262] Setting the target sending port to stop receiving data packets from the multi-stage switching network;
[0263] Controlling at least some of the receiving ports to send data packets to the target sending port until the multi-stage switching network cannot receive data packets from the receiving ports;
[0264] The total amount of data sent by at least part of the receiving ports to the multi-stage switching network is counted, and the total amount of data is used as the maximum amount of in-transit data corresponding to the target sending port.
[0265] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0266] The data packet reordering device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, including a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0267] The embodiment of the present invention also provides a switching chip, such as a PCIe Switch chip, which can be applied to a general server, an AI server, etc. The switching chip includes: a plurality of receiving ports and a plurality of sending ports; the plurality of receiving ports and the plurality of sending ports are interconnected through a multi-stage switching network; for example, an architecture of the switching chip can be seen in Fig.17 As shown, node 0-0 and node 0-1 are first-level nodes, node 1-0, node 1-1, and node 1-2 are second-level nodes, and node 2-0 and node 2-1 are third-level nodes.
[0268] At least some of the sending ports are configured to send data packets externally according to the data packet reordering method provided in the above embodiment. For example, a corresponding chain cache can be set for each sending port of the switching chip, and sharing is achieved based on the chain cache to reduce the cache space required by the switching chip.
[0269] In some optional embodiments, after the target sending port sends the data packet transmitted by the target receiving port, the sequence number of the data packet sent this time is used as the current response sequence number and fed back to the target receiving port; the target sending port is a sending port in the switching chip, and the target receiving port is a receiving port in the switching chip.
[0270] Among them, the target receiving port records the acknowledged sequence number and the sent sequence number; the acknowledged sequence number is the maximum valid acknowledgement sequence number received, and the sent sequence number is the maximum sequence number of the data packet currently sent by the target receiving port; after receiving the current acknowledgement sequence number, the target receiving port determines whether the current acknowledgement sequence number is between the acknowledged sequence number and the sent sequence number; when the current acknowledgement sequence number is between the acknowledged sequence number and the sent sequence number, it is determined that the current acknowledgement sequence number is valid, and the acknowledged sequence number is updated to the current acknowledgement sequence number; when the current acknowledgement sequence number is not between the acknowledged sequence number and the sent sequence number, the current acknowledgement sequence number is discarded.
[0271] The target receiving port implements the response method. For details, please refer to Figure 8 , Fig. 9 The relevant description is not repeated here. In this embodiment, the target sending port gives a response sequence number, indicating that all data packets before the response sequence number have been received, and the response sequence number may be discontinuous. After receiving the response sequence number, the receiving port only needs to determine whether it is in the valid area, and then update the response sequence number. This mechanism can achieve reliable response when both data and response paths are out of order.
[0272] Optionally, the target sending port is directly connected to at least some of the receiving ports via a control line; the target sending port is a sending port in the switching chip; when the target sending port needs to send a back pressure signal to the receiving port, the level of the corresponding control line is adjusted.
[0273] In this embodiment, a certain transmitting port may be directly connected to some or all receiving ports, and then a back pressure signal may be sent in the form of a level signal. For example, if back pressure is required, a high level signal is output; if back pressure needs to be released, a low level signal is output.
[0274] By using the directly connected control lines, each transmitting port can use a 1-bit backpressure signal for each receiving port, and the backpressure signal can be connected from the transmitting port to the receiving port in a fully connected network. Fig.18 FIG. 6 shows a schematic diagram of a back pressure signal output by the sending port 6. Therefore, although the multi-stage switching network is an N×M fully connected network ( Fig.18In the example, N=16, M=16), since the back pressure signal is only 1 bit, back pressure can still be easily implemented; and since the control line transmits signals quickly, the back pressure signal can be transmitted to the corresponding receiving port in a very short fixed time.
[0275] In addition, each receiving port can receive M back pressure signals (M is the number of sending ports), which come from M sending ports. When the receiving port receives the back pressure signal, it judges the data packet to be sent. If the back pressure signal of the target port of the data packet is valid (i.e., back pressure is required), the receiving port cannot output the data packet to the multi-stage switching network. Otherwise, the receiving port can still output normally. This ensures that when back pressure occurs, data packets that do not bring overflow risks to the sending port cache can still pass through the multi-stage switching network, thereby improving throughput.
[0276] The embodiment of the present invention further provides a network device, which includes the switching chip as described above. For example, the network device may be a switch, a network card, and the like.
[0277] The embodiment of the present invention also provides a computer device having the above Fig.16 The data packet reordering device is shown.
[0278] See also Fig.19 , Fig.19 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Fig.19 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Fig.19 A processor 10 is taken as an example.
[0279] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0280] The memory 20 stores instructions executable by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.
[0281] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0282] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0283] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.
[0284] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0285] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A method for reordering a data packet, characterized in that: A sending node applied to a multi-stage switching network, the sending node comprising at least one target sending port for sending data packets externally, the method comprising: Allocating a linked cache for reordering data packets to the target sending port; the linked cache includes a plurality of cache entries for caching data packets, the cache entries initially belonging to a free pool linked list; the linked cache is shared by a plurality of receiving ports in the multi-stage switching network; the cache entry includes a storage space for caching data packets and a successor pointer, the successor pointer pointing to the next cache entry in order; Acquire a current data packet transmitted by a target receiving port through the multi-stage switching network; the target receiving port is a receiving port in the multi-stage switching network; In the case where the current data packet is out of order, the current data packet is cached in a target cache entry assigned to the target receiving port; the target cache entry is a cache entry taken from the free pool linked list and used to cache unsent data packets in order; After sending a previous data packet of the current data packet externally, taking out the current data packet from the corresponding target cache entry, and sending the current data packet externally; Reclaiming the target cache entry used for caching the current data packet to the free pool linked list; The step of reclaiming the target cache entry used for caching the current data packet to the free pool linked list includes: Update the successor pointer of the last cache entry of the free pool linked list to point to the target cache entry for caching the current data packet; updating a subsequent pointer of a target cache entry for caching the current data packet to be invalid; The method further comprises: A plurality of pointer queues are provided; the pointer queues correspond to the receiving ports, and the pointer queues include a plurality of queue entries, and the queue entries are capable of storing a pointer pointing to one of the cache entries; and the pointer queues are provided with a head position and a tail position, and the queue entries between the head position and the tail position are used to store pointers pointing to the cache entries assigned to the corresponding receiving ports; After sending the data packet externally, the head position of the target pointer queue is moved backward by one position; the target pointer queue is the pointer queue corresponding to the target receiving port; The current data packet includes a current sequence number set in sequence; and caching the current data packet to a target cache entry assigned to the target receiving port includes: In the case where the current sequence number is greater than the maximum sequence number, the current data packet is cached to the last target cache entry; the maximum sequence number is the largest sequence number among the data packets received by the target receiving port, and the initial value of the maximum sequence number is the minimum sequence number of the data packets transmitted by the target receiving port; In the case where the current sequence number is less than the maximum sequence number, the corresponding offset is determined according to the difference between the current sequence number and the expected sequence number of the target receiving port; the expected sequence number is the sequence number of the data packet to be sent externally this time, and the initial value of the expected sequence number is the minimum sequence number of the data packet transmitted by the target receiving port; The current data packet is cached in a target cache entry pointed to by a pointer in a valid queue entry; the valid queue entry is: a queue entry corresponding to the first position in the target pointer queue plus the offset.
2. The method according to claim 1, characterized in that Also includes: In the case that the current data packet is not out of order, the current data packet is sent externally, and then the step of recycling the target cache entry used to cache the current data packet to the free pool linked list is performed.
3. The method according to claim 1 or 2, characterized in that: Also includes: After sending a data packet to the outside, the subsequent judgment operations are executed cyclically until there is no need to send a packet to the outside; The subsequent judgment operation includes: Determine whether there is a cached data packet in the next target cache entry; The next target cache entry is the next target cache entry of the target cache entry that caches the last data packet sent externally; When there is no cached data packet in the next target cache entry, determining that there is no need to send the packet externally; If there is a cached data packet in the next target cache entry, taking the cached data packet from the next target cache entry and sending the cached data packet externally; The next target cache entry is recycled to the free pool linked list.
4. The method according to claim 3, characterized in that The determining whether there is a cached data packet in the next target cache entry includes: The head pointer is taken out from the head position of the updated target pointer queue, and it is determined whether there is a cached data packet in the target cache entry pointed to by the head pointer.
5. The method according to claim 1, characterized in that Also includes: A free pool head pointer and a plurality of receiving port head pointers are set; wherein the free pool head pointer points to: the first cache entry of the free pool linked list; the receiving port head pointer points to: the first cache entry of the linked list composed of cache entries allocated to the receiving port in the linked cache arranged in order; The updating of the successor pointer of the last cache entry of the free pool linked list to point to the target cache entry for caching the current data packet comprises: Updating the successor pointer of the last cache entry of the free pool linked list to the head pointer of the target receiving port; Afterwards, the successor pointer of the cache entry pointed to by the head pointer of the target receiving port is used as a new head pointer of the target receiving port.
6. The method according to claim 1, characterized in that Also includes: In the case where the current data packets are out of order, determining whether more target cache entries need to be allocated to the target receiving port; When more target cache entries need to be allocated to the target receiving port, the number k of cache entries required to be allocated to the target receiving port is determined, and the first k cache entries in the free pool linked list are used as target cache entries allocated to the target receiving port.
7. The method according to claim 6, characterized in that The method of using the first k cache entries in the free pool linked list as target cache entries allocated to the target receiving port includes: Starting from the current tail position of the target pointer queue, write the pointers of the first k cache entries in the free pool linked list for the k queue entries of the target pointer queue in sequence, and shift the tail position of the target pointer queue backward by k positions; The successor pointer of the last cache entry among the first k cache entries is updated to be invalid.
8. The method according to claim 7, characterized in that Also includes: A free pool head pointer and a plurality of receiving port head pointers are set; wherein the free pool head pointer points to: the first cache entry of the free pool linked list; the receiving port head pointer points to: the first cache entry of the linked list composed of cache entries allocated to the receiving port in the linked cache arranged in order; In the case of adding a linked list for the target receiving port, setting the head pointer of the target receiving port as the head pointer of the free pool linked list; After removing the first k cache entries of the free pool linked list, the free pool head pointer is updated to: a pointer to the first cache entry of the free pool linked list after removing the first k cache entries.
9. The method according to claim 7, characterized in that: The determining whether more target cache entries need to be allocated to the target receiving port includes: Determine whether the current sequence number is greater than the maximum sequence number of the target receiving port; In the case that the current sequence number is greater than the maximum sequence number, more target cache entries need to be allocated to the target receiving port; and the maximum sequence number is updated to the current sequence number.
10. The method according to claim 1, characterized in that The method further comprises: Determining whether the current sequence number is the same as the expected sequence number of the target receiving port; When the current sequence number is the same as the expected sequence number, determining that the current data packet is not out of order; In a case where the current sequence number is different from the expected sequence number, it is determined that the current data packet is out of sequence.
11. The method according to claim 1, characterized in that: Also includes: After sending the data packet externally, the sequence number of the data packet sent externally this time is used as the current response sequence number and fed back to the target receiving port.
12. The method according to claim 1, characterized in that Also includes: Determine whether the cache space size of the free pool linked list is less than a target threshold; The target threshold is not less than the maximum amount of in-transit data corresponding to the target sending port; When the cache space of the free pool linked list is less than the target threshold, a back pressure signal is sent to all receiving ports or receiving ports that currently have an out-of-order problem; the receiving port that receives the back pressure signal stops sending data packets to the multi-stage switching network.
13. The method according to claim 12, characterized in that The maximum amount of in-transit data corresponding to the target sending port is determined in the following manner: Setting the target sending port to stop receiving data packets from the multi-stage switching network; Controlling each receiving port to send a data packet to the target sending port until the multi-stage switching network cannot receive the data packet from the receiving port; The total amount of data sent by each receiving port to the multi-stage switching network is counted, and the total amount of data is used as the maximum amount of in-transit data corresponding to the target sending port.
14. A data packet reordering device, characterized in that: A sending node applied to a multi-stage switching network, the sending node comprising at least one target sending port for sending data packets externally, the device comprising: A preprocessing module, configured to allocate a chain cache for reordering data packets to the target sending port; the chain cache includes a plurality of cache entries for caching data packets, the cache entries initially belonging to a free pool linked list; the chain cache is shared by a plurality of receiving ports in the multi-stage switching network; the cache entry includes a storage space for caching data packets and a successor pointer, the successor pointer pointing to the next cache entry in order; An acquisition module, used for acquiring a current data packet transmitted by a target receiving port through the multi-stage switching network; the target receiving port is a receiving port in the multi-stage switching network; an out-of-order processing module, which, when the current data packet is out of order, caches the current data packet into a target cache entry assigned to the target receiving port; the target cache entry is a cache entry taken from the free pool linked list and used to cache unsent data packets in order; A sending module, configured to fetch the current data packet from a corresponding target cache entry after sending a previous data packet of the current data packet externally, and send the current data packet externally; A recycling module, used for recycling the target cache entry used for caching the current data packet to the free pool linked list; The recycling module reclaims the target cache entry used to cache the current data packet to the free pool linked list, including: Update the successor pointer of the last cache entry of the free pool linked list to point to the target cache entry for caching the current data packet; updating a subsequent pointer of a target cache entry for caching the current data packet to be invalid; The preprocessing module is further used to: set a plurality of pointer queues; the pointer queues correspond to the receiving ports, and the pointer queues include a plurality of queue entries, and the queue entries can store a pointer to one of the cache entries; and the pointer queues are provided with a head position and a tail position, and the queue entries between the head position and the tail position are used to store pointers to the cache entries assigned to the corresponding receiving ports; after sending a data packet externally, the head position of the target pointer queue is moved backward by one position; the target pointer queue is a pointer queue corresponding to the target receiving port; The current data packet includes a current sequence number set in sequence; and caching the current data packet to a target cache entry assigned to the target receiving port includes: In the case where the current sequence number is greater than the maximum sequence number, the current data packet is cached to the last target cache entry; the maximum sequence number is the largest sequence number among the data packets received by the target receiving port, and the initial value of the maximum sequence number is the minimum sequence number of the data packets transmitted by the target receiving port; In the case where the current sequence number is less than the maximum sequence number, the corresponding offset is determined according to the difference between the current sequence number and the expected sequence number of the target receiving port; the expected sequence number is the sequence number of the data packet to be sent externally this time, and the initial value of the expected sequence number is the minimum sequence number of the data packet transmitted by the target receiving port; The current data packet is cached in a target cache entry pointed to by a pointer in a valid queue entry; the valid queue entry is: a queue entry corresponding to the first position in the target pointer queue plus the offset.
15. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the method for reordering data packets described in any one of claims 1 to 13 by executing the computer instructions.
16. A switching chip, characterized in that: include: A plurality of receiving ports and a plurality of sending ports; the plurality of receiving ports and the plurality of sending ports are interconnected via a multi-stage switching network; At least part of the sending ports are configured to send data packets externally according to the data packet reordering method according to any one of claims 1 to 13.
17. The switching chip according to claim 16, characterized in that: After the target sending port sends the data packet transmitted by the target receiving port, the target sending port uses the sequence number of the data packet sent this time as the current response sequence number and feeds it back to the target receiving port; the target sending port is a sending port in the switching chip, and the target receiving port is a receiving port in the switching chip; The target receiving port records the acknowledged sequence number and the sent sequence number; the acknowledged sequence number is the maximum valid acknowledgement sequence number received, and the sent sequence number is the maximum sequence number of the data packet currently sent by the target receiving port; After receiving the current response sequence number, the target receiving port determines whether the current response sequence number is between the responded sequence number and the sent sequence number; In the case where the current response sequence number is between the responded sequence number and the sent sequence number, determining that the current response sequence number is valid, and updating the responded sequence number to the current response sequence number; In the case that the current response sequence number is not between the acknowledged sequence number and the sent sequence number, the current response sequence number is discarded.
18. The switching chip according to claim 16, characterized in that: The target sending port is directly connected to at least part of the receiving ports via a control line; the target sending port is a sending port in the switching chip; In the case where the target sending port needs to send a back pressure signal to the receiving port, the level of the corresponding control line is adjusted.
19. A network device, characterized in that: The method comprises a switching chip as claimed in any one of claims 16 to 18.
20. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the data packet reordering method according to any one of claims 1 to 13.
