aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging
diff options
context:
space:
mode:
authorHaiyang Zhang <haiyangz@microsoft.com>2010-12-10 15:03:56 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2010-12-13 13:31:51 -0500
commitc2a4efddc73bfd44479fc8d84dadbb352c4efb07 (patch)
tree2c7bbcb36cf6b47eb682e035878406eb19b2c860 /drivers/staging
parent5a71ae303c0f82968d93d86724c1d94d753b34d7 (diff)
staging: hv: Convert camel cased variables in rndis_filter.c to lower cases
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com> Signed-off-by: Hank Janssen <hjanssen@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/hv/rndis_filter.c582
1 files changed, 296 insertions, 286 deletions
diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index b85c82542421..28b7e7e59f0a 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -32,7 +32,7 @@
32/* Data types */ 32/* Data types */
33struct rndis_filter_driver_object { 33struct rndis_filter_driver_object {
34 /* The original driver */ 34 /* The original driver */
35 struct netvsc_driver InnerDriver; 35 struct netvsc_driver inner_drv;
36}; 36};
37 37
38enum rndis_device_state { 38enum rndis_device_state {
@@ -43,61 +43,61 @@ enum rndis_device_state {
43}; 43};
44 44
45struct rndis_device { 45struct rndis_device {
46 struct netvsc_device *NetDevice; 46 struct netvsc_device *net_dev;
47 47
48 enum rndis_device_state State; 48 enum rndis_device_state state;
49 u32 LinkStatus; 49 u32 link_stat;
50 atomic_t NewRequestId; 50 atomic_t new_req_id;
51 51
52 spinlock_t request_lock; 52 spinlock_t request_lock;
53 struct list_head RequestList; 53 struct list_head req_list;
54 54
55 unsigned char HwMacAddr[ETH_ALEN]; 55 unsigned char hw_mac_adr[ETH_ALEN];
56}; 56};
57 57
58struct rndis_request { 58struct rndis_request {
59 struct list_head ListEntry; 59 struct list_head list_ent;
60 struct osd_waitevent *WaitEvent; 60 struct osd_waitevent *waitevent;
61 61
62 /* 62 /*
63 * FIXME: We assumed a fixed size response here. If we do ever need to 63 * FIXME: We assumed a fixed size response here. If we do ever need to
64 * handle a bigger response, we can either define a max response 64 * handle a bigger response, we can either define a max response
65 * message or add a response buffer variable above this field 65 * message or add a response buffer variable above this field
66 */ 66 */
67 struct rndis_message ResponseMessage; 67 struct rndis_message response_msg;
68 68
69 /* Simplify allocation by having a netvsc packet inline */ 69 /* Simplify allocation by having a netvsc packet inline */
70 struct hv_netvsc_packet Packet; 70 struct hv_netvsc_packet pkt;
71 struct hv_page_buffer Buffer; 71 struct hv_page_buffer buf;
72 /* FIXME: We assumed a fixed size request here. */ 72 /* FIXME: We assumed a fixed size request here. */
73 struct rndis_message RequestMessage; 73 struct rndis_message request_msg;
74}; 74};
75 75
76 76
77struct rndis_filter_packet { 77struct rndis_filter_packet {
78 void *CompletionContext; 78 void *completion_ctx;
79 void (*OnCompletion)(void *context); 79 void (*completion)(void *context);
80 struct rndis_message Message; 80 struct rndis_message msg;
81}; 81};
82 82
83 83
84static int RndisFilterOnDeviceAdd(struct hv_device *Device, 84static int RndisFilterOnDeviceAdd(struct hv_device *dev,
85 void *AdditionalInfo); 85 void *additional_info);
86 86
87static int RndisFilterOnDeviceRemove(struct hv_device *Device); 87static int RndisFilterOnDeviceRemove(struct hv_device *dev);
88 88
89static void RndisFilterOnCleanup(struct hv_driver *Driver); 89static void RndisFilterOnCleanup(struct hv_driver *drv);
90 90
91static int RndisFilterOnSend(struct hv_device *Device, 91static int RndisFilterOnSend(struct hv_device *dev,
92 struct hv_netvsc_packet *Packet); 92 struct hv_netvsc_packet *pkt);
93 93
94static void RndisFilterOnSendCompletion(void *Context); 94static void RndisFilterOnSendCompletion(void *ctx);
95 95
96static void RndisFilterOnSendRequestCompletion(void *Context); 96static void RndisFilterOnSendRequestCompletion(void *ctx);
97 97
98 98
99/* The one and only */ 99/* The one and only */
100static struct rndis_filter_driver_object gRndisFilter; 100static struct rndis_filter_driver_object rndis_filter;
101 101
102static struct rndis_device *GetRndisDevice(void) 102static struct rndis_device *GetRndisDevice(void)
103{ 103{
@@ -109,19 +109,19 @@ static struct rndis_device *GetRndisDevice(void)
109 109
110 spin_lock_init(&device->request_lock); 110 spin_lock_init(&device->request_lock);
111 111
112 INIT_LIST_HEAD(&device->RequestList); 112 INIT_LIST_HEAD(&device->req_list);
113 113
114 device->State = RNDIS_DEV_UNINITIALIZED; 114 device->state = RNDIS_DEV_UNINITIALIZED;
115 115
116 return device; 116 return device;
117} 117}
118 118
119static struct rndis_request *GetRndisRequest(struct rndis_device *Device, 119static struct rndis_request *GetRndisRequest(struct rndis_device *dev,
120 u32 MessageType, 120 u32 msg_type,
121 u32 MessageLength) 121 u32 msg_len)
122{ 122{
123 struct rndis_request *request; 123 struct rndis_request *request;
124 struct rndis_message *rndisMessage; 124 struct rndis_message *rndis_msg;
125 struct rndis_set_request *set; 125 struct rndis_set_request *set;
126 unsigned long flags; 126 unsigned long flags;
127 127
@@ -129,61 +129,61 @@ static struct rndis_request *GetRndisRequest(struct rndis_device *Device,
129 if (!request) 129 if (!request)
130 return NULL; 130 return NULL;
131 131
132 request->WaitEvent = osd_waitevent_create(); 132 request->waitevent = osd_waitevent_create();
133 if (!request->WaitEvent) { 133 if (!request->waitevent) {
134 kfree(request); 134 kfree(request);
135 return NULL; 135 return NULL;
136 } 136 }
137 137
138 rndisMessage = &request->RequestMessage; 138 rndis_msg = &request->request_msg;
139 rndisMessage->NdisMessageType = MessageType; 139 rndis_msg->NdisMessageType = msg_type;
140 rndisMessage->MessageLength = MessageLength; 140 rndis_msg->MessageLength = msg_len;
141 141
142 /* 142 /*
143 * Set the request id. This field is always after the rndis header for 143 * Set the request id. This field is always after the rndis header for
144 * request/response packet types so we just used the SetRequest as a 144 * request/response packet types so we just used the SetRequest as a
145 * template 145 * template
146 */ 146 */
147 set = &rndisMessage->Message.SetRequest; 147 set = &rndis_msg->Message.SetRequest;
148 set->RequestId = atomic_inc_return(&Device->NewRequestId); 148 set->RequestId = atomic_inc_return(&dev->new_req_id);
149 149
150 /* Add to the request list */ 150 /* Add to the request list */
151 spin_lock_irqsave(&Device->request_lock, flags); 151 spin_lock_irqsave(&dev->request_lock, flags);
152 list_add_tail(&request->ListEntry, &Device->RequestList); 152 list_add_tail(&request->list_ent, &dev->req_list);
153 spin_unlock_irqrestore(&Device->request_lock, flags); 153 spin_unlock_irqrestore(&dev->request_lock, flags);
154 154
155 return request; 155 return request;
156} 156}
157 157
158static void PutRndisRequest(struct rndis_device *Device, 158static void PutRndisRequest(struct rndis_device *dev,
159 struct rndis_request *Request) 159 struct rndis_request *req)
160{ 160{
161 unsigned long flags; 161 unsigned long flags;
162 162
163 spin_lock_irqsave(&Device->request_lock, flags); 163 spin_lock_irqsave(&dev->request_lock, flags);
164 list_del(&Request->ListEntry); 164 list_del(&req->list_ent);
165 spin_unlock_irqrestore(&Device->request_lock, flags); 165 spin_unlock_irqrestore(&dev->request_lock, flags);
166 166
167 kfree(Request->WaitEvent); 167 kfree(req->waitevent);
168 kfree(Request); 168 kfree(req);
169} 169}
170 170
171static void DumpRndisMessage(struct rndis_message *RndisMessage) 171static void DumpRndisMessage(struct rndis_message *rndis_msg)
172{ 172{
173 switch (RndisMessage->NdisMessageType) { 173 switch (rndis_msg->NdisMessageType) {
174 case REMOTE_NDIS_PACKET_MSG: 174 case REMOTE_NDIS_PACKET_MSG:
175 DPRINT_DBG(NETVSC, "REMOTE_NDIS_PACKET_MSG (len %u, " 175 DPRINT_DBG(NETVSC, "REMOTE_NDIS_PACKET_MSG (len %u, "
176 "data offset %u data len %u, # oob %u, " 176 "data offset %u data len %u, # oob %u, "
177 "oob offset %u, oob len %u, pkt offset %u, " 177 "oob offset %u, oob len %u, pkt offset %u, "
178 "pkt len %u", 178 "pkt len %u",
179 RndisMessage->MessageLength, 179 rndis_msg->MessageLength,
180 RndisMessage->Message.Packet.DataOffset, 180 rndis_msg->Message.Packet.DataOffset,
181 RndisMessage->Message.Packet.DataLength, 181 rndis_msg->Message.Packet.DataLength,
182 RndisMessage->Message.Packet.NumOOBDataElements, 182 rndis_msg->Message.Packet.NumOOBDataElements,
183 RndisMessage->Message.Packet.OOBDataOffset, 183 rndis_msg->Message.Packet.OOBDataOffset,
184 RndisMessage->Message.Packet.OOBDataLength, 184 rndis_msg->Message.Packet.OOBDataLength,
185 RndisMessage->Message.Packet.PerPacketInfoOffset, 185 rndis_msg->Message.Packet.PerPacketInfoOffset,
186 RndisMessage->Message.Packet.PerPacketInfoLength); 186 rndis_msg->Message.Packet.PerPacketInfoLength);
187 break; 187 break;
188 188
189 case REMOTE_NDIS_INITIALIZE_CMPLT: 189 case REMOTE_NDIS_INITIALIZE_CMPLT:
@@ -191,147 +191,157 @@ static void DumpRndisMessage(struct rndis_message *RndisMessage)
191 "(len %u, id 0x%x, status 0x%x, major %d, minor %d, " 191 "(len %u, id 0x%x, status 0x%x, major %d, minor %d, "
192 "device flags %d, max xfer size 0x%x, max pkts %u, " 192 "device flags %d, max xfer size 0x%x, max pkts %u, "
193 "pkt aligned %u)", 193 "pkt aligned %u)",
194 RndisMessage->MessageLength, 194 rndis_msg->MessageLength,
195 RndisMessage->Message.InitializeComplete.RequestId, 195 rndis_msg->Message.InitializeComplete.RequestId,
196 RndisMessage->Message.InitializeComplete.Status, 196 rndis_msg->Message.InitializeComplete.Status,
197 RndisMessage->Message.InitializeComplete.MajorVersion, 197 rndis_msg->Message.InitializeComplete.MajorVersion,
198 RndisMessage->Message.InitializeComplete.MinorVersion, 198 rndis_msg->Message.InitializeComplete.MinorVersion,
199 RndisMessage->Message.InitializeComplete.DeviceFlags, 199 rndis_msg->Message.InitializeComplete.DeviceFlags,
200 RndisMessage->Message.InitializeComplete.MaxTransferSize, 200 rndis_msg->Message.InitializeComplete.MaxTransferSize,
201 RndisMessage->Message.InitializeComplete.MaxPacketsPerMessage, 201 rndis_msg->Message.InitializeComplete.
202 RndisMessage->Message.InitializeComplete.PacketAlignmentFactor); 202 MaxPacketsPerMessage,
203 rndis_msg->Message.InitializeComplete.
204 PacketAlignmentFactor);
203 break; 205 break;
204 206
205 case REMOTE_NDIS_QUERY_CMPLT: 207 case REMOTE_NDIS_QUERY_CMPLT:
206 DPRINT_DBG(NETVSC, "REMOTE_NDIS_QUERY_CMPLT " 208 DPRINT_DBG(NETVSC, "REMOTE_NDIS_QUERY_CMPLT "
207 "(len %u, id 0x%x, status 0x%x, buf len %u, " 209 "(len %u, id 0x%x, status 0x%x, buf len %u, "
208 "buf offset %u)", 210 "buf offset %u)",
209 RndisMessage->MessageLength, 211 rndis_msg->MessageLength,
210 RndisMessage->Message.QueryComplete.RequestId, 212 rndis_msg->Message.QueryComplete.RequestId,
211 RndisMessage->Message.QueryComplete.Status, 213 rndis_msg->Message.QueryComplete.Status,
212 RndisMessage->Message.QueryComplete.InformationBufferLength, 214 rndis_msg->Message.QueryComplete.
213 RndisMessage->Message.QueryComplete.InformationBufferOffset); 215 InformationBufferLength,
216 rndis_msg->Message.QueryComplete.
217 InformationBufferOffset);
214 break; 218 break;
215 219
216 case REMOTE_NDIS_SET_CMPLT: 220 case REMOTE_NDIS_SET_CMPLT:
217 DPRINT_DBG(NETVSC, 221 DPRINT_DBG(NETVSC,
218 "REMOTE_NDIS_SET_CMPLT (len %u, id 0x%x, status 0x%x)", 222 "REMOTE_NDIS_SET_CMPLT (len %u, id 0x%x, status 0x%x)",
219 RndisMessage->MessageLength, 223 rndis_msg->MessageLength,
220 RndisMessage->Message.SetComplete.RequestId, 224 rndis_msg->Message.SetComplete.RequestId,
221 RndisMessage->Message.SetComplete.Status); 225 rndis_msg->Message.SetComplete.Status);
222 break; 226 break;
223 227
224 case REMOTE_NDIS_INDICATE_STATUS_MSG: 228 case REMOTE_NDIS_INDICATE_STATUS_MSG:
225 DPRINT_DBG(NETVSC, "REMOTE_NDIS_INDICATE_STATUS_MSG " 229 DPRINT_DBG(NETVSC, "REMOTE_NDIS_INDICATE_STATUS_MSG "
226 "(len %u, status 0x%x, buf len %u, buf offset %u)", 230 "(len %u, status 0x%x, buf len %u, buf offset %u)",
227 RndisMessage->MessageLength, 231 rndis_msg->MessageLength,
228 RndisMessage->Message.IndicateStatus.Status, 232 rndis_msg->Message.IndicateStatus.Status,
229 RndisMessage->Message.IndicateStatus.StatusBufferLength, 233 rndis_msg->Message.IndicateStatus.StatusBufferLength,
230 RndisMessage->Message.IndicateStatus.StatusBufferOffset); 234 rndis_msg->Message.IndicateStatus.StatusBufferOffset);
231 break; 235 break;
232 236
233 default: 237 default:
234 DPRINT_DBG(NETVSC, "0x%x (len %u)", 238 DPRINT_DBG(NETVSC, "0x%x (len %u)",
235 RndisMessage->NdisMessageType, 239 rndis_msg->NdisMessageType,
236 RndisMessage->MessageLength); 240 rndis_msg->MessageLength);
237 break; 241 break;
238 } 242 }
239} 243}
240 244
241static int RndisFilterSendRequest(struct rndis_device *Device, 245static int RndisFilterSendRequest(struct rndis_device *dev,
242 struct rndis_request *Request) 246 struct rndis_request *req)
243{ 247{
244 int ret; 248 int ret;
245 struct hv_netvsc_packet *packet; 249 struct hv_netvsc_packet *packet;
246 250
247 /* Setup the packet to send it */ 251 /* Setup the packet to send it */
248 packet = &Request->Packet; 252 packet = &req->pkt;
249 253
250 packet->IsDataPacket = false; 254 packet->IsDataPacket = false;
251 packet->TotalDataBufferLength = Request->RequestMessage.MessageLength; 255 packet->TotalDataBufferLength = req->request_msg.MessageLength;
252 packet->PageBufferCount = 1; 256 packet->PageBufferCount = 1;
253 257
254 packet->PageBuffers[0].Pfn = virt_to_phys(&Request->RequestMessage) >> 258 packet->PageBuffers[0].Pfn = virt_to_phys(&req->request_msg) >>
255 PAGE_SHIFT; 259 PAGE_SHIFT;
256 packet->PageBuffers[0].Length = Request->RequestMessage.MessageLength; 260 packet->PageBuffers[0].Length = req->request_msg.MessageLength;
257 packet->PageBuffers[0].Offset = 261 packet->PageBuffers[0].Offset =
258 (unsigned long)&Request->RequestMessage & (PAGE_SIZE - 1); 262 (unsigned long)&req->request_msg & (PAGE_SIZE - 1);
259 263
260 packet->Completion.Send.SendCompletionContext = Request;/* packet; */ 264 packet->Completion.Send.SendCompletionContext = req;/* packet; */
261 packet->Completion.Send.OnSendCompletion = 265 packet->Completion.Send.OnSendCompletion =
262 RndisFilterOnSendRequestCompletion; 266 RndisFilterOnSendRequestCompletion;
263 packet->Completion.Send.SendCompletionTid = (unsigned long)Device; 267 packet->Completion.Send.SendCompletionTid = (unsigned long)dev;
264 268
265 ret = gRndisFilter.InnerDriver.OnSend(Device->NetDevice->Device, packet); 269 ret = rndis_filter.inner_drv.OnSend(dev->net_dev->Device, packet);
266 return ret; 270 return ret;
267} 271}
268 272
269static void RndisFilterReceiveResponse(struct rndis_device *Device, 273static void RndisFilterReceiveResponse(struct rndis_device *dev,
270 struct rndis_message *Response) 274 struct rndis_message *resp)
271{ 275{
272 struct rndis_request *request = NULL; 276 struct rndis_request *request = NULL;
273 bool found = false; 277 bool found = false;
274 unsigned long flags; 278 unsigned long flags;
275 279
276 spin_lock_irqsave(&Device->request_lock, flags); 280 spin_lock_irqsave(&dev->request_lock, flags);
277 list_for_each_entry(request, &Device->RequestList, ListEntry) { 281 list_for_each_entry(request, &dev->req_list, list_ent) {
278 /* 282 /*
279 * All request/response message contains RequestId as the 1st 283 * All request/response message contains RequestId as the 1st
280 * field 284 * field
281 */ 285 */
282 if (request->RequestMessage.Message.InitializeRequest.RequestId 286 if (request->request_msg.Message.InitializeRequest.RequestId
283 == Response->Message.InitializeComplete.RequestId) { 287 == resp->Message.InitializeComplete.RequestId) {
284 DPRINT_DBG(NETVSC, "found rndis request for " 288 DPRINT_DBG(NETVSC, "found rndis request for "
285 "this response (id 0x%x req type 0x%x res " 289 "this response (id 0x%x req type 0x%x res "
286 "type 0x%x)", 290 "type 0x%x)",
287 request->RequestMessage.Message.InitializeRequest.RequestId, 291 request->request_msg.Message.
288 request->RequestMessage.NdisMessageType, 292 InitializeRequest.RequestId,
289 Response->NdisMessageType); 293 request->request_msg.NdisMessageType,
294 resp->NdisMessageType);
290 295
291 found = true; 296 found = true;
292 break; 297 break;
293 } 298 }
294 } 299 }
295 spin_unlock_irqrestore(&Device->request_lock, flags); 300 spin_unlock_irqrestore(&dev->request_lock, flags);
296 301
297 if (found) { 302 if (found) {
298 if (Response->MessageLength <= sizeof(struct rndis_message)) { 303 if (resp->MessageLength <= sizeof(struct rndis_message)) {
299 memcpy(&request->ResponseMessage, Response, 304 memcpy(&request->response_msg, resp,
300 Response->MessageLength); 305 resp->MessageLength);
301 } else { 306 } else {
302 DPRINT_ERR(NETVSC, "rndis response buffer overflow " 307 DPRINT_ERR(NETVSC, "rndis response buffer overflow "
303 "detected (size %u max %zu)", 308 "detected (size %u max %zu)",
304 Response->MessageLength, 309 resp->MessageLength,
305 sizeof(struct rndis_filter_packet)); 310 sizeof(struct rndis_filter_packet));
306 311
307 if (Response->NdisMessageType == 312 if (resp->NdisMessageType ==
308 REMOTE_NDIS_RESET_CMPLT) { 313 REMOTE_NDIS_RESET_CMPLT) {
309 /* does not have a request id field */ 314 /* does not have a request id field */
310 request->ResponseMessage.Message.ResetComplete.Status = STATUS_BUFFER_OVERFLOW; 315 request->response_msg.Message.ResetComplete.
316 Status = STATUS_BUFFER_OVERFLOW;
311 } else { 317 } else {
312 request->ResponseMessage.Message.InitializeComplete.Status = STATUS_BUFFER_OVERFLOW; 318 request->response_msg.Message.
319 InitializeComplete.Status =
320 STATUS_BUFFER_OVERFLOW;
313 } 321 }
314 } 322 }
315 323
316 osd_waitevent_set(request->WaitEvent); 324 osd_waitevent_set(request->waitevent);
317 } else { 325 } else {
318 DPRINT_ERR(NETVSC, "no rndis request found for this response " 326 DPRINT_ERR(NETVSC, "no rndis request found for this response "
319 "(id 0x%x res type 0x%x)", 327 "(id 0x%x res type 0x%x)",
320 Response->Message.InitializeComplete.RequestId, 328 resp->Message.InitializeComplete.RequestId,
321 Response->NdisMessageType); 329 resp->NdisMessageType);
322 } 330 }
323} 331}
324 332
325static void RndisFilterReceiveIndicateStatus(struct rndis_device *Device, 333static void RndisFilterReceiveIndicateStatus(struct rndis_device *dev,
326 struct rndis_message *Response) 334 struct rndis_message *resp)
327{ 335{
328 struct rndis_indicate_status *indicate = 336 struct rndis_indicate_status *indicate =
329 &Response->Message.IndicateStatus; 337 &resp->Message.IndicateStatus;
330 338
331 if (indicate->Status == RNDIS_STATUS_MEDIA_CONNECT) { 339 if (indicate->Status == RNDIS_STATUS_MEDIA_CONNECT) {
332 gRndisFilter.InnerDriver.OnLinkStatusChanged(Device->NetDevice->Device, 1); 340 rndis_filter.inner_drv.OnLinkStatusChanged(
341 dev->net_dev->Device, 1);
333 } else if (indicate->Status == RNDIS_STATUS_MEDIA_DISCONNECT) { 342 } else if (indicate->Status == RNDIS_STATUS_MEDIA_DISCONNECT) {
334 gRndisFilter.InnerDriver.OnLinkStatusChanged(Device->NetDevice->Device, 0); 343 rndis_filter.inner_drv.OnLinkStatusChanged(
344 dev->net_dev->Device, 0);
335 } else { 345 } else {
336 /* 346 /*
337 * TODO: 347 * TODO:
@@ -339,18 +349,18 @@ static void RndisFilterReceiveIndicateStatus(struct rndis_device *Device,
339 } 349 }
340} 350}
341 351
342static void RndisFilterReceiveData(struct rndis_device *Device, 352static void RndisFilterReceiveData(struct rndis_device *dev,
343 struct rndis_message *Message, 353 struct rndis_message *msg,
344 struct hv_netvsc_packet *Packet) 354 struct hv_netvsc_packet *pkt)
345{ 355{
346 struct rndis_packet *rndisPacket; 356 struct rndis_packet *rndis_pkt;
347 u32 dataOffset; 357 u32 data_offset;
348 358
349 /* empty ethernet frame ?? */ 359 /* empty ethernet frame ?? */
350 /* ASSERT(Packet->PageBuffers[0].Length > */ 360 /* ASSERT(Packet->PageBuffers[0].Length > */
351 /* RNDIS_MESSAGE_SIZE(struct rndis_packet)); */ 361 /* RNDIS_MESSAGE_SIZE(struct rndis_packet)); */
352 362
353 rndisPacket = &Message->Message.Packet; 363 rndis_pkt = &msg->Message.Packet;
354 364
355 /* 365 /*
356 * FIXME: Handle multiple rndis pkt msgs that maybe enclosed in this 366 * FIXME: Handle multiple rndis pkt msgs that maybe enclosed in this
@@ -358,48 +368,48 @@ static void RndisFilterReceiveData(struct rndis_device *Device,
358 */ 368 */
359 369
360 /* Remove the rndis header and pass it back up the stack */ 370 /* Remove the rndis header and pass it back up the stack */
361 dataOffset = RNDIS_HEADER_SIZE + rndisPacket->DataOffset; 371 data_offset = RNDIS_HEADER_SIZE + rndis_pkt->DataOffset;
362 372
363 Packet->TotalDataBufferLength -= dataOffset; 373 pkt->TotalDataBufferLength -= data_offset;
364 Packet->PageBuffers[0].Offset += dataOffset; 374 pkt->PageBuffers[0].Offset += data_offset;
365 Packet->PageBuffers[0].Length -= dataOffset; 375 pkt->PageBuffers[0].Length -= data_offset;
366 376
367 Packet->IsDataPacket = true; 377 pkt->IsDataPacket = true;
368 378
369 gRndisFilter.InnerDriver.OnReceiveCallback(Device->NetDevice->Device, 379 rndis_filter.inner_drv.OnReceiveCallback(dev->net_dev->Device,
370 Packet); 380 pkt);
371} 381}
372 382
373static int RndisFilterOnReceive(struct hv_device *Device, 383static int RndisFilterOnReceive(struct hv_device *dev,
374 struct hv_netvsc_packet *Packet) 384 struct hv_netvsc_packet *pkt)
375{ 385{
376 struct netvsc_device *netDevice = Device->Extension; 386 struct netvsc_device *net_dev = dev->Extension;
377 struct rndis_device *rndisDevice; 387 struct rndis_device *rndis_dev;
378 struct rndis_message rndisMessage; 388 struct rndis_message rndis_msg;
379 struct rndis_message *rndisHeader; 389 struct rndis_message *rndis_hdr;
380 390
381 if (!netDevice) 391 if (!net_dev)
382 return -EINVAL; 392 return -EINVAL;
383 393
384 /* Make sure the rndis device state is initialized */ 394 /* Make sure the rndis device state is initialized */
385 if (!netDevice->Extension) { 395 if (!net_dev->Extension) {
386 DPRINT_ERR(NETVSC, "got rndis message but no rndis device..." 396 DPRINT_ERR(NETVSC, "got rndis message but no rndis device..."
387 "dropping this message!"); 397 "dropping this message!");
388 return -1; 398 return -1;
389 } 399 }
390 400
391 rndisDevice = (struct rndis_device *)netDevice->Extension; 401 rndis_dev = (struct rndis_device *)net_dev->Extension;
392 if (rndisDevice->State == RNDIS_DEV_UNINITIALIZED) { 402 if (rndis_dev->state == RNDIS_DEV_UNINITIALIZED) {
393 DPRINT_ERR(NETVSC, "got rndis message but rndis device " 403 DPRINT_ERR(NETVSC, "got rndis message but rndis device "
394 "uninitialized...dropping this message!"); 404 "uninitialized...dropping this message!");
395 return -1; 405 return -1;
396 } 406 }
397 407
398 rndisHeader = (struct rndis_message *)kmap_atomic( 408 rndis_hdr = (struct rndis_message *)kmap_atomic(
399 pfn_to_page(Packet->PageBuffers[0].Pfn), KM_IRQ0); 409 pfn_to_page(pkt->PageBuffers[0].Pfn), KM_IRQ0);
400 410
401 rndisHeader = (void *)((unsigned long)rndisHeader + 411 rndis_hdr = (void *)((unsigned long)rndis_hdr +
402 Packet->PageBuffers[0].Offset); 412 pkt->PageBuffers[0].Offset);
403 413
404 /* Make sure we got a valid rndis message */ 414 /* Make sure we got a valid rndis message */
405 /* 415 /*
@@ -408,39 +418,39 @@ static int RndisFilterOnReceive(struct hv_device *Device,
408 * range shows 52 bytes 418 * range shows 52 bytes
409 * */ 419 * */
410#if 0 420#if 0
411 if (Packet->TotalDataBufferLength != rndisHeader->MessageLength) { 421 if (pkt->TotalDataBufferLength != rndis_hdr->MessageLength) {
412 kunmap_atomic(rndisHeader - Packet->PageBuffers[0].Offset, 422 kunmap_atomic(rndis_hdr - pkt->PageBuffers[0].Offset,
413 KM_IRQ0); 423 KM_IRQ0);
414 424
415 DPRINT_ERR(NETVSC, "invalid rndis message? (expected %u " 425 DPRINT_ERR(NETVSC, "invalid rndis message? (expected %u "
416 "bytes got %u)...dropping this message!", 426 "bytes got %u)...dropping this message!",
417 rndisHeader->MessageLength, 427 rndis_hdr->MessageLength,
418 Packet->TotalDataBufferLength); 428 pkt->TotalDataBufferLength);
419 return -1; 429 return -1;
420 } 430 }
421#endif 431#endif
422 432
423 if ((rndisHeader->NdisMessageType != REMOTE_NDIS_PACKET_MSG) && 433 if ((rndis_hdr->NdisMessageType != REMOTE_NDIS_PACKET_MSG) &&
424 (rndisHeader->MessageLength > sizeof(struct rndis_message))) { 434 (rndis_hdr->MessageLength > sizeof(struct rndis_message))) {
425 DPRINT_ERR(NETVSC, "incoming rndis message buffer overflow " 435 DPRINT_ERR(NETVSC, "incoming rndis message buffer overflow "
426 "detected (got %u, max %zu)...marking it an error!", 436 "detected (got %u, max %zu)...marking it an error!",
427 rndisHeader->MessageLength, 437 rndis_hdr->MessageLength,
428 sizeof(struct rndis_message)); 438 sizeof(struct rndis_message));
429 } 439 }
430 440
431 memcpy(&rndisMessage, rndisHeader, 441 memcpy(&rndis_msg, rndis_hdr,
432 (rndisHeader->MessageLength > sizeof(struct rndis_message)) ? 442 (rndis_hdr->MessageLength > sizeof(struct rndis_message)) ?
433 sizeof(struct rndis_message) : 443 sizeof(struct rndis_message) :
434 rndisHeader->MessageLength); 444 rndis_hdr->MessageLength);
435 445
436 kunmap_atomic(rndisHeader - Packet->PageBuffers[0].Offset, KM_IRQ0); 446 kunmap_atomic(rndis_hdr - pkt->PageBuffers[0].Offset, KM_IRQ0);
437 447
438 DumpRndisMessage(&rndisMessage); 448 DumpRndisMessage(&rndis_msg);
439 449
440 switch (rndisMessage.NdisMessageType) { 450 switch (rndis_msg.NdisMessageType) {
441 case REMOTE_NDIS_PACKET_MSG: 451 case REMOTE_NDIS_PACKET_MSG:
442 /* data msg */ 452 /* data msg */
443 RndisFilterReceiveData(rndisDevice, &rndisMessage, Packet); 453 RndisFilterReceiveData(rndis_dev, &rndis_msg, pkt);
444 break; 454 break;
445 455
446 case REMOTE_NDIS_INITIALIZE_CMPLT: 456 case REMOTE_NDIS_INITIALIZE_CMPLT:
@@ -449,37 +459,37 @@ static int RndisFilterOnReceive(struct hv_device *Device,
449 /* case REMOTE_NDIS_RESET_CMPLT: */ 459 /* case REMOTE_NDIS_RESET_CMPLT: */
450 /* case REMOTE_NDIS_KEEPALIVE_CMPLT: */ 460 /* case REMOTE_NDIS_KEEPALIVE_CMPLT: */
451 /* completion msgs */ 461 /* completion msgs */
452 RndisFilterReceiveResponse(rndisDevice, &rndisMessage); 462 RndisFilterReceiveResponse(rndis_dev, &rndis_msg);
453 break; 463 break;
454 464
455 case REMOTE_NDIS_INDICATE_STATUS_MSG: 465 case REMOTE_NDIS_INDICATE_STATUS_MSG:
456 /* notification msgs */ 466 /* notification msgs */
457 RndisFilterReceiveIndicateStatus(rndisDevice, &rndisMessage); 467 RndisFilterReceiveIndicateStatus(rndis_dev, &rndis_msg);
458 break; 468 break;
459 default: 469 default:
460 DPRINT_ERR(NETVSC, "unhandled rndis message (type %u len %u)", 470 DPRINT_ERR(NETVSC, "unhandled rndis message (type %u len %u)",
461 rndisMessage.NdisMessageType, 471 rndis_msg.NdisMessageType,
462 rndisMessage.MessageLength); 472 rndis_msg.MessageLength);
463 break; 473 break;
464 } 474 }
465 475
466 return 0; 476 return 0;
467} 477}
468 478
469static int RndisFilterQueryDevice(struct rndis_device *Device, u32 Oid, 479static int RndisFilterQueryDevice(struct rndis_device *dev, u32 oid,
470 void *Result, u32 *ResultSize) 480 void *result, u32 *result_size)
471{ 481{
472 struct rndis_request *request; 482 struct rndis_request *request;
473 u32 inresultSize = *ResultSize; 483 u32 inresult_size = *result_size;
474 struct rndis_query_request *query; 484 struct rndis_query_request *query;
475 struct rndis_query_complete *queryComplete; 485 struct rndis_query_complete *query_complete;
476 int ret = 0; 486 int ret = 0;
477 487
478 if (!Result) 488 if (!result)
479 return -EINVAL; 489 return -EINVAL;
480 490
481 *ResultSize = 0; 491 *result_size = 0;
482 request = GetRndisRequest(Device, REMOTE_NDIS_QUERY_MSG, 492 request = GetRndisRequest(dev, REMOTE_NDIS_QUERY_MSG,
483 RNDIS_MESSAGE_SIZE(struct rndis_query_request)); 493 RNDIS_MESSAGE_SIZE(struct rndis_query_request));
484 if (!request) { 494 if (!request) {
485 ret = -1; 495 ret = -1;
@@ -487,71 +497,71 @@ static int RndisFilterQueryDevice(struct rndis_device *Device, u32 Oid,
487 } 497 }
488 498
489 /* Setup the rndis query */ 499 /* Setup the rndis query */
490 query = &request->RequestMessage.Message.QueryRequest; 500 query = &request->request_msg.Message.QueryRequest;
491 query->Oid = Oid; 501 query->Oid = oid;
492 query->InformationBufferOffset = sizeof(struct rndis_query_request); 502 query->InformationBufferOffset = sizeof(struct rndis_query_request);
493 query->InformationBufferLength = 0; 503 query->InformationBufferLength = 0;
494 query->DeviceVcHandle = 0; 504 query->DeviceVcHandle = 0;
495 505
496 ret = RndisFilterSendRequest(Device, request); 506 ret = RndisFilterSendRequest(dev, request);
497 if (ret != 0) 507 if (ret != 0)
498 goto Cleanup; 508 goto Cleanup;
499 509
500 osd_waitevent_wait(request->WaitEvent); 510 osd_waitevent_wait(request->waitevent);
501 511
502 /* Copy the response back */ 512 /* Copy the response back */
503 queryComplete = &request->ResponseMessage.Message.QueryComplete; 513 query_complete = &request->response_msg.Message.QueryComplete;
504 514
505 if (queryComplete->InformationBufferLength > inresultSize) { 515 if (query_complete->InformationBufferLength > inresult_size) {
506 ret = -1; 516 ret = -1;
507 goto Cleanup; 517 goto Cleanup;
508 } 518 }
509 519
510 memcpy(Result, 520 memcpy(result,
511 (void *)((unsigned long)queryComplete + 521 (void *)((unsigned long)query_complete +
512 queryComplete->InformationBufferOffset), 522 query_complete->InformationBufferOffset),
513 queryComplete->InformationBufferLength); 523 query_complete->InformationBufferLength);
514 524
515 *ResultSize = queryComplete->InformationBufferLength; 525 *result_size = query_complete->InformationBufferLength;
516 526
517Cleanup: 527Cleanup:
518 if (request) 528 if (request)
519 PutRndisRequest(Device, request); 529 PutRndisRequest(dev, request);
520 530
521 return ret; 531 return ret;
522} 532}
523 533
524static int RndisFilterQueryDeviceMac(struct rndis_device *Device) 534static int RndisFilterQueryDeviceMac(struct rndis_device *dev)
525{ 535{
526 u32 size = ETH_ALEN; 536 u32 size = ETH_ALEN;
527 537
528 return RndisFilterQueryDevice(Device, 538 return RndisFilterQueryDevice(dev,
529 RNDIS_OID_802_3_PERMANENT_ADDRESS, 539 RNDIS_OID_802_3_PERMANENT_ADDRESS,
530 Device->HwMacAddr, &size); 540 dev->hw_mac_adr, &size);
531} 541}
532 542
533static int RndisFilterQueryDeviceLinkStatus(struct rndis_device *Device) 543static int RndisFilterQueryDeviceLinkStatus(struct rndis_device *dev)
534{ 544{
535 u32 size = sizeof(u32); 545 u32 size = sizeof(u32);
536 546
537 return RndisFilterQueryDevice(Device, 547 return RndisFilterQueryDevice(dev,
538 RNDIS_OID_GEN_MEDIA_CONNECT_STATUS, 548 RNDIS_OID_GEN_MEDIA_CONNECT_STATUS,
539 &Device->LinkStatus, &size); 549 &dev->link_stat, &size);
540} 550}
541 551
542static int RndisFilterSetPacketFilter(struct rndis_device *Device, 552static int RndisFilterSetPacketFilter(struct rndis_device *dev,
543 u32 NewFilter) 553 u32 new_filter)
544{ 554{
545 struct rndis_request *request; 555 struct rndis_request *request;
546 struct rndis_set_request *set; 556 struct rndis_set_request *set;
547 struct rndis_set_complete *setComplete; 557 struct rndis_set_complete *set_complete;
548 u32 status; 558 u32 status;
549 int ret; 559 int ret;
550 560
551 /* ASSERT(RNDIS_MESSAGE_SIZE(struct rndis_set_request) + sizeof(u32) <= */ 561 /* ASSERT(RNDIS_MESSAGE_SIZE(struct rndis_set_request) + sizeof(u32) <= */
552 /* sizeof(struct rndis_message)); */ 562 /* sizeof(struct rndis_message)); */
553 563
554 request = GetRndisRequest(Device, REMOTE_NDIS_SET_MSG, 564 request = GetRndisRequest(dev, REMOTE_NDIS_SET_MSG,
555 RNDIS_MESSAGE_SIZE(struct rndis_set_request) + 565 RNDIS_MESSAGE_SIZE(struct rndis_set_request) +
556 sizeof(u32)); 566 sizeof(u32));
557 if (!request) { 567 if (!request) {
@@ -560,19 +570,19 @@ static int RndisFilterSetPacketFilter(struct rndis_device *Device,
560 } 570 }
561 571
562 /* Setup the rndis set */ 572 /* Setup the rndis set */
563 set = &request->RequestMessage.Message.SetRequest; 573 set = &request->request_msg.Message.SetRequest;
564 set->Oid = RNDIS_OID_GEN_CURRENT_PACKET_FILTER; 574 set->Oid = RNDIS_OID_GEN_CURRENT_PACKET_FILTER;
565 set->InformationBufferLength = sizeof(u32); 575 set->InformationBufferLength = sizeof(u32);
566 set->InformationBufferOffset = sizeof(struct rndis_set_request); 576 set->InformationBufferOffset = sizeof(struct rndis_set_request);
567 577
568 memcpy((void *)(unsigned long)set + sizeof(struct rndis_set_request), 578 memcpy((void *)(unsigned long)set + sizeof(struct rndis_set_request),
569 &NewFilter, sizeof(u32)); 579 &new_filter, sizeof(u32));
570 580
571 ret = RndisFilterSendRequest(Device, request); 581 ret = RndisFilterSendRequest(dev, request);
572 if (ret != 0) 582 if (ret != 0)
573 goto Cleanup; 583 goto Cleanup;
574 584
575 ret = osd_waitevent_waitex(request->WaitEvent, 2000/*2sec*/); 585 ret = osd_waitevent_waitex(request->waitevent, 2000/*2sec*/);
576 if (!ret) { 586 if (!ret) {
577 ret = -1; 587 ret = -1;
578 DPRINT_ERR(NETVSC, "timeout before we got a set response..."); 588 DPRINT_ERR(NETVSC, "timeout before we got a set response...");
@@ -584,27 +594,27 @@ static int RndisFilterSetPacketFilter(struct rndis_device *Device,
584 } else { 594 } else {
585 if (ret > 0) 595 if (ret > 0)
586 ret = 0; 596 ret = 0;
587 setComplete = &request->ResponseMessage.Message.SetComplete; 597 set_complete = &request->response_msg.Message.SetComplete;
588 status = setComplete->Status; 598 status = set_complete->Status;
589 } 599 }
590 600
591Cleanup: 601Cleanup:
592 if (request) 602 if (request)
593 PutRndisRequest(Device, request); 603 PutRndisRequest(dev, request);
594Exit: 604Exit:
595 return ret; 605 return ret;
596} 606}
597 607
598int RndisFilterInit(struct netvsc_driver *Driver) 608int RndisFilterInit(struct netvsc_driver *drv)
599{ 609{
600 DPRINT_DBG(NETVSC, "sizeof(struct rndis_filter_packet) == %zd", 610 DPRINT_DBG(NETVSC, "sizeof(struct rndis_filter_packet) == %zd",
601 sizeof(struct rndis_filter_packet)); 611 sizeof(struct rndis_filter_packet));
602 612
603 Driver->RequestExtSize = sizeof(struct rndis_filter_packet); 613 drv->RequestExtSize = sizeof(struct rndis_filter_packet);
604 614
605 /* Driver->Context = rndisDriver; */ 615 /* Driver->Context = rndisDriver; */
606 616
607 memset(&gRndisFilter, 0, sizeof(struct rndis_filter_driver_object)); 617 memset(&rndis_filter, 0, sizeof(struct rndis_filter_driver_object));
608 618
609 /*rndisDriver->Driver = Driver; 619 /*rndisDriver->Driver = Driver;
610 620
@@ -612,38 +622,38 @@ int RndisFilterInit(struct netvsc_driver *Driver)
612 rndisDriver->OnLinkStatusChanged = Driver->OnLinkStatusChanged;*/ 622 rndisDriver->OnLinkStatusChanged = Driver->OnLinkStatusChanged;*/
613 623
614 /* Save the original dispatch handlers before we override it */ 624 /* Save the original dispatch handlers before we override it */
615 gRndisFilter.InnerDriver.Base.OnDeviceAdd = Driver->Base.OnDeviceAdd; 625 rndis_filter.inner_drv.Base.OnDeviceAdd = drv->Base.OnDeviceAdd;
616 gRndisFilter.InnerDriver.Base.OnDeviceRemove = 626 rndis_filter.inner_drv.Base.OnDeviceRemove =
617 Driver->Base.OnDeviceRemove; 627 drv->Base.OnDeviceRemove;
618 gRndisFilter.InnerDriver.Base.OnCleanup = Driver->Base.OnCleanup; 628 rndis_filter.inner_drv.Base.OnCleanup = drv->Base.OnCleanup;
619 629
620 /* ASSERT(Driver->OnSend); */ 630 /* ASSERT(Driver->OnSend); */
621 /* ASSERT(Driver->OnReceiveCallback); */ 631 /* ASSERT(Driver->OnReceiveCallback); */
622 gRndisFilter.InnerDriver.OnSend = Driver->OnSend; 632 rndis_filter.inner_drv.OnSend = drv->OnSend;
623 gRndisFilter.InnerDriver.OnReceiveCallback = Driver->OnReceiveCallback; 633 rndis_filter.inner_drv.OnReceiveCallback = drv->OnReceiveCallback;
624 gRndisFilter.InnerDriver.OnLinkStatusChanged = 634 rndis_filter.inner_drv.OnLinkStatusChanged =
625 Driver->OnLinkStatusChanged; 635 drv->OnLinkStatusChanged;
626 636
627 /* Override */ 637 /* Override */
628 Driver->Base.OnDeviceAdd = RndisFilterOnDeviceAdd; 638 drv->Base.OnDeviceAdd = RndisFilterOnDeviceAdd;
629 Driver->Base.OnDeviceRemove = RndisFilterOnDeviceRemove; 639 drv->Base.OnDeviceRemove = RndisFilterOnDeviceRemove;
630 Driver->Base.OnCleanup = RndisFilterOnCleanup; 640 drv->Base.OnCleanup = RndisFilterOnCleanup;
631 Driver->OnSend = RndisFilterOnSend; 641 drv->OnSend = RndisFilterOnSend;
632 /* Driver->QueryLinkStatus = RndisFilterQueryDeviceLinkStatus; */ 642 /* Driver->QueryLinkStatus = RndisFilterQueryDeviceLinkStatus; */
633 Driver->OnReceiveCallback = RndisFilterOnReceive; 643 drv->OnReceiveCallback = RndisFilterOnReceive;
634 644
635 return 0; 645 return 0;
636} 646}
637 647
638static int RndisFilterInitDevice(struct rndis_device *Device) 648static int RndisFilterInitDevice(struct rndis_device *dev)
639{ 649{
640 struct rndis_request *request; 650 struct rndis_request *request;
641 struct rndis_initialize_request *init; 651 struct rndis_initialize_request *init;
642 struct rndis_initialize_complete *initComplete; 652 struct rndis_initialize_complete *init_complete;
643 u32 status; 653 u32 status;
644 int ret; 654 int ret;
645 655
646 request = GetRndisRequest(Device, REMOTE_NDIS_INITIALIZE_MSG, 656 request = GetRndisRequest(dev, REMOTE_NDIS_INITIALIZE_MSG,
647 RNDIS_MESSAGE_SIZE(struct rndis_initialize_request)); 657 RNDIS_MESSAGE_SIZE(struct rndis_initialize_request));
648 if (!request) { 658 if (!request) {
649 ret = -1; 659 ret = -1;
@@ -651,103 +661,103 @@ static int RndisFilterInitDevice(struct rndis_device *Device)
651 } 661 }
652 662
653 /* Setup the rndis set */ 663 /* Setup the rndis set */
654 init = &request->RequestMessage.Message.InitializeRequest; 664 init = &request->request_msg.Message.InitializeRequest;
655 init->MajorVersion = RNDIS_MAJOR_VERSION; 665 init->MajorVersion = RNDIS_MAJOR_VERSION;
656 init->MinorVersion = RNDIS_MINOR_VERSION; 666 init->MinorVersion = RNDIS_MINOR_VERSION;
657 /* FIXME: Use 1536 - rounded ethernet frame size */ 667 /* FIXME: Use 1536 - rounded ethernet frame size */
658 init->MaxTransferSize = 2048; 668 init->MaxTransferSize = 2048;
659 669
660 Device->State = RNDIS_DEV_INITIALIZING; 670 dev->state = RNDIS_DEV_INITIALIZING;
661 671
662 ret = RndisFilterSendRequest(Device, request); 672 ret = RndisFilterSendRequest(dev, request);
663 if (ret != 0) { 673 if (ret != 0) {
664 Device->State = RNDIS_DEV_UNINITIALIZED; 674 dev->state = RNDIS_DEV_UNINITIALIZED;
665 goto Cleanup; 675 goto Cleanup;
666 } 676 }
667 677
668 osd_waitevent_wait(request->WaitEvent); 678 osd_waitevent_wait(request->waitevent);
669 679
670 initComplete = &request->ResponseMessage.Message.InitializeComplete; 680 init_complete = &request->response_msg.Message.InitializeComplete;
671 status = initComplete->Status; 681 status = init_complete->Status;
672 if (status == RNDIS_STATUS_SUCCESS) { 682 if (status == RNDIS_STATUS_SUCCESS) {
673 Device->State = RNDIS_DEV_INITIALIZED; 683 dev->state = RNDIS_DEV_INITIALIZED;
674 ret = 0; 684 ret = 0;
675 } else { 685 } else {
676 Device->State = RNDIS_DEV_UNINITIALIZED; 686 dev->state = RNDIS_DEV_UNINITIALIZED;
677 ret = -1; 687 ret = -1;
678 } 688 }
679 689
680Cleanup: 690Cleanup:
681 if (request) 691 if (request)
682 PutRndisRequest(Device, request); 692 PutRndisRequest(dev, request);
683 693
684 return ret; 694 return ret;
685} 695}
686 696
687static void RndisFilterHaltDevice(struct rndis_device *Device) 697static void RndisFilterHaltDevice(struct rndis_device *dev)
688{ 698{
689 struct rndis_request *request; 699 struct rndis_request *request;
690 struct rndis_halt_request *halt; 700 struct rndis_halt_request *halt;
691 701
692 /* Attempt to do a rndis device halt */ 702 /* Attempt to do a rndis device halt */
693 request = GetRndisRequest(Device, REMOTE_NDIS_HALT_MSG, 703 request = GetRndisRequest(dev, REMOTE_NDIS_HALT_MSG,
694 RNDIS_MESSAGE_SIZE(struct rndis_halt_request)); 704 RNDIS_MESSAGE_SIZE(struct rndis_halt_request));
695 if (!request) 705 if (!request)
696 goto Cleanup; 706 goto Cleanup;
697 707
698 /* Setup the rndis set */ 708 /* Setup the rndis set */
699 halt = &request->RequestMessage.Message.HaltRequest; 709 halt = &request->request_msg.Message.HaltRequest;
700 halt->RequestId = atomic_inc_return(&Device->NewRequestId); 710 halt->RequestId = atomic_inc_return(&dev->new_req_id);
701 711
702 /* Ignore return since this msg is optional. */ 712 /* Ignore return since this msg is optional. */
703 RndisFilterSendRequest(Device, request); 713 RndisFilterSendRequest(dev, request);
704 714
705 Device->State = RNDIS_DEV_UNINITIALIZED; 715 dev->state = RNDIS_DEV_UNINITIALIZED;
706 716
707Cleanup: 717Cleanup:
708 if (request) 718 if (request)
709 PutRndisRequest(Device, request); 719 PutRndisRequest(dev, request);
710 return; 720 return;
711} 721}
712 722
713static int RndisFilterOpenDevice(struct rndis_device *Device) 723static int RndisFilterOpenDevice(struct rndis_device *dev)
714{ 724{
715 int ret; 725 int ret;
716 726
717 if (Device->State != RNDIS_DEV_INITIALIZED) 727 if (dev->state != RNDIS_DEV_INITIALIZED)
718 return 0; 728 return 0;
719 729
720 ret = RndisFilterSetPacketFilter(Device, 730 ret = RndisFilterSetPacketFilter(dev,
721 NDIS_PACKET_TYPE_BROADCAST | 731 NDIS_PACKET_TYPE_BROADCAST |
722 NDIS_PACKET_TYPE_ALL_MULTICAST | 732 NDIS_PACKET_TYPE_ALL_MULTICAST |
723 NDIS_PACKET_TYPE_DIRECTED); 733 NDIS_PACKET_TYPE_DIRECTED);
724 if (ret == 0) 734 if (ret == 0)
725 Device->State = RNDIS_DEV_DATAINITIALIZED; 735 dev->state = RNDIS_DEV_DATAINITIALIZED;
726 736
727 return ret; 737 return ret;
728} 738}
729 739
730static int RndisFilterCloseDevice(struct rndis_device *Device) 740static int RndisFilterCloseDevice(struct rndis_device *dev)
731{ 741{
732 int ret; 742 int ret;
733 743
734 if (Device->State != RNDIS_DEV_DATAINITIALIZED) 744 if (dev->state != RNDIS_DEV_DATAINITIALIZED)
735 return 0; 745 return 0;
736 746
737 ret = RndisFilterSetPacketFilter(Device, 0); 747 ret = RndisFilterSetPacketFilter(dev, 0);
738 if (ret == 0) 748 if (ret == 0)
739 Device->State = RNDIS_DEV_INITIALIZED; 749 dev->state = RNDIS_DEV_INITIALIZED;
740 750
741 return ret; 751 return ret;
742} 752}
743 753
744static int RndisFilterOnDeviceAdd(struct hv_device *Device, 754static int RndisFilterOnDeviceAdd(struct hv_device *dev,
745 void *AdditionalInfo) 755 void *additional_info)
746{ 756{
747 int ret; 757 int ret;
748 struct netvsc_device *netDevice; 758 struct netvsc_device *netDevice;
749 struct rndis_device *rndisDevice; 759 struct rndis_device *rndisDevice;
750 struct netvsc_device_info *deviceInfo = AdditionalInfo; 760 struct netvsc_device_info *deviceInfo = additional_info;
751 761
752 rndisDevice = GetRndisDevice(); 762 rndisDevice = GetRndisDevice();
753 if (!rndisDevice) 763 if (!rndisDevice)
@@ -760,7 +770,7 @@ static int RndisFilterOnDeviceAdd(struct hv_device *Device,
760 * NOTE! Once the channel is created, we may get a receive callback 770 * NOTE! Once the channel is created, we may get a receive callback
761 * (RndisFilterOnReceive()) before this call is completed 771 * (RndisFilterOnReceive()) before this call is completed
762 */ 772 */
763 ret = gRndisFilter.InnerDriver.Base.OnDeviceAdd(Device, AdditionalInfo); 773 ret = rndis_filter.inner_drv.Base.OnDeviceAdd(dev, additional_info);
764 if (ret != 0) { 774 if (ret != 0) {
765 kfree(rndisDevice); 775 kfree(rndisDevice);
766 return ret; 776 return ret;
@@ -768,12 +778,12 @@ static int RndisFilterOnDeviceAdd(struct hv_device *Device,
768 778
769 779
770 /* Initialize the rndis device */ 780 /* Initialize the rndis device */
771 netDevice = Device->Extension; 781 netDevice = dev->Extension;
772 /* ASSERT(netDevice); */ 782 /* ASSERT(netDevice); */
773 /* ASSERT(netDevice->Device); */ 783 /* ASSERT(netDevice->Device); */
774 784
775 netDevice->Extension = rndisDevice; 785 netDevice->Extension = rndisDevice;
776 rndisDevice->NetDevice = netDevice; 786 rndisDevice->net_dev = netDevice;
777 787
778 /* Send the rndis initialization message */ 788 /* Send the rndis initialization message */
779 ret = RndisFilterInitDevice(rndisDevice); 789 ret = RndisFilterInitDevice(rndisDevice);
@@ -793,43 +803,43 @@ static int RndisFilterOnDeviceAdd(struct hv_device *Device,
793 } 803 }
794 804
795 DPRINT_INFO(NETVSC, "Device 0x%p mac addr %pM", 805 DPRINT_INFO(NETVSC, "Device 0x%p mac addr %pM",
796 rndisDevice, rndisDevice->HwMacAddr); 806 rndisDevice, rndisDevice->hw_mac_adr);
797 807
798 memcpy(deviceInfo->MacAddr, rndisDevice->HwMacAddr, ETH_ALEN); 808 memcpy(deviceInfo->MacAddr, rndisDevice->hw_mac_adr, ETH_ALEN);
799 809
800 RndisFilterQueryDeviceLinkStatus(rndisDevice); 810 RndisFilterQueryDeviceLinkStatus(rndisDevice);
801 811
802 deviceInfo->LinkState = rndisDevice->LinkStatus; 812 deviceInfo->LinkState = rndisDevice->link_stat;
803 DPRINT_INFO(NETVSC, "Device 0x%p link state %s", rndisDevice, 813 DPRINT_INFO(NETVSC, "Device 0x%p link state %s", rndisDevice,
804 ((deviceInfo->LinkState) ? ("down") : ("up"))); 814 ((deviceInfo->LinkState) ? ("down") : ("up")));
805 815
806 return ret; 816 return ret;
807} 817}
808 818
809static int RndisFilterOnDeviceRemove(struct hv_device *Device) 819static int RndisFilterOnDeviceRemove(struct hv_device *dev)
810{ 820{
811 struct netvsc_device *netDevice = Device->Extension; 821 struct netvsc_device *net_dev = dev->Extension;
812 struct rndis_device *rndisDevice = netDevice->Extension; 822 struct rndis_device *rndis_dev = net_dev->Extension;
813 823
814 /* Halt and release the rndis device */ 824 /* Halt and release the rndis device */
815 RndisFilterHaltDevice(rndisDevice); 825 RndisFilterHaltDevice(rndis_dev);
816 826
817 kfree(rndisDevice); 827 kfree(rndis_dev);
818 netDevice->Extension = NULL; 828 net_dev->Extension = NULL;
819 829
820 /* Pass control to inner driver to remove the device */ 830 /* Pass control to inner driver to remove the device */
821 gRndisFilter.InnerDriver.Base.OnDeviceRemove(Device); 831 rndis_filter.inner_drv.Base.OnDeviceRemove(dev);
822 832
823 return 0; 833 return 0;
824} 834}
825 835
826static void RndisFilterOnCleanup(struct hv_driver *Driver) 836static void RndisFilterOnCleanup(struct hv_driver *drv)
827{ 837{
828} 838}
829 839
830int RndisFilterOnOpen(struct hv_device *Device) 840int RndisFilterOnOpen(struct hv_device *dev)
831{ 841{
832 struct netvsc_device *netDevice = Device->Extension; 842 struct netvsc_device *netDevice = dev->Extension;
833 843
834 if (!netDevice) 844 if (!netDevice)
835 return -EINVAL; 845 return -EINVAL;
@@ -837,9 +847,9 @@ int RndisFilterOnOpen(struct hv_device *Device)
837 return RndisFilterOpenDevice(netDevice->Extension); 847 return RndisFilterOpenDevice(netDevice->Extension);
838} 848}
839 849
840int RndisFilterOnClose(struct hv_device *Device) 850int RndisFilterOnClose(struct hv_device *dev)
841{ 851{
842 struct netvsc_device *netDevice = Device->Extension; 852 struct netvsc_device *netDevice = dev->Extension;
843 853
844 if (!netDevice) 854 if (!netDevice)
845 return -EINVAL; 855 return -EINVAL;
@@ -847,8 +857,8 @@ int RndisFilterOnClose(struct hv_device *Device)
847 return RndisFilterCloseDevice(netDevice->Extension); 857 return RndisFilterCloseDevice(netDevice->Extension);
848} 858}
849 859
850static int RndisFilterOnSend(struct hv_device *Device, 860static int RndisFilterOnSend(struct hv_device *dev,
851 struct hv_netvsc_packet *Packet) 861 struct hv_netvsc_packet *pkt)
852{ 862{
853 int ret; 863 int ret;
854 struct rndis_filter_packet *filterPacket; 864 struct rndis_filter_packet *filterPacket;
@@ -857,62 +867,62 @@ static int RndisFilterOnSend(struct hv_device *Device,
857 u32 rndisMessageSize; 867 u32 rndisMessageSize;
858 868
859 /* Add the rndis header */ 869 /* Add the rndis header */
860 filterPacket = (struct rndis_filter_packet *)Packet->Extension; 870 filterPacket = (struct rndis_filter_packet *)pkt->Extension;
861 /* ASSERT(filterPacket); */ 871 /* ASSERT(filterPacket); */
862 872
863 memset(filterPacket, 0, sizeof(struct rndis_filter_packet)); 873 memset(filterPacket, 0, sizeof(struct rndis_filter_packet));
864 874
865 rndisMessage = &filterPacket->Message; 875 rndisMessage = &filterPacket->msg;
866 rndisMessageSize = RNDIS_MESSAGE_SIZE(struct rndis_packet); 876 rndisMessageSize = RNDIS_MESSAGE_SIZE(struct rndis_packet);
867 877
868 rndisMessage->NdisMessageType = REMOTE_NDIS_PACKET_MSG; 878 rndisMessage->NdisMessageType = REMOTE_NDIS_PACKET_MSG;
869 rndisMessage->MessageLength = Packet->TotalDataBufferLength + 879 rndisMessage->MessageLength = pkt->TotalDataBufferLength +
870 rndisMessageSize; 880 rndisMessageSize;
871 881
872 rndisPacket = &rndisMessage->Message.Packet; 882 rndisPacket = &rndisMessage->Message.Packet;
873 rndisPacket->DataOffset = sizeof(struct rndis_packet); 883 rndisPacket->DataOffset = sizeof(struct rndis_packet);
874 rndisPacket->DataLength = Packet->TotalDataBufferLength; 884 rndisPacket->DataLength = pkt->TotalDataBufferLength;
875 885
876 Packet->IsDataPacket = true; 886 pkt->IsDataPacket = true;
877 Packet->PageBuffers[0].Pfn = virt_to_phys(rndisMessage) >> PAGE_SHIFT; 887 pkt->PageBuffers[0].Pfn = virt_to_phys(rndisMessage) >> PAGE_SHIFT;
878 Packet->PageBuffers[0].Offset = 888 pkt->PageBuffers[0].Offset =
879 (unsigned long)rndisMessage & (PAGE_SIZE-1); 889 (unsigned long)rndisMessage & (PAGE_SIZE-1);
880 Packet->PageBuffers[0].Length = rndisMessageSize; 890 pkt->PageBuffers[0].Length = rndisMessageSize;
881 891
882 /* Save the packet send completion and context */ 892 /* Save the packet send completion and context */
883 filterPacket->OnCompletion = Packet->Completion.Send.OnSendCompletion; 893 filterPacket->completion = pkt->Completion.Send.OnSendCompletion;
884 filterPacket->CompletionContext = 894 filterPacket->completion_ctx =
885 Packet->Completion.Send.SendCompletionContext; 895 pkt->Completion.Send.SendCompletionContext;
886 896
887 /* Use ours */ 897 /* Use ours */
888 Packet->Completion.Send.OnSendCompletion = RndisFilterOnSendCompletion; 898 pkt->Completion.Send.OnSendCompletion = RndisFilterOnSendCompletion;
889 Packet->Completion.Send.SendCompletionContext = filterPacket; 899 pkt->Completion.Send.SendCompletionContext = filterPacket;
890 900
891 ret = gRndisFilter.InnerDriver.OnSend(Device, Packet); 901 ret = rndis_filter.inner_drv.OnSend(dev, pkt);
892 if (ret != 0) { 902 if (ret != 0) {
893 /* 903 /*
894 * Reset the completion to originals to allow retries from 904 * Reset the completion to originals to allow retries from
895 * above 905 * above
896 */ 906 */
897 Packet->Completion.Send.OnSendCompletion = 907 pkt->Completion.Send.OnSendCompletion =
898 filterPacket->OnCompletion; 908 filterPacket->completion;
899 Packet->Completion.Send.SendCompletionContext = 909 pkt->Completion.Send.SendCompletionContext =
900 filterPacket->CompletionContext; 910 filterPacket->completion_ctx;
901 } 911 }
902 912
903 return ret; 913 return ret;
904} 914}
905 915
906static void RndisFilterOnSendCompletion(void *Context) 916static void RndisFilterOnSendCompletion(void *ctx)
907{ 917{
908 struct rndis_filter_packet *filterPacket = Context; 918 struct rndis_filter_packet *filterPacket = ctx;
909 919
910 /* Pass it back to the original handler */ 920 /* Pass it back to the original handler */
911 filterPacket->OnCompletion(filterPacket->CompletionContext); 921 filterPacket->completion(filterPacket->completion_ctx);
912} 922}
913 923
914 924
915static void RndisFilterOnSendRequestCompletion(void *Context) 925static void RndisFilterOnSendRequestCompletion(void *ctx)
916{ 926{
917 /* Noop */ 927 /* Noop */
918} 928}