Flow table processing method, apparatus, chip, network interface card, device, medium and program product

By introducing the collaborative work of forwarding threads and background threads in a hardware programmable processor to generate and manage flow table data, the problem of high CPU usage in the traditional OVS model is solved, and efficient flow table processing and network forwarding are achieved.

CN121056423BActive Publication Date: 2026-01-27SHENZHEN JAGUAR MICROSYSTEMS CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511589566.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-11-03
Publication Date
2026-01-27
Estimated Expiration
2045-11-03

AI Technical Summary

Technical Problem

In 10 Gigabit networks with high CPU usage, slow path forwarding under the traditional OVS model may consume dozens of CPU cores, making it difficult to support ultra-large-scale traffic.

Method used

By introducing forwarding threads and background threads into the hardware programmable processor, the forwarding thread generates flow table data and writes it to the target cache block, while the background thread manages the flow table configuration and works together to generate and update the flow table, reducing CPU involvement.

Benefits of technology

It improves flow table processing efficiency, reduces CPU usage, and enhances network forwarding performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121056423B_ABST
    Figure CN121056423B_ABST
Patent Text Reader

Abstract

The application relates to a flow table processing method and device, a chip, a network interface card, equipment, a medium and a program product, which are applied to a hardware programmable processor, the hardware programmable processor comprising a forwarding thread and a background thread, and the method comprises the following steps: the forwarding thread generates flow table data and writes the generated flow table data into a target cache block of a target cache space under the condition that it is determined that a data packet does not hit a fast path flow table; the forwarding thread informs a lookup engine of information about writing completion, wherein the information about writing completion is used to instruct the lookup engine to configure a fast path flow table based on the flow table data written into the target cache block; the background thread acquires a processing result of the lookup engine, releases the target cache block based on the processing result, and informs the forwarding thread of the released target cache block. The method can improve the flow table processing efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communication technology, and in particular to a flow table processing method, apparatus, chip, network interface card, device, medium, and program product. Background Technology

[0002] Whether the packet is sent from the host side of the smart network card or received from the physical network, it will first go through the hardware part of the smart network card to match the flow table entries. If the packet matches the flow table entry on the hardware, the hardware part will directly forward the packet, thereby accelerating the hardware and improving the forwarding performance.

[0003] In traditional technologies, Open vSwitch (OVS), as a core component of Software-Defined Networking (SDN), uses two types of packet forwarding paths: Slow Path: Handled by the OVS software kernel module (ovs-vswitchd) or user-space processes, requiring a complete flow table matching process. Fast Path: Forwarding logic is offloaded to the network interface card (NIC) through hardware offloading (e.g., SmartNIC, FPGA) or hardware acceleration technologies (e.g., DPDK), reducing CPU involvement. In this OVS model, the first traffic processed—a new flow (not matching the flow table)—must pass through the slow path to establish a flow table entry before subsequent traffic can enter the fast path.

[0004] However, in a 10 Gigabit network with high CPU usage, slow path forwarding may consume dozens of CPU cores, making it difficult to support ultra-large-scale traffic. Summary of the Invention

[0005] Therefore, it is necessary to provide a flow table processing method, device, chip, network interface card, equipment, medium, and program product that can improve the efficiency of flow table processing in order to address the above-mentioned technical problems.

[0006] In a first aspect, this application provides a flow table processing method applied to a hardware programmable processor, the hardware programmable processor including a forwarding thread and a background thread, the method comprising:

[0007] If the forwarding thread determines that the data packet does not hit the fast path flow table, it generates flow table data and writes the generated flow table data into the target cache block of the target cache space.

[0008] The forwarding thread notifies the lookup engine of the write completion information, which is used to instruct the lookup engine to configure a fast path flow table based on the flow table data written to the target cache block.

[0009] The background thread obtains the processing result of the lookup engine, releases the target cache block based on the processing result, and informs the forwarding thread of the released target cache block.

[0010] In one embodiment, the target cache space is a circular cache space, and the pointers of the circular cache space include a first pointer pointing to the last target cache block that the forwarding thread has continuously filled, a second pointer pointing to the last target cache block released by the background thread based on the processing result, and a third pointer pointing to the latest free target cache block allocated to the forwarding thread for writing the flow table data.

[0011] In one embodiment, before writing the generated flow table data into the target cache block of the target cache space, the method further includes:

[0012] Read the second pointer and the third pointer of the target cache space;

[0013] If, based on the second pointer and the third pointer, it is determined that there is a free target cache block in the target cache space, the generated flow table data is written into the target cache block of the target cache space;

[0014] If, based on the second pointer and the third pointer, it is determined that there is no free target cache block in the target cache space, the flow table data is discarded and not written to the target cache space.

[0015] In one embodiment, writing the generated flow table data into a target cache block of the target cache space includes:

[0016] If a token corresponding to the flow table data is obtained, the flow table data is written to the target cache block of the target cache space based on the token. The token is used to rate limit the flow corresponding to the flow table data.

[0017] If no token for the flow corresponding to the flow table data is obtained, the flow table data is discarded.

[0018] In one embodiment, before writing the generated flow table data into the target cache block of the target cache space, the method further includes:

[0019] When at least two of the forwarding threads write the flow table data to the target cache space, the target cache block determined by incrementing a counter is obtained.

[0020] In one embodiment, notifying the lookup engine of the write completion includes:

[0021] Obtain lock permissions for the table lookup engine;

[0022] Update the first pointer based on the first pointer and the target cache blocks that have been continuously filled by each of the forwarding threads;

[0023] The updated first pointer is sent to the lookup engine, and upon successful transmission, the lock permissions of the lookup engine are released.

[0024] In one embodiment, generating the flow table data includes:

[0025] If the data packet does not hit the slow path flow table, flow table data is generated for creating a new flow table;

[0026] If the data packet hits the slow path flow table, flow table data is generated to update the slow path flow table.

[0027] In one embodiment, each cache block of the target cache space corresponds to a flow table index; the step of writing the generated flow table data into the target cache block of the target cache space includes:

[0028] When the flow table data is used to create a new flow table, the flow table data is written to the target cache block based on the flow table index corresponding to the target cache block;

[0029] When the flow table data is used to update the slow path flow table, the flow table data is written to the target cache block based on the flow table index corresponding to the slow path flow table.

[0030] In one embodiment, the background thread obtains the processing result of the lookup engine, releases the target cache block based on the processing result, and informs the forwarding thread of the released target cache block, including:

[0031] The background thread periodically retrieves the processing results from the lookup engine;

[0032] If the target cache block pointed to by the second pointer is different from the current target cache block to be processed by the background thread;

[0033] Obtain the flow table processing result of the current target cache block to be processed by the background thread;

[0034] If the result of the flow table processing of the current target cache block to be processed by the background thread is to create a new flow table, a new flow table index is allocated to the current target cache block, and the current target cache block to be processed by the background thread is updated.

[0035] If the result of the flow table processing of the current target cache block to be processed by the background thread is to update the slow path flow table, then update the current target cache block to be processed by the background thread.

[0036] If the target cache block pointed to by the second pointer is the same as the current target cache block to be processed by the background thread, the second pointer is informed to the forwarding thread.

[0037] Secondly, this application also provides a flow table processing apparatus applied to a hardware programmable processor, the hardware programmable processor including a forwarding thread and a background thread, the apparatus comprising:

[0038] The forwarding module is used to generate flow table data when the forwarding thread determines that the data packet does not hit the fast path flow table; and to write the generated flow table data into the target cache block of the target cache space.

[0039] The flow table configuration module is used to notify the lookup engine of write completion information through the forwarding thread. The write completion information is used to instruct the lookup engine to configure a fast path flow table based on the flow table data written to the target cache block.

[0040] The cache processing module is used to obtain the processing result of the lookup engine through the background thread, release the target cache block based on the processing result, and inform the forwarding thread of the released target cache block.

[0041] Thirdly, this application also provides a chip including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the method in any of the above embodiments.

[0042] Fourthly, this application also provides a network interface card, including the chip and multiple interfaces as described in any of the above embodiments.

[0043] The chip processes data or communicates with the outside world through the interface.

[0044] Fifthly, this application also provides a computer device including a network interface card in any of the above embodiments, the network interface card being used for processing data or external communication.

[0045] Sixthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the methods in any of the above embodiments.

[0046] In a seventh aspect, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the method in any of the above embodiments.

[0047] The aforementioned flow table processing method, apparatus, chip, network interface card, device, medium, and program product are applied to a hardware programmable processor. The hardware programmable processor includes a forwarding thread and a background thread. This placement of flow table processing within the hardware programmable processor results in higher efficiency compared to software processing. Furthermore, the method includes: when the forwarding thread determines that a data packet does not match the fast path flow table, it generates flow table data and writes the generated flow table data into a target cache block in the target cache space; it notifies the lookup engine of the write completion information, which instructs the lookup engine to configure the fast path flow table based on the flow table data written to the target cache block; the background thread obtains the processing result from the lookup engine, releases the target cache block based on the processing result, and informs the forwarding thread of the released target cache block. In this way, the forwarding thread and the background thread collaborate to generate and configure flow tables, improving flow table generation efficiency. The forwarding thread only needs to create or update flow tables, while the background thread manages the flow tables, thus achieving both flow table management and timely creation and updating, thereby improving flow table processing efficiency. Attached Figure Description

[0048] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0049] Figure 1 This is a diagram illustrating the application environment of the flow table processing method in one embodiment;

[0050] Figure 2 This is a flowchart illustrating a flow table processing method in one embodiment;

[0051] Figure 3 This is a schematic diagram of the target cache space in one embodiment;

[0052] Figure 4 A flowchart of the flow table data filling step for a forwarding thread in one embodiment;

[0053] Figure 5 This is a flowchart of the background thread flow table processing steps in one embodiment;

[0054] Figure 6Create a business collaboration graph for the flow table in one embodiment;

[0055] Figure 7 This is a structural block diagram of a flow table processing device in one embodiment;

[0056] Figure 8 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0057] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0058] It should be noted that the terms "first," "second," etc., used in this application may be used to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from the second element. The terms "comprising" and "having," and any variations thereof, used in this application, are intended to cover non-exclusive inclusion. The term "multiple" used in this application refers to two or more.

[0059] The flow table processing method provided in this application can be applied to, for example, Figure 1 In the application environment shown, when the host side 102 (CPU) determines a data packet to be sent, the forwarding thread of the hardware programmable processor 104, upon determining that the data packet does not match the fast path flow table, generates flow table data and writes the generated flow table data to the target cache block in the target cache space. The forwarding thread notifies the lookup engine of the write completion information, which instructs the lookup engine to configure the fast path flow table based on the flow table data written to the target cache block. The background thread of the hardware programmable processor 104 obtains the processing result of the lookup engine, releases the target cache block based on the processing result, and informs the forwarding thread of the released target cache block. This approach, placing flow table processing in the hardware programmable processor, is more efficient than software processing. Furthermore, the collaboration between the forwarding thread and the background thread in generating and configuring flow tables also improves flow table generation efficiency. That is, the forwarding thread only needs to create or update flow tables, while the background thread manages the flow tables. This achieves both flow table management and timely creation and updating, thereby improving flow table processing efficiency.

[0060] In one exemplary embodiment, such as Figure 2 As shown, a flow table processing method is provided, which can be applied to... Figure 1 Taking a hardware programmable processor as an example, the explanation includes the following steps S202 to S206. Wherein:

[0061] S202: If the forwarding thread determines that the data packet does not hit the fast path flow table, it generates flow table data and writes the generated flow table data into the target cache block of the target cache space.

[0062] In this application, slow path processing (i.e., flow table matching; corresponding fast path processing involves offloading forwarding logic to the network card via hardware offloading (e.g., SmartNIC, FPGA) or hardware acceleration technology (e.g., DPDK) to reduce CPU involvement) is offloaded to the network card's forwarding thread. This can be implemented, for example, through a hardware programmable processor (MPP). The MPP is a programmable processor based on the RISC-CV instruction set architecture and is not the main CPU running the operating system. This programmable processor includes a forwarding thread and a background thread. The forwarding thread generates the fast path flow table, while the background thread does not process packets but manages the target buffer space based on the flow table processing results from the lookup engine.

[0063] Upon receiving a data packet, it can be checked whether the data packet matches a specific fast path flow table. If it does, the data packet is processed through a fast path, i.e., it is forwarded through a fast path.

[0064] If a fast path flow table is not matched, it means that the flow table corresponding to the data packet does not exist, or the flow table corresponding to the data packet is a slow path flow table, or the version number of the flow table corresponding to the data packet has changed.

[0065] In some alternative embodiments, generating flow table data includes: generating flow table data for creating a new flow table when the data packet does not hit the slow path flow table; and generating flow table data for updating the slow path flow table when the data packet hits the slow path flow table.

[0066] Therefore, in this application, the forwarding thread continues to detect whether the data packet hits a certain slow path flow table in the slow path flow table. If it hits, the flow table data for updating the slow path flow table is generated. If it does not hit, the flow table data for creating a new fast path flow table is generated.

[0067] The flow table data can include a Key and a Result. The Key uniquely identifies the flow table corresponding to the flow table data and can include at least one of the following fields from the data packet: ingress port, source MAC address, destination MAC address, source IP address, destination IP address, IP protocol type, TCP / UDP source port, and TCP / UDP destination port. The Result represents the processing behavior of the data packet, such as forwarding, dropping, or modifying the packet header, etc., without specific limitations.

[0068] The target cache space is used to temporarily cache these flow table data; see [link / reference] for details. Figure 3 As shown, in some optional embodiments, the target cache space is a circular cache space. The pointers of the circular cache space include a first pointer pointing to the last target cache block that the forwarding thread has continuously filled, a second pointer pointing to the last target cache block that the background thread has released based on the processing result, and a third pointer pointing to the latest free target cache block allocated by the forwarding thread for writing flow table data.

[0069] Each time, the forwarding thread fills a stream table data into a cache block, which is the latest free cache block, and updates the first pointer pointing to the last target cache block that has been continuously filled. The background thread is used to release the target cache block filled by the forwarding thread based on the processing result of the query engine. Each time the background thread finishes processing, it informs the forwarding thread of the second pointer pointing to the last target cache block released by the background thread based on the processing result. Thus, the forwarding thread can update and obtain the third pointer pointing to the latest free target cache block used to write stream table data.

[0070] Specifically combined Figure 3 The first pointer, ReqPtr, represents the furthest position where the forwarding thread has completed continuous filling of Entries (i.e., cache blocks in the circular buffer space). The second pointer, RspPtr, represents the last Entry position where the background thread completed processing the TSE return information. The third pointer, AllocPtr, represents the latest free position allocated to the forwarding thread for filling the flow table information. The positional relationship along the data filling direction is: second pointer RspPtr, first pointer ReqPtr, and third pointer AllocPtr. Figure 3 The circular cache space provides 1024 cache blocks. In other embodiments, the number of cache blocks can also be other values, which will not be elaborated here. Each cache block corresponds to a flow table index. When creating a new flow table, the flow table index is assigned to the new flow table; when updating an old flow table, the flow table index of the old flow table is used, and the flow table index corresponding to the cache block is not updated.

[0071] S204: The forwarding thread notifies the lookup engine of the write completion information. The write completion information is used to instruct the lookup engine to configure the fast path flow table based on the flow table data written to the target cache block.

[0072] The lookup engine is used to configure fast path flow tables based on flow table data written to the target cache block, such as generating new fast path flow tables or updating slow path flow tables to fast path flow tables.

[0073] After writing the flow table data to the target cache block, the forwarding thread notifies the lookup engine of the writing completion information. This writing completion information can be generated by the forwarding thread based on the last processed second pointer RspPtr to the end of the first pointer ReqPtr. The lookup engine processes the flow table data in each target cache block sequentially from the last processed second pointer RspPtr to the end of the first pointer ReqPtr to configure the fast path flow table.

[0074] The forwarding process and the table lookup engine can communicate via Doorbell. Other communication methods can also be used in other embodiments, and no specific limitations are made here.

[0075] S206: The background thread obtains the processing result of the lookup engine, releases the target cache block based on the processing result, and informs the forwarding thread of the released target cache block.

[0076] The processing result of the lookup engine includes a data filling area formed from the second pointer RspPtr to the first pointer ReqPtr, specifically, the target cache block involved in the area from the second pointer RspPtr to the first pointer ReqPtr.

[0077] The background thread primarily releases the target cache space based on the processing results of the lookup engine. Specifically, the forwarding thread forms a data filling area from the second pointer RspPtr to the first pointer ReqPtr. After the lookup engine finishes processing, the background thread retrieves the processing results, releases the target cache block involved in the processing results, and informs the forwarding thread of the released target cache block, that is, informs the forwarding thread of the new free location so that the forwarding thread can write the flow table data to the target cache space next time.

[0078] The aforementioned flow table processing method is applied to a hardware programmable processor, which includes a forwarding thread and a background thread. Placing flow table processing on the hardware programmable processor results in higher efficiency compared to software processing. Furthermore, the method includes: when the forwarding thread determines that a data packet has not hit the fast path flow table, it generates flow table data and writes the generated flow table data to the target cache block in the target cache space; the forwarding thread notifies the lookup engine of the write completion information, which instructs the lookup engine to configure the fast path flow table based on the flow table data written to the target cache block; the background thread obtains the processing result from the lookup engine, releases the target cache block based on the processing result, and informs the forwarding thread of the released target cache block. In this way, the forwarding thread and the background thread collaborate to achieve flow table generation and configuration, improving flow table generation efficiency. That is, the forwarding thread only needs to create or update flow tables, while the background thread manages the flow tables. This achieves both flow table management and timely creation and updating, thereby improving flow table processing efficiency.

[0079] In some optional embodiments, before writing the generated flow table data into the target cache block of the target cache space, the method further includes: reading the second pointer and the third pointer of the target cache space; if it is determined based on the second pointer and the third pointer that there is a free target cache block in the target cache space, writing the generated flow table data into the target cache block of the target cache space; if it is determined based on the second pointer and the third pointer that there is no free target cache block in the target cache space, discarding the flow table data and not writing it into the target cache block.

[0080] In this application, a maximum threshold for filling the target cache space is set. If the threshold is exceeded, it means that the target cache space is full, that is, there is no free target cache block. The forwarding thread can no longer fill the flow table data into the target cache space. Appropriate background thread processing is required to release the corresponding free cache block.

[0081] Determining whether the target cache space is full, i.e. whether there are any free target cache blocks, can be based on pointers to the target cache space. For example, it can be based on the third pointer AllocPtr and the second pointer RspPtr. If AllocPtr – RspPtr >= the threshold, then the target cache space is considered to be full, i.e., there are no free target cache blocks. The threshold can be 0 or set to other values, such as 1, etc. There are no specific restrictions here, but it is just to make full use of the target cache space.

[0082] In the above embodiments, before placing the flow table data into the target cache space, the forwarding thread first determines whether there is a free target cache block in the target cache space, which can avoid write failure.

[0083] In some optional embodiments, writing the generated flow table data into the target cache block of the target cache space includes: if a token for the flow corresponding to the flow table data is obtained, writing the flow table data into the target cache block of the target cache space based on the token, wherein the token is used to rate limit the flow corresponding to the flow table data; if a token for the flow corresponding to the flow table data is not obtained, discarding the flow table data.

[0084] The token is mainly used to rate limit the flow, that is, to protect the filling of the target cache space by limiting the rate and avoid wasting cache blocks in the target cache space.

[0085] In this application, rate limiting for the flow is achieved using tokens. After generating flow table data, the forwarding thread acquires a token corresponding to that data. If a token cannot be acquired, the flow table data is discarded; otherwise, it is written to the target buffer block in the target buffer space. This means that the rate at which each forwarding process writes flow table data to the target buffer space is limited by tokens. Since a forwarding thread typically processes data packets from one flow, and given a large number of data packets in the flow, the flow table data corresponding to each data packet is not written to the target buffer space every time. Instead, rate limiting is performed based on tokens. This ensures that the target buffer space (RingBuffer) is not wasted and also prevents background thread processing performance from being impacted, as background threads do not need to continuously process the same flow table data across different target buffer blocks, reducing unnecessary processing.

[0086] In some alternative embodiments, before writing the generated flow table data to the target cache block of the target cache space, the method further includes: obtaining the target cache block determined by incrementing a counter, in the case that at least two forwarding threads write flow table data to the target cache space.

[0087] In this process, writing flow table data to the target cache space can be done simultaneously by multiple forwarding threads, meaning that concurrent writing by multiple forwarding threads is supported. When multiple threads' flow table data are received in the target cache space, the target cache block corresponding to each forwarding thread is determined by incrementing a counter. For example, if there are three forwarding threads: the first forwarding thread, the second forwarding thread, and the third forwarding thread, then target cache block 4 is assigned to the first forwarding thread, target cache block 5 is assigned to the second forwarding thread, and target cache block 6 is assigned to the third forwarding thread. This allows different forwarding threads to write flow table data to different cache blocks in the target cache space simultaneously, speeding up the processing efficiency of slow paths. Furthermore, by incrementing the write position using a counter, it is ensured that the target cache blocks obtained by different forwarding threads do not conflict.

[0088] In some optional embodiments, notifying the lookup engine of the write completion includes: acquiring the lookup engine's lock privileges; updating the first pointer based on the first pointer and the target cache blocks that have been continuously filled by each forwarding thread; sending the updated first pointer to the lookup engine, and releasing the lookup engine's lock privileges after successful transmission.

[0089] Only one of the different forwarding threads can acquire the lock permission of the lookup engine's doorbell at any given time. That is, only one forwarding thread's doorbell sent to the lookup engine will be responded to, notifying the lookup engine (hardware) to process the flow table. Therefore, the doorbell sent in this application by locking ensures that the forwarding threads do not conflict.

[0090] When a forwarding thread sends a doorbell to the lookup engine, it updates the first pointer ReqPtr, which points to the furthest position that has been continuously filled, to the lookup engine. Therefore, the forwarding thread needs to determine how many Entry data (target cache blocks) all forwarding threads have continuously filled since the last position pointed to by the first pointer ReqPtr, and report this information to the lookup engine. In other words, based on the last target cache block that the forwarding thread has continuously filled, and the target cache blocks that each forwarding thread has continuously filled, the last target cache block that has been continuously filled is updated. This allows the lookup engine to obtain the latest last target cache block that has been continuously filled. After successful transmission, the forwarding thread releases the lock on the lookup engine to allow other forwarding threads to process it. If a forwarding thread finds that the target cache block it is filling has already been reported by another forwarding thread, it abandons this reporting attempt. That is, it determines whether a report has already been made based on the last position of the first pointer ReqPtr and the target cache blocks that the forwarding thread has continuously filled; if it has, there is no need to report it again.

[0091] In the above embodiments, parallel processing of multiple forwarding threads is supported, and the lock permissions of the lookup engine are set to avoid processing conflicts of the lookup engine.

[0092] In some optional embodiments, each cache block in the target cache space corresponds to a flow table index; writing the generated flow table data into the target cache block of the target cache space includes: when the flow table data is used to create a new flow table, writing the flow table data into the target cache block based on the flow table index corresponding to the target cache block; when the flow table data is used to update a slow path flow table, writing the flow table data into the target cache block based on the flow table index corresponding to the slow path flow table.

[0093] In this application, if a new fast path flow table is created, the flow table index corresponding to the target cache block needs to be obtained. The flow table index corresponding to the target cache block is pre-allocated by the background thread. If it is an update operation of the slow path flow table, since the corresponding flow table index has already been created when the slow path flow table is generated, it is not necessary to use the flow table index of the target cache block. Only the flow table index of the slow path flow table is reused, and no additional free index is required. The background thread also does not need to allocate the flow table index again.

[0094] For ease of understanding, combined with Figure 4 , Figure 4 This is a flowchart of the flow table data filling step of the forwarding thread in one embodiment. In this embodiment, the forwarding process first performs a flow table lookup, that is, determines whether the data packet hits the fast path flow table. If it hits, a version comparison is performed. If the version comparison passes, the data packet is processed according to the fast path flow table with the correct version.

[0095] If there is no hit, or the version comparison fails, or the slow path flow table is hit or not hit, then flow table data needs to be generated. If neither the fast path flow table nor the slow path flow table is hit, then the remaining flow table data is used to create a new fast path flow table. If the version comparison fails or the slow path flow table is hit, then update flow table data is generated.

[0096] The process reads the second and third pointers of the target cache space. Based on these pointers, it determines whether the target cache space is full. If it is full, it waits for the background thread to process. If it is not full, it performs flow rate limiting, which restricts the rate at which the flow table data corresponding to this flow is written to the target cache space. If the flow rate limiting passes, it acquires the third pointer AllocPtr to determine the target cache block, and then writes the flow table data into the target cache block. After writing, it acquires the lock permission of the query engine's doorbell. If the lock permission acquisition fails, the process ends. If the lock permission acquisition succeeds, it notifies the query engine of the location of the target cache block through the doorbell, i.e., after writing the first pointer ReqPtr to the location, it releases the lock permission of the doorbell.

[0097] In some optional embodiments, the background thread obtains the processing result of the lookup engine, releases the target cache block based on the processing result, and informs the forwarding thread of the released target cache block. This includes: the background thread periodically obtaining the processing result of the lookup engine; if the last target cache block pointed to by the second pointer is different from the current target cache block to be processed by the background thread; obtaining the flow table processing result of the current target cache block to be processed by the background thread; if the flow table processing result of the current target cache block to be processed by the background thread is to create a new flow table, allocating a new flow table index to the current target cache block and updating the current target cache block to be processed by the background thread; if the flow table processing result of the current target cache block to be processed by the background thread is to update the slow path flow table, updating the current target cache block to be processed by the background thread; and if the target cache block pointed to by the second pointer is the same as the current target cache block to be processed by the background thread, informing the forwarding thread of the second pointer.

[0098] Among them, combined Figure 5 As shown, Figure 5 This is a flowchart of the background thread flow table processing steps in one embodiment. In this embodiment, the background thread processes the flow table information in the target buffer space RingBuffer, maintains the flow table index, and notifies the forwarding thread of the location pointed to by the second pointer RspPtr after the query engine has finished processing.

[0099] The processing results caused by the periodic scanning query of the background thread, such as querying once every 1 second, can be set to other values ​​in other embodiments, and no specific limitation is made here.

[0100] If the second pointer RspPtr pointing to the last target cache block is the same as the current target cache block LastRspPtr that the background thread is to process, then the second pointer RspPtr is updated for use by the programmable processor's forwarding thread.

[0101] If the second pointer RspPtr pointing to the last target cache block is different from the LastRspPtr of the current target cache block to be processed by the background thread, then the processing result of the LastRspPtr of the current target cache block to be processed by the background thread is obtained. If the creation of a new fast path flow table is successful, it means that the index of the target cache block has been used. Therefore, the background thread allocates a new flow table index to the current target cache block. If it is not adding a new fast path flow table, but only updating the flow table, then there is no need to update the flow table index of the current target cache block, and the next target cache block is processed until the processing is completed. That is, the second pointer RspPtr pointing to the last target cache block is the same as the LastRspPtr of the current target cache block to be processed by the background thread.

[0102] For ease of understanding, combined with Figure 6 As shown, Figure 6 In one embodiment, a service collaboration graph is created for the flow table. In this embodiment, while the hardware programmable processor is processing slow path services, for packets where the fast path flow table cannot be found and packets where the flow table version does not match, the key and result of the flow table are constructed, and the flow table data (key, result) is written into the target buffer space RingBuffer.

[0103] After the query triggers TSE to write flow table data to the target buffer RingBuffer in the forwarding thread, it processes the flow table data in the target buffer RingBuffer, performing flow table addition or update operations. The background thread processes the results returned by TSE in the target buffer, maintains the Entry index of each buffer block, and updates the second pointer RspPtr to the forwarding thread.

[0104] The target buffer, RingBuffer, requires three pointers to maintain data consistency; see the pointers section above for details. The forwarding thread notifies the query engine (TSE) to process the flow table by knocking the doorbell. The TSE processing result is obtained by the background thread reading the TSE's processing result (Response) and notifying the forwarding thread of the completed position. The background thread needs to maintain the flow table index and provide it to the forwarding thread.

[0105] In the above embodiments, the CPU usage of the control plane is reduced, the performance of slow path processing is improved, and the efficiency of fast path flow table generation is increased.

[0106] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps. It is understood that the steps in different embodiments can be freely combined as needed, and all non-contradictory solutions formed by such combinations are within the scope of protection of this application.

[0107] Based on the same inventive concept, this application also provides a flow table processing apparatus for implementing the flow table processing method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more flow table processing apparatus embodiments provided below can be found in the limitations of the flow table processing method described above, and will not be repeated here.

[0108] In one exemplary embodiment, such as Figure 7 As shown, a flow table processing device is provided, applied to a hardware programmable processor. The hardware programmable processor includes a forwarding thread and a background thread, comprising: a forwarding module 701, a flow table configuration module 702, and a cache processing module 703, wherein:

[0109] The forwarding module 701 is used to generate flow table data when the forwarding thread determines that the data packet does not hit the fast path flow table; and write the generated flow table data into the target cache block of the target cache space.

[0110] The flow table configuration module 702 is used to notify the lookup engine of the write completion information through the forwarding thread. The write completion information is used to instruct the lookup engine to configure the fast path flow table based on the flow table data written to the target cache block.

[0111] The cache processing module 703 is used to obtain the processing result of the lookup engine through the background thread, release the target cache block based on the processing result, and inform the forwarding thread of the released target cache block.

[0112] In some optional embodiments, the target cache space is a circular cache space, and the pointers of the circular cache space include a first pointer pointing to the last target cache block that the forwarding thread has continuously filled, a second pointer pointing to the last target cache block that the background thread has released based on the processing result, and a third pointer pointing to the latest free target cache block allocated by the forwarding thread for writing flow table data.

[0113] In some optional embodiments, the forwarding module 701 is further configured to read the second pointer and the third pointer of the target cache space; if it is determined based on the second pointer and the third pointer that there is a free target cache block in the target cache space, write the generated flow table data into the target cache block of the target cache space; if it is determined based on the second pointer and the third pointer that there is no free target cache block in the target cache space, discard the flow table data and do not write it into the target cache space.

[0114] In some optional embodiments, the forwarding module 701 is further configured to, if a token corresponding to the flow table data is obtained, write the flow table data into the target cache block of the target cache space based on the token, the token being used to rate limit the flow corresponding to the flow table data; if a token corresponding to the flow table data is not obtained, discard the flow table data.

[0115] In some optional embodiments, the forwarding module 701 is further configured to obtain the target cache block determined by incrementing a counter when at least two forwarding threads write flow table data to the target cache space.

[0116] In some optional embodiments, the forwarding module 701 is further configured to acquire the lock privileges of the lookup engine; update the first pointer based on the first pointer and the target cache blocks that have been continuously filled by each forwarding thread; send the updated first pointer to the lookup engine; and release the lock privileges of the lookup engine after successful transmission.

[0117] In some optional embodiments, the forwarding module 701 is further configured to generate flow table data for creating a new flow table when the data packet does not hit the slow path flow table; and to generate flow table data for updating the slow path flow table when the data packet does not hit the slow path flow table.

[0118] In some optional embodiments, each cache block of the target cache space corresponds to a flow table index; the forwarding module 701 is further configured to write flow table data into the target cache block based on the flow table index corresponding to the target cache block when the flow table data is used to create a new flow table; and to write flow table data into the target cache block based on the flow table index corresponding to the slow path flow table when the flow table data is used to update the slow path flow table.

[0119] In some optional embodiments, the cache processing module 703 is further configured to periodically obtain the processing results of the lookup engine through a background thread; if the last target cache block pointed to by the second pointer is different from the current target cache block to be processed by the background thread; obtain the flow table processing result of the current target cache block to be processed by the background thread; if the flow table processing result of the current target cache block to be processed by the background thread is to create a new flow table, allocate a new flow table index to the current target cache block and update the current target cache block to be processed by the background thread; if the flow table processing result of the current target cache block to be processed by the background thread is to update the slow path flow table, update the current target cache block to be processed by the background thread; and if the target cache block pointed to by the second pointer is the same as the current target cache block to be processed by the background thread, inform the forwarding thread of the second pointer.

[0120] Each module in the aforementioned flow table processing device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.

[0121] In one exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 8 As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface, such as a network interface card (NIC), is used for wired or wireless communication with external terminals. Wireless communication can be achieved through Wi-Fi, mobile cellular networks, Near Field Communication (NFC), or other technologies. When the computer program is executed by the processor, it implements a flow table processing method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.

[0122] Those skilled in the art will understand that Figure 8 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0123] In one exemplary embodiment, a chip is provided, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps of the method in any of the above embodiments.

[0124] In one exemplary embodiment, a network interface card is provided, including a chip as described in any of the above embodiments and multiple interfaces, through which the chip processes data or communicates externally.

[0125] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.

[0126] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.

[0127] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0128] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.

[0129] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0130] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A flow table processing method, characterized in that, Applied to a hardware programmable processor, the hardware programmable processor including a forwarding thread and a background thread, the method includes: If the forwarding thread determines that the data packet does not hit the fast path flow table, it generates flow table data and writes the generated flow table data into the target cache block of the target cache space. The forwarding thread notifies the lookup engine of the write completion information, which is used to instruct the lookup engine to configure a fast path flow table based on the flow table data written to the target cache block. The background thread obtains the processing result of the lookup engine, releases the target cache block based on the processing result, and informs the forwarding thread of the released target cache block.

2. The method according to claim 1, characterized in that, The target cache space is a circular cache space. The pointers of the circular cache space include a first pointer pointing to the last target cache block that the forwarding thread has continuously filled, a second pointer pointing to the last target cache block released by the background thread based on the processing result, and a third pointer pointing to the latest free target cache block allocated by the forwarding thread for writing the flow table data.

3. The method according to claim 2, characterized in that, Before writing the generated flow table data into the target cache block of the target cache space, the method further includes: Read the second pointer and the third pointer of the target cache space; If, based on the second pointer and the third pointer, it is determined that there is a free target cache block in the target cache space, the generated flow table data is written into the target cache block of the target cache space; If, based on the second pointer and the third pointer, it is determined that there is no free target cache block in the target cache space, the flow table data is discarded and not written to the target cache space.

4. The method according to claim 1 or 2, characterized in that, The step of writing the generated flow table data into the target cache block of the target cache space includes: If a token corresponding to the flow table data is obtained, the flow table data is written to the target cache block of the target cache space based on the token. The token is used to rate limit the flow corresponding to the flow table data. If no token for the flow corresponding to the flow table data is obtained, the flow table data is discarded.

5. The method according to claim 1 or 2, characterized in that, Before writing the generated flow table data into the target cache block of the target cache space, the method further includes: When at least two of the forwarding threads write the flow table data to the target cache space, the target cache block determined by incrementing a counter is obtained.

6. The method according to claim 2, characterized in that, The notification to the table lookup engine that the write is complete includes: Obtain lock permissions for the table lookup engine; Update the first pointer based on the first pointer and the target cache blocks that have been continuously filled by each of the forwarding threads; The updated first pointer is sent to the lookup engine, and upon successful transmission, the lock permissions of the lookup engine are released.

7. The method according to claim 1 or 2, characterized in that, The generated flow table data includes: If the data packet does not hit the slow path flow table, flow table data is generated for creating a new flow table; If the data packet hits the slow path flow table, flow table data is generated to update the slow path flow table.

8. The method according to claim 7, characterized in that, Each cache block in the target cache space corresponds to a flow table index; writing the generated flow table data into the target cache block of the target cache space includes: When the flow table data is used to create a new flow table, the flow table data is written to the target cache block based on the flow table index corresponding to the target cache block; When the flow table data is used to update the slow path flow table, the flow table data is written to the target cache block based on the flow table index corresponding to the slow path flow table.

9. The method according to claim 2, characterized in that, The background thread obtains the processing result of the lookup engine, releases the target cache block based on the processing result, and informs the forwarding thread of the released target cache block, including: The background thread periodically retrieves the processing results from the lookup engine; If the target cache block pointed to by the second pointer is different from the current target cache block to be processed by the background thread; Obtain the flow table processing result of the current target cache block to be processed by the background thread; If the result of the flow table processing of the current target cache block to be processed by the background thread is to create a new flow table, a new flow table index is allocated to the current target cache block, and the current target cache block to be processed by the background thread is updated. If the result of the flow table processing of the current target cache block to be processed by the background thread is to update the slow path flow table, then update the current target cache block to be processed by the background thread. If the target cache block pointed to by the second pointer is the same as the current target cache block to be processed by the background thread, the second pointer is informed to the forwarding thread.

10. A flow meter processing device, characterized in that, Applied to a hardware programmable processor, the hardware programmable processor including a forwarding thread and a background thread, the device includes: The forwarding module is used to generate flow table data when the forwarding thread determines that the data packet does not hit the fast path flow table; and to write the generated flow table data into the target cache block of the target cache space. The flow table configuration module is used to notify the lookup engine of write completion information through the forwarding thread. The write completion information is used to instruct the lookup engine to configure a fast path flow table based on the flow table data written to the target cache block. The cache processing module is used to obtain the processing result of the lookup engine through the background thread, release the target cache block based on the processing result, and inform the forwarding thread of the released target cache block.

11. A chip comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 9.

12. A network interface card, characterized in that, Includes the chip as described in claim 11 and multiple interfaces. The chip processes data or communicates with the outside world through the interface.

13. A computer device, characterized in that, Includes the network interface card as described in claim 12, wherein the network interface card is used for processing data or external communication.

14. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 9.

15. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Forwarding rule issuing method, intelligent network card and storage medium

    CN115460145A

  • Message forwarding method and device, computing equipment and unloading card

    CN115567446A