WO2011153784A1 - 一种三态内容寻址存储器的表项更新方法及装置 - Google Patents

一种三态内容寻址存储器的表项更新方法及装置 Download PDF

Info

Publication number
WO2011153784A1
WO2011153784A1 PCT/CN2010/078298 CN2010078298W WO2011153784A1 WO 2011153784 A1 WO2011153784 A1 WO 2011153784A1 CN 2010078298 W CN2010078298 W CN 2010078298W WO 2011153784 A1 WO2011153784 A1 WO 2011153784A1
Authority
WO
WIPO (PCT)
Prior art keywords
tcam
entry
added
list
storage location
Prior art date
Application number
PCT/CN2010/078298
Other languages
English (en)
French (fr)
Inventor
高兴福
Original Assignee
北京星网锐捷网络技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 北京星网锐捷网络技术有限公司 filed Critical 北京星网锐捷网络技术有限公司
Priority to US13/158,262 priority Critical patent/US8527694B2/en
Publication of WO2011153784A1 publication Critical patent/WO2011153784A1/zh

Links

Classifications

    • GPHYSICS
    • G11INFORMATION STORAGE
    • G11CSTATIC STORES
    • G11C15/00Digital stores in which information comprising one or more characteristic parts is written into the store and in which information is read-out by searching for one or more of these characteristic parts, i.e. associative or content-addressed stores

Definitions

  • the present invention relates to the field of data processing, and in particular, to a method and apparatus for updating an entry of a three-state content addressed memory. Background technique
  • TCAM Ternary Content Addressable Memory
  • ACL Access Control List
  • QOS Quality of Service
  • policy routing and various security technologies.
  • the content of the packet is generally used as the search input of the TCAM, and the TCAM compares the input with all the entries at the same time. If an exact matching entry is found, the action bound to the entry is performed. For example, discard the packet, or allow forwarding, or modify some information of the packet; if there are multiple entries that match exactly, take the top one.
  • the destination IP address of the input message is taken as the content input TCAM, and the corresponding next hop information is searched.
  • Other applications are similar processes.
  • the user configures "Permit ip host 192.168.1.1; Deny ip any any” and binds to the port.
  • the port receives the packet, it extracts the input port of the packet, and the protocol type field.
  • the source IP address is used as the content input TCAM search. If the packet type is IP and the source IP address is 192.168.1.1, the corresponding TCAM entry of the permit ip host 192.168.1.1 is hit, and the behavior of the permit is executed, that is, the permission is allowed. Forward; otherwise, other messages will be deny, that is, discarded.
  • TCAM is applied to the security domain such as the fast route search or the ACL search.
  • the TCAM entries often need to maintain a certain order, or a fixed priority relationship, and use continuous space storage, TCAM entries. It will be continuously updated during the operation of the device.
  • the invention provides a method and a device for updating an entry of a three-state content addressable memory, which is used to solve the problem that the update efficiency of the entry of the existing three-state content addressable memory is low.
  • the method for updating an entry of a three-state content-addressable memory includes: creating a virtual three-state content addressable memory TCAM list, where each first TCAM entry in the virtual TCAM list is stored in a hardware TCAM Each of the second TCAM entries corresponds one-to-one;
  • an update operation is performed on the second TCAM entry to be updated based on the determined storage location.
  • a creating unit configured to create a virtual three-state content addressing memory TCAM list, where each first item in the virtual TCAM list has a one-to-one correspondence with each second TCAM entry stored in the hardware TCAM;
  • a storage location determining unit configured to determine, according to a pre-assigned relationship between a first TCAM entry to be updated and a storage location of other first TCAM entries in the virtual TCAM list, in the idle resource of the hardware TCAM a storage location of the second TCAM entry to be updated corresponding to the updated first TCAM entry; an update operation unit, configured to perform, in the hardware TCAM, the second TCAM entry to be updated based on the determined storage location Update operation.
  • the method and device for updating the entry of the three-state content-addressable memory utilizes the corresponding one of the first TCAM entries in the created virtual TCAM list and the second TCAM entries in the hardware TCAM. And determining, according to a pre-determined relationship between the first TCAM entry to be updated and the storage location of the other first TCAM entries in the virtual TCAM list, determining the first TCAM entry to be updated in the idle resource of the hardware TCAM Corresponding storage location of the second TCAM entry to be updated, in the hardware TCAM, performing a corresponding update operation on the second TCAM entry to be updated based on the determined storage location.
  • the storage location of the second TCAM entry to be updated is selected as much as possible in the idle location in the hardware TCAM, which avoids the prior art directly updating the second TCAM entry of the hardware TCAM.
  • the second TCAM entries in the hardware TCAM are often stored in a continuous storage space. To ensure the sequential relationship between the second TCAM entries to be updated and other second TCAM entries, the second TCAM to be updated. When a location conflict occurs, the related second TCAM entry has to be moved in a large amount, resulting in a problem that the hardware TCAM entry updated by a large number of second TCAM entries is less efficient.
  • DRAWINGS 1 is a schematic diagram of an entry of a three-state content addressable memory provided by the prior art
  • FIG. 2 is a flowchart of a method for updating an entry of a three-state content-addressable memory according to an embodiment of the present invention
  • FIG. 3 is a flowchart of determining a storage location of a first TCAM entry to be added in a hardware TCAM according to an embodiment of the present invention
  • Flow chart of the method
  • FIG. 4 is a flowchart of determining correlation between a first TCAM entry to be added and data content of other first TCAM entries according to an embodiment of the present invention
  • FIG. 5 is a schematic structural diagram of an apparatus for updating an entry of a three-state content addressable memory according to an embodiment of the present invention
  • FIG. 6 is a schematic structural diagram of a creation unit according to an embodiment of the present invention
  • FIG. 7 is a schematic structural diagram of a storage location determining unit according to an embodiment of the present invention. detailed description
  • TCAM three-state content addressable memory
  • the TCAM entry update method uses a one-to-one correspondence between the virtual entry in the virtual TCAM list and the TCAM entry in the virtual TCAM list, and performs a series of execution on the virtual entry in the virtual TCAM list. The operation is performed to update the corresponding entry in the TCAM of the entity.
  • the virtual entry in the virtual TCAM list is referred to as the first TCAM entry, and the entry in the TCAM of the entity is called Is the second TCAM entry.
  • the physical TCAM is called a hardware TCAM.
  • the method for updating an entry of a TCAM includes the following steps: S201: Create a virtual TCAM list, where each first TCAM entry in the virtual TCAM list is stored in a hardware TCAM. Each second TCAM entry corresponds to one by one;
  • S202 Determine, according to a predetermined relationship between the first TCAM entry to be updated and the storage location of the other first TCAM entries in the virtual TCAM list, the first TCAM entry to be updated in the idle resource of the hardware TCAM. a storage location of the second TCAM entry to be updated;
  • a linked list is created as a virtual TCAM list, and each data node in the linked list is a first TCAM entry, and each first TCAM entry in the linked list is arranged in a predetermined order, and with hardware.
  • Each second TCAM entry stored by the TCAM is in one-to-one correspondence;
  • the records in each first TCAM entry include at least the following six items:
  • the data content of the second TCAM entry corresponding to the first TCAM entry (represented by data); the storage location of the second TCAM entry corresponding to the first TCAM entry in the hardware TCAM (represented by toamID);
  • Prelist a list of pre-list entries of the first TCAM entry (indicated by Prelist);
  • a list of the back entries of the first TCAM entry (indicated by Poslist).
  • each first TCAM entry may also record a preset identifier of an idle resource counter for recording the number of idle resources between minID and maxID.
  • the parameters recorded by the idle resource counter include:
  • minID the upper limit of the idle resource counter monitoring area
  • IdleNum The number of idle second TCAM entries in the idle resource counter monitoring area.
  • a counter may be added to make its minID equal to 0, and its maxID is equal to TCAM.
  • the maximum number of entries in the table can be managed in the following manner in the implementation of the embodiment of the present invention.
  • step S3 Judging the search result, if found, executing step S4, otherwise performing step S5.
  • S4 The referNum field of the counter is incremented by 1, and the counter pointer is returned.
  • S5 Create a new counter in the database and calculate the number of free entries in the specified range.
  • the number of bits equal to 0 in the specified range can be calculated for the resource bit table, and the idleNum field is written.
  • the referNum field value is 1, returning the counter pointer.
  • the value of the referNum field of the counter is decremented by 1, indicating that one of the entries for applying this counter is missing.
  • step 324 can be deleted. Otherwise return directly.
  • this embodiment only accepts the type of addition or deletion operation.
  • step S5 it is determined whether the tcamID parameter is greater than or equal to the minID, and the small is equal to the maxID, if yes, step S5 is performed, otherwise step S4 is performed;
  • step S4 Determine if the last counter has been processed, and then end, and exit this program. Otherwise, step S6 is performed;
  • next counter is obtained. For example, if you are a linked list, take the next pointer value. If it is an array, add a 1 to the subscript.
  • an idle resource bit table may also be established, for example, applying for a memory block, the number of bytes of the memory block being equal to the maximum number of entries of the TCAM/8, and Make all bits 0.
  • Step S2 determining whether the minID in the virtual TCAM table is less than maxID, if yes, performing step S5, otherwise Step S3;
  • step S4 If no idle resource is found, it indicates that the range is filled with other entries, and the range search is required, that is, step S5 is performed, otherwise the direct return is successful.
  • the parameters here include a virtual TCAM entry pointer and a free entry tcamID.
  • step S2 If minID-1 is less than maxID+l, then the pre- and post-positions of the current entry should be interchanged, then step S3 is performed, otherwise S4 is performed;
  • tcamlD is greater than minlD
  • the item corresponding to maxID is interchanged, which is converted to tcamlD which is smaller than the largest tcamlD in the remaining post list, and then the new idle entry tcamlD is exchanged with the corresponding item of minlD, thus changing again
  • the new tcamlD is greater than the tcamlD in the remaining post list, and so on, until the idle entry tcamlD is greater than the tcamlD of the predecessor and less than the tcamID of all post entries.
  • step S4 In the case that the pre- and post-order are correct, it is judged whether the idle entry is in front of the front or in front of the rear, that is, whether tcamlD is smaller than minlD, and if it is in front of the front, the result of the judgment is yes. Then step S6 is performed; otherwise, step S5 is performed.
  • the parameters here include the virtual TCAM entry pointer to be changed and the idle entry tcamID.
  • step S3 If it is determined whether the toamID of the idle entry is in the spatial area indicated by the minID and the maxID of the to-be-replaced entry, step S3 is performed; otherwise, step S4 is performed first, and then step S3 is performed.
  • the hardware entry corresponding to the entry to be changed is copied to the corresponding location of the idle entry, and the virtual TCAM entry data is changed, and the counter update is triggered.
  • S4 Recursively invokes all steps, passing in non-replaceable pre or post nodes and free entry IDs.
  • step S3 is performed.
  • the method for updating an entry of a TCAM is mainly because the operation of adding and deleting an entry in a hardware TCAM may cause a rewriting of a large number of entries, resulting in a low efficiency of hardware TCAM update.
  • the operations of the two updates are also improved accordingly.
  • S202 and S203 shown in FIG. 1 have different implementation manners because of different update operations. The following two steps are implemented for adding and deleting entries respectively. the way.
  • the second TCAM entry For the operation of adding the second TCAM entry (hereinafter referred to as the second TCAM entry to be added) in the hardware TCAM, the second TCAM entry is generally pre-specified in an existing second TCAM table.
  • the first TCAM entry in the virtual TCAM list corresponding to the second TCAM entry to be added (hereinafter referred to as the first TCAM entry to be added) is required.
  • the following operations are performed: S202K, in the virtual TCAM list, determining a storage location of a first TCAM entry of the first TCAM entry to be added corresponding to the second TCAM entry to be added that is to be added in advance;
  • the first TCAM entry to be added is inserted, and the data content (data) of the second TCAM entry to be added is recorded in the first TCAM entry to be added;
  • the idle resource counter between the minID and the maxID set in advance may determine whether there is an idle resource in the current hardware TCAM, and if so, further perform the following step S2026.
  • step S2025 Determine, according to the minimum storage location and the maximum storage location obtained in step S2025, the storage location of the second TCAM entry to be added in the idle resource of the hardware TCAM.
  • the inventor of the present invention finds that there is a correlation between the entries in the second TCAM entry stored by the existing hardware TCAM, which must be maintained in a strict sequence relationship.
  • step S2023 in the virtual TCAM list, The process of determining other first TCAM entries related to the first TCAM entry to be added, that is, the process of determining the first TCAM entry having a strict sequence with the first TCAM entry to be added.
  • the first TCAM entry to be added and the other first TCAM entry in the virtual TCAM list are determined on the premise that the content of the first TCAM entry does not involve the four-layer port information. Whether there is a correlation between the first TCAM entries to be added and the data content of other first TCAM entries is as follows:
  • each second TCAM entry is stored in the hardware TCAM in the form of a ⁇ rule value (ie, a keyword of an address), a mask>sequence, and a second TCAM table in the hardware TCAM.
  • a ⁇ rule value ie, a keyword of an address
  • a mask>sequence ie, a mask>sequence
  • a second TCAM table in the hardware TCAM.
  • the recorded data content is the value and mask of the rule included in the corresponding second TCAM entry.
  • the above formula is performed by an exclusive OR operation with ⁇ 2 and then with Mi and 2 in sequence. If the final operation result is zero, the first TCAM entry may be considered to be related to the other first TCAM entry. Otherwise, the two are irrelevant.
  • the values and masks of the rules of the other first TCAM entries are respectively: 192.168.5.0 255.255.255.0; From the logical relationship, the value of the rule of the first TCAM entry to be added is the rule of the other first TCAM entry. A subset of the values.
  • the final result of the above calculation indicates that the first TCAM entry to be added and the other first TCAM entries are related, and the result of the logical relationship judgment is consistent.
  • the second implementation manner is that the content recorded in the first TCAM entry includes, in addition to the foregoing six pieces of information, four layers of port number information and associated behavior information.
  • This method is more common in the existing ACL application.
  • the correlation between the first TCAM entry to be added and the data content of other first TCAM entries is determined as shown in FIG. 4, including The following steps:
  • the first TCAM entry to be added and the data content recorded by other first TCAM entries in the virtual TCAM list are divided into rule values and masks.
  • step S403 If the calculation result is zero, the following step S403 is performed; otherwise, the process proceeds to step S406 described below;
  • step S403 further comparing whether there is an intersection between the first TCAM entry to be added and the four-layer port number information recorded by the other first TCAM entry, if yes, proceeding to step S404, otherwise proceeding to step S406;
  • step S404 further comparing whether the first TCAM entry to be added is consistent with the associated behavior information of other first TCAM entries in the virtual TCAM list; if not, proceeding to step S405; if yes, proceeding to step S406;
  • the four-layer port number information can be compared by the four-layer port comparator to the description of the four-layer port number information, for example, the first TCAM entry to be added and the four-layer port of the other first TCAM entry. If the number of the information is greater than a certain port number, it is obvious that the two TCAM entries to be added are related to the other first TCAM entries.
  • the associated behavior information recorded by the first TCAM entry is an execution action corresponding to the first TCAM entry, for example, an entry of the Premit tcp any any gt 80 any, the Premit is allowed to be forwarded as its associated behavior information.
  • the prior art there are other, for example, discarding packets, mirroring, redirection, performing a route next hop, modifying certain fields of the packet, controlling bandwidth, and the like, and associating the behavior information with the first TCAM entry. , that there is no correlation, that is, there is no strict order.
  • the inventors of the present invention have also found that in a virtual TCAM list, the more bits equal to 1 in the first TCAM entry, in other words, the fewer bits equal to 0, the more likely it is placed in front of the virtual TCAM list. Then, with this feature, try to allocate the first TCAM entry with more bits equal to 1 in the mask to the higher storage location. This can further reduce the occurrence of entry movement.
  • the following formula can be used to calculate a possible storage location of the second TCAM entry to be added in the hardware TCAM by the following formula:
  • tcamID N* (maxID-minID+1) +minID;
  • the tcamID is a possible storage location of the second TCAM entry to be added in the hardware TCAM; N is a ratio of zero bits in the mask of the first TCAM entry to be added to the total number of bits of the mask;
  • the maximum storage location of the second TCAM entry to be added that can be arbitrarily moved in the hardware TCAM, minlD is the first to be added The minimum storage location where the two TCAM entries can be arbitrarily moved in the hardware TCAM.
  • the calculated possible storage location may be used as a storage location of the second TCAM entry to be added in the hardware TCAM;
  • the above possible storage location is already occupied in the hardware TCAM, then the idle storage resource can be searched up or down at the calculated storage location, and an idle location closest to the calculated possible storage location is selected as The storage location of the second TCAM entry to be added in the hardware TCAM.
  • the first TCAM entry to be added is added;
  • the first TCAM entry to be added is added.
  • the first to be added according to the storage location of the second TCAM entry to be added in the hardware TCAM The data content of the corresponding second TCAM entry to be added recorded in a TCAM entry may be written to the storage location.
  • the operation of deleting the second TCAM entry (hereinafter referred to as the second TCAM entry to be deleted) in the hardware TCAM, the operation is relatively simple, as long as the virtual TCAM list corresponding to the second TCAM entry to be deleted is selected.
  • the storage location of the second TCAM entry to be deleted recorded in the first TCAM entry (hereinafter referred to as the first TCAM entry to be deleted) may be deleted in the hardware TCAM.
  • an embodiment of the present invention further provides an entry updating device for a three-state content addressed memory.
  • the principle of solving the problem is similar to the foregoing method for updating a table entry of a three-state content addressed memory. Therefore, the implementation of the device can be referred to the implementation of the method, and the repeated description will not be repeated.
  • the apparatus for updating an entry of a three-state content addressable memory includes: a creating unit 501, configured to create a virtual three-state content-addressable memory TCAM list, where each first entry in the virtual TCAM list is in one-to-one correspondence with each second TCAM entry stored in the hardware TCAM;
  • the storage location determining unit 502 is configured to determine, according to a preset storage location relationship between the first TCAM entry to be updated and the other first TCAM entries in the virtual TCAM list, the idle location in the hardware TCAM a storage location of the second TCAM entry to be updated corresponding to the updated first TCAM entry;
  • the update operation unit 503 is configured to perform an update operation on the second TCAM entry to be updated based on the determined storage location in the hardware TCAM.
  • the above creating unit 501 further includes:
  • the linked list creating subunit 5011 is configured to create a linked list as a virtual TCAM list; and each first TCAM entry in the linked list is arranged in a predetermined order and corresponding to each second TCAM entry stored in the hardware TCAM;
  • the recording sub-unit 5012 is configured to include, in each of the first TCAM entry records, a data content of the second TCAM entry corresponding to the first TCAM entry, and a second TCAM entry corresponding to the first TCAM entry. a storage location in the hardware TCAM, a minimum storage location and a maximum storage location of the second TCAM entry corresponding to the first TCAM entry arbitrarily moved in the hardware TCAM, and a list of pre-list entries of the first TCAM entry and List of post entries.
  • the storage location determining unit 502 further includes:
  • a first storage location determining sub-unit 5021 configured to determine, in the virtual TCAM list, a storage location of a first TCAM entry of the first TCAM entry to be added corresponding to the second TCAM entry to be added that is to be added in advance;
  • the correlation determining sub-unit 5022 is configured to insert the first TCAM entry to be added after the determined storage location, and record the data of the second TCAM entry to be added in the first TCAM entry to be added. And determining, according to the recorded data content and the data content recorded by the other first TCAM entries in the virtual TCAM list, other first TCAM entries related to the first TCAM entry to be added;
  • a maximum/minimum storage location determining sub-unit 5023 configured to determine, in the virtual TCAM list, all the first TCAM entries related to the first TCAM entry to be added before the first TCAM entry to be added as an entry in the pre-list; Determining, in the virtual TCAM list, all the first TCAM entries related to the first TCAM entry to be added after the first TCAM entry to be added as an entry in the subsequent list; The storage location of the second TCAM entry corresponding to the first TCAM entry in the hardware TCAM is increased by 1, as the minimum storage location of the second TCAM entry to be added that can be arbitrarily moved in the hardware TCAM; The storage location of the second TCAM entry corresponding to the first TCAM entry in the list in the hardware TCAM minus 1 is used as the location. Determining a maximum storage location of the added second TCAM entry that can be arbitrarily moved in the hardware TCAM; a second storage location determining subunit 5024 for using the hardware according to the minimum storage location and the maximum storage location
  • the storage location of the second TCAM entry to be added is determined in the idle resource of the TCAM.
  • correlation determining sub-unit 5022 is configured to divide the data content recorded by the first TCAM entry to be added and the other first TCAM entries in the virtual TCAM list into rule values and masks;
  • correlation determining sub-unit 5022 is configured to divide the data content recorded by the first TCAM entry to be added and the other first TCAM entries in the virtual TCAM list into rule values and masks;
  • the result of the calculation is not zero, it is determined that the first TCAM entry to be added is not related to the other first TCAM entry; otherwise, the first TCAM entry to be added and the other first TCAM entry are further compared. Whether there is an intersection between the four-layer port number information, if not, determining that the first TCAM entry to be added is not related to the other first TCAM entries; if yes, further comparing the first TCAM to be added Whether the associated behavior information of the entry is consistent with the other first TCAM entry records. If not, the first TCAM entry to be added is related to the other first TCAM entries; if they are consistent, the information is irrelevant.
  • the foregoing second storage location determining subunit 5024 is further configured to calculate a possible storage location of the second TCAM entry to be added in the hardware TCAM by using the following formula:
  • tcamID N* (maxID-minID+1) +minID;
  • tcamlD is a possible storage location of the second TCAM entry to be added in the hardware TCAM
  • N is a ratio of zero bits in the mask of the first TCAM entry to be added to the total number of bits of the mask
  • maxID For the stated The maximum storage location, minID is the minimum storage location.
  • Determining whether the calculated possible storage location is an idle resource of the TCAM if yes, determining the calculated storage location as a storage location of the second TCAM entry to be added in the hardware TCAM; Then, the storage location of the calculated idle resource that is closest to the possible storage location is used as the storage location of the second TCAM entry to be added in the hardware TCAM.
  • the maximum/minimum storage location determining sub-unit 5023 is further configured to: add the to-be-listed in a post-list of each first TCAM entry of the pre-list of the first TCAM entry to be added. Adding the first TCAM entry; and adding the first TCAM entry to be added in the pre-list of each first TCAM entry of the post-list of the first TCAM entry to be added.
  • the foregoing update operation unit 503 is further configured to: in the hardware TCAM, according to the second to be deleted
  • the storage location of the second TCAM entry to be deleted recorded in the first TCAM entry to be deleted corresponding to the TCAM entry, and deleting the second TCAM entry of the storage location.
  • the update operation unit 503 is further configured to delete the first TCAM to be deleted in a post-list of each first TCAM entry of the pre-list of the first TCAM entry to be deleted. Deleting the first TCAM entry to be deleted in the pre-list of each first TCAM entry of the post-list of the first TCAM entry to be deleted; in the virtual TCAM list The first TCAM entry to be deleted is deleted.
  • the method and device for updating the entry of the three-state content-addressable memory utilizes the corresponding one of the first TCAM entries in the created virtual TCAM list and the second TCAM entries in the hardware TCAM. And determining, according to the storage location relationship between the first TCAM entry to be updated and the other first TCAM entries in the virtual TCAM list, determining the corresponding TCAM entry to be updated in the idle resource of the hardware TCAM. The storage location of the second TCAM entry to be updated, in the hardware TCAM, performing a corresponding update operation on the second TCAM entry to be updated based on the determined storage location.
  • the storage location of the second TCAM entry to be updated is selected as much as possible in the idle location in the hardware TCAM, which avoids the prior art directly updating the second TCAM entry of the hardware TCAM.
  • the second TCAM entries in the hardware TCAM are often stored in a continuous storage space. To ensure the sequential relationship between the second TCAM entries to be updated and other second TCAM entries, the second TCAM to be updated. When a location conflict occurs, the related second TCAM entry has to be moved in a large amount, resulting in a problem that the hardware TCAM entry updated by a large number of second TCAM entries is less efficient.
  • the first TCAM corresponding to the second TCAM entry to be updated is identified.
  • the correlation between the entry and the other first TCAM entries in the virtual TCAM list so that when the second TCAM entry to be updated has a position conflict, even if there is no idle resource to be selected, the second TCAM entry is inevitably needed to be moved. Only the entries related to the second TCAM entry to be updated (maintaining the strict order) are moved, and the entries that are not related to the second TCAM entry to be updated (there is no strict order) are greatly reduced.
  • the number of possible second TCAM entries further overcomes the problem of low efficiency of updating existing hardware TCAM entries.

Description

一种三态内容寻址存储器的表项更新方法及装置 技术领域
本发明涉及数据处理领域, 尤其涉及一种三态内容寻址存储器的表项更新方法及装 置。 背景技术
在网络设备中, 由于三态内容寻址存储器 (Ternary Content Addressable Memory, TCAM ) 具备的快速查找特性而被广泛应用, 如应用于快速路由查找、 访问控制列表 (Access Control List, ACL) 查找、 基于流的服务质量 (Quality of Service, QOS)、 策 略路由及各种安全技术。 在网络设备中一般以报文的某些内容作为 TCAM的查找输入, TCAM将该输入同时与所有表项比对, 若找到一条完全匹配的表项, 则执行与该表项绑 定的动作, 例如丢弃该报文, 或允许转发, 或修改该报文的某些信息; 若有多条表项与 之完全匹配, 则取最靠前的一条。
例如,快速路由查找的应用中,是取输入报文的目的 IP地址作为内容输入 TCAM中, 查找相应的下一跳信息。其它应用也是类似过程。 再例如, ACL查找的应用中, 用户配 置了 " Permit ip host 192.168.1.1 ; Deny ip any any"并绑定到端口, 当端口接收到报文时, 会提取报文的输入端口, 协议类型字段和源 IP地址作为内容输入 TCAM查找, 如果报 文类型是 IP,源 IP等于 192.168.1.1,则会命中 permit ip host 192.168.1.1这条对应的 TCAM 表项, 并执行其 permit的行为, 即允许转发; 否则其它报文都会被执行 deny的行为, 即 丢弃。
TCAM不论是应用于快速路由查找, 还是应用于 ACL查找等安全领域, TCAM的 表项之间常常需要保持一定的先后顺序, 或者说存在固定的优先级关系, 并采用连续空 间存储, TCAM表项会在设备的运行过程中, 不断地被更新。
现有的 TCAM表项的更新方法中, 当 TCAM中已存在较多表项时, 如图 1所示, 如果需要在表项 3和表项 4之间添加表项, 而表项 3和表项 4之间没有大小合适的连续 硬件空间, 则可能需要上下移动其他表项, 一个表项的添加, 可能带来其他大量表项的 重写, 导致表项更新效率较低。 发明内容
本发明提供一种三态内容寻址存储器的表项更新方法及装置, 用以解决现有三态内 容寻址存储器的表项更新效率较低的问题。 本发明实施例提供的一种三态内容寻址存储器的表项更新方法, 包括: 创建虚拟三态内容寻址存储器 TCAM列表, 所述虚拟 TCAM列表中各第一 TCAM 表项与硬件 TCAM中存储的各第二 TCAM表项一一对应;
根据预先指定的待更新的第一 TCAM 表项与所述虚拟 TCAM 列表中其他第一 TCAM表项存储位置的先后关系,在硬件 TCAM的空闲资源中确定出所述待更新的第一 TCAM表项对应的待更新的第二 TCAM表项的存储位置;
在硬件 TCAM中, 基于确定出的所述存储位置, 对待更新的第二 TCAM表项进行 更新操作。
本发明实施例提供的一种三态内容寻址存储器的表项更新装置, 包括:
创建单元, 用于创建虚拟三态内容寻址存储器 TCAM列表, 所述虚拟 TCAM列表 中各第一表项与硬件 TCAM中存储的各第二 TCAM表项一一对应;
存储位置确定单元, 用于根据预先指定的待更新的第一 TCAM 表项与所述虚拟 TCAM列表中其他第一 TCAM表项存储位置的先后关系, 在硬件 TCAM的空闲资源中 确定出所述待更新的第一 TCAM表项对应的待更新的第二 TCAM表项的存储位置; 更新操作单元, 用于在硬件 TCAM中, 基于确定出的所述存储位置, 对待更新的第 二 TCAM表项进行更新操作。
本发明实施例的有益效果包括:
本发明实施例提供的一种三态内容寻址存储器的表项更新方法及装置, 利用了创建 的虚拟 TCAM列表中各第一 TCAM表项与硬件 TCAM中各第二 TCAM表项的——对应 关系, 根据预先指定的待更新的第一 TCAM表项与虚拟 TCAM列表中其他第一 TCAM 表项存储位置之间的先后关系,在硬件 TCAM的空闲资源中确定该待更新的第一 TCAM 表项对应的待更新的第二 TCAM表项的存储位置, 在硬件 TCAM中, 基于确定出的存 储位置, 对待更新的第二 TCAM表项进行相应的更新操作。 本发明实施例使得待更新的 第二 TCAM表项的存储位置尽可能地在硬件 TCAM中的空闲位置中选择, 避免了现有 技术直接对于硬件 TCAM的第二 TCAM表项进行更新操作时, 由于硬件 TCAM中的各 第二 TCAM表项常常采用连续的存储空间进行存放, 为了保证待更新的第二 TCAM表 项与其他第二 TCAM表项之间的先后排列关系, 当待更新的第二 TCAM表项发生位置 冲突时, 不得不大量移动相关的第二 TCAM表项, 导致大量第二 TCAM表项重写引发 的硬件 TCAM表项更新效率较低的问题。 附图说明 图 1为现有技术提供的三态内容寻址存储器的表项示意图;
图 2为本发明实施例提供的三态内容寻址存储器的表项更新方法流程图; 图 3为本发明实施例提供的确定出待添加的第一 TCAM表项在硬件 TCAM中的存 储位置的方法的流程图;
图 4为本发明实施例提供的待添加的第一 TCAM表项与其他第一 TCAM表项的数 据内容的相关性判断的流程图;
图 5为本发明实施例提供的三态内容寻址存储器的表项更新装置的结构示意图; 图 6为本发明实施例提供的创建单元的结构示意图;
图 7为本发明实施例提供的存储位置确定单元的结构示意图。 具体实施方式
下面结合附图, 对本发明实施例提供的一种三态内容寻址存储器 (TCAM) 的表项 更新方法及装置的具体实施方式进行详细地说明。
本发明实施例提供的 TCAM的表项更新方法, 利用软件实现的虚拟 TCAM列表中 虚拟表项与实体的 TCAM中表项的一一对应关系, 通过对虚拟 TCAM列表中虚拟表项 执行一系列的操作, 来实现对实体的 TCAM中其对应的表项进行更新操作, 以下为了描 述简便起见, 将虚拟 TCAM列表中的虚拟表项称为第一 TCAM表项, 将实体的 TCAM 中的表项称为第二 TCAM表项。 为了与虚拟 TCAM列表相区分, 将实体的 TCAM称为 硬件 TCAM。
具体地, 如图 2所示, 本发明实施例提供的 TCAM的表项更新方法包括下述步骤: S201、创建虚拟 TCAM列表,该虚拟 TCAM列表中各第一 TCAM表项与硬件 TCAM 中存储的各第二 TCAM表项一一对应;
S202、 根据预先指定的待更新的第一 TCAM 表项与虚拟 TCAM 列表中其他第一 TCAM 表项存储位置的先后关系, 在硬件 TCAM 的空闲资源中确定出待更新的第一 TCAM表项对应的待更新的第二 TCAM表项的存储位置;
S203、 在硬件 TCAM中, 基于确定出的该存储位置, 对待更新的第二 TCAM表项 进行相应的更新操作。
下面对上述各步骤的具体实现过程进行详细地描述。
上述步骤 S201中, 创建一个链表作为虚拟 TCAM列表, 该链表中的每个数据节点 就是第一 TCAM表项, 在该链表中的每个第一 TCAM表项按照预定的先后顺序排列, 并与硬件 TCAM存储的各第二 TCAM表项一一对应; 每个第一 TCAM表项中的记录至少包括下述 6项内容:
与该第一 TCAM表项对应的第二 TCAM表项的数据内容 (用 data表示); 该第一 TCAM表项对应的第二 TCAM表项在硬件 TCAM中的存储位置(用 toamID 表示);
该第一 TCAM表项对应的第二 TCAM表项在硬件 TCAM中可任意移动的最小存储 位置 (用 minID表示);
该第一 TCAM表项对应的第二 TCAM表项在硬件 TCAM中可任意移动的最大存储 位置 (用 maxID表示);
该第一 TCAM表项的前置表项列表 (用 Prelist表示);
该第一 TCAM表项的后置表项列表 (用 Poslist表示)。
在具体实施时, 在上述记录的内容的基础上, 每个第一 TCAM表项还可以记录预先 设置的、 用于记录在 minID和 maxID之间空闲资源数量的空闲资源计数器的标识。
空闲资源计数器所记录的参数包括:
minID (该空闲资源计数器监控区域的上限);
maxID (该空闲资源计数器监控区域的下限);
referNum (该空闲资源计数器被引用的次数);
IdleNum (该空闲资源计数器监控区域内空闲的第二 TCAM表项的数量)。
在本发明具体实施时, 当建立了虚拟 TCAM列表后, 为了对该虚拟 TCAM列表中 的第一 TCAM表项进行有效管理, 还可以添加一个计数器, 令其 minID等于 0, 并令其 maxID等于 TCAM表的最大表项数, 在本发明实施例实施过程中, 可以通过如下方法对 该计数器进行相应管理。
在一个实施方式中, 当需要添加计数器时, 可以通过如下步骤完成:
S1: 输入计数器的 minID值和 maxID值;
其中,在本步骤中,只处理 maxID大于等于 minID,并且 minID大于等于 0和 maxID 小于 TCAM的总表项数。
S2: 根据输入参数查找计数器数据库。
其中, 数据存储形式有很多, 如链表, 二叉树, 数组等, 不同数据存储方式, 其查 找方法也不全相同, 在此不再赘述。
S3: 判断查找结果, 如果找到, 则执行步骤 S4, 否则执行步骤 S5。
S4: 计数器的 referNum字段加 1, 并返回计数器指针。 S5 : 在数据库中建立一新的计数器, 并计算指定范围内空闲条目数。
其中,可以对资源位表计算出指定范围内等于 0的位数,写入 idleNum字段。 referNum 字段值为 1, 返回计数器指针。
在另外一个实施方式中, 当需要删除计数器时, 可以通过如下步骤完成:
S1 : 输入计数器指针进行参数合法性检查;
S2: 计数器的 referNum字段值减 1;
其中, 计数器的 referNum字段值减 1, 表示应用此计数器的表项少了一个。
S3: 判断是否已经可以删除了, 即 referNum是否等于 0。
其中, 如果 referNum等于 0, 则表示没有任何引用者, 那么就可以执行步骤 324删 除了。 否则直接返回。
S4: 将计数器从计数器管理库中删除。
在另外一个实施方式中, 当需要对相关计数器更新时, 可以通过如下步骤完成: S1: 输入 tcamID及操作类型进行参数合法性检查;
其中, 本实施例只接受添加或删除操作类型。
S2: 遍历计数器数据库, 获取第一个计数器;
S3: 判断获取到的第一个计数器是否在范围中;
其中, 可以根据计数器的 minID和 maxID判断, 输入 tcamID参数是否大于等于 minID, 并且小等于 maxID, 是则执行步骤 S5, 否则执行步骤 S4;
S4: 判断是否是最后一个计数器被处理了, 是则结束, 并退出此段程序。 否则执行 步骤 S6;
S5 : 根据操作类型, 更新计数器的 idleNum值, 如果是添加操作, 则加一, 否则减
S6: 依据具体计数器采用的管理方式, 获得下一个计数器。 如链表, 则取 next指针 值, 若是数组, 则下标加 1等等。
在本发明具体实施时, 当建立了虚拟 TCAM列表后, 为了合理分配空闲资源, 还可 以建立空闲资源位表,例如申请一块内存块, 内存块字节数等于 TCAM的最大条目数 /8, 并使所有位都为 0。
在一个实施方式中, 当需要分配一个空闲表项时, 可以通过如下步骤完成:
S1 : 输入参数检查, 只接受有效的虚拟 TCAM表项;
S2: 判断虚拟 TCAM表中 minID是否小于 maxID, 如果是, 则执行步骤 S5, 否则 步骤 S3;
S3: 在资源位表的 minlD 禾 B maxID 间, 通过公式: (weight/掩码总的 bit数) * (maxld-minld+l ) +minID, 计算得到一个可能空闲的位置, 以此位置为中心, 向前后两 个方向寻找一个空闲资源, 直到寻找到或遍历完该区间的每一个 bit;
S4: 如果没有找到空闲资源, 则说明该范围内被填满了其它表项, 需扩大范围查找, 即执行步骤 S5, 否则直接返回成功。
S5 : 在整个 TCAM列表范围内, 必定会找到一个空闲表项, 因为添加虚拟 TCAM表 操作时, 已经判断整表有至少一个空闲表项。通过公式: (weight/掩码总的 bit数) * (team 表总数) 得到查找的初始位置, 直到找到空闲表项。
S6: 由于扩大范围得到的空闲资源位置, 不能满足优先级关系, 因此需要调整相关 表项。
在另外一个实施方式中, 当插入空闲表项时, 可以通过如下步骤完成:
S1 : 输入参数检查;
其中, 这里的参数包括虚拟 TCAM表项指针和空闲表项 tcamID。
S2: 如果 minID-1小于 maxID+l , 那么说明现在表项的前置和后置位置应该互换, 则执行步骤 S3, 否则执行 S4;
S3: 利用空闲表项, 将所有前置及后置表项逐个对换;
其中, tcamlD大于 minlD, 那么与 maxID对应表项互换, 这就转换成 tcamlD小于 剩下后置列表中最大的 tcamlD, 接着将新空闲表项 tcamlD同 minlD对应表项互换, 这 样就又变成新的 tcamlD大于剩余后置列表中的 tcamlD,如此反复,直到空闲表项 tcamlD 大于前置表项的 tcamlD, 并且小于所有后置表项的 tcamID。
S4: 在前置和后置顺序正确情况下, 判断空闲表项是在前置前面还是在后置前面, 也即判断 tcamlD是否小于 minlD, 如果在前置前面, 也即判断的结果为是, 则执行步骤 S6; 否则执行步骤 S5。
S5 : 取 maxID对应表项对换;
其中, 只需要将空闲表项同前置中最大一个替换就能满足表项插入后的交集约束条 件。
S6: 取 minlD对应表项对换。
其中, 只需要将空闲表项同后置中最小一个替换就能满足表项插入后的交集约束条 件。 在另外一个实施方式中, 当要置换空闲表项时, 可以通过如下步骤完成:
S1 : 输入参数检查;
其中, 这里的参数包括待换虚拟 TCAM表项指针和空闲表项 tcamID。
S2: 判断是否可以置换?
其中, 通过判断空闲表项 toamID是否在待换表项的 minID和 maxID所指的空间区 域内, 是则执行步骤 S3, 否则先执行步骤 S4后再执行步骤 S3。
S3: 完成表项交换, 并触发计数器更新操作;
其中, 将待换表项对应的硬件表项复制到空闲表项对应位置, 并更改虚拟 TCAM表 项数据, 及触发计数器更新。
S4: 递归调用所有步骤, 传入不可换的前置或后置节点和空闲表项 ID。
其中,如果传入的待换表项 tcamID大于空闲表项的 tcamID,那么取待换节点的 minID 值对应的表项先与空闲表项交换, 否则取 maxID对应的表项先于空闲表项交换, 这个过 程可能需要多次递归才能完成。 完成后执行步骤 S3。
由于现有技术中, 主要是添加和删除硬件 TCAM中表项的操作, 可能引起大量表项 的重写, 导致硬件 TCAM更新效率较低的问题, 本发明实施例提供的 TCAM的表项更 新方法也针对这两种更新的操作进行相应地改进, 图 1所示的 S202和 S203因为不同的 更新操作会有不同的实现方式, 下面分别针对添加表项和删除表项说明这两个步骤的实 现方式。
对于在硬件 TCAM中添加第二 TCAM表项 (以下称为待添加的第二 TCAM表项) 的操作来说, 一般会预先指定该第二 TCAM表项排在某个已有的第二 TCAM表项之后, 相应地, 上述步骤 S202中, 如图 3所示, 需要对待添加的第二 TCAM表项对应的虚拟 TCAM列表中的第一 TCAM表项 (以下称为待添加的第一 TCAM表项)进行下述操作: S202K 在虚拟 TCAM列表中, 确定预先指定的待添加的第二 TCAM表项对应的待 添加的第一 TCAM表项前一个第一 TCAM表项的存储位置;
S2022, 在确定出的存储位置之后插入待添加的第一 TCAM表项, 并在待添加的第 一 TCAM表项中记录该待添加的第二 TCAM表项的数据内容 (data);
52023、根据记录的数据内容与虚拟 TCAM列表中其他第一 TCAM表项的数据内容, 确定虚拟 TCAM列表中与该待添加的第一 TCAM表项相关的其他第一 TCAM表项;
52024, 将虚拟 TCAM列表中排列在该待添加的第一 TCAM表项之前与其相关的所 有第一 TCAM表项确定为其前置列表中的表项; 将虚拟 TCAM列表中排列在所述待添加的第一 TCAM表项之后与其相关的所有第 一 TCAM表项确定为其后置列表中的表项;
52025、 将该待添加的第一 TCAM表项的前置列表中位置最靠后的第一 TCAM表项 对应的第二 TCAM表项在硬件 TCAM中的存储位置增加 1,作为该待添加的第二 TCAM 表项在硬件 TCAM中可任意移动的最小存储位置, 用 minID表示;
将所述后置列表中位置最靠前的第一 TCAM 表项对应的第二 TCAM 表项在硬件 TCAM中的存储位置减去 1,作为该待添加的第二 TCAM表项在硬件 TCAM中可任意移 动的最大存储位置, 用 maxID表示;
较佳地, 在上述步骤 S2025之后, 可以通过预先设置的 minID和 maxID之间的空闲 资源计数器判断当前硬件 TCAM 中是否有空闲资源, 如果有, 进一步执行下述步骤 S2026。
52026、 根据步骤 S2025得到的最小存储位置和最大存储位置, 在硬件 TCAM的空 闲资源中确定该待添加的第二 TCAM表项的存储位置。
本发明的发明人发现, 现有硬件 TCAM存储的第二 TCAM表项中, 必须保持严格 的先后关系的表项之间是存在相关性的,对应地,步骤 S2023中,在虚拟 TCAM列表中, 确定与待添加的第一 TCAM表项相关的其他第一 TCAM表项的过程, 也就是确定与待 添加的第一 TCAM表项有严格先后顺序的第一 TCAM表项的过程。
在本发明实施例中, 第一种实施方式是在第一 TCAM表项内容不涉及四层端口信息 的前提下, 确定待添加的第一 TCAM表项与虚拟 TCAM列表中其他第一 TCAM表项之 间是否有相关性, 是通过待添加的第一 TCAM表项与其他第一 TCAM表项的数据内容 的相关性来判断, 具体做法如下:
将待添加的第一 TCAM表项与虚拟 TCAM列表中其他第一 TCAM表项记录的数据 内容分为规则的值和掩码;
现有技术中, 每一个第二 TCAM表项在硬件 TCAM中都是以<规则的值 (即地址的 关键字)、 掩码 >序偶的形式存储, 对于与硬件 TCAM中的第二 TCAM表项一一对应的 第一 TCAM表项来说, 其记录的数据内容就是其对应的第二 TCAM表项中包含的规则 的值和掩码。
针对待添加的第一 TCAM表项和虚拟 TCAM列表中某一个已有的第一 TCAM表项, 也即其他第一 TCAM表项, 进行下列计算: (^ © Ν^Μ^Μ ,
上式中: ^为待添加的第一 TCAM表项的规则的值; N2为该其他第一 TCAM表项 的规则的值; 为待添加的第一 TCAM表项的掩码; M2为该其他第一 TCAM表项的 掩码。
上述公式通过 与^2之间进行的异或运算,然后再依次与 Mi和 2进行与运算,如 果最终运算结果为零, 则可以认为第一 TCAM表项和该其他第一 TCAM表项相关, 否 则, 两者不相关。
上述公式(^1 @ ^2) * 1 * 2原理说明如下: 与^2之间进行异或运算, 得到参与 计算的两个第一 TCAM表项的规则间的差异部分, M B M2进行与运算, 得到参与计算 的两个第一 TCAM表项的公共掩码, 将差异部分与公共掩码再进行与运算, 如果结果为 零, 则表示参与计算的两个第一 TCAM表项的规则之间的差异部分, 总是与参与计算的 某一个第一 TCAM 表项的规则不相关, 换言之该差异部分总与参与计算的某一个第一 TCAM表项的规则之间不存在交集, 则判断参与计算的两个第一 TCAM表项相关。
下面举个实例来说明上述公式的计算过程:
假设待添加的第一 TCAM 表项的规则的值和掩码分别为: 192.168.5.1 255.255.255.255;
其他第一 TCAM表项的规则的值和掩码分别为: 192.168.5.0 255.255.255.0; 从逻辑关系上看, 待添加的第一 TCAM表项的规则的值是其他第一 TCAM表项的 规则的值的子集。
如果使用上述公式, 192.168.5.1同 192.168.5.0之间进行异或运算得到结果 0.0.0.1 ; 进一步同掩码 255.255.255.255进行与运算, 得到 0.0.0.1的结果;
进一步同掩码 255.255.255.0进行与运算, 得到最终的结果 0.0.0.0;
上述计算的最终结果说明, 上述参与计算的待添加的第一 TCAM 表项与其他第一 TCAM表项之间相关, 与逻辑关系判断的结果是一致的。
第二种实施方式是在第一 TCAM表项记录的内容,除了上述 6项信息之外,还包括: 四层端口号信息和关联行为信息。 这种在现有的 ACL应用中比较常见, 在这种实施方式 下, 待添加的第一 TCAM表项与其他第一 TCAM表项的数据内容的相关性来判断过程 如图 4所示, 包括下述步骤:
5401、 将待添加的第一 TCAM表项与虚拟 TCAM列表中其他第一 TCAM表项记录 的数据内容分为规则的值和掩码;
5402、针对待添加的第一 TCAM表项和虚拟 TCAM列表中某一个已有的第一 TCAM 表项 (其他第一 TCAM表项) 进行下列计算: (Ν Ν^Μ^Μ 上式中: 为待添加的第一 TCAM表项的规则的值; N2为该其他第一 TCAM表项 的规则的值; 为待添加的第一 TCAM表项的掩码; M2为该其他第一 TCAM表项的 掩码。
如果计算结果为零, 则执行下述步骤 S403; 否则, 跳转至下述步骤 S406;
S403、 进一步比较待添加的第一 TCAM表项与该其他第一 TCAM表项记录的四层 端口号信息之间是否存在交集, 若存在, 则转向步骤 S404, 否则转向步骤 S406;
S404、 进一步比较待添加的第一 TCAM表项与虚拟 TCAM列表中其他第一 TCAM 表项记录的关联行为信息是否一致; 若不一致, 则转向步骤 S405; 若一致, 则转向步骤 S406;
S405、 确定待添加的第一 TCAM表项与该其他第一 TCAM表项相关;
S406、 确定待添加的第一 TCAM表项与该其他第一 TCAM表项不相关。
上述步骤 S403中,四层端口号信息可以通过四层端口比较器对四层端口号信息的描 述语句进行比较, 例如待添加的第一 TCAM表项与该其他第一 TCAM表项的四层端口 号信息描述的都是大于某一个端口号的情况, 则显然两者存在交集, 则可以认定待添加 的第一 TCAM表项与该其他第一 TCAM表项相关。
上述步骤 S404中, 第一 TCAM表项记录的关联行为信息, 就是第一 TCAM表项对 应的执行动作, 例如 Premit tcp any any gt 80 any的表项来说, Premit即允许转发就是其 关联行为信息, 现有技术中, 还存在其他例如丢弃报文、 镜像、 重定向、 执行路由下一 跳、 修改报文的某些字段、 控制带宽等等, 关联行为信息一样的第一 TCAM表项之间, 认为是没有相关性的, 也就是不存在严格的先后排列顺序。
本发明的发明人还发现, 虚拟 TCAM列表中, 第一 TCAM表项中等于 1的比特越 多, 换言之等于 0的比特越少, 越有可能放在虚拟 TCAM列表的前面。 那么利用这一特 点, 尽量将掩码中含有较多等于 1的比特的第一 TCAM表项分配在较靠前的存储位置。 这样可进一步减少表项移动的发生。
基于上述原理的应用, 可以在上述步骤 S2026在具体实施时, 先通过下述公式计算 待添加的第二 TCAM表项在硬件 TCAM中的一个可能的存储位置:
tcamID=N* (maxID-minID+1 ) +minID;
其中, tcamID为该待添加的第二 TCAM表项在硬件 TCAM中可能的存储位置; N 为该待添加的第一 TCAM表项的掩码中零比特与该掩码总比特数的比值; maxID为待添 加的第二 TCAM表项在硬件 TCAM中可任意移动的最大存储位置, minlD为待添加的第 二 TCAM表项在硬件 TCAM中可任意移动的最小存储位置。
然后, 如果上述可能的存储位置在硬件 TCAM中没有被占用, 那么可以将计算出的 所述可能的存储位置作为待添加的第二 TCAM表项在硬件 TCAM中的存储位置; 反之, 如果计算出的上述可能的存储位置在硬件 TCAM中已经被占用, 那么可以在计算出的存 储位置往上或者往下继续查找空闲的存储资源, 选择距离该计算出的可能的存储位置最 近的一个空闲位置作为待添加的第二 TCAM表项在硬件 TCAM中的存储位置。
在添加表项的操作中,上述步骤 S2024之后,对虚拟 TCAM列表中已有的第一 TCAM 表项来说, 还可以执行下述操作:
对待添加的第一 TCAM表项的前置列表的每个第一 TCAM表项来说, 在其后置列 表中, 增加该待添加的第一 TCAM表项;
对待添加的第一 TCAM表项的后置列表的每个第一 TCAM表项来说, 在其前置列 表中, 增加该待添加的第一 TCAM表项。
完成将待添加的第一 TCAM表项插入到虚拟 TCAM列表的操作之后, 本发明实施 例中, 只要根据该待添加的第二 TCAM表项在硬件 TCAM中的存储位置, 将该待添加 的第一 TCAM表项中记录的其对应的该待添加的第二 TCAM表项数据内容写入到该存 储位置即可。
对于在硬件 TCAM中删除第二 TCAM表项 (以下称为待删除的第二 TCAM表项) 的操作来说,其操作较为简单,只要根据待删除的第二 TCAM表项对应的虚拟 TCAM列 表中的第一 TCAM表项 (以下称为待删除的第一 TCAM表项) 中记录的该待删除的第 二 TCAM表项的存储位置, 在硬件 TCAM中删除即可。
另外, 还需要对虚拟 TCAM列表, 执行下述一系列删除操作:
在待删除的第一 TCAM表项的前置列表的每个第一表项的后置列表中, 删除该待删 除的第一 TCAM表项;
在待删除的第一 TCAM表项的后置列表的每个第一表项的前置列表中, 删除该待删 除的第一 TCAM表项;
最后, 在虚拟 TCAM列表中删除该待删除的第一 TCAM表项。
基于同一发明构思, 本发明实施例还提供了一种三态内容寻址存储器的表项更新装 置, 由于该装置解决问题的原理与前述一种三态内容寻址存储器的表项更新方法相似, 因此该装置的实施可以参见方法的实施, 重复之处不再赘述。
如图 5所示, 本发明实施例提供的三态内容寻址存储器的表项更新装置包括: 创建单元 501, 用于创建虚拟三态内容寻址存储器 TCAM列表, 该虚拟 TCAM列表 中各第一表项与硬件 TCAM中存储的各第二 TCAM表项一一对应;
存储位置确定单元 502, 用于根据预先指定的待更新的第一 TCAM表项与所述虚拟 TCAM列表中其他第一 TCAM表项的先后存储位置关系, 在硬件 TCAM的空闲资源中 确定出该待更新的第一 TCAM表项对应的待更新的第二 TCAM表项的存储位置;
更新操作单元 503, 用于在硬件 TCAM中, 基于确定出的存储位置, 对待更新的第 二 TCAM表项进行更新操作。
如图 6所示, 上述创建单元 501进一步包括:
链表创建子单元 5011, 用于创建一个链表作为虚拟 TCAM列表; 将该链表中的每个 第一 TCAM表项按照预定的先后顺序排列, 并与硬件 TCAM存储的各第二 TCAM表项 对应;
记录子单元 5012, 用于在每个第一 TCAM表项记录中包括: 与该第一 TCAM表项 对应的第二 TCAM表项的数据内容、 该第一 TCAM表项对应的第二 TCAM表项在硬件 TCAM中的存储位置、 该第一 TCAM表项对应的第二 TCAM表项在硬件 TCAM中可任 意移动的最小存储位置和最大存储位置以及该第一 TCAM表项的前置表项列表和后置表 项列表。
如图 7所示, 上述存储位置确定单元 502进一步包括:
第一存储位置确定子单元 5021, 用于在虚拟 TCAM列表中, 确定预先指定的待添加 的第二 TCAM表项对应的待添加的第一 TCAM表项前一个第一 TCAM表项的存储位置; 相关性判断子单元 5022, 用于在确定出的存储位置之后插入该待添加的第一 TCAM 表项, 并在待添加的第一 TCAM表项中记录该待添加的第二 TCAM表项的数据内容; 并根据记录的所述数据内容与虚拟 TCAM列表中其他第一 TCAM表项记录的数据内容, 确定与待添加的第一 TCAM表项相关的其他第一 TCAM表项;
最大 /最小存储位置确定子单元 5023, 用于将虚拟 TCAM列表中排列在所述待添加 的第一 TCAM表项之前与其相关的所有第一 TCAM表项确定为其前置列表中的表项; 将虚拟 TCAM 列表中排列在所述待添加的第一 TCAM 表项之后与其相关的所有第一 TCAM表项确定为其后置列表中的表项;将所述前置列表中位置最靠后的第一 TCAM表 项对应的第二 TCAM表项在硬件 TCAM中的存储位置增加 1, 作为所述待添加的第二 TCAM表项在硬件 TCAM中可任意移动的最小存储位置;将所述后置列表中位置最靠前 的第一 TCAM表项对应的第二 TCAM表项在硬件 TCAM中的存储位置减去 1, 作为所 述待添加的第二 TCAM表项在硬件 TCAM中可任意移动的最大存储位置; 第二存储位置确定子单元 5024, 用于根据该最小存储位置和最大存储位置, 在硬件
TCAM的空闲资源中确定出该待添加的第二 TCAM表项的存储位置。
进一步地, 相关性判断子单元 5022, 用于将该待添加的第一 TCAM 表项与虚拟 TCAM列表中其他第一 TCAM表项记录的数据内容分为规则的值和掩码;
针对该待添加的第一 TCAM 表项和所述其他第一 TCAM 表项进行下列计算: 上式中: 为该待添加的第一 TCAM表项的规则的值; N2为虚拟 TCAM列表中其 他第一 TCAM表项的规则的值; 为该待添加的第一 TCAM表项的掩码; M2为该其 他第一 TCAM表项的掩码。
如果计算结果为零, 则确定所述待添加的第一 TCAM表项与该其他第一 TCAM表 项相关, 否则不相关。
进一步地, 相关性判断子单元 5022, 用于将该待添加的第一 TCAM 表项与虚拟 TCAM列表中其他第一 TCAM表项记录的数据内容分为规则的值和掩码;
针对该待添加的第一 TCAM 表项和该其他第一 TCAM 表项进行下列计算: 上式中: 为该待添加的第一 TCAM表项的规则的值; N2为虚拟 TCAM列表中其 他第一 TCAM表项的规则的值; 为该待添加的第一 TCAM表项的掩码; M2为该其 他第一 TCAM表项的掩码。
如果计算结果不为零, 则确定该待添加的第一 TCAM表项与该其他第一 TCAM表 项不相关; 否则, 进一步比较待添加的第一 TCAM表项与该其他第一 TCAM表项记录 的四层端口号信息之间是否存在交集, 若不存在, 则确定该待添加的第一 TCAM表项与 该其他第一 TCAM表项不相关; 若存在, 则进一步比较待添加的第一 TCAM表项与该 其他第一 TCAM表项记录的关联行为信息是否一致, 若不一致, 则确定该待添加的第一 TCAM表项与该其他第一 TCAM表项相关; 若一致, 则不相关。
进一步地, 上述第二存储位置确定子单元 5024, 还用于通过下述公式计算该待添加 的第二 TCAM表项在硬件 TCAM中可能的存储位置:
tcamID=N* (maxID-minID+1 ) +minID;
其中, tcamlD为待添加的第二 TCAM表项在硬件 TCAM中可能的存储位置; N为 所述待添加的第一 TCAM表项的掩码中零比特与该掩码总比特数的比值; maxID为所述 最大存储位置, minID为所述最小存储位置。
判断计算出的所述可能的存储位置是否为 TCAM的空闲资源; 若是, 则将计算出的 所述可能的存储位置作为待添加的第二 TCAM表项在硬件 TCAM中的存储位置; 若否, 则将距离计算出的所述可能的存储位置最近的空闲资源所在的存储位置作为待添加的第 二 TCAM表项在硬件 TCAM中的存储位置。
进一步地, 上述最大 /最小存储位置确定子单元 5023, 还用于在所述待添加的第一 TCAM 表项的前置列表的每个第一 TCAM表项的后置列表中, 增加所述待添加的第一 TCAM表项; 以及在所述待添加的第一 TCAM表项的后置列表的每个第一 TCAM表项 的前置列表中, 增加所述待添加的第一 TCAM表项。
进一步地, 上述更新操作单元 503, 还用于在硬件 TCAM 中, 根据待删除的第二
TCAM表项对应的待删除的第一 TCAM表项中记录的待删除的第二 TCAM表项的存储 位置, 删除该存储位置的第二 TCAM表项。
进一步地, 上述更新操作单元 503, 还用于在所述待删除的第一 TCAM表项的前置 列表的每个第一 TCAM表项的后置列表中, 删除所述待删除的第一 TCAM表项; 在所 述待删除的第一 TCAM表项的后置列表的每个第一 TCAM表项的前置列表中, 删除所 述待删除的第一 TCAM表项; 在所述虚拟 TCAM列表中删除所述待删除的第一 TCAM 表项。
本发明实施例提供的一种三态内容寻址存储器的表项更新方法及装置, 利用了创建 的虚拟 TCAM列表中各第一 TCAM表项与硬件 TCAM中各第二 TCAM表项的——对应 关系, 根据预先指定的待更新的第一 TCAM表项与虚拟 TCAM列表中其他第一 TCAM 表项的先后存储位置关系, 在硬件 TCAM的空闲资源中确定该待更新的第一 TCAM表 项对应的待更新的第二 TCAM表项的存储位置, 在硬件 TCAM中, 基于确定出的存储 位置, 对待更新的第二 TCAM表项进行相应的更新操作。
本发明实施例使得待更新的第二 TCAM表项的存储位置尽可能地在硬件 TCAM中 的空闲位置中选择, 避免了现有技术直接对于硬件 TCAM的第二 TCAM表项进行更新 操作时, 由于硬件 TCAM中的各第二 TCAM表项常常采用连续的存储空间进行存放, 为了保证待更新的第二 TCAM表项与其他第二 TCAM表项之间的先后排列关系, 当待 更新的第二 TCAM表项发生位置冲突时, 不得不大量移动相关的第二 TCAM表项, 导 致大量第二 TCAM表项重写引发的硬件 TCAM表项更新效率较低的问题。
进一步地, 本发明实施例中, 通过识别待更新的第二 TCAM表项对应的第一 TCAM 表项与虚拟 TCAM列表中其他第一 TCAM表项的相关性, 使得待更新的第二 TCAM表 项发生位置冲突时,即使没有空闲资源可选择,不可避免地需要移动第二 TCAM表项时, 仅移动与待更新的第二 TCAM表项相关 (保持严格先后排列顺序) 的表项, 而无需移动 与待更新的第二 TCAM表项无关 (没有严格先后排列顺序) 的表项, 大幅降低了可能移 动的第二 TCAM表项的数目, 进一步克服了现有硬件 TCAM表项更新效率较低的问题。
显然, 本领域的技术人员可以对本发明进行各种改动和变型而不脱离本发明的精神 和范围。 这样, 倘若本发明的这些修改和变型属于本发明权利要求及其等同技术的范围 之内, 则本发明也意图包含这些改动和变型在内。

Claims

权利要求书
1、 一种三态内容寻址存储器的表项更新方法, 其特征在于, 包括:
创建虚拟三态内容寻址存储器 TCAM列表, 所述虚拟 TCAM列表中各第一 TCAM 表项与硬件 TCAM中存储的各第二 TCAM表项一一对应;
根据预先指定的待更新的第一 TCAM 表项与所述虚拟 TCAM 列表中其他第一
TCAM表项存储位置的先后关系,在硬件 TCAM的空闲资源中确定出所述待更新的第一
TCAM表项对应的待更新的第二 TCAM表项的存储位置;
在硬件 TCAM中, 基于确定出的所述存储位置, 对待更新的第二 TCAM表项进行 更新操作。
2、如权利要求 1所述的方法,其特征在于,所述创建虚拟三态内容寻址存储器 TCAM 列表, 包括:
创建一个链表作为虚拟 TCAM列表;
将该链表中的每个第一 TCAM表项按照预定的先后顺序排列, 并与硬件 TCAM存 储的各第二 TCAM表项一一对应;
在每个第一 TCAM表项记录中包括: 与该第一 TCAM表项对应的第二 TCAM表项 的数据内容、与该第一 TCAM表项对应的第二 TCAM表项在硬件 TCAM中的存储位置、 与该第一 TCAM表项对应的第二 TCAM表项在硬件 TCAM中可任意移动的最小存储位 置和最大存储位置、 以及该第一 TCAM表项的前置表项列表和后置表项列表。
3、 如权利要求 2所述的方法, 其特征在于, 当更新操作为添加第二 TCAM表项时, 在硬件 TCAM的空闲资源中确定出待更新的第二 TCAM表项的存储位置, 包括:
在虚拟 TCAM列表中, 确定预先指定的待添加的第二 TCAM表项对应的待添加的 第一 TCAM表项的前一个第一 TCAM表项的存储位置;
在确定出的存储位置之后插入所述待添加的第一 TCAM 表项, 并在待添加的第一 TCAM表项中记录所述待添加的第二 TCAM表项的数据内容;
根据记录的所述数据内容与虚拟 TCAM列表中其他第一 TCAM表项记录的数据内 容, 确定与所述待添加的第一 TCAM表项相关的其他第一 TCAM表项;
将虚拟 TCAM列表中排列在所述待添加的第一 TCAM表项之前与其相关的所有第 一 TCAM表项确定为其前置列表中的表项;
将虚拟 TCAM列表中排列在所述待添加的第一 TCAM表项之后与其相关的所有第 一 TCAM表项确定为其后置列表中的表项; 将所述前置列表中位置最靠后的第一 TCAM 表项对应的第二 TCAM 表项在硬件 TCAM中的存储位置增加 1,作为所述待添加的第二 TCAM表项在硬件 TCAM中可任意 移动的最小存储位置;
将所述后置列表中位置最靠前的第一 TCAM 表项对应的第二 TCAM 表项在硬件 TCAM中的存储位置减去 1,作为所述待添加的第二 TCAM表项在硬件 TCAM中可任意 移动的最大存储位置;
根据所述最小存储位置和最大存储位置, 在硬件 TCAM的空闲资源中确定出所述待 添加的第二 TCAM表项的存储位置。
4、 如权利要求 3所述的方法, 其特征在于, 所述确定与所述待添加的第一 TCAM 表项相关的其他第一 TCAM表项, 包括:
将所述待添加的第一 TCAM表项与虚拟 TCAM列表中其他第一 TCAM表项记录的 数据内容分为规则的值和掩码;
针对所述待添加的第一 TCAM 表项和所述其他第一 TCAM 表项进行下列计算: 上式中: Ν,为所述待添加的第一 TCAM表项的规则的值; N2为所述其他第一 TCAM 表项的规则的值; 为所述待添加的第一 TCAM表项的掩码; 2为所述其他第一 TCAM 表项的掩码;
如果计算结果为零, 则确定所述待添加的第一 TCAM表项与其他第一 TCAM表项 相关, 否则不相关。
5、 如权利要求 3所述的方法, 其特征在于, 每个第一 TCAM表项的记录进一步还 包括: 四层端口号信息和关联行为信息;
所述确定与所述待添加的第一 TCAM表项相关的其他第一 TCAM表项, 包括: 将所述待添加的第一 TCAM表项与虚拟 TCAM列表中其他第一 TCAM表项记录的 数据内容分为规则的值和掩码;
针对所述待添加的第一 TCAM 表项和所述其他第一 TCAM 表项进行下列计算: 上式中: 为所述待添加的第一 TCAM表项的规则的值; 2为所述其他第一 TCAM 表项的规则的值; 为所述待添加的第一 TCAM表项的掩码; 2为所述其他第一 TCAM 表项的掩码;
如果计算结果不为零, 则确定所述待添加的第一 TCAM表项与其他第一 TCAM表 项不相关;
否则, 进一步比较待添加的第一 TCAM表项与虚拟 TCAM列表中其他第一 TCAM 表项记录的四层端口号信息之间是否存在交集, 若不存在, 则确定所述待添加的第一 TCAM表项与其他第一 TCAM表项不相关; 若存在, 则进一步比较待添加的第一 TCAM 表项与虚拟 TCAM列表中其他第一 TCAM表项记录的关联行为信息是否一致, 若不一 致, 则确定所述待添加的第一 TCAM表项与其他第一 TCAM表项相关; 若一致, 则不 相关。
6、如权利要求 3所述的方法,其特征在于,根据所述最小存储位置和最大存储位置, 在硬件 TCAM的空闲资源中确定出所述待添加的第二 TCAM表项的存储位置, 包括: 通过下述公式计算所述待添加的第二 TCAM表项在硬件 TCAM中可能的存储位置: tcamID=N* (maxID-minID+1 ) +minID;
其中, tcamlD为待添加的第二 TCAM表项在硬件 TCAM中可能的存储位置; N为 所述待添加的第一 TCAM表项的掩码中零比特与该掩码总比特数的比值; maxID为所述 最大存储位置, minID为所述最小存储位置;
判断计算出的所述可能的存储位置是否为硬件 TCAM的空闲资源;
若是, 则将计算出的所述可能的存储位置作为待添加的第二 TCAM 表项在硬件 TCAM中的存储位置;
若否, 则将距离计算出的所述可能的存储位置最近的空闲资源所在的存储位置作为 待添加的第二 TCAM表项在硬件 TCAM中的存储位置。
7、如权利要求 3-6任一项所述的方法, 其特征在于, 确定待添加的第一 TCAM表项 的前置列表和后置列表的步骤之后, 还包括:
在所述待添加的第一 TCAM表项的前置列表的每个第一 TCAM表项的后置列表中, 增加所述待添加的第一 TCAM表项;
在所述待添加的第一 TCAM表项的后置列表的每个第一 TCAM表项的前置列表中, 增加所述待添加的第一 TCAM表项。
8、 如权利要求 2所述的方法, 其特征在于, 当更新操作为删除第二 TCAM表项时, 在硬件 TCAM中, 根据确定出的所述存储位置, 对待更新的第二 TCAM表项进行更新 操作, 包括:
在硬件 TCAM中, 根据待删除的第二 TCAM表项对应的待删除的第一 TCAM表项 中记录的所述待删除的第二 TCAM表项的存储位置, 删除该存储位置的第二 TCAM表项。
9、 如权利要求 8所述的方法, 其特征在于, 在硬件 TCAM中删除第二 TCAM表项 的步骤之前, 还包括:
在所述待删除的第一 TCAM表项的前置列表的每个第一 TCAM表项的后置列表中, 删除所述待删除的第一 TCAM表项;
在所述待删除的第一 TCAM表项的后置列表的每个第一 TCAM表项的前置列表中, 删除所述待删除的第一 TCAM表项;
在所述虚拟 TCAM列表中删除所述待删除的第一 TCAM表项。
10、 一种三态内容寻址存储器的表项更新装置, 其特征在于, 包括:
创建单元, 用于创建虚拟三态内容寻址存储器 TCAM列表, 所述虚拟 TCAM列表 中各第一表项与硬件 TCAM中存储的各第二 TCAM表项一一对应;
存储位置确定单元, 用于根据预先指定的待更新的第一 TCAM 表项与所述虚拟 TCAM列表中其他第一 TCAM表项存储位置的先后关系, 在硬件 TCAM的空闲资源中 确定出所述待更新的第一 TCAM表项对应的待更新的第二 TCAM表项的存储位置; 更新操作单元, 用于在硬件 TCAM中, 基于确定出的所述存储位置, 对待更新的第 二 TCAM表项进行更新操作。
11、 如权利要求 10所述的装置, 其特征在于, 所述创建单元, 进一步还包括: 链表创建子单元, 用于创建一个链表作为虚拟 TCAM列表; 将该链表中的每个第一
TCAM表项按照预定的先后顺序排列, 并与硬件 TCAM存储的各第二 TCAM表项一一 对应;
记录子单元, 用于在每个第一 TCAM表项记录中包括: 与该第一 TCAM表项对应 的第二 TCAM表项的数据内容、 与该第一 TCAM表项对应的第二 TCAM表项在硬件 TCAM中的存储位置、 与该第一 TCAM表项对应的第二 TCAM表项在硬件 TCAM中可 任意移动的最小存储位置和最大存储位置、 以及该第一 TCAM表项的前置表项列表和后 置表项列表。
12、如权利要求 11所述的装置, 其特征在于, 所述存储位置确定单元, 进一步包括: 第一存储位置确定子单元, 用于在虚拟 TCAM列表中, 确定预先指定的待添加的第 二 TCAM表项对应的待添加的第一 TCAM表项的前一个第一 TCAM表项的存储位置; 相关性判断子单元, 用于在确定出的存储位置之后插入所述待添加的第一 TCAM表 项, 并在待添加的第一 TCAM表项中记录所述待添加的第二 TCAM表项记录的数据内 容; 根据记录的所述数据内容与虚拟 TCAM列表中其他第一 TCAM表项的数据内容, 确定与所述待添加的第一 TCAM表项相关的其他第一 TCAM表项;
最大 /最小存储位置确定子单元,用于将虚拟 TCAM列表中排列在所述待添加的第一 TCAM 表项之前与其相关的所有第一 TCAM表项确定为其前置列表中的表项; 将虚拟 TCAM列表中排列在所述待添加的第一 TCAM表项之后与其相关的所有第一 TCAM表 项确定为其后置列表中的表项; 将所述前置列表中位置最靠后的第一 TCAM表项对应的 第二 TCAM表项在硬件 TCAM中的存储位置增加 1, 作为所述待添加的第二 TCAM表 项在硬件 TCAM 中可任意移动的最小存储位置; 将所述后置列表中位置最靠前的第一 TCAM表项对应的第二 TCAM表项在硬件 TCAM中的存储位置减去 1,作为所述待添加 的第二 TCAM表项在硬件 TCAM中可任意移动的最大存储位置;
第二存储位置确定子单元, 用于根据所述最小存储位置和最大存储位置, 在硬件
TCAM的空闲资源中确定出所述待添加的第二 TCAM表项的存储位置。
13、 如权利要求 12所述的装置, 其特征在于, 所述相关性判断子单元, 进一步用于 将所述待添加的第一 TCAM表项与虚拟 TCAM列表中其他第一 TCAM表项记录的数据 内容分为规则的值和掩码;
针对所述待添加的第一 TCAM 表项和所述其他第一 TCAM 表项进行下列计算: 上式中: 为所述待添加的第一 TCAM表项的规则的值; 2为所述其他第一 TCAM 表项的规则的值; 为所述待添加的第一 TCAM表项的掩码; 2为所述其他第一 TCAM 表项的掩码;
如果计算结果为零, 则确定所述待添加的第一 TCAM表项与其他第一 TCAM表项 相关, 否则不相关。
14、 如权利要求 12所述的装置, 其特征在于, 所述相关性判断子单元, 进一步用于 将所述待添加的第一 TCAM表项与虚拟 TCAM列表中其他第一 TCAM表项记录的数据 内容分为规则的值和掩码;
针对所述待添加的第一 TCAM 表项和所述其他第一 TCAM 表项进行下列计算: 上式中: 为所述待添加的第一 TCAM表项的规则的值; 2为所述其他第一 TCAM 表项的规则的值; 为所述待添加的第一 TCAM表项的掩码; 2为所述其他第一 TCAM 表项的掩码;
如果计算结果不为零, 则确定所述待添加的第一 TCAM表项与其他第一 TCAM表 项不相关;
否则, 进一步比较待添加的第一 TCAM表项与虚拟 TCAM列表中其他第一 TCAM 表项记录的四层端口号信息之间是否存在交集, 若不存在, 则确定所述待添加的第一 TCAM表项与其他第一 TCAM表项不相关; 若存在, 则进一步比较待添加的第一 TCAM 表项与虚拟 TCAM列表中其他第一 TCAM表项记录的关联行为信息是否一致, 若不一 致, 则确定所述待添加的第一 TCAM表项与其他第一 TCAM表项相关; 若一致, 则不 相关。
15、 如权利要求 12所述的装置, 其特征在于, 所述第二存储位置确定子单元, 进一 步用于通过下述公式计算所述待添加的第二 TCAM表项在硬件 TCAM中可能的存储位 置: tcamID=N* (maxID-minID+1 ) +minID;
其中, tcamlD为待添加的第二 TCAM表项在硬件 TCAM中可能的存储位置; N为 所述待添加的第一 TCAM表项的掩码中零比特与该掩码总比特数的比值; maxID为所述 最大存储位置, minID为所述最小存储位置;
判断计算出的所述可能的存储位置是否为 TCAM的空闲资源;
若是, 则将计算出的所述可能的存储位置作为待添加的第二 TCAM 表项在硬件
TCAM中的存储位置;
若否, 则将距离计算出的所述可能的存储位置最近的空闲资源所在的存储位置作为 待添加的第二 TCAM表项在硬件 TCAM中的存储位置。
16、 如权利要求 12所述的装置, 其特征在于, 所述最大 /最小存储位置确定子单元, 还用于在所述待添加的第一 TCAM表项的前置列表的每个第一 TCAM表项的后置列表 中, 增加所述待添加的第一 TCAM表项; 以及在所述待添加的第一 TCAM表项的后置 列表的每个第一 TCAM表项的前置列表中, 增加所述待添加的第一 TCAM表项。
17、 如权利要求 11所述的装置, 其特征在于, 所述更新操作单元, 进一步用于在硬 件 TCAM中, 根据待删除的第二 TCAM表项对应的待删除的第一 TCAM表项中记录的 所述待删除的第二 TCAM表项的存储位置, 删除该存储位置的第二 TCAM表项。
18、 如权利要求 17所述的装置, 其特征在于, 所述更新操作单元, 还用于在所述待 删除的第一 TCAM表项的前置列表的每个第一 TCAM表项的后置列表中, 删除所述待 删除的第一 TCAM表项;在所述待删除的第一 TCAM表项的后置列表的每个第一 TCAM 表项的前置列表中, 删除所述待删除的第一 TCAM表项; 在所述虚拟 TCAM列表中删 除所述待删除的第一 TCAM表项。
PCT/CN2010/078298 2010-06-11 2010-11-01 一种三态内容寻址存储器的表项更新方法及装置 WO2011153784A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US13/158,262 US8527694B2 (en) 2010-06-11 2011-06-10 Method and apparatus for updating table entries of a ternary content addressable memory

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN 201010205047 CN101866357B (zh) 2010-06-11 2010-06-11 一种三态内容寻址存储器的表项更新方法及装置
CN201010205047.3 2010-06-11

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US13/158,262 Continuation US8527694B2 (en) 2010-06-11 2011-06-10 Method and apparatus for updating table entries of a ternary content addressable memory

Publications (1)

Publication Number Publication Date
WO2011153784A1 true WO2011153784A1 (zh) 2011-12-15

Family

ID=42958085

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2010/078298 WO2011153784A1 (zh) 2010-06-11 2010-11-01 一种三态内容寻址存储器的表项更新方法及装置

Country Status (2)

Country Link
CN (1) CN101866357B (zh)
WO (1) WO2011153784A1 (zh)

Families Citing this family (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101866357B (zh) * 2010-06-11 2011-11-16 北京星网锐捷网络技术有限公司 一种三态内容寻址存储器的表项更新方法及装置
CN101986271B (zh) * 2010-10-29 2014-11-05 中兴通讯股份有限公司 调度tcam查询和刷新消息的方法和装置
CN102045262B (zh) * 2011-01-14 2012-05-30 福建星网锐捷网络有限公司 媒体接入控制地址表更新方法、装置及网络设备
WO2012159311A1 (zh) * 2011-06-29 2012-11-29 华为技术有限公司 一种tcam表项的设置方法及装置
US8527695B2 (en) * 2011-07-29 2013-09-03 The Boeing Company System for updating an associative memory
CN102819617A (zh) * 2012-09-11 2012-12-12 苏州雄立科技有限公司 查找数据库中显性定义记录表项优先级的方法
CN105786733B (zh) * 2014-12-26 2020-08-07 南京中兴新软件有限责任公司 一种写入tcam条目的方法及装置
CN104702508B (zh) * 2015-03-24 2018-07-10 深圳中兴网信科技有限公司 表项动态更新方法及系统
CN107528782A (zh) * 2016-06-20 2017-12-29 中兴通讯股份有限公司 一种tcam表项的更新方法、装置及tcam
CN106330759B (zh) * 2016-09-29 2019-09-17 杭州迪普科技股份有限公司 一种调整acl表项的方法及装置
CN110557335B (zh) * 2018-06-04 2022-06-17 中兴通讯股份有限公司 三态内容寻址存储器tcam表项处理方法及装置
CN109688126B (zh) * 2018-12-19 2021-08-17 迈普通信技术股份有限公司 一种数据处理方法、网络设备及计算机可读存储介质
CN110032378B (zh) * 2019-04-16 2022-03-29 苏州盛科通信股份有限公司 一种芯片表项的带掩码操作方法及装置
CN111064714A (zh) * 2019-11-29 2020-04-24 苏州浪潮智能科技有限公司 一种基于fpga的智能网卡acl更新装置
CN110943871B (zh) * 2019-12-27 2022-11-01 杭州迪普科技股份有限公司 一种资源区间调整方法及装置
US11837330B2 (en) 2020-03-18 2023-12-05 Western Digital Technologies, Inc. Reference-guided genome sequencing
US20210398618A1 (en) * 2020-06-22 2021-12-23 Western Digital Technologies, Inc. Devices and methods for genome sequencing

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1896991A (zh) * 2006-03-02 2007-01-17 华为技术有限公司 动态范围匹配表维护方法
CN101039215A (zh) * 2006-08-10 2007-09-19 华为技术有限公司 一种维护三态内容可寻址存储器表项的方法和系统
CN101866357A (zh) * 2010-06-11 2010-10-20 福建星网锐捷网络有限公司 一种三态内容寻址存储器的表项更新方法及装置

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1216473C (zh) * 2003-03-28 2005-08-24 清华大学 支持多个下一跳的三态内容可寻址存储器查找方法及系统
US7120040B2 (en) * 2004-06-01 2006-10-10 Mosaid Technologies Incorporation Ternary CAM cell for reduced matchline capacitance

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1896991A (zh) * 2006-03-02 2007-01-17 华为技术有限公司 动态范围匹配表维护方法
CN101039215A (zh) * 2006-08-10 2007-09-19 华为技术有限公司 一种维护三态内容可寻址存储器表项的方法和系统
CN101866357A (zh) * 2010-06-11 2010-10-20 福建星网锐捷网络有限公司 一种三态内容寻址存储器的表项更新方法及装置

Also Published As

Publication number Publication date
CN101866357A (zh) 2010-10-20
CN101866357B (zh) 2011-11-16

Similar Documents

Publication Publication Date Title
WO2011153784A1 (zh) 一种三态内容寻址存储器的表项更新方法及装置
US7774538B2 (en) Method for ternary contents address memory table management
US8750144B1 (en) System and method for reducing required memory updates
CN103238145B (zh) 用于网络装备中的高性能、可更新和确定的哈希表的方法和设备
US20140301394A1 (en) Exact match hash lookup databases in network switch devices
KR100612256B1 (ko) 터너리 내용 주소화 메모리 관리 장치 및 그 방법
Qiu et al. Fastrule: Efficient flow entry updates for tcam-based openflow switches
US7327727B2 (en) Atomic lookup rule set transition
EP3661153B1 (en) Building decision tree for packet classification
JP2007202152A (ja) ルーティングシステム及びルーティングシステムのルールエントリー管理方法
Mishra et al. Duos-simple dual tcam architecture for routing tables with incremental update
JP2005513895A5 (zh)
CN107454019A (zh) 软件定义网络动态带宽分配方法、装置、设备及存储介质
US7392349B1 (en) Table management within a policy-based routing system
CN106487769B (zh) 一种访问控制列表acl的实现方法及装置
TWI638554B (zh) 用於網路交換機中的可擴展且靈活的表格搜索的裝置和方法
CN110557335B (zh) 三态内容寻址存储器tcam表项处理方法及装置
US20110307655A1 (en) Method and apparatus for updating table entries of a ternary content addressable memory
WO2015027924A1 (zh) 一种流表更新的控制方法、装置及控制器
US10084613B2 (en) Self adapting driver for controlling datapath hardware elements
CN106789727B (zh) 报文分类方法和装置
CN103907318B (zh) 流表刷新的方法及装置
US11368354B2 (en) Multi-result lookups
CN107528782A (zh) 一种tcam表项的更新方法、装置及tcam
JP5144225B2 (ja) 情報検索装置、及び情報検索装置へのエントリ情報の登録方法

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 10852775

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 10852775

Country of ref document: EP

Kind code of ref document: A1