winmad: support registration for unsolicited MADs
authorshefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 12 May 2009 17:21:47 +0000 (17:21 +0000)
committershefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 12 May 2009 17:21:47 +0000 (17:21 +0000)
To support ibping, winmad needs to support registering for unsolicited
MADs.  We just need to change the MAD service context from referencing
the WMProvider to the WMRegistration.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@2171 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

core/winmad/kernel/wm_provider.c
core/winmad/kernel/wm_reg.c

index 56df62f..a150bf1 100644 (file)
@@ -106,7 +106,7 @@ void WmProviderDeregister(WM_PROVIDER *pProvider, WM_REGISTRATION *pRegistration
                next = mad->p_next;\r
                mad->p_next = NULL;\r
 \r
-               if (mad->send_context1 == pRegistration) {\r
+               if (mad->context1 == pRegistration) {\r
                        pRegistration->pDevice->IbInterface.put_mad(mad);\r
                } else {\r
                        WmInsertMad(pProvider, mad);\r
@@ -215,14 +215,9 @@ void WmProviderRemoveHandler(WM_PROVIDER *pProvider, WM_IB_DEVICE *pDevice)
        WmProviderUnlockRemove(pProvider);\r
 }\r
 \r
-static NTSTATUS WmCopyRead(WM_PROVIDER *pProvider, WM_IO_MAD *pIoMad,\r
-                                                  ib_mad_element_t *pMad, size_t *pLen)\r
+static NTSTATUS WmCopyMad(WM_IO_MAD *pIoMad, ib_mad_element_t *pMad, size_t *pLen)\r
 {\r
-       WM_REGISTRATION         *reg;\r
-\r
-       reg = (WM_REGISTRATION *) pMad->send_context1;\r
-       pIoMad->Id = reg->Id;\r
-\r
+       pIoMad->Id = ((WM_REGISTRATION *) pMad->context1)->Id;\r
        pIoMad->Status = pMad->status;\r
        pIoMad->Timeout = pMad->timeout_ms;\r
        pIoMad->Retries = pMad->retry_cnt;\r
@@ -278,9 +273,9 @@ void WmProviderRead(WM_PROVIDER *pProvider, WDFREQUEST Request)
        }\r
 \r
        len = outlen;\r
-       status = WmCopyRead(pProvider, wmad, pProvider->MadHead, &len);\r
+       status = WmCopyMad(wmad, pProvider->MadHead, &len);\r
        if (status == STATUS_SUCCESS) {\r
-               reg = (WM_REGISTRATION *) pProvider->MadHead->send_context1;\r
+               reg = (WM_REGISTRATION *) pProvider->MadHead->context1;\r
                reg->pDevice->IbInterface.put_mad(WmRemoveMad(pProvider));\r
        }\r
        WdfObjectReleaseLock(pProvider->ReadQueue);\r
@@ -302,7 +297,6 @@ static NTSTATUS WmSendMad(WM_REGISTRATION *pRegistration, WM_IO_MAD *pIoMad, UIN
                return STATUS_NO_MEMORY;\r
        }\r
 \r
-       mad->context1 = pRegistration;\r
        RtlCopyMemory(mad->p_mad_buf, pIoMad + 1, size);\r
        mad->remote_qp = pIoMad->Address.Qpn;\r
        mad->remote_qkey = pIoMad->Address.Qkey;\r
@@ -322,7 +316,9 @@ static NTSTATUS WmSendMad(WM_REGISTRATION *pRegistration, WM_IO_MAD *pIoMad, UIN
        mad->remote_sl = pIoMad->Address.ServiceLevel;\r
        mad->pkey_index = pIoMad->Address.PkeyIndex;\r
        mad->path_bits = pIoMad->Address.PathBits;\r
-       mad->p_mad_buf->trans_id &= 0xFFFFFFFF00000000;\r
+       if (!ib_mad_is_response(mad->p_mad_buf)) {\r
+               mad->p_mad_buf->trans_id &= 0xFFFFFFFF00000000;\r
+       }\r
 \r
        ib_status = pifc->send_mad(pRegistration->hService, mad, NULL);\r
        if (ib_status != IB_SUCCESS) {\r
@@ -366,15 +362,16 @@ out:
 void WmReceiveHandler(ib_mad_svc_handle_t hService, void *Context,\r
                                          ib_mad_element_t *pMad)\r
 {\r
-       WM_REGISTRATION *reg;\r
-       WM_PROVIDER             *prov = Context;\r
+       WM_REGISTRATION *reg = Context;\r
+       WM_PROVIDER             *prov;\r
        WDFREQUEST              request;\r
        NTSTATUS                status;\r
        WM_IO_MAD               *wmad;\r
        size_t                  len = 0;\r
 \r
        UNREFERENCED_PARAMETER(hService);\r
-       reg = (WM_REGISTRATION *) pMad->send_context1;\r
+       prov = reg->pProvider;\r
+       pMad->context1 = reg;\r
 \r
        WdfObjectAcquireLock(prov->ReadQueue);\r
        if (reg->hService == NULL) {\r
@@ -394,9 +391,8 @@ void WmReceiveHandler(ib_mad_svc_handle_t hService, void *Context,
                goto complete;\r
        }\r
 \r
-       status = WmCopyRead(prov, wmad, pMad, &len);\r
+       status = WmCopyMad(wmad, pMad, &len);\r
        if (status == STATUS_SUCCESS) {\r
-               reg = (WM_REGISTRATION *) pMad->send_context1;\r
                reg->pDevice->IbInterface.put_mad(pMad);\r
        } else {\r
                WmInsertMad(prov, pMad);\r
@@ -412,9 +408,8 @@ void WmSendHandler(ib_mad_svc_handle_t hService, void *Context,
                                   ib_mad_element_t *pMad)\r
 {\r
        if (pMad->status == IB_SUCCESS) {\r
-               ((WM_REGISTRATION *) pMad->context1)->pDevice->IbInterface.put_mad(pMad);\r
+               ((WM_REGISTRATION *) Context)->pDevice->IbInterface.put_mad(pMad);\r
        } else {\r
-               pMad->send_context1 = (void*) pMad->context1;\r
                WmReceiveHandler(hService, Context, pMad);\r
        }\r
 }\r
index 22c0211..59f5055 100644 (file)
@@ -146,7 +146,7 @@ static NTSTATUS WmRegInit(WM_REGISTRATION *pRegistration, WM_IO_REGISTER *pAttri
                goto err4;\r
        }\r
 \r
-       svc.mad_svc_context = pRegistration->pProvider;\r
+       svc.mad_svc_context = pRegistration;\r
        svc.pfn_mad_send_cb = WmSendHandler;\r
        svc.pfn_mad_recv_cb = WmReceiveHandler;\r
        svc.support_unsol = WmConvertMethods(&svc, pAttributes);\r