A method, device and computer storage medium for implementing TCAM storage lookup

By determining the storage location of the key in TCAM and generating combined information, the problem of mixed lookup of keys of different lengths in TCAM is solved, the application scope of TCAM is expanded, and complex packet matching in switch networks is supported.

CN116092558BActive Publication Date: 2026-07-03北京晟芯网络科技有限公司

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
北京晟芯网络科技有限公司
Filing Date
2023-01-12
Publication Date
2026-07-03

AI Technical Summary

Technical Problem

Existing technologies cannot effectively support mixed lookups of keys of different lengths and combinations in TCAM, which limits the implementation of matching rules for various types of packets in switch networks.

Method used

By determining the storage location of the key to be stored in the TCAM, generating key combination information, and recording the bit width combination rules of the TCAM rows, the storage and retrieval of keys of different length types can be realized.

Benefits of technology

It enables the storage and lookup of keys of arbitrary length in TCAM, enriching the application scenarios of TCAM and supporting mixed lookup of keys of various length types in switch networks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116092558B_ABST
    Figure CN116092558B_ABST
Patent Text Reader

Abstract

This paper discloses a method, apparatus, and computer storage medium for implementing TCAM storage lookup, comprising: determining a TCAM row in a Tri-State Content Addressing Memory (TCAM) that can be used to store the key to be stored; storing the key to be stored into the determined TCAM row that can be used to store the key to be stored, and generating corresponding key combination information for the TCAM row, wherein the key combination information is used to record the bit width combination rules of all keys stored in the TCAM row; performing a TCAM lookup according to the generated key combination information; wherein the length of the key to be stored is less than or equal to the total bit width of the TCAM row; and the TCAM contains two or more TCAM rows. This invention enables the storage and lookup of keys of arbitrary length that can be stored in the TCAM, enriching the storage and lookup of keys of different length types in the TCAM and expanding the application scenarios of the TCAM.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This article relates to, but is not limited to, switch network technology, and in particular to a method, apparatus, and computer storage medium for realizing TCAM storage lookup. Background Technology

[0002] Ternary content addressable memory (TCAM) is widely used in digital communication networks. Each bit in a TCAM has three states: 0, 1, and X. X represents the "don't care" state (also called the irrelevant state), which can be used as a mask to indicate that the bit is not relevant, enabling TCAM to perform broader lookups based on pattern matching. Compared to static random access memory (SRAM), which requires N queries to traverse an entire table entry for an N-depth SRAM, TCAM uses parallel entry access, requiring only one query to find the corresponding table entry. Therefore, TCAM lookups play a crucial role in the switch / router field. In the switch field, the bit width of access control lists (ACLs) varies greatly due to user behavior; some applications may only need a small number of bits to store keywords (short keys), while others require a large number of bits to store keys (long keys); both short and long keys may exist simultaneously on the same switch; furthermore, the lengths of short and long keys used in applications can vary. Generally, the physical width of each TCAM is fixed. Assuming that the physical width of a TCAM is 40 bits, then for a key with a width of 160 bits (defined as the logical width of the key in this article), four TCAMs need to be spliced ​​together.

[0003] The related technology can support the mixing of keys of different length types, but it only supports mixed lookups of keys of different length types in the same combination for all entries in the same TCAM; that is, after setting the unit width, it only supports mixed lookups of keys with a fixed number of key widths, such as 1x width, 3x width and 4x width. Figure 1 This is a diagram illustrating how related technologies support mixed lookups of keys of different lengths, such as... Figure 1As shown, the dashed box identifies a TCAM module. The TCAM in the diagram is formed by splicing together 8 TCAM modules. Each TCAM row is used to store keys with a width of 1 unit (key1), 3 units (key2), and 4 units (key3), respectively. Related technologies support the storage and retrieval of keys of different length types within the same combination in the spliced ​​TCAM. That is, it only supports key combination retrieval using the same combination rule for TCAM rows, but it does not support mixed retrieval of keys of different length types from different combinations for each table entry. Figure 1 The TCAMs are numbered from top to bottom and left to right. The leftmost TCAM modules without padding generate corresponding entries for each row of TCAM modules based on the addresses of TCAM modules numbered 0 to 3. The middle TCAM modules with left underline padding generate corresponding entries for each row of TCAM modules based on the addresses of TCAM modules numbered 12 to 15. The rightmost TCAM modules with right underline padding generate corresponding entries for each row of TCAM modules based on the addresses of TCAM modules numbered 29 to 32. The pointers (index) 0 to index 3 for mixed lookups are all generated using keys of one or more fixed length types based on the same combination rules. However, in switched networks, various types of protocol messages and data packets exist. To distinguish these different protocol messages and data packets, TCAMs are widely used. Different types of messages have different matching rules, such as matching 3-bit Type of Service (COS) priority, matching 12-bit Virtual LAN Identifier (VLAN ID), matching 128-bit Internet Protocol version 6 (IPv6) addresses, matching 112-bit Internet Protocol version 4 (IPv4) 5-tuples, matching 304-bit IPv6 5-tuples, and matching 1024-bit headers. Therefore, there are various key matching widths, ranging from 3 bits to thousands of bits. Since the physical width of a TCAM is fixed, how to utilize multiple TCAMs with a fixed physical width to satisfy the lookup of as many different key length types as possible is of significant application importance.

[0004] In summary, how to support the storage and lookup of keys of more than one length type with different combinations for each pointer pair has become a problem to be solved. Summary of the Invention

[0005] The following is an overview of the subject matter described in detail herein. This overview is not intended to limit the scope of the claims.

[0006] This invention provides a method, apparatus, and computer storage medium for TCAM storage lookup, which can support storage lookup of keys of different length types composed of different combinations.

[0007] This invention provides a method for implementing TCAM storage lookup, comprising:

[0008] For the key to be stored, determine the TCAM row in the tri-state content-addressable memory (TCAM) that can be used to store the key to be stored;

[0009] The key to be stored is stored in a TCAM row that can be used to store the key to be stored, and the corresponding key combination information of the TCAM row is generated. The key combination information is used to record the bit width combination rules of all keys stored in the TCAM row.

[0010] Perform a TCAM lookup based on the generated key combination information;

[0011] Wherein, the length of the key to be stored is less than or equal to the total bit width of the TCAM row; the TCAM contains two or more TCAM rows.

[0012] On the other hand, embodiments of the present invention also provide a computer storage medium storing a computer program, which, when executed by a processor, implements the above-described method for TCAM storage lookup.

[0013] Furthermore, embodiments of the present invention also provide a terminal, comprising: a memory and a processor, wherein the memory stores a computer program; wherein,

[0014] The processor is configured to execute computer programs in memory;

[0015] When the computer program is executed by the processor, it implements the TCAM storage lookup method as described above.

[0016] The technical solution of this application includes: determining a TCAM row in a Tri-State Content Addressable Memory (TCAM) that can be used to store the key to be stored; storing the key to be stored into the determined TCAM row that can be used to store the key to be stored, and generating corresponding key combination information for the TCAM row, the key combination information being used to record the bit width combination rules of all keys stored in the TCAM row; performing a TCAM lookup according to the generated key combination information; wherein, the length of the key to be stored is less than or equal to the total bit width of the TCAM row; and the TCAM contains two or more TCAM rows. This embodiment of the invention enables the storage and lookup of keys of arbitrary length that can be stored in the TCAM, enriching the storage and lookup of keys of different length types in the TCAM and expanding the application scenarios of the TCAM.

[0017] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention may be realized and obtained by means of the structures particularly pointed out in the description, claims, and drawings. Attached Figure Description

[0018] The accompanying drawings are provided to further understand the technical solutions of the present invention and constitute a part of the specification. They are used together with the embodiments of this application to explain the technical solutions of the present invention and do not constitute a limitation on the technical solutions of the present invention.

[0019] Figure 1 This diagram illustrates how related technologies support mixed lookups of keys of different lengths.

[0020] Figure 2 This is a flowchart illustrating the method for TCAM storage lookup in an embodiment of the present invention;

[0021] Figure 3 This is a flowchart illustrating the storage process of the key to be stored in an embodiment of the present invention.

[0022] Figure 4 This is a schematic diagram illustrating the process of generating key combination information in an embodiment of the present invention;

[0023] Figure 5 This is a schematic diagram illustrating how the present invention supports mixed lookups of keys of different lengths. Detailed Implementation

[0024] To make the objectives, technical solutions, and advantages of the present invention clearer, the embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be noted that, unless otherwise specified, the embodiments and features described in this application can be arbitrarily combined with each other.

[0025] The steps illustrated in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases the steps shown or described may be performed in a different order than that presented here.

[0026] Figure 2 This is a flowchart illustrating the method for TCAM storage lookup in an embodiment of the present invention, as shown below. Figure 2 As shown, it includes:

[0027] Step 201: For the key to be stored, determine the TCAM row in the Tri-State Content Addressing Memory (TCAM) that can be used to store the key to be stored;

[0028] Step 202: Store the key to be stored into a determined TCAM row that can be used to store the key to be stored, and generate the corresponding key combination information for the TCAM row. The key combination information is used to record the bit width combination rules of all keys stored in the TCAM row.

[0029] Step 203: Perform a TCAM lookup based on the generated key combination information;

[0030] The length of the key to be stored is less than or equal to the total width of the TCAM row; the TCAM contains two or more TCAM rows.

[0031] This invention enables the storage and retrieval of keys of arbitrary length that can be stored in TCAM, enriching the storage and retrieval capabilities of keys of different lengths in TCAM and expanding the application scenarios of TCAM.

[0032] In one exemplary instance, embodiments of the present invention determine TCAM rows in a TCAM that can be used to store a key to be stored, including:

[0033] Determine if the TCAM contains more than one TCAM row without a stored key;

[0034] When a TCAM contains more than one TCAM row that does not store a key, select one of the TCAM rows that does not store a key as the TCAM row that can be used to store the key to be stored.

[0035] If the TCAM does not contain any TCAM rows that do not contain a key, and it is determined that the TCAM contains TCAM rows with a remaining storable bit width greater than or equal to the bit width of the key to be stored, then one TCAM row is selected from these rows as a TCAM row that can be used to store the key to be stored.

[0036] In one exemplary instance, embodiments of the present invention determine a TCAM row in the TCAM that can be used to store the key to be stored, including:

[0037] If a TCAM contains one or more TCAM rows that store more than one key, and there are remaining TCAM rows whose storable bit width is greater than or equal to the bit width of the key to be stored, then select one TCAM row from these rows as the TCAM row that can be used to store the key to be stored.

[0038] If, in a TCAM containing one or more TCAM rows that store more than one key, all remaining storable bit widths of all TCAM rows are less than the bit width of the key to be stored, then if a TCAM contains one or more TCAM rows that do not store a key, select one of these TCAM rows as the TCAM row that can be used to store the key to be stored.

[0039] In one exemplary instance, embodiments of the present invention store the key to be stored into a determined TCAM row that can be used to store the key to be stored, including:

[0040] If it is determined that the generated key combination information is included, and the generated key combination information contains a key that is the same as the key parameter to be stored, then the key to be stored is stored in the TCAM row that can be used to store the key to be stored, according to the generated key combination information.

[0041] If it is determined that the generated key combination information is not included, or the generated key combination information does not contain a key that is the same as the key parameter to be stored, the key to be stored is directly stored in the TCAM row that can be used to store the key to be stored;

[0042] The key parameter to be stored includes: bit width.

[0043] It should be noted that, in this embodiment of the invention, as long as steps 201 and 202 are referred to, the process of storing the key to be stored into the determined TCAM row that can be used to store the key to be stored is performed, that is, the corresponding key combination information is generated.

[0044] In one exemplary instance, whether the key to be stored is stored in a TCAM row that does not store a key, or the key to be stored is stored in a TCAM row that stores more than one key, the process of generating key combination information is performed when storing in a TCAM row.

[0045] It should be noted that, in the embodiments of the present invention, keys with the same bit width are allowed to be stored in TCAM rows according to different combination rules. That is, keys with the same bit width are allowed to be stored in TCAM rows according to existing combination rules, keys to be stored are allowed to be stored in TCAM rows with remaining storable bit widths greater than the bit width of the key to be stored, and keys to be stored are allowed to be stored in new TCAM rows. Except for the first case, new combination rules will be formed in the latter two storage methods.

[0046] In one exemplary instance, embodiments of the present invention store the key to be stored into a determined TCAM row that can be used to store the key to be stored, including:

[0047] When a TCAM row containing more than one key is determined to be a TCAM row that can be used to store the key to be stored, the key to be stored is stored after the one or more keys already stored in that TCAM row.

[0048] In one exemplary instance, embodiments of the present invention determine TCAM rows that meet the following conditions as TCAM rows with a remaining storable bit width greater than or equal to the bit width of the key to be stored:

[0049] M i <N i *W≤M i +W;

[0050] N≥N1+N2…+N i ;

[0051] Where N is the total number of units of bit width available in the TCAM row for storing the key, W is the unit bit width, and M is the total number of units of bit width. i The bit width of the key to be stored, N1, N2, ... N i-1 N represents the number of bits per unit width occupied by each key already stored in the TCAM row. i *W represents the bit width required to store the key to be stored.

[0052] In one exemplary instance, in this embodiment of the invention, when a TCAM row can store a maximum of n keys, N ≥ N1 + N2 ... + N n When it is determined that a TCAM row can store a maximum of n keys, it means that these n keys can be of any length, and according to the order and position of storing the TCAM rows, a mixed combination of keys is formed.

[0053] In one exemplary instance, the method of this embodiment of the invention further includes adding the following parameters to each key in the key combination information:

[0054] Type information used to distinguish key types and / or location information used to identify the start and end positions of the TCAM rows occupied by each key.

[0055] It should be noted that when the key parameters include type information in addition to bit width, the key combination information in this embodiment of the invention is further distinguished according to the type information. In other words, if the key length combinations recorded in the key combination information are the same, and the types of keys with the same bit width are different, then the two key combination information are different combination information.

[0056] Figure 3 This is a flowchart illustrating the storage process of the key to be stored in an embodiment of the present invention, as shown below. Figure 3 As shown, a line with a width of N i The keys for *W include:

[0057] Step 301: Determine whether it contains generated key combination information; In an exemplary instance, theoretically, as long as a key has been stored, key combination information will be generated.

[0058] If it is determined that the generated key combination information is not included, proceed to step 302; if it is determined that the generated key combination information is included, proceed to step 303.

[0059] Step 302: Select a TCAM row from the TCAM that does not contain a key, and directly store the key to be stored in that TCAM row;

[0060] Step 303: Determine whether the generated key combination information contains a key with the same key parameter as the key to be stored; here, the same parameter includes: the same bit width and / or the same type information.

[0061] If the generated key combination information contains a key that is the same as the key parameter to be stored, proceed to step 3031; if the generated key combination information does not contain a key that is the same as the key parameter to be stored, proceed to step 3032.

[0062] Step 3031: Store the key to be stored according to the generated key combination information;

[0063] Step 3032: Determine whether the TCAM contains TCAM rows with more than one key that have a remaining storable bit width greater than or equal to the bit width of the key to be stored.

[0064] If a TCAM contains a row or more containing one or more keys, and the remaining storable bit width is greater than or equal to the bit width of the key to be stored, then proceed to step 30321; if the remaining storable bit width of all TCAM rows is less than the bit width of the key to be stored, then proceed to step 30322.

[0065] Step 30321: Select a TCAM row from the remaining TCAM rows whose storable bit width is greater than or equal to the bit width of the key to be stored, and store the key to be stored after one or more keys already stored in the TCAM row;

[0066] Step 30322: Select a TCAM row that does not contain a key from the TCAM, and directly store the key to be stored in that TCAM row.

[0067] Figure 4 This is a schematic diagram illustrating the process of generating key combination information in an embodiment of the present invention, such as... Figure 3As shown, for the first key, abbreviated as key1, this embodiment of the invention stores it in any TCAM row of TCAM, assuming it is TCAM row 1. The name of the generated key combination information is Mixed key 0. In the first item of Mixed key0, the key 1 stored at the first bit width (0 is the starting address of the first bit width) of TCAM row 1 is recorded, and the bit width is N. 1* W, N1=1, data type (key-type=1), the sorting of this record and N1=1 determine that the start and end positions of the TCAM row occupied by key1 are both positions 0 of the TCAM row. V is an abbreviation for valid, v=1 indicates valid; for the second key, referred to as key2, in this embodiment of the invention, the bit width of key2 stored in the TCAM row of key1 is used to store key2, and the bit width is N. 2* Given W, N2 = 4, data type (key-type = 2), the sorting of this record, and N2 = 1, it can be determined that the start and end positions of the TCAM row occupied by the key to be stored are positions 1-4 of the TCAM row. Assuming that key3 cannot be stored in TCAM row 1, this embodiment of the invention stores key3 in TCAM row 2. The name of the generated key combination information is Mixed key 1. In the first item of Mixed key 1, the starting address of the first bit width of key 3 stored in TCAM row 1 is recorded, with a bit width of N. 3* W, N3 = 4, data type (key-type = 3), the start and end positions of the TCAM row occupied by key1 are both 0-3 of the TCAM row. Assuming that key4 can be stored in TCAM row 1, in this embodiment of the invention, after key3 is stored, the storage of key4 and the generation of key combination information are performed in TCAM row 1 in accordance with the above processing.

[0068] Figure 5 This is a schematic diagram illustrating how the present invention supports mixed lookups of keys of different lengths, as shown in the embodiment of the invention. Figure 5 As shown, the TCAM contains several TCAM rows, each row containing one or more keys of different lengths. The key is identified by the letter K, and the number following K distinguishes different keys. The same number indicates the same bit width and type. In this embodiment of the invention, keys are stored in a mixed manner in the TCAM according to arbitrary sorting combinations. In an exemplary instance, before performing a TCAM lookup based on the generated key combination information, the method of this embodiment of the invention further includes:

[0069] Each time a key to be stored is stored in a TCAM row, a corresponding table entry for that key is generated based on its position within the TCAM row. This table entry is used to perform a TCAM lookup. Here, the position of the key in the TCAM row can be considered as its position within the key combinations generated by the TCAM row.

[0070] In this embodiment of the invention, a TCAM lookup is performed based on each key stored in the TCAM table. This can be done with reference to related technologies, and will not be elaborated here. In this embodiment of the invention, when performing a TCAM lookup, different types of key combinations can be searched multiple times. This can be done with reference to related technologies, and will not be elaborated here.

[0071] This invention also provides a computer storage medium storing a computer program, which, when executed by a processor, implements the above-described method for TCAM storage lookup.

[0072] This invention also provides a terminal, comprising: a memory and a processor, wherein the memory stores a computer program; wherein,

[0073] The processor is configured to execute computer programs in memory;

[0074] When a computer program is executed by a processor, it implements the above-described method for TCAM memory lookup.

[0075] It will be understood by those skilled in the art that all or some of the steps, systems, or apparatuses disclosed above, and their functional modules / units, can be implemented as software, firmware, hardware, or suitable combinations thereof. In hardware implementations, the division between functional modules / units mentioned above does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed collaboratively by several physical components. Some or all components may be implemented as software executed by a processor, such as a digital signal processor or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit (ASIC). Such software may be distributed on a computer-readable medium, which may include computer storage media (or non-transitory media) and communication media (or transient media). As is known to those skilled in the art, the term computer storage media 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 disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. Furthermore, it is well known to those skilled in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.

Claims

1. A method for implementing TCAM storage lookup, comprising: For the key to be stored, determine the TCAM row in the tri-state content-addressable memory (TCAM) that can be used to store the key to be stored; The key to be stored is stored in a determined TCAM row that can be used to store the key to be stored, and the corresponding key combination information of the TCAM row is generated. The key combination information is used to record the bit width combination rules of all keys stored in the TCAM row. The key combination information includes: each of the several TCAM rows contained in the TCAM has one or more keys with different lengths. Perform a TCAM lookup based on the generated key combination information; Wherein, the length of the key to be stored is less than or equal to the total bit width of the TCAM row; the TCAM contains two or more TCAM rows.

2. The method of claim 1, wherein, The process of determining which TCAM rows in the TCAM can be used to store the key to be stored includes: Determine whether the TCAM contains one or more TCAM rows that do not store a key; When the TCAM contains one or more TCAM rows that do not store a key, select one of the TCAM rows that does not store a key as the TCAM row that can be used to store the key to be stored. If the TCAM does not contain any TCAM rows that do not store the key, and it is determined that the TCAM contains remaining TCAM rows with a storable bit width greater than or equal to the bit width of the key to be stored, then one TCAM row is selected from these rows as the TCAM row that can be used to store the key to be stored.

3. The method of claim 1, wherein, The process of determining which TCAM row in the TCAM can be used to store the key to be stored includes: If, among the TCAM rows containing one or more keys, there are remaining TCAM rows whose storable bit width is greater than or equal to the bit width of the key to be stored, then one TCAM row is selected as the TCAM row that can be used to store the key to be stored. If it is determined that among the TCAM rows containing one or more keys, the remaining storable bit width of all TCAM rows is less than the bit width of the key to be stored, and if it is determined that the TCAM contains one or more TCAM rows without a stored key, then one of the TCAM rows without a stored key is selected as the TCAM row that can be used to store the key to be stored.

4. The method of claim 2, wherein, The step of storing the key to be stored into a determined TCAM row that can be used to store the key to be stored includes: When it is determined that the generated key combination information is included, and the generated key combination information contains a key that is the same as the key parameter to be stored, the key to be stored is stored in the TCAM row that can be used to store the key to be stored, according to the generated key combination information. If it is determined that the generated key combination information is not included, or the generated key combination information does not contain a key that is the same as the key parameter to be stored, the key to be stored is directly stored in the TCAM row that can be used to store the key to be stored; The parameters include bit width.

5. The method of claim 3, wherein, The step of storing the key to be stored into a determined TCAM row that can be used to store the key to be stored includes: When a TCAM row containing one or more keys is determined to be a TCAM row that can be used to store the key to be stored, the key to be stored is stored after the one or more keys already stored in that TCAM row.

6. The method according to any one of claims 2-5, characterized in that, TCAM rows that meet the following conditions are identified as TCAM rows whose remaining storable bit width is greater than or equal to the bit width of the key to be stored: M i <N i *W≤M i +W; N ≥ N1 + N2 +... + N i ; wherein, N is the total number of unit bit width that TCAM row can be used to store key, W is unit bit width, M i is the bit width of the key to be stored, N1, N2,... N i-1 respectively represent the number of unit bit width occupied by each key stored in the TCAM row, N i * W is the bit width that can be used to store the key to be stored.

7. The method according to any one of claims 1 to 5, characterized in that, The method further includes adding the following parameters to each key in the key combination information: Type information used to distinguish key types and / or location information used to identify the start and end positions of the TCAM rows occupied by each key.

8. The method according to any one of claims 1 to 5, characterized in that, Before performing the TCAM lookup based on the generated key combination information, the method further includes: Each time the key to be stored is stored in the TCAM row, a corresponding table entry for the key to be stored is generated according to the storage position of the key in the TCAM row. The table entry is used to perform the TCAM lookup.

9. A computer storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the method for TCAM storage lookup as described in any one of claims 1-8.

10. A terminal comprising: A memory and a processor, wherein the memory stores a computer program; wherein, The processor is configured to execute computer programs in memory; When the computer program is executed by the processor, it implements the method for TCAM storage lookup as described in any one of claims 1-8.