netdirect: add winverbs ND provider
[mirror/winof/.git] / ulp / netdirect / user / nd_ep.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_ENDPOINT_H_\r
33 #define _ND_ENDPOINT_H_\r
34 \r
35 #include <initguid.h>\r
36 #include <ndspi.h>\r
37 #include "nd_base.h"\r
38 #include "nd_connect.h"\r
39 #include "nd_cq.h"\r
40 #include "nd_adapter.h"\r
41 \r
42 \r
43 #define ND_MAX_SGE      8\r
44 \r
45 \r
46 class CNDEndpoint : public INDEndpoint, public CNDBase\r
47 {\r
48 public:\r
49         // IUnknown methods\r
50         STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR* ppvObj);\r
51         STDMETHODIMP_(ULONG) AddRef();\r
52         STDMETHODIMP_(ULONG) Release();\r
53 \r
54         // INDEndpoint methods\r
55         STDMETHODIMP Flush();\r
56         STDMETHODIMP_(void) StartRequestBatch();\r
57         STDMETHODIMP_(void) SubmitRequestBatch();\r
58         STDMETHODIMP Send(ND_RESULT* pResult, const ND_SGE* pSgl, SIZE_T nSge, DWORD Flags);\r
59         STDMETHODIMP SendAndInvalidate(ND_RESULT* pResult, const ND_SGE* pSgl, SIZE_T nSge,\r
60                                                                    const ND_MW_DESCRIPTOR* pRemoteMwDescriptor,\r
61                                                                    DWORD Flags);\r
62         STDMETHODIMP Receive(ND_RESULT* pResult, const ND_SGE* pSgl, SIZE_T nSge);\r
63         STDMETHODIMP Bind(ND_RESULT* pResult, ND_MR_HANDLE hMr, INDMemoryWindow* pMw,\r
64                                           const void* pBuffer, SIZE_T BufferSize, DWORD Flags,\r
65                                           ND_MW_DESCRIPTOR* pMwDescriptor);\r
66         STDMETHODIMP Invalidate(ND_RESULT* pResult, INDMemoryWindow* pMw, DWORD Flags);\r
67         STDMETHODIMP Read(ND_RESULT* pResult, const ND_SGE* pSgl, SIZE_T nSge,\r
68                                           const ND_MW_DESCRIPTOR* pRemoteMwDescriptor,\r
69                                           ULONGLONG Offset, DWORD Flags);\r
70         STDMETHODIMP Write(ND_RESULT* pResult, const ND_SGE* pSgl, SIZE_T nSge,\r
71                                            const ND_MW_DESCRIPTOR* pRemoteMwDescriptor,\r
72                                            ULONGLONG Offset, DWORD Flags);\r
73         \r
74         CNDEndpoint(CNDConnector *pConnector);\r
75         ~CNDEndpoint();\r
76         void Delete() {delete this;}\r
77         static STDMETHODIMP\r
78         CreateInstance(CNDConnector *pConnector,\r
79                                    CNDCompletionQueue* pInboundCq, CNDCompletionQueue* pOutboundCq,\r
80                                    SIZE_T nInboundEntries, SIZE_T nOutboundEntries,\r
81                                    SIZE_T nInboundSge, SIZE_T nOutboundSge,\r
82                                    SIZE_T InboundReadLimit, SIZE_T OutboundReadLimit,\r
83                                    SIZE_T* pMaxInlineData, INDEndpoint** ppEndpoint)\r
84         {\r
85                 HRESULT hr;\r
86                 CNDEndpoint *ep;\r
87 \r
88                 ep = new CNDEndpoint(pConnector);\r
89                 if (ep == NULL) {\r
90                         hr = ND_NO_MEMORY;\r
91                         goto err1;\r
92                 }\r
93 \r
94                 hr = ep->Init(pInboundCq, pOutboundCq, nInboundEntries, nOutboundEntries,\r
95                                           nInboundSge, nOutboundSge, InboundReadLimit, OutboundReadLimit,\r
96                                           pMaxInlineData);\r
97                 if (FAILED(hr)) {\r
98                         goto err2;\r
99                 }\r
100 \r
101                 *ppEndpoint = ep;\r
102                 return ND_SUCCESS;\r
103 \r
104         err2:\r
105                 ep->Release();\r
106         err1:\r
107                 *ppEndpoint = NULL;\r
108                 return hr;\r
109         }\r
110 \r
111         IWVConnectQueuePair     *m_pWvQp;\r
112         SIZE_T                          m_InitiatorDepth;\r
113         SIZE_T                          m_ResponderResources;\r
114 \r
115 protected:\r
116         CNDConnector            *m_pConnector;\r
117         CNDCompletionQueue      *m_pInboundCq;\r
118         CNDCompletionQueue      *m_pOutboundCq;\r
119 \r
120         STDMETHODIMP Init(CNDCompletionQueue* pInboundCq, CNDCompletionQueue* pOutboundCq,\r
121                                           SIZE_T nInboundEntries, SIZE_T nOutboundEntries,\r
122                                           SIZE_T nInboundSge, SIZE_T nOutboundSge,\r
123                                           SIZE_T InboundReadLimit, SIZE_T OutboundReadLimit,\r
124                                           SIZE_T* pMaxInlineData);\r
125         STDMETHODIMP_(void)     ConvertSgl(const ND_SGE* pSgl, SIZE_T nSge, WV_SGE *pWvSgl);\r
126         STDMETHODIMP_(DWORD) ConvertSendFlags(DWORD Flags);\r
127         STDMETHODIMP_(DWORD) ConvertAccessFlags(DWORD Flags);\r
128 };\r
129 \r
130 #endif // _ND_ENDPOINT_H_\r