# Patent

## Title
System and method for parsing, filtering, and computing the checksum in a host Ethernet adapter (HEA)

## Abstract

A system and method for parsing, filtering, and computing the checksum in a host Ethernet adapter (HEA) that is coupled to a host. The method includes receiving a part of a frame, wherein a plurality of parts of a frame constitute a entire frame. Next, parse the part of a frame before receiving the entire frame. The HEA computes a checksum of the part of a frame. The HEA filters the part of a frame based on a logical, port-specific policy and transmits the checksum to the host.

## Background
FIELD OF THE INVENTION
The present invention relates to adapters for parsing Ethernet packets generally, and specifically to a system and method for parsing, filtering and computing the Internet checksum in a host Ethernet adapter (HEA).
CROSS-REFERENCE TO RELATED APPLICATIONS
U.S. patent application Ser. No. 11/097,608, entitled “Host Ethernet Adapter for Networking Offload in Server Environment”, filed on even date herewith and assigned to the assignee of the present invention.
U.S. patent application Ser. No. 11/096,363, entitled “Method and System for Accommodating Several Ethernet Ports and a Wrap Transmitted Flow Handled by a Simplified Frame-By-Frame Upper Structure”, filed on even date herewith and assigned to the assignee of the present invention.
U.S. patent application Ser. No. 11/096,571, entitled “Method and Apparatus for Providing a Network Connection Table”, filed on even date herewith and assigned to the assignee of the present invention.
U.S. patent application Ser. No. 11/097,051, entitled “Network Communications for Operating System Partitions”, filed on even date herewith and assigned to the assignee of the present invention.
U.S. patent application Ser. No. 11/097,652, entitled “Configurable Ports for a Host Ethernet Adapter”, filed on even date herewith and assigned to the assignee of the present invention.
U.S. patent application Ser. No. 11/096,353, entitled “System and Method for a Method for Reducing Latency in a Host Ethernet Adapter (HEA)”, filed on even date herewith and assigned to the assignee of the present invention.
U.S. patent application Ser. No. 11/097,055. entitled “Method and Apparatus for Blind Checksum and Correction for Network Transmissions”, filed on even date herewith and assigned to the assignee of the present invention.
U.S. patent application Ser. No. 11/096,362, entitled “Method and system for Performing a Packet Header Lookup”, filed on even date herewith and assigned to the assignee of the present invention.
U.S. patent application Ser. No. 11/097,430, entitled “system and Method for Computing a Blind Checksum in a Host Ethernet Adapter (HEA)”, filed on even date herewith and assigned to the assignee of the present invention.
Adapters typically receive and store frames over a network. After a frame is received, it may be passed along, opened, filtered and checked for validity. One problem with this is that it may take some time to receive the entire frame, then begin the work of parsing, filtering and checking validity.
BACKGROUND OF THE INVENTION
A computer, or host, connects to a network through an adapter that parses, or separates, each frame received over the network. The adapter may be known as a host Ethernet adapter (HEA).
Adapters typically receive and store frames over a network. After a frame is received, it may be passed along, opened, filtered and checked for validity. One problem with this is that it may take some time to receive the entire frame, then begin the work or parsing, filtering and checking validity.
Accordingly, what is needed is a system and method for parsing, filtering and computing the checksum in a host Ethernet adapter (HEA). The present invention addresses such a need.
BRIEF SUMMARY OF THE INVENTION
The present invention provides a system and method for parsing, filtering, and computing the checksum in a host Ethernet adapter (HEA) that is coupled to a host. The method includes receiving a part of a frame, wherein a plurality of parts of a frame constitute an entire frame. Next, parse the part of a frame before receiving the entire frame. The HEA computes a checksum of the part of a frame. The HEA filters the part of a frame based on a logical, port-specific policy and transmits the checksum to the host.
The HEA computes a checksum of some of the bytes of the part of a frame and updates a running checksum. The HEA filters the frame based on a logical, port-specific policy and transmits the checksum to the host.



BRIEF DESCRIPTION OF SEVERAL VIEWS OF THE DRAWINGS
FIG. 1 is a block diagram of a server system in accordance with the present invention.
FIG. 2 is a simple block diagram of the HEA in accordance with the present invention.
FIG. 3 illustrates one embodiment of the invention in a RxAccel unit, which is a part of packet acceleration and virtualization layer from FIG. 2.
FIG. 4 is a diagram illustrating one embodiment of the PFC from FIG. 3.
FIG. 5 is a table illustrating IPv4 header field offsets as a function of layer-2 length/encapsulations and TCP header field offsets as a function of layer-2 length and IP header options.
FIG. 6 is a table illustrating a continuation of TCP header field offsets as a function of layer-2 length and IP header options.



DETAILED DESCRIPTION OF THE INVENTION
The present invention relates to a system and method for parsing, filtering, and computing the checksum of a host Ethernet adapter (HEA). The following description is presented to enable one of ordinary skill in the art to make and use the invention and is provided in the context of a patent application and its requirements. Various modifications to the preferred embodiments and the generic principles and features described herein will be readily apparent to those skilled in the art. Thus, the present invention is not intended to be limited to the embodiments shown, but is to be accorded the widest scope consistent with the principles and features described herein.
FIG. 1 is a block diagram of a server system 100 in accordance with the present invention. The server system 100 includes a processor 102 that is coupled between a memory 104 and an interface adapter chip 106. The interface adapter chip 106 includes an interface 108 to the private (Gx) bus of the processor 102 and a Host Ethernet Adapter (HEA) 110. The HEA 110 receives and transmits signals from and to the processor 102.
The HEA 110 is an integrated Ethernet adapter. A set of accelerator features are provided such that a TCP/IP stack within the servers uses those features when and as required. The interface between the processor 102 and the interface adapter chip 106 has been streamlined by bypassing the PCI bus and providing interface techniques that enable demultiplexing and multiqueueing and packet header separation. In so doing an Ethernet adapter is provided that allows for improved functionality with a high-speed system while allowing for compatibility with legacy server environments. Some of the key features of this improved functionality are described hereinbelow.
Acceleration Functions
The HEA 110 supports advanced acceleration features. One key observation is that the current acceleration functions do a good job on the transmit side (ie transmitting packets from the processor) but not a very good job on the receive side (ie receiving packets via the adapter). The HEA 110 addresses this gap by introducing new features such as Packet Demultiplexing and Multiqueueing, and Header separation.
All of the HEA 110 new features are optional; it is up to the TCP/IP stack to take advantage of them if and when required. For example, a vanilla TCP/IP stack can use the HEA 110 without using per the connection queueing feature and yet take advantage of the other features of HEA such as throughput, low latency and virtualization support.
Packets Demultiplexing and Multiqueueing
Multiqueueing and Demultiplexing is the key feature to support functions such as virtualization, per connection queueing, and OS bypass. HEA demultiplexing uses the concept of Queue Pairs, Completion Queues and Event Queues. Enhancements have been added to better address OS protocol stacks requirements and short packet latency reduction.
Depending upon system requirements and configuration, HEA can demultiplex incoming packets based on:

    
    
        Destination MAC address (typically one MAC address and one default queue per partition)
        Connection identifier (ID) for established connections (Protocol, Source IP address, Destination IP address, Source port, Destination port).
        Destination port and optionally destination IP address for TCP connection setup packet (SYN).
    
    


Packet Header Separation
The HEA 110 is optionally capable of separating the TCP/IP header from the data payload. This feature allows the header to be directed to the protocol stack for processing without polluting the received buffers posted by the applications. This feature is a component required for enabling zero-copy operations.
Enhanced Features
Many enhanced features are provided by the HEA 110 in the server environment. Some of these features are listed below.
(a) Multiple Receive Queue: The queue pair concept is extended to support more than one receive queue per pair. This enables the stack to better manage its buffer pool memory. For example, one queue can be assigned to small packets, one to medium packets and one to large packets. The HEA will select the ad hoc queue according to the received packet size.
(b) Low Latency Queue: On the transmit side a descriptor (WQE) may contain immediate data, in such case no indirection, i.e., no additional DMA from system memory is required to get the data to be sent. On the receive side, low latency queues doe not supply buffers but rather receive immediate packet data. The HEA writes to the receive queue rather than reading. Short packets take advantage of this feature leading to a dramatic reduction of DMA operations: one single DMA write per packet as opposed to one DMA read and one DMA write per packet.
(c) Receive low latency queues are also used to support the packet header separation: the header is written in the low latency queue while the payload is DMAed to a buffer indicated in the ad-hoc receive queues.
In summary, Demultiplexing and Multiqueueing, Address Translation and Packet Header Separation are the basic building blocks to virtualization and provide low latency in operation. Furthermore, it should be noted that these features can also be used to improve traditional OS protocol stack performance, for example, per-connection queueing allows for the removal of code and more importantly the memory accesses—and associated stalls/cache pollution—consumed to locate the TCP connection control block (TCB) in the system memory.
To describe the features of the HEA 110 in more detail refer now to the following description in conjunction with the accompanying figures.
FIG. 2 is a simple block diagram of the HEA 110 in accordance with the present invention. As is seen the HEA 110 has a three-layer architecture. The first layer comprises a Media Access Controller (MAC) and Serialization/Deserialization (Serdes) Layer 202, which provides a plurality of interfaces from and to other devices on the Ethernet network. In the layer 202 the same chip I/Os are used to provide a plurality of interfaces. For example, in a preferred embodiment, the same chip I/Os are utilized to provide either a 10 Gigabit interface or a 1 Gigabit interface.
The second layer comprises a Packet Acceleration and Virtualization Layer 204. The layer 204 provides for receiving packets and demultiplexing the flow of packets for enabling virtualization. The layer 204 enables virtualization or partitioning of the operating system of a server based upon the packets. The layer 204 also provides packet header separation to enable zero copy operation. Also since layer 204 interacts directly with the private bus (Gx) through the Host Interface Layer 206, a low latency, high bandwidth connection is provided.
The third layer comprises the Host Interface Layer 206. The Host Interface Layer 206 provides the interface to the Gx or private bus of the processor. The layer 206 provides for multiple receive sub-queues per Queue Pair (QP) to enable effective buffer management for a TCP stack. The host layer 206 provides the context management for a given flow of data packets.
FIG. 3 illustrates one embodiment of the invention in a RxAccel unit 300, which is a part of layer 204 (see FIG. 2). The RxAccel 300 receives data and control signals and performs parsing, filtering, checksum and lookup functions in preparation for processing by the host interface layer 206 (FIG. 2). The RxAccel 300 is composed of a Receive Backbone (RBB) 302, the Parser, Filter and Checksum Unit (PFC) 304, the Local Lookup Unit (LLU) 306, the Remote Lookup Unit (RLU) 308 and an MIB database 310.
Data flows through the RxAccel 300 from the RxMAC (not shown) unaltered. The RBB 302 manages the flow of data and is responsible for the clock and data bus width conversion functions. Control and data received from the RxMAC is used by the PFC 304 to perform acceleration functions and to make a discard decision. The PFC 304 passes control and data extracted from the frame, including the 5-tuple key, to the LLU 306 in order to resolve a Queue Pair number (QPN) for the RBB 302. The LLU 306 either finds the QPN immediately or allocates a cache entry to reserve the slot. If the current key is not in the cache, the LLU 306 searches for the key in memory. The PFC 304 interfaces to the MIB database 310 to store packet statistics.
FIG. 4 is a diagram illustrating one embodiment of PFC 304 from FIG. 3. The PFC 304 includes a PFC-Finite State Machine (FSM) 400 composed of subunits for a parse logic unit 405, a checksum (CS) logic unit 410, and an accumulator 415. The PFC-FSM 400 controls the PFC 304 and performs packet parsing and checksum functions. A MAC lookup 420 performs a lookup on the MAC destination address (DA). If a lookup on the MAC DA is found, various per-MAC flags are also found. A MAC filter 425 performs filtering on multicast packets. A virtual local area network (VLAN) filter 430 performs VLAN filtering. A MIB 435 measures performance in the PFC 400. Status information from the MAC and from the PFC 400 are sent for each packet to the MIB 435. Discard decisions based on the results from the above units are made by the PFC-FSM 400. The specifics of filtering and parsing are discussed below.
One aspect of the invention with respect to filtering, virtualization, is applied through VLAN filter 430. Rather than limiting a filter to one global policy for each adapter, VLAN filter 430 may apply a different filter for each logical partition (not shown) in the server system 100. Logical partitions may be parts of a single memory storage area (not shown), for example a hard disk drive, that are divided into different parts and appear to other systems and software as separate storage areas. Packets may be directed to these different logical partitions in the server system 100, and different criteria (or filter policy) may be used to determine whether a given packet is sent to the intended partition or not. Next, filtering in general is discussed after an introduction to data flow to the PFC.
Each frame, or packet, (not shown) received by HEA 110 may a different length, for example 5,000, 7,400 and 9,000 bits long. However, HEA 110 receives only a certain number of those bits at a time, for example up to 128 bits. In order to increase performance, PFC 304 performs “on-the-fly” parsing, filtering, and computing checksums, meaning that for each part of the entire frame that is received (for example, each block of 128 bits), PFC 304 is taking steps to parse, filter and compute the checksum of the frame so that by the time the last part of the frame is received, PFC 304 may perform, on the last part of the frame received, the last parsing, filtering and computing of the checksum that is needed for the entire frame. This saves significant time over conventional systems that do not begin those processes until after receiving the entire frame.
So each clock cycle, PFC 304 should be able to handle 128 bits. The fewest number of bits expected before filtering should begin (based on the IPv4, TCP/UDP standard) is 384. Therefore, PFC 304 must be ready to filter after as few as three clock cycles (512/128=3). Examples of pre-filtering processing performed in these clock cycles is described below.
After receiving the first 128 bits in a frame, (referred to generally as quadword or QW), in the first clock cycle the PFC 304 reads the physical-port specific policies. Then, MAC lookup 420 receives the DA MAC and may determine a logical port destination for the packet. A DA MAC hash is then formed.
In the second clock cycle, PFC 304 reads and loads into registers any logical-port specific policies looked up in the first clock cycle. Then, the PFC 304 uses the DA MAC hash and the source port for the frame to read the MAC filter policy.
In the third clock cycle, PFC 304 reads and loads into VLAN 430 the virtual LAN policy. By the fourth clock cycle, all of the filtering policies are available in the appropriate registers and PFC 304 is ready to begin filtering.
Although filtering is discussed prior to parsing, some of the steps in filtering follow steps in parsing, or are performed simultaneously with parsing. One of ordinary skill in the art will recognize that some information used in filtering must first be parsed from a frame.
Having discussed filtering in the PFC 304, parsing is discussed in the following description. An algorithm is presented in Very high-speed integrated circuit Hardware Description Language (VHDL), which is an IEEE standard, in order to help with the explanation of parsing. The algorithm may be used for parsing, for example, data in IPv4, TCP/UDP.
Along with the 128 bits (potentially) of each frame that the PFC 400 receives, the following inputs, for example, are also received:

    
    
        1. Ext_Rdy: 1 bit: RBB is giving valid data during this cycle.
        2. SOP: 1 bit: Start of Packet/Frame—Indicates whether the QW (up to 128 bits) is the start of the Frame
        3. EOP: 1 bit: End of Packet/Frame—Indicates whether the QW (up to 128 bits) is the end of the Frame
        4. Data: 128 bits: 16 bytes of data (or the potentially 128 bits, or QW) belonging to the frame. If SOP is true, these are the first 16 bytes, if EOP is true, then these are the last bytes. Meaning full only if Ext_Rdy is true, meaning this is valid data
        5. BEn: 5 bits: Number of most significant valid bytes, meaningful only if EOP is true, if EOP is not true, this is implicitly 16. Most groups will contain the full 128 bits, but at the end of the packet, fewer than 128 bits may be sent and the PFC 304 needs to know how many are being sent
        6. Stat_rdy: 1 bit: Status information is valid, (Ext_rdy need not be true). Indicates that the data is not corrupted.
        7. ByteCnt: 14 bits: Length of the frame, meaningful only if Stat_rdy is true
        8. Status: 27 bits: status of the frame, meaningful only if Stat_rdy is true.
    
    


After parsing, parse logic unit 405 will output the following:
Certain info about the layer 2 (ethernet header): Unicast/Broadcast/Multicast, VLAN Id, VLAN tagged?
Certain fields of IP header like IP SA (Source Address) and IP DA (Destination address)
Certain fields of TCP/UDP header like SP and DP (Source Port, Destination Port)
The most significant 16 bits of Data will be denoted by half-word (hw) 0 and the next 16 bits of data by hw1 and so on, The last 16 bits being hw7. Eight half-words making up the four QW of the data input to PFC 304 each cycle.
Each paragraph of bold text (referred to as “process”) describes a latch or register. There are two kinds of names derived from the same stem. For example, from the word “Step”, we have PFC_Step_O and PFC_C_Step, i.e. one with _O and one with _C. The one with _O is the value in the register/latch in the current cycle. The one with _C will be the value of the register/latch in the next cycle.
The parsing algorithm:















 if EXT_Rdy = ‘1’ and Stat_rdy= ‘0’ then PFC_C_Step <=



PFC_Step_O + 1;










 elsif Stat_rdy= ‘1’
 then PFC_C_Step <= 0;



 else
PFC_C_Step <= PFC_Step_O;



 end if;










The function of the above process is a counter (not shown) that is incremented each time a QW of data is received by the PFC 304. The counter is reset to 0 when Stat_rdy is received. ‘Step’ represents the number of quadwords given to PFC in the current frame under process. This process keeps track of the part of the frame that the PFC 304 is receiving.
The following short hand notation is used in the description of the algorithm:

    PFC_WS0 to mean the boolean condition PFC_Step_O=0 and Ext_Rdy=‘1’
    PFC_WS1 to mean the boolean condition PFC_Step_O=1 and Ext_Rdy=‘1’
    PFC_WS2 to mean the boolean condition PFC Step O=2 and Ext_Rdy=‘1’
    PFC_WS3 to mean the boolean condition PFC_Step_O=3 and Ext_Rdy=‘1’
    PFC_WSgt1 to mean the boolean condition (PFC_Step_O>1) and Ext_Rdy=‘1’
    PFC_WSgt2 to mean the boolean condition (PFC_Step_O>2) and Ext_Rdy=‘=1’


Another segment of the algorithm is:















if PFC_WS0 = ‘1’ and hw6 <= 1536 and hw7 = 0xaaaa then



  PFC_C_LLCaaaa <= ‘1’;



elsif PFC_WS0 = ‘1’ then



  PFC_C_LLCaaaa <= ‘0’; -- inter frame reset



else



  PFC_C_LLCaaaa <= PFC_LLCaaaa_O;



end if;










The function of the above process is that by examining the first QW, PFC detects whether the frame is in LLC format (i.e. not DIX). If the last hw contains “aaaa”, the frame may be a LLC/SNAP frame. If the last hw contains “aaaa,” then a bit is set that will be checked with the next hw to determine if is a LLC/SNAP frame (if it hasn't already been determined). By checking a qualifier in one hw (for example, the requirement for “aaaa”) and setting a single bit, the PFC 304 avoids having to store the entire sequence while checking another hw.
Continuing with the algorithm:












if PFC_WS0 = ‘1’ then  PFC_C_VLAN_ID <= hw7(11 downto 0);


else     PFC_C_VLAN_ID <= PFC_VLAN_ID_O;


end if;









The function of the above process is to get the VLAN identifier for VLAN filtering by the VLAN filter 430.
Continuing with the algorithm:












if PFC_WS0 = ‘1’ and hw0(8) = ‘1’ then  PFC_C_MAC_MC <=


‘1’;


elsif PFC_WS0 = ‘1’ then    PFC_C_MAC_MC <= ‘0’; -- inter


  frame reset


else


  PFC_C_MAC_MC <= PFC_MAC_MC_O;


end if;









The function of the above process is to detect whether the frame is a multicast frame (a type of frame). The lease significant bit of the most significant byte of the first QW (i.e. the eighth bit of the first byte in the first QW) of a frame received provides this information. MAC filter 425 performs filtering on multicast frames. If the frame is not a multicast frame (broadcast is a type of multicast frame), then it is assumed the frame is unicast.
Continuing with the algorithm:












if PFC_WS0 = ‘1’ and hw0 = 0xffff and hw1 = 0xffff and hw2 = 0xffff


then


  PFC_C_MAC_BC <= ‘1’;


elsif PFC_WS0 = ‘1’ then


  PFC_C_MAC_BC <= ‘0’; -- inter frame reset


  else


  PFC_C_MAC_BC <= PFC_MAC_BC_O ;









The function of the above process is to detect whether the frame is a broadcast frame. If the most significant 48 bits of the first QW received is all 1's, then the frame is an Ethernet broadcast frame.
Continuing with the algorithm:













if  PFC_WS0 = ‘1’ and hw6 = 0x8100
then PFC_C_tag <= ‘1’;


elsif PFC_WS0 = ‘1’
then PFC_C_tag <= ‘0’;


  -- inter frame reset


else
PFC_C_tag <=


PFC_tag_O;


end if;









The function of the above process is to determine if a frame is VLAN tagged. A frame is VLAN tagged if the hw6 of the first QW (bits 20-24) received by PFC 400 is 0x8100.
Continuing with the algorithm:












if (PFC_WS0 = ‘1’ and PFC_C_tag = ‘0’ and hw6 >= 1536) then


  PFC_C_DIX <= ‘1’;


elsif (PFC_WS1 = ‘1’ and PFC_C_tag = ‘1’ and hw0 >= 1536) then


  PFC_C_DIX <= ‘1’;








elsif PFC_WS0 = ‘1’ then
PFC_C_DIX <= ‘0’; -- inter frame reset


else
 PFC_C_DIX <= PFC_DIX_O;


end if;









The function of the above process is to check whether the current Ethernet frame's layer-2 header is in DIX format. If the Ethertype/Length field in the Ethernet header is =1536 then the layer-2 header is in DIX format. This Ethertype/length field could be present in hw6 of QW 0 for non-VLAN tagged frames and in hw1 of QW 1 for VLAN-tagged frames. So the location of the Ethertype/Length field depends on whether the frame is VLAN tagged or not, parsed during the immediately preceding process.
Continuing with the algorithm:












if PFC_WS0 = ‘1’ and PFC_C_tag = ‘0’ and PFC_C_DIX = ‘1’








then
PFC_C_l2Len <= “01110”; -- 14



PFC_C_l2len14 <= ‘1’;



PFC_C_l2len18 <= ‘0’;



PFC_C_l2len22 <= ‘0’;



PFC_C_l2len26 <= ‘0’;







elsif PFC_WS0 = ‘1’ and PFC_C_tag = ‘0’ and PFC_C_DIX = ‘0’








then
PFC_C_l2len <= “10110”; -- 22



PFC_C_l2len14 <= ‘0’;



PFC_C_l2len18 <= ‘0’;



PFC_C_l2len22 <= ‘1’;



PFC_C_l2len26 <= ‘0’;







elsif PFC_WS1 = ‘1’ and PFC_C_tag = ‘1’ and PFC_C_DIX = ‘1’








then
PFC_C_l2Len <= “10010”; -- 18



PFC_C_l2len14 <= ‘0’;



PFC_C_l2len18 <= ‘1’;



PFC_C_l2len22 <= ‘0’;



PFC_C_l2len26 <= ‘0’;







elsif PFC_WS1 = ‘1’ and PFC_C_tag = ‘1’ and PFC_C_DIX = ‘0’








then
PFC_C_l2Len <= “11010”; -- 26;



PFC_C_l2len14 <= ‘0’;



PFC_C_l2len18 <= ‘0’;



PFC_C_l2len22 <= ‘0’;



PFC_C_l2len26 <= ‘1’;







elsif PFC_WS0 = ‘1’








then
PFC_C_l2Len <= “00000”; -- inter frame reset



PFC_C_l2len14 <= ‘0’;



PFC_C_l2len18 <= ‘0’;



PFC_C_l2len22 <= ‘0’;



PFC_C_l2len26 <= ‘0’;


else
PFC_C_l2Len <= PFC_l2Len_O;



PFC_C_l2len14 <= PFC_l2len14_O;



PFC_C_l2len18 <= PFC_l2len18_O;



PFC_C_l2len22 <= PFC_l2len22_O;



PFC_C_l2len26 <= PFC_l2len26_O;


end if;









The function of the above process is to compute and store the layer-2 header length. Examples of layer-2 header length are 14, 18, 22 or 26. Once the layer-2 header length is computed this indicates where the layer-3 header begins, which can be used to parse the IP header.
Continuing with the algorithm:












if PFC_WS0 = ‘1’ and PFC_C_tag = ‘0’ and hw6 = 0x800


  then PFC_C_l2IPv4 <= ‘1’;


elsif PFC_WS1 = ‘1’ and PFC_C_tag = ‘1’ and hw0 = 0x800


  then PFC_C_l2IPv4 <= ‘1’;


elsif PFC_WS1 = ‘1’ and PFC_C_tag = ‘1’ and hw0 < 1536 and hw1 =


  SNAPH0 and hw2 = SNAPH1 and hw3 = SNAPH2 and hw4 =


  IPV4_ETYPE


  then PFC_C_l2IPv4 <= ‘1’;


elsif PFC_WS1 = ‘1’ and PFC_C_tag = ‘0’ and PFC_C_LLCaaaa =


‘1’ and


  hw0 = SNAPH1 and hw1 = SNAPH2 and hw2 = IPV4_ETYPE


  then PFC_C_l2IPv4 <= ‘1’;


elsif PFC_WS0 = ‘1’


  then PFC_C_l2Ipv4 <= ‘0’; -- inter frame reset


else PFC_C_l2IPv4 <= PFC_l2IPv4_O;


end if;









The function of the above process is to ensure that the frame looks like an IPv4 packet from the layer-2 header perspective. A packet will look like an IP packet from layer-2 perspective, if

    
    
        Ethertype=0x0800 with or without VLAN tag
        LLC/SNAP hdr is aaaa0300000800 with or without VLAN tag
    
    


Continuing with the algorithm:












if PFC_WS0 = ‘1’ and PFC_C_l2len14 = ‘1’ and hw7(15 downto 12) =


   4 and hw7(11 downto 8) >= 5


  then PFC_C_l3IPv4 <= ‘1’;


elsif PFC_WS1 = ‘1’ and PFC_C_l2len18 = ‘1’ and hw1 (15 downto


  12) = 4 and hw1(11 downto 8) >= 5


  then PFC_C_l3IPv4 <= ‘1’;


elsif PFC_WS1 = ‘1’ and PFC_C_l2len22 = ‘1’ and hw3(15 downto


12) = 4 and hw3(11 downto 8) >= 5


  then PFC_C_l3IPv4 <= ‘1’;


elsif PFC_WS1 = ‘1’ and PFC_C_l2len26 = ‘1’ and hw5(15 downto


12) = 4 and hw5(11 downto 8) >= 5


  then PFC_C_l3IPv4 <= ‘1’;


elsif PFC_WS0 = ‘1’


  then PFC_C_l3IPv4 <= ‘0’; --reset


else PFC_C_l3IPv4 <= PFC_l3IPv4_O;


end if;









The function of the above process is to ensure that the frame looks like an IPv4 packet from the layer-3 header perspective. A packet will look like an IP packet from the layer-3 perspective if IP version field in the IP header is 4 and header length field in IP header is equal to 5.
Continuing with the algorithm:















if PFC_WS0 = ‘1’ and PFC_C_l2len14 = ‘1’



   then PFC_C_lHL <= hw7(11 downto 8);



elsif PFC_WS1 = ‘1’ and PFC_C_l2len18 = ‘1’



   then PFC_C_lHL <= hw1(11 downto 8);



elsif PFC_WS1 = ‘1’ and PFC_C_l2len22 = ‘1’



   then PFC_C_lHL <= hw3(11 downto 8);



elsif PFC_WS1 = ‘1’ and PFC_C_l2len26 = ‘1’



   then PFC_C_lHL <= hw5(11 downto 8);



elsif PFC_WS0 = ‘1’



   then PFC_C_lHL <= “0000”; -- inter frame reset



else PFC_C_lHL <= PFC_lHL_O;



end if;










The function of the above process is to save the IP header length (in units of 4 bytes). This will provide the length of the IP header and tell where the layer-4 header (for example, TCP or UDP) begins, which is needed in order to parse layer-4.
Continuing with the algorithm:















if PFC_WS1 = ‘1’ and PFC_C_l2len14 = ‘1’ and



hw2(13 downto 0) /= 0



   then PFC_C_IPfrag <= ‘1’;



elsif PFC_WS1 = ‘1’ and PFC_C_l2len18 = ‘1’ and



hw4(13 downto 0) /= 0



   then PFC_C_IPfrag <= ‘1’;



elsif PFC_WS1 = ‘1’ and PFC_C_l2len22 = ‘1’ and



hw6(13 downto 0) /= 0



   then PFC_C_IPfrag <= ‘1’;



elsif PFC_WS2 = ‘1’ and PFC_C_l2len26 = ‘1’ and



hw0(13 downto 0) /= 0



   then PFC_C_IPfrag <= ‘1’;



elsif PFC_WS0 = ‘1’



   then PFC_C_IPfrag <= ‘0’;



else PFC_C_IPfrag <= PFC IPfrag_O; -- inter frame reset



end if;










The function of the above process is to detect whether the IP packet is an IP fragment. An IP fragment is broken up during transmission such that the TCP/UDP is not coded into the layer-3 payload. If it is an IP fragment, TCP/UDP header might not be there in the layer-3 payload. The algorithm might not parse an IP fragment. To detect whether the frame is an IP fragment, access bytes numbered 6 and 7 (note, we start at 0) in the IP header. The byte structure is (Reserved)(DF)(MF)(13 bits of frag offset). If the last 14 bits are non zero, then this is a fragment.
Continuing with the algorithm:













if EXT_Rdy = ‘1’



  then PFC_C_l2l3IPv4
<= PFC_C_l2IPv4 and PFC_C_l3IPv4;


else PFC_C_l2l3IPv4
<= PFC_L2L3IPv4_O;


end if;









The function of the above process is to detect whether the frame is an IPv4 frame from both the layer-2 (Ethernet layer) and layer-3 (Internet layer) perspective.
Continuing with the algorithm:













if PFC_WS1 = ‘1’ and PFC_C_l2len14 = ‘1’ and hw3(7 downto 0) = 6



  then PFC_C_encIPv4prot <= “10”; -- TCP


elsif PFC_WS1 = ‘1’ and PFC_C_l2len14 = ‘1’ and


hw3(7 downto 0) = 17


  then PFC_C_encIPv4prot <= “11”; -- UDP


elsif PFC_WS1 = ‘1’ and PFC_C_l2len18 = ‘1’ and


hw5(7 downto 0) = 6


  then PFC_C_encIPv4prot <= “10”; -- TCP


elsif PFC_WS1 = ‘1’ and PFC_C_l2len18 = ‘1’ and


hw5(7 downto 0) = 17


  then PFC_C_encIPv4prot <= “11”; -- UDP


elsif PFC_WS1 = ‘1’ and PFC_C_l2len22 = ‘1’ and


hw7(7 downto 0) = 6


  then PFC_C_encIPv4prot <= “10”; -- TCP


elsif PFC_WS1 = ‘1’ and PFC_C_l2len22 = ‘1’ and


hw7(7 downto 0) = 17


  then PFC_C_encIPv4prot <= “11”; -- UDP


 -------------------------------------------------------------------------


 ---   Step 2


 -------------------------------------------------------------------------


elsif PFC_WS2 = ‘1’ and PFC_C_l2len26 = ‘1’ and


hw1(7 downto 0) = 6


  then PFC_C_encIPv4prot <= “10”; -- TCP


elsif PFC_WS2 = ‘1’ and PFC_C_l2len26 = ‘1’ and


hw1(7 downto 0) = 17


  then PFC_C_encIPv4prot <= “11”; -- UDP


elsif PFC_WS0 = ‘1’


  then PFC_C_encIPv4prot <= “00”; -- inter frame reset


else PFC_C_encIPv4prot <= PFC_encIPv4prot_O;


end if;









The function of the above process is to detect the layer-4 protocol payload by examining the protocol field in the IP header. This process assumes that the packet is TCP/UDP over IPv4. If the 8-bit protocol field at byte 10 of the IPv4 Header is decimal 6 then its in TCP. However, if it is decimal 17 then its in UDP.
Continuing with the algorithm:












if PFC_WS1 = ‘1’ and PFC_C_l2len14 = ‘1’


   then PFC_C_SAh <= hw5;


elsif PFC_WS1 = ‘1’ and PFC_C_l2len18 = ‘1’


   then PFC_C_SAh <= hw7;


elsif PFC_WS2 = ‘1’ and PFC_C_l2len22 = ‘1’


   then PFC_C_SAh <= hw1;


elsif PFC_WS2 = ‘1’ and PFC_C_l2len26 = ‘1’


   then PFC_C_SAh <= hw3;


elsif PFC_WS0 = ‘1’


   then PFC_C_SAh <= “0000000000000000”; -- inter frame reset


else PFC_C_SAh <= PFC_SAh_O;


end if;









The function of the above process is to save the IP SA (Source Address). The IP SA is 4 bytes long, and it can straddle 2 QW. So, the entire IP SA might not be received at the same time. Since layer-2 lengths are multiples of 2 and the IP SA lies on a 4-byte boundary within an IP header, the IP SA can only break at a two-byte boundary if the whole of IP SA is not received at the same time.
Continuing with the algorithm:












if PFC_WS1 = ‘1’ and PFC_C_l2len14 = ‘1’


  then PFC_C_SAl <= hw6;


elsif PFC_WS2 = ‘1’ and PFC_C_l2len18 = ‘1’


  then PFC_C_SAl <= hw0;


elsif PFC_WS2 = ‘1’ and PFC_C_l2len22 = ‘1’


  then PFC_C_SAl <= hw2;


elsif PFC_WS2 = ‘1’ and PFC_C_l2len26 = ‘1’


  then PFC_C_SAl <= hw4;


elsif PFC_WS0 = ‘1’


  then PFC_C_SAl <= “0000000000000000”; -- inter frame reset


else PFC_C_SAl <= PFC_SAl_O;


end if; In this manner, any field of the IP header can be determined.


if PFC_WS1 = ‘1’


  then PFC_C_SPstk <= (“00”&PFC_C_l2Len) +


  (“0”&PFC_C_IHL & “00”);


elsif PFC_WS0 = ‘1’


  then PFC_C_SPstk <= “0000000”;  -- inter frame reset


else PFC_C_SPstk <= PFC_SPstk_O;


end if;









The function of the above process is to get the TCP/UDP SP to LLU 306. The byte offsets (from the start of the frame) in which the hw that contains TCP/UDP SP could be several (44 in fact, 4 layer-2 hdr lengths×11 IP header lengths). In order to avoid writing if/then/else statement with 44 branches (which typically requires a large multiplexer that consumes a large space), compute a 7-bit stake where the field of interest lies. The 7-bit stake could be interpreted as (SSS)(BBBB) where S is the step number and B is the byte offset at which the field of interest could be located.
The byte-offset (stake) from the start of the frame to the hw in the TCP header contains the TCP SP, which is given by layer-2 header length+IP header length. CP SP is the start of the TCP header. In a similar manner, the stake of any field in the Layer-4 header, for example DP (Destination port) can be figured out. See FIGS. 5 and 6 for more details on offset.
The proof for using SPstk_O instead of C_SPstk is that the earliest step in which SP could be encountered is 2, while the latest step in which PFC_SPstk becomes stable is 1.
Continuing with the algorithm:












if EXT_Rdy = ‘1’ and PFC_Step_O = “0”&PFC_SPstk_O(6 downto 4)


and PFC_SPstk_O(3 downto 0) = 0


   then PFC_C_SP <= hw0;


elsif EXT_Rdy = ‘1’ and PFC_Step_O = “0”&PFC_SPstk_O(6


downto 4) and PFC_SPstk_O(3 downto 0) = 2


   then PFC_C_SP <= hw1;


elsif EXT_Rdy = ‘1’ and PFC_Step_O = “0”&PFC_SPstk_O(6


downto 4) and PFC_SPstk_O(3 downto 0) = 4


   then PFC_C_SP <= hw2;


elsif EXT_Rdy = ‘1’ and PFC_Step_O = “0”&PFC_SPstk_O(6


downto 4) and PFC_SPstk_O(3 downto 0) = 6


   then PFC_C_SP <= hw3;


elsif EXT_Rdy = ‘1’ and PFC_Step_O = “0”&PFC_SPstk_O(6


downto 4) and PFC_SPstk_O(3 downto 0) = 8


   then PFC_C_SP <= hw4;


elsif EXT_Rdy = ‘1’ and PFC_Step_O = “0”&PFC_SPstk_O(6


downto 4) and PFC_SPstk_O(3 downto 0) = 10


   then PFC_C_SP <= hw5;


elsif EXT_Rdy = ‘1’ and PFC_Step_O = “0”&PFC_SPstk_O(6


downto 4) and PFC_SPstk_O(3 downto 0) = 12


   then PFC_C_SP <= hw6;


elsif EXT_Rdy = ‘1’ and PFC_Step_O = “0”&PFC_SPstk_O(6


downto 4) and PFC_SPstk_O(3 downto 0) = 14


   then PFC_C_SP <= hw7;


elsif PFC_WS0 = ‘1’


   then PFC_C_SP <= “0000000000000000”; -- inter frame reset


else PFC_C_SP <= PFC_SP_O;


end if;









The function of the above process is to store a field from the TCP/UDP header. SP and DP occur at the same offsets for TCP and UDP. So, there is no need to distinguish between TCP and UDP. The stake (byte offset from the start of the frame) has been computed and stored in PFC_SPstk. When the step counter matches the ms 3 bits of the stake, the Is 4 bits specify the byte offset within the current QW of data of the TCP/UDP SP. In the same way, any field in TCP/UDP header can be stored.
Note that for the following, PFC_C_norunt is true when the number of bytes received in the current frame is equal to 64, i.e. when PFC_Step_O>4 or *(PFC_Step_O=3 and the number bytes being processed by PFC is 16). Continuing with the algorithm:












if PFC_C_norunt = ‘1’ and (PFC_l2IPv4_O = ‘0’


or PFC_l3IPv4_O = ‘0’)


   then PFC_C_Parsing_complete_VE92 <= ‘1’;


elsif PFC_C_norunt = ‘1’ and (PFC_l2IPv4_O = ‘1’ and


PFC_l3IPv4_O = ‘1’) and PFC_encIPv4prot_O =


ENCIPv4PROT_UNS


   then PFC_C_Parsing_complete_VE92 <= ‘1’;


  --------------------------------------------------------------------


  -- TCP/IPv4: Complete when SYN flag is received and no runt


  -- If PFC_C_norunt = 1, then PFC 304 is processing the QW


  numbered 3.


  -- Qw 0,1,2 have been received in the previous cycles.


  -- This means TCP_HLflags_Stake, l2IPv4, l3IPv4,


  PFC_encIPv4prot are all


stable. Could use latch output.


  --------------------------------------------------------------------


elsif EXT_Rdy = ‘1’ and


PFC_C_norunt = ‘1’   -- non-runt


and PFC_l2IPv4_O = ‘1’ and PFC_l3IPv4_O = ‘1’ and


PFC_encIPv4prot_O = ENCIPv4PROT_TCP -- TCP/IP frame


and (PFC_Step_O > (“0”&PFC_TCP_HLflags_stake_O(6


downto 4))


   or  (PFC_Step_O = (“0”&PFC_TCP_HLflags_stake_O(6


   downto 4))


   and  (EXT_END  =  ‘0’  or  last_byte_stk_t  >


PFC_TCP_HLflags_stake_O(3 downto 0))))


   then PFC_C_Parsing_complete_VE92 <= ‘1’;


  --------------------------------------------------------------------


  -- UDP/IPv4: Complete when DP is received and no runt


  -- If PFC_C_norunt = 1, then we are processing the QW numbered 3.


  -- Qw 0,1,2 have been received in the previous cycles.


  -- This means TCP_HLflags_Stake, l2IPv4, l3IPv4,


  PFC_encIPv4prot are all


stable. Could use latch output.


  --------------------------------------------------------------------


elsif EXT_Rdy = ‘1’ and EXT_Error = ‘0’ and


PFC_C_norunt = ‘1’ -- non-runt


and PFC_l2IPv4_O = ‘1’ and PFC_l3IPv4_O = ‘1’ and


PFC_encIPv4prot_O = ENCIPv4PROT_UDP -- UDP/IP frame and


PFC_Step_O    > (“0”&PFC_DPstk_O(6 downto 4))


   or  (PFC_Step_O = (“0”&PFC_DPstk_O(6 downto 4))


   and (EXT_END = ‘0’ or last_byte_stk_t >


   PFC_DPstk_O(3 downto 0))))


   then PFC_C_Parsing_complete_VE92 <= ‘1’;


elsif PFC_WS0 = ‘1’


   then PFC_C_Parsing_complete_VE92 <= ‘0’; -- Inter frame


   reset


else PFC_C_Parsing_complete_VE92<=


PFC_Parsing_complete_VE92_O;


end if;









In conclusion of the parsing, the results from the PFC 304 are forwarded to the RBB 302 directly and through the LLU 306. The results may include whether or not to discard the frame, the header split length, the checksum, and VLAN swap.
FIG. 5 is a table illustrating IPv4 header field offsets as a function of layer-2 length/encapsulations and TCP header field offsets as a function of layer-2 length and IP header options.
FIG. 6 is a table illustrating a continuation of TCP header field offsets as a function of layer-2 length and IP header options.
In summary, PFC 304 performs the functions of:

    
    
        Packet parsing for:
        
            Ethernet DIX and SNAP Header
            IPv4 Header (for IP checksum validation)
            TCP header (for TCP checksum validation, Syn detection, and TCP port number)
            UDP header (for UDP checksum validation and UDP port number)
        
        
        IP checksum validation
        TCP packet validation
        TCP checksum validation
        UDP checksum validation
        Blind checksum calculation
        Unicast MAC destination lookup
        Multicast (broadcast) MAC destination address filtering through 4K bit array
        6-tuple key assembly (input to hash)
        MIB counters
    
    


According to the method and system disclosed herein, the present invention discloses a system and method for parsing, filtering, and computing the checksum in a HEA. One skilled in the art will recognize that the particular standards used are exemplary, and any bandwidth-limited network may apply the invention in the above manner. The present invention has been described in accordance with the embodiments shown, and one of ordinary skill in the art will readily recognize that there could be variations to the embodiments, and any variations would be within the spirit and scope of the present invention. Accordingly, many modifications may be made by one of ordinary skill in the art without departing from the spirit and scope of the appended claims.

## Claims

1. A method for parsing, filtering, and computing a checksum using a host Ethernet adapter (HEA) coupled to a host computer, the method comprising:
receiving a part of a frame with the HEA, wherein a plurality of parts of the frame constitute an entire frame;
parsing the part of the frame with the HEA before receiving the entire frame;
computing a checksum of the part of the frame with the HEA before receiving the entire frame;
filtering, with the HEA, the part of the frame based on a logical, port-specific policy before receiving the entire frame,
wherein a plurality of parts of the frame are received to constitute the frame, and wherein at a time when a last part of the frame is received, the parsing, filtering, and computing the checksum is performed on the last part of the frame with no additional parsing, filtering, and computing the checksum needed for the frame;
transmitting the checksum with the HEA to the host computer; and
during reception of one or more initial parts of the plurality of parts of the frame with the HEA, performing pre-filtering processing with the HEA including loading the logical, port specific filter policy into one or more registers of the HEA for use with the filtering.

2. The method of claim 1, wherein the parsing step comprises:
keeping track of the part of the frame that is received; and
determining if the frame is in a particular format, wherein the format can be any of a multicast, broadcast or unicast format.

3. The method of claim 1, wherein the pre-filtering processing is performed such that the HEA is ready to filter the part of the frame using the logical, port specific policy after a number of clock cycles of the HEA in accordance with a soonest time specified by a standard used by the HEA in receiving the parts of the frame.

4. The method of claim 3, wherein the pre-filtering processing includes:
reading a plurality of filter policies and loading the plurality of filter policies into registers of the HEA, the plurality of filter policies including a MAC filter policy, a Virtual Local Area Network (VLAN) filter policy, and the logical port specific policy, such that the HEA is ready to filter the part of the frame using the plurality of filter policies after the number of clock cycles of the HEA in accordance with the soonest time specified by the standard used by the HEA in receiving the parts of the frame; and
determining a logical port destination of the frame.

5. The method of claim 1, wherein the parsing step detects a protocol payload by examining a protocol field in a header of the frame.

6. The method of claim 1, which includes forwarding results to the filtering step.

7. The method of claim 1, wherein a minimum number of portions of the frame are required to be received before the filtering of the part of the frame is performed, and wherein the pre-filtering processing is started during the reception of the initial parts of the frame and is performed and completed by the time the minimum number of portions of the frame are received.

8. The method of claim 1, wherein the filtering includes Virtual Local Area Network (VLAN) filtering.

9. The method of claim 1, wherein the filtering includes applying a different filter for each of a plurality of different logical partitions provided in a single memory storage area in a server system, wherein each of the logical partitions has different criteria to determine whether a frame is sent to that logical partition.

10. The method of claim 1 further comprising detecting whether the frame is an IP fragment indicating that the frame was broken up during transmission and a particular protocol header is not present in the frame.

11. The method of claim 1 wherein the parsing includes parsing a particular field in a header in the frame using a byte-offset stake that indicates a location of the particular field in the frame, wherein a first portion of the bits of the stake are used to indicate a particular one of the parts of the frame numbered from the beginning of the frame, and a second portion of the bits of the stake determines a byte offset within the particular part of the frame.

12. A host Ethernet adapter (HEA) coupled to a host computer, the HEA for parsing, filtering, and computing a checksum, the system comprising:
a mechanism for receiving a part of a frame, wherein a plurality of parts of the frame constitute an entire frame;
a parser for parsing the part of the frame before receiving the entire frame;
a mechanism for computing a checksum of the part of the frame before receiving the entire frame;
a mechanism for filtering the part of the frame based on a logical, port-specific policy before receiving the entire frame,
wherein a plurality of parts of the frame are received to constitute the frame, and wherein at a time when a last part of the frame is received, the parser, the mechanism for filtering, and the mechanism for computing the checksum perform parsing, filtering, and computing the checksum, respectively, on the last part of the frame with no additional parsing, filtering, and computing the checksum needed for the frame;
a mechanism for transmitting the checksum to the host computer; and
a mechanism for performing pre-filtering processing during reception of one or more initial parts of the plurality of parts of the frame, the pre-filtering processing including loading the logical, port specific filter policy into one or more registers of the HEA for use with the filtering.

13. The host Ethernet adapter of claim 12, wherein the pre-filtering processing is performed such that the mechanism for filtering is ready to filter the part of the frame using the logical, port specific policy after a number of clock cycles of the HEA in accordance with a soonest time specified by a standard used by the HEA in receiving the parts of the frame.

14. The host Ethernet adapter of claim 12, wherein the parser keeps track of the part of the frame that is received and determines if the frame is in a particular format.

15. The host Ethernet adapter of claim 14, wherein the format can be any of a multicast, broadcast or unicast format.

16. The host Ethernet adapter of claim 12, wherein a minimum number of portions of the frame are required to be received before the mechanism for filtering filters the part of the frame, and wherein the filtering initialization is started during the reception of the initial parts of the frame and is performed and completed by the time the minimum number of portions of the frame are received.

17. The host Ethernet adapter of claim 12, wherein the mechanism for performing pre-filtering processing reads a plurality of filter policies and loads the plurality of filter policies into registers of the HEA, the plurality of filter policies including a MAC filter policy, a Virtual Local Area Network (VLAN) filter policy, and the logical port specific policy, and wherein the mechanism for performing pre-filtering processing determines a logical port destination of the frame.

18. The host Ethernet adapter of claim 12, wherein the mechanism for filtering applies a different filter for each of a plurality of different logical partitions provided in a single memory storage area in a server system, wherein each of the logical partitions has different criteria to determine whether a frame is sent to that logical partition.

19. The host Ethernet adapter of claim 12 further comprising a mechanism for detecting whether the frame is an IP fragment indicating that the frame was broken up during transmission and a particular protocol header is not present in the frame.

20. The host Ethernet adapter of claim 12 wherein the parser parses a particular field in a header in the frame using a byte-offset stake that indicates a location of the particular field in the frame, wherein a first portion of the bits of the stake are used to indicate a particular one of the parts of the frame numbered from the beginning of the frame, and a second portion of the bits of the stake determines a byte offset within the particular part of the frame.