Method and system for packet processing according to a table lookup
Patent Information
- Authority / Receiving Office
- TW · TW
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2021-07-19
- Publication Date
- 2022-05-16
Smart Images

Figure TWG2TA000858443_001 
Figure TWG2TA000858443_002 
Figure TWG2TA000858443_003
Abstract
Description
[Technical Field]
[0001] The present invention relates to a method and system for grouping based on table lookup, and more specifically, to a method and system for hardware table lookup with search prioritized, multi-condition, and wildcard-containing table entries. [Previous Technology]
[0002] Traditionally, there are several existing methods for implementing lookup tables. One is to use so-called CAM (Content-Addressable Memory), and another is to use a hash function to calculate the table index.
[0003] Content-addressable memory (CAM) can refer to a special type of memory used in certain ultra-high-speed search applications. Also known as content-addressable memory, it includes input search data for a stored data table and returns the address of the matching data.
[0004] CAM is also frequently used in network devices because it accelerates operations on the forwarding database and routing table. This associative memory is also used in cache memory. In associative cache memory, addresses and contents are stored side-by-side. When an address matches, the corresponding content is retrieved from the cache memory.
[0005] Furthermore, a hash function is any function that can be used to map data of any size to a fixed-size value. The value returned by a hash function is called a hash value, digest, or simply a hash. These values are typically used to index a fixed-size table called a hash table. Indexing a hash table using a hash function is called hash addressing or distributed storage addressing.
[0006] However, using CAM or hash solutions leads to higher costs and circuit complexity. Functionally, searching a small lookup table does not necessarily require a CAM or hash solution. In some cases, it may not meet product requirements, considering the target market and selling price. [Summary of the Invention]
[0007] The present invention relates to a method and system for grouping based on table lookup, and more specifically, to a method and system for hardware table lookup to search for table entries with priority, multiple conditions and wildcards.
[0008] According to the present invention, the present invention provides a method for processing packets according to a lookup table, comprising: receiving a packet, the packet including a packet header, the packet header being composed of control information; providing a lookup table of M entries, wherein each entry includes N conditions and a result / action indicator, the M entries being sorted by priority; matching the information with the N conditions; and applying the result / action indicator of the matching entry with the highest priority to the packet.
[0009] Preferably, for each piece of information in the packet header, a bitmap array is given after matching.
[0010] Preferably, the bitmap array after searching each piece of information in the self-encapsulated header is processed by a logic OR gate to merge the bit arrays.
[0011] Preferably, all merged bit arrays are processed by a logic AND procedure to produce a final simplified bitmap array with priority.
[0012] Preferably, the result / action indicator indicates whether to allow the packet to pass, discard the packet, forward the packet, or modify the contents of the data packet header.
[0013] Preferably, the packet header information includes IP version, source / destination IP address, time-to-live count, source / destination MAC address, VLAN tag, TCP / UDP source / destination port number and other communication protocols.
[0014] Preferably, the priority order is sorted by the software.
[0015] According to the present invention, the present invention provides a system for processing packets according to a lookup table, comprising: a receiver for receiving packets, wherein the packets include a packet header, the packet header being composed of control information; a memory for storing a lookup table with M entries, wherein each entry includes N conditions and a result / action indicator, the M entries being sorted by priority; and a processor, wherein the processor matches the information with the N conditions and applies the result / action indicator of the matching entry with the highest priority in the matching to the packet.
[0016] Preferably, for each piece of information in the packet header, a bitmap array is given after matching.
[0017] Preferably, the bit array of each piece of information in the self-encapsulated header is processed by a logic OR gate to merge the bit arrays.
[0018] Preferably, all merged bit arrays are processed by a logic AND procedure to produce a final simplified bit array with priority.
[0019] Preferably, the result / action indicator indicates whether to allow the packet to pass, discard the packet, forward the packet, or modify the contents of the data packet header.
[0020] Preferably, the packet header information includes IP version, source / destination IP address, time-to-live count, source / destination MAC address, VLAN tag, TCP / UDP source / destination port number and other communication protocols.
[0021] Preferably, the priority order is sorted by software.
Implementation Method
[0024] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this disclosure pertains. Terms will be further understood; those defined, for example, in common dictionaries, should be interpreted as having a meaning consistent with their meaning in the context of the relevant technology and this disclosure, and will not be interpreted herein in an idealized or overly formal sense unless explicitly defined as such.
[0025] Throughout this specification, references to “one embodiment” or “one embodiment” mean that a particular feature, structure, or characteristic described in connection with that embodiment is included in at least one embodiment. Therefore, the phrases “in one embodiment” or “in one embodiment” appearing throughout this specification do not necessarily refer to the same embodiment. Furthermore, particular features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
[0026] Referring to Figures 1 and 2. Figures 1A-1D illustrate an embodiment of the present invention. First, referring to Figure 1A, Figure 1A shows a lookup table 100. The lookup table 100 includes four entries, each labeled as Entry 1, Entry 2, Entry 3, and Entry 4. These four entries are predetermined and have a priority from high to low, i.e., from Entry 1 to Entry 4. Each entry includes two conditions and a result / action indicator. Each condition is labeled as Condition 1 and Condition 2.
[0027] It should be noted that the number of entries is not limited to four, and the number of conditions is not limited to two. The number of entries and conditions in this embodiment is mainly for illustrative purposes and should not limit the scope of the invention.
[0028] In this embodiment, condition 1 represents the source IP (hereinafter referred to as "Src IP"), and condition 2 represents the destination IP (hereinafter referred to as "Dst IP"). As can be seen from Figure 1A, Src IP can also be understood as a lookup table for Condition 1 Src IP 101, and Dst IP can also be understood as a lookup table for Condition 2 Src IP 102. Furthermore, lookup table 100 can be implemented on any type of memory.
[0029] In Condition 1 of Entry 3, the condition is "Src IP:Any Value". This condition means that the match will always be true regardless of the incoming value. Alternatively, it can be understood as the match will always be true (or will always match) regardless of the incoming value. Any value can also be called a wildcard, as shown in the lookup table for Condition 1 Src IP 101 and the lookup table for Condition 2 Dst IP 102.
[0030] Next, referring to FIG1B, packet 103 is received. Packet 103 includes data packet header information (e.g., IP header) with Src IP 3.3.3.3 and Dst IP 4.4.4.4 (in some other embodiments, the data packet header may include other information, such as source MAC address, destination MAC address, Ethernet type information, etc.). According to the present invention, Src IP 3.3.3.3 in the IP header will be processed to determine which entry the Src IP matches under condition 1, and Dst IP 4.4.4.4 in the IP header will be processed to determine which entry the Dst IP matches under condition 2. As can be seen from FIG1B, Src IP 3.3.3.3 in the IP header will be processed according to the Lookup table of Condition 1 Src IP 101, and Dst IP 4.4.4.4 in the IP header will be processed according to the Lookup table of Condition 2 Src IP 102.
[0031] Next, refer to Figure 1C. Since the Src IP in the IP header is 3.3.3.3, such a Src IP does not match Condition 1 of Entry 1, but matches Condition 1 of Entry 2. It does not match Condition 1 of Entry 4, but matches Condition 1 of Entry 3, because such a condition is a wildcard (any value will be matched, as mentioned above).
[0032] Further referring to the bit map array of the Lookup table in Condition 1 Src IP 101, for Entry 1, there is no match, so the bit map array can be represented as 0.0.0.0. For Entry 2, there is one match, so the bit map array can be represented as 0.0.1.0. For Entry 4, there is no match, so the bit map array can be represented as 0.0.0.0. For Entry 3, there is a match, so the bit map array can be represented as 0.1.0.0. Then, the four bit map arrays are calculated using an OR logic gate. Therefore, for Src IP 3.3.3.3 in the IP header, it matches Entry 2 and Entry 3, and this result can be simplified to a simplified bit map array of 0.1.1.0.
[0033] Further referring to the bitmap array of the Lookup table for Condition 2 Dst IP 101, for Entry 1, there is no match, so the bitmap array can be represented as 0.0.0.0. For Entry 2, there is one match, so the bitmap array can be represented as 0.0.1.0. For Entry 3, there is no match, so the bitmap array can be represented as 0.0.0.0. For Entry 4, there is one match, so the bitmap array can be represented as 1.0.0.0. The four bitmap arrays are then calculated using an OR logic gate. Therefore, for Dst IP 4.4.4.4 in the IP header, it matches Entry 2 and Entry 4, and this result can be simplified to a simplified bitmap array of 1.0.1.0.
[0034] In addition, the two simplified bitmap arrays, bitmap array 0.1.1.0 and bitmap array 1.0.1.0, are processed by AND logic gate 110 to implement priority conditions, as shown in Figure 1C.
[0035] Refer to Figure 1D next. Since each entry has a priority, in this embodiment, the priorities of Entry 1 to Entry 4 are from high to low. Therefore, after AND logic processing, the final bitmap array is 0.0.1.0, as shown in Figure 1D. That is to say, for the IP header 3.3.3.3 Src IP and 4.4.4.4 Dst IP, only Entry 2 meets all the conditions. The bitmap array can also be called a bitmap vector.
[0036] According to the lookup table and the match, the packet will be dropped because the result / action of the matching entry is to drop the packet.
[0037] It should be noted that if multiple entries match all conditions, only the entry with the highest priority is selected, and its corresponding result / action is applied to the packet.
[0038] Furthermore, the result / action is not limited to "allowing the packet to pass" and "discarding the packet". The result / action may also be "modifying the contents of the packet header". Those skilled in the art can modify such result / action or have other implementations.
[0039] It should also be noted that a bit map index is generated after the lookup. Furthermore, for each bit map index, it points to a bit map array (also known as a bit map vector) stored in the storage space.
[0040] Referring now to Figures 1 and 2. Figures 2A-2D illustrate a general embodiment of the invention for general lookup table matching and corresponding grouping processes. As shown in Figure 2A, the lookup table 200 includes M entries, each labeled as entry 1, entry 2, ... to entry M. Priorities are from top to bottom (i.e., from entry 1 to entry M) from high to low. Each entry includes N conditions, labeled as condition 1, condition 2, ... to condition N. Each entry has a result / action area (as described above as a result / action indicator) after condition N. The lookup operation finds the matching entry that satisfies multiple conditions and has the highest priority.
[0041] The number of entries is not limited. For example, the number of entries can be 20. Furthermore, the number of conditions is not limited. For example, the number of conditions can be 30, and those skilled in the art can change these numbers according to their needs.
[0042] One of the general objectives of this invention is to find the corresponding result / action (i.e., how to process groups) for combined search conditions. For example, different types of network packets can be distinguished based on a combination of fields in the headers of different types of data packets, and corresponding actions can be taken on the packets. Another example is to find the corresponding output port / queue of a packet based on combined conditions. As yet another example, an event triggering mechanism can be designed to trigger an event under multiple matching conditions.
[0043] Referring next to Figure 2B, it should be noted that the priority of each entry is sorted by the software. The sorting is well known to those skilled in the art and will not be described further for convenience. Furthermore, a divide-and-conquer approach is used to check each matching condition against all specified matching values in parallel.
[0044] Referring next to Figure 2C, each matching value of the matching condition has a corresponding bitmap array that indicates which table entries request an exact match for the value. Furthermore, each matching condition has a corresponding wildcard bitmap array that indicates which table entries always satisfy the condition.
[0045] As shown in Figure 2C, for each condition X (condition X can be condition 1, condition 2, ... or condition N), each condition X of each entry stores a value (e.g., the condition described above, embodiment 4.4.4.4, 6.6.6.6, or others). The bitmap array is then processed by an OR logic gate to generate a simplified bitmap array of condition X and indicate the priority.
[0046] Finally, referring to Figure 2D, each bitmap array for each condition is processed via an AND logic gate. The packet is then processed according to the result / operation belonging to the matching entry with the highest priority.
[0047] In addition, for the matching condition, the bitmap arrays of all matching values and the wildcard bitmap arrays are merged (using OR logic gates) to obtain a single-condition result bitmap array, which indicates which table entries satisfy the matching condition.
[0048] For all matching conditions, merge (using AND logic gates) all single-condition result bit arrays to obtain the final multi-condition result bit map array, which describes which table entries satisfy all matching conditions.
[0049] The sequence of the bitmap array represents the priority of each table entry. Examine the final multi-condition result bitmap array to find the matching entry with the highest priority.
[0050] For table lookup operations, the goal is to find the matching entry that satisfies multiple conditions and has the highest priority.
[0051] After the logical AND gate (using OR logic gate) operation, a priority order is defined in the bitmap array. The priority order can be from MSB to LSB or from LSB to MSB, depending on the hardware implementation. The priority order depends on the application requirements, and the software can rearrange the order.
[0052] In summary, this invention divides a large lookup table (logically) into several smaller lookup tables (physically), each associated with a matching condition for an entry. Furthermore, the so-called smaller lookup tables are generated from a finite number of valid matching values, which is sufficient for some lookup applications. Therefore, the lookup operation does not require a CAM or hash solution.
[0053] In summary, the most suitable search algorithm can be applied to each table to obtain the best performance, depending on the matching conditions of each table.
[0054] Furthermore, the present invention can be applied to various communication and network devices. Additionally, the present invention can be applied to all hardware designs requiring table lookup operations with priorities, multiple conditions, and entries containing wildcards.
[0055] In summary, the present invention provides a scalable hardware lookup table method for searching table entries with priority, multiple conditions and wildcards, wherein priority table entries are sorted by software. This design reduces hardware complexity and increases hardware search speed performance.
[0056] Furthermore, in this invention, multiple conditions are matched simultaneously to reduce table lookup response time.
[0057] In addition, the inclusion of wildcards in the design provides flexibility in specifying matching values, thus increasing the utilization of the table.
[0058] It should also be noted that the control information in the packet header may include MAC header, VLAN tag, IP header, TCP header, UDP header, etc. Packet headers are well-known technology to those skilled in the art.
[0059] It is evident that this disclosure, by breaking through previous technologies, has indeed achieved the desired improved effect, and is not something that those familiar with the technology would easily conceive of. Its progressiveness and practicality clearly meet the requirements for patent application, and therefore a patent application is filed in accordance with the law.
[0060] The above description is merely illustrative and not restrictive. Any equivalent modifications or alterations made to this disclosure without departing from its spirit and scope should be included within the scope of the appended patent applications. [Simplified Explanation of the Diagram]
[0022] Figures 1A-1D illustrate exemplary embodiments of the present invention; and
[0023] Figures 2A-2D illustrate general embodiments of the present invention.
Claims
1. A method for processing packets based on a lookup table, comprising: Receive a packet, wherein the packet contains packet header information, and the packet header contains control information; Provide a lookup table of M entries, each containing N conditions and a result / action indicator, with the M entries ordered by priority; match the information against the N conditions; and apply the result / action indicator of the match with the highest priority to the packet.
2. The method for processing packets based on a lookup table as described in claim 1, wherein, For each piece of information in the packet header, a bitmap array is generated after matching.
3. The method for processing packets based on a lookup table as described in claim 2, wherein, The bitmap array of each message in the self-encapsulated header is processed by a logic OR gate procedure to merge the bitmap arrays.
4. The method for processing packets based on a lookup table as described in claim 3, wherein, All merged bitmap arrays are processed using a logic AND procedure to produce a final simplified bitmap array with priority order.
5. The method for processing packets based on a lookup table as described in claim 1, wherein, The result / action indicator tells you whether to let the packet pass, drop the packet, forward the packet, or modify the contents of the data packet header.
6. The method for processing packets based on a lookup table as described in claim 1, wherein, The packet header information includes IP version, source / destination IP address, time-to-live count, source / destination MAC address, VLAN tag, TCP / UDP source / destination port number, and other communication protocols.
7. The method for processing packets based on a lookup table as described in claim 1, wherein, Priority is determined by software order.
8. A system for processing packets based on a lookup table, comprising: A receiver is used to receive packets, wherein the packets include a packet header consisting of control information; The memory stores a lookup table with M entries, each entry including N conditions and a result / action indicator, the M entries being ordered by priority; and a processor that matches information against the N conditions and applies the result / action indicator to the packet of the highest priority matching entry.
9. The system for processing packets based on a lookup table as described in claim 8, wherein, For each piece of information in the packet header, a bitmap array is generated after matching.
10. The system for processing packets based on a lookup table as described in claim 8, wherein, The bitmap of each message in the self-encapsulated header is processed by a logic OR gate to merge the bitmap array.
11. The system for processing packets based on a lookup table as described in claim 8, wherein, All merged bitmap arrays are processed using a logic AND procedure to produce a final simplified bitmap array with priority order.
12. The system for processing packets based on a lookup table as described in claim 8, wherein, The result / action indicator tells you whether to let the packet pass, drop the packet, forward the packet, or modify the contents of the data packet header.
13. The system for processing packets based on a lookup table as described in claim 8, wherein, The packet header information includes IP version, source / destination IP address, time-to-live count, source / destination MAC address, VLAN tag, TCP / UDP source / destination port number, and other communication protocols.
14. The system for processing packets based on a lookup table as described in claim 8, wherein, Priority is determined by software order.