[IPoIB] Fix NDIS WHQL 1c_OffloadInvalid test failure.
authorftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 13 Mar 2006 18:04:04 +0000 (18:04 +0000)
committerftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 13 Mar 2006 18:04:04 +0000 (18:04 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@244 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

ulp/ipoib/kernel/ipoib_driver.c

index 6850cde..4047adb 100644 (file)
@@ -1289,8 +1289,8 @@ __ipoib_get_tcp_task_offload(
                p_adapter->guids.port_num) );\r
 \r
        buf_len = sizeof(NDIS_TASK_OFFLOAD_HEADER) +\r
-               sizeof(NDIS_TASK_OFFLOAD) +\r
-               sizeof(NDIS_TASK_TCP_IP_CHECKSUM) - 1;\r
+               offsetof( NDIS_TASK_OFFLOAD, TaskBuffer ) +\r
+               sizeof(NDIS_TASK_TCP_IP_CHECKSUM);\r
 \r
        *(p_oid_info->p_bytes_needed) = buf_len;\r
 \r
@@ -1354,6 +1354,69 @@ __ipoib_get_tcp_task_offload(
 }\r
 \r
 \r
+static NDIS_STATUS\r
+__ipoib_set_tcp_task_offload(\r
+       IN                              ipoib_adapter_t*                        p_adapter,\r
+       IN                              void* const                                     p_info_buf,\r
+       IN                              ULONG* const                            p_info_len )\r
+{\r
+       NDIS_TASK_OFFLOAD_HEADER        *p_offload_hdr;\r
+       NDIS_TASK_OFFLOAD                       *p_offload_task;\r
+       NDIS_TASK_TCP_IP_CHECKSUM       *p_offload_chksum;\r
+\r
+       IPOIB_TRACE( IPOIB_DBG_OID | IPOIB_DBG_INFO,\r
+               ("Port %d received set for OID_TCP_TASK_OFFLOAD\n",\r
+               p_adapter->guids.port_num) );\r
+\r
+       p_offload_hdr = (NDIS_TASK_OFFLOAD_HEADER*)p_info_buf;\r
+\r
+       if( *p_info_len < sizeof(NDIS_TASK_OFFLOAD_HEADER) )\r
+               return NDIS_STATUS_INVALID_LENGTH;\r
+\r
+       if( p_offload_hdr->Version != NDIS_TASK_OFFLOAD_VERSION )\r
+               return NDIS_STATUS_INVALID_DATA;\r
+\r
+       if( p_offload_hdr->Size != sizeof(NDIS_TASK_OFFLOAD_HEADER) )\r
+               return NDIS_STATUS_INVALID_LENGTH;\r
+\r
+       if( !p_offload_hdr->OffsetFirstTask )\r
+               return NDIS_STATUS_SUCCESS;\r
+\r
+       if( p_offload_hdr->EncapsulationFormat.Encapsulation !=\r
+               IEEE_802_3_Encapsulation )\r
+       {\r
+               return NDIS_STATUS_INVALID_DATA;\r
+       }\r
+\r
+       p_offload_task = (NDIS_TASK_OFFLOAD*)\r
+               (((UCHAR*)p_offload_hdr) + p_offload_hdr->OffsetFirstTask);\r
+\r
+       if( *p_info_len < sizeof(NDIS_TASK_OFFLOAD_HEADER) +\r
+               offsetof( NDIS_TASK_OFFLOAD, TaskBuffer ) +\r
+               sizeof(NDIS_TASK_TCP_IP_CHECKSUM) )\r
+       {\r
+               return NDIS_STATUS_INVALID_LENGTH;\r
+       }\r
+\r
+       if( p_offload_task->Version != NDIS_TASK_OFFLOAD_VERSION )\r
+               return NDIS_STATUS_INVALID_DATA;\r
+       p_offload_chksum =\r
+               (NDIS_TASK_TCP_IP_CHECKSUM*)p_offload_task->TaskBuffer;\r
+\r
+       if( !p_adapter->params.send_chksum_offload &&\r
+               (p_offload_chksum->V4Transmit.IpOptionsSupported ||\r
+               p_offload_chksum->V4Transmit.TcpOptionsSupported ||\r
+               p_offload_chksum->V4Transmit.TcpChecksum ||\r
+               p_offload_chksum->V4Transmit.UdpChecksum ||\r
+               p_offload_chksum->V4Transmit.IpChecksum) )\r
+       {\r
+               return NDIS_STATUS_NOT_SUPPORTED;\r
+       }\r
+\r
+       return NDIS_STATUS_SUCCESS;\r
+}\r
+\r
+\r
 //! Issues a hardware reset to the NIC and/or resets the driver's software state.\r
 /*  Tear down the connection and start over again.  This is only called when there is a problem.\r
 For example, if a send, query info, or set info had a time out.  MiniportCheckForHang will\r
@@ -1575,8 +1638,10 @@ ipoib_set_info(
        case OID_TCP_TASK_OFFLOAD:\r
                IPOIB_TRACE( IPOIB_DBG_OID | IPOIB_DBG_INFO,\r
                        ("Port %d received set for OID_TCP_TASK_OFFLOAD\n", port_num) );\r
-               /* TODO: See if we need to handle this OID, or if just setting the\r
-               * checksum OK flags in the packets always works. */\r
+\r
+               buf_len = info_buf_len;\r
+               status =\r
+                       __ipoib_set_tcp_task_offload( p_adapter, info_buf, &buf_len );\r
                break;\r
 \r
        /* Optional General */\r