]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/pdk.git/blob - packages/ti/board/diag/cpsw/src/cpsw_eth_test.h
3ee1edf7ca0ea1c62ea1c462fbc580add9554593
[processor-sdk/pdk.git] / packages / ti / board / diag / cpsw / src / cpsw_eth_test.h
1 /******************************************************************************\r
2  * Copyright (c) 2019 Texas Instruments Incorporated - http://www.ti.com\r
3  *\r
4  *  Redistribution and use in source and binary forms, with or without\r
5  *  modification, are permitted provided that the following conditions\r
6  *  are met:\r
7  *\r
8  *    Redistributions of source code must retain the above copyright\r
9  *    notice, this list of conditions and the following disclaimer.\r
10  *\r
11  *    Redistributions in binary form must reproduce the above copyright\r
12  *    notice, this list of conditions and the following disclaimer in the\r
13  *    documentation and/or other materials provided with the\r
14  *    distribution.\r
15  *\r
16  *    Neither the name of Texas Instruments Incorporated nor the names of\r
17  *    its contributors may be used to endorse or promote products derived\r
18  *    from this software without specific prior written permission.\r
19  *\r
20  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
21  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
22  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
23  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
24  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
25  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
26  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
27  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
28  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
29  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
30  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
31  *\r
32  *****************************************************************************/\r
33 \r
34 /**\r
35  *  \file   cpsw_eth_test.h\r
36  *\r
37  *  \brief  This file contains all Local definitions for CPSW 9G Ethernet test\r
38  *          application.\r
39  *\r
40  */\r
41 \r
42 #ifndef __CPSW_ETH_TEST_H__\r
43 #define __CPSW_ETH_TEST_H__\r
44 \r
45 #include <stdint.h>\r
46 #include <stdio.h>\r
47 #include <stdlib.h>\r
48 #include <string.h>\r
49 \r
50 #include "board.h"\r
51 #include "board_cfg.h"\r
52 #include "board_ethernet_config.h"\r
53 #include "board_pinmux.h"\r
54 #include "board_control.h"\r
55 #include "board_serdes_cfg.h"\r
56 \r
57 #include <ti/drv/sciclient/sciclient.h>\r
58 \r
59 #include <ti/drv/uart/UART.h>\r
60 #include <ti/drv/uart/UART_stdio.h>\r
61 \r
62 #include <ti/osal/TimerP.h>\r
63 #include <ti/osal/osal.h>\r
64 \r
65 #include <ti/drv/pm/include/dmsc/pmlib_clkrate.h>\r
66 \r
67 #include <ti/drv/udma/udma.h>\r
68 \r
69 #include <ti/drv/cpsw/cpsw.h>\r
70 \r
71 #include <ti/drv/cpsw/soc/cpsw_soc.h>\r
72 \r
73 #include <ti/drv/cpsw/include/cpsw_dma.h>\r
74 #include <ti/drv/cpsw/include/dp83867.h>\r
75 #include <ti/drv/cpsw/include/cpsw_queue.h>\r
76 #include <ti/drv/cpsw/include/cpsw_ale.h>\r
77 #include <ti/drv/cpsw/include/cpsw_cfg.h>\r
78 #include <ti/drv/cpsw/include/cpsw_types.h>\r
79 #include <ti/drv/cpsw/include/cpsw_rm.h>\r
80 \r
81 #include <ti/drv/cpsw/examples/cpsw_apputils/inc/cpsw_apputils.h>\r
82 #include <ti/drv/cpsw/examples/cpsw_apputils/inc/cpsw_appsoc.h>\r
83 #include <ti/drv/cpsw/examples/cpsw_apputils/inc/cpsw_appmemutils_cfg.h>\r
84 #include <ti/drv/cpsw/examples/cpsw_apputils/inc/cpsw_appmemutils.h>\r
85 #include <ti/drv/cpsw/examples/cpsw_apputils/inc/cpsw_appboardutils.h>\r
86 #include <ti/drv/cpsw/examples/cpsw_apputils/inc/cpswapp_ethutils.h>\r
87 \r
88 #include "diag_common_cfg.h"\r
89 \r
90 #ifdef __cplusplus\r
91 extern "C" {\r
92 #endif\r
93 \r
94 /* ========================================================================== */\r
95 /*                           Macros & Typedefs                                */\r
96 /* ========================================================================== */\r
97 \r
98 #define BOARD_DIAG_CPSW_TEST_LEN                (500U)\r
99 \r
100 #define BOARD_DIAG_CPSW_TEST_NUM_LOOP           (1U)\r
101 #define BOARD_DIAG_CPSW_TEST_PTK_NUM            (128U)\r
102 \r
103 #define BOARD_DIAG_CPSW_RGMII_TEST              (1U)\r
104 #define BOARD_DIAG_CPSW_SGMII_TEST              (2U)\r
105 #define BOARD_DIAG_MCU_CPSW_RGMII_TEST          (3U)\r
106 \r
107 #define BOARD_DIAG_CPSW_RGMII_PRG0_TEST         (1U)\r
108 #define BOARD_DIAG_CPSW_RGMII_PRG1_TEST         (2U)\r
109 \r
110 #define BOARD_DIAG_CPSW_SGMII_P0P1_TEST         (1U)\r
111 #define BOARD_DIAG_CPSW_SGMII_P2P3_TEST         (2U)\r
112 \r
113 #define BOARD_DIAG_CPSW_PHY_START_ADDRESS       (0U)\r
114 #define BOARD_DIAG_CPSW_PHY_END_ADDRESS         (31U)\r
115 \r
116 typedef void *CpswApp_ClkHandle;\r
117 \r
118 /**\r
119  * \brief  CPSW device object structure\r
120  */\r
121 typedef struct\r
122 {\r
123     /* CPSW instance type */\r
124     Cpsw_Type            cpswType;\r
125 \r
126     /* Core Id */\r
127     uint32_t             coreId;\r
128     /*Core Key */\r
129     uint32_t             coreKey;\r
130 \r
131     /* MAC port number */\r
132     Cpsw_MacPort         portNum0;\r
133 \r
134     /* MAC port number */\r
135     Cpsw_MacPort         portNum1;\r
136 \r
137     /* CPSW driver handle */\r
138     Cpsw_Handle          hCpsw;\r
139     Udma_DrvHandle       hUdmaDrv;\r
140 \r
141     CpswDma_RxFlowHandle hRxFlow;\r
142     CpswDma_PktInfoQ     rxFreeQ;\r
143     CpswDma_PktInfoQ     rxReadyQ;\r
144 \r
145     CpswDma_TxChHandle   hTxCh;\r
146     CpswDma_PktInfoQ     txFreePktInfoQ;\r
147 \r
148     /* TX Eth packet memory */\r
149     uint8_t              txBufMem[CPSW_APPMEMUTILS_NUM_TX_PKTS][CPSWAPPUTILS_ALIGN(ETH_MAX_FRAME_LEN)]\r
150                                 __attribute__((aligned(UDMA_CACHELINE_ALIGNMENT)));\r
151     /* TX DMA packet info memory */\r
152     CpswDma_PktInfo      txFreePktInfo[CPSW_APPMEMUTILS_NUM_TX_PKTS];\r
153 \r
154     uint8_t              hostMacAddr0[ETH_MAC_ADDR_LEN];\r
155 \r
156     uint8_t              hostMacAddr1[CPSW_MAC_ADDR_LEN];\r
157 \r
158     /* Whether to print received Ethernet frames */\r
159     bool printFrame;\r
160 \r
161     uint32_t             rxStartFlowIdx;\r
162 \r
163     uint32_t             rxFlowIdx;\r
164 \r
165     uint32_t             txChNum;\r
166 }cpsw_Obj;\r
167 \r
168 /**\r
169  *  \brief    This function runs CPSW9G ethernet test\r
170  *\r
171  *  \return   int8_t\r
172  *               0 - in case of success\r
173  *              -1 - in case of failure.\r
174  *\r
175  */\r
176 int8_t BoardDiag_CpswEthRunTest(void);\r
177 \r
178 #ifdef __cplusplus\r
179 }\r
180 #endif\r
181 #endif /* __CPSW_ETH_TEST_H__ */\r