1 /*
2 * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
3 *
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the
15 * distribution.
16 *
17 * Neither the name of Texas Instruments Incorporated nor the names of
18 * its contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 */
35 /* ========================================================================== */
36 /* Include Files */
37 /* ========================================================================== */
39 #include <stdio.h>
40 #include <string.h>
41 #include <stdlib.h>
42 #include <ti/ndk/inc/stkmain.h>
43 #include <ti/sysbios/BIOS.h>
44 #include <ti/sysbios/knl/Task.h>
46 #include <ti/drv/emac/emac_drv.h>
47 #include <ti/drv/emac/src/v4/emac_drv_v4.h>
48 #include <ti/board/board.h>
50 /* UART Header files */
51 #include <ti/drv/uart/UART.h>
52 #include <ti/drv/uart/UART_stdio.h>
54 void app_stats(UArg arg0, UArg arg1);
56 void app_stats(UArg arg0, UArg arg1)
57 {
58 EMAC_STATISTICS_T stats;
59 EMAC_DRV_ERR_E ret = EMAC_DRV_RESULT_OK;
61 while (TRUE) {
62 memset(&stats, 0, sizeof(EMAC_STATISTICS_T));
64 /* Read EMAC statistics */
65 ret = emac_get_statistics(0, &stats);
67 if (ret != EMAC_DRV_RESULT_OK) {
68 UART_printf("Failed to retrieve EMAC stats: %d\n", ret);
69 continue;
70 }
72 UART_printf("--------------------------------------------------------------------------------------\n");
73 UART_printf(" RX | Good:%8d | Bcast:%8d | Mcast:%8d | Oct:%12d |\n",
74 stats.RxGoodFrames,
75 stats.RxBCastFrames,
76 stats.RxMCastFrames,
77 stats.RxOctets);
78 UART_printf(" RX | Pause:%8d | CRC:%8d | AlignErr:%8d | Oversz:%12d |\n",
79 stats.RxPauseFrames,
80 stats.RxCRCErrors,
81 stats.RxAlignCodeErrors,
82 stats.RxOversized);
83 UART_printf(" RX | Jabber:%8d | Undersz:%8d | Frag:%8d | Filt:%12d |\n",
84 stats.RxJabber,
85 stats.RxUndersized,
86 stats.RxFragments,
87 stats.RxFiltered);
88 UART_printf(" RX | QoS:%8d | SOFOvr:%8d | MOFOvr:%8d | DMAOvr:%12d |\n",
89 stats.RxQOSFiltered,
90 stats.RxSOFOverruns,
91 stats.RxMOFOverruns,
92 stats.RxDMAOverruns);
93 UART_printf(" TX | Good:%8d | Bcast:%8d | Mcast:%8d | Oct:%12d |\n",
94 stats.TxGoodFrames,
95 stats.TxBCastFrames,
96 stats.TxMCastFrames,
97 stats.TxOctets);
98 UART_printf(" TX | Pause:%8d | Deferred:%7d | Coll:%8d | Udrn:%12d |\n",
99 stats.TxPauseFrames,
100 stats.TxDeferred,
101 stats.TxCollision,
102 stats.TxUnderrun);
104 UART_printf("--------------------------------------------------------------------------------------\n");
106 Task_sleep(10000);
107 }
108 }