On Thu, Sep 06, 2007 at 08:12:23PM +0300, Michael S. Tsirkin wrote: > > FWIW, general gateways do have a bit of a problem doing the csum > > insertion because there are alot of cases and new protocols do crop up > > from time to time. It would be best if part of the information sent in > > this case was instructions on how to do the insertion like an general > > ethernet chip would use. > > Not sure I know what do you mean. Could you give an example please?
Ok, this is basically what the comments in skbuff.h about NETIF_F_HW_CSUM vs NETIF_F_IP_CSUM are about, it applies just as well to this case as to a NIC case. Look at how skb_copy_and_csum_dev/skb_checksum_help works for generic csumming. Basically, the trick is the hw csum operates over a specified subset of the packet. The csum value to update must be within that subset and its location is also specified in the skb (csum_offset). The kernel computes the IP pseudo header (or really any other additional bits that get csumed) in advance and initializes the csum field in the packet. The HW then csums the range *which includes the csum field* and then replaces the csum field with this new value. The results in the hardware computing csum(pseudo_hdr) + csum(payload) without actually having any idea what the pseudo_hdr is. This is generic non-protocol specific offload (NETIF_F_HW_CSUM). This is how CHECKSUM_PARTIAL works. CHECKSUM_COMPLETE is the analog on the RX side. The HW computes a csum across every byte of the packet and stores that out of band. Again through the properties of the csum you can subtract bytes you don't want summed (more or less the csum of the negative of the psuedo_hdr) from the csum and get a MAGIC constant back if the packet csum is valid. This is how protocol agnostic recieve csum offload is done. Adding this to the IPoIB 'VNIC' wire protocol would relieve anyone from actually having to figure out the pseudo_hdr and L4 protocol to deduce the proper algorithm for computing the csum (NETIF_F_IP_CSUM) Jason _______________________________________________ general mailing list [email protected] http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general
