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 /** Packet Pool Management (Packet) */
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_packet.h"
30
31
32 /**************************************************************************/
33 /* */
34 /* FUNCTION RELEASE */
35 /* */
36 /* _nx_packet_pool_info_get PORTABLE C */
37 /* 6.1 */
38 /* AUTHOR */
39 /* */
40 /* Yuxin Zhou, Microsoft Corporation */
41 /* */
42 /* DESCRIPTION */
43 /* */
44 /* This function retrieves information about the specified packet */
45 /* pool. */
46 /* */
47 /* INPUT */
48 /* */
49 /* pool_ptr Pool to get information from */
50 /* total_packets Destination for total packets */
51 /* free_packets Destination for free packets */
52 /* empty_pool_requests Destination for empty requests*/
53 /* empty_pool_suspensions Destination for empty */
54 /* suspensions */
55 /* invalid_packet_releases Destination for invalid packet*/
56 /* release requests */
57 /* */
58 /* OUTPUT */
59 /* */
60 /* status Completion status */
61 /* */
62 /* CALLS */
63 /* */
64 /* None */
65 /* */
66 /* CALLED BY */
67 /* */
68 /* Application Code */
69 /* */
70 /* RELEASE HISTORY */
71 /* */
72 /* DATE NAME DESCRIPTION */
73 /* */
74 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
75 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
76 /* resulting in version 6.1 */
77 /* */
78 /**************************************************************************/
_nx_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)79 UINT _nx_packet_pool_info_get(NX_PACKET_POOL *pool_ptr, ULONG *total_packets, ULONG *free_packets,
80 ULONG *empty_pool_requests, ULONG *empty_pool_suspensions,
81 ULONG *invalid_packet_releases)
82 {
83 TX_INTERRUPT_SAVE_AREA
84
85
86 /* Disable interrupts to get packet pool information. */
87 TX_DISABLE
88
89 /* Determine if pool total packets is wanted. */
90 if (total_packets)
91 {
92
93 /* Return the number of total packets in this pool. */
94 *total_packets = pool_ptr -> nx_packet_pool_total;
95 }
96
97 /* Determine if pool free packets is wanted. */
98 if (free_packets)
99 {
100
101 /* Return the number of free packets in this pool. */
102 *free_packets = pool_ptr -> nx_packet_pool_available;
103 }
104
105 /* Determine if empty pool requests is wanted. */
106 if (empty_pool_requests)
107 {
108
109 /* Return the number of empty pool requests made in this pool. */
110 *empty_pool_requests = pool_ptr -> nx_packet_pool_empty_requests;
111 }
112
113 /* Determine if empty pool suspensions is wanted. */
114 if (empty_pool_suspensions)
115 {
116
117 /* Return the number of empty pool suspensions made in this pool. */
118 *empty_pool_suspensions = pool_ptr -> nx_packet_pool_empty_suspensions;
119 }
120
121 /* Determine if invalid packet releases is wanted. */
122 if (invalid_packet_releases)
123 {
124
125 /* Return the number of invalid packet releases made in this pool. */
126 *invalid_packet_releases = pool_ptr -> nx_packet_pool_invalid_releases;
127 }
128
129 /* Restore interrupts. */
130 TX_RESTORE
131
132 /* If trace is enabled, insert this event into the trace buffer. */
133 NX_TRACE_IN_LINE_INSERT(NX_TRACE_PACKET_POOL_INFO_GET, pool_ptr, pool_ptr -> nx_packet_pool_total, pool_ptr -> nx_packet_pool_available, pool_ptr -> nx_packet_pool_empty_requests, NX_TRACE_PACKET_EVENTS, 0, 0);
134
135 /* Return completion status. */
136 return(NX_SUCCESS);
137 }
138
139