AM64x MCU+ SDK  08.06.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 
231 
242 
253 
254 };
255 
259 typedef struct Enet_DfltFlowInfo_s
260 {
262  uint32_t coreKey;
263 
265  uint32_t chIdx;
266 
268  uint32_t startIdx;
269 
271  uint32_t flowIdx;
273 
277 typedef struct Enet_MacDstFlowInfo_s
278 {
280  uint32_t coreKey;
281 
283  uint32_t startIdx;
284 
286  uint32_t flowIdx;
287 
289  uint8_t macAddress[ENET_MAC_ADDR_LEN];
291 
295 typedef struct EnetPer_PortLinkCfg_s
296 {
299 
301  void *macCfg;
302 
305 
308 
312 
316 typedef struct EnetPer_AttachCoreOutArgs_s
317 {
319  uint32_t coreKey;
320 
322  uint32_t rxMtu;
323 
325  uint32_t txMtu[ENET_PRI_NUM];
327 
328 
332 typedef struct Enet_ExtPhyLinkUpEventInfo_s
333 {
336 
340 
344 typedef struct Enet_IoctlRegisterHandlerInArgs_s
345 {
347  uint32_t cmd;
348 
350  uintptr_t fxn;
352 
358 typedef struct EnetPer_Obj_s *EnetPer_Handle;
359 
370 typedef void (* const EnetPer_InitCfg)(EnetPer_Handle hPer,
371  Enet_Type enetType,
372  void *cfg,
373  uint32_t cfgSize);
374 
389 typedef int32_t (* const EnetPer_Open)(EnetPer_Handle hPer,
390  Enet_Type enetType,
391  uint32_t instId,
392  const void *cfg,
393  uint32_t cfgSize);
394 
410 typedef int32_t (* const EnetPer_Rejoin)(EnetPer_Handle hPer,
411  Enet_Type enetType,
412  uint32_t instId);
413 
425 typedef int32_t (* const EnetPer_Ioctl)(EnetPer_Handle hPer,
426  uint32_t cmd,
427  Enet_IoctlPrms *prms);
428 
443 typedef void (* const EnetPer_Poll)(EnetPer_Handle hPer,
444  Enet_Event evt,
445  const void *arg,
446  uint32_t argSize);
447 
464 typedef uint64_t (* const EnetPer_ConvertTs)(EnetPer_Handle hPer,
465  uint64_t ts);
466 
474 typedef void (* const EnetPer_PeriodicTick)(EnetPer_Handle hPer);
475 
489 typedef void (* const EnetPer_RegisterEventCb)(EnetPer_Handle hPer,
490  Enet_Event evt,
491  uint32_t evtNum,
492  Enet_EventCallback evtCb,
493  void *evtCbArgs);
494 
504 typedef void (* const EnetPer_UnregisterEventCb)(EnetPer_Handle hPer,
505  Enet_Event evt,
506  uint32_t evtNum);
507 
515 typedef void (* const EnetPer_Close)(EnetPer_Handle hPer);
516 
520 typedef struct EnetPer_Obj_s
521 {
523  const char *name;
524 
527 
529  uint32_t instId;
530 
533 
539  uint64_t physAddr;
540 
542  void *virtAddr;
543 
545  uint64_t physAddr2;
546 
548  void *virtAddr2;
549 
551  uint32_t features;
552 
554  uint32_t errata;
555 
558 
561 
564 
567 
570 
573 
576 
579 
582 
585 } EnetPer_Obj;
586 
587 /* ========================================================================== */
588 /* Global Variables Declarations */
589 /* ========================================================================== */
590 
591 /* None */
592 
593 /* ========================================================================== */
594 /* Function Declarations */
595 /* ========================================================================== */
596 
597 /* None */
598 
599 /* ========================================================================== */
600 /* Deprecated Function Declarations */
601 /* ========================================================================== */
602 
603 /* None */
604 
605 /* ========================================================================== */
606 /* Static Function Definitions */
607 /* ========================================================================== */
608 
609 /* None */
610 
611 #ifdef __cplusplus
612 }
613 #endif
614 
615 #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:523
EnetPer_Obj::close
EnetPer_Close close
Definition: enet_per.h:584
ENET_PER_IOCTL_HANDLE_EXTPHY_LINKDOWN_EVENT
@ ENET_PER_IOCTL_HANDLE_EXTPHY_LINKDOWN_EVENT
Handle link down event for an externally managed PHY.
Definition: enet_per.h:241
Enet_IoctlRegisterHandlerInArgs::fxn
uintptr_t fxn
Definition: enet_per.h:350
EnetPer_Ioctl
int32_t(*const EnetPer_Ioctl)(EnetPer_Handle hPer, uint32_t cmd, Enet_IoctlPrms *prms)
Issue an operation on the Enet Peripheral.
Definition: enet_per.h:425
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:298
EnetPer_Obj::virtAddr2
void * virtAddr2
Definition: enet_per.h:548
EnetMacPort_LinkCfg
Link speed and duplexity configuration.
Definition: enet_mod_macport.h:457
EnetPer_Obj::magic
Enet_Magic magic
Definition: enet_per.h:532
EnetPer_Obj::features
uint32_t features
Definition: enet_per.h:551
enet_types.h
This file contains the basic types using across the Enet driver.
EnetPer_AttachCoreOutArgs::rxMtu
uint32_t rxMtu
Definition: enet_per.h:322
EnetPer_Obj::instId
uint32_t instId
Definition: enet_per.h:529
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
EnetPer_Poll
void(*const EnetPer_Poll)(EnetPer_Handle hPer, Enet_Event evt, const void *arg, uint32_t argSize)
Poll for Ethernet events.
Definition: enet_per.h:443
Enet_MacPort
Enet_MacPort
MAC port.
Definition: enet_types.h:409
Enet_Event
Enet_Event
Ethernet events.
Definition: enet_types.h:265
Enet_MacDstFlowInfo::flowIdx
uint32_t flowIdx
Definition: enet_per.h:286
EnetPer_AttachCoreOutArgs
Output args for ENET_PER_IOCTL_ATTACH_CORE command.
Definition: enet_per.h:317
EnetPer_Obj::physAddr
uint64_t physAddr
Definition: enet_per.h:539
EnetPer_Obj::rejoin
EnetPer_Rejoin rejoin
Definition: enet_per.h:563
Enet_ExtPhyLinkUpEventInfo
Input args for ENET_PER_IOCTL_HANDLE_EXTPHY_LINKUP_EVENT command.
Definition: enet_per.h:333
enet_ioctl.h
This file contains the type definitions and helper macros for the Enet IOCTL interface.
EnetPer_PeriodicTick
void(*const EnetPer_PeriodicTick)(EnetPer_Handle hPer)
Run periodic tick on the Ethernet peripheral.
Definition: enet_per.h:474
Enet_Magic
Enet_Magic
Enet driver magic value, used to indicate if driver is open or not.
Definition: enet_types.h:235
EnetPer_Obj::physAddr2
uint64_t physAddr2
Definition: enet_per.h:545
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:356
Enet_ExtPhyLinkUpEventInfo::macPort
Enet_MacPort macPort
Definition: enet_per.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
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:275
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:304
EnetPer_Obj
Ethernet Peripheral object.
Definition: enet_per.h:521
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:296
ENET_PRI_NUM
#define ENET_PRI_NUM
Packet priority.
Definition: enet_types.h:165
EnetPer_UnregisterEventCb
void(*const EnetPer_UnregisterEventCb)(EnetPer_Handle hPer, Enet_Event evt, uint32_t evtNum)
Unregister callback for an event.
Definition: enet_per.h:504
EnetMacPort_Interface
MAC port interface.
Definition: enet_mod_macport.h:442
Enet_MacDstFlowInfo::coreKey
uint32_t coreKey
Definition: enet_per.h:280
EnetPer_Obj::registerEventCb
EnetPer_RegisterEventCb registerEventCb
Definition: enet_per.h:578
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_InitCfg
void(*const EnetPer_InitCfg)(EnetPer_Handle hPer, Enet_Type enetType, void *cfg, uint32_t cfgSize)
Initialize peripheral's configuration parameters.
Definition: enet_per.h:370
EnetPer_Obj::convertTs
EnetPer_ConvertTs convertTs
Definition: enet_per.h:572
Enet_DfltFlowInfo::chIdx
uint32_t chIdx
Definition: enet_per.h:265
EnetPer_PortLinkCfg::linkCfg
EnetMacPort_LinkCfg linkCfg
Definition: enet_per.h:310
Enet_DfltFlowInfo
Rx Default Flow Info used for default flow registration/unregistration.
Definition: enet_per.h:260
EnetPer_Handle
struct EnetPer_Obj_s * EnetPer_Handle
Ethernet Peripheral handle.
Definition: enet_per.h:358
EnetPer_Close
void(*const EnetPer_Close)(EnetPer_Handle hPer)
Close the Enet Peripheral.
Definition: enet_per.h:515
EnetPer_Obj::initCfg
EnetPer_InitCfg initCfg
Definition: enet_per.h:557
EnetPer_Open
int32_t(*const 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:389
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:199
EnetPer_Obj::enetType
Enet_Type enetType
Definition: enet_per.h:526
EnetPer_Obj::poll
EnetPer_Poll poll
Definition: enet_per.h:569
Enet_MacDstFlowInfo::startIdx
uint32_t startIdx
Definition: enet_per.h:283
Enet_ExtPhyLinkUpEventInfo::phyLinkCfg
EnetPhy_LinkCfg phyLinkCfg
Definition: enet_per.h:338
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_ConvertTs
uint64_t(*const EnetPer_ConvertTs)(EnetPer_Handle hPer, uint64_t ts)
Convert a timestamp to nanoseconds.
Definition: enet_per.h:464
Enet_IoctlRegisterHandlerInArgs
ENET_PER_IOCTL_REGISTER_IOCTL_HANDLER inArgs
Definition: enet_per.h:345
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:542
EnetPhy_LinkCfg
Link speed and duplexity configuration.
Definition: enetphy.h:302
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:268
Enet_DfltFlowInfo::flowIdx
uint32_t flowIdx
Definition: enet_per.h:271
Enet_EventCallback
void(* Enet_EventCallback)(Enet_Event evt, uint32_t evtNum, void *evtCbArgs, void *arg1, void *arg2)
Event callback.
Definition: enet_types.h:451
EnetPer_Obj::ioctl
EnetPer_Ioctl ioctl
Definition: enet_per.h:566
Enet_IoctlRegisterHandlerInArgs::cmd
uint32_t cmd
Definition: enet_per.h:347
EnetPer_RegisterEventCb
void(*const 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:489
EnetPer_Obj::errata
uint32_t errata
Definition: enet_per.h:554
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:278
ENET_PER_IOCTL_REGISTER_IOCTL_HANDLER
@ ENET_PER_IOCTL_REGISTER_IOCTL_HANDLER
Register IOCTL handler.
Definition: enet_per.h:252
EnetPer_Obj::periodicTick
EnetPer_PeriodicTick periodicTick
Definition: enet_per.h:575
EnetPer_PortLinkCfg::macCfg
void * macCfg
Definition: enet_per.h:301
Enet_DfltFlowInfo::coreKey
uint32_t coreKey
Definition: enet_per.h:262
EnetPer_AttachCoreOutArgs::coreKey
uint32_t coreKey
Definition: enet_per.h:319
EnetPer_Obj::open
EnetPer_Open open
Definition: enet_per.h:560
EnetPer_Rejoin
int32_t(*const EnetPer_Rejoin)(EnetPer_Handle hPer, Enet_Type enetType, uint32_t instId)
Rejoin a running Enet Peripheral.
Definition: enet_per.h:410
ENET_PER_IOCTL_HANDLE_EXTPHY_LINKUP_EVENT
@ ENET_PER_IOCTL_HANDLE_EXTPHY_LINKUP_EVENT
Handle link up event for an externally managed PHY.
Definition: enet_per.h:230
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:581
EnetPer_PortLinkCfg::mii
EnetMacPort_Interface mii
Definition: enet_per.h:307