Tri-state content-addressable memory and its entry management method
Patent Information
- Application Number
- CN202310149502.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-22
- Publication Date
- 2026-09-01
- Estimated Expiration
- 2043-02-22
AI Technical Summary
在TCAM条目管理方法中,通常会采用插入备存储层的方式减少条目变化时的条目移动,但是如果不及时对TCAM中备存储层及存储条目的分布进行更新调整操作,那么终究有可能出现备选空间越来越集中,存储条目也越来越集中的情况,导致TCAM更新时间的延长以及通讯数据的延迟与丢失
[0054]Through the above technical solution, the tri-state content addressing memory provided by the present invention can realize the above-mentioned entry management method, thereby ensuring correct matching results and effective utilization of the backup storage layer.
Smart Images

Figure CN116774920B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of memory, and in particular to a three-state content-addressable memory and its entry management method. Background Technology
[0002] With the rapid development of the Internet and the significant increase in the number of nodes in the network, the requirements for router interface speeds are also increasing. For example, routers supporting 10G speeds need a single packet forwarding processing time of less than 50 nanoseconds, and software routing lookup mechanisms are clearly no longer sufficient to meet line-speed forwarding requirements. Because Tri-State Content Addressing Memory (TCAM) offers fast table lookup speeds and solves the longest prefix matching problem in CIDR, it has become a commonly used hardware solution in the industry.
[0003] There are two main types of TCAM entry management methods. One type strictly arranges internally stored entries in descending order of priority. The other type stores entries using a Directed Acyclic Graph (DAG), which processes entries recursively. It only needs to ensure that the relative positions of the results obtained after matching the transmitted data stream are correct according to priority to correctly classify the data stream. In TCAM entry management methods, the insertion of backup storage layers is often used to reduce entry movement when entries change. However, if the distribution of backup storage layers and stored entries in the TCAM is not updated and adjusted in a timely manner, the backup space and stored entries may eventually become increasingly concentrated, leading to prolonged TCAM update time and delays and loss of communication data. Summary of the Invention
[0004] To address the aforementioned technical problems, this application provides a three-state content-addressable memory and its entry management method. In each update and adjustment operation, entries in the backup storage layer are moved to the main storage layer, thereby ensuring a uniform distribution of the backup storage layer and making the amount of operations for each update and adjustment operation relatively consistent. This ensures that the TCAM update time does not increase with the increase of usage time.
[0005] A method for managing entries in a three-state content-addressable memory, characterized in that it includes entry insertion operations and update / adjustment operations;
[0006] The update and adjustment process includes the following steps:
[0007] S110. Move the entries in the backup storage layer to the main storage layer;
[0008] S120. Check if there is an entry to be inserted, and insert the entry to be inserted into the main storage layer;
[0009] S130. Check whether the relevant entries on each data stream are arranged in recursive order. If not, adjust the positions of the relevant entries so that the relevant entries on the same data stream are arranged in recursive order.
[0010] S140, repeat S130, until the relevant entries on each data stream are arranged in recursive order.
[0011] In the above technical solution, since each update moves the entries in the backup storage layer to the main storage layer, it ensures that the distribution of the backup storage layer will not become more and more concentrated as the TCAM is used normally, thereby ensuring that the time required for each update and adjustment operation will not become longer and longer.
[0012] In one possible implementation, S110, the operation of moving an entry from the backup storage layer to the main storage layer, includes the following steps:
[0013] S111. Determine whether there are any related entries in the main storage layer that are in the same data stream as the entry to be moved. If there are no related entries, move the entry to be moved directly to the free main storage layer; otherwise, execute S112.
[0014] S112. Determine the shortest path of the entry to be moved in the data stream. If the priority of the entry on the shortest path is lower than that of the entry to be moved, move the entry on the shortest path to a free main storage layer at a higher storage address once, and then insert the entry to be moved into the corresponding main storage layer.
[0015] If the entry on the shortest path has a higher priority than the entry to be moved, then the entry on the shortest path is moved once to a free main storage layer at a lower storage address, and then the entry to be moved is inserted into the corresponding main storage layer.
[0016] In the above technical solution, the entry stored in the backup storage layer is moved to the main storage layer. First, it is determined whether there are related entries in the half of the main storage layer that need to be moved. If there are related entries, the insertion point of the entry to be moved is determined according to the relative order in the data stream. If there is no free insertion point, the entries on the shortest path in the data stream are requested to be moved. Through the above operation, it is ensured that each main storage layer has an adjacent free backup storage layer that can be used to temporarily store entries. The backup storage layers are distributed relatively widely, reducing the frequency of storage space update and adjustment operations.
[0017] In one possible implementation, the operation of determining the shortest path of the item to be moved in the data stream is to compare the priority of the relevant items with the item to be moved, and then obtain the number of relevant items with lower priority than the item to be moved, Ni, and the number of relevant items with higher priority than the item to be moved, Nj, and compare the size of Ni and Nj.
[0018] If Ni > Nj, then the shortest path is the path following the direction of the data flow;
[0019] If Ni≤Nj, then the shortest path is the path in the opposite direction to the data flow.
[0020] In the above technical solution, the number of related entries above and below the entry to be moved in the same data stream is compared to determine the direction of the shortest path. By adjusting related entries on the same data stream, incorrect matching results can be output due to the search not following the data flow direction. The algorithm using the minimum number of moves for position adjustment has high update and adjustment efficiency.
[0021] In one possible implementation, the operation of adjusting the position of related entries involves comparing the priorities of each related entry in the same data stream, determining the ordered relative position of each related entry, calculating the minimum number of moves required to move an entry from its current position to its ordered relative position, and then making the move.
[0022] In the above technical solution, the position of the relevant items is adjusted by calculating the minimum number of times the current position is moved to an ordered relative position.
[0023] In one possible implementation, the entry management method for the tri-state content-addressable memory also includes an entry insertion operation. The update adjustment operation is configured to be passively triggered when there are no free main storage layers and backup storage layers in the memory space capable of performing the entry insertion operation, or when related entries on the same data stream are not arranged in recursive order after an entry insertion operation.
[0024] In the above technical solution, the update and adjustment operation is only passively triggered when there is no storage space for the entry insertion operation or when the relevant entries are not arranged in recursive order. Compared with the existing actively triggered update and adjustment operation, this solution can maximize the utilization of the backup storage layer, reduce the number of updates, and improve the efficiency of entry management.
[0025] In one possible implementation, the entry insertion operation includes the following steps:
[0026] S210. Determine whether there is a related entry for the entry to be inserted in the storage space. If not, execute S220; otherwise, execute S230.
[0027] S220. Determine whether there is a free main storage layer between the highest storage address and the lowest storage address of the stored entries in the storage space. If there is, insert the entry to be inserted into the free main storage layer between the highest storage address and the lowest storage address of the stored entries in the storage space. Otherwise, execute S221.
[0028] S221. Determine whether there is a free main storage layer in the storage space. If there is, execute S222; otherwise, insert the entry to be inserted into a free backup storage layer.
[0029] S222. Determine the number of free main storage layers with storage addresses higher than the highest storage address containing entries and the number of free main storage layers with storage addresses lower than the lowest storage address containing entries. If the number of free main storage layers with storage addresses higher than the highest storage address containing entries is larger, insert the entry to be inserted into a free main storage layer adjacent to the lowest storage address containing entries; otherwise, insert the entry to be inserted into a free main storage layer adjacent to the highest storage address containing entries.
[0030] S230. Locate related entries on the same data stream as the entry to be inserted and compare their priorities;
[0031] If there is at least one related entry with a lower priority than the entry to be inserted, obtain the lowest storage address Rj.addr of the related entries with a lower priority than the entry to be inserted;
[0032] If there is at least one related entry with a higher priority than the entry to be inserted, obtain the highest storage address Ri.addr of the related entry with a higher priority than the entry to be inserted;
[0033] If only Rj.addr exists, execute S231; if only Ri.addr exists, execute S232; if both Rj.addr and Ri.addr exist, execute S233.
[0034] S231. Determine whether there is a free main storage layer with a storage address lower than Rj.addr between the highest storage address and the lowest storage address of the stored entries. If there is, insert the entry to be inserted into the corresponding main storage layer; otherwise, insert the entry to be inserted into the free main storage layer adjacent to the highest storage address of the stored entries.
[0035] S232. Determine whether there is a free main storage layer with a storage address higher than Ri.addr between the highest storage address of the stored entry and the lowest storage address of the stored entry. If there is, insert the entry to be inserted into the corresponding main storage layer; otherwise, insert the entry to be inserted into the free main storage layer adjacent to the lowest storage address of the stored entry.
[0036] S233. Compare Ri.addr and Rj.addr. If Ri.addr > Rj.addr, then perform an update adjustment operation. Otherwise, determine whether there is a free main storage layer with a storage address higher than Ri.addr and lower than Rj.addr between the highest storage address and the lowest storage address of the stored entries. If there is, insert the entry to be inserted into the corresponding main storage layer. Otherwise, check whether there is a free backup storage layer between the main storage layers corresponding to Ri.addr and Rj.addr. If there is, insert the entry to be inserted into the backup storage layer. Otherwise, perform an update adjustment operation.
[0037] S234. After completing any one of S231, S232 and S233, check whether the relevant entries of the entry to be inserted are arranged in recursive order. If so, end the operation; otherwise, perform an update and adjustment operation.
[0038] In the above technical solution, if the entry to be inserted is unrelated to any existing stored entry, it can be inserted into any free storage unit. When an entry related to the entry to be inserted exists in the storage space, the entry should be inserted into the storage address according to the data flow direction. If both the primary and backup storage layers are full, or if the storage addresses of related entries are found to be inconsistent with the data flow direction, an update / adjustment operation is triggered to release storage units capable of storing the entry to be inserted or to adjust the order of the stored entries. In the above entry insertion operation, except in cases requiring update / adjustment operations, only the entry to be inserted is operated on without affecting other stored entries, resulting in a small operation workload.
[0039] In one possible implementation, the storage space is also configured with a vacancy table, which records the available storage addresses of the main storage layer between the highest storage address containing an entry and the lowest storage address containing an entry.
[0040] In one possible implementation, each storage space is configured with a Ptop pointer and a Pbot pointer, where the Ptop pointer points to the lowest address where the storage entry is stored, and the Pbot pointer points to the highest address where the storage entry is stored.
[0041] In the above technical solution, the use of an empty space table, Ptop pointer, and Pbot pointer to record the storage status can facilitate the reading of the storage address corresponding to the possible storage unit, reducing the amount of operation caused by detecting the storage status each time an update or adjustment operation is performed.
[0042] In one possible implementation, the tri-state content-addressable memory also includes entry deletion and entry insertion operations;
[0043] The entry insertion operation involves deleting the entry to be replaced and then inserting a new replacement entry at the storage address of the replaced entry.
[0044] The entry deletion operation includes:
[0045] S310. Mark the entry to be deleted as an entry to be deleted. Determine whether the entry to be deleted is stored in the main storage layer. If so, execute S320; otherwise, delete the entry to be deleted directly.
[0046] S320. Determine whether the entry to be deleted is located at the storage address pointed to by the Ptop pointer or the Pbot pointer. If so, execute S321; otherwise, execute S322.
[0047] S321. If the entry to be deleted is located at the storage address pointed to by the Ptop pointer, then delete the entry to be deleted, and at the same time, let the Ptop pointer redetermine the lowest storage address of the main storage layer where the entry is stored.
[0048] If the entry to be deleted is located at the storage address pointed to by the Pbot pointer, then delete the entry to be deleted, and at the same time, instruct the Pbot pointer to re-determine the highest storage address of the main storage layer where the entry is stored;
[0049] S322. Delete the entry to be deleted and fill the storage address of the entry to be deleted into the empty space table.
[0050] In the above technical solution, the entry replacement operation only operates on the deleted entry and the newly replaced entry, while other entries, the empty space table, the Ptop pointer, and the Pbot pointer remain unchanged, resulting in a small amount of operation.
[0051] In the above technical solution, the entry deletion operation includes three cases: when the entry to be deleted is stored in the backup storage layer, the entry deletion operation will not affect the empty space table, the Ptop pointer, and the Pbot pointer; when the entry to be deleted is stored at the storage address pointed to by the Ptop pointer or the Pbot pointer, the storage address pointed to by the pointer needs to be re-determined after deleting the entry; when the entry to be deleted is located in the main storage layer that is not pointed to by the Ptop pointer or the Pbot pointer, the corresponding storage address needs to be added to the empty space table after deletion. The above entry deletion operation only operates on the entry to be deleted and does not affect other stored entries, resulting in a small amount of operation.
[0052] Accordingly, this application also provides a three-state content-addressable memory, configured to implement the above-described entry management method for the three-state content-addressable memory, including:
[0053] The first processing module is used for update and adjustment operations.
[0054] Through the above technical solution, the tri-state content addressing memory provided by the present invention can realize the above-mentioned entry management method, thereby ensuring correct matching results and effective utilization of the backup storage layer.
[0055] Compared with existing technologies, the entry management method for a three-state content-addressable memory (TCAM) provided in this application includes adjustment and update operations. These operations consist of two parts: first, moving entries stored in the backup storage layer to the main storage layer to ensure that each main storage layer has an adjacent free backup storage layer for temporary entry storage. The backup storage layers are relatively dispersed, reducing the amount of operations required for entry changes and preventing frequent update and adjustment operations on storage space. Then, related entries on the same data stream are adjusted to prevent lookups from being unable to proceed according to the data flow direction. Whether adjusting entries in the backup storage layer or related entries, the shortest path and / or least-movement-time algorithms are used to select the entries to be moved, achieving high update and adjustment efficiency. Compared with existing technologies, this method reduces the frequency of adjustment and update operations, ensuring that the TCAM update time does not increase with usage time, while also guaranteeing a high accuracy rate for the output matching results. Attached Figure Description
[0056] The accompanying drawings are included to provide a further understanding of the embodiments and are incorporated in and constitute a part of this specification. The drawings illustrate embodiments and, together with the description, serve to explain the principles of this application. Other embodiments and many anticipated advantages of these embodiments will be readily recognized as they become better understood through reference to the following detailed description. Elements in the drawings are not necessarily to scale. The same reference numerals refer to corresponding similar parts.
[0057] Figure 1 This is a schematic diagram of the storage space structure in one embodiment of this application;
[0058] Figure 2a and Figure 2b This is a schematic diagram illustrating the entry replacement operation in one embodiment of this application;
[0059] Figure 3a and Figure 3b This is a schematic diagram illustrating an entry deletion operation in one embodiment of this application;
[0060] Figure 4a This is a schematic diagram of operation S221 in one embodiment of this application;
[0061] Figure 4b This is a schematic diagram of the operation when there are many storage entries in the upper main storage layer during step S222 in one embodiment of this application;
[0062] Figure 5a and Figure 5b This is a schematic diagram of operation S231 in one embodiment of this application;
[0063] Figure 6a and Figure 6b This is a schematic diagram of operation S232 in one embodiment of this application;
[0064] Figure 7 , Figure 8a and Figure 8b This is a schematic diagram of operation S233 in one embodiment of this application;
[0065] Figure 9a This is a DAG diagram of the data flow triggered by condition one in one embodiment of this application;
[0066] Figure 9b This is a schematic diagram of the item distribution in one embodiment of the present application, showing the update and adjustment operation triggered by condition one.
[0067] Figure 10 for Figure 9a and Figure 9b A diagram showing the distribution of entries after updating and adjusting the relevant entries;
[0068] Figure 11a This is a DAG diagram of the data flow of the relevant entries whose update and adjustment operation is triggered by condition two in one embodiment of this application;
[0069] Figure 11b This is a schematic diagram of the item distribution for the update and adjustment operation triggered by condition two in one embodiment of this application;
[0070] Figure 12a for Figure 11a and Figure 11b The DAG diagram of the data flow of the relevant entries after updating and adjusting the relevant entries in the diagram;
[0071] Figure 12b for Figure 11a and Figure 11b The diagram shows the distribution of related entries after updating and adjusting the relevant entries. Detailed Implementation
[0072] In the following detailed description, reference is made to the accompanying drawings, which form part of the detailed description and illustrate illustrative specific embodiments in which the present application may be practiced. In this regard, directional terms such as “top,” “bottom,” “left,” “right,” “up,” “down,” etc., are used with reference to the orientation of the described figures. Because the storage space of the embodiments can be positioned in several different orientations, directional terms are used for illustrative purposes and are by no means limiting. It should be understood that other embodiments may be utilized or logical changes may be made without departing from the scope of the present application. Therefore, the following detailed description should not be taken in a limiting sense, and the scope of the present application is defined by the appended claims.
[0073] A three-state content-addressable memory includes a storage module, a first processing module, and a second processing module.
[0074] The storage space of the storage module was initialized, such as... Figure 1 As shown, the storage space includes N+1 backup storage layers and N main storage layers located between two adjacent backup storage layers. Each main storage layer and backup storage layer has a stored unit for storing entries. Each main storage layer and backup storage layer has a different storage address Ni (0.5≤Ni≤N+0.5). From top to bottom, the storage addresses of the main storage layers and backup storage layers increase sequentially, and their priorities decrease sequentially. The storage addresses between adjacent main storage layers and backup storage layers differ by 0.5.
[0075] The first processing module is used to perform update and adjustment operations. The update and adjustment operations involve moving entries in the backup storage layer to the adjacent main storage layer and adjusting the positions of entries stored in the main storage layer so that entries in the same data stream are arranged from top to bottom according to priority.
[0076] The second processing module is used to perform entry insertion, entry replacement, and entry deletion operations on the storage module.
[0077] In other possible implementations, the tri-state content-addressable memory only needs to contain the first processing module.
[0078] In this embodiment, the matching fields of two adjacent related entries in the same data stream are ANDed to 1 and have different priorities. The data stream flows from the higher priority entries to the lower priority entries.
[0079] Let R.addr be the storage address of entry R, R.match be the matching field of entry R, and R.prio be the priority of the entry. If there are two entries Ri and Rj, and Ri.match & Rj.match = 1, but Ri.prio > Rj.prio, then Ri and Rj are related entries and the process is recursive from Ri to Rj (Ri → Rj).
[0080] The storage location of related entries conforms to the recursive order or the entries are arranged in a recursive order, which means that as the priority of related entries increases, the storage address gradually decreases.
[0081] In this embodiment, the storage space is configured with two pointers, Ptop and Pbot, and a space table. Ptop points to the lowest storage address in the main storage layer containing entries, and Pbot points to the highest storage address. The space table stores the addresses of available main storage layers between Ptop and Pbot. When no entries are stored in the main storage layer, we set Ptop = Pbot = N / 2, meaning both Pbot and Ptop pointers point to the main storage layer located in the middle of the storage space. When the first entry is inserted, both pointers remain unchanged, reducing the likelihood of errors when inserting the first entry or deleting the last entry. Furthermore, inserting entries from the middle outwards reduces the number of update adjustments required.
[0082] The item management method in this embodiment includes item replacement operation, item deletion operation, item insertion operation, and update and adjustment operation.
[0083] When an entry replacement operation is required, as shown in Figure 2, the replacement can be performed directly regardless of whether the new replacement entry is located in the main storage layer or the backup storage layer. The Ptop pointer, Pbot pointer, and empty space table remain unchanged. The operation only involves the deletion of the replaced entry and the insertion of the new replacement entry, without involving operations on other entries, resulting in a small number of operations.
[0084] The entry deletion operation includes the following steps:
[0085] S310. Mark the entry to be deleted as an entry to be deleted. Determine whether the entry to be deleted is stored in the main storage layer. If yes, execute S320; otherwise, proceed as follows: Figure 3b As shown, directly delete the item to be deleted.
[0086] S320. Determine whether the entry to be deleted is located at the storage address pointed to by the Ptop pointer or the Pbot pointer. If so, execute S321; otherwise, execute S322.
[0087] S321. If the entry to be deleted is located at the storage address pointed to by the Ptop pointer, then delete the entry to be deleted, and at the same time, let the Ptop pointer redetermine the lowest storage address of the main storage layer where the entry is stored.
[0088] If the entry to be deleted is located at the storage address pointed to by the Pbot pointer, then the entry to be deleted is deleted, and the Pbot pointer is instructed to redetermine the highest storage address of the main storage layer where the entry is stored.
[0089] S322, such as Figure 3a As shown, delete the entry to be deleted and fill the empty space table with the storage address of the entry to be deleted.
[0090] In the above-mentioned entry deletion operation, only the entry to be deleted is deleted, and the Ptop pointer, Pbot pointer or empty space table are adjusted as needed. No other entries are involved, so the amount of operation is small.
[0091] The entry insertion operation includes the following steps:
[0092] S210: Mark the entry to be inserted, Rnew, and determine whether there exists a Ri (Ptop≤i≤Pbot) such that Rnew→Ri or Ri→Rnew. If not, execute S220; otherwise, execute S230.
[0093] S220. Determine whether there is a free main storage layer between the main storage layer corresponding to the storage address pointed to by the Ptop pointer and the main storage layer corresponding to the storage address pointed to by the Pbot pointer, that is, whether there is a storage address recorded in the empty space table. If there is, execute S221; otherwise, execute S222.
[0094] S221, such as Figure 4a As shown, the empty space table is queried and the entry to be inserted is inserted into the free main storage layer between the main storage layer corresponding to the storage address pointed to by the Ptop pointer and the main storage layer corresponding to the storage address pointed to by the Pbot pointer. That is, the entry to be inserted is inserted into any storage address recorded in the empty space table, and the above storage address is deleted from the empty space table.
[0095] S222. Determine the size of Pbot-N / 2 and N / 2-Ptop. If Pbot-N / 2 > N / 2-Ptop, insert the entry to be inserted into the main storage layer of Ptop-1 and set Ptop = Ptop-1. Otherwise, insert the entry to be inserted into the main storage layer of Pbot+1 and set Pbot = Pbot+1.
[0096] That is, the storage space is divided into upper and lower parts with N / 2 as the boundary, and the number of entries stored in the main storage layer of the upper and lower parts is compared. If the upper part stores more entries, then... Figure 4bAs shown, the entry to be inserted is placed at the lower position Pbot+1, and Pbot is set to Pbot+1. If there are many entries stored in the lower part, the entry to be inserted is placed at the upper position Ptop-1, and Ptop is set to Ptop-1. The above operations can make the free main storage layer at both ends of the Pbot and Ptop pointers evenly distributed, making the selection of the insertable storage address more flexible.
[0097] S230. Locate entries related to the entry to be inserted and compare their priorities;
[0098] If there is at least one related entry with a lower priority than the entry to be inserted, obtain the lowest storage address Rj.addr of the related entries with a lower priority than the entry to be inserted;
[0099] If there is at least one related entry with a higher priority than the entry to be inserted, obtain the highest storage address Ri.addr of the related entry with a higher priority than the entry to be inserted;
[0100] Execute S231 when only Rj.addr exists, execute S232 when only Ri.addr exists, and execute S233 when both Rj.addr and Ri.addr exist.
[0101] S231, Query the empty space table, such as Figure 5a As shown, if a storage address lower than Rj.addr exists in the empty space table, the entry to be inserted is inserted into the corresponding main storage level, and the storage address is deleted from the empty space table; otherwise, ... Figure 5b The entry to be inserted is inserted into the main storage layer of Pbot+1 and Pbot = Pbot+1 is set.
[0102] S232, Query the empty space table, such as Figure 6a As shown, if a storage address higher than Ri.addr exists in the empty space table, the entry to be inserted is inserted into the corresponding main storage layer, and the storage address is deleted from the empty space table. Otherwise, the process proceeds as follows: Figure 6b As shown, insert the entry to be inserted into the main storage layer of Ptop-1 and set Ptop = Ptop-1;
[0103] S233. Compare Ri.addr and Rj.addr. If... Figure 7 As shown, if Ri.addr > Rj.addr, then perform an update and adjustment operation; otherwise, query the empty space table. If there is a storage address in the empty space table that is higher than Ri.addr but lower than Rj.addr, then insert the entry to be inserted into the corresponding primary storage. If not, check if there is a free backup storage layer between the primary storage layers corresponding to Ri.addr and Rj.addr. If there is, then proceed as follows. Figure 8aAs shown, insert the entry to be inserted into the backup storage layer; otherwise, as shown... Figure 8b As shown, perform update and adjustment operations.
[0104] S234. After completing any one of S231, S232 and S233, check whether the relevant entries of the entry to be inserted are arranged in recursive order. If so, end the operation; otherwise, perform an update and adjustment operation.
[0105] For update and adjustment operations, there are two triggering conditions. The first condition is as follows: Figure 8b As shown, the insertion point corresponding to the entry to be inserted has no free primary or secondary storage layers. Condition two is as follows: Figure 7 As shown, the insertion of a new entry results in entries in TCAM not being arranged in a recursive order.
[0106] To address the issues in the two triggering conditions mentioned above, the update and adjustment operation is divided into two parts. The first part involves moving the entry to be inserted and the entries in the backup storage layer to the main storage layer according to their relative positions in the original data streams. The second part involves adjusting the relative positions of the stored entries.
[0107] The following explains the update and adjustment procedures.
[0108] like Figure 9a and Figure 9b As shown, the inserted Rnew at this time triggers condition one. First, traverse all backup storage layers and find entries R5 and R10 stored in the backup storage layers. Then, find the shortest path on the data stream related to R5 and R10 and request the movement of entries on the path.
[0109] For R5, the entries on its shortest path are R4 and R2, and both R4.addr and R2.addr are lower than R5.addr. Therefore, R5 requests a move to the lower memory address from R4 and R2. For R10, the entry on its shortest path is R11, and R11.addr is higher than R10.addr. Therefore, R10 requests a move to the higher memory address from R11.
[0110] After moving all entries from the backup storage layer to the primary storage layer, we look at the entry Rnew that triggered the update adjustment operation. It needs to be inserted between entries R9 and R10. After insertion, the entries on the shortest path are R10 and R11, and the storage addresses of these entries should be higher than the storage address after insertion. Therefore, Rnew requests R10 and R11 to move to a higher storage address once. So, ultimately, R4 and R2 need to move to a lower storage address once, R5, R10, and Rnew need to move to their corresponding primary storage layer once, and R11 needs to move two units to a higher storage address. The final entry distribution in TCAM is as follows: Figure 10 As shown.
[0111] like Figure 11a and Figure 11b As shown, the inserted entry Rnew triggers condition two. First, it iterates through all backup storage layers and finds entry R5 stored in each backup storage layer. Then, it finds the shortest path on the data stream associated with R5 and requests the movement of entries along that path.
[0112] For R5, the entry on its shortest path is R6, and R6.addr is higher than R5.addr. Therefore, R5 requests R6 to move to a higher memory address once. At this point, R5 and Rnew are moved once towards the main memory level, and R6 is moved once to a higher memory address. The resulting data stream is as follows: Figure 12a As shown, examine the distribution order of each entry in the data stream within the storage space. Figure 11b Whether the data flow direction is the same, in Example 2, R3.prio and R4.prio are less than Rnew.prio, while R3.addr and R4.addr are less than Rnew.addr. Therefore, the R3 and R4 entries are moved to the free main storage layer at a higher storage address than the Ri entry's storage address, resulting in... Figure 12b The entries are distributed as shown, and the original storage addresses of R3 and R4 are added to the empty space table.
[0113] It should be noted that in the above embodiments, the update and adjustment operation, the entry insertion operation, and the entry deletion operation all use the empty space table, the Ptop pointer, and the Pbot pointer to record and read the storage state. In other possible implementations, the empty space table, the Ptop pointer, and the Pbot pointer may not be used.
[0114] In this embodiment, without triggering update / adjustment operations, the amount of work involved in item insertion, item replacement, and item deletion operations is minimal, and for TCAM, it can be completed instantaneously. Therefore, real-time changes to items can be made during the search process, ensuring the accuracy of grouping and classification results. Furthermore, when the main storage layer to be inserted is full, items can be temporarily stored in the backup storage layer. Update / adjustment operations are only triggered when the backup storage layer is also full, maximizing the utilization of the backup storage layer's space and reducing the number of update / adjustment operations. Moreover, since each update / adjustment operation moves items in the backup storage layer, the interval between the next update / adjustment operation is maximized. Compared to existing technologies, the backup storage layer in this embodiment maintains a relatively uniform distribution, and the amount of work involved in each update / adjustment operation is relatively consistent. This avoids the problem of the backup storage layer becoming increasingly concentrated and the update / adjustment operation workload and operation time increasing with usage time.
[0115] It is obvious that those skilled in the art can make various modifications and alterations to the embodiments of this application without departing from the spirit and scope of this application. In this way, this application also aims to cover such modifications and alterations if they fall within the scope of the claims and their equivalents. The word "comprising" does not exclude the presence of other elements or steps not listed in the claims. The simple fact that certain measures are described in mutually different dependent claims does not indicate that a combination of these measures cannot be used for profit. Any reference numerals in the claims should not be considered limiting in scope.
Claims
1. A method for managing entries in a three-state content-addressable memory, characterized in that, This includes entry insertion and update / adjustment operations; The entry insertion operation includes the following steps: S210. Determine whether there is a related entry for the entry to be inserted in the storage space. If not, execute S220; otherwise, execute S230. S220. Determine whether there is a free main storage layer between the highest storage address and the lowest storage address of the stored entries in the storage space. If there is, insert the entry to be inserted into the free main storage layer between the highest storage address and the lowest storage address of the stored entries in the storage space. Otherwise, execute S221. S221. Determine whether there is a free main storage layer in the storage space. If there is, execute S222; otherwise, insert the entry to be inserted into a free backup storage layer. S222. Determine the number of free main storage layers with storage addresses higher than the highest storage address containing the entry and the number of free main storage layers with storage addresses lower than the lowest storage address containing the entry. If the number of free main storage layers with storage addresses higher than the highest storage address containing the entry is larger, then insert the entry to be inserted into a free main storage layer adjacent to the lowest storage address containing the entry; otherwise, insert the entry to be inserted into a free main storage layer adjacent to the highest storage address containing the entry. S230. Locate the relevant entries that are located on the same data stream as the entry to be inserted and perform a priority comparison; If there exists at least one related entry with a lower priority than the entry to be inserted, obtain the lowest storage address Rj.addr of the related entry with a lower priority than the entry to be inserted; If there exists at least one related entry with a higher priority than the entry to be inserted, obtain the highest storage address Ri.addr of the related entry with a higher priority than the entry to be inserted; If only Rj.addr exists, execute S231; if only Ri.addr exists, execute S232; if both Rj.addr and Ri.addr exist, execute S233. S231. Determine whether there is a free main storage layer with a storage address lower than Rj.addr between the highest storage address and the lowest storage address of the stored entries. If there is, insert the entry to be inserted into the corresponding main storage layer; otherwise, insert the entry to be inserted into a free main storage layer adjacent to the highest storage address of the stored entries. S232. Determine whether there is a free main storage layer with a storage address higher than Ri.addr between the highest storage address of the stored entries and the lowest storage address of the stored entries. If there is, insert the entry to be inserted into the corresponding main storage layer; otherwise, insert the entry to be inserted into a free main storage layer adjacent to the lowest storage address of the stored entries. S233. Compare Ri.addr and Rj.addr. If Ri.addr > Rj.addr, then perform the update adjustment operation. Otherwise, determine whether there is a free main storage layer with a storage address higher than Ri.addr and lower than Rj.addr between the highest storage address and the lowest storage address of the stored entries. If there is, insert the entry to be inserted into the corresponding main storage layer. Otherwise, check whether there is a free backup storage layer between the main storage layers corresponding to Ri.addr and Rj.addr. If there is, insert the entry to be inserted into the backup storage layer. Otherwise, perform the update adjustment operation. S234. After completing any one of S231, S232 and S233, check whether the relevant entries of the entry to be inserted are arranged in recursive order. If so, end the operation; otherwise, perform the update and adjustment operation. The update adjustment operation is configured to be passively triggered when there are no free primary storage layer and backup storage layer in the storage space that can perform the entry insertion operation, or when the related entries on the same data stream are not arranged in recursive order after the entry insertion operation is performed. The update and adjustment operation includes the following steps: S110. Move the entries in the backup storage layer to the main storage layer; S120. Check if there is an entry to be inserted, and insert the entry to be inserted into the main storage layer; S130. Check whether the relevant entries on each data stream are arranged in recursive order. If not, adjust the position of the relevant entries so that the relevant entries on the same data stream are arranged in recursive order. S140, Repeat S130 until the relevant entries on each data stream are arranged in recursive order.
2. The entry management method for a three-state content-addressable memory according to claim 1, characterized in that, The operation of moving entries from the backup storage layer to the main storage layer in step S110 includes the following steps: S111. Determine whether there is a related entry in the main storage layer that is in the same data stream as the entry to be moved. If there is no related entry, move the entry to be moved directly to the idle main storage layer; otherwise, execute S112. S112. Determine the shortest path of the entry to be moved on the data stream. If the priority of the entry on the shortest path is lower than that of the entry to be moved, move the entry on the shortest path to a free main storage layer at a higher storage address once, and then insert the entry to be moved into the corresponding main storage layer. If the entry on the shortest path has a higher priority than the entry to be moved, then the entry on the shortest path is moved once to a free main storage layer at a lower storage address, and then the entry to be moved is inserted into the corresponding main storage layer.
3. The entry management method for a three-state content-addressable memory according to claim 2, characterized in that, The operation of determining the shortest path of the entry to be moved on the data stream is to compare the priority of the relevant entry with the entry to be moved, and then obtain the number of relevant entries Ni with a priority lower than the entry to be moved and the number of relevant entries Nj with a priority higher than the entry to be moved, and compare the size of Ni and Nj. If Ni > Nj, then the shortest path is the path following the direction of the data flow; If Ni ≤ Nj, then the shortest path is the path opposite to the direction of the data flow.
4. The entry management method for a three-state content-addressable memory according to claim 2, characterized in that, The operation of adjusting the position of the related entries involves comparing the priorities of each related entry in the same data stream, determining the ordered relative position of each related entry, calculating the minimum number of moves required to move the entry from its current position to the ordered relative position, and then moving it.
5. The entry management method for a three-state content-addressable memory according to claim 1, characterized in that, The storage space is also configured with a vacancy table, which records the vacant storage addresses of the main storage layer between the highest storage address containing an entry and the lowest storage address containing an entry.
6. The entry management method for a three-state content-addressable memory according to claim 5, characterized in that, Each of the storage spaces is configured with a Ptop pointer and a Pbot pointer, wherein the Ptop pointer points to the lowest address where the storage entry is stored, and the Pbot pointer points to the highest address where the storage entry is stored.
7. The entry management method for a three-state content-addressable memory according to claim 6, characterized in that, It also includes entry deletion and entry insertion operations; The entry insertion operation is to delete the entry to be replaced, and then insert a new replacement entry at the storage address of the replaced entry; The entry deletion operation includes: S310. Determine whether the entry to be deleted is stored in the main storage layer. If yes, execute S320; otherwise, delete the entry to be deleted directly. S320. Determine whether the entry to be deleted is located at the storage address pointed to by the Ptop pointer or the Pbot pointer. If so, execute S321; otherwise, execute S322. S321. If the entry to be deleted is located at the storage address pointed to by the Ptop pointer, then delete the entry to be deleted, and at the same time, let the Ptop pointer redetermine the lowest storage address of the main storage layer where the entry is stored. If the entry to be deleted is located at the storage address pointed to by the Pbot pointer, then the entry to be deleted is deleted, and at the same time the Pbot pointer is instructed to re-determine the highest storage address of the main storage layer where the entry is stored; S322. Delete the entry to be deleted and fill the storage address of the entry to be deleted into the empty space table.
8. A tri-state content-addressable memory, configured to implement the entry management method for the tri-state content-addressable memory according to any one of claims 1-7, characterized in that, include: The first processing module is used for update and adjustment operations.
Citation Information
Patent Citations
TCAM (Ternary Content Addressable Memory) multi-priority storage method and device and readable storage medium
CN115422406A
Method, Hardware Architecture and Recording Medium forSearching IP Address by Using Pipeline Binary Tree
KR1020050036794A