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