PDK API Guide for J721E
lwip2enet_ic.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Texas Instruments Incorporated 2021
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
39 #ifndef LWIP2ENET_IC_H_
40 #define LWIP2ENET_IC_H_
41 
42 /* ========================================================================== */
43 /* Include Files */
44 /* ========================================================================== */
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 /* Standard language headers */
51 #include <stdint.h>
52 #include <assert.h>
53 
54 /* OS/Posix headers */
55 #include <ti/osal/osal.h>
56 #include <ti/osal/TaskP.h>
57 #include <ti/osal/SemaphoreP.h>
58 #include <ti/osal/ClockP.h>
59 #include <ti/osal/DebugP.h>
60 
61 
62 /* Project dependency headers */
63 #include <ti/drv/enet/enet.h>
64 #include <ti/drv/enet/enet_cfg.h>
65 #include <ti/drv/enet/intercore/intercore.h>
67 
68 /* ========================================================================== */
69 /* Macros */
70 /* ========================================================================== */
71 
74 #define IC_ETH_IF_MCU2_0_MCU2_1 0
75 
77 #define IC_ETH_IF_MCU2_1_MCU2_0 1
78 
84 #define IC_ETH_IF_MCU2_0_A72 2
85 
86 #define IC_ETH_MAX_VIRTUAL_IF 3
87 
89 #define LWIP2ENETIC_OK (0)
90 
91 #define LWIP2ENETIC_ERROR (-1)
92 
94 #define IC_ETH_RX_POLLING_MODE 1
95 
96 #define IC_ETH_RX_POLLING_INTERVAL 1 /* milli-seconds */
97 
98 /* ========================================================================== */
99 /* Structures and Enums */
100 /* ========================================================================== */
101 
105 typedef struct Lwip2EnetIc_RxStats_s
106 {
107  uint32_t largePktErr;
108  uint32_t pbufNullErr;
109  uint32_t pbufTakeErr;
110  uint32_t netifInputErr;
111  uint32_t rxQEmptyWarn;
112  uint32_t pktDeq;
113  uint32_t pktSentToStk;
115 
119 typedef struct Lwip2EnetIc_TxStats_s
120 {
121  uint32_t pktDropInitErr;
122  uint32_t pbufNullErr;
123  uint32_t txQFullErr;
124  uint32_t pktEnq;
126 
127 typedef struct Lwip2EnetIc_Stats_s
128 {
131  uint32_t driverBufGet;
132  uint32_t driverBufFree;
135 
144 typedef struct Lwip2EnetIc_OBJECT_
145 {
146  /* Intercore trasport global object */
147  Ic_Object icObj;
148 
150  uint32_t instId;
151 
152  /* Mac Address assigned to this interface */
153  uint8_t macAddr[ENET_MAC_ADDR_LEN];
154 
155  /* Initialization flag.*/
156  volatile uint32_t initDone;
157 
158  /* Link is up flag. */
159  uint32_t linkIsUp;
160 
161  /* No of PBM packets allocated by application - used for debug purpose.*/
163 
164  /* Handle to IPC receive task */
166 
167  /*
168  * Handle to Rx task: Receives packets from the intercore transport
169  * and give them to the LWIP stack.
170  */
172 
173  /*
174  * Handle to Rx semaphore: Posted by the IPC RX task on getting a
175  * packet notification from the remote core.
176  */
178 
179  /* Handle to input task that sends pbufs to the LWIP stack */
181 
182  /*
183  * Handle to counting shutdown semaphore, which all subtasks created in the
184  * open function must post before the close operation can complete.
185  */
187 
188  /* Boolean to indicate shutDownFlag status of translation layer.*/
189  volatile bool shutDownFlag;
190 
191  /* Print buffer */
192  char printBuf[ENET_CFG_PRINT_BUF_LEN];
193 
194  /* Print Function */
196 
197  /* Driver buffer pool for this core */
199 
200  /* Stats */
202 
203 } Lwip2EnetIc_Object, *Lwip2EnetIc_Handle;
204 
205 typedef struct Lwip2EnetIc_Params_
206 {
208  uint32_t instId;
209 
211  uint32_t ownerId;
212 
214  uint32_t txQId;
215 
217  uint32_t rxQId;
218 
220  uint32_t bufPoolId;
221 
223  uint32_t reqEndPtId;
224 
226  uint32_t remoteCoreId;
227 
229  char endPtName[ICETH_ENDPT_NAME_LEN_MAX];
230 
232  char remoteEndPtName[ICETH_ENDPT_NAME_LEN_MAX];
233 
235  uint8_t macAddr[ENET_MAC_ADDR_LEN];
236 
238 
239 
240 /* ========================================================================== */
241 /* External Variable Declarations */
242 /* ========================================================================== */
243 
244 /* ========================================================================== */
245 /* API/Public Function Declarations */
246 /* ========================================================================== */
247 
248 /*
249  * Functions Provided by our translation layer code
250  */
251 extern Lwip2EnetIc_Handle Lwip2EnetIc_open(uint32_t instId);
252 
253 extern void Lwip2EnetIc_close(Lwip2EnetIc_Handle hlwip2enetIc);
254 
255 extern int32_t Lwip2EnetIc_remoteCorePktNotify(Lwip2EnetIc_Handle hLwip2EnetIc);
256 
257 /* ========================================================================== */
258 /* Deprecated Function Declarations */
259 /* ========================================================================== */
260 
261 /* None */
262 
263 /* ========================================================================== */
264 /* Static Function Definitions */
265 /* ========================================================================== */
266 
267 static inline void Lwip2EnetIcStats_addOne(uint32_t *statCnt)
268 {
269 #if defined(LWIPIFIC_INSTRUMENTATION_ENABLED)
270  *statCnt += 1U;
271 #endif
272 }
273 
274 static inline void Lwip2EnetIcStats_addNum(uint32_t *statCnt,
275  uint32_t addCnt)
276 {
277 #if defined(LWIPIFIC_INSTRUMENTATION_ENABLED)
278  *statCnt += addCnt;
279 #endif
280 }
281 
282 static inline void Lwip2EnetIc_assert(bool cond)
283 {
284  assert(cond);
285 }
286 
287 #ifdef __cplusplus
288 }
289 #endif
290 
291 #endif /* LWIP2ENET_IC_H_ */
OS Abstraction Layer header.
Lwip2EnetIc_Handle Lwip2EnetIc_open(uint32_t instId)
Definition: lwip2enet_ic.h:127
uint32_t driverBufNullErr
Definition: lwip2enet_ic.h:133
#define ENET_CFG_PRINT_BUF_LEN
EnetUtils print buffer length.
Definition: enet_cfg.h:73
#define assert(expr)
Definition: mcasp_osal.h:21
lwIP interface layer's TX statistics.
Definition: lwip2enet_ic.h:119
TaskP_Handle hLWIPIF2LWIPinput
Definition: lwip2enet_ic.h:180
volatile uint32_t initDone
Definition: lwip2enet_ic.h:156
static void Lwip2EnetIcStats_addOne(uint32_t *statCnt)
Definition: lwip2enet_ic.h:267
uint32_t driverBufFree
Definition: lwip2enet_ic.h:132
uint32_t instId
Definition: lwip2enet_ic.h:150
uint32_t largePktErr
Definition: lwip2enet_ic.h:107
uint32_t pktEnq
Definition: lwip2enet_ic.h:124
uint32_t netifInputErr
Definition: lwip2enet_ic.h:110
void * SemaphoreP_Handle
Opaque client reference to an instance of a SemaphoreP.
Definition: SemaphoreP.h:112
void(* Enet_Print)(const char *fmt,...)
Info/debug print function prototype.
Definition: enet_utils.h:165
TaskP_Handle hRxPacketTask
Definition: lwip2enet_ic.h:171
#define ENET_MAC_ADDR_LEN
MAC address length in bytes/octets.
Definition: enet_types.h:153
Lwip2EnetIc_Stats stats
Definition: lwip2enet_ic.h:201
uint32_t pktSentToStk
Definition: lwip2enet_ic.h:113
uint32_t reqEndPtId
Definition: lwip2enet_ic.h:223
struct BufPool_Pool_s * BufPool_Handle
BufPool handle.
Definition: bufpool.h:154
int32_t Lwip2EnetIc_remoteCorePktNotify(Lwip2EnetIc_Handle hLwip2EnetIc)
uint32_t driverBufGet
Definition: lwip2enet_ic.h:131
uint32_t rxQId
Definition: lwip2enet_ic.h:217
volatile bool shutDownFlag
Definition: lwip2enet_ic.h:189
SemaphoreP_Handle hRxPacketSem
Definition: lwip2enet_ic.h:177
uint32_t pbufNullErr
Definition: lwip2enet_ic.h:122
TaskP_Handle hIpcRxTask
Definition: lwip2enet_ic.h:165
Lwip2EnetIc_TxStats txStats
Definition: lwip2enet_ic.h:129
uint32_t pktDropInitErr
Definition: lwip2enet_ic.h:121
void * TaskP_Handle
Opaque client reference to an instance of a TaskP.
Definition: TaskP.h:81
uint32_t bufPoolId
Definition: lwip2enet_ic.h:220
Lwip2EnetIc_RxStats rxStats
Definition: lwip2enet_ic.h:130
uint32_t pktDeq
Definition: lwip2enet_ic.h:112
Implements a simple buffer pool.
uint32_t remoteCoreId
Definition: lwip2enet_ic.h:226
uint32_t linkIsUp
Definition: lwip2enet_ic.h:159
static void Lwip2EnetIc_assert(bool cond)
Definition: lwip2enet_ic.h:282
uint32_t pbufTakeErr
Definition: lwip2enet_ic.h:109
SemaphoreP_Handle hShutDownSem
Definition: lwip2enet_ic.h:186
Semaphore module for the RTOS Porting Interface.
Inter-core virtual device object.
Definition: lwip2enet_ic.h:144
void Lwip2EnetIc_close(Lwip2EnetIc_Handle hlwip2enetIc)
Task module for the RTOS Porting Interface.
lwIP interface layer's RX statistics.
Definition: lwip2enet_ic.h:105
static void Lwip2EnetIcStats_addNum(uint32_t *statCnt, uint32_t addCnt)
Definition: lwip2enet_ic.h:274
uint32_t txQFullErr
Definition: lwip2enet_ic.h:123
Definition: lwip2enet_ic.h:205
uint32_t instId
Definition: lwip2enet_ic.h:208
uint32_t ownerId
Definition: lwip2enet_ic.h:211
This file contains the top-level API of the Enet driver.
Clock module for the RTOS Porting Interface. This implements the software timer support....
uint32_t rxQEmptyWarn
Definition: lwip2enet_ic.h:111
uint32_t pbufNullErr
Definition: lwip2enet_ic.h:108
Enet_Print print
Definition: lwip2enet_ic.h:195
uint32_t numAllocPbufPkts
Definition: lwip2enet_ic.h:162
BufPool_Handle hBufPool
Definition: lwip2enet_ic.h:198
This file contains the Enet configuration parameters.
uint32_t txQId
Definition: lwip2enet_ic.h:214
Ic_Object icObj
Definition: lwip2enet_ic.h:147