Message processing method and device, electronic equipment and computer readable storage medium

By receiving and processing data packets in hardware, parsing message information, and calculating hash values ​​to obtain entry addresses, the problem of high CPU memory access pressure during software table lookups is solved, thus improving software forwarding performance.

CN116015613BActive Publication Date: 2026-02-27SUZHOU CENTEC COMM CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310014512.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-01-05
Publication Date
2026-02-27
Estimated Expiration
2043-01-05

AI Technical Summary

Technical Problem

In soft forwarding scenarios, the CPU experiences significant memory access pressure when the software looks up tables, resulting in poor overall performance.

Method used

The system receives data packets through hardware, parses the message information, calculates hash values, obtains the entry address, and sends it to the bus via the interface to write it into the cache space, thereby reducing the CPU's memory access pressure.

Benefits of technology

It effectively reduces the CPU's memory access pressure and improves the overall performance of soft forwarding.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116015613B_ABST
    Figure CN116015613B_ABST
Patent Text Reader

Abstract

The application discloses a message processing method and device, electronic equipment and a computer readable storage medium. The method comprises the following steps: receiving a data packet by hardware; analyzing the data packet to obtain message information required by software table lookup; calculating a hash value of the software table lookup based on the message information; obtaining an entry address of the software table lookup based on the hash value of the software table lookup; sending the entry address to a bus by the hardware through an interface; and writing entry data in a memory into a cache space through the interface according to the entry address by the bus. The application solves the technical problem that the CPU memory access pressure is large and the overall performance of software forwarding is poor when a large number of services perform software table lookup in the related art.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of computers, in particular to a message processing method and device, electronic equipment and computer readable storage medium. BACKGROUND

[0002] With the development of computers, in the soft forwarding scene, the business is more and more complex, and currently the software mainly performs the identification and search processing of the business message and the message editing. However, in the related technology, when a large number of businesses are searched by software, there is a problem of large memory access pressure of CPU and poor overall performance of soft forwarding.

[0003] At present, no effective solution has been proposed for the above problems. SUMMARY

[0004] Embodiments of the present application provide a message processing method and device, electronic equipment and computer readable storage medium to at least solve the technical problem of large memory access pressure of CPU and poor overall performance of soft forwarding when a large number of businesses are searched by software in the related technology.

[0005] According to an aspect of an embodiment of the present application, a message processing method is provided, comprising: receiving a transmitted data packet by hardware; parsing the data packet to obtain message information required for software lookup table; calculating a hash value of the software lookup table based on the message information; obtaining an entry address of the software lookup table based on the hash value of the software lookup table; sending the entry address to a bus by the hardware through an interface; and writing entry data in a memory into a cache space through the interface according to the entry address by the bus.

[0006] Optionally, the type of the software lookup table includes a global table and a forwarding table, and the calculating of the hash value of the software lookup table based on the message information includes: obtaining an identification ID of the software lookup table and an entry type to be searched; and calculating the hash value of the software lookup table based on the message information and the entry type to be searched.

[0007] Optionally, the method further comprises: setting table information of the software lookup table, wherein the table information includes a starting address of the software lookup table, a software table size, an entry length, and a prefetch length.

[0008] Optionally, the obtaining of the entry address of the software lookup table based on the hash value of the software lookup table includes: calculating the entry address of the software lookup table based on the starting address of the software lookup table, the entry length, and the hash value.

[0009] Optionally, after the hardware sends the entry address to the bus through the interface, the method further comprises: obtaining a packet receiving state of a packet receiving channel or a packet receiving queue used by the hardware to receive the data packet, wherein the packet receiving state comprises at least one of a data depth in a to-be-processed state and a number of descriptors of a memory in an unprocessed state; and determining that the hardware pre-fetching of the entry data needs to be performed in a case where the packet receiving state is greater than a preset threshold.

[0010] Optionally, the method further comprises: determining, by the hardware, the pre-fetching of at least one entry data based on the entry address and the entry length.

[0011] Optionally, the pre-fetching operation is triggered by a bus instruction, and the pre-fetching operation represents the hardware pre-fetching of the entry data.

[0012] According to an aspect of an embodiment of the present application, a packet processing apparatus is provided, comprising: a receiving module configured to receive, by hardware, a transmitted data packet; a parsing module configured to parse the data packet to obtain packet information required for software table lookup; a calculating module configured to calculate a hash value of the software table lookup based on the packet information; an obtaining module configured to obtain an entry address of the software table lookup based on the hash value of the software table lookup; a first sending module configured to send, by the hardware, the entry address to a bus through an interface; and a second sending module configured to write, by the bus, entry data in a memory into a cache space through the interface according to the entry address.

[0013] Optionally, the type of the software table lookup comprises a global table and a forwarding table, and the calculating module comprises: a sub-obtaining module configured to obtain an identification ID of the software table lookup and an entry type to be looked up; and a sub-calculating module configured to calculate the hash value of the software table lookup based on the packet information and the entry type to be looked up.

[0014] According to an aspect of an embodiment of the present application, an electronic device is provided, comprising: a processor; and a memory configured to store instructions executable by the processor; wherein the processor is configured to execute the instructions to implement any of the packet processing methods described above.

[0015] According to an aspect of an embodiment of the present application, a computer readable storage medium is provided, when instructions in the computer readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform any of the packet processing methods described above.

[0016] In the embodiment of the present application, the transmitted data packet is received by hardware, and then the data packet is parsed to obtain message information required by software lookup table. Then, based on the message information, a hash value of the software lookup table is calculated. Then, based on the hash value of the software lookup table, an entry address of the software lookup table is obtained. Then, the hardware sends the entry address to the bus through an interface. Finally, the bus writes entry data in the memory into the cache space through the interface according to the entry address. Since the transmitted data packet is received by hardware, the speed of receiving the data packet is fast and the time consumption is short. Since the hardware sends the entry address to the bus through the interface, and the bus writes the entry data in the memory into the cache space through the interface according to the entry address, the memory access pressure of the CPU can be effectively reduced, and the overall performance of the software forwarding can be improved. Thus, the technical effect of improving the overall performance of the software forwarding is achieved, and the technical problem of the large memory access pressure of the CPU and the poor overall performance of the software forwarding in the software lookup table of a large amount of services in the related art is solved. BRIEF DESCRIPTION OF DRAWINGS

[0017] The accompanying drawings, which are included to provide a further understanding of the present application and are incorporated in and constitute a part of this application, illustrate embodiments of the present application and together with the description serve to explain the present application. In the drawings:

[0018] Figure 1 is a flowchart of a message processing method according to an embodiment of the present application;

[0019] Figure 2 is a schematic diagram of a message processing method in the related art;

[0020] Figure 3 is a schematic diagram of a message processing method provided by an optional embodiment of the present application;

[0021] Figure 4 is a structural block diagram of a message processing device according to an embodiment of the present application. DETAILED DESCRIPTION

[0022] In order for those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings of the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor should fall within the scope of protection of the present application.

[0023] It is to be understood that the terminology "first", "second" and the like used in the specification and the claims of the application as well as the foregoing drawings is merely intended to distinguish between similar objects and not necessarily for describing a particular sequential order. It is to be understood that the use of the singular herein includes the plural unless specifically stated otherwise. The use of the term "including", "comprising" and variations thereof as well as the terms "consisting of" and variations thereof are intended to cover the various steps of a process, method, system, product, or apparatus, including for example, the steps of a process, method, system, product, or apparatus, without limiting the number of steps or the order in which they are performed, unless specifically stated otherwise.

[0024] Embodiment 1

[0025] According to an embodiment of the application, there is provided an embodiment of a packet processing method. It is to be understood that the steps shown in the flowcharts of the drawings can be performed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowcharts, in some cases the steps shown or described can be performed in an order different from that shown here.

[0026] Figure 1 is a flowchart of a packet processing method according to an embodiment of the application, as shown in Figure 1 the method comprises the following steps:

[0027] Step S102, the hardware receives the transmitted data packet;

[0028] In the technical solution provided by the above step S102 of the application, the transmitted data packet is received by hardware, so the speed of receiving the data packet is faster and the time consumption is shorter.

[0029] Step S104, the data packet is parsed to obtain the packet information required by the software lookup table;

[0030] In the technical solution provided by the above step S104 of the application, the data packet is parsed to accurately obtain the packet information required by the software lookup table, such as the IP quintuple in the typical value of the routing access scenario, which can be additionally combined with the three-layer interface Interface or the virtual routing forwarding VRF (Virtual Routing Forwarding) information.

[0031] Step S106, the hash value of the software lookup table is calculated based on the packet information;

[0032] In the technical solution provided by the above step S106 of the application, the hash value of the software lookup table can be quickly calculated based on the packet information.

[0033] Step S108, obtaining the entry address of the software lookup table based on the hash value of the software lookup table;

[0034] In the technical solution provided in the above step S108 of the present application, based on the hash value of the software lookup table, the entry address of the software lookup table can be accurately obtained.

[0035] Step S110, the hardware sends the entry address to the bus through the interface;

[0036] In the technical solution provided in the above step S110 of the present application, the hardware can be a direct memory access controller (DMA Controller), and the interface can be an accelerator coherency port (ACP) interface. The DMA Controller sends the entry address to the bus through the ACP interface, without the need to pass through the central processing unit (CPU), which can effectively reduce the memory access pressure of the CPU and improve the overall performance of the software forwarding.

[0037] Step S112, the bus writes the entry data in the memory into the cache space through the interface according to the entry address.

[0038] In the technical solution provided in the above step S112 of the present application, the memory can be a double data rate synchronous dynamic random access memory (DDR). Since the bus writes the entry data in the DDR into the cache space through the interface according to the entry address, the entry data can be quickly written into the cache space (Cache).

[0039] Through the above step S102 to the above step S112, the hardware receives the transmitted data packet, then parses the data packet to obtain the message information required by the software lookup table, calculates the hash value of the software lookup table based on the message information, obtains the entry address of the software lookup table based on the hash value of the software lookup table, and then sends the entry address to the bus through the interface. Finally, the bus writes the entry data in the memory into the cache space through the interface according to the entry address. Since the hardware receives the transmitted data packet, the speed of receiving the data packet is fast and the time consumption is short. Since the hardware sends the entry address to the bus through the interface, and the bus writes the entry data in the memory into the cache space through the interface according to the entry address, the memory access pressure of the CPU can be effectively reduced, and the overall performance of the software forwarding can be improved. Thus, the technical effect of improving the overall performance of the software forwarding is achieved, and the technical problem of large CPU memory access pressure and poor overall performance of software forwarding in related technologies when a large number of services are software looked up is solved.

[0040] As an optional embodiment, the type of the software lookup table comprises: a global table and a forwarding table, and the hash value of the software lookup table is calculated based on the packet information, comprising: obtaining an identification ID of the software lookup table and an entry type to be searched; and calculating the hash value of the software lookup table based on the packet information and the entry type to be searched.

[0041] In this embodiment, the type of the software lookup table comprises: a global table and a forwarding table based on the combination of IPv4 / IPv6 type, packet receiving port, packet receiving channel and packet receiving queue information. After obtaining the identification ID of the software lookup table and the entry type to be searched, the hash value of the software lookup table can be accurately and quickly calculated based on the packet information and the entry type to be searched.

[0042] As an optional embodiment, the method further comprises: setting table information of the software lookup table, wherein the table information comprises: a starting address of the software lookup table, a software table size, an entry length and a prefetch length.

[0043] In this embodiment, the starting address of the software lookup table, the software table size, the entry length and the prefetch length are important table information of the software lookup table. Therefore, when setting the table information of the software lookup table, the table information comprises the starting address of the software lookup table, the software table size, the entry length and the prefetch length.

[0044] As an optional embodiment, based on the hash value of the software lookup table, the entry address of the software lookup table is obtained, comprising: calculating the entry address of the software lookup table based on the starting address of the software lookup table, the entry length and the hash value.

[0045] In this embodiment, based on the starting address of the software lookup table, the entry length and the hash value, the entry address of the software lookup table can be accurately calculated.

[0046] As an optional embodiment, after the hardware sends the entry address to the bus through the interface, it further comprises: obtaining a packet receiving state of a packet receiving channel or a packet receiving queue used by the hardware to receive a data packet, wherein the packet receiving state comprises at least one of: a data depth in a to-be-processed state and a descriptor number of a memory in an unprocessed state; and in a case where the packet receiving state is greater than a preset threshold, it is determined that the hardware prefetch of the entry data needs to be performed.

[0047] In this embodiment, the packet receiving state of the packet receiving channel and the packet receiving queue corresponds to the direct memory access controller DMAController. The packet receiving state comprises at least one of: a data depth in a to-be-processed state and a descriptor number of a memory in an unprocessed state, for example, a first-in-first-out FIFO depth and a number of direct memory access DMA descriptors not processed by software. In a case where the packet receiving state is greater than a preset threshold, it can be determined that the hardware prefetch of the entry data needs to be performed.

[0048] As an optional embodiment, the method comprises: the hardware determines to prefetch the at least one entry data based on the entry address and the entry length.

[0049] In this embodiment, the DMAController can accurately prefetch the corresponding one or more entry data into the cache space Cache based on the entry address and the entry length.

[0050] As an optional embodiment, the prefetch operation is triggered by a bus instruction, wherein the prefetch operation represents the hardware prefetch of the entry data.

[0051] In this embodiment, the prefetch operation initiated by the DMAController is completed through the bus instruction, and the steps are as follows: the DMAController sends the data address to the bus one or more times, then the bus takes out the data from the storage space in the unit of entry data according to the address, and writes the data into the specific region allocated in the cache space Cache through the CPU-side interface, wherein the storage space can be a double data rate synchronous dynamic random access memory (DDR), and when the CPU is an ARM architecture, the CPU-side interface can be an ACP interface. In this way, the prefetch operation can be triggered quickly through the bus instruction.

[0052] Based on the above embodiments and optional embodiments, an optional implementation is provided, which is described in detail as follows.

[0053] In the related art, when a large amount of business software looks up a table, the CPU has a large memory access pressure, and the overall performance of the software forwarding is poor.

[0054] In view of this, the optional implementation of the present application provides a message processing method, which can effectively reduce the memory access delay required by the CPU for message business lookup, thereby greatly improving the efficiency of software forwarding.

[0055] Figure 2 is a schematic diagram of the message processing method in the related art, Figure 2In the specific implementation, the central processor cluster (CPU Cluster) includes N+1 central processor cores (CPU Core) sharing an L3 Cache, the N+1 CPU Cores are CPU Core 0, CPU Core 1, …, and CPU Core N respectively, each CPU Core includes an L1 I-Cache, an L1 D-Cache, and an L2 Cache, the DMA Controller RX is the direct memory access controller (DMA Controller) in the foregoing description, the ACE and the ACE-Lite are bus interfaces, the BUS is a bus, the DDR 4 is the double data rate synchronous dynamic random access memory (DDR) in the foregoing description, the DDR Intf is an interface between the bus and the DDR, the Packet is the data packet in the foregoing description, the PacketData is used for storing the Packet, and the Hot Data is the entry data in the foregoing description. Figure 2 As shown in the figure, the steps of the soft forwarding in the related art are as follows:

[0056] S1, the direct memory access controller (DMA Controller) writes a packet to the double data rate synchronous dynamic random access memory (DDR), after writing the corresponding packet, the direct memory access (DMA) descriptor is updated or an interrupt is provided;

[0057] S2, the central processor (CPU) perceives the packet reception by polling the DMA descriptor or the interrupt provided by the DMA;

[0058] S3, the CPU acquires and analyzes the packet data, and calculates a hash value of software lookup based on the packet data;

[0059] S4, the CPU reads the entry data at a corresponding position of the software table, and the read operation will leave the corresponding entry data in the cache space (Cache); in the case that the bus supports cache consistency, when the same software table data is accessed, only the Cache is accessed, and it is not necessary to repeatedly read the DDR;

[0060] S5, since the time delay of the CPU reading the DDR is long, the CPU cannot continue to process the received packet before the data is retrieved, which leads to the waste of CPU resources, and the overall performance of the soft forwarding is greatly reduced.

[0061] Figure 3 is a schematic diagram of a packet processing method provided by an optional implementation of the present application, Figure 3In the specific embodiment, the central processor cluster CPU Cluster includes N+1 central processor cores CPU Core sharing an L3 Cache, the N+1 CPU Cores are CPU Core 0, CPU Core 1, …, CPU Core N respectively, each CPU Core includes an L1 I-Cache, an L1 D-Cache and an L2 Cache, the DMAController RX is the direct memory access controller DMA Controller in the foregoing, the ACE and the ACE-Lite are bus interfaces, the ACP is the ACP interface in the foregoing, the BUS is a bus, the DDR 4 is a double data rate synchronous dynamic random access memory DDR in the foregoing, the DDR Intf is an interface between the bus and the DDR, the Packet is a data packet in the foregoing, the Hot Data is entry data in the foregoing, the Transaction is a transmission transaction structure of the bus, and the Hot Data in the Partition Cache ACP Private is a specific region allocated in a cache space Cache, as shown in Figure 3 The steps of the soft forwarding in the application are as follows:

[0062] S1, analyzing a data packet to obtain message information required by software lookup table, for example, the typical value of the route access scene is an IP five-tuple, and three-layer interface information or virtual routing forwarding VRF information can be additionally combined;

[0063] S2, judging a software table, the type of the software lookup table includes: a global table, a forwarding table set based on a combination of IPv4 / IPv6 types, a packet receiving port, a packet receiving channel and packet receiving queue information, obtaining an identification ID of the software lookup table and an entry type to be searched;

[0064] S3, calculating a hash value of the software lookup table based on the message information and the entry type to be searched;

[0065] S4, setting table information of the software lookup table, wherein the table information includes: a starting address of the software lookup table, a software table size, an entry length and a prefetch length;

[0066] S5, calculating an entry address of the software lookup table based on the starting address of the software lookup table, the entry length and the hash value;

[0067] S6, the DMA Controller corresponds to the packet channel, the packet queue and the packet state. The packet state includes at least one of the following: the data depth in the pending state and the number of descriptors in the memory in the unprocessed state, for example, the data FIFO depth, the number of software unprocessed DMA descriptors. In the case of the packet state being greater than the preset threshold, it can be determined that the hardware prefetch of entry data needs to be performed;

[0068] S7, the DMA Controller pre-fetches one or more corresponding entry data into the cache space Cache based on the entry address and the entry length;

[0069] S8, the DMA Controller initiates the prefetch operation through the bus instruction, and the steps are as follows: the DMA Controller sends the data address to the bus one or more times, then the bus takes out the data from the storage space in the unit of entry data according to the address, and writes the data into the specific area allocated in the cache space Cache through the CPU side interface, wherein the storage space can be a double data rate synchronous dynamic random access memory (DDR), and when the CPU is an ARM architecture, the CPU side interface can be an ACP interface.

[0070] Through the above optional implementation, at least the following beneficial effects can be achieved:

[0071] (1) effectively reducing the memory access delay required by the CPU for packet service lookup, thereby greatly improving the soft forwarding efficiency;

[0072] (2) reducing the memory access pressure of the CPU and improving the overall performance of the soft forwarding.

[0073] It should be noted that, for the foregoing method embodiments, in order to simply describe, they are all expressed as a series of action combinations, but those skilled in the art should know that the present application is not limited by the action sequence described, because according to the present application, some steps can be performed in other order or simultaneously. Secondly, those skilled in the art should know that the embodiments described in the specification all belong to preferred embodiments, and the actions and modules involved are not necessarily necessary for the present application.

[0074] Those skilled in the art can clearly understand that the method according to the above-mentioned embodiments can be realized by means of software and necessary general hardware platforms, of course, can also be realized by hardware, but in many cases, the former is a better embodiment. Based on such understanding, the technical solutions of the present application can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes a plurality of instructions for making a terminal device (which can be a mobile phone, computer, server, or network device) execute the method of each embodiment of the present application.

[0075] Embodiment 2

[0076] According to the embodiments of the present application, a device for implementing the above packet processing method is further provided, Figure 4 is a structural block diagram of the packet processing device according to the embodiments of the present application, as shown in the figure, the device comprises: a receiving module 402, an analysis module 404, a calculation module 406, an acquisition module 408, a first sending module 410 and a second sending module 412, which will be described in detail below. Figure 4

[0077] The receiving module 402 is used for receiving the transmitted data packet by hardware; the analysis module 404 is connected to the receiving module 402 and is used for analyzing the data packet to obtain the packet information required by the software lookup table; the calculation module 406 is connected to the analysis module 404 and is used for calculating the hash value of the software lookup table based on the packet information; the acquisition module 408 is connected to the calculation module 406 and is used for acquiring the entry address of the software lookup table based on the hash value of the software lookup table; the first sending module 410 is connected to the acquisition module 408 and is used for sending the entry address to the bus by the interface by hardware; and the second sending module 412 is connected to the first sending module 410 and is used for writing the entry data in the memory into the cache space by the interface according to the entry address by the bus.

[0078] It should be noted that the receiving module 402, the analysis module 404, the calculation module 406, the acquisition module 408, the first sending module 410 and the second sending module 412 correspond to steps S102 to S112 in the implementation of the packet processing method, and the multiple modules and the instances and application scenarios realized by the corresponding steps are the same, but are not limited to the content disclosed in the above-mentioned embodiment 1.

[0079] ​As an optional embodiment, the type of the software lookup table comprises a global table and a forwarding table, and the calculation module comprises a sub-acquisition module configured to acquire an identification ID of the software lookup table and an entry type to be looked up, and a sub-calculation module configured to calculate a hash value of the software lookup table based on the packet information and the entry type to be looked up.

[0080] In this embodiment, the sub-acquisition module can acquire the identification ID of the software lookup table and the entry type to be looked up, and the sub-calculation module can calculate the hash value of the software lookup table based on the packet information and the entry type to be looked up, so that the calculation module comprising the sub-acquisition module and the sub-calculation module can calculate the hash value of the software lookup table based on the packet information.

[0081] Embodiment 3

[0082] According to another aspect of the embodiments of the present application, an electronic device is also provided, comprising a processor and a memory for storing processor-executable instructions, wherein the processor is configured to execute the instructions to implement the packet processing method of any of the above.

[0083] Embodiment 4

[0084] According to another aspect of the embodiments of the present application, a computer-readable storage medium is also provided, which, when the instructions in the computer-readable storage medium are executed by a processor of an electronic device, enables the electronic device to perform the packet processing method of any of the above.

[0085] The above-mentioned serial numbers of the embodiments of the present application are only for description, and do not represent the advantages or disadvantages of the embodiments.

[0086] In the above-mentioned embodiments of the present application, the description of each embodiment has its own focus, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments.

[0087] In the several embodiments provided in this application, it should be understood that the disclosed technology can be implemented in other ways. Of course, the unit described as the division is only a logic function division, and there can be another division way when actually implemented, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some interface, unit or module, and can be electrical or other forms.

[0088] The units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment scheme.

[0089] In addition, each functional unit in each embodiment of the present application can be integrated in one processing unit, or each unit can exist physically, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.

[0090] The integrated unit, if realized in the form of a software functional unit and sold or used as an independent product, can be stored in a computer readable storage medium. Based on such understanding, the technical scheme of the present application or the part of the present application which contributes to the prior art or the whole or part of the technical scheme can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The foregoing storage medium includes various media that can store program codes, such as a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.

[0091] The above is only the preferred embodiment of the present application, and it should be pointed out that for ordinary skilled in the art, without departing from the principles of the present application, a number of improvements and refinements can be made, and these improvements and refinements should be considered as the protection scope of the present application.

Claims

1. A method of processing a packet, the method comprising: The method comprises: hardware receives a transmitted data packet; parsing the data packet to obtain message information required by a software lookup table; based on the message information, calculating a hash value of the software lookup table; based on the hash value of the software lookup table, obtaining an entry address of the software lookup table; the hardware sends the entry address to the bus through an interface; the bus reads entry data in the memory through an access interface between the bus and the memory according to the entry address, and writes the entry data into the cache space of the CPU through the interface on the CPU side; after the hardware sends the entry address to the bus through the interface, further comprising: obtaining the packet receiving state of the packet receiving channel or the packet receiving queue used by the hardware to receive the data packet, wherein the packet receiving state comprises at least one of the following: data depth in a to-be-processed state and descriptor number of the memory in an unprocessed state; in the case that the packet receiving state is greater than a preset threshold, it is determined that hardware prefetching of the entry data needs to be performed.

2. The method of claim 1, wherein, The type of the software lookup table includes: global table and forwarding table, and the calculation of the hash value of the software lookup table based on the message information comprises: obtaining the identification ID of the software lookup table and the entry type to be searched; based on the message information and the entry type to be searched, calculating the hash value of the software lookup table.

3. The method of claim 2, wherein, The method further comprises: setting table information of the software lookup table, wherein the table information comprises: the starting address of the software lookup table, the software table size, the entry length, and the prefetch length.

4. The method of claim 3, wherein, Based on the hash value of the software lookup table, obtaining the entry address of the software lookup table comprises: based on the starting address of the software lookup table, the entry length, and the hash value, calculating the entry address of the software lookup table.

5. The method of claim 4, wherein, The method comprises: the hardware determines to prefetch at least one entry data based on the entry address and the entry length.

6. The method of claim 1, wherein, The prefetch operation is triggered by a bus instruction, wherein the prefetch operation represents hardware prefetching of the entry data.

7. A packet processing device, characterized by The method comprises: a receiving module for hardware to receive a transmitted data packet; a parsing module for parsing the data packet to obtain message information required by a software lookup table; a calculation module for calculating a hash value of the software lookup table based on the message information; an obtaining module for obtaining an entry address of the software lookup table based on the hash value of the software lookup table; a first sending module for the hardware to send the entry address to the bus through an interface; a second sending module for the bus to read entry data in the memory through an access interface between the bus and the memory according to the entry address, and to write the entry data into the cache space of the CPU through the interface on the CPU side; After the hardware sends the entry address to the bus through the interface, further comprising: obtaining a packet receiving state of a packet receiving channel or a packet receiving queue used by the hardware to receive the data packet, wherein the packet receiving state comprises at least one of the following: a data depth in a to-be-processed state and a number of descriptors of a memory in an unprocessed state; and in a case where the packet receiving state is greater than a preset threshold, determining that the hardware prefetch of the entry data needs to be performed.

8. The apparatus of claim 7, wherein, The type of the software lookup table comprises: a global table and a forwarding table, wherein the calculation module comprises: a sub-acquisition module configured to acquire an identification ID of the software lookup table and an entry type to be searched; a sub-calculation module configured to calculate a hash value of the software lookup table based on the packet information and the entry type to be searched.

9. An electronic device, comprising: comprise: a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement the packet processing method according to any one of claims 1 to 6.

10. A computer-readable storage medium, characterized in that, When the instructions in the computer readable storage medium are executed by the processor of the electronic device, the electronic device can perform the packet processing method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Method for improving data forwarding performance, electronic equipment and storage medium

    CN110708250A

  • Message processing DMA system and method of multi-core network processor

    CN114490467A