\r
static void WvDeviceEventHandler(ib_event_rec_t *pEvent)\r
{\r
- WV_DEVICE *dev = (WV_DEVICE *) pEvent->context;\r
+ WV_DEVICE *dev;\r
UINT32 event;\r
UINT8 i;\r
\r
return;\r
}\r
\r
+ dev = CONTAINING_RECORD(pEvent->context, WV_DEVICE, EventHandler);\r
+\r
if (event == WV_IO_EVENT_ERROR) {\r
for (i = 0; i < dev->PortCount; i++) {\r
WvDeviceCompleteRequests(&dev->pPorts[i], STATUS_SUCCESS, event);\r
pDevice->PortCount = attr->num_ports;\r
ExFreePool(attr);\r
\r
- pDevice->pPorts = ExAllocatePoolWithTag(PagedPool, sizeof(WV_PORT) *\r
+ pDevice->pPorts = ExAllocatePoolWithTag(NonPagedPool, sizeof(WV_PORT) *\r
pDevice->PortCount, 'cpvw');\r
if (pDevice->pPorts == NULL) {\r
return STATUS_NO_MEMORY;\r
}\r
\r
STDMETHODIMP CWVProtectionDomain::\r
-CreateAddressHandle(WV_ADDRESS_VECTOR* pAddress, IWVAddressHandle** ppAh)\r
+CreateAddressHandle(WV_ADDRESS_VECTOR* pAddress, IWVAddressHandle** ppAh, ULONG_PTR *pAhKey)\r
{\r
- return CWVAddressHandle::CreateInstance(this, pAddress, ppAh);\r
+ return CWVAddressHandle::CreateInstance(this, pAddress, ppAh, pAhKey);\r
}\r
\r
\r
ib_api_status_t stat;\r
HRESULT hr;\r
ci_umv_buf_t verbsData;\r
- ib_av_attr_t av;\r
+ ib_av_attr_t attr;\r
CWVBuffer buf;\r
\r
- hr = ConvertAv(&av, pAddress);\r
+ hr = ConvertAv(&attr, pAddress);\r
if (FAILED(hr)) {\r
return hr;\r
}\r
\r
- stat = m_pVerbs->pre_create_av(m_pPd->m_hVerbsPd, &av, &verbsData, &m_hVerbsAh);\r
+ stat = m_pVerbs->pre_create_av(m_pPd->m_hVerbsPd, &attr, &verbsData, &m_hVerbsAh);\r
if (stat != IB_SUCCESS) {\r
if (stat == IB_VERBS_PROCESSING_DONE) {\r
m_Id = (ULONG_PTR) m_hVerbsAh;\r
STDMETHODIMP DeregisterMemory(UINT32 Lkey, OVERLAPPED* pOverlapped);\r
STDMETHODIMP AllocateMemoryWindow(IWVMemoryWindow** ppMw);\r
STDMETHODIMP CreateAddressHandle(WV_ADDRESS_VECTOR* pAddress,\r
- IWVAddressHandle** ppAh);\r
+ IWVAddressHandle** ppAh, ULONG_PTR *pAhKey);\r
\r
CWVProtectionDomain(CWVDevice *pDevice);\r
~CWVProtectionDomain();\r
void Delete() {delete this;}\r
static STDMETHODIMP\r
CreateInstance(CWVProtectionDomain *pPd, WV_ADDRESS_VECTOR* pAddress,\r
- IWVAddressHandle** ppAh)\r
+ IWVAddressHandle** ppAh, ULONG_PTR* pAhKey)\r
{\r
HRESULT hr;\r
CWVAddressHandle *ah;\r
}\r
\r
*ppAh = ah;\r
+ *pAhKey = (ULONG_PTR) ah->m_hVerbsAh;\r
return WV_SUCCESS;\r
\r
err2:\r
STDMETHODIMP CWVQueuePair::\r
PostSend(WV_SEND_REQUEST *pSend, WV_SEND_REQUEST **ppFailed)\r
{\r
- CWVAddressHandle *ah;\r
ib_send_wr_t *wr;\r
ib_api_status_t stat;\r
HRESULT hr;\r
\r
- if (m_Type == WvQpTypeUd) {\r
- if (pSend->pNext != NULL) {\r
- return WV_NOT_SUPPORTED;\r
- }\r
-\r
- WvConvertSgl(pSend->pSgl, pSend->nSge);\r
- ah = (CWVAddressHandle *) pSend->Wr.Datagram.pAddresHandle;\r
- pSend->Wr.Datagram.pAddresHandle = (IWVAddressHandle *) ah->m_hVerbsAh;\r
- stat = m_pVerbs->post_send(m_hVerbsQp, (ib_send_wr_t *) pSend,\r
- (ppFailed == NULL) ? &wr : (ib_send_wr_t **) ppFailed);\r
- pSend->Wr.Datagram.pAddresHandle = (IWVAddressHandle *) ah;\r
- } else {\r
- stat = m_pVerbs->post_send(m_hVerbsQp, WvConvertSends(pSend),\r
- (ppFailed == NULL) ? &wr : (ib_send_wr_t **) ppFailed);\r
- }\r
-\r
+ stat = m_pVerbs->post_send(m_hVerbsQp, WvConvertSends(pSend),\r
+ (ppFailed == NULL) ? &wr : (ib_send_wr_t **) ppFailed);\r
if (stat == IB_SUCCESS) {\r
hr = WV_SUCCESS;\r
} else {\r
}\r
\r
STDMETHODIMP CWVDatagramQueuePair::\r
-Send(UINT64 WrId, IWVAddressHandle* pAddressHandle,\r
+Send(UINT64 WrId, ULONG_PTR AhKey,\r
WV_SGE* pSge, DWORD Flags, NET32 DestinationQpn,\r
NET32 DestinationQkey)\r
{\r
\r
wr.Wr.Datagram.DestinationQkey = DestinationQkey;\r
wr.Wr.Datagram.DestinationQpn = DestinationQpn;\r
- wr.Wr.Datagram.pAddresHandle = pAddressHandle;\r
+ wr.Wr.Datagram.AhKey = AhKey;\r
\r
hr = PostSend(&wr, NULL);\r
return hr;\r
\r
wr.Wr.Datagram.DestinationQkey = pSend->DestinationQkey;\r
wr.Wr.Datagram.DestinationQpn = pSend->DestinationQpn;\r
- wr.Wr.Datagram.pAddresHandle = pSend->pAddressHandle;\r
+ wr.Wr.Datagram.AhKey = pSend->AhKey;\r
\r
hr = PostSend(&wr, NULL);\r
return hr;\r
STDMETHODIMP PostSend(WV_SEND_REQUEST *pSend, WV_SEND_REQUEST **ppFailed);\r
\r
// IWVDatagramQueuePair Methods\r
- STDMETHODIMP Send(UINT64 WrId, IWVAddressHandle* pAddressHandle,\r
+ STDMETHODIMP Send(UINT64 WrId, ULONG_PTR AhKey,\r
WV_SGE* pSge, DWORD Flags, NET32 DestinationQpn,\r
NET32 DestinationQkey);\r
STDMETHODIMP SendMessage(WV_SEND_DATAGRAM* pSend);\r
typedef struct _WV_SEND_DATAGRAM\r
{\r
UINT64 WrId;\r
- interface IWVAddressHandle* pAddressHandle;\r
+ ULONG_PTR AhKey;\r
\r
WV_SGE* pSgl;\r
SIZE_T nSge;\r
\r
struct\r
{\r
- interface IWVAddressHandle* pAddresHandle;\r
+ ULONG_PTR AhKey;\r
NET32 DestinationQpn;\r
NET32 DestinationQkey;\r
\r
STDMETHOD(Send)(\r
THIS_\r
__in UINT64 WrId,\r
- __in IWVAddressHandle* pAddressHandle,\r
+ __in ULONG_PTR AhKey,\r
__in WV_SGE* pSge,\r
__in DWORD Flags,\r
__in NET32 DestinationQpn,\r
STDMETHOD(CreateAddressHandle)(\r
THIS_\r
__in WV_ADDRESS_VECTOR* pAddress,\r
- __deref_out IWVAddressHandle** ppAh\r
+ __deref_out IWVAddressHandle** ppAh,\r
+ __out ULONG_PTR* pAhKey\r
) PURE;\r
};\r
\r
return 1;\r
}\r
\r
- printf("%s: async eventd\n", ibv_get_device_name(*dev_list));\r
+ printf("%s: async event\n", ibv_get_device_name(*dev_list));\r
\r
while (1) {\r
if (ibv_get_async_event(context, &event))\r
struct ibv_context *context;\r
struct ibv_pd *pd;\r
IWVAddressHandle *handle;\r
+ ULONG_PTR key;\r
};\r
\r
struct ibv_device;\r
DWORD event_flag;\r
};\r
\r
-#define EVENT_PORT_NONE -1\r
+#define EVENT_PORT_NONE 0xFF\r
\r
struct verbs_context\r
{\r
struct verbs_device device;\r
HANDLE *event;\r
struct verbs_port *port;\r
- uint8_t event_port_num;\r
+ uint8_t event_port_index;\r
};\r
\r
__declspec(dllexport)\r
return NULL;\r
}\r
memcpy(&vcontext->device, vdev, sizeof(struct verbs_device));\r
- vcontext->event_port_num = EVENT_PORT_NONE;\r
+ vcontext->event_port_index = EVENT_PORT_NONE;\r
+ vcontext->context.timeout = INFINITE;\r
\r
vcontext->port = new struct verbs_port[vdev->phys_port_cnt];\r
if (vcontext->port == NULL) {\r
vcontext->port[i].overlap.hEvent = vcontext->event[i];\r
vcontext->port[i].event_flag = 0;\r
\r
- vcontext->context.cmd_if->Notify((UINT8) i,\r
+ vcontext->context.cmd_if->Notify((UINT8) i + 1,\r
&vcontext->port[i].overlap,\r
&vcontext->port[i].event_flag);\r
}\r
WV_PORT_ATTRIBUTES attr;\r
HRESULT hr;\r
\r
- hr = vcontext->context.cmd_if->QueryPort(vcontext->event_port_num, &attr);\r
+ hr = vcontext->context.cmd_if->QueryPort(vcontext->event_port_index + 1, &attr);\r
if (FAILED(hr)) {\r
return IBV_EVENT_PORT_ERR;\r
}\r
struct verbs_port *port;\r
int ret = 0;\r
\r
- port = &vcontext->port[vcontext->event_port_num];\r
- event->element.port_num = vcontext->event_port_num;\r
+ port = &vcontext->port[vcontext->event_port_index];\r
+ event->element.port_num = vcontext->event_port_index + 1;\r
\r
if (port->event_flag & WV_EVENT_ERROR) {\r
event->event_type = IBV_EVENT_DEVICE_FATAL;\r
}\r
\r
if (port->event_flag == 0) {\r
- vcontext->context.cmd_if->Notify(vcontext->event_port_num,\r
+ vcontext->context.cmd_if->Notify(vcontext->event_port_index + 1,\r
&port->overlap, &port->event_flag);\r
- vcontext->event_port_num = EVENT_PORT_NONE;\r
+ vcontext->event_port_index = EVENT_PORT_NONE;\r
}\r
return ret;\r
}\r
int i;\r
\r
vcontext = CONTAINING_RECORD(context, struct verbs_context, context);\r
- if (vcontext->event_port_num != EVENT_PORT_NONE) {\r
+ if (vcontext->event_port_index != EVENT_PORT_NONE) {\r
if (ibv_report_port_event(vcontext, event) == 0) {\r
return 0;\r
}\r
return HRESULT_FROM_WIN32(GetLastError());\r
}\r
\r
- vcontext->event_port_num = (UINT8) hr;\r
+ vcontext->event_port_index = (UINT8) hr;\r
return ibv_report_port_event(vcontext, event);\r
}\r
\r
{\r
struct ibv_send_wr *cur_wr;\r
HRESULT hr = 0;\r
+ struct ibv_ah *ah;\r
+\r
+ if ((qp->qp_type == IBV_QPT_UD) && (wr->next != NULL))\r
+ return WV_NOT_SUPPORTED;\r
\r
for (cur_wr = wr; cur_wr != NULL; cur_wr = cur_wr->next) {\r
+ if (qp->qp_type == IBV_QPT_UD) {\r
+ ah = cur_wr->wr.ud.ah;\r
+ cur_wr->wr.ud.ah = (struct ibv_ah *) ah->key;\r
+ cur_wr->wr.ud.remote_qkey = htonl(cur_wr->wr.ud.remote_qkey);\r
+ cur_wr->wr.ud.remote_qpn = htonl(cur_wr->wr.ud.remote_qpn);\r
+ }\r
+\r
if ((cur_wr->opcode & 0x80000000) != 0) {\r
cur_wr->opcode = (ibv_wr_opcode) (cur_wr->opcode & ~0x80000000);\r
cur_wr->send_flags = (ibv_send_flags) (cur_wr->send_flags | WV_SEND_IMMEDIATE);\r
hr = qp->handle->PostSend((WV_SEND_REQUEST *) wr, (WV_SEND_REQUEST **) bad_wr);\r
\r
for (cur_wr = wr; cur_wr != NULL; cur_wr = cur_wr->next) {\r
+ if (qp->qp_type == IBV_QPT_UD) {\r
+ cur_wr->wr.ud.ah = ah;\r
+ cur_wr->wr.ud.remote_qkey = ntohl(cur_wr->wr.ud.remote_qkey);\r
+ cur_wr->wr.ud.remote_qpn = ntohl(cur_wr->wr.ud.remote_qpn);\r
+ }\r
+\r
if ((cur_wr->send_flags & WV_SEND_IMMEDIATE) != 0) {\r
cur_wr->send_flags = (ibv_send_flags) (cur_wr->send_flags & ~WV_SEND_IMMEDIATE);\r
cur_wr->opcode = (ibv_wr_opcode) (cur_wr->opcode | 0x80000000);\r
ah->context = pd->context;\r
ah->pd = pd;\r
ibv_convert_ah_attr(pd->context, &av, attr);\r
- hr = pd->handle->CreateAddressHandle(&av, &ah->handle);\r
+ hr = pd->handle->CreateAddressHandle(&av, &ah->handle, &ah->key);\r
if (FAILED(hr)) {\r
delete ah;\r
return NULL;\r