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
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
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
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
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
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
m_rcq = NULL;\r
m_scq = NULL;\r
m_qp = NULL;\r
+ m_mr = NULL;\r
\r
m_state = SS_IDLE;\r
}\r
return rc;\r
}\r
\r
+# if 0\r
struct sdpc_buff {\r
// struct sdpc_buff *next;\r
// struct sdpc_buff *prev;\r
#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
\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
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
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
{\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
\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