diff options
author | Haiyang Zhang <haiyangz@microsoft.com> | 2010-12-10 15:03:54 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-12-13 13:31:50 -0500 |
commit | 85799a37553f89b23797ec4f69e45f6c5e9109df (patch) | |
tree | bb28dba6aa74f3d59159e4af2917af130205ecfd | |
parent | e1b8a37ede8b47dbad002ec61a67706b70b23ccf (diff) |
staging: hv: Convert camel cased variables in netvsc.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>
-rw-r--r-- | drivers/staging/hv/netvsc.c | 852 |
1 files changed, 445 insertions, 407 deletions
diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c index 8022781a9b13..1c1ee57482a5 100644 --- a/drivers/staging/hv/netvsc.c +++ b/drivers/staging/hv/netvsc.c | |||
@@ -31,141 +31,141 @@ | |||
31 | 31 | ||
32 | 32 | ||
33 | /* Globals */ | 33 | /* Globals */ |
34 | static const char *gDriverName = "netvsc"; | 34 | static const char *driver_name = "netvsc"; |
35 | 35 | ||
36 | /* {F8615163-DF3E-46c5-913F-F2D2F965ED0E} */ | 36 | /* {F8615163-DF3E-46c5-913F-F2D2F965ED0E} */ |
37 | static const struct hv_guid gNetVscDeviceType = { | 37 | static const struct hv_guid netvsc_device_type = { |
38 | .data = { | 38 | .data = { |
39 | 0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46, | 39 | 0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46, |
40 | 0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E | 40 | 0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E |
41 | } | 41 | } |
42 | }; | 42 | }; |
43 | 43 | ||
44 | static int NetVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo); | 44 | static int NetVscOnDeviceAdd(struct hv_device *device, void *additional_info); |
45 | 45 | ||
46 | static int NetVscOnDeviceRemove(struct hv_device *Device); | 46 | static int NetVscOnDeviceRemove(struct hv_device *device); |
47 | 47 | ||
48 | static void NetVscOnCleanup(struct hv_driver *Driver); | 48 | static void NetVscOnCleanup(struct hv_driver *driver); |
49 | 49 | ||
50 | static void NetVscOnChannelCallback(void *context); | 50 | static void NetVscOnChannelCallback(void *context); |
51 | 51 | ||
52 | static int NetVscInitializeSendBufferWithNetVsp(struct hv_device *Device); | 52 | static int NetVscInitializeSendBufferWithNetVsp(struct hv_device *device); |
53 | 53 | ||
54 | static int NetVscInitializeReceiveBufferWithNetVsp(struct hv_device *Device); | 54 | static int NetVscInitializeReceiveBufferWithNetVsp(struct hv_device *device); |
55 | 55 | ||
56 | static int NetVscDestroySendBuffer(struct netvsc_device *NetDevice); | 56 | static int NetVscDestroySendBuffer(struct netvsc_device *net_device); |
57 | 57 | ||
58 | static int NetVscDestroyReceiveBuffer(struct netvsc_device *NetDevice); | 58 | static int NetVscDestroyReceiveBuffer(struct netvsc_device *net_device); |
59 | 59 | ||
60 | static int NetVscConnectToVsp(struct hv_device *Device); | 60 | static int NetVscConnectToVsp(struct hv_device *device); |
61 | 61 | ||
62 | static void NetVscOnSendCompletion(struct hv_device *Device, | 62 | static void NetVscOnSendCompletion(struct hv_device *device, |
63 | struct vmpacket_descriptor *Packet); | 63 | struct vmpacket_descriptor *packet); |
64 | 64 | ||
65 | static int NetVscOnSend(struct hv_device *Device, | 65 | static int NetVscOnSend(struct hv_device *device, |
66 | struct hv_netvsc_packet *Packet); | 66 | struct hv_netvsc_packet *packet); |
67 | 67 | ||
68 | static void NetVscOnReceive(struct hv_device *Device, | 68 | static void NetVscOnReceive(struct hv_device *device, |
69 | struct vmpacket_descriptor *Packet); | 69 | struct vmpacket_descriptor *packet); |
70 | 70 | ||
71 | static void NetVscOnReceiveCompletion(void *Context); | 71 | static void NetVscOnReceiveCompletion(void *context); |
72 | 72 | ||
73 | static void NetVscSendReceiveCompletion(struct hv_device *Device, | 73 | static void NetVscSendReceiveCompletion(struct hv_device *device, |
74 | u64 TransactionId); | 74 | u64 transaction_id); |
75 | 75 | ||
76 | 76 | ||
77 | static struct netvsc_device *AllocNetDevice(struct hv_device *Device) | 77 | static struct netvsc_device *AllocNetDevice(struct hv_device *device) |
78 | { | 78 | { |
79 | struct netvsc_device *netDevice; | 79 | struct netvsc_device *net_device; |
80 | 80 | ||
81 | netDevice = kzalloc(sizeof(struct netvsc_device), GFP_KERNEL); | 81 | net_device = kzalloc(sizeof(struct netvsc_device), GFP_KERNEL); |
82 | if (!netDevice) | 82 | if (!net_device) |
83 | return NULL; | 83 | return NULL; |
84 | 84 | ||
85 | /* Set to 2 to allow both inbound and outbound traffic */ | 85 | /* Set to 2 to allow both inbound and outbound traffic */ |
86 | atomic_cmpxchg(&netDevice->RefCount, 0, 2); | 86 | atomic_cmpxchg(&net_device->RefCount, 0, 2); |
87 | 87 | ||
88 | netDevice->Device = Device; | 88 | net_device->Device = device; |
89 | Device->Extension = netDevice; | 89 | device->Extension = net_device; |
90 | 90 | ||
91 | return netDevice; | 91 | return net_device; |
92 | } | 92 | } |
93 | 93 | ||
94 | static void FreeNetDevice(struct netvsc_device *Device) | 94 | static void FreeNetDevice(struct netvsc_device *device) |
95 | { | 95 | { |
96 | WARN_ON(atomic_read(&Device->RefCount) == 0); | 96 | WARN_ON(atomic_read(&device->RefCount) == 0); |
97 | Device->Device->Extension = NULL; | 97 | device->Device->Extension = NULL; |
98 | kfree(Device); | 98 | kfree(device); |
99 | } | 99 | } |
100 | 100 | ||
101 | 101 | ||
102 | /* Get the net device object iff exists and its refcount > 1 */ | 102 | /* Get the net device object iff exists and its refcount > 1 */ |
103 | static struct netvsc_device *GetOutboundNetDevice(struct hv_device *Device) | 103 | static struct netvsc_device *GetOutboundNetDevice(struct hv_device *device) |
104 | { | 104 | { |
105 | struct netvsc_device *netDevice; | 105 | struct netvsc_device *net_device; |
106 | 106 | ||
107 | netDevice = Device->Extension; | 107 | net_device = device->Extension; |
108 | if (netDevice && atomic_read(&netDevice->RefCount) > 1) | 108 | if (net_device && atomic_read(&net_device->RefCount) > 1) |
109 | atomic_inc(&netDevice->RefCount); | 109 | atomic_inc(&net_device->RefCount); |
110 | else | 110 | else |
111 | netDevice = NULL; | 111 | net_device = NULL; |
112 | 112 | ||
113 | return netDevice; | 113 | return net_device; |
114 | } | 114 | } |
115 | 115 | ||
116 | /* Get the net device object iff exists and its refcount > 0 */ | 116 | /* Get the net device object iff exists and its refcount > 0 */ |
117 | static struct netvsc_device *GetInboundNetDevice(struct hv_device *Device) | 117 | static struct netvsc_device *GetInboundNetDevice(struct hv_device *device) |
118 | { | 118 | { |
119 | struct netvsc_device *netDevice; | 119 | struct netvsc_device *net_device; |
120 | 120 | ||
121 | netDevice = Device->Extension; | 121 | net_device = device->Extension; |
122 | if (netDevice && atomic_read(&netDevice->RefCount)) | 122 | if (net_device && atomic_read(&net_device->RefCount)) |
123 | atomic_inc(&netDevice->RefCount); | 123 | atomic_inc(&net_device->RefCount); |
124 | else | 124 | else |
125 | netDevice = NULL; | 125 | net_device = NULL; |
126 | 126 | ||
127 | return netDevice; | 127 | return net_device; |
128 | } | 128 | } |
129 | 129 | ||
130 | static void PutNetDevice(struct hv_device *Device) | 130 | static void PutNetDevice(struct hv_device *device) |
131 | { | 131 | { |
132 | struct netvsc_device *netDevice; | 132 | struct netvsc_device *net_device; |
133 | 133 | ||
134 | netDevice = Device->Extension; | 134 | net_device = device->Extension; |
135 | /* ASSERT(netDevice); */ | 135 | /* ASSERT(netDevice); */ |
136 | 136 | ||
137 | atomic_dec(&netDevice->RefCount); | 137 | atomic_dec(&net_device->RefCount); |
138 | } | 138 | } |
139 | 139 | ||
140 | static struct netvsc_device *ReleaseOutboundNetDevice(struct hv_device *Device) | 140 | static struct netvsc_device *ReleaseOutboundNetDevice(struct hv_device *device) |
141 | { | 141 | { |
142 | struct netvsc_device *netDevice; | 142 | struct netvsc_device *net_device; |
143 | 143 | ||
144 | netDevice = Device->Extension; | 144 | net_device = device->Extension; |
145 | if (netDevice == NULL) | 145 | if (net_device == NULL) |
146 | return NULL; | 146 | return NULL; |
147 | 147 | ||
148 | /* Busy wait until the ref drop to 2, then set it to 1 */ | 148 | /* Busy wait until the ref drop to 2, then set it to 1 */ |
149 | while (atomic_cmpxchg(&netDevice->RefCount, 2, 1) != 2) | 149 | while (atomic_cmpxchg(&net_device->RefCount, 2, 1) != 2) |
150 | udelay(100); | 150 | udelay(100); |
151 | 151 | ||
152 | return netDevice; | 152 | return net_device; |
153 | } | 153 | } |
154 | 154 | ||
155 | static struct netvsc_device *ReleaseInboundNetDevice(struct hv_device *Device) | 155 | static struct netvsc_device *ReleaseInboundNetDevice(struct hv_device *device) |
156 | { | 156 | { |
157 | struct netvsc_device *netDevice; | 157 | struct netvsc_device *net_device; |
158 | 158 | ||
159 | netDevice = Device->Extension; | 159 | net_device = device->Extension; |
160 | if (netDevice == NULL) | 160 | if (net_device == NULL) |
161 | return NULL; | 161 | return NULL; |
162 | 162 | ||
163 | /* Busy wait until the ref drop to 1, then set it to 0 */ | 163 | /* Busy wait until the ref drop to 1, then set it to 0 */ |
164 | while (atomic_cmpxchg(&netDevice->RefCount, 1, 0) != 1) | 164 | while (atomic_cmpxchg(&net_device->RefCount, 1, 0) != 1) |
165 | udelay(100); | 165 | udelay(100); |
166 | 166 | ||
167 | Device->Extension = NULL; | 167 | device->Extension = NULL; |
168 | return netDevice; | 168 | return net_device; |
169 | } | 169 | } |
170 | 170 | ||
171 | /* | 171 | /* |
@@ -185,8 +185,8 @@ int NetVscInitialize(struct hv_driver *drv) | |||
185 | /* Make sure we are at least 2 pages since 1 page is used for control */ | 185 | /* Make sure we are at least 2 pages since 1 page is used for control */ |
186 | /* ASSERT(driver->RingBufferSize >= (PAGE_SIZE << 1)); */ | 186 | /* ASSERT(driver->RingBufferSize >= (PAGE_SIZE << 1)); */ |
187 | 187 | ||
188 | drv->name = gDriverName; | 188 | drv->name = driver_name; |
189 | memcpy(&drv->deviceType, &gNetVscDeviceType, sizeof(struct hv_guid)); | 189 | memcpy(&drv->deviceType, &netvsc_device_type, sizeof(struct hv_guid)); |
190 | 190 | ||
191 | /* Make sure it is set by the caller */ | 191 | /* Make sure it is set by the caller */ |
192 | /* FIXME: These probably should still be tested in some way */ | 192 | /* FIXME: These probably should still be tested in some way */ |
@@ -204,14 +204,14 @@ int NetVscInitialize(struct hv_driver *drv) | |||
204 | return 0; | 204 | return 0; |
205 | } | 205 | } |
206 | 206 | ||
207 | static int NetVscInitializeReceiveBufferWithNetVsp(struct hv_device *Device) | 207 | static int NetVscInitializeReceiveBufferWithNetVsp(struct hv_device *device) |
208 | { | 208 | { |
209 | int ret = 0; | 209 | int ret = 0; |
210 | struct netvsc_device *netDevice; | 210 | struct netvsc_device *net_device; |
211 | struct nvsp_message *initPacket; | 211 | struct nvsp_message *init_packet; |
212 | 212 | ||
213 | netDevice = GetOutboundNetDevice(Device); | 213 | net_device = GetOutboundNetDevice(device); |
214 | if (!netDevice) { | 214 | if (!net_device) { |
215 | DPRINT_ERR(NETVSC, "unable to get net device..." | 215 | DPRINT_ERR(NETVSC, "unable to get net device..." |
216 | "device being destroyed?"); | 216 | "device being destroyed?"); |
217 | return -1; | 217 | return -1; |
@@ -220,12 +220,12 @@ static int NetVscInitializeReceiveBufferWithNetVsp(struct hv_device *Device) | |||
220 | /* page-size grandularity */ | 220 | /* page-size grandularity */ |
221 | /* ASSERT((netDevice->ReceiveBufferSize & (PAGE_SIZE - 1)) == 0); */ | 221 | /* ASSERT((netDevice->ReceiveBufferSize & (PAGE_SIZE - 1)) == 0); */ |
222 | 222 | ||
223 | netDevice->ReceiveBuffer = | 223 | net_device->ReceiveBuffer = |
224 | osd_page_alloc(netDevice->ReceiveBufferSize >> PAGE_SHIFT); | 224 | osd_page_alloc(net_device->ReceiveBufferSize >> PAGE_SHIFT); |
225 | if (!netDevice->ReceiveBuffer) { | 225 | if (!net_device->ReceiveBuffer) { |
226 | DPRINT_ERR(NETVSC, | 226 | DPRINT_ERR(NETVSC, |
227 | "unable to allocate receive buffer of size %d", | 227 | "unable to allocate receive buffer of size %d", |
228 | netDevice->ReceiveBufferSize); | 228 | net_device->ReceiveBufferSize); |
229 | ret = -1; | 229 | ret = -1; |
230 | goto Cleanup; | 230 | goto Cleanup; |
231 | } | 231 | } |
@@ -240,9 +240,9 @@ static int NetVscInitializeReceiveBufferWithNetVsp(struct hv_device *Device) | |||
240 | * channel. Note: This call uses the vmbus connection rather | 240 | * channel. Note: This call uses the vmbus connection rather |
241 | * than the channel to establish the gpadl handle. | 241 | * than the channel to establish the gpadl handle. |
242 | */ | 242 | */ |
243 | ret = vmbus_establish_gpadl(Device->channel, netDevice->ReceiveBuffer, | 243 | ret = vmbus_establish_gpadl(device->channel, net_device->ReceiveBuffer, |
244 | netDevice->ReceiveBufferSize, | 244 | net_device->ReceiveBufferSize, |
245 | &netDevice->ReceiveBufferGpadlHandle); | 245 | &net_device->ReceiveBufferGpadlHandle); |
246 | if (ret != 0) { | 246 | if (ret != 0) { |
247 | DPRINT_ERR(NETVSC, | 247 | DPRINT_ERR(NETVSC, |
248 | "unable to establish receive buffer's gpadl"); | 248 | "unable to establish receive buffer's gpadl"); |
@@ -254,18 +254,20 @@ static int NetVscInitializeReceiveBufferWithNetVsp(struct hv_device *Device) | |||
254 | /* Notify the NetVsp of the gpadl handle */ | 254 | /* Notify the NetVsp of the gpadl handle */ |
255 | DPRINT_INFO(NETVSC, "Sending NvspMessage1TypeSendReceiveBuffer..."); | 255 | DPRINT_INFO(NETVSC, "Sending NvspMessage1TypeSendReceiveBuffer..."); |
256 | 256 | ||
257 | initPacket = &netDevice->ChannelInitPacket; | 257 | init_packet = &net_device->ChannelInitPacket; |
258 | 258 | ||
259 | memset(initPacket, 0, sizeof(struct nvsp_message)); | 259 | memset(init_packet, 0, sizeof(struct nvsp_message)); |
260 | 260 | ||
261 | initPacket->Header.MessageType = NvspMessage1TypeSendReceiveBuffer; | 261 | init_packet->Header.MessageType = NvspMessage1TypeSendReceiveBuffer; |
262 | initPacket->Messages.Version1Messages.SendReceiveBuffer.GpadlHandle = netDevice->ReceiveBufferGpadlHandle; | 262 | init_packet->Messages.Version1Messages.SendReceiveBuffer. |
263 | initPacket->Messages.Version1Messages.SendReceiveBuffer.Id = NETVSC_RECEIVE_BUFFER_ID; | 263 | GpadlHandle = net_device->ReceiveBufferGpadlHandle; |
264 | init_packet->Messages.Version1Messages. | ||
265 | SendReceiveBuffer.Id = NETVSC_RECEIVE_BUFFER_ID; | ||
264 | 266 | ||
265 | /* Send the gpadl notification request */ | 267 | /* Send the gpadl notification request */ |
266 | ret = vmbus_sendpacket(Device->channel, initPacket, | 268 | ret = vmbus_sendpacket(device->channel, init_packet, |
267 | sizeof(struct nvsp_message), | 269 | sizeof(struct nvsp_message), |
268 | (unsigned long)initPacket, | 270 | (unsigned long)init_packet, |
269 | VmbusPacketTypeDataInBand, | 271 | VmbusPacketTypeDataInBand, |
270 | VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); | 272 | VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); |
271 | if (ret != 0) { | 273 | if (ret != 0) { |
@@ -274,13 +276,15 @@ static int NetVscInitializeReceiveBufferWithNetVsp(struct hv_device *Device) | |||
274 | goto Cleanup; | 276 | goto Cleanup; |
275 | } | 277 | } |
276 | 278 | ||
277 | osd_waitevent_wait(netDevice->ChannelInitEvent); | 279 | osd_waitevent_wait(net_device->ChannelInitEvent); |
278 | 280 | ||
279 | /* Check the response */ | 281 | /* Check the response */ |
280 | if (initPacket->Messages.Version1Messages.SendReceiveBufferComplete.Status != NvspStatusSuccess) { | 282 | if (init_packet->Messages.Version1Messages. |
283 | SendReceiveBufferComplete.Status != NvspStatusSuccess) { | ||
281 | DPRINT_ERR(NETVSC, "Unable to complete receive buffer " | 284 | DPRINT_ERR(NETVSC, "Unable to complete receive buffer " |
282 | "initialzation with NetVsp - status %d", | 285 | "initialzation with NetVsp - status %d", |
283 | initPacket->Messages.Version1Messages.SendReceiveBufferComplete.Status); | 286 | init_packet->Messages.Version1Messages. |
287 | SendReceiveBufferComplete.Status); | ||
284 | ret = -1; | 288 | ret = -1; |
285 | goto Cleanup; | 289 | goto Cleanup; |
286 | } | 290 | } |
@@ -289,32 +293,36 @@ static int NetVscInitializeReceiveBufferWithNetVsp(struct hv_device *Device) | |||
289 | /* ASSERT(netDevice->ReceiveSectionCount == 0); */ | 293 | /* ASSERT(netDevice->ReceiveSectionCount == 0); */ |
290 | /* ASSERT(netDevice->ReceiveSections == NULL); */ | 294 | /* ASSERT(netDevice->ReceiveSections == NULL); */ |
291 | 295 | ||
292 | netDevice->ReceiveSectionCount = initPacket->Messages.Version1Messages.SendReceiveBufferComplete.NumSections; | 296 | net_device->ReceiveSectionCount = init_packet->Messages. |
297 | Version1Messages.SendReceiveBufferComplete.NumSections; | ||
293 | 298 | ||
294 | netDevice->ReceiveSections = kmalloc(netDevice->ReceiveSectionCount * sizeof(struct nvsp_1_receive_buffer_section), GFP_KERNEL); | 299 | net_device->ReceiveSections = kmalloc(net_device->ReceiveSectionCount |
295 | if (netDevice->ReceiveSections == NULL) { | 300 | * sizeof(struct nvsp_1_receive_buffer_section), GFP_KERNEL); |
301 | if (net_device->ReceiveSections == NULL) { | ||
296 | ret = -1; | 302 | ret = -1; |
297 | goto Cleanup; | 303 | goto Cleanup; |
298 | } | 304 | } |
299 | 305 | ||
300 | memcpy(netDevice->ReceiveSections, | 306 | memcpy(net_device->ReceiveSections, |
301 | initPacket->Messages.Version1Messages.SendReceiveBufferComplete.Sections, | 307 | init_packet->Messages.Version1Messages. |
302 | netDevice->ReceiveSectionCount * sizeof(struct nvsp_1_receive_buffer_section)); | 308 | SendReceiveBufferComplete.Sections, |
309 | net_device->ReceiveSectionCount * | ||
310 | sizeof(struct nvsp_1_receive_buffer_section)); | ||
303 | 311 | ||
304 | DPRINT_INFO(NETVSC, "Receive sections info (count %d, offset %d, " | 312 | DPRINT_INFO(NETVSC, "Receive sections info (count %d, offset %d, " |
305 | "endoffset %d, suballoc size %d, num suballocs %d)", | 313 | "endoffset %d, suballoc size %d, num suballocs %d)", |
306 | netDevice->ReceiveSectionCount, | 314 | net_device->ReceiveSectionCount, |
307 | netDevice->ReceiveSections[0].Offset, | 315 | net_device->ReceiveSections[0].Offset, |
308 | netDevice->ReceiveSections[0].EndOffset, | 316 | net_device->ReceiveSections[0].EndOffset, |
309 | netDevice->ReceiveSections[0].SubAllocationSize, | 317 | net_device->ReceiveSections[0].SubAllocationSize, |
310 | netDevice->ReceiveSections[0].NumSubAllocations); | 318 | net_device->ReceiveSections[0].NumSubAllocations); |
311 | 319 | ||
312 | /* | 320 | /* |
313 | * For 1st release, there should only be 1 section that represents the | 321 | * For 1st release, there should only be 1 section that represents the |
314 | * entire receive buffer | 322 | * entire receive buffer |
315 | */ | 323 | */ |
316 | if (netDevice->ReceiveSectionCount != 1 || | 324 | if (net_device->ReceiveSectionCount != 1 || |
317 | netDevice->ReceiveSections->Offset != 0) { | 325 | net_device->ReceiveSections->Offset != 0) { |
318 | ret = -1; | 326 | ret = -1; |
319 | goto Cleanup; | 327 | goto Cleanup; |
320 | } | 328 | } |
@@ -322,26 +330,26 @@ static int NetVscInitializeReceiveBufferWithNetVsp(struct hv_device *Device) | |||
322 | goto Exit; | 330 | goto Exit; |
323 | 331 | ||
324 | Cleanup: | 332 | Cleanup: |
325 | NetVscDestroyReceiveBuffer(netDevice); | 333 | NetVscDestroyReceiveBuffer(net_device); |
326 | 334 | ||
327 | Exit: | 335 | Exit: |
328 | PutNetDevice(Device); | 336 | PutNetDevice(device); |
329 | return ret; | 337 | return ret; |
330 | } | 338 | } |
331 | 339 | ||
332 | static int NetVscInitializeSendBufferWithNetVsp(struct hv_device *Device) | 340 | static int NetVscInitializeSendBufferWithNetVsp(struct hv_device *device) |
333 | { | 341 | { |
334 | int ret = 0; | 342 | int ret = 0; |
335 | struct netvsc_device *netDevice; | 343 | struct netvsc_device *net_device; |
336 | struct nvsp_message *initPacket; | 344 | struct nvsp_message *init_packet; |
337 | 345 | ||
338 | netDevice = GetOutboundNetDevice(Device); | 346 | net_device = GetOutboundNetDevice(device); |
339 | if (!netDevice) { | 347 | if (!net_device) { |
340 | DPRINT_ERR(NETVSC, "unable to get net device..." | 348 | DPRINT_ERR(NETVSC, "unable to get net device..." |
341 | "device being destroyed?"); | 349 | "device being destroyed?"); |
342 | return -1; | 350 | return -1; |
343 | } | 351 | } |
344 | if (netDevice->SendBufferSize <= 0) { | 352 | if (net_device->SendBufferSize <= 0) { |
345 | ret = -EINVAL; | 353 | ret = -EINVAL; |
346 | goto Cleanup; | 354 | goto Cleanup; |
347 | } | 355 | } |
@@ -349,11 +357,11 @@ static int NetVscInitializeSendBufferWithNetVsp(struct hv_device *Device) | |||
349 | /* page-size grandularity */ | 357 | /* page-size grandularity */ |
350 | /* ASSERT((netDevice->SendBufferSize & (PAGE_SIZE - 1)) == 0); */ | 358 | /* ASSERT((netDevice->SendBufferSize & (PAGE_SIZE - 1)) == 0); */ |
351 | 359 | ||
352 | netDevice->SendBuffer = | 360 | net_device->SendBuffer = |
353 | osd_page_alloc(netDevice->SendBufferSize >> PAGE_SHIFT); | 361 | osd_page_alloc(net_device->SendBufferSize >> PAGE_SHIFT); |
354 | if (!netDevice->SendBuffer) { | 362 | if (!net_device->SendBuffer) { |
355 | DPRINT_ERR(NETVSC, "unable to allocate send buffer of size %d", | 363 | DPRINT_ERR(NETVSC, "unable to allocate send buffer of size %d", |
356 | netDevice->SendBufferSize); | 364 | net_device->SendBufferSize); |
357 | ret = -1; | 365 | ret = -1; |
358 | goto Cleanup; | 366 | goto Cleanup; |
359 | } | 367 | } |
@@ -367,9 +375,9 @@ static int NetVscInitializeSendBufferWithNetVsp(struct hv_device *Device) | |||
367 | * channel. Note: This call uses the vmbus connection rather | 375 | * channel. Note: This call uses the vmbus connection rather |
368 | * than the channel to establish the gpadl handle. | 376 | * than the channel to establish the gpadl handle. |
369 | */ | 377 | */ |
370 | ret = vmbus_establish_gpadl(Device->channel, netDevice->SendBuffer, | 378 | ret = vmbus_establish_gpadl(device->channel, net_device->SendBuffer, |
371 | netDevice->SendBufferSize, | 379 | net_device->SendBufferSize, |
372 | &netDevice->SendBufferGpadlHandle); | 380 | &net_device->SendBufferGpadlHandle); |
373 | if (ret != 0) { | 381 | if (ret != 0) { |
374 | DPRINT_ERR(NETVSC, "unable to establish send buffer's gpadl"); | 382 | DPRINT_ERR(NETVSC, "unable to establish send buffer's gpadl"); |
375 | goto Cleanup; | 383 | goto Cleanup; |
@@ -380,18 +388,20 @@ static int NetVscInitializeSendBufferWithNetVsp(struct hv_device *Device) | |||
380 | /* Notify the NetVsp of the gpadl handle */ | 388 | /* Notify the NetVsp of the gpadl handle */ |
381 | DPRINT_INFO(NETVSC, "Sending NvspMessage1TypeSendSendBuffer..."); | 389 | DPRINT_INFO(NETVSC, "Sending NvspMessage1TypeSendSendBuffer..."); |
382 | 390 | ||
383 | initPacket = &netDevice->ChannelInitPacket; | 391 | init_packet = &net_device->ChannelInitPacket; |
384 | 392 | ||
385 | memset(initPacket, 0, sizeof(struct nvsp_message)); | 393 | memset(init_packet, 0, sizeof(struct nvsp_message)); |
386 | 394 | ||
387 | initPacket->Header.MessageType = NvspMessage1TypeSendSendBuffer; | 395 | init_packet->Header.MessageType = NvspMessage1TypeSendSendBuffer; |
388 | initPacket->Messages.Version1Messages.SendReceiveBuffer.GpadlHandle = netDevice->SendBufferGpadlHandle; | 396 | init_packet->Messages.Version1Messages.SendReceiveBuffer. |
389 | initPacket->Messages.Version1Messages.SendReceiveBuffer.Id = NETVSC_SEND_BUFFER_ID; | 397 | GpadlHandle = net_device->SendBufferGpadlHandle; |
398 | init_packet->Messages.Version1Messages.SendReceiveBuffer.Id = | ||
399 | NETVSC_SEND_BUFFER_ID; | ||
390 | 400 | ||
391 | /* Send the gpadl notification request */ | 401 | /* Send the gpadl notification request */ |
392 | ret = vmbus_sendpacket(Device->channel, initPacket, | 402 | ret = vmbus_sendpacket(device->channel, init_packet, |
393 | sizeof(struct nvsp_message), | 403 | sizeof(struct nvsp_message), |
394 | (unsigned long)initPacket, | 404 | (unsigned long)init_packet, |
395 | VmbusPacketTypeDataInBand, | 405 | VmbusPacketTypeDataInBand, |
396 | VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); | 406 | VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); |
397 | if (ret != 0) { | 407 | if (ret != 0) { |
@@ -400,32 +410,35 @@ static int NetVscInitializeSendBufferWithNetVsp(struct hv_device *Device) | |||
400 | goto Cleanup; | 410 | goto Cleanup; |
401 | } | 411 | } |
402 | 412 | ||
403 | osd_waitevent_wait(netDevice->ChannelInitEvent); | 413 | osd_waitevent_wait(net_device->ChannelInitEvent); |
404 | 414 | ||
405 | /* Check the response */ | 415 | /* Check the response */ |
406 | if (initPacket->Messages.Version1Messages.SendSendBufferComplete.Status != NvspStatusSuccess) { | 416 | if (init_packet->Messages.Version1Messages. |
417 | SendSendBufferComplete.Status != NvspStatusSuccess) { | ||
407 | DPRINT_ERR(NETVSC, "Unable to complete send buffer " | 418 | DPRINT_ERR(NETVSC, "Unable to complete send buffer " |
408 | "initialzation with NetVsp - status %d", | 419 | "initialzation with NetVsp - status %d", |
409 | initPacket->Messages.Version1Messages.SendSendBufferComplete.Status); | 420 | init_packet->Messages.Version1Messages. |
421 | SendSendBufferComplete.Status); | ||
410 | ret = -1; | 422 | ret = -1; |
411 | goto Cleanup; | 423 | goto Cleanup; |
412 | } | 424 | } |
413 | 425 | ||
414 | netDevice->SendSectionSize = initPacket->Messages.Version1Messages.SendSendBufferComplete.SectionSize; | 426 | net_device->SendSectionSize = init_packet-> |
427 | Messages.Version1Messages.SendSendBufferComplete.SectionSize; | ||
415 | 428 | ||
416 | goto Exit; | 429 | goto Exit; |
417 | 430 | ||
418 | Cleanup: | 431 | Cleanup: |
419 | NetVscDestroySendBuffer(netDevice); | 432 | NetVscDestroySendBuffer(net_device); |
420 | 433 | ||
421 | Exit: | 434 | Exit: |
422 | PutNetDevice(Device); | 435 | PutNetDevice(device); |
423 | return ret; | 436 | return ret; |
424 | } | 437 | } |
425 | 438 | ||
426 | static int NetVscDestroyReceiveBuffer(struct netvsc_device *NetDevice) | 439 | static int NetVscDestroyReceiveBuffer(struct netvsc_device *net_device) |
427 | { | 440 | { |
428 | struct nvsp_message *revokePacket; | 441 | struct nvsp_message *revoke_packet; |
429 | int ret = 0; | 442 | int ret = 0; |
430 | 443 | ||
431 | /* | 444 | /* |
@@ -434,20 +447,23 @@ static int NetVscDestroyReceiveBuffer(struct netvsc_device *NetDevice) | |||
434 | * NvspMessage1TypeSendReceiveBuffer msg) therefore, we need | 447 | * NvspMessage1TypeSendReceiveBuffer msg) therefore, we need |
435 | * to send a revoke msg here | 448 | * to send a revoke msg here |
436 | */ | 449 | */ |
437 | if (NetDevice->ReceiveSectionCount) { | 450 | if (net_device->ReceiveSectionCount) { |
438 | DPRINT_INFO(NETVSC, | 451 | DPRINT_INFO(NETVSC, |
439 | "Sending NvspMessage1TypeRevokeReceiveBuffer..."); | 452 | "Sending NvspMessage1TypeRevokeReceiveBuffer..."); |
440 | 453 | ||
441 | /* Send the revoke receive buffer */ | 454 | /* Send the revoke receive buffer */ |
442 | revokePacket = &NetDevice->RevokePacket; | 455 | revoke_packet = &net_device->RevokePacket; |
443 | memset(revokePacket, 0, sizeof(struct nvsp_message)); | 456 | memset(revoke_packet, 0, sizeof(struct nvsp_message)); |
444 | 457 | ||
445 | revokePacket->Header.MessageType = NvspMessage1TypeRevokeReceiveBuffer; | 458 | revoke_packet->Header.MessageType = |
446 | revokePacket->Messages.Version1Messages.RevokeReceiveBuffer.Id = NETVSC_RECEIVE_BUFFER_ID; | 459 | NvspMessage1TypeRevokeReceiveBuffer; |
460 | revoke_packet->Messages.Version1Messages. | ||
461 | RevokeReceiveBuffer.Id = NETVSC_RECEIVE_BUFFER_ID; | ||
447 | 462 | ||
448 | ret = vmbus_sendpacket(NetDevice->Device->channel, revokePacket, | 463 | ret = vmbus_sendpacket(net_device->Device->channel, |
464 | revoke_packet, | ||
449 | sizeof(struct nvsp_message), | 465 | sizeof(struct nvsp_message), |
450 | (unsigned long)revokePacket, | 466 | (unsigned long)revoke_packet, |
451 | VmbusPacketTypeDataInBand, 0); | 467 | VmbusPacketTypeDataInBand, 0); |
452 | /* | 468 | /* |
453 | * If we failed here, we might as well return and | 469 | * If we failed here, we might as well return and |
@@ -461,11 +477,11 @@ static int NetVscDestroyReceiveBuffer(struct netvsc_device *NetDevice) | |||
461 | } | 477 | } |
462 | 478 | ||
463 | /* Teardown the gpadl on the vsp end */ | 479 | /* Teardown the gpadl on the vsp end */ |
464 | if (NetDevice->ReceiveBufferGpadlHandle) { | 480 | if (net_device->ReceiveBufferGpadlHandle) { |
465 | DPRINT_INFO(NETVSC, "Tearing down receive buffer's GPADL..."); | 481 | DPRINT_INFO(NETVSC, "Tearing down receive buffer's GPADL..."); |
466 | 482 | ||
467 | ret = vmbus_teardown_gpadl(NetDevice->Device->channel, | 483 | ret = vmbus_teardown_gpadl(net_device->Device->channel, |
468 | NetDevice->ReceiveBufferGpadlHandle); | 484 | net_device->ReceiveBufferGpadlHandle); |
469 | 485 | ||
470 | /* If we failed here, we might as well return and have a leak rather than continue and a bugchk */ | 486 | /* If we failed here, we might as well return and have a leak rather than continue and a bugchk */ |
471 | if (ret != 0) { | 487 | if (ret != 0) { |
@@ -473,30 +489,30 @@ static int NetVscDestroyReceiveBuffer(struct netvsc_device *NetDevice) | |||
473 | "unable to teardown receive buffer's gpadl"); | 489 | "unable to teardown receive buffer's gpadl"); |
474 | return -1; | 490 | return -1; |
475 | } | 491 | } |
476 | NetDevice->ReceiveBufferGpadlHandle = 0; | 492 | net_device->ReceiveBufferGpadlHandle = 0; |
477 | } | 493 | } |
478 | 494 | ||
479 | if (NetDevice->ReceiveBuffer) { | 495 | if (net_device->ReceiveBuffer) { |
480 | DPRINT_INFO(NETVSC, "Freeing up receive buffer..."); | 496 | DPRINT_INFO(NETVSC, "Freeing up receive buffer..."); |
481 | 497 | ||
482 | /* Free up the receive buffer */ | 498 | /* Free up the receive buffer */ |
483 | osd_page_free(NetDevice->ReceiveBuffer, | 499 | osd_page_free(net_device->ReceiveBuffer, |
484 | NetDevice->ReceiveBufferSize >> PAGE_SHIFT); | 500 | net_device->ReceiveBufferSize >> PAGE_SHIFT); |
485 | NetDevice->ReceiveBuffer = NULL; | 501 | net_device->ReceiveBuffer = NULL; |
486 | } | 502 | } |
487 | 503 | ||
488 | if (NetDevice->ReceiveSections) { | 504 | if (net_device->ReceiveSections) { |
489 | NetDevice->ReceiveSectionCount = 0; | 505 | net_device->ReceiveSectionCount = 0; |
490 | kfree(NetDevice->ReceiveSections); | 506 | kfree(net_device->ReceiveSections); |
491 | NetDevice->ReceiveSections = NULL; | 507 | net_device->ReceiveSections = NULL; |
492 | } | 508 | } |
493 | 509 | ||
494 | return ret; | 510 | return ret; |
495 | } | 511 | } |
496 | 512 | ||
497 | static int NetVscDestroySendBuffer(struct netvsc_device *NetDevice) | 513 | static int NetVscDestroySendBuffer(struct netvsc_device *net_device) |
498 | { | 514 | { |
499 | struct nvsp_message *revokePacket; | 515 | struct nvsp_message *revoke_packet; |
500 | int ret = 0; | 516 | int ret = 0; |
501 | 517 | ||
502 | /* | 518 | /* |
@@ -505,20 +521,23 @@ static int NetVscDestroySendBuffer(struct netvsc_device *NetDevice) | |||
505 | * NvspMessage1TypeSendReceiveBuffer msg) therefore, we need | 521 | * NvspMessage1TypeSendReceiveBuffer msg) therefore, we need |
506 | * to send a revoke msg here | 522 | * to send a revoke msg here |
507 | */ | 523 | */ |
508 | if (NetDevice->SendSectionSize) { | 524 | if (net_device->SendSectionSize) { |
509 | DPRINT_INFO(NETVSC, | 525 | DPRINT_INFO(NETVSC, |
510 | "Sending NvspMessage1TypeRevokeSendBuffer..."); | 526 | "Sending NvspMessage1TypeRevokeSendBuffer..."); |
511 | 527 | ||
512 | /* Send the revoke send buffer */ | 528 | /* Send the revoke send buffer */ |
513 | revokePacket = &NetDevice->RevokePacket; | 529 | revoke_packet = &net_device->RevokePacket; |
514 | memset(revokePacket, 0, sizeof(struct nvsp_message)); | 530 | memset(revoke_packet, 0, sizeof(struct nvsp_message)); |
515 | 531 | ||
516 | revokePacket->Header.MessageType = NvspMessage1TypeRevokeSendBuffer; | 532 | revoke_packet->Header.MessageType = |
517 | revokePacket->Messages.Version1Messages.RevokeSendBuffer.Id = NETVSC_SEND_BUFFER_ID; | 533 | NvspMessage1TypeRevokeSendBuffer; |
534 | revoke_packet->Messages.Version1Messages. | ||
535 | RevokeSendBuffer.Id = NETVSC_SEND_BUFFER_ID; | ||
518 | 536 | ||
519 | ret = vmbus_sendpacket(NetDevice->Device->channel, revokePacket, | 537 | ret = vmbus_sendpacket(net_device->Device->channel, |
538 | revoke_packet, | ||
520 | sizeof(struct nvsp_message), | 539 | sizeof(struct nvsp_message), |
521 | (unsigned long)revokePacket, | 540 | (unsigned long)revoke_packet, |
522 | VmbusPacketTypeDataInBand, 0); | 541 | VmbusPacketTypeDataInBand, 0); |
523 | /* | 542 | /* |
524 | * If we failed here, we might as well return and have a leak | 543 | * If we failed here, we might as well return and have a leak |
@@ -532,10 +551,10 @@ static int NetVscDestroySendBuffer(struct netvsc_device *NetDevice) | |||
532 | } | 551 | } |
533 | 552 | ||
534 | /* Teardown the gpadl on the vsp end */ | 553 | /* Teardown the gpadl on the vsp end */ |
535 | if (NetDevice->SendBufferGpadlHandle) { | 554 | if (net_device->SendBufferGpadlHandle) { |
536 | DPRINT_INFO(NETVSC, "Tearing down send buffer's GPADL..."); | 555 | DPRINT_INFO(NETVSC, "Tearing down send buffer's GPADL..."); |
537 | ret = vmbus_teardown_gpadl(NetDevice->Device->channel, | 556 | ret = vmbus_teardown_gpadl(net_device->Device->channel, |
538 | NetDevice->SendBufferGpadlHandle); | 557 | net_device->SendBufferGpadlHandle); |
539 | 558 | ||
540 | /* | 559 | /* |
541 | * If we failed here, we might as well return and have a leak | 560 | * If we failed here, we might as well return and have a leak |
@@ -546,49 +565,51 @@ static int NetVscDestroySendBuffer(struct netvsc_device *NetDevice) | |||
546 | "gpadl"); | 565 | "gpadl"); |
547 | return -1; | 566 | return -1; |
548 | } | 567 | } |
549 | NetDevice->SendBufferGpadlHandle = 0; | 568 | net_device->SendBufferGpadlHandle = 0; |
550 | } | 569 | } |
551 | 570 | ||
552 | if (NetDevice->SendBuffer) { | 571 | if (net_device->SendBuffer) { |
553 | DPRINT_INFO(NETVSC, "Freeing up send buffer..."); | 572 | DPRINT_INFO(NETVSC, "Freeing up send buffer..."); |
554 | 573 | ||
555 | /* Free up the receive buffer */ | 574 | /* Free up the receive buffer */ |
556 | osd_page_free(NetDevice->SendBuffer, | 575 | osd_page_free(net_device->SendBuffer, |
557 | NetDevice->SendBufferSize >> PAGE_SHIFT); | 576 | net_device->SendBufferSize >> PAGE_SHIFT); |
558 | NetDevice->SendBuffer = NULL; | 577 | net_device->SendBuffer = NULL; |
559 | } | 578 | } |
560 | 579 | ||
561 | return ret; | 580 | return ret; |
562 | } | 581 | } |
563 | 582 | ||
564 | 583 | ||
565 | static int NetVscConnectToVsp(struct hv_device *Device) | 584 | static int NetVscConnectToVsp(struct hv_device *device) |
566 | { | 585 | { |
567 | int ret; | 586 | int ret; |
568 | struct netvsc_device *netDevice; | 587 | struct netvsc_device *net_device; |
569 | struct nvsp_message *initPacket; | 588 | struct nvsp_message *init_packet; |
570 | int ndisVersion; | 589 | int ndis_version; |
571 | 590 | ||
572 | netDevice = GetOutboundNetDevice(Device); | 591 | net_device = GetOutboundNetDevice(device); |
573 | if (!netDevice) { | 592 | if (!net_device) { |
574 | DPRINT_ERR(NETVSC, "unable to get net device..." | 593 | DPRINT_ERR(NETVSC, "unable to get net device..." |
575 | "device being destroyed?"); | 594 | "device being destroyed?"); |
576 | return -1; | 595 | return -1; |
577 | } | 596 | } |
578 | 597 | ||
579 | initPacket = &netDevice->ChannelInitPacket; | 598 | init_packet = &net_device->ChannelInitPacket; |
580 | 599 | ||
581 | memset(initPacket, 0, sizeof(struct nvsp_message)); | 600 | memset(init_packet, 0, sizeof(struct nvsp_message)); |
582 | initPacket->Header.MessageType = NvspMessageTypeInit; | 601 | init_packet->Header.MessageType = NvspMessageTypeInit; |
583 | initPacket->Messages.InitMessages.Init.MinProtocolVersion = NVSP_MIN_PROTOCOL_VERSION; | 602 | init_packet->Messages.InitMessages.Init.MinProtocolVersion = |
584 | initPacket->Messages.InitMessages.Init.MaxProtocolVersion = NVSP_MAX_PROTOCOL_VERSION; | 603 | NVSP_MIN_PROTOCOL_VERSION; |
604 | init_packet->Messages.InitMessages.Init.MaxProtocolVersion = | ||
605 | NVSP_MAX_PROTOCOL_VERSION; | ||
585 | 606 | ||
586 | DPRINT_INFO(NETVSC, "Sending NvspMessageTypeInit..."); | 607 | DPRINT_INFO(NETVSC, "Sending NvspMessageTypeInit..."); |
587 | 608 | ||
588 | /* Send the init request */ | 609 | /* Send the init request */ |
589 | ret = vmbus_sendpacket(Device->channel, initPacket, | 610 | ret = vmbus_sendpacket(device->channel, init_packet, |
590 | sizeof(struct nvsp_message), | 611 | sizeof(struct nvsp_message), |
591 | (unsigned long)initPacket, | 612 | (unsigned long)init_packet, |
592 | VmbusPacketTypeDataInBand, | 613 | VmbusPacketTypeDataInBand, |
593 | VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); | 614 | VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); |
594 | 615 | ||
@@ -597,47 +618,52 @@ static int NetVscConnectToVsp(struct hv_device *Device) | |||
597 | goto Cleanup; | 618 | goto Cleanup; |
598 | } | 619 | } |
599 | 620 | ||
600 | osd_waitevent_wait(netDevice->ChannelInitEvent); | 621 | osd_waitevent_wait(net_device->ChannelInitEvent); |
601 | 622 | ||
602 | /* Now, check the response */ | 623 | /* Now, check the response */ |
603 | /* ASSERT(initPacket->Messages.InitMessages.InitComplete.MaximumMdlChainLength <= MAX_MULTIPAGE_BUFFER_COUNT); */ | 624 | /* ASSERT(initPacket->Messages.InitMessages.InitComplete.MaximumMdlChainLength <= MAX_MULTIPAGE_BUFFER_COUNT); */ |
604 | DPRINT_INFO(NETVSC, "NvspMessageTypeInit status(%d) max mdl chain (%d)", | 625 | DPRINT_INFO(NETVSC, "NvspMessageTypeInit status(%d) max mdl chain (%d)", |
605 | initPacket->Messages.InitMessages.InitComplete.Status, | 626 | init_packet->Messages.InitMessages.InitComplete.Status, |
606 | initPacket->Messages.InitMessages.InitComplete.MaximumMdlChainLength); | 627 | init_packet->Messages.InitMessages. |
628 | InitComplete.MaximumMdlChainLength); | ||
607 | 629 | ||
608 | if (initPacket->Messages.InitMessages.InitComplete.Status != | 630 | if (init_packet->Messages.InitMessages.InitComplete.Status != |
609 | NvspStatusSuccess) { | 631 | NvspStatusSuccess) { |
610 | DPRINT_ERR(NETVSC, | 632 | DPRINT_ERR(NETVSC, |
611 | "unable to initialize with netvsp (status 0x%x)", | 633 | "unable to initialize with netvsp (status 0x%x)", |
612 | initPacket->Messages.InitMessages.InitComplete.Status); | 634 | init_packet->Messages.InitMessages.InitComplete.Status); |
613 | ret = -1; | 635 | ret = -1; |
614 | goto Cleanup; | 636 | goto Cleanup; |
615 | } | 637 | } |
616 | 638 | ||
617 | if (initPacket->Messages.InitMessages.InitComplete.NegotiatedProtocolVersion != NVSP_PROTOCOL_VERSION_1) { | 639 | if (init_packet->Messages.InitMessages.InitComplete. |
640 | NegotiatedProtocolVersion != NVSP_PROTOCOL_VERSION_1) { | ||
618 | DPRINT_ERR(NETVSC, "unable to initialize with netvsp " | 641 | DPRINT_ERR(NETVSC, "unable to initialize with netvsp " |
619 | "(version expected 1 got %d)", | 642 | "(version expected 1 got %d)", |
620 | initPacket->Messages.InitMessages.InitComplete.NegotiatedProtocolVersion); | 643 | init_packet->Messages.InitMessages. |
644 | InitComplete.NegotiatedProtocolVersion); | ||
621 | ret = -1; | 645 | ret = -1; |
622 | goto Cleanup; | 646 | goto Cleanup; |
623 | } | 647 | } |
624 | DPRINT_INFO(NETVSC, "Sending NvspMessage1TypeSendNdisVersion..."); | 648 | DPRINT_INFO(NETVSC, "Sending NvspMessage1TypeSendNdisVersion..."); |
625 | 649 | ||
626 | /* Send the ndis version */ | 650 | /* Send the ndis version */ |
627 | memset(initPacket, 0, sizeof(struct nvsp_message)); | 651 | memset(init_packet, 0, sizeof(struct nvsp_message)); |
628 | 652 | ||
629 | ndisVersion = 0x00050000; | 653 | ndis_version = 0x00050000; |
630 | 654 | ||
631 | initPacket->Header.MessageType = NvspMessage1TypeSendNdisVersion; | 655 | init_packet->Header.MessageType = NvspMessage1TypeSendNdisVersion; |
632 | initPacket->Messages.Version1Messages.SendNdisVersion.NdisMajorVersion = | 656 | init_packet->Messages.Version1Messages. |
633 | (ndisVersion & 0xFFFF0000) >> 16; | 657 | SendNdisVersion.NdisMajorVersion = |
634 | initPacket->Messages.Version1Messages.SendNdisVersion.NdisMinorVersion = | 658 | (ndis_version & 0xFFFF0000) >> 16; |
635 | ndisVersion & 0xFFFF; | 659 | init_packet->Messages.Version1Messages. |
660 | SendNdisVersion.NdisMinorVersion = | ||
661 | ndis_version & 0xFFFF; | ||
636 | 662 | ||
637 | /* Send the init request */ | 663 | /* Send the init request */ |
638 | ret = vmbus_sendpacket(Device->channel, initPacket, | 664 | ret = vmbus_sendpacket(device->channel, init_packet, |
639 | sizeof(struct nvsp_message), | 665 | sizeof(struct nvsp_message), |
640 | (unsigned long)initPacket, | 666 | (unsigned long)init_packet, |
641 | VmbusPacketTypeDataInBand, 0); | 667 | VmbusPacketTypeDataInBand, 0); |
642 | if (ret != 0) { | 668 | if (ret != 0) { |
643 | DPRINT_ERR(NETVSC, | 669 | DPRINT_ERR(NETVSC, |
@@ -654,48 +680,48 @@ static int NetVscConnectToVsp(struct hv_device *Device) | |||
654 | /* osd_waitevent_wait(NetVscChannel->ChannelInitEvent); */ | 680 | /* osd_waitevent_wait(NetVscChannel->ChannelInitEvent); */ |
655 | 681 | ||
656 | /* Post the big receive buffer to NetVSP */ | 682 | /* Post the big receive buffer to NetVSP */ |
657 | ret = NetVscInitializeReceiveBufferWithNetVsp(Device); | 683 | ret = NetVscInitializeReceiveBufferWithNetVsp(device); |
658 | if (ret == 0) | 684 | if (ret == 0) |
659 | ret = NetVscInitializeSendBufferWithNetVsp(Device); | 685 | ret = NetVscInitializeSendBufferWithNetVsp(device); |
660 | 686 | ||
661 | Cleanup: | 687 | Cleanup: |
662 | PutNetDevice(Device); | 688 | PutNetDevice(device); |
663 | return ret; | 689 | return ret; |
664 | } | 690 | } |
665 | 691 | ||
666 | static void NetVscDisconnectFromVsp(struct netvsc_device *NetDevice) | 692 | static void NetVscDisconnectFromVsp(struct netvsc_device *net_device) |
667 | { | 693 | { |
668 | NetVscDestroyReceiveBuffer(NetDevice); | 694 | NetVscDestroyReceiveBuffer(net_device); |
669 | NetVscDestroySendBuffer(NetDevice); | 695 | NetVscDestroySendBuffer(net_device); |
670 | } | 696 | } |
671 | 697 | ||
672 | /* | 698 | /* |
673 | * NetVscOnDeviceAdd - Callback when the device belonging to this driver is added | 699 | * NetVscOnDeviceAdd - Callback when the device belonging to this driver is added |
674 | */ | 700 | */ |
675 | static int NetVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo) | 701 | static int NetVscOnDeviceAdd(struct hv_device *device, void *additional_info) |
676 | { | 702 | { |
677 | int ret = 0; | 703 | int ret = 0; |
678 | int i; | 704 | int i; |
679 | struct netvsc_device *netDevice; | 705 | struct netvsc_device *net_device; |
680 | struct hv_netvsc_packet *packet, *pos; | 706 | struct hv_netvsc_packet *packet, *pos; |
681 | struct netvsc_driver *netDriver = | 707 | struct netvsc_driver *net_driver = |
682 | (struct netvsc_driver *)Device->Driver; | 708 | (struct netvsc_driver *)device->Driver; |
683 | 709 | ||
684 | netDevice = AllocNetDevice(Device); | 710 | net_device = AllocNetDevice(device); |
685 | if (!netDevice) { | 711 | if (!net_device) { |
686 | ret = -1; | 712 | ret = -1; |
687 | goto Cleanup; | 713 | goto Cleanup; |
688 | } | 714 | } |
689 | 715 | ||
690 | DPRINT_DBG(NETVSC, "netvsc channel object allocated - %p", netDevice); | 716 | DPRINT_DBG(NETVSC, "netvsc channel object allocated - %p", net_device); |
691 | 717 | ||
692 | /* Initialize the NetVSC channel extension */ | 718 | /* Initialize the NetVSC channel extension */ |
693 | netDevice->ReceiveBufferSize = NETVSC_RECEIVE_BUFFER_SIZE; | 719 | net_device->ReceiveBufferSize = NETVSC_RECEIVE_BUFFER_SIZE; |
694 | spin_lock_init(&netDevice->receive_packet_list_lock); | 720 | spin_lock_init(&net_device->receive_packet_list_lock); |
695 | 721 | ||
696 | netDevice->SendBufferSize = NETVSC_SEND_BUFFER_SIZE; | 722 | net_device->SendBufferSize = NETVSC_SEND_BUFFER_SIZE; |
697 | 723 | ||
698 | INIT_LIST_HEAD(&netDevice->ReceivePacketList); | 724 | INIT_LIST_HEAD(&net_device->ReceivePacketList); |
699 | 725 | ||
700 | for (i = 0; i < NETVSC_RECEIVE_PACKETLIST_COUNT; i++) { | 726 | for (i = 0; i < NETVSC_RECEIVE_PACKETLIST_COUNT; i++) { |
701 | packet = kzalloc(sizeof(struct hv_netvsc_packet) + | 727 | packet = kzalloc(sizeof(struct hv_netvsc_packet) + |
@@ -708,18 +734,18 @@ static int NetVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo) | |||
708 | break; | 734 | break; |
709 | } | 735 | } |
710 | list_add_tail(&packet->ListEntry, | 736 | list_add_tail(&packet->ListEntry, |
711 | &netDevice->ReceivePacketList); | 737 | &net_device->ReceivePacketList); |
712 | } | 738 | } |
713 | netDevice->ChannelInitEvent = osd_waitevent_create(); | 739 | net_device->ChannelInitEvent = osd_waitevent_create(); |
714 | if (!netDevice->ChannelInitEvent) { | 740 | if (!net_device->ChannelInitEvent) { |
715 | ret = -ENOMEM; | 741 | ret = -ENOMEM; |
716 | goto Cleanup; | 742 | goto Cleanup; |
717 | } | 743 | } |
718 | 744 | ||
719 | /* Open the channel */ | 745 | /* Open the channel */ |
720 | ret = vmbus_open(Device->channel, netDriver->RingBufferSize, | 746 | ret = vmbus_open(device->channel, net_driver->RingBufferSize, |
721 | netDriver->RingBufferSize, NULL, 0, | 747 | net_driver->RingBufferSize, NULL, 0, |
722 | NetVscOnChannelCallback, Device); | 748 | NetVscOnChannelCallback, device); |
723 | 749 | ||
724 | if (ret != 0) { | 750 | if (ret != 0) { |
725 | DPRINT_ERR(NETVSC, "unable to open channel: %d", ret); | 751 | DPRINT_ERR(NETVSC, "unable to open channel: %d", ret); |
@@ -731,7 +757,7 @@ static int NetVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo) | |||
731 | DPRINT_INFO(NETVSC, "*** NetVSC channel opened successfully! ***"); | 757 | DPRINT_INFO(NETVSC, "*** NetVSC channel opened successfully! ***"); |
732 | 758 | ||
733 | /* Connect with the NetVsp */ | 759 | /* Connect with the NetVsp */ |
734 | ret = NetVscConnectToVsp(Device); | 760 | ret = NetVscConnectToVsp(device); |
735 | if (ret != 0) { | 761 | if (ret != 0) { |
736 | DPRINT_ERR(NETVSC, "unable to connect to NetVSP - %d", ret); | 762 | DPRINT_ERR(NETVSC, "unable to connect to NetVSP - %d", ret); |
737 | ret = -1; | 763 | ret = -1; |
@@ -745,24 +771,24 @@ static int NetVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo) | |||
745 | 771 | ||
746 | close: | 772 | close: |
747 | /* Now, we can close the channel safely */ | 773 | /* Now, we can close the channel safely */ |
748 | vmbus_close(Device->channel); | 774 | vmbus_close(device->channel); |
749 | 775 | ||
750 | Cleanup: | 776 | Cleanup: |
751 | 777 | ||
752 | if (netDevice) { | 778 | if (net_device) { |
753 | kfree(netDevice->ChannelInitEvent); | 779 | kfree(net_device->ChannelInitEvent); |
754 | 780 | ||
755 | list_for_each_entry_safe(packet, pos, | 781 | list_for_each_entry_safe(packet, pos, |
756 | &netDevice->ReceivePacketList, | 782 | &net_device->ReceivePacketList, |
757 | ListEntry) { | 783 | ListEntry) { |
758 | list_del(&packet->ListEntry); | 784 | list_del(&packet->ListEntry); |
759 | kfree(packet); | 785 | kfree(packet); |
760 | } | 786 | } |
761 | 787 | ||
762 | ReleaseOutboundNetDevice(Device); | 788 | ReleaseOutboundNetDevice(device); |
763 | ReleaseInboundNetDevice(Device); | 789 | ReleaseInboundNetDevice(device); |
764 | 790 | ||
765 | FreeNetDevice(netDevice); | 791 | FreeNetDevice(net_device); |
766 | } | 792 | } |
767 | 793 | ||
768 | return ret; | 794 | return ret; |
@@ -771,53 +797,53 @@ Cleanup: | |||
771 | /* | 797 | /* |
772 | * NetVscOnDeviceRemove - Callback when the root bus device is removed | 798 | * NetVscOnDeviceRemove - Callback when the root bus device is removed |
773 | */ | 799 | */ |
774 | static int NetVscOnDeviceRemove(struct hv_device *Device) | 800 | static int NetVscOnDeviceRemove(struct hv_device *device) |
775 | { | 801 | { |
776 | struct netvsc_device *netDevice; | 802 | struct netvsc_device *net_device; |
777 | struct hv_netvsc_packet *netvscPacket, *pos; | 803 | struct hv_netvsc_packet *netvsc_packet, *pos; |
778 | 804 | ||
779 | DPRINT_INFO(NETVSC, "Disabling outbound traffic on net device (%p)...", | 805 | DPRINT_INFO(NETVSC, "Disabling outbound traffic on net device (%p)...", |
780 | Device->Extension); | 806 | device->Extension); |
781 | 807 | ||
782 | /* Stop outbound traffic ie sends and receives completions */ | 808 | /* Stop outbound traffic ie sends and receives completions */ |
783 | netDevice = ReleaseOutboundNetDevice(Device); | 809 | net_device = ReleaseOutboundNetDevice(device); |
784 | if (!netDevice) { | 810 | if (!net_device) { |
785 | DPRINT_ERR(NETVSC, "No net device present!!"); | 811 | DPRINT_ERR(NETVSC, "No net device present!!"); |
786 | return -1; | 812 | return -1; |
787 | } | 813 | } |
788 | 814 | ||
789 | /* Wait for all send completions */ | 815 | /* Wait for all send completions */ |
790 | while (atomic_read(&netDevice->NumOutstandingSends)) { | 816 | while (atomic_read(&net_device->NumOutstandingSends)) { |
791 | DPRINT_INFO(NETVSC, "waiting for %d requests to complete...", | 817 | DPRINT_INFO(NETVSC, "waiting for %d requests to complete...", |
792 | atomic_read(&netDevice->NumOutstandingSends)); | 818 | atomic_read(&net_device->NumOutstandingSends)); |
793 | udelay(100); | 819 | udelay(100); |
794 | } | 820 | } |
795 | 821 | ||
796 | DPRINT_INFO(NETVSC, "Disconnecting from netvsp..."); | 822 | DPRINT_INFO(NETVSC, "Disconnecting from netvsp..."); |
797 | 823 | ||
798 | NetVscDisconnectFromVsp(netDevice); | 824 | NetVscDisconnectFromVsp(net_device); |
799 | 825 | ||
800 | DPRINT_INFO(NETVSC, "Disabling inbound traffic on net device (%p)...", | 826 | DPRINT_INFO(NETVSC, "Disabling inbound traffic on net device (%p)...", |
801 | Device->Extension); | 827 | device->Extension); |
802 | 828 | ||
803 | /* Stop inbound traffic ie receives and sends completions */ | 829 | /* Stop inbound traffic ie receives and sends completions */ |
804 | netDevice = ReleaseInboundNetDevice(Device); | 830 | net_device = ReleaseInboundNetDevice(device); |
805 | 831 | ||
806 | /* At this point, no one should be accessing netDevice except in here */ | 832 | /* At this point, no one should be accessing netDevice except in here */ |
807 | DPRINT_INFO(NETVSC, "net device (%p) safe to remove", netDevice); | 833 | DPRINT_INFO(NETVSC, "net device (%p) safe to remove", net_device); |
808 | 834 | ||
809 | /* Now, we can close the channel safely */ | 835 | /* Now, we can close the channel safely */ |
810 | vmbus_close(Device->channel); | 836 | vmbus_close(device->channel); |
811 | 837 | ||
812 | /* Release all resources */ | 838 | /* Release all resources */ |
813 | list_for_each_entry_safe(netvscPacket, pos, | 839 | list_for_each_entry_safe(netvsc_packet, pos, |
814 | &netDevice->ReceivePacketList, ListEntry) { | 840 | &net_device->ReceivePacketList, ListEntry) { |
815 | list_del(&netvscPacket->ListEntry); | 841 | list_del(&netvsc_packet->ListEntry); |
816 | kfree(netvscPacket); | 842 | kfree(netvsc_packet); |
817 | } | 843 | } |
818 | 844 | ||
819 | kfree(netDevice->ChannelInitEvent); | 845 | kfree(net_device->ChannelInitEvent); |
820 | FreeNetDevice(netDevice); | 846 | FreeNetDevice(net_device); |
821 | return 0; | 847 | return 0; |
822 | } | 848 | } |
823 | 849 | ||
@@ -828,69 +854,72 @@ static void NetVscOnCleanup(struct hv_driver *drv) | |||
828 | { | 854 | { |
829 | } | 855 | } |
830 | 856 | ||
831 | static void NetVscOnSendCompletion(struct hv_device *Device, | 857 | static void NetVscOnSendCompletion(struct hv_device *device, |
832 | struct vmpacket_descriptor *Packet) | 858 | struct vmpacket_descriptor *packet) |
833 | { | 859 | { |
834 | struct netvsc_device *netDevice; | 860 | struct netvsc_device *net_device; |
835 | struct nvsp_message *nvspPacket; | 861 | struct nvsp_message *nvsp_packet; |
836 | struct hv_netvsc_packet *nvscPacket; | 862 | struct hv_netvsc_packet *nvsc_packet; |
837 | 863 | ||
838 | netDevice = GetInboundNetDevice(Device); | 864 | net_device = GetInboundNetDevice(device); |
839 | if (!netDevice) { | 865 | if (!net_device) { |
840 | DPRINT_ERR(NETVSC, "unable to get net device..." | 866 | DPRINT_ERR(NETVSC, "unable to get net device..." |
841 | "device being destroyed?"); | 867 | "device being destroyed?"); |
842 | return; | 868 | return; |
843 | } | 869 | } |
844 | 870 | ||
845 | nvspPacket = (struct nvsp_message *)((unsigned long)Packet + (Packet->DataOffset8 << 3)); | 871 | nvsp_packet = (struct nvsp_message *)((unsigned long)packet + |
872 | (packet->DataOffset8 << 3)); | ||
846 | 873 | ||
847 | DPRINT_DBG(NETVSC, "send completion packet - type %d", | 874 | DPRINT_DBG(NETVSC, "send completion packet - type %d", |
848 | nvspPacket->Header.MessageType); | 875 | nvsp_packet->Header.MessageType); |
849 | 876 | ||
850 | if ((nvspPacket->Header.MessageType == NvspMessageTypeInitComplete) || | 877 | if ((nvsp_packet->Header.MessageType == NvspMessageTypeInitComplete) || |
851 | (nvspPacket->Header.MessageType == | 878 | (nvsp_packet->Header.MessageType == |
852 | NvspMessage1TypeSendReceiveBufferComplete) || | 879 | NvspMessage1TypeSendReceiveBufferComplete) || |
853 | (nvspPacket->Header.MessageType == | 880 | (nvsp_packet->Header.MessageType == |
854 | NvspMessage1TypeSendSendBufferComplete)) { | 881 | NvspMessage1TypeSendSendBufferComplete)) { |
855 | /* Copy the response back */ | 882 | /* Copy the response back */ |
856 | memcpy(&netDevice->ChannelInitPacket, nvspPacket, | 883 | memcpy(&net_device->ChannelInitPacket, nvsp_packet, |
857 | sizeof(struct nvsp_message)); | 884 | sizeof(struct nvsp_message)); |
858 | osd_waitevent_set(netDevice->ChannelInitEvent); | 885 | osd_waitevent_set(net_device->ChannelInitEvent); |
859 | } else if (nvspPacket->Header.MessageType == | 886 | } else if (nvsp_packet->Header.MessageType == |
860 | NvspMessage1TypeSendRNDISPacketComplete) { | 887 | NvspMessage1TypeSendRNDISPacketComplete) { |
861 | /* Get the send context */ | 888 | /* Get the send context */ |
862 | nvscPacket = (struct hv_netvsc_packet *)(unsigned long)Packet->TransactionId; | 889 | nvsc_packet = (struct hv_netvsc_packet *)(unsigned long) |
890 | packet->TransactionId; | ||
863 | /* ASSERT(nvscPacket); */ | 891 | /* ASSERT(nvscPacket); */ |
864 | 892 | ||
865 | /* Notify the layer above us */ | 893 | /* Notify the layer above us */ |
866 | nvscPacket->Completion.Send.OnSendCompletion(nvscPacket->Completion.Send.SendCompletionContext); | 894 | nvsc_packet->Completion.Send.OnSendCompletion( |
895 | nvsc_packet->Completion.Send.SendCompletionContext); | ||
867 | 896 | ||
868 | atomic_dec(&netDevice->NumOutstandingSends); | 897 | atomic_dec(&net_device->NumOutstandingSends); |
869 | } else { | 898 | } else { |
870 | DPRINT_ERR(NETVSC, "Unknown send completion packet type - " | 899 | DPRINT_ERR(NETVSC, "Unknown send completion packet type - " |
871 | "%d received!!", nvspPacket->Header.MessageType); | 900 | "%d received!!", nvsp_packet->Header.MessageType); |
872 | } | 901 | } |
873 | 902 | ||
874 | PutNetDevice(Device); | 903 | PutNetDevice(device); |
875 | } | 904 | } |
876 | 905 | ||
877 | static int NetVscOnSend(struct hv_device *Device, | 906 | static int NetVscOnSend(struct hv_device *device, |
878 | struct hv_netvsc_packet *Packet) | 907 | struct hv_netvsc_packet *packet) |
879 | { | 908 | { |
880 | struct netvsc_device *netDevice; | 909 | struct netvsc_device *net_device; |
881 | int ret = 0; | 910 | int ret = 0; |
882 | 911 | ||
883 | struct nvsp_message sendMessage; | 912 | struct nvsp_message sendMessage; |
884 | 913 | ||
885 | netDevice = GetOutboundNetDevice(Device); | 914 | net_device = GetOutboundNetDevice(device); |
886 | if (!netDevice) { | 915 | if (!net_device) { |
887 | DPRINT_ERR(NETVSC, "net device (%p) shutting down..." | 916 | DPRINT_ERR(NETVSC, "net device (%p) shutting down..." |
888 | "ignoring outbound packets", netDevice); | 917 | "ignoring outbound packets", net_device); |
889 | return -2; | 918 | return -2; |
890 | } | 919 | } |
891 | 920 | ||
892 | sendMessage.Header.MessageType = NvspMessage1TypeSendRNDISPacket; | 921 | sendMessage.Header.MessageType = NvspMessage1TypeSendRNDISPacket; |
893 | if (Packet->IsDataPacket) { | 922 | if (packet->IsDataPacket) { |
894 | /* 0 is RMC_DATA; */ | 923 | /* 0 is RMC_DATA; */ |
895 | sendMessage.Messages.Version1Messages.SendRNDISPacket.ChannelType = 0; | 924 | sendMessage.Messages.Version1Messages.SendRNDISPacket.ChannelType = 0; |
896 | } else { | 925 | } else { |
@@ -902,17 +931,17 @@ static int NetVscOnSend(struct hv_device *Device, | |||
902 | sendMessage.Messages.Version1Messages.SendRNDISPacket.SendBufferSectionIndex = 0xFFFFFFFF; | 931 | sendMessage.Messages.Version1Messages.SendRNDISPacket.SendBufferSectionIndex = 0xFFFFFFFF; |
903 | sendMessage.Messages.Version1Messages.SendRNDISPacket.SendBufferSectionSize = 0; | 932 | sendMessage.Messages.Version1Messages.SendRNDISPacket.SendBufferSectionSize = 0; |
904 | 933 | ||
905 | if (Packet->PageBufferCount) { | 934 | if (packet->PageBufferCount) { |
906 | ret = vmbus_sendpacket_pagebuffer(Device->channel, | 935 | ret = vmbus_sendpacket_pagebuffer(device->channel, |
907 | Packet->PageBuffers, | 936 | packet->PageBuffers, |
908 | Packet->PageBufferCount, | 937 | packet->PageBufferCount, |
909 | &sendMessage, | 938 | &sendMessage, |
910 | sizeof(struct nvsp_message), | 939 | sizeof(struct nvsp_message), |
911 | (unsigned long)Packet); | 940 | (unsigned long)packet); |
912 | } else { | 941 | } else { |
913 | ret = vmbus_sendpacket(Device->channel, &sendMessage, | 942 | ret = vmbus_sendpacket(device->channel, &sendMessage, |
914 | sizeof(struct nvsp_message), | 943 | sizeof(struct nvsp_message), |
915 | (unsigned long)Packet, | 944 | (unsigned long)packet, |
916 | VmbusPacketTypeDataInBand, | 945 | VmbusPacketTypeDataInBand, |
917 | VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); | 946 | VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); |
918 | 947 | ||
@@ -920,31 +949,31 @@ static int NetVscOnSend(struct hv_device *Device, | |||
920 | 949 | ||
921 | if (ret != 0) | 950 | if (ret != 0) |
922 | DPRINT_ERR(NETVSC, "Unable to send packet %p ret %d", | 951 | DPRINT_ERR(NETVSC, "Unable to send packet %p ret %d", |
923 | Packet, ret); | 952 | packet, ret); |
924 | 953 | ||
925 | atomic_inc(&netDevice->NumOutstandingSends); | 954 | atomic_inc(&net_device->NumOutstandingSends); |
926 | PutNetDevice(Device); | 955 | PutNetDevice(device); |
927 | return ret; | 956 | return ret; |
928 | } | 957 | } |
929 | 958 | ||
930 | static void NetVscOnReceive(struct hv_device *Device, | 959 | static void NetVscOnReceive(struct hv_device *device, |
931 | struct vmpacket_descriptor *Packet) | 960 | struct vmpacket_descriptor *packet) |
932 | { | 961 | { |
933 | struct netvsc_device *netDevice; | 962 | struct netvsc_device *net_device; |
934 | struct vmtransfer_page_packet_header *vmxferpagePacket; | 963 | struct vmtransfer_page_packet_header *vmxferpage_packet; |
935 | struct nvsp_message *nvspPacket; | 964 | struct nvsp_message *nvsp_packet; |
936 | struct hv_netvsc_packet *netvscPacket = NULL; | 965 | struct hv_netvsc_packet *netvsc_packet = NULL; |
937 | unsigned long start; | 966 | unsigned long start; |
938 | unsigned long end, endVirtual; | 967 | unsigned long end, end_virtual; |
939 | /* struct netvsc_driver *netvscDriver; */ | 968 | /* struct netvsc_driver *netvscDriver; */ |
940 | struct xferpage_packet *xferpagePacket = NULL; | 969 | struct xferpage_packet *xferpage_packet = NULL; |
941 | int i, j; | 970 | int i, j; |
942 | int count = 0, bytesRemain = 0; | 971 | int count = 0, bytes_remain = 0; |
943 | unsigned long flags; | 972 | unsigned long flags; |
944 | LIST_HEAD(listHead); | 973 | LIST_HEAD(listHead); |
945 | 974 | ||
946 | netDevice = GetInboundNetDevice(Device); | 975 | net_device = GetInboundNetDevice(device); |
947 | if (!netDevice) { | 976 | if (!net_device) { |
948 | DPRINT_ERR(NETVSC, "unable to get net device..." | 977 | DPRINT_ERR(NETVSC, "unable to get net device..." |
949 | "device being destroyed?"); | 978 | "device being destroyed?"); |
950 | return; | 979 | return; |
@@ -954,39 +983,40 @@ static void NetVscOnReceive(struct hv_device *Device, | |||
954 | * All inbound packets other than send completion should be xfer page | 983 | * All inbound packets other than send completion should be xfer page |
955 | * packet | 984 | * packet |
956 | */ | 985 | */ |
957 | if (Packet->Type != VmbusPacketTypeDataUsingTransferPages) { | 986 | if (packet->Type != VmbusPacketTypeDataUsingTransferPages) { |
958 | DPRINT_ERR(NETVSC, "Unknown packet type received - %d", | 987 | DPRINT_ERR(NETVSC, "Unknown packet type received - %d", |
959 | Packet->Type); | 988 | packet->Type); |
960 | PutNetDevice(Device); | 989 | PutNetDevice(device); |
961 | return; | 990 | return; |
962 | } | 991 | } |
963 | 992 | ||
964 | nvspPacket = (struct nvsp_message *)((unsigned long)Packet + | 993 | nvsp_packet = (struct nvsp_message *)((unsigned long)packet + |
965 | (Packet->DataOffset8 << 3)); | 994 | (packet->DataOffset8 << 3)); |
966 | 995 | ||
967 | /* Make sure this is a valid nvsp packet */ | 996 | /* Make sure this is a valid nvsp packet */ |
968 | if (nvspPacket->Header.MessageType != NvspMessage1TypeSendRNDISPacket) { | 997 | if (nvsp_packet->Header.MessageType != |
998 | NvspMessage1TypeSendRNDISPacket) { | ||
969 | DPRINT_ERR(NETVSC, "Unknown nvsp packet type received - %d", | 999 | DPRINT_ERR(NETVSC, "Unknown nvsp packet type received - %d", |
970 | nvspPacket->Header.MessageType); | 1000 | nvsp_packet->Header.MessageType); |
971 | PutNetDevice(Device); | 1001 | PutNetDevice(device); |
972 | return; | 1002 | return; |
973 | } | 1003 | } |
974 | 1004 | ||
975 | DPRINT_DBG(NETVSC, "NVSP packet received - type %d", | 1005 | DPRINT_DBG(NETVSC, "NVSP packet received - type %d", |
976 | nvspPacket->Header.MessageType); | 1006 | nvsp_packet->Header.MessageType); |
977 | 1007 | ||
978 | vmxferpagePacket = (struct vmtransfer_page_packet_header *)Packet; | 1008 | vmxferpage_packet = (struct vmtransfer_page_packet_header *)packet; |
979 | 1009 | ||
980 | if (vmxferpagePacket->TransferPageSetId != NETVSC_RECEIVE_BUFFER_ID) { | 1010 | if (vmxferpage_packet->TransferPageSetId != NETVSC_RECEIVE_BUFFER_ID) { |
981 | DPRINT_ERR(NETVSC, "Invalid xfer page set id - " | 1011 | DPRINT_ERR(NETVSC, "Invalid xfer page set id - " |
982 | "expecting %x got %x", NETVSC_RECEIVE_BUFFER_ID, | 1012 | "expecting %x got %x", NETVSC_RECEIVE_BUFFER_ID, |
983 | vmxferpagePacket->TransferPageSetId); | 1013 | vmxferpage_packet->TransferPageSetId); |
984 | PutNetDevice(Device); | 1014 | PutNetDevice(device); |
985 | return; | 1015 | return; |
986 | } | 1016 | } |
987 | 1017 | ||
988 | DPRINT_DBG(NETVSC, "xfer page - range count %d", | 1018 | DPRINT_DBG(NETVSC, "xfer page - range count %d", |
989 | vmxferpagePacket->RangeCount); | 1019 | vmxferpage_packet->RangeCount); |
990 | 1020 | ||
991 | /* | 1021 | /* |
992 | * Grab free packets (range count + 1) to represent this xfer | 1022 | * Grab free packets (range count + 1) to represent this xfer |
@@ -994,13 +1024,13 @@ static void NetVscOnReceive(struct hv_device *Device, | |||
994 | * We grab it here so that we know exactly how many we can | 1024 | * We grab it here so that we know exactly how many we can |
995 | * fulfil | 1025 | * fulfil |
996 | */ | 1026 | */ |
997 | spin_lock_irqsave(&netDevice->receive_packet_list_lock, flags); | 1027 | spin_lock_irqsave(&net_device->receive_packet_list_lock, flags); |
998 | while (!list_empty(&netDevice->ReceivePacketList)) { | 1028 | while (!list_empty(&net_device->ReceivePacketList)) { |
999 | list_move_tail(netDevice->ReceivePacketList.next, &listHead); | 1029 | list_move_tail(net_device->ReceivePacketList.next, &listHead); |
1000 | if (++count == vmxferpagePacket->RangeCount + 1) | 1030 | if (++count == vmxferpage_packet->RangeCount + 1) |
1001 | break; | 1031 | break; |
1002 | } | 1032 | } |
1003 | spin_unlock_irqrestore(&netDevice->receive_packet_list_lock, flags); | 1033 | spin_unlock_irqrestore(&net_device->receive_packet_list_lock, flags); |
1004 | 1034 | ||
1005 | /* | 1035 | /* |
1006 | * We need at least 2 netvsc pkts (1 to represent the xfer | 1036 | * We need at least 2 netvsc pkts (1 to represent the xfer |
@@ -1010,129 +1040,137 @@ static void NetVscOnReceive(struct hv_device *Device, | |||
1010 | if (count < 2) { | 1040 | if (count < 2) { |
1011 | DPRINT_ERR(NETVSC, "Got only %d netvsc pkt...needed %d pkts. " | 1041 | DPRINT_ERR(NETVSC, "Got only %d netvsc pkt...needed %d pkts. " |
1012 | "Dropping this xfer page packet completely!", | 1042 | "Dropping this xfer page packet completely!", |
1013 | count, vmxferpagePacket->RangeCount + 1); | 1043 | count, vmxferpage_packet->RangeCount + 1); |
1014 | 1044 | ||
1015 | /* Return it to the freelist */ | 1045 | /* Return it to the freelist */ |
1016 | spin_lock_irqsave(&netDevice->receive_packet_list_lock, flags); | 1046 | spin_lock_irqsave(&net_device->receive_packet_list_lock, flags); |
1017 | for (i = count; i != 0; i--) { | 1047 | for (i = count; i != 0; i--) { |
1018 | list_move_tail(listHead.next, | 1048 | list_move_tail(listHead.next, |
1019 | &netDevice->ReceivePacketList); | 1049 | &net_device->ReceivePacketList); |
1020 | } | 1050 | } |
1021 | spin_unlock_irqrestore(&netDevice->receive_packet_list_lock, | 1051 | spin_unlock_irqrestore(&net_device->receive_packet_list_lock, |
1022 | flags); | 1052 | flags); |
1023 | 1053 | ||
1024 | NetVscSendReceiveCompletion(Device, | 1054 | NetVscSendReceiveCompletion(device, |
1025 | vmxferpagePacket->d.TransactionId); | 1055 | vmxferpage_packet->d.TransactionId); |
1026 | 1056 | ||
1027 | PutNetDevice(Device); | 1057 | PutNetDevice(device); |
1028 | return; | 1058 | return; |
1029 | } | 1059 | } |
1030 | 1060 | ||
1031 | /* Remove the 1st packet to represent the xfer page packet itself */ | 1061 | /* Remove the 1st packet to represent the xfer page packet itself */ |
1032 | xferpagePacket = (struct xferpage_packet *)listHead.next; | 1062 | xferpage_packet = (struct xferpage_packet *)listHead.next; |
1033 | list_del(&xferpagePacket->ListEntry); | 1063 | list_del(&xferpage_packet->ListEntry); |
1034 | 1064 | ||
1035 | /* This is how much we can satisfy */ | 1065 | /* This is how much we can satisfy */ |
1036 | xferpagePacket->Count = count - 1; | 1066 | xferpage_packet->Count = count - 1; |
1037 | /* ASSERT(xferpagePacket->Count > 0 && xferpagePacket->Count <= */ | 1067 | /* ASSERT(xferpagePacket->Count > 0 && xferpagePacket->Count <= */ |
1038 | /* vmxferpagePacket->RangeCount); */ | 1068 | /* vmxferpagePacket->RangeCount); */ |
1039 | 1069 | ||
1040 | if (xferpagePacket->Count != vmxferpagePacket->RangeCount) { | 1070 | if (xferpage_packet->Count != vmxferpage_packet->RangeCount) { |
1041 | DPRINT_INFO(NETVSC, "Needed %d netvsc pkts to satisy this xfer " | 1071 | DPRINT_INFO(NETVSC, "Needed %d netvsc pkts to satisy this xfer " |
1042 | "page...got %d", vmxferpagePacket->RangeCount, | 1072 | "page...got %d", vmxferpage_packet->RangeCount, |
1043 | xferpagePacket->Count); | 1073 | xferpage_packet->Count); |
1044 | } | 1074 | } |
1045 | 1075 | ||
1046 | /* Each range represents 1 RNDIS pkt that contains 1 ethernet frame */ | 1076 | /* Each range represents 1 RNDIS pkt that contains 1 ethernet frame */ |
1047 | for (i = 0; i < (count - 1); i++) { | 1077 | for (i = 0; i < (count - 1); i++) { |
1048 | netvscPacket = (struct hv_netvsc_packet *)listHead.next; | 1078 | netvsc_packet = (struct hv_netvsc_packet *)listHead.next; |
1049 | list_del(&netvscPacket->ListEntry); | 1079 | list_del(&netvsc_packet->ListEntry); |
1050 | 1080 | ||
1051 | /* Initialize the netvsc packet */ | 1081 | /* Initialize the netvsc packet */ |
1052 | netvscPacket->XferPagePacket = xferpagePacket; | 1082 | netvsc_packet->XferPagePacket = xferpage_packet; |
1053 | netvscPacket->Completion.Recv.OnReceiveCompletion = | 1083 | netvsc_packet->Completion.Recv.OnReceiveCompletion = |
1054 | NetVscOnReceiveCompletion; | 1084 | NetVscOnReceiveCompletion; |
1055 | netvscPacket->Completion.Recv.ReceiveCompletionContext = | 1085 | netvsc_packet->Completion.Recv.ReceiveCompletionContext = |
1056 | netvscPacket; | 1086 | netvsc_packet; |
1057 | netvscPacket->Device = Device; | 1087 | netvsc_packet->Device = device; |
1058 | /* Save this so that we can send it back */ | 1088 | /* Save this so that we can send it back */ |
1059 | netvscPacket->Completion.Recv.ReceiveCompletionTid = | 1089 | netvsc_packet->Completion.Recv.ReceiveCompletionTid = |
1060 | vmxferpagePacket->d.TransactionId; | 1090 | vmxferpage_packet->d.TransactionId; |
1061 | 1091 | ||
1062 | netvscPacket->TotalDataBufferLength = | 1092 | netvsc_packet->TotalDataBufferLength = |
1063 | vmxferpagePacket->Ranges[i].ByteCount; | 1093 | vmxferpage_packet->Ranges[i].ByteCount; |
1064 | netvscPacket->PageBufferCount = 1; | 1094 | netvsc_packet->PageBufferCount = 1; |
1065 | 1095 | ||
1066 | /* ASSERT(vmxferpagePacket->Ranges[i].ByteOffset + */ | 1096 | /* ASSERT(vmxferpagePacket->Ranges[i].ByteOffset + */ |
1067 | /* vmxferpagePacket->Ranges[i].ByteCount < */ | 1097 | /* vmxferpagePacket->Ranges[i].ByteCount < */ |
1068 | /* netDevice->ReceiveBufferSize); */ | 1098 | /* netDevice->ReceiveBufferSize); */ |
1069 | 1099 | ||
1070 | netvscPacket->PageBuffers[0].Length = | 1100 | netvsc_packet->PageBuffers[0].Length = |
1071 | vmxferpagePacket->Ranges[i].ByteCount; | 1101 | vmxferpage_packet->Ranges[i].ByteCount; |
1072 | 1102 | ||
1073 | start = virt_to_phys((void *)((unsigned long)netDevice->ReceiveBuffer + vmxferpagePacket->Ranges[i].ByteOffset)); | 1103 | start = virt_to_phys((void *)((unsigned long)net_device-> |
1104 | ReceiveBuffer + vmxferpage_packet->Ranges[i].ByteOffset)); | ||
1074 | 1105 | ||
1075 | netvscPacket->PageBuffers[0].Pfn = start >> PAGE_SHIFT; | 1106 | netvsc_packet->PageBuffers[0].Pfn = start >> PAGE_SHIFT; |
1076 | endVirtual = (unsigned long)netDevice->ReceiveBuffer | 1107 | end_virtual = (unsigned long)net_device->ReceiveBuffer |
1077 | + vmxferpagePacket->Ranges[i].ByteOffset | 1108 | + vmxferpage_packet->Ranges[i].ByteOffset |
1078 | + vmxferpagePacket->Ranges[i].ByteCount - 1; | 1109 | + vmxferpage_packet->Ranges[i].ByteCount - 1; |
1079 | end = virt_to_phys((void *)endVirtual); | 1110 | end = virt_to_phys((void *)end_virtual); |
1080 | 1111 | ||
1081 | /* Calculate the page relative offset */ | 1112 | /* Calculate the page relative offset */ |
1082 | netvscPacket->PageBuffers[0].Offset = | 1113 | netvsc_packet->PageBuffers[0].Offset = |
1083 | vmxferpagePacket->Ranges[i].ByteOffset & (PAGE_SIZE - 1); | 1114 | vmxferpage_packet->Ranges[i].ByteOffset & |
1115 | (PAGE_SIZE - 1); | ||
1084 | if ((end >> PAGE_SHIFT) != (start >> PAGE_SHIFT)) { | 1116 | if ((end >> PAGE_SHIFT) != (start >> PAGE_SHIFT)) { |
1085 | /* Handle frame across multiple pages: */ | 1117 | /* Handle frame across multiple pages: */ |
1086 | netvscPacket->PageBuffers[0].Length = | 1118 | netvsc_packet->PageBuffers[0].Length = |
1087 | (netvscPacket->PageBuffers[0].Pfn << PAGE_SHIFT) | 1119 | (netvsc_packet->PageBuffers[0].Pfn << |
1120 | PAGE_SHIFT) | ||
1088 | + PAGE_SIZE - start; | 1121 | + PAGE_SIZE - start; |
1089 | bytesRemain = netvscPacket->TotalDataBufferLength - | 1122 | bytes_remain = netvsc_packet->TotalDataBufferLength - |
1090 | netvscPacket->PageBuffers[0].Length; | 1123 | netvsc_packet->PageBuffers[0].Length; |
1091 | for (j = 1; j < NETVSC_PACKET_MAXPAGE; j++) { | 1124 | for (j = 1; j < NETVSC_PACKET_MAXPAGE; j++) { |
1092 | netvscPacket->PageBuffers[j].Offset = 0; | 1125 | netvsc_packet->PageBuffers[j].Offset = 0; |
1093 | if (bytesRemain <= PAGE_SIZE) { | 1126 | if (bytes_remain <= PAGE_SIZE) { |
1094 | netvscPacket->PageBuffers[j].Length = bytesRemain; | 1127 | netvsc_packet->PageBuffers[j].Length = |
1095 | bytesRemain = 0; | 1128 | bytes_remain; |
1129 | bytes_remain = 0; | ||
1096 | } else { | 1130 | } else { |
1097 | netvscPacket->PageBuffers[j].Length = PAGE_SIZE; | 1131 | netvsc_packet->PageBuffers[j].Length = |
1098 | bytesRemain -= PAGE_SIZE; | 1132 | PAGE_SIZE; |
1133 | bytes_remain -= PAGE_SIZE; | ||
1099 | } | 1134 | } |
1100 | netvscPacket->PageBuffers[j].Pfn = | 1135 | netvsc_packet->PageBuffers[j].Pfn = |
1101 | virt_to_phys((void *)(endVirtual - bytesRemain)) >> PAGE_SHIFT; | 1136 | virt_to_phys((void *)(end_virtual - |
1102 | netvscPacket->PageBufferCount++; | 1137 | bytes_remain)) >> PAGE_SHIFT; |
1103 | if (bytesRemain == 0) | 1138 | netvsc_packet->PageBufferCount++; |
1139 | if (bytes_remain == 0) | ||
1104 | break; | 1140 | break; |
1105 | } | 1141 | } |
1106 | /* ASSERT(bytesRemain == 0); */ | 1142 | /* ASSERT(bytesRemain == 0); */ |
1107 | } | 1143 | } |
1108 | DPRINT_DBG(NETVSC, "[%d] - (abs offset %u len %u) => " | 1144 | DPRINT_DBG(NETVSC, "[%d] - (abs offset %u len %u) => " |
1109 | "(pfn %llx, offset %u, len %u)", i, | 1145 | "(pfn %llx, offset %u, len %u)", i, |
1110 | vmxferpagePacket->Ranges[i].ByteOffset, | 1146 | vmxferpage_packet->Ranges[i].ByteOffset, |
1111 | vmxferpagePacket->Ranges[i].ByteCount, | 1147 | vmxferpage_packet->Ranges[i].ByteCount, |
1112 | netvscPacket->PageBuffers[0].Pfn, | 1148 | netvsc_packet->PageBuffers[0].Pfn, |
1113 | netvscPacket->PageBuffers[0].Offset, | 1149 | netvsc_packet->PageBuffers[0].Offset, |
1114 | netvscPacket->PageBuffers[0].Length); | 1150 | netvsc_packet->PageBuffers[0].Length); |
1115 | 1151 | ||
1116 | /* Pass it to the upper layer */ | 1152 | /* Pass it to the upper layer */ |
1117 | ((struct netvsc_driver *)Device->Driver)->OnReceiveCallback(Device, netvscPacket); | 1153 | ((struct netvsc_driver *)device->Driver)-> |
1154 | OnReceiveCallback(device, netvsc_packet); | ||
1118 | 1155 | ||
1119 | NetVscOnReceiveCompletion(netvscPacket->Completion.Recv.ReceiveCompletionContext); | 1156 | NetVscOnReceiveCompletion(netvsc_packet-> |
1157 | Completion.Recv.ReceiveCompletionContext); | ||
1120 | } | 1158 | } |
1121 | 1159 | ||
1122 | /* ASSERT(list_empty(&listHead)); */ | 1160 | /* ASSERT(list_empty(&listHead)); */ |
1123 | 1161 | ||
1124 | PutNetDevice(Device); | 1162 | PutNetDevice(device); |
1125 | } | 1163 | } |
1126 | 1164 | ||
1127 | static void NetVscSendReceiveCompletion(struct hv_device *Device, | 1165 | static void NetVscSendReceiveCompletion(struct hv_device *device, |
1128 | u64 TransactionId) | 1166 | u64 transaction_id) |
1129 | { | 1167 | { |
1130 | struct nvsp_message recvcompMessage; | 1168 | struct nvsp_message recvcompMessage; |
1131 | int retries = 0; | 1169 | int retries = 0; |
1132 | int ret; | 1170 | int ret; |
1133 | 1171 | ||
1134 | DPRINT_DBG(NETVSC, "Sending receive completion pkt - %llx", | 1172 | DPRINT_DBG(NETVSC, "Sending receive completion pkt - %llx", |
1135 | TransactionId); | 1173 | transaction_id); |
1136 | 1174 | ||
1137 | recvcompMessage.Header.MessageType = | 1175 | recvcompMessage.Header.MessageType = |
1138 | NvspMessage1TypeSendRNDISPacketComplete; | 1176 | NvspMessage1TypeSendRNDISPacketComplete; |
@@ -1142,8 +1180,8 @@ static void NetVscSendReceiveCompletion(struct hv_device *Device, | |||
1142 | 1180 | ||
1143 | retry_send_cmplt: | 1181 | retry_send_cmplt: |
1144 | /* Send the completion */ | 1182 | /* Send the completion */ |
1145 | ret = vmbus_sendpacket(Device->channel, &recvcompMessage, | 1183 | ret = vmbus_sendpacket(device->channel, &recvcompMessage, |
1146 | sizeof(struct nvsp_message), TransactionId, | 1184 | sizeof(struct nvsp_message), transaction_id, |
1147 | VmbusPacketTypeCompletion, 0); | 1185 | VmbusPacketTypeCompletion, 0); |
1148 | if (ret == 0) { | 1186 | if (ret == 0) { |
1149 | /* success */ | 1187 | /* success */ |
@@ -1152,7 +1190,7 @@ retry_send_cmplt: | |||
1152 | /* no more room...wait a bit and attempt to retry 3 times */ | 1190 | /* no more room...wait a bit and attempt to retry 3 times */ |
1153 | retries++; | 1191 | retries++; |
1154 | DPRINT_ERR(NETVSC, "unable to send receive completion pkt " | 1192 | DPRINT_ERR(NETVSC, "unable to send receive completion pkt " |
1155 | "(tid %llx)...retrying %d", TransactionId, retries); | 1193 | "(tid %llx)...retrying %d", transaction_id, retries); |
1156 | 1194 | ||
1157 | if (retries < 4) { | 1195 | if (retries < 4) { |
1158 | udelay(100); | 1196 | udelay(100); |
@@ -1160,22 +1198,22 @@ retry_send_cmplt: | |||
1160 | } else { | 1198 | } else { |
1161 | DPRINT_ERR(NETVSC, "unable to send receive completion " | 1199 | DPRINT_ERR(NETVSC, "unable to send receive completion " |
1162 | "pkt (tid %llx)...give up retrying", | 1200 | "pkt (tid %llx)...give up retrying", |
1163 | TransactionId); | 1201 | transaction_id); |
1164 | } | 1202 | } |
1165 | } else { | 1203 | } else { |
1166 | DPRINT_ERR(NETVSC, "unable to send receive completion pkt - " | 1204 | DPRINT_ERR(NETVSC, "unable to send receive completion pkt - " |
1167 | "%llx", TransactionId); | 1205 | "%llx", transaction_id); |
1168 | } | 1206 | } |
1169 | } | 1207 | } |
1170 | 1208 | ||
1171 | /* Send a receive completion packet to RNDIS device (ie NetVsp) */ | 1209 | /* Send a receive completion packet to RNDIS device (ie NetVsp) */ |
1172 | static void NetVscOnReceiveCompletion(void *Context) | 1210 | static void NetVscOnReceiveCompletion(void *context) |
1173 | { | 1211 | { |
1174 | struct hv_netvsc_packet *packet = Context; | 1212 | struct hv_netvsc_packet *packet = context; |
1175 | struct hv_device *device = (struct hv_device *)packet->Device; | 1213 | struct hv_device *device = (struct hv_device *)packet->Device; |
1176 | struct netvsc_device *netDevice; | 1214 | struct netvsc_device *net_device; |
1177 | u64 transactionId = 0; | 1215 | u64 transaction_id = 0; |
1178 | bool fSendReceiveComp = false; | 1216 | bool fsend_receive_comp = false; |
1179 | unsigned long flags; | 1217 | unsigned long flags; |
1180 | 1218 | ||
1181 | /* ASSERT(packet->XferPagePacket); */ | 1219 | /* ASSERT(packet->XferPagePacket); */ |
@@ -1185,15 +1223,15 @@ static void NetVscOnReceiveCompletion(void *Context) | |||
1185 | * send out receive completion, we are using GetInboundNetDevice() | 1223 | * send out receive completion, we are using GetInboundNetDevice() |
1186 | * since we may have disable outbound traffic already. | 1224 | * since we may have disable outbound traffic already. |
1187 | */ | 1225 | */ |
1188 | netDevice = GetInboundNetDevice(device); | 1226 | net_device = GetInboundNetDevice(device); |
1189 | if (!netDevice) { | 1227 | if (!net_device) { |
1190 | DPRINT_ERR(NETVSC, "unable to get net device..." | 1228 | DPRINT_ERR(NETVSC, "unable to get net device..." |
1191 | "device being destroyed?"); | 1229 | "device being destroyed?"); |
1192 | return; | 1230 | return; |
1193 | } | 1231 | } |
1194 | 1232 | ||
1195 | /* Overloading use of the lock. */ | 1233 | /* Overloading use of the lock. */ |
1196 | spin_lock_irqsave(&netDevice->receive_packet_list_lock, flags); | 1234 | spin_lock_irqsave(&net_device->receive_packet_list_lock, flags); |
1197 | 1235 | ||
1198 | /* ASSERT(packet->XferPagePacket->Count > 0); */ | 1236 | /* ASSERT(packet->XferPagePacket->Count > 0); */ |
1199 | packet->XferPagePacket->Count--; | 1237 | packet->XferPagePacket->Count--; |
@@ -1203,31 +1241,31 @@ static void NetVscOnReceiveCompletion(void *Context) | |||
1203 | * Return the xfer page packet itself to the freelist | 1241 | * Return the xfer page packet itself to the freelist |
1204 | */ | 1242 | */ |
1205 | if (packet->XferPagePacket->Count == 0) { | 1243 | if (packet->XferPagePacket->Count == 0) { |
1206 | fSendReceiveComp = true; | 1244 | fsend_receive_comp = true; |
1207 | transactionId = packet->Completion.Recv.ReceiveCompletionTid; | 1245 | transaction_id = packet->Completion.Recv.ReceiveCompletionTid; |
1208 | list_add_tail(&packet->XferPagePacket->ListEntry, | 1246 | list_add_tail(&packet->XferPagePacket->ListEntry, |
1209 | &netDevice->ReceivePacketList); | 1247 | &net_device->ReceivePacketList); |
1210 | 1248 | ||
1211 | } | 1249 | } |
1212 | 1250 | ||
1213 | /* Put the packet back */ | 1251 | /* Put the packet back */ |
1214 | list_add_tail(&packet->ListEntry, &netDevice->ReceivePacketList); | 1252 | list_add_tail(&packet->ListEntry, &net_device->ReceivePacketList); |
1215 | spin_unlock_irqrestore(&netDevice->receive_packet_list_lock, flags); | 1253 | spin_unlock_irqrestore(&net_device->receive_packet_list_lock, flags); |
1216 | 1254 | ||
1217 | /* Send a receive completion for the xfer page packet */ | 1255 | /* Send a receive completion for the xfer page packet */ |
1218 | if (fSendReceiveComp) | 1256 | if (fsend_receive_comp) |
1219 | NetVscSendReceiveCompletion(device, transactionId); | 1257 | NetVscSendReceiveCompletion(device, transaction_id); |
1220 | 1258 | ||
1221 | PutNetDevice(device); | 1259 | PutNetDevice(device); |
1222 | } | 1260 | } |
1223 | 1261 | ||
1224 | static void NetVscOnChannelCallback(void *Context) | 1262 | static void NetVscOnChannelCallback(void *context) |
1225 | { | 1263 | { |
1226 | int ret; | 1264 | int ret; |
1227 | struct hv_device *device = Context; | 1265 | struct hv_device *device = context; |
1228 | struct netvsc_device *netDevice; | 1266 | struct netvsc_device *net_device; |
1229 | u32 bytesRecvd; | 1267 | u32 bytes_recvd; |
1230 | u64 requestId; | 1268 | u64 request_id; |
1231 | unsigned char *packet; | 1269 | unsigned char *packet; |
1232 | struct vmpacket_descriptor *desc; | 1270 | struct vmpacket_descriptor *desc; |
1233 | unsigned char *buffer; | 1271 | unsigned char *buffer; |
@@ -1241,20 +1279,20 @@ static void NetVscOnChannelCallback(void *Context) | |||
1241 | return; | 1279 | return; |
1242 | buffer = packet; | 1280 | buffer = packet; |
1243 | 1281 | ||
1244 | netDevice = GetInboundNetDevice(device); | 1282 | net_device = GetInboundNetDevice(device); |
1245 | if (!netDevice) { | 1283 | if (!net_device) { |
1246 | DPRINT_ERR(NETVSC, "net device (%p) shutting down..." | 1284 | DPRINT_ERR(NETVSC, "net device (%p) shutting down..." |
1247 | "ignoring inbound packets", netDevice); | 1285 | "ignoring inbound packets", net_device); |
1248 | goto out; | 1286 | goto out; |
1249 | } | 1287 | } |
1250 | 1288 | ||
1251 | do { | 1289 | do { |
1252 | ret = vmbus_recvpacket_raw(device->channel, buffer, bufferlen, | 1290 | ret = vmbus_recvpacket_raw(device->channel, buffer, bufferlen, |
1253 | &bytesRecvd, &requestId); | 1291 | &bytes_recvd, &request_id); |
1254 | if (ret == 0) { | 1292 | if (ret == 0) { |
1255 | if (bytesRecvd > 0) { | 1293 | if (bytes_recvd > 0) { |
1256 | DPRINT_DBG(NETVSC, "receive %d bytes, tid %llx", | 1294 | DPRINT_DBG(NETVSC, "receive %d bytes, tid %llx", |
1257 | bytesRecvd, requestId); | 1295 | bytes_recvd, request_id); |
1258 | 1296 | ||
1259 | desc = (struct vmpacket_descriptor *)buffer; | 1297 | desc = (struct vmpacket_descriptor *)buffer; |
1260 | switch (desc->Type) { | 1298 | switch (desc->Type) { |
@@ -1270,8 +1308,8 @@ static void NetVscOnChannelCallback(void *Context) | |||
1270 | DPRINT_ERR(NETVSC, | 1308 | DPRINT_ERR(NETVSC, |
1271 | "unhandled packet type %d, " | 1309 | "unhandled packet type %d, " |
1272 | "tid %llx len %d\n", | 1310 | "tid %llx len %d\n", |
1273 | desc->Type, requestId, | 1311 | desc->Type, request_id, |
1274 | bytesRecvd); | 1312 | bytes_recvd); |
1275 | break; | 1313 | break; |
1276 | } | 1314 | } |
1277 | 1315 | ||
@@ -1293,16 +1331,16 @@ static void NetVscOnChannelCallback(void *Context) | |||
1293 | } | 1331 | } |
1294 | } else if (ret == -2) { | 1332 | } else if (ret == -2) { |
1295 | /* Handle large packet */ | 1333 | /* Handle large packet */ |
1296 | buffer = kmalloc(bytesRecvd, GFP_ATOMIC); | 1334 | buffer = kmalloc(bytes_recvd, GFP_ATOMIC); |
1297 | if (buffer == NULL) { | 1335 | if (buffer == NULL) { |
1298 | /* Try again next time around */ | 1336 | /* Try again next time around */ |
1299 | DPRINT_ERR(NETVSC, | 1337 | DPRINT_ERR(NETVSC, |
1300 | "unable to allocate buffer of size " | 1338 | "unable to allocate buffer of size " |
1301 | "(%d)!!", bytesRecvd); | 1339 | "(%d)!!", bytes_recvd); |
1302 | break; | 1340 | break; |
1303 | } | 1341 | } |
1304 | 1342 | ||
1305 | bufferlen = bytesRecvd; | 1343 | bufferlen = bytes_recvd; |
1306 | } | 1344 | } |
1307 | } while (1); | 1345 | } while (1); |
1308 | 1346 | ||