]> Pileus Git - ~andy/linux/blob - drivers/staging/hv/include/nvspprotocol.h
e1dd4676d978acad6ee635bee23364929defabd0
[~andy/linux] / drivers / staging / hv / include / nvspprotocol.h
1 /*
2  *
3  * Copyright (c) 2009, Microsoft Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms and conditions of the GNU General Public License,
7  * version 2, as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16  * Place - Suite 330, Boston, MA 02111-1307 USA.
17  *
18  * Authors:
19  *   Haiyang Zhang <haiyangz@microsoft.com>
20  *   Hank Janssen  <hjanssen@microsoft.com>
21  *
22  */
23
24
25 #pragma once
26
27 #include "VmbusChannelInterface.h"
28
29 #define NVSP_INVALID_PROTOCOL_VERSION           ((UINT32)0xFFFFFFFF)
30
31 #define NVSP_PROTOCOL_VERSION_1                 2
32 #define NVSP_MIN_PROTOCOL_VERSION               NVSP_PROTOCOL_VERSION_1
33 #define NVSP_MAX_PROTOCOL_VERSION               NVSP_PROTOCOL_VERSION_1
34
35 typedef enum _NVSP_MESSAGE_TYPE
36 {
37     NvspMessageTypeNone = 0,
38
39     //
40     // Init Messages
41     //
42     NvspMessageTypeInit                         = 1,
43     NvspMessageTypeInitComplete                 = 2,
44
45     NvspVersionMessageStart                     = 100,
46
47     //
48     // Version 1 Messages
49     //
50     NvspMessage1TypeSendNdisVersion             = NvspVersionMessageStart,
51
52     NvspMessage1TypeSendReceiveBuffer,
53     NvspMessage1TypeSendReceiveBufferComplete,
54     NvspMessage1TypeRevokeReceiveBuffer,
55
56     NvspMessage1TypeSendSendBuffer,
57     NvspMessage1TypeSendSendBufferComplete,
58     NvspMessage1TypeRevokeSendBuffer,
59
60     NvspMessage1TypeSendRNDISPacket,
61     NvspMessage1TypeSendRNDISPacketComplete,
62
63     //
64     // This should be set to the number of messages for the version
65     // with the maximum number of messages.
66     //
67     NvspNumMessagePerVersion                    = 9,
68
69 } NVSP_MESSAGE_TYPE, *PNVSP_MESSAGE_TYPE;
70
71 typedef enum _NVSP_STATUS
72 {
73     NvspStatusNone = 0,
74     NvspStatusSuccess,
75     NvspStatusFailure,
76     NvspStatusProtocolVersionRangeTooNew,
77     NvspStatusProtocolVersionRangeTooOld,
78     NvspStatusInvalidRndisPacket,
79     NvspStatusBusy,
80     NvspStatusMax,
81 } NVSP_STATUS, *PNVSP_STATUS;
82
83 #pragma pack(push, 1)
84
85 typedef struct _NVSP_MESSAGE_HEADER
86 {
87     UINT32                                  MessageType;
88 } NVSP_MESSAGE_HEADER, *PNVSP_MESSAGE_HEADER;
89
90 //
91 // Init Messages
92 //
93
94 //
95 // This message is used by the VSC to initialize the channel
96 // after the channels has been opened. This message should
97 // never include anything other then versioning (i.e. this
98 // message will be the same for ever).
99 //
100 typedef struct _NVSP_MESSAGE_INIT
101 {
102     UINT32                                  MinProtocolVersion;
103     UINT32                                  MaxProtocolVersion;
104 } NVSP_MESSAGE_INIT, *PNVSP_MESSAGE_INIT;
105
106 //
107 // This message is used by the VSP to complete the initialization
108 // of the channel. This message should never include anything other
109 // then versioning (i.e. this message will be the same for ever).
110 //
111 typedef struct _NVSP_MESSAGE_INIT_COMPLETE
112 {
113     UINT32                                  NegotiatedProtocolVersion;
114     UINT32                                  MaximumMdlChainLength;
115     UINT32                                  Status;
116 } NVSP_MESSAGE_INIT_COMPLETE, *PNVSP_MESSAGE_INIT_COMPLETE;
117
118 typedef union _NVSP_MESSAGE_INIT_UBER
119 {
120     NVSP_MESSAGE_INIT                       Init;
121     NVSP_MESSAGE_INIT_COMPLETE              InitComplete;
122 } NVSP_MESSAGE_INIT_UBER;
123
124 //
125 // Version 1 Messages
126 //
127
128 //
129 // This message is used by the VSC to send the NDIS version
130 // to the VSP. The VSP can use this information when handling
131 // OIDs sent by the VSC.
132 //
133 typedef struct _NVSP_1_MESSAGE_SEND_NDIS_VERSION
134 {
135     UINT32                                  NdisMajorVersion;
136     UINT32                                  NdisMinorVersion;
137 } NVSP_1_MESSAGE_SEND_NDIS_VERSION, *PNVSP_1_MESSAGE_SEND_NDIS_VERSION;
138
139 //
140 // This message is used by the VSC to send a receive buffer
141 // to the VSP. The VSP can then use the receive buffer to
142 // send data to the VSC.
143 //
144 typedef struct _NVSP_1_MESSAGE_SEND_RECEIVE_BUFFER
145 {
146     GPADL_HANDLE                            GpadlHandle;
147     u16                                  Id;
148 } NVSP_1_MESSAGE_SEND_RECEIVE_BUFFER, *PNVSP_1_MESSAGE_SEND_RECEIVE_BUFFER;
149
150 typedef struct _NVSP_1_RECEIVE_BUFFER_SECTION
151 {
152     UINT32                                  Offset;
153     UINT32                                  SubAllocationSize;
154     UINT32                                  NumSubAllocations;
155     UINT32                                  EndOffset;
156 } NVSP_1_RECEIVE_BUFFER_SECTION, *PNVSP_1_RECEIVE_BUFFER_SECTION;
157
158 //
159 // This message is used by the VSP to acknowledge a receive
160 // buffer send by the VSC. This message must be sent by the
161 // VSP before the VSP uses the receive buffer.
162 //
163 typedef struct _NVSP_1_MESSAGE_SEND_RECEIVE_BUFFER_COMPLETE
164 {
165     UINT32                                  Status;
166     UINT32                                  NumSections;
167
168     //
169     // The receive buffer is split into two parts, a large
170     // suballocation section and a small suballocation
171     // section. These sections are then suballocated by a
172     // certain size.
173     //
174     // For example, the following break up of the receive
175     // buffer has 6 large suballocations and 10 small
176     // suballocations.
177     //
178     // |            Large Section          |  |   Small Section   |
179     // ------------------------------------------------------------
180     // |     |     |     |     |     |     |  | | | | | | | | | | |
181     // |                                      |
182     // LargeOffset                            SmallOffset
183     //
184     NVSP_1_RECEIVE_BUFFER_SECTION           Sections[1];
185
186 } NVSP_1_MESSAGE_SEND_RECEIVE_BUFFER_COMPLETE, *PNVSP_1_MESSAGE_SEND_RECEIVE_BUFFER_COMPLETE;
187
188 //
189 // This message is sent by the VSC to revoke the receive buffer.
190 // After the VSP completes this transaction, the vsp should never
191 // use the receive buffer again.
192 //
193 typedef struct _NVSP_1_MESSAGE_REVOKE_RECEIVE_BUFFER
194 {
195     u16                                  Id;
196 } NVSP_1_MESSAGE_REVOKE_RECEIVE_BUFFER, *PNVSP_1_MESSAGE_REVOKE_RECEIVE_BUFFER;
197
198 //
199 // This message is used by the VSC to send a send buffer
200 // to the VSP. The VSC can then use the send buffer to
201 // send data to the VSP.
202 //
203 typedef struct _NVSP_1_MESSAGE_SEND_SEND_BUFFER
204 {
205     GPADL_HANDLE                            GpadlHandle;
206     u16                                  Id;
207 } NVSP_1_MESSAGE_SEND_SEND_BUFFER, *PNVSP_1_MESSAGE_SEND_SEND_BUFFER;
208
209 //
210 // This message is used by the VSP to acknowledge a send
211 // buffer sent by the VSC. This message must be sent by the
212 // VSP before the VSP uses the sent buffer.
213 //
214 typedef struct _NVSP_1_MESSAGE_SEND_SEND_BUFFER_COMPLETE
215 {
216     UINT32                                  Status;
217
218     //
219     // The VSC gets to choose the size of the send buffer and
220     // the VSP gets to choose the sections size of the buffer.
221     // This was done to enable dynamic reconfigurations when
222     // the cost of GPA-direct buffers decreases.
223     //
224     UINT32                                  SectionSize;
225 } NVSP_1_MESSAGE_SEND_SEND_BUFFER_COMPLETE, *PNVSP_1_MESSAGE_SEND_SEND_BUFFER_COMPLETE;
226
227 //
228 // This message is sent by the VSC to revoke the send buffer.
229 // After the VSP completes this transaction, the vsp should never
230 // use the send buffer again.
231 //
232 typedef struct _NVSP_1_MESSAGE_REVOKE_SEND_BUFFER
233 {
234     u16                                  Id;
235 } NVSP_1_MESSAGE_REVOKE_SEND_BUFFER, *PNVSP_1_MESSAGE_REVOKE_SEND_BUFFER;
236
237 //
238 // This message is used by both the VSP and the VSC to send
239 // a RNDIS message to the opposite channel endpoint.
240 //
241 typedef struct _NVSP_1_MESSAGE_SEND_RNDIS_PACKET
242 {
243     //
244     // This field is specified by RNIDS. They assume there's
245     // two different channels of communication. However,
246     // the Network VSP only has one. Therefore, the channel
247     // travels with the RNDIS packet.
248     //
249     UINT32                                  ChannelType;
250
251     //
252     // This field is used to send part or all of the data
253     // through a send buffer. This values specifies an
254     // index into the send buffer. If the index is
255     // 0xFFFFFFFF, then the send buffer is not being used
256     // and all of the data was sent through other VMBus
257     // mechanisms.
258     //
259     UINT32                                  SendBufferSectionIndex;
260     UINT32                                  SendBufferSectionSize;
261 } NVSP_1_MESSAGE_SEND_RNDIS_PACKET, *PNVSP_1_MESSAGE_SEND_RNDIS_PACKET;
262
263 //
264 // This message is used by both the VSP and the VSC to complete
265 // a RNDIS message to the opposite channel endpoint. At this
266 // point, the initiator of this message cannot use any resources
267 // associated with the original RNDIS packet.
268 //
269 typedef struct _NVSP_1_MESSAGE_SEND_RNDIS_PACKET_COMPLETE
270 {
271     UINT32                                  Status;
272 } NVSP_1_MESSAGE_SEND_RNDIS_PACKET_COMPLETE, *PNVSP_1_MESSAGE_SEND_RNDIS_PACKET_COMPLETE;
273
274 typedef union _NVSP_MESSAGE_1_UBER
275 {
276     NVSP_1_MESSAGE_SEND_NDIS_VERSION            SendNdisVersion;
277
278     NVSP_1_MESSAGE_SEND_RECEIVE_BUFFER          SendReceiveBuffer;
279     NVSP_1_MESSAGE_SEND_RECEIVE_BUFFER_COMPLETE SendReceiveBufferComplete;
280     NVSP_1_MESSAGE_REVOKE_RECEIVE_BUFFER        RevokeReceiveBuffer;
281
282     NVSP_1_MESSAGE_SEND_SEND_BUFFER             SendSendBuffer;
283     NVSP_1_MESSAGE_SEND_SEND_BUFFER_COMPLETE    SendSendBufferComplete;
284     NVSP_1_MESSAGE_REVOKE_SEND_BUFFER           RevokeSendBuffer;
285
286     NVSP_1_MESSAGE_SEND_RNDIS_PACKET            SendRNDISPacket;
287     NVSP_1_MESSAGE_SEND_RNDIS_PACKET_COMPLETE   SendRNDISPacketComplete;
288 } NVSP_1_MESSAGE_UBER;
289
290 typedef union _NVSP_ALL_MESSAGES
291 {
292     NVSP_MESSAGE_INIT_UBER                  InitMessages;
293     NVSP_1_MESSAGE_UBER                     Version1Messages;
294
295 } NVSP_ALL_MESSAGES;
296
297 //
298 // ALL Messages
299 //
300 typedef struct _NVSP_MESSAGE
301 {
302     NVSP_MESSAGE_HEADER                     Header;
303     NVSP_ALL_MESSAGES                       Messages;
304 } NVSP_MESSAGE, *PNVSP_MESSAGE;
305
306 #pragma pack(pop)