Offloading Checksum Tasks (NDIS 5.1)

Offloading Checksum Tasks (NDIS 5.1)

Note   NDIS 5. x has been deprecated and is superseded by NDIS 6. x. For new NDIS driver development, see Network Drivers Starting with Windows Vista. For information about porting NDIS 5. x drivers to NDIS 6. x, see Porting NDIS 5.x Drivers to NDIS 6.0.

Checksum tasks cannot be offloaded to a load-balancing miniport driver. For more information about load balancing, see Load Balancing and Failover.

Before passing to the miniport driver a packet descriptor for a packet on which the miniport driver will perform one or more checksum tasks, the TCP/IP transport specifies the checksum information associated with the packet descriptor. This information is specified by an NDIS_TCP_IP_CHECKSUM_PACKET_INFOstructure, which is part of the per-packet information (extended out-of-band data) that is associated with the packet descriptor.

The NDIS_TCP_IP_CHECKSUM_PACKET_INFO structure is defined as:

      ULONG    NdisPacketChecksumV4:1;
      ULONG    NdisPacketChecksumV6:1;
      ULONG    NdisPacketTcpChecksum:1;
      ULONG    NdisPacketUdpChecksum:1;
      ULONG    NdisPacketIpChecksum:1;
    } Transmit;
      ULONG   NdisPacketTcpChecksumFailed:1;
      ULONG   NdisPacketUdpChecksumFailed:1;
      ULONG   NdisPacketIpChecksumFailed:1;
      ULONG   NdisPacketTcpChecksumSucceeded:1;
      ULONG   NdisPacketUdpChecksumSucceeded:1;
      ULONG   NdisPacketIpChecksumSucceeded:1;
      ULONG   NdisPacketLoopback:1;
    } Receive;
  ULONG    Value;

Before offloading the checksum calculation for a TCP packet, the TCP/IP transport calculates the one's complement sum for the TCP pseudoheader. The TCP/IP transport calculates the one's complement sum across all fields in the pseudoheader, including Source IP Address, Destination IP Address, Protocol, and the TCP length for TCP packets. The TCP/IP transport enters the one's complement sum for the pseudoheader in the Checksum field of the TCP header.

The one's complement sum for the pseudoheader provided by the TCP/IP transport gives the NIC an early start in calculating the real TCP checksum for the send packet. To calculate the actual TCP checksum, the NIC calculates the variable part of the TCP checksum (for the TCP header and payload), adds this checksum to the one's complement sum for the pseudoheader calculated by the TCP/IP transport, and calculates the 16-bit one's complement for the checksum. For more information about calculating such checksums, see RFC 793 and RFC 1122.

Note that the TCP/IP transport always ensures that the checksum field in the IP header of a packet is set to zero before passing the packet to an underlying miniport driver. The miniport driver should ignore the checksum field in an IP header. The miniport driver does not need to verify that the checksum field is set to zero and does not need to set this field to zero.

After it receives the packet descriptor in its MiniportSend, MiniportSendPackets, or MiniportCoSendPacketsfunction, a miniport driver typically does the following checksum processing:

  1. NDIS_PER_PACKET_INFO_FROM_PACKET macro with an InfoType of TcpIpCheckSumPacketInfo to obtain a NDIS_TCP_IP_CHECKSUM_PACKET_INFO structure. Alternatively, the miniport driver can call the NDIS_PACKET_EXTENSION_FROM_PACKET macro to obtain a pointer to the NDIS_PACKET_EXTENSION structure. The miniport driver can then use the TcpIpCheckSumPacketInfo array index to obtain the NDIS_TCP_IP_CHECKSUM_PACKET_INFO structure.

  2. The miniport driver tests the NdisPacketChecksumV4 flag in the NDIS_TCP_IP_CHECKSUM_PACKET_INFO structure. If the NdisPacketChecksumV4 flag is not set, the miniport driver's NIC should not perform any checksum operations on the packet.

  3. If the NdisPacketChecksumV4 flag is set, the miniport driver tests the NdisPacketTcpChecksum, NdisPacketUdpChecksum, and NdisPacketIpChecksum flags to determine which checksums its NIC should calculate for the packet.

  4. The miniport driver passes the packet to its NIC, which calculates the appropriate checksums for the packet. If a packet has both a tunnel IP header and a transport IP header, a NIC that supports IP checksum offloads performs IP checksum tasks only on the tunnel header. The TCP/IP transport performs IP checksum tasks on the transport IP header.

Before indicating up a receive packet on which it performs checksum tasks, the miniport driver validates the appropriate checksum(s) and sets the appropriate NdisPacketXxxChecksumFailed and/or NdisPacketXxxChecksumSucceeded flags in the NDIS_TCP_IP_CHECKSUM_PACKET_INFO structure.



Send comments about this topic to Microsoft

© 2016 Microsoft