winverbs/nd: map completion status to ND values
[mirror/winof/.git] / ulp / netdirect / user / nd_cq.h
1 /*\r
2  * Copyright (c) 2009 Intel Corporation. All rights reserved.\r
3  *\r
4  * This software is available to you under the OpenIB.org BSD license\r
5  * below:\r
6  *\r
7  *     Redistribution and use in source and binary forms, with or\r
8  *     without modification, are permitted provided that the following\r
9  *     conditions are met:\r
10  *\r
11  *      - Redistributions of source code must retain the above\r
12  *        copyright notice, this list of conditions and the following\r
13  *        disclaimer.\r
14  *\r
15  *      - Redistributions in binary form must reproduce the above\r
16  *        copyright notice, this list of conditions and the following\r
17  *        disclaimer in the documentation and/or other materials\r
18  *        provided with the distribution.\r
19  *\r
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
23  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
24  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
25  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
26  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
27  * SOFTWARE.\r
28  */\r
29 \r
30 #pragma once\r
31 \r
32 #ifndef _ND_CQ_H_\r
33 #define _ND_CQ_H_\r
34 \r
35 #include <initguid.h>\r
36 #include <ndspi.h>\r
37 #include "nd_base.h"\r
38 #include "nd_adapter.h"\r
39 \r
40 class CNDCompletionQueue : public INDCompletionQueue, public CNDBase\r
41 {\r
42 public:\r
43         // IUnknown methods\r
44         STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR* ppvObj);\r
45         STDMETHODIMP_(ULONG) AddRef();\r
46         STDMETHODIMP_(ULONG) Release();\r
47 \r
48         // INDOverlapped methods\r
49         STDMETHODIMP CancelOverlappedRequests();\r
50         STDMETHODIMP GetOverlappedResult(OVERLAPPED *pOverlapped,\r
51                                                                          SIZE_T *pNumberOfBytesTransferred, BOOL bWait);\r
52 \r
53         // INDCompletionQueue methods\r
54         STDMETHODIMP Resize(SIZE_T nEntries);\r
55         STDMETHODIMP Notify(DWORD Type, OVERLAPPED* pOverlapped);\r
56         STDMETHODIMP_(SIZE_T) GetResults(ND_RESULT* pResults[], SIZE_T nResults);\r
57 \r
58         CNDCompletionQueue(CNDAdapter *pAdapter);\r
59         ~CNDCompletionQueue();\r
60         void Delete() {delete this;}\r
61         static STDMETHODIMP\r
62         CreateInstance(CNDAdapter *pAdapter, SIZE_T nEntries, INDCompletionQueue** ppCq)\r
63         {\r
64                 HRESULT hr;\r
65                 CNDCompletionQueue *cq;\r
66 \r
67                 cq = new CNDCompletionQueue(pAdapter);\r
68                 if (cq == NULL) {\r
69                         hr = ND_NO_MEMORY;\r
70                         goto err1;\r
71                 }\r
72 \r
73                 hr = cq->Init(nEntries);\r
74                 if (FAILED(hr)) {\r
75                         goto err2;\r
76                 }\r
77 \r
78                 *ppCq = cq;\r
79                 return ND_SUCCESS;\r
80 \r
81         err2:\r
82                 cq->Release();\r
83         err1:\r
84                 *ppCq = NULL;\r
85                 return hr;\r
86         }\r
87 \r
88         IWVCompletionQueue      *m_pWvCq;\r
89 \r
90 protected:\r
91         CNDAdapter                      *m_pAdapter;\r
92         STDMETHODIMP            Init(SIZE_T nEntries);\r
93         STDMETHODIMP_(HRESULT) ConvertStatus(WV_WC_STATUS Status);\r
94 };\r
95 \r
96 #endif // _ND_CQ_H_\r