CN109039911B - Method and system for sharing RAM based on HASH searching mode - Google Patents

Method and system for sharing RAM based on HASH searching mode Download PDF

Info

Publication number
CN109039911B
CN109039911B CN201810842538.5A CN201810842538A CN109039911B CN 109039911 B CN109039911 B CN 109039911B CN 201810842538 A CN201810842538 A CN 201810842538A CN 109039911 B CN109039911 B CN 109039911B
Authority
CN
China
Prior art keywords
ram
search
items
type
item
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
CN201810842538.5A
Other languages
Chinese (zh)
Other versions
CN109039911A (en
Inventor
杨彦波
张艳
张伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fiberhome Telecommunication Technologies Co Ltd
Wuhan Fisilink Microelectronics Technology Co Ltd
Original Assignee
Fiberhome Telecommunication Technologies Co Ltd
Wuhan Fisilink Microelectronics Technology Co Ltd
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 Fiberhome Telecommunication Technologies Co Ltd, Wuhan Fisilink Microelectronics Technology Co Ltd filed Critical Fiberhome Telecommunication Technologies Co Ltd
Priority to CN201810842538.5A priority Critical patent/CN109039911B/en
Publication of CN109039911A publication Critical patent/CN109039911A/en
Application granted granted Critical
Publication of CN109039911B publication Critical patent/CN109039911B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/74Address processing for routing
    • H04L45/745Address table lookup; Address filtering
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/74Address processing for routing
    • H04L45/745Address table lookup; Address filtering
    • H04L45/7453Address table lookup; Address filtering using hashing

Abstract

The invention discloses a method and a system for sharing RAM based on HASH searching mode, relating to computer communication technology. The invention most economically utilizes RAM resources, supports the longest entry checking and provides the ability of preventing HASH conflict for the non-longest entry checking.

Description

Method and system for sharing RAM based on HASH searching mode
Technical Field
The invention relates to the technical field of computer communication, in particular to a method and a system for sharing RAM based on HASH searching mode.
Background
Currently, in the field of communications, communications based on ethernet packets or IP packets dominate. Data communication devices such as an ethernet switch and a router need to process an ethernet packet or an IP packet by using a packet processing chip or an FPGA, and need to process according to protocol field information carried in a header of a data frame, an input port and an output port of the data packet, and configuration information, which relates to a large amount of table lookup processing. For example: an entry VLAN (virtual Local Access network) processing needs to perform table lookup according to an input port and a VLAN _ ID (VLAN identification) of a data frame to obtain a behavior of VLAN processing, an ethernet bridge needs to perform table lookup according to a DMAC _ address (destination Media Access Control address) and the VLAN _ ID of the data frame to determine a forwarding behavior, needs to perform address learning according to an SMAC _ address (source Media Access Control address) and the VLAN _ ID, and needs to perform table lookup according to an IPv4(Internet Protocol version 4) or IPv6(Internet Protocol version 6) address in an ip (Internet Protocol) exchange to determine the forwarding behavior.
In the above-mentioned table lookup processing, the HASH-based method is a commonly used method, and it hashes the KEY value of the table lookup, and uses the operation result as a table lookup index, and before table lookup, the KEY value of the table lookup needs to be written into the table lookup database according to the table lookup index, and when table lookup, the written value is read according to the table lookup index, and compared with the table lookup KEY, the matching is considered to be found. To overcome conflicts, HASH lookups often use multiple entries in parallel for lookup, i.e., one HASH index corresponds to multiple entries, and any match is considered a match.
In the field of packet processing, different application scenarios have different size requirements for each entry, and devices that focus on IP switching may have lower requirements for VLAN-processed entries, while ethernet bridge devices do not require IP functionality. In one design, if the sizes of the items can be flexibly adjusted according to application scenes, the application range of the chip or the FPGA is certainly enlarged.
Some current switching chips do not have an item scale adjustment function; some designs implement entry sharing by allocating RAM blocks according to configuration, and include a large number of small blocks of RAM, which makes the design and use complicated.
Disclosure of Invention
Aiming at the defects in the prior art, the invention aims to provide a method and a system for sharing a RAM based on a HASH searching mode, so that a plurality of databases of table searching types can be stored in one or a group of RAMs.
In order to achieve the above purposes, the technical scheme adopted by the invention is as follows: a method for sharing RAM based on HASH searching mode includes the following steps:
s1, acquiring the number and bit width of each table look-up type, and determining the bit width of the shared RAM according to the bit width of each table look-up type, wherein the bit width of the shared RAM is not less than the maximum value of the bit width of each item;
s2, calculating the RAM depth corresponding to each table look-up type according to the shared RAM bit width determined in S1 and the number of entries of each table look-up type, and determining the required shared RAM depth;
s3, configuring the base address of each table lookup type in the shared RAM, wherein the configured base address is any address of the shared RAM; configuring the HASH result bit number taken by each table look-up type, wherein the maximum value of the binary number value corresponding to the taken HASH result bit number is not less than the RAM depth corresponding to each table look-up type; and determining the size of the database in the shared RAM corresponding to each table look-up type according to the number of the taken HASH result bits.
On the basis of the above technical solution, step S2 specifically includes the following steps:
dividing the bit width of the shared RAM by the entry bit width of each table look-up type, and rounding down to obtain the number of parallel table look-up times corresponding to each table look-up type;
dividing the number of entries of each table lookup type by the corresponding number of times of parallel table lookup, and rounding up according to a binary system to obtain the corresponding RAM depth of each table lookup type;
and determining the required shared RAM depth, wherein the shared RAM depth is not less than the accumulated value of the RAM depths corresponding to the table look-up of each time.
On the basis of the above technical solution, the step S3 is followed by the step S4:
when the search item configuration in the shared RAM is carried out, HASH calculation is carried out according to the key word value of the search item to be configured, the calculation result is valued according to the number of the HASH result bits of the search list type to which the search item belongs, and the value is added with the base address of the search list type to which the search item belongs to serve as the RAM address of the entry to be written in the shared RAM; and configuring the key word value of the item to be searched and the corresponding table searching result to the RAM address of the item to be written in the shared RAM, and configuring the effective identification of the item of the searched item as effective.
On the basis of the technical scheme, the step of configuring the key word values of the items to be searched and the table search results to the RAM addresses of the items to be written in the shared RAM, and configuring the valid identifiers of the items as valid specifically comprises the following steps:
reading the RAM data corresponding to the RAM address of the item to be written, sequentially analyzing the searched items in the read RAM data from left to right, judging whether the searched items in the RAM data are valid, if so, checking whether the key word value is consistent with the searched items, and if so, updating the table searching result corresponding to the searched items; if the two items are inconsistent, skipping the search item, and continuously checking the next search item in the read RAM data; and if the search item is invalid, configuring the key word value of the search item to be configured and the table search result to the search item in the shared RAM, and configuring the effective item identifier of the search item in the shared RAM as effective.
On the basis of the above technical solution, the step S4 is followed by the step S5:
when a search request is received, HASH calculation is carried out according to a keyword value of the search request, values are taken on the calculation result according to the number of bits of the obtained HASH result of the table look-up type to which the configured search items belong, the base address of the table look-up type to which the configured search items belong is added to serve as the RAM address of the item to be read out in the shared RAM, and corresponding RAM data are read out; analyzing all search items in the read RAM data from left to right in sequence, comparing the key word value of the search request with the key word value in the read search items when the effective identification of the search items is effective, and outputting a search result corresponding to the key word value when the key word values are matched; otherwise, judging the next search item in the read RAM data.
The invention also discloses a system for sharing RAM based on HASH searching mode, which comprises:
the RAM bit width calculation module is used for acquiring the number of entries and the bit width of the entries of each table look-up type, and determining the bit width of the shared RAM required according to the bit width of the entries of each table look-up type, wherein the bit width of the shared RAM is not less than the maximum value of the bit width of the entries;
the RAM depth calculation module is used for calculating the RAM depth corresponding to each table look-up type according to the bit width of the shared RAM and the number of entries of each table look-up type and determining the required shared RAM depth;
the RAM configuration module is used for configuring the base address of each table look-up type in the shared RAM, and the configured base address is any address of the shared RAM; configuring the HASH result bit number taken by each table look-up type, wherein the maximum value of the binary number value corresponding to the taken HASH result bit number is not less than the RAM depth corresponding to each table look-up type; and determining the size of the database in the shared RAM corresponding to each table look-up type according to the number of the taken HASH result bits.
On the basis of the technical scheme, the RAM depth calculation module is specifically configured to:
dividing the bit width of the shared RAM by the entry bit width of each table look-up type, and rounding down to obtain the number of parallel table look-up times corresponding to each table look-up type;
dividing the number of entries of each table lookup type by the corresponding number of times of parallel table lookup, and rounding up according to a binary system to obtain the corresponding RAM depth of each table lookup type;
and determining the required shared RAM depth, wherein the shared RAM depth is not less than the accumulated value of the RAM depths corresponding to the table look-up of each time.
On the basis of the above technical solution, the system further includes a lookup entry configuration module, which is configured to:
when the search item configuration in the shared RAM is carried out, HASH calculation is carried out according to the key word value of the search item to be configured, the calculation result is valued according to the number of the HASH result bits of the search list type to which the search item belongs, and the value is added with the base address of the search list type to which the search item belongs to serve as the RAM address of the entry to be written in the shared RAM; and configuring the key word value of the item to be searched and the corresponding table searching result to the RAM address of the item to be written in the shared RAM, and configuring the effective identification of the item of the searched item as effective.
On the basis of the technical scheme, the entry configuration module configures the key word value and the table look-up result of the searched entry to be configured to the RAM address of the entry to be written in the shared RAM, and configures the valid identifier of the entry to be valid, and the method specifically comprises the following processes:
reading the RAM data corresponding to the RAM address of the item to be written, sequentially analyzing the searched items in the read RAM data from left to right, judging whether the searched items in the RAM data are valid, if so, checking whether the key word value is consistent with the searched items, and if so, updating the table searching result corresponding to the searched items; if the two items are inconsistent, skipping the search item, and continuously checking the next search item in the read RAM data; and if the search item is invalid, configuring the key word value of the search item to be configured and the table search result to the search item in the shared RAM, and configuring the effective item identifier of the search item in the shared RAM as effective.
On the basis of the technical scheme, the system also comprises a table look-up function module and a calculation read-write module;
the table look-up function module is used for: when a search request is received, extracting a keyword value of the search request and outputting the keyword value to a calculation read-write module;
the calculation read-write module is used for: HASH calculation is carried out according to the key word value of the search request, the calculation result is subjected to value taking according to the number of HASH result bits of the search list type to which the configured search item belongs, the configured base address of the search item is added to serve as the RAM address of the item to be read out in the shared RAM, and corresponding RAM data is read out and output to the search list function module;
the table lookup function module is further configured to: analyzing all search items in the read RAM data from left to right in sequence, comparing a keyword value of a search request with a keyword value in the read search item when an item effective identifier of the read corresponding search item is effective, and outputting a search result corresponding to the keyword value when the keyword values are matched; otherwise, judging the next search item in the read RAM data.
Compared with the prior art, the invention has the advantages that:
the method and the system for sharing the RAM based on the HASH searching mode are provided, and the width of the RAM is reasonably determined according to the entry bit width of each table look-up type by configuring a base address and the number of bits of the obtained HASH result for each table look-up type, so that a plurality of databases of the table look-up types can be co-stored in one block or one group of RAMs. The invention makes the most economical use of RAM resources and provides the ability to overcome HASH conflicts for non-longest entries while supporting the longest entries.
The invention can flexibly adjust the size of the database by changing the base address configured by the table look-up type and the bit number of the taken HASH result, so that the design can be suitable for a plurality of application scenes.
Drawings
FIG. 1 is a schematic flow chart illustrating a method for sharing RAM based on HASH search mode according to an embodiment of the present invention;
FIG. 2 is a diagram illustrating a data structure of search items according to the HASH-based method for sharing RAM in the embodiment of the present invention;
fig. 3 is a schematic structural diagram of a database in the RAM based on the method for sharing the RAM in the HASH search manner in the embodiment of the present invention;
FIG. 4 is a schematic structural diagram of a system for sharing RAM based on HASH search method according to an embodiment of the present invention;
fig. 5 is a schematic diagram of the working principle of the entry configuration module, the table look-up function module, and the calculation read-write module of the system for sharing the RAM based on the HASH search method according to the embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples.
Example 1:
referring to fig. 1, an embodiment of the present invention provides a method for sharing a RAM based on a HASH lookup manner, including the following steps:
s1, obtaining the item number and item bit width of the search items contained in each table look-up type, and determining the bit width of the shared RAM according to the item bit width of each table look-up type, wherein the bit width of the shared RAM is not less than the maximum value of the item bit width; each lookup table type comprises a plurality of lookup entries, and each lookup entry comprises an entry effective identifier, a key word value and a lookup table result.
S2, calculating the RAM depth corresponding to each table look-up type according to the shared RAM bit width determined in S1 and the number of entries of each table look-up type, and determining the required shared RAM depth;
s3, configuring the base address of each table lookup type in the shared RAM, wherein the configured base address is any address of the shared RAM; configuring the HASH result bit number taken by each table look-up type, wherein the maximum value of the binary number value corresponding to the taken HASH result bit number is not less than the RAM depth corresponding to each table look-up type; and determining the size of the database in the shared RAM corresponding to each table look-up type according to the number of the taken HASH result bits.
Step S2 specifically includes the following steps:
dividing the bit width of the shared RAM by the entry bit width of each table look-up type, and rounding down to obtain the number of parallel table look-up times corresponding to each table look-up type; for example, if the shared RAM bit width is 10 and the entry bit width is 3, then 10 ÷ 3, and then 3 after rounding down.
Dividing the number of entries of each table lookup type by the corresponding number of times of parallel table lookup, and rounding up according to a binary system to obtain the corresponding RAM depth of each table lookup type; for example, the number of entries is 128, and if the number of parallel table lookups is 3, then 128/3 is rounded up to 64 in binary.
And determining the required shared RAM depth, wherein the shared RAM depth is not less than the accumulated value of the RAM depths corresponding to the table look-up of each time.
The invention configures the base address and the number of bits of the HASH result for each table lookup, and reasonably determines the width of the RAM according to the bit width of the entry of each table lookup type, so that a plurality of databases can be stored in one or a group of RAMs. The invention makes the most economical use of RAM resources and provides the ability to overcome HASH conflicts for non-longest entries while supporting the longest entries.
Example 2:
on the basis of example 1, assume that 4 types of table lookup are required in a certain design requirement: the bit width of the first table lookup type is 50, and the number of entries is 256; the entry bit width of the second lookup table type is 65, the entry number is 2048, the entry bit width of the third lookup table type is 80, the entry number is 4096, and the entry bit width of the fourth lookup table type is 180; the number of entries 512.
Step S1 specifically includes the following processes:
1. calculating according to the method for determining the bit width of the RAM and the number of times of comparison required by each search:
setting the bit width of the required shared RAM as 200 bits, and continuously calculating according to the bit width of the shared RAM to obtain the following table:
each type of table lookup Number of parallel table lookup m Calculating the required RAM depth
1 4 64(256/4=64)
2 3 1024(2048/3 683 times 256 to get 1024)
3 2 2048(4096/2=2048)
4 1 512(512/1=512)
And accumulating the RAM depths corresponding to the table look-up types to obtain the minimum shared RAM depth of 4096, and setting the required shared RAM to 8192 in order to reduce HASH conflicts.
2. The base address and the number of HASH result bits taken for each lookup table are configured as follows
Figure BDA0001745915970000081
Figure BDA0001745915970000091
In order to avoid the conflict of different table look-up types, the configuration of the base addresses of different table look-up types requires that the shared RAM addresses corresponding to different table look-up types are not covered.
As a preferred scheme, the base address of the first table lookup type is configured from 0, the base address of the second table lookup type is configured from the end of the shared RAM address corresponding to the database of the first table lookup type, the base address of the third table lookup type is configured from the end of the shared RAM address corresponding to the database of the second table lookup type, and so on, so as to avoid space waste of the shared RAM.
3. The configured database is shown in FIG. 3
4. Assuming that an entry needs to be changed in a certain application scenario, the 3 rd and 4 th searches do not need to be performed, the entry is changed to 16k for the first search, and the number of bits of the HASH result is changed to 8k for the 2 nd search, the base addresses and the number of bits of the HASH result are configured as follows:
each type of table lookup Base address The number of HASH result bits taken Actual containable item capacity
1 0 12 16k(212*4=16384)
2 4096 12 12k(212*3=12288)
3 8192 0 0
4 8192 0 0
Example 3:
on the basis of embodiment 1, step S3 is followed by step S4:
when the search item configuration in the shared RAM is carried out, HASH calculation is carried out according to the key word value of the search item to be configured, the calculation result is valued according to the number of the HASH result bits of the search list type to which the search item belongs, and the value is added with the base address of the search list type to which the search item belongs to serve as the RAM address of the entry to be written in the shared RAM; and configuring the key word value of the item to be searched and the corresponding table searching result to the RAM address of the item to be written in the shared RAM, and configuring the effective identification of the item of the searched item as effective.
The method for configuring the key word values of the items to be searched and the table search results to the RAM addresses of the items to be written in the shared RAM and configuring the effective identifiers of the items to be written as effective specifically comprises the following steps:
reading the RAM data corresponding to the RAM address of the item to be written, sequentially analyzing the searched items in the read RAM data from left to right, judging whether the searched items in the RAM data are valid, if so, checking whether the key word value is consistent with the searched items, and if so, updating the table searching result corresponding to the searched items; if the two items are inconsistent, skipping the search item, and continuously checking the next search item in the read RAM data; and if the search item is invalid, configuring the key word value of the search item to be configured and the table search result to the search item in the shared RAM, and configuring the effective item identifier of the search item in the shared RAM as effective.
The invention can flexibly adjust the size of the database by changing the base address configured by the table lookup and the number of bits of the taken HASH result, so that the design can be suitable for a plurality of application scenes.
Step S5 is also included after step S4:
when a search request is received, HASH calculation is carried out according to a keyword value of the search request, values are taken on the calculation result according to the number of bits of the obtained HASH result of the table look-up type to which the configured search items belong, the base address of the table look-up type to which the configured search items belong is added to serve as the RAM address of the item to be read out in the shared RAM, and corresponding RAM data are read out; analyzing all search items in the read RAM data from left to right in sequence, comparing the key word value of the search request with the key word value in the read search items when the effective identification of the search items is effective, and outputting a search result corresponding to the key word value when the key word values are matched; otherwise, judging the next search item in the read RAM data.
Example 4:
the embodiment discloses a system for sharing RAM based on HASH search mode, as shown in fig. 4, including:
the RAM bit width calculation module is used for acquiring the number of items and the bit width of the items to be searched contained in each table look-up type, and determining the bit width of the shared RAM to be required according to the bit width of the items of each table look-up type, wherein the bit width of the shared RAM is not less than the maximum value of the bit width of the items;
the RAM depth calculation module is used for calculating the RAM depth corresponding to each table look-up type according to the bit width of the shared RAM and the number of entries of each table look-up type and determining the required shared RAM depth;
the RAM configuration module is used for configuring the base address of each table look-up type in the shared RAM, and the configured base address is any address of the shared RAM; configuring the HASH result bit number taken by each table look-up type, wherein the maximum value of the binary number value corresponding to the taken HASH result bit number is not less than the RAM depth corresponding to each table look-up type; and determining the size of the database in the shared RAM corresponding to each table look-up type according to the number of the taken HASH result bits.
The RAM depth calculation module is specifically configured to:
dividing the bit width of the shared RAM by the entry bit width of each table look-up type, and rounding down to obtain the number of parallel table look-up times corresponding to each table look-up type; for example, if the shared RAM bit width is 10 and the entry bit width is 3, then 10 ÷ 3, and then 3 after rounding down.
Dividing the number of entries of each table lookup type by the corresponding number of times of parallel table lookup, and rounding up according to a binary system to obtain the corresponding RAM depth of each table lookup type; for example, the number of entries is 128, and if the number of parallel table lookups is 3, then 128/3 is rounded up to 64 in binary.
And determining the required shared RAM depth, wherein the shared RAM depth is not less than the accumulated value of the RAM depths corresponding to the table look-up of each time.
Example 5:
on the basis of embodiment 4, the system further comprises a lookup entry configuration module for:
when the search item configuration in the shared RAM is carried out, HASH calculation is carried out according to the key word value of the search item to be configured, the calculation result is valued according to the number of the HASH result bits of the search list type to which the search item belongs, and the value is added with the base address of the search list type to which the search item belongs to serve as the RAM address of the entry to be written in the shared RAM; and configuring the key word value of the item to be searched and the corresponding table searching result to the RAM address of the item to be written in the shared RAM, and configuring the effective identification of the item of the searched item as effective.
The item configuration module configures the key word value and the table look-up result of the item to be searched to the RAM address of the item to be written in the shared RAM, and configures the effective identifier of the item to be effective, which specifically comprises the following processes:
reading the RAM data corresponding to the RAM address of the item to be written, sequentially analyzing the searched items in the read RAM data from left to right, judging whether the searched items in the RAM data are valid, if so, checking whether the key word value is consistent with the searched items, and if so, updating the table searching result corresponding to the searched items; if the two items are inconsistent, skipping the search item, and continuously checking the next search item in the read RAM data; and if the search item is invalid, configuring the key word value of the search item to be configured and the table search result to the search item in the shared RAM, and configuring the effective item identifier of the search item in the shared RAM as effective.
The system also comprises a table look-up function module and a calculation read-write module;
the table look-up function module is used for: when a search request is received, extracting a keyword value of the search request and outputting the keyword value to a calculation read-write module;
the calculation read-write module is used for: HASH calculation is carried out according to the key word value of the search request, the calculation result is subjected to value taking according to the number of HASH result bits of the search list type to which the configured search item belongs, the configured base address of the search item is added to serve as the RAM address of the item to be read out in the shared RAM, and corresponding RAM data is read out and output to the search list function module;
the table lookup function module is further configured to: analyzing all search items in the read RAM data from left to right in sequence, comparing a keyword value of a search request with a keyword value in the read search item when an item effective identifier of the read corresponding search item is effective, and outputting a search result corresponding to the keyword value when the keyword values are matched; otherwise, judging the next search item in the read RAM data.
Example 6:
on the basis of embodiment 4, referring to fig. 5, this embodiment discloses an apparatus for sharing RAM based on HASH search mode, which is composed of 4 parts: the system comprises a plurality of table look-up function modules, a calculation read-write module, an item configuration module and an RAM. The input of the device is data packet information, and the output is table lookup result information.
The function of the table lookup function module is as follows: adopting input data packet information to form a search keyword value, outputting the search keyword value and a search request to a calculation read-write module, comparing the search keyword value and an entry effective identifier which are sent to a table search function module, and comparing the search entries in the RAM in sequence when the input entry effective identifier is effective; and outputting a table lookup result when the lookup entry is effective and the lookup key words are matched. Referring to fig. 2, a data structure of lookup entries in the RAM includes m lookup entries or a plurality of spare bits in a database corresponding to each lookup table type, where each lookup entry includes an entry valid identifier, a key value and a lookup table result, and the databases corresponding to different lookup table types include different numbers of entries because the key value and the lookup table result of each lookup are different in bit width.
The calculation read-write module comprises the configuration of the base address searched for each time and the configuration of the HASH result bit number searched for each time, and the data base size of the lookup table is obtained by multiplying the maximum value of the binary number corresponding to the HASH result bit number searched for each lookup table type by the parallel search times corresponding to each lookup table type.
The calculation read-write module has two functions, one function is to respond to the search request of each table search function module in sequence, to perform HASH calculation according to each searched keyword value, then to fetch the corresponding digit of the HASH calculation result according to the fetched HASH result digit of each search configuration, then to add the base address configuration value corresponding to the search, to take the final result as the RAM address to perform RAM reading, and to send the read RAM data to each search function module, and to output the effective identification of the item to all table search function modules. The other function is to respond to the read-write access of the item configuration module to the RAM, and is used for managing and configuring each database in the RAM.
The function of the item configuration module is to carry out read-write configuration on the RAM and configure the base address searched for each time and the number of bits of the taken HASH result.
The present invention is not limited to the above-described embodiments, and it will be apparent to those skilled in the art that various modifications and improvements can be made without departing from the principle of the present invention, and such modifications and improvements are also considered to be within the scope of the present invention. Those not described in detail in this specification are within the skill of the art.

Claims (6)

1. A method for sharing RAM based on HASH searching mode is characterized by comprising the following steps:
s1, obtaining the item number and item bit width of the search items contained in each table look-up type, and determining the bit width of the shared RAM according to the item bit width of each table look-up type, wherein the bit width of the shared RAM is not less than the maximum value of the item bit width;
s2, calculating the RAM depth corresponding to each table look-up type according to the shared RAM bit width determined in S1 and the number of entries of each table look-up type, and determining the required shared RAM depth;
s3, configuring the base address of each table lookup type in the shared RAM, wherein the configured base address is any address of the shared RAM; configuring the HASH result bit number taken by each table look-up type, wherein the maximum value of the binary number value corresponding to the taken HASH result bit number is not less than the RAM depth corresponding to each table look-up type; determining the size of the database in the shared RAM corresponding to each table look-up type according to the number of bits of the HASH result;
s4, when configuring the search items in the shared RAM, HASH calculation is carried out according to the key word values of the search items to be configured, the calculation results are valued according to the HASH result digit of the search list type to which the search items belong, and the base address of the search list type to which the search items belong is added to be used as the RAM address of the items to be written in the shared RAM; configuring key word values of items to be searched and corresponding table searching results to the RAM address of the items to be written in the shared RAM, and configuring effective identifiers of the items to be searched as effective, wherein the method specifically comprises the following steps: reading the RAM data corresponding to the RAM address of the item to be written, sequentially analyzing the searched items in the read RAM data from left to right, judging whether the searched items in the RAM data are valid, if so, checking whether the key word value is consistent with the searched items, and if so, updating the table searching result corresponding to the searched items; if the two items are inconsistent, skipping the search item, and continuously checking the next search item in the read RAM data; and if the search item is invalid, configuring the key word value of the search item to be configured and the table search result to the search item in the shared RAM, and configuring the effective item identifier of the search item in the shared RAM as effective.
2. The method of claim 1, wherein the method for sharing RAM based on HASH search mode comprises: step S2 specifically includes the following steps:
dividing the bit width of the shared RAM by the entry bit width of each table look-up type, and rounding down to obtain the number of parallel table look-up times corresponding to each table look-up type;
dividing the number of entries of each table lookup type by the corresponding number of times of parallel table lookup, and rounding up according to a binary system to obtain the corresponding RAM depth of each table lookup type;
and determining the required shared RAM depth, wherein the shared RAM depth is not less than the accumulated value of the RAM depths corresponding to the table look-up of each time.
3. The method of claim 1, wherein the method for sharing RAM based on HASH search mode comprises: step S5 is also included after step S4:
when a search request is received, HASH calculation is carried out according to a keyword value of the search request, values are taken on the calculation result according to the number of bits of the obtained HASH result of the table look-up type to which the configured search items belong, the base address of the table look-up type to which the configured search items belong is added to serve as the RAM address of the item to be read out in the shared RAM, and corresponding RAM data are read out; analyzing all search items in the read RAM data from left to right in sequence, comparing the key word value of the search request with the key word value in the read search items when the effective identification of the search items is effective, and outputting a search result corresponding to the key word value when the key word values are matched; otherwise, judging the next search item in the read RAM data.
4. A system for sharing RAM based on HASH searching mode is characterized by comprising:
the RAM bit width calculation module is used for acquiring the number of items and the bit width of the items to be searched contained in each table look-up type, and determining the bit width of the shared RAM to be required according to the bit width of the items of each table look-up type, wherein the bit width of the shared RAM is not less than the maximum value of the bit width of the items;
the RAM depth calculation module is used for calculating the RAM depth corresponding to each table look-up type according to the bit width of the shared RAM and the number of entries of each table look-up type and determining the required shared RAM depth;
the RAM configuration module is used for configuring the base address of each table look-up type in the shared RAM, and the configured base address is any address of the shared RAM; configuring the HASH result bit number taken by each table look-up type, wherein the maximum value of the binary number value corresponding to the taken HASH result bit number is not less than the RAM depth corresponding to each table look-up type; determining the size of the database in the shared RAM corresponding to each table look-up type according to the number of bits of the HASH result;
a lookup entry configuration module to: when the search item configuration in the shared RAM is carried out, HASH calculation is carried out according to the key word value of the search item to be configured, the calculation result is valued according to the number of the HASH result bits of the search list type to which the search item belongs, and the value is added with the base address of the search list type to which the search item belongs to serve as the RAM address of the entry to be written in the shared RAM; configuring key word values of items to be searched and corresponding table searching results to the RAM address of the items to be written in the shared RAM, and configuring effective identifiers of the items to be searched as effective, wherein the method specifically comprises the following steps: reading the RAM data corresponding to the RAM address of the item to be written, sequentially analyzing the searched items in the read RAM data from left to right, judging whether the searched items in the RAM data are valid, if so, checking whether the key word value is consistent with the searched items, and if so, updating the table searching result corresponding to the searched items; if the two items are inconsistent, skipping the search item, and continuously checking the next search item in the read RAM data; and if the search item is invalid, configuring the key word value of the search item to be configured and the table search result to the search item in the shared RAM, and configuring the effective item identifier of the search item in the shared RAM as effective.
5. The system for sharing RAM based on HASH lookup as claimed in claim 4 wherein: the RAM depth calculation module is specifically configured to:
dividing the bit width of the shared RAM by the entry bit width of each table look-up type, and rounding down to obtain the number of parallel table look-up times corresponding to each table look-up type;
dividing the number of entries of each table lookup type by the corresponding number of times of parallel table lookup, and rounding up according to a binary system to obtain the corresponding RAM depth of each table lookup type;
and determining the required shared RAM depth, wherein the shared RAM depth is not less than the accumulated value of the RAM depths corresponding to the table look-up of each time.
6. The system for sharing RAM based on HASH lookup as claimed in claim 4 wherein: the system also comprises a table look-up function module and a calculation read-write module;
the table look-up function module is used for: when a search request is received, extracting a keyword value of the search request and outputting the keyword value to a calculation read-write module;
the calculation read-write module is used for: HASH calculation is carried out according to the key word value of the search request, the calculation result is subjected to value taking according to the number of HASH result bits of the search list type to which the configured search item belongs, the configured base address of the search item is added to serve as the RAM address of the item to be read out in the shared RAM, and corresponding RAM data is read out and output to the search list function module;
the table lookup function module is further configured to: analyzing all search items in the read RAM data from left to right in sequence, comparing a keyword value of a search request with a keyword value in the read search item when an item effective identifier of the read corresponding search item is effective, and outputting a search result corresponding to the keyword value when the keyword values are matched; otherwise, judging the next search item in the read RAM data.
CN201810842538.5A 2018-07-27 2018-07-27 Method and system for sharing RAM based on HASH searching mode Active CN109039911B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810842538.5A CN109039911B (en) 2018-07-27 2018-07-27 Method and system for sharing RAM based on HASH searching mode

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810842538.5A CN109039911B (en) 2018-07-27 2018-07-27 Method and system for sharing RAM based on HASH searching mode

Publications (2)

Publication Number Publication Date
CN109039911A CN109039911A (en) 2018-12-18
CN109039911B true CN109039911B (en) 2021-02-26

Family

ID=64646036

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810842538.5A Active CN109039911B (en) 2018-07-27 2018-07-27 Method and system for sharing RAM based on HASH searching mode

Country Status (1)

Country Link
CN (1) CN109039911B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114615196A (en) * 2022-03-24 2022-06-10 北京左江科技股份有限公司 High-speed accurate matching search method
CN117478626B (en) * 2023-12-27 2024-04-05 天津光电聚能通信股份有限公司 Quick matching searching system, method, equipment and medium based on group connection cache

Family Cites Families (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100355241C (en) * 2003-04-14 2007-12-12 华为技术有限公司 Method of realizing HASH position width compression
CN1787477A (en) * 2004-12-09 2006-06-14 北京三星通信技术研究有限公司 Method for searching IPv6 routing table
CN100450100C (en) * 2006-08-29 2009-01-07 华为技术有限公司 Route method and equipment
CN101621502A (en) * 2008-06-30 2010-01-06 华为技术有限公司 Method and device for storing and searching routing table
CN101827137B (en) * 2010-04-13 2013-01-30 西安邮电学院 Hash table-based and extended memory-based high-performance IPv6 address searching method
CN102364463B (en) * 2011-09-19 2013-07-10 浪潮电子信息产业股份有限公司 Hash-based method for searching CAM (central address memory)
US9620213B2 (en) * 2013-12-27 2017-04-11 Cavium, Inc. Method and system for reconfigurable parallel lookups using multiple shared memories
CN105224532B (en) * 2014-05-28 2019-11-08 腾讯科技(深圳)有限公司 Data processing method and device
US10169124B2 (en) * 2014-12-16 2019-01-01 Samsung Electronics Co., Ltd. Unified object interface for memory and storage system
CN104809179B (en) * 2015-04-16 2018-10-02 华为技术有限公司 The device and method for accessing Hash table
CN105608028A (en) * 2015-10-19 2016-05-25 陕西宝成航空仪表有限责任公司 EMIF (External Memory Interface) and dual-port RAM (Random Access Memory)-based method for realizing high-speed communication of DSP (Digital Signal Processor) and FPGA (Field Programmable Gate Array)
CN106446099A (en) * 2016-09-13 2017-02-22 国家超级计算深圳中心(深圳云计算中心) Distributed cloud storage method and system and uploading and downloading method thereof

Also Published As

Publication number Publication date
CN109039911A (en) 2018-12-18

Similar Documents

Publication Publication Date Title
US10496680B2 (en) High-performance bloom filter array
US9984144B2 (en) Efficient lookup of TCAM-like rules in RAM
US20220045875A1 (en) Multicast message processing method and apparatus, storage medium and processor
CN109921995B (en) Method for configuring address table, FPGA and network equipment applying FPGA
WO2021135491A1 (en) Flow table matching method and apparatus
US20090282167A1 (en) Method and apparatus for bridging
US9485179B2 (en) Apparatus and method for scalable and flexible table search in a network switch
CN109039911B (en) Method and system for sharing RAM based on HASH searching mode
CN107547407A (en) Message transmitting method, device and realization device
CN111988231A (en) Mask five-tuple rule matching method and device
US20190294549A1 (en) Hash Table-Based Mask Length Computation for Longest Prefix Match Caching
CN113986560B (en) Method for realizing P4 and OvS logic multiplexing in intelligent network card/DPU
US11140078B1 (en) Multi-stage prefix matching enhancements
CN112187636B (en) ECMP route storage method and device
US20230041395A1 (en) Method and Device for Processing Routing Table Entries
CN104253754A (en) ACL (access control list) fast matching method and equipment
CN112818185A (en) Method for searching longest prefix matching hardware system based on SRAM
US20060198379A1 (en) Prefix optimizations for a network search engine
CN115086221B (en) Message processing method, device, forwarding equipment and storage medium
CN112667640B (en) Routing address storage method and device
CN103368852A (en) Method and system for processing hash conflict
CN113343034A (en) IP searching method, system and storage medium
Lee et al. Approaches for improving tuple space search-based table lookup
CN101822027A (en) Method and apparatus for efficient cam lookup for internet protocol addresses
US7934198B2 (en) Prefix matching structure and method for fast packet switching

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant