2 * FreeRTOS Kernel V10.2.0
\r
3 * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
\r
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
\r
6 * this software and associated documentation files (the "Software"), to deal in
\r
7 * the Software without restriction, including without limitation the rights to
\r
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
\r
9 * the Software, and to permit persons to whom the Software is furnished to do so,
\r
10 * subject to the following conditions:
\r
12 * The above copyright notice and this permission notice shall be included in all
\r
13 * copies or substantial portions of the Software.
\r
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
\r
17 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
\r
18 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
22 * http://www.FreeRTOS.org
\r
23 * http://aws.amazon.com/freertos
\r
25 * 1 tab == 4 spaces!
\r
29 * This file, along with DemoIPTrace.h, provides a basic example use of the
\r
30 * FreeRTOS+UDP trace macros. The statistics gathered here can be viewed in
\r
31 * the command line interface.
\r
32 * See http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/UDP_IP_Trace.shtml
\r
35 #ifndef DEMO_IP_TRACE_MACROS_H
\r
36 #define DEMO_IP_TRACE_MACROS_H
\r
38 typedef void ( *vTraceAction_t )( uint32_t *, uint32_t );
\r
40 /* Type that defines each statistic being gathered. */
\r
41 typedef struct ExampleDebugStatEntry
\r
43 uint8_t ucIdentifier; /* Unique identifier for statistic. */
\r
44 const uint8_t * const pucDescription; /* Text description for the statistic. */
\r
45 vTraceAction_t vPerformAction; /* Action to perform when the statistic is updated (increment counter, store minimum value, store maximum value, etc. */
\r
46 uint32_t ulData; /* The meaning of this data is dependent on the trace macro ID. */
\r
47 } xExampleDebugStatEntry_t;
\r
49 /* Unique identifiers used to locate the entry for each trace macro in the
\r
50 xIPTraceValues[] table defined in DemoIPTrace.c. */
\r
51 #define iptraceID_NETWORK_INTERFACE_RECEIVE 0
\r
52 #define iptraceID_NETWORK_INTERFACE_TRANSMIT 1
\r
53 #define iptraceID_PACKET_DROPPED_TO_GENERATE_ARP 2
\r
54 /* Do not change IDs above this line as the ID is shared with a FreeRTOS+Nabto
\r
56 #define iptraceID_NETWORK_BUFFER_OBTAINED 3
\r
57 #define iptraceID_NETWORK_BUFFER_OBTAINED_FROM_ISR 4
\r
58 #define iptraceID_NETWORK_EVENT_RECEIVED 5
\r
59 #define iptraceID_FAILED_TO_OBTAIN_NETWORK_BUFFER 6
\r
60 #define iptraceID_ARP_TABLE_ENTRY_EXPIRED 7
\r
61 #define iptraceID_FAILED_TO_CREATE_SOCKET 8
\r
62 #define iptraceID_RECVFROM_DISCARDING_BYTES 9
\r
63 #define iptraceID_ETHERNET_RX_EVENT_LOST 10
\r
64 #define iptraceID_STACK_TX_EVENT_LOST 11
\r
65 #define ipconfigID_BIND_FAILED 12
\r
66 #define iptraceID_RECVFROM_TIMEOUT 13
\r
67 #define iptraceID_SENDTO_DATA_TOO_LONG 14
\r
68 #define iptraceID_SENDTO_SOCKET_NOT_BOUND 15
\r
69 #define iptraceID_NO_BUFFER_FOR_SENDTO 16
\r
70 #define iptraceID_WAIT_FOR_TX_DMA_DESCRIPTOR 17
\r
71 #define iptraceID_FAILED_TO_NOTIFY_SELECT_GROUP 18
\r
73 /* It is possible to remove the trace macros using the
\r
74 configINCLUDE_DEMO_DEBUG_STATS setting in FreeRTOSIPConfig.h. */
\r
75 #if configINCLUDE_DEMO_DEBUG_STATS == 1
\r
77 /* The trace macro definitions themselves. Any trace macros left undefined
\r
78 will default to be empty macros. */
\r
79 #define iptraceNETWORK_BUFFER_OBTAINED( pxBufferAddress ) vExampleDebugStatUpdate( iptraceID_NETWORK_BUFFER_OBTAINED, uxQueueMessagesWaiting( ( xQueueHandle ) xNetworkBufferSemaphore ) )
\r
80 #define iptraceNETWORK_BUFFER_OBTAINED_FROM_ISR( pxBufferAddress ) vExampleDebugStatUpdate( iptraceID_NETWORK_BUFFER_OBTAINED, uxQueueMessagesWaiting( ( xQueueHandle ) xNetworkBufferSemaphore ) )
\r
82 #define iptraceNETWORK_EVENT_RECEIVED( eEvent ) { \
\r
84 usSpace = ( uint16_t ) uxQueueMessagesWaiting( xNetworkEventQueue ); \
\r
85 /* Minus one as an event was removed before the space was queried. */ \
\r
86 usSpace = ( ipconfigEVENT_QUEUE_LENGTH - usSpace ) - 1; \
\r
87 vExampleDebugStatUpdate( iptraceID_NETWORK_EVENT_RECEIVED, usSpace ); \
\r
90 #define iptraceFAILED_TO_OBTAIN_NETWORK_BUFFER() vExampleDebugStatUpdate( iptraceID_FAILED_TO_OBTAIN_NETWORK_BUFFER, 0 )
\r
91 #define iptraceARP_TABLE_ENTRY_EXPIRED( ulIPAddress ) vExampleDebugStatUpdate( iptraceID_ARP_TABLE_ENTRY_EXPIRED, 0 )
\r
92 #define iptracePACKET_DROPPED_TO_GENERATE_ARP( ulIPAddress ) vExampleDebugStatUpdate( iptraceID_PACKET_DROPPED_TO_GENERATE_ARP, 0 )
\r
93 #define iptraceFAILED_TO_CREATE_SOCKET() vExampleDebugStatUpdate( iptraceID_FAILED_TO_CREATE_SOCKET, 0 )
\r
94 #define iptraceRECVFROM_DISCARDING_BYTES( xNumberOfBytesDiscarded ) vExampleDebugStatUpdate( iptraceID_RECVFROM_DISCARDING_BYTES, 0 )
\r
95 #define iptraceETHERNET_RX_EVENT_LOST() vExampleDebugStatUpdate( iptraceID_ETHERNET_RX_EVENT_LOST, 0 )
\r
96 #define iptraceSTACK_TX_EVENT_LOST( xEvent ) vExampleDebugStatUpdate( iptraceID_STACK_TX_EVENT_LOST, 0 )
\r
97 #define iptraceBIND_FAILED( xSocket, usPort ) vExampleDebugStatUpdate( ipconfigID_BIND_FAILED, 0 )
\r
98 #define iptraceNETWORK_INTERFACE_TRANSMIT() vExampleDebugStatUpdate( iptraceID_NETWORK_INTERFACE_TRANSMIT, 0 )
\r
99 #define iptraceRECVFROM_TIMEOUT() vExampleDebugStatUpdate( iptraceID_RECVFROM_TIMEOUT, 0 )
\r
100 #define iptraceSENDTO_DATA_TOO_LONG() vExampleDebugStatUpdate( iptraceID_SENDTO_DATA_TOO_LONG, 0 )
\r
101 #define iptraceSENDTO_SOCKET_NOT_BOUND() vExampleDebugStatUpdate( iptraceID_SENDTO_SOCKET_NOT_BOUND, 0 )
\r
102 #define iptraceNO_BUFFER_FOR_SENDTO() vExampleDebugStatUpdate( iptraceID_NO_BUFFER_FOR_SENDTO, 0 )
\r
103 #define iptraceWAITING_FOR_TX_DMA_DESCRIPTOR() vExampleDebugStatUpdate( iptraceID_WAIT_FOR_TX_DMA_DESCRIPTOR, 0 )
\r
104 #define iptraceFAILED_TO_NOTIFY_SELECT_GROUP( xSocket ) vExampleDebugStatUpdate( iptraceID_FAILED_TO_NOTIFY_SELECT_GROUP, 0 )
\r
105 #define iptraceNETWORK_INTERFACE_RECEIVE() vExampleDebugStatUpdate( iptraceID_NETWORK_INTERFACE_RECEIVE, 0 )
\r
108 * The function that updates a line in the xIPTraceValues table.
\r
110 void vExampleDebugStatUpdate( uint8_t ucIdentifier, uint32_t ulValue );
\r
113 * Returns the number of entries in the xIPTraceValues table.
\r
115 BaseType_t xExampleDebugStatEntries( void );
\r
117 #endif /* configINCLUDE_DEMO_DEBUG_STATS == 1 */
\r
120 #endif /* DEMO_IP_TRACE_MACROS_H */
\r