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 /* Bring in externs for caller checking code.  */
31 
32 NX_CALLER_CHECKING_EXTERNS
33 
34 
35 /**************************************************************************/
36 /*                                                                        */
37 /*  FUNCTION                                               RELEASE        */
38 /*                                                                        */
39 /*    _nxe_packet_pool_info_get                           PORTABLE C      */
40 /*                                                           6.1          */
41 /*  AUTHOR                                                                */
42 /*                                                                        */
43 /*    Yuxin Zhou, Microsoft Corporation                                   */
44 /*                                                                        */
45 /*  DESCRIPTION                                                           */
46 /*                                                                        */
47 /*    This function checks for errors in the packet pool information get  */
48 /*    function call.                                                      */
49 /*                                                                        */
50 /*  INPUT                                                                 */
51 /*                                                                        */
52 /*    pool_ptr                              Pool to get information from  */
53 /*    total_packets                         Destination for total packets */
54 /*    free_packets                          Destination for free packets  */
55 /*    empty_pool_requests                   Destination for empty requests*/
56 /*    empty_pool_suspensions                Destination for empty         */
57 /*                                            suspensions                 */
58 /*    invalid_packet_releases               Destination for invalid packet*/
59 /*                                            release requests            */
60 /*                                                                        */
61 /*  OUTPUT                                                                */
62 /*                                                                        */
63 /*    status                                Completion status             */
64 /*                                                                        */
65 /*  CALLS                                                                 */
66 /*                                                                        */
67 /*    _nx_packet_pool_info_get              Actual packet pool info get   */
68 /*                                            function                    */
69 /*                                                                        */
70 /*  CALLED BY                                                             */
71 /*                                                                        */
72 /*    Application Code                                                    */
73 /*                                                                        */
74 /*  RELEASE HISTORY                                                       */
75 /*                                                                        */
76 /*    DATE              NAME                      DESCRIPTION             */
77 /*                                                                        */
78 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
79 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
80 /*                                            resulting in version 6.1    */
81 /*                                                                        */
82 /**************************************************************************/
_nxe_packet_pool_info_get(NX_PACKET_POOL * pool_ptr,ULONG * total_packets,ULONG * free_packets,ULONG * empty_pool_requests,ULONG * empty_pool_suspensions,ULONG * invalid_packet_releases)83 UINT  _nxe_packet_pool_info_get(NX_PACKET_POOL *pool_ptr, ULONG *total_packets, ULONG *free_packets,
84                                 ULONG *empty_pool_requests, ULONG *empty_pool_suspensions,
85                                 ULONG *invalid_packet_releases)
86 {
87 
88 UINT status;
89 
90 
91     /* Check for invalid input pointers.  */
92     if ((pool_ptr == NX_NULL) || (pool_ptr -> nx_packet_pool_id != NX_PACKET_POOL_ID))
93     {
94         return(NX_PTR_ERROR);
95     }
96 
97     /* Check for appropriate caller.  */
98     NX_NOT_ISR_CALLER_CHECKING
99 
100     /* Call actual packet pool information get function.  */
101     status =  _nx_packet_pool_info_get(pool_ptr, total_packets, free_packets, empty_pool_requests,
102                                        empty_pool_suspensions, invalid_packet_releases);
103 
104     /* Return completion status.  */
105     return(status);
106 }
107 
108