]> git.openfabrics.org - ~shefty/rdma-win.git/commitdiff
Moved send to register and use physical memory (Rev 80)
authortzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 21 Nov 2005 12:12:24 +0000 (12:12 +0000)
committertzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 21 Nov 2005 12:12:24 +0000 (12:12 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1@165 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

trunk/ulp/sdp/kernel/SdpBufferPool.cpp
trunk/ulp/sdp/kernel/SdpBufferPool.h
trunk/ulp/sdp/kernel/SdpSocket.cpp
trunk/ulp/sdp/kernel/SdpSocket.h
trunk/ulp/sdp/todo [new file with mode: 0644]

index b71a6be240749ac8c1f5bf477e3c23ea015eec9b..e801a4dc0ff12088fea4601231af3f9974424cbf 100644 (file)
@@ -9,7 +9,8 @@ BufferPool::Init(
     int MaxConcurrentSends, \r
     int MaxMessageSize,\r
     ib_pd_handle_t pd,\r
-    ib_qp_handle_t qp\r
+    ib_qp_handle_t qp,\r
+    net32_t lkey\r
     )\r
 {\r
     SDP_PRINT(SDP_TRACE, SDP_BUFFER_POOL, ("this = 0x%p \n",this));\r
@@ -25,6 +26,8 @@ BufferPool::Init(
     m_pd = pd;\r
     ASSERT(qp != NULL);    \r
     m_qp = qp;\r
+    ASSERT(lkey != NULL);\r
+    m_lkey = lkey;\r
 \r
     return STATUS_SUCCESS;\r
 }\r
@@ -206,8 +209,6 @@ BufferPool::AllocateBuffer(BufferDescriptor ** ppBufferDescriptor)
     SDP_PRINT(SDP_TRACE, SDP_BUFFER_POOL, ("this = 0x%p \n",this));\r
     NTSTATUS rc = STATUS_SUCCESS;\r
     BufferDescriptor *pBufferDescriptor = NULL;\r
-    ib_mr_create_t mr_create;\r
-    uint32_t rkey;\r
 \r
     // Allocate the buffer descriptor\r
     pBufferDescriptor = \r
@@ -240,18 +241,7 @@ BufferPool::AllocateBuffer(BufferDescriptor ** ppBufferDescriptor)
     pBufferDescriptor->BufferSize = m_MaxMessageSize;\r
     pBufferDescriptor->DataSize = 0;\r
     pBufferDescriptor->mr_handle = NULL;\r
-    \r
-    // Now we need to register this memory with the hardware\r
-    mr_create.vaddr = pBufferDescriptor->pBuffer;\r
-    mr_create.length = pBufferDescriptor->BufferSize;\r
-    mr_create.access_ctrl = IB_AC_LOCAL_WRITE;\r
 \r
-    ib_api_status_t ib_status = ib_reg_mem( m_pd, &mr_create, &pBufferDescriptor->ds_array.lkey, &rkey, &pBufferDescriptor->mr_handle );\r
-    if( ib_status != IB_SUCCESS ) {\r
-        SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("ib_reg_mem failed ib_status = 0x%d\n", ib_status ));\r
-        rc = IB2Status(ib_status);\r
-        goto Cleanup;\r
-    }\r
 \r
 Cleanup:\r
     if (!NT_SUCCESS(rc)) {\r
@@ -269,9 +259,8 @@ Cleanup:
 VOID \r
 BufferPool::DeAllocateBuffer(BufferDescriptor *pBufferDescriptor)\r
 {\r
-    //????? clear the memory here. \r
-    // ?????\r
-\r
+    ExFreePoolWithTag(pBufferDescriptor->pBuffer, SEND_BUFFERS_ALLOCATION_TAG);\r
+    ExFreePoolWithTag(pBufferDescriptor, SEND_BUFFERS_ALLOCATION_TAG);\r
 }\r
 \r
 NTSTATUS\r
@@ -301,7 +290,8 @@ BufferPool::SendBuffer(BufferDescriptor *pBufferDescriptor)
     send_wr.send_opt = IB_SEND_OPT_SIGNALED;//socket_info->send_opt;\r
 \r
     pBufferDescriptor->ds_array.length = pBufferDescriptor->DataSize + sizeof msg_hdr_bsdh;\r
-    pBufferDescriptor->ds_array.vaddr = (uint64_t)(void* __ptr64) pBufferDescriptor->pBuffer;\r
+    pBufferDescriptor->ds_array.vaddr = MmGetPhysicalAddress( pBufferDescriptor->pBuffer ).QuadPart;\r
+    pBufferDescriptor->ds_array.lkey = m_lkey;\r
 \r
     send_wr.num_ds = 1;\r
     send_wr.ds_array = &pBufferDescriptor->ds_array;\r
index a88fd35d8424f4788548ea47094430838694234e..a73e6464fccadda72f3bf0b1e2e397a200ae5442 100644 (file)
@@ -77,7 +77,8 @@ public:
         int MaxConcurrentSends, \r
         int MaxMessageSize,\r
         ib_pd_handle_t pd,\r
-        ib_qp_handle_t qp\r
+        ib_qp_handle_t qp,\r
+        net32_t lkey\r
         );\r
 \r
     NTSTATUS GetBuffer(\r
@@ -124,6 +125,7 @@ private:
     // TODO: Should they stay here and be used like this ?\r
     ib_pd_handle_t          m_pd;\r
     ib_qp_handle_t          m_qp;\r
+    net32_t                            m_lkey;\r
 \r
     // A list of events that the users has to wait on. ???? currently only one\r
     KEVENT m_WaitingClients; // switch to a linked list\r
index a1853604271a91554d82947b3a521905060db4c5..807eee60fe86478e23589acef3420abd47d4343b 100644 (file)
@@ -70,6 +70,7 @@ SdpSocket::SdpSocket()
     m_rcq = NULL;\r
     m_scq = NULL;\r
     m_qp = NULL;\r
+    m_mr = NULL;\r
 \r
     m_state = SS_IDLE;\r
 }\r
@@ -90,6 +91,7 @@ NTSTATUS SdpSocket::Init(
     return rc;\r
 }\r
 \r
+# if 0\r
 struct sdpc_buff {\r
 //    struct sdpc_buff   *next;\r
 //    struct sdpc_buff   *prev;\r
@@ -130,6 +132,7 @@ const int BUFFER_SIZE = 4000 + 16;//65536;
 #define SDP_BUFF_F_SET_UNSIG(buff) ((buff)->flags |=   SDP_BUFF_F_UNSIG)\r
 #define SDP_BUFF_F_CLR_UNSIG(buff) ((buff)->flags &= (~SDP_BUFF_F_UNSIG))\r
 \r
+#endif \r
 \r
 NTSTATUS SdpSocket::WSPSend(\r
         WspSendIn    *pWspSendIn,\r
@@ -605,7 +608,7 @@ NTSTATUS SdpSocket::CmSendRTU()
 \r
     int MaxMessageSize = min(m_hello_ack.hah.l_rcv_size, MAX_SEND_BUFFER_SIZE);\r
 \r
-    rc = m_SendBufferPool.Init(MAX_SEND_PACKETS, QP_ATTRIB_SQ_DEPTH, MaxMessageSize, m_pd, m_qp);\r
+    rc = m_SendBufferPool.Init(MAX_SEND_PACKETS, QP_ATTRIB_SQ_DEPTH, MaxMessageSize, m_pd, m_qp, m_lkey);\r
     if (!NT_SUCCESS(rc)) {\r
         SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_SendBufferPool.Init failed rc = 0x%x\n", rc ));\r
         goto Cleanup;\r
@@ -841,9 +844,14 @@ __qp_event1(
 NTSTATUS SdpSocket::CreateQp()\r
 {\r
     NTSTATUS rc = STATUS_SUCCESS;\r
-    ib_cq_create_t  cq_create;\r
-    ib_qp_create_t    qp_create;\r
-    ib_api_status_t ib_status;\r
+    ib_cq_create_t      cq_create;\r
+    ib_qp_create_t      qp_create;\r
+    ib_api_status_t     ib_status;\r
+    ib_phys_create_t    phys_create;\r
+    ib_phys_range_t     phys_range;\r
+    uint64_t            vaddr;\r
+    net32_t             rkey;\r
+\r
 \r
     SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("CreateQp called this = 0x%p\n", this));\r
     /* Open the CA. */\r
@@ -941,9 +949,35 @@ NTSTATUS SdpSocket::CreateQp()
        return status;\r
     }\r
     p_port->ib_mgr.qpn = qp_attr.num;\r
-#endif    \r
+#endif\r
+    const net64_t MEM_REG_SIZE = 0xFFFFFFFFFFFFFFFF;\r
+    /* Register all of physical memory */\r
+    phys_create.length = MEM_REG_SIZE;\r
+    phys_create.num_ranges = 1;\r
+    phys_create.range_array = &phys_range;\r
+    phys_create.buf_offset = 0;\r
+    phys_create.hca_page_size = PAGE_SIZE;\r
+    phys_create.access_ctrl = IB_AC_LOCAL_WRITE;\r
+    phys_range.base_addr = 0;\r
+    phys_range.size = MEM_REG_SIZE;\r
+    vaddr = 0;\r
+    ib_status = ib_reg_phys(\r
+                        m_pd, \r
+                        &phys_create, \r
+                        &vaddr,\r
+                        &m_lkey,\r
+                        &rkey, \r
+                        &m_mr );\r
+    if( ib_status != IB_SUCCESS ) {\r
+        SDP_PRINT(SDP_ERR, SDP_SOCKET, ("ib_reg_phys failed ib_status = 0x%d\n", ib_status ));\r
+        rc = IB2Status(ib_status);\r
+        goto Cleanup;\r
+    }\r
            \r
 Cleanup:\r
+    // In the case of failure the mess will be cleaned on\r
+    // shutdown \r
+    // TODO: Need to make a beter cleanup here\r
     return rc;\r
 \r
 }\r
@@ -1037,6 +1071,8 @@ VOID SdpSocket::Shutdown()
 {\r
     //???? locking\r
     // if(m_shutdown - on the lock) ???\r
+    ib_api_status_t     ib_status;\r
+\r
 \r
     SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("SdpSocket::Shutdown called this = 0x%p\n", this));\r
 \r
@@ -1062,6 +1098,20 @@ VOID SdpSocket::Shutdown()
 \r
     // Now that all ibal operations have finished we can free the memory\r
     m_SendBufferPool.ShutDown();\r
+\r
+\r
+/*\r
+    Memory reagion probably cleans when the other handles are closed\r
+    if (m_mr != NULL) {\r
+        ib_status = ib_dereg_mr(m_mr);\r
+        if( ib_status != IB_SUCCESS ) {\r
+            SDP_PRINT(SDP_ERR, SDP_SOCKET, ("ib_dereg_mr failed ib_status = 0x%d\n", ib_status ));\r
+            ASSERT( ib_status == IB_SUCCESS );\r
+        }\r
+        m_mr = NULL;\r
+    }\r
+*/\r
+    \r
 }\r
 \r
 /*\r
index adb4420c74e585a6e997ec36c3beeb7c9de3e171..97ffdea3d3a904ca00c26016f3b4ed59da8dcb71 100644 (file)
@@ -66,6 +66,10 @@ private:
    \r
     ib_qp_handle_t          m_qp;\r
 \r
+    ib_mr_handle_t          m_mr;\r
+\r
+    net32_t                            m_lkey;\r
+\r
     BufferPool              m_SendBufferPool;\r
 \r
     KEVENT                  m_ConnectCmCompleteEvent;\r
diff --git a/trunk/ulp/sdp/todo b/trunk/ulp/sdp/todo
new file mode 100644 (file)
index 0000000..3fcf50d
--- /dev/null
@@ -0,0 +1,21 @@
+This file includes things that should be impreoved in the sdp implmentation\r
+=============================================================================\r
+\r
+KERNEL MODE:\r
+1) On send: implmeant some kind of a negal algorithm.\r
+2) On send: Create some kind of mechanism that will allow to recieve complitions on more than\r
+one send.\r
+\r
+\r
+\r
+\r
+USER MODE:\r
+\r
+\r
+* Check the lifetime of the SdpSocket (when is it deleted and so)??\r
+\r
+* make sure that the asserts are implmented in debug\r
+* check with intel that we can remove their lisence from the files.\r
+\r
+\r
+* make sure that the SDP socket is deleted at least in the main path
\ No newline at end of file