From 9abd550558317c525e7f7f82caae75f1a810d2b7 Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Tue, 13 Jul 2010 12:02:21 -0700 Subject: [PATCH] winverbs: add ability to query kernel interface version Define IOCTL to support querying what version of the ioctl interface is supported. Signed-off-by: Sean Hefty --- trunk/core/winverbs/kernel/wv_driver.c | 17 +++++++++++++++++ trunk/core/winverbs/user/wv_provider.cpp | 15 +++++++++++++++ trunk/core/winverbs/user/wv_provider.h | 6 ++++++ trunk/core/winverbs/wv_ioctl.h | 8 +++++++- 4 files changed, 45 insertions(+), 1 deletion(-) diff --git a/trunk/core/winverbs/kernel/wv_driver.c b/trunk/core/winverbs/kernel/wv_driver.c index d5321602..281fdf69 100644 --- a/trunk/core/winverbs/kernel/wv_driver.c +++ b/trunk/core/winverbs/kernel/wv_driver.c @@ -127,6 +127,20 @@ void WvCompleteRequestsWithInformation(WDFQUEUE Queue, NTSTATUS ReqStatus) } } +static void WvVersionQuery(WDFREQUEST Request) +{ + size_t len = 0; + UINT64 *version; + NTSTATUS status; + + status = WdfRequestRetrieveOutputBuffer(Request, sizeof(UINT64), &version, &len); + if (NT_SUCCESS(status)) { + *version = WV_KERNEL_VERSION; + } + + WdfRequestCompleteWithInformation(Request, status, len); +} + static void WvGuidQuery(WDFREQUEST Request) { WV_IO_GUID_LIST *list; @@ -212,6 +226,9 @@ static VOID WvIoDeviceControl(WDFQUEUE Queue, WDFREQUEST Request, // TODO: verify this compiles as a jump table, or use function pointers switch (IoControlCode) { + case WV_IO_FUNCTION_VERSION_QUERY: + WvVersionQuery(Request); + break; case WV_IOCTL_GUID_QUERY: WvGuidQuery(Request); break; diff --git a/trunk/core/winverbs/user/wv_provider.cpp b/trunk/core/winverbs/user/wv_provider.cpp index 65b0c878..e4fdf581 100644 --- a/trunk/core/winverbs/user/wv_provider.cpp +++ b/trunk/core/winverbs/user/wv_provider.cpp @@ -40,6 +40,7 @@ CWVProvider::CWVProvider() { InterlockedIncrement(&WvRef); m_hFile = INVALID_HANDLE_VALUE; + m_KernelVersion = WV_KERNEL_VERSION; } CWVProvider::~CWVProvider() @@ -81,6 +82,20 @@ GetFileHandle(void) return m_hFile; } +/* + * Version query was not supported in initial version 1 release. + */ +void CWVProvider:: +SetKernelVersion(void) +{ + DWORD bytes; + + if (!WvDeviceIoControl(m_hFile, WV_IOCTL_VERSION_QUERY, NULL, 0, + &m_KernelVersion, sizeof(m_KernelVersion), &bytes, NULL)) { + m_KernelVersion = 1; + } +} + STDMETHODIMP CWVProvider:: QueryDeviceList(NET64* pGuidList, SIZE_T* pBufferSize) { diff --git a/trunk/core/winverbs/user/wv_provider.h b/trunk/core/winverbs/user/wv_provider.h index 5daa4c77..fc637aca 100644 --- a/trunk/core/winverbs/user/wv_provider.h +++ b/trunk/core/winverbs/user/wv_provider.h @@ -91,6 +91,7 @@ public: hr = HRESULT_FROM_WIN32(GetLastError()); goto err2; } + wv->SetKernelVersion(); *ppProvider = wv; return WV_SUCCESS; @@ -100,6 +101,11 @@ public: *ppProvider = NULL; return hr; } + + UINT64 m_KernelVersion; + +private: + void SetKernelVersion(); }; #endif // _WV_PROVIDER_H_ \ No newline at end of file diff --git a/trunk/core/winverbs/wv_ioctl.h b/trunk/core/winverbs/wv_ioctl.h index 7a8701f1..ce091d10 100644 --- a/trunk/core/winverbs/wv_ioctl.h +++ b/trunk/core/winverbs/wv_ioctl.h @@ -36,6 +36,8 @@ typedef UINT16 NET16; typedef UINT32 NET32; typedef UINT64 NET64; +#define WV_KERNEL_VERSION 1 + #define WV_IOCTL(f) CTL_CODE(FILE_DEVICE_INFINIBAND, f, METHOD_BUFFERED,\ FILE_READ_DATA | FILE_WRITE_DATA) @@ -44,7 +46,7 @@ typedef UINT64 NET64; #define WV_IO_FUNCTION_BASE 0x800 enum { - WV_IO_FUNCTION_MIN, + WV_IO_FUNCTION_VERSION_QUERY, WV_IO_FUNCTION_GUID_QUERY, WV_IO_FUNCTION_LIBRARY_QUERY, WV_IO_FUNCTION_DEVICE_OPEN, @@ -100,6 +102,10 @@ enum { WV_IO_FUNCTION_PD_CANCEL }; +// none / UINT64 Version +#define WV_IOCTL_VERSION_QUERY WV_IOCTL(WV_IO_FUNCTION_BASE + \ + WV_IO_FUNCTION_VERSION_QUERY) + // none / WV_IO_GUID_LIST #define WV_IOCTL_GUID_QUERY WV_IOCTL(WV_IO_FUNCTION_BASE + \ WV_IO_FUNCTION_GUID_QUERY) -- 2.46.0