]> git.openfabrics.org - ~shefty/rdma-win.git/commitdiff
Refresh of umad-dbg
authorSean Hefty <sean.hefty@intel.com>
Fri, 18 Jun 2010 18:04:35 +0000 (11:04 -0700)
committerSean Hefty <sean.hefty@intel.com>
Fri, 18 Jun 2010 18:04:35 +0000 (11:04 -0700)
trunk/core/al/al_mad.c
trunk/ulp/libibumad/src/umad.cpp

index f11ac2b257ddc9ca314320305f5c265dd65a789f..51310f990b4a27f8b914c29baefc936f4fa43cae 100644 (file)
@@ -61,6 +61,7 @@
 \r
 #define AL_RMPP_WINDOW                 16                              /* Max size of RMPP window */\r
 #define AL_REASSEMBLY_TIMEOUT  5000                    /* 5 seconds */\r
+#define AL_RMPP_RETRIES                        5\r
 \r
 static void\r
 __cleanup_mad_disp(\r
@@ -1452,6 +1453,12 @@ __init_send_mad(
                        return IB_INVALID_SETTING;\r
                }\r
 \r
+               if( !p_mad_element->timeout_ms )\r
+                       p_mad_element->timeout_ms = AL_REASSEMBLY_TIMEOUT;\r
+\r
+               if( !h_send->retry_cnt )\r
+                       h_send->retry_cnt = AL_RMPP_RETRIES;\r
+\r
                p_rmpp_hdr->rmpp_version = rmpp_version;\r
                p_rmpp_hdr->rmpp_type = IB_RMPP_TYPE_DATA;\r
                ib_rmpp_set_resp_time( p_rmpp_hdr, IB_RMPP_NO_RESP_TIME );\r
index f033cbe672555f8724b02aac04b0ca23f1d65796..99a918779f2589d9bac3e53f76f262494284123b 100644 (file)
@@ -49,7 +49,6 @@ typedef struct um_port
        IWMProvider *prov;\r
        NET64           dev_guid;\r
        OVERLAPPED      overlap;\r
-       BOOL            pending;\r
        UINT8           port_num;\r
 \r
 }      um_port_t;\r
@@ -590,6 +589,14 @@ int umad_send(int portid, int agentid, void *umad, int length,
        return 0;\r
 }\r
 \r
+static void umad_cancel_recv(um_port_t *port)\r
+{\r
+       DWORD bytes;\r
+\r
+       port->prov->CancelOverlappedRequests();\r
+       port->prov->GetOverlappedResult(&port->overlap, &bytes, TRUE);\r
+}\r
+\r
 __declspec(dllexport)\r
 int umad_recv(int portid, void *umad, int *length, int timeout_ms)\r
 {\r
@@ -599,18 +606,12 @@ int umad_recv(int portid, void *umad, int *length, int timeout_ms)
 \r
        port = &ports[portid];\r
        hr = port->prov->Receive(mad, sizeof(WM_MAD) + (size_t) *length, &port->overlap);\r
-\r
        if (hr == WV_IO_PENDING) {\r
-               if (port->pending && timeout_ms == 0) {\r
-                       do {\r
-                               hr = WaitForSingleObject(port->overlap.hEvent, 250);\r
-                       } while (hr == WAIT_TIMEOUT && port->pending);\r
-               } else {\r
-                       hr = WaitForSingleObject(port->overlap.hEvent, (DWORD) timeout_ms);\r
-                       if (hr == WAIT_TIMEOUT) {\r
-                               _set_errno(EWOULDBLOCK);\r
-                               return -EWOULDBLOCK;\r
-                       }\r
+               hr = WaitForSingleObject(port->overlap.hEvent, (DWORD) timeout_ms);\r
+               if (hr == WAIT_TIMEOUT) {\r
+                       umad_cancel_recv(port);\r
+                       _set_errno(EWOULDBLOCK);\r
+                       return -EWOULDBLOCK;\r
                }\r
        }\r
 \r
@@ -620,7 +621,6 @@ int umad_recv(int portid, void *umad, int *length, int timeout_ms)
        }\r
 \r
        if (mad->Length <= (UINT32) *length) {\r
-               port->pending = FALSE;\r
                hr = (HRESULT) mad->Id;\r
                umad_convert_av(&mad->Address, &((struct ib_user_mad *) mad)->addr);\r
        } else {\r
@@ -641,19 +641,20 @@ int umad_poll(int portid, int timeout_ms)
 \r
        port = &ports[portid];\r
        hr = port->prov->Receive(&mad, sizeof mad, &port->overlap);\r
-\r
        if (hr == WV_IO_PENDING) {\r
                hr = WaitForSingleObject(port->overlap.hEvent, (DWORD) timeout_ms);\r
                if (hr == WAIT_TIMEOUT) {\r
+                       umad_cancel_recv(port);\r
+                       _set_errno(ETIMEDOUT);\r
                        return -ETIMEDOUT;\r
                }\r
        }\r
 \r
        if (FAILED(hr) && hr != ERROR_MORE_DATA) {\r
+               _set_errno(EIO);\r
                return -EIO;\r
        }\r
 \r
-       port->pending = TRUE;\r
        return 0;\r
 }\r
 \r
@@ -705,7 +706,6 @@ int umad_register(int portid, int mgmt_class, int mgmt_version,
 __declspec(dllexport)\r
 int umad_unregister(int portid, int agentid)\r
 {\r
-       ports[portid].pending = FALSE;\r
        return ports[portid].prov->Deregister((UINT64) agentid);\r
 }\r
 \r