]> git.openfabrics.org - ~shefty/rdma-win.git/commitdiff
Credits are being implemented for send. (Rev 110,111)
authortzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 21 Nov 2005 12:17:02 +0000 (12:17 +0000)
committertzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 21 Nov 2005 12:17:02 +0000 (12:17 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1@169 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

trunk/ulp/sdp/kernel/SdpBufferPool.cpp
trunk/ulp/sdp/kernel/SdpBufferPool.h
trunk/ulp/sdp/kernel/SdpGenUtils.cpp
trunk/ulp/sdp/kernel/SdpGenUtils.h
trunk/ulp/sdp/kernel/SdpRecvPool.cpp
trunk/ulp/sdp/kernel/SdpRecvPool.h
trunk/ulp/sdp/kernel/SdpSocket.cpp
trunk/ulp/sdp/kernel/SdpSocket.h

index 5524e4de25e8ee45eb51f11307ac89c09b7c753f..412558720855dc9a51d2d7c8c61b5b4bb2e12c47 100644 (file)
@@ -189,21 +189,12 @@ BufferPool::AddBufferToQueuedList(BufferDescriptor *pBufferDescriptor)
 \r
     NTSTATUS rc = STATUS_SUCCESS;\r
 \r
-    if ((m_CurrentlySentBuffers < m_MaxConcurrentSends) && \r
-        (m_QueuedPackets.Size() == 0 )){\r
-        // we can send right away (no need to wait for anything)\r
-        rc = SendBuffer(pBufferDescriptor);\r
-        if (!NT_SUCCESS(rc)) {\r
-            SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("SendBuffer failed rc = 0x%x\n", rc ));\r
-            m_FreePackets.InsertTailList(&pBufferDescriptor->BuffersList);\r
-            goto Cleanup;\r
-        }        \r
-        // We have finished our job\r
+    m_QueuedPackets.InsertTailList(&pBufferDescriptor->BuffersList);\r
+    rc = SendBuffersIfCan();\r
+    if (!NT_SUCCESS(rc)) {\r
+        SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("SendBuffersIfCan failed rc = 0x%x\n", rc ));\r
         goto Cleanup;\r
-    } else {\r
-        // we put the buffer in the queued list\r
-        m_QueuedPackets.InsertTailList(&pBufferDescriptor->BuffersList);\r
-    }\r
+    }        \r
 \r
 Cleanup:    \r
     return rc;\r
@@ -264,7 +255,8 @@ BufferPool::SendBuffersIfCan()
     NTSTATUS rc = STATUS_SUCCESS;\r
 \r
     while ((m_QueuedPackets.Size() > 0) && \r
-           (m_CurrentlySentBuffers < m_MaxConcurrentSends)) {\r
+           (m_CurrentlySentBuffers < m_MaxConcurrentSends) &&\r
+           (m_rRecvBuf > 2)) {\r
         // we can now send the next buffer\r
         LIST_ENTRY *item = m_QueuedPackets.RemoveHeadList();\r
         BufferDescriptor *pBufferDescriptor = CONTAINING_RECORD(item, BufferDescriptor , BuffersList);\r
@@ -319,7 +311,7 @@ BufferPool::SendBuffer(BufferDescriptor *pBufferDescriptor)
 \r
     pHeader->recv_bufs = m_pSdpSocket->m_RecvBufferPool.GetCurrentlyPostedRecievedBuffers(); //?????recv_bufs = conn->l_advt_bf;\r
     pHeader->size = pBufferDescriptor->DataSize + sizeof msg_hdr_bsdh;\r
-    pHeader->seq_num = GetSendSeq();\r
+    pHeader->seq_num = GetAndIncreaseSendSeq();\r
     pHeader->seq_ack = m_pSdpSocket->m_RecvBufferPool.GetRecvSeq();//????conn->advt_seq;\r
     m_AdvtSeq = pHeader->seq_ack;// Currently only for debug\r
     pHeader->mid = SDP_MID_DATA;\r
@@ -350,6 +342,7 @@ BufferPool::SendBuffer(BufferDescriptor *pBufferDescriptor)
         goto Cleanup;\r
     }\r
     m_CurrentlySentBuffers ++;\r
+    m_rRecvBuf--;\r
 \r
 Cleanup:\r
     return rc;\r
index 28ed8db3cf8f4a7a6499a93f6b9e272930935faa..bf6683863f164b3accc25b1288d83c45bcef3512 100644 (file)
@@ -136,10 +136,18 @@ public:
 \r
     VOID ShutDown();\r
 \r
-    uint32_t GetSendSeq() {return m_SendSeq++;}\r
+    uint32_t GetSendSeq() {return m_SendSeq;}\r
+    uint32_t GetAndIncreaseSendSeq() {return m_SendSeq++;}\r
     uint32_t GetAdvtSeq() {return m_AdvtSeq;}\r
 \r
-    \r
+    VOID SetRemoteRecvBuf (uint16_t rRecvBuf) {\r
+        if (m_rRecvBuf == 2) {\r
+            SDP_PRINT(SDP_ALL, SDP_BUFFER_POOL,("m_rRecvBuf = %d, it is being set to %d seqnum = %d\n", m_rRecvBuf, rRecvBuf, m_SendSeq));\r
+        }\r
+        m_rRecvBuf = rRecvBuf;\r
+    }\r
+\r
+\r
     \r
 private:\r
 \r
@@ -172,7 +180,8 @@ private:
     bool   m_ClientWaiting;\r
 \r
     uint32_t m_SendSeq; //sequence number of last message sent (send_seq in linux)\r
-    uint32_t m_AdvtSeq; // sequence number of last message acknowledged (advt_seq in linux) \r
+    uint32_t m_AdvtSeq; // sequence number of last message acknowledged (advt_seq in linux)\r
+    uint16_t m_rRecvBuf; // number of recv buffers remote currently has (r_recv_bf in linux)\r
 \r
     SdpSocket *m_pSdpSocket;\r
 \r
index db4eb65998b0f7c05d8eefb22c9317202a04f0cb..5f246978d0672510ef8315f7051ca937696b7019 100644 (file)
@@ -136,6 +136,11 @@ VOID UpdateRc(NTSTATUS *rc, NTSTATUS rc1)
     }\r
 }\r
 \r
+int abs(int i){\r
+    if (i > 0) return i;\r
+    return -i;\r
+}\r
+\r
 void* __cdecl operator new(size_t n ) throw() {\r
     return ExAllocatePoolWithTag(NonPagedPool , n, GLOBAL_ALLOCATION_TAG);\r
 }\r
index e810afdce7807600b1bb7e72f862541255e817a5..497b8059dcc75dc56a23cacb35a9abe241dcc4e1 100644 (file)
@@ -70,6 +70,8 @@ CopyToUser(
 \r
 VOID UpdateRc(NTSTATUS *rc, NTSTATUS rc1);\r
 \r
+int abs(int i);\r
+\r
 \r
 // This error codes are taken from winsock2.h (the file can not)\r
 // be included from user mode\r
index 2cdf2e8f5ae3a919fc05788c53e743779065785c..1781d355bf24b11b143881dc11feb1dc6c8ba7ed 100644 (file)
@@ -1,5 +1,4 @@
 /* Copyright mellanox */\r
-#pragma warning(disable: 4244 ) \r
 \r
 #include "preCompile.h"\r
 \r
@@ -34,9 +33,7 @@ RecvPool::Init(
     m_qp = qp;\r
     ASSERT(lkey != NULL);\r
     m_lkey = lkey;\r
-#if DBG    \r
     m_pSdpSocket = pSdpSocket;\r
-#endif\r
     return STATUS_SUCCESS;\r
 }\r
 \r
@@ -66,19 +63,40 @@ RecvPool::RecievedBuffer(BufferDescriptor *pBufferDescriptor, bool error)
     pBufferDescriptor->DataSize = pHeader->size - sizeof msg_hdr_bsdh;\r
 \r
     m_RecvSeq = pHeader->seq_num;\r
-    \r
-    m_FullPackets.InsertTailList(&pBufferDescriptor->BuffersList);\r
-    ASSERT(m_FullPackets.Size() <= m_MaxBuffers);\r
 \r
-    // we need to notify the client that is waiting\r
-    if (m_ClientWaiting) {\r
-        KeSetEvent( &m_WaitingClients, IO_NO_INCREMENT, FALSE );\r
-        m_ClientWaiting = false;\r
+    // Start processing the different messages:\r
+    // No metter what the message type is, we can update our credits\r
+\r
+    uint16_t rRecvBuf = \r
+                pHeader->recv_bufs - \r
+                abs (\r
+                    (int)m_pSdpSocket->m_SendBufferPool.GetSendSeq()- \r
+                    (int)pHeader->seq_ack);\r
+    m_pSdpSocket->m_SendBufferPool.SetRemoteRecvBuf(rRecvBuf);\r
+\r
+\r
+    if(pHeader->size > sizeof msg_hdr_bsdh) {\r
+        m_FullPackets.InsertTailList(&pBufferDescriptor->BuffersList);\r
+        ASSERT(m_FullPackets.Size() <= m_MaxBuffers);\r
+\r
+        // we need to notify the client that is waiting\r
+        if (m_ClientWaiting) {\r
+            KeSetEvent( &m_WaitingClients, IO_NO_INCREMENT, FALSE );\r
+            m_ClientWaiting = false;\r
+        }\r
+    } else {\r
+        // This is an empty buffer\r
+        ASSERT(pHeader->size == sizeof msg_hdr_bsdh);\r
+        m_FreePackets.InsertTailList(&pBufferDescriptor->BuffersList);        \r
     }\r
     // ???? Handle state changes here ????\r
 \r
-    //???? we will also have to wake up the clients of the send ???????\r
-\r
+    // Wake up the clients of the send (new credits were added)\r
+    rc = m_pSdpSocket->m_SendBufferPool.SendBuffersIfCan();\r
+    if (!NT_SUCCESS(rc)) {\r
+        SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("SendBuffersIfCan failed rc = 0x%x\n", rc ));\r
+        goto Cleanup;\r
+    }        \r
 \r
     m_CurrentlyPostedRecievedBuffers--;\r
     ASSERT(m_CurrentlyPostedRecievedBuffers >= 0);\r
index 68ac1833e4c453628a5c47d1b9ffad581ff3d92b..4e86b027242ed239a519b75c6b7b0645bf03054e 100644 (file)
@@ -71,10 +71,7 @@ private:
 \r
     uint32_t m_RecvSeq;      // sequence number of last message received (recv_seq)\r
 \r
-\r
-#if DBG\r
     SdpSocket *m_pSdpSocket;\r
-#endif //DBG\r
 \r
 VOID AssertLocked();\r
 \r
index af8adbb192ac4a56621301b4242af9ba34c239ed..6add3c1eb9b55b52d75457829941e8636e47d976 100644 (file)
@@ -546,6 +546,7 @@ NTSTATUS SdpSocket::CmSendRTU()
         SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_RecvBufferPool.Init failed rc = 0x%x\n", rc ));\r
         goto Cleanup;\r
     }\r
+    m_SendBufferPool.SetRemoteRecvBuf(m_hello_ack.bsdh.recv_bufs);\r
 \r
 #if 0\r
     /*\r
@@ -669,19 +670,19 @@ SdpSocket::recv_cb()
     }\r
 \r
     ib_api_status_t     ib_status;\r
-    ib_wc_t             wc[QP_ATTRIB_RQ_DEPTH], *p_free, *p_wc1;\r
+    ib_wc_t             *p_free, *p_wc1;\r
     uint32_t            pkt_cnt, recv_cnt = 0;\r
     size_t              i;\r
     BufferDescriptor *pBufferDescriptor = NULL;\r
 \r
     for( i = 0; i < QP_ATTRIB_RQ_DEPTH; i++ )\r
-        wc[i].p_next = &wc[i + 1];\r
-    wc[QP_ATTRIB_RQ_DEPTH - 1].p_next = NULL;\r
+        m_RecvComplitionWC[i].p_next = &m_RecvComplitionWC[i + 1];\r
+    m_RecvComplitionWC[QP_ATTRIB_RQ_DEPTH - 1].p_next = NULL;\r
 \r
     do\r
     {\r
         /* If we get here, then the list of WCs is intact. */\r
-        p_free = wc;\r
+        p_free = m_RecvComplitionWC;\r
 \r
         ib_status = ib_poll_cq( m_rcq, &p_free, &p_wc1 );\r
         if( (ib_status != IB_SUCCESS) && (ib_status != IB_NOT_FOUND) ) {\r
@@ -792,24 +793,23 @@ static NTSTATUS __recv_cb2(SdpSocket * pSdpSocket)
     return pSdpSocket->recv_cb();\r
 }\r
 \r
-\r
 NTSTATUS SdpSocket::send_cb()\r
 {\r
     SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("called this =0x%x\n", this));\r
     NTSTATUS rc = STATUS_SUCCESS;\r
     ib_api_status_t     ib_status;\r
-    ib_wc_t             wc[QP_ATTRIB_SQ_DEPTH], *p_wc, *p_free;\r
+    ib_wc_t  *p_wc, *p_free;\r
     size_t              i;\r
     BufferDescriptor *pBufferDescriptor = NULL;\r
 \r
     for( i = 0; i < QP_ATTRIB_SQ_DEPTH; i++ ) {\r
-        wc[i].p_next = &wc[i + 1];\r
+        m_SendComplitionWC[i].p_next = &m_SendComplitionWC[i + 1];\r
     }\r
-    wc[QP_ATTRIB_SQ_DEPTH - 1].p_next = NULL;\r
+    m_SendComplitionWC[QP_ATTRIB_SQ_DEPTH - 1].p_next = NULL;\r
 \r
     do \r
     {\r
-        p_free = wc;\r
+        p_free = m_SendComplitionWC;\r
         ib_status = ib_poll_cq( m_scq, &p_free, &p_wc );\r
         ASSERT( ib_status == IB_SUCCESS || ib_status == IB_NOT_FOUND);\r
         if (ib_status == IB_NOT_FOUND) {\r
@@ -1065,7 +1065,7 @@ VOID SdpSocket::CreateHelloHeader(
     hello_msg->bsdh.flags     = SDP_MSG_FLAG_NON_FLAG;\r
     hello_msg->bsdh.mid       = SDP_MID_HELLO;\r
     hello_msg->bsdh.size      = sizeof(struct sdp_msg_hello);\r
-    hello_msg->bsdh.seq_num   = m_SendBufferPool.GetSendSeq();//conn->send_seq; ???\r
+    hello_msg->bsdh.seq_num   = m_SendBufferPool.GetAndIncreaseSendSeq();//conn->send_seq; ???\r
     hello_msg->bsdh.seq_ack   = m_RecvBufferPool.GetRecvSeq();//conn->advt_seq; ???\r
 \r
     hello_msg->hh.max_adv       = QP_ATTRIB_RQ_DEPTH;// ??? conn->l_max_adv;\r
index b31ce87dcc9bf62e487c0b5098e3fdd6e9bc1cff..4092a4d2daf9d5cf68ac1e305120204517f6f096 100644 (file)
@@ -16,14 +16,14 @@ const int MAX_SEND_PACKETS              = 200;    // This is the maximum number
 const int MAX_RECV_PACKETS              = 200;    // This is the maximum number of packets allocated per send\r
                                   \r
 \r
-#define QP_ATTRIB_SQ_DEPTH                             32\r
+#define QP_ATTRIB_SQ_DEPTH                             64\r
 #define QP_ATTRIB_SQ_SGE                               1       /* Set based on inline data requirements */\r
 \r
 /* \r
  * TODO: During testing, the switch has been observed to post\r
  * 12 receive buffers.  It would be nice to know what the max is.\r
  */\r
-#define QP_ATTRIB_RQ_DEPTH                             16\r
+#define QP_ATTRIB_RQ_DEPTH                             64\r
 #define QP_ATTRIB_RQ_SGE                               1\r
 \r
 /* Number of entries in a CQ */\r
@@ -74,6 +74,11 @@ private:
     KEVENT                  m_ConnectCmCompleteEvent;\r
     KEVENT                  m_ShutdownCompleteEvent;\r
 \r
+    ib_wc_t                 m_SendComplitionWC[QP_ATTRIB_SQ_DEPTH];\r
+    ib_wc_t                 m_RecvComplitionWC[QP_ATTRIB_RQ_DEPTH];\r
+\r
+    \r
+\r
     VOID SignalShutdown();\r
 \r
     static VOID __send_cb1(\r