AM64x MCU+ SDK  08.02.00
enet_per.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 
40 #ifndef ENET_PER_H_
41 #define ENET_PER_H_
42 
43 /* ========================================================================== */
44 /* Include Files */
45 /* ========================================================================== */
46 
47 #include <stdint.h>
51 #include <include/phy/enetphy.h>
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
57 /* ========================================================================== */
58 /* Macros */
59 /* ========================================================================== */
60 
62 #define ENET_TO_PER(per) ((EnetPer_Handle)(per))
63 
65 #define ENET_PER_NAME(per) (ENET_TO_PER(per)->name)
66 
68 #define ENET_PER_PUBLIC_IOCTL(x) (ENET_IOCTL_TYPE_PUBLIC | \
69  ENET_IOCTL_PER_BASE | \
70  ENET_IOCTL_MIN(x))
71 
72 /* ========================================================================== */
73 /* Structures and Enums */
74 /* ========================================================================== */
75 
80 {
89 
98 
107 
116 
125 
134 
143 
152 
161 
173 
186 
198 
209 
220 };
221 
225 typedef struct Enet_DfltFlowInfo_s
226 {
228  uint32_t coreKey;
229 
231  uint32_t chIdx;
232 
234  uint32_t startIdx;
235 
237  uint32_t flowIdx;
239 
243 typedef struct Enet_MacDstFlowInfo_s
244 {
246  uint32_t coreKey;
247 
249  uint32_t startIdx;
250 
252  uint32_t flowIdx;
253 
255  uint8_t macAddress[ENET_MAC_ADDR_LEN];
257 
261 typedef struct EnetPer_PortLinkCfg_s
262 {
265 
267  void *macCfg;
268 
271 
274 
278 
282 typedef struct EnetPer_AttachCoreOutArgs_s
283 {
285  uint32_t coreKey;
286 
288  uint32_t rxMtu;
289 
291  uint32_t txMtu[ENET_PRI_NUM];
293 
299 typedef struct EnetPer_Obj_s *EnetPer_Handle;
300 
311 typedef void (*EnetPer_InitCfg)(EnetPer_Handle hPer,
312  Enet_Type enetType,
313  void *cfg,
314  uint32_t cfgSize);
315 
330 typedef int32_t (*EnetPer_Open)(EnetPer_Handle hPer,
331  Enet_Type enetType,
332  uint32_t instId,
333  const void *cfg,
334  uint32_t cfgSize);
335 
351 typedef int32_t (*EnetPer_Rejoin)(EnetPer_Handle hPer,
352  Enet_Type enetType,
353  uint32_t instId);
354 
366 typedef int32_t (*EnetPer_Ioctl)(EnetPer_Handle hPer,
367  uint32_t cmd,
368  Enet_IoctlPrms *prms);
369 
384 typedef void (*EnetPer_Poll)(EnetPer_Handle hPer,
385  Enet_Event evt,
386  const void *arg,
387  uint32_t argSize);
388 
405 typedef uint64_t (*EnetPer_ConvertTs)(EnetPer_Handle hPer,
406  uint64_t ts);
407 
415 typedef void (*EnetPer_PeriodicTick)(EnetPer_Handle hPer);
416 
431  Enet_Event evt,
432  uint32_t evtNum,
433  Enet_EventCallback evtCb,
434  void *evtCbArgs);
435 
446  Enet_Event evt,
447  uint32_t evtNum);
448 
456 typedef void (*EnetPer_Close)(EnetPer_Handle hPer);
457 
461 typedef struct EnetPer_Obj_s
462 {
464  const char *name;
465 
468 
470  uint32_t instId;
471 
474 
480  uint64_t physAddr;
481 
483  void *virtAddr;
484 
486  uint64_t physAddr2;
487 
489  void *virtAddr2;
490 
492  uint32_t features;
493 
495  uint32_t errata;
496 
499 
502 
505 
508 
511 
514 
517 
520 
523 
526 } EnetPer_Obj;
527 
528 /* ========================================================================== */
529 /* Global Variables Declarations */
530 /* ========================================================================== */
531 
532 /* None */
533 
534 /* ========================================================================== */
535 /* Function Declarations */
536 /* ========================================================================== */
537 
538 /* None */
539 
540 /* ========================================================================== */
541 /* Deprecated Function Declarations */
542 /* ========================================================================== */
543 
544 /* None */
545 
546 /* ========================================================================== */
547 /* Static Function Definitions */
548 /* ========================================================================== */
549 
550 /* None */
551 
552 #ifdef __cplusplus
553 }
554 #endif
555 
556 #endif /* ENET_PER_H_ */
ENET_PER_IOCTL_SET_VLAN_AWARE
@ ENET_PER_IOCTL_SET_VLAN_AWARE
Enable VLAN aware mode.
Definition: enet_per.h:208
EnetPer_Obj::name
const char * name
Definition: enet_per.h:464
EnetPer_Obj::close
EnetPer_Close close
Definition: enet_per.h:525
ENET_PER_IOCTL_GET_VERSION
@ ENET_PER_IOCTL_GET_VERSION
Get the hardware version of the peripheral.
Definition: enet_per.h:88
enet_mod_macport.h
This file contains the type definitions and helper macros for the Enet MAC port module interface.
ENET_PER_IOCTL_OPEN_PORT_LINK
@ ENET_PER_IOCTL_OPEN_PORT_LINK
Open port link (MAC port and PHY).
Definition: enet_per.h:106
EnetPer_PortLinkCfg::macPort
Enet_MacPort macPort
Definition: enet_per.h:264
EnetPer_Obj::virtAddr2
void * virtAddr2
Definition: enet_per.h:489
EnetMacPort_LinkCfg
Link speed and duplexity configuration.
Definition: enet_mod_macport.h:289
EnetPer_Obj::magic
Enet_Magic magic
Definition: enet_per.h:473
EnetPer_UnregisterEventCb
void(* EnetPer_UnregisterEventCb)(EnetPer_Handle hPer, Enet_Event evt, uint32_t evtNum)
Unregister callback for an event.
Definition: enet_per.h:445
EnetPer_Obj::features
uint32_t features
Definition: enet_per.h:492
enet_types.h
This file contains the basic types using across the Enet driver.
EnetPer_AttachCoreOutArgs::rxMtu
uint32_t rxMtu
Definition: enet_per.h:288
EnetPer_Obj::instId
uint32_t instId
Definition: enet_per.h:470
ENET_IOCTL_UNREGISTER_DSTMAC_RX_FLOW
@ ENET_IOCTL_UNREGISTER_DSTMAC_RX_FLOW
Unregister destination MAC address to a specific flow.
Definition: enet_per.h:197
Enet_MacPort
Enet_MacPort
MAC port.
Definition: enet_types.h:406
Enet_Event
Enet_Event
Ethernet events.
Definition: enet_types.h:262
Enet_MacDstFlowInfo::flowIdx
uint32_t flowIdx
Definition: enet_per.h:252
EnetPer_ConvertTs
uint64_t(* EnetPer_ConvertTs)(EnetPer_Handle hPer, uint64_t ts)
Convert a timestamp to nanoseconds.
Definition: enet_per.h:405
EnetPer_AttachCoreOutArgs
Output args for ENET_PER_IOCTL_ATTACH_CORE command.
Definition: enet_per.h:283
EnetPer_Obj::physAddr
uint64_t physAddr
Definition: enet_per.h:480
EnetPer_Obj::rejoin
EnetPer_Rejoin rejoin
Definition: enet_per.h:504
EnetPer_PeriodicTick
void(* EnetPer_PeriodicTick)(EnetPer_Handle hPer)
Run periodic tick on the Ethernet peripheral.
Definition: enet_per.h:415
enet_ioctl.h
This file contains the type definitions and helper macros for the Enet IOCTL interface.
Enet_Magic
Enet_Magic
Enet driver magic value, used to indicate if driver is open or not.
Definition: enet_types.h:232
EnetPer_Obj::physAddr2
uint64_t physAddr2
Definition: enet_per.h:486
ENET_PER_IOCTL_SET_VLAN_UNAWARE
@ ENET_PER_IOCTL_SET_VLAN_UNAWARE
Disable VLAN aware mode.
Definition: enet_per.h:219
EnetPhy_Cfg
PHY configuration parameters.
Definition: enetphy.h:335
ENET_PER_PUBLIC_IOCTL
#define ENET_PER_PUBLIC_IOCTL(x)
Helper macro to create IOCTL commands for peripherals.
Definition: enet_per.h:68
EnetPer_Rejoin
int32_t(* EnetPer_Rejoin)(EnetPer_Handle hPer, Enet_Type enetType, uint32_t instId)
Rejoin a running Enet Peripheral.
Definition: enet_per.h:351
EnetPer_Ioctl
int32_t(* EnetPer_Ioctl)(EnetPer_Handle hPer, uint32_t cmd, Enet_IoctlPrms *prms)
Issue an operation on the Enet Peripheral.
Definition: enet_per.h:366
ENET_PER_IOCTL_PRINT_REGS
@ ENET_PER_IOCTL_PRINT_REGS
Print registers of the peripheral and all its modules.
Definition: enet_per.h:97
Enet_IoctlPrms
Enet IOCTL param.
Definition: enet_ioctl.h:233
enetphy.h
This file contains the type definitions and helper macros for the Ethernet PHY interface.
EnetPer_PortLinkCfg::phyCfg
EnetPhy_Cfg phyCfg
Definition: enet_per.h:270
EnetPer_Obj
Ethernet Peripheral object.
Definition: enet_per.h:462
ENET_PER_IOCTL_GET_PORT_LINK_CFG
@ ENET_PER_IOCTL_GET_PORT_LINK_CFG
Get port link configuration (speed and duplexity).
Definition: enet_per.h:133
EnetPer_PortLinkCfg
Input args for ENET_PER_IOCTL_OPEN_PORT_LINK command.
Definition: enet_per.h:262
ENET_PRI_NUM
#define ENET_PRI_NUM
Packet priority.
Definition: enet_types.h:165
EnetMacPort_Interface
MAC port interface.
Definition: enet_mod_macport.h:274
Enet_MacDstFlowInfo::coreKey
uint32_t coreKey
Definition: enet_per.h:246
EnetPer_Obj::registerEventCb
EnetPer_RegisterEventCb registerEventCb
Definition: enet_per.h:519
ENET_IOCTL_REGISTER_DSTMAC_RX_FLOW
@ ENET_IOCTL_REGISTER_DSTMAC_RX_FLOW
Register destination MAC address to a specific rx flow.
Definition: enet_per.h:185
EnetPer_Obj::convertTs
EnetPer_ConvertTs convertTs
Definition: enet_per.h:513
Enet_DfltFlowInfo::chIdx
uint32_t chIdx
Definition: enet_per.h:231
EnetPer_PortLinkCfg::linkCfg
EnetMacPort_LinkCfg linkCfg
Definition: enet_per.h:276
Enet_DfltFlowInfo
Rx Default Flow Info used for default flow registration/unregistration.
Definition: enet_per.h:226
EnetPer_Handle
struct EnetPer_Obj_s * EnetPer_Handle
Ethernet Peripheral handle.
Definition: enet_per.h:299
EnetPer_Obj::initCfg
EnetPer_InitCfg initCfg
Definition: enet_per.h:498
EnetPer_Open
int32_t(* EnetPer_Open)(EnetPer_Handle hPer, Enet_Type enetType, uint32_t instId, const void *cfg, uint32_t cfgSize)
Open and initialize the Enet Peripheral.
Definition: enet_per.h:330
EnetPer_Poll
void(* EnetPer_Poll)(EnetPer_Handle hPer, Enet_Event evt, const void *arg, uint32_t argSize)
Poll for Ethernet events.
Definition: enet_per.h:384
ENET_PER_IOCTL_ATTACH_CORE
@ ENET_PER_IOCTL_ATTACH_CORE
Attach core to Ethernet peripheral.
Definition: enet_per.h:142
Enet_Type
Enet_Type
Ethernet peripheral type.
Definition: enet_types.h:196
EnetPer_Obj::enetType
Enet_Type enetType
Definition: enet_per.h:467
EnetPer_Obj::poll
EnetPer_Poll poll
Definition: enet_per.h:510
Enet_MacDstFlowInfo::startIdx
uint32_t startIdx
Definition: enet_per.h:249
ENET_PER_IOCTL_DETACH_CORE
@ ENET_PER_IOCTL_DETACH_CORE
Detach core from Ethernet peripheral using its core key.
Definition: enet_per.h:151
EnetPer_Close
void(* EnetPer_Close)(EnetPer_Handle hPer)
Close the Enet Peripheral.
Definition: enet_per.h:456
ENET_PER_IOCTL_IS_PORT_LINK_UP
@ ENET_PER_IOCTL_IS_PORT_LINK_UP
Check if port link is up.
Definition: enet_per.h:124
EnetPer_Obj::virtAddr
void * virtAddr
Definition: enet_per.h:483
EnetPer_Ioctl_e
EnetPer_Ioctl_e
Ethernet peripheral IOCTL commands.
Definition: enet_per.h:80
ENET_IOCTL_REGISTER_RX_DEFAULT_FLOW
@ ENET_IOCTL_REGISTER_RX_DEFAULT_FLOW
Register default flow to a specific rx flow.
Definition: enet_per.h:160
ENET_PER_IOCTL_CLOSE_PORT_LINK
@ ENET_PER_IOCTL_CLOSE_PORT_LINK
Close port link (MAC port and PHY).
Definition: enet_per.h:115
Enet_DfltFlowInfo::startIdx
uint32_t startIdx
Definition: enet_per.h:234
Enet_DfltFlowInfo::flowIdx
uint32_t flowIdx
Definition: enet_per.h:237
Enet_EventCallback
void(* Enet_EventCallback)(Enet_Event evt, uint32_t evtNum, void *evtCbArgs, void *arg1, void *arg2)
Event callback.
Definition: enet_types.h:448
EnetPer_InitCfg
void(* EnetPer_InitCfg)(EnetPer_Handle hPer, Enet_Type enetType, void *cfg, uint32_t cfgSize)
Initialize peripheral's configuration parameters.
Definition: enet_per.h:311
EnetPer_RegisterEventCb
void(* EnetPer_RegisterEventCb)(EnetPer_Handle hPer, Enet_Event evt, uint32_t evtNum, Enet_EventCallback evtCb, void *evtCbArgs)
Register a callback for an event.
Definition: enet_per.h:430
EnetPer_Obj::ioctl
EnetPer_Ioctl ioctl
Definition: enet_per.h:507
EnetPer_Obj::errata
uint32_t errata
Definition: enet_per.h:495
ENET_MAC_ADDR_LEN
#define ENET_MAC_ADDR_LEN
MAC address length in bytes/octets.
Definition: enet_types.h:153
Enet_MacDstFlowInfo
Output args for ENET_PER_IOCTL_ATTACH_CORE command.
Definition: enet_per.h:244
EnetPer_Obj::periodicTick
EnetPer_PeriodicTick periodicTick
Definition: enet_per.h:516
EnetPer_PortLinkCfg::macCfg
void * macCfg
Definition: enet_per.h:267
Enet_DfltFlowInfo::coreKey
uint32_t coreKey
Definition: enet_per.h:228
EnetPer_AttachCoreOutArgs::coreKey
uint32_t coreKey
Definition: enet_per.h:285
EnetPer_Obj::open
EnetPer_Open open
Definition: enet_per.h:501
ENET_IOCTL_UNREGISTER_RX_DEFAULT_FLOW
@ ENET_IOCTL_UNREGISTER_RX_DEFAULT_FLOW
Unregister default flow.
Definition: enet_per.h:172
EnetPer_Obj::unregisterEventCb
EnetPer_UnregisterEventCb unregisterEventCb
Definition: enet_per.h:522
EnetPer_PortLinkCfg::mii
EnetMacPort_Interface mii
Definition: enet_per.h:273