]>
Commit | Line | Data |
---|---|---|
8a67d61d | 1 | /** @file\r |
2 | \r | |
3 | Copyright (c) 2005 - 2007, Intel Corporation\r | |
4 | All rights reserved. This program and the accompanying materials\r | |
5 | are licensed and made available under the terms and conditions of the BSD License\r | |
6 | which accompanies this distribution. The full text of the license may be found at\r | |
7 | http://opensource.org/licenses/bsd-license.php\r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | MnpIo.c\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | Implementation of Managed Network Protocol I/O functions.\r | |
19 | \r | |
20 | \r | |
21 | **/\r | |
22 | \r | |
23 | #include <Library/NetLib.h>\r | |
24 | #include <Library/BaseMemoryLib.h>\r | |
25 | #include <Library/BaseLib.h>\r | |
26 | #include <Library/MemoryAllocationLib.h>\r | |
27 | #include "MnpImpl.h"\r | |
28 | \r | |
29 | \r | |
30 | /**\r | |
31 | Validates the Mnp transmit token.\r | |
32 | \r | |
33 | @param Instance Pointer to the Mnp instance context data.\r | |
34 | @param Token Pointer to the transmit token to check.\r | |
35 | \r | |
36 | @return The Token is valid or not.\r | |
37 | \r | |
38 | **/\r | |
39 | BOOLEAN\r | |
40 | MnpIsValidTxToken (\r | |
41 | IN MNP_INSTANCE_DATA *Instance,\r | |
42 | IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token\r | |
43 | )\r | |
44 | {\r | |
45 | MNP_SERVICE_DATA *MnpServiceData;\r | |
8a67d61d | 46 | EFI_MANAGED_NETWORK_TRANSMIT_DATA *TxData;\r |
47 | UINT32 Index;\r | |
48 | UINT32 TotalLength;\r | |
49 | EFI_MANAGED_NETWORK_FRAGMENT_DATA *FragmentTable;\r | |
50 | \r | |
51 | MnpServiceData = Instance->MnpServiceData;\r | |
52 | NET_CHECK_SIGNATURE (MnpServiceData, MNP_SERVICE_DATA_SIGNATURE);\r | |
53 | \r | |
8a67d61d | 54 | TxData = Token->Packet.TxData;\r |
55 | \r | |
56 | if ((Token->Event == NULL) || (TxData == NULL) || (TxData->FragmentCount == 0)) {\r | |
57 | //\r | |
58 | // The token is invalid if the Event is NULL, or the TxData is NULL, or\r | |
59 | // the fragment count is zero.\r | |
60 | //\r | |
61 | MNP_DEBUG_WARN (("MnpIsValidTxToken: Invalid Token.\n"));\r | |
62 | return FALSE;\r | |
63 | }\r | |
64 | \r | |
65 | if ((TxData->DestinationAddress != NULL) && (TxData->HeaderLength != 0)) {\r | |
66 | //\r | |
67 | // The token is invalid if the HeaderLength isn't zero while the DestinationAddress\r | |
68 | // is NULL (The destination address is already put into the packet).\r | |
69 | //\r | |
70 | MNP_DEBUG_WARN (("MnpIsValidTxToken: DestinationAddress isn't NULL, HeaderLength must be 0.\n"));\r | |
71 | return FALSE;\r | |
72 | }\r | |
73 | \r | |
74 | TotalLength = 0;\r | |
75 | FragmentTable = TxData->FragmentTable;\r | |
76 | for (Index = 0; Index < TxData->FragmentCount; Index++) {\r | |
77 | \r | |
78 | if ((FragmentTable[Index].FragmentLength == 0) || (FragmentTable[Index].FragmentBuffer == NULL)) {\r | |
79 | //\r | |
80 | // The token is invalid if any FragmentLength is zero or any FragmentBuffer is NULL.\r | |
81 | //\r | |
82 | MNP_DEBUG_WARN (("MnpIsValidTxToken: Invalid FragmentLength or FragmentBuffer.\n"));\r | |
83 | return FALSE;\r | |
84 | }\r | |
85 | \r | |
86 | TotalLength += FragmentTable[Index].FragmentLength;\r | |
87 | }\r | |
88 | \r | |
89 | if ((TxData->DestinationAddress == NULL) && (FragmentTable[0].FragmentLength < TxData->HeaderLength)) {\r | |
90 | //\r | |
91 | // Media header is split between fragments.\r | |
92 | //\r | |
93 | return FALSE;\r | |
94 | }\r | |
95 | \r | |
96 | if (TotalLength != (TxData->DataLength + TxData->HeaderLength)) {\r | |
97 | //\r | |
98 | // The length calculated from the fragment information doesn't equal to the\r | |
99 | // sum of the DataLength and the HeaderLength.\r | |
100 | //\r | |
101 | MNP_DEBUG_WARN (("MnpIsValidTxData: Invalid Datalength compared with the sum of fragment length.\n"));\r | |
102 | return FALSE;\r | |
103 | }\r | |
104 | \r | |
105 | if (TxData->DataLength > MnpServiceData->Mtu) {\r | |
106 | //\r | |
107 | // The total length is larger than the MTU.\r | |
108 | //\r | |
109 | MNP_DEBUG_WARN (("MnpIsValidTxData: TxData->DataLength exceeds Mtu.\n"));\r | |
110 | return FALSE;\r | |
111 | }\r | |
112 | \r | |
113 | return TRUE;\r | |
114 | }\r | |
115 | \r | |
116 | \r | |
117 | /**\r | |
118 | Build the packet to transmit from the TxData passed in.\r | |
119 | \r | |
120 | @param MnpServiceData Pointer to the mnp service context data.\r | |
121 | @param TxData Pointer to the transmit data containing the\r | |
122 | information to build the packet.\r | |
123 | @param PktBuf Pointer to record the address of the packet.\r | |
124 | @param PktLen Pointer to a UINT32 variable used to record the\r | |
125 | packet's length.\r | |
126 | \r | |
127 | @return None.\r | |
128 | \r | |
129 | **/\r | |
130 | VOID\r | |
131 | MnpBuildTxPacket (\r | |
132 | IN MNP_SERVICE_DATA *MnpServiceData,\r | |
133 | IN EFI_MANAGED_NETWORK_TRANSMIT_DATA *TxData,\r | |
134 | OUT UINT8 **PktBuf,\r | |
135 | OUT UINT32 *PktLen\r | |
136 | )\r | |
137 | {\r | |
138 | EFI_SIMPLE_NETWORK_MODE *SnpMode;\r | |
139 | UINT8 *DstPos;\r | |
140 | UINT16 Index;\r | |
141 | \r | |
142 | if ((TxData->DestinationAddress == NULL) && (TxData->FragmentCount == 1)) {\r | |
143 | //\r | |
144 | // Media header is in FragmentTable and there is only one fragment,\r | |
145 | // use fragment buffer directly.\r | |
146 | //\r | |
147 | *PktBuf = TxData->FragmentTable[0].FragmentBuffer;\r | |
148 | *PktLen = TxData->FragmentTable[0].FragmentLength;\r | |
149 | } else {\r | |
150 | //\r | |
151 | // Either media header isn't in FragmentTable or there is more than\r | |
152 | // one fragment, copy the data into the packet buffer. Reserve the\r | |
153 | // media header space if necessary.\r | |
154 | //\r | |
155 | SnpMode = MnpServiceData->Snp->Mode;\r | |
156 | DstPos = MnpServiceData->TxBuf;\r | |
157 | \r | |
158 | *PktLen = 0;\r | |
159 | if (TxData->DestinationAddress != NULL) {\r | |
160 | //\r | |
161 | // If dest address is not NULL, move DstPos to reserve space for the\r | |
162 | // media header. Add the media header length to buflen.\r | |
163 | //\r | |
164 | DstPos += SnpMode->MediaHeaderSize;\r | |
165 | *PktLen += SnpMode->MediaHeaderSize;\r | |
166 | }\r | |
167 | \r | |
168 | for (Index = 0; Index < TxData->FragmentCount; Index++) {\r | |
169 | //\r | |
170 | // Copy the data.\r | |
171 | //\r | |
172 | NetCopyMem (\r | |
173 | DstPos,\r | |
174 | TxData->FragmentTable[Index].FragmentBuffer,\r | |
175 | TxData->FragmentTable[Index].FragmentLength\r | |
176 | );\r | |
177 | DstPos += TxData->FragmentTable[Index].FragmentLength;\r | |
178 | }\r | |
179 | \r | |
180 | //\r | |
181 | // Set the buffer pointer and the buffer length.\r | |
182 | //\r | |
183 | *PktBuf = MnpServiceData->TxBuf;\r | |
184 | *PktLen += TxData->DataLength + TxData->HeaderLength;\r | |
185 | }\r | |
186 | }\r | |
187 | \r | |
188 | \r | |
189 | /**\r | |
190 | Synchronously send out the packet.\r | |
191 | \r | |
192 | @param MnpServiceData Pointer to the mnp service context data.\r | |
193 | @param Packet Pointer to the pakcet buffer.\r | |
194 | @param Length The length of the packet.\r | |
195 | @param Token Pointer to the token the packet generated from.\r | |
196 | \r | |
197 | @retval EFI_SUCCESS The packet is sent out.\r | |
198 | @retval EFI_TIMEOUT Time out occurs, the packet isn't sent.\r | |
199 | @retval EFI_DEVICE_ERROR An unexpected network error occurs.\r | |
200 | \r | |
201 | **/\r | |
202 | EFI_STATUS\r | |
203 | MnpSyncSendPacket (\r | |
204 | IN MNP_SERVICE_DATA *MnpServiceData,\r | |
205 | IN UINT8 *Packet,\r | |
206 | IN UINT32 Length,\r | |
207 | IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token\r | |
208 | )\r | |
209 | {\r | |
210 | EFI_STATUS Status;\r | |
211 | EFI_SIMPLE_NETWORK_PROTOCOL *Snp;\r | |
212 | EFI_MANAGED_NETWORK_TRANSMIT_DATA *TxData;\r | |
213 | UINT32 HeaderSize;\r | |
214 | UINT8 *TxBuf;\r | |
215 | \r | |
216 | Snp = MnpServiceData->Snp;\r | |
217 | TxData = Token->Packet.TxData;\r | |
218 | \r | |
219 | HeaderSize = Snp->Mode->MediaHeaderSize - TxData->HeaderLength;\r | |
220 | \r | |
221 | //\r | |
222 | // Start the timeout event.\r | |
223 | //\r | |
224 | Status = gBS->SetTimer (\r | |
225 | MnpServiceData->TxTimeoutEvent,\r | |
226 | TimerRelative,\r | |
227 | MNP_TX_TIMEOUT_TIME\r | |
228 | );\r | |
229 | if (EFI_ERROR (Status)) {\r | |
230 | \r | |
231 | goto SIGNAL_TOKEN;\r | |
232 | }\r | |
233 | \r | |
234 | for (;;) {\r | |
235 | //\r | |
236 | // Transmit the packet through SNP.\r | |
237 | //\r | |
238 | Status = Snp->Transmit (\r | |
239 | Snp,\r | |
240 | HeaderSize,\r | |
241 | Length,\r | |
242 | Packet,\r | |
243 | TxData->SourceAddress,\r | |
244 | TxData->DestinationAddress,\r | |
245 | &TxData->ProtocolType\r | |
246 | );\r | |
247 | if ((Status != EFI_SUCCESS) && (Status != EFI_NOT_READY)) {\r | |
248 | \r | |
249 | Status = EFI_DEVICE_ERROR;\r | |
250 | break;\r | |
251 | }\r | |
252 | \r | |
253 | //\r | |
254 | // If Status is EFI_SUCCESS, the packet is put in the transmit queue.\r | |
255 | // if Status is EFI_NOT_READY, the transmit engine of the network interface is busy.\r | |
256 | // Both need to sync SNP.\r | |
257 | //\r | |
258 | TxBuf = NULL;\r | |
259 | do {\r | |
260 | //\r | |
261 | // Get the recycled transmit buffer status.\r | |
262 | //\r | |
4eb65aff | 263 | Snp->GetStatus (Snp, NULL, (VOID **) &TxBuf);\r |
8a67d61d | 264 | \r |
265 | if (!EFI_ERROR (gBS->CheckEvent (MnpServiceData->TxTimeoutEvent))) {\r | |
266 | \r | |
267 | Status = EFI_TIMEOUT;\r | |
268 | break;\r | |
269 | }\r | |
270 | } while (TxBuf == NULL);\r | |
271 | \r | |
272 | if ((Status == EFI_SUCCESS) || (Status == EFI_TIMEOUT)) {\r | |
273 | \r | |
274 | break;\r | |
275 | } else {\r | |
276 | //\r | |
277 | // Status is EFI_NOT_READY. Restart the timer event and call Snp->Transmit again.\r | |
278 | //\r | |
279 | gBS->SetTimer (\r | |
280 | MnpServiceData->TxTimeoutEvent,\r | |
281 | TimerRelative,\r | |
282 | MNP_TX_TIMEOUT_TIME\r | |
283 | );\r | |
284 | }\r | |
285 | }\r | |
286 | \r | |
287 | //\r | |
288 | // Cancel the timer event.\r | |
289 | //\r | |
290 | gBS->SetTimer (MnpServiceData->TxTimeoutEvent, TimerCancel, 0);\r | |
291 | \r | |
292 | SIGNAL_TOKEN:\r | |
293 | \r | |
294 | Token->Status = Status;\r | |
295 | gBS->SignalEvent (Token->Event);\r | |
296 | \r | |
297 | return EFI_SUCCESS;\r | |
298 | }\r | |
299 | \r | |
300 | \r | |
301 | /**\r | |
302 | Try to deliver the received packet to the instance.\r | |
303 | \r | |
304 | @param Instance Pointer to the mnp instance context data.\r | |
305 | \r | |
306 | @retval EFI_SUCCESS The received packet is delivered, or there is no\r | |
307 | packet to deliver, or there is no available receive\r | |
308 | token.\r | |
309 | @retval EFI_OUT_OF_RESOURCES The deliver fails due to lack of memory resource.\r | |
310 | \r | |
311 | **/\r | |
312 | EFI_STATUS\r | |
313 | MnpInstanceDeliverPacket (\r | |
314 | IN MNP_INSTANCE_DATA *Instance\r | |
315 | )\r | |
316 | {\r | |
317 | MNP_SERVICE_DATA *MnpServiceData;\r | |
318 | MNP_RXDATA_WRAP *RxDataWrap;\r | |
319 | NET_BUF *DupNbuf;\r | |
320 | EFI_MANAGED_NETWORK_RECEIVE_DATA *RxData;\r | |
321 | EFI_SIMPLE_NETWORK_MODE *SnpMode;\r | |
322 | EFI_MANAGED_NETWORK_COMPLETION_TOKEN *RxToken;\r | |
323 | \r | |
324 | MnpServiceData = Instance->MnpServiceData;\r | |
325 | NET_CHECK_SIGNATURE (MnpServiceData, MNP_SERVICE_DATA_SIGNATURE);\r | |
326 | \r | |
327 | if (NetMapIsEmpty (&Instance->RxTokenMap) || NetListIsEmpty (&Instance->RcvdPacketQueue)) {\r | |
328 | //\r | |
329 | // No pending received data or no available receive token, return.\r | |
330 | //\r | |
331 | return EFI_SUCCESS;\r | |
332 | }\r | |
333 | \r | |
334 | ASSERT (Instance->RcvdPacketQueueSize != 0);\r | |
335 | \r | |
336 | RxDataWrap = NET_LIST_HEAD (&Instance->RcvdPacketQueue, MNP_RXDATA_WRAP, WrapEntry);\r | |
337 | if (RxDataWrap->Nbuf->RefCnt > 2) {\r | |
338 | //\r | |
339 | // There are other instances share this Nbuf, duplicate to get a\r | |
340 | // copy to allow the instance to do R/W operations.\r | |
341 | //\r | |
342 | DupNbuf = MnpAllocNbuf (MnpServiceData);\r | |
343 | if (DupNbuf == NULL) {\r | |
344 | MNP_DEBUG_WARN (("MnpDeliverPacket: Failed to allocate a free Nbuf.\n"));\r | |
345 | \r | |
346 | return EFI_OUT_OF_RESOURCES;\r | |
347 | }\r | |
348 | \r | |
349 | //\r | |
350 | // Duplicate the net buffer.\r | |
351 | //\r | |
352 | NetbufDuplicate (RxDataWrap->Nbuf, DupNbuf, 0);\r | |
353 | MnpFreeNbuf (MnpServiceData, RxDataWrap->Nbuf);\r | |
354 | RxDataWrap->Nbuf = DupNbuf;\r | |
355 | }\r | |
356 | \r | |
357 | //\r | |
358 | // All resources are OK, remove the packet from the queue.\r | |
359 | //\r | |
360 | NetListRemoveHead (&Instance->RcvdPacketQueue);\r | |
361 | Instance->RcvdPacketQueueSize--;\r | |
362 | \r | |
363 | RxData = &RxDataWrap->RxData;\r | |
364 | SnpMode = MnpServiceData->Snp->Mode;\r | |
365 | \r | |
366 | //\r | |
367 | // Set all the buffer pointers.\r | |
368 | //\r | |
369 | RxData->MediaHeader = NetbufGetByte (RxDataWrap->Nbuf, 0, NULL);\r | |
370 | RxData->DestinationAddress = RxData->MediaHeader;\r | |
371 | RxData->SourceAddress = (UINT8 *) RxData->MediaHeader + SnpMode->HwAddressSize;\r | |
372 | RxData->PacketData = (UINT8 *) RxData->MediaHeader + SnpMode->MediaHeaderSize;\r | |
373 | \r | |
374 | //\r | |
375 | // Insert this RxDataWrap into the delivered queue.\r | |
376 | //\r | |
377 | NetListInsertTail (&Instance->RxDeliveredPacketQueue, &RxDataWrap->WrapEntry);\r | |
378 | \r | |
379 | //\r | |
380 | // Get the receive token from the RxTokenMap.\r | |
381 | //\r | |
382 | RxToken = NetMapRemoveHead (&Instance->RxTokenMap, NULL);\r | |
383 | \r | |
384 | //\r | |
385 | // Signal this token's event.\r | |
386 | //\r | |
387 | RxToken->Packet.RxData = &RxDataWrap->RxData;\r | |
388 | RxToken->Status = EFI_SUCCESS;\r | |
389 | gBS->SignalEvent (RxToken->Event);\r | |
390 | \r | |
391 | return EFI_SUCCESS;\r | |
392 | }\r | |
393 | \r | |
394 | \r | |
395 | /**\r | |
396 | Deliver the received packet for the instances belonging to the MnpServiceData.\r | |
397 | \r | |
398 | @param MnpServiceData Pointer to the mnp service context data.\r | |
399 | \r | |
400 | @return None.\r | |
401 | \r | |
402 | **/\r | |
403 | STATIC\r | |
404 | VOID\r | |
405 | MnpDeliverPacket (\r | |
406 | IN MNP_SERVICE_DATA *MnpServiceData\r | |
407 | )\r | |
408 | {\r | |
409 | NET_LIST_ENTRY *Entry;\r | |
410 | MNP_INSTANCE_DATA *Instance;\r | |
411 | \r | |
412 | NET_CHECK_SIGNATURE (MnpServiceData, MNP_SERVICE_DATA_SIGNATURE);\r | |
413 | \r | |
414 | NET_LIST_FOR_EACH (Entry, &MnpServiceData->ChildrenList) {\r | |
415 | Instance = NET_LIST_USER_STRUCT (Entry, MNP_INSTANCE_DATA, InstEntry);\r | |
416 | NET_CHECK_SIGNATURE (Instance, MNP_INSTANCE_DATA_SIGNATURE);\r | |
417 | \r | |
418 | //\r | |
419 | // Try to deliver packet for this instance.\r | |
420 | //\r | |
421 | MnpInstanceDeliverPacket (Instance);\r | |
422 | }\r | |
423 | }\r | |
424 | \r | |
425 | \r | |
426 | /**\r | |
427 | Recycle the RxData and other resources used to hold and deliver the received\r | |
428 | packet.\r | |
429 | \r | |
430 | @param Event The event this notify function registered to.\r | |
431 | @param Context Pointer to the context data registerd to the Event.\r | |
432 | \r | |
433 | @return None.\r | |
434 | \r | |
435 | **/\r | |
436 | VOID\r | |
437 | EFIAPI\r | |
438 | MnpRecycleRxData (\r | |
439 | IN EFI_EVENT Event,\r | |
440 | IN VOID *Context\r | |
441 | )\r | |
442 | {\r | |
443 | MNP_RXDATA_WRAP *RxDataWrap;\r | |
444 | MNP_SERVICE_DATA *MnpServiceData;\r | |
445 | \r | |
446 | ASSERT (Context != NULL);\r | |
447 | \r | |
448 | RxDataWrap = (MNP_RXDATA_WRAP *) Context;\r | |
449 | NET_CHECK_SIGNATURE (RxDataWrap->Instance, MNP_INSTANCE_DATA_SIGNATURE);\r | |
450 | \r | |
451 | ASSERT (RxDataWrap->Nbuf != NULL);\r | |
452 | \r | |
453 | MnpServiceData = RxDataWrap->Instance->MnpServiceData;\r | |
454 | NET_CHECK_SIGNATURE (MnpServiceData, MNP_SERVICE_DATA_SIGNATURE);\r | |
455 | \r | |
456 | //\r | |
457 | // Free this Nbuf.\r | |
458 | //\r | |
459 | MnpFreeNbuf (MnpServiceData, RxDataWrap->Nbuf);\r | |
460 | RxDataWrap->Nbuf = NULL;\r | |
461 | \r | |
462 | //\r | |
463 | // Close the recycle event.\r | |
464 | //\r | |
465 | gBS->CloseEvent (RxDataWrap->RxData.RecycleEvent);\r | |
466 | \r | |
467 | //\r | |
468 | // Remove this Wrap entry from the list.\r | |
469 | //\r | |
470 | NetListRemoveEntry (&RxDataWrap->WrapEntry);\r | |
471 | \r | |
472 | NetFreePool (RxDataWrap);\r | |
473 | }\r | |
474 | \r | |
475 | \r | |
476 | /**\r | |
477 | Queue the received packet into instance's receive queue.\r | |
478 | \r | |
479 | @param Instance Pointer to the mnp instance context data.\r | |
480 | @param RxDataWrap Pointer to the Wrap structure containing the\r | |
481 | received data and other information.\r | |
482 | \r | |
483 | @return None.\r | |
484 | \r | |
485 | **/\r | |
486 | STATIC\r | |
487 | VOID\r | |
488 | MnpQueueRcvdPacket (\r | |
489 | IN MNP_INSTANCE_DATA *Instance,\r | |
490 | IN MNP_RXDATA_WRAP *RxDataWrap\r | |
491 | )\r | |
492 | {\r | |
493 | MNP_RXDATA_WRAP *OldRxDataWrap;\r | |
494 | \r | |
495 | NET_CHECK_SIGNATURE (Instance, MNP_INSTANCE_DATA_SIGNATURE);\r | |
496 | \r | |
497 | //\r | |
498 | // Check the queue size. If it exceeds the limit, drop one packet\r | |
499 | // from the head.\r | |
500 | //\r | |
501 | if (Instance->RcvdPacketQueueSize == MNP_MAX_RCVD_PACKET_QUE_SIZE) {\r | |
502 | \r | |
503 | MNP_DEBUG_WARN (("MnpQueueRcvdPacket: Drop one packet bcz queue size limit reached.\n"));\r | |
504 | \r | |
505 | //\r | |
506 | // Get the oldest packet.\r | |
507 | //\r | |
508 | OldRxDataWrap = NET_LIST_HEAD (\r | |
509 | &Instance->RcvdPacketQueue,\r | |
510 | MNP_RXDATA_WRAP,\r | |
511 | WrapEntry\r | |
512 | );\r | |
513 | \r | |
514 | //\r | |
515 | // Recycle this OldRxDataWrap, this entry will be removed by the callee.\r | |
516 | //\r | |
517 | MnpRecycleRxData (NULL, (VOID *) OldRxDataWrap);\r | |
518 | Instance->RcvdPacketQueueSize--;\r | |
519 | }\r | |
520 | \r | |
521 | //\r | |
522 | // Update the timeout tick using the configured parameter.\r | |
523 | //\r | |
524 | RxDataWrap->TimeoutTick = Instance->ConfigData.ReceivedQueueTimeoutValue;\r | |
525 | \r | |
526 | //\r | |
527 | // Insert this Wrap into the instance queue.\r | |
528 | //\r | |
529 | NetListInsertTail (&Instance->RcvdPacketQueue, &RxDataWrap->WrapEntry);\r | |
530 | Instance->RcvdPacketQueueSize++;\r | |
531 | }\r | |
532 | \r | |
533 | \r | |
534 | /**\r | |
535 | Match the received packet with the instance receive filters.\r | |
536 | \r | |
537 | @param Instance Pointer to the mnp instance context data.\r | |
538 | @param RxData Pointer to the EFI_MANAGED_NETWORK_RECEIVE_DATA.\r | |
539 | @param GroupAddress Pointer to the GroupAddress, the GroupAddress is\r | |
540 | non-NULL and it contains the destination multicast\r | |
541 | mac address of the received packet if the packet\r | |
542 | destinated to a multicast mac address.\r | |
543 | @param PktAttr The received packets attribute.\r | |
544 | \r | |
545 | @return The received packet matches the instance's receive filters or not.\r | |
546 | \r | |
547 | **/\r | |
548 | STATIC\r | |
549 | BOOLEAN\r | |
550 | MnpMatchPacket (\r | |
551 | IN MNP_INSTANCE_DATA *Instance,\r | |
552 | IN EFI_MANAGED_NETWORK_RECEIVE_DATA *RxData,\r | |
553 | IN MNP_GROUP_ADDRESS *GroupAddress OPTIONAL,\r | |
554 | IN UINT8 PktAttr\r | |
555 | )\r | |
556 | {\r | |
557 | EFI_MANAGED_NETWORK_CONFIG_DATA *ConfigData;\r | |
558 | NET_LIST_ENTRY *Entry;\r | |
559 | MNP_GROUP_CONTROL_BLOCK *GroupCtrlBlk;\r | |
560 | \r | |
561 | NET_CHECK_SIGNATURE (Instance, MNP_INSTANCE_DATA_SIGNATURE);\r | |
562 | \r | |
563 | ConfigData = &Instance->ConfigData;\r | |
564 | \r | |
565 | if (ConfigData->EnablePromiscuousReceive) {\r | |
566 | //\r | |
567 | // Always match if this instance is configured to be promiscuous.\r | |
568 | //\r | |
569 | return TRUE;\r | |
570 | }\r | |
571 | //\r | |
572 | // Check the protocol type.\r | |
573 | //\r | |
574 | if ((ConfigData->ProtocolTypeFilter != 0) && (ConfigData->ProtocolTypeFilter != RxData->ProtocolType)) {\r | |
575 | return FALSE;\r | |
576 | }\r | |
577 | \r | |
578 | //\r | |
579 | // The protocol type is matched, check receive filter, include unicast and broadcast.\r | |
580 | //\r | |
581 | if ((Instance->ReceiveFilter & PktAttr) != 0) {\r | |
582 | return TRUE;\r | |
583 | }\r | |
584 | \r | |
585 | //\r | |
586 | // Check multicast addresses.\r | |
587 | //\r | |
588 | if (ConfigData->EnableMulticastReceive && RxData->MulticastFlag) {\r | |
589 | \r | |
590 | ASSERT (GroupAddress != NULL);\r | |
591 | \r | |
592 | NET_LIST_FOR_EACH (Entry, &Instance->GroupCtrlBlkList) {\r | |
593 | \r | |
594 | GroupCtrlBlk = NET_LIST_USER_STRUCT (Entry, MNP_GROUP_CONTROL_BLOCK, CtrlBlkEntry);\r | |
595 | if (GroupCtrlBlk->GroupAddress == GroupAddress) {\r | |
596 | //\r | |
597 | // The instance is configured to receiveing packets destinated to this\r | |
598 | // multicast address.\r | |
599 | //\r | |
600 | return TRUE;\r | |
601 | }\r | |
602 | }\r | |
603 | }\r | |
604 | \r | |
605 | //\r | |
606 | // No match.\r | |
607 | //\r | |
608 | return FALSE;\r | |
609 | }\r | |
610 | \r | |
611 | \r | |
612 | /**\r | |
613 | Analyse the received packets.\r | |
614 | \r | |
615 | @param MnpServiceData Pointer to the mnp service context data.\r | |
616 | @param Nbuf Pointer to the net buffer holding the received\r | |
617 | packet.\r | |
618 | @param RxData Pointer to the buffer used to save the analysed\r | |
619 | result in EFI_MANAGED_NETWORK_RECEIVE_DATA.\r | |
620 | @param GroupAddress Pointer to pointer to a MNP_GROUP_ADDRESS used to\r | |
621 | pass out the address of the multicast address the\r | |
622 | received packet destinated to.\r | |
623 | @param PktAttr Pointer to the buffer used to save the analysed\r | |
624 | packet attribute.\r | |
625 | \r | |
626 | @return None.\r | |
627 | \r | |
628 | **/\r | |
629 | STATIC\r | |
630 | VOID\r | |
631 | MnpAnalysePacket (\r | |
632 | IN MNP_SERVICE_DATA *MnpServiceData,\r | |
633 | IN NET_BUF *Nbuf,\r | |
634 | IN EFI_MANAGED_NETWORK_RECEIVE_DATA *RxData,\r | |
635 | OUT MNP_GROUP_ADDRESS **GroupAddress,\r | |
636 | OUT UINT8 *PktAttr\r | |
637 | )\r | |
638 | {\r | |
639 | EFI_SIMPLE_NETWORK_MODE *SnpMode;\r | |
640 | UINT8 *BufPtr;\r | |
641 | NET_LIST_ENTRY *Entry;\r | |
642 | \r | |
643 | SnpMode = MnpServiceData->Snp->Mode;\r | |
644 | \r | |
645 | //\r | |
646 | // Get the packet buffer.\r | |
647 | //\r | |
648 | BufPtr = NetbufGetByte (Nbuf, 0, NULL);\r | |
649 | ASSERT (BufPtr != NULL);\r | |
650 | \r | |
651 | //\r | |
652 | // Set the initial values.\r | |
653 | //\r | |
654 | RxData->BroadcastFlag = FALSE;\r | |
655 | RxData->MulticastFlag = FALSE;\r | |
656 | RxData->PromiscuousFlag = FALSE;\r | |
657 | *PktAttr = UNICAST_PACKET;\r | |
658 | \r | |
659 | if (!NET_MAC_EQUAL (&SnpMode->CurrentAddress, BufPtr, SnpMode->HwAddressSize)) {\r | |
660 | //\r | |
661 | // This packet isn't destinated to our current mac address, it't not unicast.\r | |
662 | //\r | |
663 | *PktAttr = 0;\r | |
664 | \r | |
665 | if (NET_MAC_EQUAL (&SnpMode->BroadcastAddress, BufPtr, SnpMode->HwAddressSize)) {\r | |
666 | //\r | |
667 | // It's broadcast.\r | |
668 | //\r | |
669 | RxData->BroadcastFlag = TRUE;\r | |
670 | *PktAttr = BROADCAST_PACKET;\r | |
671 | } else if ((*BufPtr & 0x01) == 0x1) {\r | |
672 | //\r | |
673 | // It's multicast, try to match the multicast filters.\r | |
674 | //\r | |
675 | NET_LIST_FOR_EACH (Entry, &MnpServiceData->GroupAddressList) {\r | |
676 | \r | |
677 | *GroupAddress = NET_LIST_USER_STRUCT (Entry, MNP_GROUP_ADDRESS, AddrEntry);\r | |
678 | if (NET_MAC_EQUAL (BufPtr, &((*GroupAddress)->Address), SnpMode->HwAddressSize)) {\r | |
679 | RxData->MulticastFlag = TRUE;\r | |
680 | break;\r | |
681 | }\r | |
682 | }\r | |
683 | \r | |
684 | if (!RxData->MulticastFlag) {\r | |
685 | //\r | |
686 | // No match, set GroupAddress to NULL. This multicast packet must\r | |
687 | // be the result of PROMISUCOUS or PROMISUCOUS_MULTICAST flag is on.\r | |
688 | //\r | |
689 | *GroupAddress = NULL;\r | |
690 | RxData->PromiscuousFlag = TRUE;\r | |
691 | \r | |
692 | if (MnpServiceData->PromiscuousCount == 0) {\r | |
693 | //\r | |
694 | // Skip the below code, there is no receiver of this packet.\r | |
695 | //\r | |
696 | return ;\r | |
697 | }\r | |
698 | }\r | |
699 | } else {\r | |
700 | RxData->PromiscuousFlag = TRUE;\r | |
701 | }\r | |
702 | }\r | |
703 | \r | |
704 | NetZeroMem (&RxData->Timestamp, sizeof (EFI_TIME));\r | |
705 | \r | |
706 | //\r | |
707 | // Fill the common parts of RxData.\r | |
708 | //\r | |
709 | RxData->PacketLength = Nbuf->TotalSize;\r | |
710 | RxData->HeaderLength = SnpMode->MediaHeaderSize;\r | |
711 | RxData->AddressLength = SnpMode->HwAddressSize;\r | |
712 | RxData->DataLength = RxData->PacketLength - RxData->HeaderLength;\r | |
713 | RxData->ProtocolType = NTOHS (*(UINT16 *) (BufPtr + 2 * SnpMode->HwAddressSize));\r | |
714 | }\r | |
715 | \r | |
716 | \r | |
717 | /**\r | |
718 | Wrap the RxData.\r | |
719 | \r | |
720 | @param Instance Pointer to the mnp instance context data.\r | |
721 | @param RxData Pointer to the receive data to wrap.\r | |
722 | \r | |
723 | @return Pointer to a MNP_RXDATA_WRAP which wraps the RxData.\r | |
724 | \r | |
725 | **/\r | |
726 | STATIC\r | |
727 | MNP_RXDATA_WRAP *\r | |
728 | MnpWrapRxData (\r | |
729 | IN MNP_INSTANCE_DATA *Instance,\r | |
730 | IN EFI_MANAGED_NETWORK_RECEIVE_DATA *RxData\r | |
731 | )\r | |
732 | {\r | |
733 | EFI_STATUS Status;\r | |
734 | MNP_RXDATA_WRAP *RxDataWrap;\r | |
735 | \r | |
736 | //\r | |
737 | // Allocate memory.\r | |
738 | //\r | |
739 | RxDataWrap = NetAllocatePool (sizeof (MNP_RXDATA_WRAP));\r | |
740 | if (RxDataWrap == NULL) {\r | |
741 | MNP_DEBUG_ERROR (("MnpDispatchPacket: Failed to allocate a MNP_RXDATA_WRAP.\n"));\r | |
742 | return NULL;\r | |
743 | }\r | |
744 | \r | |
745 | RxDataWrap->Instance = Instance;\r | |
746 | \r | |
747 | //\r | |
748 | // Fill the RxData in RxDataWrap,\r | |
749 | //\r | |
687a2e5f | 750 | CopyMem (&RxDataWrap->RxData, RxData, sizeof (RxDataWrap->RxData));\r |
8a67d61d | 751 | \r |
752 | //\r | |
753 | // Create the recycle event.\r | |
754 | //\r | |
755 | Status = gBS->CreateEvent (\r | |
756 | EVT_NOTIFY_SIGNAL,\r | |
757 | NET_TPL_RECYCLE,\r | |
758 | MnpRecycleRxData,\r | |
759 | RxDataWrap,\r | |
760 | &RxDataWrap->RxData.RecycleEvent\r | |
761 | );\r | |
762 | if (EFI_ERROR (Status)) {\r | |
763 | \r | |
764 | MNP_DEBUG_ERROR (("MnpDispatchPacket: gBS->CreateEvent failed, %r.\n", Status));\r | |
765 | NetFreePool (RxDataWrap);\r | |
766 | return NULL;\r | |
767 | }\r | |
768 | \r | |
769 | return RxDataWrap;\r | |
770 | }\r | |
771 | \r | |
772 | \r | |
773 | /**\r | |
774 | Enqueue the received the packets to the instances belonging to the\r | |
775 | MnpServiceData.\r | |
776 | \r | |
777 | @param MnpServiceData Pointer to the mnp service context data.\r | |
778 | @param Nbuf Pointer to the net buffer representing the received\r | |
779 | packet.\r | |
780 | \r | |
781 | @return None.\r | |
782 | \r | |
783 | **/\r | |
784 | STATIC\r | |
785 | VOID\r | |
786 | MnpEnqueuePacket (\r | |
787 | IN MNP_SERVICE_DATA *MnpServiceData,\r | |
788 | IN NET_BUF *Nbuf\r | |
789 | )\r | |
790 | {\r | |
791 | NET_LIST_ENTRY *Entry;\r | |
792 | MNP_INSTANCE_DATA *Instance;\r | |
793 | EFI_MANAGED_NETWORK_RECEIVE_DATA RxData;\r | |
794 | UINT8 PktAttr;\r | |
795 | MNP_GROUP_ADDRESS *GroupAddress;\r | |
796 | MNP_RXDATA_WRAP *RxDataWrap;\r | |
797 | \r | |
67a58d0f | 798 | \r |
799 | GroupAddress = NULL;\r | |
8a67d61d | 800 | //\r |
801 | // First, analyse the packet header.\r | |
802 | //\r | |
803 | MnpAnalysePacket (MnpServiceData, Nbuf, &RxData, &GroupAddress, &PktAttr);\r | |
804 | \r | |
805 | if (RxData.PromiscuousFlag && (MnpServiceData->PromiscuousCount == 0)) {\r | |
806 | //\r | |
807 | // No receivers, no more action need.\r | |
808 | //\r | |
809 | return ;\r | |
810 | }\r | |
811 | \r | |
812 | //\r | |
813 | // Iterate the children to find match.\r | |
814 | //\r | |
815 | NET_LIST_FOR_EACH (Entry, &MnpServiceData->ChildrenList) {\r | |
816 | \r | |
817 | Instance = NET_LIST_USER_STRUCT (Entry, MNP_INSTANCE_DATA, InstEntry);\r | |
818 | NET_CHECK_SIGNATURE (Instance, MNP_INSTANCE_DATA_SIGNATURE);\r | |
819 | \r | |
820 | if (!Instance->Configured) {\r | |
821 | continue;\r | |
822 | }\r | |
823 | \r | |
824 | //\r | |
825 | // Check the packet against the instance receive filters.\r | |
826 | //\r | |
827 | if (MnpMatchPacket (Instance, &RxData, GroupAddress, PktAttr)) {\r | |
828 | \r | |
829 | //\r | |
830 | // Wrap the RxData.\r | |
831 | //\r | |
687a2e5f | 832 | RxDataWrap = MnpWrapRxData (Instance, &RxData);\r |
8a67d61d | 833 | if (RxDataWrap == NULL) {\r |
834 | continue;\r | |
835 | }\r | |
836 | \r | |
837 | //\r | |
838 | // Associate RxDataWrap with Nbuf and increase the RefCnt.\r | |
839 | //\r | |
840 | RxDataWrap->Nbuf = Nbuf;\r | |
841 | NET_GET_REF (RxDataWrap->Nbuf);\r | |
842 | \r | |
843 | //\r | |
844 | // Queue the packet into the instance queue.\r | |
845 | //\r | |
846 | MnpQueueRcvdPacket (Instance, RxDataWrap);\r | |
847 | }\r | |
848 | }\r | |
849 | }\r | |
850 | \r | |
851 | \r | |
852 | /**\r | |
853 | Try to receive a packet and deliver it.\r | |
854 | \r | |
855 | @param MnpServiceData Pointer to the mnp service context data.\r | |
856 | \r | |
857 | @retval EFI_SUCCESS add return value to function comment\r | |
858 | @retval EFI_NOT_STARTED The simple network protocol is not started.\r | |
859 | @retval EFI_NOT_READY No packet received.\r | |
860 | @retval EFI_DEVICE_ERROR An unexpected error occurs.\r | |
861 | \r | |
862 | **/\r | |
863 | EFI_STATUS\r | |
864 | MnpReceivePacket (\r | |
865 | IN MNP_SERVICE_DATA *MnpServiceData\r | |
866 | )\r | |
867 | {\r | |
868 | EFI_STATUS Status;\r | |
869 | EFI_SIMPLE_NETWORK_PROTOCOL *Snp;\r | |
870 | NET_BUF *Nbuf;\r | |
871 | UINT8 *BufPtr;\r | |
872 | UINTN BufLen;\r | |
873 | UINTN HeaderSize;\r | |
874 | UINT32 Trimmed;\r | |
875 | \r | |
876 | NET_CHECK_SIGNATURE (MnpServiceData, MNP_SERVICE_DATA_SIGNATURE);\r | |
877 | \r | |
878 | Snp = MnpServiceData->Snp;\r | |
879 | if (Snp->Mode->State != EfiSimpleNetworkInitialized) {\r | |
880 | //\r | |
881 | // The simple network protocol is not started.\r | |
882 | //\r | |
883 | return EFI_NOT_STARTED;\r | |
884 | }\r | |
885 | \r | |
886 | if (NetListIsEmpty (&MnpServiceData->ChildrenList)) {\r | |
887 | //\r | |
888 | // There is no child, no need to receive packets.\r | |
889 | //\r | |
890 | return EFI_SUCCESS;\r | |
891 | }\r | |
892 | \r | |
893 | if (MnpServiceData->RxNbufCache == NULL) {\r | |
894 | //\r | |
895 | // Try to get a new buffer as there may be buffers recycled.\r | |
896 | //\r | |
897 | MnpServiceData->RxNbufCache = MnpAllocNbuf (MnpServiceData);\r | |
898 | \r | |
899 | if (MnpServiceData->RxNbufCache == NULL) {\r | |
900 | //\r | |
901 | // No availabe buffer in the buffer pool.\r | |
902 | //\r | |
903 | return EFI_DEVICE_ERROR;\r | |
904 | }\r | |
905 | \r | |
906 | NetbufAllocSpace (\r | |
907 | MnpServiceData->RxNbufCache,\r | |
908 | MnpServiceData->BufferLength,\r | |
909 | NET_BUF_TAIL\r | |
910 | );\r | |
911 | }\r | |
912 | \r | |
913 | Nbuf = MnpServiceData->RxNbufCache;\r | |
914 | BufLen = Nbuf->TotalSize;\r | |
915 | BufPtr = NetbufGetByte (Nbuf, 0, NULL);\r | |
916 | ASSERT (BufPtr != NULL);\r | |
917 | \r | |
918 | //\r | |
919 | // Receive packet through Snp.\r | |
920 | //\r | |
921 | Status = Snp->Receive (Snp, &HeaderSize, &BufLen, BufPtr, NULL, NULL, NULL);\r | |
922 | if (EFI_ERROR (Status)) {\r | |
923 | \r | |
924 | DEBUG_CODE (\r | |
925 | if (Status != EFI_NOT_READY) {\r | |
926 | MNP_DEBUG_ERROR (("MnpReceivePacket: Snp->Receive() = %r.\n", Status));\r | |
927 | }\r | |
928 | );\r | |
929 | \r | |
930 | return Status;\r | |
931 | }\r | |
932 | \r | |
933 | //\r | |
934 | // Sanity check.\r | |
935 | //\r | |
936 | if ((HeaderSize != Snp->Mode->MediaHeaderSize) || (BufLen < HeaderSize)) {\r | |
937 | \r | |
938 | MNP_DEBUG_WARN (\r | |
939 | ("MnpReceivePacket: Size error, HL:TL = %d:%d.\n",\r | |
940 | HeaderSize,\r | |
941 | BufLen)\r | |
942 | );\r | |
943 | return EFI_DEVICE_ERROR;\r | |
944 | }\r | |
945 | \r | |
946 | Trimmed = 0;\r | |
947 | if (Nbuf->TotalSize != BufLen) {\r | |
948 | //\r | |
949 | // Trim the packet from tail.\r | |
950 | //\r | |
951 | Trimmed = NetbufTrim (Nbuf, Nbuf->TotalSize - (UINT32) BufLen, NET_BUF_TAIL);\r | |
952 | ASSERT (Nbuf->TotalSize == BufLen);\r | |
953 | }\r | |
954 | \r | |
955 | //\r | |
956 | // Enqueue the packet to the matched instances.\r | |
957 | //\r | |
958 | MnpEnqueuePacket (MnpServiceData, Nbuf);\r | |
959 | \r | |
960 | if (Nbuf->RefCnt > 2) {\r | |
961 | //\r | |
962 | // RefCnt > 2 indicates there is at least one receiver of this packet.\r | |
963 | // Free the current RxNbufCache and allocate a new one.\r | |
964 | //\r | |
965 | MnpFreeNbuf (MnpServiceData, Nbuf);\r | |
966 | \r | |
967 | Nbuf = MnpAllocNbuf (MnpServiceData);\r | |
968 | MnpServiceData->RxNbufCache = Nbuf;\r | |
969 | if (Nbuf == NULL) {\r | |
970 | MNP_DEBUG_ERROR (("MnpReceivePacket: Alloc packet for receiving cache failed.\n"));\r | |
971 | return EFI_DEVICE_ERROR;\r | |
972 | }\r | |
973 | \r | |
974 | NetbufAllocSpace (Nbuf, MnpServiceData->BufferLength, NET_BUF_TAIL);\r | |
975 | } else {\r | |
976 | //\r | |
977 | // No receiver for this packet.\r | |
978 | //\r | |
772db4bb | 979 | if (Trimmed > 0) {\r |
980 | NetbufAllocSpace (Nbuf, Trimmed, NET_BUF_TAIL);\r | |
981 | }\r | |
982 | \r | |
8a67d61d | 983 | goto EXIT;\r |
984 | }\r | |
985 | //\r | |
986 | // Deliver the queued packets.\r | |
987 | //\r | |
988 | MnpDeliverPacket (MnpServiceData);\r | |
989 | \r | |
990 | EXIT:\r | |
991 | \r | |
992 | ASSERT (Nbuf->TotalSize == MnpServiceData->BufferLength);\r | |
993 | \r | |
994 | return Status;\r | |
995 | }\r | |
996 | \r | |
997 | \r | |
998 | /**\r | |
999 | Remove the received packets if timeout occurs.\r | |
1000 | \r | |
1001 | @param Event The event this notify function registered to.\r | |
1002 | @param Context Pointer to the context data registered to the\r | |
1003 | event.\r | |
1004 | \r | |
1005 | @return None.\r | |
1006 | \r | |
1007 | **/\r | |
1008 | VOID\r | |
1009 | EFIAPI\r | |
1010 | MnpCheckPacketTimeout (\r | |
1011 | IN EFI_EVENT Event,\r | |
1012 | IN VOID *Context\r | |
1013 | )\r | |
1014 | {\r | |
1015 | MNP_SERVICE_DATA *MnpServiceData;\r | |
1016 | NET_LIST_ENTRY *Entry;\r | |
1017 | NET_LIST_ENTRY *RxEntry;\r | |
1018 | NET_LIST_ENTRY *NextEntry;\r | |
1019 | MNP_INSTANCE_DATA *Instance;\r | |
1020 | MNP_RXDATA_WRAP *RxDataWrap;\r | |
1021 | EFI_TPL OldTpl;\r | |
1022 | \r | |
1023 | MnpServiceData = (MNP_SERVICE_DATA *) Context;\r | |
1024 | NET_CHECK_SIGNATURE (MnpServiceData, MNP_SERVICE_DATA_SIGNATURE);\r | |
1025 | \r | |
1026 | NET_LIST_FOR_EACH (Entry, &MnpServiceData->ChildrenList) {\r | |
1027 | \r | |
1028 | Instance = NET_LIST_USER_STRUCT (Entry, MNP_INSTANCE_DATA, InstEntry);\r | |
1029 | NET_CHECK_SIGNATURE (Instance, MNP_INSTANCE_DATA_SIGNATURE);\r | |
1030 | \r | |
1031 | if (!Instance->Configured || (Instance->ConfigData.ReceivedQueueTimeoutValue == 0)) {\r | |
1032 | //\r | |
1033 | // This instance is not configured or there is no receive time out,\r | |
1034 | // just skip to the next instance.\r | |
1035 | //\r | |
1036 | continue;\r | |
1037 | }\r | |
1038 | \r | |
1039 | OldTpl = NET_RAISE_TPL (NET_TPL_RECYCLE);\r | |
1040 | \r | |
1041 | NET_LIST_FOR_EACH_SAFE (RxEntry, NextEntry, &Instance->RcvdPacketQueue) {\r | |
1042 | \r | |
1043 | RxDataWrap = NET_LIST_USER_STRUCT (RxEntry, MNP_RXDATA_WRAP, WrapEntry);\r | |
1044 | \r | |
1045 | if (RxDataWrap->TimeoutTick >= MNP_TIMEOUT_CHECK_INTERVAL) {\r | |
1046 | \r | |
1047 | RxDataWrap->TimeoutTick -= MNP_TIMEOUT_CHECK_INTERVAL;\r | |
1048 | } else {\r | |
1049 | //\r | |
1050 | // Drop the timeout packet.\r | |
1051 | //\r | |
1052 | MNP_DEBUG_WARN (("MnpCheckPacketTimeout: Received packet timeout.\n"));\r | |
1053 | MnpRecycleRxData (NULL, RxDataWrap);\r | |
1054 | Instance->RcvdPacketQueueSize--;\r | |
1055 | }\r | |
1056 | }\r | |
1057 | \r | |
1058 | NET_RESTORE_TPL (OldTpl);\r | |
1059 | }\r | |
1060 | }\r | |
1061 | \r | |
1062 | \r | |
1063 | /**\r | |
1064 | Poll to receive the packets from Snp. This function is either called by upperlayer\r | |
1065 | protocols/applications or the system poll timer notify mechanism.\r | |
1066 | \r | |
1067 | @param Event The event this notify function registered to.\r | |
1068 | @param Context Pointer to the context data registered to the\r | |
1069 | event.\r | |
1070 | \r | |
1071 | @return None.\r | |
1072 | \r | |
1073 | **/\r | |
1074 | VOID\r | |
1075 | EFIAPI\r | |
1076 | MnpSystemPoll (\r | |
1077 | IN EFI_EVENT Event,\r | |
1078 | IN VOID *Context\r | |
1079 | )\r | |
1080 | {\r | |
1081 | MNP_SERVICE_DATA *MnpServiceData;\r | |
1082 | \r | |
1083 | MnpServiceData = (MNP_SERVICE_DATA *) Context;\r | |
1084 | NET_CHECK_SIGNATURE (MnpServiceData, MNP_SERVICE_DATA_SIGNATURE);\r | |
1085 | \r | |
1086 | //\r | |
1087 | // Try to receive packets from Snp.\r | |
1088 | //\r | |
1089 | MnpReceivePacket (MnpServiceData);\r | |
1090 | }\r |