Message order preserving method and device and network equipment

By using multiple task queues and order-saving queues in network devices to maintain messages and order-saving data flows in concurrently processed, the problems of out-of-order messages and software order-saving resources in network devices are solved, and higher order-saving depth and performance are achieved.

CN120223653APending Publication Date: 2025-06-27BEIJING HUAWEI DIGITAL TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311813784.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-26
Publication Date
2025-06-27

AI Technical Summary

Technical Problem

In network devices, due to the different delays of multiple processing modules in parallel processing packets, the packets in the data stream are out of order, and the existing software sequence-saving method requires additional consumption of data processing resources of network devices, affecting performance.

Method used

By configuring a network device with multiple task queues and order-saving queues, messages are distributed to multiple task queues, and messages that have been dispatched from the task queue are protected through multiple order-saving queues, and finally, order-saving of the processed messages in the data stream is completed through aggregation operation.

Benefits of technology

It realizes that the order-keeping depth of network equipment is maintained when the network equipment is protected by the data flow while avoiding additional consumption of network equipment data processing resources, thereby improving the order-keeping performance of network equipment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120223653A_ABST
    Figure CN120223653A_ABST
Patent Text Reader

Abstract

The invention discloses a message order preserving method and device and network equipment, and belongs to the technical field of communication. The method is applied to network equipment configured with a first task queue, a first order-preserving queue, a second task queue and a second order-preserving queue. The method comprises the following steps: distributing a message of a first data stream to be processed to a first task queue and a second task queue; performing order preserving on the messages which are scheduled and dequeued from the first task queue through a first order preserving queue to obtain a first order preserving result, and performing order preserving on the messages which are scheduled and dequeued from the second task queue through a second order preserving queue to obtain a second order preserving result; and executing an aggregation operation on the first order preserving result and the second order preserving result to complete order preserving of the processed messages in the first data stream. Through the method, the order-preserving depth of the network equipment is improved under the condition of avoiding extra consumption of data processing resources of the network equipment, and the order-preserving performance of the network equipment is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technologies, and particularly to a method and apparatus for packet sequence preservation and a network device. Background Art

[0002] Currently, to improve the packet processing efficiency, a network device can process packets in a data stream in parallel through multiple processing modules (such as multiple central processing units (CPUs)).

[0003] The delays of multiple processing modules for parallel packet processing are generally different, which may cause packet out-of-order when packets in a data stream are processed in parallel through multiple processing modules. Therefore, when a network device processes packets in a data stream in parallel through multiple processing modules, it is necessary to preserve the order of the processed packets. Summary of the Invention

[0004] The present application provides a method and apparatus for packet sequence preservation and a network device, and the method can improve the sequence preservation performance of the network device.

[0005] The technical solution provided by the present application is as follows:

[0006] In a first aspect, the present application provides a method for packet sequence preservation. The method is applied to a network device configured with a first task queue, a first sequence preservation queue, a second task queue, and a second sequence preservation queue. The method includes: distributing packets of a first data stream to be processed to the first task queue and the second task queue; preserving the order of the packets dequeued from the first task queue through the first sequence preservation queue to obtain a first sequence preservation result, and preserving the order of the packets dequeued from the second task queue through the second sequence preservation queue to obtain a second sequence preservation result; performing an aggregation operation on the first sequence preservation result and the second sequence preservation result to complete the sequence preservation of the processed packets in the first data stream.

[0007] Through the method provided by the present application, the purpose of preserving the order of packets in a concurrently processed data stream through multiple sequence preservation queues in a network device is achieved, so that it is possible to avoid additional consumption of network device data processing resources caused by software sequence preservation and improve the sequence preservation depth when the network device preserves the order of packets in a data stream, thereby improving the sequence preservation performance of the network device.

[0008] In a possible design, the above-mentioned first task queue and first sequence preservation queue are provided in a first scheduler of the network device, the above-mentioned second task queue and second sequence preservation queue are provided in a second scheduler of the network device, and the first scheduler and the second scheduler are integrated in different system-on-chips (SoCs) of the network device.

[0009] Through this possible design method, the purpose of packet sequence preservation for concurrently processed data streams is achieved through the ordered queues of schedulers on multiple SoCs in a network device. That is, packet sequence preservation is performed on the packets of the same data stream by using the ordered resources of schedulers on multiple SoCs, so that the packet sequence preservation depth can be increased.

[0010] In another possible design method, the above-mentioned first task queue and first ordered queue are set in the first scheduler of the network device, and the above-mentioned second task queue and second ordered queue are set in the second scheduler of the network device. The first scheduler and the second scheduler are integrated into the same SoC of the network device.

[0011] Through this possible design method, the purpose of packet sequence preservation for concurrently processed data streams is achieved through the ordered queues of multiple schedulers on the SoC in a network device. That is, packet sequence preservation is performed on the packets of the same data stream by using the ordered resources of multiple schedulers on the SoC, so that the packet sequence preservation depth can be increased.

[0012] In yet another possible design method, when the above-mentioned first scheduler is configured as the main scheduler, the above-mentioned aggregation operation on the first ordered result and the second ordered result includes: performing the aggregation operation on the first ordered result and the second ordered result by the first scheduler.

[0013] In yet another possible design method, a cache queue is set in the above-mentioned first scheduler, and the method further includes: sending the second ordered result to the cache queue according to the aggregation mark included in the element used to indicate the packets of the first data stream in the second ordered queue. The above-mentioned aggregation operation on the first ordered result and the second ordered result by the first scheduler includes: performing the aggregation operation on the first ordered result and the second ordered result indicated by the cache queue by the first scheduler. Wherein, the aggregation mark is used to indicate that the first scheduler performs the aggregation operation on the first ordered result and the second ordered result.

[0014] In yet another possible design method, before the above-mentioned sending the second ordered result to the cache queue according to the aggregation mark included in the element used to indicate the packets of the first data stream in the second ordered queue, the method further includes: adding an aggregation mark to the element used to indicate the first packet in the second task queue for the first packet in the first data stream; migrating the element used to indicate the first packet from the second task queue to the second ordered queue. Wherein, the first packet is any packet scheduled to the second task queue in the first data stream. Or, before the above-mentioned sending the second ordered result to the cache queue according to the aggregation mark included in the element used to indicate the packets of the first data stream in the second ordered queue, the method further includes: adding an aggregation mark to the element used to indicate the first packet in the second ordered queue.

[0015] In yet another possible design, the above-mentioned aggregation operation performed by the first scheduler on the first in-order result and the second in-order result indicated by the cache queue includes: the first scheduler schedules the elements in the first in-order queue for indicating the first data stream packets and the elements in the cache queue for indicating the first data stream packets to the in-order completion queue in sequence according to the aggregation rule, so as to implement the aggregation operation performed on the first in-order result and the second in-order result indicated by the cache queue. Among them, the aggregation rule is a scheduling rule corresponding to the distribution rule, and the distribution rule is a scheduling rule for distributing the packets of the first data stream to the first task queue and the second task queue.

[0016] Through the above several possible design methods, the purpose of aggregating the in-order results of the in-order queues in multiple schedulers is achieved.

[0017] In yet another possible design, when the SoC to which the first scheduler belongs further includes other schedulers, the first scheduler and other schedulers share the above-mentioned cache queue. In this way, sharing the cache queue by multiple schedulers in the SoC can save the storage resources of the SoC.

[0018] In yet another possible design, the above-mentioned distribution of the packets of the first data stream to be processed to the first task queue and the second task queue includes: distributing the packets of the first data stream to be processed to the first task queue and the second task queue according to a preset distribution rule.

[0019] In a second aspect, the present application provides a packet in-order device. The packet in-order device is used to execute any method provided in the first aspect above. The present application can divide the functional modules of the packet in-order device according to any method provided in the first aspect above. For example, each functional module can be divided corresponding to each function, or two or more functions can be integrated into one processing module. Exemplarily, the present application can divide the packet in-order device into a distribution unit, an in-order unit, an aggregation unit, etc. according to functions. The descriptions of the possible technical solutions and beneficial effects executed by each of the above-mentioned divided functional modules can all refer to the solutions provided in the first aspect and any possible design method in the first aspect, and will not be elaborated here.

[0020] In a third aspect, the present application provides a network device. The network device includes: a memory, a communication interface, and one or more processors. Among them, the one or more processors receive or send data through the communication interface, and the one or more processors are configured to read program instructions stored in the memory to execute the method provided in the first aspect and any possible design method in the first aspect.

[0021] Fourthly, the present application provides a computer-readable storage medium, which is a non-volatile computer-readable storage medium and includes computer program instructions. When the computer program instructions are executed by a computing device or a processor, the computing device or the processor executes the method provided in the first aspect and any possible design manner in the first aspect.

[0022] Fifthly, the present application provides a computer program product containing instructions. When the instructions run on a computing device or a processor, the computing device or the processor is caused to execute the method provided in the first aspect and any possible design manner in the first aspect.

[0023] Sixthly, the present application provides a chip, which includes a processor for running program instructions or code. The chip or a device including the chip can be used to execute the method provided in the first aspect and any possible design manner in the first aspect. Exemplarily, the chip further includes: an input interface, an output interface, and a memory. Among them, the input interface, output interface, processor, and memory of the chip are connected through an internal connection path of the chip. The memory in the chip is used to store program instructions or code run by the processor, and the input interface and output interface of the chip are used for connection communication between the chip and other chips or devices.

[0024] It can be understood that any of the above-provided message sequence preservation devices, network devices, computer-readable storage media, computer program products, or chips, etc. can be applied to the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods and will not be elaborated here.

[0025] In the present application, the names of the above message sequence preservation devices, etc. do not constitute a limitation on the devices or functional modules themselves. In actual implementation, these devices or functional modules may appear under other names. As long as the functions of each device or functional module are similar to those of the present application, they all fall within the protection scope of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 is a schematic diagram of a message sequence preservation mechanism;

[0027] Figure 2 is a schematic diagram of an implementation environment provided by an embodiment of the present application;

[0028] Figure 3 is a schematic structural diagram of a network device provided by an embodiment of the present application;

[0029] Figure 4 is a schematic structural diagram of a scheduler in the network device provided by an embodiment of the present application;

[0030] Figure 5 It is another structural schematic diagram of the scheduler in the network device provided by the embodiment of the present application;

[0031] Figure 6 It is a flowchart of a packet sequence preservation method provided by the embodiment of the present application;

[0032] Figure 7 It is a schematic diagram of distributing packets provided by the embodiment of the present application;

[0033] Figure 8 It is another schematic diagram of distributing packets provided by the embodiment of the present application;

[0034] Figure 9 It is yet another schematic diagram of distributing packets provided by the embodiment of the present application;

[0035] Figure 10 It is a schematic diagram of the process of preserving the order of packets that have been scheduled and dequeued from the first task queue through the first order-preserving queue of the first scheduler provided by the embodiment of the present application;

[0036] Figure 11 It is a schematic diagram of aggregating the first order-preserving result and the second order-preserving result according to the aggregation rule provided by the embodiment of the present application;

[0037] Figure 12 It is another schematic diagram of aggregating the first order-preserving result and the second order-preserving result according to the aggregation rule provided by the embodiment of the present application;

[0038] Figure 13 It is a schematic diagram of a process of the packet sequence preservation method provided by the embodiment of the present application;

[0039] Figure 14 It is another flowchart of the packet sequence preservation method provided by the embodiment of the present application;

[0040] Figure 15 It is a structural schematic diagram of a packet sequence preservation device provided by the embodiment of the present application;

[0041] Figure 16 It is a structural schematic diagram of a network device provided by the embodiment of the present application;

[0042] Figure 17 It is another structural schematic diagram of a network device provided by the embodiment of the present application. Detailed implementation manners

[0043] To make the objectives, technical solutions and advantages of the present application clearer, the following will further describe the embodiments of the present application in detail with reference to the accompanying drawings.

[0044] For ease of understanding, the technologies and backgrounds involved in the embodiments of the present application will be explained below.

[0045] Since the delays of multiple processing modules of a network device in processing packets in parallel are generally different, packet disorder may occur when the packets in a data stream are processed in parallel by multiple processing modules of the network device. In this case, after a processing module in the network device finishes processing a certain service operation for any packet in the data stream, it cannot directly start the processing process of the next service for the packet, but needs to queue up and wait for other processing modules to complete the processing operation of the aforementioned "certain service" for the packets that belong to the same data stream as this packet and are in front of this packet. This will cause waste of the network device's data processing resources.

[0046] To avoid waste of the network device's data processing resources, the network device will adopt a packet ordering mechanism to perform packet ordering on the packets processed concurrently. Among them, the packet ordering mechanism is also called the packet (packet) ordering mechanism, which refers to the mechanism that the packets of a data stream remain in the same order after the network device concurrently finishes processing a certain service operation. In the current packet ordering mechanism, a packet ordering module (or called a packet order enforcer, POE) is designed in the network device. The packet ordering module can queue up and wait on behalf of the processing module in the network device that is used to perform processing operations on the packets, so as to ensure the order of the packets (denoted as co-flow packets or co-flow packets) that belong to the same data stream. In the packet ordering mechanism, since there is no need for the processing module of the network device to queue up and wait, the waste of the network device's data processing resources is avoided. In some implementation manners, the packet ordering module is implemented through an ordering queue set in the network device hardware scheduler.

[0047] Taking the processing module of the network device as a central processing unit (CPU), and the network device being configured with CPU 0, CPU 1, CPU 2, and CPU 3 as an example, refer to Figure 1 , Figure 1 shows a schematic diagram of a packet ordering mechanism.

[0048] As Figure 1As shown in the figure, assume that after packets 0, 1, 2, and 3 belonging to data stream 1 enter the task queue of the network device in sequence, the CPU 0, CPU 1, CPU 2, and CPU 3 of the network device concurrently perform the processing operation of service 1 on packets 0, 1, 2, and 3. When CPU 0, CPU 1, CPU 2, and CPU 3 start to concurrently perform the processing operation of service 1 on packets 0, 1, 2, and 3, the network device sends packets 0, 1, 2, and 3 into the in-sequence queue of the network device in sequence. Furthermore, at time t1, when CPU 3 finishes the processing operation of service 1 on packet 3, since packets 0, 1, and 2 in data stream 1 that are before packet 3 have not completed the processing operation of service 1, packet 3 waits in the in-sequence queue. Similarly, at time t2, when CPU 2 finishes the processing operation of service 1 on packet 2, since packets 0 and 1 in data stream 1 that are before packet 2 have not completed the processing operation of service 1, packet 2 waits in the in-sequence queue. At time t3, when CPU 0 finishes the processing operation of service 1 on packet 0, and packet 0 is the head packet of the in-sequence queue, the network device then schedules packet 0 out of the in-sequence queue and starts the processing process of service 2 on packet 0. Among them, service 2 is the next service that needs to be performed on data stream 1 after the processing operation of service 1 on data stream 1 is completed. At time t4, when CPU 1 finishes the processing operation of service 1 on packet 1, since the head packet of the in-sequence queue becomes packet 1 after packet 0 is scheduled out of the in-sequence queue, the network device then schedules packet 1 out of the in-sequence queue and starts the processing process of service 2 on packet 1. Then, the network device schedules packet 2, which has been completed the processing operation of service 1 by CPU 2 at time t2, out of the in-sequence queue and starts the processing process of service 2 on packet 2. Then, the network device schedules packet 3, which has been completed the processing operation of service 1 by CPU 3 at time t1, out of the in-sequence queue and starts the processing process of service 2 on packet 3. In this way, during the process that the network device concurrently performs the processing operation of service 1 on the packets of data stream 1 that enter the task queue of the network device in sequence through multiple CPUs, the network device realizes the in-sequence preservation of the packets after processing data stream 1 through the in-sequence queue, so that the network device performs the processing process of service 2 on data stream 1 that has completed the processing operation of service 1 and is in-sequence preserved.

[0049] It can be seen that by setting an in-sequence queue in the network device, it is possible to make the packets that have been completed a certain service processing operation by the processing module wait in the in-sequence queue for the same-stream packets that have not completed the processing operation of this service. In this way, it is possible to timely release the data processing resources of the network device on the basis of realizing packet in-sequence preservation, thereby avoiding the waste of the data processing resources of the network device.

[0050] However, when implementing packet in-sequence delivery through an in-sequence queue, generally, a single in-sequence queue is used to perform in-sequence delivery on packets of the same flow. Since the depth of a single in-sequence queue is limited, for elephant flows, the depth of a single in-sequence queue is insufficient to meet the packet in-sequence delivery requirements. Herein, an elephant flow refers to a large and continuous data stream transmitted through a network link. In some embodiments, when the depth of a single in-sequence queue cannot meet the packet in-sequence delivery requirements of a data stream, software in-sequence delivery can be implemented for the data stream. However, software in-sequence delivery does not solve the problem of insufficient in-sequence queue depth and consumes the computing power of the network device, that is, it requires additional consumption of the data processing resources of the network device, which will affect the performance of the network device.

[0051] Based on this, the embodiments of the present application provide a packet in-sequence delivery method, which is applied to a network device. This method performs packet in-sequence delivery on a data stream through at least two in-sequence queues in the network device, achieving an increase in the in-sequence depth of the network device without additional consumption of the data processing resources of the network device, that is, this method improves the in-sequence performance of the network device.

[0052] Herein, the packet described in the embodiments of the present application can also be referred to as a data packet (packet). In one example, when the data stream is transmitted using the Transmission Control Protocol (TCP), the above-mentioned packet can be referred to as a TCP packet or a TCP data packet. In another example, when the data stream is transmitted using the User Datagram Protocol (UDP), the above-mentioned packet can be referred to as a UDP packet or a UDP data packet.

[0053] Reference Figure 2 , Figure 2 shows a schematic diagram of an implementation environment provided by the embodiments of the present application. As Figure 2 shown, the network device includes m processing modules, namely processing module 1, processing module 2, …, and processing module m, where m is an integer greater than 2. When the network device uses these m processing modules to concurrently execute the processing operation of the first service on the data stream to be processed, the network device executes the method provided by the embodiments of the present application, and can achieve packet in-sequence delivery on the data stream to be processed after concurrently executing the processing operation of the first service on the data stream to be processed through these m processing modules, so as to obtain a data stream that has completed the processing operation of the first service and has packet in-sequence delivery. In this way, the network device can execute the processing process of the second service for the data stream that has completed the processing operation of the first service and has packet in-sequence delivery.

[0054] The embodiments of the present application do not specifically limit the first service and the second service. In some examples, the first service may be malicious packet detection, and the second service may be packet forwarding. In other examples, the first service may be a header update service during packet forwarding, and the second service may be a packet sending service during packet forwarding. It is not limited thereto.

[0055] It should be understood that the above content is an exemplary description of the application scenarios of the method provided by the embodiments of the present application, and does not constitute a limitation on the application scenarios of the method. Those skilled in the art know that with the change of business requirements, its application scenarios can be adjusted according to application needs, and the embodiments of the present application do not list them one by one.

[0056] The embodiments of the present application further provide a packet order-preserving device, which is applied to a network device and is used to execute the packet order-preserving method provided by the embodiments of the present application to achieve packet order-preserving for data streams concurrently processed by multiple processing modules of the network device.

[0057] In one example, the network device is a network forwarding device, such as a router, a switch, a gateway, etc., which is not limited thereto.

[0058] In another example, the network device is a network end device, which includes a client device and a server device. The client device is, for example, a computer, a tablet, a laptop, a mobile phone, a vehicle-mounted device, etc. accessing the network, and the server device is, for example, a server, a cloud computing platform, etc., which is not limited thereto.

[0059] In the embodiments of the present application, the above network device includes multiple processing modules and multiple schedulers. When each scheduler in at least one scheduler of the network device can schedule the packets to be processed to at least two processing modules correspondingly, the method provided by the embodiments of the present application can achieve packet order-preserving for the same-flow packets concurrently processed by multiple processing modules. It should be understood that when a certain scheduler is used to schedule the packets to be processed to one or more processing modules, there is a binding relationship between the scheduler and the one or more processing modules. That is, the scheduler is the scheduler bound to the one or more processing modules, and the one or more processing modules are the processing modules bound to the scheduler.

[0060] As an example, refer to Figure 3 , Figure 3 shows a schematic structural diagram of a network device provided by the embodiments of the present application. As Figure 3 shown, the network device includes multiple processing modules, and the multiple processing modules include Figure 3 the first processing module, the second processing module, the third processing module, and the fourth processing module shown in Figure 3The network device shown is also configured with multiple schedulers, and the multiple schedulers include Figure 3 the first scheduler and the second scheduler shown. Among them, the first scheduler is used to schedule packets to be processed to at least two processing modules including the first processing module and the second processing module, and the second scheduler is used to schedule packets to be processed to at least two processing modules including the third processing module and the fourth processing module. When Figure 3 the network device shown executes the packet sequence preservation method provided in the embodiment of the present application, it can achieve packet sequence preservation for the same-flow packets concurrently processed by multiple processing modules.

[0061] Among them, the above-mentioned processing module can be a processor (such as a CPU, etc.), a processing circuit, a microprocessing circuit, a microcontroller unit (MCU), etc., and is not limited thereto. The detailed description of the processor can be referred to in the following Figure 16 description of the processor, and will not be elaborated here.

[0062] The above scheduler is a hardware scheduler, and a task queue and an order-preserving queue with a corresponding relationship are set in the above scheduler. Among them, the task queue is used to schedule packets to be processed to one or more processing modules bound to its own scheduler, and the order-preserving queue is used to perform packet sequence preservation on the same-flow packets scheduled by the task queue. Moreover, both the task queue and the order-preserving queue are first-in-first-out (FIFO) queues. Optionally, one or more task queues and one or more order-preserving queues can be set in a scheduler, and this is not limited. When there are multiple task queues in a scheduler, at least one of the multiple task queues corresponds to an order-preserving queue, and the order-preserving queue can perform order preservation on the same-flow packets scheduled by the at least one task queue.

[0063] In some examples, only one task queue and one order-preserving queue are set in a scheduler. In this case, the packet sequence preservation for the same-flow packets concurrently processed through multiple order-preserving queues described in the embodiment of the present application can also be understood as packet sequence preservation for the same-flow packets concurrently processed through multiple schedulers.

[0064] For simplicity of description, in the following text of the embodiment of the present application, an example in which only one task queue and one order-preserving queue are set in a scheduler is used for description.

[0065] In the embodiments of the present application, when multiple schedulers are used to ensure the order of the same-flow packets in concurrent processing, one of the multiple schedulers is a primary scheduler and there is at least one secondary scheduler, and there is a corresponding relationship between the primary scheduler and the at least one secondary scheduler. That is, in the embodiments of the present application, the primary scheduler and the at least one secondary scheduler corresponding to the primary scheduler are used to ensure the order of the same-flow packets in concurrent processing. Among them, in addition to being configured with a task queue and an order-preserving queue, the network device also configures an accessible order-preserving completion queue for the primary scheduler. The order-preserving completion queue is used to store the results of the same-flow packets after being ordered by multiple schedulers. For the detailed process, reference can be made to the description in the following method and will not be elaborated here. Optionally, the order-preserving completion queue can be set inside the primary scheduler or outside the primary scheduler, and this is not limited. It should be understood that the number of order-preserving completion queues configured by the primary scheduler can be one or multiple, and this is not limited.

[0066] In some possible cases, when the memories of the multiple schedulers used to ensure the order of the same-flow packets are non-shared memories, it means that the memories of the multiple schedulers are isolated from each other, so the multiple schedulers cannot access each other's order-preserving queues. In this case, for the primary scheduler among the multiple schedulers, the network device also configures an accessible cache queue for the primary scheduler. The cache queue is used to store the order-preserving results of the order-preserving queues of the secondary schedulers in the multiple schedulers for the aforementioned same-flow packets. For the detailed description, reference can be made to the description in the following method and will not be elaborated here.

[0067] In some possible implementation manners, the cache queue configured for the primary scheduler can be set inside or outside the primary scheduler, and the cache queue is a dedicated cache queue of the primary scheduler. It can be understood that when the cache queue configured by the network device for the primary scheduler is a dedicated cache queue of the primary scheduler, the number of cache queues of the primary scheduler can be one or multiple, and this is not limited. When the cache queue configured by the network device for the primary scheduler is one, the order-preserving queues of the multiple secondary schedulers corresponding to the primary scheduler share the cache queue, that is, the cache queue is used to store the order-preserving results of the order-preserving queues of the multiple secondary schedulers. When the number of cache queues configured by the network device for the primary scheduler is multiple, each of the multiple secondary schedulers corresponding to the primary scheduler corresponds to a cache queue. It should be understood that the cache queue corresponding to a certain secondary scheduler is only used to store the order-preserving results of the order-preserving queue in that secondary scheduler.

[0068] In some other possible implementation manners, the cache queue configured for the primary scheduler is set outside the primary scheduler, such as being set in a system-on-chip (SoC) including the primary scheduler, so that the multiple schedulers configured in the SoC can share the cache queue.

[0069] It should be understood that when the same-flow packets are ordered by multiple schedulers of a network device, the multiple schedulers can be configured in the same SoC of the network device or in different SoCs, and there is no limitation in this regard. The embodiments of the present application do not specifically limit the specific form of the SoC. For example, an SoC can be a die, but is not limited thereto.

[0070] As an example, when the number of multiple schedulers for ordering the same-flow packets is 2, referring to Figure 4 , Figure 4 shows a schematic structural diagram of a scheduler in the network device provided by the embodiments of the present application. As shown in Figure 4 , the network device orders the same-flow packets through the first scheduler configured in SoC 1 and the second scheduler configured in SoC 2. Among them, a first task queue and a first ordering queue are set in the first scheduler, and a second task queue and a second ordering queue are set in the second scheduler. When the first scheduler is configured as the main scheduler, the second scheduler is the secondary scheduler at this time. In this case, an ordering completion queue is also set in the first scheduler, and the ordering completion queue is used to store the ordering results after the same-flow packets are ordered by the first ordering queue and the second ordering queue. In addition, when the memories of the first scheduler and the second scheduler are non-shared memories, a cache queue is also set in SoC 1 where the first scheduler is located, and the cache queue is used to store the ordering results of the second ordering queue. And when there are other schedulers configured in SoC 1 ( Figure 4 not shown in the figure), the first scheduler and the other scheduler can share the Figure 4 shown cache queue.

[0071] As another example, in combination with Figure 4 , referring to Figure 5 , the above-mentioned first scheduler and second scheduler are configured in the same SoC of the network device.

[0072] The implementation process of the packet ordering method provided by the embodiments of the present application will be described below.

[0073] Referring to Figure 6 , Figure 6 shows a flowchart of a packet ordering method provided by the embodiments of the present application. For ease of description, it is assumed that the method is executed by a network device having the Figure 4 or Figure 5 shown structure, so as to order the packets of the first data stream through the first scheduler and the second scheduler shown in Figure 4 or Figure 5 as an example for description. As shown in Figure 6 , the method includes the following steps.

[0074] Step 101: Distribute the packets of the first data stream to be processed to the first task queue and the second task queue.

[0075] Among them, the first data stream is any data stream that needs to be processed by the network device. For example, the first data stream is a data stream received by the network device that needs to perform malicious packet detection and / or packet forwarding, but is not limited thereto.

[0076] The first task queue is the task queue of the first scheduler set in the network device, and the second task queue is the task queue of the second scheduler set in the network device.

[0077] In the embodiment of the present application, the network device first needs to determine which schedulers are required to perform packet sequence preservation on the first data stream during concurrent processing, and needs to determine the main scheduler and the secondary scheduler among the schedulers used for packet sequence preservation of the first data stream. Among them, the secondary scheduler is used to send the sequence preservation result of its own sequence preservation queue to the cache queue of the main scheduler, and the main scheduler is used to aggregate the sequence preservation result of its own sequence preservation queue and the sequence preservation result indicated by the cache queue to obtain the final sequence preservation result of the first data stream. For a detailed description, please refer to the description of step 103 below and will not be elaborated here.

[0078] In a possible implementation manner, the network device is pre-configured as follows: when concurrently processing the packets of the data stream, the first scheduler and the second scheduler are used to perform packet sequence preservation on the data stream, and the first scheduler is used as the main scheduler and the second scheduler is used as the secondary scheduler. In this case, when the network device determines that multiple processing modules are required to perform concurrent processing on the first data stream, the network device determines that the first scheduler and the second scheduler are required to perform sequence preservation on the first data stream, and determines that the first scheduler is the main scheduler and the second scheduler is the secondary scheduler.

[0079] In another possible implementation manner, when the network device determines that multiple processing modules are required to perform concurrent processing on the first data stream, the network device first determines, according to the first preset rule or randomly, that the first scheduler and the second scheduler are used to perform packet sequence preservation on the first data stream among the multiple schedulers configured by itself. The embodiment of the present application does not limit the first preset rule. For example, the first preset rule is: determine the scheduler with the current load less than the threshold as the scheduler for performing packet sequence preservation on the first data stream. Another example is that the first preset rule is: determine the schedulers with the loads sorted from small to large and ranked in the top n (n is an integer greater than 1) as the schedulers for performing packet sequence preservation on the first data stream, but is not limited thereto.

[0080] Next, the network device determines the primary scheduler and the secondary scheduler from the determined first scheduler and second scheduler according to a second preset rule or randomly. For example, the network device determines the first scheduler as the primary scheduler and the second scheduler as the secondary scheduler. Here, the embodiments of the present application do not specifically limit the second preset rule for determining the primary scheduler and the secondary scheduler. For simplicity of description, in the following embodiments of the present application, the case where the first scheduler is determined as the primary scheduler and the second scheduler is determined as the secondary scheduler is used for description.

[0081] After the network device determines that the first data stream needs to be processed concurrently and the first data stream needs to be packet-order-preserved by the first scheduler and the second scheduler, the network device distributes the packets of the first data stream to be processed to the task queue of the first scheduler (i.e., the first task queue) and the task queue of the second scheduler (i.e., the second task queue) in sequence according to a preset distribution rule. The embodiments of the present application do not specifically limit this distribution rule. For example, the distribution rule may be round-robin distribution, or distribution according to a preset pattern, and so on.

[0082] In one example, when the distribution rule is round-robin distribution, refer to Figure 7 , Figure 7 shows a schematic diagram of distributing packets provided by the embodiments of the present application. As Figure 7 shown, for the packets of the first data stream, the network device distributes packet 1 of the first data stream to the first task queue. After that, the network device distributes the next packet of packet 1 in the first data stream (i.e., packet 2) to the second task queue. Then, the network device distributes the next packet of packet 2 in the first data stream (i.e., packet 3) to the first task queue. Then, the network device distributes the next packet of packet 3 in the first data stream (i.e., packet 4) to the second task queue. Then, the network device distributes the next packet of packet 4 in the first data stream (i.e., packet 5) to the first task queue. Then, the network device distributes the next packet of packet 5 in the first data stream (i.e., packet 6) to the second task queue. By circulating like this, the purpose of distributing the packets of the first data stream to the first task queue and the second task queue in a round-robin manner can be achieved.

[0083] In specific implementation, optionally, when the network device distributes packets to the task queue, it writes the elements of the indication packet into the task queue. For example, when the network device distributes packet 1 to the first task queue, it writes element 11 of packet 1 into the first task queue. In this way, element 11 serves as a queue element in the first task queue. In the embodiments of the present application, an element and a queue element have the same meaning and can be interchanged. In this way, after the network device distributes the packets of the first data stream to the first task queue and the second task queue in a round-robin manner, as Figure 7As shown, the first task queue includes element 11 indicating message 1, element 12 indicating message 3, and element 13 indicating message 5, while the second task queue includes element 21 indicating message 2, element 22 indicating message 4, and element 23 indicating message 6.

[0084] In another example, when the distribution rule is to distribute messages according to preset rule 1, and preset rule 1 is to distribute one message to the task queue of the second scheduler after continuously distributing two messages to the task queue of the first scheduler, refer to Figure 8 , Figure 8 shows another schematic diagram of message distribution provided by the embodiment of the present application. As Figure 8 shown, for the messages of the first data stream, the network device distributes consecutive messages 1 and 2 in the first data stream to the first task queue. After that, the network device distributes the next message of message 2 in the first data stream (i.e., message 3) to the second task queue. Then, the network device distributes the next two messages of message 3 in the first data stream (i.e., messages 4 and 5) to the first task queue. Next, the network device distributes the next message of message 5 in the first data stream (i.e., message 6) to the second task queue. By repeating this cycle, the purpose of distributing the messages of the first data stream to the first task queue and the second task queue according to preset rule 1 can be achieved.

[0085] In a specific implementation, optionally, when the network device distributes a message to a task queue, it writes the element indicating the message into the task queue. Thus, after distributing the messages of the first data stream to the first task queue and the second task queue according to preset rule 1, as Figure 8 shown, the first task queue includes element 11 indicating message 1, element 12 indicating message 2, element 13 indicating message 4, and element 14 indicating message 5, while the second task queue includes element 21 indicating message 3 and element 22 indicating message 6.

[0086] In addition, after the network device determines that the first scheduler is the primary scheduler and the second scheduler is the secondary scheduler among the first scheduler and the second scheduler used for packet sequence preservation of the first data stream, optionally, for any packet, such as the first packet, distributed (or scheduled) by the network device to the second task queue, the network device also adds an aggregation tag (or denoted as reduce_tag) to the queue element in the second task queue that is used to indicate the first packet. This aggregation tag is used to represent the first scheduler as the primary scheduler and is used to indicate that the aggregation operation described in step S103 is performed by the first scheduler as the primary scheduler. The specific implementation form of this aggregation tag is not specifically limited in the embodiments of this application. For example, this aggregation tag is a combination of any numbers and / or letters, etc., and is not limited thereto. Another example is that this aggregation tag is the identifier of the first scheduler. In some examples, this aggregation tag can be added to the packet task descriptor (PD) of the element.

[0087] In one example, after the network device determines that the second scheduler is the secondary scheduler, when the network device schedules the first packet to the second task queue of the second scheduler, the network device adds an aggregation tag representing the first scheduler to the element that is used to indicate the first packet, and writes the element with the added aggregation tag into the second task queue. In another example, after the network device determines that the second scheduler is the secondary scheduler, the network device instructs the second scheduler to add an aggregation tag representing the first scheduler to the queue elements in the second task queue that are used to indicate the first data stream packets. In response, the second scheduler adds an aggregation tag representing the first scheduler to each element written into the second task queue and used to indicate the first data stream packets.

[0088] Optionally, the network device also adds the identifier of the second scheduler to the queue elements in the second task queue that are used to indicate the first data stream packets, so as to indicate that these packets are the first data stream packets scheduled via the second task queue and ordered via the second sequence preservation queue. The second sequence preservation queue is used to preserve the order of the packets scheduled via the second task queue. In one example, the network device adds the identifier of the second scheduler to the PD of the element in the second task queue. Optionally, the network device also adds the identifier of the first scheduler to the queue elements in the first task queue that are used to indicate the first data stream packets, so as to indicate that these packets are the first data stream packets scheduled via the first task queue and ordered via the first sequence preservation queue. The first sequence preservation queue is used to preserve the order of the packets scheduled via the first task queue. In one example, the network device adds the identifier of the second scheduler to the PD of the element in the first task queue.

[0089] As an example, taking the identifier of the first scheduler as 0 and the identifier of the second scheduler as 1 as above, refer to Figure 9, Figure 9 shows another schematic diagram of distributing packets provided by an embodiment of the present application. As Figure 9 shown, after the first data flow is distributed by the network device, the packets distributed to the first task queue all include the identifier "0" of the first scheduler, and the packets distributed to the second task queue all include the identifier "1" of the second scheduler.

[0090] In addition, after the network device determines that the first scheduler is the main scheduler and the second scheduler is the secondary scheduler, when the memories of the first scheduler and the second scheduler are non-shared memories, the network device also sends the addressing information of the cache queue configured for the first scheduler to the second scheduler, and the addressing information includes but is not limited to the base address, read / write pointer address, etc. of the cache queue.

[0091] Step 102: Perform packet sequence preservation on the packets that have been scheduled out of the first task queue through the first sequence preservation queue to obtain a first sequence preservation result, and perform packet sequence preservation on the packets that have been scheduled out of the second task queue through the second sequence preservation queue to obtain a second sequence preservation result.

[0092] Among them, the process in which the network device performs packet sequence preservation on the packets that have been scheduled out of the first task queue through the first sequence preservation queue to obtain a first sequence preservation result is the same as the process in which the network device performs packet sequence preservation on the packets that have been scheduled out of the second task queue through the second sequence preservation queue to obtain a second sequence preservation result, and both can refer to Figure 1 the process description of packet sequence preservation for data stream 1 through the sequence preservation queue in

[0093] Next, an exemplary introduction will be given by taking the process in which the network device performs packet sequence preservation on the packets that have been scheduled out of the first task queue through the first sequence preservation queue of the first scheduler to obtain a first sequence preservation result as an example.

[0094] Exemplarily, when the multiple processing modules bound to the first scheduler in the network device at least include Figure 3 the first processing module and the second processing module shown in Figure 10 , Figure 10 shows a schematic diagram of the process of performing packet sequence preservation on the packets that have been scheduled out of the first task queue through the first sequence preservation queue of the first scheduler provided by an embodiment of the present application.

[0095] As Figure 10As shown in the figure, first, the first processing module executes a processing process on the message indicated by the queue element in the first task queue: the first processing module reads the element 1_1 at the head of the first task queue through the first command (such as the get_poe command), so as to address the message indicated by the element 1_1 according to the element 1_1 and process the message. After the first processing module reads the element 1_1, the first scheduler migrates the element 1_1 to the first in-order queue, and at this time the element 1_1 is scheduled out of the queue. Furthermore, after the first processing module finishes processing the message indicated by the element 1_1, through the second command (such as the send_poe command) carrying the ID of the element 1_1, the status of the element 1_1 in the first in-order queue is updated from "unprocessed" to "processed".

[0096] After the element 1_1 at the head of the first task queue is scheduled out of the queue, the head element of the first task queue becomes the element 1_2. At this time, the second processing module executes a processing process on the message indicated by the queue element in the first task queue: the second processing module reads the element 1_2 at the head of the first task queue through the first command, so as to address the message indicated by the element 1_2 according to the element 1_2 and process the message. After the second processing module reads the element 1_2, the first scheduler migrates the element 1_2 to the first in-order queue, and at this time the element 1_2 is scheduled out of the queue. Furthermore, after the second processing module finishes processing the message indicated by the element 1_2, through the second command carrying the ID of the element 1_2, the status of the element 1_2 in the first in-order queue is updated from "unprocessed" to "processed". Similarly, after the element 1_2 at the head of the first task queue is scheduled out of the queue, the head element of the first task queue becomes the element 1_3. At this time, another processing module bound to the first scheduler executes a processing process on the message indicated by the queue element in the first task queue.

[0097] Furthermore, when the status of a certain element in the first in-order queue is updated to "processed", and this element is at the head of the first in-order queue, it means that this element meets the condition for leaving the first in-order queue. In this case, the element in the first in-order queue that meets the dequeue condition is the first in-order result obtained by performing in-order preservation on the messages that have been scheduled out of the first task queue through the first in-order queue. Similarly, the element in the second in-order queue that meets the dequeue condition is the second in-order result obtained by performing in-order preservation on the messages that have been scheduled out of the second task queue through the second in-order queue. In this way, through Figure 10 the above process, the purpose of performing in-order preservation on the messages that have been scheduled out of the first task queue through the first in-order queue is achieved.

[0098] It can be seen that since the elements in the first order-preserving queue are migrated from the first task queue, and the dequeue condition of the first task queue is only that the element is at the head of the queue, while the dequeue condition of the first order-preserving queue includes that the element is at the head of the queue and the status of the element is updated to "processed", therefore, the enqueue order of the elements in the first order-preserving queue is the same as the enqueue order of the elements in the first task queue, the dequeue order of the elements in the first order-preserving queue is the same as the dequeue order of the elements in the first task queue, and the order of the elements in the first order-preserving queue is the same as the order of the elements in the first task queue.

[0099] Similarly, since the elements in the second order-preserving queue are migrated from the second task queue, and the dequeue condition of the second task queue is only that the element is at the head of the queue, while the dequeue condition of the second order-preserving queue includes that the element is at the head of the queue and the status of the element is updated to "processed", therefore, the enqueue order of the elements in the second order-preserving queue is the same as the enqueue order of the elements in the second task queue, the dequeue order of the elements in the second order-preserving queue is the same as the dequeue order of the elements in the second task queue, and the order of the elements in the second order-preserving queue is the same as the order of the elements in the second task queue.

[0100] It should be noted that for the packets distributed by the network device to the sub-scheduler task queue, such as the first packet distributed to the second task queue of the second scheduler, when the network device has added an aggregation tag to the queue element in the second task queue for indicating the first packet in step 101, after the element in the second task queue for indicating the first packet is migrated to the second order-preserving queue, the aggregation tag is still included in the element in the second order-preserving queue. When the network device does not add an aggregation tag to the queue element in the second task queue for indicating the first packet in step 101, in step 102, the second scheduler adds the above-mentioned aggregation tag to the element in the second order-preserving queue for indicating the first packet.

[0101] Optionally, when the processing module bound to the second scheduler reads the element for indicating the first packet from the second task queue, the second scheduler migrates the element to the second order-preserving queue. In one example, the second scheduler can first add an aggregation tag to the element for indicating the first packet, and then migrate the element to the second order-preserving queue. In another example, the second scheduler can migrate the element for indicating the first packet from the second task queue to the second order-preserving queue, and then add an aggregation tag to the element.

[0102] Step 103: Perform an aggregation operation on the first order-preserving result and the second order-preserving result to complete the order-preserving of the processed packets in the first data stream.

[0103] The network device performs an aggregation operation on the first in-order result and the second in-order result through a first scheduler acting as the main scheduler to complete the in-order preservation of the processed packets in the first data stream.

[0104] In a possible case, when the memories of the first scheduler and the second scheduler are non-shared memories, it means that the first scheduler cannot access the second in-order result of the second in-order queue. In this case, the network device configures a cache queue for the first scheduler, so the second scheduler can first send the second in-order result of the second in-order queue to the cache queue configured by the network device for the first scheduler.

[0105] In some examples, if the network device performs packet in-order preservation on the first data stream through the first scheduler, the second scheduler, and the third scheduler, and the memories of the first scheduler, the second scheduler, and the third scheduler are non-shared memories, this means that the first scheduler cannot access the in-order result of the second in-order queue and the in-order result of the third in-order queue in the third scheduler. At this time, when the network device configures two cache queues corresponding to the second scheduler and the third scheduler respectively for the first scheduler, the second scheduler needs to send the in-order result of the second in-order queue to the cache queue configured by the network device for the first scheduler and corresponding to the second scheduler, and the third scheduler needs to send the in-order result of the third in-order queue to the cache queue configured by the network device for the first scheduler and corresponding to the third scheduler. When the network device configures only one cache queue for the first scheduler, it means that the second in-order queue of the second scheduler and the third in-order queue of the third scheduler share this cache queue. In this case, the second scheduler needs to send the in-order result of the second in-order queue to this cache queue, and the third scheduler needs to send the in-order result of the third in-order queue to this cache queue. Details are not described again.

[0106] Specifically, the second scheduler sending the second in-order result of the second in-order queue to the cache queue configured by the network device for the first scheduler includes: the second scheduler sending the second in-order result of the second in-order queue to the cache queue configured by the network device for the first scheduler according to the aggregation tag included in the element for indicating the packets of the first data stream in the second in-order queue. Among them, the relevant description of the aggregation tag of the elements in the second in-order queue can refer to the description in step 101 or step 102 above, and details are not described again.

[0107] As an example, the process in which the second scheduler sends the second order-preserving result of the second order-preserving queue to the buffer queue configured by the network device for the first scheduler according to the aggregation tags included in the elements in the second order-preserving queue includes: for the first element in the second order-preserving queue that meets the dequeue condition, the second scheduler first determines the primary scheduler according to the aggregation tag of the first element. Then, the second scheduler queries the addressing information of the buffer queue configured by the network device for the primary scheduler obtained in advance to determine the base address and read / write pointers of the buffer queue. Furthermore, the second scheduler writes the first element into the buffer queue according to the base address and write pointer address of the buffer queue. Among them, when the first scheduler and the second scheduler are set in the same SoC, the second scheduler writes the first element into the buffer queue configured by the network device for the first scheduler through the internal communication bus of the SoC according to the base address and write pointer address of the buffer queue. When the first scheduler and the second scheduler are set in different SoCs, at this time, the buffer queue configured by the network device for the first scheduler is set in the SoC where the first scheduler is located. Therefore, the second scheduler writes the first element into the buffer queue configured by the network device for the first scheduler according to the base address and write pointer address of the buffer queue and through the communication bus between the SoC where the second scheduler is located and the SoC where the first scheduler is located. Through this process, the buffer queue configured by the network device for the first scheduler can obtain the second order-preserving result of the second order-preserving queue in the second scheduler.

[0108] Since the dequeue order of the elements in the second order-preserving queue is the same as the enqueue order of the elements in the buffer queue, the order of the elements in the second order-preserving queue is the same as the order of these elements in the buffer queue. And since the order of the elements in the second task queue is the same as the order of the elements in the second order-preserving queue, the order of the elements in the second task queue is the same as the order of these elements in the buffer queue. Therefore, the first scheduler performing the aggregation operation on the first order-preserving result and the second order-preserving result includes: the first scheduler performing the aggregation operation on the first order-preserving result of the first order-preserving queue and the second order-preserving result indicated by the buffer queue.

[0109] Specifically, the first scheduler can, according to the aggregation rule, schedule the elements in the first order-preserving queue for indicating the first data stream packet and the elements in the buffer queue for indicating the first data stream packet to the order-preserving completion queue in sequence to implement the aggregation operation performed on the first order-preserving result of the first order-preserving queue and the second order-preserving result indicated by the buffer queue.

[0110] Among them, the aggregation rule is a scheduling rule corresponding to the distribution rule described above. Since the order of elements in the first task queue is the same as the order of elements in the first order-preserving queue, and the order of elements in the second task queue is the same as the order of these elements in the cache queue, in one example, when the distribution rule described above is round-robin distribution, the aggregation rule corresponding to this distribution rule is: alternately schedule the elements of the first order-preserving queue and the elements of the cache queue to the order-preserving completion queue. In another example, when the distribution rule described above is distribution according to a preset rule, the aggregation rule corresponding to this distribution rule is: schedule the elements of the first order-preserving queue and the elements of the cache queue to the order-preserving completion queue according to a preset rule.

[0111] In the first possible implementation manner, the cache queue configured by the network device for the first scheduler is a cache queue dedicated to the first scheduler, and each deputy scheduler corresponding to the first scheduler corresponds to a cache queue. In this case, the first scheduler alternately schedules the elements in the first order-preserving queue indicating the first data stream packets and the elements in the cache queue indicating the first data stream packets to the order-preserving completion queue according to the aggregation rule, including: the first scheduler alternately schedules the elements in the first order-preserving queue that meet the dequeue condition and the element at the head of the cache queue when the cache queue is not empty to the order-preserving completion queue according to the aggregation rule.

[0112] As an example, in combination with Figure 7 , refer to Figure 11 , Figure 11 shows a schematic diagram of aggregating the first order-preserving result and the second order-preserving result according to the aggregation rule provided by an embodiment of the present application. As Figure 11 shown, when the first scheduler determines that it is necessary to alternately schedule the order-preserving results from the first order-preserving queue and the cache queue according to the Figure 7 distribution rule described above, after the element 11 in the first order-preserving queue meets the dequeue condition, the first scheduler schedules the element 11 to the order-preserving completion queue. Then, the first scheduler schedules the element 21 at the head of the cache queue to the order-preserving completion queue. After the element 21 is dequeued from the cache queue, the element at the head of the cache queue becomes the element 22. After that, after the element 12 in the first order-preserving queue meets the dequeue condition, the first scheduler schedules the element 12 to the order-preserving completion queue. Then, the first scheduler schedules the element 22 at the head of the cache queue to the order-preserving completion queue. After the element 22 is dequeued from the cache queue, the element at the head of the cache queue becomes the element 23. In this way, the first scheduler can alternately schedule the elements in the first order-preserving queue and the elements in the cache queue to the order-preserving completion queue according to the aggregation rule corresponding to the Figure 7 distribution rule described above, and aggregate the first order-preserving result and the second order-preserving result in the order-preserving completion queue.

[0113] As another example, in combination with Figure 8 , refer toFigure 12 , Figure 12 shows another schematic diagram of aggregating the first order-preserving result and the second order-preserving result according to the aggregation rule provided by the embodiment of the present application. As Figure 12 shown, when the first scheduler determines that the order-preserving results need to be scheduled from the first order-preserving queue and the cache queue according to the rule inverse to the preset rule 1 according to the Figure 8 described distribution rule, after the element 11 in the first order-preserving queue meets the dequeue condition, the first scheduler schedules the element 11 to the order-preserving completion queue, and, after the element 12 in the first order-preserving queue meets the dequeue condition, the first scheduler schedules the element 12 to the order-preserving completion queue. Then, the first scheduler schedules the element 21 at the head of the cache queue to the order-preserving completion queue. After the element 21 is dequeued from the cache queue, the element at the head of the cache queue becomes the element 22. After that, after the element 13 in the first order-preserving queue meets the dequeue condition, the first scheduler schedules the element 13 to the order-preserving completion queue, and, after the element 14 in the first order-preserving queue meets the dequeue condition, the first scheduler schedules the element 14 to the order-preserving completion queue. After that, the first scheduler schedules the element 22 at the head of the cache queue to the order-preserving completion queue. In this way, the first scheduler can aggregate the first order-preserving result and the second order-preserving result in the order-preserving completion queue according to the aggregation rule corresponding to the Figure 8 described distribution rule.

[0114] In the second possible implementation manner, the first scheduler schedules the elements in the first order-preserving queue for indicating the first data stream packet and the elements in the cache queue for indicating the first data stream packet to the order-preserving completion queue in sequence according to the aggregation rule, including: the first scheduler schedules the elements in the first order-preserving queue that meet the dequeue condition and the elements in the cache queue marked with the second scheduler identifier to the order-preserving completion queue in sequence according to the aggregation rule.

[0115] Among them, the elements in the cache queue include the identifier of the secondary scheduler, and the secondary scheduler refers to the secondary scheduler used to schedule the packets indicated by the elements in the cache queue to the processing module. For example, for the elements in the cache queue that indicate the first data stream packets, the first data stream packets indicated by these elements are scheduled to the processing module via the second scheduler as the secondary scheduler. Therefore, the identifier of the second scheduler is included in the elements in the cache queue that indicate the first data stream packets. It can be understood that the identifier of the second scheduler included in the elements in the cache queue that indicate the first data stream packets is added by the network device to these elements in step 101 described above when the elements are in the second task queue, which will not be elaborated here. In this way, when the number of secondary schedulers for packet order preservation of the first data stream is multiple and the order preservation results of these multiple secondary schedulers are all sent to a cache queue configured for the primary scheduler, this implementation method can aggregate the order preservation results of the primary scheduler and the multiple secondary schedulers.

[0116] As an example, in combination with Figure 7 and referring to Figure 11 , when the first scheduler determines according to the Figure 7 described distribution rule that it is necessary to alternately schedule the order preservation results from the first order preservation queue and the cache queue, and the initial aggregation task flag (simply referred to as the aggregation task flag of the first data stream) when the first scheduler aggregates the order preservation results of the first data stream is the identifier of the first scheduler, the first scheduler, according to the identifier of the first scheduler, after the element 11 in the first order preservation queue of the first scheduler meets the dequeue condition, schedules the element 11 to the order preservation completed queue, and updates the aggregation task flag of the first data stream to the identifier of the second scheduler. Then, the first scheduler schedules the element 21 that is closest to the head of the cache queue and carries the identifier of the second scheduler from the cache queue to the order preservation completed queue according to the identifier of the second scheduler, and updates the aggregation task flag of the first data stream to the identifier of the first scheduler. After that, the first scheduler, according to the identifier of the first scheduler, after the element 12 in the first order preservation queue of the first scheduler meets the dequeue condition, schedules the element 12 to the order preservation completed queue, and updates the aggregation task flag of the first data stream to the identifier of the second scheduler. Then, the first scheduler schedules the element 22 that is closest to the head of the cache queue and carries the identifier of the second scheduler from the cache queue to the order preservation completed queue according to the identifier of the second scheduler, and updates the aggregation task flag of the first data stream to the identifier of the first scheduler. In this way, by looping, the first scheduler can aggregate the first order preservation result and the second order preservation result in the order preservation completed queue according to the aggregation rule corresponding to the Figure 7 described distribution rule.

[0117] As another example, in combination with Figure 8 and referring to Figure 12 , when the first scheduler determines according toFigure 8 When the distribution rule determines that the ordered results need to be scheduled from the first ordered queue and the cache queue according to the rule opposite to the preset rule 1, and the initial aggregation task flag of the first data stream is the identifier of the first scheduler, the first scheduler, according to the identifier of the first scheduler, after the element 11 in the first ordered queue of the first scheduler meets the dequeue condition, schedules the element 11 to the ordered completion queue, and keeps the aggregation task flag of the first data stream as the identifier of the first scheduler unchanged. Then, the first scheduler continues to schedule the element 12 in the first ordered queue of the first scheduler to the ordered completion queue according to the identifier of the first scheduler after the element 12 meets the dequeue condition, and updates the aggregation task flag of the first data stream to the identifier of the second scheduler. After that, the first scheduler schedules the element 21 which is closest to the head of the cache queue and carries the identifier of the second scheduler from the cache queue to the ordered completion queue according to the identifier of the second scheduler, and updates the aggregation task flag of the first data stream to the identifier of the first scheduler. After that, the first scheduler schedules the element 13 in the first ordered queue of the first scheduler to the ordered completion queue according to the identifier of the first scheduler after the element 13 meets the dequeue condition, and keeps the aggregation task flag of the first data stream as the identifier of the first scheduler unchanged. Then, the first scheduler continues to schedule the element 14 in the first ordered queue of the first scheduler to the ordered completion queue according to the identifier of the first scheduler after the element 14 meets the dequeue condition, and updates the aggregation task flag of the first data stream to the identifier of the second scheduler. Then, the first scheduler schedules the element 22 which is closest to the head of the cache queue and carries the identifier of the second scheduler from the cache queue to the ordered completion queue according to the identifier of the second scheduler, and updates the aggregation task flag of the first data stream to the identifier of the first scheduler. In this way, the first scheduler can aggregate the first ordered result and the second ordered result in the ordered completion queue according to the aggregation rule corresponding to the Figure 8 distribution rule described above.

[0118] It should be understood that the ordered results obtained after multiple schedulers perform ordering on the first data stream must be aggregated through an ordered completion queue, and an ordered completion queue can aggregate the multiple ordered results corresponding to each data stream in multiple data streams. For example, the ordered results after the data stream 1 is ordered by the scheduler 1 and the scheduler 2 can be aggregated through the ordered completion queue 1 configured for the scheduler 1, and the ordered results after the data stream 2 is ordered by the scheduler 1 and the scheduler 3 can also be aggregated through the ordered completion queue 1 configured for the scheduler 1. The embodiments of the present application do not limit this.

[0119] Therefore, in some embodiments, when an in-order completion queue configured for a first scheduler can aggregate the in-order results of multiple data streams including a first data stream, the first scheduler is configured with the correspondence between each data stream and multiple schedulers for performing in-order processing on each data stream. In this way, when the first scheduler aggregates the in-order results after the message in-order processing of a certain data stream by multiple schedulers, each time the first scheduler schedules an in-order result from the first in-order queue to the in-order completion queue, it needs to update the aggregation task flag of the data stream according to the in-order result and the foregoing correspondence, so that the first scheduler can schedule the in-order result according to the aggregation task flag of the data stream. For example, after the first scheduler schedules the second element that meets the dequeue condition from the first in-order queue to the in-order completion queue, when the first scheduler determines that the second element is used to indicate the first data stream message according to the second element, the first scheduler determines multiple schedulers for performing in-order processing on the first data stream according to the foregoing correspondence, so that the first scheduler determines a certain scheduler among the multiple schedulers as the scheduler for obtaining the next in-order result to be scheduled according to the aggregation rule, and then the first scheduler updates the aggregation task flag of the first data stream to the identifier of the scheduler.

[0120] In another possible case, when the memory of the first scheduler and the second scheduler is shared memory, it means that the first scheduler can directly access the second in-order result of the second in-order queue. In this case, the first scheduler can directly perform an aggregation operation on the first in-order result of the first in-order queue in the first scheduler and the second in-order result of the second in-order queue in the second scheduler to complete the in-order processing of the processed messages in the first data stream. Among them, for the detailed description of the first scheduler performing an aggregation operation on the first in-order result of the first in-order queue and the second in-order result of the second in-order queue, reference can be made to the description of the first scheduler performing an aggregation operation on the first in-order result of the first in-order queue and the second in-order result indicated by the cache queue, which will not be elaborated here.

[0121] Furthermore, optionally, the network device can perform the processing operation of the next service on the first data stream that has been in-order processed by the first scheduler and the second scheduler, which is not limited herein.

[0122] So far, through the method described in steps 101 to 103, the purpose of performing message in-order processing on the concurrently processed data streams through the in-order queues of multiple schedulers in the network device is achieved, so that the in-order depth of the network device for performing message in-order processing on the data stream can be increased without consuming additional data processing resources of the network device, and thus the in-order performance of the network device is improved.

[0123] To deepen the understanding of the solution described in the embodiments of the present application, the following further description is made in combination with specific examples (Example 1 and Example 2).

[0124] Example 1: When the network device concurrently processes data stream 1, the packet sequence preservation of data stream 1 is performed by scheduler 1 and scheduler 2. By default, the network device configures scheduler 1 as the main scheduler and scheduler 2 as the secondary scheduler. Among them, scheduler 1 includes task queue 11, sequence preservation queue 12, and sequence preservation completion queue, and scheduler 2 includes task queue 21 and sequence preservation queue 22. In addition, the network device pre-sets a distribution rule for distributing packets to task queue 11 of scheduler 1 and task queue 21 of scheduler 2, and a corresponding aggregation rule for the distribution rule. Moreover, the network device has pre-set an initial aggregation task flag for performing an aggregation operation on the sequence preservation result obtained after the sequence preservation of data stream 1 by scheduler 1 and scheduler 2.

[0125] Reference Figure 13 , Figure 13 shows a schematic process diagram of the packet sequence preservation method provided by an embodiment of the present application. Reference Figure 13 , when the network device determines that data stream 1 needs to be concurrently processed, the network device distributes data stream 1 to task queue 11 of scheduler 1 and task queue 21 of scheduler 2 in turn according to the round-robin distribution method (the specific process is as described in step 101). Among them, after the network device distributes the packets of data stream 1 to task queue 21, the elements in task queue 21 of scheduler 2 for indicating the packets of data stream 1 include the identifier of scheduler 2 and an aggregation mark for indicating the main scheduler (i.e., scheduler 1). For example, elements 2_1, 2_2, and 2_3 in task queue 21 all include the identifier of scheduler 2 and an aggregation mark indicating scheduler 1.

[0126] Furthermore, multiple processing modules bound to scheduler 1 process the packets indicated by each element (such as elements 1_1, 1_2, and 1_3, etc.) in task queue 11, and multiple processing modules bound to scheduler 2 process the packets indicated by each element (such as elements 2_1, 2_2, and 2_3, etc.) in task queue 21. For example, processing module 1 bound to scheduler 1 reads element 1_1 from task queue 11 through the get_poe command to process the packet indicated by element 1_1. At the same time, the network device migrates element 1_1 to sequence preservation queue 12 and sets the status of element 1_1 to "unprocessed". When processing module 1 finishes processing the packet indicated by element 1_1, processing module 1 updates the status of element 1_1 in sequence preservation queue 12 to "processed and completed" through the send_poe command. In this way, when the elements in sequence preservation queue 12 and sequence preservation queue 22 are at the head of their respective queues and the status is "processed and completed", the element meets the dequeue condition.

[0127] Further, when an element in the in-order queue 22 meets the dequeue condition, the scheduler 2 sends / writes the element to the buffer queue configured for the scheduler 1 by the network device according to the aggregation tag in the element (refer to the relevant description in step 103).

[0128] Next, the scheduler 1 schedules an element (such as element 1_1) that meets the dequeue condition from the in-order queue 12 to the in-order completion queue according to the initial aggregation task flag of data stream 1 (i.e., the identifier of the scheduler 1). The scheduler 1 also determines the packet for data stream 1 indicated by element 1_1, and determines that the schedulers for packet in-order preservation of data stream 1 include the scheduler 1 and the scheduler 2 according to the corresponding relationship between the data stream and the scheduler. Then, the scheduler 1 updates the task aggregation flag of data stream 1 from the identifier of the scheduler 1 to the identifier of the scheduler 2 according to the preset aggregation rule. Then, the scheduler 1 schedules the element 2_1 that is closest to the head of the queue in the buffer queue and includes the identifier of the scheduler 2 to the in-order completion queue. The scheduler 1 also determines the packet for data stream 1 indicated by element 2_1, and determines that the schedulers for packet in-order preservation of data stream 1 include the scheduler 1 and the scheduler 2 according to the corresponding relationship between the data stream and the scheduler. Then, the scheduler 1 updates the task aggregation flag of data stream 1 from the identifier of the scheduler 2 to the identifier of the scheduler 1 according to the preset aggregation rule. In this way, the in-order results of the in-order queue 12 and the in-order queue 22 are aggregated, and further, packet in-order preservation of data stream 1 is achieved when processing data stream 1 concurrently.

[0129] Example 2: When the network device processes data stream 2 concurrently, packet in-order preservation of data stream 2 is performed by the scheduler 1, the scheduler 2, and the scheduler 3. The network device defaults to configuring the scheduler 1 as the main scheduler and the scheduler 2 and the scheduler 3 as the secondary schedulers. Among them, the scheduler 1 includes a task queue 11, an in-order queue 12, and an in-order completion queue. The scheduler 2 includes a task queue 21 and an in-order queue 22. The scheduler 3 includes a task queue 31 and an in-order queue 32. Moreover, the network device presets a distribution rule for distributing packets to the task queue 11 of the scheduler 1, the task queue 21 of the scheduler 2, and the task queue 31, and a corresponding aggregation rule. Also, the network device has preset an initial aggregation task flag for performing an aggregation operation on the in-order results obtained after in-order preservation of data stream 2 by the scheduler 1, the scheduler 2, and the scheduler 3.

[0130] Reference Figure 14 , Figure 14 shows another flowchart of the packet in-order preservation method provided by the embodiment of the present application. Reference Figure 14, when the network device determines that the data stream 2 needs to be processed concurrently, the network device distributes the data stream 2 to the task queue 11 of the scheduler 1, the task queue 21 of the scheduler 2, and the task queue 31 of the scheduler 3 in turn according to the round-robin distribution method (for the specific process, refer to the description in step 101). Among them, after the network device distributes the packets of the data stream 2 to the task queue 21 and the task queue 31, the elements in the task queue 21 of the scheduler 2 for indicating the packets of the data stream 2 include the identifier of the scheduler 2 and the aggregation mark for indicating the main scheduler (i.e., the scheduler 1), and the elements in the task queue 31 of the scheduler 3 for indicating the packets of the data stream 2 include the identifier of the scheduler 3 and the aggregation mark for indicating the main scheduler (i.e., the scheduler 1). For example, the elements 2_1, 2_2, and 2_3 in the task queue 21 all include the identifier of the scheduler 2 and the aggregation mark indicating the scheduler 1, and the elements 3_1, 3_2, and 3_3 in the task queue 31 all include the identifier of the scheduler 3 and the aggregation mark indicating the scheduler 1.

[0131] Furthermore, multiple processing modules bound to the scheduler 1 process the packets indicated by each element (such as elements 1_1, 1_2, and 1_3, etc.) in the task queue 11, multiple processing modules bound to the scheduler 2 process the packets indicated by each element (such as elements 2_1, 2_2, and 2_3, etc.) in the task queue 21, and multiple processing modules bound to the scheduler 3 process the packets indicated by each element (such as elements 3_1, 3_2, and 3_3, etc.) in the task queue 31. For example, the processing module 2 bound to the scheduler 2 reads the element 2_1 from the task queue 21 through the get_poe command to process the packet indicated by the element 2_1. At the same time, the network device migrates the element 2_1 to the in-order queue 22 and sets the status of the element 2_1 to "unprocessed". When the processing module 2 finishes processing the packet indicated by the element 2_1, the processing module 2 updates the status of the element 2_1 in the in-order queue 22 to "processed and completed" through the send_poe command. In this way, when the elements in the in-order queue 12, the in-order queue 22, and the in-order queue 32 are at the head of their respective queues and the status is "processed and completed", the element meets the dequeue condition.

[0132] Further, when the element in the in-order queue 22 meets the dequeue condition, the scheduler 2 sends / writes the element to the buffer queue configured for the scheduler 1 by the network device according to the aggregation mark in the element (refer to the relevant description in step 103). When the element in the in-order queue 32 meets the dequeue condition, the scheduler 3 sends / writes the element to the buffer queue configured for the scheduler 1 by the network device according to the aggregation mark in the element (refer to the relevant description in step 103).

[0133] Next, the scheduler 1 schedules an element (such as element 1_1) that meets the dequeue condition from the in-order queue 12 to the in-order completion queue according to the initial aggregation task flag of the data stream 2 (i.e., the identifier of the scheduler 1). The scheduler 1 also determines the message for the data stream 2 indicated by the element 1_1, and determines that the schedulers for message in-order of the data stream 2 include the scheduler 1, the scheduler 2, and the scheduler 3 according to the correspondence between the data stream and the scheduler. Then, the scheduler 1 updates the task aggregation flag of the data stream 2 from the identifier of the scheduler 1 to the identifier of the scheduler 2 according to the preset aggregation rule. After that, the scheduler 1 schedules the element 2_1 that is closest to the head of the queue in the buffer queue and includes the identifier of the scheduler 2 to the in-order completion queue. The scheduler 1 also determines the message for the data stream 2 indicated by the element 2_1, and determines that the schedulers for message in-order of the data stream 2 include the scheduler 1, the scheduler 2, and the scheduler 3 according to the correspondence between the data stream and the scheduler. Then, the scheduler 1 updates the task aggregation flag of the data stream 2 from the identifier of the scheduler 2 to the identifier of the scheduler 3 according to the preset aggregation rule. Then, the scheduler 1 schedules the element 3_1 that is closest to the head of the queue in the buffer queue and includes the identifier of the scheduler 3 to the in-order completion queue. The scheduler 1 also determines the message for the data stream 2 indicated by the element 3_1, and determines that the schedulers for message in-order of the data stream 2 include the scheduler 1, the scheduler 2, and the scheduler 3 according to the correspondence between the data stream and the scheduler. Then, the scheduler 1 updates the task aggregation flag of the data stream 2 from the identifier of the scheduler 3 to the identifier of the scheduler 1 according to the preset aggregation rule. Then, the scheduler 1 schedules an element (such as element 1_2) that meets the dequeue condition from the in-order queue 12 according to the identifier of the scheduler 1 to the in-order completion queue. The scheduler 1 also determines the message for the data stream 2 indicated by the element 1_2, and determines that the schedulers for message in-order of the data stream 2 include the scheduler 1, the scheduler 2, and the scheduler 3 according to the correspondence between the data stream and the scheduler. Then, the scheduler 1 updates the task aggregation flag of the data stream 2 from the identifier of the scheduler 1 to the identifier of the scheduler 2 according to the preset aggregation rule. In this way, the in-order results of the in-order queue 12, the in-order results of the in-order queue 22, and the in-order results of the in-order queue 32 are aggregated, and then the message in-order of the data stream 2 is realized during the concurrent processing of the data stream 2.

[0134] The above mainly introduces the solution provided by the embodiment of the present application from the perspective of the method.

[0135] To implement the above functions, as Figure 15 shown, Figure 15 FIG. shows a schematic structural diagram of a message in-order device provided by an embodiment of the present application. As Figure 15As shown, the packet sequence-preserving device 1500 is applied to a network device configured with a first task queue, a first sequence-preserving queue, a second task queue, and a second sequence-preserving queue, and is used to execute the packet sequence-preserving method described above, for example, used to execute Figure 6 , Figure 13 or Figure 14 the method shown. The packet sequence-preserving device 1500 may include a distribution unit 1501, a first sequence-preserving unit 1502, a second sequence-preserving unit 1503, and an aggregation unit 1504.

[0136] The distribution unit 1501 is used to distribute the packets of the first data stream to be processed to the first task queue and the second task queue. The first sequence-preserving unit 1502 is used to perform sequence preservation on the packets dequeued from the first task queue through the first sequence-preserving queue to obtain a first sequence-preserving result. The second sequence-preserving unit 1503 is used to perform sequence preservation on the packets dequeued from the second task queue through the second sequence-preserving queue to obtain a second sequence-preserving result. The aggregation unit 1504 is used to perform an aggregation operation on the first sequence-preserving result and the second sequence-preserving result to complete the sequence preservation of the processed packets in the first data stream.

[0137] As an example, in combination with Figure 6 , the distribution unit 1501 may be used to execute step 101, the first sequence-preserving unit 1502 and the second sequence-preserving unit 1503 may be used to execute step 102, and the aggregation unit 1504 may be used to execute step 103.

[0138] Optionally, the first task queue and the first sequence-preserving queue are set in a first scheduler, the second task queue and the second sequence-preserving queue are set in a second scheduler, and the first scheduler and the second scheduler are integrated in different SoCs of the network device.

[0139] Optionally, the first task queue and the first sequence-preserving queue are set in a first scheduler, the second task queue and the second sequence-preserving queue are set in a second scheduler, and the first scheduler and the second scheduler are integrated in the same SoC of the network device.

[0140] Optionally, when the first scheduler is configured as the main scheduler, the aggregation unit 1504 is specifically used to perform an aggregation operation on the first sequence-preserving result and the second sequence-preserving result through the first scheduler.

[0141] Optionally, a cache queue is provided in the first scheduler. The packet in-order device 1500 further includes: a sending unit 1505, configured to send the second in-order result to the cache queue according to the aggregation tag included in the element indicating the first data stream packet in the second in-order queue. The aggregation unit 1504 is specifically configured to perform an aggregation operation on the first in-order result and the second in-order result indicated by the cache queue through the first scheduler. The aggregation tag is used to indicate that the first scheduler performs an aggregation operation on the first in-order result and the second in-order result.

[0142] Optionally, the packet in-order device 1500 further includes an aggregation tag setting unit 1506, configured to add an aggregation tag to the element indicating the first packet in the second task queue and migrate the element indicating the first packet from the second task queue to the second in-order queue before sending the second in-order result to the cache queue according to the aggregation tag included in the element indicating the first data stream packet in the second in-order queue. The first packet is any packet of the first data stream scheduled to the second task queue. Alternatively, the aggregation tag setting unit 1506 is configured to add an aggregation tag to the element indicating the first packet in the second in-order queue before sending the second in-order result to the cache queue according to the aggregation tag included in the element indicating the first data stream packet in the second in-order queue.

[0143] Optionally, the aggregation unit 1504 is specifically configured to schedule the element indicating the first data stream packet in the first in-order queue and the element indicating the first data stream packet in the cache queue to the in-order completion queue in sequence through the first scheduler according to an aggregation rule, so as to implement the aggregation operation performed on the first in-order result and the second in-order result indicated by the cache queue. The aggregation rule is a scheduling rule corresponding to the distribution rule, and the distribution rule is a scheduling rule for distributing the packets of the first data stream to the first task queue and the second task queue.

[0144] Optionally, when other schedulers are further included in the SoC to which the first scheduler belongs, the first scheduler and the other schedulers share the cache queue.

[0145] Optionally, the distribution unit 1501 is specifically configured to distribute the packets of the first data stream to be processed to the first task queue and the second task queue according to a preset distribution rule.

[0146] For the specific descriptions of the above optional manners, reference may be made to the foregoing method embodiments, which will not be elaborated herein. In addition, the explanations and descriptions of the beneficial effects of any of the foregoing packet in-order devices 1500 may refer to the corresponding method embodiments above, and will not be elaborated.

[0147] As an example, in combination with the following Figure 16, the functions implemented by the distribution unit 1501 in the message sequence preservation device 1500 can be Figure 16 implemented by the processor 1601 executing Figure 16 the program code in the memory 1602 in Figure 16 . The functions implemented by the first sequence preservation unit 1502 and the aggregation unit 1504 can be Figure 16 implemented by the scheduler 1605a in Figure 16 . The functions implemented by the second sequence preservation unit 1503 and the aggregation tag setting unit 1506 can be

[0148] implemented by the scheduler 1605b in

[0149] . The functions implemented by the sending unit 1505 can be Figure 15 implemented by the communication interface 1603 in

[0150] Those skilled in the art should easily realize that, for the units and algorithm steps of each example described in combination with the embodiments disclosed herein, this application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed in the form of hardware or computer software driving the hardware depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application. Figure 16 , Figure 16 shows a schematic structural diagram of a network device provided by an embodiment of this application. As Figure 16 shown, the network device 1600 includes a processor 1601, a memory 1602, a communication interface 1603, a bus 1604, a scheduler 1605a, and a scheduler 1605b. Among them, the processor 1601, the memory 1602, the communication interface 1603, the scheduler 1605a, and the scheduler 1605b are communicatively connected to each other through the bus 1604.

[0151] The processor 1601 may include a general-purpose processor and / or a dedicated hardware chip. The general-purpose processor may include: a central processing unit (CPU), a microprocessor, or a graphics processing unit (GPU). The CPU is, for example, a single-core processor (single-CPU) or a multi-core processor (multi-CPU). The dedicated hardware chip is a high-performance processing hardware module. The dedicated hardware chip includes at least one of a digital signal processing (DSP), a data processing unit (DPU), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, a neural processing unit (NPU), a tensor processing unit (TPU), an artificial intelligent chip, or a network processor (NP). The processor 1601 may also be an integrated circuit chip with signal processing capabilities. In the implementation process, part or all of the functions of the method provided by the embodiments of the present application may be completed by the integrated logic circuit in the hardware of the processor 1601 or instructions in software form.

[0152] The memory 1602 is used to store computer programs, which include an operating system 1602a and executable code (i.e., program instructions) 1602b. The memory 1602 is, for example, a read-only memory (ROM), a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), a flash memory, or other types of static storage devices that can store static information and instructions, or is a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous DRAM (SDRAM), a double data rate SDRAM (DDR SDRAM), an enhanced SDRAM (ESDRAM), a synchlink DRAM (SLDRAM), or other types of dynamic storage devices that can store information and instructions, or is a read-only optical disc or other optical disc storage, optical disc storage (including compact discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), magnetic disk storage media, or other magnetic storage devices, or any other medium that can be used to carry or store the desired executable code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. For example, the memory 1602 is used to set the cache queue and the like described above. The memory 1602 exists independently, for example, and is connected to the processor 1601 through a bus 1604. Or the memory 1602 and the processor 1601 are integrated together. The memory 1602 can store executable code. When the executable code stored in the memory 1602 is executed by the processor 1601, the processor 1601 is used to perform some or all of the functions of the message in-order method provided in the embodiments of the present application. For the implementation manner of the processor 1601 to execute this process, please refer to the relevant descriptions in the foregoing embodiments accordingly. The memory 1602 may also include software modules, data, etc. required for other running processes such as an operating system.

[0153] The communication interface 1603 includes, but is not limited to, a transceiver module such as a transceiver, and realizes communication with other devices or communication networks through the transceiver module. For example, the communication interface 1603 can be any one or any combination of the following devices: communication interfaces (such as Ethernet interfaces), wireless network cards, and other devices with network access functions. Among them, the communication interface 1603 includes a receiving unit for receiving data / messages and a sending unit for sending data / messages.

[0154] The communication interface 1603 also includes an interface for interconnecting various modules / devices inside the network device 1600. This interface includes a hardware interface and a logical interface, and is not limited thereto.

[0155] The bus 1604 is of any type and is a communication bus for realizing the interconnection of internal devices of the network device 1600 (for example, the memory 1602, the processor 1601, the communication interface 1603, the scheduler 1605a, the scheduler 1605b). For example, a system bus. In the embodiments of the present application, the above-mentioned devices inside the network device 1600 are interconnected through the bus 1604 as an example. Optionally, the above-mentioned devices inside the network device 1600 can also communicate with each other by other connection methods except the bus 1604. For example, the above-mentioned devices inside the network device 1600 are interconnected through internal logical interfaces.

[0156] For the detailed description of the scheduler 1605a and the scheduler 1605b, reference can be made to the description of the scheduler above, and details are not repeated here.

[0157] It should be noted that the above-mentioned multiple devices can be respectively arranged on independent chips, or at least partially or completely arranged on the same chip. Whether to independently arrange each device on different chips or integrate and arrange them on one or more chips often depends on the needs of product design. The embodiments of the present application do not limit the specific implementation forms of the above-mentioned devices. And the descriptions of the processes corresponding to the above-mentioned respective drawings have different focuses. For parts not detailed in a certain process, reference can be made to the relevant descriptions of other processes.

[0158] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product providing the program development platform includes one or more computer instructions. When these computer program instructions are loaded and executed on the network device 1600, part or all of the functions of the message sequence preservation method provided by the embodiments of the present application are implemented in whole or in part.

[0159] Moreover, computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (such as coaxial cable, optical fiber, digital subscriber line) or wireless (such as infrared, wireless, microwave, etc.) means. The computer-readable storage medium stores computer program instructions that provide a program development platform.

[0160] The embodiments of the present application also provide another network device for implementing the message in-sequence method provided by the embodiments of the present application. Refer to Figure 17 , Figure 17 which shows a schematic structural diagram of another network device provided by the embodiments of the present application. As Figure 17 shown, the network device 1700 includes SoC 1 and SoC 2. The modules / devices in SoC 1 and the modules / devices in SoC 2 are connected and communicate through the inter-SoC communication bus.

[0161] SoC 1 includes processor 1, processor 2, scheduler 1, scheduler 2, memory 1, communication interface 1, and the internal communication bus of SoC 1. Among them, processor 1, processor 2, scheduler 1, scheduler 2, memory 1, and communication interface 1 communicate through the internal communication bus of SoC1. When it is necessary to process the data stream in parallel through processor 1 and processor 2, SoC 1 executes the message in-sequence method provided by the embodiments of the present application, which can realize message in-sequence for the data stream processed in parallel through processor 1 and processor 2 by scheduler 1 and scheduler 2, and can improve the in-sequence depth when performing message in-sequence on the data stream.

[0162] SoC 2 includes processor 3, processor 4, scheduler 3, scheduler 4, memory 2, communication interface 2, and the internal communication bus of SoC 2. Among them, processor 3, processor 4, scheduler 3, scheduler 4, memory 2, and communication interface 2 communicate through the internal communication bus of SoC2. When it is necessary to process the data stream in parallel through processor 3 and processor 4, SoC 2 executes the message in-sequence method provided by the embodiments of the present application, which can realize message in-sequence for the data stream processed in parallel through processor 3 and processor 4 by scheduler 3 and scheduler 4, and can improve the in-sequence depth when performing message in-sequence on the data stream.

[0163] Optionally, when it is necessary to pass through Figure 17When the shown processors 1, 2, 3, and 4 concurrently process the data stream, the network device 1700 executes the message order-preserving method provided in the embodiments of the present application, which can achieve message order-preserving for the data streams processed in parallel by processors 1, 2, 3, and 4 through schedulers 1, 2, 3, and 4, thereby increasing the order-preserving depth when performing message order-preserving on the data stream and improving the order-preserving performance of message order-preserving for the data stream.

[0164] Among them, the detailed descriptions of the processor, scheduler, memory, communication interface, and communication bus can all refer to Figure 16 the relevant descriptions and will not be elaborated here.

[0165] The embodiments of the present application also provide a computer-readable storage medium, which is a non-volatile computer-readable storage medium. The computer-readable storage medium includes computer program instructions. When the computer program instructions are executed by a computing device or a processor, the computing device or the processor executes the message order-preserving method provided in the embodiments of the present application.

[0166] The embodiments of the present application also provide a computer program product containing instructions. When the instructions run on a computing device or a processor, the message order-preserving method provided in the embodiments of the present application is implemented on the computing device or the processor.

[0167] Those of ordinary skill in the art can understand that all or part of the steps of implementing the above embodiments can be completed by hardware or can be completed by a program instructing relevant hardware. The described program can be stored in a computer-readable storage medium. The above-mentioned storage medium can be a read-only memory, a magnetic disk, an optical disc, or the like.

[0168] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data for analysis, stored data, displayed data, etc.), and signals involved in the present application are all authorized by users or fully authorized by all parties, and the collection, use, and processing of relevant data need to comply with the relevant laws, regulations, and standards of relevant countries and regions.

[0169] The embodiments of the present application also provide a chip, which includes a processor for running program instructions or code. The chip or a device including the chip can be used to execute the message order-preserving method provided in the embodiments of the present application. Exemplarily, the chip further includes: an input interface, an output interface, and a memory. Among them, the input interface, output interface, processor, and memory of the chip are connected through the internal connection path of the chip. The memory in the chip is used to store program instructions or code run by the processor, and the input interface and output interface of the chip are used for the connection and communication of the chip with other chips or devices.

[0170] In the embodiments of the present application, the terms "first", "second", and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance. The term "at least one" means one or more, and the term "a plurality" means a plurality, unless otherwise clearly defined.

[0171] The term "and / or" in the present application is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist simultaneously, and B exists alone. In addition, the character " / " in this document generally represents an "or" relationship between the associated objects before and after.

[0172] It should be understood that the terms used in the description of various examples herein are only for describing specific examples and are not intended to be limiting. As used in the description of various examples and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.

[0173] It should be understood that determining B based on A does not mean determining B solely based on A, but also based on A and / or other information.

[0174] It should be understood that the term "comprising" (also referred to as "includes", "including", "comprises", and / or "comprising") when used in this specification specifies the presence of the stated features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or their groups.

[0175] It should also be understood that in the various embodiments of the present application, the magnitudes of the sequence numbers of the various processes do not mean the order of execution, and the order of execution of each process should be determined according to its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.

[0176] The above are only optional embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the concept and principles of the present application shall be included within the protection scope of the present application.

Claims

1. A method for maintaining the order of messages, characterized in that, Applied to a network device, the network device being configured with a first task queue, a first in-sequence queue, a second task queue, and a second in-sequence queue, the method includes: Distributing packets of a first data stream to be processed to the first task queue and the second task queue; Performing in-sequence processing on the packets dequeued from the first task queue through the first in-sequence queue to obtain a first in-sequence result, and performing in-sequence processing on the packets dequeued from the second task queue through the second in-sequence queue to obtain a second in-sequence result; Performing an aggregation operation on the first in-sequence result and the second in-sequence result to complete the in-sequence processing of the processed packets in the first data stream.

2. The method according to claim 1, characterized in that, The first task queue and the first in-sequence queue are disposed in a first scheduler, the second task queue and the second in-sequence queue are disposed in a second scheduler, and the first scheduler and the second scheduler are integrated in different system-on-chips (SoCs) of the network device.

3. The method according to claim 1, characterized in that The first task queue and the first in-sequence queue are disposed in a first scheduler, the second task queue and the second in-sequence queue are disposed in a second scheduler, and the first scheduler and the second scheduler are integrated in the same system-on-chip (SoC) of the network device.

4. The method according to claim 2 or 3, characterized in that, When the first scheduler is configured as the main scheduler, the performing an aggregation operation on the first in-sequence result and the second in-sequence result includes: Performing an aggregation operation on the first in-sequence result and the second in-sequence result through the first scheduler.

5. The method according to claim 4, wherein A cache queue is disposed in the first scheduler, and the method further includes: Sending the second in-sequence result to the cache queue according to an aggregation flag included in an element in the second in-sequence queue for indicating a packet of the first data stream; the aggregation flag is used to indicate that the first scheduler performs an aggregation operation on the first in-sequence result and the second in-sequence result; The performing an aggregation operation on the first in-sequence result and the second in-sequence result through the first scheduler includes: Performing an aggregation operation on the first in-sequence result and the second in-sequence result indicated by the cache queue through the first scheduler.

6. The method according to claim 5, wherein Before sending the second in-sequence result to the cache queue according to an aggregation flag included in an element in the second in-sequence queue for indicating a packet of the first data stream, the method further includes: For a first packet in the first data stream, adding the aggregation flag to an element in the second task queue for indicating the first packet; migrating the element for indicating the first packet from the second task queue to the second in-sequence queue; the first packet is any packet in the first data stream that is scheduled to the second task queue; or, Adding the aggregation flag to an element in the second in-sequence queue for indicating the first packet.

7. The method according to claim 5 or 6, characterized in that, The performing an aggregation operation on the first in-sequence result and the second in-sequence result indicated by the cache queue through the first scheduler includes: Through the first scheduler, in accordance with an aggregation rule, the elements in the first in-order queue for indicating the first data stream packets and the elements in the buffer queue for indicating the first data stream packets are sequentially scheduled to the in-order completion queue, so as to implement an aggregation operation on the first in-order result and the second in-order result indicated by the buffer queue; wherein, the aggregation rule is a scheduling rule corresponding to a distribution rule, and the distribution rule is a scheduling rule for distributing the packets of the first data stream to the first task queue and the second task queue.

8. The method according to any one of claims 5 to 7, characterized in that When other schedulers are further included in the SoC to which the first scheduler belongs, the first scheduler and the other schedulers share the buffer queue.

9. The method according to any one of claims 1 to 8, characterized in that, The distributing of the packets of the first data stream to be processed to the first task queue and the second task queue includes: According to a preset distribution rule, distributing the packets of the first data stream to be processed to the first task queue and the second task queue.

10. A message sequence-preserving device, characterized in that, Applied to a network device, the network device is configured with a first task queue, a first in-order queue, a second task queue, and a second in-order queue. The apparatus includes: A distribution unit, configured to distribute the packets of the first data stream to be processed to the first task queue and the second task queue; A first in-order unit, configured to perform in-order processing on the packets dequeued from the first task queue through the first in-order queue to obtain a first in-order result; A second in-order unit, configured to perform in-order processing on the packets dequeued from the second task queue through the second in-order queue to obtain a second in-order result; An aggregation unit, configured to perform an aggregation operation on the first in-order result and the second in-order result to complete the in-order processing of the processed packets in the first data stream.

11. The device according to claim 10, characterized in that, The first task queue and the first in-order queue are arranged in a first scheduler, the second task queue and the second in-order queue are arranged in a second scheduler, and the first scheduler and the second scheduler are integrated in different system-on-chips (SoCs) of the network device.

12. The device according to claim 10, characterized in that The first task queue and the first in-order queue are arranged in a first scheduler, the second task queue and the second in-order queue are arranged in a second scheduler, and the first scheduler and the second scheduler are integrated in the same system-on-chip (SoC) of the network device.

13. The device according to claim 11 or 12, characterized in that, When the first scheduler is configured as the main scheduler, The aggregation unit is specifically configured to perform an aggregation operation on the first in-order result and the second in-order result through the first scheduler.

14. The device according to claim 13, characterized in that, A buffer queue is arranged in the first scheduler, and the apparatus further includes: A sending unit, configured to send the second in-order result to the buffer queue according to the aggregation flag included in the elements in the second in-order queue for indicating the first data stream packets; the aggregation flag is used to indicate that the first scheduler performs an aggregation operation on the first in-order result and the second in-order result; The aggregation unit is specifically configured to perform an aggregation operation on the first in-order result and the second in-order result indicated by the buffer queue through the first scheduler.

15. The device according to claim 14, characterized in that, The device further includes: An aggregation tag setting unit, configured to, before sending the second order-preserving result to the cache queue according to the aggregation tag included in the element in the second order-preserving queue for indicating the first data stream packet, add the aggregation tag to the element in the second task queue for indicating the first packet, and migrate the element for indicating the first packet from the second task queue to the second order-preserving queue; wherein, the first packet is any packet in the first data stream scheduled to the second task queue; or, The aggregation tag setting unit is configured to add the aggregation tag to the element in the second order-preserving queue for indicating the first packet.

16. The device according to claim 14 or 15, wherein The aggregation unit is specifically configured to, through the first scheduler, schedule the element in the first order-preserving queue for indicating the first data stream packet and the element in the cache queue for indicating the first data stream packet to the order-preserving completion queue in sequence according to an aggregation rule, so as to implement an aggregation operation on the first order-preserving result and the second order-preserving result indicated by the cache queue; wherein, the aggregation rule is a scheduling rule corresponding to a distribution rule, and the distribution rule is a scheduling rule for distributing the packets of the first data stream to the first task queue and the second task queue.

17. The device according to any one of claims 14 to 16, characterized in that When there are other schedulers in the SoC to which the first scheduler belongs, the first scheduler and the other schedulers share the cache queue.

18. The device according to any one of claims 10 to 17, wherein The distribution unit is specifically configured to distribute the packets of the first data stream to be processed to the first task queue and the second task queue according to a preset distribution rule.

19. A network device, characterized in that, Comprising: A memory, a communication interface, and one or more processors, wherein the one or more processors receive or send data through the communication interface, and the one or more processors are configured to read program instructions stored in the memory to execute the method according to any one of claims 1 to 9.

20. A computer-readable storage medium, characterized in that, Comprising computer program instructions, when the computer program instructions are executed by a computing device or a processor, the computing device or the processor executes the method according to any one of claims 1 to 9.

21. A computer program product comprising instructions, characterized in that, When the instructions run on a computing device or a processor, the computing device or the processor is caused to execute the method according to any one of claims 1 to 9.