This invention relates generally to the field of network communication processors, and more specifically to the field of extracting bit fields from a packet.
Network communication systems demand fast performance. The performance of conventional processors in network communication systems is degraded by slow accessing of bit fields in received packets.
When a packet is received at a network processor it is stored in registers. The stored packets are not always aligned the same way in the registers. A stored packet may be stored over one or more registers and be offset. Conventional systems have a plurality of code paths written to handle the different possibilities of packet positioning within registers. For example,
Therefore, it would be desirable to have a single set of instructions that may be used, regardless of the bit field's positioning in the registers to extract the bit field from the packet and insert in a result register.
Systems and methods consistent with the present invention extract fields from a packet using a pair of instructions.
A processing system for extracting a field from a packet consistent with the present invention includes an instruction memory having a pair of instructions, a processor having a set of general registers and temporary registers, a portion of the packet being stored in a pair of general registers. The processor is configured to extract, responsive to a first instruction, any part of the field in a first general register designated as a first source register. The processor is further configured to extract, responsive to a second instruction, any part of the field in a second general register designated as a second source register.
A method for extracting a field from a packet consistent with the present invention stores a portion of the packet in a pair of general registers, executes a first instruction extracting any part of the field from a first general register designated as a first source register, and executes a second instruction extracting any part of the field from a second general register designated as a second source register.
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate one embodiment of the invention and, together with the description, serve to explain the objects, advantages, and principles of the invention. In the drawings:
a shows the fields of an EXTIV instruction consistent with methods and systems of the present invention;
b shows the fields of an INSV instruction consistent with methods and systems of the present invention;
a-4c show packet data and contents of a temporary and result register using three different data field placements consistent with methods and systems of the present invention;
Reference will now be made in detail to embodiments consistent with this invention that are illustrated in the accompanying drawings. The same reference numbers in different drawings generally refer to the same or like parts.
Current processing systems for network communications require a plurality of code paths to extract bit fields from a packet stored across a plurality of registers. Systems and methods consistent with the present invention provide a pair of instructions that may be used, regardless of the packet's position in registers, to extract and insert a field from the packet into a result register. Systems consistent with this invention can extract a field from data stored in a pair of words. For example, referring to
One example application of the systems and methods consistent with the present invention is the formation of a key used for a table lookup operation. In order to look up data in a table lookup unit, a processor sends an operation with data to the table lookup unit (TLU). The operation commands the TLU to look up data in a table using a key. This key is typically comprised of a number of unaligned fields in packet data. To form a key for accessing the TLU, the fields need to be extracted and then inserted in a result register in a specific order.
a and 2b show the format of the pair of instructions consistent with the systems and methods of the present invention.
An INSV instruction is executed following an EXTIV instruction to ensure that a complete field is extracted and stored in a result register.
a-4c show example register contents consistent with the present invention. In each of
a shows the content of a pair of general registers 410, a temporary register 420, and a result register 430 where the field of interest is held entirely in a low order word in register rT.sub.1. In this example, the EXTIV instruction extracts all of the field from register rT.sub.1 and stores the result in temporary register 420. The INSV instruction copies the field from the temporary register 420 to the result register 430 offset by insert offset (p).
b shows the content of a pair of general registers 410, a temporary register 420, and a result register 430 where the field of interest is held entirely in register rT.sub.2. In this example, the EXTIV instruction does not need to extract any of the field because no portion of the field is in register rT.sub.1. Therefore, the EXTIV instruction does not copy any data into the temporary register 420. The INSV instruction copies the field from register rT.sub.2 and stores the result in result register 430 offset by insert offset (p).
c shows the content of a pair of general registers 410, a temporary register 420, and a result register 430 where a portion of the field of interest is held in both registers rT.sub.1 and rT.sub.2. In this example, the EXTIV instruction extracts a first part of the field from register rT.sub.1 and stores the result in temporary register 420. The INSV instruction extracts a second part of the field from register rT.sub.2 and stores the result, along with the part of the field in the temporary register 420, in the result register 430 offset by insert offset (p).
To allow extraction of a particular field from the pair of registers holding at least a portion of the packet, the program forms a constant using the extraction width (m), extraction offset (n), and insert offset (p) for the field (step 530). This constant is combined with the packet information in R1 and stored in another general purpose register R2 (step 540). The program loads a first 32-bit word from the packet into a general purpose register R3 and loads the second 32-bit word of the packet into a general register R4 (step 550).
A field of interest in the packet may be in any of the positions shown in
After performing an EXTIV instruction, the program must execute an INSV instruction to extract any portion of the field in the upper order word in register R3. Using this example, the INSV instruction in
If the program requires the extraction of additional fields (step 580), then steps 530-570 are repeated for each additional field. Once all fields of interest have been extracted, the result registers R5, R6, . . . contain a concatenation of the fields extracted from the packet (step 590).
If the extraction offset is less than 32 bits and the sum of the width of the field and the extraction offset minus 1 is greater than 31 bits (step 750), then the field is contained in both the low order and high order words. The portion of the field extracted in the EXTIV instruction is copied from a temporary register temp2 to a final result register along with the portion of the field in the high order word (step 760). The entire field is then contained in the final result register.
If the extraction offset is greater than 31 bits, then the entire field is contained in the high order word. The field is copied from the register containing the high order word rT.sub.2 into the result register and any remaining bits in the result register are set to zero (step 770). No data needs to be copied from the temporary register temp2 because the EXTIV instruction did not extract any part of the field. The contents of the final result register are copied to the destination register rD.sub.2 and the remaining bits of rD.sub.2 not holding the field, are copied from rS.sub.2. Register rS.sub.2 holds a copy of data from rD.sub.2 so that bits not holding field data may be reinstated.
There are many variations that may be made consistent with the present invention. For example, in another embodiment, the extraction offset is relative to a position of a first field to be extracted. In this case, the extraction offset n refers to the fixed offset value of a field to be extracted relative to a position of a first field to be extracted. For example, if the first field's least significant bit is 60, and a current field to be extracted has a LSB of 40, the difference between these locations, −20, is stored as the extraction offset n for the current field.
Further, while the implementations above use registers being a word in size, systems and methods consistent with the present invention may be used with other sized registers.
The foregoing description is presented for purposes of illustration and description. It is not exhaustive and does not limit the invention to the precise form disclosed. Modifications and variations are possible in light of the above teachings or may be acquired from practicing the invention. The scope of the invention is defined by the claims and their equivalents.
This application is a divisional of U.S. application Ser. No. 12/544,167, filed Aug. 19, 2009, now allowed, which is a continuation of U.S. application Ser. No. 11/279,136, filed Apr. 10, 2006, now U.S. Pat. No. 7,581,091, which is a continuation of U.S. application Ser. No. 09/799,610, filed Mar. 7, 2001, now U.S. Pat. No. 7,039,060, each of which is hereby incorporated in their entirety by reference.
Number | Name | Date | Kind |
---|---|---|---|
3560935 | Beers | Feb 1971 | A |
3657705 | Mekota et al. | Apr 1972 | A |
3657736 | Boom et al. | Apr 1972 | A |
4785393 | Chu et al. | Nov 1988 | A |
5491829 | Kau et al. | Feb 1996 | A |
5568624 | Sites et al. | Oct 1996 | A |
5669012 | Shimizu et al. | Sep 1997 | A |
5710773 | Shiga | Jan 1998 | A |
5835793 | Li et al. | Nov 1998 | A |
5838984 | Nguyen et al. | Nov 1998 | A |
6032190 | Bremer et al. | Feb 2000 | A |
6052522 | Mattela et al. | Apr 2000 | A |
6061783 | Harriman | May 2000 | A |
6308253 | Gadre et al. | Oct 2001 | B1 |
6334176 | Scales et al. | Dec 2001 | B1 |
6629115 | Rossignol | Sep 2003 | B1 |
7039060 | Katzman et al. | May 2006 | B2 |
7133040 | Abdallah et al. | Nov 2006 | B1 |
7228403 | Leber et al. | Jun 2007 | B2 |
7519795 | Lee et al. | Apr 2009 | B2 |
7581091 | Gelinas et al. | Aug 2009 | B2 |
7793077 | Van Hook et al. | Sep 2010 | B2 |
7895423 | Katzman et al. | Feb 2011 | B2 |
7979676 | Kishida et al. | Jul 2011 | B2 |
20010020266 | Kojima et al. | Sep 2001 | A1 |
20050053093 | Fukushima et al. | Mar 2005 | A1 |
20090313457 | Katzman et al. | Dec 2009 | A1 |
20100070742 | Dowling | Mar 2010 | A1 |
Number | Date | Country | |
---|---|---|---|
20110099353 A1 | Apr 2011 | US |
Number | Date | Country | |
---|---|---|---|
Parent | 12544167 | Aug 2009 | US |
Child | 12985680 | US |
Number | Date | Country | |
---|---|---|---|
Parent | 11279136 | Apr 2006 | US |
Child | 12544167 | US | |
Parent | 09799610 | Mar 2001 | US |
Child | 11279136 | US |