AM263x MCU+ SDK  08.03.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 };
243 
247 typedef struct Enet_DfltFlowInfo_s
248 {
250  uint32_t coreKey;
251 
253  uint32_t chIdx;
254 
256  uint32_t startIdx;
257 
259  uint32_t flowIdx;
261 
265 typedef struct Enet_MacDstFlowInfo_s
266 {
268  uint32_t coreKey;
269 
271  uint32_t startIdx;
272 
274  uint32_t flowIdx;
275 
277  uint8_t macAddress[ENET_MAC_ADDR_LEN];
279 
283 typedef struct EnetPer_PortLinkCfg_s
284 {
287 
289  void *macCfg;
290 
293 
296 
300 
304 typedef struct EnetPer_AttachCoreOutArgs_s
305 {
307  uint32_t coreKey;
308 
310  uint32_t rxMtu;
311 
313  uint32_t txMtu[ENET_PRI_NUM];
315 
316 
320 typedef struct Enet_ExtPhyLinkUpEventInfo_s
321 {
324 
328 
334 typedef struct EnetPer_Obj_s *EnetPer_Handle;
335 
346 typedef void (*EnetPer_InitCfg)(EnetPer_Handle hPer,
347  Enet_Type enetType,
348  void *cfg,
349  uint32_t cfgSize);
350 
365 typedef int32_t (*EnetPer_Open)(EnetPer_Handle hPer,
366  Enet_Type enetType,
367  uint32_t instId,
368  const void *cfg,
369  uint32_t cfgSize);
370 
386 typedef int32_t (*EnetPer_Rejoin)(EnetPer_Handle hPer,
387  Enet_Type enetType,
388  uint32_t instId);
389 
401 typedef int32_t (*EnetPer_Ioctl)(EnetPer_Handle hPer,
402  uint32_t cmd,
403  Enet_IoctlPrms *prms);
404 
419 typedef void (*EnetPer_Poll)(EnetPer_Handle hPer,
420  Enet_Event evt,
421  const void *arg,
422  uint32_t argSize);
423 
440 typedef uint64_t (*EnetPer_ConvertTs)(EnetPer_Handle hPer,
441  uint64_t ts);
442 
450 typedef void (*EnetPer_PeriodicTick)(EnetPer_Handle hPer);
451 
466  Enet_Event evt,
467  uint32_t evtNum,
468  Enet_EventCallback evtCb,
469  void *evtCbArgs);
470 
481  Enet_Event evt,
482  uint32_t evtNum);
483 
491 typedef void (*EnetPer_Close)(EnetPer_Handle hPer);
492 
496 typedef struct EnetPer_Obj_s
497 {
499  const char *name;
500 
503 
505  uint32_t instId;
506 
509 
515  uint64_t physAddr;
516 
518  void *virtAddr;
519 
521  uint64_t physAddr2;
522 
524  void *virtAddr2;
525 
527  uint32_t features;
528 
530  uint32_t errata;
531 
534 
537 
540 
543 
546 
549 
552 
555 
558 
561 } EnetPer_Obj;
562 
563 /* ========================================================================== */
564 /* Global Variables Declarations */
565 /* ========================================================================== */
566 
567 /* None */
568 
569 /* ========================================================================== */
570 /* Function Declarations */
571 /* ========================================================================== */
572 
573 /* None */
574 
575 /* ========================================================================== */
576 /* Deprecated Function Declarations */
577 /* ========================================================================== */
578 
579 /* None */
580 
581 /* ========================================================================== */
582 /* Static Function Definitions */
583 /* ========================================================================== */
584 
585 /* None */
586 
587 #ifdef __cplusplus
588 }
589 #endif
590 
591 #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:499
EnetPer_Obj::close
EnetPer_Close close
Definition: enet_per.h:560
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_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:286
EnetPer_Obj::virtAddr2
void * virtAddr2
Definition: enet_per.h:524
EnetMacPort_LinkCfg
Link speed and duplexity configuration.
Definition: enet_mod_macport.h:298
EnetPer_Obj::magic
Enet_Magic magic
Definition: enet_per.h:508
EnetPer_UnregisterEventCb
void(* EnetPer_UnregisterEventCb)(EnetPer_Handle hPer, Enet_Event evt, uint32_t evtNum)
Unregister callback for an event.
Definition: enet_per.h:480
EnetPer_Obj::features
uint32_t features
Definition: enet_per.h:527
enet_types.h
This file contains the basic types using across the Enet driver.
EnetPer_AttachCoreOutArgs::rxMtu
uint32_t rxMtu
Definition: enet_per.h:310
EnetPer_Obj::instId
uint32_t instId
Definition: enet_per.h:505
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:274
EnetPer_ConvertTs
uint64_t(* EnetPer_ConvertTs)(EnetPer_Handle hPer, uint64_t ts)
Convert a timestamp to nanoseconds.
Definition: enet_per.h:440
EnetPer_AttachCoreOutArgs
Output args for ENET_PER_IOCTL_ATTACH_CORE command.
Definition: enet_per.h:305
EnetPer_Obj::physAddr
uint64_t physAddr
Definition: enet_per.h:515
EnetPer_Obj::rejoin
EnetPer_Rejoin rejoin
Definition: enet_per.h:539
EnetPer_PeriodicTick
void(* EnetPer_PeriodicTick)(EnetPer_Handle hPer)
Run periodic tick on the Ethernet peripheral.
Definition: enet_per.h:450
Enet_ExtPhyLinkUpEventInfo
Input args for ENET_PER_IOCTL_HANDLE_EXTPHY_LINKUP_EVENT command.
Definition: enet_per.h:321
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:521
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_ExtPhyLinkUpEventInfo::macPort
Enet_MacPort macPort
Definition: enet_per.h:323
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:386
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:401
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:292
EnetPer_Obj
Ethernet Peripheral object.
Definition: enet_per.h:497
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:284
ENET_PRI_NUM
#define ENET_PRI_NUM
Packet priority.
Definition: enet_types.h:165
EnetMacPort_Interface
MAC port interface.
Definition: enet_mod_macport.h:283
Enet_MacDstFlowInfo::coreKey
uint32_t coreKey
Definition: enet_per.h:268
EnetPer_Obj::registerEventCb
EnetPer_RegisterEventCb registerEventCb
Definition: enet_per.h:554
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:548
Enet_DfltFlowInfo::chIdx
uint32_t chIdx
Definition: enet_per.h:253
EnetPer_PortLinkCfg::linkCfg
EnetMacPort_LinkCfg linkCfg
Definition: enet_per.h:298
Enet_DfltFlowInfo
Rx Default Flow Info used for default flow registration/unregistration.
Definition: enet_per.h:248
EnetPer_Handle
struct EnetPer_Obj_s * EnetPer_Handle
Ethernet Peripheral handle.
Definition: enet_per.h:334
EnetPer_Obj::initCfg
EnetPer_InitCfg initCfg
Definition: enet_per.h:533
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:365
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:419
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:502
EnetPer_Obj::poll
EnetPer_Poll poll
Definition: enet_per.h:545
Enet_MacDstFlowInfo::startIdx
uint32_t startIdx
Definition: enet_per.h:271
Enet_ExtPhyLinkUpEventInfo::phyLinkCfg
EnetPhy_LinkCfg phyLinkCfg
Definition: enet_per.h:326
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:491
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:518
EnetPhy_LinkCfg
Link speed and duplexity configuration.
Definition: enetphy.h:296
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:256
Enet_DfltFlowInfo::flowIdx
uint32_t flowIdx
Definition: enet_per.h:259
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:346
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:465
EnetPer_Obj::ioctl
EnetPer_Ioctl ioctl
Definition: enet_per.h:542
EnetPer_Obj::errata
uint32_t errata
Definition: enet_per.h:530
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:266
EnetPer_Obj::periodicTick
EnetPer_PeriodicTick periodicTick
Definition: enet_per.h:551
EnetPer_PortLinkCfg::macCfg
void * macCfg
Definition: enet_per.h:289
Enet_DfltFlowInfo::coreKey
uint32_t coreKey
Definition: enet_per.h:250
EnetPer_AttachCoreOutArgs::coreKey
uint32_t coreKey
Definition: enet_per.h:307
EnetPer_Obj::open
EnetPer_Open open
Definition: enet_per.h:536
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:557
EnetPer_PortLinkCfg::mii
EnetMacPort_Interface mii
Definition: enet_per.h:295