Message distribution method, network equipment and storage medium
Through the combination of network card chips and processing cores, the packet diversion and forwarding tasks are dynamically adjusted, and the problem of waste of multi-core processor resources is solved, achieving efficient performance improvement and service compatibility of network equipment.
Patent Information
- Application Number
- CN202410214445.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-27
- Publication Date
- 2025-08-29
AI Technical Summary
In the prior art, the packet diversion and forwarding of multi-core processors have the problem of not being able to fully utilize the processor's capabilities, especially when the number of processor cores is small, resource waste is serious and atypical services cannot be effectively processed.
The received packets are initially diverted through the network card chip, cached to the hardware default queue or hardware RSS queue, and the processing core performs shunt or forwarding tasks when a spin lock is acquired, realizing the adaptation of dynamic adjustment of shunt rate and forwarding rate.
It realizes the rational use of multi-core resources, improves the performance of network equipment, is compatible with standard and non-standard services, avoids resource waste, and ensures the normal operation of services.
Smart Images

Figure CN120567950A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to a message diversion method, network equipment and storage medium. Background Art
[0002] Network devices such as routers mostly rely on the participation of processors to send, receive, and process messages. However, today's processors are developing towards multi-core. How to reasonably allocate processor resources and fully utilize the processor's performance to speed up the router's data forwarding performance has become a major challenge.
[0003] To fully leverage the processing power of multi-core processors, many network adapters (NICs) used in current network devices support multiple queues. They can identify and classify packets based on certain characteristics, cache them into different queues, and then distribute them to different processor cores for processing, known as traffic diversion. Currently, mainstream NICs offer packet diversion and identification mechanisms such as RSS (Receive-Side Scaling, a message hashing technique) and field matching. These functions are primarily based on fields such as the packet quintuple. Due to the varying design capabilities of NIC chipsets from different manufacturers, when faced with atypical services or special packet formats, it is often impossible to fully rely on NIC diversion to achieve multi-core load balancing. This, in turn, hinders achieving a balanced application performance and functionality. However, these services may be essential, and customers are particularly concerned about the forwarding performance of routers for these types of services.
[0004] The current solution to this problem is to pre-assign fixed roles to each processor core, setting some processor cores as shunting cores and others as forwarding cores. However, this approach doesn't fully leverage the performance of multi-core processors. For example, if the shunting cores process packets at a higher rate than the forwarding cores, the forwarding cores become a performance bottleneck; conversely, the shunting cores become a performance bottleneck. Furthermore, this solution isn't suitable for devices with a limited number of processor cores. Given limited processing power, allocating some processor cores to shunting cores wastes these cores when there are no packets requiring shunting. In short, the current solutions for packet shunting and forwarding fail to fully utilize processor capabilities. Summary of the Invention
[0005] In view of this, an object of the present invention is to provide a message diversion method, a network device and a storage medium.
[0006] In order to achieve the above object, the technical solution adopted by the present invention is as follows:
[0007] In a first aspect, the present invention provides a message diversion method, which is applied to a network device, wherein the network device includes a network card chip and multiple processing cores, and the message diversion method includes:
[0008] The network card chip shunts the received messages to cache the received messages into a hardware default queue or a corresponding hardware RSS queue;
[0009] When executing the diversion task, each processing core attempts to obtain the spin lock of the hardware default queue, obtains multiple messages from the hardware default queue and diverts the multiple messages if the spin lock is obtained, or switches to executing the forwarding task if the spin lock is not obtained.
[0010] In an optional implementation manner, the network card chip diverts the received messages to cache the received messages into a hardware default queue or a corresponding hardware RSS queue, including:
[0011] The network card chip identifies the received message;
[0012] When the network card chip fails to recognize the received message, it caches the received message into the hardware default queue;
[0013] When the network card chip identifies the received message, it caches the received message in a corresponding hardware RSS queue.
[0014] In an optional implementation manner, when the network card chip identifies the received message, caching the received message into a corresponding hardware RSS queue includes:
[0015] When the network card chip identifies the received message, it parses the received message to obtain message content, calculates a hash value of the received message according to the message content, and caches the received message in a hardware RSS queue corresponding to the hash value.
[0016] In an optional implementation, obtaining a plurality of messages from the hardware default queue and diverting the plurality of messages when the spin lock is acquired includes:
[0017] The processing core that obtains the spin lock treats the multiple messages as messages to be processed respectively, determines the software queues corresponding to the messages to be processed, and caches the messages to be processed to the corresponding software queues, so as to divert each message to the corresponding software queue.
[0018] In an optional implementation manner, determining the software queue corresponding to the to-be-processed message includes:
[0019] The processing core that obtains the spin lock parses the message to be processed according to preset rules, obtains the message content of the message to be processed, and calculates the hash value of the message to be processed based on the message content of the message to be processed, and uses the software queue with the same hash value as the hash value of the message to be processed as the software queue corresponding to the message to be processed.
[0020] In an optional embodiment, the multiple hardware RSS queues correspond one-to-one to the multiple processing cores, and the message offloading method further includes:
[0021] When executing a forwarding task, each of the processing cores obtains a message from the corresponding hardware RSS queue and software queue and forwards the message.
[0022] In a second aspect, the present invention provides a network device, comprising a network card chip and a plurality of processing cores;
[0023] The network card chip is used to shunt the received messages to cache the received messages into a hardware default queue or a corresponding hardware RSS queue;
[0024] Each of the processing cores is used to attempt to obtain the spin lock of the hardware default queue when executing a diversion task, obtain multiple messages from the hardware default queue and divert the multiple messages if the spin lock is obtained, or switch to executing a forwarding task if the spin lock is not obtained.
[0025] In an optional embodiment, each of the processing cores is also used to: when obtaining the spin lock, treat the multiple messages as messages to be processed respectively, determine the software queues corresponding to the messages to be processed, and cache the messages to be processed to the corresponding software queues to divert each message to the corresponding software queue.
[0026] In an optional embodiment, each of the processing cores is also used to: when obtaining the spin lock, parse the message to be processed according to preset rules to obtain the message content of the message to be processed, and calculate the hash value of the message to be processed based on the message content of the message to be processed, and use the software queue with the same hash value as the hash value of the message to be processed as the software queue corresponding to the message to be processed.
[0027] In a third aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the message diversion method described in any one of the aforementioned embodiments is implemented.
[0028] The present invention provides a message diversion method, network device, and storage medium. The network device includes a network card chip and multiple processing cores. The network card chip diverts received messages to cache the received messages to a hardware default queue or a corresponding hardware RSS queue. When executing a diversion task, each processing core attempts to obtain a spin lock of the hardware default queue. When the spin lock is obtained, multiple messages are obtained from the hardware default queue and diverted, or when the spin lock is not obtained, the processing core switches to perform a forwarding task. By combining the network card chip with the processing core, messages of standard services and non-standard services are diverted, and by adaptively switching roles of the processing core to adjust tasks, the diversion rate and forwarding rate of the messages are dynamically adjusted to adapt the two, thereby achieving rational utilization of multi-core resources, while ensuring the normal operation of standard services and non-standard services, and improving the performance of the network device.
[0029] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without paying any creative work.
[0031] Figure 1 A block diagram of a network device provided by an embodiment of the present invention is shown;
[0032] Figure 2 A schematic diagram of a flow chart of a message diversion method provided by an embodiment of the present invention is shown;
[0033] Figure 3 Another schematic diagram of a flow chart of a message diversion method provided by an embodiment of the present invention is shown;
[0034] Figure 4 Another flow chart of the message diversion method provided by an embodiment of the present invention is shown.
[0035] Icon: 110-processor; 120-memory; 130-network card chip. DETAILED DESCRIPTION
[0036] The following will be combined with the accompanying drawings to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings herein can be arranged and designed in various different configurations.
[0037] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention as claimed, but is merely intended to represent selected embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative work are within the scope of protection of the present invention.
[0038] It should be noted that relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus comprising the element.
[0039] See also Figure 1 is a block diagram of a network device according to an embodiment of the present invention. The network device includes a processor 110, a memory 120, and a network interface card chip 130. These components are electrically connected to each other, directly or indirectly, to enable data transmission or interaction. For example, these components may be electrically connected to each other via one or more communication buses or signal lines.
[0040] Processor 110 is used to read / write data or programs stored in memory 120 and execute corresponding functions. It can be a general-purpose processor such as a CPU (Central Processing Unit) or a Network Processor (NP). It can also be a DSP (Digital Signal Processor), an ASIC (Application-Specific Integrated Circuit), an FPGA (Off-the-Shelf Programmable Gate Array), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. Processor 110 includes multiple processing cores, each of which is configured with offload tasks and forwarding tasks, and each processing core has a corresponding software queue.
[0041] The memory 120 is used to store programs or data. The memory 120 can be RAM (Random Access Memory), ROM (Read Only Memory), PROM (Programmable Read-Only Memory), EPROM (Erasable Programmable Read-Only Memory), EEPROM (Electric Erasable Programmable Read-Only Memory), etc.
[0042] The network card chip 130 is used to receive and distribute packets, and is configured with a hardware default queue and multiple hardware RSS queues, which correspond one-to-one to multiple processing cores in the processor 110. Optionally, the network card chip 130 may be a MAC (Media Access Control) chip.
[0043] It is understandable that Figure 1 The structure shown is only a schematic diagram of the structure of the network device. The network device may also include Figure 1 More or fewer components than shown, or with Figure 1 Different configurations shown. Figure 1 Each component shown in the figure can be implemented by hardware, software or a combination thereof.
[0044] See also Figure 2 , is a flow chart of a message diversion method provided by an embodiment of the present invention.
[0045] Step S202: The network card chip diverts the received messages to cache the received messages into a hardware default queue or a corresponding hardware RSS queue.
[0046] In this embodiment, the hardware RSS queue is used to cache messages of standard services defined by the network card chip; the hardware default queue is used to cache messages not defined by the network card chip (non-standard services), and the hardware default queue has a spin lock, which is used to control access to the hardware default queue.
[0047] When the network card chip receives a message, it will divert it by judging whether the received message is a standard service message, so as to cache the received message into the hardware default queue or the corresponding hardware RSS queue.
[0048] Step S204: Each processing core attempts to acquire the spin lock of the hardware default queue when executing the offload task;
[0049] Step S206A, obtaining multiple messages from the hardware default queue and diverting the multiple messages when the spin lock is acquired;
[0050] Step S206B: switching to executing the forwarding task if the spin lock is not obtained;
[0051] In this embodiment, each processing core will alternately perform diversion tasks and forwarding tasks, that is, each processing core will not only perform diversion tasks, nor will it only perform forwarding tasks, but will adjust tasks according to the message diversion situation and message forwarding situation to achieve message diversion rate and forwarding rate adaptation.
[0052] To facilitate understanding, an embodiment of the present invention provides an example. For example, a processor includes four processing cores, namely, processing cores 1 through 4. Assuming that during a certain period of time, processing cores 1, 2, and 4 are all executing offload tasks, all three processing cores will attempt to acquire the spin lock of the hardware default queue.
[0053] Assuming that core 1 acquires the spin lock, it can access the hardware default queue based on the spin lock. Core 1 then retrieves multiple packets from the hardware default queue and distributes them. Cores 2 and 4, however, cannot access the hardware default queue because they haven't acquired the spin lock. Therefore, they switch to forwarding tasks.
[0054] It can be understood that the embodiment of the present invention performs preliminary diversion of messages through the network card chip, and simultaneously uses multiple processing cores to compete to seize the spin lock of the hardware default queue, so that the processing core that seizes the spin lock acts as a diversion core to divert non-standard service messages in the hardware default queue, and the processing core that does not seize the spin lock acts as a forwarding core to forward the messages. That is, the embodiment of the present invention combines the network card chip with the processing core to divert messages of standard services and non-standard services, and dynamically adjusts the diversion rate and forwarding rate of messages to adapt them by adaptively switching roles of the processing core to adjust tasks, thereby achieving rational utilization of multi-core resources, while ensuring the normal operation of standard services and non-standard services, and improving the performance of network equipment.
[0055] It can be seen that based on the above steps, the network device includes a network card chip and multiple processing cores. The network card chip diverts the received messages to cache the received messages to the hardware default queue or the corresponding hardware RSS queue. When performing the diversion task, each processing core attempts to obtain the spin lock of the hardware default queue. If the spin lock is obtained, it obtains multiple messages from the hardware default queue and diverts the multiple messages, or switches to executing the forwarding task if the spin lock is not obtained. By combining the network card chip with the processing core, the messages of standard services and non-standard services are diverted, and the processing core adaptively switches roles to adjust tasks, so as to dynamically adjust the message diversion rate and forwarding rate to adapt the two, thereby achieving the rational use of multi-core resources, while ensuring the normal operation of standard services and non-standard services, and improving the performance of the network device.
[0056] Optionally, for step S202, the embodiment of the present invention provides a possible implementation method, see Figure 3 .
[0057] Step S202-1: The network card chip identifies the received message;
[0058] Step S202-3A: If the network card chip fails to recognize the received message, it caches the received message into the hardware default queue;
[0059] In step S202-3B, when the network card chip identifies the received message, it buffers the received message into the corresponding hardware RSS queue.
[0060] In this embodiment, when receiving a message, the network card chip may use the RSS mechanism to identify the received message, and determine whether the received message is a standard service message based on the identification result to divert the message.
[0061] For ease of understanding, an example is provided in the embodiment of the present invention. For example, assuming that the message received by the network card chip is "message 1", the network chip uses the RSS mechanism to identify "message 1".
[0062] If the network card chip does not recognize "Message 1", it means that the format of "Message 1" is not the standard format defined by the network card chip, and "Message 1" is determined to be a message for non-standard services. Then, "Message 1" is cached in the hardware default queue so that it can be subsequently diverted by the processing core.
[0063] If the network card chip recognizes "Message 1", it means that the format of "Message 1" is the standard format defined by the network, and it is determined that "Message 1" is a message for standard services. Then, "Message 1" is cached in the corresponding hardware RSS queue so that it can be forwarded by the processing core later.
[0064] It can be understood that the embodiments of the present invention use the network card chip to identify received packets and initially divert them. Non-standard service packets not identified by the network card chip are then cached in the hardware default queue, allowing the processing core to subsequently divert these packets. In other words, by combining the network card chip with the processing core, diversion of standard and non-standard service packets is achieved, improving the network device's compatibility with both standard and non-standard services and enhancing network device performance.
[0065] Optionally, for step S202-3B, an embodiment of the present invention provides a possible implementation method, namely: when the network card chip identifies the received message, it parses the received message to obtain the message content, calculates the hash value of the received message based on the message content, and caches the received message to the hardware RSS queue corresponding to the hash value.
[0066] In this embodiment, each hardware RSS queue has a corresponding hash value, which indicates which standard service the corresponding hardware RSS queue is used to cache. The hash value of the message can then be used to determine the standard service to which the message belongs, and the message can be shunted to the corresponding hardware RSS queue based on the standard service to which the message belongs.
[0067] For ease of understanding, the above example is continued for explanation. The network chip is configured with four hardware RSS queues, namely hardware RSS queue 1 to hardware RSS queue 4.
[0068] If the network card chip recognizes "Message 1", "Message 1" is a message for the standard service, then the network card chip will parse "Message 1" to obtain the message content of "Message 1"; then calculate the hash value of "Message 1" based on the message content of "Message 1" to determine the standard service to which "Message 1" belongs; then, among all hardware RSS queues, select the hardware RSS queue with the same hash value as the hash value of "Message 1", for example, if the hash value of hardware RSS queue 2 is the same as the hash value of "Message 1", it means that hardware RSS queue 2 is used to cache messages for the standard service to which "Message 1" belongs, then "Message 1" is cached in hardware RSS queue 2.
[0069] It can be understood that the embodiment of the present invention represents the type of standard service based on the hash value of the hardware queue, and determines the type of standard service to which the message belongs by calculating the hash value of the message, so that messages with the same hash value, i.e., messages belonging to the same standard service, are diverted to the same hardware RSS queue, thereby achieving message order preservation in standard services and effectively avoiding message disorder.
[0070] Optionally, for the process of the processing core diverting multiple messages in step S206A, an embodiment of the present invention provides a possible implementation method, namely: the processing core that obtains the spin lock treats multiple messages as messages to be processed respectively, determines the software queues corresponding to the messages to be processed, and caches the messages to be processed to the corresponding software queues to divert each message to the corresponding software queue.
[0071] In this embodiment, each processing core has a corresponding software queue, and these software queues are used to buffer messages of different non-standard services.
[0072] For ease of understanding, we'll continue with the example of processing core 1. After acquiring the spin lock, processing core 1 retrieves a set number of messages from the hardware default queue, obtaining multiple messages and then shunting them one by one. As you can see, since processing core 1 shunts each message in a similar manner, for ease of description, we'll use the pending message as an example.
[0073] Processing core 1 determines the software queue corresponding to the pending message from among all software queues. Specifically, it determines the software queue corresponding to the non-standard service to which the pending message belongs, and caches the pending message in that software queue. Similarly, processing core 1 processes each message received from the hardware default queue, shunts each message to the corresponding software queue.
[0074] Optionally, for the process of the above-mentioned processing core determining the software queue corresponding to the message to be processed, an embodiment of the present invention provides a possible implementation method, namely: the processing core that obtains the spin lock parses the message to be processed according to preset rules, obtains the message content of the message to be processed, and calculates the hash value of the message to be processed based on the message content of the message to be processed, and uses the software queue with the same hash value as the hash value of the message to be processed as the software queue corresponding to the message to be processed.
[0075] In this embodiment, each software queue has a corresponding hash value, which indicates which non-standard service the corresponding software queue is used to cache. The non-standard service to which the message belongs can then be determined based on the message's hash value, allowing the message to be diverted to the corresponding software queue based on the non-standard service it belongs to.
[0076] For ease of understanding, the description continues with processing core 1 in the above example. Since there are four processing cores in the above example, there are also four software queues, and processing cores 1 to 4 correspond one-to-one to software queues 1 to 4, respectively.
[0077] Processing core 1 can use a set software program to parse the message to be processed according to preset rules to obtain the message content of the message to be processed; then calculate the hash value of the message to be processed based on the message content of the message to be processed; then, among all software queues, select the software queue with the same hash value as the hash value of the message to be processed. For example, the hash value of software queue 3 is the same as the hash value of the message to be processed, which means that software queue 3 is used to cache messages of non-standard services to which the message to be processed belongs. Then, software queue 3 is used as the software queue corresponding to the message to be processed, and the message to be processed is cached in software queue 3.
[0078] It can be understood that the embodiment of the present invention represents the type of non-standard service based on the hash value of the software queue, and determines the type of non-standard service to which the message belongs by calculating the hash value of the message, so that messages with the same hash value, i.e., messages belonging to the same non-standard service, are diverted to the same software queue, thereby achieving message order preservation in non-standard services and effectively avoiding message disorder.
[0079] Optionally, the embodiment of the present invention further provides a method for implementing the forwarding task performed by the processing core, see Figure 4 .
[0080] Step S208 : When executing the forwarding task, each processing core obtains the message from the corresponding hardware RSS queue and software queue and forwards it.
[0081] In this embodiment, multiple hardware RSS queues correspond one-to-one to multiple processing cores. For example, in the above example, there are four processing cores and four hardware RSS queues, and it is assumed that processing cores 1 to 4 correspond one-to-one to hardware RSS queues 1 to 4.
[0082] Then when processing core 1 performs the forwarding task, processing core 1 obtains the message from hardware RSS queue 1 and software queue 1 and forwards it; when processing core 2 performs the forwarding task, processing core 2 obtains the message from hardware RSS queue 2 and software queue 2 and forwards it; when processing core 3 performs the forwarding task, processing core 3 obtains the message from hardware RSS queue 3 and software queue 3 and forwards it; when processing core 4 performs the forwarding task, processing core 4 obtains the message from hardware RSS queue 4 and software queue 4 and forwards it.
[0083] It should be understood that the number of processing cores, the number of hardware RSS queues and the number of software queues in the above embodiment can be set according to actual conditions, and the embodiments of the present invention do not limit it, but it should be noted that the number of processing cores, hardware RSS queues and software queues must be kept consistent.
[0084] An embodiment of the present invention further provides a network device, which includes a network card chip and multiple processing cores.
[0085] The network card chip is used to divert the received messages and cache the received messages into the hardware default queue or the corresponding hardware RSS queue;
[0086] Each processing core is used to try to obtain the spin lock of the hardware default queue when executing the diversion task. If the spin lock is obtained, it obtains multiple messages from the hardware default queue and diverts the multiple messages, or switches to executing the forwarding task if the spin lock is not obtained.
[0087] Optionally, the network card chip is further used to: identify the received message; if the received message is not identified, cache the received message to the hardware default queue; if the received message is identified, cache the received message to the corresponding hardware RSS queue.
[0088] Optionally, the network card chip is also used to: when a received message is identified, parse the received message to obtain message content, calculate a hash value of the received message based on the message content, and cache the received message to a hardware RSS queue corresponding to the hash value.
[0089] Optionally, each processing core is also used to: when obtaining the spin lock, treat multiple messages as messages to be processed, determine the software queues corresponding to the messages to be processed, and cache the messages to be processed to the corresponding software queues to divert each message to the corresponding software queue.
[0090] Optionally, each processing core is also used to: when obtaining the spin lock, parse the message to be processed according to preset rules, obtain the message content of the message to be processed, and calculate the hash value of the message to be processed based on the message content of the message to be processed, and use the software queue with the same hash value as the hash value of the message to be processed as the software queue corresponding to the message to be processed.
[0091] Optionally, multiple hardware RSS queues correspond one-to-one to multiple processing cores, and each processing core is further configured to obtain and forward messages from the corresponding hardware RSS queue and software queue when executing a forwarding task.
[0092] An embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the message diversion method disclosed in the embodiment of the present invention is implemented.
[0093] It should be noted that the basic principles and technical effects of the network device provided in the embodiment of the present invention are the same as those in the above embodiment. For the sake of brief description, for the parts not mentioned in this embodiment, reference can be made to the corresponding contents in the above embodiment.
[0094] In summary, the packet diversion method, network device, and storage medium provided by the embodiments of the present invention have the following beneficial effects compared with the prior art: (1) It realizes the rational utilization of hardware resources and is compatible with standard services and non-standard services. (2) The present invention can give full play to the capabilities of the processing core and can also improve the performance of network devices with fewer processing cores. (3) The load of the processing core can be dynamically adjusted, that is, the lighter the forwarding task, the greater the possibility of the processing core grabbing the spin lock, and the greater the probability of it acting as a diversion core, so it can share more diversion work. (4) Based on the characteristic of dynamically adjusting the load, the multi-core processing capability can be better utilized in the packet diversion scenario where there are both hardware-identified packets and software-identified packets. (5) The hash value of the packet is calculated for diversion, which can ensure the order of the packets and provide support for the normal operation of the service. (6) The present invention has good scalability and can be applied not only to the scenario of a single hardware queue, but also to the scenario of multiple hardware queues, and also to the scenario of a combination of hardware queues and software queues.
[0095] In several embodiments provided by the present invention, it should be understood that each box in the flow chart or block diagram can represent a part of a module, program segment or code, and the part of the module, program segment or code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart, can be implemented by a dedicated hardware-based system that performs the specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions.
[0096] In addition, the functional modules in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.
[0097] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes various media that can store program code, such as a USB flash drive, a mobile hard disk, ROM, RAM, a magnetic disk, or an optical disk.
[0098] The foregoing description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Those skilled in the art will readily appreciate that various modifications and variations of the present invention are possible. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention are intended to be within the scope of protection of the present invention.
Claims
1. A message diversion method, characterized in that: Applied to a network device, the network device includes a network card chip and multiple processing cores, and the message diversion method includes: The network card chip shunts the received messages to cache the received messages into a hardware default queue or a corresponding hardware RSS queue; When executing the diversion task, each processing core attempts to obtain the spin lock of the hardware default queue, obtains multiple messages from the hardware default queue and diverts the multiple messages if the spin lock is obtained, or switches to executing the forwarding task if the spin lock is not obtained.
2. The message diversion method according to claim 1, characterized in that: The network card chip shunts the received messages to cache the received messages into a hardware default queue or a corresponding hardware RSS queue, including: The network card chip identifies the received message; When the network card chip fails to recognize the received message, it caches the received message into the hardware default queue; When the network card chip identifies the received message, it caches the received message in a corresponding hardware RSS queue.
3. The message diversion method according to claim 2, characterized in that: When the network card chip identifies the received message, it caches the received message into a corresponding hardware RSS queue, including: When the network card chip identifies the received message, it parses the received message to obtain message content, calculates a hash value of the received message according to the message content, and caches the received message in a hardware RSS queue corresponding to the hash value.
4. The message diversion method according to claim 1, characterized in that: The acquiring of multiple messages from the hardware default queue and shunting the multiple messages when the spin lock is acquired includes: The processing core that obtains the spin lock treats the multiple messages as messages to be processed respectively, determines the software queues corresponding to the messages to be processed, and caches the messages to be processed to the corresponding software queues, so as to divert each message to the corresponding software queue.
5. The message diversion method according to claim 4, characterized in that: Determining the software queue corresponding to the to-be-processed message includes: The processing core that obtains the spin lock parses the message to be processed according to preset rules, obtains the message content of the message to be processed, and calculates the hash value of the message to be processed based on the message content of the message to be processed, and uses the software queue with the same hash value as the hash value of the message to be processed as the software queue corresponding to the message to be processed.
6. The message diversion method according to claim 4, characterized in that: The multiple hardware RSS queues correspond one-to-one to the multiple processing cores, and the message diversion method further includes: When executing a forwarding task, each of the processing cores obtains a message from the corresponding hardware RSS queue and software queue and forwards the message.
7. A network device, characterized in that: The network device includes a network card chip and multiple processing cores; The network card chip is used to shunt the received messages to cache the received messages into a hardware default queue or a corresponding hardware RSS queue; Each of the processing cores is used to attempt to obtain the spin lock of the hardware default queue when executing a diversion task, obtain multiple messages from the hardware default queue and divert the multiple messages if the spin lock is obtained, or switch to executing a forwarding task if the spin lock is not obtained.
8. The network device according to claim 7, wherein: Each of the processing cores is further configured to: upon obtaining the spin lock, treat the multiple messages as messages to be processed, determine the software queues corresponding to the messages to be processed, and cache the messages to be processed to the corresponding software queues, so as to divert each message to the corresponding software queue.
9. The network device according to claim 8, wherein: Each of the processing cores is also used to: when obtaining the spin lock, parse the message to be processed according to preset rules to obtain the message content of the message to be processed, and calculate the hash value of the message to be processed based on the message content of the message to be processed, and use the software queue with the same hash value as the hash value of the message to be processed as the software queue corresponding to the message to be processed.
10. A computer-readable storage medium, characterized in that The storage medium stores a computer program, which, when executed by a processor, implements the message diversion method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Multi-core multi-thread dual-operating system network equipment and control method thereof
CN102609307A
Shunting method, device and system, processing equipment and storage medium
CN111371694A
Task scheduling method and device, electronic equipment and storage medium
CN116263697A
Message shunting method and device, network equipment and storage medium
CN116668375A
Dynamic load balancing for multi-core computing environments
US20210075730A1