From: shefty Date: Sat, 19 Jul 2008 04:31:58 +0000 (+0000) Subject: winverbs/libibverbs: update to support UD QPs and async events X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=fa00a715e1e56edab5bff496191c51e1c937d370;p=~shefty%2Frdma-win.git winverbs/libibverbs: update to support UD QPs and async events Signed-off-by: Sean Hefty git-svn-id: svn://openib.tc.cornell.edu/gen1@1421 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- diff --git a/branches/winverbs/core/winverbs/kernel/wv_device.c b/branches/winverbs/core/winverbs/kernel/wv_device.c index 87fffa6d..c411f114 100644 --- a/branches/winverbs/core/winverbs/kernel/wv_device.c +++ b/branches/winverbs/core/winverbs/kernel/wv_device.c @@ -113,7 +113,7 @@ static void WvDeviceCompleteRequests(WV_PORT *pPort, NTSTATUS ReqStatus, UINT32 static void WvDeviceEventHandler(ib_event_rec_t *pEvent) { - WV_DEVICE *dev = (WV_DEVICE *) pEvent->context; + WV_DEVICE *dev; UINT32 event; UINT8 i; @@ -122,6 +122,8 @@ static void WvDeviceEventHandler(ib_event_rec_t *pEvent) return; } + dev = CONTAINING_RECORD(pEvent->context, WV_DEVICE, EventHandler); + if (event == WV_IO_EVENT_ERROR) { for (i = 0; i < dev->PortCount; i++) { WvDeviceCompleteRequests(&dev->pPorts[i], STATUS_SUCCESS, event); @@ -202,7 +204,7 @@ static NTSTATUS WvDeviceCreatePorts(WV_DEVICE *pDevice) pDevice->PortCount = attr->num_ports; ExFreePool(attr); - pDevice->pPorts = ExAllocatePoolWithTag(PagedPool, sizeof(WV_PORT) * + pDevice->pPorts = ExAllocatePoolWithTag(NonPagedPool, sizeof(WV_PORT) * pDevice->PortCount, 'cpvw'); if (pDevice->pPorts == NULL) { return STATUS_NO_MEMORY; diff --git a/branches/winverbs/core/winverbs/user/wv_pd.cpp b/branches/winverbs/core/winverbs/user/wv_pd.cpp index beb1d1dc..6002bb1d 100644 --- a/branches/winverbs/core/winverbs/user/wv_pd.cpp +++ b/branches/winverbs/core/winverbs/user/wv_pd.cpp @@ -198,9 +198,9 @@ AllocateMemoryWindow(IWVMemoryWindow** ppMw) } STDMETHODIMP CWVProtectionDomain:: -CreateAddressHandle(WV_ADDRESS_VECTOR* pAddress, IWVAddressHandle** ppAh) +CreateAddressHandle(WV_ADDRESS_VECTOR* pAddress, IWVAddressHandle** ppAh, ULONG_PTR *pAhKey) { - return CWVAddressHandle::CreateInstance(this, pAddress, ppAh); + return CWVAddressHandle::CreateInstance(this, pAddress, ppAh, pAhKey); } @@ -328,15 +328,15 @@ Create(WV_ADDRESS_VECTOR* pAddress) ib_api_status_t stat; HRESULT hr; ci_umv_buf_t verbsData; - ib_av_attr_t av; + ib_av_attr_t attr; CWVBuffer buf; - hr = ConvertAv(&av, pAddress); + hr = ConvertAv(&attr, pAddress); if (FAILED(hr)) { return hr; } - stat = m_pVerbs->pre_create_av(m_pPd->m_hVerbsPd, &av, &verbsData, &m_hVerbsAh); + stat = m_pVerbs->pre_create_av(m_pPd->m_hVerbsPd, &attr, &verbsData, &m_hVerbsAh); if (stat != IB_SUCCESS) { if (stat == IB_VERBS_PROCESSING_DONE) { m_Id = (ULONG_PTR) m_hVerbsAh; diff --git a/branches/winverbs/core/winverbs/user/wv_pd.h b/branches/winverbs/core/winverbs/user/wv_pd.h index 00f46b8d..209894ad 100644 --- a/branches/winverbs/core/winverbs/user/wv_pd.h +++ b/branches/winverbs/core/winverbs/user/wv_pd.h @@ -58,7 +58,7 @@ public: STDMETHODIMP DeregisterMemory(UINT32 Lkey, OVERLAPPED* pOverlapped); STDMETHODIMP AllocateMemoryWindow(IWVMemoryWindow** ppMw); STDMETHODIMP CreateAddressHandle(WV_ADDRESS_VECTOR* pAddress, - IWVAddressHandle** ppAh); + IWVAddressHandle** ppAh, ULONG_PTR *pAhKey); CWVProtectionDomain(CWVDevice *pDevice); ~CWVProtectionDomain(); @@ -170,7 +170,7 @@ public: void Delete() {delete this;} static STDMETHODIMP CreateInstance(CWVProtectionDomain *pPd, WV_ADDRESS_VECTOR* pAddress, - IWVAddressHandle** ppAh) + IWVAddressHandle** ppAh, ULONG_PTR* pAhKey) { HRESULT hr; CWVAddressHandle *ah; @@ -192,6 +192,7 @@ public: } *ppAh = ah; + *pAhKey = (ULONG_PTR) ah->m_hVerbsAh; return WV_SUCCESS; err2: diff --git a/branches/winverbs/core/winverbs/user/wv_qp.cpp b/branches/winverbs/core/winverbs/user/wv_qp.cpp index 775a1ed7..ac4a75ae 100644 --- a/branches/winverbs/core/winverbs/user/wv_qp.cpp +++ b/branches/winverbs/core/winverbs/user/wv_qp.cpp @@ -419,27 +419,12 @@ PostReceive(UINT64 WrId, WV_SGE* pSgl, SIZE_T nSge) STDMETHODIMP CWVQueuePair:: PostSend(WV_SEND_REQUEST *pSend, WV_SEND_REQUEST **ppFailed) { - CWVAddressHandle *ah; ib_send_wr_t *wr; ib_api_status_t stat; HRESULT hr; - if (m_Type == WvQpTypeUd) { - if (pSend->pNext != NULL) { - return WV_NOT_SUPPORTED; - } - - WvConvertSgl(pSend->pSgl, pSend->nSge); - ah = (CWVAddressHandle *) pSend->Wr.Datagram.pAddresHandle; - pSend->Wr.Datagram.pAddresHandle = (IWVAddressHandle *) ah->m_hVerbsAh; - stat = m_pVerbs->post_send(m_hVerbsQp, (ib_send_wr_t *) pSend, - (ppFailed == NULL) ? &wr : (ib_send_wr_t **) ppFailed); - pSend->Wr.Datagram.pAddresHandle = (IWVAddressHandle *) ah; - } else { - stat = m_pVerbs->post_send(m_hVerbsQp, WvConvertSends(pSend), - (ppFailed == NULL) ? &wr : (ib_send_wr_t **) ppFailed); - } - + stat = m_pVerbs->post_send(m_hVerbsQp, WvConvertSends(pSend), + (ppFailed == NULL) ? &wr : (ib_send_wr_t **) ppFailed); if (stat == IB_SUCCESS) { hr = WV_SUCCESS; } else { @@ -709,7 +694,7 @@ PostSend(WV_SEND_REQUEST *pSend, WV_SEND_REQUEST **ppFailed) } STDMETHODIMP CWVDatagramQueuePair:: -Send(UINT64 WrId, IWVAddressHandle* pAddressHandle, +Send(UINT64 WrId, ULONG_PTR AhKey, WV_SGE* pSge, DWORD Flags, NET32 DestinationQpn, NET32 DestinationQkey) { @@ -725,7 +710,7 @@ Send(UINT64 WrId, IWVAddressHandle* pAddressHandle, wr.Wr.Datagram.DestinationQkey = DestinationQkey; wr.Wr.Datagram.DestinationQpn = DestinationQpn; - wr.Wr.Datagram.pAddresHandle = pAddressHandle; + wr.Wr.Datagram.AhKey = AhKey; hr = PostSend(&wr, NULL); return hr; @@ -747,7 +732,7 @@ SendMessage(WV_SEND_DATAGRAM* pSend) wr.Wr.Datagram.DestinationQkey = pSend->DestinationQkey; wr.Wr.Datagram.DestinationQpn = pSend->DestinationQpn; - wr.Wr.Datagram.pAddresHandle = pSend->pAddressHandle; + wr.Wr.Datagram.AhKey = pSend->AhKey; hr = PostSend(&wr, NULL); return hr; diff --git a/branches/winverbs/core/winverbs/user/wv_qp.h b/branches/winverbs/core/winverbs/user/wv_qp.h index 749778d2..3060c151 100644 --- a/branches/winverbs/core/winverbs/user/wv_qp.h +++ b/branches/winverbs/core/winverbs/user/wv_qp.h @@ -171,7 +171,7 @@ public: STDMETHODIMP PostSend(WV_SEND_REQUEST *pSend, WV_SEND_REQUEST **ppFailed); // IWVDatagramQueuePair Methods - STDMETHODIMP Send(UINT64 WrId, IWVAddressHandle* pAddressHandle, + STDMETHODIMP Send(UINT64 WrId, ULONG_PTR AhKey, WV_SGE* pSge, DWORD Flags, NET32 DestinationQpn, NET32 DestinationQkey); STDMETHODIMP SendMessage(WV_SEND_DATAGRAM* pSend); diff --git a/branches/winverbs/inc/user/rdma/winverbs.h b/branches/winverbs/inc/user/rdma/winverbs.h index b597339e..19a6fceb 100644 --- a/branches/winverbs/inc/user/rdma/winverbs.h +++ b/branches/winverbs/inc/user/rdma/winverbs.h @@ -272,7 +272,7 @@ typedef struct _WV_SGE typedef struct _WV_SEND_DATAGRAM { UINT64 WrId; - interface IWVAddressHandle* pAddressHandle; + ULONG_PTR AhKey; WV_SGE* pSgl; SIZE_T nSge; @@ -323,7 +323,7 @@ typedef struct _WV_SEND_REQUEST struct { - interface IWVAddressHandle* pAddresHandle; + ULONG_PTR AhKey; NET32 DestinationQpn; NET32 DestinationQkey; @@ -989,7 +989,7 @@ DECLARE_INTERFACE_(IWVDatagramQueuePair, IWVQueuePair) STDMETHOD(Send)( THIS_ __in UINT64 WrId, - __in IWVAddressHandle* pAddressHandle, + __in ULONG_PTR AhKey, __in WV_SGE* pSge, __in DWORD Flags, __in NET32 DestinationQpn, @@ -1084,7 +1084,8 @@ DECLARE_INTERFACE_(IWVProtectionDomain, IUnknown) STDMETHOD(CreateAddressHandle)( THIS_ __in WV_ADDRESS_VECTOR* pAddress, - __deref_out IWVAddressHandle** ppAh + __deref_out IWVAddressHandle** ppAh, + __out ULONG_PTR* pAhKey ) PURE; }; diff --git a/branches/winverbs/ulp/libibverbs/examples/asyncwatch/asyncwatch.c b/branches/winverbs/ulp/libibverbs/examples/asyncwatch/asyncwatch.c index 49096030..385c8979 100644 --- a/branches/winverbs/ulp/libibverbs/examples/asyncwatch/asyncwatch.c +++ b/branches/winverbs/ulp/libibverbs/examples/asyncwatch/asyncwatch.c @@ -92,7 +92,7 @@ int __cdecl main(int argc, char *argv[]) return 1; } - printf("%s: async eventd\n", ibv_get_device_name(*dev_list)); + printf("%s: async event\n", ibv_get_device_name(*dev_list)); while (1) { if (ibv_get_async_event(context, &event)) diff --git a/branches/winverbs/ulp/libibverbs/include/infiniband/verbs.h b/branches/winverbs/ulp/libibverbs/include/infiniband/verbs.h index daea712b..c849d759 100644 --- a/branches/winverbs/ulp/libibverbs/include/infiniband/verbs.h +++ b/branches/winverbs/ulp/libibverbs/include/infiniband/verbs.h @@ -656,6 +656,7 @@ struct ibv_ah struct ibv_context *context; struct ibv_pd *pd; IWVAddressHandle *handle; + ULONG_PTR key; }; struct ibv_device; diff --git a/branches/winverbs/ulp/libibverbs/src/device.cpp b/branches/winverbs/ulp/libibverbs/src/device.cpp index bb6fc088..6b29b295 100644 --- a/branches/winverbs/ulp/libibverbs/src/device.cpp +++ b/branches/winverbs/ulp/libibverbs/src/device.cpp @@ -47,7 +47,7 @@ struct verbs_port DWORD event_flag; }; -#define EVENT_PORT_NONE -1 +#define EVENT_PORT_NONE 0xFF struct verbs_context { @@ -55,7 +55,7 @@ struct verbs_context struct verbs_device device; HANDLE *event; struct verbs_port *port; - uint8_t event_port_num; + uint8_t event_port_index; }; __declspec(dllexport) @@ -163,7 +163,8 @@ struct ibv_context *ibv_open_device(struct ibv_device *device) return NULL; } memcpy(&vcontext->device, vdev, sizeof(struct verbs_device)); - vcontext->event_port_num = EVENT_PORT_NONE; + vcontext->event_port_index = EVENT_PORT_NONE; + vcontext->context.timeout = INFINITE; vcontext->port = new struct verbs_port[vdev->phys_port_cnt]; if (vcontext->port == NULL) { @@ -188,7 +189,7 @@ struct ibv_context *ibv_open_device(struct ibv_device *device) vcontext->port[i].overlap.hEvent = vcontext->event[i]; vcontext->port[i].event_flag = 0; - vcontext->context.cmd_if->Notify((UINT8) i, + vcontext->context.cmd_if->Notify((UINT8) i + 1, &vcontext->port[i].overlap, &vcontext->port[i].event_flag); } @@ -233,7 +234,7 @@ static enum ibv_event_type ibv_get_port_event_state(struct verbs_context *vconte WV_PORT_ATTRIBUTES attr; HRESULT hr; - hr = vcontext->context.cmd_if->QueryPort(vcontext->event_port_num, &attr); + hr = vcontext->context.cmd_if->QueryPort(vcontext->event_port_index + 1, &attr); if (FAILED(hr)) { return IBV_EVENT_PORT_ERR; } @@ -248,8 +249,8 @@ static int ibv_report_port_event(struct verbs_context *vcontext, struct verbs_port *port; int ret = 0; - port = &vcontext->port[vcontext->event_port_num]; - event->element.port_num = vcontext->event_port_num; + port = &vcontext->port[vcontext->event_port_index]; + event->element.port_num = vcontext->event_port_index + 1; if (port->event_flag & WV_EVENT_ERROR) { event->event_type = IBV_EVENT_DEVICE_FATAL; @@ -272,9 +273,9 @@ static int ibv_report_port_event(struct verbs_context *vcontext, } if (port->event_flag == 0) { - vcontext->context.cmd_if->Notify(vcontext->event_port_num, + vcontext->context.cmd_if->Notify(vcontext->event_port_index + 1, &port->overlap, &port->event_flag); - vcontext->event_port_num = EVENT_PORT_NONE; + vcontext->event_port_index = EVENT_PORT_NONE; } return ret; } @@ -288,7 +289,7 @@ int ibv_get_async_event(struct ibv_context *context, int i; vcontext = CONTAINING_RECORD(context, struct verbs_context, context); - if (vcontext->event_port_num != EVENT_PORT_NONE) { + if (vcontext->event_port_index != EVENT_PORT_NONE) { if (ibv_report_port_event(vcontext, event) == 0) { return 0; } @@ -302,7 +303,7 @@ int ibv_get_async_event(struct ibv_context *context, return HRESULT_FROM_WIN32(GetLastError()); } - vcontext->event_port_num = (UINT8) hr; + vcontext->event_port_index = (UINT8) hr; return ibv_report_port_event(vcontext, event); } diff --git a/branches/winverbs/ulp/libibverbs/src/verbs.cpp b/branches/winverbs/ulp/libibverbs/src/verbs.cpp index f0bdb40f..9fab212a 100644 --- a/branches/winverbs/ulp/libibverbs/src/verbs.cpp +++ b/branches/winverbs/ulp/libibverbs/src/verbs.cpp @@ -814,8 +814,19 @@ int ibv_post_send(struct ibv_qp *qp, struct ibv_send_wr *wr, { struct ibv_send_wr *cur_wr; HRESULT hr = 0; + struct ibv_ah *ah; + + if ((qp->qp_type == IBV_QPT_UD) && (wr->next != NULL)) + return WV_NOT_SUPPORTED; for (cur_wr = wr; cur_wr != NULL; cur_wr = cur_wr->next) { + if (qp->qp_type == IBV_QPT_UD) { + ah = cur_wr->wr.ud.ah; + cur_wr->wr.ud.ah = (struct ibv_ah *) ah->key; + cur_wr->wr.ud.remote_qkey = htonl(cur_wr->wr.ud.remote_qkey); + cur_wr->wr.ud.remote_qpn = htonl(cur_wr->wr.ud.remote_qpn); + } + if ((cur_wr->opcode & 0x80000000) != 0) { cur_wr->opcode = (ibv_wr_opcode) (cur_wr->opcode & ~0x80000000); cur_wr->send_flags = (ibv_send_flags) (cur_wr->send_flags | WV_SEND_IMMEDIATE); @@ -825,6 +836,12 @@ int ibv_post_send(struct ibv_qp *qp, struct ibv_send_wr *wr, hr = qp->handle->PostSend((WV_SEND_REQUEST *) wr, (WV_SEND_REQUEST **) bad_wr); for (cur_wr = wr; cur_wr != NULL; cur_wr = cur_wr->next) { + if (qp->qp_type == IBV_QPT_UD) { + cur_wr->wr.ud.ah = ah; + cur_wr->wr.ud.remote_qkey = ntohl(cur_wr->wr.ud.remote_qkey); + cur_wr->wr.ud.remote_qpn = ntohl(cur_wr->wr.ud.remote_qpn); + } + if ((cur_wr->send_flags & WV_SEND_IMMEDIATE) != 0) { cur_wr->send_flags = (ibv_send_flags) (cur_wr->send_flags & ~WV_SEND_IMMEDIATE); cur_wr->opcode = (ibv_wr_opcode) (cur_wr->opcode | 0x80000000); @@ -877,7 +894,7 @@ struct ibv_ah *ibv_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr) ah->context = pd->context; ah->pd = pd; ibv_convert_ah_attr(pd->context, &av, attr); - hr = pd->handle->CreateAddressHandle(&av, &ah->handle); + hr = pd->handle->CreateAddressHandle(&av, &ah->handle, &ah->key); if (FAILED(hr)) { delete ah; return NULL;