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 
30 
31 /**************************************************************************/
32 /*                                                                        */
33 /*  FUNCTION                                               RELEASE        */
34 /*                                                                        */
35 /*    _nx_ip_driver_deferred_enable                       PORTABLE C      */
36 /*                                                           6.1          */
37 /*  AUTHOR                                                                */
38 /*                                                                        */
39 /*    Yuxin Zhou, Microsoft Corporation                                   */
40 /*                                                                        */
41 /*  DESCRIPTION                                                           */
42 /*                                                                        */
43 /*    This function enabled the deferred driver packet processing         */
44 /*    in NetX.  The supplied driver packet handler is called from the     */
45 /*    IP helper thread to fully process a received driver packet.  The    */
46 /*    driver's receive packet processing only makes a call to the         */
47 /*    _nx_ip_driver_deferred_receive processing from the ISR.             */
48 /*                                                                        */
49 /*  INPUT                                                                 */
50 /*                                                                        */
51 /*    ip_ptr                                Pointer to IP control block   */
52 /*    driver_deferred_packet_handler        Function pointer to driver's  */
53 /*                                            deferred packet handling    */
54 /*                                            routine                     */
55 /*                                                                        */
56 /*  OUTPUT                                                                */
57 /*                                                                        */
58 /*    None                                                                */
59 /*                                                                        */
60 /*  CALLS                                                                 */
61 /*                                                                        */
62 /*    None                                                                */
63 /*                                                                        */
64 /*  CALLED BY                                                             */
65 /*                                                                        */
66 /*    Application Driver Initialization                                   */
67 /*                                                                        */
68 /*  RELEASE HISTORY                                                       */
69 /*                                                                        */
70 /*    DATE              NAME                      DESCRIPTION             */
71 /*                                                                        */
72 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
73 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
74 /*                                            resulting in version 6.1    */
75 /*                                                                        */
76 /**************************************************************************/
_nx_ip_driver_deferred_enable(NX_IP * ip_ptr,VOID (* driver_deferred_packet_handler)(NX_IP * ip_ptr,NX_PACKET * packet_ptr))77 VOID  _nx_ip_driver_deferred_enable(NX_IP *ip_ptr, VOID (*driver_deferred_packet_handler)(NX_IP *ip_ptr, NX_PACKET *packet_ptr))
78 {
79 
80 #ifdef NX_DRIVER_DEFERRED_PROCESSING
81 TX_INTERRUPT_SAVE_AREA
82 
83     /* Disable interrupts.  */
84     TX_DISABLE
85 
86     /* Initialize the deferred packet queue to be empty */
87     ip_ptr -> nx_ip_driver_deferred_packet_head =  NX_NULL;
88     ip_ptr -> nx_ip_driver_deferred_packet_tail =  NX_NULL;
89 
90     /* Setup the driver's deferred packet processing routine */
91     ip_ptr ->  nx_ip_driver_deferred_packet_handler =  driver_deferred_packet_handler;
92 
93     TX_RESTORE
94 #else
95     NX_PARAMETER_NOT_USED(ip_ptr);
96     NX_PARAMETER_NOT_USED(driver_deferred_packet_handler);
97 #endif
98 }
99 
100