TCAM Matching Search Method and Device
By using RAM and pipeline processing in TCAM matching search, combined with linear, step-by-step and list search, the problems of high power consumption and high cost of TCAM devices are solved, and efficient and low-cost high-speed search capabilities are achieved.
Patent Information
- Application Number
- CN202211194609.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-29
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2042-09-29
AI Technical Summary
Existing TCAM devices consume high power, cost, and are difficult to obtain in some scenarios in high-speed search applications.
RAM is used for table entries storage and search, and through pipeline processing, combining linear search, step-by-step search and list search to realize TCAM matching search.
It significantly reduces the power consumption and cost of the search system, achieves extremely high search throughput, and can complete a search request in one clock cycle.
Smart Images

Figure CN115604208B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of communication technologies, and more specifically, relates to a TCAM matching search method and apparatus. Background Art
[0002] As the speed and accuracy of artificial intelligence (AI) gradually approach those of the human brain, various systems are increasingly relying on data center servers to connect applications from the edge to the cloud. Due to the explosive growth in the number of devices connected to the Internet and the exponential growth of Internet traffic, today's systems often require extremely fast search speeds in many cases. A router is a key component of network devices and needs to decide where to send a received data packet after receiving it to perform Internet Protocol (IP) forwarding (or routing). Today's routers need to perform fast lookups in a large amount of data to achieve fast data packet routing. Other applications that require high-speed searches also include the CPU (Central Processing Unit), database search engines, etc.
[0003] Although designers have various options to perform these searches, the most effective method is still to use TCAM (Ternary Content Addressable Memory). TCAM compares the search data with a table listing the stored data and returns the address of the matching data. The TCAM search function runs much faster than its counterpart in software, so TCAM is widely used in network devices. For example, address lookup, data compression, and database acceleration in Internet routers.
[0004] TCAM is a ternary content addressable memory mainly used for quickly looking up entries such as ACL (Access Control List) and routing tables. Each bit in TCAM has three states. In addition to "0" and "1", there is also a don't care state. It is this state characteristic of TCAM that enables it to perform both exact match lookups and fuzzy match lookups.
[0005] When using a TCAM device for lookup, all entries in the TCAM are accessed in parallel. For example, if there are 100 ACL entries, the TCAM can perform comparison operations on these 100 ACLs at once and then return the address where the comparison is successful. Therefore, TCAM also has an advantage in lookup performance.
[0006] Although TCAM has performance advantages, it requires a larger area and higher power consumption. Compared with the commonly used RAM (Random Access Memory), each individual storage bit in TCAM must have a comparison circuit to detect the match between the storage bit and the input bit. In addition, when using TCAM, since all entries are searched in parallel during the search time, a large number of circuits are active. Therefore, the power consumption of TCAM is also very high.
[0007] Using TCAM for lookup has the advantages of fast speed and simple implementation, but there are also some deficiencies:
[0008] As a dedicated device, TCAM requires additional IP costs (when using TCAM inside the chip) or device costs (when using TCAM as an external device), and in some scenarios (such as inside an FPGA), TCAM is not easily available.
[0009] Since TCAM uses a parallel matching comparison method, the power consumption of the TCAM chip is large, resulting in a high power consumption of the chip or system. Summary of the Invention
[0010] In view of the above deficiencies of the prior art, the present invention provides a TCAM matching lookup scheme, which uses RAM for table entry storage and lookup, and through pipeline processing, can obtain extremely high lookup throughput, achieving a speed of completing one lookup request in one clock cycle. Using this method does not require purchasing relevant TCAM IP or devices, which can significantly reduce the cost of the lookup system. At the same time, using RAM for storage and table lookup also significantly reduces the power consumption of the system.
[0011] To achieve the above object, according to one aspect of the present invention, a TCAM matching lookup method is provided, the method includes: adopting a segmented lookup method, combining linear lookup, step-by-step lookup and list lookup to implement the TCAM matching lookup method, and improving the system lookup performance through pipeline processing, wherein:
[0012] The segmented lookup is to divide the content to be looked up into several segments for multi-level lookup;
[0013] The linear lookup method directly uses the content to be looked up as the access address of the memory, and uses the access result as the matching lookup result;
[0014] The step-by-step lookup adopts a multi-branch tree lookup method;
[0015] The list lookup method stores the table entries in the form of a list in the memory. When looking up, the table entry configurations in the storage space are compared one by one to find the matching lookup result.
[0016] In one embodiment of the present invention, linear search, step-by-step search, and list search are combined, specifically as follows:
[0017] A structure composed of a linear search unit and several step-by-step and list search units is adopted. N step-by-step and list search units follow the linear search unit. The matching search proceeds in a pipelined manner from the linear search unit through the N step-by-step and list search units in sequence, and each stage performs the search in a pipelined manner until a matching path is found. The arbitration of the search results is performed at each stage, and the final search result is output. N is a preset value.
[0018] In one embodiment of the present invention, the linear search unit is composed of a linear entry storage unit and a linear search control unit. The input signal of the linear search unit is the input signal key to be searched. The linear search control unit takes the n highest bits of the key as the address to access the linear entry storage unit according to the set search length n of this unit. The linear entry storage unit is used to store the search table entries.
[0019] In one embodiment of the present invention, the data structure required for implementing the look-up table operation is stored in the linear entry storage unit. The numbers on both sides of the arrow in the data structure illustrate the corresponding relationship between the data structures connected by the arrow. Specifically:
[0020] 1. Take the first n bits of the key, that is, the first n bits as the address to access the linear entry storage unit and obtain a linear entry;
[0021] 2. Take m bits from the high bits of the key that have not participated in the search yet and participate in the address access of the next level;
[0022] 3. Use k bits of a certain step-by-step search segment of the key as the address to access the sub-entry in this level;
[0023] 4. The list contains 0 to validNum list sub-entries. The length of the key taken is based on StrideLen2 in the previous matching entry. ValidNum represents the number of sub-entries StrideEntry contained in the entry;
[0024] 5. It means accessing the step-by-step and list entries according to TileIndexNext and BlockIndexNext.
[0025] In one embodiment of the present invention, the step-by-step and list search unit consists of a step-by-step and list entry storage unit and a step-by-step and list search control unit. The step-by-step and list entry storage unit stores search entries. The step-by-step and list search control unit is used to perform the following operations after receiving the previous-stage input signal: Step 1: Determine the value of TileIndexNext. If it indicates that there is no need to continue table lookup, then do not perform table lookup, directly send out the input result, and jump to Step 6; Step 2: Determine whether TileIndexNext is equal to the number of this step-by-step and list search unit. If not, then do not perform table lookup, directly send out the input result, and jump to Step 6; if equal, then continue to Step 3; Step 3: Access the table entry according to BlockIndexNext, and then jump to Step 4; Step 4: Take the high StrideLenNext bits of KeyRemainingBits, denoted as key_k, and then jump to Step 5; Step 5: Determine the value of CmdNext. If it indicates that step-by-step search is to be performed, jump to the step-by-step search step; otherwise, jump to the list search step; Step 6: End this search.
[0026] Among them, TileIndexNext represents the step-by-step and list unit for the next table lookup, BlockIndexNext represents the database address in the step-by-step and list unit for the next lookup, KeyRemainingBits represents the key data that has not participated in the lookup yet, StrideLenNext represents the table lookup bit width for the next lookup, and CmdNext represents the type of the next table lookup.
[0027] In one embodiment of the present invention, before the lookup, entry configuration is first performed. It is necessary to segment the key value to be looked up, segment it from the high bit to the low bit of the key value. Take a fixed value for the first segment of all key values for linear search; the other segments correspond to each step-by-step and list search unit in turn. For the same key value, the same or different segments can be allocated to each unit; for different key values, the segmented values can be found according to the entry configuration; then the entries to be looked up are configured in turn.
[0028] In one embodiment of the present invention, segmenting a certain key value to be looked up specifically is as follows:
[0029] The first segment is n bits for linear search, and then several m + k bits correspond to step-by-step and list search 1, using step-by-step or list search; then several segments of k bits, respectively corresponding to the corresponding step-by-step and list search units, using step-by-step search, several segments of x bits, respectively corresponding to the corresponding step-by-step and list search units, using list search, and finally a segment of y bits, corresponding to the corresponding step-by-step and list search unit, using list search. Then configure these segments well. When looking up, take the relevant segments of the key for lookup respectively.
[0030] The n, m, k, x, and y are all configurable values, and different m, k, x, and y values can be assigned to each step and list search unit entry for different key values.
[0031] In an embodiment of the present invention, the size of the first segment n determines the address bit width of the linear entry storage unit, and the address bit width of this unit must be greater than or equal to n, that is, this unit must ensure that there are 2^n storage entries;
[0032] The size of m is determined by the address bit width of the step and list entry storage unit, and the address bit width of this unit must be greater than or equal to m, that is, this unit must ensure that there are at least 2^m storage entries;
[0033] The k segment corresponds to the step search in the step and list search. Since step entries need to be stored in this unit, and 2^k sub-step entries are to be stored in one step entry;
[0034] The x segment corresponds to the list search in the step and list search. List entries need to be stored in this unit. Under the condition of the selected entry bit width, the selected x value should ensure that the list entries can carry at least one list sub-entry;
[0035] The setting principle of the y segment is the same as that of the x segment.
[0036] In an embodiment of the present invention, during the search, first, a linear unit search is performed to generate an inter-module signal; then, it sequentially enters each step and list search unit, that is, step and list search 1 to step and list search N. In each unit, it is judged whether TileIndexNext matches this unit. For the matching ones, the search and update of the intermediate information of the look-up table are performed at this level, and then the search of the subsequent units continues. For the non-matching ones, the search of the subsequent units is directly performed. Until all units are searched, MathFieldNext in the intermediate signal of the look-up table output by the step and list search unit N is the final search result.
[0037] According to another aspect of the present invention, there is also provided a TCAM matching search device, including at least one processor and a memory. The at least one processor and the memory are connected through a data bus. The memory stores instructions executable by the at least one processor. After being executed by the processor, the instructions are used to complete the TCAM matching search method described above.
[0038] Generally speaking, compared with the prior art through the above technical solutions conceived by the present invention, the following beneficial effects are achieved:
[0039] (1) The matching and searching method of the present invention can achieve the TCAM table lookup method through a combination of linear search, step-by-step search, and list search, reducing the cost of purchasing TCAM IP or devices; in the case where it is difficult to obtain TCAM resources, it is an effective implementation path, improving resource utilization and having more flexible configuration;
[0040] (2) By selecting the position of the search unit, the present invention can flexibly use each search resource while maintaining the search efficiency;
[0041] (3) By processing list entries and step-by-step entries together, there is no need to specially allocate a new dedicated area, improving the consistency of the structure. This consistent structure improves the flexibility of programming;
[0042] (4) Using list search further reduces the resource scale when all are implemented with step-by-step entries, and the width of list matching is configurable; using list search can also make a variable search length appear in the middle of a fixed-length step-by-step search, which can simplify the storage of matching table information with the same position and the same field. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 is the overall structure diagram of the present invention;
[0044] Figure 2 is the structure diagram of the linear search unit of the present invention;
[0045] Figure 3 is the structure diagram of the step-by-step and list search unit of the present invention;
[0046] Figure 4 is the diagram of an embodiment of segment configuration of a key value of the present invention;
[0047] Figure 5 is the relationship diagram between various data configurations required for the table lookup operation of the present invention;
[0048] Figure 6 is the search flow chart of the present invention;
[0049] Figure 7 is the diagram of an embodiment of the entry to be searched of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0050] In order to make the objectives, technical solutions and advantages of the present invention clearer and more understandable, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention. In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0051] The present invention belongs to the field of communications, and more specifically to the field of flow identification and processing in a communication system, applicable to ACL, IP LPM (Longest Prefix Match), and flow table functions; meanwhile, the invention is also applicable to other applications that require high-speed searching, including applications such as CPUs and database search engines.
[0052] The present invention discloses a RAM-based TCAM matching and searching method, which adopts a segmented searching method, combines linear searching, step-by-step searching, and list searching to implement the TCAM matching and searching method, and improves the system searching performance through a pipeline processing method.
[0053] By using the method of the present invention, the corresponding functions can be realized without using TCAM, and it can also be realized in an FPGA lacking TCAM, making the application scenarios more extensive.
[0054] The so-called segmented searching is to divide the content to be searched into several segments for multi-level searching; that is, divide the content to be searched into several segments for multi-level segmented searching, and different searching methods can be used for each segment respectively;
[0055] The linear searching method: directly use the content to be searched as the access address of the memory, and use the access result as the matching and searching result; when using the linear searching method for segments, use the segment value as the address for accessing the memory. The disadvantage of this method is the address diffusion problem, where each front segment entry corresponds to 2 k entries of the subsequent segment (k is the segment width corresponding to the subsequent segment);
[0056] The step-by-step searching adopts a multi-branch tree searching method; when using the multi-branch tree searching method for segments, it can effectively prevent the address diffusion of segments. The step-by-step searching refers to using the multi-branch tree searching for segments;
[0057] The list searching method: store the table entries continuously in the memory (RAM) in the form of a list. When searching, compare the table entries in the storage space one by one to find the matching and searching result. The mask corresponding to the data is also stored in the memory for list searching to further select the data to participate in the comparison.
[0058] The present invention comprehensively uses three searching methods: linear searching, step-by-step searching, and list searching, and uses the segmented method to flexibly combine the above three searchings together, and processes each segment by means of pipeline processing, improving the efficiency of table lookup.
[0059] The principle of the invention is as Figure 1As shown in the figure, in order to combine linear search, step-by-step search, and list search, the present invention adopts a structure composed of a linear search unit and several step-by-step and list search units (N step-by-step and list search units are given in the figure). N step-by-step and list search units (corresponding to 1 to N respectively) follow the linear search unit. The matching search is carried out in a pipeline manner from the linear search unit through N step-by-step and list search units in sequence, and each stage uses a pipeline manner for searching until a matching path is found. The arbitration of the search results is carried out at each stage, and the final search result is output.
[0060] The matching search method of the present invention can achieve the TCAM table lookup method by combining linear search, step-by-step search, and list search, reducing the cost of purchasing TCAM IP or devices; in the case where it is difficult to obtain TCAM resources, it is an effective implementation path, improving resource utilization and having more flexible configuration.
[0061] The structure of the linear search unit is as Figure 2 shown, and it is composed of a linear entry storage unit and a linear search control unit. The input signal of the linear search unit is the input signal to be searched (hereinafter referred to as key). The linear search control unit uses the search length n set in this unit to take the n highest bits of the key (for example, assuming the bit width of the key is w, and bit 0 is the highest bit, i.e., key[0:w - 1], taking n highest bits (n is less than or equal to w), i.e., key[0:n - 1], and the following description is the same hereinafter) as the address to access the linear entry storage unit.
[0062] The linear entry storage unit stores the lookup table entries, and its entry structure is as follows:
[0063]
[0064]
[0065] After the search, the intermediate information of the table lookup is output:
[0066] TileIndexNext: Represents the step-by-step and list unit for the next table lookup, taking the TileIndex in the table entry;
[0067] BlockIndexNext: Represents the database address in the step-by-step and list unit for the next search. When StrideLen1 in the table entry is 0, take the BlockIndex in the table entry; otherwise, the value is BlockIndex + key[n:StrideLen1 + n - 1], where key[n:StrideLen1 + n - 1] is the remaining part of the input key after subtracting the linear search part, taking the high StrideLen1 bits;
[0068] StrideLenNext: It represents the width of the lookup table position for the next search, and takes the value StrideLen2 in the table entry;
[0069] KeyRemainingBits: It represents the key data that has not participated in the search, and is equal to the input key minus key[0:StrideLen1+n-1], that is, minus the part participating in the linear search and the StrideLen1 part participating in the next search;
[0070] CmdNext: It represents the type of the next lookup table, and takes Cmd in the table entry;
[0071] MathFieldNext: Take the value MathField in the table entry.
[0072] The structure of the step-by-step sum and list lookup unit is as Figure 3 shown, and it consists of a step-by-step sum and list entry storage unit and a step-by-step sum and list lookup control unit.
[0073] The step-by-step sum and list entry storage unit stores lookup entries, and the specific data structure is as follows:
[0074] When used for step-by-step search, the table entry structure is as follows:
[0075] Domain Name Domain Description <![CDATA[StrideEntry2 k -1]]> <![CDATA[Sub-entry 2 k -1(StrideEntry)]]> … StrideEntry1 Sub - entry 1 StrideEntry0 Sub - entry 0
[0076] The data structure of the sub-entry (StrideEntry) is the same as that of the linear entry table entry.
[0077] When used for list search, the table entry structure is as follows:
[0078]
[0079]
[0080] Instructions for using StrideEntryLen: Denote the data fields of StrideEntry0 to StrideEntryn-1 as StrideEntryT, then StrideEntry#i = StrideEntryT[i×StrideEntryLen:(i+1)×StrideEntryLen-1], where i is a variable, and #i represents taking the value of i.
[0081] For example, assume that in a certain entry: ValidNum = 3, StrideEntryLen = 20, and there are 77 bits in StrideEntry0 to StrideEntryn - 1, denoted as StrideEntryT[0:76]. Then StrideEntry0 = StrideEntryT[0:19]; StrideEntry1 = StrideEntryT[20:39]; StrideEntry2 = StrideEntryT[40:59], and no valid data is stored in StrideEntryT[60:76].
[0082] When used for list search, the StrideEntry structure:
[0083]
[0084] The function of the step - by - step and list search control unit is to perform the following operations after receiving the previous - stage input signals (i.e., the following TileIndexNext, BlockIndexNext, StrideLenNext, CmdNext, KeyRemainingBits, MathFieldNext):
[0085] Step 1: If the value of TileIndexNext indicates that there is no need to continue looking up the table (for example, 0 means no need to continue looking up the table), then do not perform the table lookup, directly send out the input result, and jump to Step 6;
[0086] Step 2: Determine whether TileIndexNext is equal to the number of this step - by - step and list search unit. If not, then do not perform the table lookup, directly send out the input result, and jump to Step 6; if equal, continue to Step 3;
[0087] Step 3: Access the table entry according to BlockIndexNext, and then jump to Step 4;
[0088] Step 4: Take the high StrideLenNext bits of KeyRemainingBits (i.e., KeyRemainingBits[0:StrideLenNext - 1]), denoted as key_k (the signal width is k bits, k = StrideLenNext), and then jump to Step 5;
[0089] Step 5: Determine the value of CmdNext. If it indicates that a step - by - step search is to be performed (for example, 0 means a step - by - step search is to be performed), jump to the step - by - step search steps; otherwise, jump to the list search steps;
[0090] Step 6: This search ends.
[0091] The present invention processes list entries and step-by-step entries together without the need to specifically allocate a new dedicated area, improving the consistency of the structure. This consistent structure enhances the programmability flexibility.
[0092] The steps for step-by-step search are as follows:
[0093] Step 1: Select the corresponding entry according to key_k (when the key_k encoding value is 0, select StrideEntry0; when the encoding value is 2 k -1, select StrideEntry2 k -1 and so on for other encodings), and jump to Step 2;
[0094] Step 2: Update the intermediate information for table lookup:
[0095] KeyRemainingBits: Remove the input KeyRemainingBits[0:StrideLenNext + StrideLen1 - 1] from the input KeyRemainingBits (where StrideLenNext is the input value and StrideLen1 is the value in the corresponding entry selected according to key_k), that is, remove the key_k part involved in the search and the StrideLen1 part involved in the update of BlockIndexNext after this search from the input KeyRemainingBits;
[0096] TileIndexNext: Take the entry value TileIndex;
[0097] BlockIndexNext: When the entry value StrideLen1 is 0, BlockIndexNext takes the entry value BlockIndex; otherwise BlockIndexNext is equal to the entry value BlockIndex plus the output KeyRemainingBits[0:StrideLen1 - 1];
[0098] StrideLenNext: Take the entry value StrideLen2;
[0099] CmdNext: Take the entry value Cmd;
[0100] MathFieldNext: If the entry MathValueValid is valid, update it to the table entry value; otherwise keep the input value.
[0101] Jump to Step 3
[0102] Step 3: End this search
[0103] The steps for list search:
[0104] Step 1: First, check ValidNum. If it is 0, jump to Step 2; otherwise, jump to Step 3.
[0105] Step 2: Update the intermediate information for table look-up.
[0106] TileIndexNext: Take the entry value CTileIndex.
[0107] BlockIndexNext: Take the entry value CBlockIndex.
[0108] The remaining output signals are equal to the input values.
[0109] Jump to Step 8.
[0110] Step 3: According to ValidNum and StrideEntryLen, sequentially select StrideEntry0 - StrideEntryn - 1 for judgment. The specific process is as follows: Set the variable i = 0, select StrideEntry#i (#i represents taking the value of variable i), and jump to Step 4.
[0111] Step 4: Judge whether the expressions key_k & ValidBits and Prefix & ValidBits are exactly equal (the "&" in the expressions represents the "bitwise AND" operation. When configuring the table look-up entries, it is necessary to ensure that the signal widths of key_k, ValidBits, and Prefix are the same). When they are exactly equal, jump to Step 5; otherwise, i = i + 1 and jump to Step 6.
[0112] Step 5: If TileToCmdAvlb is not 0, jump to Step 7; otherwise, update the intermediate information for table look-up.
[0113] MathFieldNext: If the entry MathValueValid is valid, update it to the table entry value; otherwise, keep the input value and update the other intermediate information for table look-up to 0.
[0114] Step 6: Judge whether i is less than ValidNum - 1. If it is less, jump to Step 3; otherwise, jump to Step 2.
[0115] Step 7: Update the intermediate information for table look-up:
[0116] KeyRemainingBits: Remove the input KeyRemainingBits[0:StrideLen1 + StrideLenNext - 1] from the input KeyRemainingBits, that is, subtract the key_k part participating in the look-up and the StrideLen1 part participating in the next look-up.
[0117] TileIndexNext: Take the entry value TileIndex;
[0118] BlockIndexNext: When the entry value StrideLen1 is 0, BlockIndexNext takes the entry value BlockIndex; otherwise BlockIndexNext is equal to the entry value BlockIndex plus the output KeyRemainingBits[0:StrideLen1 - 1];
[0119] StrideLenNext: Take the entry value StrideLen2;
[0120] CmdNext: Take the entry value Cmd;
[0121] MathFieldNext: If the entry MathValueValid is valid, update it to the table entry value; otherwise keep the input value.
[0122] Jump to step 8.
[0123] Step 8: This search ends.
[0124] When using list search, the sub - entries with higher matching priorities should be placed in the StrideEntry numbers with lower values, that is, StrideEntry0 has the highest priority.
[0125] The present invention uses list search to further reduce the resource scale when all are implemented with step - by - step entries, and the width of list matching is configurable; using list search can also make a variable search length appear in the middle of a fixed - length step - by - step search, which can simplify the storage of matching table information with the same position and the same fields.
[0126] Entry configuration method:
[0127] Before the search, first perform entry configuration. It is necessary to segment the key value to be searched. Segment from the high - order bit to the low - order bit of the key value. Take a fixed value for the first segment of all key values for linear search; other segments correspond to each step - by - step and list search unit in turn. For the same key value, the same or different segments can be allocated to each unit; for different key values, the segmented values can be found according to the entry configuration; then configure the entries to be searched in turn.
[0128] Figure 4 It is a schematic diagram of segmented configuration for a certain key value to be searched (embodiment)
[0129] Such as Figure 4As shown, first, the key value is segmented. The first segment is n bits for linear search, the second segment is several m + k bits corresponding to step-by-step and list search 1, using step-by-step or list search; then there are several segments of k bits, each corresponding to a corresponding step-by-step and list search unit, using step-by-step search, several segments of x bits, each corresponding to a corresponding step-by-step and list search unit, using list search, and finally a segment of y bits, corresponding to a corresponding step-by-step and list search unit, using list search. Then these segments are configured. When searching, the relevant segments of the key are taken for search respectively.
[0130] During each level of search, an offset address can also be configured according to StrideLen1. m refers to this part, and k refers to the part specified by StrideLen2; when m is 0, the search for k is performed at this level. So these k, x, and y are all embodiments. Because different values can be configured for each entry.
[0131] The n, m, k, x, and y mentioned above are all configurable values. Each step-by-step and list search unit entry can be assigned different m, k, x, and y values for different key values.
[0132] The size of the first segment n determines the address bit width of the linear entry storage unit. The address bit width of this unit must be greater than or equal to n, that is, this unit must ensure that there are 2^n storage entries. After the address bit width of the linear entry storage unit has been selected, the selected n value should satisfy that the storage unit can store 2^n storage entries;
[0133] The size of m is determined by the address bit width of the step-by-step and list entry storage unit. The address bit width of this unit must be greater than or equal to m, that is, this unit must ensure at least 2^m storage entries; after the address bit width of the corresponding step-by-step and list entry storage unit has been selected, the selected m value should satisfy that the storage unit can store 2^m storage entries;
[0134] The k segment corresponds to the step-by-step search in the step-by-step and list search. Because step-by-step entries need to be stored in this unit, and 2^k sub-step entries (StrideEntry) need to be stored in one step-by-step entry. Under the condition that the entry bit width has been selected, the selected k value should enable the entry to have 2^k sub-step entries.
[0135] The x segment corresponds to the list search in the step-by-step and list search. List entries need to be stored in this unit. Under the condition that the entry bit width has been selected, the selected x value should enable the list entry to carry at least one list sub-entry; then each list sub-entry is configured one by one. When the current list entry cannot configure all the sub-entries corresponding to the current x segment, configure CTileIndex and CBlockIndex to point to other list entries searched for this segment (referring to the current x segment, not the subsequent x segment).
[0136] The setting principle of the y segmentation is the same as that of the x segmentation. Here, the y segmentation is set to distinguish the x segmentation.
[0137] In the list sub - entries, ValidBits is configured to select the comparison data to achieve fuzzy matching or prefix matching.
[0138] The linear entry storage unit and the step - by - step and list entry storage unit store the data configurations required for implementing the look - up table operation. The relationship between the data configurations is as Figure 5 shown.
[0139] The numbers on both sides of the arrows in the figure illustrate the corresponding relationship between the data configurations connected by the arrows. The one - to - many relationship is described below;
[0140] 1. Take the first n bits of the key as the address (there are a total of 2^n possible values), access the linear entry storage unit, and obtain a linear entry;
[0141] 2. Take m bits of the key (according to StrideLen1 in the previous matching entry) and participate in the next - level access address;
[0142] 3. Take k bits of a certain step - by - step search segment of the key (taken according to StrideLen2 in the previous matching entry) as the address and access the step - by - step sub - entry at this level;
[0143] 4. The list contains 0 to validNum list sub - entries. The length of the key is taken according to StrideLen2 in the previous matching entry;
[0144] 5. It means to access the step - by - step and list entries according to TileIndexNext and BlockIndexNext.
[0145] Figure 6 This is the look - up flow chart of the present invention. During the look - up, first, the linear unit look - up is performed to generate inter - module signals; then, it enters each step - by - step and list look - up unit in turn (i.e., step - by - step and list look - up 1 to step - by - step and list look - up N). In each unit, it is judged whether TileIndexNext matches this unit. For the matching ones, look - up and update the intermediate information of the look - up table at this level, and then continue with the subsequent unit look - up. For the non - matching ones, directly perform the subsequent unit look - up. Until all unit look - ups are completed, MathFieldNext in the intermediate look - up signals output by the step - by - step and list look - up unit N is the final look - up result. By selecting the position of the look - up unit, the present invention can flexibly use each look - up resource while maintaining the look - up efficiency.
[0146] Figure 7 This is a diagram of an item configuration implementation example.
[0147] In this diagram, 6 search and configuration paths are stored together:
[0148] Path 1: Consists of a linear item, step-by-step items, step-by-step items, and list items;
[0149] Path 2: Consists of a linear item, step-by-step items, step-by-step items, list items, and list items;
[0150] Path 3: Consists of a linear item, step-by-step items, step-by-step items, step-by-step items, step-by-step items, list items, and list items;
[0151] Path 4: Consists of a linear item, step-by-step items, step-by-step items, step-by-step items, and list items;
[0152] Path 5: Consists of a linear item, step-by-step items, step-by-step items, step-by-step items, and step-by-step items;
[0153] Path 6: Consists of a linear item, step-by-step items, list items, step-by-step items, and list items;
[0154] Path 7: Consists of a linear item and list items.
[0155] It can be seen from the diagram that each complete path item can be flexibly composed of linear items, each step-by-step and list search items; from the linear item, it can flexibly point to each step-by-step item or list search item, the step-by-step item can point to the step-by-step item or list item, and the list item can also point to the list item or step-by-step item; different sub-items of the same step-by-step or list item can specify different search types.
[0156] The key segments corresponding to the sub-items of the same step-by-step item are the same, and the key segments corresponding to the sub-items of the same list item are the same; but the key segment lengths corresponding to different items can be different.
[0157] For different key values, examples of configuring different segment values according to item configuration are as follows: Assume key1 = 0b0001 00010001; key2 = 0b1000 1000 1000; the search segments and items of the two can be configured as follows:
[0158]
[0159] Because the segments of the step-by-step and list 1 items corresponding to key1 and the step-by-step and list 2 items corresponding to key2 are all different, when configuring, the item addresses of the step-by-step and list 1 corresponding to key1 and the item addresses of the step-by-step and list 2 corresponding to key2 are all different addresses. Specific Embodiments
[0161] Assume that the key to be searched is {VRF (Virtual Routing Forwarding), IPv4_da (IPv4 destination address)}, the VRF to be searched is 0b00001000 (0b represents binary), and the IPv4_da to be searched is 62.75.62.1 in 32 bits. The entire key to be searched is configured and searched in 4 parts.
[0162] The corresponding configuration is as follows:
[0163] Linear entry configuration: For the entry corresponding to address 8, the configuration is as follows:
[0164]
[0165]
[0166] Step-by-step and list 1 entry configuration: For the sub-entry 4 in the entry corresponding to address 262, the configuration is as follows:
[0167] Signal Signal Description MathField {MathValueValid, MathValue}: {1, 2} TileIndex 2 BlockIndex 10 StrideLen1 0 StrideLen2 4 Cmd 1
[0168] Step-by-step and list 2 entry configuration: For the sub-entry 11 in the entry corresponding to address 10, the configuration is as follows:
[0169] Signal Signal Description MathField {MathValueValid, MathValue}: {1, 3} TileIndex 3 BlockIndex 11 StrideLen1 0 StrideLen2 4 Cmd 1
[0170] Step-by-step and list 3 entry configuration: For the sub-entry 3 in the entry corresponding to address 11, the configuration is as follows:
[0171] Signal Signal Description MathField {MathValueValid, MathValue}: {0, 0} TileIndex 4 BlockIndex 12 StrideLen1 0 StrideLen2 12 Cmd 0
[0172] Step-by-step and list 4 entry configuration: For the entry corresponding to address 12, the configuration is as follows:
[0173]
[0174]
[0175] The sub-entry configuration is as follows:
[0176]
[0177] Step-by-step and list 5 entry configuration: For the entry corresponding to address 20, the configuration is as follows:
[0178] Domain Name Domain Description StrideEntryLen 12 ValidNum 1 StrideEntry2 Sub - entry 2 StrideEntry1 Sub - entry 1 StrideEntry0 Sub - entry 0 CTileIndex 0 CBlockIndex 0
[0179] The sub-entry configuration is as follows:
[0180]
[0181]
[0182] For a data packet with VRF being 0b0001000 and IPv4_da being 62.75.62.1, the key to be searched is 0b00001000_00111110 01001011 00111110 00000001;
[0183] The search process is as follows:
[0184] The first step is to perform a linear search using the 8-bit VRF value 0b00001000 as the address to find the corresponding entry (i.e., among 2^8 = 256 entries, find the entry with the address 0b00001000 (i.e., in this embodiment, the entry corresponding to address 8 in the linear entry configuration)). In the corresponding entry, obtain TileIndex = 1, BlockIndex = 200, StrideLen1 = 8, StrideLen2 = 4, CmdNext = 1, MathField = {1,1}. The first 8 bits of the key have been matched. At the same time, since the search result shows that StrideLen1 is equal to 8, that is, the high 9-16 bits (i.e., 0b00111110) of the input KeyRemainingBits need to participate in generating BlockIndexNext, 0b _ 01001011 00111110 00000001 (it should be noted that the strikethrough in the above numbers indicates that the corresponding bit has been matched, and the strikethrough in the following text also means the same). Output the intermediate search information KeyRemainingBits = 0b 01001011 00111110 00000001, TileIndexNext = 1, BlockIndexNext = 262 (BlockIndex (200) + the high 9-16 bits of the input KeyRemainingBits (i.e., the value of 0b00111110 is 62)), StrideLenNext = 4, CmdNext = 1, MathFieldNext = {1,1};
[0185] The second step is to search for the entry with the address 262 in the step-by-step search and list search 1. This entry contains 2 4= 16 sub - entry information (where the exponent 4 is determined by StrideLenNext = 4 in the first - step output). Take the 4 (determined by StrideLenNext = 4 in the first - step output) highest bits of KeyRemainingBits, that is, 0b0100. According to 0b0100, take the information of the corresponding sub - entry (StrideEntry4). Where StrideLen1 = 0. Update the intermediate information in the lookup table according to the sub - entry information. TileIndexNext = 2, BlockIndexNext = 10, StrideLenNext = 4, CmdNext = 1, MathFieldNext = {1, 2}. This time, 4 bits are matched (these 4 bits are the 4 bits determined by StrideLenNext = 4 in the first - step output. Since StrideLen1 is 0 in this lookup, there is no additional key information to participate in updating BlockIndexNext), 0b 101100111110 00000001, the information obtained from KeyRemainingBits = 0b1011 00111110 00000001 is that the next step is also a step - by - step search.
[0186] In the third step, continue the step - by - step search. Take the entry corresponding to address 10 (i.e., BlockIndex = 10 output in the previous step (the second step)) in the step - by - step and list search 2. Take the 4 highest bits of KeyRemainingBits, that is, 0b1011 (where 0b1011 is determined by StrideLenNext = 4 in the previous step (the second step)). According to 0b1011, take the information of the corresponding sub - entry (StrideEntry11). Update the intermediate information in the lookup table according to the sub - entry information: TileIndexNext = 3, BlockIndexNext = 11, StrideLenNext = 4, CmdNext = 1, MathFieldNext = {1, 3}. This time, 4 bits are matched, 0b 00111110 00000001, the information obtained from KeyRemainingBits = 0b00111110 00000001 is that the next step is also a step - by - step search.
[0187] In the fourth step, continue with the step-by-step search. In step-by-step and list search 3, retrieve the entry corresponding to address 11 (i.e., BlockIndex = 11 output in the previous step (i.e., the third step)). Take the 4 most significant bits of KeyRemainingBits, which is 0b0011 (since StrideLenNext = 4 was output in the previous step (the third step), so take 4 bits in sequence, i.e., 0b0011). According to 0b0011, retrieve the information of the corresponding sub-entry (StrideEntry3), and update the intermediate information for table lookup based on the sub-entry information: TileIndexNext = 4, BlockIndexNext = 12, StrideLenNext = 12, CmdNext = 0, MathFieldNext = {1, 3}. After matching 4 bits, 0b 1110 00000001, KeyRemainingBits = 0b 1110 00000001, and the information obtained is that the next step is a list search.
[0188] In the fifth step, perform a list search on the entry corresponding to address 12 (i.e., BlockIndex = 12 output in the previous step (i.e., the fourth step)) in step-by-step and list search 4. Take 12 bits of KeyRemainingBits (because StrideLenNext = 12 was output in the previous step (i.e., the fourth step)), which is 0b 1110 00000001. Compare each list sub-entry one by one according to the entry ValidNum and StrideEntryLen. Since sub-entry 0 is the matching item (because the expression key_k & ValidBits is 0b111000000001 & 0b1111 11111111 = 0b1110 00000001, and the expression Prefix & ValidBits is 0b111000000001 & 0b1111 11111111 = 0b1110 00000001, and the two are equal, so it is a matching item), the search ends. Output the intermediate information for table lookup: TileIndexNext = 0, BlockIndexNext = 0, StrideLenNext = 0, CmdNext = 0 (because the corresponding fields in the sub-entry are configured as non-existent, so the above 4 are assigned 0), MathFieldNext = {1, 14}, KeyRemainingBits = 0 bit (indicating that all have participated in the comparison and there are no remaining bits). After matching 12 bits, 0b , all match, and the table lookup result is MathFieldNext = {1, 14}.
[0189] If it is assumed that the last 12 bits of the taken IP address are 0b 0000 00000001, there will be no matching items at this level. Therefore, the intermediate information of the lookup table is updated according to the entries CTileIndex and CBlockIndex. TileIndexNext = 5, BlockIndexNext = 20 (according to the previous configuration CTileIndex = 5, CBlockIndex = 20), StrideLenNext = 12 (since there is no matching item in the fifth-step lookup, the input value is maintained), CmdNext = 0 (since there is no matching item in the fifth-step lookup, the input value is maintained), MathFieldNext = {1,3} (since there is no matching item in the fifth-step lookup, the input value is maintained), KeyRemainingBits = 0b 1110 00000001 (since there is no matching item in the fifth-step lookup, the input value is maintained), and the sixth-step lookup continues.
[0190] In the sixth step, the list lookup continues. The entry corresponding to address 20 in the step-by-step and list lookup 5 is taken for the list lookup. The last 12 bits of the IP address, that is, 0b 0000 00000001, are used to compare each list sub-entry one by one according to the entries ValidNum and StrideEntryLen. The matching sub-entry 0 is found (because the expression key_k&ValidBits is 0b000000000001&0b0000 00000000 = 0b0000 00000000, and the expression Prefix&ValidBits is 0b000000000000&0b0000 00000000 = 0b0000 00000000, and the two are equal, which is a matching item). The output is TileIndexNext = 0, BlockIndexNext = 0, StrideLenNext = 0, CmdNext = 0 (because the corresponding fields of the sub-entry are configured as non-existent, so the above 4 are assigned 0), MathFieldNext = {1,24}, and KeyRemainingBits = 0bit (indicating that all have participated in the comparison and there are no remaining bits). The lookup result is MathFieldNext = {1,24}.
[0191] Furthermore, the present invention also provides a TCAM matching lookup device, including at least one processor and a memory. The at least one processor and the memory are connected through a data bus. The memory stores instructions executable by the at least one processor. After being executed by the processor, the instructions are used to complete the TCAM matching lookup method.
[0192] Those skilled in the art can easily understand that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.
Claims
1. A TCAM matching search method, characterized in that, the method includes: adopting a segmented search method, combining linear search, step-by-step search and list search to implement the TCAM matching search method, and improving the system search performance through a pipelining processing method, where: the segmented search is to divide the content to be searched into several segments for multi-level search; the linear search method directly uses the search content as the access address of the memory, and uses the access result as the matching search result; the step-by-step search adopts a multi-branch tree search method; the list search method stores the table entries in the form of a list in the memory. When searching, the table entry configurations in the storage space are compared sequentially to find the matching search result; wherein, combining the linear search, step-by-step search and list search specifically is: adopting a structure composed of a linear search unit and several step-by-step and list search units. N step-by-step and list search units follow the linear search unit. The matching search sequentially passes through the N step-by-step and list search units from the linear search unit in a pipelining manner, and each level performs the search in a pipelining manner until a matching path is found. The search results of each level are arbitrated, and the final search result is output. N is a preset value.
2. The TCAM matching search method according to claim 1, characterized in that, the linear search unit is composed of a linear entry storage unit and a linear search control unit. The input signal of the linear search unit is the input signal key to be searched. The linear search control unit takes the n highest bits of the key as the address to access the linear entry storage unit according to the set search length n of this unit. The linear entry storage unit is used to store the search table entries.
3. The TCAM matching search method according to claim 2, characterized in that, the data structure required for implementing the table lookup operation is stored in the linear entry storage unit. The numbers on both sides of the arrow in the data structure illustrate the corresponding relationship between the data structures connected by the arrow. Specifically:
1. Take the first n bits of the key as the address, access the linear entry storage unit, and obtain a linear entry; 2、 Starting from the high-order bits of the keys that have not yet participated in the search, take m bits and participate in the next-level access address; 3. Take the k bits of a certain step-by-step search segment of the key as the address and access the sub-entries at this level; 4、 The list contains 0 to validNum list sub-entries. The length of the key is taken according to StrideLen2 in the previous matching entry. ValidNum represents the number of sub-entries StrideEntry contained in the entry; 5、 Indicates accessing step-by-step and list entries according to TileIndexNext and BlockIndexNext.
4. The TCAM matching search method according to claim 1, characterized in that, the step-by-step and list search unit is composed of a step-by-step and list entry storage unit and a step-by-step and list search control unit. The step-by-step and list entry storage unit stores the search entries. The step-by-step and list search control unit is used to perform the following operations after receiving the previous stage input signal: Step 1: Judge the value of TileIndexNext. If it indicates that there is no need to continue the table lookup, do not perform the table lookup, directly send out the input result, and jump to Step 6; Step 2: Judge whether TileIndexNext is equal to the number of this step-by-step and list search unit. If not, do not perform the table lookup, directly send out the input result, and jump to Step 6; If equal, continue to Step 3; Step 3: Access the table entry according to BlockIndexNext, and then jump to Step 4; Step 4: Take the high StrideLenNext bits of KeyRemainingBits, denoted as key_k, and then jump to Step 5; Step 5: Judge the value of CmdNext. If it indicates a step-by-step search, jump to the step-by-step search steps; otherwise, jump to the list search steps; Step 6: End this search; Among them, TileIndexNext represents the step-by-step and list unit for the next table lookup, BlockIndexNext represents the database address in the step-by-step and list unit for the next lookup, KeyRemainingBits represents the key data that has not participated in the lookup, StrideLenNext represents the table lookup bit width for the next lookup, and CmdNext represents the type of the next table lookup.
5. The TCAM matching search method according to claim 1, characterized in that, Before the search, first perform entry configuration. It is necessary to segment the key value to be searched. Segment it from the high bit to the low bit of the key value. Take a fixed value for the first segment of all key values for linear search; other segments correspond to each step-by-step and list search unit in turn. For the same key value, the same or different segments can be allocated to each unit; for different key values, find the segment value according to the entry configuration; then configure the entries to be searched in turn.
6. The TCAM matching search method according to claim 5, characterized in that, Segmenting a key value to be searched is specifically as follows: The first segment is n bits for linear search, and then there are several m + k bits corresponding to the step-by-step and list search units, using step-by-step or list search; then there are several k-bit segments, each corresponding to the corresponding step-by-step and list search unit, using step-by-step search, and several x-bit segments, each corresponding to the corresponding step-by-step and list search unit, using list search. Finally, there is a y-bit segment, corresponding to the corresponding step-by-step and list search unit, using list search. When searching, take the relevant segments of the key for search respectively; The n, m, k, x, and y are all configurable values, and different m, k, x, and y values can be allocated to the entries of each step-by-step and list search unit for different key values.
7. The TCAM matching search method according to claim 6, characterized in that, The size of the first segment n determines the address bit width of the linear entry storage unit, and the address bit width of this unit must be greater than or equal to n, that is, this unit must ensure that there are 2^n storage entries; The size of m is determined by the address bit width of the step-by-step and list entry storage unit, and the address bit width of this unit must be greater than or equal to m, that is, this unit must ensure at least 2^m storage entries; The k segment corresponds to the step-by-step search in the step-by-step and list search. Because it is necessary to store step-by-step entries in this unit, and 2^k sub-step entries need to be stored in one step-by-step entry; The x segment corresponds to the list search in the step-by-step and list search. It is necessary to store list entries in this unit. Under the condition that the selected entry bit width has been determined, the selected x value should ensure that the list entries can carry at least one list sub-entry; The setting principle of the y segmentation is the same as that of the x segmentation.
8. The TCAM matching search method according to claim 1, characterized in that during the search, a linear unit search is first performed to generate an inter-module signal; then it sequentially enters each step-by-step and list search unit, that is, from step-by-step and list search 1 to step-by-step and list search N. In each unit, it is judged whether TileIndexNext matches this unit. For the matching ones, the search and update of the intermediate information of the lookup table are performed at this level, and then the search of the subsequent units continues. For the non-matching ones, the search of the subsequent units is directly performed; until all units are searched, MathFieldNext in the intermediate lookup signal output by the step-by-step and list search unit N is the final search result.
9. A TCAM matching search device, characterized in that: it includes at least one processor and a memory, the at least one processor and the memory are connected through a data bus, the memory stores instructions executable by the at least one processor, and after the instructions are executed by the processor, they are used to complete the TCAM matching search method according to any one of claims 1-8.
Citation Information
Patent Citations
BitMap high-speed fuzzy search method
CN110442570A