# Patent

## Title
System and method for fault tolerant TCP offload

## Abstract

Systems and methods that provide fault tolerant transmission control protocol (TCP) offloading are provided. In one example, a method that provides fault tolerant TCP offloading is provided. The method may include one or more of the following steps: receiving TCP segment via a TCP offload engine (TOE); calculating a TCP sequence number; writing a receive sequence record based upon at least the calculated TCP sequence number to a TCP sequence update queue in a host; and updating a first host variable with a value from the written receive sequence record.

## Background
RELATED APPLICATIONS
This application is a CONTINUATION of U.S. application Ser. No. 11/696,398, filed Apr. 4, 2007, and issuing on Jun. 29, 2010 as U.S. Pat. No. 7,746,867; which is a CONTINUATION of U.S. application Ser. No. 10/337,029, filed Jan. 6, 2003, now U.S. Pat. No. 7,224,692; which claims priority to and claims benefit from U.S. Provisional Patent Application Ser. No. 60/408,207, entitled “System and Method for Fault Tolerant TCP Offload” and filed on Sep. 4, 2002. The above-identified applications are hereby incorporated herein by reference in their entirety.


INCORPORATION BY REFERENCE
The above-referenced United States patent application is hereby incorporated herein by reference in its entirety.
BACKGROUND OF THE INVENTION
Transmission control protocol (TCP) connections may be offloaded to a dedicated TCP offload engine (TOE) to increase performance and to reduce host CPU utilization. Some TCP state variables (e.g., a TCP sequence number (TCP_SEQ), a TCP acknowledgement number (TCP_ACK), etc.) are managed entirely by the dedicated TOE after the TCP connection is offloaded. However, using the TOE increases the risk of an unreliable TCP connection. For example, in the event of a TOE hardware failure, the values of the TCP variables are lost. The host CPU must then terminate the TCP connection.
Further limitations and disadvantages of conventional and traditional approaches will become apparent to one of ordinary skill in the art through comparison of such systems with aspects of the present invention as set forth in the remainder of the present application with reference to the drawings.
BRIEF SUMMARY OF THE INVENTION
Aspects of the present invention may be found in, for example, systems and methods that provide fault tolerant TCP offloading. In one embodiment, the present invention may provide a method that provides fault tolerant TCP offloading. The method may include, for example, one or more of the following steps: receiving a TCP segment via a TOE; calculating a TCP sequence number; writing a receive sequence record based upon at least the calculated TCP sequence number to a TCP sequence update queue in a host; and updating a first host variable with a value from the written receive sequence record.
In another embodiment, the present invention may provide a system that provides fault tolerant TCP offloading. The system may include, for example, a host coupled to a TOE. The host may include, for example, a first host variable storage buffer and a TCP sequence update data structure. A TCP segment may be received by the TOE. A TCP sequence number may be calculated based upon the received TCP segment. A receive sequence record based upon at least the calculated TCP sequence number may be written to the TCP sequence update data structure. The first host variable storage buffer may be updated with a value from the written receive sequence record.
These and other features and advantages of the present invention may be appreciated from a review of the following detailed description of the present invention, along with the accompanying figures in which like reference numerals refer to like parts throughout.



BRIEF DESCRIPTION OF THE DRAWINGS
FIG. 1 shows a block diagram of an embodiment of a system that provides fault tolerant TCP offload according to the present invention.
FIG. 2 shows a flow chart illustrating an embodiment of an initialization process carried out by a host according to the present invention.
FIGS. 3A-B show a flow chart illustrating an embodiment of protocol processing by a TCP offload engine according to the present invention.
FIG. 4 shows a flow chart illustrating an embodiment of protocol processing by a host according to the present invention.
FIGS. 5A-B show flow charts illustrating embodiments of processes that detect faults according to the present invention.
FIGS. 6A-B show flow charts illustrating embodiments of processes that provide corrective action according to the present invention.



DETAILED DESCRIPTION OF THE INVENTION
FIG. 1 shows a block diagram of an embodiment of a system that provides fault tolerant TCP offload according to the present invention. The system 10 may include, for example, a host 20, a host interface 30 and a TOE 40. The host 20 may include, for example, a host CPU 25, a TCP sequence update queue 50, a transmission (TX) buffer 60, a reception (RX) buffer 70, a timer 80, a HOST_RCV_NEXT buffer 90 and a HOST_SND_UNA buffer 100. Although some components may be described as queues or buffers, the present invention contemplates that other memory structures or storage structures may be used. The TOE 40 may include, for example, a NEW_RCV_NEXT buffer 110, an RCV_NEXT buffer 120 and an SND_UNA buffer 130. The host 20 may be coupled to the TOE 40 via the host interface 30, which may be, for example, a peripheral component interconnect (PCI). The TOE 40 may also be coupled to a physical communications medium 140 such as, for example, an Ethernet.
The operations of an embodiment of the system 10 according to the present invention may be categorized into at least four phases: initialization, protocol processing, fault detection and corrective action.
FIG. 2 shows a flow chart illustrating an embodiment of an initialization process carried out by the host (e.g., a host CPU) according to the present invention. In step 150, the host 20 may save a copy of all TCP state variables. In step 160, the host 20 may initialize and may maintain a variable indicating a host sequence number based upon the next received segment (i.e., a HOST_RCV_NEXT variable). The HOST_RCV_NEXT variable, which may be stored in the HOST_RCV_NEXT buffer 90, may be set to a RCV_NEXT variable, which may be stored in the RCV_NEXT buffer 120 of the TOE 40. The host 20 may initialize and may maintain a variable indicating a host sequence number for the first un-acknowledged data (i.e., a HOST_SND_UNA variable). The HOST_SND_UNA variable, which may be stored in the HOST_SND_UNA buffer 100, may be set to the SND_UNA variable, which may be stored in the SND_UNA buffer 130 of the TOE 40. In step 170, the TCP sequence update queue 50 may be initialized. In step 180, the host 20 may notify, via the host interface 30, the TOE 40 of the location of the TCP sequence update queue 50 in the host buffers. The TOE 40 may save the address of the TCP sequence update queue 50.
FIGS. 3A-B show a flow chart illustrating an embodiment of protocol processing by the TOE according to the present invention. FIG. 3A shows that, for TCP segments received in order from the physical communications medium (e.g., the Ethernet), the TOE may perform one or more of the steps as set forth below. In step 190, the TOE may calculate a new TCP received sequence number. The new TCP received sequence number may be stored in the NEW_RCV_NEXT buffer 110. In step 200, the TOE 40 may transfer the received segment or a portion thereof to a host buffer. In one example, the TOE 40 may employ a direct memory access (DMA) engine to place the received segment in the RX buffer 70. The received segment may include, for example, a payload, a data segment, etc. In step 210, the TOE may write a receive sequence record with the new TCP received sequence number to the TCP sequence update queue 50. In step 220, the RCV_NEXT variable stored in the RCV_NEXT buffer 120 may be updated with the new TCP received sequence number. In step 225, the TOE may use RCV_NEXT to generate an outgoing TCP segment which acknowledges the receipt of the received TCP segment being placed into host buffer.
In query 230, the TOE may determine for every TCP segment received whether the TCP segment acknowledges previously sent data. If the previously sent data is not acknowledged, then the process may be complete. If the previously sent data is acknowledged, then, in step 240, the SND_UNA variable stored in the SND_UNA buffer 130 may be updated with the new TCP received sequence number. In step 250, a send sequence record with the updated SND_UNA value may be written to the TCP sequence update queue 50.
FIG. 4 shows a flow chart illustrating an embodiment of protocol processing by the host according to the present invention. For every TCP segment received in order, the host (e.g., host CPU) may, in step 260, remove the corresponding entry from the TCP sequence update queue 50. The corresponding entry may be, for example, the receive sequence record written into the TCP sequence update queue 50. In step 270, the host 20 may update HOST_RCV_NEXT variable stored in the HOST_RCV_NEXT buffer 90 with the value from the removed (e.g., de-queued) entry. In query 280, the host 20 may determine whether the TCP segment acknowledges previously sent data. If the previously sent data is not acknowledged, then the process may be complete. If the previously sent data is acknowledged, then, in step 290, a corresponding entry from the TCP sequence update queue may be removed. The corresponding entry may be, for example, the send sequence record written into the TCP sequence update queue 50. In step 300, the HOST_SND_UNA variable stored in the HOST_SND_UNA buffer 100 may be updated with the value in the de-queued entry.
FIGS. 5A-B show flow charts illustrating embodiments of processes that detect faults according to the present invention. FIG. 5A shows a flow chart of an embodiment of a process that monitors for a failure event generated by the TOE 40 according to the present invention. In step 310, the host 20 (e.g., the host CPU 25) may monitor the TCP sequence update queue 50. The host 20 may search for a failure event (e.g., a hardware failure event) that may have been generated by the TOE 40. In query 320, the host 20 may determine whether a failure has occurred, for example, in the TOE 40. If the host 20 does not detect a failure event, then the process may loop back to step 310. If the host 20 does detect a failure event (e.g., detects a hardware failure event generated by the TOE 40), then the, in step 330, corrective action may be taken as set forth below.
FIG. 5B shows a flow chart of an embodiment of a process that probes the TOE according to the present invention. In step 340, the host 20 may probe the TOE 40. For example, the host may use the timer 80 to periodically probe the TOE 40. In query 350, the host 20 may determine whether the TOE has responded to the probe in a timely manner. If a proper response to the probe is received by the host 20 from the TOE 40 within a particular period of time, then the TOE 40 may be considered not to have failed and the process may loop back to step 340. If an improper response to the probe is received by the host 20 from the TOE 40, then the host 20 may consider the TOE 40 to have failed. An improper response may be, for example, no response, an improperly formed response or a late response (i.e., received after the elapse of a particular period of time).
In an embodiment of a process that detects faults according to the present invention, the TOE 40 may try with its best efforts to report a hardware failure by transferring all the TCP state variables to the host 20 (e.g., the host CPU 25) via the TCP sequence update queue.
FIGS. 6A-B show flow charts illustrating embodiments of processes that provide corrective action according to the present invention. FIG. 6A shows a flow chart illustrating an embodiment of a process that provides corrective action if the fault is detected via an improper response to a probe according to the present invention. For example, if the fault is detected via a timeout, then corrective action may take place including one or more of the steps as set forth below. In step 370, the host 20 (e.g., the host CPU) may assign the HOST_SND_UNA variable to the SND_UNA variable. In step 380, the host 20 may assign the HOST_RCV_NEXT variable to the RCV_NEXT variable. In step 390, the host 20 may simulate TCP processing when the TCP retransmission timer is triggered. In step 400, the host continues the TCP connection in software. In one example, the host 20 may use another network interface (e.g., network interface card (NIC)) instead of the TOE 40.
FIG. 6B shows a flow chart illustrating an embodiment of a process that provides corrective action if the fault is reported by the TOE 40 according to the present invention. In step 410, the host 20 may update the TCP state variables using the values reported by the TOE 40 via the TCP sequence update queue 50. In step 420, the host may continue the TCP connection in software. In one example, the host may continue the TCP connection in software using the updated TCP state variables.
While the present invention has been described with reference to certain embodiments, it will be understood by those skilled in the art that various changes may be made and equivalents may be substituted without departing from the scope of the present invention. In addition, many modifications may be made to adapt a particular situation or material to the teachings of the present invention without departing from its scope. Therefore, it is intended that the present invention not be limited to the particular embodiment disclosed, but that the present invention will include all embodiments falling within the scope of the appended claims.

## Claims

1. In a network interface, a method for interfacing a host computer to a communication network, the method comprising:
in a network interface:
in a first mode of operation, where the first mode of operation comprises receiving in-order TCP segments, at least:
receiving a TCP segment;
calculating a TCP received sequence number based upon the received TCP segment;
updating a value of a first network interface variable with the calculated TCP received sequence number; and
transferring only a portion of the received TCP segment to a buffer of the host, wherein said transferring comprises using direct memory access to transfer the portion; and

in a recovery mode of operation, at least:
transferring the received TCP segment to a buffer of the host for TCP processing by the host.

2. The method of claim 1, comprising in the recovery mode of operation, utilizing a network interface card different from an interface utilized in the first mode of operation.

3. The method of claim 1, comprising in the recovery mode of operation, setting state variables in the network interface.

4. The method of claim 1, comprising in the recovery mode of operation, setting state variables in the network interface under control of the host.

5. The method of claim 1, comprising in the recovery mode of operation, receiving TCP segments out-of-order.

6. The method of claim 5, comprising in the recovery mode of operation, monitoring ACK messages to determine when received TCP segments are back in order.

7. The method of claim 1, wherein the transferred portion of the received TCP segment is a payload of the received TCP segment.

8. The method of claim 1, comprising:
detecting a communication condition; and
in response to at least detecting the communication condition:
entering the recovery mode of operation; and
transferring TCP state variable information to the host.

9. The method of claim 8, wherein detecting a communication condition comprise detecting a fault.

10. The method of claim 1, comprising, during an initialization mode of operation, receiving buffer address information from the host.

11. The method of claim 1, wherein the network interface comprises a TCP offload engine.

12. In a network interface for interfacing a host computer to a communication network, at least one circuit operable to, at least:
in a first mode of operation, where the first mode of operation comprises receiving in-order TCP segments, at least:
receive a TCP segment;
calculate a TCP received sequence number based upon the received TCP segment;
update a value of a first network interface variable with the calculated TCP received sequence number; and
transfer only a portion of the received TCP segment to a buffer of the host, where said at least one circuit is operable to transfer the portion using direct memory access; and

in a recovery mode of operation, at least:
transfer the received TCP segment to a buffer of the host for TCP processing by the host.

13. The network interface of claim 12, wherein in the recovery mode of operation, the at least one circuit is operable to utilize a network interface card different from an interface utilized in the first mode of operation.

14. The network interface of claim 12, wherein in the recovery mode of operation, the at least one circuit is operable to set state variables in the network interface.

15. The network interface of claim 12, wherein in the recovery mode of operation, the at least one circuit is operable to set state variables in the network interface under control of the host.

16. The network interface of claim 12, wherein in the recovery mode of operation, the at least one circuit is operable to receive TCP segments out-of-order.

17. The network interface of claim 16, wherein in the recovery mode of operation, the at least one circuit is operable to monitor ACK messages to determine when received TCP segments are back in order.

18. The network interface of claim 12, where said only a portion of the received TCP segment is a payload of the received TCP segment.

19. The network interface of claim 12, where the at least one circuit is operable to:
detect a communication condition; and
in response to at least detecting the communication condition:
enter the recovery mode of operation; and
transfer TCP state variable information to the host.

20. The network interface of claim 19, wherein the at least one circuit is operable to detect a communication condition by, at least in part, operating to detect a fault.

21. The network interface of claim 12, wherein the at least one circuit is operable to, during an initialization mode of operation, receive buffer address information from the host.

22. The network interface of claim 12, wherein the network interface comprises a TCP offload engine.