A TCAM detection method, device and storage medium
By configuring detection data and searching keywords to detect TCAM entry corruption, and using the address mapping table to repair corrupted entries, the problem of resource waste caused by corrupted entries in the TCAM memory is solved, and the utilization rate of TCAM is improved.
Patent Information
- Application Number
- CN202211513236.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-29
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2042-11-29
AI Technical Summary
TCAM memory may experience abnormalities or damage during detection and use, resulting in wasted resources. Existing technologies have failed to effectively detect and repair damaged entries.
By configuring detection data and searching keywords, TCAM entries are detected, and the address mapping table is used to map the addresses of damaged entries to the addresses of undamaged entries, thereby improving TCAM utilization.
Effectively detect and repair damaged TCAM entries, improve the utilization rate of TCAM chips, and avoid resource waste.
Smart Images

Figure CN115718686B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of TCAM detection, and in particular to a TCAM detection method, a device for implementing the method and a storage medium. BACKGROUND
[0002] TCAM is a ternary content addressable memory, mainly used for fast lookup of ACL, routing and other table items. It is developed from the basis of CAM. In general, the state of each bit in the CAM memory is only 0 or 1, while in the TCAM, each bit has three states, in addition to 0 and 1, there is also a don't care state, so it is called ternary.
[0003] TCAM is a special kind of memory, and traditional memory is read out according to the address, such as static memory (SRAM) and dynamic access memory (DRAM), while TCAM is obtained according to the corresponding address of the stored content. When implemented, a data (called lookup content or lookup key) is input, the lookup key and the entries stored in the TCAM are compared in parallel, and then the matching address is output. If there are multiple entries that match the lookup key, the smallest address is output.
[0004] TCAM supports exact lookup and fuzzy matching, and the basic unit of TCAM is composed of a data part (data) and a mask part (mask). The mask determines which part of the data needs to participate in the comparison and which part does not participate in the comparison. We can achieve exact lookup and fuzzy matching by configuring different masks. Each TCAM occupies a size of 80 bits, 160 bits, 320 bits, and 640 bits. Each 80 bits (a minimum TCAM entry) has a valid bit to indicate whether the TCAM is valid. Only in the case of validity, it participates in the TCAM lookup. Through the combination of data and mask, ternary can be achieved, that is, each bit can be 0, 1 or X (don't care).
[0005] Although TCAM is faster than SRAM and DRAM memory in terms of lookup speed, TCAM is more expensive. In actual application, due to the existence of abnormal detection mechanism in the early stage, part of the TCAM is abnormal and not detected, or part of the TCAM entries is invalid during the use of the chip, which causes the entire TCAM chip to be unable to continue to be used, ultimately resulting in resource waste.
[0006] The information disclosed in this BACKGROUND section is only intended to increase an understanding of the general background of the application and should not be construed as a recognition of the prior art of any form. SUMMARY
[0007] The present application aims to provide a TCAM detection method, device and storage medium, which can detect the entries in the TCAM to detect whether the corresponding entries are damaged, and when damage is detected, map the damaged entry address to the undamaged entry address based on the address mapping table existing inside the TCAM, thereby effectively improving the TCAM utilization.
[0008] To achieve the above-mentioned purpose, the embodiments of the present application provide a TCAM detection method, which comprises:
[0009] A plurality of detection data are configured for each TCAM entry, and the plurality of detection data are formed by configuring each bit of the TCAM entry, and each bit is configured as 1 or 0 when configured;
[0010] A plurality of search keys are configured for each detection data of each TCAM entry, and the plurality of search keys at least include a first search key that can hit the corresponding entry and a second search key that does not hit the corresponding entry;
[0011] The corresponding plurality of search keys of each TCAM entry are sequentially used for TCAM search;
[0012] In response to the search result being a search failure, the damaged TCAM entry address is mapped to the undamaged entry address based on the address mapping table existing inside the chip.
[0013] In one or more embodiments of the present application, the detection data include a data detection part and a mask detection part, and the first search key is formed by logical operation of the data detection part and the mask detection part.
[0014] In one or more embodiments of the present application, the first search key is formed by logical AND operation of the data detection part and the mask detection part.
[0015] In one or more embodiments of the present application, the second search key is obtained by performing a NOT operation on the first search key.
[0016] In one or more embodiments of the present application, the search key further includes a third search key, when the data detection part is all 0, the third search key is a single bit of 1 from the lowest bit and is left shifted by 1 after each search.
[0017] In one or more embodiments of the present application, the search key further comprises a fourth search key, when all bits of the data detection part are 1, the fourth search key is a single bit of 0 from the lowest bit and left shift 1 bit after each search.
[0018] In one or more embodiments of the present application, the search failure is selected from one of the following:
[0019] the expected search result is found, but the actual search result is not found,
[0020] the expected search result is not found, but the actual search result is found,
[0021] the expected search result is not found, but the actual search result is found.
[0022] The present application also provides a TCAM detection device, comprising:
[0023] a first configuration module, configured to configure a plurality of detection data for each entry in the TCAM, the plurality of detection data being formed by configuring each bit of the TCAM entry, and each bit being configured to 1 or 0 when configured;
[0024] a second configuration module, configured to configure a plurality of search keys for each detection data of each entry, the plurality of search keys at least comprising a first search key expected to find the corresponding entry and output an address expected to be the expected address, and a second search key expected not to find the corresponding entry;
[0025] a search module, configured to sequentially search the TCAM for each TCAM entry using its corresponding plurality of search keys;
[0026] a mapping module, configured to, in response to a search result being a search failure, map a damaged TCAM entry address to a non-damaged entry address based on an address mapping table existing in the chip.
[0027] The present application also provides a TCAM detection device, comprising:
[0028] at least one processor;
[0029] at least one memory coupled to the at least one processor and storing a computer program for execution by the at least one processor, the computer program being executed by the at least one processor to cause the electronic device to perform the method described above.
[0030] The present application also provides a computer readable storage medium having a computer program stored thereon, the computer program being executed by a machine to implement the method described above.
[0031] Compared with the prior art, the application can detect the entries in the TCAM to detect whether the corresponding entries are damaged, and when damage is detected, map the damaged entry address to the undamaged entry address based on the address mapping table existing inside the TCAM, thereby effectively improving the utilization rate of the TCAM. BRIEF DESCRIPTION OF DRAWINGS
[0032] Figure 1 is a TCAM detection method flow chart according to an embodiment of the application;
[0033] Figure 2 is a TCAM detection flow chart according to an embodiment of the application;
[0034] Figure 3 is a schematic diagram of the TCAM without damage;
[0035] Figure 4 is a schematic diagram of the TCAM with damage;
[0036] Figure 5 is a TCAM detection device structure block diagram according to an embodiment of the application. DETAILED DESCRIPTION
[0037] The specific embodiments of the application will be described in detail below with reference to the accompanying drawings, but it should be understood that the protection scope of the application is not limited by the specific embodiments.
[0038] Unless otherwise clearly indicated, in the entire specification and claims, the term "comprise" or its variants such as "contain" or "include" and the like will be understood to include the stated element or component, but not to exclude the presence of other elements or components.
[0039] In combination Figure 1 and Figure 2 As shown, according to a TCAM detection method according to a preferred embodiment of the application, the entries in the TCAM can be detected to detect whether the corresponding entries are damaged, and when damage is detected, the damaged entry address is mapped to the undamaged entry address based on the address mapping table existing inside the TCAM, thereby effectively improving the utilization rate of the TCAM.
[0040] Specifically, the TCAM detection method comprises the following steps:
[0041] First, configure several detection data for each entry in the TCAM, and the several detection data are formed by configuring each bit of the TCAM entry, and each bit is configured to be 1 or 0 when configured;
[0042] Specifically, in order to detect whether each entry in the TCAM is damaged. First, configure detection data for each entry, which can be used to detect whether the entry is damaged. Since in the TCAM, each entry includes a data part (Data), a mask part (Mask) and a value (Valid) part, when configuring detection data, the configured detection data needs to cover the data part, the mask part and the value part of the entry to improve the accuracy of detection. The detection data here includes a data detection part, a mask detection part and a value detection part. In implementation, the detection data can be formed by configuring each bit of the entry, that is, for each bit of the entry, it is assigned a value, such as 0 or 1, for example, for each bit of the data part, it is assigned a value to form the data detection part in the detection data; for each bit of the mask part, it is assigned a value to form the mask detection part in the detection data; for each bit of the value part, it is assigned a value to form the value detection part in the detection data.
[0043] Further, when configuring, each bit needs to be configured to 0 or 1, that is, the detection data needs to cover the case of assigning 0 or 1 to each bit to improve the accuracy of detection. The following takes the TCAM entry that can output address 0 as an example to configure detection data. When configuring detection data, the data part (Data) can be selected from all 0, all 0xF, all 0x5, and all 0xA, while the mask part can be configured according to actual needs, such as all 0xF or all 0x5, etc.; the value part can be configured to 0 or 1 according to actual needs. A total of 9 different detection data are configured, as shown in the following table:
[0044]
[0045] Secondly, configure a plurality of search keys for each detection data of each entry, and the plurality of search keys at least include a first search key for expecting to search the corresponding entry and output an expected address, and a second search key for expecting not to search the corresponding entry.
[0046] Specifically, after configuring detection data for each entry, further configure a plurality of search keys (Key) for each detection data to select whether to use the corresponding search key to hit the entry according to actual needs, where hitting means searching the relevant entry. The search key here at least includes a first search key and a second search key, wherein the first search key is a key for expecting to search the corresponding entry and output an expected address, and the second search key is a key for expecting not to search the corresponding entry.
[0047] In implementation, the first search key can be obtained by logically operating the data detection part with the mask detection part. For example, the first search key is obtained by logically ANDing the data detection part with the mask detection part. The second search key can be set according to actual requirements, as long as it cannot hit the corresponding entry. In implementation, the second search key is preferably obtained by performing a NOT operation on the first search key. For example, when the first search key is 0x5, the second search key obtained by performing a NOT operation on the first search key is 0xA. As shown in the above table, a plurality of search keys are configured for the above nine detection data. For example, for the first detection data, the first search key is configured as 0x5, and it is expected that the corresponding entry can be hit by the first search key, and the output address is address 0; the second search key is configured as 0xA, and it is expected that the corresponding entry cannot be hit by the second search key.
[0048] Further, when configuring the search key for each detection data, other bit positions taking different values also need to be considered to affect the current bit position. In this embodiment, for the case that the data detection part is all 0 or all 1, a corresponding third search key can also be configured. For example, for the case that the data detection part is all 0, the third search key is that a single bit is 1 from the lowest bit position and is left shifted by 1 after each search. For example, for the case that the data detection part is all 1, the third search key is that a single bit is 0 from the lowest bit position and is left shifted by 1 after each search. As shown in the above table, for the eighth detection data and the ninth detection data, the third search keys are respectively configured as that a single bit is 1 from the lowest bit position and is left shifted by 1 after each search, and that a single bit is 0 from the lowest bit position and is left shifted by 1 after each search.
[0049] Further, each TCAM entry is sequentially searched by using a plurality of search keys corresponding to the TCAM entry.
[0050] Specifically, after the corresponding detection data and search key are configured for each entry, a search operation is further performed. In implementation, as shown in the figure, after the TCAM search operation is enabled by using the functions provided by the chip, each TCAM entry is sequentially searched by using a plurality of search keys corresponding to the TCAM entry.
[0051] Finally, in response to the search result being a search failure, the damaged TCAM entry address is mapped to a non-damaged entry address based on the address mapping table existing in the chip.
[0052] Specifically, when performing TCAM lookup for each entry with its corresponding lookup key, there are usually two cases for the lookup result, one is a lookup pass case, and the other is a lookup fail case. For the lookup pass case, it includes (1) expected to be able to find, actually found and the address output by the lookup result is consistent with the expectation, such as in the configuration, it is expected to find entry 1 with lookup key 0x5, and the address output is address 0, while performing TCAM lookup, entry 1 is hit with lookup key 0x5, and the address output is consistent with the expected address, which is address 0. (2) expected not to be able to find, actually not found.
[0053] For the lookup fail case, it includes (1) expected to be able to find, actually can find, but the address output by the lookup result does not meet the expectation, such as in the configuration, it is expected to find entry 1 with lookup key 0x5, and the address output is address 0, while performing TCAM lookup, entry 1 is hit with lookup key 0x5, but the address output is address 1, which is inconsistent with the expected address. (2) expected to be able to find, actually not found; (3) expected not to be able to find, actually found.
[0054] When the lookup result is a lookup fail, the damaged TCAM entry address is mapped to a non-damaged entry address based on the address mapping table existing in the chip, thereby improving the utilization rate of the TCAM chip. In combination with Figure 3 and Figure 4 , it is shown that Figure 3 when the TCAM does not exist damage, Figure 4 when the TCAM exists damage. When the TCAM does not exist damage, the access address transmitted by the CPU and the actual access address of the chip are one-to-one mapped. When the TCAM exists damage, such as detecting that entry 2 and entry 6 exist damage through the above TCAM detection method, the TCAM chip can automatically complete the avoidance of the damaged TCAM entry through the address mapping table, such as Figure 4 , when the CPU accesses the address of TCAM entry 2, because TCAM entry 2 is damaged, the actual chip accesses the address of TCAM entry 3 through the chip address mapping, and the actual chip accesses the address of TCAM entry 5 corresponding to entry 4, and the actual chip accesses the address of TCAM entry 7 corresponding to entry 5 when the CPU accesses the address of entry 5, because TCAM entry 6 is damaged, and so on, when the CPU accesses TCAM entries 10 and 11, the chip is automatically mapped to the invalid address 0xFFFFFFFF.
[0055] After the mapping is completed, the number of TCAM entries accessible by the CPU is the number of valid TCAM entries minus the number of damaged TCAM entries.
[0056] Further, as Figure 2As shown, after mapping is complete (i.e., TCAM isolation), it is further determined whether the search has ended. If the search has not ended, the TCAM search keywords can be reconfigured and subsequent detection processes can be executed. If the search has ended, it is further determined whether the TCAM entry has been detected, and if not, the TCAM detection data is reconfigured and subsequent detection processes are executed.
[0057] This invention configures different TCAM lookup keywords and uses these keywords to detect TCAM damaged entries one by one. When a TCAM damaged entry is detected, based on the address mapping table inside the chip, the address of the damaged entry is mapped to the address of an undamaged entry, thereby effectively improving chip utilization.
[0058] like Figure 5 As shown, the present invention also provides a TCAM detection device that can implement the above-mentioned TCAM detection method, comprising a first configuration module, a second configuration module, a search module, and a mapping module. The first configuration module is used to configure several detection data for each TCAM entry. The several detection data are formed by configuring each bit of the TCAM entry, and each bit is configured with either 1 or 0 during configuration. The second configuration module is used to configure several search keywords for each detection data of each entry. The several search keywords include at least a first search keyword that expects to find the corresponding entry and output the desired address, and a second search keyword that expects not to find the corresponding entry. The search module is used to sequentially perform a TCAM search for each TCAM entry using its corresponding search keywords. The mapping module is used to, in response to a search failure, map the address of the damaged TCAM entry to the address of an undamaged entry based on an address mapping table existing within the chip.
[0059] How each module implements the above functions is detailed above and will not be repeated here.
[0060] The application further provides a TCAM detection device, which can include but is not limited to a personal computer, a server computer, a workstation, a desktop computer, a laptop computer, a notebook computer, a mobile electronic device, a smart phone, a tablet computer, a cellular phone, a personal digital assistant (PDA), a handheld device, a messaging device, a wearable electronic device, a consumer electronic device, and the like. The TCAM detection device can implement the TCAM detection method described above, can detect the entries in the TCAM to detect whether the corresponding entries are damaged, and when damage is detected, can map the damaged entry address to an undamaged entry address based on the address mapping table existing in the TCAM, thereby effectively improving the utilization rate of the TCAM. Specifically, the TCAM detection device includes at least one memory, at least one processor, and a computer program, the at least one memory is coupled to the at least one processor, wherein the computer program is stored in the memory and can be executed in the processor, such as the computer program being a TCAM detection program, and the like. When implemented, the processor can implement each step in the TCAM detection method described above when executing the computer program, such as configuring a plurality of detection data for each TCAM entry, the plurality of detection data being formed by configuring each bit of the TCAM entry, and each bit being configured as 1 or 0, and the like.
[0061] The computer program herein can be divided into one or more units, which are stored in the memory and executed by the memory to complete the application. One or more units can be a series of computer program instruction segments capable of completing a specific function, which are used to describe the execution process of the computer program in the electronic device.
[0062] It should be noted that the electronic device herein includes but is not limited to the memory, the processor, and the computer program described above, and can further include other components, such as an input device (such as a keyboard, and the like) for inputting prediction information, a communication interface, and the like, which communicate with each other through a bus.
[0063] The application further discloses a computer readable storage medium, which stores a computer program, and the computer program can implement the TCAM detection method described above when executed by a processor. The computer program includes computer program code, which can be in the form of source code, an executable file, or some intermediate form, and the computer readable medium can include any entity or device, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), and the like, which can carry the computer program code.
[0064] Those skilled in the art will appreciate that embodiments of the present application can be readily used as a method, a system or a computer program product. Accordingly, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application can take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage devices, etc.) embodying computer readable program code.
[0065] The present application is described in reference to the flowchart illustrations and / or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processing system or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart illustrations and / or block diagrams block or blocks. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams block or blocks. Figure 1 means for carrying out each of the
[0066] These computer program instructions can also be stored in a computer- readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the function specified in the flowchart illustrations and / or block diagrams block or blocks. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams block or blocks. Figure 1 means for carrying out each of the
[0067] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart illustrations and / or block diagrams block or blocks. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams block or blocks. Figure 1 means for carrying out each of the
[0068] The foregoing description of specific exemplary embodiments of the application has been presented for the purposes of illustration and description. It is not intended to be exhaustive or to limit the application to the precise forms disclosed, and obviously many modifications and variations are possible in light of the above teaching. It is intended that the scope of the application be limited not with this detailed description, but rather by the claims appended hereto.
Claims
1. A TCAM detection method, characterized in that, The TCAM detection method includes: For each entry in TCAM, several detection data are configured. The several detection data are formed by configuring each bit of the TCAM entry, and each bit is configured to be 1 or 0 during configuration. For each detection data of each entry, several search keywords are configured. The several search keywords include at least a first search keyword that expects to find the corresponding entry and output the expected address, and a second search keyword that expects not to find the corresponding entry. For each TCAM entry, a TCAM search is performed sequentially using its corresponding search keywords; If the lookup result is a failure, the corrupted TCAM entry address is mapped to the uncorrupted entry address based on the address mapping table existing inside the chip.
2. The TCAM detection method as described in claim 1, characterized in that, The detection data includes a data detection part and a mask detection part, and the first search keyword is formed by logical operations of the data detection part and the mask detection part.
3. The TCAM detection method as described in claim 2, characterized in that, The first search keyword is formed by the logical AND operation of the data detection part and the mask detection part.
4. The TCAM detection method as described in claim 2, characterized in that, The second search keyword is obtained by inverting the first search keyword.
5. The TCAM detection method as described in claim 2, characterized in that, The search keyword also includes a third search keyword. When all data detection bits are 0, the third search keyword is a single bit that is 1 starting from the least significant bit and shifted left by 1 bit after each search.
6. The TCAM detection method as described in claim 2 or 5, characterized in that, The search keyword also includes a fourth search keyword. When all data detection bits are 1, the fourth search keyword is a single bit that is 0 starting from the least significant bit and shifted left by 1 bit after each search.
7. The TCAM detection method as described in claim 1, characterized in that, The search failure is selected from one of the following: It was expected to be found, and it was indeed found, but the address output by the search results did not match the expectation; I was hoping to find it, but I couldn't. I expected not to find it, but I actually found it.
8. A TCAM inspection device, characterized in that, The TCAM detection device includes: The first configuration module is used to configure several detection data for each entry in the TCAM. The several detection data are formed by configuring each bit of the TCAM entry, and each bit is configured to be 1 or 0 during configuration. The second configuration module is used to configure several search keywords for each detection data of each entry. The several search keywords include at least a first search keyword that expects to find the corresponding entry and output the expected address, and a second search keyword that expects not to find the corresponding entry. The search module is used to sequentially perform a TCAM search for each TCAM entry using its corresponding search keywords; The mapping module is used to map the address of the corrupted TCAM entry to the address of the uncorrupted entry based on the address mapping table existing inside the chip if the search result is a search failure.
9. A TCAM inspection device, characterized in that, The TCAM detection device includes: At least one processor; At least one memory, coupled to the at least one processor and storing a computer program for execution by the at least one processor, wherein, when executed by the at least one processor, the computer program causes the TCAM inspection device to perform the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by a machine, implements the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Method for quickly searching keywords and reading lists by using ternary content addressable memory (TCAM)
CN102402611A
Method of error detection in ternary content addressable memory
CN112447254A