A method, computer storage medium, and terminal for implementing a look-up table operation
By preprocessing access operations and resolving conflicts in a pipelined manner, the method addresses MAC address table conflicts, ensuring efficient and accurate MAC address table management by utilizing TCAM to store and relocate conflicting entries.
Patent Information
- Application Number
- CN202310102012.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-29
- Publication Date
- 2025-07-15
- Estimated Expiration
- 2043-01-29
AI Technical Summary
The prior art is inefficient in handling access conflicts of MAC address tables, especially when frequent access in hash tables, it is easy to cause table entry conflicts and count inconsistencies, affecting the accuracy of search and update.
By preprocessing the operation-related information of different access sources, generating table lookup operation instructions, and performing table lookup operations in a streamlined manner, processing conflicts, including cache conflicted table entries in TCAM and moving them to the hash table when they are aged.
It improves the search efficiency of MAC address tables, reduces errors caused by conflicts, ensures the accuracy and consistency of table entries, and improves the response speed and stability of network devices.
Smart Images

Figure CN116074264B_ABST
Abstract
Description
Technical Field
[0001] This document relates to, but is not limited to, switch network technologies, and particularly to a method for implementing a look-up operation, a computer storage medium, and a terminal. Background Art
[0002] As a network device, a switch records the correspondence between the MAC addresses of other devices and interfaces, as well as information such as the virtual local area network (VLAN) to which the interfaces belong, through a Media Access Control (MAC) address table. Generally, the MAC address table is automatically learned by the device based on the source MAC address in the received data frame; when the device forwards a message, it queries the MAC address table according to the destination MAC address of the message. If the MAC address table contains an entry corresponding to the destination MAC address of the message, the message is directly forwarded through the outgoing interface in the entry; if the MAC address table does not contain an entry corresponding to the destination MAC address, the device forwards the message in a broadcast manner on all interfaces within the VLAN to which it belongs except the interface that received the message. The MAC address table is generally stored using a hash table structure, and multiple entries can be stored sequentially inside each hash bucket; when performing MAC address learning and lookup, the hash address is calculated using a hash function based on the source MAC address and VLAN_ID as the index of the hash table to look up the internal entry, and the source MAC address is stored in the free entry.
[0003] To adapt to network changes, the MAC address table needs to be continuously updated; the entries automatically generated in the MAC address table are not always valid, and each entry has a lifetime (also called the aging time). Entries that have not been updated by the time they reach the lifetime will be deleted; if an entry is updated before reaching the lifetime, the aging time of the entry is recalculated. In actual business operations, in addition to the automatic update of the MAC address table, developers and maintainers also need to monitor and debug the MAC address table, query the number of entries and the entry content in the MAC address table based on the MAC address (source MAC address or destination MAC address) or VLAN_ID.
[0004] In summary, in the process of establishing and maintaining the MAC address table, the MAC address table needs to be frequently operated, especially when the source MAC address of the message entering the device from the interface is learned, the destination address is searched, the table entry is updated according to the life cycle, and the MAC address table is monitored and debugged at the same time, the MAC address table needs to be able to effectively resolve conflicts and accurately and quickly respond to access requests. When the MAC address table is stored in a hash table, in order to avoid access conflicts, when the hash table has multiple access sources such as source MAC address learning, destination address search, table entry update and debugging, it is often necessary to perform access processing on the access source one by one. Once an access conflict occurs, the table entry stored in the hash table will be wrong. For example: the source MAC of message 1 is learned and the table query result determines that the table entry is idle, then the source MAC and VLAN_ID of the message are written into the table entry. During this period, the source MAC of message 2 is also learned and the table query result also determines that the table entry is idle (the information of message 1 has not been written at this time). The two messages find the same table entry in a very short time, resulting in an error in the end. The information of a message 1 is overwritten by the information of message 2; in addition, the access conflict will also cause the entry learning count of the hash table to be inconsistent with the actual number of stored entries (for example, the entry content is obtained after looking up the table according to the source MAC address of the message, and the entry content is updated and then written to the MAC address table (the MAC address table will update the entry lifetime value (TTL) after looking up the table and then write the entry content back to the MAC address table). If the address entry is modified by other access sources during the period from looking up the table to writing it back to the MAC address table, when the entry TTL is updated later and the entry content is written back to the MAC address table, the entry cannot be sensed as deleted and the previous entry content is still updated to the MAC address table).
[0005] In the related technology, in order to solve the problem of conflict in learning and searching the MAC address table, a common practice is to add a ternary content addressable memory (TCAM) to the MAC address table. When no free table entries can be found based on the source MAC address learning (the purpose of learning and searching the MAC address table based on the message is to write the information of the message into the table entries of the hash table, so the hash table entry must be guaranteed to be free), the source MAC and VLAN_ID of the message and other information are stored in the TCAM. However, this method does not have a migration mechanism (moving the content in the TCAM to the MAC address table). During long-term network operation, the TCAM will store a large number of conflicting table entries. Even if the MAC address table becomes free due to aging of some table entries, the cached table entries in the TCAM cannot be migrated back to the MAC address table, which reduces the application efficiency of the ternary content addressable memory in solving the access conflict problem of the MAC address table.
[0006] In summary, how to handle access conflicts in the MAC address table has become a problem to be solved. Summary of the Invention
[0007] The following is an overview of the subject matter described in detail herein. This overview is not intended to limit the scope of protection of the claims.
[0008] Embodiments of the present invention provide a method, a computer storage medium, and a terminal for implementing a look-up table operation, capable of handling access conflicts.
[0009] Embodiments of the present invention provide a method for implementing a look-up table operation, including:
[0010] For operations on the Media Access Control (MAC) address table of access physical addresses from different access sources, preprocess the operation-related information in a preset format to generate a look-up table operation instruction corresponding to each access source;
[0011] According to the generated look-up table operation instruction, perform the look-up table operation in a pipelined manner;
[0012] When it is determined that there is a look-up table address conflict according to the look-up table address for performing the look-up table operation, perform look-up table address conflict handling according to the result of performing the look-up table operation in a pipelined manner;
[0013] Among them, the operations on the MAC address table of different access sources include one or any combination of the following: learning and looking up the MAC address table according to a message, query control by a Central Processing Unit (CPU), and timed aging control; the operation-related information includes the information required for performing the look-up table operation processing.
[0014] On the other hand, embodiments of the present invention further provide a computer storage medium, in which a computer program is stored, and when the computer program is executed by a processor, the method for implementing the look-up table operation as described above is realized.
[0015] On yet another aspect, embodiments of the present invention further provide a terminal, including: a memory and a processor, and a computer program is stored in the memory; wherein,
[0016] The processor is configured to execute the computer program in the memory;
[0017] When the computer program is executed by the processor, the method for implementing the look-up table operation as described above is realized.
[0018] The technical solution of this application includes: operating on the access MAC address tables from different access sources, preprocessing the operation-related information according to a preset format to generate a look-up table operation instruction for each access source; executing the look-up table operation in a pipelined manner according to the look-up table operation instruction; when it is determined that there is a look-up table address conflict according to the look-up table address of the look-up table operation, performing processing for the look-up table address conflict. In the embodiment of the present invention, for the operation on the access MAC address tables from different access sources, according to the look-up table operation instruction in the preset format, the look-up table operation instruction is executed in a pipelined manner, and when there is a look-up table address conflict, the result of the look-up table operation executed in a pipelined manner is used to implement the processing of the look-up table address conflict.
[0019] Other features and advantages of the present invention will be described in the following specification, and part of them will be obvious from the specification or understood by implementing the present invention. The objectives and other advantages of the present invention can be achieved and obtained through the structures specifically pointed out in the specification, claims and drawings. Description of the Drawings
[0020] The drawings are used to provide a further understanding of the technical solution of the present invention, and constitute a part of the specification. Together with the embodiments of the present application, they are used to explain the technical solution of the present invention, and do not constitute a limitation to the technical solution of the present invention.
[0021] Figure 1 It is a flowchart of the method for implementing the look-up table operation in the embodiment of the present invention;
[0022] Figure 2 It is a schematic diagram of aging and clearing table entries in the embodiment of the present invention. Detailed Embodiment
[0023] To make the objectives, technical solutions and advantages of the present invention clearer and more understandable, the embodiments of the present invention will be described in detail below with reference to the drawings. It should be noted that, without conflict, the embodiments and features in the embodiments of the present application can be combined with each other arbitrarily.
[0024] The steps shown in the flowchart of the drawings can be executed in a computer system such as a set of computer-executable instructions. And although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.
[0025] Figure 1 It is a flowchart of the method for implementing the look-up table operation in the embodiment of the present invention, as Figure 1 shown, including:
[0026] Step 101: Operating on the access physical address MAC address tables from different access sources, preprocessing the operation-related information according to a preset format to generate a corresponding look-up table operation instruction for each access source;
[0027] Execute the look-up table operation in a pipelined manner according to the generated look-up table operation instruction;
[0028] When it is determined that there is a look-up table address conflict according to the look-up table address for executing the look-up table operation, perform look-up table address conflict handling according to the result of executing the look-up table operation in a pipelined manner;
[0029] Among them, the operations on the access MAC address table of different access sources include one or any combination of the following: learning and looking up the MAC address table according to the packet, central processing unit (CPU) query control, and timed aging control; the operation-related information includes the information required for performing the look-up table operation processing.
[0030] In the embodiments of the present invention, for the operations on the access MAC address table of different access sources, according to the look-up table operation instruction in a preset format, the look-up table operation instruction is executed in a pipelined manner. When there is a look-up table address conflict, the look-up table address conflict handling is realized through the result of the look-up table operation executed in a pipelined manner.
[0031] In an exemplary example, in the embodiments of the present invention:
[0032] When the operation of accessing the MAC address table is to learn and look up the MAC address table according to the packet, the operation-related information includes the information of packet parsing;
[0033] When the operation of accessing the MAC address table is CPU query control, the operation-related information includes the operation request indication and the operation information;
[0034] When the operation of accessing the MAC address table is timed aging control, the operation-related information is the aging request indication and the aging address.
[0035] When the operation of accessing the MAC address table in the embodiments of the present invention is to learn and look up the MAC address table according to the packet, refer to the related art to access the MAC address table according to the MAC and VLAN ID information of the packet. The operation-related information is the information of packet parsing, and the information of packet parsing includes the source MAC address and the destination MAC address, the local area network coding VLAN_ID, the forwarding port, and other data information; in the preprocessing, the destination MAC and the source MAC are respectively obtained through HASH calculation to obtain the destination HASH address and the source HASH address;
[0036] When the operation of accessing the MAC address table in the embodiments of the present invention is CPU query control, the operation-related information is the operation request indication and the operation information, including the address of the operation HASH table, the KEY value (MAC and VLAN_ID), and the instruction for operating the HASH table (echo, clear, modify, or update).
[0037] When the operation of accessing the MAC address table in the embodiment of the present invention is timed aging control, the operation-related information is the aging request indication and the aging address, and the instruction for operating the HASH table is only clearing.
[0038] In an exemplary instance, the look-up table operation instruction in the embodiment of the present invention includes the following information:
[0039] The look-up table indication information for indicating different access sources, the look-up table address for performing the look-up table operation, the key value of the look-up table, the mask information of the look-up table result, and the operation information after querying the MAC address table.
[0040] In an exemplary instance, the look-up table operation instruction in the embodiment of the present invention further includes the information written into the MAC address table;
[0041] Among them, the information written into the MAC address table includes: the forwarding port and / or the time-to-live value TTL.
[0042] The preprocessing in the embodiment of the present invention is a formatting process, mainly preprocessing the operation-related information such as the information for looking up the MAC address table and the operation commands of the table entries according to a preset format. The information involved includes the following item or any combination:
[0043] The look-up table indication information (search_vld), which is used to indicate different access sources, and serves as the valid signal for looking up the table through this signal; in an exemplary instance, the access sources in the embodiment of the present invention include: First, the packets received by the device; Second, the timed update according to the aging control time; Third, the operation of the developer or maintainer queries and controls the MAC address table through the CPU (the software command of the CPU).
[0044] The look-up table address (search_addr) for performing the look-up table operation; in an exemplary instance, when the access source in the embodiment of the present invention is a packet, the packet calculates the look-up table address according to its KEY to look up the MAC address table; when the access source is to update the table entry according to the aging time, the table entry is searched according to the address (the addresses are incremented and the table is searched in turn); when the access source is the CPU query control, the look-up table address can be determined according to the preset configuration rules (the preset rules include calculating the address information according to the configured KEY to look up the MAC address table, or searching the table entry according to the address), and the information of the MAC address table (or the hash table) is read through the determined look-up table address;
[0045] The key value (search_key) of the look-up table is a combination of {MAC, VLAN_ID}, including: {MAC = source MAC address, VLAN_ID} and {MAC = destination MAC address, VLAN_ID};
[0046] Mask (search_mask) of the look-up table result. In an exemplary instance, in the embodiments of the present invention, the MAC address, VLAN_ID, and PORT_ID can be masked respectively (one of the contents of mask preprocessing, considering various scenarios: for example, when looking up the table with the key value = {MAC, VLAN_ID} as mentioned before, the VLAN_ID can be masked through the mask to achieve looking up the table with the key value = {MAC}). According to the different access sources of the operation MAC address table, different masks are applied to the look-up table result. In an exemplary instance, when the access source in the embodiments of the present invention is the packet MAC look-up table, only the key value of the look-up table needs to be concerned, and other fields do not need to be concerned. Therefore, the port number (PORT_ID) is masked (the content of the entry found in the MAC address table includes: port number, MAC address, VLAN_ID, etc.; PORT_ID indicates from which port the packet enters the device). When aging control queries the table entries, only the valid table entries are queried, and other fields do not need to be concerned. Therefore, MAC, VLAN_ID, and PORT_ID are masked. When the CPU queries and controls the table entries, the masked fields are determined according to the configuration rules.
[0047] Information (search_data) written to the MAC address table. In an exemplary instance, the information written to the MAC address table in the embodiments of the present invention includes the forwarding port and / or TTL, etc.
[0048] Operations (search_cmd) after querying the MAC address table. According to the different sources of querying the MAC address table, the specific operations after querying the MAC address table are different. In an exemplary instance, in the embodiments of the present invention, after the destination MAC look-up table, only forwarding is performed. Therefore, the operation after querying is only read (only read). After the source MAC look-up table, learning is required. Therefore, the operation after querying is read and write update (read+write_updata). The CPU query control can be configured as only read (the operator of echoing the table entry queries and controls through the CPU, and displays the table entry stored in the hash table to the interface, and the information stored in the hash table can be intuitively seen), read and clear the table entry (read+write_clear), read and find and update the table entry (read+write_updata), or read and modify the table entry (read+write_ins) according to the requirements; aging control traverses the look-up table and clears it. Therefore, the operation after querying is read and clear the table entry (read+write_clear).
[0049] In an exemplary instance, the embodiments of the present invention perform the look-up table operation in a pipelined manner, including performing the look-up table operation in a pipelined manner through the following three clock cycles:
[0050] Search for the hash HASH table according to the look-up table address (search_addr);
[0051] Based on the key value (search_key) obtained from the table look-up and the mask information (search_mask) of the table look-up result, compare the retrieved HASH table to determine whether the key value obtained from the table look-up is consistent with the key value of the retrieved HASH table; retrieve the entry (table) of the HASH table based on the key value.
[0052] Based on the judgment result of whether the key values are consistent and the operation (search_cmd) after querying the MAC address table, operate on the entries of the MAC address table.
[0053] In the embodiment of the present invention, each packet only needs 3 clock cycles to find the forwarding information, which greatly improves the table look-up efficiency.
[0054] In an exemplary example, the embodiment of the present invention compares the retrieved HASH table based on the key value (search_key) obtained from the table look-up and the mask information (search_mask) of the table look-up result, including:
[0055] Perform a hidden code process on the preset fields in the retrieved HASH table according to the mask information (search_mask) of the table look-up result; for example: when the key value = {MAC, VLAN_ID} is used for table look-up, the VLAN ID can be masked by the mask; to achieve the comparison between the key value = {MAC} for table look-up, the search mask and the information read from the HASH table, and determine whether the key values are consistent.
[0056] Compare the key value obtained from the table look-up with the HASH table with the preset fields processed by the hidden code process to determine whether the key value obtained from the table look-up is consistent with the key value of the retrieved HASH table.
[0057] Among them, the preset fields include: fields that have nothing to do with the comparison being performed, that is, fields that are not concerned during the comparison process.
[0058] In an exemplary example, the fields that are not concerned during the comparison process in the embodiment of the present invention are configured by developers or maintainers according to the operations to be performed. The configuration method is a conventional technical means for those skilled in the art in the related art and will not be elaborated here.
[0059] In an exemplary instance, in the embodiment of the present invention, all valid entries of the HASH table found by traversing the query are configured with mask information of the lookup table result. After initiating a query request, the HASH table traverses from the starting address to find all valid entries, and combines the configured mask information with the lookup table result to determine whether the found entry matches the key configured by the CPU. If the entry of the found HASH table matches the key value of the lookup table configured by the CPU, the content and address information of the current valid entry are returned, and the table lookup is stopped until the entry is operated according to the CPU configuration again, and the table lookup continues from the address of the previous valid entry; if the entry of the found HASH table does not match the key value of the lookup table configured by the CPU, it automatically jumps to the next table lookup address to continue the table lookup. If no matching valid entry is found after traversing to the end of the table, the table lookup is stopped. Through the above method, the embodiment of the present invention can implement querying or clearing all entries containing the KEY configured by the technician's operation.
[0060] In an exemplary instance, when the embodiment of the present invention accesses the MAC address table and performs learning lookup of the MAC address table according to the packet, it looks up the HASH table according to the lookup table address (search_addr), including:
[0061] The destination MAC address in the packet is calculated through HASH to obtain the destination HASH address; the HASH table storing the MAC address table is looked up through the destination HASH address;
[0062] The source MAC address in the packet is calculated through HASH to obtain the source HASH address; the HASH table storing the MAC address table is looked up through the source HASH address.
[0063] In an exemplary instance, the processing of the embodiment of the present invention for learning and looking up the MAC address table according to the packet includes:
[0064] According to the destination MAC address of the packet, the destination HASH address is calculated through HASH; the HASH table storing the MAC address table is looked up through the destination HASH address to obtain a lookup table result including information such as port number, MAC address, VLAN_ID, and (time to live) TTL; when the MAC address in the lookup table result is the same as the destination MAC address of the packet, the packet is forwarded according to the port number in the lookup table result; if no valid entry is found or the MAC address in the lookup table result is inconsistent with the destination MAC address of the packet, the packet is forwarded to all ports;
[0065] The source MAC address is used to calculate the source HASH address through HASH calculation. The HASH table is searched using the source HASH address. The search result is compared with the source MAC address of the packet. If the MAC address in the search result is the same as the source MAC address of the packet, the table entry and (Time To Live) TTL are updated according to the port number carried by the packet. If no valid table entry is found, the source MAC address is written into the MAC address table. If the MAC address in the search result is different from the source MAC address of the packet and no valid table entry is found (the validity of the table entry is indicated by TTL (whether it is an empty table entry)), the packet is considered to be in conflict. At this time, if there is an empty table entry in the TCAM, the source MAC address of the packet is written into the TCAM. If there is no empty table entry in the TCAM either, the learning is considered to have failed. In the embodiment of the present invention, the size of the hash table is limited. For example, an address space (addr) of the hash table contains 8 table entries, and these 8 table entries do not store any content, that is, the empty table entries mentioned here. Now 8 packets are received, and the address spaces calculated according to the source MAC addresses of these 8 packets are exactly equal to addr, then these 8 table entries are filled, and there are no empty table entries in the address space addr.
[0066] In an exemplary example, when the operation of accessing the MAC address table in the embodiment of the present invention is CPU query control, the HASH table is searched according to the search address (search_addr), including:
[0067] The HASH address for the table search is calculated according to the key value of the table search;
[0068] The HASH table is searched using the obtained HASH address through calculation.
[0069] When the operation of accessing the MAC address table in the embodiment of the present invention is CPU query control, if the key value of the table entry found when searching the HASH table matches the key value configured by the CPU (the KEY configured by the CPU is configured by developers or maintainers to perform a certain operation and is the same as the key = {MAC, VLAN_ID} in the MAC address table), it is considered that the table entry is found. At this time, the table entry can be operated according to the CPU configuration.
[0070] In the embodiment of the present invention, in order for developers or maintainers to operate according to the configuration rules (by searching the entire table entry (also the "echo" mentioned later, and all table entry contents of the entire MAC address table can be visually seen through the interface); or searching for all table entries containing a certain MAC address; developers or maintainers actively clear all table entry contents of the entire MAC address table; developers or maintainers actively insert / modify a table entry) the HASH table.
[0071] In an exemplary instance, when the embodiment of the present invention determines that there is a lookup table address conflict according to the lookup table address for performing the lookup table operation, the lookup table address conflict is processed according to the result of performing the lookup table operation in a pipelined manner, including:
[0072] When performing the lookup table operation in the i-th clock cycle, determine whether the lookup table address in the i-th clock cycle conflicts with the lookup table addresses in the previous n clock cycles;
[0073] When there is more than one lookup table address in the previous n clock cycles that conflicts with the lookup table address in the i-th clock cycle, replace the operation result of the table entry in the closest clock cycle that conflicts with the lookup table address in the i-th clock cycle with the lookup result in the i-th clock cycle;
[0074] Wherein, the previous n clock cycles are the clock cycles within a preset duration.
[0075] When the embodiment of the present invention performs the lookup operation of the HASH table in a pipelined form, in the currently read HASH table data, the address space of the lookup operation may be exactly updated to the latest data, resulting in the read data being outdated. As shown in Table 1, after obtaining the lookup result of a certain address in the second cycle, at this time, the table entry of this address may have been operated in the 0th cycle or the 1st cycle; this kind of address read-write conflict generally occurs in a relatively large packet transmission bandwidth, or when there is both aging control and the CPU actively accessing the HASH table, and when performing read-write operations on the same HASH address. To solve the above address conflict problem, taking Table 1 as an example, the processing performed by the embodiment of the present invention includes: determining whether the lookup table address in the second cycle conflicts with the lookup table address in the first cycle. If the lookup table address in the second cycle conflicts with the lookup table address in the first cycle, then replace the lookup result obtained in the second cycle with the operation result of the table entry in the first cycle; if there is no conflict between the lookup table address in the second cycle and the lookup table address in the first cycle, determine whether the lookup table address in the second cycle conflicts with the lookup table address in the 0th cycle. If the lookup table address in the second cycle conflicts with the lookup table address in the 0th cycle, then replace the lookup result obtained in the second cycle with the operation result of the table entry in the 0th cycle.
[0076]
[0077]
[0078] Table 1
[0079] In an exemplary instance, when looking up the HASH table according to the lookup table address (search_addr), the method of the embodiment of the present invention further includes:
[0080] The operation of accessing the MAC address table is to learn and search the MAC address table according to the packet. When there is no available entry in the HASH table, the entry with HASH address conflict is written into the pre-set TCAM table;
[0081] When the entry with HASH address conflict is aged and cleared, the entry with HASH address conflict written into the TCAM table is moved to the HASH table;
[0082] Among them, the HASH address is obtained by calculating the keyword value of the packet through the HASH function.
[0083] The embodiment of the present invention learns and searches according to the MAC address and VLAN ID in the packet. The method for resolving HASH address conflict:
[0084] HASH conflict often occurs when learning and searching for entries according to the MAC address (source MAC and / or destination MAC) and VLAN ID in the packet. Since the keywords of different packets obtain the same HASH address through the HASH function, it causes the packet to not find an available entry in the HASH table through this HASH address (the purpose of learning and searching according to the packet is to write the information of the packet into the hash entry, so it must be ensured that this hash entry is available (not occupied by other packets)); when HASH address conflict occurs, the entry with HASH address conflict is written into the TCAM table to resolve the HASH address conflict.
[0085] The embodiment of the present invention improves the utilization rate of TCAM when resolving HASH address conflict. On the basis of the traditional method, the TCAM records the address of the conflict entry. If the entry corresponding to the HASH address is aged and cleared, the entry in the TCAM can be timely moved to the HASH table.
[0086] The data structures of the HASH table entry and the TCAM table entry are shown in Table 2 and Table 3.
[0087] MAC address VLAN ID TTL Forwarding port
[0088] Table 2
[0089] HASH table address MAC address VLAN ID TTL Forwarding port
[0090] Table 3
[0091] Figure 2 is a schematic diagram of aging and clearing entries in the embodiment of the present invention. As Figure 2 shown, when the operation of accessing the MAC address table is timed aging control, the method of the embodiment of the present invention further includes:
[0092] When looking up the HASH table according to the lookup table address (search_addr), use the HASH address as the key value to find the matching TCAM table entry;
[0093] When performing a lookup operation on the entries of the HASH table, according to the lookup operation instruction for the entries of the HASH table, the lookup operation on the entries of the HASH table includes whether to clear the entries of the HASH table;
[0094] Determine whether to move the TCAM table to the HASH table according to the found matching TCAM table entry and the lookup operation on the entries of the HASH table;
[0095] Among them, the HASH address for finding the matching TCAM table entry as the key value is obtained by calculating the lookup table address controlled by aging through the HASH function.
[0096] In an exemplary instance, the embodiment of the present invention can traverse all entries under the action of an internal timer, set the TTL of the queried entry (querying the entry according to the address calculated by the key value) to 0, and locate the entry as empty by setting the TTL to 0 to achieve the aging and clearing of the entry.
[0097] In an exemplary instance, when performing the lookup operation in a pipelined manner, the method of the embodiment of the present invention further includes performing the following counting process:
[0098] When the operation on the entry of the MAC address table is read and clear the entry (read+writ_clear), subtract one from the learning count of the port and VLAN ID of the lookup operation;
[0099] When the operation on the entry of the MAC address table is read and modify the entry (read+writ_ins), subtract one from the learning count of the port and VLAN ID in the read entry; add one to the learning count of the port and VLAN ID in the modified entry.
[0100] The embodiment of the present invention provides a learning counting function based on the port and VLAN ID, and performs the learning counting of the port and VLAN ID by dynamically monitoring the TTL operation result of the HASH table entry.
[0101] When the operation on the MAC address table is read+writ_clear: Read out the valid entries (TTL non-zero), write in the invalid entries (TTL = 0), and decrement the learning count of the port and VLAN ID by 1; Whether this entry is aged out or actively cleared by the CPU, the read+writ_clear operation will be performed on this entry. Under this operation, first read out the entry to obtain the content in the entry (port and vlan id), and then write in the invalid entry (writing in the invalid entry means clearing this entry); When the operation on the MAC address table is read+writ_ins, read out the valid entries (TTL non-zero), modify the entries (TTL non-zero), and decrement the learning count of the port and VLAN ID in the read-out entry by 1; Increment the learning count of the port and VLAN ID in the modified entry by 1.
[0102] Embodiments of the present invention monitor the number of entries in the HASH table in real time, including the learning count based on the port and the learning count based on the FID.
[0103] Embodiments of the present invention also provide a computer storage medium, in which a computer program is stored, and when the computer program is executed by a processor, the method for implementing the table lookup operation as described above is realized.
[0104] Embodiments of the present invention also provide a terminal, including: a memory and a processor, and a computer program is stored in the memory; wherein,
[0105] The processor is configured to execute the computer program in the memory;
[0106] When the computer program is executed by the processor, the method for implementing the table lookup operation as described above is realized.
[0107] Those of ordinary skill in the art will understand that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, and their appropriate combinations. In the hardware implementation, the division between the functional modules / units mentioned above does not necessarily correspond to the division of physical components; for example, one physical component may have multiple functions, or one function or step may be executed by several physical components in cooperation. Some or all of the components can be implemented as software executed by a processor, such as a digital signal processor or a microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software can be distributed on a computer-readable medium, which can include a computer storage medium (or non-transitory medium) and a communication medium (or transitory medium). As is well known to those of ordinary skill in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information, such as computer-readable instructions, data structures, program modules, or other data. Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disk (DVD) or other optical disk storage, magnetic cassettes, tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, it is well known to those of ordinary skill in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transmission mechanism, and can include any information delivery medium.
Claims
1. A method for implementing a look-up table operation, comprising: Preprocessing operation-related information according to a preset format for operations on a physical address MAC address table from different access sources, and generating look-up table operation instructions corresponding to each access source; Performing a look-up table operation in a pipelined manner according to the generated look-up table operation instructions; When it is determined that there is a look-up table address conflict according to the look-up table address for performing the look-up table operation, performing look-up table address conflict processing according to the result of performing the look-up table operation in a pipelined manner; Wherein, the operations on the MAC address table from different access sources include one or any combination of the following: learning and looking up the MAC address table according to a packet, central processing unit (CPU) query control, and timed aging control; the operation-related information includes information required for performing look-up table operation processing; the performing look-up table address conflict processing according to the result of performing the look-up table operation in a pipelined manner includes: when there is more than one look-up table address in the previous n clock cycles that conflicts with the look-up table address in the i-th clock cycle, replacing the operation result of the table entry in the clock cycle closest to the look-up table address that conflicts with the look-up table address in the i-th clock cycle with the look-up result in the i-th clock cycle.
2. The method according to claim 1, wherein: When the operation on the MAC address table is the learning and looking up of the MAC address table according to the packet, the operation-related information includes the information obtained by parsing the packet; When the operation on the MAC address table is the CPU query control, the operation-related information includes an operation request indication and operation information; When the operation on the MAC address table is the timed aging control, the operation-related information is an aging request indication and an aging address.
3. The method according to claim 1, wherein The look-up table operation instructions contain the following information: Look-up table indication information for indicating different access sources, a look-up table address for performing the look-up table operation, a key value of the look-up, mask information of the look-up result, and operation information after querying the MAC address table.
4. The method according to claim 3, wherein The look-up table operation instructions further include information to be written into the MAC address table; Wherein, the information to be written into the MAC address table includes: a forwarding port and / or a time-to-live (TTL) value.
5. The method according to claim 3, wherein The performing the look-up table operation in a pipelined manner includes performing the look-up table operation in a pipelined manner in the following three clock cycles: Looking up a hash (HASH) table according to the look-up table address; Comparing the found HASH table according to the key value of the look-up and the mask information of the look-up result to determine whether the key value of the look-up is consistent with the key value of the found HASH table; Operating on the table entry of the MAC address table according to the determination result of whether the key value of the look-up is consistent with the key value of the found HASH table and the operation information after querying the MAC address table.
6. The method according to claim 5, characterized in that, The comparing the found HASH table according to the key value of the look-up and the mask information of the look-up result includes: Performing hidden code processing on a preset field in the found HASH table according to the mask information of the look-up result; Compare the key value of the table lookup with the HASH table that processes the preset field with the hidden code to determine whether the key value of the table lookup is consistent with the key value of the found HASH table; Among them, the preset field includes: fields irrelevant to the comparison being performed.
7. The method according to claim 5, characterized in that, When the operation of accessing the MAC address table is to learn and look up the MAC address table according to the packet, the method of looking up the HASH table according to the table lookup address includes: Obtain the destination HASH address by performing HASH calculation on the destination MAC address in the packet; look up the HASH table storing the MAC address table through the destination HASH address; Obtain the source HASH address by performing HASH calculation on the source MAC address in the packet; look up the HASH table storing the MAC address table through the source HASH address.
8. The method according to claim 5, characterized in that When the operation of accessing the MAC address table is CPU query control, the method of looking up the HASH table according to the table lookup address includes: Calculate the HASH address of the table lookup according to the key value of the table lookup; Look up the HASH table through the obtained HASH address by calculation.
9. The method according to any one of claims 1-8, characterized in that, The previous n clock cycles are clock cycles within a preset duration.
10. The method according to claim 7, wherein When looking up the HASH table according to the table lookup address, the method further includes: When the operation of accessing the MAC address table is to learn and look up the MAC address table according to the packet, but no free HASH table entry can be found, write the entry with HASH address conflict into a preset ternary content addressable memory TCAM table; When the entry with HASH address conflict is aged and cleared, move the entry with HASH address conflict written into the TCAM table to the HASH table; Among them, the HASH address is obtained by calculating the keyword value of the packet through a HASH function.
11. The method according to claim 5, wherein When the operation of accessing the MAC address table is the timing aging control, the method further includes: When looking up the HASH table according to the table lookup address, use the HASH address as the key value to look up the matching TCAM table entry; When performing a table lookup operation on the entry of the HASH table, according to the table lookup operation instruction for the entry of the HASH table, the table lookup operation on the entry of the HASH table includes whether to clear the entry of the HASH table; According to the found matching TCAM table entry and the table lookup operation on the entry of the HASH table, determine whether to move the TCAM table to the HASH table; Among them, the HASH address for looking up the matching TCAM table entry as the key value is obtained by calculating the table lookup address of the aging control through a HASH function.
12. The method according to any one of claims 1-8, characterized in that, When performing the table lookup operation in a pipelined manner, the method further includes performing the following counting process: When the operation on the entry of the MAC address table is to read and clear the entry, subtract one from the learning count of the port and VLAN ID of the table lookup operation; When the operation on the entry of the MAC address table is to read and modify the entry, subtract one from the learning count of the port and VLAN ID in the read entry; Increment the learning count of the port and VLAN ID in the modified entry by one.
13. A computer storage medium storing a computer program, which when executed by a processor implements the method for implementing a look-up table operation according to any one of claims 1 to 12.
14. A terminal, comprising: A memory and a processor, the memory storing a computer program; wherein, The processor is configured to execute the computer program in the memory; The computer program, when executed by the processor, implements the method for implementing a look-up table operation according to any one of claims 1 to 12.
Citation Information
Patent Citations
Method and system for avoiding Hash collision during MAC address learning
CN103731355A
LZ process hardware compression method and LZ process hardware compression system based on parallel and pipeline design
CN109361398A