CN109039911A - It is a kind of to search the method and system that mode shares RAM based on HASH - Google Patents
It is a kind of to search the method and system that mode shares RAM based on HASH Download PDFInfo
- Publication number
- CN109039911A CN109039911A CN201810842538.5A CN201810842538A CN109039911A CN 109039911 A CN109039911 A CN 109039911A CN 201810842538 A CN201810842538 A CN 201810842538A CN 109039911 A CN109039911 A CN 109039911A
- Authority
- CN
- China
- Prior art keywords
- entry
- ram
- lookup
- type
- tabling look
- 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.)
- Granted
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L45/00—Routing or path finding of packets in data switching networks
- H04L45/74—Address processing for routing
- H04L45/745—Address table lookup; Address filtering
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L45/00—Routing or path finding of packets in data switching networks
- H04L45/74—Address processing for routing
- H04L45/745—Address table lookup; Address filtering
- H04L45/7453—Address table lookup; Address filtering using hashing
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The method and system that mode shares RAM are searched based on HASH the invention discloses a kind of, it is related to computer communication technology, the present invention passes through to each type configuration base address and taken HASH result length of tabling look-up, and the width and depth that shared RAM is rationally determined according to the entry width for type of respectively tabling look-up, coexist in multiple databases in one piece or one group of RAM.The present invention is most economical to be utilized RAM resource, while supporting longest to look into entry, looks into entry for non-longest and provides the ability that gram HASH conflicts.
Description
Technical field
The present invention relates to computer communication technology fields, and in particular to a kind of that the side that mode shares RAM is searched based on HASH
Method and system.
Background technique
At present in the communications field, the communication based on Ethernet packet or IP packet accounts for dominant position.Ethernet switch therein,
The data communications equipment such as router are required to handle Ethernet packet or IP packet using packet processing chip or FPGA, be needed
According to the protocol fields information carried in data frame head, data packet input port, output port and configuration information are handled,
It is related to processing of largely tabling look-up.Such as: ingress VLAN (Virtual Local Access Network) processing needs basis
The VLAN_ID (VLAN Identification) of input port and data frame is tabled look-up to obtain the behavior of VLAN processing, ether
Network bridge need according to the DMAC_Addr (Destination MediaAccess ControlAddress) of data frame and
VLAN_ID carries out determining forwarding behavior of tabling look-up, and needs according to SMAC_Addr (Source Media Access Control
Address) and VLAN_ID carries out address learning, needs in IP (Internet Protocol) exchange according to IPv4
The address (InternetProtocol version 4) or IPv6 (Internet Protocol version 6) table look-up really
Surely behavior is forwarded.
In processing of tabling look-up mentioned above, the method based on HASH is a kind of common method, it is the pass that will be tabled look-up
Key word value carries out hash operations, using operation result as lookup table index, needs elder generation that will be tabled look-up before tabling look-up according to lookup table index
Key value is written in lookup data library, reads write-in value according to lookup table index when tabling look-up, and be compared with the KEY that tables look-up,
It is matched to think to find.To overcome conflict, HASH lookup is searched frequently with multiple parallel entries, i.e. a HASH index
Corresponding multiple entries, any one matching are thought to match.
In packet process field, different application scenarios are different the size requirements of each entry, lay particular emphasis on IP exchange
Equipment may be lower to the entry requirement of VLAN processing, and ethernet bridge equipment does not need IP function.In one design such as
Fruit can flexibly carry out the adjustment of each entry scale according to application scenarios, then can undoubtedly expand chip or the use model of FPGA
It encloses.
Current exchange chip, some do not have entry scale and adjust function;Some passes through the tune of RAM block according to configuration
Match to realize that entry is shared, design and use can be kept all more complex comprising a large amount of small block RAM in design.
Summary of the invention
In view of the deficiencies in the prior art, mode is searched based on HASH the purpose of the present invention is to provide one kind to share
The method and system of RAM realize that the database of multiple types of tabling look-up can coexist in one piece or one group of RAM.
To achieve the above objectives, the technical solution adopted by the present invention is that: it is a kind of based on HASH search mode share RAM side
Method, comprising the following steps:
S1 obtains the entry number and entry bit wide of type of respectively tabling look-up, according to the entry bit wide for type of respectively tabling look-up, needed for determining
Shared RAM bit is wide, and it is wide not less than entry bit wide maximum value to share RAM bit;
S2, it is wide according to the shared RAM bit determined in S1 and respectively table look-up the entry number of type, calculate type pair of respectively tabling look-up
The RAM depth answered, shared RAM depth needed for determining;
S3, configuration are respectively tabled look-up base address of the type in shared RAM, the base address configured be share RAM anyly
Location;Configuration is respectively tabled look-up the taken HASH result length of type, and the corresponding binary numeral maximum value of taken HASH result length is not small
In the corresponding RAM depth of type of respectively tabling look-up;It is determined in the corresponding shared RAM of type that respectively tables look-up according to taken HASH result length
The size of database.
Based on the above technical solution, step S2 specifically includes the following steps:
Shared RAM bit is wide respectively divided by the entry bit wide for type of respectively tabling look-up, and be rounded downwards, type pair of respectively being tabled look-up
The number of tabling look-up parallel answered;
By the entry number for type of respectively tabling look-up, divided by corresponding number of tabling look-up parallel, and rounds up, obtain according to binary system
The corresponding RAM depth of type of respectively tabling look-up;
Shared RAM depth needed for determining, shares the accumulated value that RAM depth is not less than each corresponding RAM depth of tabling look-up.
Based on the above technical solution, further include step S4 after step S3:
When carrying out the lookup entry configuration in shared RAM, HASH is carried out according to the key value of lookup entry to be configured
It calculates, the taken HASH result length for type of being tabled look-up according to belonging to the lookup entry carries out value to calculated result, in addition looking into
The base address for looking for type of tabling look-up belonging to entry, the address ram as entry to be written in shared RAM;By lookup item to be configured
Purpose key value and corresponding checking result, are configured to the address ram of entry to be written in shared RAM, and configure the lookup
The entry of entry is effectively identified as effectively.
Based on the above technical solution, described to configure the key value of lookup entry to be configured and checking result
The address ram of entry to be written into shared RAM, and configure entry and be effectively identified as effectively, specifically include following procedure:
The corresponding RAM data of address ram for reading entry to be written, to the lookup entry in the RAM data of reading from a left side
To the right side successively analyze, judge in RAM data search entry it is whether effective, if effectively, check key value whether with search entry
In it is consistent, if unanimously, updating and searching the corresponding checking result of entry;If inconsistent, the lookup entry is skipped, is continued checking
Next lookup entry in the RAM data of reading;If invalid, by the key value of lookup entry to be configured and knot of tabling look-up
Fruit is configured to the lookup entry in shared RAM, and the entry for configuring the lookup entry in shared RAM is effectively identified as effectively.
Based on the above technical solution, further include step S5 after step S4:
When receiving search request, HASH calculating is carried out according to the key value of search request, to calculated result further according to matching
The taken HASH result length for type of tabling look-up belonging to the lookup entry set carries out value, in addition tabling look-up belonging to the lookup entry of configuration
The base address of type reads corresponding RAM data as being read out the address ram of entry in shared RAM;To the RAM of reading
All lookup entries are from left to right successively analyzed in data, and when the entry for searching entry is effectively identified as effective, lookup is asked
Key value in the key value asked and the lookup entry read is compared, and key value pair is exported when key value matches
The checking result answered;Otherwise next judgement for searching entry in the RAM data read.
The system that mode shares RAM is searched based on HASH the invention also discloses a kind of, comprising:
The wide computing module of RAM bit is used to obtain the entry number and entry bit wide of type of respectively tabling look-up, according to type of respectively tabling look-up
Entry bit wide, shared RAM bit needed for determining is wide, shares that RAM bit is wide to be not less than entry bit wide maximum value;
RAM depth calculation module, it is wide according to shared RAM bit and respectively table look-up the entry number of type, calculate class of respectively tabling look-up
The corresponding RAM depth of type, shared RAM depth needed for determining;
RAM configuration module is used to configure base address of the type in shared RAM of respectively tabling look-up, and the base address configured is
Any address of shared RAM;Configuration is respectively tabled look-up the taken HASH result length of type, the corresponding binary system of taken HASH result length
Numerical value maximum value is not less than the corresponding RAM depth of type of respectively tabling look-up;Type pair of respectively tabling look-up is determined according to taken HASH result length
The size for the database in shared RAM answered.
Based on the above technical solution, the RAM depth calculation module is specifically used for:
Shared RAM bit is wide respectively divided by the entry bit wide for type of respectively tabling look-up, and be rounded downwards, type pair of respectively being tabled look-up
The number of tabling look-up parallel answered;
By the entry number for type of respectively tabling look-up, divided by corresponding number of tabling look-up parallel, and rounds up, obtain according to binary system
The corresponding RAM depth of type of respectively tabling look-up;
Shared RAM depth needed for determining, shares the accumulated value that RAM depth is not less than each corresponding RAM depth of tabling look-up.
Based on the above technical solution, which further includes searching entry configuration module, is used for:
When carrying out the lookup entry configuration in shared RAM, HASH is carried out according to the key value of lookup entry to be configured
It calculates, the taken HASH result length for type of being tabled look-up according to belonging to the lookup entry carries out value to calculated result, in addition looking into
The base address for looking for type of tabling look-up belonging to entry, the address ram as entry to be written in shared RAM;By lookup item to be configured
Purpose key value and corresponding checking result, are configured to the address ram of entry to be written in shared RAM, and configure the lookup
The entry of entry is effectively identified as effectively.
Based on the above technical solution, the entry configuration module by the key value of lookup entry to be configured and
Checking result is configured to the address ram of entry to be written in shared RAM, and configures entry and be effectively identified as effectively, specifically includes
Following procedure:
The corresponding RAM data of address ram for reading entry to be written, to the lookup entry in the RAM data of reading from a left side
To the right side successively analyze, judge in RAM data search entry it is whether effective, if effectively, check key value whether with search entry
In it is consistent, if unanimously, updating and searching the corresponding checking result of entry;If inconsistent, the lookup entry is skipped, is continued checking
Next lookup entry in the RAM data of reading;If invalid, by the key value of lookup entry to be configured and knot of tabling look-up
Fruit is configured to the lookup entry in shared RAM, and the entry for configuring the lookup entry in shared RAM is effectively identified as effectively.
Based on the above technical solution, which further includes table lookup function module and calculating module for reading and writing;
The table lookup function module is used for: when receiving search request, extract search request key value export to
Calculate module for reading and writing;
The calculating module for reading and writing is used for: carrying out HASH calculating according to the key value of search request, again to calculated result
The taken HASH result length for type of being tabled look-up according to belonging to the lookup entry of configuration carries out value, in addition the lookup entry of configuration
Base address reads corresponding RAM data and exports to table lookup function module as being read out the address ram of entry in shared RAM;
The table lookup function module is also used to: lookup entries all in the RAM data of reading from left to right successively analyzed,
When the entry for reading corresponding lookup entry is effectively identified as effective, by the lookup item of the key value of search request and reading
Key value in mesh is compared, output key value corresponding checking result when key value matches;Otherwise it is read
RAM data in it is next search entry judgement.
Compared with the prior art, the advantages of the present invention are as follows:
The method and system that mode shares RAM are searched based on HASH this paper presents a kind of, by each type of tabling look-up
Base address and taken HASH result length are configured, and rationally determines the width of RAM according to the entry bit wide for type of respectively tabling look-up, is made
The database of multiple types of tabling look-up can coexist in one piece or one group of RAM.The present invention is most economical to be utilized RAM resource,
While supporting longest entry, a gram ability for HASH conflict is provided for non-longest entry.
The present invention can be by changing the base address and taken HASH result length flexibly adjustment number that type is configured of tabling look-up
According to the size in library, make design that can be suitble to multiple application scenarios.
Detailed description of the invention
Fig. 1 is to search the flow diagram that mode shares the method for RAM based on HASH in the embodiment of the present invention;
Fig. 2 is the data structure for searching the lookup entry of method of the shared RAM of mode in the embodiment of the present invention based on HASH
Schematic diagram;
Fig. 3 is to be shown in the embodiment of the present invention based on the HASH structure for searching database in the RAM for the method that mode shares RAM
It is intended to;
Fig. 4 is to search the structural schematic diagram that mode shares the system of RAM based on HASH in the embodiment of the present invention;
Fig. 5 is to search the entry configuration module of the system of the shared RAM of mode, function of tabling look-up based on HASH in the embodiment of the present invention
It can module, the operation principle schematic diagram of calculating module for reading and writing.
Specific embodiment
Invention is further described in detail with reference to the accompanying drawings and embodiments.
Embodiment 1:
It is shown in Figure 1, the embodiment of the present invention provide it is a kind of based on HASH search mode share RAM method, including with
Lower step:
S1 obtains the entry number and entry bit wide of the lookup entry that type includes of respectively tabling look-up, according to the item for type of respectively tabling look-up
Mesh bit wide, shared RAM bit needed for determining is wide, and it is wide not less than entry bit wide maximum value to share RAM bit;Type of each tabling look-up includes more
A lookup entry, each lookup entry includes that entry effectively identifies, key value and checking result.
S2, it is wide according to the shared RAM bit determined in S1 and respectively table look-up the entry number of type, calculate type pair of respectively tabling look-up
The RAM depth answered, shared RAM depth needed for determining;
S3, configuration are respectively tabled look-up base address of the type in shared RAM, the base address configured be share RAM anyly
Location;Configuration is respectively tabled look-up the taken HASH result length of type, and the corresponding binary numeral maximum value of taken HASH result length is not small
In the corresponding RAM depth of type of respectively tabling look-up;It is determined in the corresponding shared RAM of type that respectively tables look-up according to taken HASH result length
The size of database.
Step S2 specifically includes the following steps:
Shared RAM bit is wide respectively divided by the entry bit wide for type of respectively tabling look-up, and be rounded downwards, type pair of respectively being tabled look-up
The number of tabling look-up parallel answered;For example, shared RAM bit width is 10, entry bit wide is 3, then 10 ÷ 3, is 3 after being rounded downwards.
By the entry number for type of respectively tabling look-up, divided by corresponding number of tabling look-up parallel, and rounds up, obtain according to binary system
The corresponding RAM depth of type of respectively tabling look-up;For example, calculating entry number is 128, and number 3 of tabling look-up parallel, then 128 ÷ 3, according to two
System round up 64.
Shared RAM depth needed for determining, shares the accumulated value that RAM depth is not less than each corresponding RAM depth of tabling look-up.
The present invention is by configuring base address and taken HASH result length to each table look-up, and according to type of respectively tabling look-up
Entry bit wide rationally determines the width of RAM, coexists in multiple databases in one piece or one group of RAM.The present invention is most economical
RAM resource is utilized, while supporting longest entry, provide an ability for gram HASH conflict for non-longest entry.
Embodiment 2:
On the basis of embodiment 1, it is assumed that 4 kinds of types of tabling look-up: the item of first type of tabling look-up are needed in certain design requirement
Mesh bit wide is 50, entry number 256;The entry bit wide of second type of tabling look-up is 65, entry number 2048, a type of tabling look-up of third
Entry bit wide is 80, entry number 4096, and the entry bit wide of the 4th type of tabling look-up is 180;Entry number 512.
Step S1 specifically includes following procedure:
1, the method for the number that need to be compared according to the determining wide and each lookup of RAM bit calculates:
Shared RAM bit width is 200 bits needed for setting, according to shared RAM bit width continues that following table is calculated:
It respectively tables look-up type | Table look-up number m parallel | Calculate required RAM depth |
1 | 4 | 64 (256/4=64) |
2 | 3 | 1024 (2048/3=683 takes 256 multiple to obtain 1024) |
3 | 2 | 2048 (4096/2=2048) |
4 | 1 | 512 (512/1=512) |
The cumulative corresponding RAM depth of type of respectively tabling look-up show that shared RAM minimum-depth is 4096, in order to reduce HASH punching
Prominent, shared RAM needed for being arranged is 8192.
2, the base address and taken HASH result length that configuration is respectively tabled look-up, such as following table
For the conflict for avoiding different types of tabling look-up, the table look-up base address of types of configuration difference need to be arranged difference and table look-up type pair
The shared address ram answered does not cover mutually.
As a preferred option, the base address for being initially configured the first type of tabling look-up from 0, the base of second of type of tabling look-up
Location is since the end of the corresponding shared address ram of the database of the first type of tabling look-up, the base address of the third type of tabling look-up
Since the end of the corresponding shared address ram of the database of second of type of tabling look-up, and so on, avoid the sky of shared RAM
Between waste.
3, Fig. 3 is seen with the database postponed
4, assume to need to change entry under some application scenarios, the 3rd time, 4 lookup do not need, lookup entry for the first time
It is changed to 16k, the 2nd lookup is changed to 8k, then each base address and the configuration of taken HASH result length are as follows:
It respectively tables look-up type | Base address | Taken HASH result length | Practical open ended entry capacity |
1 | 0 | 12 | 16k(212* 4=16384) |
2 | 4096 | 12 | 12k(212* 3=12288) |
3 | 8192 | 0 | 0 |
4 | 8192 | 0 | 0 |
Embodiment 3:
On the basis of embodiment 1, further include step S4 after step S3:
When carrying out the lookup entry configuration in shared RAM, HASH is carried out according to the key value of lookup entry to be configured
It calculates, the taken HASH result length for type of being tabled look-up according to belonging to the lookup entry carries out value to calculated result, in addition looking into
The base address for looking for type of tabling look-up belonging to entry, the address ram as entry to be written in shared RAM;By lookup item to be configured
Purpose key value and corresponding checking result, are configured to the address ram of entry to be written in shared RAM, and configure the lookup
The entry of entry is effectively identified as effectively.
It is described that the key value of lookup entry to be configured and checking result are configured to entry to be written in shared RAM
Address ram, and configure entry and be effectively identified as effectively, specifically include following procedure:
The corresponding RAM data of address ram for reading entry to be written, to the lookup entry in the RAM data of reading from a left side
To the right side successively analyze, judge in RAM data search entry it is whether effective, if effectively, check key value whether with search entry
In it is consistent, if unanimously, updating and searching the corresponding checking result of entry;If inconsistent, the lookup entry is skipped, is continued checking
Next lookup entry in the RAM data of reading;If invalid, by the key value of lookup entry to be configured and knot of tabling look-up
Fruit is configured to the lookup entry in shared RAM, and the entry for configuring the lookup entry in shared RAM is effectively identified as effectively.
The present invention can be by changing the base address for tabling look-up configured and taken HASH result length flexibly adjustment database
Size, make design can be suitble to multiple application scenarios.
Further include step S5 after step S4:
When receiving search request, HASH calculating is carried out according to the key value of search request, to calculated result further according to matching
The taken HASH result length for type of tabling look-up belonging to the lookup entry set carries out value, in addition tabling look-up belonging to the lookup entry of configuration
The base address of type reads corresponding RAM data as being read out the address ram of entry in shared RAM;To the RAM of reading
All lookup entries are from left to right successively analyzed in data, and when the entry for searching entry is effectively identified as effective, lookup is asked
Key value in the key value asked and the lookup entry read is compared, and key value pair is exported when key value matches
The checking result answered;Otherwise next judgement for searching entry in the RAM data read.
Embodiment 4:
It is shown in Figure 4 present embodiment discloses a kind of system for searching the shared RAM of mode based on HASH, comprising:
The wide computing module of RAM bit is used to obtain the entry number and entry bit wide of the lookup entry that type includes of respectively tabling look-up,
According to the entry bit wide for type of respectively tabling look-up, shared RAM bit needed for determining is wide, and it is wide not less than entry bit wide maximum value to share RAM bit;
RAM depth calculation module, it is wide according to shared RAM bit and respectively table look-up the entry number of type, calculate class of respectively tabling look-up
The corresponding RAM depth of type, shared RAM depth needed for determining;
RAM configuration module is used to configure base address of the type in shared RAM of respectively tabling look-up, and the base address configured is
Any address of shared RAM;Configuration is respectively tabled look-up the taken HASH result length of type, the corresponding binary system of taken HASH result length
Numerical value maximum value is not less than the corresponding RAM depth of type of respectively tabling look-up;Type pair of respectively tabling look-up is determined according to taken HASH result length
The size for the database in shared RAM answered.
RAM depth calculation module is specifically used for:
Shared RAM bit is wide respectively divided by the entry bit wide for type of respectively tabling look-up, and be rounded downwards, type pair of respectively being tabled look-up
The number of tabling look-up parallel answered;For example, shared RAM bit width is 10, entry bit wide is 3, then 10 ÷ 3, is 3 after being rounded downwards.
By the entry number for type of respectively tabling look-up, divided by corresponding number of tabling look-up parallel, and rounds up, obtain according to binary system
The corresponding RAM depth of type of respectively tabling look-up;For example, calculating entry number is 128, and number 3 of tabling look-up parallel, then 128 ÷ 3, according to two
System round up 64.
Shared RAM depth needed for determining, shares the accumulated value that RAM depth is not less than each corresponding RAM depth of tabling look-up.
Embodiment 5:
On the basis of embodiment 4, which further includes searching entry configuration module, is used for:
When carrying out the lookup entry configuration in shared RAM, HASH is carried out according to the key value of lookup entry to be configured
It calculates, the taken HASH result length for type of being tabled look-up according to belonging to the lookup entry carries out value to calculated result, in addition looking into
The base address for looking for type of tabling look-up belonging to entry, the address ram as entry to be written in shared RAM;By lookup item to be configured
Purpose key value and corresponding checking result, are configured to the address ram of entry to be written in shared RAM, and configure the lookup
The entry of entry is effectively identified as effectively.
The key value of lookup entry to be configured and checking result are configured in shared RAM by the entry configuration module
The address ram of entry to be written, and configure entry and be effectively identified as effectively, specifically include following procedure:
The corresponding RAM data of address ram for reading entry to be written, to the lookup entry in the RAM data of reading from a left side
To the right side successively analyze, judge in RAM data search entry it is whether effective, if effectively, check key value whether with search entry
In it is consistent, if unanimously, updating and searching the corresponding checking result of entry;If inconsistent, the lookup entry is skipped, is continued checking
Next lookup entry in the RAM data of reading;If invalid, by the key value of lookup entry to be configured and knot of tabling look-up
Fruit is configured to the lookup entry in shared RAM, and the entry for configuring the lookup entry in shared RAM is effectively identified as effectively.
The system further includes table lookup function module and calculating module for reading and writing;
Table lookup function module is used for: when receiving search request, the key value for extracting search request is exported to calculating
Module for reading and writing;
Calculate module for reading and writing be used for: according to the key value of search request carry out HASH calculating, to calculated result further according to
The taken HASH result length for type of tabling look-up belonging to the lookup entry of configuration carries out value, in addition the base of the lookup entry of configuration
Location reads corresponding RAM data and exports to table lookup function module as being read out the address ram of entry in shared RAM;
Table lookup function module is also used to: from left to right successively being analyzed lookup entries all in the RAM data of reading, is worked as reading
It, will be in the key value of search request and the lookup entry of reading when the corresponding entry for searching entry is effectively identified as effective out
Key value be compared, output key value corresponding checking result when key value matches;Otherwise the RAM read
Next judgement for searching entry in data.
Embodiment 6:
It is shown in Figure 5 on the basis of embodiment 4, mode is searched based on HASH present embodiment discloses one kind and is shared
The device of RAM, the device are made of 4 parts: several table lookup function modules, calculate module for reading and writing, entry configuration module and RAM.
The input of the present apparatus is packet information, and output is checking result information.
The function of table lookup function module is: forming search key value using the packet information of input, and asks with lookup
It asks and is output to calculating module for reading and writing together, and progress is effectively identified according to the search key and entry of being sent into table lookup function module
It compares, when the entry of input effectively identifies effective, the lookup entry in RAM is successively compared;When searching, entry is effective
And when search key matching, checking result is exported.The data structure of lookup entry in RAM is shown in Figure 2, each tables look-up
In the corresponding database of type comprising m lookup entry or also several vacant bits, each lookup entry includes that entry has
Criterion is known, key value and checking result, and the entry number that the different corresponding databases of type of tabling look-up include is different, because looking into every time
The key value looked for is different with the bit wide of checking result.
Calculating module for reading and writing includes that matching for taken HASH result length is searched in the configuration of the base address of each lookup and each time
It sets, the corresponding binary numeral maximum value of the taken HASH result length of type of respectively tabling look-up is looked into parallel multiplied by type of respectively tabling look-up is corresponding
Looking for number is exactly the Database size that this time is tabled look-up.
Calculating module for reading and writing, there are two functions, and a function is successively to respond the search request of each table lookup function module, root
HASH calculating is carried out according to the key value of each lookup, then according to each taken HASH result length for searching configuration, HASH is taken to count
The corresponding digit of result is calculated, the corresponding base address Configuration Values of the lookup are then added, last result is carried out as address ram
RAM is read, and the RAM data of reading is sent to each locating function block, and export entry and be effectively identified to all table lookup function moulds
Block.Another function is in response to read and write access of the entry configuration module to RAM, for being managed, matching to database each in RAM
It sets.
The function of entry configuration module be RAM is written and read configuration and to configuration each time lookup base address with taken
HASH result length.
The present invention is not limited to the above-described embodiments, for those skilled in the art, is not departing from
Under the premise of the principle of the invention, several improvements and modifications can also be made, these improvements and modifications are also considered as protection of the invention
Within the scope of.The content being not described in detail in this specification belongs to the prior art well known to professional and technical personnel in the field.
Claims (10)
1. a kind of search the method that mode shares RAM based on HASH, which comprises the following steps:
S1 obtains the entry number and entry bit wide of the lookup entry that type includes of respectively tabling look-up, according to the entry position for type of respectively tabling look-up
Width, shared RAM bit needed for determining is wide, and it is wide not less than entry bit wide maximum value to share RAM bit;
S2, it is wide according to the shared RAM bit determined in S1 and respectively table look-up the entry number of type, it is corresponding to calculate type of respectively tabling look-up
RAM depth, shared RAM depth needed for determining;
S3, configures base address of the type in shared RAM of respectively tabling look-up, and the base address configured is any address of shared RAM;Match
Set the taken HASH result length of type of respectively tabling look-up, the corresponding binary numeral maximum value of taken HASH result length is not less than respectively looking into
The corresponding RAM depth of table type;The database in the corresponding shared RAM of type that respectively tables look-up is determined according to taken HASH result length
Size.
2. a kind of method for searching the shared RAM of mode based on HASH as described in claim 1, it is characterised in that: step S2 tool
Body the following steps are included:
Shared RAM bit is wide respectively divided by the entry bit wide for type of respectively tabling look-up, and be rounded downwards, type of respectively being tabled look-up is corresponding
Parallel number of tabling look-up;
By the entry number for type of respectively tabling look-up, divided by corresponding number of tabling look-up parallel, and rounds up according to binary system, respectively looked into
The corresponding RAM depth of table type;
Shared RAM depth needed for determining, shares the accumulated value that RAM depth is not less than each corresponding RAM depth of tabling look-up.
A kind of the method that mode shares RAM is searched based on HASH 3. as described in claim 1, it is characterised in that: step S3 it
After further include step S4:
When carrying out the lookup entry configuration in shared RAM, HASH calculating is carried out according to the key value of lookup entry to be configured,
The taken HASH result length for type of being tabled look-up according to belonging to the lookup entry carries out value to calculated result, in addition searching entry
The base address of affiliated type of tabling look-up, the address ram as entry to be written in shared RAM;By the pass of lookup entry to be configured
Key word value and corresponding checking result, are configured to the address ram of entry to be written in shared RAM, and configure the lookup entry
Entry is effectively identified as effectively.
A kind of the method that mode shares RAM is searched based on HASH 4. as claimed in claim 3, it is characterised in that: it is described will be to
The key value and checking result of the lookup entry of configuration are configured to the address ram of entry to be written in shared RAM, and configure item
Mesh is effectively identified as effectively, specifically includes following procedure:
The corresponding RAM data of address ram of entry to be written is read, from left to right to the lookup entry in the RAM data of reading
Successively analyze, judge in RAM data search entry it is whether effective, if effectively, check key value whether with search entry in
Unanimously, if unanimously, updating and searching the corresponding checking result of entry;If inconsistent, the lookup entry is skipped, reading is continued checking
RAM data in next lookup entry;If invalid, the key value of lookup entry to be configured and checking result are matched
The lookup entry in shared RAM is set, and the entry for configuring the lookup entry in shared RAM is effectively identified as effectively.
A kind of the method that mode shares RAM is searched based on HASH 5. as claimed in claim 3, it is characterised in that: step S4 it
After further include step S5:
When receiving search request, HASH calculating is carried out according to the key value of search request, to calculated result further according to configuration
The taken HASH result length for searching type of tabling look-up belonging to entry carries out value, in addition type of tabling look-up belonging to the lookup entry of configuration
Base address as being read out the address ram of entry in shared RAM, and read corresponding RAM data;To the RAM data of reading
In all lookup entries from left to right successively analyze, when search entry entry be effectively identified as effective when, by search request
Key value in key value and the lookup entry read is compared, and output key value is corresponding when key value matches
Checking result;Otherwise next judgement for searching entry in the RAM data read.
6. a kind of search the system that mode shares RAM based on HASH characterized by comprising
The wide computing module of RAM bit is used to obtain the entry number and entry bit wide of the lookup entry that type includes of respectively tabling look-up, according to
The entry bit wide for type of respectively tabling look-up, shared RAM bit needed for determining is wide, and it is wide not less than entry bit wide maximum value to share RAM bit;
RAM depth calculation module, it is wide according to shared RAM bit and respectively table look-up the entry number of type, calculate type pair of respectively tabling look-up
The RAM depth answered, shared RAM depth needed for determining;
RAM configuration module is used to configure base address of the type in shared RAM of respectively tabling look-up, and the base address configured is shared
Any address of RAM;Configuration is respectively tabled look-up the taken HASH result length of type, the corresponding binary numeral of taken HASH result length
Maximum value is not less than the corresponding RAM depth of type of respectively tabling look-up;Determine that type of respectively tabling look-up is corresponding according to taken HASH result length
The size of database in shared RAM.
7. a kind of system for searching the shared RAM of mode based on HASH as claimed in claim 6, it is characterised in that: the RAM is deep
Degree computing module is specifically used for:
Shared RAM bit is wide respectively divided by the entry bit wide for type of respectively tabling look-up, and be rounded downwards, type of respectively being tabled look-up is corresponding
Parallel number of tabling look-up;
By the entry number for type of respectively tabling look-up, divided by corresponding number of tabling look-up parallel, and rounds up according to binary system, respectively looked into
The corresponding RAM depth of table type;
Shared RAM depth needed for determining, shares the accumulated value that RAM depth is not less than each corresponding RAM depth of tabling look-up.
8. a kind of system for searching the shared RAM of mode based on HASH as claimed in claim 6, it is characterised in that: the system is also
Including lookup entry configuration module, it is used for:
When carrying out the lookup entry configuration in shared RAM, HASH calculating is carried out according to the key value of lookup entry to be configured,
The taken HASH result length for type of being tabled look-up according to belonging to the lookup entry carries out value to calculated result, in addition searching entry
The base address of affiliated type of tabling look-up, the address ram as entry to be written in shared RAM;By the pass of lookup entry to be configured
Key word value and corresponding checking result, are configured to the address ram of entry to be written in shared RAM, and configure the lookup entry
Entry is effectively identified as effectively.
9. a kind of system for searching the shared RAM of mode based on HASH as claimed in claim 8, it is characterised in that: the entry
The key value of lookup entry to be configured and checking result are configured to the RAM of entry to be written in shared RAM by configuration module
Address, and configure entry and be effectively identified as effectively, specifically include following procedure:
The corresponding RAM data of address ram of entry to be written is read, from left to right to the lookup entry in the RAM data of reading
Successively analyze, judge in RAM data search entry it is whether effective, if effectively, check key value whether with search entry in
Unanimously, if unanimously, updating and searching the corresponding checking result of entry;If inconsistent, the lookup entry is skipped, reading is continued checking
RAM data in next lookup entry;If invalid, the key value of lookup entry to be configured and checking result are matched
The lookup entry in shared RAM is set, and the entry for configuring the lookup entry in shared RAM is effectively identified as effectively.
10. a kind of system for searching the shared RAM of mode based on HASH as claimed in claim 8, it is characterised in that: the system is also
Including table lookup function module and calculate module for reading and writing;
The table lookup function module is used for: when receiving search request, the key value for extracting search request is exported to calculating
Module for reading and writing;
The calculating module for reading and writing is used for: according to the key value of search request carry out HASH calculating, to calculated result further according to
The taken HASH result length for type of tabling look-up belonging to the lookup entry of configuration carries out value, in addition the base of the lookup entry of configuration
Location reads corresponding RAM data and exports to table lookup function module as being read out the address ram of entry in shared RAM;
The table lookup function module is also used to: from left to right successively being analyzed lookup entries all in the RAM data of reading, is worked as reading
It, will be in the key value of search request and the lookup entry of reading when the corresponding entry for searching entry is effectively identified as effective out
Key value be compared, output key value corresponding checking result when key value matches;Otherwise the RAM read
Next judgement for searching entry in data.
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 true CN109039911A (en) | 2018-12-18 |
CN109039911B 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) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114615196A (en) * | 2022-03-24 | 2022-06-10 | 北京左江科技股份有限公司 | High-speed accurate matching search method |
CN117478626A (en) * | 2023-12-27 | 2024-01-30 | 天津光电聚能通信股份有限公司 | Quick matching searching system, method, equipment and medium based on group connection cache |
Citations (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1538661A (en) * | 2003-04-14 | 2004-10-20 | 华为技术有限公司 | Method of realizing HASH position width compression |
CN1787477A (en) * | 2004-12-09 | 2006-06-14 | 北京三星通信技术研究有限公司 | Method for searching IPv6 routing table |
CN1909518A (en) * | 2006-08-29 | 2007-02-07 | 华为技术有限公司 | Route method and equipment |
CN101621502A (en) * | 2008-06-30 | 2010-01-06 | 华为技术有限公司 | Method and device for storing and searching routing table |
CN101827137A (en) * | 2010-04-13 | 2010-09-08 | 西安邮电学院 | Hash table-based and extended memory-based high-performance IPv6 address searching method |
CN102364463A (en) * | 2011-09-19 | 2012-02-29 | 浪潮电子信息产业股份有限公司 | Hash-based method for searching CAM (central address memory) |
CN104809179A (en) * | 2015-04-16 | 2015-07-29 | 华为技术有限公司 | Device and method for accessing Hash table |
CN104951494A (en) * | 2013-12-27 | 2015-09-30 | 凯为公司 | Method and system for reconfigurable parallel lookups using multiple shared memories |
CN105224532A (en) * | 2014-05-28 | 2016-01-06 | 腾讯科技(深圳)有限公司 | Data processing method and device |
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) |
US20160170649A1 (en) * | 2014-12-16 | 2016-06-16 | Samsung Electronics Co., Ltd. | Unified object interface for memory and storage system |
CN106446099A (en) * | 2016-09-13 | 2017-02-22 | 国家超级计算深圳中心(深圳云计算中心) | Distributed cloud storage method and system and uploading and downloading method thereof |
-
2018
- 2018-07-27 CN CN201810842538.5A patent/CN109039911B/en active Active
Patent Citations (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1538661A (en) * | 2003-04-14 | 2004-10-20 | 华为技术有限公司 | Method of realizing HASH position width compression |
CN1787477A (en) * | 2004-12-09 | 2006-06-14 | 北京三星通信技术研究有限公司 | Method for searching IPv6 routing table |
CN1909518A (en) * | 2006-08-29 | 2007-02-07 | 华为技术有限公司 | Route method and equipment |
CN101621502A (en) * | 2008-06-30 | 2010-01-06 | 华为技术有限公司 | Method and device for storing and searching routing table |
CN101827137A (en) * | 2010-04-13 | 2010-09-08 | 西安邮电学院 | Hash table-based and extended memory-based high-performance IPv6 address searching method |
CN102364463A (en) * | 2011-09-19 | 2012-02-29 | 浪潮电子信息产业股份有限公司 | Hash-based method for searching CAM (central address memory) |
CN104951494A (en) * | 2013-12-27 | 2015-09-30 | 凯为公司 | Method and system for reconfigurable parallel lookups using multiple shared memories |
CN105224532A (en) * | 2014-05-28 | 2016-01-06 | 腾讯科技(深圳)有限公司 | Data processing method and device |
US20160170649A1 (en) * | 2014-12-16 | 2016-06-16 | Samsung Electronics Co., Ltd. | Unified object interface for memory and storage system |
CN104809179A (en) * | 2015-04-16 | 2015-07-29 | 华为技术有限公司 | 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 |
Non-Patent Citations (1)
Title |
---|
刘鹏: "高性能路由器中高速转发查表算法研究与实现", 《中国优秀硕士学位论文全文数据库》 * |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114615196A (en) * | 2022-03-24 | 2022-06-10 | 北京左江科技股份有限公司 | High-speed accurate matching search method |
CN117478626A (en) * | 2023-12-27 | 2024-01-30 | 天津光电聚能通信股份有限公司 | Quick matching searching system, method, equipment and medium based on group connection cache |
CN117478626B (en) * | 2023-12-27 | 2024-04-05 | 天津光电聚能通信股份有限公司 | Quick matching searching system, method, equipment and medium based on group connection cache |
Also Published As
Publication number | Publication date |
---|---|
CN109039911B (en) | 2021-02-26 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11811660B2 (en) | Flow classification apparatus, methods, and systems | |
US10496680B2 (en) | High-performance bloom filter array | |
US9984144B2 (en) | Efficient lookup of TCAM-like rules in RAM | |
CN101309216B (en) | IP packet classification method and apparatus | |
CN105122745B (en) | Efficient longest prefix match technology for the network equipment | |
US10333845B2 (en) | Forwarding data packets | |
CN113542125B (en) | Method and device for forwarding message based on integrated flow table | |
CN110912826B (en) | Method and device for expanding IPFIX table items by using ACL | |
WO2017032238A1 (en) | Route management | |
US20140105215A1 (en) | Converting addresses for nodes of a data center network into compact identifiers for determining flow keys for received data packets | |
US11652744B1 (en) | Multi-stage prefix matching enhancements | |
CN109039911A (en) | It is a kind of to search the method and system that mode shares RAM based on HASH | |
CN111988231A (en) | Mask five-tuple rule matching method and device | |
CN104025520A (en) | Lookup table creation method and query method, and controller, forwarding device and system therefor | |
CN107248939A (en) | Network flow high-speed associative method based on hash memories | |
CN104253754A (en) | ACL (access control list) fast matching method and equipment | |
CN112187636B (en) | ECMP route storage method and device | |
CN104424316A (en) | Data storage method, data searching method, related device and system | |
CN111131049B (en) | Method and device for processing routing table entry | |
CN105743678A (en) | Method and apparatus for managing table space of ternary content addressable memory (TCAM) | |
CN115834478A (en) | Method for realizing PBR high-speed forwarding by using TCAM | |
CN110704419A (en) | Data structure, data indexing method, device and equipment, and storage medium | |
CN105634999A (en) | Aging method and device for medium access control address | |
CN101822027A (en) | Method and apparatus for efficient cam lookup for internet protocol addresses | |
JP2008085886A (en) | Packet processing apparatus, packet processing method, and packet processing program |
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 |