PDK API Guide for J721E
enet_types.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Texas Instruments Incorporated 2020
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 
45 #ifndef ENET_TYPES_H_
46 #define ENET_TYPES_H_
47 
48 /* ========================================================================== */
49 /* Include Files */
50 /* ========================================================================== */
51 
52 #include <stdint.h>
53 #include <stdbool.h>
54 #include <ti/csl/csl_types.h>
55 
56 #ifdef __cplusplus
57 extern "C" {
58 #endif
59 
60 /* ========================================================================== */
61 /* Macros */
62 /* ========================================================================== */
63 
73 /* Enet driver error codes are same as CSL's to maintain consistency */
74 
76 #define ENET_SOK (CSL_PASS)
77 
79 #define ENET_SINPROGRESS (1)
80 
82 #define ENET_EFAIL (CSL_EFAIL)
83 
85 #define ENET_EBADARGS (CSL_EBADARGS)
86 
88 #define ENET_EINVALIDPARAMS (CSL_EINVALID_PARAMS)
89 
91 #define ENET_ETIMEOUT (CSL_ETIMEOUT)
92 
94 #define ENET_EALLOC (CSL_EALLOC)
95 
97 #define ENET_EUNEXPECTED (CSL_EALLOC - 1)
98 
100 #define ENET_EBUSY (CSL_EALLOC - 2)
101 
103 #define ENET_EALREADYOPEN (CSL_EALLOC - 3)
104 
106 #define ENET_EPERM (CSL_EALLOC - 4)
107 
109 #define ENET_ENOTSUPPORTED (CSL_EALLOC - 5)
110 
112 #define ENET_ENOTFOUND (CSL_EALLOC - 6)
113 
115 #define ENET_EUNKNOWNIOCTL (CSL_EALLOC - 7)
116 
118 #define ENET_EMALFORMEDIOCTL (CSL_EALLOC - 8)
119 
123 #define ENET_ARRAYSIZE(x) (sizeof(x) / sizeof(x[0]))
124 
126 #define ENET_BIT(n) (1U << (n))
127 
129 #define ENET_GET_BIT(val, n) (((val) & ENET_BIT(n)) >> (n))
130 
132 #define ENET_IS_BIT_SET(val, n) (((val) & ENET_BIT(n)) != 0U)
133 
135 #define ENET_NOT_ZERO(val) ((uint32_t)0U != (uint32_t)(val))
136 
138 #define ENET_FEXT(reg, PER_REG_FIELD) \
139  (((reg) & PER_REG_FIELD##_MASK) >> PER_REG_FIELD##_SHIFT)
140 
142 #define ENET_FINS(reg, PER_REG_FIELD, val) \
143  ((reg) = ((reg) & ~PER_REG_FIELD##_MASK) \
144  | (((val) << PER_REG_FIELD##_SHIFT) & PER_REG_FIELD##_MASK))
145 
147 #define ENET_DIV_ROUNDUP(val, div) (((val) + (div) - 1) / (div))
148 
150 #define ENET_VERSION_NONE (0xFFFFFFFFU)
151 
153 #define ENET_MAC_ADDR_LEN (6U)
154 
156 #define ENET_OUI_ADDR_LEN (3U)
157 
159 #define ENET_IPv4_ADDR_LEN (4U)
160 
162 #define ENET_IPv6_ADDR_LEN (16U)
163 
165 #define ENET_PRI_NUM (8U)
166 
168 #define ENET_PRI_MIN (0U)
169 
171 #define ENET_PRI_MAX (ENET_PRI_NUM - 1U)
172 
174 #define ENET_TOS_PRI_NUM (64U)
175 
177 #define ENET_TOS_PRI_MIN (0U)
178 
180 #define ENET_TOS_PRI_MAX (ENET_TOS_PRI_NUM - 1U)
181 
183 #define ENET_VLAN_ID_MAX (4095U)
184 
186 #define ENET_ETHERTYPE_PTP (0x88F7U)
187 
188 /* ========================================================================== */
189 /* Structures and Enums */
190 /* ========================================================================== */
191 
195 typedef enum Enet_Type_e
196 {
199 
202 
205 
208 
211 
214 
217 
220 } Enet_Type;
221 
223 #define ENET_TYPE_NUM (ENET_TYPE_COUNT + 1U)
224 
228 typedef enum Enet_Magic_e
229 {
231  ENET_MAGIC = 0xABABABABU,
232 
235 } Enet_Magic;
236 
240 typedef enum Enet_CrcType_e
241 {
244 
247 } Enet_CrcType;
248 
258 typedef enum Enet_Event_e
259 {
262 
268 
271 
274 
277 
280 
283 
291 
294 
297 
300  ENET_EVT_ANY = 0xFFFFFFFFU,
301 } Enet_Event;
302 
312 typedef struct Enet_Version_s
313 {
315  uint32_t maj;
316 
318  uint32_t min;
319 
321  uint32_t rtl;
322 
324  uint32_t id;
325 
327  uint32_t other1;
328 
330  uint32_t other2;
331 } Enet_Version;
332 
336 typedef enum Enet_Speed_e
337 {
340 
343 
346 
349 } Enet_Speed;
350 
354 typedef enum Enet_Duplexity_e
355 {
358 
361 
365 
369 typedef enum Enet_VlanTagType_e
370 {
373 
377 
381 typedef struct Enet_VlanTag_s
382 {
384  uint16_t tpid;
385 
387  uint8_t pcp;
388 
390  uint8_t dei;
391 
393  uint16_t vlanId;
394 
397 } Enet_VlanTag;
398 
402 typedef enum Enet_MacPort_e
403 {
406 
409 
412 
415 
418 
421 
424 
427 
430 
433 } Enet_MacPort;
434 
445 typedef void (*Enet_EventCallback)(Enet_Event evt,
446  uint32_t evtNum,
447  void *evtCbArgs,
448  void *arg1,
449  void *arg2);
450 
452 #define ENET_MAC_PORT_NUM ((uint32_t)ENET_MAC_PORT_LAST + 1U)
453 
460 #define ENET_MACPORT_NORM(n) ((n) - ENET_MAC_PORT_FIRST)
461 
468 #define ENET_MACPORT_DENORM(n) ((Enet_MacPort)((n) + ENET_MAC_PORT_FIRST))
469 
477 #define ENET_MACPORT_ID(n) ((n) - ENET_MAC_PORT_FIRST + 1U)
478 
480 #define ENET_MAC_PORT_INV ((Enet_MacPort)0xFFFFU)
481 
483 #define ENET_TRAFFIC_CLASS_INV ((uint32_t)0xFFFFU)
484 
490 #define ENET_MACPORT_MASK(n) (ENET_BIT(ENET_MACPORT_NORM(n)))
491 
492 /* ========================================================================== */
493 /* Global Variables Declarations */
494 /* ========================================================================== */
495 
496 /* None */
497 
498 /* ========================================================================== */
499 /* Function Declarations */
500 /* ========================================================================== */
501 
509 static inline bool Enet_isCpswFamily(Enet_Type enetType);
510 
518 static inline bool Enet_isIcssFamily(Enet_Type enetType);
519 
520 /* ========================================================================== */
521 /* Deprecated Function Declarations */
522 /* ========================================================================== */
523 
524 /* None */
525 
526 /* ========================================================================== */
527 /* Static Function Definitions */
528 /* ========================================================================== */
529 
530 static inline bool Enet_isCpswFamily(Enet_Type enetType)
531 {
532  return ((enetType == ENET_GMAC_3G) ||
533  (enetType == ENET_CPSW_2G) ||
534  (enetType == ENET_CPSW_5G) ||
535  (enetType == ENET_CPSW_9G));
536 }
537 
538 static inline bool Enet_isIcssFamily(Enet_Type enetType)
539 {
540  return ((enetType == ENET_ICSSG_DUALMAC) ||
541  (enetType == ENET_ICSSG_SWITCH));
542 }
543 
544 #ifdef __cplusplus
545 }
546 #endif
547 
548 #endif /* ENET_TYPES_H_ */
549 
uint16_t vlanId
Definition: enet_types.h:393
Definition: enet_types.h:339
Enet_Magic
Enet driver magic value, used to indicate if driver is open or not.
Definition: enet_types.h:228
Definition: enet_types.h:290
uint32_t maj
Definition: enet_types.h:315
Enet_Type
Ethernet peripheral type.
Definition: enet_types.h:195
Definition: enet_types.h:293
Definition: enet_types.h:357
Definition: enet_types.h:432
Definition: enet_types.h:420
Definition: enet_types.h:243
Definition: enet_types.h:363
Enet_CrcType
CRC type.
Definition: enet_types.h:240
Definition: enet_types.h:372
Definition: enet_types.h:231
Definition: enet_types.h:267
Definition: enet_types.h:276
uint32_t min
Definition: enet_types.h:318
Definition: enet_types.h:414
Definition: enet_types.h:207
Definition: enet_types.h:246
Definition: enet_types.h:429
uint32_t id
Definition: enet_types.h:324
Definition: enet_types.h:204
VLAN tag.
Definition: enet_types.h:381
Definition: enet_types.h:423
Definition: enet_types.h:270
Definition: enet_types.h:411
Definition: enet_types.h:417
uint32_t rtl
Definition: enet_types.h:321
Definition: enet_types.h:408
Definition: enet_types.h:198
Definition: enet_types.h:273
static bool Enet_isIcssFamily(Enet_Type enetType)
Check if Ethernet peripheral type is part of ICSS family.
Definition: enet_types.h:538
Definition: enet_types.h:210
Definition: enet_types.h:405
Enet_Speed
MAC interface speed.
Definition: enet_types.h:336
Definition: enet_types.h:300
uint16_t tpid
Definition: enet_types.h:384
static bool Enet_isCpswFamily(Enet_Type enetType)
Check if Ethernet peripheral type is part of CPSW family.
Definition: enet_types.h:530
uint8_t pcp
Definition: enet_types.h:387
Definition: enet_types.h:282
Definition: enet_types.h:360
Definition: enet_types.h:426
uint32_t other1
Definition: enet_types.h:327
Definition: enet_types.h:219
Version of a peripheral or module.
Definition: enet_types.h:312
This file contains the Register Desciptions for CSL types.
Definition: enet_types.h:348
Enet_Event
Ethernet events.
Definition: enet_types.h:258
Enet_MacPort
MAC port.
Definition: enet_types.h:402
Definition: enet_types.h:261
Definition: enet_types.h:342
uint32_t other2
Definition: enet_types.h:330
Definition: enet_types.h:234
Definition: enet_types.h:216
Definition: enet_types.h:345
#define ENET_BIT(n)
Macro to set bit at given bit position.
Definition: enet_types.h:126
Definition: enet_types.h:375
Definition: enet_types.h:296
Definition: enet_types.h:201
Enet_VlanTagType
Double tagging VLAN type.
Definition: enet_types.h:369
Enet_VlanTagType tagType
Definition: enet_types.h:396
void(* Enet_EventCallback)(Enet_Event evt, uint32_t evtNum, void *evtCbArgs, void *arg1, void *arg2)
Event callback.
Definition: enet_types.h:445
Definition: enet_types.h:279
Definition: enet_types.h:213
Enet_Duplexity
MAC interface duplexity.
Definition: enet_types.h:354
uint8_t dei
Definition: enet_types.h:390