A method and device for counting flow table rules of data packets of a network card

By generating a bitmap image and requesting hit flow table statistical results within the preset time period, the problem of inefficient flow table rules statistics in the prior art is solved, and more efficient flow table rules statistics and hardware response are achieved.

CN116366521BActive Publication Date: 2024-11-26CHINA TELECOM CLOUD TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211711655.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-29
Publication Date
2024-11-26
Estimated Expiration
2042-12-29

AI Technical Summary

Technical Problem

The prior art is inefficient when stating the flow table rules of network cards, especially when there are only a few hits in a large number of flow tables, and it is necessary to frequently request and process meaningless statistical counts, resulting in large amount of data for software and hardware interaction and logic consumption. excessive.

Method used

By determining the three-level flow table Dpcls of the data packet and configuring the reverifier thread and bitmap image cache, the bitmap image is generated to statistical flow table rules, and only the hit flow table statistical results are requested within the preset time period, reducing Meaningless flow table processing and hardware response.

Benefits of technology

It improves the efficiency of flow table rules statistics, reduces the amount of packet data and hardware processing logic for software and hardware interaction, and improves the response speed of statistical results and the software update performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116366521B_ABST
    Figure CN116366521B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention provides a method and device for counting flow table rules for data packets of a network card, by determining a three-level flow table Dpcls of a flow table OVS Datapath to be unloaded for the data packet; configuring a corresponding revalidator thread OVS Revalidator and a bitmap image cache for the statistical thread; generating a bitmap image for the flow table rules, and storing the bitmap image in the bitmap image cache; and counting the flow table rules for the data packet based on the three-level flow table Dpcls and the bitmap image by the revalidator thread OVS Revalidator, thereby achieving statistics on the flow table rules of multiple data packets, thereby improving the efficiency of flow table rule statistics for the data packets of the network card.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of flow table rule statistics for data packets of a network card, and in particular to a flow table rule statistics method for data packets of a network card, a flow table rule statistics device for data packets of a network card, a network card, an electronic device and a computer-readable storage medium. Background Art

[0002] There is a hardware flow table in the hardware of the smart network card. When a data packet fails to match the hardware flow table, it will be sent to the software OVS to generate flow table rules. The flow table rules include a match field and an action field. The match field consists of the packet message information, and the action field specifies the action that the packet should perform. After the generated flow table rules are converted and written into the hardware, the data packet matches the hardware flow table and is directly forwarded, which can achieve hardware unloading.

[0003] Therefore, how to improve the statistical efficiency of flow table rules for data packets of a network card has become a technical problem that those skilled in the art need to overcome. Summary of the invention

[0004] The embodiment of the present invention provides a method, device, electronic device and computer-readable storage medium for counting flow table rules of data packets of a network card, so as to solve the problem of how to improve the efficiency of counting flow table rules of data packets of a network card.

[0005] The embodiment of the present invention discloses a method for counting flow table rules of data packets of a network card, wherein the network card has a corresponding counting thread, including:

[0006] Determine a third-level flow table Dpcls of the flow table OVS Datapath to be offloaded for the data packet;

[0007] Configure a corresponding revalidator thread OVS Revalidator and a bitmap image cache for the statistical thread;

[0008] generating a bitmap image for the flow table rule, and storing the bitmap image in the bitmap image cache;

[0009] The flow table rules for the data packet are counted based on the three-level flow table Dpcls and the bitmap image by the revalidator thread OVS Revalidator.

[0010] Optionally, the step of generating a bitmap image for the flow table rule may include:

[0011] When the data packet hits the native flow table rule corresponding to the data packet, a bitmap image for the flow table rule is generated.

[0012] Optionally, the step of counting the flow table rules for the data packet based on the three-level flow table Dpcls and the bitmap image by the revalidator thread OVS Revalidator may include:

[0013] Constructing a pointer array associated with the third-level flow table Dpcls in the revalidator thread OVS Revalidator;

[0014] Merging the bitmap images to generate a bitmap image result;

[0015] The flow table rules for the data packet are counted based on the pointer array and the bitmap image results by the revalidator thread OVS Revalidator.

[0016] Optionally, the bitmap image result has a corresponding position identifier, and may also include:

[0017] Acquire a flow table ID corresponding to the location identifier according to a preset time period;

[0018] An ID list is constructed based on the flow table ID.

[0019] Optionally, the step of counting flow table rules for the data packet based on the pointer array and the bitmap image result by the revalidator thread OVS Revalidator may include:

[0020] Sending a statistics request message including the ID list to the network card to control the network card to generate a flow table rule statistics result list for the target flow table rule based on the ID list;

[0021] Receive the flow table rule statistical result list, and generate statistical results for the target flow table rule based on the flow table rule statistical result list;

[0022] The statistical result is updated to the revalidator thread OVS Revalidator through the pointer array.

[0023] Optionally, it may also include:

[0024] Control the network card to reset the bitmap image.

[0025] The embodiment of the present invention further discloses a flow table rule statistics device for data packets of a network card, wherein the network card has a corresponding statistics thread, which may include:

[0026] A third-level flow table Dpcls determination module, used to determine the third-level flow table Dpcls of the flow table OVS Datapath to be offloaded for the data packet;

[0027] A revalidator thread OVS Revalidator and a bitmap image cache configuration module, used to configure a corresponding revalidator thread OVS Revalidator and a bitmap image cache for the statistical thread;

[0028] A bitmap image generation module, used for generating a bitmap image for the flow table rule, and storing the bitmap image in the bitmap image cache;

[0029] A flow table rule statistics module is used to count the flow table rules for the data packet based on the three-level flow table Dpcls and the bitmap image through the revalidator thread OVS Revalidator.

[0030] Optionally, the bitmap image generation module may include:

[0031] The bitmap image generation submodule is used to generate a bitmap image for the flow table rule when the data packet hits the native flow table rule corresponding to the data packet.

[0032] Optionally, the flow table rule statistics module may include:

[0033] A pointer array construction submodule, used to construct a pointer array associated with the third-level flow table Dpcls in the revalidator thread OVS Revalidator;

[0034] A bitmap image result generation submodule, used for merging the bitmap images to generate a bitmap image result;

[0035] The flow table rule statistics submodule is used to count the flow table rules for the data packet based on the pointer array and the bitmap image results through the revalidator thread OVS Revalidator.

[0036] Optionally, the bitmap image result has a corresponding position identifier, and may also include:

[0037] A flow table ID acquisition submodule, used to acquire a flow table ID corresponding to the location identifier according to a preset time period;

[0038] The ID list construction submodule is used to control the network card to construct an ID list based on the flow table ID.

[0039] Optionally, the flow table rule statistics submodule may include:

[0040] A statistics request information sending unit, used to send statistics request information to the network card to control the network card to generate a flow table rule statistics result list for the target flow table rule based on the ID list;

[0041] A flow table rule statistics result list receiving unit, used to receive the flow table rule statistics result list, and generate statistics for the target flow table rule based on the flow table rule statistics result list;

[0042] The flow table rule statistics unit is used to update the statistical results to the revalidator thread OVS Revalidator through the pointer array.

[0043] Optionally, it may also include:

[0044] The bitmap image resetting submodule is used to control the network card to reset the bitmap image.

[0045] The embodiment of the present invention further discloses a network card, wherein the network card is configured with a flow table rule statistics system for data packets of the network card, and the flow table rule statistics system is used to implement the method described in the embodiment of the present invention.

[0046] The embodiment of the present invention further discloses an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;

[0047] The memory is used to store computer programs;

[0048] The processor is used to implement the method described in the embodiment of the present invention when executing the program stored in the memory.

[0049] The embodiment of the present invention further discloses a computer-readable storage medium having instructions stored thereon, which, when executed by one or more processors, enables the processors to execute the method described in the embodiment of the present invention.

[0050] The embodiments of the present invention include the following advantages:

[0051] According to an embodiment of the present invention, a three-level flow table Dpcls of the flow table OVS Datapath to be offloaded for the data packet is determined; a corresponding revalidator thread OVS Revalidator and a bitmap image cache are configured for the statistical thread; a bitmap image for the flow table rules is generated, and the bitmap image is stored in the bitmap image cache; and the flow table rules for the data packet are counted based on the three-level flow table Dpcls and the bitmap image by the revalidator thread OVS Revalidator, thereby realizing that the flow table rules of multiple data packets can be counted, thereby improving the efficiency of flow table rule statistics for the data packets of the network card. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] Figure 1It is a flow chart of the steps of a method for counting flow table rules of data packets of a network card provided in an embodiment of the present invention;

[0053] Figure 2 is a schematic diagram for a pointer array provided in an embodiment of the present invention;

[0054] Figure 3 It is a schematic diagram of a statistical result list for an ID list and a flow table rule provided in an embodiment of the present invention;

[0055] Figure 4 It is a structural diagram of a flow table rule statistics system provided in an embodiment of the present invention;

[0056] Figure 5 It is a structural block diagram of a flow table rule statistics device for data packets of a network card provided in an embodiment of the present invention;

[0057] Figure 6 It is a hardware structure block diagram of an electronic device provided in each embodiment of the present invention. DETAILED DESCRIPTION

[0058] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0059] In actual applications, the first few data packets of the existing smart network card that need to be connected by the communication protocol are sent to the software first, and the corresponding hardware flow table rules are generated on the software side, and then unloaded to the hardware, and then the hardware matching and forwarding are performed. After unloading to the hardware, the software still needs to obtain the corresponding flow table statistics from the hardware in real time, including the number of forwarded packets and forwarded bytes of each flow table rule, so as to support the upper-layer services in cloud computing, such as real-time traffic monitoring of virtual machines.

[0060] The related technology uses a method of periodically traversing the hardware flow table in full and one by one to obtain the statistical results of the uninstalled hardware flow table. The principle of periodically traversing the hardware flow table in full and one by one is:

[0061] The software maintains all the flow tables that have been uninstalled. The software OVS Revalidator thread periodically (for example, every 500ms) traverses all the flow tables in full, and obtains the hardware-side statistical counts of all the flow tables that have been uninstalled to the hardware through the hardware interface in turn.

[0062] The following problems may occur when the related technology collects statistics on flow table rules:

[0063] 1) The OVS Revalidator thread needs to request the statistical counts of all hardware flow tables in turn. Even if there is no data packet coming to this flow table in the hardware during the aging period (such as 10s), it is necessary to request the statistical count of the flow table every 500ms. The response content includes the ID of each flow table, the number of hit packets and the number of hit bytes. When there are many flow tables in the hardware and relatively few flow tables are actually hit during the traversal cycle, for example, only a few flow tables are hit out of 4 million flow tables, then every 500ms traversal will contain too much meaningless flow table processing. Even if the flow table hit count is 0, the statistical count update of the flow table needs to be processed.

[0064] 2) In the existing statistical method, the software sends the IDs of all flow tables to the hardware, and the hardware returns the statistical counts of these flow tables, which also increases the amount of data carried by these interactions between the software and the hardware. Even when the number of hardware flow tables is large, multiple requests for response are required to obtain all flow table statistics. Taking 4 million flow tables as an example, each flow table ID is 32 bits, the byte statistics count and the message count statistics are both 64 bits, and when the message MTU is 1500, 4000000÷(1500÷(4+8+8))=53333 response messages are required to return the statistical results of all flow tables. In fact, only a few flow tables may be hit in the current cycle, and only the statistics of these flow tables need to be updated and reported.

[0065] 3) For miss messages, the hardware also needs to report a statistical result with a value of 0, which unnecessarily consumes hardware processing logic.

[0066] Therefore, as one of the core invention points of the embodiment of the present invention, on the basis of not modifying the OVS flow table statistics traversal, according to the flow table hit bit map reported by the current hardware flow table, only the statistical results of the flow table that has hit in the current cycle can be requested from the hardware, so that the software and hardware can complete the statistical result reporting in as few round-trip messages as possible, while avoiding the software processing the flow table statistical results that have not hit in the current cycle, reducing the software and hardware traffic exchange, reducing the processing logic of the hardware sending statistical results, and improving the performance of the software updating the flow table statistical results.

[0067] Reference Figure 1 , shows a flow chart of a method for counting flow table rules of packets of a network card provided in an embodiment of the present invention, which may specifically include the following steps:

[0068] Step 101, determining a third-level flow table Dpcls of the flow table OVS Datapath to be offloaded for the data packet;

[0069] Step 102, configuring a corresponding revalidator thread OVS Revalidator and a bitmap image cache for the statistical thread;

[0070] Step 103, generating a bitmap image for the flow table rule, and storing the bitmap image in the bitmap image cache;

[0071] Step 104: The revalidator thread OVS Revalidator counts the flow table rules for the data packet based on the three-level flow table Dpcls and the bitmap image.

[0072] In a specific implementation, the embodiment of the present invention can be applied to a flow table rule statistics system for data packets of a network card. The flow table rule statistics system of the embodiment of the present invention can be integrated into the network card. The flow table rule statistics system of the embodiment of the present invention may include a statistics thread and a revalidator thread OVS Revalidator.

[0073] In practical applications, KVM (kernel-based virtual machine) is a complete virtualization solution. Using KVM, you can run multiple virtual machines of unmodified Linux or Windows images, each of which has its own virtualized hardware: network card, disk, graphics adapter, etc.

[0074] The network card in the embodiment of the present invention may be a smart network card, which may include but is not limited to a smart network card loaded in a KVM virtual machine.

[0075] In practical applications, OVS-DPDK: DPDK is a collection of libraries and drivers for fast processing of messages on the X86 platform. OVS (OpenvSwitch) has been widely used in cloud environments as a multi-layer virtual switch with its rich functions. The main function of OpenvSwitch is to provide Layer 2 network access for VMs on physical machines, and work in parallel with other physical switches in the cloud environment at Layer 2. Traditional host ovs works in kernel mode, and data transmission with guest virtio requires multiple kernel mode and user mode data switching, which brings performance bottlenecks.

[0076] The third-level flow table Dpcls is the name of the megaflow flow table in OVS-DPDK in the OVS-DPDK code. The embodiment of the present invention can determine the third-level flow table Dpcls of the flow table OVS Datapath to be offloaded for the data packet.

[0077] A bitmap image, also known as a dot matrix image or a raster image, is composed of a single point called a pixel (picture element). The bitmap image cache of the embodiment of the present invention can be used to cache the bitmap image.

[0078] An embodiment of the present invention can configure a corresponding revalidator thread OVS Revalidator and a bitmap image cache for the statistical thread, mark the flow table rules for multiple data packets respectively to generate corresponding bitmap images, and store them in the bitmap image cache, and use the revalidator thread OVS Revalidator to count the flow table rules for the data packets based on the three-level flow table Dpcls and the bitmap image.

[0079] For example, when data packet A corresponds to flow table rule 1 and data packet B corresponds to flow table rule 2, when data packet A and data packet B interact with flow table rule 1 and flow table rule 2 respectively, the network card can be controlled to generate bitmap image 1 for flow table rule 1 and bitmap image 2 for flow table rule 2. After determining the bitmap image and bitmap image, the flow table rules for data packet 1 and data packet 2 can be counted based on the three-level flow table Dpcls and bitmap image 1 and bitmap image 2 through the revalidator thread OVS Revalidator.

[0080] According to an embodiment of the present invention, a three-level flow table Dpcls of the flow table OVS Datapath to be offloaded for the data packet is determined; a corresponding revalidator thread OVS Revalidator and a bitmap image cache are configured for the statistical thread; a bitmap image for the flow table rules is generated, and the bitmap image is stored in the bitmap image cache; and the flow table rules for the data packet are counted based on the three-level flow table Dpcls and the bitmap image by the revalidator thread OVS Revalidator, thereby realizing statistics on the flow table rules of multiple data packets, thereby improving the efficiency of flow table rule statistics for the data packets of the network card.

[0081] Based on the above embodiment, a variant embodiment of the above embodiment is proposed. It should be noted that in order to make the description concise, only the differences from the above embodiment are described in the variant embodiment.

[0082] In an optional embodiment of the present invention, the step of generating a bitmap image for the flow table rule includes:

[0083] When the data packet hits the native flow table rule corresponding to the data packet, a bitmap image for the flow table rule is generated.

[0084] In the specific implementation, a full traversal of all flow tables will lead to data redundancy, which in turn leads to low statistical efficiency and waste of computing power. For example, for missed packets, the hardware also needs to report a statistical result with a value of 0, which unnecessarily consumes hardware processing logic.

[0085] The embodiment of the present invention can generate a bitmap image for the flow table rule when the data packet hits the native flow table rule corresponding to the data packet to avoid full statistical bitmap image, thereby further improving the statistical efficiency of the flow table rule for the data packet of the network card.

[0086] For example, the SmartNIC maintains a hit bitmap BITMAP to express all flow tables offloaded to the SmartNIC hardware. The bits correspond to the flow tables in the hardware one by one. When a data packet enters the SmartNIC and matches and hits the flow table FlOW_A, the statistics of the flow table FlOW_A are updated. A bitmap image for the data packet and FlOW_A is generated in the hit bitmap of the SmartNIC.

[0087] In an optional embodiment of the present invention, the step of counting the flow table rules for the data packet based on the three-level flow table Dpcls and the bitmap image by the revalidator thread OVS Revalidator includes:

[0088] Constructing a pointer array associated with the third-level flow table Dpcls in the revalidator thread OVS Revalidator;

[0089] Merging the bitmap images to generate a bitmap image result;

[0090] The flow table rules for the data packet are counted based on the pointer array and the bitmap image results by the revalidator thread OVS Revalidator.

[0091] refer to Figure 2 , Figure 2 It is a schematic diagram for a pointer array provided in an embodiment of the present invention. The embodiment of the present invention can maintain a pointer to Dpcls in the DPDK statistics thread for all OVS Datapath flow tables Dpcls unloaded to hardware, that is, the Dpcls pointer array Dpcls_Pointer_Array, and each item in the pointer array corresponds one-to-one to the flow table actually unloaded to the hardware.

[0092] The smart network card of the embodiment of the present invention can report the current BITMAP status to the flow table rule statistics system according to a preset period, such as BITMAP_A, BITMAP_B, BITMAP_C, etc., and then the flow table rule statistics system can merge the bitmap images to generate a bitmap image result BITMAP_RESULT.

[0093] After generating the bitmap image result, the embodiment of the present invention can use the bitmap image result to determine the statistical result for the flow table rule, and update the statistical result to the revalidator thread OVS Revalidator through the pointer array to complete the statistics of the flow table rule for the data packet.

[0094] In an optional embodiment of the present invention, the bitmap image result has a corresponding position identifier, and further includes:

[0095] Acquire a flow table ID corresponding to the location identifier according to a preset time period;

[0096] An ID list is constructed based on the flow table ID.

[0097] In the specific implementation, the bitmap icon result is only used to express the flow table rules related to one or more data packets and cannot be directly used as statistical data.

[0098] The bitmap image result BITMAP_RESULT of the embodiment of the present invention can have a corresponding location identifier, and the flow table rule statistics system can obtain the flow table ID corresponding to the location identifier according to a preset time period, and then control the network card to build an ID list FLOW_ID_LIST based on the flow table ID, wherein the flow table ID can be used to mark the flow table rules that the data packet matches and hits.

[0099] Exemplarily, the statistics thread in the DPDK can calculate the flow table ID corresponding to the bit position 1 according to the current BITMAP_RESULT in a preset time period, and obtain a list FLOW_ID_LIST of these flow table IDs.

[0100] In an embodiment of the present invention, a flow table ID corresponding to the location identifier is obtained according to a preset time period; an ID list is constructed based on the flow table ID, and a bitmap icon result that cannot be directly used as a statistical result is converted into an ID list, thereby laying a foundation for requesting the statistical results of the most recently hit flow table from the network card according to the bit map sent by the network card in the OVS-DPDK statistical thread.

[0101] In an optional embodiment of the present invention, the step of counting the flow table rules for the data packet based on the pointer array and the bitmap image result by the revalidator thread OVS Revalidator includes:

[0102] Sending a statistics request message including the ID list to the network card to control the network card to generate a flow table rule statistics result list for the target flow table rule based on the ID list;

[0103] Receive the flow table rule statistical result list, and generate statistical results for the target flow table rule based on the flow table rule statistical result list;

[0104] The statistical result is updated to the revalidator thread OVS Revalidator through the pointer array.

[0105] refer to Figure 3 , Figure 3 It is a schematic diagram for an ID list and a flow table rule statistics result list provided in an embodiment of the present invention. The embodiment of the present invention sends a statistical request message containing an ID list to a network card so that the network card can respond to the statistical request message, and generates a flow table rule statistics result list FLOW_ID_STATS_LIST for a target flow table rule based on the ID list FLOW_ID_LIST. The flow table rule statistics result list FLOW_ID_STATS_LIST may include flow table rules matched and hit by data packets. The flow table rule statistics system may receive the flow table rule statistics result list FLOW_ID_STATS_LIST sent by the network card, and generate statistics for expressing data packet matching and hitting based on the flow table rule statistics result list FLOW_ID_STATS_LIST, and update the statistics to the revalidator thread OVS Revalidator through a pointer array.

[0106] Exemplarily, the statistics thread sends a statistics request to the network card, and the request includes a flow table ID list FLOW_ID_LIST. When the smart network card receives the statistics request from the software, the smart network card needs to parse the flow table ID list FLOW_ID_LIST in the request, and return the flow table ID in the ID list and the statistical result FLOW_ID_STATS_LIST of the flow table rules corresponding to the flow table ID. When the DPDK statistics thread receives the statistical result FLOW_ID_STATS_LIST from the smart network card, the DPDK statistics thread parses the statistical response to obtain the statistical result FlOW_A_STATS corresponding to the FlOW_A flow table. The DPDK statistics thread finds the table entry corresponding to FlOW_A_STATS according to the maintained Dpcls_Pointer_Array, and uses the pointer pointing to Dpcls_A therein to directly update the statistical count STATS_A of the Datapath flow table Dpcls_A in the corresponding OVS.

[0107] In an embodiment of the present invention, a statistical request message including the ID list is sent to the network card to control the network card to generate a flow table rule statistical result list for the target flow table rule based on the ID list; the flow table rule statistical result list is received, and the statistical result for the target flow table rule is generated based on the flow table rule statistical result list; the statistical result is updated to the revalidator thread OVS Revalidator through the pointer array, so that the network card responds and feeds back the corresponding flow table statistical result according to the request flow table ID list sent by the flow table rule statistical system, the OVS-DPDK statistical thread maintains the pointer of the unloaded flow table Dpcls, and according to the response result of the hardware, directly uses the Dpcls pointer to update the corresponding OVS Dpcls flow table statistical result, thereby avoiding the OVS Relivalidator thread from continuously traversing all flow tables and sending statistical requests to the hardware, thereby further improving the flow table rule statistical efficiency of the data packets of the network card.

[0108] Optionally, it also includes:

[0109] Control the network card to reset the bitmap image.

[0110] In practical applications, the embodiment of the present invention can control the network card to reset the bitmap image after the network card generates the bitmap image for the flow table rule, for example, resetting the bitmap reported in the current network card to 0.

[0111] The embodiment of the present invention controls the network card to reset the bitmap image so that the network card can accurately generate the bitmap image of the next time period, thereby further improving the statistical efficiency of the flow table rules for the data packets of the network card.

[0112] In order to enable those skilled in the art to better understand the embodiments of the present invention, the embodiments of the present invention are described below using a complete example.

[0113] join Figure 2 ,All OVS Datapath flow tables Dpcls that are unloaded to the hardware will maintain a pointer to Dpcls in the DPDK statistics thread, that is, the Dpcls pointer array Dpcls_Pointer_Array, and each item in the array corresponds one to one to the flow table that is actually unloaded to the hardware.

[0114] refer to Figure 4 , Figure 4It is a structural diagram of a flow table rule statistics system provided in an embodiment of the present invention. For all flow tables unloaded to the smart network card hardware, the smart network card will maintain a hit bit map BITMAP, and each bit corresponds to the flow table in the hardware one by one; the data packet enters the smart network card, matches and hits the flow table FlOW_A, and updates the statistical count of the flow table FlOW_A at the same time. At the same time, in the hit bitmap of the smart network card, the bit position corresponding to the flow table FlOW_A is set to 1. The smart network card regularly reports the current BITMAP status to the software, such as BITMAP_A, BITMAP_B, BITMAP_C, etc., and resets the reported bitmap in the current network card to 0. The newly added DPDK statistics thread in DPDK no longer directly obtains the hardware statistics results in full, but continuously caches the bitmaps BITMAP_A, BITMAP_B, BITMAP_C, etc. reported by the hardware, and merges these bitmaps into a new BITMAP_RESULT; the merging principle is that if a bit position is 1 once, the corresponding bit position in the final BITMAP_RESULT is set to 1; Figure 3 As shown in the figure, the statistics thread in DPDK periodically calculates the flow table ID corresponding to the bit 1 according to the current BITMAP_RESULT, and obtains the list of these flow table IDs FLOW_ID_LIST. The statistics thread sends a statistics request to the hardware, and the request contains the flow table ID list FLOW_ID_LIST. When the smart network card receives the statistics request from the software, the smart network card needs to parse the flow table ID list FLOW_ID_LIST in the request and return these flow table IDs and their statistical results FLOW_ID_STATS_LIST, as shown in Figure 3 As shown in the figure, after the DPDK statistics thread receives the statistics result FLOW_ID_STATS_LIST of the smart network card, the DPDK statistics thread parses the statistics response and obtains the statistics result FlOW_A_STATS corresponding to the FlOW_A flow table, as shown in the figure. Figure 2 As shown, the DPDK statistics thread finds the table entry corresponding to FlOW_A_STATS according to the maintained Dpcls_Pointer_Array, and uses the pointer pointing to Dpcls_A therein to directly update the statistical count STATS_A of the Datapath flow table Dpcls_A in the corresponding OVS.

[0115] Through the above method, the list of flow table IDs that hit the current cycle is calculated first, and only the statistics of the flow tables that have hit the current cycle need to be requested from the hardware, which reduces unnecessary hardware access and calculation of statistics of missed flow tables, avoids the hardware response message containing meaningless statistical results, greatly reduces the amount of message data in the software and hardware interaction, and improves the response speed of the hardware statistical results.

[0116] Furthermore, by calculating the current hit flow table ID list in advance, the software only requests the hardware for the statistical results of the flow tables that have hits in the current cycle, and after obtaining the statistical results, it can directly update the statistical results of these hit flow tables, avoiding the software requesting and processing the statistics of the missed flow tables, improving the software's statistical update processing efficiency, and reducing the software CPU consumption while improving software performance.

[0117] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.

[0118] An embodiment of the present invention also discloses a network card, which is configured with a flow table rule statistics system for data packets of the network card. The flow table rule statistics system is used to implement the various processes of the above-mentioned flow table rule statistics method embodiment for data packets of the network card during execution, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0119] Reference Figure 5 , shows a structural block diagram of a flow table rule statistics device for a data packet of a network card provided in an embodiment of the present invention, which may specifically include the following modules:

[0120] A third-level flow table Dpcls determining module 501, used to determine the third-level flow table Dpcls of the flow table OVSDatapath to be offloaded for the data packet;

[0121] A revalidator thread OVS Revalidator and a bitmap image cache configuration module 502, configured to configure a corresponding revalidator thread OVS Revalidator and a bitmap image cache for the statistics thread;

[0122] A bitmap image generation module 503, used to generate a bitmap image for the flow table rule, and store the bitmap image in the bitmap image cache;

[0123] The flow table rule statistics module 504 is used to count the flow table rules for the data packet based on the three-level flow table Dpcls and the bitmap image through the revalidator thread OVS Revalidator.

[0124] Optionally, the bitmap image generation module may include:

[0125] The bitmap image generation submodule is used to generate a bitmap image for the flow table rule when the data packet hits the native flow table rule corresponding to the data packet.

[0126] Optionally, the flow table rule statistics module may include:

[0127] A pointer array construction submodule, used to construct a pointer array associated with the third-level flow table Dpcls in the revalidator thread OVS Revalidator;

[0128] A bitmap image result generation submodule, used for merging the bitmap images to generate a bitmap image result;

[0129] The flow table rule statistics submodule is used to count the flow table rules for the data packet based on the pointer array and the bitmap image results through the revalidator thread OVS Revalidator.

[0130] Optionally, the bitmap image result has a corresponding position identifier, and may also include:

[0131] A flow table ID acquisition submodule, used to acquire a flow table ID corresponding to the location identifier according to a preset time period;

[0132] The ID list construction submodule is used to control the network card to construct an ID list based on the flow table ID.

[0133] Optionally, the flow table rule statistics submodule may include:

[0134] A statistics request information sending unit, used to send statistics request information to the network card to control the network card to generate a flow table rule statistics result list for the target flow table rule based on the ID list;

[0135] A flow table rule statistics result list receiving unit, used to receive the flow table rule statistics result list, and generate statistics for the target flow table rule based on the flow table rule statistics result list;

[0136] The flow table rule statistics unit is used to update the statistical results to the revalidator thread OVS Revalidator through the pointer array.

[0137] Optionally, it may also include:

[0138] The bitmap image resetting submodule is used to control the network card to reset the bitmap image.

[0139] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0140] In addition, an embodiment of the present invention also provides an electronic device, including: a processor, a memory, and a computer program stored in the memory and runnable on the processor. When the computer program is executed by the processor, the various processes of the above-mentioned flow table rule statistics method embodiment for data packets of the network card are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0141] The embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, each process of the above-mentioned embodiment of the method for counting flow table rules for packets of a network card is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0142] Figure 6 A schematic diagram of the hardware structure of an electronic device for implementing various embodiments of the present invention.

[0143] The electronic device 600 includes but is not limited to: a radio frequency unit 601, a network module 602, an audio output unit 603, an input unit 604, a sensor 605, a display unit 606, a user input unit 607, an interface unit 608, a memory 609, a processor 610, and a power supply 611. Those skilled in the art will appreciate that Figure 6 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and the electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. In the embodiments of the present invention, the electronic device includes but is not limited to a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted terminal, a wearable device, and a pedometer.

[0144] It should be understood that in the embodiment of the present invention, the radio frequency unit 601 can be used for receiving and sending signals during information transmission or communication. Specifically, after receiving downlink data from the base station, it is sent to the processor 610 for processing; in addition, uplink data is sent to the base station. Generally, the radio frequency unit 601 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier, a duplexer, etc. In addition, the radio frequency unit 601 can also communicate with the network and other devices through a wireless communication system.

[0145] The electronic device provides users with wireless broadband Internet access through the network module 602, such as helping users to send and receive emails, browse web pages, and access streaming media.

[0146] The audio output unit 603 can convert the audio data received by the RF unit 601 or the network module 602 or stored in the memory 609 into an audio signal and output it as sound. Moreover, the audio output unit 603 can also provide audio output related to a specific function performed by the electronic device 600 (for example, a call signal reception sound, a message reception sound, etc.). The audio output unit 603 includes a speaker, a buzzer, a receiver, etc.

[0147] The input unit 604 is used to receive audio or video signals. The input unit 604 may include a graphics processor (GPU) 6041 and a microphone 6042, and the graphics processor 6041 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The processed image frame can be displayed on the display unit 606. The image frame processed by the graphics processor 6041 can be stored in the memory 609 (or other storage medium) or sent via the radio frequency unit 601 or the network module 602. The microphone 6042 can receive sound and can process such sound into audio data. The processed audio data can be converted into a format output that can be sent to a mobile communication base station via the radio frequency unit 601 in the case of a telephone call mode.

[0148] The electronic device 600 also includes at least one sensor 605, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor includes an ambient light sensor and a proximity sensor, wherein the ambient light sensor can adjust the brightness of the display panel 6061 according to the brightness of the ambient light, and the proximity sensor can turn off the display panel 6061 and / or the backlight when the electronic device 600 is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in each direction (generally three axes), and can detect the magnitude and direction of gravity when stationary, which can be used to identify the posture of the electronic device (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; the sensor 605 can also include a fingerprint sensor, a pressure sensor, an iris sensor, a molecular sensor, a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, etc., which will not be repeated here.

[0149] The display unit 606 is used to display information input by the user or information provided to the user. The display unit 606 may include a display panel 6061, which may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.

[0150] The user input unit 607 can be used to receive input digital or character information, and to generate key signal input related to user settings and function control of the electronic device. Specifically, the user input unit 607 includes a touch panel 6071 and other input devices 6072. The touch panel 6071, also known as a touch screen, can collect the user's touch operation on or near it (such as the user's operation on the touch panel 6071 or near the touch panel 6071 using any suitable object or accessory such as a finger, stylus, etc.). The touch panel 6071 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into contact coordinates, and then sends it to the processor 610, receives the command sent by the processor 610 and executes it. In addition, the touch panel 6071 can be implemented in various types such as resistive, capacitive, infrared and surface acoustic waves. In addition to the touch panel 6071, the user input unit 607 may also include other input devices 6072. Specifically, other input devices 6072 may include but are not limited to a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be described in detail here.

[0151] Furthermore, the touch panel 6071 may be overlaid on the display panel 6061. When the touch panel 6071 detects a touch operation on or near it, it is transmitted to the processor 610 to determine the type of touch event. Then, the processor 610 provides corresponding visual output on the display panel 6061 according to the type of touch event. Figure 6 In the figure, the touch panel 6071 and the display panel 6061 are used as two independent components to realize the input and output functions of the electronic device. However, in some embodiments, the touch panel 6071 and the display panel 6061 can be integrated to realize the input and output functions of the electronic device, which is not limited here.

[0152] The interface unit 608 is an interface for connecting an external device to the electronic device 600. For example, the external device may include a wired or wireless headset port, an external power supply (or battery charger) port, a wired or wireless data port, a memory card port, a port for connecting a device with an identification module, an audio input / output (I / O) port, a video I / O port, a headphone port, etc. The interface unit 608 may be used to receive input (e.g., data information, power, etc.) from an external device and transmit the received input to one or more elements within the electronic device 600 or may be used to transmit data between the electronic device 600 and an external device.

[0153] The memory 609 can be used to store software programs and various data. The memory 609 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory 609 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0154] The processor 610 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 609 and calling data stored in the memory 609, it performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. The processor 610 may include one or more processing units; preferably, the processor 610 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 610.

[0155] The electronic device 600 may also include a power supply 611 (such as a battery) for supplying power to each component. Preferably, the power supply 611 may be logically connected to the processor 610 through a power management system, thereby implementing functions such as charging, discharging, and power consumption management through the power management system.

[0156] In addition, the electronic device 600 includes some functional modules not shown, which will not be described in detail here.

[0157] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.

[0158] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.

[0159] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation modes, which are merely illustrative rather than restrictive. Under the guidance of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims, all of which are within the protection of the present invention.

[0160] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in the embodiments of the present invention can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0161] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0162] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0163] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0164] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0165] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, ROM, RAM, magnetic disks, or optical disks.

[0166] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A method for counting flow table rules of data packets of a network card, characterized in that: The network card has a corresponding statistical thread, including: Determine the third-level flow table Dpcls of the flow table OVSDatapath to be unloaded for the data packet; Configure a corresponding revalidator thread OVS Revalidator and a bitmap image cache for the statistical thread; When the data packet hits a native flow table rule corresponding to the data packet, marking the flow table rule of the data packet, generating a bitmap image for the flow table rule, and storing the bitmap image in the bitmap image cache; The flow table rules for the data packet are counted based on the three-level flow table Dpcls and the bitmap image by the revalidator thread OVS Revalidator, including: Constructing a pointer array associated with the third-level flow table Dpcls in the revalidator thread OVS Revalidator; Merging the bitmap images to generate a bitmap image result; The flow table rules for the data packet are counted based on the pointer array and the bitmap image results by the revalidator thread OVS Revalidator.

2. The method according to claim 1, characterized in that The bitmap image result has a corresponding position identifier and also includes: Acquire a flow table ID corresponding to the location identifier according to a preset time period; An ID list is constructed based on the flow table ID.

3. The method according to claim 2, characterized in that The step of counting the flow table rules for the data packet based on the pointer array and the bitmap image result by the revalidator thread OVSRevalidator comprises: Sending a statistics request message including the ID list to the network card to control the network card to generate a flow table rule statistics result list for the target flow table rule based on the ID list; Receive the flow table rule statistical result list, and generate statistical results for the target flow table rule based on the flow table rule statistical result list; The statistical result is updated to the revalidator thread OVS Revalidator through the pointer array.

4. The method according to claim 1, characterized in that Also includes: Control the network card to reset the bitmap image.

5. A flow table rule statistics device for data packets of a network card, characterized in that: The network card has a corresponding statistical thread, including: A three-level flow table Dpcls determination module, used to determine the three-level flow table Dpcls of the flow table OVSDatapath to be unloaded for the data packet; A revalidator thread OVS Revalidator and a bitmap image cache configuration module, used to configure a corresponding revalidator thread OVS Revalidator and a bitmap image cache for the statistical thread; A bitmap image generation module, used for generating a bitmap image for the flow table rule, and storing the bitmap image in the bitmap image cache; A bitmap image generation submodule, used for marking the flow table rule of the data packet and generating a bitmap image for the flow table rule when the data packet hits the native flow table rule corresponding to the data packet; A flow table rule statistics module is used to count the flow table rules for the data packet based on the three-level flow table Dpcls and the bitmap image through the revalidator thread OVS Revalidator, including: A pointer array construction submodule, used to construct a pointer array associated with the third-level flow table Dpcls in the revalidator thread OVS Revalidator; A bitmap image result generation submodule, used for merging the bitmap images to generate a bitmap image result; The flow table rule statistics submodule is used to count the flow table rules for the data packet based on the pointer array and the bitmap image results through the revalidator thread OVS Revalidator.

6. The device according to claim 5, characterized in that The bitmap image result has a corresponding position identifier and also includes: A flow table ID acquisition submodule, used to acquire a flow table ID corresponding to the location identifier according to a preset time period; The ID list construction submodule is used to control the network card to construct an ID list based on the flow table ID.

7. The device according to claim 6, characterized in that The flow table rule statistics submodule includes: A statistics request information sending unit, used to send statistics request information to the network card to control the network card to generate a flow table rule statistics result list for the target flow table rule based on the ID list; A flow table rule statistics result list receiving unit, used to receive the flow table rule statistics result list, and generate statistics for the target flow table rule based on the flow table rule statistics result list; The flow table rule statistics unit is used to update the statistical results to the revalidator thread OVS Revalidator through the pointer array.

8. The device according to claim 5, characterized in that Also includes: The bitmap image resetting submodule is used to control the network card to reset the bitmap image.

9. A network card, characterized in that: The network card is configured with a flow table rule statistics system for data packets of the network card, and the flow table rule statistics system is used to implement the method according to any one of claims 1-4.

10. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; The memory is used to store computer programs; The processor is used to implement the method according to any one of claims 1 to 4 when executing the program stored in the memory.

11. A computer-readable storage medium having instructions stored thereon, which, when executed by one or more processors, cause the processors to perform the method according to any one of claims 1 to 4.