\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
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
\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
goto Cleanup;\r
}\r
m_CurrentlySentBuffers ++;\r
+ m_rRecvBuf--;\r
\r
Cleanup:\r
return rc;\r
\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
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
}\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
\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
/* Copyright mellanox */\r
-#pragma warning(disable: 4244 ) \r
\r
#include "preCompile.h"\r
\r
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
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
\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
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
}\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
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
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
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
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