Hardware flow table aging method and apparatus, software flow table aging method and apparatus, and electronic device
The hardware device periodically records flow table hit records and generates a hit table, which is sent to the driver software to determine the flow table to be aged. This solves the problems of high number of interactions and long time consumption in the existing technology, and improves the aging efficiency of the flow table.
Patent Information
- Application Number
- PCT/CN2023/140365
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-03-06
- Filing Date
- 2023-12-20
- Publication Date
- 2024-09-12
AI Technical Summary
In the existing flow table aging method, the driver software interacts with the hardware device many times and takes a long time, resulting in high complexity and low efficiency of the hardware device.
The hardware device periodically records the hit records of multiple flow tables, generates a hit table, and sends it to the driver software. The driver software determines the target flow table to be aged based on the hit table, reducing the number of interactions and time-consuming.
It greatly reduces the number and time-consuming interactions between driver software and hardware devices, and improves flow table aging efficiency.
Smart Images

Figure CN2023140365_12092024_PF_FP_ABST
Abstract
Description
Hardware flow table aging method, software flow table aging method, device and electronic equipment
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on March 6, 2023, with application number 202310205465.X and invention name “Hardware flow table aging method, software flow table aging method, device and electronic device”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of smart network card technology, and in particular to a hardware flow table aging method, a software flow table aging method, a device and an electronic device. Background Art
[0003] SmartNIC hardware and driver software contain flow tables. When a packet fails to match a flow table in the hardware, it is sent to the driver software to generate new flow table rules. When a connection is idle or disconnected, unused flow tables are deleted through aging to free up space on the hardware.
[0004] Currently, flow table aging is mainly achieved in two ways:
[0005] In the first approach, the hardware device calculates and determines the flow table to be aged, and the driver software performs the aging operation. In the second approach, the hardware device records the usage of the flow table. The driver software interacts with the hardware device to obtain the usage information for the flow table and then calculates whether the flow table needs to be aged. In this approach, the driver software can only obtain the usage information of one flow table at a time.
[0006] As a result, the current flow table aging requires high complexity of hardware devices on the one hand, and on the other hand, the driver software must interact with the hardware device once for each flow table aging judgment, which results in a large number of interactions and a long time consumption.
[0007] Summary of the Invention
[0008] In view of this, the present application aims to propose a hardware flow table aging method, a software flow table aging method, an apparatus and an electronic device to solve the current problem of frequent interactions between the driver software and the hardware device during flow table aging, which takes a long time.
[0009] To achieve the above objectives, the technical solution of this application is implemented as follows:
[0010] A hardware flow table aging method, applied to a hardware device of a smart network card, includes:
[0011] Periodically record the hit records of multiple flow tables in the hardware device, and generate a hit table for each flow table based on the hit records; the hit table contains multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table has hit;
[0012] Send the hit table generated in the current cycle to the driver software of the smart network card to drive the driver software to determine the target flow table to be aged;
[0013] In response to the aging instruction sent by the driver software, the target flow table is deleted.
[0014] Optionally, after sending the hit table generated in the current cycle to the driver software of the smart network card, the method further includes:
[0015] The hit table generated in the current cycle is subjected to target processing to record the hit conditions of multiple flow tables in the next cycle; wherein the target processing includes deleting the hit table in the current cycle, or initializing the identification bits in the hit table in the current cycle.
[0016] Optionally, the identification bit is a bit.
[0017] Optionally, periodically record hit records of multiple flow tables in the hardware device, including:
[0018] In the current cycle, the hit status of each flow table is recorded in turn, and the hit status of each flow table is written into the corresponding identification bit of the hit table of the current cycle, so that the value of the identification bit represents the hit status of the flow table;
[0019] Send the hit table generated in the current cycle to the driver software of the SmartNIC, including:
[0020] During the current cycle, the current hit list is sent to the driver software of the smart network card at preset intervals.
[0021] or,
[0022] After writing each identification bit in the hit table in the current cycle, the multiple identification bits in the hit table in the current cycle are segmented according to a preset length, and the multiple identification bit segments obtained by segmentation are sent to the driver software of the smart network card;
[0023] Each identification bit segment includes at least one identification bit.
[0024] Compared with the existing technology, the hardware flow table aging method of this application has the following advantages:
[0025] This application periodically records the hit records of multiple flow tables and generates a hit table for each flow table; the hit table contains multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table is hit; the hit table in the current cycle is sent to the driver software of the smart network card to drive the driver software to determine the target flow table to be aged; in response to the aging instruction sent by the driver software, the target flow table is deleted.
[0026] Since the hardware device records the hit tables of multiple flow tables and sends them to the driver software, the driver software can obtain the hit records of multiple flow tables after a few interactions with the hardware device, so as to make aging judgments on each flow table, which greatly reduces the number of interactions between the driver software and the hardware device and the time spent on the interactions, thereby improving efficiency.
[0027] Another object of the present application is to provide a software flow table aging method to solve the current problem that the driver software and hardware devices interact frequently and time-consumingly during flow table aging.
[0028] To achieve the above objectives, the technical solution of this application is implemented as follows:
[0029] A software flow table aging method, applied to driver software of an intelligent network card, includes:
[0030] Receive the hit table in the current cycle sent by the hardware device of the smart network card; the hit table contains multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table is hit;
[0031] Determine a target flow table to be aged based on values of multiple identification bits of the hit table in the current cycle;
[0032] An aging instruction is sent to the hardware device of the smart network card, where the aging instruction is used to instruct the hardware device to age the target flow table.
[0033] Optionally, the method further comprises:
[0034] Add the target flow table to the aging list, which is used to store the numbers of the flow tables to be aged in the driver software;
[0035] Delete the target flow table in the driver software.
[0036] Optionally, the method further comprises:
[0037] Update the flow table associated with the target flow table.
[0038] Optionally, determining a target flow table to be aged based on values of multiple identification bits of the hit table in the current cycle includes:
[0039] Determine the flow table corresponding to the second preset value of the flag bit as a candidate flow table, and determine the last use time of the candidate flow table;
[0040] The target flow table is determined based on the difference between the last usage time of the candidate flow table and the current time.
[0041] Optionally, the last usage time of each flow table is determined by:
[0042] When the value of the corresponding identification bit of the flow table is the first preset value, updating the last use time of the flow table;
[0043] When the value of the corresponding flag of the flow table is the second preset value, the last usage time of the most recent update of the flow table is used as the last usage time;
[0044] The first preset value is different from the second preset value.
[0045] Optionally, update the last usage time of the flow table, including:
[0046] Query the time when the hit table of the flow table is received;
[0047] Update the last usage time of the flow table to the receiving time.
[0048] Optionally, determining the target flow table based on the difference between the last use time of the candidate flow table and the current time includes:
[0049] The candidate flow table whose difference exceeds the aging threshold is determined as the target flow table.
[0050] The software flow table aging method has the same advantages as the above-mentioned hardware flow table aging method over the prior art, and will not be described in detail here.
[0051] Another object of the present application is to provide a hardware flow table aging device to solve the current problem that the driver software and hardware devices interact frequently and time-consumingly during flow table aging.
[0052] To achieve the above objectives, the technical solution of this application is implemented as follows:
[0053] A hardware flow table aging device, applied to a hardware device of a smart network card, comprising:
[0054] A generation module is used to periodically record hit records of multiple flow tables and generate a hit table for each flow table; the hit table contains multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table has hit;
[0055] A hit table sending module is used to send the hit table in the current cycle to the driver software of the smart network card, so as to drive the driver software to determine the target flow table to be aged;
[0056] The deletion module is used to delete the target flow table in response to the aging instruction sent by the driver software.
[0057] The hardware flow table aging device has the same advantages as the above-mentioned hardware flow table aging method over the prior art, which will not be described in detail here.
[0058] Another object of the present application is to propose a software flow table aging device to solve the current problem that the driver software and hardware devices interact frequently and time-consumingly during flow table aging.
[0059] To achieve the above objectives, the technical solution of this application is implemented as follows:
[0060] A software flow table aging device, applied to driver software of an intelligent network card, comprises:
[0061] A receiving module is used to receive a hit table in the current cycle sent by the hardware device of the smart network card; the hit table contains multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table is hit;
[0062] A determination module, configured to determine a target flow table to be aged based on values of multiple identification bits of the hit table in a current cycle;
[0063] The instruction sending module is used to send an aging instruction to the hardware device of the smart network card, and the aging instruction is used to instruct the hardware device to age the target flow table.
[0064] The advantages of the software flow table aging device and the above-mentioned hardware flow table aging method over the prior art are the same, and will not be described in detail here.
[0065] Another object of the present application is to provide an electronic device to solve the current problem of frequent and time-consuming interactions between driver software and hardware devices when flow tables age.
[0066] To achieve the above objectives, the technical solution of this application is implemented as follows:
[0067] An electronic device, comprising:
[0068] A processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the processor implements any of the above-mentioned hardware flow table aging methods or any of the above-mentioned software flow table aging methods.
[0069] The advantages of the electronic device and the above-mentioned hardware flow table aging method over the prior art are the same, which will not be described in detail here.
[0070] Another object of the present application is to provide a computer-readable storage medium to solve the current problem that when the flow table ages, the driver software and the hardware device interact frequently and time-consumingly.
[0071] To achieve the above objectives, the technical solution of this application is implemented as follows:
[0072] A computer-readable storage medium comprising:
[0073] When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute any one of the above-mentioned hardware flow table aging methods, or execute any one of the above-mentioned software flow table aging methods.
[0074] The advantages of the computer-readable storage medium and the above-mentioned hardware flow table aging method over the prior art are the same, and are not described in detail here. BRIEF DESCRIPTION OF THE DRAWINGS
[0075] The accompanying drawings, which constitute part of this application, are intended to provide a further understanding of this application. The exemplary embodiments and descriptions of this application are intended to explain this application and do not constitute an improper limitation on this application. In the accompanying drawings:
[0076] FIG1 shows a flowchart of a method for aging a hardware flow table according to an embodiment of the present application;
[0077] FIG2 shows an example flow chart of the hardware device of the smart network card of the present application generating a hit table;
[0078] FIG3 shows a flowchart of another method for aging a software flow table according to an embodiment of the present application;
[0079] FIG4 shows a flowchart of steps for determining a target flow table to be aged in a software flow table aging method according to another embodiment of the present application;
[0080] FIG5 shows an example flow chart of a software flow table aging method according to another embodiment of the present application;
[0081] FIG6 shows a schematic structural diagram of a hardware flow table aging device according to an embodiment of the present application;
[0082] FIG7 shows a schematic structural diagram of another software flow table aging device according to an embodiment of the present application. DETAILED DESCRIPTION
[0083] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0084] It should be noted that, unless there is any conflict, the embodiments and features in the embodiments of the present application can be combined with each other.
[0085] SmartNICs, also known as intelligent network adapters, provide network data transmission capabilities and a built-in programmable and configurable hardware acceleration engine. During data transmission, data with common characteristics or attributes passing through the same network at the same time is called a flow. The collection of policy entries for one or more specific flows is called a flow table, which is responsible for packet lookup and forwarding.
[0086] The hardware and driver software in the SmartNIC store multiple flow tables. During data transmission, a packet is first matched against the flow table in the hardware. If a match is successful, the action corresponding to the matching flow table is executed (for example, forwarding to a specific path). If a match fails, the hardware device sends the packet to the Open Virtual Switch (OVS) driver software to generate new flow table rules.
[0087] OpenFlow is a new network communication protocol used for communication between controllers and forwarders in software-defined networking (SDN) architectures. A core concept of SDN is the separation of forwarding and control. To achieve this separation, a communication interface standard must be established between the controller and forwarders, allowing the controller to directly access and control the forwarding plane of the forwarder. The OpenFlow protocol architecture consists of a controller, switches, and secure channels. The controller deploys the corresponding flow table on the forwarder through an interface. The forwarder uses the flow table to guide packet forwarding, thereby achieving control over the forwarding plane.
[0088] Open vSwitch (OVS) is a virtual switch that supports multi-layer data forwarding and is suitable for the OpenFlow protocol.
[0089] When a connection is invalid, idle, or disconnected, the flow table of the smart network card hardware device needs to delete the flow table that has not been used for a long time through aging to free up space.
[0090] The existing flow table aging methods mainly include the following two methods:
[0091] The first method is that the hardware device counts and calculates the usage of the flow table, determines the flow table to be aged, adds the flow table to the aging queue, and then sends the aging queue to the driver software, which performs the aging operation.
[0092] This method uses hardware devices to complete the aging judgment of the flow table, which requires time and cycle calculations, increasing the complexity of the hardware devices.
[0093] The second method is that the hardware device counts the usage of the flow table, and the driver software periodically obtains the packet statistics of each flow table from the hardware to determine whether there is a packet hit, and then performs calculations to determine the flow table to be aged and performs the aging operation.
[0094] In this approach, the driver software can only obtain the usage status of one flow table at a time when interacting with the hardware. Therefore, the number of interactions required is proportional to the number of flow tables on the hardware device. Furthermore, the aging process periodically determines whether all flow tables need aging, which requires frequent hardware interactions and is time-consuming.
[0095] In view of this, an embodiment of the present application provides a flow table aging method with simple hardware implementation and a small number of interactions, so as to improve the efficiency of flow table aging.
[0096] 1 , which shows a flowchart of a method for aging a hardware flow table according to an embodiment of the present application, the method is applied to a hardware device of a smart network card, as shown in FIG1 , and includes:
[0097] Step S101: periodically record the hit records of multiple flow tables in the hardware device, and generate a hit table for each flow table based on the hit records; the hit table contains multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table is hit.
[0098] In an embodiment of the present application, the hardware device of the SmartNIC periodically records hit records for each flow table, generates and stores a hit table for each flow table. The hardware device stores the hit table under a fixed path, and when generating a hit record for each flow table in the current cycle, it updates the corresponding flag in the stored hit table.
[0099] The hardware device determines whether each flow table is hit by the following criteria: whether the flow table matches the data packet within the cycle. As long as the flow table matches the data packet, the flow table is considered to be hit.
[0100] The hit table contains hit information of each flow table, but does not contain hit count information.
[0101] It can be understood that if the number of flow table hits in a cycle is greater than or equal to one, it is recorded as a hit; if the number of flow table hits in a cycle is zero, it is recorded as a miss.
[0102] In an optional embodiment, the identification bit is a bit.
[0103] After recording the hit records of each flow table, the hardware device of the smart network card can generate a bit table. The bit table contains multiple bits, each bit corresponds to a flow table, and the value of each bit indicates whether the corresponding flow table is hit.
[0104] A bit is the smallest unit of data in current computer systems. A data structure that uses an array of bits to store specific data is called a bit table. The hit table in this application can be considered a bit table.
[0105] The value of each identification bit in the hit table, that is, the bit is usually 0 or 1. The bit value of 0 indicates that the corresponding flow table is not hit, and the bit value of 1 indicates that the corresponding flow table is hit.
[0106] When the hardware device records the hit records of each flow table in the current cycle, if the flow table hit count is greater than or equal to one, the corresponding bit value in the hit table is recorded as 1; if the flow table hit count is zero, the corresponding bit value in the hit table is recorded as 0.
[0107] In an optional embodiment, the duration of one cycle is in the range of microseconds to milliseconds.
[0108] The length of a cycle for the Smart NIC to record hit records for each flow table is in the order of microseconds to milliseconds.
[0109] Referring to Figure 2, Figure 2 shows an example flow diagram of the hardware device generating a hit table for the smart network card of the present application. As shown in Figure 2, when data transmission occurs on the smart network card, a data packet arrives at the hardware device and is matched against multiple flow tables in the hardware device. After the data packet matches the flow table, the hardware device records the hit record of the flow table, generates a hit table, and updates the value of the corresponding flag bit in the hit table.
[0110] For example, if a data packet matches a certain flow table, the hardware device can record the hit in the form of a bit table, recording the value of the bit corresponding to the flow table as 1, and recording the value of the bits corresponding to other unmatched flow tables as 0. The bit table that has completed the recording of all flow tables in the current cycle is regarded as the hit table in the current cycle.
[0111] Then execute step S102.
[0112] Step S102: Send the hit table generated in the current cycle to the driver software of the smart network card, so as to drive the driver software to determine the target flow table to be aged.
[0113] After the hardware device completes recording the hit records of each flow table in a cycle, it sends the generated hit table to the driver software, which performs calculations based on the hit table to determine the target flow table to be aged. The target flow table is the flow table that has not been hit.
[0114] For example, the hardware device records the hit records of each flow table in the form of a bit table. After completing the recording within a cycle, the multiple bits corresponding to the multiple flow tables are divided into groups of N to obtain one or more bit tables, and the one or more bit tables are sent to the driver software.
[0115] In a specific implementation, the hardware device sends the hit list to the Data Plane Development Kit (DPDK) module of the driver software. The DPDK is a collection of libraries and drivers for fast packet processing configured by the virtual switch.
[0116] In a specific implementation, multiple bits in the hit table may be divided into groups of 8.
[0117] After receiving the hit table, the driver software calculates the difference between the last usage time and the current time of each flow table based on the hit records of each flow table, determines the flow tables whose difference exceeds the aging threshold, and uses these flow tables as target flow tables to be aged.
[0118] After determining the target flow table to be aged, the driver software sends an aging instruction to the hardware device. The aging instruction is used to instruct the hardware device to age the target flow table to be aged, and the aging instruction at least includes the number of the target flow table to be aged.
[0119] Then execute step S103.
[0120] Step S103: In response to the aging instruction sent by the driver software, the target flow table is deleted.
[0121] After receiving the aging instruction sent by the driver software, the hardware device obtains the number of the target flow table to be aged contained in the aging instruction, retrieves the target flow table based on the number, and deletes it from the hardware device.
[0122] In an optional embodiment, after sending the hit table generated in the current cycle to the driver software of the smart network card, the hardware flow table aging method provided in the embodiment of the present application further includes:
[0123] The hit table generated in the current cycle is subjected to target processing to record the hit conditions of multiple flow tables in the next cycle; wherein the target processing includes deleting the hit table in the current cycle, or initializing the identification bits in the hit table in the current cycle.
[0124] After the hardware device of the smart network card sends the hit table generated in the current cycle to the driver software, the hit table generated in the current cycle is processed in a targeted manner so as to record in the next cycle.
[0125] Among them, when the target processing is deletion processing, the hardware device can delete the hit table generated in the current cycle, generate a new hit table when recording the next cycle, and write the hit status of the corresponding flow table in the identification bit of the new hit table.
[0126] Among them, when the target processing is initialization processing, the hardware device can initialize the identification bits of the hit table generated in the current cycle, that is, initialize the values of the identification bits in the hit table generated in the current cycle to the target value, such as 0, and retain the table of the hit table. When recording the next cycle, the hit status of the corresponding flow table is rewritten in the identification bits of the initialized hit table.
[0127] In an optional embodiment, periodically recording hit records of multiple flow tables in a hardware device includes: in a current period, recording the hit status of each flow table in turn, and writing the hit status of each flow table into a corresponding identification bit of the hit table of the current period, so that the value of the identification bit represents the hit status of the flow table;
[0128] Send the hit table generated in the current cycle to the driver software of the SmartNIC, including:
[0129] During the current cycle, the current hit list is sent to the driver software of the smart network card at preset intervals.
[0130] or,
[0131] After writing each identification bit in the hit table in the current cycle, the multiple identification bits in the hit table in the current cycle are segmented according to a preset length, and the multiple identification bit segments obtained by segmentation are sent to the driver software of the smart network card;
[0132] Each identification bit segment includes at least one identification bit.
[0133] The hardware device of the smart network card sends the hit list to the driver software in segments.
[0134] Optionally, when sending the hit list to the driver software, the hardware device may send the current hit list to the driver software at preset intervals within the current cycle.
[0135] In a specific implementation, the preset time may be less than one cycle or may be equal to one cycle, and is set based on actual application requirements and is not limited here.
[0136] For example, let's assume a preset time of m. Within the current cycle, the hardware device continues writing to the hit table from the time it begins writing to the hit table until time m. After reaching time m, the hardware device sends the multiple target identification bits written during that period to the driver software. At the next time point 2m, the hardware device then sends the multiple target identification bits written between time m and time 2m to the driver software. Alternatively, at the next time point 2m, the hardware device then sends the multiple target identification bits written between time 0 and time 2m to the driver software.
[0137] It is understandable that the examples herein are only for better illustrating the present embodiment, and are not the sole limitation to the present application.
[0138] Optionally, when the hardware device sends the hit table to the driver software, it can segment the multiple identification bits in the hit table in the current cycle according to a preset length after the writing of each identification bit in the hit table of the current cycle is completed, and send the multiple identification bit segments obtained by segmentation to the driver software of the smart network card.
[0139] The preset length can be set based on actual application requirements and is not limited here. In a specific implementation, each identification bit segment includes at least one identification bit.
[0140] For example, after the hardware device has completed writing all the hit table identification bits of the current cycle, that is, after the hit situation recording of all flow tables that need to record the hit situation is completed, the hit table with completed records is segmented according to the length of 2k identification bits as a segment, and multiple hit table segments consisting of 2k identification bits are obtained, and then the hit table segments are sent to the driver software in sequence, or sent to the driver software in batches.
[0141] The embodiment of the present application periodically records the hit records of multiple flow tables and generates a hit table for each flow table; the hit table includes multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table is hit; the hit table in the current cycle is sent to the driver software of the smart network card, so that the driver software determines the target flow table to be aged; and in response to the aging instruction sent by the driver software, the target flow table is deleted.
[0142] Since the hardware device records the hit tables of multiple flow tables and sends them to the driver software, the driver software can obtain the hit records of multiple flow tables with only a few interactions with the hardware device (far less than the number of flow tables), thereby making aging judgments on each flow table, greatly reducing the number and time of interactions between the driver software and the hardware device.
[0143] 3 , which shows a flowchart of another method for aging a software flow table according to an embodiment of the present application, the method is applied to the driver software of the smart network card, as shown in FIG3 , including:
[0144] Step S301: Receive a hit table in the current cycle sent by the hardware device of the smart network card; the hit table includes multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table is hit.
[0145] The driver software of the smart network card receives a hit table of hit records of each flow table in the current cycle sent by the hardware device, and performs aging judgment on each flow table based on the hit table.
[0146] In an optional embodiment, the hit table may be in the form of a bit table.
[0147] A bit is the smallest unit of data in current computer systems. A data structure that uses an array of bits to store specific data is called a bitmap.
[0148] The value of a bit is usually 0 or 1.
[0149] A bit value of 0 indicates that the corresponding flow table has not been hit and may need to be aged. A bit value of 1 indicates that the corresponding flow table has been hit and does not need to be aged.
[0150] In a specific implementation, the driver software receives the hit list sent by the hardware device through the data plane development kit module.
[0151] The data plane development kit module is a collection of libraries and drivers for fast packet processing configured by the virtual switch.
[0152] The data plane development kit module includes an aging thread and an unloading thread. The aging thread is used to receive the hit table and perform aging judgment, and the unloading thread is used to delete the target flow table to be aged in the driver software.
[0153] When receiving the hit list sent by the hardware device, the driver software first drives the aging thread, and the aging thread polls the system and calls the corresponding interface to receive the hit list.
[0154] Then execute step S302.
[0155] Step S302: Determine the target flow table to be aged based on the values of multiple flags of the hit table in the current cycle.
[0156] After receiving the hit table, the driver software of the smart network card obtains the value of each identification bit in the hit table and determines the target flow table. For example, the flow table corresponding to the identification bit value of 0 is determined as the target flow table.
[0157] In some other embodiments, the target flow table may also be determined from the flow table corresponding to the value of the flag bit being 1.
[0158] Among them, the last usage time of the corresponding flow table can be updated based on the value of each identification bit, and the difference between the last usage time of each flow table and the current time can be calculated. The flow table whose difference exceeds the aging threshold is determined as the target flow table to be aged.
[0159] It can be understood that there may be one or more target flow tables to be aged.
[0160] In a specific implementation, after the aging thread determines the target flow table to be aged, the target flow table number may be sent to the unloading thread to perform the aging operation.
[0161] Then execute step S303.
[0162] Step S303: Send an aging instruction to the hardware device of the smart network card; the aging instruction is used to instruct the hardware device to perform aging of the target flow table.
[0163] After determining the target flow table to be aged, the driver software sends an aging instruction to the hardware device. The aging instruction is used to instruct the hardware device to age the target flow table to be aged. The aging instruction at least includes the number of the target flow table to be aged.
[0164] In a specific implementation, the offload thread sends an aging instruction to the hardware device.
[0165] After receiving the aging instruction, the hardware device obtains the number of the target flow table to be aged contained in the aging instruction, and retrieves the target flow table based on the number for deletion.
[0166] 4 , which shows a flowchart of steps for determining a target flow table to be aged in a software flow table aging method according to another embodiment of the present application, as shown in FIG4 , including:
[0167] Step S401: Determine the flow table corresponding to the second preset value of the flag as a candidate flow table, and determine the last use time of the candidate flow table.
[0168] In a specific implementation, the second preset value is 0.
[0169] After receiving the hit list of each flow table in the current cycle, the driver software of the smart network card obtains multiple identification bits in the hit list and determines the candidate flow table based on the values of the corresponding identification bits. Among them, the candidate flow table is a candidate flow table to be aged.
[0170] The flow table with the corresponding flag value of 0 is determined as the candidate flow table. The value of the flow table corresponding flag is 0, which means that the flow table has not been hit in the current cycle, so aging judgment is required.
[0171] Then execute step S402.
[0172] Step S402: Determine a target flow table based on the difference between the last usage time of the candidate flow table and the current time.
[0173] After the candidate flow tables are determined, the last use time of each candidate flow table is obtained, and the difference between the last use time of each candidate flow table and the current time is calculated.
[0174] When the difference between the last usage time of the candidate flow table and the current time exceeds the aging threshold, the candidate flow table is determined as a target flow table to be aged.
[0175] If the difference between the last use time of the candidate flow table and the current time does not exceed the aging threshold, it is determined that the candidate flow table is not the target flow table.
[0176] Among them, by using the difference between the last used time and the current time, some flow tables that need to be aged but may still be needed can work for a period of time to meet the forwarding and sending of data packets, while some flow tables that are no longer needed can be aged.
[0177] In an optional embodiment, the last usage time of each flow table is determined in the following manner, including: when the value of the corresponding identification bit of the flow table is a first preset value, updating the last usage time of the flow table; when the value of the corresponding identification bit of the flow table is a second preset value, using the last usage time of the most recent update of the flow table as the last usage time; wherein the first preset value is different from the second preset value.
[0178] In a specific implementation, the first preset value may be 1, and the second preset value may be 0.
[0179] When the value of the corresponding flag bit of the flow table is 1, it means that the flow table is hit in the current cycle, and the last use time of the flow table is updated.
[0180] When the value of the flag bit corresponding to the flow table is 0, it means that the flow table has not been hit in the current cycle, and the last usage time of the most recent update of the flow table is directly used as the last usage time of the flow table for aging judgment.
[0181] In an optional embodiment, updating the last usage time of the flow table includes:
[0182] Query the time when the hit table of the flow table is received;
[0183] Update the last usage time of the flow table to the receiving time.
[0184] When the value of the flag corresponding to the flow table is the first preset value, the driver software updates the last use time of the target flow table.
[0185] First, the driver software queries the reception time of the hit table for the flow table, and then updates the reception time to the last use time of the flow table. For example, if the flow table is G, and the received hit table contains the flag indicating that flow table G has been written, the reception time s is recorded and s is used as the last use time of flow table G.
[0186] In an optional embodiment, determining a target flow table based on a difference between the last use time of the candidate flow table and the current time includes:
[0187] The candidate flow table whose difference exceeds the aging threshold is determined as the target flow table.
[0188] If the difference between the last usage time of the candidate flow table and the current time exceeds the aging threshold, the candidate flow table is determined to be a target flow table to be aged, and the target flow table to be aged is aged.
[0189] In an optional embodiment, the flow table aging method further includes: adding the target flow table to an aging list, the aging list being used to store numbers of flow tables to be aged in the driver software;
[0190] Delete the target flow table in the driver software.
[0191] Both the hardware and driver software of the Smart NIC store multiple flow tables.
[0192] It can be understood that the driver software not only stores the same flow table as the hardware device, but also can store flow tables that are not stored in the hardware device.
[0193] After the aging thread of the driver software determines the target flow table to be aged, it adds the number of the target flow table to the aging list.
[0194] The aging list can store the numbers of one or more target flow tables to be aged.
[0195] The aging thread sends the aging list to the uninstall thread. The uninstall thread retrieves the target flow table to be aged contained in the aging list from all flow tables stored in the driver software and deletes it.
[0196] In an optional embodiment, the flow table aging method further includes: updating the flow table associated with the target flow table.
[0197] After deleting the target flow table to be aged in the software, the uninstall thread of the driver software updates the flow table associated with the deleted target flow table.
[0198] Updating the flow table associated with the deleted target flow table may be to release the association with the target flow table, or to delete the content corresponding to the target flow table in the associated flow table.
[0199] The embodiment of the present application receives a hit table within the current cycle sent by the hardware device of the smart network card; the hit table includes multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table is hit; based on the values of multiple identification bits in the hit table within the current cycle, the target flow table to be aged is determined; an aging instruction is sent to the hardware device of the smart network card; the aging instruction is used to instruct the hardware device to age the target flow table.
[0200] Since the driver software determines whether the target flow table is hit by the value of the corresponding identification bit, and then updates the last usage time of the target flow table, the target flow table to be aged is determined based on the difference between the last usage time and the current time. The driver software can obtain the usage status of all flow tables after interacting with the hardware device once, and then make an aging judgment, which greatly reduces the number of interactions between the driver software and the hardware device and the time spent on aging judgment.
[0201] The following example illustrates the implementation process of the flow table aging method of this application:
[0202] Referring to Figure 5, Figure 5 shows an example flow chart of the software flow table aging method of another embodiment of the present application. As shown in Figure 5, first, when the smart network card transmits data, the data packet arrives at the hardware device and is matched with the flow table. The hardware device records the hit records of each flow table. When the flow table is matched, the value of the corresponding bit is recorded as 1. When the flow table is not matched, the value of the corresponding bit is recorded as 0.
[0203] After completing the hit record of all flow tables in the current cycle, a hit table is generated. The hit table includes multiple bits, each bit corresponding to a flow table. The hit table is then sent to the data plane development kit module of the driver software.
[0204] After receiving the hit list, the driver software data plane development kit module drives the aging thread.
[0205] The aging thread determines the last usage time of each flow table based on the values of multiple bits of the hit table in the current cycle.
[0206] Among them, for the first flow table corresponding to the flag value of 1, the last usage time of the first flow table is updated; for the second flow table corresponding to the flag value of 0, the last usage time of the second flow table's most recent update is used as the last usage time of the second flow table.
[0207] For the first flow table, the aging thread queries the hit table received in the current cycle for the receiving time corresponding to the first flow table, and then updates the last use time of the first flow table to the receiving time.
[0208] For the second flow table, which is a candidate flow table to be subjected to aging judgment, the last use time of the second flow table is queried and the difference between the last use time of the second flow table and the current time is calculated.
[0209] When the difference between the last usage time of the second flow table and the current time exceeds the aging threshold, the second flow table is determined to be a target flow table that needs to be aged, and the number of the target flow table is added to the aging list.
[0210] Next, the aging thread sends the aging list to the uninstallation thread, so that the uninstallation thread performs the aging operation.
[0211] The offloading thread sends an aging instruction to the hardware device, where the aging instruction is used to instruct the hardware device to perform aging on the target flow table to be aged.
[0212] After receiving the aging instruction, the hardware device deletes the target flow table to be aged.
[0213] At the same time, the uninstall thread retrieves the target flow table to be aged from all flow tables stored in the driver software, deletes it, and then updates the flow table associated with the deleted target flow table.
[0214] 6 , which shows a schematic structural diagram of a hardware flow table aging device according to an embodiment of the present application, the device is applied to a hardware device of a smart network card, including:
[0215] The generation module 601 is used to periodically record hit records of multiple flow tables and generate a hit table for each flow table; the hit table includes multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table has hit;
[0216] The hit table sending module 602 is used to send the hit table in the current cycle to the driver software of the smart network card, so as to drive the driver software to determine the target flow table to be aged;
[0217] The deletion module 603 is configured to delete the target flow table in response to an aging instruction sent by the driver software.
[0218] In an optional embodiment, the deletion module 603 includes:
[0219] The target processing module is used to perform target processing on the hit table generated in the current cycle to record the hit status of multiple flow tables in the next cycle; wherein, the target processing includes deleting the hit table in the current cycle, or initializing the identification bit in the hit table in the current cycle.
[0220] In an optional embodiment, the generating module 601 includes:
[0221] The writing module is used to record the hit status of each flow table in turn within the current cycle, and write the hit status of each flow table into the corresponding identification bit of the hit table of the current cycle, so that the value of the identification bit represents the hit status of the flow table.
[0222] In an optional embodiment, the hit list sending module 602 includes:
[0223] A first sending submodule is configured to send the current hit list to the driver software of the smart network card at preset intervals within the current cycle;
[0224] The second sending submodule is used to segment the multiple identification bits in the hit table in the current cycle according to the preset length after the writing of each identification bit in the hit table in the current cycle is completed, and send the multiple identification bit segments obtained by segmentation to the driver software of the smart network card; wherein, each identification bit segment includes at least one identification bit.
[0225] 7 , which shows a schematic structural diagram of another software flow table aging device according to an embodiment of the present application, the device is applied to the driver software of the smart network card, including:
[0226] Receiving module 701, configured to receive a hit table in the current cycle sent by the hardware device of the smart network card; the hit table includes multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table is hit;
[0227] A determination module 702 is configured to determine a target flow table to be aged based on values of multiple identification bits of the hit table in a current cycle;
[0228] The instruction sending module 703 is used to send an aging instruction to the hardware device of the smart network card; the aging instruction is used to instruct the hardware device to age the target flow table.
[0229] In an optional embodiment, the device further includes:
[0230] An adding module is used to add the target flow table to the aging list, and the aging list is used to store the numbers of the flow tables to be aged in the driver software;
[0231] A first deletion submodule is used to delete the target flow table in the driver software;
[0232] In an optional embodiment, the device further includes:
[0233] The update module is used to update the flow table associated with the target flow table.
[0234] In an optional embodiment, the determination module 702 includes
[0235] A first determining submodule is configured to determine a flow table corresponding to a preset value of a flag bit as a candidate flow table, and determine a last use time of the candidate flow table;
[0236] a second determining submodule, configured to determine a target flow table based on a difference between the last use time of the candidate flow table and the current time;
[0237] In an optional embodiment, the first determining submodule includes:
[0238] A first updating submodule, configured to update the last usage time of the flow table when the value of the corresponding identification bit of the flow table is a first preset value;
[0239] The second updating submodule is configured to use the last usage time of the most recent update of the flow table as the last usage time when the value of the corresponding identification bit of the flow table is a second preset value; wherein the first preset value is different from the second preset value.
[0240] In an optional embodiment, the first updating submodule includes:
[0241] The query submodule is used to query the reception time when the hit table of the flow table is received;
[0242] The last used time update submodule is used to update the last used time of the flow table to the receiving time.
[0243] In an optional embodiment, the second determining submodule includes:
[0244] The target flow table determination submodule is configured to determine the candidate flow table whose difference exceeds the aging threshold as the target flow table.
[0245] Based on the same inventive concept, an embodiment of the present application further provides an electronic device, including:
[0246] A processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the processor implements any of the hardware flow table aging methods of the first embodiment or any of the software flow table aging methods of the second embodiment.
[0247] Based on the same inventive concept, an embodiment of the present application also provides a computer-readable storage medium, including: when the instructions in the storage medium are executed by the processor of an electronic device, the electronic device is enabled to execute the hardware flow table aging method of any one of the above-mentioned embodiments one, or execute the software flow table aging method of any one of the above-mentioned embodiments two.
[0248] The above are only preferred embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application.
[0249] For the sake of simplicity, the method embodiments are described as a series of action combinations. However, those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, 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 this specification are all preferred embodiments, and the actions and components involved are not necessarily required by this application.
[0250] The above is a detailed introduction to a hardware flow table aging method, a software flow table aging method, a device and an electronic device provided by this application. This article uses specific examples to illustrate the principles and implementation methods of this application. The description of the above embodiments is only used to help understand the method of this application and its core idea; at the same time, for general technical personnel in this field, based on the ideas of this application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on this application.
Claims
1. A method for aging a hardware flow table, characterized in that: A hardware device applied to a smart network card, the method comprising: Periodically record the hit records of multiple flow tables in the hardware device, and generate a hit table of each flow table based on the hit records; the hit table includes multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table hits; Sending the hit table generated in the current cycle to the driver software of the smart network card to drive the driver software to determine the target flow table to be aged; In response to the aging instruction sent by the driver software, the target flow table is deleted.
2. The method according to claim 1, characterized in that After sending the hit table generated in the current cycle to the driver software of the smart network card, the method further includes: The hit table generated in the current cycle is subjected to target processing to record the hit conditions of multiple flow tables in the next cycle; wherein the target processing includes deleting the hit table in the current cycle, or initializing the identification bits in the hit table in the current cycle.
3. The method according to claim 1, characterized in that The identification bit is a bit.
4. The method according to claim 1, characterized in that: The periodic recording of hit records of multiple flow tables in the hardware device includes: In the current cycle, the hit situation of each flow table is recorded in sequence, and the hit situation of each flow table is written into the corresponding identification bit of the hit table of the current cycle, so that the value of the identification bit represents the hit situation of the flow table; The step of sending the hit table generated in the current cycle to the driver software of the smart network card includes: In the current cycle, at a preset time interval, the current hit table is sent to the driver software of the smart network card; or, After writing of each of the identification bits in the hit table in the current cycle is completed, the multiple identification bits in the hit table in the current cycle are segmented according to a preset length, and the multiple identification bit segments obtained by segmentation are sent to the driver software of the smart network card; Each of the identification bit segments includes at least one identification bit.
5. A software flow table aging method, characterized in that: The driver software applied to the smart network card comprises: Receive a hit table in the current cycle sent by the hardware device of the smart network card; the hit table contains multiple An identification bit, each of which corresponds to a flow table, and a value of the identification bit is used to indicate whether the corresponding flow table is hit; Based on the values of the multiple identification bits of the hit table in the current cycle, a target flow table to be aged is determined; and an aging instruction is sent to the hardware device of the smart network card, where the aging instruction is used to instruct the hardware device to age the target flow table.
6. The method according to claim 5, characterized in that The method further comprises: Adding the target flow table to an aging list, wherein the aging list is used to store numbers of flow tables to be aged in the driver software; The target flow table located in the driver software is deleted.
7. The method according to claim 6, characterized in that The method further comprises: The flow table associated with the target flow table is updated.
8. The method according to claim 5, characterized in that The determining the target flow table to be aged based on the values of the plurality of identification bits of the hit table in the current cycle includes: Determine the flow table corresponding to the second preset value of the flag as a candidate flow table, and determine the last use time of the candidate flow table; The target flow table is determined based on the difference between the last use time of the candidate flow table and the current time.
9. The method according to claim 8, characterized in that The last usage time of each of the flow tables is determined by: When the value of the flag corresponding to the flow table is a first preset value, updating the last use time of the flow table; When the value of the flag corresponding to the flow table is the second preset value, the last use time of the most recent update of the flow table is used as the last use time; The first preset value is different from the second preset value.
10. The method according to claim 9, characterized in that The updating of the last usage time of the flow table includes: Query the reception time when the hit table of the flow table is received; The last usage time of the flow table is updated to the receiving time.
11. The method according to claim 8, characterized in that The determining the target flow table based on the difference between the last use time of the candidate flow table and the current time includes: The candidate flow table whose difference exceeds an aging threshold is determined as the target flow table.
12. A hardware flow table aging device, characterized in that: A hardware device applied to a smart network card, the device comprising: A generation module, used to periodically record hit records of multiple flow tables and generate hit tables for each of the flow tables; the hit table includes multiple identification bits, each of the identification bits corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table is hit; A hit table sending module, used to send the hit table in the current cycle to the driver software of the smart network card, so as to drive the driver software to determine the target flow table to be aged; The deleting module is used to delete the target flow table in response to the aging instruction sent by the driver software.
13. A software flow table aging device, characterized in that: Driver software applied to a smart network card, the device comprising: A receiving module, used to receive a hit table in the current cycle sent by the hardware device of the smart network card; the hit table includes multiple identification bits, each of which corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table hits; A determination module, configured to determine a target flow table to be aged based on the values of the plurality of identification bits of the hit table in the current cycle; The instruction sending module is used to send an aging instruction to the hardware device of the smart network card, and the aging instruction is used to instruct the hardware device to perform aging of the target flow table.
14. An electronic device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the hardware flow table aging method according to any one of claims 1 to 4 is implemented, or the software flow table aging method according to any one of claims 5 to 11 is implemented.
15. A computer-readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the hardware flow table aging method described in any one of claims 1 to 4, or to execute the software flow table aging method described in any one of claims 5 to 11.
Citation Information
Patent Citations
VTEP (Virtual eXtensible Local Area Network Tunnel End Point)-based routing table maintenance method and device
CN109617779A
Flow table aging time adjusting method and device and storage medium
CN112134806A
Flow table aging management method and related equipment
CN114915587A
Hardware flow table aging method and device, software flow table aging method and device and electronic equipment
CN116074247A
Aging processing apparatus and aging processing method
JP2005109592A
