AM263x MCU+ SDK  10.00.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 
264 
275 
276 };
277 
281 typedef struct Enet_DfltFlowInfo_s
282 {
284  uint32_t coreKey;
285 
287  uint32_t chIdx;
288 
290  uint32_t startIdx;
291 
293  uint32_t flowIdx;
295 
299 typedef struct Enet_MacDstFlowInfo_s
300 {
302  uint32_t coreKey;
303 
305  uint32_t startIdx;
306 
308  uint32_t flowIdx;
309 
311  uint8_t macAddress[ENET_MAC_ADDR_LEN];
313 
317 typedef struct EnetPer_PortLinkCfg_s
318 {
321 
323  void *macCfg;
324 
327 
330 
334 
338 typedef struct EnetPer_AttachCoreOutArgs_s
339 {
341  uint32_t coreKey;
342 
344  uint32_t rxMtu;
345 
347  uint32_t txMtu[ENET_PRI_NUM];
349 
350 
354 typedef struct Enet_ExtPhyLinkUpEventInfo_s
355 {
358 
362 
366 typedef struct Enet_IoctlRegisterHandlerInArgs_s
367 {
369  uint32_t cmd;
370 
372  uintptr_t fxn;
374 
380 typedef struct EnetPer_Obj_s *EnetPer_Handle;
381 
392 typedef void (* const EnetPer_InitCfg)(EnetPer_Handle hPer,
393  Enet_Type enetType,
394  void *cfg,
395  uint32_t cfgSize);
396 
411 typedef int32_t (* const EnetPer_Open)(EnetPer_Handle hPer,
412  Enet_Type enetType,
413  uint32_t instId,
414  const void *cfg,
415  uint32_t cfgSize);
416 
432 typedef int32_t (* const EnetPer_Rejoin)(EnetPer_Handle hPer,
433  Enet_Type enetType,
434  uint32_t instId);
435 
447 typedef int32_t (* const EnetPer_Ioctl)(EnetPer_Handle hPer,
448  uint32_t cmd,
449  Enet_IoctlPrms *prms);
450 
465 typedef void (* const EnetPer_Poll)(EnetPer_Handle hPer,
466  Enet_Event evt,
467  const void *arg,
468  uint32_t argSize);
469 
486 typedef uint64_t (* const EnetPer_ConvertTs)(EnetPer_Handle hPer,
487  uint64_t ts);
488 
496 typedef void (* const EnetPer_PeriodicTick)(EnetPer_Handle hPer);
497 
511 typedef void (* const EnetPer_RegisterEventCb)(EnetPer_Handle hPer,
512  Enet_Event evt,
513  uint32_t evtNum,
514  Enet_EventCallback evtCb,
515  void *evtCbArgs);
516 
526 typedef void (* const EnetPer_UnregisterEventCb)(EnetPer_Handle hPer,
527  Enet_Event evt,
528  uint32_t evtNum);
529 
537 typedef void (* const EnetPer_Close)(EnetPer_Handle hPer);
538 
546 typedef void (* const EnetPer_SaveCtxt)(EnetPer_Handle hPer);
547 
560 typedef int32_t (* const EnetPer_RestoreCtxt)(EnetPer_Handle hPer,
561  Enet_Type enetType,
562  uint32_t instId);
563 
567 typedef struct EnetPer_Obj_s
568 {
570  const char *name;
571 
574 
576  uint32_t instId;
577 
580 
586  uint64_t physAddr;
587 
589  void *virtAddr;
590 
592  uint64_t physAddr2;
593 
595  void *virtAddr2;
596 
598  uint32_t features;
599 
601  uint32_t errata;
602 
605 
608 
611 
614 
617 
620 
623 
626 
629 
632 
635 
638 } EnetPer_Obj;
639 
640 /* ========================================================================== */
641 /* Global Variables Declarations */
642 /* ========================================================================== */
643 
644 /* None */
645 
646 /* ========================================================================== */
647 /* Function Declarations */
648 /* ========================================================================== */
649 
650 /* None */
651 
652 /* ========================================================================== */
653 /* Deprecated Function Declarations */
654 /* ========================================================================== */
655 
656 /* None */
657 
658 /* ========================================================================== */
659 /* Static Function Definitions */
660 /* ========================================================================== */
661 
662 /* None */
663 
664 #ifdef __cplusplus
665 }
666 #endif
667 
668 #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:570
EnetPer_Obj::close
EnetPer_Close close
Definition: enet_per.h:631
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_PER_IOCTL_CLEAR_ISOLATE_STATE
@ ENET_PER_IOCTL_CLEAR_ISOLATE_STATE
Clear PHY ISOLATE mode.
Definition: enet_per.h:274
Enet_IoctlRegisterHandlerInArgs::fxn
uintptr_t fxn
Definition: enet_per.h:372
EnetPer_SaveCtxt
void(*const EnetPer_SaveCtxt)(EnetPer_Handle hPer)
Save and close the Enet Peripheral.
Definition: enet_per.h:546
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:447
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:320
EnetPer_Obj::virtAddr2
void * virtAddr2
Definition: enet_per.h:595
EnetMacPort_LinkCfg
Link speed and duplexity configuration.
Definition: enet_mod_macport.h:457
EnetPer_Obj::magic
Enet_Magic magic
Definition: enet_per.h:579
EnetPer_Obj::features
uint32_t features
Definition: enet_per.h:598
enet_types.h
This file contains the basic types using across the Enet driver.
EnetPer_AttachCoreOutArgs::rxMtu
uint32_t rxMtu
Definition: enet_per.h:344
EnetPer_Obj::instId
uint32_t instId
Definition: enet_per.h:576
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:465
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:308
EnetPer_AttachCoreOutArgs
Output args for ENET_PER_IOCTL_ATTACH_CORE command.
Definition: enet_per.h:339
EnetPer_Obj::physAddr
uint64_t physAddr
Definition: enet_per.h:586
EnetPer_Obj::rejoin
EnetPer_Rejoin rejoin
Definition: enet_per.h:610
Enet_ExtPhyLinkUpEventInfo
Input args for ENET_PER_IOCTL_HANDLE_EXTPHY_LINKUP_EVENT command.
Definition: enet_per.h:355
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:496
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:592
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
EnetPer_RestoreCtxt
int32_t(*const EnetPer_RestoreCtxt)(EnetPer_Handle hPer, Enet_Type enetType, uint32_t instId)
Restores and Opens the Enet Peripheral.
Definition: enet_per.h:560
Enet_ExtPhyLinkUpEventInfo::macPort
Enet_MacPort macPort
Definition: enet_per.h:357
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:326
EnetPer_Obj
Ethernet Peripheral object.
Definition: enet_per.h:568
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:318
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:526
EnetMacPort_Interface
MAC port interface.
Definition: enet_mod_macport.h:442
Enet_MacDstFlowInfo::coreKey
uint32_t coreKey
Definition: enet_per.h:302
EnetPer_Obj::registerEventCb
EnetPer_RegisterEventCb registerEventCb
Definition: enet_per.h:625
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
ENET_PER_IOCTL_SET_ISOLATE_STATE
@ ENET_PER_IOCTL_SET_ISOLATE_STATE
Setting PHY ISOLATE mode.
Definition: enet_per.h:263
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:392
EnetPer_Obj::convertTs
EnetPer_ConvertTs convertTs
Definition: enet_per.h:619
Enet_DfltFlowInfo::chIdx
uint32_t chIdx
Definition: enet_per.h:287
EnetPer_PortLinkCfg::linkCfg
EnetMacPort_LinkCfg linkCfg
Definition: enet_per.h:332
Enet_DfltFlowInfo
Rx Default Flow Info used for default flow registration/unregistration.
Definition: enet_per.h:282
EnetPer_Handle
struct EnetPer_Obj_s * EnetPer_Handle
Ethernet Peripheral handle.
Definition: enet_per.h:380
EnetPer_Close
void(*const EnetPer_Close)(EnetPer_Handle hPer)
Close the Enet Peripheral.
Definition: enet_per.h:537
EnetPer_Obj::initCfg
EnetPer_InitCfg initCfg
Definition: enet_per.h:604
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:411
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:573
EnetPer_Obj::poll
EnetPer_Poll poll
Definition: enet_per.h:616
Enet_MacDstFlowInfo::startIdx
uint32_t startIdx
Definition: enet_per.h:305
Enet_ExtPhyLinkUpEventInfo::phyLinkCfg
EnetPhy_LinkCfg phyLinkCfg
Definition: enet_per.h:360
EnetPer_Obj::restoreCtxt
EnetPer_RestoreCtxt restoreCtxt
Definition: enet_per.h:637
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:486
Enet_IoctlRegisterHandlerInArgs
ENET_PER_IOCTL_REGISTER_IOCTL_HANDLER inArgs
Definition: enet_per.h:367
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:589
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:290
Enet_DfltFlowInfo::flowIdx
uint32_t flowIdx
Definition: enet_per.h:293
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:613
Enet_IoctlRegisterHandlerInArgs::cmd
uint32_t cmd
Definition: enet_per.h:369
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:511
EnetPer_Obj::errata
uint32_t errata
Definition: enet_per.h:601
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:300
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:622
EnetPer_PortLinkCfg::macCfg
void * macCfg
Definition: enet_per.h:323
Enet_DfltFlowInfo::coreKey
uint32_t coreKey
Definition: enet_per.h:284
EnetPer_AttachCoreOutArgs::coreKey
uint32_t coreKey
Definition: enet_per.h:341
EnetPer_Obj::open
EnetPer_Open open
Definition: enet_per.h:607
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:432
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:628
EnetPer_PortLinkCfg::mii
EnetMacPort_Interface mii
Definition: enet_per.h:329
EnetPer_Obj::saveCtxt
EnetPer_SaveCtxt saveCtxt
Definition: enet_per.h:634