1 /**************************************************************************/ 2 /* */ 3 /* Copyright (c) Microsoft Corporation. All rights reserved. */ 4 /* */ 5 /* This software is licensed under the Microsoft Software License */ 6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */ 7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ 8 /* and in the root directory of this software. */ 9 /* */ 10 /**************************************************************************/ 11 12 13 /**************************************************************************/ 14 /**************************************************************************/ 15 /** */ 16 /** NetX Component */ 17 /** */ 18 /** Internet Protocol (IP) */ 19 /** */ 20 /**************************************************************************/ 21 /**************************************************************************/ 22 23 #define NX_SOURCE_CODE 24 25 26 /* Include necessary system files. */ 27 28 #include "nx_api.h" 29 #include "nx_ip.h" 30 #include "nx_packet.h" 31 32 33 /**************************************************************************/ 34 /* */ 35 /* FUNCTION RELEASE */ 36 /* */ 37 /* _nx_ip_driver_deferred_receive PORTABLE C */ 38 /* 6.1 */ 39 /* AUTHOR */ 40 /* */ 41 /* Yuxin Zhou, Microsoft Corporation */ 42 /* */ 43 /* DESCRIPTION */ 44 /* */ 45 /* This function places the supplied packet on the driver's deferred */ 46 /* receive queue. It will be processed later during subsequent */ 47 /* execution of the IP helper thread by calling the driver's deferred */ 48 /* handling routine. */ 49 /* */ 50 /* INPUT */ 51 /* */ 52 /* ip_ptr Pointer to IP control block */ 53 /* packet_ptr Raw receive packet */ 54 /* */ 55 /* OUTPUT */ 56 /* */ 57 /* None */ 58 /* */ 59 /* CALLS */ 60 /* */ 61 /* None */ 62 /* */ 63 /* CALLED BY */ 64 /* */ 65 /* Application Driver Receive ISR */ 66 /* */ 67 /* RELEASE HISTORY */ 68 /* */ 69 /* DATE NAME DESCRIPTION */ 70 /* */ 71 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ 72 /* 09-30-2020 Yuxin Zhou Modified comment(s), */ 73 /* resulting in version 6.1 */ 74 /* */ 75 /**************************************************************************/ _nx_ip_driver_deferred_receive(NX_IP * ip_ptr,NX_PACKET * packet_ptr)76VOID _nx_ip_driver_deferred_receive(NX_IP *ip_ptr, NX_PACKET *packet_ptr) 77 { 78 79 #ifdef NX_DRIVER_DEFERRED_PROCESSING 80 TX_INTERRUPT_SAVE_AREA 81 82 /* Disable interrupts. */ 83 TX_DISABLE 84 85 /* Add the packet to the end of the driver queue for processing */ 86 packet_ptr -> nx_packet_queue_next = NX_NULL; 87 if (ip_ptr -> nx_ip_driver_deferred_packet_head == NX_NULL) 88 { 89 90 /* The queue is empty, set both the first and last packet 91 pointers to the new packet */ 92 ip_ptr -> nx_ip_driver_deferred_packet_head = packet_ptr; 93 ip_ptr -> nx_ip_driver_deferred_packet_tail = packet_ptr; 94 95 /* Restore interrupts. */ 96 TX_RESTORE 97 98 /* Wakeup IP helper thread to process the packet. */ 99 tx_event_flags_set(&(ip_ptr -> nx_ip_events), NX_IP_DRIVER_PACKET_EVENT, TX_OR); 100 } 101 else 102 { 103 104 /* The queue is not empty, simply add the packet to the end of the queue. */ 105 (ip_ptr -> nx_ip_driver_deferred_packet_tail) -> nx_packet_queue_next = packet_ptr; 106 ip_ptr -> nx_ip_driver_deferred_packet_tail = packet_ptr; 107 108 /* Restore interrupts. */ 109 TX_RESTORE 110 } 111 112 #else 113 NX_PARAMETER_NOT_USED(ip_ptr); 114 115 /* No deferred packet processing, just release the packet. */ 116 _nx_packet_release(packet_ptr); 117 #endif 118 } 119 120