From 04b8ea3669a44e1c0cc8ca562d4fcaebb3ef6ea2 Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Tue, 15 Jun 2010 17:04:28 +0000 Subject: [PATCH] winmad: fixup return values and zero allocated mad Winmad simply returns the status values defined by IBAL. Convert those values into winmad define status values and align those values with errno. This matches the expectations of libibumad. As part of the cleanup, convert the check for success from IB_SUCCESS to IB_WCS_SUCCESS. Both are defined as 0, so there's no functional change,but the mad status is a 'work completion status' value, not an API status value. Finally, return the correct status value when canceling a read request. Signed-off-by: Sean Hefty git-svn-id: svn://openib.tc.cornell.edu/gen1@2823 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- trunk/core/winmad/kernel/wm_provider.c | 10 ++++++---- trunk/core/winmad/wm_ioctl.h | 3 +++ trunk/inc/user/iba/winmad.h | 3 +++ trunk/ulp/libibumad/src/umad.cpp | 4 ++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/trunk/core/winmad/kernel/wm_provider.c b/trunk/core/winmad/kernel/wm_provider.c index a150bf1e..f3926f9e 100644 --- a/trunk/core/winmad/kernel/wm_provider.c +++ b/trunk/core/winmad/kernel/wm_provider.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008 Intel Corporation. All rights reserved. + * Copyright (c) 2008-2010 Intel Corporation. All rights reserved. * * This software is available to you under the OpenIB.org BSD license * below: @@ -407,9 +407,10 @@ unlock: void WmSendHandler(ib_mad_svc_handle_t hService, void *Context, ib_mad_element_t *pMad) { - if (pMad->status == IB_SUCCESS) { + if (pMad->status == IB_WCS_SUCCESS) { ((WM_REGISTRATION *) Context)->pDevice->IbInterface.put_mad(pMad); } else { + pMad->status = WM_IO_TIMEOUT; WmReceiveHandler(hService, Context, pMad); } } @@ -417,10 +418,11 @@ void WmSendHandler(ib_mad_svc_handle_t hService, void *Context, void WmProviderCancel(WM_PROVIDER *pProvider, WDFREQUEST Request) { WDFREQUEST request; - NTSTATUS status; + NTSTATUS status, result; WdfObjectAcquireLock(pProvider->ReadQueue); status = WdfIoQueueRetrieveNextRequest(pProvider->ReadQueue, &request); + result = status; while (NT_SUCCESS(status)) { WdfRequestComplete(request, STATUS_CANCELLED); @@ -428,5 +430,5 @@ void WmProviderCancel(WM_PROVIDER *pProvider, WDFREQUEST Request) } WdfObjectReleaseLock(pProvider->ReadQueue); - WdfRequestComplete(Request, status); + WdfRequestComplete(Request, result); } diff --git a/trunk/core/winmad/wm_ioctl.h b/trunk/core/winmad/wm_ioctl.h index 628b5b62..56063e0e 100644 --- a/trunk/core/winmad/wm_ioctl.h +++ b/trunk/core/winmad/wm_ioctl.h @@ -98,6 +98,9 @@ typedef struct _WM_IO_MAD_AV } WM_IO_MAD_AV; +#define WM_IO_SUCCESS 0 +#define WM_IO_TIMEOUT 138 + #pragma warning(push) #pragma warning(disable: 4200) typedef struct _WM_IO_MAD diff --git a/trunk/inc/user/iba/winmad.h b/trunk/inc/user/iba/winmad.h index 779ef74e..35261f55 100644 --- a/trunk/inc/user/iba/winmad.h +++ b/trunk/inc/user/iba/winmad.h @@ -72,6 +72,9 @@ typedef struct _WM_MAD_AV } WM_MAD_AV; +#define WM_SUCCESS 0 +#define WM_TIMEOUT 138 + #pragma warning(push) #pragma warning(disable: 4200) typedef struct _WM_MAD diff --git a/trunk/ulp/libibumad/src/umad.cpp b/trunk/ulp/libibumad/src/umad.cpp index 3ec19360..cdf73fdc 100644 --- a/trunk/ulp/libibumad/src/umad.cpp +++ b/trunk/ulp/libibumad/src/umad.cpp @@ -533,13 +533,13 @@ void *umad_get_mad(void *umad) __declspec(dllexport) void *umad_alloc(int num, size_t size) { - return new uint8_t[num * size]; + return calloc(num, size); } __declspec(dllexport) void umad_free(void *umad) { - delete umad; + free(umad); } __declspec(dllexport) -- 2.41.0