[IPoIB NDIS 6.0 CM]
authortzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 17 Nov 2009 12:28:29 +0000 (12:28 +0000)
committertzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 17 Nov 2009 12:28:29 +0000 (12:28 +0000)
Bugfix: free NBL only after freeing SG. (mlnx 5114)

git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@2569 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

ulp/ipoib_NDIS6_CM/kernel/ipoib_adapter.cpp
ulp/ipoib_NDIS6_CM/kernel/ipoib_driver.cpp
ulp/ipoib_NDIS6_CM/kernel/ipoib_port.cpp

index d975c36..97e859d 100644 (file)
@@ -737,8 +737,7 @@ __ipoib_pnp_cb(
                                                                           NDIS_STATUS_LINK_STATE,\r
                                                                           (PVOID)&link_state,\r
                                                                           sizeof(link_state));\r
-                               IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_INIT,\r
-                       ("Indicate DISCONNECT\n") );\r
+                               IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_INIT, ("Indicate DISCONNECT\n") );\r
                                NdisMIndicateStatusEx(p_adapter->h_adapter,&status_indication);                 \r
                        }\r
                }\r
index a3cfc3f..497739a 100644 (file)
@@ -440,12 +440,8 @@ ipoib_halt_ex(
 \r
 NDIS_STATUS\r
 ipoib_query_info(\r
-       IN                              NDIS_HANDLE                                     adapter_context,\r
-       IN                              NDIS_OID                                        oid,\r
-       IN                              PVOID                                           info_buf,\r
-       IN                              ULONG                                           info_buf_len,\r
-               OUT                     PULONG                                          p_bytes_written,\r
-               OUT                     PULONG                                          p_bytes_needed );\r
+    IN         NDIS_HANDLE         adapter_context,\r
+    IN  OUT PNDIS_OID_REQUEST   pNdisRequest);\r
 \r
 \r
 \r
@@ -456,12 +452,9 @@ ipoib_reset(
 \r
 NDIS_STATUS\r
 ipoib_set_info(\r
-       IN                              NDIS_HANDLE                                     adapter_context,\r
-       IN                              NDIS_OID                                        oid,\r
-       IN                              PVOID                                           info_buf,\r
-       IN                              ULONG                                           info_buf_length,\r
-               OUT                     PULONG                                          p_bytes_read,\r
-               OUT                     PULONG                                          p_bytes_needed );\r
+    IN         NDIS_HANDLE         adapter_context,\r
+    IN  OUT PNDIS_OID_REQUEST   pNdisRequest);\r
+\r
 \r
 //NDIS60\r
 void\r
@@ -2222,14 +2215,12 @@ __ipoib_get_offload_config(
 NDIS_STATUS_INVALID_LENGTH, NDIS_STATUS_NOT_ACCEPTED, NDIS_STATUS_NOT_SUPPORTED,\r
 NDIS_STATUS_RESOURCES\r
 */\r
+\r
 NDIS_STATUS\r
 ipoib_query_info(\r
-       IN                              NDIS_HANDLE                                     adapter_context,\r
-       IN                              NDIS_OID                                        oid,\r
-       IN                              PVOID                                           info_buf,\r
-       IN                              ULONG                                           info_buf_len,\r
-               OUT                     PULONG                                          p_bytes_written,\r
-               OUT                     PULONG                                          p_bytes_needed )\r
+    IN         NDIS_HANDLE         adapter_context,\r
+    IN  OUT PNDIS_OID_REQUEST   pNdisRequest)\r
+\r
        {\r
                ipoib_adapter_t         *p_adapter;\r
                NDIS_STATUS             status;\r
@@ -2246,17 +2237,18 @@ ipoib_query_info(
                \r
                IPOIB_ENTER( IPOIB_DBG_OID );\r
                \r
-               oid_info.oid = oid;\r
-               oid_info.p_buf = info_buf;\r
-               oid_info.buf_len = info_buf_len;\r
-               oid_info.p_bytes_used = p_bytes_written;\r
-               oid_info.p_bytes_needed = p_bytes_needed;\r
+               oid_info.oid = pNdisRequest->DATA.QUERY_INFORMATION.Oid;\r
+               oid_info.p_buf = pNdisRequest->DATA.QUERY_INFORMATION.InformationBuffer;\r
+               oid_info.buf_len = pNdisRequest->DATA.QUERY_INFORMATION.InformationBufferLength;\r
+               oid_info.p_bytes_used = (PULONG)&pNdisRequest->DATA.QUERY_INFORMATION.BytesWritten;\r
+               oid_info.p_bytes_needed = (PULONG)&pNdisRequest->DATA.QUERY_INFORMATION.BytesNeeded;\r
+               oid_info.p_pending_oid = NULL;\r
                \r
                CL_ASSERT( adapter_context );\r
                p_adapter = (ipoib_adapter_t*)adapter_context;\r
 \r
-               CL_ASSERT( p_bytes_written );\r
-               CL_ASSERT( p_bytes_needed );\r
+               CL_ASSERT( oid_info.p_bytes_used );\r
+               CL_ASSERT( oid_info.p_bytes_needed );\r
                CL_ASSERT( !p_adapter->pending_query );\r
                \r
                status = NDIS_STATUS_SUCCESS;\r
@@ -2265,7 +2257,7 @@ ipoib_query_info(
        \r
                port_num = p_adapter->guids.port_num;\r
        \r
-               switch( oid )\r
+               switch( oid_info.oid )\r
                {\r
                /* Required General */\r
                case OID_GEN_SUPPORTED_LIST:\r
@@ -2326,7 +2318,7 @@ ipoib_query_info(
                case OID_GEN_LINK_SPEED:\r
                        IPOIB_PRINT( TRACE_LEVEL_INFORMATION,IPOIB_DBG_OID,\r
                                ("Port %d received query for OID_GEN_LINK_SPEED\n", port_num) );\r
-                       if (info_buf_len < buf_len)\r
+                       if (oid_info.buf_len < buf_len)\r
                        {\r
                                break;\r
                        }\r
@@ -2340,6 +2332,7 @@ ipoib_query_info(
        \r
                                /* Save the request parameters. */\r
                                p_adapter->query_oid = oid_info;\r
+                               p_adapter->query_oid.p_pending_oid = pNdisRequest;\r
        \r
                                IPOIB_PRINT( TRACE_LEVEL_INFORMATION,IPOIB_DBG_OID,\r
                                        ("Port %d returning NDIS_STATUS_PENDING\n", port_num) );\r
@@ -2467,6 +2460,7 @@ ipoib_query_info(
                                 */\r
                                p_adapter->pending_query = TRUE;\r
                                p_adapter->query_oid = oid_info;\r
+                               p_adapter->query_oid.p_pending_oid = pNdisRequest;\r
        \r
                                IPOIB_PRINT( TRACE_LEVEL_INFORMATION,IPOIB_DBG_OID,\r
                                        ("Port %d returning NDIS_STATUS_PENDING\n", port_num) );\r
@@ -2505,7 +2499,7 @@ ipoib_query_info(
                                ("Port %d received query for OID_GEN_STATISTICS\n", port_num) );\r
                        src_buf = NULL;   \r
                         buf_len =  sizeof(NDIS_STATISTICS_INFO);\r
-                       if (info_buf_len < buf_len)\r
+                       if (oid_info.buf_len < buf_len)\r
                        {\r
                           break;\r
                        } \r
@@ -2677,9 +2671,9 @@ ipoib_query_info(
                        break;\r
                case OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES:\r
             buf_len = sizeof(NDIS_OFFLOAD);\r
-            if (buf_len < info_buf_len)\r
+            if (buf_len < oid_info.buf_len)\r
             {\r
-                *p_bytes_needed = buf_len;\r
+                *oid_info.p_bytes_needed = buf_len;\r
                                return NDIS_STATUS_BUFFER_TOO_SHORT;\r
             }\r
 \r
@@ -2717,7 +2711,7 @@ ipoib_query_info(
                case OID_PNP_CAPABILITIES:\r
                        status = NDIS_STATUS_NOT_SUPPORTED;\r
                        IPOIB_PRINT( TRACE_LEVEL_INFORMATION,IPOIB_DBG_OID,\r
-                               ("Port %d received an unsupported oid of 0x%.8X!\n", port_num, oid) );\r
+                               ("Port %d received an unsupported oid of 0x%.8X!\n", port_num, oid_info.oid) );\r
                        break;\r
        \r
                case OID_GEN_PROTOCOL_OPTIONS:\r
@@ -2727,7 +2721,7 @@ ipoib_query_info(
                        IPOIB_PRINT( TRACE_LEVEL_INFORMATION,IPOIB_DBG_OID,\r
                                ("Port %d received query for OID_GEN_PROTOCOL_OPTIONS or OID_GEN_NETWORK_LAYER_ADDRESSES or OID_GEN_TRANSPORT_HEADER_OFFSET  OID_PNP_ENABLE_WAKE_UPn", port_num) );\r
                        IPOIB_PRINT( TRACE_LEVEL_INFORMATION,IPOIB_DBG_OID,\r
-                               ("Number of OID: 0x%.8X!\n", oid) );\r
+                               ("Number of OID: 0x%.8X!\n", oid_info.oid) );\r
                        status = NDIS_STATUS_SUCCESS; \r
                        break;\r
                        \r
@@ -2742,10 +2736,10 @@ ipoib_query_info(
                        IPOIB_PRINT( TRACE_LEVEL_INFORMATION,IPOIB_DBG_OID,\r
                                ("Port %d received query for OID_PNP_QUERY_POWER\n", port_num) );\r
                                //ulBytesAvailable = ulInfoLen = sizeof(NDIS_OFFLOAD);\r
-                               if (info_buf_len <  sizeof(NDIS_OFFLOAD))\r
+                               if (oid_info.buf_len <  sizeof(NDIS_OFFLOAD))\r
                                {\r
                                        \r
-                                       *p_bytes_needed = sizeof(NDIS_OFFLOAD) ;\r
+                                       *oid_info.p_bytes_needed = sizeof(NDIS_OFFLOAD) ;\r
                                        return NDIS_STATUS_BUFFER_TOO_SHORT;\r
                                }\r
        \r
@@ -2756,7 +2750,7 @@ ipoib_query_info(
                default:\r
                        status = NDIS_STATUS_INVALID_OID;\r
                        IPOIB_PRINT( TRACE_LEVEL_ERROR,IPOIB_DBG_ERROR,\r
-                               ("Port %d received an invalid oid of 0x%.8X!\n", port_num, oid) );\r
+                               ("Port %d received an invalid oid of 0x%.8X!\n", port_num, oid_info.oid) );\r
                        break;\r
                }\r
        \r
@@ -2873,23 +2867,6 @@ SetOffloadEncapsulation(
     return NDIS_STATUS_SUCCESS;\r
 }\r
 \r
-#if 0\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
-\r
-       return NDIS_STATUS_SUCCESS;\r
-\r
-       \r
-}\r
-#endif\r
-\r
-\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
@@ -2953,12 +2930,9 @@ NDIS_STATUS_NOT_SUPPORTED, NDIS_STATUS_RESOURCES
 */\r
 NDIS_STATUS\r
 ipoib_set_info(\r
-       IN                              NDIS_HANDLE                                     adapter_context,\r
-       IN                              NDIS_OID                                        oid,\r
-       IN                              PVOID                                           info_buf,\r
-       IN                              ULONG                                           info_buf_len,\r
-               OUT                     PULONG                                          p_bytes_read,\r
-               OUT                     PULONG                                          p_bytes_needed )\r
+    IN         NDIS_HANDLE         adapter_context,\r
+    IN  OUT PNDIS_OID_REQUEST   pNdisRequest)\r
+\r
 {\r
        ipoib_adapter_t*        p_adapter;\r
        NDIS_STATUS                     status;\r
@@ -2973,6 +2947,12 @@ ipoib_set_info(
        CL_ASSERT( adapter_context );\r
        p_adapter = (ipoib_adapter_t*)adapter_context;\r
 \r
+       NDIS_OID    oid = pNdisRequest->DATA.SET_INFORMATION.Oid;\r
+       PVOID       info_buf = pNdisRequest->DATA.SET_INFORMATION.InformationBuffer;\r
+       UINT        info_buf_len = pNdisRequest->DATA.SET_INFORMATION.InformationBufferLength;\r
+       PULONG          p_bytes_read = (PULONG)&pNdisRequest->DATA.SET_INFORMATION.BytesRead;\r
+       PULONG          p_bytes_needed = (PULONG)&pNdisRequest->DATA.SET_INFORMATION.BytesNeeded;\r
+       \r
        CL_ASSERT( p_bytes_read );\r
        CL_ASSERT( p_bytes_needed );\r
        CL_ASSERT( !p_adapter->pending_set );\r
@@ -3020,6 +3000,7 @@ ipoib_set_info(
                                p_adapter->set_oid.buf_len = info_buf_len;\r
                                p_adapter->set_oid.p_bytes_used = p_bytes_read;\r
                                p_adapter->set_oid.p_bytes_needed = p_bytes_needed;\r
+                               p_adapter->set_oid.p_pending_oid = pNdisRequest;\r
                                p_adapter->pending_set = TRUE;\r
                                status = NDIS_STATUS_PENDING;\r
                                break;\r
@@ -3214,8 +3195,8 @@ ipoib_set_info(
 \r
 static NDIS_STATUS\r
 ipoib_oid_handler(\r
-    IN  NDIS_HANDLE         adapter_context,\r
-    IN  PNDIS_OID_REQUEST   pNdisRequest)\r
+    IN         NDIS_HANDLE         adapter_context,\r
+    IN  OUT PNDIS_OID_REQUEST   pNdisRequest)\r
 {\r
     NDIS_REQUEST_TYPE       RequestType;\r
        NDIS_STATUS     status = NDIS_STATUS_SUCCESS;\r
@@ -3227,22 +3208,12 @@ ipoib_oid_handler(
        switch(RequestType)\r
        {\r
         case NdisRequestSetInformation:            \r
-            status = ipoib_set_info(adapter_context,\r
-                                               pNdisRequest->DATA.SET_INFORMATION.Oid,\r
-                                               pNdisRequest->DATA.SET_INFORMATION.InformationBuffer,\r
-                                               pNdisRequest->DATA.SET_INFORMATION.InformationBufferLength,\r
-                                               (PULONG)&pNdisRequest->DATA.SET_INFORMATION.BytesRead,\r
-                                               (PULONG)&pNdisRequest->DATA.SET_INFORMATION.BytesNeeded);\r
+            status = ipoib_set_info(adapter_context, pNdisRequest);\r
             break;\r
                 \r
         case NdisRequestQueryInformation:\r
         case NdisRequestQueryStatistics:\r
-            status = ipoib_query_info(adapter_context,\r
-                                               pNdisRequest->DATA.QUERY_INFORMATION.Oid,\r
-                                               pNdisRequest->DATA.QUERY_INFORMATION.InformationBuffer,\r
-                                               pNdisRequest->DATA.QUERY_INFORMATION.InformationBufferLength,\r
-                                               (PULONG)&pNdisRequest->DATA.QUERY_INFORMATION.BytesWritten,\r
-                                               (PULONG)&pNdisRequest->DATA.QUERY_INFORMATION.BytesNeeded);\r
+            status = ipoib_query_info(adapter_context, pNdisRequest);\r
                                                \r
             break;\r
 \r
@@ -3332,7 +3303,8 @@ ipoib_send_net_buffer_list(
 \r
                \r
                cl_perf_start( PortSend );\r
-               \r
+               IPOIB_PRINT( TRACE_LEVEL_VERBOSE, IPOIB_DBG_SEND,\r
+                               ("Sending NBL=%p, g_NBL=%d, g_NBL_completed=%d \n", curr_net_buffer_list, g_NBL, g_NBL_complete) );\r
                ipoib_port_send( p_port, curr_net_buffer_list, send_flags);\r
                cl_perf_stop( &p_adapter->perf, PortSend );\r
        }\r
@@ -3347,7 +3319,7 @@ compl_status:
        {\r
 \r
                IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
-                               ("Got bad status \n") );\r
+                               ("Got bad status, g_NBL=%d, g_NBL_completed=%d \n", g_NBL, g_NBL_complete) );\r
                send_complete_flags = 0;\r
            \r
                for (curr_net_buffer_list = net_buffer_list;\r
index 5b86eae..5afe93d 100644 (file)
@@ -5487,23 +5487,23 @@ __send_complete_net_buffer(
                PNDIS_TCP_LARGE_SEND_OFFLOAD_NET_BUFFER_LIST_INFO pLsoInfo =    \r
                        (PNDIS_TCP_LARGE_SEND_OFFLOAD_NET_BUFFER_LIST_INFO) (PULONG)&NET_BUFFER_LIST_INFO(s_buf->p_nbl, TcpLargeSendNetBufferListInfo);\r
         if(pLsoInfo->Transmit.Type == NDIS_TCP_LARGE_SEND_OFFLOAD_V1_TYPE)\r
-        {            \r
-            UINT TcpPayLoad = 0;\r
+               {            \r
+                       UINT TcpPayLoad = 0;\r
                        //TODO optimize this code during MSS/LSO building\r
-            for (PNET_BUFFER NetBuffer = NET_BUFFER_LIST_FIRST_NB(s_buf->p_nbl);\r
-                 NetBuffer != NULL ; \r
-                 NetBuffer = NET_BUFFER_NEXT_NB(NetBuffer))\r
-            {\r
-                //TcpPayLoad += IPOIB_TCP_PAYLOAD_FROM_NB(NetBuffer);           \r
-                TcpPayLoad += s_buf->tcp_payload;\r
-            }\r
-            pLsoInfo->LsoV1TransmitComplete.TcpPayload = TcpPayLoad;            \r
-        }\r
-        else if (pLsoInfo->Transmit.Type == NDIS_TCP_LARGE_SEND_OFFLOAD_V2_TYPE)\r
-        {\r
-            pLsoInfo->LsoV2TransmitComplete.Reserved = 0;\r
-            pLsoInfo->LsoV2TransmitComplete.Type = NDIS_TCP_LARGE_SEND_OFFLOAD_V2_TYPE;\r
-        }\r
+                       for (PNET_BUFFER NetBuffer = NET_BUFFER_LIST_FIRST_NB(s_buf->p_nbl);\r
+                            NetBuffer != NULL ; \r
+                            NetBuffer = NET_BUFFER_NEXT_NB(NetBuffer))\r
+                       {\r
+                       \r
+                               TcpPayLoad += s_buf->tcp_payload;\r
+                       }\r
+                       pLsoInfo->LsoV1TransmitComplete.TcpPayload = TcpPayLoad;            \r
+               }\r
+           else if (pLsoInfo->Transmit.Type == NDIS_TCP_LARGE_SEND_OFFLOAD_V2_TYPE)\r
+           {\r
+               pLsoInfo->LsoV2TransmitComplete.Reserved = 0;\r
+               pLsoInfo->LsoV2TransmitComplete.Type = NDIS_TCP_LARGE_SEND_OFFLOAD_V2_TYPE;\r
+           }\r
                \r
                if (bLock) {\r
                        cl_spinlock_release( &s_buf->p_port->send_lock );\r
@@ -5514,10 +5514,7 @@ __send_complete_net_buffer(
                        NdisMSendNetBufferListsCompleteX( s_buf->p_port->p_adapter->h_adapter,\r
                                s_buf->p_nbl, compl_flags );\r
                }\r
-       } else {\r
-               IPOIB_PRINT(TRACE_LEVEL_INFORMATION, IPOIB_DBG_SEND,\r
-               ("BAD BAD BAD COUNTER=%d for NBL=0x%p .\n",  s_buf->p_nbl, IPOIB_GET_NET_BUFFER_LIST_REF_COUNT(s_buf->p_nbl) ));\r
-       }\r
+       } \r
 \r
        \r
        //Free SGL element allocated by NDIS\r