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 
31 
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _nx_ip_auxiliary_packet_pool_set                    PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Yuxin Zhou, Microsoft Corporation                                   */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function assigns an auxiliary packet pool to IP instance.      */
45 /*    Note in order to utilize the auxiliary packet pool feature, the     */
46 /*    symbol NX_ENABLE_DUAL_PACKET_POOL must be defined when building     */
47 /*    NetX Duo library.                                                   */
48 /*                                                                        */
49 /*  INPUT                                                                 */
50 /*                                                                        */
51 /*    ip_ptr                                Pointer to IP control block   */
52 /*    auxiliary_pool                        Pointer to auxiliary packet   */
53 /*                                            pool                        */
54 /*                                                                        */
55 /*  OUTPUT                                                                */
56 /*                                                                        */
57 /*    status                                Completion status             */
58 /*                                                                        */
59 /*  CALLS                                                                 */
60 /*                                                                        */
61 /*    tx_mutex_get                          Get protection mutex          */
62 /*    tx_mutex_put                          Put protection mutex          */
63 /*                                                                        */
64 /*  CALLED BY                                                             */
65 /*                                                                        */
66 /*    Application                                                         */
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_auxiliary_packet_pool_set(NX_IP * ip_ptr,NX_PACKET_POOL * auxiliary_pool)77 UINT  _nx_ip_auxiliary_packet_pool_set(NX_IP *ip_ptr, NX_PACKET_POOL *auxiliary_pool)
78 {
79 
80 #ifdef NX_ENABLE_DUAL_PACKET_POOL
81 TX_INTERRUPT_SAVE_AREA
82 
83 
84     /* Disable interrupts.  */
85     TX_DISABLE
86 
87     /* Choose a packet pool with smaller payload size as auxiliary packet pool. */
88     if (auxiliary_pool -> nx_packet_pool_payload_size > ip_ptr -> nx_ip_default_packet_pool -> nx_packet_pool_payload_size)
89     {
90         ip_ptr -> nx_ip_default_packet_pool = auxiliary_pool;
91     }
92     else
93     {
94         ip_ptr -> nx_ip_auxiliary_packet_pool = auxiliary_pool;
95     }
96 
97     /* Restore interrupts.  */
98     TX_RESTORE
99 
100     /* Return success to the caller.  */
101     return(NX_SUCCESS);
102 
103 #else /* !NX_ENABLE_DUAL_PACKET_POOL */
104     NX_PARAMETER_NOT_USED(ip_ptr);
105     NX_PARAMETER_NOT_USED(auxiliary_pool);
106 
107     return(NX_NOT_SUPPORTED);
108 
109 #endif /* NX_ENABLE_DUAL_PACKET_POOL */
110 }
111 
112