[ofw] [PATCH 1/4] winmad: support registration for unsolicited MADs
Sean Hefty
sean.hefty at intel.com
Fri May 8 11:17:14 PDT 2009
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 at intel.com>
---
diff -up -r -X \mshefty\scm\winof\trunk\docs\dontdiff.txt -I '\$Id:' trunk\core\winmad/kernel/wm_provider.c
branches\winverbs\core\winmad/kernel/wm_provider.c
--- trunk\core\winmad/kernel/wm_provider.c 2009-05-05 11:54:32.247285400 -0700
+++ branches\winverbs\core\winmad/kernel/wm_provider.c 2009-05-06 11:29:12.287547100 -0700
@@ -106,7 +106,7 @@ void WmProviderDeregister(WM_PROVIDER *p
next = mad->p_next;
mad->p_next = NULL;
- if (mad->send_context1 == pRegistration) {
+ if (mad->context1 == pRegistration) {
pRegistration->pDevice->IbInterface.put_mad(mad);
} else {
WmInsertMad(pProvider, mad);
@@ -215,14 +215,9 @@ void WmProviderRemoveHandler(WM_PROVIDER
WmProviderUnlockRemove(pProvider);
}
-static NTSTATUS WmCopyRead(WM_PROVIDER *pProvider, WM_IO_MAD *pIoMad,
- ib_mad_element_t *pMad, size_t *pLen)
+static NTSTATUS WmCopyMad(WM_IO_MAD *pIoMad, ib_mad_element_t *pMad, size_t *pLen)
{
- WM_REGISTRATION *reg;
-
- reg = (WM_REGISTRATION *) pMad->send_context1;
- pIoMad->Id = reg->Id;
-
+ pIoMad->Id = ((WM_REGISTRATION *) pMad->context1)->Id;
pIoMad->Status = pMad->status;
pIoMad->Timeout = pMad->timeout_ms;
pIoMad->Retries = pMad->retry_cnt;
@@ -278,9 +273,9 @@ void WmProviderRead(WM_PROVIDER *pProvid
}
len = outlen;
- status = WmCopyRead(pProvider, wmad, pProvider->MadHead, &len);
+ status = WmCopyMad(wmad, pProvider->MadHead, &len);
if (status == STATUS_SUCCESS) {
- reg = (WM_REGISTRATION *) pProvider->MadHead->send_context1;
+ reg = (WM_REGISTRATION *) pProvider->MadHead->context1;
reg->pDevice->IbInterface.put_mad(WmRemoveMad(pProvider));
}
WdfObjectReleaseLock(pProvider->ReadQueue);
@@ -302,7 +297,6 @@ static NTSTATUS WmSendMad(WM_REGISTRATIO
return STATUS_NO_MEMORY;
}
- mad->context1 = pRegistration;
RtlCopyMemory(mad->p_mad_buf, pIoMad + 1, size);
mad->remote_qp = pIoMad->Address.Qpn;
mad->remote_qkey = pIoMad->Address.Qkey;
@@ -322,7 +316,9 @@ static NTSTATUS WmSendMad(WM_REGISTRATIO
mad->remote_sl = pIoMad->Address.ServiceLevel;
mad->pkey_index = pIoMad->Address.PkeyIndex;
mad->path_bits = pIoMad->Address.PathBits;
- mad->p_mad_buf->trans_id &= 0xFFFFFFFF00000000;
+ if (!ib_mad_is_response(mad->p_mad_buf)) {
+ mad->p_mad_buf->trans_id &= 0xFFFFFFFF00000000;
+ }
ib_status = pifc->send_mad(pRegistration->hService, mad, NULL);
if (ib_status != IB_SUCCESS) {
@@ -366,15 +362,16 @@ out:
void WmReceiveHandler(ib_mad_svc_handle_t hService, void *Context,
ib_mad_element_t *pMad)
{
- WM_REGISTRATION *reg;
- WM_PROVIDER *prov = Context;
+ WM_REGISTRATION *reg = Context;
+ WM_PROVIDER *prov;
WDFREQUEST request;
NTSTATUS status;
WM_IO_MAD *wmad;
size_t len = 0;
UNREFERENCED_PARAMETER(hService);
- reg = (WM_REGISTRATION *) pMad->send_context1;
+ prov = reg->pProvider;
+ pMad->context1 = reg;
WdfObjectAcquireLock(prov->ReadQueue);
if (reg->hService == NULL) {
@@ -394,9 +391,8 @@ void WmReceiveHandler(ib_mad_svc_handle_
goto complete;
}
- status = WmCopyRead(prov, wmad, pMad, &len);
+ status = WmCopyMad(wmad, pMad, &len);
if (status == STATUS_SUCCESS) {
- reg = (WM_REGISTRATION *) pMad->send_context1;
reg->pDevice->IbInterface.put_mad(pMad);
} else {
WmInsertMad(prov, pMad);
@@ -412,9 +408,8 @@ void WmSendHandler(ib_mad_svc_handle_t h
ib_mad_element_t *pMad)
{
if (pMad->status == IB_SUCCESS) {
- ((WM_REGISTRATION *) pMad->context1)->pDevice->IbInterface.put_mad(pMad);
+ ((WM_REGISTRATION *) Context)->pDevice->IbInterface.put_mad(pMad);
} else {
- pMad->send_context1 = (void*) pMad->context1;
WmReceiveHandler(hService, Context, pMad);
}
}
diff -up -r -X \mshefty\scm\winof\trunk\docs\dontdiff.txt -I '\$Id:' trunk\core\winmad/kernel/wm_reg.c
branches\winverbs\core\winmad/kernel/wm_reg.c
--- trunk\core\winmad/kernel/wm_reg.c 2009-05-05 11:54:32.356661800 -0700
+++ branches\winverbs\core\winmad/kernel/wm_reg.c 2009-05-06 10:00:53.643734500 -0700
@@ -146,7 +146,7 @@ static NTSTATUS WmRegInit(WM_REGISTRATIO
goto err4;
}
- svc.mad_svc_context = pRegistration->pProvider;
+ svc.mad_svc_context = pRegistration;
svc.pfn_mad_send_cb = WmSendHandler;
svc.pfn_mad_recv_cb = WmReceiveHandler;
svc.support_unsol = WmConvertMethods(&svc, pAttributes);
More information about the ofw
mailing list