]> git.openfabrics.org - ~shefty/rdma-win.git/commitdiff
winverbs/libibverbs: update to support UD QPs and async events
authorshefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Sat, 19 Jul 2008 04:31:58 +0000 (04:31 +0000)
committershefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Sat, 19 Jul 2008 04:31:58 +0000 (04:31 +0000)
Signed-off-by: Sean Hefty <sean.hefty@intel.com>
git-svn-id: svn://openib.tc.cornell.edu/gen1@1421 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

branches/winverbs/core/winverbs/kernel/wv_device.c
branches/winverbs/core/winverbs/user/wv_pd.cpp
branches/winverbs/core/winverbs/user/wv_pd.h
branches/winverbs/core/winverbs/user/wv_qp.cpp
branches/winverbs/core/winverbs/user/wv_qp.h
branches/winverbs/inc/user/rdma/winverbs.h
branches/winverbs/ulp/libibverbs/examples/asyncwatch/asyncwatch.c
branches/winverbs/ulp/libibverbs/include/infiniband/verbs.h
branches/winverbs/ulp/libibverbs/src/device.cpp
branches/winverbs/ulp/libibverbs/src/verbs.cpp

index 87fffa6dd2ac2b3526a7abfd5a89ae82ddbac043..c411f114bba1f9a3ae206072d0410de2b151aeb6 100644 (file)
@@ -113,7 +113,7 @@ static void WvDeviceCompleteRequests(WV_PORT *pPort, NTSTATUS ReqStatus, UINT32
 \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
@@ -122,6 +122,8 @@ static void WvDeviceEventHandler(ib_event_rec_t *pEvent)
                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
@@ -202,7 +204,7 @@ static NTSTATUS WvDeviceCreatePorts(WV_DEVICE *pDevice)
        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
index beb1d1dccdde3e5ec686e6fa1950b457e8e2ebc8..6002bb1d16bbecca40816f3502380ed82c38841f 100644 (file)
@@ -198,9 +198,9 @@ AllocateMemoryWindow(IWVMemoryWindow** ppMw)
 }\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
@@ -328,15 +328,15 @@ Create(WV_ADDRESS_VECTOR* pAddress)
        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
index 00f46b8ddfe698901e3d36a3bbb18c689b88a049..209894ad6e0410daf36879bcfa1ca8c664a65b5c 100644 (file)
@@ -58,7 +58,7 @@ public:
        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
@@ -170,7 +170,7 @@ public:
        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
@@ -192,6 +192,7 @@ public:
                }\r
 \r
                *ppAh = ah;\r
+               *pAhKey = (ULONG_PTR) ah->m_hVerbsAh;\r
                return WV_SUCCESS;\r
 \r
        err2:\r
index 775a1ed70b69e9d91079b1c360e3630d3034fe08..ac4a75ae32dc32b5aaaae61144320c425ce944ce 100644 (file)
@@ -419,27 +419,12 @@ PostReceive(UINT64 WrId, WV_SGE* pSgl, SIZE_T nSge)
 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
@@ -709,7 +694,7 @@ PostSend(WV_SEND_REQUEST *pSend, WV_SEND_REQUEST **ppFailed)
 }\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
@@ -725,7 +710,7 @@ Send(UINT64 WrId, IWVAddressHandle* pAddressHandle,
 \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
@@ -747,7 +732,7 @@ SendMessage(WV_SEND_DATAGRAM* pSend)
 \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
index 749778d2223b48846750f9b95b27aa47bf66ebec..3060c1517bda173323c90f7f910d33a803f908f2 100644 (file)
@@ -171,7 +171,7 @@ public:
        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
index b597339e36c5ef733c36e104995f0dd0b4e48a98..19a6fcebf6f80dd5c527075f69eb6ca585edf187 100644 (file)
@@ -272,7 +272,7 @@ typedef struct _WV_SGE
 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
@@ -323,7 +323,7 @@ typedef struct _WV_SEND_REQUEST
 \r
                struct\r
                {\r
-                       interface IWVAddressHandle* pAddresHandle;\r
+                       ULONG_PTR               AhKey;\r
                        NET32                   DestinationQpn;\r
                        NET32                   DestinationQkey;\r
 \r
@@ -989,7 +989,7 @@ DECLARE_INTERFACE_(IWVDatagramQueuePair, IWVQueuePair)
        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
@@ -1084,7 +1084,8 @@ DECLARE_INTERFACE_(IWVProtectionDomain, IUnknown)
        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
index 49096030c4476a90cd83ff3cb85d734bf9ce6fda..385c8979a95c098def39a27fcf17973c1aa43b8c 100644 (file)
@@ -92,7 +92,7 @@ int __cdecl main(int argc, char *argv[])
                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
index daea712bc0be72c66fca4fdf9eaf08dac00cfd53..c849d759e517b03b1290ccf5512617f0dfd97d84 100644 (file)
@@ -656,6 +656,7 @@ struct ibv_ah
        struct ibv_context              *context;\r
        struct ibv_pd                   *pd;\r
        IWVAddressHandle                *handle;\r
+       ULONG_PTR                               key;\r
 };\r
 \r
 struct ibv_device;\r
index bb6fc0883ea458e3d5de59f9c27574afb310e679..6b29b2950955198d25da0b7b26180f881c08bbbe 100644 (file)
@@ -47,7 +47,7 @@ struct verbs_port
        DWORD                           event_flag;\r
 };\r
 \r
-#define EVENT_PORT_NONE        -1\r
+#define EVENT_PORT_NONE        0xFF\r
 \r
 struct verbs_context\r
 {\r
@@ -55,7 +55,7 @@ struct verbs_context
        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
@@ -163,7 +163,8 @@ struct ibv_context *ibv_open_device(struct ibv_device *device)
                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
@@ -188,7 +189,7 @@ struct ibv_context *ibv_open_device(struct ibv_device *device)
                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
@@ -233,7 +234,7 @@ static enum ibv_event_type ibv_get_port_event_state(struct verbs_context *vconte
        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
@@ -248,8 +249,8 @@ static int ibv_report_port_event(struct verbs_context *vcontext,
        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
@@ -272,9 +273,9 @@ static int ibv_report_port_event(struct verbs_context *vcontext,
        }\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
@@ -288,7 +289,7 @@ int ibv_get_async_event(struct ibv_context *context,
        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
@@ -302,7 +303,7 @@ int ibv_get_async_event(struct ibv_context *context,
                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
index f0bdb40ff2210621d8b5cb169cf2a4037d84731f..9fab212a655f7678004f588ca9fc5fa28f2c6d88 100644 (file)
@@ -814,8 +814,19 @@ int ibv_post_send(struct ibv_qp *qp, struct ibv_send_wr *wr,
 {\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
@@ -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);\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
@@ -877,7 +894,7 @@ struct ibv_ah *ibv_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr)
        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