Message forwarding method, network card, gateway device, storage medium and program
By introducing multiple sequence-saving queues and polling methods to process messages in the programmable chip of the network card, the problem of excessive CPU core load caused by elephant streaming messages is solved, and the forwarding performance is improved and the sequential processing and transmission of messages is ensured.
Patent Information
- Application Number
- CN202411676107.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-21
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2044-11-21
AI Technical Summary
In scenarios such as data centers, the gateway device is continuously sent to the same CPU core in the receiver's zoom mode, resulting in excessive load on the CPU core, affecting the forwarding performance of the gateway device.
By introducing multiple sequence-saving queues into the programmable chip of the network card, the required number of sequence-saving queues is configured according to the characteristics of the target service, the target sequence-saving queue and serial number of the target message are determined, and the messages are sent to multiple processor cores for processing in a polled manner, ensuring that the messages are sent to the destination device in sequence number order.
It effectively avoids excessive load caused by a single CPU core due to processing elephant streaming messages, improves the forwarding performance of gateway devices, and ensures the sequential processing and transmission of messages.
Smart Images

Figure CN119211151B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of network technology, and in particular to a message forwarding method, a network card, a gateway device, a storage medium and a program. Background Art
[0002] The communication traffic carried on various Internet networks is continuously growing and changing. Among them, the transmission of elephant flows will occupy more network resources. Elephant flows refer to network traffic with a long duration and large data volume in the network. For example, elephant flows with a message share of about 5% may account for about 40% of the network bandwidth. Common elephant flows include virtual machine migration, data migration, distributed database data processing, etc. In scenarios such as data centers, there is often a need to forward elephant flows. For example, a gateway device in a data center forwards the elephant flow received from a switch to the corresponding cloud server.
[0003] Many gateway devices use the network card multi-queue technology. The so-called network card multi-queue, as the name implies, means that the high-speed network card has multiple direct memory access (DMA) queues. The network card has an allocation mechanism based on multiple DMA queues. A DMA queue can be bound to a processor core (usually a CPU core) in the gateway device. At present, since the receive side scaling (RSS) mode has a natural message order preservation function, the RSS mode is usually used for message distribution. That is, when the gateway device receives a message, it can calculate the hash value according to the specific area of the message header, such as the five-tuple (including the five fields of source IP, source port, destination IP, destination port and protocol number), and query the forwarding table based on multiple low-significant bits of the hash value, that is, the index indirection table, to determine the corresponding CPU core number, so as to allocate the message to the corresponding CPU core for processing. It is understandable that different messages under the same network flow have the same specific header area (such as the same quintuple). Therefore, in RSS mode, the messages of the same network flow (especially when the network flow belongs to an elephant flow) will be distributed to the same CPU core for processing. This method can easily overwhelm a single CPU core and ultimately affect the forwarding performance of the gateway device. Summary of the invention
[0004] The embodiment of the present invention provides a message forwarding method, a network card, a gateway device, a storage medium and a program, which are used to improve the forwarding performance of the gateway device.
[0005] In a first aspect, an embodiment of the present invention provides a message forwarding method, which is applied to a programmable chip in a network card, wherein the network card is located in a gateway device, and the gateway device includes multiple processor cores, and the method includes:
[0006] Receiving a target message sent by a source device, wherein the target message corresponds to a target service;
[0007] Determine, among the multiple order-preserving queues corresponding to the target service, a target queue number of the target order-preserving queue corresponding to the target message, and determine a target message sequence number corresponding to the target message in the target order-preserving queue, and add the target queue number and the target message sequence number to the target message;
[0008] Sending the target message to a target processor core among the multiple processor cores for processing in a polling manner;
[0009] If a processed target message fed back by the target processor core is received, the processed target message is sent to the destination device in the order of the message sequence number according to the target queue number and the target message sequence number, and the target message sequence number is deleted from the target order-preserving queue after being sent to the destination device.
[0010] In a second aspect, an embodiment of the present invention provides a message forwarding device, which is applied to a programmable chip in a network card, wherein the network card is located in a gateway device, and the gateway device includes multiple processor cores, and the device includes:
[0011] A receiving module, used for receiving a target message sent by a source device, wherein the target message corresponds to a target service;
[0012] A determination module, used to determine the target queue number of the target order-preserving queue corresponding to the target message among the multiple order-preserving queues corresponding to the target service, and determine the target message sequence number corresponding to the target message in the target order-preserving queue, and add the target queue number and the target message sequence number to the target message;
[0013] A processing module, configured to send the target message to a target processor core among the multiple processor cores for processing in a polling manner;
[0014] A sending module is used to send the processed target message fed back by the target processor core to the destination device in the order of the message sequence number according to the target queue number and the target message sequence number, if the processed target message is received, and to delete the target message sequence number from the target order-preserving queue after sending it to the destination device.
[0015] In a third aspect, an embodiment of the present invention provides a network card, wherein the network card includes a programmable chip, and the network card is respectively communicatively connected to a plurality of processor cores in a gateway device;
[0016] The programmable chip is used to receive a target message corresponding to a target service sent by a source device; determine the target queue number of the target order-preserving queue corresponding to the target message among multiple order-preserving queues corresponding to the target service, and determine the target message sequence number corresponding to the target message in the target order-preserving queue, and add the target queue number and the target message sequence number to the target message; send the target message to a target processor core among the multiple processor cores in a polling manner for processing; and, if a processed target message fed back by the target processor core is received, send the processed target message to the destination device in the order of the message sequence number according to the target queue number and the target message sequence number, and delete the target message sequence number from the target order-preserving queue after sending it to the destination device.
[0017] In a fourth aspect, an embodiment of the present invention provides a gateway device, the gateway device comprising:
[0018] Multiple processor cores;
[0019] A network card, wherein the network card includes a programmable chip and the network card is communicatively connected to the multiple processor cores respectively;
[0020] The programmable chip is used to: receive a target message corresponding to a target service sent by a source device; determine the target queue number of the target order-preserving queue corresponding to the target message among multiple order-preserving queues corresponding to the target service, and determine the target message sequence number corresponding to the target message in the target order-preserving queue, and add the target queue number and the target message sequence number to the target message; send the target message to a target processor core among the multiple processor cores for processing in a polling manner; and, if a processed target message fed back by the target processor core is received, send the processed target message to the destination device in the order of the message sequence number according to the target queue number and the target message sequence number, and delete the target message sequence number from the target order-preserving queue after sending it to the destination device.
[0021] In a fifth aspect, an embodiment of the present invention provides a message forwarding system, the message forwarding system comprising:
[0022] Multiple processor cores;
[0023] A network card, wherein the network card includes a plurality of network card receiving queues, a plurality of network card sending queues, and a programmable chip, wherein the programmable chip includes a message receiving module, a message sending module, and an order-preserving queue scheduling module, and the network card is respectively communicatively connected with the plurality of processor cores;
[0024] The message receiving module is used to: receive a target message corresponding to a target service sent by a source device, and determine a target queue number of a target order-preserving queue corresponding to the target message among multiple order-preserving queues corresponding to the target service, and receive a target message sequence number of the target message in the target order-preserving queue sent by the order-preserving queue scheduling module, add the target queue number and the target message sequence number to the target message, and send the target message to a target processor core among the multiple processor cores through a target network card receiving queue in a polling manner for processing, wherein the target network card receiving queue is one of the multiple network card receiving queues;
[0025] The message sending module is used to: receive the processed target message fed back by the target processor core through the target network card sending queue corresponding to the target network card receiving queue, and send the target queue number and the target message sequence number to the order-preserving queue scheduling module, and receive the message sending notification sent by the order-preserving queue scheduling module, send the processed target message to the destination device in the order of the message sequence number based on the message sending notification, and send the message sending result to the order-preserving queue scheduling module, wherein the target network card sending queue is one of the multiple network card sending queues;
[0026] The order-preserving queue scheduling module is used to: assign the target message sequence number corresponding to the target message in the target order-preserving queue, send the target message sequence number to the message receiving module, and write the target message sequence number into the target order-preserving queue, and determine the message sending notification based on the target queue number and the target message sequence number sent by the message sending module, and send the message sending notification to the message sending module, and delete the target message sequence number from the target order-preserving queue according to the message sending result sent by the message sending module.
[0027] In the sixth aspect, an embodiment of the present invention provides a non-temporary machine-readable storage medium, on which executable code is stored. When the executable code is executed by a programmable chip in a gateway device, the programmable chip executes the message forwarding method described in the first aspect.
[0028] In a seventh aspect, an embodiment of the present invention provides a computer program product, comprising: a computer program, which, when executed by a programmable chip in a gateway device, enables the programmable chip to execute the message forwarding method described in the first aspect.
[0029] The message forwarding method provided by the embodiment of the present invention configures the required number of order-preserving queues according to the needs of the target service based on the characteristics of the target service. When receiving the target message of the target service, the target order-preserving queue corresponding to the target message is determined among the multiple order-preserving queues corresponding to the target service, and the target message sequence number corresponding to the target message in the target order-preserving queue is determined, and the target queue number and the target message sequence number of the target order-preserving queue are added to the target message, which is equivalent to marking the target message with a sequence number. When the processed target message fed back by the processor core is subsequently sent to the destination device, the sending order of the target message can be determined based on the mark to ensure that the target messages are sent in sequence. When the processed target message is sent, its corresponding target message sequence number is deleted from the target order-preserving queue to free up storage space in the queue. In this process, by configuring multiple order-preserving queues for the target service, more space is provided for storing message sequence numbers for the messages corresponding to the target service, avoiding the situation where the allocated message sequence numbers cannot be removed from the order-preserving queues due to the long delay in processing the messages by the processor core, and the new message sequence numbers cannot be allocated, that is, the new messages cannot be received normally (for example, packet loss occurs), which affects the message forwarding performance of the gateway device for the target service.
[0030] Moreover, in the specific implementation, the target message is sent to the target processor core among multiple processor cores for processing by polling. That is to say, when the gateway device receives different messages, these messages are sent to different processor cores by polling. This avoids a processor core being overwhelmed due to continuously receiving too many messages (that is, the load is too high, which will cause the message processing delay to increase). BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0032] Figure 1 A flowchart of a message forwarding method provided by an embodiment of the present invention;
[0033] Figure 2 A schematic diagram of an application of a message forwarding method provided by an embodiment of the present invention;
[0034] Figure 3 A schematic diagram of an application of an order-preserving queue provided in an embodiment of the present invention;
[0035] Figure 4 A flowchart of sending the processed target message to the destination device according to the message sequence number sequence in the target sequence-preserving queue provided by an embodiment of the present invention;
[0036] Figure 5 A schematic diagram of another application of an order-preserving queue provided in an embodiment of the present invention;
[0037] Figure 6 An application schematic diagram of a message forwarding system provided by an embodiment of the present invention;
[0038] Figure 7 A schematic structural diagram of a message forwarding device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0039] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0040] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the embodiments of the present invention are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0041] Some embodiments of the present invention are described in detail below in conjunction with the accompanying drawings. In the case where there is no conflict between the embodiments, the following embodiments and the features in the embodiments can be combined with each other. In addition, the step sequence in the following method embodiments is only an example and not a strict limitation.
[0042] First, the terms or concepts involved in the embodiments of the present invention are explained:
[0043] Gateway device: can be a gateway-type forwarding node in application scenarios such as data centers, and is a traffic convergence point. The gateway device in the embodiment of the present invention can also be a network device such as a switch, a router, etc. that can forward messages.
[0044] Field-Programmable Gate Array (FPGA) is a programmable chip, an integrated circuit that can be reconfigured at the hardware level.
[0045] Although the RSS mode has the advantage of natural message order preservation, when forwarding messages in the RSS mode, messages of the same network flow will be continuously sent to the same processor core, causing excessive load on the processor core and large message processing delays, ultimately affecting the forwarding performance of the gateway device.
[0046] In view of this, an embodiment of the present invention provides a new message forwarding mechanism, in which an order-preserving queue is introduced to realize the function of message order-preserving in the message forwarding process. In addition, the message forwarding mechanism can flexibly configure the number of order-preserving queues according to the needs of the target service, so as to avoid the situation that the allocated message sequence number cannot be removed from the order-preserving queue (i.e., new messages cannot be allocated) due to the large delay in processing the message by the processor core, thereby affecting the message forwarding performance of the gateway device for the target service. In practical applications, when a target message of the target service is received, the target order-preserving queue corresponding to the target message and the target message sequence number corresponding to the target message in the target order-preserving queue are determined in the multiple order-preserving queues corresponding to the target service, and the target queue number and the target message sequence number of the target order-preserving queue are added to the target message, and the target message is sent to the target processor core in the multiple processor cores for processing by polling. It should be understood that when the gateway device receives different messages, these messages are sent to different processor cores by polling, so as to avoid a certain processor core from receiving too many messages continuously, resulting in excessive load on the processor core and increased message processing delay.
[0047] If a processed target message is subsequently received from the target processor core, the processed target message will be sent to the destination device in the order of the message sequence number according to the target queue number and the target message sequence number, and the target message sequence number will be deleted from the target order-preserving queue after being sent to the destination device. In this way, it can be ensured that the target messages are sent in sequence, and storage space in the queue can be freed up after the target messages are sent in sequence.
[0048] Figure 1 The present invention provides a flowchart of a message forwarding method, which is applied to a programmable chip in a network card, the network card is located in a gateway device, and the gateway device includes multiple processor cores. Figure 1 As shown, the method comprises the following steps:
[0049] 101. Receive a target message sent by a source device, where the target message corresponds to a target service.
[0050] 102. Determine the target queue number of the target order-preserving queue corresponding to the target message among the multiple order-preserving queues corresponding to the target service, and determine the target message sequence number corresponding to the target message in the target order-preserving queue, and add the target queue number and the target message sequence number to the target message.
[0051] 103. Send the target message to a target processor core among the multiple processor cores in a polling manner for processing.
[0052] 104. If a processed target message fed back by the target processor core is received, the processed target message is sent to the destination device in the order of the message sequence number according to the target queue number and the target message sequence number, and the target message sequence number is deleted from the target order-preserving queue after being sent to the destination device.
[0053] It should be noted that the target service can be a live broadcast application service, a game application service, etc., which are not listed here one by one. The source device and the destination device refer to two devices that need to communicate through the gateway device, such as a terminal device that uses the target service and a cloud server that provides the target service. Multiple processor cores can usually be multiple CPU cores, such as Figure 2 The CPU core 1, CPU core 2, ..., CPU core n in the gateway device shown in FIG. The programmable chip may be Figure 2 The FPGA chip in the embodiment is not limited thereto, and other dedicated integrated chips may also be used. The following description will be given by taking the processor core as the CPU core and the programmable chip as the FPGA chip as an example. Figure 2 As shown in the figure, a network card is provided in the gateway device, and the FPGA chip is located in the network card. The network card is a multi-queue gateway, which may include multiple DMA receiving queues illustrated in the figure and multiple DMA sending queues corresponding thereto one by one.
[0054] In actual applications, the configuration information corresponding to the target service can be first received through a programmable chip, and the configuration information includes the identification information of the target service and the queue numbers of multiple order-keeping queues corresponding to the target service. In specific implementation, optionally, an information configuration interface is provided on the gateway device, and the information configuration interface displays some auxiliary information for the user to configure. The auxiliary information can be used to find the usage record corresponding to the target service from the historical usage record of the gateway device when the user enters the identification information of the target service into the information configuration interface, so as to determine the historical network traffic characteristics of the target service based on the usage record. If it is determined that the target service belongs to the service of the elephant flow based on the historical network traffic characteristics, a prompt is issued to the user, such as "Since the network traffic of the target service you are processing is large, it is recommended that you choose 4 order-keeping queues, specifically, you can choose order-keeping queue 1, order-keeping queue 2, order-keeping queue 3 and order-keeping queue 4", so that the user can configure the order-keeping queue according to the prompt. It should be understood that the order-keeping queue 1, order-keeping queue 2, order-keeping queue 3 and order-keeping queue 4 are idle order-keeping queues that are not used by other services in multiple order-keeping queues. Of course, users can also independently decide the number of order-keeping queues to be allocated for the target service and which specific order-keeping queues to allocate. By receiving the configuration information corresponding to the target service, the number of order-keeping queues required can be configured on demand based on the traffic characteristics of the target service before message forwarding officially begins, to avoid the situation where the processor core cannot process the messages corresponding to the target service in a timely manner due to excessive network traffic required by the target service, causing a certain order-keeping queue to be quickly filled and no other order-keeping queues to be available, affecting the gateway device's message forwarding performance for the target service.
[0055] After determining the number of sequence-preserving queues corresponding to the target service and the queue numbers of the multiple sequence-preserving queues corresponding to the target service based on the configuration information, receive the target message under the target service (any message under the target service) sent by the source device, and determine the target queue number of the target sequence-preserving queue corresponding to the target message and the target message sequence number (Packet Sequence Number, PSN for short) corresponding to the target message in the target sequence-preserving queue among the multiple sequence-preserving queues corresponding to the target service, so as to add the target queue number and the target message sequence number to the target message.
[0056] As a first implementation method, the target queue number of the target order-keeping queue corresponding to the target message can be determined from multiple order-keeping queues by polling multiple order-keeping queues corresponding to the target service. For example, assuming that the target service corresponds to 4 order-keeping queues, they are Figure 2As shown in the figure: order-preserving queue 1, order-preserving queue 2, order-preserving queue 3 and order-preserving queue 4, and each order-preserving queue is polled in this order. Assuming that the previous message of the target message is polled to order-preserving queue 2, then, according to the method of polling multiple order-preserving queues, the target order-preserving queue corresponding to the target message should be order-preserving queue 3. After determining the target order-preserving queue, the target message sequence number is sequentially assigned to the target message. For example, before the target message, 9 message sequence numbers (1 to 9) have been successively assigned, then the target message sequence number corresponding to the target message in the target order-preserving queue is 10. After that, add "the target queue number is order-preserving queue 3" and "the target message sequence number is 10" to the target message. The execution process of this implementation method is described in detail below. Here, we only want to emphasize one point: under this implementation method, the message sequence numbers stored in different order-preserving queues corresponding to the target service will not be repeated. Assuming that each order-preserving queue can accommodate a maximum of 1000 message sequence numbers, it means that the plug-in that generates message sequence numbers needs to be able to generate N*1000 message sequence numbers, where N represents the number of order-preserving queues corresponding to the target service. In actual applications, the message sequence numbers can be continuous integers starting from 1. When they reach, for example, N*1000, they are reallocated from 1.
[0057] As a second implementation method, the target queue number of the target order-preserving queue corresponding to the target message and the target message sequence number corresponding to the target order-preserving queue can be determined in the multiple order-preserving queues corresponding to the target service according to the characteristic information of the target message, wherein the characteristic information is used to distinguish different network flows under the target service, such as the five-tuple contained in the message. A service can contain multiple network flows. For ease of understanding, different service objects under the target service can be regarded as different network flows.
[0058] In specific implementation, the hash value corresponding to the target message is determined according to the five-tuple information of the target message; the target queue number of the target order-preserving queue corresponding to the target message is determined in the multiple order-preserving queues according to the remainder of the hash value and the total number of queues of the multiple order-preserving queues; the target message sequence number is sequentially assigned to the target message according to the message sequence number already assigned in the target order-preserving queue. For ease of understanding, the following example is given:
[0059] The hash value corresponding to the target message is calculated based on the five-tuple information of the target message (including the five fields of source IP, source port, destination IP, destination port and protocol number). Assuming that the hash value corresponding to the target message is 15, the number of all order-preserving queues corresponding to the multiple services running on the gateway device is 8, namely order-preserving queue 1, order-preserving queue 2, order-preserving queue 3, order-preserving queue 4, order-preserving queue 5, order-preserving queue 6, order-preserving queue 7 and order-preserving queue 8, wherein the multiple order-preserving queues corresponding to the target service are order-preserving queue 1, order-preserving queue 2, order-preserving queue 3 and order-preserving queue 4, that is, the total number is 4. Then, after calculation, the remainder of the hash value and the total number of order-preserving queues corresponding to the target service is 3. At this time, the order-preserving queue number stored in the address corresponding to index 3 can be determined based on the index indirection table. Assuming that the order-preserving queue number is 3, it can be determined that order-preserving queue 3 is the target order-preserving queue corresponding to the target message. Among them, each table entry in the index indirection table corresponds to a different remainder, and each table entry stores the order-preserving queue number corresponding to the corresponding remainder. After determining the target sequence-preserving queue, the target message sequence number is sequentially assigned to the target message based on the message sequence number that has been assigned in the target sequence-preserving queue in a manner that different sequence-preserving queues are individually assigned message sequence numbers. For example, currently in sequence-preserving queue 3, message sequence number 9 has been assigned, and the target message sequence number corresponding to the target message in the target sequence-preserving queue is 10. Afterwards, "the target queue number is sequence-preserving queue 3" and "the target message sequence number is 10" are added to the target message. Among them, the message sequence number is assigned in a manner that different sequence-preserving queues are individually assigned message sequence numbers, and duplicate message sequence numbers may appear in different sequence-preserving queues at this time. Assuming that each sequence-preserving queue can accommodate up to 1000 message sequence numbers, it means that the plug-in that generates the message sequence number needs to be able to generate 1000 message sequence numbers for each sequence-preserving queue on demand. The message sequence number in each sequence-preserving queue can be, for example, a continuous integer starting from 1. When it reaches, for example, 1000, it is reallocated from 1.
[0060] It can be seen that in the above two methods, the upper limit of the message sequence number required by the target service is different, but the total number of message sequence numbers that can be stored in multiple order-preserving queues is unchanged. For example, when the target service corresponds to 4 order-preserving queues, 4000 message sequence numbers can be stored. That is to say, it can tolerate the source device to continuously send 4000 messages, but the processor core does not complete the message processing and sends the message.
[0061] After determining the target queue number of the target order-preserving queue corresponding to the target message and the target message sequence number corresponding to the target message in the target order-preserving queue based on the above two methods, and adding the target queue number and the target message sequence number to the target message, the target message can be sent to the target processor core among the multiple processor cores for processing (such as encapsulation, parsing, security verification, etc.) by polling. The specific process is as follows:
[0062] Poll the network card receiving queue (i.e., DMA queue) corresponding to the target service, store the target message in the currently polled target network card receiving queue, and upload the target message to the target processor core bound to the target network card receiving queue for processing through the target network card receiving queue.
[0063] In actual applications, the network card receiving queues corresponding to the target service have a set correspondence with the processor core. For ease of understanding, please refer to Figure 2 , Figure 2 A schematic diagram of an application of a message forwarding method provided by an embodiment of the present invention. Figure 2 In the example, queue 1 in the DMA receive queue corresponds to CPU core 1, queue 2 in the DMA receive queue corresponds to CPU core 2, and queue n in the DMA receive queue corresponds to CPU core n. Assuming that the target network card receive queue currently polled is queue 2, the target message received by the message receiving module is sent to the target processor core (i.e., processor core 2) through queue 2 for processing. Among them, the message receiving module is a module that receives messages from the source device. In the above example, processor core 2 will read the target message from the corresponding network card receive queue for processing.
[0064] Further, the processed target message fed back by the target processor core is stored in the target network card sending queue corresponding to the target network card receiving queue, so as to read the processed target message from the target network card sending queue.
[0065] It should be noted that the NIC send queue and the NIC receive queue are one-to-one corresponding. In specific implementation, the target message uploaded through the target NIC receive queue will be sent to the corresponding target NIC send queue after being processed by the target processor core. For ease of understanding, please refer to Figure 2 .exist Figure 2In the DMA transmission queue, queue 1 corresponds to CPU core 1, queue 2 corresponds to CPU core 2, and queue n corresponds to processor core n. Assuming that the target processor core is processor core 2, the processed target message fed back by it will be stored in DMA transmission queue 2 corresponding to DMA receiving queue 2. The message sending module responsible for sending the processed message to the destination device will read the processed target message from DMA transmission queue 2, perform "sequence preservation processing" according to the target queue number and target message sequence number of the target sequence preservation queue contained in the processed target message, and then send it.
[0066] Afterwards, if Figure 2 As shown, after the target message is read through the message sending module, the processed target message can be sent to the destination device in the order of the message sequence number according to the target queue number and the target message sequence number carried in the target message, and the target message sequence number can be deleted from the target order-preserving queue after being sent to the destination device. For this process, the above two implementations have different processing methods, which can be specifically referred to in the following embodiments, and will not be introduced in detail here. Only one point is emphasized here: assuming that the target message sequence number of the target message is K, after obtaining the processed target message, it is found that there are still message sequence numbers less than K in the multiple order-preserving queues corresponding to the target service, which means that the message received from the source device before the target message has not been sent, so it is necessary to wait for the previous message to be fed back from the corresponding processor core and sent to the destination device before the target message can be sent to achieve order-preserving sending of the message. Of course, optionally, in order to avoid the target message being delayed in being sent out due to the previous message being lost or other failures that have not been fed back, a timer can be set. When the timer of the processed target message ends, if there are still messages with a smaller message sequence number than it that have not been sent out, the wait is stopped and the processed target message is sent out immediately. Among them, the message sequence number stored in the order-keeping queue is: the message sequence number corresponding to the message that has been allocated but not yet sent. If the message has been sent to the destination device, the corresponding message sequence number is deleted from the corresponding order-keeping queue.
[0067] The message forwarding method provided by the embodiment of the present invention configures multiple order-preserving queues for the target service, providing more space for storing message sequence numbers for the messages corresponding to the target service, thereby avoiding the situation where the allocated message sequence numbers cannot be removed from the order-preserving queues due to the large delay in processing the messages by the processor core, and the new message sequence numbers cannot be allocated, that is, the new messages cannot be received normally (for example, packets will be lost), thereby affecting the message forwarding performance of the gateway device for the target service. In actual applications, after receiving the target message of the target service, the target message carrying the target queue number of the target order-preserving queue and the target message sequence number will be sent to the target processor core among the multiple processor cores in a polling manner for processing, thereby avoiding the situation where a certain processor core is overloaded due to continuous reception of too many messages, and the message processing delay increases.
[0068] The specific process of "sending the processed target message to the destination device in the order of the message sequence number" is described in detail below based on the above two implementation methods:
[0069] It should be noted that the target service corresponds to multiple network flows, and each network flow corresponds to multiple messages. When forwarding messages, the messages under the same network flow need to be sent to the destination device in sequence according to the set sending order.
[0070] In the first implementation, different network flows under the target service are not distinguished. If a processed target message is received from the target processor core, multiple order-preserving queues corresponding to the target service are polled according to the target queue number and the target message sequence number to determine whether there is a message sequence number before the target message sequence number in the multiple order-preserving queues. If so, the processed target message, the target queue number and the target message sequence number are cached, and after the processed message corresponding to the message sequence number less than the target message sequence number is sent, the processed target message is sent to the destination device. In this process, a first-in-first-out (FIFO) strategy can be used to manage the writing and removal of message sequence numbers in the order-preserving queues. Among them, the above polling of multiple order-preserving queues corresponding to the target service according to the target queue number and the target message sequence number can be understood as: when multiple services are running in the gateway device, the queue number of the multiple order-preserving queues corresponding to each service is a group, and there will be no identical queue numbers between different groups. Therefore, based on the above target queue number, the group to which it belongs can be determined, thereby determining the multiple order-preserving queues that need to be polled, and then querying whether there are message sequence numbers less than the target message sequence number in these multiple order-preserving queues. For ease of understanding, the following examples are given:
[0071] Assume that the target service corresponds to 4 order-preserving queues, namely order-preserving queue 1, order-preserving queue 2, order-preserving queue 3 and order-preserving queue 4, and the target service corresponds to 2 network flows, of which the first network flow corresponds to 4 messages, namely message 1, message 2, message 3 and message 4, and the second network flow corresponds to 8 messages. The following takes the target message as message 3 in the first network flow as an example. In the specific implementation, the queue number of the target order-preserving queue corresponding to the target message is determined by polling. Assume that message 1 is assigned to order-preserving queue 1 (assuming that the message sequence number of message 1 in order-preserving queue 1 is 1), and message 2 is assigned to order-preserving queue 2 (assuming that the message sequence number of message 2 in order-preserving queue 2 is 2). In this case, message 3 will be polled to order-preserving queue 3 (assuming that the message sequence number of message 3 in order-preserving queue 3 is 3). For details, please refer to Figure 3 In summary, in the first implementation mode, network flows are not distinguished. When assigning message sequence numbers, the order-preserving queue corresponding to each message is determined and the message sequence number is assigned to it by polling the order-preserving queue in the order in which the message receiving module receives the message.
[0072] Afterwards, message 3 with the target queue number (sequence-keeping queue 3) and the target message sequence number (No. 3) is sent to the target processor core for processing in a polling manner. If the processed target message fed back by the target processor core is received, the sequence-keeping queue 1, sequence-keeping queue 2, sequence-keeping queue 3 and sequence-keeping queue 4 are polled to determine whether the previous message 1 and message 2 have been sent to the destination device. Specifically, according to the above example, when polling from sequence-keeping queue 1 to sequence-keeping queue 2, it can be determined whether message 1 and message 2 have been sent to the destination device. If the corresponding message sequence number is no longer there, it means that it has been sent. If message 1 and message 2 have been sent to the destination device, message 3 is directly sent to the destination device, and the corresponding message sequence number 3 in sequence-keeping queue 3 is deleted. If message 1 or message 2 has not been sent to the destination device, the processed message 3, as well as the target queue number and target message sequence number corresponding to message 3 are cached, and the processed message 3 is sent to the destination device after waiting for the processed message 1 and message 2 to be sent out.
[0073] It should be noted that in the first implementation, the order-preserving delivery of service-level messages is actually achieved, and of course the order-preserving delivery of network flow-level messages is also achieved, because the order in which messages are received under the same network flow is consistent with the order in which they are sent. However, because different network flows are not explicitly distinguished, it can be considered that all network flows under the target service share multiple order-preserving queues.
[0074] Based on this, in the first implementation mode, although the order-preserving forwarding of the message can be successfully completed, it has at least the following problems:
[0075] 1. The first implementation does not distinguish between different network flows under the target service, that is, when it allocates order-keeping queues for multiple messages corresponding to the target service, it does not consider the network flows corresponding to the multiple messages, and multiple messages corresponding to the same network flow will be allocated to different order-keeping queues. In this case, when the processed message needs to be sent to the destination device, it is necessary to traverse the multiple order-keeping queues corresponding to the target service to determine whether the previous message has been sent. The whole process takes a long time and the query cost is high.
[0076] 2. In the first implementation, the order-preserving queues are not independent of each other. Assuming that each order-preserving queue can store 1000 message sequence numbers, the four order-preserving queues corresponding to the target service can store 4000 message sequence numbers. For ease of understanding, the following is combined with Figure 3 For example, suppose the message sequence numbers in the order-preserving queue 1 are "1, 5, 9, 13...3997", the message sequence numbers in the order-preserving queue 2 are "2, 6, 10, 14...3998", the message sequence numbers in the order-preserving queue 3 are "3, 7, 11, 15...3999", and the message sequence numbers in the order-preserving queue 4 are "4, 8, 12, 16...4000". It can be seen that under the first implementation method, the message sequence numbers in each order-preserving queue are different. For different order-preserving queues, the message sequence numbers cannot be reused, which increases the cost of generating message sequence numbers.
[0077] In view of this, the above problem can be solved by the second implementation, specifically:
[0078] In the second implementation, different network flows under the target service are distinguished by feature information. If a processed target message fed back by the target processor core is received, the processed target message is sent to the destination device in the order of the message sequence numbers in the target order-preserving queue according to the target queue number and the target message sequence number. At this time, for the processed target message, only the order-preserving queue corresponding to the target queue number needs to be queried, and the query cost is low. Moreover, as described above, in this method, the message sequence numbers of multiple order-preserving queues can be reused.
[0079] Figure 4 The flowchart of sending the processed target message to the destination device according to the message sequence number sequence in the target sequence-preserving queue provided by the embodiment of the present invention is as follows: Figure 4 As shown, according to the target queue number and the target message sequence number, the processed target message is sent to the destination device in the message sequence number order in the target sequence-preserving queue, including the following steps:
[0080] 401. According to the target queue number, query the message sequence number currently stored in the target sequence-preserving queue.
[0081] 402. If the target message sequence number is the smallest message sequence number among the currently stored message sequence numbers, the processed target message is directly sent to the destination device.
[0082] 403. If there is a message sequence number smaller than the target message sequence number among the currently stored message sequence numbers, the processed target message, the target queue number and the target message sequence number are cached, and after waiting for the processed message corresponding to the message sequence number smaller than the target message sequence number to be sent out, the processed target message is sent to the destination device.
[0083] For ease of understanding, the following is a specific example of the execution process of the above steps:
[0084] Assume that the target service corresponds to 4 order-preserving queues, namely order-preserving queue 1, order-preserving queue 2, order-preserving queue 3 and order-preserving queue 4, and the target service corresponds to 2 network flows, of which the first network flow corresponds to 4 packets, namely packet 1, packet 2, packet 3 and packet 4, and the second network flow corresponds to 8 packets. In the phase of allocating packets to order-preserving queues, since the five-tuple information carried by different packets under the same network flow is the same, multiple packets under the same network flow can be allocated to the same order-preserving queue. For example, assign packet 1, packet 2, packet 3 and packet 4 to order-preserving queue 1, and each order-preserving queue is independently assigned a packet sequence number: Assume that the packet sequence number of packet 1 in order-preserving queue 1 is 1, the packet sequence number of packet 2 in order-preserving queue 1 is 2, the packet sequence number of packet 3 in order-preserving queue 1 is 3, and the packet sequence number of packet 4 in order-preserving queue 1 is 4. For details, please refer to Figure 5 At the same time, the 8 packets corresponding to the second network flow are sent to the order-preserving queue 2.
[0085] In actual applications, assuming that the target message is message 3 in the first network flow, then the currently stored message sequence number is directly queried in the order-preserving queue 1 according to the target queue number (assuming it is 3). If the message sequence numbers currently stored in the order-preserving queue 1 include "No. 3, No. 4, No. 5", it means that the target message sequence number (No. 3) is the smallest message sequence number (No. 3) among the currently stored message sequence numbers. At this time, the processed target message can be directly sent to the destination device, and "No. 3" in the order-preserving queue 1 is deleted. If the message sequence numbers currently stored in the order-preserving queue 1 include "No. 2, No. 3, No. 4, No. 5", it means that there is a message sequence number (No. 2) that is smaller than the target message sequence number among the currently stored message sequence numbers. At this time, it is necessary to wait for message 2 corresponding to No. 2 to be processed and successfully sent to the destination device before sending the target message (message 3) to the destination device.
[0086] Based on the above, the second implementation method can distinguish different network flows under the target service through characteristic information (such as quintuple). It should be understood that different messages under the same network flow have the same quintuple. Therefore, the quintuple can be used to divide the messages based on the concept of "network flow" and assign the messages of the same network flow to the same order-preserving queue. On this basis, when the processed target message needs to be sent to the destination device, there is no need to traverse the multiple order-preserving queues corresponding to the target service. You can directly query the currently stored message sequence number in the target order-preserving queue according to the target queue number. If the target message sequence number is the minimum message sequence number among the currently stored message sequence numbers, the processed target message can be directly sent to the destination device. The whole process takes a short time and the message forwarding efficiency is high.
[0087] In addition, in the second implementation, each order-preserving queue is independent of each other. Assuming that each order-preserving queue can store 1000 message sequence numbers, the four order-preserving queues corresponding to the target service can store 4000 message sequence numbers. For ease of understanding, the following is combined with Figure 5 Take an example: suppose the message sequence numbers in the order-preserving queue 1 are "1, 2, 3, 4... 1000", the message sequence numbers in the order-preserving queue 2 can also be "1, 2, 3, 4... 1000", the message sequence numbers in the order-preserving queue 3 can also be "1, 2, 3, 4... 1000", and the message sequence numbers in the order-preserving queue 4 can also be "1, 2, 3, 4... 1000". It can be seen that under the second implementation method, the message sequence numbers in multiple order-preserving queues can be the same. In the process of creating message sequence numbers for multiple order-preserving queues, the message sequence numbers can be reused, reducing the cost of generating message sequence numbers.
[0088] For ease of understanding, the following Figure 6 The scheme of the present invention is specifically illustrated by examples:
[0089] Figure 6 The following is a schematic diagram of an application of a message forwarding system provided by an embodiment of the present invention. Figure 6 As shown, the system includes: a network card and multiple processor cores, and the network card is respectively connected to the multiple processor cores. The network card includes multiple network card receiving queues, multiple network card sending queues corresponding to the network card receiving queues, and a programmable chip, and the programmable chip includes a message receiving module, a message sending module, and an order-preserving queue scheduling module.
[0090] The message receiving module is used to: receive the target message corresponding to the target service sent by the source device, and determine the target queue number of the target order-preserving queue corresponding to the target message among the multiple order-preserving queues corresponding to the target service, and the target message sequence number of the target message sent by the receiving order-preserving queue scheduling module in the target order-preserving queue, add the target queue number and the target message sequence number to the target message, and send the target message to the target processor core among the multiple processor cores through the target network card receiving queue in a polling manner for processing, wherein the target network card receiving queue is one of the multiple network card receiving queues.
[0091] The message sending module is used to: receive the processed target message fed back by the target processor core through the target network card sending queue corresponding to the target network card receiving queue, and send the target queue number and the target message sequence number to the order-preserving queue scheduling module, and receive the message sending notification sent by the order-preserving queue scheduling module, and send the processed target message to the destination device in the order of the message sequence number based on the message sending notification, and send the message sending result to the order-preserving queue scheduling module, wherein the target network card sending queue is one of multiple network card sending queues.
[0092] The order-preserving queue scheduling module is used to: assign a target message sequence number corresponding to the target message in the target order-preserving queue, send the target message sequence number to the message receiving module, and write the target message sequence number into the target order-preserving queue, as well as determine the message sending notification based on the target queue number and the target message sequence number sent by the message sending module, and send the message sending notification to the message sending module, and delete the target message sequence number in the target order-preserving queue according to the message sending result sent by the message sending module.
[0093] In practical applications, the message forwarding system can be implemented as a gateway device. In order to facilitate understanding of the specific application process of multiple processor cores, multiple network card receiving queues, multiple network card sending queues, and various functional modules in the programmable chip under the message forwarding system, a detailed example is given below. Figure 6 As shown, the gateway device includes multiple processor cores (i.e. Figure 6 CPU core 1, CPU core 2...CPU core n) and network cards, which are connected to multiple processor cores. The network card includes a programmable chip (i.e. Figure 6 FPGA chip in the ), multiple network card receiving queues (i.e. Figure 6 DMA receive queue 1, DMA receive queue 2...DMA receive queue n) and multiple network card send queues (i.e. Figure 6DMA send queue 1, DMA send queue 2...DMA send queue n in the programmable chip includes: a message receiving module, a message sending module and an order-preserving queue scheduling module, wherein the order-preserving queue scheduling module is used to schedule multiple order-preserving queues (such as Figure 6 The order-preserving queue 1, order-preserving queue 2, order-preserving queue 3...order-preserving queue n).
[0094] During specific implementation, S1, a message receiving module receives configuration information corresponding to a target service, where the configuration information is used to indicate queue numbers of multiple order-preserving queues corresponding to the target service.
[0095] S2. The message receiving module receives a target message sent by the source device, wherein the target message corresponds to a target service.
[0096] S3. The message receiving module determines the target queue number (No. 2) of the target order-preserving queue (assuming it is order-preserving queue 2) corresponding to the target message in the multiple order-preserving queues corresponding to the target service according to the characteristic information of the target message, and receives the target message sequence number (assuming it is No. 3) corresponding to the target message in the target order-preserving queue sent by the order-preserving queue scheduling module. During this process, the order-preserving queue scheduling module writes the target message sequence number into the target order-preserving queue. At this point, the message receiving module adds the target queue number (No. 2) and the target message sequence number (assuming it is No. 3) to the target message.
[0097] S4. The message receiving module sends the target message to the DMA receiving queue 2 in a polling manner, so as to send the target message to the target CPU core (assuming it is CPU core 2) through the DMA receiving queue 2 for message parsing and processing.
[0098] S5. The message sending module receives the target message processed by the target CPU core through DMA sending queue 2, and sends the target queue number (No. 2) and the target message sequence number (assuming it is No. 3) corresponding to the target message to the order-preserving queue scheduling module, so as to determine the relationship between the target message sequence number and the minimum message sequence number in the currently stored message sequence numbers in the target order-preserving queue (order-preserving queue 2) through the order-preserving queue scheduling module.
[0099] If the target message sequence number (No. 2) is the smallest message sequence number among the currently stored message sequence numbers (No. 2, No. 3, No. 4), the order-preserving queue scheduling module sends a message sending notification to the message sending module, and the message sending module directly sends the processed target message to the destination device, and sends the message sending result indicating that the target message is successfully sent to the order-preserving queue scheduling module.
[0100] If there is a message sequence number smaller than the target message sequence number (No. 2) among the currently stored message sequence numbers (No. 1, No. 3, No. 4), the processed target message, target queue number and target message sequence number are cached by the order-preserving queue scheduling module. After the processed message corresponding to the message sequence number (No. 1) smaller than the target message sequence number is sent, the order-preserving queue scheduling module sends a message sending notification to the message sending module, so that the processed target message is sent to the destination device through the message sending module, and the message sending result indicating that the target message is successfully sent is sent to the order-preserving queue scheduling module.
[0101] S6. The order-preserving queue scheduling module receives the message sending result sent by the message sending module, and determines that the target message has been successfully sent to the destination device. At this time, the target message sequence number is deleted from the target order-preserving queue.
[0102] The message forwarding device of one or more embodiments of the present invention will be described in detail below. Those skilled in the art will appreciate that these devices can be configured using commercially available hardware components through the steps taught in this solution.
[0103] Figure 7 A schematic diagram of the structure of a message forwarding device provided in an embodiment of the present invention, the device is applied to a programmable chip in a network card, the network card is located in a gateway device, and the gateway device includes multiple processor cores, such as Figure 7 As shown, the device includes: a receiving module 11, a determining module 12, a processing module 13 and a sending module 14.
[0104] The receiving module 11 is used to receive a target message sent by a source device, where the target message corresponds to a target service.
[0105] Determination module 12 is used to determine the target queue number of the target order-preserving queue corresponding to the target message among the multiple order-preserving queues corresponding to the target service, and determine the target message sequence number corresponding to the target message in the target order-preserving queue, and add the target queue number and the target message sequence number to the target message.
[0106] The processing module 13 is used to send the target message to a target processor core among the multiple processor cores for processing in a polling manner.
[0107] The sending module 14 is used to send the processed target message fed back by the target processor core to the destination device in the order of the message sequence number according to the target queue number and the target message sequence number, and delete the target message sequence number in the target order-preserving queue after sending it to the destination device.
[0108] Among them, optionally, the determination module 12 is specifically used to: determine the target queue number of the target order-preserving queue corresponding to the target message among the multiple order-preserving queues corresponding to the target service according to the characteristic information of the target message, and determine the target message sequence number corresponding to the target message in the target order-preserving queue, wherein the characteristic information is used to distinguish different network flows under the target service.
[0109] Furthermore, the determination module 12 is specifically used to: determine the hash value corresponding to the target message based on the five-tuple information of the target message; determine the target queue number of the target order-preserving queue corresponding to the target message among the multiple order-preserving queues based on the remainder of the hash value and the total number of queues of the multiple order-preserving queues; and sequentially assign the target message sequence number to the target message based on the message sequence numbers already assigned in the target order-preserving queue.
[0110] Among them, optionally, the sending module 14 is specifically used to: query the message sequence number currently stored in the target order-preserving queue according to the target queue number; if the target message sequence number is the minimum message sequence number among the currently stored message sequence numbers, directly send the processed target message to the destination device; if there is a message sequence number smaller than the target message sequence number among the currently stored message sequence numbers, cache the processed target message, the target queue number and the target message sequence number, wait for the processed message corresponding to the message sequence number smaller than the target message sequence number to be sent, and then send the processed target message to the destination device.
[0111] Among them, optionally, the processing module 13 is specifically used to: poll the network card receiving queue corresponding to the target service, store the target message in the currently polled target network card receiving queue; upload the target message to the target processor core bound to the target network card receiving queue through the target network card receiving queue for processing.
[0112] Optionally, the device further includes: a storage module, used to store the processed target message fed back by the target processor core into a target network card sending queue corresponding to the target network card receiving queue, so as to read the processed target message from the target network card sending queue.
[0113] Optionally, the device further comprises: a configuration information receiving module, configured to receive configuration information corresponding to the target service, wherein the configuration information comprises identification information of the target service and queue numbers of the multiple order-preserving queues corresponding to the target service.
[0114] Figure 7The device shown can execute the steps provided in the aforementioned embodiments. For detailed execution process and technical effects, please refer to the description in the aforementioned embodiments, which will not be repeated here.
[0115] In addition, an embodiment of the present invention provides a network card, which is respectively communicated with multiple processor cores in a gateway device; the programmable chip is used to receive a target message corresponding to a target service sent by a source device; among the multiple order-preserving queues corresponding to the target service, the target queue number of the target order-preserving queue corresponding to the target message is determined, and the target message sequence number corresponding to the target message in the target order-preserving queue is determined, and the target queue number and the target message sequence number are added to the target message; the target message is sent to a target processor core among the multiple processor cores in a polling manner for processing; and if a processed target message fed back by the target processor core is received, the processed target message is sent to the destination device in the order of the message sequence number according to the target queue number and the target message sequence number, and the target message sequence number is deleted from the target order-preserving queue after being sent to the destination device.
[0116] Among them, optionally, in the process of determining the target queue number and the target message sequence number, the programmable chip is specifically used to: determine the hash value corresponding to the target message according to the five-tuple information of the target message; determine the target queue number of the target order-preserving queue corresponding to the target message among the multiple order-preserving queues according to the remainder of the hash value and the total number of queues of the multiple order-preserving queues; and sequentially assign the target message sequence numbers to the target messages according to the message sequence numbers already assigned in the target order-preserving queue.
[0117] The network card can execute the steps provided in the aforementioned embodiments. The detailed execution process and technical effects can be found in the description of the aforementioned embodiments, which will not be repeated here.
[0118] The embodiment of the present invention also provides a gateway device, which includes: a network card and multiple processor cores. The network card includes a programmable chip, and the network card is respectively connected to the multiple processor cores in communication; the programmable chip is used to: receive a target message corresponding to a target service sent by a source device; determine the target queue number of the target order-preserving queue corresponding to the target message in the multiple order-preserving queues corresponding to the target service, and determine the target message sequence number corresponding to the target message in the target order-preserving queue, and add the target queue number and the target message sequence number to the target message; send the target message to the target processor core in the multiple processor cores in a polling manner for processing; and, if a processed target message fed back by the target processor core is received, send the processed target message to the destination device in the order of the message sequence number according to the target queue number and the target message sequence number, and delete the target message sequence number in the target order-preserving queue after sending it to the destination device.
[0119] The gateway device can execute the steps provided in the aforementioned embodiments. For detailed execution process and technical effects, please refer to the description in the aforementioned embodiments, which will not be repeated here.
[0120] In addition, an embodiment of the present invention provides a non-temporary machine-readable storage medium, on which executable code is stored. When the executable code is executed by a programmable chip in a gateway device, the programmable chip can at least implement the message forwarding method provided in the aforementioned embodiment.
[0121] In addition, an embodiment of the present invention provides a computer program product, which includes: a computer program, when the computer program is executed by a programmable chip in a gateway device, the programmable chip can at least implement the message forwarding method provided in the above embodiment.
[0122] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment. Those of ordinary skill in the art may understand and implement the present invention without creative effort.
[0123] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by adding a necessary general hardware platform, and of course can also be implemented by combining hardware and application programs. Based on such an understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a computer product, and the present invention can be in the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0124] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A message forwarding method, characterized in that: A programmable chip applied to a network card, the network card is located in a gateway device, the gateway device includes multiple processor cores, the network card includes corresponding multiple network card receiving queues and multiple network card sending queues, and the method includes: Receiving a target message sent by a source device, wherein the target message corresponds to a target service; Determine, among the multiple order-preserving queues corresponding to the target service, a target queue number of the target order-preserving queue corresponding to the target message, and determine a target message sequence number corresponding to the target message in the target order-preserving queue, and add the target queue number and the target message sequence number to the target message; Sending the target message to a target processor core among the multiple processor cores for processing in a polling manner; If a processed target message fed back by the target processor core is received, the processed target message is sent to the destination device in the message sequence number order according to the target queue number and the target message sequence number, and the target message sequence number is deleted from the target order-preserving queue after being sent to the destination device; Among them, determining the target queue number of the target order-preserving queue corresponding to the target message among the multiple order-preserving queues corresponding to the target service, and determining the target message sequence number corresponding to the target message in the target order-preserving queue, include: determining the target queue number of the target order-preserving queue corresponding to the target message among the multiple order-preserving queues corresponding to the target service according to the characteristic information of the target message, and determining the target message sequence number corresponding to the target message in the target order-preserving queue by separately allocating message sequence numbers to different order-preserving queues under the same total number limit of message sequence numbers, wherein the characteristic information is used to distinguish different network flows under the target service.
2. The method according to claim 1, characterized in that The step of determining, according to the characteristic information of the target message, a target queue number of a target order-preserving queue corresponding to the target message and a target message sequence number corresponding to the target message in the target order-preserving queue among multiple order-preserving queues corresponding to the target service, comprises: Determine a hash value corresponding to the target message according to the five-tuple information of the target message; Determine, according to a remainder of the hash value and the total number of queues of the multiple order-preserving queues, a target queue number of a target order-preserving queue corresponding to the target message in the multiple order-preserving queues; The target message sequence numbers are sequentially allocated to the target messages according to the message sequence numbers that have been allocated in the target order-preserving queue.
3. The method according to claim 1, characterized in that The step of sending the processed target message to the destination device in the order of the message sequence numbers according to the target queue number and the target message sequence number includes: According to the target queue number, query the message sequence number currently stored in the target order-preserving queue; If the target message sequence number is the smallest message sequence number among the currently stored message sequence numbers, directly sending the processed target message to the destination device; If there is a message sequence number smaller than the target message sequence number among the currently stored message sequence numbers, the processed target message, the target queue number and the target message sequence number are cached, and after waiting for the processed message corresponding to the message sequence number smaller than the target message sequence number to be sent out, the processed target message is sent to the destination device.
4. The method according to any one of claims 1 to 3, characterized in that The step of sending the target message to a target processor core among the multiple processor cores for processing in a polling manner includes: Polling the network card receiving queue corresponding to the target service, and storing the target message in the currently polled target network card receiving queue; The target message is uploaded to the target processor core bound to the target network card receiving queue through the target network card receiving queue for processing.
5. The method according to claim 4, characterized in that The method further comprises: The processed target message fed back by the target processor core is stored in a target network card sending queue corresponding to the target network card receiving queue, so as to read the processed target message from the target network card sending queue.
6. The method according to any one of claims 1 to 3, characterized in that The method further comprises: Configuration information corresponding to the target service is received, where the configuration information includes identification information of the target service and queue numbers of the multiple order-preserving queues corresponding to the target service.
7. A network card, characterized in that: The network card includes a programmable chip, a corresponding plurality of network card receiving queues and a plurality of network card sending queues, and the network card is respectively connected to a plurality of processor cores in the gateway device; The programmable chip is used to receive a target message corresponding to a target service sent by a source device; Determine, among the multiple order-preserving queues corresponding to the target service, a target queue number of the target order-preserving queue corresponding to the target message, and determine a target message sequence number corresponding to the target message in the target order-preserving queue, and add the target queue number and the target message sequence number to the target message; Sending the target message to a target processor core among the multiple processor cores for processing in a polling manner; and, if a processed target message fed back by the target processor core is received, sending the processed target message to the destination device in the order of the message sequence number according to the target queue number and the target message sequence number, and deleting the target message sequence number in the target order-preserving queue after sending it to the destination device; Among them, determining the target queue number of the target order-preserving queue corresponding to the target message among the multiple order-preserving queues corresponding to the target service, and determining the target message sequence number corresponding to the target message in the target order-preserving queue, include: determining the target queue number of the target order-preserving queue corresponding to the target message among the multiple order-preserving queues corresponding to the target service according to the characteristic information of the target message, and determining the target message sequence number corresponding to the target message in the target order-preserving queue by separately allocating message sequence numbers to different order-preserving queues under the same total number limit of message sequence numbers, wherein the characteristic information is used to distinguish different network flows under the target service.
8. The network card according to claim 7, characterized in that: In the process of determining the target queue number and the target message sequence number, the programmable chip is specifically used to: determine the hash value corresponding to the target message according to the five-tuple information of the target message; determine the target queue number of the target order-preserving queue corresponding to the target message in the multiple order-preserving queues according to the remainder of the hash value and the total number of queues of the multiple order-preserving queues; The target message sequence numbers are sequentially allocated to the target messages according to the message sequence numbers that have been allocated in the target order-preserving queue.
9. A gateway device, characterized in that: include: Multiple processor cores; A network card, wherein the network card comprises a programmable chip, a corresponding plurality of network card receiving queues and a plurality of network card sending queues, and the network card is respectively communicatively connected with the plurality of processor cores; The programmable chip is used to: receive a target message corresponding to a target service sent by a source device; Determine, among the multiple order-preserving queues corresponding to the target service, a target queue number of the target order-preserving queue corresponding to the target message, and determine a target message sequence number corresponding to the target message in the target order-preserving queue, and add the target queue number and the target message sequence number to the target message; Sending the target message to a target processor core among the multiple processor cores for processing in a polling manner; and, if a processed target message fed back by the target processor core is received, sending the processed target message to the destination device in the order of the message sequence number according to the target queue number and the target message sequence number, and deleting the target message sequence number in the target order-preserving queue after sending it to the destination device; Among them, determining the target queue number of the target order-preserving queue corresponding to the target message among the multiple order-preserving queues corresponding to the target service, and determining the target message sequence number corresponding to the target message in the target order-preserving queue, include: determining the target queue number of the target order-preserving queue corresponding to the target message among the multiple order-preserving queues corresponding to the target service according to the characteristic information of the target message, and determining the target message sequence number corresponding to the target message in the target order-preserving queue by separately allocating message sequence numbers to different order-preserving queues under the same total number limit of message sequence numbers, wherein the characteristic information is used to distinguish different network flows under the target service.
10. A message forwarding system, characterized in that: include: Multiple processor cores; A network card, wherein the network card includes a plurality of network card receiving queues, a plurality of network card sending queues, and a programmable chip, wherein the programmable chip includes a message receiving module, a message sending module, and an order-preserving queue scheduling module, and the network card is respectively communicatively connected with the plurality of processor cores; The message receiving module is used to: receive a target message corresponding to a target service sent by a source device, and determine a target queue number of a target order-preserving queue corresponding to the target message among multiple order-preserving queues corresponding to the target service, and receive a target message sequence number of the target message in the target order-preserving queue sent by the order-preserving queue scheduling module, add the target queue number and the target message sequence number to the target message, and send the target message to a target processor core among the multiple processor cores through a target network card receiving queue in a polling manner for processing, wherein the target network card receiving queue is one of the multiple network card receiving queues; The message sending module is used to: receive the processed target message fed back by the target processor core through the target network card sending queue corresponding to the target network card receiving queue, and send the target queue number and the target message sequence number to the order-preserving queue scheduling module, and receive the message sending notification sent by the order-preserving queue scheduling module, send the processed target message to the destination device in the order of the message sequence number based on the message sending notification, and send the message sending result to the order-preserving queue scheduling module, wherein the target network card sending queue is one of the multiple network card sending queues; The order-preserving queue scheduling module is used to: assign the target message sequence number corresponding to the target message in the target order-preserving queue, send the target message sequence number to the message receiving module, write the target message sequence number into the target order-preserving queue, and determine the message sending notification based on the target queue number and the target message sequence number sent by the message sending module, and send the message sending notification to the message sending module, and delete the target message sequence number in the target order-preserving queue according to the message sending result sent by the message sending module; Among them, the message receiving module is specifically used to: determine the target queue number of the target sequence-preserving queue corresponding to the target message among the multiple sequence-preserving queues corresponding to the target service according to the characteristic information of the target message, and determine the target message sequence number corresponding to the target message in the target sequence-preserving queue by separately allocating message sequence numbers to different sequence-preserving queues under the same total number limit of message sequence numbers, wherein the characteristic information is used to distinguish different network flows under the target service.
11. A non-transitory machine-readable storage medium, characterized in that: The non-transitory machine-readable storage medium stores executable code, and when the executable code is executed by a programmable chip in a gateway device, the programmable chip executes the message forwarding method according to any one of claims 1 to 6.
12. A computer program product, characterized in that include: A computer program, when the computer program is executed by a programmable chip in a gateway device, causes the programmable chip to execute the message forwarding method as described in any one of claims 1-6.
Citation Information
Patent Citations
Network flow processing method, apparatus and device, and storage medium
CN109688069A
Message forwarding order preserving method and device in DPU, electronic equipment and storage medium
CN117560433A