]> git.openfabrics.org - ~shefty/rdma-win.git/commitdiff
nd2: add SRQ support for 32-bit library
authorSean Hefty <sean.hefty@intel.com>
Tue, 27 Jul 2010 22:23:27 +0000 (22:23 +0000)
committerSean Hefty <sean.hefty@intel.com>
Tue, 27 Jul 2010 22:23:27 +0000 (22:23 +0000)
The SRQ receive code assumes that ND_SGE can map
to a WV_SGE.  This is only true for 64-bit platforms.
A 32-bit library must convert ND_SGE to WV_SGE.  The
ND_SGE size varies based on the build; WV_SGE is a fixed
size for all platforms.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
git-svn-id: svn://openib.tc.cornell.edu/gen1@2857 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

trunk/ulp/netdirect2/user/nd_srq.cpp

index 749961769ce5b6594f2b53fc2379d3ca6d443688..edbc70cf7a23fb79d36e12b8a7e0aae28fd3efe2 100644 (file)
@@ -1,5 +1,6 @@
 /*\r
  * Copyright (c) 2009-2010 Intel Corporation. All rights reserved.\r
+ * Copyright (c) 2010 Microsoft Corporation.  All rights reserved.\r
  *\r
  * This software is available to you under the OpenIB.org BSD license\r
  * below:\r
@@ -123,6 +124,16 @@ Notify(OVERLAPPED* pOverlapped)
        return NDConvertWVStatus(hr);\r
 }\r
 \r
+#ifdef _WIN64\r
+\r
+C_ASSERT(sizeof(WV_SGE) == sizeof(ND_SGE));\r
+C_ASSERT(FIELD_OFFSET(WV_SGE, pAddress)   == FIELD_OFFSET(ND_SGE, Buffer));\r
+C_ASSERT(RTL_FIELD_SIZE(WV_SGE, pAddress) == RTL_FIELD_SIZE(ND_SGE, Buffer));\r
+C_ASSERT(FIELD_OFFSET(WV_SGE, Length)     == FIELD_OFFSET(ND_SGE, BufferLength));\r
+C_ASSERT(RTL_FIELD_SIZE(WV_SGE, Length)   == RTL_FIELD_SIZE(ND_SGE, BufferLength));\r
+C_ASSERT(FIELD_OFFSET(WV_SGE, Lkey)       == FIELD_OFFSET(ND_SGE, MemoryRegionToken));\r
+C_ASSERT(RTL_FIELD_SIZE(WV_SGE, Lkey)     == RTL_FIELD_SIZE(ND_SGE, MemoryRegionToken));\r
+\r
 STDMETHODIMP CNDSharedReceiveQueue::\r
 Receive(VOID* requestContext, const ND_SGE* pSge, DWORD nSge)\r
 {\r
@@ -131,3 +142,37 @@ Receive(VOID* requestContext, const ND_SGE* pSge, DWORD nSge)
        hr = m_pWvSrq->PostReceive((UINT64) (ULONG_PTR) requestContext, (WV_SGE *) pSge, nSge);\r
        return NDConvertWVStatus(hr);\r
 }\r
+\r
+#else\r
+\r
+STDMETHODIMP CNDSharedReceiveQueue::\r
+Receive(VOID* requestContext, const ND_SGE* pSge, DWORD nSge)\r
+{\r
+       WV_SGE sgl[4];\r
+       WV_SGE *sge;\r
+       DWORD i;\r
+       HRESULT hr;\r
+\r
+       if (nSge > _countof(sgl)) {\r
+               sge = new WV_SGE[nSge];\r
+               if (sge == NULL) {\r
+                       return ND_NO_MEMORY;\r
+               }\r
+       } else {\r
+               sge = sgl;\r
+       }\r
+\r
+       for (i = 0; i < nSge; i++) {\r
+               sge->pAddress = pSge[i].Buffer;\r
+               sge->Length = pSge[i].BufferLength;\r
+               sge->Lkey = pSge[i].MemoryRegionToken;\r
+       }\r
+\r
+       hr = m_pWvSrq->PostReceive((UINT64) (ULONG_PTR) requestContext, sge, nSge);\r
+       if (nSge > _countof(sgl)) {\r
+               delete[] sge;\r
+       }\r
+       return NDConvertWVStatus(hr);\r
+}\r
+\r
+#endif
\ No newline at end of file