WO2014029084A1 - 数据存储方法、查找方法及装置 - Google Patents
数据存储方法、查找方法及装置 Download PDFInfo
- Publication number
- WO2014029084A1 WO2014029084A1 PCT/CN2012/080460 CN2012080460W WO2014029084A1 WO 2014029084 A1 WO2014029084 A1 WO 2014029084A1 CN 2012080460 W CN2012080460 W CN 2012080460W WO 2014029084 A1 WO2014029084 A1 WO 2014029084A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- keyword
- cpu
- index value
- entry
- tcam
- Prior art date
Links
- 238000000034 method Methods 0.000 title claims abstract description 43
- 238000013500 data storage Methods 0.000 title claims abstract description 38
- 230000015654 memory Effects 0.000 claims abstract description 85
- 230000007547 defect Effects 0.000 abstract description 6
- 238000010586 diagram Methods 0.000 description 7
- 230000006870 function Effects 0.000 description 7
- 235000013399 edible fruits Nutrition 0.000 description 1
- 238000005265 energy consumption Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000001914 filtration Methods 0.000 description 1
- 238000013507 mapping Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/903—Querying
- G06F16/90335—Query processing
- G06F16/90339—Query processing by using parallel associative memories or content-addressable memories
-
- G—PHYSICS
- G11—INFORMATION STORAGE
- G11C—STATIC STORES
- G11C15/00—Digital 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
- Embodiments of the present invention relate to computer technologies, and in particular, to a data storage method, a search method, and an apparatus.
- the state of each bit in the Ternary Content Addressable Memory can be "0" or "1", or the third state "don't care", so it is called “three.” state”.
- This feature allows the TCAM to have a filtering function for the bit field of the searched data. All entries in the TCAM table can be accessed in parallel. For example, if the TCAM has 100 entries, the comparison can be performed on the 100 entries at a time. The normal polling search method improves the speed of the search.
- TCAM is relatively expensive, and the unit price of storage space is higher than that of ordinary SRAM, and the energy consumption is much higher than that of SRAM.
- the process of issuing keywords in the TCAM is summarized as follows:
- the keyword Key is extracted from the packet header, the keyword is written into the TCAM, and the index of the keyword in the TCAM is obtained.
- the index value Index can be the storage of the keyword in the TCAM. Address; After that, the processing information corresponding to the keyword is also referred to as associated data, and is written into the space in the RAM where the address is Index.
- the process of searching for a TCAM is summarized as follows: The keyword Key is extracted from the packet header, the keyword is sent to the TCAM, and the entry matching the keyword Key is found in the TCAM, and the index value Index of the matching entry is obtained, that is, the keyword.
- the index value Index is sent to the RAM, and the associated data corresponding to the keyword Key is searched in the RAM according to the index value Index, and the associated data is the processing information of the message including the keyword Key.
- the processing information for the foregoing packet may be an address mapping entry, an Access Control List (ACL) information, and routing information.
- ACL Access Control List
- Embodiments of the present invention provide a data storage method, a searching method, and a device, which are used to solve multiple
- an embodiment of the present invention provides a data storage method, including:
- the main CPU acquires a keyword to be stored in the TCAM and associated data corresponding to the keyword; the main CPU searches the TCAM for an entry in which the keyword is stored;
- the main CPU detects that the configuration attribute of the keyword includes at least two standby CPUs and does not include the primary CPU, and The first standby CPU sends first indication information including the keyword and the associated data, and sends second indication information including the associated data to the second standby CPU in the configuration attribute of the keyword, where the a standby CPU is any one of the configuration attributes, the second standby CPU is each backup CPU of the configuration attribute except the first standby CPU; the first indication information is used to indicate The first standby CPU stores the keyword to the TCAM, and stores the associated data in a memory of the first standby CPU according to an entry of the keyword in an index of the TCAM, and the first standby CPU The number is written to the entry in the delivery record table for the index value, and the index value is sent to the second standby CPU; the second indication information is used to indicate the second standby CPU According to the institute The index value of the entry of the keyword sent by the first standby CPU in the TCAM stores the associated data to a memory of the second standby CPU
- an embodiment of the present invention provides a data search method, including:
- the CPU receives a lookup indication including a keyword, and the lookup indication is used to instruct the CPU to search for corresponding associated data of the keyword;
- the CPU searches for an entry in the TCAM that stores the keyword
- the CPU obtains an index value of the entry of the keyword in the TCAM, and searches for the CPU in the entry of the index value of the record record table; An entry created for the index value in the record record table is used to record all CPUs that store associated data according to the index value; If the CPU is found, the CPU acquires the associated data corresponding to the keyword from the memory of the CPU according to the index value.
- the embodiment of the present invention further provides a data storage device, including:
- An obtaining module configured to acquire a keyword to be stored in the TCAM and associated data corresponding to the keyword
- a searching module configured to search, in the TCAM, an entry that stores the keyword
- a judging module configured to: if the search module does not find an entry that stores the keyword, determine whether the configuration attribute of the keyword includes at least two standby CPUs, and does not include the device;
- An indicating module configured to: if the searching module does not find an entry that stores the keyword, and the determining module detects that at least two standby CPUs are included in a configuration attribute of the keyword, and does not include the device Transmitting, by the first standby CPU in the configuration attribute, first indication information including the keyword and the associated data, and sending, to the second standby CPU, the associated data in the configuration attribute of the keyword a second indication information, the first standby CPU is any one of the configuration attributes, and the second standby CPU is each standby CPU of the configuration attribute except the first standby CPU; An indication information, configured to instruct the first standby CPU to store the keyword to the TCAM, and store the associated data in a memory of the first standby CPU according to an index value of the keyword according to an entry of the keyword And writing the number of the first standby CPU to the entry that is established for the index value in the delivery record table, and sending the index value to the second standby CPU; the second indication information, And indicating that the second standby CPU stores the associated data to a memory of the
- the embodiment of the invention further provides a data search device, including:
- a receiving module configured to receive a lookup indication including a keyword, where the lookup indication is used to indicate that the associated data of the keyword is searched for;
- a searching module configured to search, in the TCAM, an entry that stores the keyword
- the searching module is further configured to: if an entry that stores the keyword is found, obtain an index value of the entry of the keyword in the TCAM, and look up the entry in the index value of the release record table. a processor to which the device belongs; an entry established in the delivery record table for the index value is used to record all processors that store associated data according to the index value;
- an obtaining module configured to: when the searching module finds the processor, acquire, from the memory of the processor, the associated data corresponding to the keyword according to the index value.
- a standby CPU in the configuration attribute is stored in the TCAM.
- the CPU storing the keyword further stores the associated data corresponding to the keyword in the memory of the TCAM according to the index of the keyword, and updates the entry of the index value in the delivery record table, and configures the foregoing The index of the TCAM index of the entry of the above-mentioned keyword by the other standby CPU in the attribute.
- the other standby CPU stores the associated data with the above keywords in its own memory according to the value of the I, and updates the issued record table. Therefore, the technical solution provided by the embodiment of the present invention avoids the defect that one keyword in the TCAM corresponds to one or more entries, and achieves the purpose of storing the associated data of the keyword in the memory of each CPU in the configuration attribute.
- FIG. 1A is a flowchart of a data storage method according to an embodiment of the present invention.
- FIG. 1B is a flowchart of another data storage method according to an embodiment of the present invention.
- 3A is a flowchart of a data searching method according to an embodiment of the present invention.
- FIG. 3B is a schematic diagram of an application scenario according to an embodiment of the present invention.
- FIG. 4A is a schematic structural diagram of a data storage device according to an embodiment of the present invention.
- FIG. 4B is a schematic structural diagram of another data storage device according to an embodiment of the present invention
- FIG. 5 is a schematic structural diagram of a data search device according to an embodiment of the present invention. detailed description
- FIG. 1 is a flowchart of a data storage method according to an embodiment of the present invention. As shown in FIG. 1A, the data storage method provided in this embodiment includes:
- Step 11 The main CPU acquires a keyword to be stored in the TCAM and associated data corresponding to the above keyword.
- the embodiment of the present invention is applicable to a scenario in which a plurality of CPUs coexist.
- the CPU in the embodiment of the present invention may be a single-core CPU or a multi-core CPU. When multiple CPUs coexist, the currently running CPU is the primary CPU, and the other CPUs that are not running are the standby CPU. In the embodiment of the present invention, all CPUs share one TCAM, and each CPU has its own memory.
- the keyword that is delivered to the primary PCU by the upper-layer application includes a configuration attribute, where the configuration attribute of the keyword includes a CPU that stores the keyword indicated by the upper-layer application, and the CPU indicated by the upper-layer application may be one or more CPUs. It may include the main CPU or it may not include the standby CPU.
- Step 12 The main CPU looks up the above keywords in all the entries in the TCAM.
- the main CPU After the main CPU obtains the keyword to be stored in the TCAM, it first searches whether all the entries in the TCAM include the entry that stores the keyword.
- Step 13 If the entry that stores the above keyword is not found, the main CPU detects that the configuration attribute of the keyword includes at least two standby CPUs and does not include the primary CPU, and the first backup to the configuration attribute. The CPU sends the first indication information including the keyword and the associated data, and sends the second indication information including the associated data to the second standby CPU in the configuration attribute of the keyword.
- the host CPU determines whether at least two CPUs are included in the configuration attribute of the keyword. If at least two CPUs are included, determine whether the CPU is included in the CPU in the configuration properties.
- the configuration attribute includes at least two CPUs, indicating that the upper application indicates that multiple CPUs store the same keyword. This embodiment mainly involves a scenario in which multiple CPUs store the same keyword.
- the first standby CPU is any one of the configuration attributes of the standby CPU. Alternatively, it may be the standby CPU with the lowest number among the configuration attributes.
- the second standby CPU can be each of the backup CPUs except the first standby CPU in the configuration properties. If the CPU has at least two CPUs in the configuration attribute of the keyword, but does not include the main CPU, that is, when all the CPUs in the configuration attribute of the keyword are standby CPUs, the main CPU sends the above-mentioned keywords and the above-mentioned keywords to the first standby CPU. Correlating the first indication information of the data, and sending the second indication information including the association data to the second standby CPU. If there are more than one CPU other than the first standby CPU in the configuration attribute, the main CPU needs to send a plurality of second indication information, and send the second indication information to each CPU except the first standby CPU.
- the first indication information is used to instruct the first standby CPU to store the keyword to the TCAM, and store the associated data in the first step according to the index value of the TCAM according to the keyword
- the memory of the standby CPU writes the number of the first standby CPU to the entry established in the delivery record table for the index value, and sends the index value to the second standby CPU.
- the index value of the keyword in the TCAM may be a storage address of the keyword in the TCAM.
- the second indication information is used to instruct the second standby CPU to store the associated data in the memory of the second standby CPU according to the index value sent by the first standby CPU, and write the number of the second standby CPU into the foregoing An entry in the record table that is created for the above index value.
- the above keywords are stored in the TCAM according to the first indication information.
- the entry of the above keyword in the TCAM is the index value of the TCAM index of the entry of the above keyword.
- the first standby CPU stores the associated data corresponding to the keyword in the memory of the first standby CPU in the index of the TCAM according to the index of the keyword, and writes the number of the first standby CPU into the delivery record table as described above. An entry established by the index value, and sending the above index value to the second standby CPU in the above configuration attribute.
- the associated data is stored in the memory of the second standby CPU according to the index value sent by the first standby CPU, and the number of the second standby CPU is written in the foregoing release record table. The entry of the above index value.
- the first standby CPU stores the above-mentioned keyword in the TCAM, and stores the associated data in the memory of the first standby CPU in the index of the TCAM according to the entry of the keyword, and creates a table for the index value in the issued record table. item.
- the entry created for the above index value in the above-mentioned issue record table is used to record all the CPUs that store the associated data according to the above index value.
- an entry in the record table is used to record an index value and all CPUs that store associated data according to the index value.
- a CPU is written in the entry of an index value of the issued record table, indicating that the CPU has written the associated data in its own memory according to the index value.
- the primary CPU selects the backup CPU with the lowest number in the configuration attribute to store the keyword in the TCAM, and the other standby CPU does not need to store the keyword in the TCAM, so that one
- the keyword includes an entry in the TCAM, thereby avoiding the phenomenon that multiple CPUs issue the same keyword in the TCAM.
- the standby CPU selected by the main CPU stores the associated data of the keyword in its own memory, updates the issued record table, and sends the index value of the keyword to other standby CPUs in the configuration attribute.
- Other standby CPUs in the configuration attribute are based on the index value sent by the standby CPU described above.
- the associated data of the keyword is stored in the memory and the issued record table is updated. Therefore, the above technical solution avoids the defect that one keyword in the TCAM corresponds to more than one entry when multiple CPUs issue the same keyword, and the memory of each CPU is stored in the configuration attribute of the keyword.
- the purpose of the keyword's associated data is stored in the memory and the issued record table is updated.
- step 14 may also be included.
- Step 14 If the entry that stores the above keyword is not found, the primary CPU detects that the configuration attribute of the keyword includes the primary CPU and the at least one standby CPU, and stores the keyword in the TCAM according to the above key.
- the entry of the word is stored in the memory of the TCAM in the index value of the TCAM, and the number of the main CPU is written in the configuration attribute of the keyword after the number of the main CPU is written in the table of the index value. All of the standby CPUs described above transmit third indication information including the associated data and the index value.
- the configuration attribute of the keyword includes at least two CPUs and includes the primary CPU
- the primary CPU stores the keyword in the TCAM, and all the backups in the configuration attribute are used.
- the CPU does not need to store this keyword in the TCAM.
- the main CPU stores the associated data in its own memory according to the index of the above-mentioned keyword, and creates an entry in the issued record table as the index value of the above keyword.
- the main CPU also sends third indication information including the index value of the keyword in the TCAM and the associated data of the keyword to all the standby CPUs in the configuration attribute.
- All the standby CPUs in the above configuration attribute store the associated data in its own memory according to the index value sent by the main CPU according to the indication of the third indication information, and write the own number into the above-mentioned issued record table as the index value.
- the created entry After the standby CPUs of the keyword configuration attribute are switched to the primary CPU, the associated data is stored in the memory of the standby CPU according to the index value sent by the primary CPU, and the own number is written in the above-mentioned delivery record table. The entry created by the index value.
- the main CPU stores the keyword in the TCAM, and if the configuration attribute does not include the main CPU
- the above keywords are stored in the TCAM by a standby CPU in the configuration properties.
- the CPU storing the keyword further stores the associated data corresponding to the keyword in the memory of the TCAM according to the index of the keyword, and updates the entry of the index value in the delivery record table, and configures the foregoing The index of the TCAM index of the entry of the above-mentioned keyword by the other standby CPU in the attribute. But other standby CPUs do not need to store keywords in the TCAM.
- the associated data of the above keywords is stored in its own memory according to the index value, and the issued record table is updated. Therefore, the technical solution provided in this embodiment avoids the defect that one keyword corresponds to more than one entry in the TCAM, and achieves the purpose of storing the associated data of the keyword in the memory of each CPU in the configuration attribute.
- the main CPU determines whether the CPU is the standby CPU or the main CPU.
- the fourth CPU transmits the fourth indication information including the keyword and the associated data to the standby CPU in the configuration attribute.
- the standby CPU stores the above keyword in the TCAM according to the indication of the fourth indication information, and stores the associated data in its own memory according to the index value of the TCAM according to the entry of the keyword, and the configuration attribute is included in the configuration attribute.
- the number of the standby CPU is written to the entry of the above index value in the above-mentioned issued record table.
- the main CPU detects that the CPU is the main CPU in the configuration attribute of the keyword, the main CPU stores the keyword in the TCAM, and stores the associated data in its own memory according to the index value of the TCAM according to the keyword, and the main CPU is The entry of the above index value in the above-mentioned issued record table is written.
- the primary CPU searches for an entry in the TCAM that stores the above keyword, in order to avoid storing duplicate entries in the TCAM, the CPU does not need to store the keyword in the TCAM again in the configuration attribute of the keyword.
- the associated data is stored in its own memory.
- the main CPU obtains the index of the TCAM, and sends the fifth indication information including the index value to each standby CPU in the configuration attribute after the index value of the TCAM, and the standby CPU in the configuration attribute is configured according to the The indication of the five indication information stores the associated data in its own memory according to the index value, and then writes its own number into the entry created in the above-mentioned issued record table for the index value.
- the main CPU obtains the index of the above keyword in the TCAM index value, and stores the associated data in its own memory according to the obtained index value, and the main CPU is The number is written to the entry of the above index value in the above-mentioned issued record table.
- FIG. 2 is a flowchart of still another data storage method according to an embodiment of the present invention.
- Figure 2 shows the specific processing process after the main CPU receives the keywords and associated data to be stored.
- the method provided in this embodiment includes:
- Step 21 The main CPU acquires the keyword to be stored and the associated data corresponding to the keyword.
- Step 22 The main CPU searches for all the entries of the TCAM including the entries storing the above keywords. If step 23 is performed, step 210 is performed.
- Step 23 If the entry containing the above keyword is included, the main CPU determines whether multiple CPUs are included in the configuration attribute of the keyword. If step 24 is performed, go to step 27.
- Step 24 If multiple CPUs are included in the configuration attribute of the keyword, determine whether multiple CPUs include the main CPU. If the CPU includes multiple CPUs, go to step 25. Otherwise, go to step 26.
- Step 25 The main CPU stores the above keywords in the TCAM, and stores the associated data in its own memory according to the index of the above-mentioned keyword, and writes the number of the main CPU into the index in the delivery record table. After the entry of the value, the third indication information including the association data and the index value is sent to each standby CPU in the configuration attribute of the keyword.
- the entry of the above keyword in the TCAM is the index value of the TCAM index of the entry of the above keyword.
- the index value of the associated data corresponding to the keyword in the memory can be determined by the index value of the TCAM index of the above keyword.
- Each of the standby CPUs in the configuration attribute stores the associated data in the memory of the standby CPU according to the index value sent by the primary CPU, and writes the respective numbers into the entries established in the above-mentioned issued record table for the index value, for example, The number of the standby CPU is written in the above-mentioned issued record table for the entry established by the above index value.
- the table of the above index value of the release record table is used to record all the processors storing the associated data according to the above index value.
- Table 1 is a delivery record table provided by an embodiment of the present invention.
- the index value of each keyword in the TCAM corresponds to an entry in the delivery record table.
- a flag corresponding to a CPU is 1, indicating that the CPU stores the associated data in its own memory according to the index value, and the flag corresponding to one CPU is 0.
- the flag bits of CPU-A and CPU-B are both 1, and the flags of other CPUs are all 0, indicating that CPU-A and CPU-B are already based on the index value 0.
- the associated data is stored in the memory.
- Table 1 is a delivery record table provided by an embodiment of the present invention. 2 1 1 1 CPU-A ⁇ B ⁇ N sharing
- Step 26 If the configuration attribute does not include the main CPU, the main CPU sends the first indication information including the keyword and the associated data to the first standby CPU in the configuration attribute, and the configuration attribute of the keyword is The second standby CPU sends a second indication letter including the foregoing associated data.
- the first standby CPU stores the keyword in the TCAM according to the instruction of the first indication information of the main CPU, and stores the associated data in the memory of the first standby CPU according to the index of the keyword in the index of the TCAM.
- the number of the first standby CPU is written into the entry established in the delivery record table for the index value, and the value of the cable is sent to the second standby CPU.
- the second standby CPU stores the associated data in the memory of the second standby CPU by using the index value sent by the first standby CPU according to the indication of the second indication information of the primary CPU, and writes the number of the second standby CPU.
- the entry in the above-mentioned issued record table is the entry of the above index value.
- the specific method of writing the number of the second standby CPU to the entry in the above-mentioned issue record table for the index value may be that the second standby CPU is in the entry in which the index value is located.
- the flag bit is written to 1.
- Step 27 If the configuration attribute of the above keyword includes a CPU, the main CPU determines whether the CPU in the configuration attribute is a standby CPU. If you are performing step 2, go to step 29.
- Step 28 If the CPU in the configuration attribute is a standby CPU, the main CPU sends a fourth indication information including the keyword and the associated data to the standby CPU in the configuration attribute.
- the backup CPU stores the above keywords in the TCAM according to the indication of the fourth indication information, and stores the associated data in its own memory according to the index of the TCAM according to the index of the keyword, in the delivery record table. Create an entry for the above index value, and write its own number to the entry created in the above-mentioned issue record table for the above index value.
- Step 29 If the CPU in the configuration attribute is the main CPU, the main CPU stores the above keywords to
- the TCAM stores the associated data in its own memory according to the index of the above-mentioned keyword in the index value of the TCAM, and writes the number of the main CPU into the entry created by the index value in the above-mentioned issued record table.
- Step 210 If an entry storing the above keyword is included in the TCAM, the main CPU acquires an index value of the entry of the keyword in the TCAM.
- Step 211 If at least one standby CPU is included in the configuration attribute, the primary CPU sends fifth indication information including the index value to each standby CPU in the configuration attribute.
- Each standby CPU in the configuration attribute stores the associated data in its own memory according to the index value according to the indication of the fifth indication information, and writes the respective numbers into the issued record table as the value of the cable The created entry.
- Step 212 If the configuration attribute further includes a main CPU, the main CPU stores the associated data in its own memory according to the index value, and writes the number of the main CPU into the issued record table to establish the index value. Entry.
- the main CPU selects a CPU to store the keyword in the shared TCAM, and all The CPU updates the issued record table and stores the associated data of the keyword according to the index value of the keyword in the TCAM. If the keyword is found in the TCAM, the CPU does not need to select the CPU to store the keyword in the TCAM, and all CPUs update the issued record table and store the associated data of the keyword according to the index value of the TCAM according to the keyword.
- FIG. 3A is a flowchart of a data searching method according to an embodiment of the present invention. Based on the above data storage method, after the TCAM storage keyword stores the associated data of the keyword in the memory, the method of finding the associated data is performed. As shown in FIG. 3A, this embodiment includes:
- Step 31 The CPU receives a lookup indication including a keyword.
- the upper layer application sends a search indication including a keyword, and instructs the main CPU to search for the associated data corresponding to the keyword.
- Step 32 The CPU searches for the entry in the TCAM that stores the above keywords.
- Step 33 If the entry that stores the above keyword is found, the CPU obtains the index value of the entry of the keyword in the TCAM, and searches for the CPU in the entry of the index value of the record record table;
- the table entries established for the above index values in the table are used to record all CPUs that store associated data according to the above index values.
- the TCAM After the CPU inputs a keyword to the TCAM, if there is an entry for storing the keyword in the TCAM, the TCAM returns the index value of the entry of the above keyword in the TCAM to the CPU.
- Step 34 If the CPU is found in the entry of the index value of the record table, the CPU Searching for the associated data corresponding to the keyword in the memory of the CPU according to the index value. If the CPU finds a keyword in the TCAM and finds the primary CPU in the entry of the index value of the TCAM in the above-mentioned keyword of the delivery record table, it is determined that the associated data corresponding to the above keyword is stored in the memory of the CPU.
- the CPU determines that the CPU does not store the associated data corresponding to the above keyword in its own memory, and the CPU returns the search failure information to the upper layer application.
- the processor after the processor searches the TCAM for storing the entry of the keyword, the processor also needs to look up the delivery record table to determine whether the entry of the index value of the keyword includes the processor. If the processor is included, the processor is based on the entry of the keyword
- the index value of the TCAM reads the associated data corresponding to the above keyword from the memory of the above processor.
- FIG. 3B is a schematic diagram of an application scenario according to an embodiment of the present invention.
- the processor may be a Network Processor (NP), and the keyword to be searched is extracted from the message, and the keyword Key to be searched is sent to the TCAM.
- the TCAM finds the keyword
- the keyword returns the index INDEX of the TCAM to the NP
- the NP determines the storage address ADDR(address) of the associated data corresponding to the keyword KEY in the memory according to the index value INDEX returned by the TCAM.
- the associated data is then read from the memory based on the memory address to process the message.
- FIG. 4A is a schematic structural diagram of a data storage device according to an embodiment of the present invention.
- the data storage device provided in this embodiment includes: an obtaining module 41, a searching module 42, a determining module 43, and an indicating module 44.
- the obtaining module 41 is configured to acquire a keyword to be stored in the TCAM and associated data corresponding to the keyword.
- the searching module 42 is configured to search for an entry in the TCAM that stores the above keyword.
- the determining module 43 is configured to determine, if the lookup module 42 does not find the entry that stores the keyword, whether the configuration attribute of the keyword includes at least two standby CPUs and does not include the data storage device.
- the indicating module 44 is configured to: if the searching module 42 does not find the entry that stores the keyword And the determining module 43 detects that the configuration attribute includes at least two standby CPUs and does not include the data storage device, and sends the first indication information including the keyword and the associated data to the first standby CPU in the configuration attribute. Transmitting, to the second standby CPU in the foregoing configuration attribute, second indication information including associated data, where the first standby CPU is any one of the configuration attributes, and the second standby CPU is the configuration Each of the backup CPUs of the first standby CPU; the first indication information is used to indicate that the first standby CPU stores the keyword to the TCAM, and the associated data is obtained according to the index value of the TCAM according to the entry of the keyword.
- the second indication information is used for Instructing the second standby CPU to store the associated data to the memory of the second standby CPU according to the index value sent by the first standby CPU, and writing the number of the second standby CPU to the issued record
- the table is an entry created for the index value.
- the first standby CPU is the standby CPU with the lowest number among the configuration attributes.
- a storage module 45 may also be included on the basis of FIG. 4A.
- the determining module 43 is further configured to determine whether the data storage device and the at least one standby CPU are included in the configuration attribute of the keyword if the search module 42 does not find the entry that stores the keyword.
- the storage module 45 is configured to: when the search module 42 does not find the entry that stores the keyword, and the determining module detects that the configuration attribute includes the data storage device and the at least one standby CPU, storing the keyword to the TCAM And storing the associated data in the memory of the TCAM according to the index of the above-mentioned keyword, and writing the number of the data storage device to the entry created by the above-mentioned value in the issued record table.
- the instructing module 44 is further configured to: after the storage module 45 writes the number of the data storage device to the entry that is established in the delivery record table for the index value, sends the data including the associated data to the standby CPU in the configuration attribute of the keyword.
- the third indication information of the index value is used to indicate that all the backup processors in the configuration attribute store the associated data in the memory of the standby processor according to the index value sent by the device, and write the own number into the foregoing issued record.
- the table is the entry created for the above index value.
- each module in the data storage device has when the entry of the above keyword is not found in the TCAM and the configuration attribute of the keyword includes multiple CPUs.
- the data storage device in a case where a plurality of CPUs are included in a configuration attribute of a keyword, if the data storage device is included in the configuration attribute, the data storage device stores a keyword in the TCAM, if configured The data storage device is not included in the attribute, and the above keyword is stored in the TCAM by a standby CPU in the configuration attribute.
- the CPU storing the keyword further stores the associated data corresponding to the keyword in the memory of the TCAM according to the index of the keyword, and updates the entry of the index value in the delivery record table, and configures the foregoing The index of the TCAM index of the entry of the above-mentioned keyword by the other standby CPU in the attribute.
- the other standby CPU stores the associated data with the above keywords in its own memory according to the value of the I, and updates the issued record table. Therefore, the technical solution provided in this embodiment avoids the defect that one keyword corresponds to more than one entry in the TCAM, and achieves the purpose of storing the associated data of the keyword in the memory of each CPU in the configuration attribute.
- the determining module 43 is further configured to: if the searching module 42 does not find the keyword, determine whether the CPU includes a CPU and is a standby processor in the configuration attribute of the keyword.
- the instructing module 44 is further configured to: if the lookup module 42 does not find the entry that stores the keyword, and the determining module 43 detects that the configuration attribute includes a CPU and is a standby CPU, sending, to the standby CPU, the configuration parameter includes: The fourth indication information of the keyword and the foregoing associated data; the fourth indication information is used to indicate that the standby CPU in the configuration attribute stores the keyword to the TCAM, and the associated data is stored in the index value of the TCAM according to the entry of the keyword. Go to your own memory and write your own number to the entry created for the index value in the issued record table.
- the determining module 43 is further configured to: if the search module does not find the keyword, determine whether the CPU includes a CPU and is the data storage device in the configuration attribute of the keyword.
- the storage module 45 is further configured to: when the search module does not find the entry that stores the keyword and the determining module detects that the configuration attribute of the keyword includes a CPU and is the data storage device, storing the keyword To TCAM, according to the above keyword entry in the TCAM index The value stores the above-mentioned associated data in its own memory, and writes the number of the data storage device into the entry created for the index value in the delivery record table.
- the following embodiment describes the function of each module of the data storage device when the table in which the above-mentioned keyword is stored is found in the TCAM and the configuration attribute of the keyword includes a CPU. Referring to the corresponding embodiment of FIG. 2:
- the searching module 42 is further configured to: if an entry storing the above keyword is found, obtain an index value of the entry of the keyword in the TCAM.
- the indicating module 44 is further configured to: if the determining module detects that the configuration attribute includes at least one standby CPU, send, to all the standby CPUs in the configuration attribute, fifth indication information that includes an index value acquired by the searching module, for indicating All the standby CPUs in the configuration attribute store the above-mentioned associated data in its own memory according to the index value, and write its own number to the entry created for the index value in the delivery record table.
- the storage module 45 is further configured to: when the determining module detects that the configuration attribute further includes the data storage device, store the associated data in a memory of the main processor according to the index value, and store the data storage device The number is written to the entry in the issued record table for the index value.
- FIG. 5 is a schematic structural diagram of a data search apparatus according to an embodiment of the present invention.
- the data search device provided in this embodiment is mainly used to search for associated data corresponding to a keyword.
- the processor provided in this embodiment includes: a receiving module 51, a searching module 52, and an obtaining module 53.
- the receiving module 51 is configured to receive a lookup indication including a keyword, where the lookup indication is used to indicate that the associated data corresponding to the keyword is searched for.
- the searching module 52 is configured to search for an entry in the TCAM that stores the keyword.
- the searching module 52 is further configured to: if the entry that stores the keyword is found, obtain an index value of the entry of the keyword in the TCAM, and search for the processing of the device in the entry of the index value of the record table.
- the entry created in the above-mentioned issue record table for the above index value is used to record all the processors that store the associated data according to the above index value.
- the obtaining module 53 is configured to: if the searching module finds the processor, obtain the associated data corresponding to the keyword from the memory of the processor according to the index value.
- the processor provided in this embodiment further includes: a returning module, configured to: if the search module does not find an entry that stores the keyword in the TCAM, or does not find the entry in the index value of the issued record table Go to the above processor and return the search failure message.
- a returning module configured to: if the search module does not find an entry that stores the keyword in the TCAM, or does not find the entry in the index value of the issued record table Go to the above processor and return the search failure message.
- the data search device searches for the entry of the keyword in the TCAM, it also needs to look up the delivery record table, and determine whether the entry of the index value of the keyword includes the processing corresponding to the device. If the processor is included, the associated data corresponding to the keyword is read from the memory of the processor according to the index value of the TCAM according to the index of the keyword.
Landscapes
- Engineering & Computer Science (AREA)
- Databases & Information Systems (AREA)
- Theoretical Computer Science (AREA)
- Computational Linguistics (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本发明实施例提供一种数据存储方法、数据查找方法及装置。该数据存储方法包括:主CPU获取待存储到TCAM的关键字和与关键字对应的关联数据;若在TCAM中没有查找到存储有关键字的表项,检测到关键字的配置属性中包括不包括主CPU时,向配置属性中的第一备用CPU发送包括关键字和关联数据的第一指示信息,并向关键字的配置属性中第二备用CPU发送包括关联数据的第二指示信息。本发明实施例提供的技术方案避免了TCAM中一个关键字对应一个以上的表项的缺陷,达到了配置属性中每个CPU的存储器都存储有该关键字的关联数据的目的。
Description
数据存储方法、 查找方法及装置
技术领域 本发明实施例涉及计算机技术, 尤其涉及一种数据存储方法、 查找方法 及装置。
背景技术
三态内容可寻址存储器(Ternary Content Addressable Memory, 简称 TCAM )中每一个 bit的状态可以是 "0"或 "1",或者是第三种状态" don't care", 所以称为"三态"。这个特点使 TCAM具有对所查找数据的位域具有筛选功能, TCAM表内所有条目都可以并行访问, 例如, 如果 TCAM有 100条表项, 能一次对这 100条表项进行对比操作, 相对与普通的轮询查找方法, 提高了 查找的速度。 然而, TCAM 成本比较高, 存储空间的单位价格高于普通的 SRAM, 耗能也远远高于 SRAM。
在 TCAM中下发关键字的过程概述如下: 从报文头提取关键字 Key, 将 关键字写入 TCAM中, 获取关键字在 TCAM的索引值 Index, 索引值 Index 可以是关键字在 TCAM的存储地址; 之后, 将该关键字对应的处理信息也称 为关联数据, 写入 RAM中地址为 Index的空间中。 查找 TCAM的过程概述 如下: 从报文头提取关键字 Key, 将关键字送入 TCAM中, 在 TCAM中查找 与关键字 Key 匹配的表项, 获取匹配表项的索引值 Index , 也就是关键字在 TCAM的索引值 Index;之后,将索引值 Index送入 RAM中,根据索引值 Index 在 RAM中查找与关键字 Key对应的关联数据,关联数据为包含有关键字 Key 的报文的处理信息,例如,可以为地址映射表项、访问控制列表( Access Control List,, 简称 ACL )信息和路由信息等针对上述报文的处理信息。
在多个 CPU共享一个 TCAM的场景下,如果多个 CPU运行的业务相同, 这些 CPU下发的关键字相同, 相应地下发的关联数据也相同。 然而, 按照现 有的技术方案, 下发相同关键字的多个 CPU分时在 TCAM中关键字, 导致 该关键字在 TCAM中对应多个表项, 而且下发表项的过程耗时较长。
发明内容
本发明实施例提供一种数据存储方法、 查找方法及装置, 用以解决多个
CPU共享一个 TCAM时, 多个 CPU在 TCAM中重复下发同一个关键字的缺 陷, 节约了 TCAM的空间, 提高了在 TCAM中下发关键字的效率。
—方面, 本发明实施例提供一种数据存储方法, 包括:
主 CPU获取待存储到 TCAM的关键字和与所述关键字对应的关联数据; 所述主 CPU在 TCAM中查找存储有所述关键字的表项;
若没有查找到存储有所述关键字的表项,所述主 CPU检测到所述关键字 的配置属性中包括至少两个备用 CPU且不包括所述主 CPU时, 向所述配置 属性中的第一备用 CPU发送包括所述关键字和所述关联数据的第一指示信 息,并向所述关键字的配置属性中第二备用 CPU发送包括所述关联数据的第 二指示信息, 所述第一备用 CPU为所述配置属性中任意一个备用 CPU, 所述 第二备用 CPU为所述配置属性中除所述第一备用 CPU的每一个备用 CPU; 所述第一指示信息 ,用于指示所述第一备用 CPU将所述关键字存储到 TCAM, 根据所述关键字的表项在 TCAM的索引值将所述关联数据存储到所述第一备 用 CPU的存储器, 将所述第一备用 CPU的编号写入下发记录表中为所述索 引值建立的表项, 并将所述索引值发送给所述第二备用 CPU; 所述第二指示 信息, 用于指示所述第二备用 CPU根据所述第一备用 CPU发送的所述关键 字的表项在 TCAM中的索引值将所述关联数据存储到所述第二备用 CPU的 存储器,并将所述第二备用 CPU的编号写入所述下发记录表中为所述索引值 建立的表项; 所述下发记录表中为所述索引值建立的表项用于记录根据所述 索引值存储关联数据的所有 CPU的编号。
另一方面, 本发明实施例提供一种数据查找方法, 包括:
CPU接收包括关键字的查找指示,所述查找指示用于指示 CPU查找所述 关键字的对应的关联数据;
所述 CPU在 TCAM中查找存储有所述关键字的表项;
若查找到存储有所述关键字的表项,所述 CPU获取所述关键字的表项在 TCAM的索引值, 并在下发记录表的所述索引值的表项中查找所述 CPU; 所 述下发记录表中为所述索引值建立的表项用于记录根据所述索引值存储关联 数据的所有 CPU;
若查找到所述 CPU, 所述 CPU根据所述索引值从所述 CPU的存储器中 获取所述关键字对应的关联数据。
又一方面, 本发明实施例还提供一种数据存储装置, 包括:
获取模块, 用于获取待存储到 TCAM的关键字和与所述关键字对应的关 联数据
查找模块, 用于在 TCAM中查找存储有所述关键字的表项;
判断模块, 用于若所述查找模块没有查找到存储有所述关键字的表项 , 判断所述关键字的配置属性中是否包括至少两个备用 CPU且不包括所述装 置;
指示模块, 用于若所述查找模块没有查找到存储有所述关键字的表项且 所述判断模块检测到所述关键字的配置属性中包括至少两个备用 CPU且不包 括所述装置时, 向所述配置属性中的第一备用 CPU发送包括所述关键字和所 述关联数据的第一指示信息,并向所述关键字的配置属性中第二备用 CPU发 送包括所述关联数据的第二指示信息,所述第一备用 CPU为所述配置属性中 任意一个备用 CPU, 所述第二备用 CPU为所述配置属性中除所述第一备用 CPU的每一个备用 CPU; 所述第一指示信息, 用于指示所述第一备用 CPU 将所述关键字存储到 TCAM,根据所述关键字的表项在 TCAM的索引值将所 述关联数据存储到所述第一备用 CPU的存储器, 将所述第一备用 CPU的编 号写入下发记录表中为所述索引值建立的表项, 并将所述索引值发送给所述 第二备用 CPU; 所述第二指示信息,用于指示所述第二备用 CPU根据所述在 TCAM中的索引值将所述关联数据存储到所述第二备用 CPU的存储器,并将 所述第二备用 CPU的编号写入所述下发记录表中为所述索引值建立的表项; 所述下发记录表中为所述索引值建立的表项用于记录根据所述索引值存储关 联数据的所有 CPU的编号。
再一方面, 本发明实施例还提供一种数据查找装置, 包括:
接收模块, 用于接收包括关键字的查找指示, 所述查找指示用于指示查 找所述关键字的对应的关联数据;
查找模块, 用于在 TCAM中查找存储有所述关键字的表项;
所述查找模块, 还用于若查找到存储有所述关键字的表项, 获取所述关 键字的表项在 TCAM的索引值, 并在下发记录表的所述索引值的表项中查找
所述装置所属的处理器; 所述下发记录表中为所述索引值建立的表项用于记 录根据所述索引值存储关联数据的所有处理器;
获取模块, 用于若所述查找模块查找到所述处理器, 根据所述索引值从 所述处理器的存储器中获取所述关键字对应的关联数据。
在本发明实施例提供的上述技术方案中, 在待存储的关键字的配置属性 中包括多个 CPU的情况下,如果配置属性中不包括主 CPU, 由配置属性中一 个备用 CPU在 TCAM中存储上述关键字。 存储上述关键字的 CPU还根据上 述关键字的表项在 TCAM的索引值在自身的存储器中存储与上述关键字对应 的关联数据, 更新上述索引值在下发记录表的表项, 并向上述配置属性中其 它备用 CPU发送上述关键字的表项在 TCAM的索引值。 其它备用 CPU根据 索弓 I值在自身的存储器中存储与上述关键字的关联数据,并更新下发记录表。 因此, 本发明实施例提供的技术方案避免了 TCAM中一个关键字对应一个以 上的表项的缺陷,达到了配置属性中每个 CPU的存储器都存储有该关键字的 关联数据的目的。 附图说明
图 1A为本发明实施例提供的一种数据存储方法流程图;
图 1B为本发明实施例提供的另一种数据存储方法流程图;
图 2为本发明实施例提供的又一种数据存储方法流程图;
图 3A为本发明实施例提供的一种数据查找方法流程图;
图 3B为本发明实施例提供的一种应用场景示意图
图 4A为本发明实施例提供的一种数据存储装置结构示意图;
图 4B为本发明实施例提供的另一种数据存储装置结构示意图; 图 5本发明实施例提供的一种数据查找装置结构示意图。 具体实施方式
图 1A为本发明实施例提供的一种数据存储方法流程图。 如图 1A所示, 本实施例提供的数据存储方法包括:
步骤 11 : 主 CPU获取待存储到 TCAM的关键字和与上述关键字对应的 关联数据。
本发明实施例适用于多个 CPU共存的场景, 本发明实施例中的 CPU可 为单核 CPU也可为多核 CPU。多个 CPU共存的情况下,当前正在运行的 CPU 为主 CPU, 其它没有运行的 CPU为备用 CPU。 本发明实施例中, 所有 CPU 共享一个 TCAM, 每个 CPU有自己的存储器。
上层应用向主 PCU下发的关键字中包括配置属性,该关键字的配置属性 中包括上层应用指示的存储该关键字的 CPU,上层应用指示的 CPU有可能是 一个也可能是多个 CPU,其中有可能包括主 CPU,也有可能不包括备用 CPU。
步骤 12: 主 CPU在 TCAM的所有表项中查找上述关键字。
主 CPU获取到待存储到 TCAM的关键字后, 先查找 TCAM的所有表项 中是否已包括存储该关键字的表项。
步骤 13: 若没有查找到存储有上述关键字的表项, 主 CPU检测到上述 关键字的配置属性中包括至少两个备用 CPU且不包括上述主 CPU时, 向上 述配置属性中的第一备用 CPU发送包括上述关键字和上述关联数据的第一指 示信息,并向上述关键字的配置属性中第二备用 CPU发送包括上述关联数据 的第二指示信息。
主 CPU在 TCAM的所有表项中没有查找到存储上层应用下发的关键字 的表项后, 判断该关键字的配置属性中是否包括至少两个 CPU。 如果包括至 少两个 CPU, 再判断配置属性中 CPU中是否包括主 CPU。 配置属性中包括 至少两个 CPU,表明上层应用指示多个 CPU存储同一个关键字。本实施例主 要涉及多个 CPU存储同一个关键字的场景。
第一备用 CPU是配置属性中任意一个备用 CPU,可选地,可以是配置属 性中编号最小的备用 CPU。 第二备用 CPU可为配置属性中除第一备用 CPU 之外的每一个备用 CPU。 如果关键字的配置属性中 CPU至少包括两个 CPU, 但不包括主 CPU时, 即关键字的配置属性中所有 CPU均为备用 CPU时, 主 CPU向第一备用 CPU发送包括上述关键字和上述关联数据的第一指示信息, 并向所第二备用 CPU发送包括上述关联数据的第二指示信息。如果配置属性 中除第一备用 CPU之外的 CPU有一个以上, 则主 CPU需要发送多个第二指 示信息, 向除第一备用 CPU之外的每一个 CPU发送第二指示信息。
第一指示信息, 用于指示上述第一备用 CPU 将上述关键字存储到 TCAM, 根据上述关键字在 TCAM的索引值将上述关联数据存储到上述第一
备用 CPU的存储器, 将上述第一备用 CPU的编号写入下发记录表中为上述 索引值建立的表项, 并将上述索引值发送给上述第二备用 CPU。 其中, 上述 关键字在 TCAM的索引值, 可以是上述关键字在 TCAM的存储地址。 第二 指示信息, 用于指示上述第二备用 CPU根据上述第一备用 CPU发送的索引 值将上述关联数据存储到上述第二备用 CPU 的存储器, 并将上述第二备用 CPU的编号写入上述下发记录表中为上述索引值建立的表项。
第一备用 CPU切换为主 CPU后, 根据第一指示信息将上述关键字存储 到 TCAM。 上述关键字被存储到 TCAM的一个空表项后, 上述关键字的表项 在 TCAM的存储地地址为上述关键字的表项在 TCAM的索引值。 第一备用 CPU根据上述关键字的表项在 TCAM的索引值将关键字对应的关联数据存储 到上述第一备用 CPU的存储器, 将上述第一备用 CPU的编号写入下发记录 表中为上述索引值建立的表项, 并将上述索引值发送给上述配置属性中上述 第二备用 CPU。 第二备用 CPU切换为主 CPU后, 根据上述第一备用 CPU发 送的索引值将上述关联数据存储到上述第二备用 CPU的存储器,并将第二备 用 CPU的编号写入上述下发记录表中上述索引值的表项。
第一备用 CPU将上述关键字存储到 TCAM, 根据上述关键字的表项在 TCAM的索引值将上述关联数据存储到上述第一备用 CPU的存储器后,在下 发记录表中为上述索引值建立表项。 上述下发记录表中为上述索引值建立的 表项用于记录根据上述索引值存储关联数据的所有 CPU。 具体地, 下发记录 表中一个表项用于记录一个索引值与根据该索引值存储关联数据的所有 CPU。 在下发记录表的一个索引值所在的表项中写入一个 CPU, 表明该 CPU 已根据该索引值在自身的存储器中写入了关联数据。 通过下发记录表可以确 定一个索引值已被哪些 CPU使用。
通过上述方法, 配置属性中多个 CPU均为备用 CPU时, 主 CPU选择配 置属性中编号最小的备用 CPU在 TCAM存储该关键字, 而其它备用 CPU不 需要在 TCAM中存储该关键字, 使得一个关键字在 TCAM中包括一个表项, 从而避免了多个 CPU在 TCAM中下发相同的关键字的现象。 主 CPU选择的 备用 CPU在 TCAM存储该关键字后, 在自身的存储器中存储该关键字的关 联数据、 更新下发记录表, 并向配置属性中其它备用 CPU发送该关键字的索 引值。 配置属性中其它备用 CPU根据上述备用 CPU发送的索引值, 在自身
的存储器中存储该关键字的关联数据并更新下发记录表。 因此, 上述技术方 案避免了,在多个 CPU下发同一关键字时, TCAM中一个关键字对应一个以 上的表项的缺陷,达到了关键字的配置属性中每个 CPU的存储器都存储有该 关键字的关联数据的目的。
如图 1B所示, 在步骤 12之后, 还可包括步骤 14。
步骤 14: 若没有查找到存储有上述关键字的表项,上述主 CPU检测到上 述关键字的配置属性中包括上述主 CPU和至少一个备用 CPU时, 将上述关 键字存储到 TCAM,根据上述关键字的表项在 TCAM的索引值将上述关联数 据存储到自身的存储器,将上述主 CPU的编号写入下发记录表中为上述索引 值建立的表项之后,向上述关键字的配置属性中上述所有备用 CPU发送包括 上述关联数据和上述索引值的第三指示信息。
TCAM中没有待存储的关键字对应表项的情况下, 如果该关键字的配置 属性中至少包括两个 CPU且包括主 CPU时, 由主 CPU在 TCAM中存储该 关键字, 配置属性中所有备用 CPU不需要在 TCAM存储该关键字。 主 CPU 在 TCAM中存储该关键字后, 根据上述关键字的表项在 TCAM的索引值在 自身的存储器中存储上述关联数据, 并在下发记录表为上述关键字的索引值 建立表项。主 CPU还向配置属性中所有备用 CPU发送包括该关键字在 TCAM 的索引值和该关键字的关联数据的第三指示信息。 上述配置属性中所有备用 CPU根据第三指示信息的指示,根据上述主 CPU发送的索引值将上述关联数 据存储到自己的存储器, 并将自己的编号写入上述下发记录表中为上述索引 值建立的表项。 关键字的配置属性中各备用 CPU切换为主 CPU后, 根据上 述主 CPU发送的索引值将上述关联数据存储到上述备用 CPU的存储器, 并 将自己的编号写入上述下发记录表中为上述索引值建立的表项。
通过本实施例提供的技术方案,在关键字的配置属性中包括多个 CPU的 情况下, 如果配置属性中包括主 CPU, 由主 CPU在 TCAM中存储关键字, 如果配置属性中不包括主 CPU, 由配置属性中一个备用 CPU在 TCAM中存 储上述关键字。 存储上述关键字的 CPU还根据上述关键字的表项在 TCAM 的索引值在自身的存储器中存储与上述关键字对应的关联数据, 更新上述索 引值在下发记录表的表项,并向上述配置属性中其它备用 CPU发送上述关键 字的表项在 TCAM的索引值。但其它备用 CPU不需要在 TCAM存储关键字,
而是根据索引值在自身的存储器中存储与上述关键字的关联数据, 并更新下 发记录表。 因此, 本实施例提供的技术方案避免了 TCAM中一个关键字对应 一个以上的表项的缺陷,达到了配置属性中每个 CPU的存储器都存储有该关 键字的关联数据的目的。
进一步, 主 CPU在 TCAM中没有查找到存储上层应用下发的关键字的 表项时, 如果配置属性中包括一个 CPU, 主 CPU判断该 CPU是备用 CPU还 是主 CPU。 主 CPU检测到上述关键字的配置属性中包括一个 CPU且为备用 CPU时,向上述配置属性中备用 CPU发送包括上述关键字和上述关联数据的 第四指示信息。 上述配置属性中备用 CPU根据第四指示信息的指示, 将上述 关键字存储到 TCAM,根据上述关键字的表项在 TCAM的索引值将上述关联 数据存储到自身的存储器,并将上述配置属性中备用 CPU的编号写入上述下 发记录表中上述索引值的表项。主 CPU检测到上述关键字的配置属性中 CPU 为上述主 CPU时, 将上述关键字存储到 TCAM, 根据上述关键字在 TCAM 的索引值将上述关联数据存储到自身的存储器,并将上述主 CPU写入上述下 发记录表中上述索引值的表项。
进一步, 若主 CPU在 TCAM中查找到存储有上述关键字的表项, 为避 免在 TCAM存储重复的表项,上述关键字的配置属性中 CPU不需要在 TCAM 中再次存储该关键字, 而是根据上述关键字的表项在 TCAM的索引值, 将与 上述关联数据存储到自身的存储器。 具体方案是, 上述主 CPU获取上述关键 字的表项在 TCAM的索引值后, 向上述配置属性中的各备用 CPU发送包括 上述索引值的第五指示信息, 配置属性中的各备用 CPU根据第五指示信息的 指示, 根据上述索引值将上述关联数据存储到自身的存储器中, 之后将自己 的编号写入上述下发记录表中为上述索引值建立的表项。 如果配置属性中还 包括主 CPU, 主 CPU获取上述关键字的表项在 TCAM的索引值后, 还根据 获取到的索引值, 将上述关联数据存储到自身的存储器中, 并将上述主 CPU 的编号写入上述下发记录表中上述索引值的表项。
图 2为本发明实施例提供的又一种数据存储方法流程图。 图 2为主 CPU 接收到待存储的关键字和关联数据后的具体处理过程。 如图 2所示, 本实施 例提供的方法包括:
步骤 21: 主 CPU获取待存储的关键字和该关键字对应的关联数据。
步骤 22: 主 CPU查找 TCAM的所有表项中是否包括存储有上述关键字 的表项。 若是执行步骤 23 , 否则执行步骤 210。
步骤 23: 若包括存储有上述关键字的表项,主 CPU判断上述关键字的配 置属性中是否包括多个 CPU。 若是执行步骤 24, 否则执行步骤 27。
步骤 24: 若上述关键字的配置属性中包括多个 CPU, 判断多个 CPU是 否包括主 CPU, 若多个 CPU中包括主 CPU,执行步骤 25, 否则执行步骤 26。
步骤 25: 主 CPU将上述关键字存储到 TCAM, 根据上述关键字的表项 在 TCAM的索引值将上述关联数据存储到自身的存储器, 将上述主 CPU的 编号写入下发记录表中上述索引值的表项之后, 向上述关键字的配置属性中 各备用 CPU发送包括上述关联数据和上述索引值的第三指示信息。
主 CPU将上述关键字存储到 TCAM的一个空表项后, 上述关键字的表 项在 TCAM的存储地地址为上述关键字的表项在 TCAM的索引值。 通过上 述关键字的表项在 TCAM的索引值, 可确定上述关键字对应的关联数据在存 储器中的索引值。 配置属性中各备用 CPU根据上述主 CPU发送的索引值, 将上述关联数据存储到上述备用 CPU的存储器,并将各自的编号写入上述下 发记录表中为上述索引值建立的表项, 例如, 将上述备用 CPU的编号写入上 述下发记录表中为上述索引值建立的表项。 下发记录表的上述索引值的表项 中用于记录根据上述索引值存储关联数据的所有处理器。
表 1为本发明实施例提供的一种下发记录表。 TCAM中每个关键字的索 引值在下发记录表对应一个表项。 如表 1所示, 在一个索引值所在的表项中, 一个 CPU对应的标志位为 1 ,表示该 CPU根据该索引值在自身的存储器存储 过关联数据,一个 CPU对应的标志位为 0,表示该 CPU没有根据该索引值在 自身的存储器存储过关联数据。 例如, 索引值 0所在的表项中, CPU-A的标 志位为 1 , 其它 CPU的标志位均为 0, 表明 CPU-A已根据索引值 0在自身的 存储器中存储了关联数据。又例如,索引值 2所在的表项中, CPU-A和 CPU-B 的标志位均为 1 , 其它 CPU的标志位均为 0, 表明 CPU-A和 CPU-B已根据 索引值 0在自身的存储器中存储了关联数据。
3 1 1 0 CPU-A\B共用
4 0 1 1 CPU-B\N共用
步骤 26: 若上述配置属性中不包括主 CPU, 主 CPU向上述配置属性中 的第一备用 CPU发送包括上述关键字和上述关联数据的第一指示信息,并向 上述关键字的配置属性中第二备用 CPU发送包括上述关联数据的第二指示信 自
上述第一备用 CPU根据主 CPU的第一指示信息的指示, 将上述关键字 存储到 TCAM,根据上述关键字的表项在 TCAM的索引值将上述关联数据存 储到上述第一备用 CPU的存储器, 将上述第一备用 CPU的编号写入下发记 录表中为上述索引值建立的表项,并将上述索弓 I值发送给上述第二备用 CPU。 第二备用 CPU根据主 CPU的第二指示信息的指示, 采用上述第一备用 CPU 发送的索引值将上述关联数据存储到上述第二备用 CPU的存储器,并将上述 第二备用 CPU的编号写入上述下发记录表中为上述索引值建立的表项。如表 1所示, 将上述第二备用 CPU的编号写入上述下发记录表中为上述索引值建 立的表项的具体方法可以是,在索引值所在的表项中将第二备用 CPU的标志 位写入 1。
步骤 27: 若上述关键字的配置属性中包括一个 CPU, 主 CPU判断配置 属 性 中 CPU 是 否 为 备 用 CPU 。 若 是 执 行 步 骤 2 8, 否则执行步骤 29。
步骤 28: 若配置属性中 CPU为备用 CPU, 主 CPU向上述配置属性中备 用 CPU发送包括上述关键字和上述关联数据的第四指示信息。
上述配置属性中各备用 CPU根据第四指示信息的指示,将上述关键字存 储到 TCAM,根据上述关键字的表项在 TCAM的索引值将上述关联数据存储 到自身的存储器, 在下发记录表中为上述索引值建立表项, 并将自己的编号 写入上述下发记录表中为上述索引值建立的表项。
步骤 29: 若配置属性中 CPU为主 CPU, 主 CPU将上述关键字存储到
TCAM, 根据上述关键字的表项在 TCAM的索引值将上述关联数据存储到自 身的存储器,并将主 CPU的编号写入上述下发记录表中为上述索引值建立的 表项。
步骤 210: 若在 TCAM中包括存储有上述关键字的表项, 主 CPU获取上 述关键字的表项在 TCAM的索引值。
步骤 211 : 若上述配置属性中包括至少一个备用 CPU时,上述主 CPU向 上述配置属性中的各备用 CPU发送包括上述索引值的第五指示信息。
上述配置属性中的各备用 CPU根据第五指示信息的指示,根据上述索引 值将上述关联数据存储到自身的存储器中, 并将各自的编号写入上述下发记 录表中为上述索弓 I值建立的表项。
步骤 212: 若上述配置属性中还包括主 CPU, 主 CPU根据上述索引值将 上述关联数据存储到自身的存储器中后,将主 CPU的编号写入上述下发记录 表中为上述索引值建立的表项。
本实施例提供的技术方案中, 在多个 CPU在共享的 TCAM中存储同一 个关键字且 TCAM没有查找到上述关键字时, 主 CPU远择一个 CPU在共享 的 TCAM 中存储关键字, 而所有 CPU 均更新下发记录表并根据关键字在 TCAM的索引值存储关键字的关联数据。 若 TCAM中查找到关键字, 不需要 选择 CPU在 TCAM中存储关键字, 所有 CPU更新下发记录表并根据关键字 在 TCAM的索引值存储关键字的关联数据。
图 3A为本发明实施例提供的一种数据查找方法流程图。 基于上述数据 存储方法在 TCAM存储关键字在存储器中存储关键字的关联数据后, 查找关 联数据的方法。 如图 3A所示, 本实施例包括:
步骤 31: CPU接收包括关键字的查找指示。
上层应用下发包括关键字的查找指示,指示主 CPU查找关键字对应的关 联数据。
步骤 32: CPU在 TCAM中查找存储有上述关键字的表项。
步骤 33: 若查找到存储有上述关键字的表项, CPU获取上述关键字的 表项在 TCAM 的索引值, 并在下发记录表的上述索引值的表项中查找上述 CPU; 上述下发记录表中为上述索引值建立的表项用于记录根据上述索引值 存储关联数据的所有 CPU。
CPU向 TCAM输入关键字后, 如果 TCAM中存在存储关键字的表项, TCAM向 CPU返回上述关键字的表项在 TCAM中的索引值。
步骤 34:若在下发记录表的上述索引值的表项中查找到上述 CPU, CPU
根据上述索引值在上述 CPU的存储器中查找上述关键字对应的关联数据。 如果 CPU在 TCAM中查找到关键字, 且在下发记录表的上述关键字在 TCAM的索引值的表项中查找到主 CPU, 则确定 CPU的存储器中存储有上 述关键字对应的关联数据。
如果 CPU在 TCAM中没有查找到上述关键字, 或者, 虽然在 TCAM中
CPU, 则确定 CPU没有在自己的存储器中存储上述关键字对应的关联数据, 上述 CPU向上层应用返回查找失败信息。
本实施例提供的技术方案中, 处理器在 TCAM中查找存储有关键字的表 项后, 还需要查找下发记录表, 以判断该关键字的索引值所在表项是否包括 上述处理器。 如果包括上述处理器, 上述处理器根据上述关键字的表项在
TCAM 的索引值从上述处理器的存储器中读取与上述关键字对应的关联数 据。
图 3B为本发明实施例提供的一种应用场景示意图。 如图 3B所示, 处理 器可以是网络处理器(Network Processor, 简称 NP ) , ΝΡ从报文中提取出待 查找的关键字,将待查找的关键字 Key送入 TCAM中。 TCAM查找到该关键 字后, 将该关键字在 TCAM的索引值 INDEX返回给 NP, NP再根据 TCAM 返回的索引值 INDEX确定关键字 KEY对应的关联数据在存储器中的存储地 址 ADDR(address), 之后根据存储地址从存储器中读取关联数据, 以对报文 进行处理。
图 4A为本发明实施例提供的一种数据存储装置结构示意图。如图 4A所 示, 本实施例提供的数据存储装置包括: 获取模块 41、 查找模块 42、 判断模 块 43和指示模块 44。
获取模块 41 ,用于获取待存储到 TCAM的关键字和与关键字对应的关联 数据。 果
查找模块 42, 用于在 TCAM中查找存储有上述关键字的表项。
判断模块 43 , 用于若查找模块 42没有查找到存储有上述关键字的表项, 判断上述关键字的配置属性中是否包括至少两个备用 CPU且不包括所述数据 存储装置。
指示模块 44, 用于若查找模块 42没有查找到存储有上述关键字的表项
且判断模块 43检测到上述配置属性中包括至少两个备用 CPU且不包括所述 数据存储装置时, 向上述配置属性中的第一备用 CPU发送包括上述关键字和 上述关联数据的第一指示信息,并向关上述配置属性中的第二备用 CPU发送 包括关联数据的第二指示信息,所述第一备用 CPU为所述配置属性中任意一 个备用 CPU, 所述第二备用 CPU为所述配置属性中除所述第一备用 CPU的 每一个备用 CPU; 第一指示信息, 用于指示第一备用 CPU将关键字存储到 TCAM, 根据上述关键字的表项在 TCAM的索引值将上述关联数据存储到第 一备用 CPU的存储器, 将第一备用 CPU的编号写入下发记录表中为索引值 建立的表项, 并将上述索引值发送给第二备用 CPU; 第二指示信息, 用于指 示第二备用 CPU根据第一备用 CPU发送的索引值将上述关联数据存储到第 二备用 CPU的存储器, 并将第二备用 CPU的编号写入下发记录表中为索引 值建立的表项。
其中, 第一备用 CPU为配置属性中编号最小的备用 CPU。
以上各模块的具体功能可参见图 1B对应实施例中描述。
如图 4B所示, 在图 4A的基础上还可包括存储模块 45。
判断模块 43 , 还用于若查找模块 42没有查找到存储有上述关键字的表 项, 判断上述关键字的配置属性中是否包括所述数据存储装置和至少一个备 用 CPU。
存储模块 45, 用于若查找模块 42没有查找到存储有上述关键字的表项 且判断模块检测到上述配置属性中包括所述数据存储装置和至少一个备用 CPU时, 将上述关键字存储到 TCAM, 根据上述关键字的表项在 TCAM的 索引值将关联数据存储到自身的存储器, 将所述数据存储装置的编号写入下 发记录表中为上述索弓 I值建立的表项。
指示模块 44, 还用于存储模块 45将所述数据存储装置的编号写入下发 记录表中为上述索引值建立的表项之后, 向上述关键字的配置属性中备用 CPU发送包括关联数据和索引值的第三指示信息, 用于指示上述配置属性中 所有备用处理器根据上述装置发送的索引值将上述关联数据存储到上述备用 处理器的存储器, 并将自己的编号写入上述下发记录表中为上述索引值建立 的表项。
以上各模块的具体功能可参见图 1B对应实施例中描述。
上述实施例提供的技术方案主要涉及在 TCAM中没有查找到上述关键字 的表项且上述关键字的配置属性中包括多个 CPU时,所述数据存储装置中各 模块具有的功能。
通过上述实施例提供的技术方案, 在关键字的配置属性中包括多个 CPU 的情况下, 如果配置属性中包括所述数据存储装置, 由所述数据存储装置在 TCAM中存储关键字, 如果配置属性中不包括所述数据存储装置, 由配置属 性中一个备用 CPU在 TCAM中存储上述关键字。 存储上述关键字的 CPU还 根据上述关键字的表项在 TCAM的索引值在自身的存储器中存储与上述关键 字对应的关联数据, 更新上述索引值在下发记录表的表项, 并向上述配置属 性中其它备用 CPU发送上述关键字的表项在 TCAM的索引值。其它备用 CPU 根据索弓 I值在自身的存储器中存储与上述关键字的关联数据, 并更新下发记 录表。 因此, 本实施例提供的技术方案避免了 TCAM中一个关键字对应一个 以上的表项的缺陷,达到了配置属性中每个 CPU的存储器都存储有该关键字 的关联数据的目的。
以下描述在 TCAM中没有查找到存储有上述关键字的表项且上述关键字 的 属性中包括一个 CPU时, 所述数据存储装置的各模块具有的功能, 可 参见图 2对应实施例:
判断模块 43 , 还用于若查找模块 42没有查找到关键字, 判断关键字的 配置属性中 CPU是否包括一个 CPU且为备用处理器。
指示模块 44, 还用于若查找模块 42没有查找到存储有上述关键字的表 项且判断模块 43检测到上述配置属性中包括一个 CPU且为备用 CPU时, 向 上述配置属性中备用 CPU发送包括上述关键字和上述关联数据的第四指示信 息; 第四指示信息, 用于指示上述配置属性中备用 CPU将上述关键字存储到 TCAM, 根据关键字的表项在 TCAM的索引值将关联数据存储到自身的存储 器, 并将自己的编号写入下发记录表中为索引值建立的表项。
判断模块 43 , 还用于若查找模块没有查找到关键字时, 判断关键字的配 置属性中 CPU是否包括一个 CPU且为所述数据存储装置。
存储模块 45, 还用于若查找模块没有查找到存储有上述关键字的表项且 判断模块检测到上述关键字的配置属性中包括一个 CPU且为所述数据存储装 置时, 将上述关键字存储到 TCAM, 根据上述关键字的表项在 TCAM的索引
值将上述关联数据存储到自身的存储器, 并将所述数据存储装置的编号写入 下发记录表中为索引值建立的表项。
以下实施例描述在 TCAM中查找到存储有上述关键字的表项且上述关键 字的配置属性中包括一个 CPU时, 所述数据存储装置的各模块具有的功能, 可参见图 2对应实施例:
查找模块 42, 还用于若查找到存储有上述关键字的表项, 获取上述关键 字的表项在 TCAM的索引值。
指示模块 44, 还用于若判断模块检测到上述配置属性中包括至少一个备 用 CPU时, 向上述配置属性中的所有备用 CPU发送包括查找模块获取到的 索引值的第五指示信息,用于指示配置属性中的所有备用 CPU根据索引值将 上述关联数据存储到自身的存储器中, 并将自己的编号写入下发记录表中为 索引值建立的表项。
存储模块 45 , 还用于若判断模块检测到上述配置属性中还包括所述数据 存储装置时, 根据上述索引值将上述关联数据存储到上述主处理器的存储器 中, 并将所述数据存储装置的编号写入下发记录表中为索引值建立的表项。
图 5本发明实施例提供的一种数据查找装置结构示意图。 本实施例提供 的数据查找装置主要用于查找与关键字对应的关联数据。 如图 5所示, 本实 施例提供的处理器包括: 接收模块 51、 查找模块 52和获取模块 53。
接收模块 51 , 用于接收包括关键字的查找指示, 查找指示用于指示查找 与上述关键字的对应的关联数据。
查找模块 52, 用于在 TCAM中查找存储有关键字的表项。
查找模块 52, 还用于若查找到存储有上述关键字的表项, 获取上述关键 字的表项在 TCAM的索引值, 并在下发记录表的索引值的表项中查找上述装 置所属的处理器, 上述下发记录表中为上述索引值建立的表项用于记录根据 上述索引值存储关联数据的所有处理器。
获取模块 53 , 用于若查找模块查找到上述处理器, 根据上述索引值从上 述处理器的存储器中获取与上述关键字对应的关联数据。
进一步, 本实施例提供的处理器还包括: 返回模块, 用于若查找模块在 TCAM中没有查找到存储有上述关键字的表项, 或, 在下发记录表的索引值 的表项中没有查找到上述处理器, 返回查找失败信息。
以上各模块的具体功能可参见图 3A对应实施例中描述。
本实施例提供的技术方案中,数据查找装置在 TCAM中查找存储有关键 字的表项后, 还需要查找下发记录表, 判断该关键字的索引值所在表项是否 包括上述装置对应的处理器, 如果包括上述处理器, 根据上述关键字的表项 在 TCAM的索引值从上述处理器的存储器中读取与上述关键字对应的关联数 据。
本领域普通技术人员可以理解: 实现上述方法实施例的全部或部分步骤 可以通过程序指令相关的硬件来完成, 前述的程序可以存储于一计算机可读 取存储介质中, 该程序在执行时, 执行包括上述方法实施例的步骤; 而前述 的存储介质包括: ROM、 RAM, 磁碟或者光盘等各种可以存储程序代码的介 质。
最后应说明的是: 以上实施例仅用以说明本发明的技术方案, 而非对其 限制; 尽管参照前述实施例对本发明进行了详细的说明, 本领域的普通技术 人员应当理解: 其依然可以对前述各实施例所记载的技术方案进行修改, 或 者对其中部分技术特征进行等同替换; 而这些修改或者替换, 并不使相应技 术方案的本质脱离本发明各实施例技术方案的范围。
Claims
1、 一种数据存储方法, 其特征在于, 包括:
主 CPU获取待存储到 TCAM的关键字和与所述关键字对应的关联数据; 所述主 CPU在 TCAM中查找存储有所述关键字的表项;
若没有查找到存储有所述关键字的表项,所述主 CPU检测到所述关键字 的配置属性中包括至少两个备用 CPU且不包括所述主 CPU时, 向所述配置 属性中的第一备用 CPU发送包括所述关键字和所述关联数据的第一指示信 息,并向所述关键字的配置属性中第二备用 CPU发送包括所述关联数据的第 二指示信息, 所述第一备用 CPU为所述配置属性中任意一个备用 CPU, 所述 第二备用 CPU为所述配置属性中除所述第一备用 CPU的每一个备用 CPU; 所述第一指示信息 ,用于指示所述第一备用 CPU将所述关键字存储到 TCAM, 根据所述关键字的表项在 TCAM的索引值将所述关联数据存储到所述第一备 用 CPU的存储器, 将所述第一备用 CPU的编号写入下发记录表中为所述索 引值建立的表项, 并将所述索引值发送给所述第二备用 CPU; 所述第二指示 信息, 用于指示所述第二备用 CPU根据所述第一备用 CPU发送的所述关键 字的表项在 TCAM中的索引值将所述关联数据存储到所述第二备用 CPU的 存储器,并将所述第二备用 CPU的编号写入所述下发记录表中为所述索引值 建立的表项; 所述下发记录表中为所述索引值建立的表项用于记录根据所述 索引值存储关联数据的所有 CPU的编号。
2、 根据权利要求 1所述的方法, 其特征在于, 还包括:
若没有查找到存储有所述关键字的表项,所述主 CPU检测到所述关键字 的配置属性中包括所述主 CPU和至少一个备用 CPU时, 将所述关键字存储 到 TCAM,根据所述关键字的表项在 TCAM的索引值将所述关联数据存储到 自身的存储器,将所述主 CPU的编号写入下发记录表中为所述索引值建立的 表项之后, 向所述关键字的配置属性中所有备用 CPU发送包括所述关联数据 和所述索引值的第三指示信息,用于指示所述配置属性中的所有备用 CPU根 据所述主 CPU发送的索引值将所述关联数据存储到所述备用 CPU的存储器, 并将自己的编号写入所述下发记录表中为所述索引值建立的表项。
3、 根据权利要求 1或 2所述的方法, 其特征在于, 所述第一备用 CPU 为所述配置属性中编号最小的备用 CPU。
4、 根据权利要求 1、 2或 3所述的方法, 其特征在于, 还包括: 若没有查找到存储有所述关键字的表项,所述主 CPU检测到所述关键字 的配置属性中包括一个 CPU且为备用 CPU时, 向所述配置属性中备用 CPU 发送包括所述关键字和所述关联数据的第四指示信息; 所述第四指示信息, 用于指示所述配置属性中备用 CPU将所述关键字存储到 TCAM,根据所述关 键字的表项在 TCAM的索引值将所述关联数据存储到自身的存储器, 并将自 己的编号写入所述下发记录表中为所述索引值建立的表项;
若没有查找到存储有所述关键字的表项,所述主 CPU检测到所述关键字 的配置属性包括一个 CPU且为所述主 CPU时,将所述关键字存储到 TCAM, 根据所述关键字的表项在 TCAM的索引值将所述关联数据存储到自身的存储 器,并将所述主 CPU的编号写入所述下发记录表中为所述索引值建立的表项。
5、 根据权利要求 1、 2、 3或 4所述的方法, 其特征在于, 还包括: 若查找到存储有所述关键字的表项,所述主 CPU获取所述关键字的表项 在 TCAM的索引值;
若所述配置属性中包括至少一个备用 CPU时, 所述主 CPU向所述配置 属性中的所有备用 CPU发送包括所述索引值的第五指示信息,用于指示所述 配置属性中的备用 CPU根据所述索引值将所述关联数据存储到自身的存储器 中,并将所述配置属性中的所有备用 CPU的编号写入所述下发记录表中为所 述索引值建立的表项;
若所述配置属性中还包括所述主 CPU,所述主 CPU根据所述索引值将所 述关联数据存储到自身的存储器中,并将所述主 CPU的编号写入所述下发记 录表中为所述索弓 I值建立的表项。
6、 一种数据查找方法, 其特征在于, 包括:
CPU接收包括关键字的查找指示,所述查找指示用于指示 CPU查找所述 关键字的对应的关联数据;
所述 CPU在 TCAM中查找存储有所述关键字的表项;
若查找到存储有所述关键字的表项,所述 CPU获取所述关键字的表项在 TCAM的索引值, 并在下发记录表的所述索引值的表项中查找所述 CPU; 所 述下发记录表中为所述索引值建立的表项用于记录根据所述索引值存储关联 数据的所有 CPU;
若查找到所述 CPU, 所述 CPU根据所述索引值从所述 CPU的存储器中 获取所述关键字对应的关联数据。
7、 根据权利要求 6所述的方法, 其特征在于, 还包括:
若在 TCAM中没有查找到存储有所述关键字的表项, 或, 在所述下发记 录表的所述索引值的表项中没有查找到所述主 CPU,所述 CPU返回查找失败 信息。
8、 一种数据存储装置, 其特征在于, 包括:
获取模块, 用于获取待存储到 TCAM的关键字和与所述关键字对应的关 联数据;
查找模块, 用于在 TCAM中查找存储有所述关键字的表项;
判断模块, 用于若所述查找模块没有查找到存储有所述关键字的表项 , 判断所述关键字的配置属性中是否包括至少两个备用 CPU且不包括所述装 置;
指示模块, 用于若所述查找模块没有查找到存储有所述关键字的表项且 所述判断模块检测到所述关键字的配置属性中包括至少两个备用 CPU且不包 括所述装置时, 向所述配置属性中的第一备用 CPU发送包括所述关键字和所 述关联数据的第一指示信息,并向所述关键字的配置属性中第二备用 CPU发 送包括所述关联数据的第二指示信息,所述第一备用 CPU为所述配置属性中 任意一个备用 CPU, 所述第二备用 CPU为所述配置属性中除所述第一备用 CPU的每一个备用 CPU; 所述第一指示信息, 用于指示所述第一备用 CPU 将所述关键字存储到 TCAM,根据所述关键字的表项在 TCAM的索引值将所 述关联数据存储到所述第一备用 CPU的存储器, 将所述第一备用 CPU的编 号写入下发记录表中为所述索引值建立的表项, 并将所述索引值发送给所述 第二备用 CPU; 所述第二指示信息,用于指示所述第二备用 CPU根据所述在 TCAM中的索引值将所述关联数据存储到所述第二备用 CPU的存储器,并将 所述第二备用 CPU的编号写入所述下发记录表中为所述索引值建立的表项; 所述下发记录表中为所述索引值建立的表项用于记录根据所述索引值存储关 联数据的所有 CPU的编号。
9、 根据权利要求 8所述的装置, 其特征在于, 还包括: 存储模块; 所述判断模块, 还用于若所述查找模块没有查找到存储有所述关键字的
表项,判断所述关键字的配置属性中是否包括所述装置且至少一个备用 CPU; 所述存储模块, 用于若所述查找模块没有查找到存储有所述关键字的表 项且所述判断模块检测到所述关键字的配置属性中包括所述装置和至少一个 备用 CPU时,将所述关键字存储到 TCAM,根据所述关键字的表项在 TCAM 的索引值将所述关联数据存储到所述装置的存储器, 将所述装置的编号写入 下发记录表中为所述索引值建立的表项;
所述指示模块, 还用于将所述装置的编号写入下发记录表中所述索引值 的表项之后,向所述关键字的配置属性中所有备用 CPU发送包括所述关联数 据和所述索引值的第三指示信息,用于指示所述配置属性中所有备用 CPU根 据所述装置发送的索引值将所述关联数据存储到所述备用 CPU的存储器,并 将自己的编号写入所述下发记录表中为所述索引值建立的表项。
10、 根据权利要求 8或 9所述的装置, 其特征在于, 所述第一备用 CPU 为所述配置属性中编号最小的备用 CPU。
11、 根据权利要求 8、 9或 10所述的装置, 其特征在于:
所述判断模块, 还用于若所述查找模块没有查找到存储有所述关键字的 表项, 判断所述关键字的配置属性中是否包括一个 CPU且为备用 CPU;
所述指示模块, 还用于若所述查找模块没有查找到存储有所述关键字的 表项且所述判断模块检测到所述关键字的配置属性中包括一个 CPU且为备用 CPU时,向所述配置属性中备用 CPU发送包括所述关键字和所述关联数据的 第四指示信息; 所述第四指示信息, 用于指示所述配置属性中备用 CPU将所 述关键字存储到 TCAM,根据所述关键字的表项在 TCAM的索引值将所述关 联数据存储到自身的存储器,并将所述配置属性中备用 CPU的编号写入所述 下发记录表中为所述索引值建立的表项;
所述判断模块, 还用于若所述查找模块没有查找到存储有所述关键字的 表项时, 判断所述关键字的配置属性中是否包括一个 CPU且为所述装置; 所述存储模块, 还用于若所述查找模块没有查找到存储有所述关键字的 表项且所述判断模块检测到所述关键字的配置属性中包括一个 CPU且为所述 装置时, 将所述关键字存储到 TCAM, 根据所述关键字的表项在 TCAM的索 弓 I值将所述关联数据存储到所述装置的存储器 , 并将所述装置的编号写入所 述下发记录表中为所述索引值建立的表项。
12、 根据权利要求 8至 11任一项所述的装置, 其特征在于: 所述查找模块, 还用于若查找到存储有所述关键字的表项, 获取所述关 键字的表项在 TCAM的索引值;
所述指示模块, 还用于若所述查找模块检测到所述配置属性中包括至少 —个备用 CPU时, 向所述配置属性中的所有备用 CPU发送包括所述查找模 块获取到的所述索引值的第五指示信息, 用于指示所述配置属性中的所有备 用 CPU根据所述索引值将所述关联数据存储到自己的存储器中,并将自己的 编号写入所述下发记录表中为所述索引值建立的表项;
所述存储模块, 还用于若所述配置属性中还包括所述装置, 根据所述索 引值将所述关联数据存储到所述装置的存储器中, 并将所述装置的编号写入 所述下发记录表中为所述索引值建立的表项。
13、 一种数据查找装置, 其特征在于, 包括:
接收模块, 用于接收包括关键字的查找指示, 所述查找指示用于指示查 找所述关键字的对应的关联数据;
查找模块, 用于在 TCAM中查找存储有所述关键字的表项;
所述查找模块, 还用于若查找到存储有所述关键字的表项, 获取所述关 键字的表项在 TCAM的索引值, 并在下发记录表的所述索引值的表项中查找 所述装置所属的处理器; 所述下发记录表中为所述索引值建立的表项用于记 录根据所述索引值存储关联数据的所有处理器;
获取模块, 用于若所述查找模块查找到所述处理器, 根据所述索引值从 所述处理器的存储器中获取所述关键字对应的关联数据。
14、 根据权利要求 13所述的装置, 其特征在于, 还包括:
返回模块, 用于若所述查找模块在 TCAM中没有查找到存储有所述关键 字的表项, 或, 在所述下发记录表的所述索引值的表项中没有查找到所述处 理器, 返回查找失败信息。
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201280001140.XA CN102959548B (zh) | 2012-08-22 | 2012-08-22 | 数据存储方法、查找方法及装置 |
PCT/CN2012/080460 WO2014029084A1 (zh) | 2012-08-22 | 2012-08-22 | 数据存储方法、查找方法及装置 |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
PCT/CN2012/080460 WO2014029084A1 (zh) | 2012-08-22 | 2012-08-22 | 数据存储方法、查找方法及装置 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2014029084A1 true WO2014029084A1 (zh) | 2014-02-27 |
Family
ID=47766347
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2012/080460 WO2014029084A1 (zh) | 2012-08-22 | 2012-08-22 | 数据存储方法、查找方法及装置 |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN102959548B (zh) |
WO (1) | WO2014029084A1 (zh) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104935517A (zh) * | 2015-04-29 | 2015-09-23 | 杭州华三通信技术有限公司 | 表项管理方法及装置 |
Families Citing this family (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103227751A (zh) * | 2013-05-14 | 2013-07-31 | 盛科网络(苏州)有限公司 | 提高转发表项空间使用率的方法和装置 |
CN103279423B (zh) * | 2013-05-15 | 2016-11-23 | 华为技术有限公司 | 一种内容寻址存储器的寻址方法及设备 |
WO2015030848A1 (en) * | 2013-08-31 | 2015-03-05 | Empire Technology Development Llc | Content-addressable memory device |
CN105791126B (zh) * | 2014-12-26 | 2020-04-24 | 中兴通讯股份有限公司 | 一种三态内容可寻址存储器tcam查表方法及装置 |
CN104615662B (zh) * | 2015-01-05 | 2019-05-14 | 宇龙计算机通信科技(深圳)有限公司 | 一种处理数据的方法、装置及终端设备 |
CN105653677A (zh) * | 2015-12-31 | 2016-06-08 | 盛科网络(苏州)有限公司 | 一种多对一索引分配的实现方法及实现装置 |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101770485A (zh) * | 2008-12-31 | 2010-07-07 | 华为技术有限公司 | 表项添加方法及装置和表项处理方法、装置及系统 |
US20100205364A1 (en) * | 2009-02-06 | 2010-08-12 | Hillel Gazit | Ternary content-addressable memory |
CN102622434A (zh) * | 2011-12-31 | 2012-08-01 | 成都市华为赛门铁克科技有限公司 | 数据存储方法、查找方法及装置 |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1870564A (zh) * | 2006-05-08 | 2006-11-29 | 国家数字交换系统工程技术研究中心 | 基于三态地址关联存储器实现组播查表的方法及系统 |
CN101840374B (zh) * | 2010-04-28 | 2012-06-27 | 福建星网锐捷网络有限公司 | 处理装置、信息查找系统及信息查找方法 |
-
2012
- 2012-08-22 CN CN201280001140.XA patent/CN102959548B/zh not_active Expired - Fee Related
- 2012-08-22 WO PCT/CN2012/080460 patent/WO2014029084A1/zh active Application Filing
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101770485A (zh) * | 2008-12-31 | 2010-07-07 | 华为技术有限公司 | 表项添加方法及装置和表项处理方法、装置及系统 |
US20100205364A1 (en) * | 2009-02-06 | 2010-08-12 | Hillel Gazit | Ternary content-addressable memory |
CN102622434A (zh) * | 2011-12-31 | 2012-08-01 | 成都市华为赛门铁克科技有限公司 | 数据存储方法、查找方法及装置 |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104935517A (zh) * | 2015-04-29 | 2015-09-23 | 杭州华三通信技术有限公司 | 表项管理方法及装置 |
CN104935517B (zh) * | 2015-04-29 | 2019-03-15 | 新华三技术有限公司 | 表项管理方法及装置 |
Also Published As
Publication number | Publication date |
---|---|
CN102959548A (zh) | 2013-03-06 |
CN102959548B (zh) | 2015-12-09 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2014029084A1 (zh) | 数据存储方法、查找方法及装置 | |
CN110998557B (zh) | 通过分布式存储器的高可用性数据库系统及方法 | |
US10114749B2 (en) | Cache memory system and method for accessing cache line | |
TWI549060B (zh) | Access methods and devices for virtual machine data | |
US11681754B2 (en) | Technologies for managing connected data on persistent memory-based systems | |
US9952783B2 (en) | Data processing method and apparatus, and shared storage device | |
JP5466257B2 (ja) | 表検索方法 | |
CN102609446B (zh) | 一种分布式Bloom过滤系统及其使用方法 | |
US20130042055A1 (en) | Memory system including key-value store | |
US9501506B1 (en) | Indexing system | |
KR20160046729A (ko) | 키-값 저장 엔진 및 그것의 효과적인 키 충돌 관리 방법 | |
TWI709862B (zh) | 用於預測性檔案快取及同步之技術 | |
TW201228303A (en) | Sas expander connection routing techniques | |
WO2023179433A1 (zh) | 流表存储及报文转发方法、装置、计算设备及介质 | |
CN114625762A (zh) | 一种元数据获取方法、网络设备及系统 | |
US8615642B2 (en) | Automatic page promotion and demotion in multiple page size environments | |
WO2016131175A1 (zh) | 多核系统中数据访问者目录的访问方法及设备 | |
CN110362590A (zh) | 数据管理方法、装置、系统、电子设备及计算机可读介质 | |
US9483568B1 (en) | Indexing system | |
WO2014190700A1 (zh) | 一种内存访问的方法、缓冲调度器和内存模块 | |
CN105574010B (zh) | 数据查询方法及装置 | |
WO2015032214A1 (zh) | 一种同时支持IPv4和IPv6的高速路由查找方法及装置 | |
WO2018036486A1 (zh) | 页表缓存的访问方法、页表缓存、处理器芯片和存储单元 | |
CN108804355B (zh) | 使用目标协作的快速排序写入的方法和系统 | |
JP2009289161A (ja) | クラスタ型ストレージシステム、そのノード装置、データの読み出しおよび書き込み制御方法およびそのプログラム |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
WWE | Wipo information: entry into national phase |
Ref document number: 201280001140.X Country of ref document: CN |
|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 12883379 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: 12883379 Country of ref document: EP Kind code of ref document: A1 |