CN108664518B - Method and device for realizing table look-up processing - Google Patents
- ️Tue Dec 07 2021
CN108664518B - Method and device for realizing table look-up processing - Google Patents
Method and device for realizing table look-up processing Download PDFInfo
-
Publication number
- CN108664518B CN108664518B CN201710210525.1A CN201710210525A CN108664518B CN 108664518 B CN108664518 B CN 108664518B CN 201710210525 A CN201710210525 A CN 201710210525A CN 108664518 B CN108664518 B CN 108664518B Authority
- CN
- China Prior art keywords
- entry
- crc
- key value
- result
- unit Prior art date
- 2017-03-31 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
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/08—Error detection or correction by redundancy in data representation, e.g. by using checking codes
- G06F11/10—Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's
- G06F11/1004—Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's to protect a block of data words, e.g. CRC or checksum
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/08—Error detection or correction by redundancy in data representation, e.g. by using checking codes
- G06F11/10—Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Quality & Reliability (AREA)
- Computer Security & Cryptography (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
一种实现查表处理方法及装置,包括:根据条目的键(KEY)值,通过循环冗余校验(CRC)多项式计算确定条目是否存在;确定条目存在时,根据CRC多项式的计算结果确定匹配表地址;根据确定的匹配表地址对匹配表进行查表后返回的结果,确定片外哈希(HASH)查表地址;根据确定的片外HASH查表地址进行查表获得哈希查表返回KEY值,根据条目的KEY值和哈希查表返回KEY值是否一致进行查表处理。本发明实施例方法减少了需要查表的条目,降低了对管脚资源、带宽资源的占用、避免了对芯片处理性能的影响。
A method and device for implementing a table lookup processing, comprising: determining whether an entry exists by calculating a cyclic redundancy check (CRC) polynomial according to a key (KEY) value of the entry; when determining that the entry exists, determining a match according to the calculation result of the CRC polynomial Table address; according to the determined matching table address, the result returned after the matching table is looked up, determine the off-chip hash (HASH) table lookup address; perform the table lookup according to the determined off-chip HASH lookup table address to obtain the hash lookup table and return KEY value, according to whether the KEY value of the entry and the hash lookup table return the same KEY value to perform table lookup processing. The method of the embodiment of the present invention reduces the entries that need to be looked up in the table, reduces the occupation of pin resources and bandwidth resources, and avoids the impact on the processing performance of the chip.
Description
技术领域technical field
本文涉及但不限于数据处理技术,尤指一种实现查表处理的方法及装置。This article relates to, but is not limited to, data processing technology, especially a method and device for implementing table lookup processing.
背景技术Background technique
随着网络技术的发展,网络交换芯片需要支持的相关表项条目数量越来越多,考虑到内容寻址存储器(CAM,content addressable memory)和三态内容寻址存储器(TCAM,ternary content addressable memory)的成本因素,在表项很大的情况下,相关技术一般使用外挂双倍速率同步动态随机存储器(DDR)的方式进行查表处理。With the development of network technology, the number of related table entries that network switching chips need to support is increasing. Considering content addressable memory (CAM, content addressable memory) and ternary content addressable memory (TCAM, ternary content addressable memory) ) cost factor, in the case of large table entries, the related art generally uses an external double-rate synchronous dynamic random access memory (DDR) method to perform table lookup processing.
由于外挂DDR需要消耗较多的管脚资源,因此,外挂DDR的数量就会受到限制,DDR数量受到限制的情况下就需要减少DDR的访问次数,防止哈希(HASH)查表不中,出现需要多次查表的情况;如果多个表项共存于一组DDR内,不同的表项均需要多次查表时,还会需要占用巨大的DDR访问带宽,限制了查表的效率并堵塞芯片的处理,极大的降低芯片的处理性能。Since the external DDR needs to consume more pin resources, the number of external DDR will be limited. When the number of DDR is limited, it is necessary to reduce the number of DDR accesses to prevent the hash (HASH) lookup table from being missed and appearing When multiple table lookups are required; if multiple table entries coexist in a set of DDR, and different table entries require multiple table lookups, huge DDR access bandwidth will also be occupied, limiting the efficiency of table lookup and blocking The processing of the chip greatly reduces the processing performance of the chip.
综上,对于表项条目数量较多的情况,进行查表时存在占用过多的管脚资源、带宽资源、影响芯片的处理性能等问题。To sum up, in the case of a large number of table entries, there are problems such as occupying too many pin resources, bandwidth resources, and affecting the processing performance of the chip when performing a table lookup.
发明内容SUMMARY OF THE INVENTION
以下是对本文详细描述的主题的概述。本概述并非是为了限制权利要求的保护范围。The following is an overview of the topics detailed in this article. This summary is not intended to limit the scope of protection of the claims.
本发明实施例提供一种实现查表处理的方法及装置,能够降低了对管脚资源、带宽资源的占用、避免对芯片处理性能的影响。Embodiments of the present invention provide a method and device for implementing table lookup processing, which can reduce the occupation of pin resources and bandwidth resources, and avoid impact on chip processing performance.
本发明实施例提供了一种实现查表处理的方法,包括:An embodiment of the present invention provides a method for implementing table lookup processing, including:
根据条目的键KEY值,通过循环冗余校验CRC多项式计算确定条目是否存在;According to the KEY value of the entry, determine whether the entry exists through the CRC polynomial calculation of the cyclic redundancy check;
确定条目存在时,根据CRC多项式的计算结果确定匹配表地址;When it is determined that the entry exists, the address of the matching table is determined according to the calculation result of the CRC polynomial;
根据确定的匹配表地址对匹配表进行查表后返回的结果,确定片外哈希HASH查表地址;According to the determined matching table address, the result returned after the matching table is looked up, determine the off-chip hash HASH lookup table address;
根据确定的片外HASH查表地址进行查表获得哈希查表返回KEY值,根据条目的KEY值和哈希查表返回KEY值是否一致进行查表处理。Perform table lookup according to the determined off-chip HASH table lookup address to obtain the KEY value returned by the hash lookup table, and perform table lookup processing according to whether the KEY value of the entry and the returned KEY value of the hash lookup table are consistent.
可选的,所述确定条目是否存在包括:Optionally, the determining whether the entry exists includes:
将所述条目的KEY值进行第一预设次所述CRC多项式计算;The KEY value of the entry is calculated for the first preset time by the CRC polynomial;
使用第0个所述CRC多项式的计算结果作为所述匹配表的地址进行查表;Use the calculation result of the 0th described CRC polynomial as the address of the matching table to look up the table;
将所述匹配表查表返回的结果与除第0个CRC外的其他的CRC多项式的计算结果进行匹配;Matching the result returned by the matching table look-up table with the calculation results of other CRC polynomials except the 0th CRC;
所述匹配表查表返回的结果与除第0个CRC外的其他的CRC多项式的计算结果匹配时,确定所述条目存在。When the result returned by the matching table lookup table matches the calculation result of other CRC polynomials except the 0th CRC, it is determined that the entry exists.
可选的,所述根据条目的KEY值和哈希查表返回KEY值是否一致进行查表处理包括:Optionally, performing the table lookup process according to whether the KEY value of the entry and the hash lookup table return KEY value are consistent includes:
所述条目的KEY值和所述哈希查表返回KEY值一致,返回所述条目;所述条目的KEY值和所述哈希查表返回KEY值不一致,确定所述条目未命中。If the KEY value of the entry is consistent with the KEY value returned by the hash lookup table, the entry is returned; the KEY value of the entry is inconsistent with the KEY value returned by the hash lookup table, and it is determined that the entry is not hit.
可选的,所述方法还包括:Optionally, the method further includes:
所述匹配表查表返回的结果与除第0个CRC外的其他的所述CRC多项式的计算结果不匹配时,将所述条目上送到中央处理器CPU进行处理,或将所述条目根据预设规则进行处理。When the result returned by the matching table lookup table does not match the calculation result of the CRC polynomial except the 0th CRC, the entry is sent to the central processing unit CPU for processing, or the entry is Preset rules for processing.
可选的,所述通过循环冗余校验CRC多项式计算确定条目是否存在之前,所述方法还包括:Optionally, before determining whether the entry exists through CRC polynomial calculation, the method further includes:
根据所述条目涉及业务设置第二预设个掩码MASK;Set a second preset mask MASK according to the service involved in the entry;
对每一个条目,分别根据报文解析结果、业务步骤、和/或应用模式选择相应类型的MASK;For each entry, select the corresponding type of MASK according to the message parsing result, service steps, and/or application mode;
根据选择的MASK,对条目中无效的KEY值进行过滤;Filter invalid KEY values in the entry according to the selected MASK;
其中,所述报文解析结果包括报文类型。Wherein, the packet parsing result includes the packet type.
可选的,所述通过循环冗余校验CRC多项式计算确定条目是否存在之前,所述方法还包括:Optionally, before determining whether the entry exists through CRC polynomial calculation, the method further includes:
配置第三预设个布鲁姆过滤器表;Configure the third preset Bloom filter table;
对所述条目的KEY值进行CRC计算,获得CRC结果;CRC calculation is performed on the KEY value of the entry to obtain a CRC result;
使用所述CRC结果查找所有布鲁姆过滤器表,得到过滤表结果;Use the CRC result to find all Bloom filter tables to obtain filter table results;
根据所述过滤表结果判断所述条目是否存在;Determine whether the entry exists according to the result of the filter table;
确定所述条目存在时,继续查表,确定所述条目不存在时,停止查表。When it is determined that the entry exists, the table lookup is continued, and when it is determined that the entry does not exist, the table lookup is stopped.
可选的,所述配置第三预设个布鲁姆过滤器表包括:Optionally, the configuring the third preset Bloom filter table includes:
根据支持冲突的条目数量配置第三预设个所述布鲁姆过滤器表。A third preset of the Bloom filter table is configured according to the number of entries supporting conflict.
另一方面,本发明实施例还提供一种实现查表处理的装置,包括:第一判断单元、匹配表地址单元、哈希地址单元、查表处理单元;其中,On the other hand, an embodiment of the present invention also provides an apparatus for implementing table lookup processing, including: a first judgment unit, a matching table address unit, a hash address unit, and a table lookup processing unit; wherein,
第一判断单元用于:根据条目的键KEY值,通过循环冗余校验CRC多项式计算确定条目是否存在;The first judgment unit is used for: according to the key KEY value of the entry, determine whether the entry exists by CRC polynomial calculation;
匹配表地址单元用于:确定条目存在时,根据CRC多项式的计算结果确定匹配表地址;The matching table address unit is used to: determine the matching table address according to the calculation result of the CRC polynomial when it is determined that the entry exists;
哈希地址单元用于:根据确定的匹配表地址对匹配表进行查表后返回的结果,确定片外哈希HASH查表地址;The hash address unit is used to: determine the off-chip hash HASH table lookup address based on the result returned after the matching table lookup table is performed according to the determined match table address;
查表处理单元用于:根据确定的片外HASH查表地址进行查表获得哈希查表返回KEY值,根据条目的KEY值和哈希查表返回KEY值是否一致进行查表处理。The table lookup processing unit is used to: perform table lookup according to the determined off-chip HASH table lookup address to obtain the hash lookup table return KEY value, and perform table lookup processing according to whether the KEY value of the entry and the hash lookup table return KEY value are consistent.
可选的,所述第一判断单元具体用于:Optionally, the first judgment unit is specifically used for:
将所述条目的KEY值进行第一预设次所述CRC多项式计算;The KEY value of the entry is calculated for the first preset time by the CRC polynomial;
使用第0个所述CRC多项式的计算结果作为所述匹配表的地址进行查表;Use the calculation result of the 0th described CRC polynomial as the address of the matching table to look up the table;
将所述匹配表查表返回的结果与除第0个CRC外的其他的CRC多项式的计算结果进行匹配;Matching the result returned by the matching table look-up table with the calculation results of other CRC polynomials except the 0th CRC;
所述匹配表查表返回的结果与除第0个CRC外的其他的CRC多项式的计算结果匹配时,确定所述条目存在。When the result returned by the matching table lookup table matches the calculation result of other CRC polynomials except the 0th CRC, it is determined that the entry exists.
可选的,所述查表处理单元具体用于:Optionally, the table lookup processing unit is specifically used for:
根据确定的片外HASH查表地址进行查表获得哈希查表返回KEY值,所述条目的KEY值和所述哈希查表返回KEY值一致,返回所述条目;所述条目的KEY值和所述哈希查表返回KEY值不一致,确定所述条目未命中。Perform a table lookup according to the determined off-chip HASH table lookup address to obtain a hash lookup table and return a KEY value, the KEY value of the entry is consistent with the returned KEY value of the hash lookup table, and return the entry; the KEY value of the entry If it is inconsistent with the KEY value returned by the hash lookup table, it is determined that the entry is not hit.
可选的,所述查表处理单元还用于:Optionally, the table lookup processing unit is also used for:
所述匹配表查表返回的结果与除第0个CRC外的其他的所述CRC多项式的计算结果不匹配时,将所述条目上送到中央处理器CPU进行处理,或将所述条目根据预设规则进行处理。When the result returned by the matching table lookup table does not match the calculation result of the CRC polynomial except the 0th CRC, the entry is sent to the central processing unit CPU for processing, or the entry is Preset rules for processing.
可选的,所述装置还包括设置掩码单元、掩码选择单元、过滤单元;其中,Optionally, the device further includes a mask setting unit, a mask selection unit, and a filtering unit; wherein,
设置掩码单元用于:根据所述条目涉及业务设置第二预设个掩码MASK;The mask setting unit is used for: setting a second preset mask MASK according to the service involved in the entry;
掩码选择单元用于:对每一个条目,分别根据报文解析结果、业务步骤、和/或应用模式选择相应类型的MASK;The mask selection unit is used to: for each entry, select a corresponding type of MASK according to the packet parsing result, service steps, and/or application mode;
过滤单元用于:根据选择的MASK,对条目中无效的KEY值进行过滤;The filtering unit is used to: filter the invalid KEY value in the entry according to the selected MASK;
其中,所述报文解析结果包括报文类型。Wherein, the packet parsing result includes the packet type.
可选的,所述装置还包括配置单元、第二计算单元、第二查表单元、第二确定单元和第二处理单元;其中,Optionally, the device further includes a configuration unit, a second calculation unit, a second table lookup unit, a second determination unit, and a second processing unit; wherein,
配置单元用于:配置第三预设个布鲁姆过滤器表;The hive is used to: configure the third preset Bloom filter table;
第二计算单元用于:对所述条目的KEY值进行CRC计算,获得CRC结果;The second calculation unit is used for: performing CRC calculation on the KEY value of the entry to obtain a CRC result;
第二查表单元用于:使用所述CRC结果查找所有布鲁姆过滤器表,得到过滤表结果;The second table lookup unit is used for: using the CRC result to look up all Bloom filter tables to obtain filter table results;
第二确定单元用于:根据所述过滤表结果判断所述条目是否存在;The second determining unit is used for: judging whether the entry exists according to the result of the filtering table;
第二处理单元用于:确定所述条目存在时,继续查表,确定所述条目不存在时,停止查表。The second processing unit is configured to: continue to look up the table when it is determined that the entry exists, and stop looking up the table when it is determined that the entry does not exist.
可选的,所述配置单元具体用于:Optionally, the configuration unit is specifically used for:
根据支持冲突的条目数量配置第三预设个所述布鲁姆过滤器表。A third preset of the Bloom filter table is configured according to the number of entries supporting conflict.
与相关技术相比,本申请技术方案包括:根据条目的键(KEY)值,通过循环冗余校验(CRC)多项式计算确定条目是否存在;确定条目存在时,根据CRC多项式的计算结果确定匹配表地址;根据确定的匹配表地址对匹配表进行查表后返回的结果,确定片外哈希(HASH)查表地址;根据确定的片外HASH查表地址进行查表获得哈希查表返回KEY值,根据条目的KEY值和哈希查表返回KEY值是否一致进行查表处理。本发明实施例方法减少了需要查表的条目,降低了对管脚资源、带宽资源的占用、避免了对芯片处理性能的影响。Compared with the related art, the technical solution of the present application includes: according to the key (KEY) value of the entry, through cyclic redundancy check (CRC) polynomial calculation to determine whether the entry exists; when it is determined that the entry exists, the matching is determined according to the calculation result of the CRC polynomial. Table address; according to the determined matching table address, the result returned after the matching table is looked up, determine the off-chip hash (HASH) table lookup address; perform the table lookup according to the determined off-chip HASH lookup table address to obtain the hash lookup table and return KEY value, according to whether the KEY value of the entry and the hash lookup table return the same KEY value to perform table lookup processing. The method of the embodiment of the present invention reduces the entries that need to be looked up in the table, reduces the occupation of pin resources and bandwidth resources, and avoids the impact on the processing performance of the chip.
本发明的其它特征和优点将在随后的说明书中阐述,并且,部分地从说明书中变得显而易见,或者通过实施本发明而了解。本发明的目的和其他优点可通过在说明书、权利要求书以及附图中所特别指出的结构来实现和获得。Other features and advantages of the present invention will be set forth in the description which follows, and in part will be apparent from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention may be realized and attained by the structure particularly pointed out in the description, claims and drawings.
附图说明Description of drawings
附图用来提供对本发明技术方案的进一步理解,并且构成说明书的一部分,与本申请的实施例一起用于解释本发明的技术方案,并不构成对本发明技术方案的限制。The accompanying drawings are used to provide a further understanding of the technical solutions of the present invention, and constitute a part of the specification. They are used to explain the technical solutions of the present invention together with the embodiments of the present application, and do not limit the technical solutions of the present invention.
图1为本发明一可选实施例实现查表处理的方法的流程图;FIG. 1 is a flowchart of a method for implementing table lookup processing according to an optional embodiment of the present invention;
图2为本发明另一可选实施例实现查表处理的方法的流程图;2 is a flowchart of a method for implementing table lookup processing according to another optional embodiment of the present invention;
图3为本发明再一可选实施例实现查表处理的方法的流程图;3 is a flowchart of a method for implementing table lookup processing according to yet another optional embodiment of the present invention;
图4为本发明实施例实现查表处理的装置的结构框图;4 is a structural block diagram of an apparatus for implementing table lookup processing according to an embodiment of the present invention;
图5为本发明应用示例的方法流程图。FIG. 5 is a flow chart of a method of an application example of the present invention.
具体实施方式Detailed ways
为使本发明的目的、技术方案和优点更加清楚明白,下文中将结合附图对本发明的实施例进行详细说明。需要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互任意组合。In order to make the objectives, technical solutions and advantages of the present invention clearer, the embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be noted that, the embodiments in the present application and the features in the embodiments may be arbitrarily combined with each other if there is no conflict.
在附图的流程图示出的步骤可以在诸如一组计算机可执行指令的计算机系统中执行。并且,虽然在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。The steps shown in the flowcharts of the figures may be performed in a computer system, such as a set of computer-executable instructions. Also, although a logical order is shown in the flowcharts, in some cases the steps shown or described may be performed in an order different from that herein.
图1为本发明实施例实现查表处理的方法的流程图,如图1所示,包括:1 is a flowchart of a method for implementing table lookup processing according to an embodiment of the present invention, as shown in FIG. 1 , including:
步骤100、根据条目的键(KEY)值,通过循环冗余校验(CRC)多项式计算确定条目是否存在;Step 100, according to the key (KEY) value of the entry, determine whether the entry exists by cyclic redundancy check (CRC) polynomial calculation;
可选的,确定条目是否存在包括:Optionally, determining whether an entry exists includes:
将条目的KEY值进行第一预设次CRC多项式计算;Perform the first preset CRC polynomial calculation on the KEY value of the entry;
使用第0个CRC多项式的计算结果作为匹配表的地址进行查表;Use the calculation result of the 0th CRC polynomial as the address of the matching table to look up the table;
将匹配表查表返回的结果与除第0个CRC外的其他的CRC多项式的计算结果进行匹配;Match the result returned by the matching table lookup table with the calculation results of other CRC polynomials except the 0th CRC;
匹配表查表返回的结果与除第0个CRC外的其他的CRC多项式的计算结果匹配时,确定条目存在。When the result returned by the matching table lookup table matches the calculation result of other CRC polynomials except the 0th CRC, it is determined that the entry exists.
需要说明的是,第一预设次可以由本领域技术人员根据支持冲突的条目数量确定。It should be noted that, the first preset time can be determined by those skilled in the art according to the number of items supporting conflict.
步骤101、确定条目存在时,根据CRC多项式的计算结果确定匹配表地址;Step 101, when determining that the entry exists, determine the matching table address according to the calculation result of the CRC polynomial;
步骤102、根据确定的匹配表地址对匹配表进行查表后返回的结果,确定片外哈希HASH查表地址;Step 102: Determine the off-chip hash HASH table lookup address according to the result returned after the matching table is looked up according to the determined match table address;
步骤103、根据确定的片外HASH查表地址进行查表获得哈希查表返回KEY值,根据条目的KEY值和哈希查表返回KEY值是否一致进行查表处理;Step 103, perform table lookup according to the determined off-chip HASH table lookup address to obtain a hash lookup table return KEY value, and perform table lookup processing according to whether the KEY value of the entry and the returned KEY value of the hash lookup table are consistent;
可选的,根据条目的KEY值和哈希查表返回KEY值是否一致进行查表处理包括:Optionally, the table lookup processing is performed according to whether the KEY value of the entry and the returned KEY value of the hash lookup table are consistent, including:
条目的KEY值和哈希查表返回KEY值一致,返回条目;条目的KEY值和哈希查表返回KEY值不一致,确定所述条目未命中。If the KEY value of the entry is consistent with the KEY value returned by the hash lookup table, the entry is returned; the KEY value of the entry is inconsistent with the KEY value returned by the hash lookup table, and it is determined that the entry is not hit.
可选的,本发明实施例方法还包括:Optionally, the method according to the embodiment of the present invention further includes:
匹配表查表返回的结果与除第0个CRC外的其他的CRC多项式的计算结果不匹配时,将条目上送到中央处理器CPU进行处理,或将条目根据预设规则进行处理。本发明实施例匹配表可以设置在片外双倍速率同步动态随机存储器(DDR)。When the result returned by the matching table lookup table does not match the calculation results of other CRC polynomials except the 0th CRC, the entry is sent to the central processing unit CPU for processing, or the entry is processed according to a preset rule. The matching table in the embodiment of the present invention may be set in an off-chip double-rate synchronous dynamic random access memory (DDR).
可选的,步骤100之前,本发明实施例方法还可以包括如图2所示的处理过程:Optionally, before step 100, the method in this embodiment of the present invention may further include the processing process shown in FIG. 2:
步骤200、根据条目涉及业务设置第二预设个MASK;Step 200, setting a second preset MASK according to the service involved in the entry;
步骤201、对每一个条目,分别根据报文解析结果、业务步骤、和/或应用模式选择相应类型的MASK;Step 201: For each entry, select a corresponding type of MASK according to the message parsing result, service steps, and/or application mode;
需要说明的是,如何选择相应类型的MASK可以由本领域技术人员根据报文解析结果、业务步骤、和/或应用模式等进行分析设置。It should be noted that how to select a corresponding type of MASK can be analyzed and set by those skilled in the art according to the packet parsing result, service steps, and/or application mode.
步骤202、根据选择的MASK,对条目中无效的KEY值进行过滤;Step 202, filter invalid KEY values in the entry according to the selected MASK;
其中,报文解析结果可以包括报文类型。The packet parsing result may include the packet type.
本发明实施例通过对条目中无效的KEY值进行过滤降低了对管脚资源、带宽资源的占用、避免了对芯片处理性能的影响。网络查表时,设计KEY的内容较多,例如、TCP中最常用的就是五元组信息,本发明实施例通过MASK可以有效过滤其中无用的内容,防止查找结果错误;例如,某些条目仅和IP地址相关,不对端口号等信进行屏蔽,将造成条目查找错误;本发明实施例可以根据条目涉及的业务对条目中无需考虑的构成内容通过MASK进行过滤,避免因为无需考虑的构成内容,造成条目被存储在多个位置。The embodiment of the present invention reduces the occupation of pin resources and bandwidth resources by filtering invalid KEY values in the entry, and avoids the impact on the processing performance of the chip. When looking up the table in the network, there are many contents in the design of KEY. For example, the most commonly used information in TCP is quintuple information. In this embodiment of the present invention, useless contents can be effectively filtered through MASK to prevent errors in the search results; for example, some entries only It is related to the IP address, and the port number and other information are not shielded, which will cause an entry search error; the embodiment of the present invention can filter the constituent content that does not need to be considered in the entry according to the business involved in the entry through MASK, to avoid the need to consider the constituent content. Causes entries to be stored in multiple locations.
可选的,步骤100之前,本发明实施例方法还可以包括如图3所示的处理过程:Optionally, before step 100, the method in this embodiment of the present invention may further include the processing process shown in FIG. 3:
步骤300、配置第三预设个布鲁姆过滤器表;Step 300, configure a third preset Bloom filter table;
可选的,本发明实施例配置第三预设个布鲁姆过滤器表包括:Optionally, the configuration of the third preset Bloom filter table in this embodiment of the present invention includes:
根据支持冲突的条目数量配置第三预设个布鲁姆过滤器表;Configure a third preset Bloom filter table based on the number of entries that support conflicts;
需要说明的是,支持冲突的条目数量可以通过相关技术中的仿真确定最大值后,根据经验加上余量获得。本发明实施例布鲁姆过滤器表可以放置在片内静态随机存取存储器(SRAM)。It should be noted that, the number of items supporting conflict can be obtained by adding a margin according to experience after determining the maximum value through simulation in the related art. The Bloom filter table in the embodiment of the present invention may be placed in an on-chip static random access memory (SRAM).
步骤301、对条目的KEY值进行CRC计算,获得CRC结果;Step 301, perform CRC calculation on the KEY value of the entry to obtain a CRC result;
步骤302、使用CRC结果查找所有布鲁姆过滤器表,得到过滤表结果;Step 302, use CRC result to find all Bloom filter tables, obtain filter table result;
步骤303、根据过滤表结果判断条目是否存在;Step 303, judge whether the entry exists according to the result of the filter table;
步骤304、确定条目存在时,继续查表,确定条目不存在时,停止查表。Step 304: When it is determined that the entry exists, continue to look up the table, and when it is determined that the entry does not exist, stop looking up the table.
本发明实施例通过对不存在的条目进行过滤,降低了对管脚资源、带宽资源的占用、避免了对芯片处理性能的影响。通过布鲁姆过滤器,判断条目是否存在,如果条目不存在则直接送给中央处理器(CPU)进行处理,无需浪费后续的查表带宽;bloom fitter一般使用片内静态随机存取存储器(SRAM,Static Random Access Memory)实现;The embodiment of the present invention reduces the occupation of pin resources and bandwidth resources by filtering non-existent entries, and avoids the impact on the processing performance of the chip. Through the bloom filter, it is judged whether the entry exists. If the entry does not exist, it is directly sent to the central processing unit (CPU) for processing, without wasting subsequent table lookup bandwidth; the bloom fitter generally uses on-chip static random access memory (SRAM). , Static Random Access Memory) implementation;
为了使本发明实施例内容清楚,以下对bloom fitter进行说明:In order to make the content of the embodiments of the present invention clear, the bloom fitter is described below:
bloom fitter一般在会进行多个CRC计算,根据多个CRC的结果进行bloom fitter表的查询,只有多个CRC的结果查到得bloom fitter结果均为1条目才存在;因此,需要进行多次查表,一般不需要支持每周期连续处理的情况,可以使用这种处理方式;例如、4个周期处理一个的情况,使用4个CRC函数分别计算CRC的值,以此查找bloom fitter表的结果,只有全部命中的情况,才进行后续处理;否则按照未命中的情况进行处理;bloom fitter表处理哈希(HASH)冲突可以有多个比特(bit)的情况,多个bit代表冲突的数量;每个bloomfitter地址支持16次冲突,就需要16bit;最多时,需要16次查表才能确定条目是否命中;如果有速率上的要求,那么无法等待双倍速率同步动态随机存储器(DDR,Dual Data Rate)的读返回就需要发起下一次的读,最差的情况DDR的读带宽会膨胀16倍,由于HASH冲突的概率较大,DDR的范围带宽膨胀在2倍以上,对于DDR内存在多种类型的条目,这种带宽膨胀是无法接受的。The bloom fitter generally performs multiple CRC calculations, and queries the bloom fitter table according to the results of multiple CRCs. Only when the results of multiple CRCs are checked and the bloom fitter result is 1 entry, there is an entry; therefore, multiple checks are required. Table, generally does not need to support continuous processing per cycle, you can use this processing method; for example, in the case of processing one in 4 cycles, use 4 CRC functions to calculate the CRC value separately, so as to find the result of the bloom fitter table, Only in the case of all hits, follow-up processing is performed; otherwise, it is processed according to the case of misses; the bloom fitter table handles hash (HASH) collisions where there can be multiple bits (bits), and multiple bits represent the number of collisions; each A bloomfitter address supports 16 collisions, which requires 16 bits; at most, 16 table lookups are required to determine whether the entry is hit; if there is a rate requirement, it cannot wait for double-rate synchronous dynamic random access memory (DDR, Dual Data Rate) In the worst case, the read bandwidth of DDR will expand by 16 times. Due to the high probability of HASH conflict, the range bandwidth of DDR will expand by more than 2 times. There are many types of DDR memory. entry, this bandwidth bloat is unacceptable.
需要说明的是,步骤200~202的处理过程和步骤300~304的处理过程可以在本发明实施例中同时应用,也可以单独作为可选实施例实施。本发明实施例,如果对处理效率和精度要求较高,还可以使用多套bloom fitter表、多个CRC函数进行处理,只有全部bloomfitter均命中的情况才进行后续处理,否则按照丢失(MISS)处理;It should be noted that, the processing procedures of steps 200 to 202 and the processing procedures of steps 300 to 304 may be simultaneously applied in this embodiment of the present invention, or may be implemented separately as optional embodiments. In this embodiment of the present invention, if the processing efficiency and accuracy are required to be high, multiple sets of bloom fitter tables and multiple CRC functions may be used for processing, and subsequent processing will be performed only when all the bloom fitters are hit, otherwise, the processing will be performed as a missing (MISS) ;
与相关技术相比,本申请技术方案包括:根据条目的键(KEY)值,通过循环冗余校验(CRC)多项式计算确定条目是否存在;确定条目存在时,根据CRC多项式的计算结果确定匹配表地址;根据确定的匹配表地址对匹配表进行查表后返回的结果,确定片外哈希(HASH)查表地址;根据确定的片外HASH查表地址进行查表获得哈希查表返回KEY值,根据条目的KEY值和哈希查表返回KEY值是否一致进行查表处理。本发明实施例方法减少了需要查表的条目,降低了对管脚资源、带宽资源的占用、避免了对芯片处理性能的影响。Compared with the related art, the technical solution of the present application includes: according to the key (KEY) value of the entry, determining whether the entry exists through cyclic redundancy check (CRC) polynomial calculation; when it is determined that the entry exists, determining the match according to the calculation result of the CRC polynomial Table address; according to the determined matching table address, the result returned after the matching table is looked up, determine the off-chip hash (HASH) table lookup address; perform the table lookup according to the determined off-chip HASH lookup table address to obtain the hash lookup table and return KEY value, according to whether the KEY value of the entry and the hash lookup table return the same KEY value to perform table lookup processing. The method of the embodiment of the present invention reduces the entries that need to look up the table, reduces the occupation of pin resources and bandwidth resources, and avoids the impact on the processing performance of the chip.
本发明实施例还提供一种计算机存储介质,计算机存储介质中存储有计算机可执行指令,计算机可执行指令用于执行上述实现查表处理的方法。Embodiments of the present invention further provide a computer storage medium, where computer-executable instructions are stored in the computer storage medium, and the computer-executable instructions are used to execute the above method for implementing table lookup processing.
本发明实施例还提供一种实现查表处理的装置,包括:存储器和处理器;其中,An embodiment of the present invention further provides an apparatus for implementing table lookup processing, including: a memory and a processor; wherein,
处理器被配置为执行存储器中的程序指令;the processor is configured to execute program instructions in the memory;
程序指令在处理器读取执行以下操作:Program instructions are read by the processor to do the following:
将条目的键(KEY)值进行第一预设次的循环冗余校验(CRC)多项式计算;Perform the first preset cyclic redundancy check (CRC) polynomial calculation on the key (KEY) value of the entry;
使用第0个CRC多项式的计算结果作为匹配表的地址进行查表;Use the calculation result of the 0th CRC polynomial as the address of the matching table to look up the table;
将查表返回的结果与除第0个CRC外的其他的CRC多项式的计算结果进行匹配;Match the result returned by the look-up table with the calculation results of other CRC polynomials except the 0th CRC;
查表返回的结果与其他的CRC多项式的计算结果匹配时,确定条目存在,并根据匹配结果得到片外哈希HASH查表地址;When the result returned by the table lookup matches the calculation results of other CRC polynomials, it is determined that the entry exists, and the off-chip hash HASH table lookup address is obtained according to the matching result;
片外哈希查表返回时,比对条目的KEY值和哈希查表返回KEY值是否一致,条目的KEY值和哈希查表返回KEY值一致,返回该条目;条目的KEY值和哈希查表返回KEY值不一致,确定所述条目未命中。When the off-chip hash lookup table is returned, compare the KEY value of the entry with the KEY value returned by the hash lookup table. If the KEY value of the entry is consistent with the KEY value returned by the hash lookup table, return the entry; the KEY value of the entry is the same as the hash lookup table. If the KEY value returned by the search table is inconsistent, it is determined that the entry is not hit.
图4为本发明实施例实现查表处理的装置的结构框图,如图4所示,包括:第一判断单元、匹配表地址单元、哈希地址单元、查表处理单元;其中,4 is a structural block diagram of an apparatus for implementing table lookup processing according to an embodiment of the present invention. As shown in FIG. 4 , it includes: a first judgment unit, a matching table address unit, a hash address unit, and a table lookup processing unit; wherein,
第一判断单元用于:根据条目的键KEY值,通过循环冗余校验CRC多项式计算确定条目是否存在;The first judgment unit is used for: according to the key KEY value of the entry, determine whether the entry exists by CRC polynomial calculation;
匹配表地址单元用于:确定条目存在时,根据CRC多项式的计算结果确定匹配表地址;The matching table address unit is used to: determine the matching table address according to the calculation result of the CRC polynomial when it is determined that the entry exists;
哈希地址单元用于:根据确定的匹配表地址对匹配表进行查表后返回的结果,确定片外哈希HASH查表地址;The hash address unit is used to: determine the off-chip hash HASH table lookup address based on the result returned after the matching table lookup table is performed according to the determined match table address;
查表处理单元用于:根据确定的片外HASH查表地址进行查表获得哈希查表返回KEY值,根据条目的KEY值和哈希查表返回KEY值是否一致进行查表处理。The table lookup processing unit is used to: perform table lookup according to the determined off-chip HASH table lookup address to obtain the hash lookup table return KEY value, and perform table lookup processing according to whether the KEY value of the entry and the hash lookup table return KEY value are consistent.
可选的,第一判断单元具体用于:Optionally, the first judgment unit is specifically used for:
将条目的KEY值进行第一预设次CRC多项式计算;Perform the first preset CRC polynomial calculation on the KEY value of the entry;
使用第0个CRC多项式的计算结果作为匹配表的地址进行查表;Use the calculation result of the 0th CRC polynomial as the address of the matching table to look up the table;
将匹配表查表返回的结果与除第0个CRC外的其他的CRC多项式的计算结果进行匹配;Match the result returned by the matching table lookup table with the calculation results of other CRC polynomials except the 0th CRC;
匹配表查表返回的结果与除第0个CRC外的其他的CRC多项式的计算结果匹配时,确定条目存在。When the result returned by the matching table lookup table matches the calculation result of other CRC polynomials except the 0th CRC, it is determined that the entry exists.
可选的,查表处理单元具体用于:Optionally, the table lookup processing unit is specifically used for:
根据确定的片外HASH查表地址进行查表获得哈希查表返回KEY值,条目的KEY值和哈希查表返回KEY值一致,返回条目;条目的KEY值和哈希查表返回KEY值不一致,确定所述条目未命中。Perform a table lookup according to the determined off-chip HASH lookup table address to obtain the hash lookup table and return the KEY value. The KEY value of the entry is the same as the hash lookup table return KEY value, and the entry is returned; the entry KEY value and the hash lookup table return the KEY value Inconsistent, the entry is determined to be a miss.
可选的,查表处理单元还用于:Optionally, the table lookup processing unit is also used for:
匹配表查表返回的结果与除第0个CRC外的其他的CRC多项式的计算结果不匹配时,将条目上送到中央处理器CPU进行处理,或将条目根据预设规则进行处理。When the result returned by the matching table lookup table does not match the calculation results of other CRC polynomials except the 0th CRC, the entry is sent to the central processing unit CPU for processing, or the entry is processed according to a preset rule.
可选的,装置还包括设置掩码单元、掩码选择单元、过滤单元;其中,Optionally, the device further includes a mask setting unit, a mask selection unit, and a filtering unit; wherein,
设置掩码单元用于:根据条目涉及业务设置第二预设个掩码;The mask setting unit is used for: setting a second preset mask according to the business involved in the entry;
掩码选择单元用于:对每一个条目,分别根据报文解析结果、业务步骤、和/或应用模式选择相应类型的MASK;The mask selection unit is used to: for each entry, select a corresponding type of MASK according to the packet parsing result, service steps, and/or application mode;
过滤单元用于:根据选择的MASK,对条目中无效的KEY值进行过滤;The filtering unit is used to: filter the invalid KEY value in the entry according to the selected MASK;
其中,报文解析结果包括报文类型。The packet parsing result includes the packet type.
可选的,装置还包括配置单元、第二计算单元、第二查表单元、第二确定单元和第二处理单元;其中,Optionally, the device further includes a configuration unit, a second calculation unit, a second table lookup unit, a second determination unit, and a second processing unit; wherein,
配置单元用于:配置第三预设个布鲁姆过滤器表;The hive is used to: configure the third preset Bloom filter table;
第二计算单元用于:对条目的KEY值进行CRC计算,获得CRC结果;The second calculation unit is used for: CRC calculation is performed on the KEY value of the entry to obtain a CRC result;
第二查表单元用于:使用CRC结果查找所有布鲁姆过滤器表,得到过滤表结果;The second table lookup unit is used for: using the CRC result to look up all Bloom filter tables to obtain the filter table results;
第二确定单元用于:根据过滤表结果判断条目是否存在;The second determining unit is used for: judging whether the entry exists according to the result of the filtering table;
第二处理单元用于:确定条目存在时,继续查表,确定条目不存在时,停止查表。The second processing unit is configured to: continue to look up the table when it is determined that the entry exists, and stop looking up the table when it is determined that the entry does not exist.
可选的,配置单元具体用于:Optionally, the hive is specifically used to:
根据支持冲突的条目数量配置第三预设个布鲁姆过滤器表。Configure a third preset bloom filter table based on the number of entries that support conflicts.
与相关技术相比,本申请技术方案包括:根据条目的键(KEY)值,通过循环冗余校验(CRC)多项式计算确定条目是否存在;确定条目存在时,根据CRC多项式的计算结果确定匹配表地址;根据确定的匹配表地址对匹配表进行查表后返回的结果,确定片外哈希(HASH)查表地址;根据确定的片外HASH查表地址进行查表获得哈希查表返回KEY值,根据条目的KEY值和哈希查表返回KEY值是否一致进行查表处理。本发明实施例方法减少了需要查表的条目,降低了对管脚资源、带宽资源的占用、避免了对芯片处理性能的影响。Compared with the related art, the technical solution of the present application includes: according to the key (KEY) value of the entry, through cyclic redundancy check (CRC) polynomial calculation to determine whether the entry exists; when it is determined that the entry exists, the matching is determined according to the calculation result of the CRC polynomial. Table address; according to the determined matching table address, the result returned after the matching table is looked up, determine the off-chip hash (HASH) table lookup address; perform the table lookup according to the determined off-chip HASH lookup table address to obtain the hash lookup table and return KEY value, according to whether the KEY value of the entry and the hash lookup table return the same KEY value to perform table lookup processing. The method of the embodiment of the present invention reduces the entries that need to be looked up in the table, reduces the occupation of pin resources and bandwidth resources, and avoids the impact on the processing performance of the chip.
以下通过应用示例对本发明方法进行清楚详细的说明,应用示例仅用于说明和解释本发明,并不用于限定本发明。The method of the present invention will be described clearly and in detail below through application examples. The application examples are only used to illustrate and explain the present invention, and are not used to limit the present invention.
图5为本发明应用示例的方法流程图,如图5所示,包括:Fig. 5 is the method flow chart of the application example of the present invention, as shown in Fig. 5, including:
步骤500、配置MASK值、工作模式和相关使能等;Step 500, configure the MASK value, working mode and related enable, etc.;
这里,工作模式、相关使能等可以根据本领域技术根据经验值进行设定。Here, the working mode, related enable, etc. can be set according to the experience value according to the technology in the art.
步骤501、初始化布鲁姆过滤器表内容、匹配表内容;Step 501, initialize Bloom filter table content, match table content;
步骤502、初始化完成后,接收外部输入的包含条目的数据;Step 502, after the initialization is completed, receive the data containing the entry input from the outside;
步骤503、根据输入数据的类型,选取对应的MASK值,并将数据的KEY值与MASK进行位与操作,得到位与操作后的KEY值;Step 503, according to the type of the input data, select the corresponding MASK value, and carry out the bit AND operation with the KEY value of the data and the MASK, obtain the KEY value after the bit AND operation;
步骤504、使用位与操作获得的KEY值并行进行两个或两个以上CRC多项式计算,得到4个CRC计算结果;Step 504, perform two or more CRC polynomial calculations in parallel using the KEY value obtained by the bit and operation to obtain 4 CRC calculation results;
步骤505、使用4个CRC值分别查对应的四张布鲁姆过滤器表;Step 505, use 4 CRC values to check corresponding four Bloom filter tables respectively;
步骤506、查四张布鲁姆过滤器表得到四个布鲁姆过滤器的返回值;Step 506, check four Bloom filter tables to obtain the return value of four Bloom filters;
步骤507、根据四个布鲁姆过滤器的返回值判断命中或未命中;其中,四个布鲁姆过滤器的返回值均为1时,表示命中,四个bloom fitter的返回值中存在一个不为1时,表示未命中;未命中时,执行步骤516;命中时,执行步骤508;Step 507, judge hit or miss according to the return values of the four bloom filters; wherein, when the return values of the four bloom filters are all 1, it indicates a hit, and there is one in the return values of the four bloom fitters When it is not 1, it means a miss; when it is a miss, go to step 516; when it hits, go to step 508;
步骤508、根据KEY值进行8个不同CRC的多项式计算,得到8个CRC多项式计算的CRC计算结果;Step 508, carry out the polynomial calculation of 8 different CRCs according to the KEY value, obtain the CRC calculation result of 8 CRC polynomial calculations;
步骤509、根据第0个CRC的计算结果查询匹配表,得到16个匹配值(value),将第一个CRC与16个匹配值值进行比对,输出16比特的比对结果;本实施例总共输出16*7bit的结果;Step 509, query the matching table according to the calculation result of the 0th CRC, obtain 16 matching values (value), compare the first CRC with the 16 matching value values, and output a 16-bit comparison result; this embodiment A total of 16*7bit results are output;
步骤510、根据16bit结果分别送出7个CRC计算得到的最终查表地址。Step 510: Send out seven final table lookup addresses calculated by CRC according to the 16-bit result.
规则:第一个CRC如果匹配,根据优先级最高的匹配结果,得到位置偏移值;例如、Rule: If the first CRC matches, the position offset value is obtained according to the matching result with the highest priority; for example,
1、输出的比对结果为0xffff时,即所有值均匹配,0偏移位置生效,最终的CRC1的查表输出地址为{CRC0,4’d0};1. When the output comparison result is 0xffff, that is, all values match, the 0 offset position takes effect, and the final CRC1 table lookup output address is {CRC0, 4'd0};
2、输出结果为0x0f**时,优先级最高匹配位第4位匹配,4偏移位置生效,最终的CRC1的查表输出地址为{CRC0,4’d4};2. When the output result is 0x0f**, the 4th bit of the highest matching bit of the priority matches, and the 4th offset position takes effect. The final CRC1 table lookup output address is {CRC0, 4'd4};
3、输出结果为0x0011时,优先级最高匹配位第11位匹配,11偏移位置生效,最终的CRC1的查表输出地址为{CRC0,4’d11};3. When the output result is 0x0011, the 11th bit of the highest matching bit of the priority matches, the 11 offset position takes effect, and the final CRC1 table lookup output address is {CRC0, 4'd11};
4、输出结果为0x0002时,优先级最高匹配位第14位匹配,14偏移位置生效;最终的CRC1的查表输出地址为{CRC0,4’d14};4. When the output result is 0x0002, the 14th bit of the highest priority matching bit matches, and the 14th offset position takes effect; the final CRC1 table lookup output address is {CRC0, 4'd14};
综上,本发明实施例,取第一个有效的(1)的位置即为偏移值;后续有效bit均不生效;To sum up, in this embodiment of the present invention, the position of the first valid (1) is taken as the offset value; subsequent valid bits are not valid;
CRC1~CRC7的结果同样,CRC1有效的情况下,采用CRC1的输出的结果,依次类推,如果全部无效,按照未命中的方式进行处理;The results of CRC1 to CRC7 are the same. When CRC1 is valid, the output result of CRC1 is used, and so on. If all are invalid, it is processed as a miss;
步骤511、获得7个CRC1至CRC7的结果;Step 511, obtain 7 results of CRC1 to CRC7;
步骤512、判断7个CRC1至CRC7的结果是否均有效;当7个CRC1至CRC7的结果均有效时,执行步骤513;如果当7个CRC1至CRC7的结果存在不匹配,执行步骤516;Step 512, judge whether the results of the 7 CRC1 to CRC7 are valid; when the results of the 7 CRC1 to CRC7 are all valid, execute step 513; if there is a mismatch between the results of the 7 CRC1 to CRC7, execute step 516;
步骤513、根据优先级和有效标记选取对应的CRC值;Step 513, select corresponding CRC value according to priority and valid mark;
步骤514、根据选取的CRC值查找匹配值表,得到匹配值和KEY值作为返回值;Step 514, search matching value table according to the selected CRC value, obtain matching value and KEY value as return value;
步骤515、将条目的KEY值与读表返回的KEY值进行匹配比对,并判断是否匹配;如果条目的KEY值与读表返回的KEY值匹配,执行步骤517;如果条目的KEY值与读表返回的KEY值不匹配,执行步骤516;Step 515: Match and compare the KEY value of the entry with the KEY value returned by the reading table, and judge whether it matches; if the KEY value of the entry matches the KEY value returned by the reading table, execute step 517; if the KEY value of the entry matches the KEY value returned by the reading table The KEY value returned by the table does not match, and step 516 is executed;
步骤516、按照预设规则进行处理;Step 516, processing according to preset rules;
步骤517、按照读表返回的结果进行处理。Step 517: Process according to the result returned by reading the meter.
本领域普通技术人员可以理解上述方法中的全部或部分步骤可通过程序来指令相关硬件(例如处理器)完成,所述程序可以存储于计算机可读存储介质中,如只读存储器、磁盘或光盘等。可选地,上述实施例的全部或部分步骤也可以使用一个或多个集成电路来实现。相应地,上述实施例中的每个模块/单元可以采用硬件的形式实现,例如通过集成电路来实现其相应功能,也可以采用软件功能模块的形式实现,例如通过处理器执行存储于存储器中的程序/指令来实现其相应功能。本发明不限制于任何特定形式的硬件和软件的结合。Those of ordinary skill in the art can understand that all or part of the steps in the above method can be completed by instructing relevant hardware (such as a processor) through a program, and the program can be stored in a computer-readable storage medium, such as a read-only memory, a magnetic disk or an optical disk Wait. Optionally, all or part of the steps in the above embodiments may also be implemented using one or more integrated circuits. Correspondingly, each module/unit in the above-mentioned embodiments can be implemented in the form of hardware, for example, an integrated circuit to implement its corresponding function, or it can be implemented in the form of a software function module, for example, a processor executes a function stored in a memory. program/instruction to achieve its corresponding function. The present invention is not limited to any particular form of combination of hardware and software.
虽然本发明所揭露的实施方式如上,但所述的内容仅为便于理解本发明而采用的实施方式,并非用以限定本发明。任何本发明所属领域内的技术人员,在不脱离本发明所揭露的精神和范围的前提下,可以在实施的形式及细节上进行任何的修改与变化,但本发明的专利保护范围,仍须以所附的权利要求书所界定的范围为准。Although the embodiments disclosed in the present invention are as above, the described contents are only the embodiments adopted to facilitate the understanding of the present invention, and are not intended to limit the present invention. Any person skilled in the art to which the present invention belongs, without departing from the spirit and scope disclosed by the present invention, can make any modifications and changes in the form and details of the implementation, but the scope of the patent protection of the present invention still needs to be The scope defined by the appended claims shall prevail.
Claims (12)
1. A method for implementing table lookup processing, comprising:
determining whether the entry exists through Cyclic Redundancy Check (CRC) polynomial calculation according to the KEY value of the entry;
when the entry exists, determining the address of the matching table according to the calculation result of the CRC polynomial;
determining the off-chip HasH table look-up address according to the returned result after the determined matching table address is used for look-up of the matching table;
performing table lookup according to the determined off-chip HASH table lookup address to obtain a KEY value returned by the Hash table lookup, and performing table lookup according to whether the KEY value of the entry is consistent with the KEY value returned by the Hash table lookup;
wherein the determining whether an entry exists comprises:
performing a first preset time of the CRC polynomial calculation on the KEY value of the entry; using the calculation result of the 0 th CRC polynomial as the address of the matching table to perform table lookup; when the result returned by the matching table lookup is matched with the calculation result of other CRC polynomials except the 0 th CRC, determining that the entry exists; wherein, the 0 th is the smallest one of the sequence numbers.
2. The method of claim 1, wherein performing a table lookup process according to whether the KEY value of the entry and the KEY value returned by the hash table lookup are consistent comprises:
the KEY value of the entry is consistent with the KEY value returned by the hash table lookup, and the entry is returned; and determining that the item is not hit when the KEY value of the item is inconsistent with the KEY value returned by the hash table lookup.
3. The method of claim 1, further comprising:
and when the result returned by the matching table lookup is not matched with the calculation results of other CRC polynomials except the 0 th CRC, the item is uploaded to a Central Processing Unit (CPU) for processing, or the item is processed according to a preset rule.
4. The method of any of claims 1-3, wherein prior to determining whether an entry exists via Cyclic Redundancy Check (CRC) polynomial computation, the method further comprises:
setting a second preset number MASK according to the entry related to the service;
for each item, selecting a MASK of a corresponding type according to a message analysis result, a service step and/or an application mode;
filtering invalid KEY values in the entries according to the selected MASK;
wherein, the message analysis result comprises the message type.
5. The method of any of claims 1-3, wherein prior to determining whether an entry exists via Cyclic Redundancy Check (CRC) polynomial computation, the method further comprises:
configuring a third preset bloom filter table;
performing CRC calculation on the KEY value of the entry to obtain a CRC result;
searching all bloom filter tables by using the CRC result to obtain a filter table result;
judging whether the entry exists according to the result of the filter table;
and when determining that the entry exists, continuing to look up the table, and when determining that the entry does not exist, stopping looking up the table.
6. The method of claim 5, wherein configuring a third preset number of bloom filter tables comprises:
and configuring a third preset number of bloom filter tables according to the number of the entries supporting the conflict.
7. An apparatus for implementing table lookup processing, comprising: the device comprises a first judgment unit, a matching table address unit, a hash address unit and a table look-up processing unit; wherein,
the first judging unit is used for: determining whether the entry exists through Cyclic Redundancy Check (CRC) polynomial calculation according to the KEY value of the entry;
the match table address unit is to: when the entry exists, determining the address of the matching table according to the calculation result of the CRC polynomial;
the hash address unit is to: determining the off-chip HasH table look-up address according to the returned result after the determined matching table address is used for look-up of the matching table;
the table look-up processing unit is used for: performing table lookup according to the determined off-chip HASH table lookup address to obtain a KEY value returned by the Hash table lookup, and performing table lookup according to whether the KEY value of the entry is consistent with the KEY value returned by the Hash table lookup;
the first judging unit is specifically configured to: performing a first preset time of the CRC polynomial calculation on the KEY value of the entry; using the calculation result of the 0 th CRC polynomial as the address of the matching table to perform table lookup; when the result returned by the matching table lookup is matched with the calculation result of other CRC polynomials except the 0 th CRC, determining that the entry exists; wherein, the 0 th is the smallest one of the sequence numbers.
8. The apparatus of claim 7, wherein the table lookup processing unit is specifically configured to:
performing table lookup according to the determined off-chip HASH table lookup address to obtain a KEY value returned by the Hash table lookup, wherein the KEY value of the entry is consistent with the KEY value returned by the Hash table lookup, and returning the entry; and determining that the item is not hit when the KEY value of the item is inconsistent with the KEY value returned by the hash table lookup.
9. The apparatus of claim 7, wherein the lookup processing unit is further configured to:
and when the result returned by the matching table lookup is not matched with the calculation results of other CRC polynomials except the 0 th CRC, the item is uploaded to a Central Processing Unit (CPU) for processing, or the item is processed according to a preset rule.
10. The device according to any one of claims 7 to 9, further comprising a setting mask unit, a mask selecting unit and a filtering unit; wherein,
a set mask unit to: setting a second preset number MASK according to the entry related to the service;
the mask selection unit is to: for each item, selecting a MASK of a corresponding type according to a message analysis result, a service step and/or an application mode;
the filtering unit is used for: filtering invalid KEY values in the entries according to the selected MASK;
wherein, the message analysis result comprises the message type.
11. The device according to any one of claims 7 to 9, wherein the device further comprises a configuration unit, a second calculation unit, a second table look-up unit, a second determination unit and a second processing unit; wherein,
the configuration unit is used for: configuring a third preset bloom filter table;
the second calculation unit is configured to: performing CRC calculation on the KEY value of the entry to obtain a CRC result;
the second table look-up unit is used for: searching all bloom filter tables by using the CRC result to obtain a filter table result;
the second determination unit is configured to: judging whether the entry exists according to the result of the filter table;
the second processing unit is used for: and when determining that the entry exists, continuing to look up the table, and when determining that the entry does not exist, stopping looking up the table.
12. The apparatus according to claim 11, wherein the configuration unit is specifically configured to:
and configuring a third preset number of bloom filter tables according to the number of the entries supporting the conflict.
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710210525.1A CN108664518B (en) | 2017-03-31 | 2017-03-31 | Method and device for realizing table look-up processing |
PCT/CN2018/079946 WO2018177184A1 (en) | 2017-03-31 | 2018-03-22 | Method and device for implementing table lookup processing, apparatus, and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710210525.1A CN108664518B (en) | 2017-03-31 | 2017-03-31 | Method and device for realizing table look-up processing |
Publications (2)
Publication Number | Publication Date |
---|---|
CN108664518A CN108664518A (en) | 2018-10-16 |
CN108664518B true CN108664518B (en) | 2021-12-07 |
Family
ID=63674222
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710210525.1A Active CN108664518B (en) | 2017-03-31 | 2017-03-31 | Method and device for realizing table look-up processing |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN108664518B (en) |
WO (1) | WO2018177184A1 (en) |
Families Citing this family (5)
* Cited by examiner, † Cited by third partyPublication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112445771A (en) * | 2020-12-10 | 2021-03-05 | 阿米华晟数据科技(江苏)有限公司 | Data processing method, device and equipment of network flow and storage medium |
CN114584482B (en) * | 2022-02-14 | 2023-09-08 | 阿里巴巴(中国)有限公司 | Method, device and network card for storing detection data based on memory |
CN117411738B (en) * | 2023-12-15 | 2024-03-08 | 格创通信(浙江)有限公司 | Multicast replication method, device, electronic equipment and storage medium |
CN117478626B (en) * | 2023-12-27 | 2024-04-05 | 天津光电聚能通信股份有限公司 | Quick matching searching system, method, equipment and medium based on group connection cache |
CN118152399B (en) * | 2024-03-18 | 2025-03-14 | 中国人民解放军陆军工程大学 | Multistage flow table matching method and device based on bloom filter |
Citations (7)
* Cited by examiner, † Cited by third partyPublication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1489336A (en) * | 2003-01-27 | 2004-04-14 | 四川南山之桥微电子有限公司 | A network filter processor |
CN101350788A (en) * | 2008-08-25 | 2009-01-21 | 中兴通讯股份有限公司 | Method for mixed loop-up table of network processor inside and outside |
CN101540723A (en) * | 2009-04-20 | 2009-09-23 | 杭州华三通信技术有限公司 | Flow stream searching method and device |
CN102682116A (en) * | 2012-05-14 | 2012-09-19 | 中兴通讯股份有限公司 | Method and device for processing table items based on Hash table |
CN102761394A (en) * | 2012-07-05 | 2012-10-31 | 中兴通讯股份有限公司 | Method and device for processing data |
CN103001878A (en) * | 2012-11-26 | 2013-03-27 | 中兴通讯股份有限公司 | Determination method and device for media access control (MAC) address Hash collision |
CN103918032A (en) * | 2011-10-31 | 2014-07-09 | 华为技术有限公司 | A method and apparatus for network table lookups |
Family Cites Families (4)
* Cited by examiner, † Cited by third partyPublication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030223417A1 (en) * | 2002-06-04 | 2003-12-04 | Masashi Higashida | Method of processing data packets |
US7904460B2 (en) * | 2008-04-23 | 2011-03-08 | Microsoft Corporation | Determining computer information from processor properties |
CN104866502B (en) * | 2014-02-25 | 2020-10-13 | 深圳市中兴微电子技术有限公司 | Data matching method and device |
CN105376159A (en) * | 2014-08-25 | 2016-03-02 | 深圳市中兴微电子技术有限公司 | Packet processing and forwarding device and method |
-
2017
- 2017-03-31 CN CN201710210525.1A patent/CN108664518B/en active Active
-
2018
- 2018-03-22 WO PCT/CN2018/079946 patent/WO2018177184A1/en active Application Filing
Patent Citations (8)
* Cited by examiner, † Cited by third partyPublication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1489336A (en) * | 2003-01-27 | 2004-04-14 | 四川南山之桥微电子有限公司 | A network filter processor |
CN1238996C (en) * | 2003-01-27 | 2006-01-25 | 四川南山之桥微电子有限公司 | Network filtering processor |
CN101350788A (en) * | 2008-08-25 | 2009-01-21 | 中兴通讯股份有限公司 | Method for mixed loop-up table of network processor inside and outside |
CN101540723A (en) * | 2009-04-20 | 2009-09-23 | 杭州华三通信技术有限公司 | Flow stream searching method and device |
CN103918032A (en) * | 2011-10-31 | 2014-07-09 | 华为技术有限公司 | A method and apparatus for network table lookups |
CN102682116A (en) * | 2012-05-14 | 2012-09-19 | 中兴通讯股份有限公司 | Method and device for processing table items based on Hash table |
CN102761394A (en) * | 2012-07-05 | 2012-10-31 | 中兴通讯股份有限公司 | Method and device for processing data |
CN103001878A (en) * | 2012-11-26 | 2013-03-27 | 中兴通讯股份有限公司 | Determination method and device for media access control (MAC) address Hash collision |
Non-Patent Citations (1)
* Cited by examiner, † Cited by third partyTitle |
---|
基于快速搜索树的路由查表算法;谭兴晔;《计算机应用研究》;20050710;全文 * |
Also Published As
Publication number | Publication date |
---|---|
WO2018177184A1 (en) | 2018-10-04 |
CN108664518A (en) | 2018-10-16 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108664518B (en) | 2021-12-07 | Method and device for realizing table look-up processing |
US10110492B2 (en) | 2018-10-23 | Exact match lookup with variable key sizes |
US7437354B2 (en) | 2008-10-14 | Architecture for network search engines with fixed latency, high capacity, and high throughput |
JP2004229163A (en) | 2004-08-12 | Device and method for retrieving fixed length data, computer program, and computer readable recording medium |
US9811777B2 (en) | 2017-11-07 | Rule matching method and apparatus for deep packet inspection |
US10243590B1 (en) | 2019-03-26 | Detection of errors in a ternary content addressable memory |
US20170078200A1 (en) | 2017-03-16 | Multi-table hash-based lookups for packet processing |
US10776427B2 (en) | 2020-09-15 | Efficient conditional state mapping in a pattern matching automaton |
CN101304342B (en) | 2010-11-24 | An Enhanced Ethernet Interface Device |
CN116866284A (en) | 2023-10-10 | System and method for managing flow table |
CN106802785A (en) | 2017-06-06 | A kind of stack analysis method and device |
US7185172B1 (en) | 2007-02-27 | CAM-based search engine devices having index translation capability |
CN106302374B (en) | 2019-08-16 | It is a kind of for improve list item access bandwidth and atomicity operation device and method |
US9507813B1 (en) | 2016-11-29 | Method and apparatus for hardware-implemented AVL tree updates |
CN110071923A (en) | 2019-07-30 | Packet identification method, device, electronic equipment and machine readable storage medium |
CN105743678A (en) | 2016-07-06 | Method and apparatus for managing table space of ternary content addressable memory (TCAM) |
US20090006782A1 (en) | 2009-01-01 | Apparatus and method for accessing a memory device |
US10846598B2 (en) | 2020-11-24 | Pattern matching |
CN116599892B (en) | 2023-10-03 | A server system, routing method, device, electronic equipment and storage medium |
WO2016101490A1 (en) | 2016-06-30 | Update processing method and device |
US10684961B1 (en) | 2020-06-16 | External memory protection for content addressable memory |
US9088476B2 (en) | 2015-07-21 | Network communication system with packet forwarding and method of operation thereof |
CN115567590A (en) | 2023-01-03 | Data packet scheduling method, device, equipment and readable storage medium |
CN111444218A (en) | 2020-07-24 | Matching method and device of combination rules |
CN100531140C (en) | 2009-08-19 | A method and device for maximum prefix matching searching without retrospection |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
2018-10-16 | PB01 | Publication | |
2018-10-16 | PB01 | Publication | |
2018-11-09 | SE01 | Entry into force of request for substantive examination | |
2018-11-09 | SE01 | Entry into force of request for substantive examination | |
2021-12-07 | GR01 | Patent grant | |
2021-12-07 | GR01 | Patent grant |