3 * Copyright (c) 2009, Microsoft Corporation.
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.
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
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.
19 * Haiyang Zhang <haiyangz@microsoft.com>
20 * Hank Janssen <hjanssen@microsoft.com>
27 #include "VmbusChannelInterface.h"
29 #define NVSP_INVALID_PROTOCOL_VERSION ((u32)0xFFFFFFFF)
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
35 typedef enum _NVSP_MESSAGE_TYPE
37 NvspMessageTypeNone = 0,
42 NvspMessageTypeInit = 1,
43 NvspMessageTypeInitComplete = 2,
45 NvspVersionMessageStart = 100,
50 NvspMessage1TypeSendNdisVersion = NvspVersionMessageStart,
52 NvspMessage1TypeSendReceiveBuffer,
53 NvspMessage1TypeSendReceiveBufferComplete,
54 NvspMessage1TypeRevokeReceiveBuffer,
56 NvspMessage1TypeSendSendBuffer,
57 NvspMessage1TypeSendSendBufferComplete,
58 NvspMessage1TypeRevokeSendBuffer,
60 NvspMessage1TypeSendRNDISPacket,
61 NvspMessage1TypeSendRNDISPacketComplete,
64 // This should be set to the number of messages for the version
65 // with the maximum number of messages.
67 NvspNumMessagePerVersion = 9,
69 } NVSP_MESSAGE_TYPE, *PNVSP_MESSAGE_TYPE;
71 typedef enum _NVSP_STATUS
76 NvspStatusProtocolVersionRangeTooNew,
77 NvspStatusProtocolVersionRangeTooOld,
78 NvspStatusInvalidRndisPacket,
81 } NVSP_STATUS, *PNVSP_STATUS;
85 typedef struct _NVSP_MESSAGE_HEADER
88 } NVSP_MESSAGE_HEADER, *PNVSP_MESSAGE_HEADER;
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).
100 typedef struct _NVSP_MESSAGE_INIT
102 u32 MinProtocolVersion;
103 u32 MaxProtocolVersion;
104 } NVSP_MESSAGE_INIT, *PNVSP_MESSAGE_INIT;
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).
111 typedef struct _NVSP_MESSAGE_INIT_COMPLETE
113 u32 NegotiatedProtocolVersion;
114 u32 MaximumMdlChainLength;
116 } NVSP_MESSAGE_INIT_COMPLETE, *PNVSP_MESSAGE_INIT_COMPLETE;
118 typedef union _NVSP_MESSAGE_INIT_UBER
120 NVSP_MESSAGE_INIT Init;
121 NVSP_MESSAGE_INIT_COMPLETE InitComplete;
122 } NVSP_MESSAGE_INIT_UBER;
125 // Version 1 Messages
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.
133 typedef struct _NVSP_1_MESSAGE_SEND_NDIS_VERSION
135 u32 NdisMajorVersion;
136 u32 NdisMinorVersion;
137 } NVSP_1_MESSAGE_SEND_NDIS_VERSION, *PNVSP_1_MESSAGE_SEND_NDIS_VERSION;
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.
144 typedef struct _NVSP_1_MESSAGE_SEND_RECEIVE_BUFFER
146 GPADL_HANDLE GpadlHandle;
148 } NVSP_1_MESSAGE_SEND_RECEIVE_BUFFER, *PNVSP_1_MESSAGE_SEND_RECEIVE_BUFFER;
150 typedef struct _NVSP_1_RECEIVE_BUFFER_SECTION
153 u32 SubAllocationSize;
154 u32 NumSubAllocations;
156 } NVSP_1_RECEIVE_BUFFER_SECTION, *PNVSP_1_RECEIVE_BUFFER_SECTION;
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.
163 typedef struct _NVSP_1_MESSAGE_SEND_RECEIVE_BUFFER_COMPLETE
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
174 // For example, the following break up of the receive
175 // buffer has 6 large suballocations and 10 small
178 // | Large Section | | Small Section |
179 // ------------------------------------------------------------
180 // | | | | | | | | | | | | | | | | | |
182 // LargeOffset SmallOffset
184 NVSP_1_RECEIVE_BUFFER_SECTION Sections[1];
186 } NVSP_1_MESSAGE_SEND_RECEIVE_BUFFER_COMPLETE, *PNVSP_1_MESSAGE_SEND_RECEIVE_BUFFER_COMPLETE;
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.
193 typedef struct _NVSP_1_MESSAGE_REVOKE_RECEIVE_BUFFER
196 } NVSP_1_MESSAGE_REVOKE_RECEIVE_BUFFER, *PNVSP_1_MESSAGE_REVOKE_RECEIVE_BUFFER;
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.
203 typedef struct _NVSP_1_MESSAGE_SEND_SEND_BUFFER
205 GPADL_HANDLE GpadlHandle;
207 } NVSP_1_MESSAGE_SEND_SEND_BUFFER, *PNVSP_1_MESSAGE_SEND_SEND_BUFFER;
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.
214 typedef struct _NVSP_1_MESSAGE_SEND_SEND_BUFFER_COMPLETE
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.
225 } NVSP_1_MESSAGE_SEND_SEND_BUFFER_COMPLETE, *PNVSP_1_MESSAGE_SEND_SEND_BUFFER_COMPLETE;
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.
232 typedef struct _NVSP_1_MESSAGE_REVOKE_SEND_BUFFER
235 } NVSP_1_MESSAGE_REVOKE_SEND_BUFFER, *PNVSP_1_MESSAGE_REVOKE_SEND_BUFFER;
238 // This message is used by both the VSP and the VSC to send
239 // a RNDIS message to the opposite channel endpoint.
241 typedef struct _NVSP_1_MESSAGE_SEND_RNDIS_PACKET
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.
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
259 u32 SendBufferSectionIndex;
260 u32 SendBufferSectionSize;
261 } NVSP_1_MESSAGE_SEND_RNDIS_PACKET, *PNVSP_1_MESSAGE_SEND_RNDIS_PACKET;
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.
269 typedef struct _NVSP_1_MESSAGE_SEND_RNDIS_PACKET_COMPLETE
272 } NVSP_1_MESSAGE_SEND_RNDIS_PACKET_COMPLETE, *PNVSP_1_MESSAGE_SEND_RNDIS_PACKET_COMPLETE;
274 typedef union _NVSP_MESSAGE_1_UBER
276 NVSP_1_MESSAGE_SEND_NDIS_VERSION SendNdisVersion;
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;
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;
286 NVSP_1_MESSAGE_SEND_RNDIS_PACKET SendRNDISPacket;
287 NVSP_1_MESSAGE_SEND_RNDIS_PACKET_COMPLETE SendRNDISPacketComplete;
288 } NVSP_1_MESSAGE_UBER;
290 typedef union _NVSP_ALL_MESSAGES
292 NVSP_MESSAGE_INIT_UBER InitMessages;
293 NVSP_1_MESSAGE_UBER Version1Messages;
300 typedef struct _NVSP_MESSAGE
302 NVSP_MESSAGE_HEADER Header;
303 NVSP_ALL_MESSAGES Messages;
304 } NVSP_MESSAGE, *PNVSP_MESSAGE;