Message forwarding method, network card, gateway device, storage medium and program

By using a programmable chip in the network card of the gateway device, the dynamic load balancing mode is determined based on the packet characteristic information, and the forwarding of messages between multiple processor cores is solved, and the forwarding performance and message sequence of the gateway device are improved.

CN119211150BActive Publication Date: 2025-05-23HANGZHOU FEITIAN CLOUD COMPUTING CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411675626.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-21
Publication Date
2025-05-23
Estimated Expiration
2044-11-21

AI Technical Summary

Technical Problem

In scenarios such as data centers, gateway devices can easily lead to excessive load on a single CPU core when forwarding elephant streams, affecting forwarding performance.

Method used

By using a programmable chip in the network card, the dynamic load balancing mode is determined based on the feature information of the message, and the target message sequence number is allocated in the sequence protection queue corresponding to the target service, metadata is generated and filled into the message, and the message is sent to multiple processor cores for processing in a polled manner.

Benefits of technology

It effectively avoids excessive load caused by a single processor core due to receiving too many elephant streaming messages, improves the forwarding performance of gateway devices, and ensures the sequential forwarding of messages.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119211150B_ABST
    Figure CN119211150B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention provides a message forwarding method, a network card, a gateway device, a storage medium and a program, which relate to the field of network technology. The method includes: responding to a first message sent by a source end device, determining a message forwarding mode of the first message according to characteristic information of the first message; if the message forwarding mode is a dynamic load balancing mode, assigning the target message sequence number of the first message in the order-keeping queue corresponding to the target service; generating first metadata, and filling the first metadata into the first message to obtain a second message; sending the second message to the first processor core running a driver in a polling manner; responding to the first processed message fed back by the first processor core, determining the sending order of the first processed message according to the first metadata contained in the first processed message, so as to send the first processed message to the corresponding destination end device in the sending order. This scheme can ensure the forwarding performance of the gateway device.
Need to check novelty before this filing date? Find Prior Art

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 indirect index table, to determine the corresponding CPU core number, so as to allocate the message to the corresponding CPU core for processing. It should be noted that the messages forwarded by the gateway device include both data messages corresponding to the application (i.e., service) and control messages corresponding to the kernel protocol stack, and these messages are all forwarded through the RSS mode. It is understandable that different messages under the same network flow (flow) under a certain service have the same specific header area (such as the same five-tuple), so in the RSS mode, no matter which type of message is in the same network flow, especially when the network flow belongs to the elephant flow, the message will be distributed to the same CPU core for processing. This method can easily explode 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 can ensure 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 a first processor core and a second processor core that are communicatively connected to the network card, and the method includes:

[0006] In response to a first message sent by a source device, determining a message forwarding mode of the first message according to characteristic information of the first message, the first message corresponding to a target service;

[0007] If the message forwarding mode is a dynamic load balancing mode, assigning the target message sequence number of the first message in the order-preserving queue corresponding to the target service;

[0008] Generate first metadata, and fill the first metadata into the first message to obtain a second message, wherein the first metadata includes first identification information corresponding to the dynamic load balancing mode, the queue number of the order-preserving queue, and the target message sequence number;

[0009] Sending the second message to a first processor core running a driver in a polling manner, so that the first processor core sends the second message to a second processor core for processing based on the first metadata to obtain a first processed message, and the second processor core runs a message processing program of the target service;

[0010] In response to the first processed message fed back by the first processor core, the sending order of the first processed message is determined according to the first metadata contained in the first processed message, so as to send the first processed message to the corresponding destination device in the sending order, and delete the target message sequence number in the order preservation queue.

[0011] 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 a first processor core and a second processor core that are communicatively connected to the network card, and the device includes:

[0012] a determination module, configured to determine, in response to a first message sent by a source device, a message forwarding mode of the first message according to characteristic information of the first message, wherein the first message corresponds to a target service;

[0013] an allocation module, configured to allocate a target message sequence number of the first message in the order-preserving queue corresponding to the target service if the message forwarding mode is a dynamic load balancing mode;

[0014] A filling module, used to generate first metadata, and fill the first metadata into the first message to obtain a second message, wherein the first metadata includes the first identification information corresponding to the dynamic load balancing mode, the queue number of the order-preserving queue, and the target message sequence number;

[0015] a processing module, configured to send the second message to a first processor core running a driver program in a polling manner, so that the first processor core sends the second message to a second processor core for processing based on the first metadata to obtain a first processed message, and the second processor core runs a message processing program of the target service;

[0016] A sending module is used to respond to the first processed message fed back by the first processor core, determine the sending order of the first processed message according to the first metadata contained in the first processed message, so as to send the first processed message to the corresponding destination device in the sending order, and delete the target message sequence number in the order-preserving queue.

[0017] In a third aspect, an embodiment of the present invention provides a message forwarding method, which is applied to a first processor core running a driver in a gateway device, wherein the first processor core is any processor core running the driver, and the gateway device also includes a network card, and the network card includes a programmable chip, and the method includes:

[0018] In response to a first message corresponding to a target service sent by a source device, a second message sent by the programmable chip in a polling manner is received, the second message being obtained by filling first metadata into the first message, wherein the first metadata includes first identification information corresponding to a dynamic load balancing mode, a queue number of an order-preserving queue corresponding to the target service, and a target message sequence number corresponding to the first message in the order-preserving queue, wherein the dynamic load balancing mode is a message forwarding mode of the first message determined by the programmable chip according to characteristic information of the first message;

[0019] sending the second message to a second processor core for processing based on the first metadata to obtain a first processed message, the second processor core running a message processing program of the target service;

[0020] In response to the first processed message fed back by the second processor core, the first processed message is sent to the programmable chip, so that the programmable chip determines the sending order of the first processed message according to the first metadata contained in the first processed message, and sends the first processed message to the corresponding destination device according to the sending order, and then deletes the target message sequence number in the order preservation queue.

[0021] In a fourth aspect, an embodiment of the present invention provides a message forwarding device, which is applied to a first processor core running a driver in a gateway device, wherein the first processor core is any processor core running the driver, and the gateway device further includes a network card, wherein the network card includes a programmable chip, and the device includes:

[0022] A receiving module, configured to receive, in response to a first message corresponding to a target service sent by a source device, a second message sent by the programmable chip in a polling manner, wherein the second message is obtained by filling first metadata into the first message, wherein the first metadata includes first identification information corresponding to a dynamic load balancing mode, a queue number of an order-preserving queue corresponding to the target service, and a target message sequence number corresponding to the first message in the order-preserving queue, wherein the dynamic load balancing mode is a message forwarding mode of the first message determined by the programmable chip according to characteristic information of the first message;

[0023] a processing module, configured to send the second message to a second processor core for processing based on the first metadata to obtain a first processed message, wherein the second processor core runs a message processing program of the target service;

[0024] A sending module is used to send the first processed message to the programmable chip in response to the first processed message fed back by the second processor core, so that the programmable chip determines the sending order of the first processed message according to the first metadata contained in the first processed message, and sends the first processed message to the corresponding destination device according to the sending order, and then deletes the target message sequence number in the order-keeping queue.

[0025] In a fifth 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 first processor core and a second processor core in a gateway device;

[0026] The programmable chip is used to respond to a first message sent by a source device, determine a message forwarding mode of the first message according to characteristic information of the first message, and the first message corresponds to a target service; if the message forwarding mode is a dynamic load balancing mode, assign the first message a target message sequence number in the order-preserving queue corresponding to the target service; generate first metadata, and fill the first metadata into the first message to obtain a second message, wherein the first metadata includes first identification information corresponding to the dynamic load balancing mode, the queue number of the order-preserving queue, and the target message sequence number; send the second message to a first processor core running a driver in a polling manner, so that the first processor core sends the second message to the second processor core for processing based on the first metadata to obtain a first processed message, and the second processor core runs the message processing program of the target service; in response to the first processed message fed back by the first processor core, determine the sending order of the first processed message according to the first metadata contained in the first processed message, so as to send the first processed message to the corresponding destination device according to the sending order, and delete the target message sequence number in the order-preserving queue.

[0027] In a sixth aspect, an embodiment of the present invention provides a gateway device, the gateway device comprising:

[0028] A plurality of processor cores, including a first processor core running a driver program and a second processor core running a message processing program for a target service;

[0029] A network card, wherein the network card includes a programmable chip, and the network card is respectively connected to the first processor core and the second processor core for communication;

[0030] The programmable chip is used to: respond to a first message sent by a source device, determine a message forwarding mode of the first message according to characteristic information of the first message, and the first message corresponds to a target service; if the message forwarding mode is a dynamic load balancing mode, assign the first message a target message sequence number in an order-preserving queue corresponding to the target service; generate first metadata, and fill the first metadata into the first message to obtain a second message, wherein the first metadata includes first identification information corresponding to the dynamic load balancing mode, the queue number of the order-preserving queue, and the target message sequence number; send the second message to the first processor core in a polling manner;

[0031] The first processor core is used to: send the second message to the second processor core for processing based on the first metadata to obtain a first processed message, and send the first processed message to the programmable chip;

[0032] The programmable chip is also used to: respond to the first processed message fed back by the first processor core, determine the sending order of the first processed message according to the first metadata contained in the first processed message, so as to send the first processed message to the corresponding destination device in the sending order, and delete the target message sequence number in the order preservation queue.

[0033] In the seventh aspect, an embodiment of the present invention provides a non-temporary machine-readable storage medium, on which an 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 as described in the first aspect. When the executable code is executed by a processor core in the gateway device, the processor core executes the message forwarding method as described in the third aspect.

[0034] In an eighth aspect, an embodiment of the present invention provides a computer program product, comprising: a computer program, when the computer program is executed by a programmable chip in a gateway device, the programmable chip executes the message forwarding method as described in the first aspect, and when the executable code is executed by a processor core in the gateway device, the processor core executes the message forwarding method as described in the third aspect.

[0035] The message forwarding method provided by the embodiment of the present invention responds to the first message sent by the source device, determines the message forwarding mode of the first message according to the characteristic information of the first message, realizes the classification of the first message, and determines whether the first message belongs to the message corresponding to the service or the message corresponding to the kernel protocol stack, so as to perform targeted processing based on the category of the first message later. If it is determined that the message forwarding mode of the first message is the dynamic load balancing mode, it means that the first message belongs to the message corresponding to the service. At this time, the target message sequence number of the first message in the order-keeping queue corresponding to the target service is assigned, and the first metadata composed of the first identification information corresponding to the dynamic load balancing mode, the queue number of the order-keeping queue and the target message sequence number is filled into the first message to obtain the second message, which is equivalent to marking the first message with a sequence number. When the first processed message fed back by the first processor core is subsequently sent to the destination device, the sending order of the first message can be determined based on the mark to ensure that the first message is sent in sequence.

[0036] Afterwards, the second message is sent to the first processor core running the driver in a polling manner. 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 increase the message processing delay), thereby ensuring the forwarding performance of the gateway device.

[0037] Furthermore, since the first message belongs to the message corresponding to the service, the second message can be sent to the second processor core of the message processing program running the target service for processing, so as to obtain the first processed message sent by the second processor core through the first processor core, and determine the sending order of the first processed message based on the first metadata contained in the first processed message, so as to send the first processed message to the corresponding destination device in the sending order, and delete the target message sequence number in the order-preserving queue. In this way, it can not only ensure that the first processed message is sent in sequence, but also free up storage space in the queue after the target message is sent in sequence. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] 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.

[0039] Figure 1 A flowchart of a message forwarding method provided by an embodiment of the present invention;

[0040] Figure 2 A schematic diagram of an application of a message forwarding method provided by an embodiment of the present invention;

[0041] Figure 3 A schematic diagram of the composition of a second message provided by an embodiment of the present invention;

[0042] Figure 4 A flowchart of another message forwarding method provided by an embodiment of the present invention;

[0043] Figure 5 A flowchart of a message forwarding method provided by an embodiment of the present invention;

[0044] Figure 6 A schematic diagram of the composition of first metadata provided by an embodiment of the present invention;

[0045] Figure 7 A flowchart of obtaining a first processed message provided by an embodiment of the present invention;

[0046] Figure 8 A flowchart of sending a first processed message to a programmable chip provided by an embodiment of the present invention;

[0047] Fig. 9 A flowchart of another message forwarding method provided by an embodiment of the present invention;

[0048] Fig.10 A schematic diagram of the structure of a message forwarding device provided in an embodiment of the present invention;

[0049] Fig.11 A schematic structural diagram of another message forwarding device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0050] 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.

[0051] 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.

[0052] 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.

[0053] First, the terms or concepts involved in the embodiments of the present invention are explained:

[0054] 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.

[0055] Field-Programmable Gate Array (FPGA) is a programmable chip, an integrated circuit that can be reconfigured at the hardware level.

[0056] At present, the messages forwarded by the gateway device include both the messages corresponding to the service and the messages corresponding to the kernel protocol stack, and these messages are forwarded through the RSS mode. Although the RSS mode has the advantage of natural message order preservation, when forwarding messages in the RSS mode, the messages of the same network flow (especially when the network flow belongs to the elephant flow) will be continuously sent to the same processor core, resulting in excessive load on the processor core and large message processing delay, which ultimately affects the forwarding performance of the gateway device.

[0057] In view of this, an embodiment of the present invention provides a message forwarding method, which can determine the message forwarding mode of the first message according to the characteristic information of the first message, which is equivalent to classifying the first message in advance according to the characteristic information, and determining whether the first message belongs to the message corresponding to the service or the message corresponding to the kernel protocol stack. When it is determined that the first message belongs to the message corresponding to the service, it can be determined that the message forwarding mode of the first message is a dynamic load balancing mode (Dynamic Load Balancer, referred to as DLB). In this dynamic load balancing mode, an order-preserving queue is introduced to realize the function of message order preservation during message forwarding. In specific implementation, the first metadata with the first identification information corresponding to the dynamic load balancing mode, the queue number of the order-preserving queue and the target message sequence number is filled into the first message to obtain the second message, and the second message is sent to the first processor core running the driver in a polling manner. 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 increasing the message processing delay, thereby ensuring the forwarding performance of the gateway device. Afterwards, since the first message belongs to the message corresponding to the service, in order to successfully complete the processing of the message, the first processor core can send the second message to the second processor core running the message processing program of the target service for processing based on the first metadata to obtain the first processed message.

[0058] After processing the second message, the second processor core will send the obtained first processed message to the programmable chip through the first processor. At this time, the programmable chip can determine the sending order of the first processed message according to the first metadata contained in the first processed message, so as to send the first processed message to the corresponding destination device in the sending order, and delete the target message sequence number in the order-preserving queue, so as to ensure that the first processed message is sent in order and free up storage space in the queue after the target message is sent in order.

[0059] Figure 1A flowchart of a message forwarding method provided in an embodiment of the present invention is applied to a programmable chip in a network card, the network card is located in a gateway device, and the gateway device includes a first processor core and a second processor core that are communicatively connected to the network card, such as Figure 1 As shown, the method comprises the following steps:

[0060] 101. The programmable chip responds to a first message sent by a source device and determines a message forwarding mode of the first message according to characteristic information of the first message, wherein the first message corresponds to a target service.

[0061] 102. If the message forwarding mode is a dynamic load balancing mode, the programmable chip allocates a target message sequence number of the first message in the order-preserving queue corresponding to the target service.

[0062] 103. The programmable chip generates first metadata, and fills the first metadata into the first message to obtain a second message, wherein the first metadata includes first identification information corresponding to the dynamic load balancing mode, the queue number of the order-preserving queue, and the target message sequence number.

[0063] 104. The programmable chip sends the second message to the first processor core running a driver in a polling manner, so that the first processor core sends the second message to the second processor core for processing based on the first metadata to obtain a first processed message, and the second processor core runs a message processing program of the target service.

[0064] 105. The programmable chip responds to the first processed message fed back by the first processor core, determines the sending order of the first processed message according to the first metadata contained in the first processed message, sends the first processed message to the corresponding destination device in the sending order, and deletes the target message sequence number in the order-preserving queue.

[0065] 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 2As 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 network card, which can include multiple DMA receiving queues shown in the figure and multiple DMA sending queues corresponding to them one by one.

[0066] In actual applications, the programmable chip receives the first message corresponding to the target service sent by the source device, and determines the message forwarding mode of the first message according to the characteristic information of the first message. The specific process is as follows: obtain the matching rule corresponding to the receiver scaling mode (i.e., RSS mode), and if it meets the matching rule, determine that the message forwarding mode of the first message is the receiver scaling mode, and if the characteristic information of the first message does not meet the matching rule, determine that the message forwarding mode of the first message is the dynamic load balancing mode. Among them, the matching rule includes the message characteristic information that needs to be forwarded according to the receiver scaling mode.

[0067] It should be noted that for a message, the header setting area generally contains the following five-tuple information: source IP, destination IP, source port, destination port, and protocol type. It is understandable that the gateway device may include one or more network cards, and different messages may be received by different network cards. In this process, the IP address of the network card receiving the message is the destination IP, and the port of the network card receiving the message is the destination port. Similarly, the IP address of the source device sending the message is the source IP, and the port of the source device sending the message is the source port.

[0068] In specific implementation, the message feature information based on which the message forwarding mode of the first message is determined may be the destination IP and protocol type in the above-mentioned five-tuple information. When determining the message forwarding mode of the first message, it is determined whether the protocol type carried in the first message corresponds to the matching rule, that is, it is determined whether the protocol type carried in the first message is consistent with the protocol type set in the matching rule. If consistent, the message forwarding mode of the first message is determined to be the receiver scaling mode (RSS mode). If inconsistent, the message forwarding mode of the first message is determined to be the dynamic load balancing mode (DLB mode). Among them, the set protocol type can be the Link Layer Discovery Protocol (LLDP for short), the Address Resolution Protocol (ARP for short), etc., which can be set according to actual needs and are not limited here. In addition, it is also possible to determine whether the destination IP carried in the first message corresponds to the matching rule, that is, to determine whether the destination IP carried in the first message is consistent with the destination IP set in the matching rule. If consistent, the message forwarding mode of the first message is determined to be the RSS mode. If not, the message forwarding mode of the first message is determined to be the DLB mode. By judging whether the characteristic information of the first message meets the matching rule, the message forwarding mode of the first message can be determined, so that the processor core for processing the first message can be determined based on the message forwarding mode, laying a foundation for the smooth forwarding of the first message.

[0069] If after judging the above matching rules, it is determined that the message forwarding mode of the first message is the DLB mode, the subsequent message forwarding work is performed in the DLB mode. Among them, the DLB mode refers to sending the message corresponding to the target service to different processor cores for processing by polling, so as to avoid a certain processor core from continuously receiving too many messages, resulting in excessive load on the processor core and increased message processing delay. In this DLB mode, an order-preserving queue is introduced to realize the function of message order preservation during message forwarding. In specific implementation, if it is determined that the message forwarding mode of the first message is the DLB mode, the programmable chip can be used to allocate the target message sequence number (Packet Sequence Number, PSN for short) corresponding to the first message in the order-preserving queue corresponding to the target service, and generate the first metadata (metadata) according to the first identification information corresponding to the dynamic load balancing mode, the queue number of the order-preserving queue, and the target message sequence number.

[0070] Optionally, in actual applications, the target service may correspond to a sequence-preserving queue, on which basis, the programmable chip allocates the target message sequence number corresponding to the first message in the sequence-preserving queue corresponding to the target service in the following manner: determine the message sequence number that has been allocated in the sequence-preserving queue, and sequentially allocate the corresponding target message sequence number to the first message based on the allocated message sequence number. For ease of understanding, for example, assuming that 9 message sequence numbers (numbers 1 to 9, respectively) have been allocated consecutively before the first message, then the target message sequence number corresponding to the first message in the sequence-preserving queue is 10. One point needs to be emphasized here: the message sequence numbers stored in the sequence-preserving queue will not be repeated. Specifically, assuming that the sequence-preserving queue can accommodate up to 1,000 message sequence numbers, then the message sequence numbers can be, for example, consecutive integers starting from 1, and when they reach 1,000, they are reallocated from 1.

[0071] Afterwards, the programmable chip fills the generated first metadata into the tail of the first message to obtain the second message. For details, see Figure 3 . It should be understood that although the first metadata can also be filled into the header or the middle of the first message, whether the first metadata is filled into the header of the first message or into the middle of the first message, the first metadata needs to be processed first when processing the first message. By filling the first metadata into the tail of the first message, the second processor core used to process the first message can be used to parse, encapsulate, and process the first message without being aware of the existence of the first metadata (because when processing the message, it is generally processed from the header of the message, thereby ignoring the first metadata at the tail), ensuring the forwarding speed of the first message. It should be noted here that if after filling the first metadata into the tail of the first message, it is necessary to continue to append data at the tail of the first message, an interface for appending data at the tail can be re-encapsulated. Among them, the first processor core and the second processor core can be the same or different, and are not limited here.

[0072] After receiving the second message, the programmable chip sends the second message to the first processor core running the driver program in a polling manner. The specific process is as follows:

[0073] The network card receiving queue (ie, DMA receiving queue) corresponding to the target service is polled to store the second message in the currently polled target network card receiving queue, so as to upload the second message to the first processor core bound to the target network card receiving queue through the target network card receiving queue.

[0074] 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 2A 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 1, the second message is sent to the first processor core bound to the target network card receive queue through queue 1.

[0075] Furthermore, the programmable chip stores the first processed message fed back by the first processor core into a target network card sending queue (ie, a DMA sending queue) corresponding to the target network card receiving queue, so as to read the first processed message from the target network card sending queue.

[0076] It should be noted that the NIC send queue and the NIC receive queue are one-to-one corresponding. In specific implementation, the second message uploaded through the target NIC receive queue will be sent to the corresponding target NIC send queue through the first processor core after being processed by the second processor core. For ease of understanding, please refer to Figure 2 .exist Figure 2 In 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 second message is sent to the first processor core through queue 1, the first processed message fed back by it will be stored in DMA transmission queue 1 corresponding to DMA receiving queue 1. The subsequent programmable chip reads the first processed message from DMA transmission queue 1, performs "sequence preservation processing" according to the queue number of the sequence preservation queue and the target message sequence number contained in the first processed message, and then sends it.

[0077] Afterwards, the programmable chip responds to the first processed message fed back by the first processor core, and can determine the sending order of the first processed message according to the first metadata contained in the first processed message. The specific process is as follows: If the target message sequence number in the first metadata is the minimum message sequence number among the message sequence numbers currently stored in the order-preserving queue, it is determined to directly send the first processed message. If there is a message sequence number less than the target message sequence number among the currently stored message sequence numbers, the first processed message is cached, and it is determined that the sending order of the first processed message is located after the processed message corresponding to the message sequence number less than the target message sequence number.

[0078] For ease of understanding, for example, assume that the target message sequence number is 3. If the message sequence numbers currently stored in the sequence-preserving queue include 3, 4, and 5, it means that the target message sequence number is the smallest message sequence number among the currently stored message sequence numbers. At this time, the first processed message can be directly sent to the destination device. If the message sequence numbers currently stored in the sequence-preserving queue include 1 and 2, it means that there is a message sequence number that is smaller than the target message sequence number among the currently stored message sequence numbers. At this time, the first processed message is cached, and after determining that the messages corresponding to 1 and 2 have been sent out, the first processed message is sent to the destination device. In this way, it is ensured that the first message can be sent to the destination device smoothly and accurately according to the set sending order.

[0079] After the first processed message is sent to the corresponding destination device in the sending order, the target message sequence number is deleted from the order-preserving queue to free up storage space in the order-preserving queue, so that other messages corresponding to subsequent target services can store corresponding message sequence numbers in the order-preserving queue.

[0080] The message forwarding method provided by the embodiment of the present invention can determine the message forwarding mode of the first message according to the characteristic information of the first message, which is equivalent to classifying the first message and determining whether the first message belongs to the message corresponding to the service or the message corresponding to the kernel protocol stack, so as to perform targeted processing based on the category of the first message later. If it is determined that the message forwarding mode of the first message is the dynamic load balancing mode, it means that the first message belongs to the message corresponding to the service. At this time, the order-preserving queue is introduced to realize the function of message order preservation during message forwarding. In specific implementation, the first metadata with the first identification information corresponding to the dynamic load balancing mode, the queue number of the order-preserving queue and the target message sequence number is filled into the first message to obtain the second message, which is equivalent to marking the first message with a sequence number. When the first processed message fed back by the first processor core is subsequently sent to the destination device, the sending order of the first message can be determined based on the mark to ensure that the first message is sent in sequence. Afterwards, the second message is sent to the first processor core running the driver program in a polling manner, thereby preventing a processor core from being overwhelmed due to continuous reception of too many messages, thereby ensuring the forwarding performance of the gateway device.

[0081] Figure 4 A flowchart of another message forwarding method provided by an embodiment of the present invention, wherein the gateway device further includes a third processor core, such as Figure 4 As shown, the method comprises the following steps:

[0082] 401. The programmable chip responds to a first message sent by a source device and determines a message forwarding mode of the first message according to characteristic information of the first message, where the first message corresponds to a target service.

[0083] 402. If the message forwarding mode is the receiver scaling mode, the programmable chip generates second metadata and fills the second metadata into the first message to obtain a third message, wherein the second metadata includes second identification information corresponding to the receiver scaling mode.

[0084] 403. The programmable chip determines, in the network card receiving queue corresponding to the target service, a target network card receiving queue corresponding to the third message according to the quintuple information of the third message.

[0085] 404. The programmable chip uploads the third message to the first processor core running a driver program bound to the target network card receiving queue through the target network card receiving queue, so that the first processor core removes the second metadata to restore the first message, sends the first message to the third processor core for processing to obtain a second processed message, and adds the third metadata corresponding to the receiver scaling mode to the second processed message to obtain a third processed message, the third processor core runs a kernel protocol stack, and the third metadata contains the second identification information.

[0086] 405. The programmable chip responds to the third processed message fed back by the first processor core and sends the third processed message to the corresponding destination device according to the second identification information included in the third metadata.

[0087] In actual applications, the programmable chip receives a first message corresponding to a target service sent by a source device, and determines a message forwarding mode of the first message according to characteristic information of the first message. The specific process can be found in the above embodiment and will not be described again here.

[0088] If the programmable chip determines that the message forwarding mode corresponding to the first message is the receiver scaling mode (i.e., RSS mode), the programmable chip generates second metadata with second identification information corresponding to the receiver scaling mode, and fills the second metadata into the first message to obtain a third message. It can be understood that the second metadata can also be filled into the tail of the first message. The specific reasons can be found in the above embodiment, which will not be repeated here.

[0089] Afterwards, in the network card receiving queue corresponding to the target service, the programmable chip determines the target network card receiving queue corresponding to the third message according to the five-tuple information of the third message. The specific method of determining the network card receiving queue is: the hash value can be calculated according to the five-tuple in the third message, and the indirect index table is queried by setting the low-order significant bits of the hash value to determine the corresponding target network card receiving queue. Through the target network card receiving queue, the third message is uploaded to the first processor core running the driver program bound to the target network card receiving queue, so that the first processor core removes the second metadata to restore the first message, and sends the first message to the kernel protocol stack in the third processor core for processing to obtain the second processed message. It should be noted that, optionally, the kernel protocol stack and the message processing program can be set in different processor cores, and the processor core running the driver program and the processor core running the message processing program can be the same processor core. The configuration method of the processor core is not limited here.

[0090] It should be noted that, since the message forwarding mode corresponding to the first message is the receiver scaling mode, it indicates that it belongs to the message corresponding to the kernel protocol stack. However, the kernel protocol stack cannot recognize the second metadata. In view of this, the embodiment of the present invention removes the second metadata from the third message, restores the first message, and sends the first message to the third processor core for processing to obtain the second processed message, and then sends the second processed message to the first processor core.

[0091] After receiving the second processed message, the first processor core identifies that there is no valid metadata in the second processed message, thereby determining that it corresponds to the receiver scaling mode, and then adds the third metadata corresponding to the receiver scaling mode to the second processed message to obtain the third processed message, and sends the third processed message to the programmable chip. It should be noted that the third metadata added by the first processor core may not be the same as the second metadata added by the programmable chip, but both contain the second identification information corresponding to the receiver scaling mode. The process of the first processor core adding the third metadata is described in other subsequent embodiments.

[0092] After receiving the third processed message, the programmable chip parses the third processed message to obtain the second identification information corresponding to the receiver's scaling mode, and based on the second identification information, directly sends the third processed message to the destination device. In this way, the natural order-preserving function of the receiver's scaling mode can be used to realize the in-order forwarding of the message, and the third processed message can be quickly sent to the destination device, thereby improving the message forwarding speed.

[0093] Based on the above, from another perspective, when forwarding messages through a gateway device, it is often the messages from the target service (which can be considered as data messages) that cause the processor core to be hit because of the large traffic, and the non-service type messages (which can be considered as control messages or management messages) will not cause the processor core to be hit because of the small traffic. In view of this, the embodiment of the present invention will first determine the message forwarding mode of the first message based on the characteristic information of the first message, which is equivalent to dividing the first message according to the message type. If the first message is a data message, then the message forwarding mode corresponding to the first message is the dynamic load balancing mode (i.e., DLB mode). This mode can reduce the possibility that a processor core is hit because of continuous reception of too many messages of the same network traffic, which causes the processor core to be hit, and effectively solves the problem that the current RSS mode is easy to hit a single processor core. If the first message is a control message, the first message will eventually need to be sent to the kernel protocol stack for processing, which will not cause the problem of hitting a single processor core. At this time, the message forwarding mode corresponding to the first message can be the RSS mode. That is, the embodiment of the present invention uses the DLB mode to process data messages that are easy to overload a single processor core, and uses the RSS mode to process control messages that are not easy to overload a single processor core. This can not only ensure the smooth forwarding of all types of messages, but also avoid a processor core being overwhelmed due to continuously receiving too many messages. The forwarding performance of the gateway device is better.

[0094] Figure 5 A flowchart of a message forwarding method provided by an embodiment of the present invention is applied to a first processor core running a driver program in a gateway device, the first processor core is any processor core running a driver program, the gateway device also includes a network card, the network card includes a programmable chip, such as Figure 5 As shown, the method comprises the following steps:

[0095] 501. The first processor core receives a second message sent by the programmable chip in a polling manner in response to a first message sent by a source device corresponding to a target service, wherein the second message is obtained by filling the first metadata into the first message, wherein the first metadata includes first identification information corresponding to a dynamic load balancing mode, a queue number of an order-preserving queue corresponding to the target service, and a target message sequence number corresponding to the first message in the order-preserving queue, wherein the dynamic load balancing mode is a message forwarding mode of the first message determined by the programmable chip according to characteristic information of the first message.

[0096] 502. The first processor core sends the second message to the second processor core for processing based on the first metadata to obtain a first processed message, and the second processor core runs a message processing program of the target service.

[0097] 503. The first processor core responds to the first processed message fed back by the second processor core by sending the first processed message to the programmable chip, so that the programmable chip determines the sending order of the first processed message according to the first metadata contained in the first processed message, and sends the first processed message to the corresponding destination device in the sending order, and then deletes the target message sequence number in the order-preserving queue.

[0098] The execution process of the message forwarding processing in this embodiment will not be described in detail, and reference may be made to the description in other aforementioned embodiments.

[0099] In the embodiment of the present invention, the first metadata also includes: the first metadata protocol version number and valid bit field supported by the programmable chip, for details, see Figure 6 . Figure 6 is a schematic diagram of the composition of the first metadata. Figure 6 The first metadata includes:

[0100] VER: indicates the first metadata protocol version number, usually 6 bits.

[0101] I: indicates the valid bit field, which is usually 1 bit. When its value is 1, it indicates that the first metadata is valid, and when its value is 0, it indicates that the first metadata is invalid. It should be noted that under normal circumstances, the value of the valid bit field is usually 1 (that is, the first metadata is valid), and if the circuit in the network card is abnormal, it is easy to cause the value of the valid bit field to change from 1 to 0 (that is, the first metadata is invalid).

[0102] D: indicates the deletion flag. If its value is 1, it means that the first message needs to be deleted. This situation usually occurs when: the processor core has some faults and the received message cannot be processed in time; or the first message received by the programmable chip hits a certain packet loss rule, etc.

[0103] R: represents the first identification information. If its value is 1, it indicates RSS mode; if its value is 0, it indicates DLB mode.

[0104] Reord_q: indicates the queue number of the order-preserving queue corresponding to the first message, usually 8 bits.

[0105] PSN: indicates the message sequence number of the first message in the order-preserving queue, usually 16 bits.

[0106] Figure 7 To obtain the flow chart of the first processed message, as Figure 7 As shown, sending the second message to the second processor core for processing based on the first metadata to obtain a first processed message specifically includes the following steps:

[0107] S1. The first processor core parses the first metadata to obtain a first metadata protocol version number, a valid bit field, and first identification information.

[0108] S2. The first processor core determines whether the first metadata protocol version number matches the second metadata protocol version number supported by the first processor core. If yes, proceed to S3; if no, delete the first metadata.

[0109] S3. The first processor core determines whether the value of the valid bit field indicates that the first metadata is valid. If so, proceed to S4; if not, delete the first metadata.

[0110] S4. The first processor core sends the second message to the second processor core for processing according to the first identification information to obtain a first processed message.

[0111] In specific implementation, it is assumed that the first metadata protocol version number obtained by the first processor core parsing the first metadata is version 2, the value of the valid bit field is 1, and the value of the first identification information is 0. At this time, the first processor core determines whether the first metadata protocol version number (version 2) matches the second metadata protocol version number (assuming version 2) supported by the first processor core. It can be seen that both are version 2, indicating that the two match. Afterwards, since the value of the valid bit field obtained by the first processor core parsing the first metadata is 1, it can be determined that the first metadata is valid. In this process, if the first metadata protocol version number does not match the second metadata protocol version number supported by the first processor core (that is, the first metadata protocol version number is different from or incompatible with the second metadata protocol version number supported by the first processor core), or the first metadata is invalid, the first metadata is deleted.

[0112] Based on the above, when the first metadata protocol version number matches the second metadata protocol version number supported by the first processor core, and the value of the valid bit field indicates that the first metadata is valid, it means that the first metadata can be used normally. At this time, the first processor core sends the second message to the second processor core for processing according to the first identification information to obtain the first processed message. By matching the first metadata protocol version number with the second metadata protocol version number supported by the first processor core, the problem that the first processor core cannot process the second message carrying the first metadata due to incompatible protocol versions can be avoided. And by judging the validity of the first metadata, it can be avoided that the first processor core or the network card suddenly becomes abnormal, thereby failing to process the second message normally.

[0113] Figure 8 A flowchart of sending the first processed message to the programmable chip, such as Figure 8As shown, sending the first processed message to the programmable chip specifically includes the following steps:

[0114] The first processor core parses the first metadata contained in the first processed message to obtain a valid bit field;

[0115] The first processor core determines whether the value of the valid bit field indicates that the first metadata is valid;

[0116] If the value of the valid bit field indicates that the first metadata is valid, the first processor core sends the first processed message to the programmable chip;

[0117] If the value of the valid bit field indicates that the first metadata is invalid, the first processor core adds new first metadata to the first processed message.

[0118] It should be understood that in the process of sending the message after the first processing, by verifying the validity of the first metadata, it can be ensured that the programmable chip can accurately obtain the queue number and message sequence number of the order-preserving queue in the first metadata, laying the foundation for the subsequent accurate sending of the first message to the destination device according to the set sending order.

[0119] Fig. 9 A flowchart of another message forwarding method provided by an embodiment of the present invention, such as Fig. 9 As shown, the method comprises the following steps:

[0120] 901. The first processor core responds to a first message corresponding to a target service sent by a source device, and receives a third message sent by a programmable chip through a target network card receiving queue corresponding to the target service, wherein the third message is obtained by filling second metadata into the first message, wherein the second metadata includes second identification information corresponding to a receiving party scaling mode, and the receiving party scaling mode is a message forwarding mode of the first message determined by the programmable chip according to characteristic information of the first message, and the target network card receiving queue is bound to the first processor core.

[0121] 902. The first processor core removes the second metadata included in the third message to restore the first message, and sends the first message to the third processor core for processing to obtain a second processed message, and the third processor core runs a kernel protocol stack.

[0122] 903. The first processor core responds to the second processed message fed back by the third processor core, adds third metadata corresponding to the receiver scaling mode in the second processed message to obtain a third processed message, and sends the third processed message to the programmable chip, so that the programmable chip sends the third processed message to the corresponding destination device according to the third metadata contained in the third processed message, and the third metadata contains second identification information.

[0123] The execution process of the message forwarding processing in this embodiment will not be described in detail, and reference may be made to the description in other aforementioned embodiments.

[0124] Furthermore, the second metadata also includes: a first metadata protocol version number and a valid bit field supported by the programmable chip. The first processor core removes the second metadata contained in the third message to restore the first message, including: the first processor core parses the second metadata contained in the third message to obtain the first metadata protocol version number, the valid bit field and the second identification information; if the first metadata protocol version number matches the second metadata protocol version number supported by the first processor core, and the value of the valid bit field indicates that the second metadata is valid, the first processor core removes the second metadata from the third message according to the second identification information to restore the first message.

[0125] It should be noted that the composition of the second metadata and the third metadata can also refer to the above Figure 6 The composition of the first metadata is shown, and the difference between the second metadata and the third metadata and the first metadata is that the second metadata and the third metadata do not contain "Reord_q" and "PSN". It should be understood that the RSS mode has a natural order-preserving function and does not use the order-preserving queue, and the second metadata and the third metadata are applied in the RSS mode, so the second metadata and the third metadata do not contain the relevant parameters of the order-preserving queue.

[0126] In practical applications, it is assumed that the first metadata protocol version number obtained by the first processor core parsing the second metadata is version 2, the value of the valid bit field is 1, and the value of the first identification information is 0. At this time, it is determined whether the first metadata protocol version number (version 2) matches the second metadata protocol version number (assuming version 2) supported by the first processor core. It can be seen that both are version 2, indicating that the two match. Afterwards, since the value of the valid bit field obtained by parsing the first metadata is 1, it can be determined that the second metadata is valid. Based on the above, when the first metadata protocol version number matches the second metadata protocol version number supported by the first processor core, and the value of the valid bit field indicates that the second metadata is valid, it means that the second metadata can be used normally. At this time, the first processor core removes the second metadata from the third message according to the second identification information to restore the first message. It can be understood that since the third message is to be sent to the third processor core running the kernel protocol stack, and the kernel protocol stack does not recognize the second metadata in the third message, before sending the third message to the third processor core for processing, the second metadata needs to be removed from the third message to restore the first message, and the first message is sent to the third processor core for processing.

[0127] It should be noted that the matching of the above version numbers can not only mean consistency, but also other "mutual compatibility" situations. For example, although the version number supported by the programmable chip is vi, and the version number supported by the first processor core is vj, the two are different, but if vj is compatible with vi, then they are also matched.

[0128] By judging the validity of the second metadata, it is possible to avoid the third processor core or the network card suddenly having an abnormality, thereby failing to process the third message normally. When it is determined that the first metadata protocol version number matches the second metadata protocol version number supported by the first processor core, and the value of the valid bit field indicates that the second metadata is valid, the second metadata is removed from the third message to restore the first message, which can ensure that the third processor core can successfully complete the processing of the first message.

[0129] Further, after the second processed message is parsed by the first processor core, if the metadata containing the second identification information is not parsed out in the second processed message, the first processor core adds the third metadata corresponding to the receiver's scaling mode in the second processed message to obtain the third processed message, wherein the third metadata also includes the second metadata protocol version number supported by the first processor core and the value of the valid bit field indicating that the third metadata is valid. By adding the third metadata corresponding to the receiver's scaling mode in the second processed message to obtain the third processed message, it is ensured that in the subsequent process of sending the third processed message to the destination device, its corresponding message forwarding mode can be accurately identified, and it can also be verified based on the second metadata protocol version number supported by the first processor core and the value of the valid bit field indicating that the third metadata is valid obtained by parsing the third metadata, ensuring that the third processed message can be smoothly forwarded to the destination device.

[0130] It is understandable that, whether in DLB mode or RSS mode, in the process of sending the processed message, the processed message (such as the first processed message and the third processed message) received by the programmable chip will contain metadata. In specific implementation, the programmable chip will determine the message forwarding mode by parsing the metadata in the received processed message (through the identification information in the metadata), and will also verify the version legitimacy and metadata validity through the parsed metadata protocol version number and valid bit field. If both verifications are passed, the processed message will be sent to the destination device in its corresponding message forwarding mode.

[0131] 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.

[0132] Fig.10 A structural schematic diagram of a message forwarding device provided in an embodiment of the present invention, wherein the device is applied to a programmable chip in a network card, the network card is located in a gateway device, the gateway device includes multiple processor cores communicatively connected to the network card, including a first processor core and a second processor core, and the device includes: a determination module 11, an allocation module 12, a filling module 13, a processing module 14 and a sending module 15.

[0133] The determination module 11 is used to determine a message forwarding mode of the first message in response to a first message sent by a source device according to characteristic information of the first message, wherein the first message corresponds to a target service.

[0134] The allocation module 12 is configured to allocate a target message sequence number of the first message in the order-preserving queue corresponding to the target service if the message forwarding mode is a dynamic load balancing mode.

[0135] The filling module 13 is used to generate first metadata and fill the first metadata into the first message to obtain a second message, wherein the first metadata includes the first identification information corresponding to the dynamic load balancing mode, the queue number of the order-preserving queue and the target message sequence number.

[0136] The processing module 14 is used to send the second message to the first processor core running a driver in a polling manner, so that the first processor core sends the second message to the second processor core for processing based on the first metadata to obtain a first processed message, and the second processor core runs the message processing program of the target service.

[0137] A sending module 15 is used to respond to the first processed message fed back by the first processor core, determine the sending order of the first processed message according to the first metadata contained in the first processed message, so as to send the first processed message to the corresponding destination device in the sending order, and delete the target message sequence number in the order preservation queue.

[0138] Among them, optionally, the processing module 14 is specifically used to: poll the network card receiving queue corresponding to the target service to store the second message to the currently polled target network card receiving queue; upload the second message to the first processor core bound to the target network card receiving queue through the target network card receiving queue.

[0139] Among them, optionally, the sending module 15 is specifically used for: if the target message sequence number in the first metadata is the smallest message sequence number among the message sequence numbers currently stored in the order-preserving queue, then determining to directly send the first processed message; if there is a message sequence number smaller than the target message sequence number among the currently stored message sequence numbers, then caching the first processed message, and determining that the sending order of the first processed message is after the processed message corresponding to the message sequence number smaller than the target message sequence number.

[0140] Wherein, optionally, the gateway device also includes a third processor core, and the filling module 13 is also used to generate second metadata if the message forwarding mode is the receiver scaling mode, and fill the second metadata into the first message to obtain a third message, wherein the second metadata includes the second identification information corresponding to the receiver scaling mode. The processing module 14 is also used to determine the target network card receiving queue corresponding to the third message according to the five-tuple information of the third message in the network card receiving queue corresponding to the target service; and upload the third message to the first processor core running a driver program bound to the target network card receiving queue through the target network card receiving queue, so that the first processor core removes the second metadata to restore the first message, sends the first message to the third processor core for processing to obtain a second processed message, and adds the third metadata corresponding to the receiver scaling mode to the second processed message to obtain a third processed message, wherein the third processor core runs a kernel protocol stack, and the third metadata includes the second identification information.

[0141] Therefore, the sending module 15 is further used for: in response to the third processed message fed back by the first processor core, sending the third processed message to the corresponding destination device according to the second identification information included in the third metadata.

[0142] Among them, optionally, the determination module 11 is specifically used to: obtain a matching rule corresponding to a receiving party scaling mode, the matching rule including message feature information that needs to be forwarded according to the receiving party scaling mode; if the feature information of the first message meets the matching rule, then determine that the message forwarding mode of the first message is the receiving party scaling mode; if the feature information of the first message does not meet the matching rule, then determine that the message forwarding mode of the first message is the dynamic load balancing mode.

[0143] Fig.10 The 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.

[0144] Fig.11 A structural schematic diagram of another message forwarding device provided in an embodiment of the present invention, wherein the device is applied to the first processor core running a driver program in a gateway device, wherein the first processor core is any processor core running the driver program, wherein the gateway device also includes a network card, wherein the network card includes a programmable chip, and wherein the device includes: a receiving module 21, a processing module 22, and a sending module 23.

[0145] The receiving module 21 is used to receive a second message sent by the programmable chip in a polling manner in response to a first message corresponding to a target service sent by a source device, wherein the second message is obtained by filling first metadata into the first message, wherein the first metadata includes first identification information corresponding to a dynamic load balancing mode, a queue number of an order-preserving queue corresponding to the target service, and a target message sequence number corresponding to the first message in the order-preserving queue, wherein the dynamic load balancing mode is a message forwarding mode of the first message determined by the programmable chip according to characteristic information of the first message.

[0146] The processing module 22 is used to send the second message to the second processor core for processing based on the first metadata to obtain a first processed message, and the second processor core runs a message processing program of the target service.

[0147] A sending module 23 is used to send the first processed message to the programmable chip in response to the first processed message fed back by the second processor core, so that the programmable chip determines the sending order of the first processed message according to the first metadata contained in the first processed message, and sends the first processed message to the corresponding destination device in accordance with the sending order, and then deletes the target message sequence number from the order preservation queue.

[0148] Among them, optionally, the first metadata also includes: a first metadata protocol version number and a valid bit field supported by the programmable chip; the processing module 22 is specifically used to: parse the first metadata to obtain the first metadata protocol version number, the valid bit field and the first identification information; if the first metadata protocol version number matches the second metadata protocol version number supported by the first processor core, and the value of the valid bit field indicates that the first metadata is valid, then send the second message to the second processor core for processing according to the first identification information to obtain a first processed message.

[0149] Among them, optionally, the sending module 23 is specifically used to: parse the first metadata contained in the first processed message to obtain the valid bit field; if the value of the valid bit field indicates that the first metadata is valid, send the first processed message to the programmable chip.

[0150] Among them, optionally, the gateway device also includes a third processor core, and the receiving module 21 is also used to receive a third message sent by the programmable chip through the target network card receiving queue corresponding to the target service, and the third message is obtained by filling second metadata into the first message, wherein the second metadata includes second identification information corresponding to the receiving party scaling mode, and the receiving party scaling mode is the message forwarding mode of the first message determined by the programmable chip according to the characteristic information of the first message, and the target network card receiving queue is bound to the first processor core.

[0151] Therefore, the processing module 22 is also used to remove the second metadata contained in the third message to restore the first message, and send the first message to the third processor core for processing to obtain a second processed message, and the third processor core runs a kernel protocol stack.

[0152] The sending module 23 is also used to respond to the second processed message fed back by the third processor core, add the third metadata corresponding to the receiving party scaling mode in the second processed message to obtain a third processed message, and send the third processed message to the programmable chip, so that the programmable chip sends the third processed message to the corresponding destination device according to the third metadata contained in the third processed message, and the third metadata contains the second identification information.

[0153] Among them, optionally, the second metadata also includes: the first metadata protocol version number and valid bit field supported by the programmable chip; the processing module 22 is specifically used to: parse the second metadata contained in the third message to obtain the first metadata protocol version number, valid bit field and the second identification information; if the first metadata protocol version number matches the second metadata protocol version number supported by the first processor core, and the value of the valid bit field indicates that the second metadata is valid, then the second metadata is removed from the third message according to the second identification information to restore the first message.

[0154] Among them, optionally, the sending module 23 is specifically used for: if the metadata containing the second identification information is not parsed out in the second processed message, then adding third metadata corresponding to the receiving party scaling mode to the second processed message to obtain a third processed message, wherein the third metadata also includes the second metadata protocol version number supported by the first processor core and the value of the valid bit field indicating that the third metadata is valid.

[0155] Fig.11 The 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.

[0156] In addition, an embodiment of the present invention provides a gateway device, the gateway device comprising: a plurality of processor cores, including a first processor core running a driver program and a second processor core running a message processing program of a target service;

[0157] A network card, the network card includes a programmable chip, and the network card is respectively connected to the first processor core and the second processor core for communication;

[0158] The programmable chip is used to: respond to a first message sent by a source device, determine a message forwarding mode of the first message according to characteristic information of the first message, and the first message corresponds to a target service; if the message forwarding mode is a dynamic load balancing mode, assign the first message a target message sequence number in an order-preserving queue corresponding to the target service; generate first metadata, and fill the first metadata into the first message to obtain a second message, wherein the first metadata includes first identification information corresponding to the dynamic load balancing mode, a queue number of the order-preserving queue, and a target message sequence number; send the second message to the first processor core in a polling manner;

[0159] The first processor core is used to: send the second message to the second processor core for processing based on the first metadata to obtain a first processed message, and send the first processed message to the programmable chip;

[0160] The programmable chip is also used to: respond to the first processed message fed back by the first processor core, determine the sending order of the first processed message according to the first metadata contained in the first processed message, send the first processed message to the corresponding destination device in the sending order, and delete the target message sequence number in the order-preserving queue.

[0161] Among them, optionally, the multiple processor cores also include a third processor core that runs the kernel protocol stack; the programmable chip is also used to: if the message forwarding mode is the receiver scaling mode, generate second metadata, and fill the second metadata into the first message to obtain a third message, wherein the second metadata includes second identification information corresponding to the receiver scaling mode; in the network card receiving queue corresponding to the target service, determine the target network card receiving queue corresponding to the third message according to the five-tuple information of the third message; upload the third message to the first processor core bound to the target network card receiving queue through the target network card receiving queue; the first processor core is also used to: remove the second metadata to restore the first message, send the first message to the third processor core for processing to obtain a second processed message, and add the third metadata corresponding to the receiver scaling mode in the second processed message to obtain a third processed message, and send the third processed message to the programmable chip; the programmable chip is also used to: send the third processed message to the corresponding destination device according to the second identification information contained in the third metadata.

[0162] 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.

[0163] 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.

[0164] 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.

[0165] 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.

[0166] 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.

[0167] 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, wherein the network card is located in a gateway device, wherein the gateway device includes a first processor core, a second processor core, and a third processor core that are communicatively connected to the network card, wherein the first processor core runs a driver program, and wherein the method includes: In response to a first message sent by a source device, if characteristic information of the first message meets a matching rule corresponding to a receiver scaling mode, determining that a message forwarding mode of the first message is the receiver scaling mode, and if the characteristic information of the first message does not meet the matching rule, determining that a message forwarding mode of the first message is a dynamic load balancing mode, wherein the characteristic information includes a destination IP and / or a protocol type, and the first message corresponds to a target service; If the message forwarding mode is a dynamic load balancing mode, assign the target message sequence number of the first message in the order-preserving queue corresponding to the target service; generate first metadata, and fill the first metadata into the first message to obtain a second message, wherein the first metadata includes first identification information, the queue number of the order-preserving queue and the target message sequence number, and the value of the first identification information indicates that the message forwarding mode is a dynamic load balancing mode; Polling the network card receiving queue corresponding to the target service to store the second message in the currently polled target network card receiving queue, uploading the second message to the first processor core bound to the target network card receiving queue through the target network card receiving queue, so that the first processor core sends the second message to the second processor core for processing based on the first identification information in the first metadata, obtaining a first processed message, and the second processor core runs the message processing program of the target service; In response to the first processed message fed back by the first processor core, the sending order of the first processed message is determined according to the size relationship between the target message sequence number contained in the first metadata contained in the first processed message and the message sequence number currently stored in the order-preserving queue, so as to send the first processed message to the corresponding destination device in the sending order, and delete the target message sequence number in the order-preserving queue; If the message forwarding mode is the receiver scaling mode, second metadata is generated, and the second metadata is filled into the first message to obtain a third message. In the network card receiving queue corresponding to the target service, the target network card receiving queue corresponding to the third message is determined according to the five-tuple information of the third message. Through the target network card receiving queue, the third message is uploaded to the first processor core bound to the target network card receiving queue, so that the first processor core removes the second metadata to restore the first message and then sends the first message to the third processor core for processing to obtain a second processed message, and adds the third metadata corresponding to the receiver scaling mode to the second processed message to obtain the third processed message, wherein the second metadata includes second identification information; and, in response to the third processed message fed back by the first processor core, according to the second identification information contained in the third metadata, the third processed message is sent to the corresponding destination device, the third processor core runs a kernel protocol stack, and the value of the second identification information indicates that the message forwarding mode is the receiver scaling mode.

2. The method according to claim 1, characterized in that The determining the sending order of the first processed message according to the size relationship between the target message sequence number contained in the first metadata in the first processed message and the message sequence number currently stored in the order-preserving queue includes: If the target message sequence number in the first metadata is the smallest message sequence number among the message sequence numbers currently stored in the order-preserving queue, determining to directly send the first processed message; If there is a message sequence number smaller than the target message sequence number among the currently stored message sequence numbers, the first processed message is cached, and the sending order of the first processed message is determined to be after the processed message corresponding to the message sequence number smaller than the target message sequence number.

3. A message forwarding method, characterized in that: A first processor core for running a driver program in a gateway device, wherein the first processor core is any processor core for running the driver program, the gateway device further includes a network card, a second processor core, and a third processor core, the network card includes a programmable chip, and the method includes: In response to a first message corresponding to a target service sent by a source device, the programmable chip is received to poll a network card receiving queue corresponding to the target service, and a second message is uploaded through the currently polled target network card receiving queue, wherein the second message is obtained by filling first metadata into the first message, wherein the first metadata includes first identification information, a queue number of an order-preserving queue corresponding to the target service, and a target message sequence number of the first message in the order-preserving queue, wherein the value of the first identification information indicates that the message forwarding mode is a dynamic load balancing mode, wherein the dynamic load balancing mode is a message forwarding mode of the first message determined by the programmable chip when the characteristic information of the first message does not meet the matching rule corresponding to the receiver scaling mode, and the receiver scaling mode is a message forwarding mode of the first message determined by the programmable chip when the characteristic information of the first message meets the matching rule corresponding to the receiver scaling mode, and the characteristic information includes a destination IP and / or a protocol type; Sending the second message to a second processor core for processing based on the first identification information in the first metadata to obtain a first processed message, the second processor core running a message processing program of the target service; In response to the first processed message fed back by the second processor core, the first processed message is sent to the programmable chip, so that the programmable chip determines the sending order of the first processed message according to the size relationship between the target message sequence number contained in the first metadata contained in the first processed message and the message sequence number currently stored in the order-preserving queue, and deletes the target message sequence number from the order-preserving queue after sending the first processed message to the corresponding destination device in accordance with the sending order; In the case where the message forwarding mode is the receiver scaling mode, the programmable chip receives a third message uploaded by the target network card receiving queue determined according to the five-tuple information in the network card receiving queue corresponding to the target service, removes the second metadata to restore the first message, sends the first message to the third processor core for processing to obtain a second processed message, and adds the third metadata corresponding to the receiver scaling mode to the second processed message to obtain a third processed message, and sends the third processed message to the programmable chip, so that the programmable chip sends the third processed message to the corresponding destination device according to the second identification information in the third processed message, the third message is obtained by filling the second metadata into the first message, the target network card receiving queue is bound to the first processor core, the second metadata includes the second identification information, the third processor core runs a kernel protocol stack, and the value of the second identification information indicates that the message forwarding mode is the receiver scaling mode.

4. The method according to claim 3, characterized in that The first metadata also includes: a first metadata protocol version number and a valid bit field supported by the programmable chip; The sending the second message to a second processor core for processing based on the first identification information in the first metadata to obtain a first processed message includes: Parsing the first metadata to obtain the first metadata protocol version number, the valid bit field and the first identification information; If the first metadata protocol version number matches the second metadata protocol version number supported by the first processor core, and the value of the valid bit field indicates that the first metadata is valid, the second message is sent to the second processor core for processing according to the first identification information to obtain a first processed message.

5. The method according to claim 4, characterized in that The sending the first processed message to the programmable chip includes: Parsing the first metadata contained in the first processed message to obtain the valid bit field; If the value of the valid bit field indicates that the first metadata is valid, the first processed message is sent to the programmable chip.

6. The method according to claim 3, characterized in that The second metadata also includes: a first metadata protocol version number and a valid bit field supported by the programmable chip; The removing the second metadata included in the third message to restore the first message includes: Parsing the second metadata contained in the third message to obtain the first metadata protocol version number, the valid bit field and the second identification information; If the first metadata protocol version number matches the second metadata protocol version number supported by the first processor core, and the value of the valid bit field indicates that the second metadata is valid, then the second metadata is removed from the third message according to the second identification information to restore the first message.

7. The method according to claim 6, characterized in that The adding the third metadata corresponding to the receiver scaling mode to the second processed message to obtain a third processed message includes: If the metadata containing the second identification information is not parsed out in the second processed message, the third metadata corresponding to the receiving party scaling mode is added to the second processed message to obtain a third processed message, wherein the third metadata also includes the second metadata protocol version number supported by the first processor core and the value of the valid bit field indicating that the third metadata is valid.

8. A network card, characterized in that: The network card includes a programmable chip, and the network card is respectively connected to a first processor core, a second processor core, and a third processor core in a gateway device, and the first processor core runs a driver program; The programmable chip is used to respond to a first message sent by a source device, and if the characteristic information of the first message meets the matching rule corresponding to the receiver scaling mode, determine that the message forwarding mode of the first message is the receiver scaling mode; if the characteristic information of the first message does not meet the matching rule, determine that the message forwarding mode of the first message is a dynamic load balancing mode, wherein the characteristic information includes a destination IP and / or a protocol type, and the first message corresponds to a target service; if the message forwarding mode is a dynamic load balancing mode, assign the first message a target message sequence number in the order-keeping queue corresponding to the target service; generate first metadata, and fill the first metadata into The method further comprises the step of: polling the network card receiving queue corresponding to the target service to store the second message in the target network card receiving queue currently polled, and uploading the second message to the first processor core bound to the target network card receiving queue through the target network card receiving queue, so that the first processor core sends the second message to the second processor core for processing based on the first identification information in the first metadata, and obtains the first processed message. The second processor core runs the message processing program of the target service; in response to the first processed message fed back by the first processor core, the sending order of the first processed message is determined according to the size relationship between the target message sequence number contained in the first metadata contained in the first processed message and the message sequence number currently stored in the order-preserving queue, so as to send the first processed message to the corresponding destination device in the sending order, and delete the target message sequence number in the order-preserving queue; if the message forwarding mode is the receiver scaling mode, second metadata is generated, and the second metadata is filled into the first message to obtain a third message, and the third message is sent to the corresponding destination device in the target service. In the network card receiving queue, determine the target network card receiving queue corresponding to the third message according to the quintuple information of the third message, upload the third message to the first processor core bound to the target network card receiving queue through the target network card receiving queue, so that the first processor core removes the second metadata to restore the first message and then sends the first message to the third processor core for processing to obtain a second processed message, and adds the third metadata corresponding to the receiving party scaling mode to the second processed message to obtain a third processed message, wherein the second metadata includes second identification information, and the value of the second identification information indicates that the message forwarding mode is the receiving party scaling mode;And, in response to the third processed message fed back by the first processor core, sending the third processed message to the corresponding destination device according to the second identification information contained in the third metadata, wherein the third processor core runs a kernel protocol stack. ; 9. A gateway device, characterized in that: include: A plurality of processor cores, including a first processor core running a driver, a second processor core running a message processing program for a target service, and a third processor core running a kernel protocol stack; A network card, wherein the network card includes a programmable chip, and the network card is respectively connected to the first processor core, the second processor core, and the third processor core for communication; The programmable chip is used to: respond to a first message sent by a source device, if the characteristic information of the first message meets the matching rule corresponding to the receiver scaling mode, determine that the message forwarding mode of the first message is the receiver scaling mode, if the characteristic information of the first message does not meet the matching rule, determine that the message forwarding mode of the first message is the dynamic load balancing mode, wherein the characteristic information includes the destination IP and / or protocol type, and the first message corresponds to the target service; if the message forwarding mode is the dynamic load balancing mode, assign the first message a target message sequence number in the order-preserving queue corresponding to the target service; generate first metadata, and fill the first metadata into the first message to obtain a second message, wherein the first metadata includes first identification information, the queue number of the order-preserving queue and the target message sequence number, and the value of the first identification information indicates that the message forwarding mode is the dynamic load balancing mode; poll the network card receiving queue corresponding to the target service to store the second message in the currently polled target network card receiving queue, and upload the second message to the first processor core bound to the target network card receiving queue through the target network card receiving queue; The first processor core is used to: send the second message to the second processor core for processing based on the first identification information in the first metadata, obtain a first processed message, and send the first processed message to the programmable chip; The programmable chip is also used for: responding to the first processed message fed back by the first processor core, determining the sending order of the first processed message according to the size relationship between the target message sequence number contained in the first metadata contained in the first processed message and the message sequence number currently stored in the order-preserving queue, so as to send the first processed message to the corresponding destination device according to the sending order, delete the target message sequence number in the order-preserving queue, and, if the message forwarding mode is the receiver scaling mode, generating second metadata, and filling the second metadata into the first message to obtain a third message, and in the network card receiving queue corresponding to the target service, determining the target network card receiving queue corresponding to the third message according to the five-tuple information of the third message. The third message is uploaded to the first processor core bound to the target network card receiving queue through the target network card receiving queue, so that the first processor core removes the second metadata to restore the first message and then sends the first message to the third processor core for processing to obtain a second processed message and adds the third metadata corresponding to the receiving party scaling mode to the second processed message to obtain a third processed message, wherein the second metadata includes second identification information, and the value of the second identification information indicates that the message forwarding mode is the receiving party scaling mode; and, in response to the third processed message fed back by the first processor core, the third processed message is sent to the corresponding destination device according to the second identification information contained in the third metadata.

10. A non-transitory machine-readable storage medium, characterized in that: The non-temporary machine-readable storage medium stores executable code. When the executable code is executed by a programmable chip in a gateway device, the programmable chip executes the message forwarding method as described in claim 1 or 2. When the executable code is executed by a processor core in the gateway device, the processor core executes the message forwarding method as described in any one of claims 3-7.

11. 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 claim 1 or 2, and when the executable code is executed by a processor core in the gateway device, causes the processor core to execute the message forwarding method as described in any one of claims 3-7.

Citation Information

Patent Citations

  • Load balancing method and apparatus of multi-core CPU

    CN106713185A

  • Message forwarding order preserving method and device in DPU, electronic equipment and storage medium

    CN117560433A