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 /**   Packet Pool Management (Packet)                                     */
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_packet.h"
29 
30 
31 /**************************************************************************/
32 /*                                                                        */
33 /*  FUNCTION                                               RELEASE        */
34 /*                                                                        */
35 /*    _nx_packet_pool_low_watermark_set                   PORTABLE C      */
36 /*                                                           6.1          */
37 /*  AUTHOR                                                                */
38 /*                                                                        */
39 /*    Yuxin Zhou, Microsoft Corporation                                   */
40 /*                                                                        */
41 /*  DESCRIPTION                                                           */
42 /*                                                                        */
43 /*    This function sets the low watermark for the specified packet pool. */
44 /*                                                                        */
45 /*  INPUT                                                                 */
46 /*                                                                        */
47 /*    pool_ptr                              Pointer to packet pool        */
48 /*    low_watermark                         Low watermark of packet pool  */
49 /*                                                                        */
50 /*  OUTPUT                                                                */
51 /*                                                                        */
52 /*    status                                Completion status             */
53 /*                                                                        */
54 /*  CALLS                                                                 */
55 /*                                                                        */
56 /*  CALLED BY                                                             */
57 /*                                                                        */
58 /*    Application Code                                                    */
59 /*                                                                        */
60 /*  RELEASE HISTORY                                                       */
61 /*                                                                        */
62 /*    DATE              NAME                      DESCRIPTION             */
63 /*                                                                        */
64 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
65 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
66 /*                                            resulting in version 6.1    */
67 /*                                                                        */
68 /**************************************************************************/
_nx_packet_pool_low_watermark_set(NX_PACKET_POOL * pool_ptr,ULONG low_watermark)69 UINT  _nx_packet_pool_low_watermark_set(NX_PACKET_POOL *pool_ptr, ULONG low_watermark)
70 {
71 #ifdef NX_ENABLE_LOW_WATERMARK
72 
73 TX_INTERRUPT_SAVE_AREA
74 
75     /* Disable interrupts to get a packet from the pool.  */
76     TX_DISABLE
77 
78     /* Set low watermark to packet pool. */
79     pool_ptr -> nx_packet_pool_low_watermark = low_watermark;
80 
81     /* Restore interrupts.  */
82     TX_RESTORE
83 
84     /* Return completion status.  */
85     return(NX_SUCCESS);
86 
87 #else /* !NX_ENABLE_LOW_WATERMARK */
88     NX_PARAMETER_NOT_USED(pool_ptr);
89     NX_PARAMETER_NOT_USED(low_watermark);
90 
91     return(NX_NOT_SUPPORTED);
92 
93 #endif /* NX_ENABLE_LOW_WATERMARK */
94 }
95 
96