![]() |
![]() |
Data Structures | |
struct | Enet_IoctlPrms_s |
Enet IOCTL param. More... | |
struct | Enet_Version_s |
Version of a peripheral or module. More... | |
struct | Enet_VlanTag_s |
VLAN tag. More... | |
Macros | |
#define | ENET_IOCTL_TYPE_OFFSET (24U) |
IOCTL type bit offset. | |
#define | ENET_IOCTL_PER_OFFSET (16U) |
IOCTL hardware peripheral bit offset. | |
#define | ENET_IOCTL_MAJOR_OFFSET (8U) |
IOCTL major number bit offset. | |
#define | ENET_IOCTL_MINOR_OFFSET (0U) |
IOCTL minor number bit offset. | |
#define | ENET_IOCTL_GET_TYPE(x) ((x) & 0xFF000000U) |
Helper macro to get the IOCTL type (public/private). | |
#define | ENET_IOCTL_GET_PER(x) ((x) & 0x00FF0000U) |
Helper macro to get the peripheral type. | |
#define | ENET_IOCTL_GET_MAJ(x) ((x) & 0x0000FF00U) |
Helper macro to get the IOCTL major number. | |
#define | ENET_IOCTL_GET_MIN(x) ((x) & 0x000000FFU) |
Helper macro to get the IOCTL major number. | |
#define | ENET_IOCTL_TYPE(x) ((x) << ENET_IOCTL_TYPE_OFFSET) |
Helper macro to set the IOCTL type. | |
#define | ENET_IOCTL_PER(x) ((x) << ENET_IOCTL_PER_OFFSET) |
Helper macro to set the IOCTL type. | |
#define | ENET_IOCTL_MAJ(x) ((x) << ENET_IOCTL_MAJOR_OFFSET) |
Helper macro to set the IOCTL major number. | |
#define | ENET_IOCTL_MIN(x) ((x) << ENET_IOCTL_MINOR_OFFSET) |
Helper macro to set the IOCTL minor number. | |
#define | ENET_IOCTL_SET_NO_ARGS(prms) |
Set null args for an IOCTL command that takes no arguments. More... | |
#define | ENET_IOCTL_SET_IN_ARGS(prms, in) |
Set the input args for an IOCTL command. More... | |
#define | ENET_IOCTL_SET_OUT_ARGS(prms, out) |
Set the output args for an IOCTL command. More... | |
#define | ENET_IOCTL_SET_INOUT_ARGS(prms, in, out) |
Set the input and output args for an IOCTL command. More... | |
#define | ENET_PUBLIC_IOCTL(x) (ENET_IOCTL_ENET_BASE | ENET_IOCTL_MIN(x)) |
Helper macro for Enet public IOCTL command ids. | |
#define | ENET_ARRAYSIZE(x) (sizeof(x) / sizeof(x[0])) |
Macro to get the size of an array. | |
#define | ENET_BIT(n) (1U << (n)) |
Macro to set bit at given bit position. | |
#define | ENET_GET_BIT(val, n) (((val) & ENET_BIT(n)) >> (n)) |
Macro to get bit at given bit position. | |
#define | ENET_IS_BIT_SET(val, n) (((val) & ENET_BIT(n)) != 0U) |
Macro to check if bit at given bit position is set. | |
#define | ENET_VERSION_NONE (0xFFFFFFFFU) |
Version field is not supported. | |
#define | ENET_MAC_ADDR_LEN (6U) |
MAC address length in bytes/octets. | |
#define | ENET_OUI_ADDR_LEN (3U) |
Organization Unique Id (OUI) address length in bytes/octets. | |
#define | ENET_IPv4_ADDR_LEN (4U) |
IPv4 address length in bytes/octets. | |
#define | ENET_IPv6_ADDR_LEN (16U) |
IPv6 address length in bytes/octets. | |
#define | ENET_PRIORITY_NUM (8U) |
Packet priority. | |
#define | ENET_PRIORITY_MIN (0U) |
Lowest packet priority. | |
#define | ENET_PRIORITY_MAX (ENET_PRIORITY_NUM - 1U) |
Lowest packet priority. | |
#define | ENET_TOS_PRIORITY_NUM (64U) |
Type of Service (ToS) priority. | |
#define | ENET_TOS_PRIORITY_MIN (0U) |
Lowest ToS priority. | |
#define | ENET_TOS_PRIORITY_MAX (ENET_TOS_PRIORITY_NUM - 1U) |
Highest ToS priority. | |
#define | ENET_TYPE_NUM (ENET_TYPE_COUNT + 1U) |
Number of supported Ethernet peripheral types. | |
#define | ENET_MAC_PORT_NUM (ENET_MAC_PORT_COUNT) |
Number of MAC ports. | |
#define | ENET_NORM_MACPORT(n) ((n) - ENET_MAC_PORT_FIRST) |
Normalize Enet_MacPort. More... | |
#define | ENET_DENORM_MACPORT(n) ((Enet_MacPort)((n) + ENET_MAC_PORT_FIRST) |
De-normalize Enet_MacPort. More... | |
#define | ENET_MAC_PORT_INV ((Enet_MacPort)0xFFFFU) |
MAC invalid port number. Used for error checks only. | |
Typedefs | |
typedef void(* | Enet_EventCallback )(Enet_Event evt, uint32_t evtNum, void *evtCbArgs, void *arg1, void *arg2) |
Event callback. More... | |
typedef struct Enet_IoctlPrms_s | Enet_IoctlPrms |
Enet IOCTL param. More... | |
typedef enum Enet_Type_e | Enet_Type |
Ethernet peripheral type. | |
typedef enum Enet_Event_e | Enet_Event |
Ethernet events. More... | |
typedef struct Enet_Version_s | Enet_Version |
Version of a peripheral or module. More... | |
typedef enum Enet_Speed_e | Enet_Speed |
MAC interface speed. | |
typedef enum Enet_Duplexity_e | Enet_Duplexity |
MAC interface duplexity. | |
typedef enum Enet_VlanTagType_e | Enet_VlanTagType |
Double tagging VLAN type. | |
typedef struct Enet_VlanTag_s | Enet_VlanTag |
VLAN tag. | |
typedef enum Enet_MacPort_e | Enet_MacPort |
MAC port. | |
Functions | |
uint32_t | Enet_getCoreId (void) |
EnetTrace_TraceLevel | Enet_setTraceLevel (EnetTrace_TraceLevel level) |
Set global trace level. More... | |
EnetTrace_TraceLevel | Enet_getTraceLevel (void) |
Get current trace level. More... | |
void | Enet_initOsalCfg (EnetOsal_Cfg *osalCfg) |
Initialize OSAL configuration. More... | |
void | Enet_initUtilsCfg (EnetUtils_Cfg *utilsCfg) |
Initialize utils configuration. More... | |
void | Enet_init (const EnetOsal_Cfg *osalCfg, const EnetUtils_Cfg *utilsCfg) |
Initialize Enet LLD. More... | |
void | Enet_deinit (void) |
De-initialize Enet LLD. More... | |
Enet_Handle | Enet_getHandle (Enet_Type enetType, uint32_t instId) |
Get the Enet handle of a peripheral. More... | |
uint32_t | Enet_getMacPortMax (Enet_Type enetType, uint32_t instId) |
Get number of MAC ports available in the Ethernet peripheral. More... | |
void | Enet_initCfg (Enet_Type enetType, uint32_t instId, void *cfg) |
Initialize the peripheral configuration parameters. More... | |
Enet_Handle | Enet_open (Enet_Type enetType, uint32_t instId, const void *cfg) |
Open and initializes the Enet driver for a peripheral. More... | |
Enet_Handle | Enet_rejoin (Enet_Type enetType, uint32_t instId) |
Rejoin a running Ethernet peripheral. More... | |
int32_t | Enet_ioctl (Enet_Handle hEnet, uint32_t coreId, uint32_t cmd, Enet_IoctlPrms *prms) |
Issue an operation on the Enet Peripheral. More... | |
void | Enet_registerEventCb (Enet_Handle hEnet, Enet_Event evt, uint32_t evtNum, Enet_EventCallback evtCb, void *evtCbArgs) |
Register a callback for an event. More... | |
void | Enet_unregisterEventCb (Enet_Handle hEnet, Enet_Event evt, uint32_t evtNum) |
Unregister callback for an event. More... | |
void | Enet_poll (Enet_Handle hEnet, uint32_t evtMask) |
Poll for Ethernet events. More... | |
void | Enet_periodicTick (Enet_Handle hEnet) |
Run periodic tick on the Ethernet peripheral. More... | |
uint32_t | Enet_getMacPortCnt (Enet_Handle hEnet) |
Get number of MAC ports available in the Ethernet peripheral. More... | |
void | Enet_close (Enet_Handle hEnet) |
Close the Enet peripheral. More... | |
Enet Error Codes | |
Error codes returned by the Enet driver APIs. | |
#define | ENET_SOK (CSL_PASS) |
Success. | |
#define | ENET_SINPROGRESS (1) |
Operation in progress. | |
#define | ENET_EFAIL (CSL_EFAIL) |
Generic failure error condition (typically caused by hardware). | |
#define | ENET_EBADARGS (CSL_EBADARGS) |
Bad arguments (i.e. NULL pointer). | |
#define | ENET_EINVALIDPARAMS (CSL_EINVALID_PARAMS) |
Invalid parameters (i.e. value out-of-range). | |
#define | ENET_ETIMEOUT (CSL_ETIMEOUT) |
Time out while waiting for a given condition to happen. | |
#define | ENET_EALLOC (CSL_EALLOC) |
Allocation failure. | |
#define | ENET_EUNEXPECTED (CSL_EALLOC - 1) |
Unexpected condition occurred (sometimes unrecoverable). | |
#define | ENET_EBUSY (CSL_EALLOC - 2) |
The resource is currently busy performing an operation. | |
#define | ENET_EALREADYOPEN (CSL_EALLOC - 3) |
Already open error. | |
#define | ENET_EPERM (CSL_EALLOC - 4) |
Operation not permitted. | |
#define | ENET_ENOTSUPPORTED (CSL_EALLOC - 5) |
Operation not supported. | |
#define | ENET_ENOTFOUND (CSL_EALLOC - 6) |
Resource not found. | |
#define | ENET_EUNKNOWNIOCTL (CSL_EALLOC - 7) |
Unknown IOCTL. | |
#define | ENET_EMALFORMEDIOCTL (CSL_EALLOC - 8) |
Malformed IOCTL (args pointer or size not as expected). | |
#define ENET_DENORM_MACPORT | ( | n | ) | ((Enet_MacPort)((n) + ENET_MAC_PORT_FIRST) |
De-normalize Enet_MacPort.
Macro to denormalize MAC port number. It takes a zero-based port number and converts it to a Enet_MacPort enum.
#define ENET_IOCTL_SET_IN_ARGS | ( | prms, | |
in | |||
) |
Set the input args for an IOCTL command.
#define ENET_IOCTL_SET_INOUT_ARGS | ( | prms, | |
in, | |||
out | |||
) |
Set the input and output args for an IOCTL command.
#define ENET_IOCTL_SET_NO_ARGS | ( | prms | ) |
Set null args for an IOCTL command that takes no arguments.
#define ENET_IOCTL_SET_OUT_ARGS | ( | prms, | |
out | |||
) |
Set the output args for an IOCTL command.
#define ENET_NORM_MACPORT | ( | n | ) | ((n) - ENET_MAC_PORT_FIRST) |
Normalize Enet_MacPort.
Macro to normalize Enet_MacPort. It takes an Enet_MacPort enum and converts it to a zero-based index.
typedef enum Enet_Event_e Enet_Event |
Ethernet events.
Used for any Enet APIs that are event related such as:
typedef void(* Enet_EventCallback)(Enet_Event evt, uint32_t evtNum, void *evtCbArgs, void *arg1, void *arg2) |
Event callback.
evt | Event being registered for |
evtNum | Event number (0 if single event) |
evtCbArgs | Callback argument given during registration in Enet_registerEventCb() |
arg1 | Event specific argument |
arg2 | Event specific argument |
typedef struct Enet_IoctlPrms_s Enet_IoctlPrms |
Enet IOCTL param.
IOCTL params structure argument for all Enet IOCTL commands
typedef struct Enet_Version_s Enet_Version |
Version of a peripheral or module.
Version of a peripheral or module. It's the type returned by any GET_VERSION IOCTL command.
Version fields that are not supported or applicable will be set to ENET_VERSION_NONE.
enum Enet_Duplexity_e |
enum Enet_Event_e |
Ethernet events.
Used for any Enet APIs that are event related such as:
enum Enet_IoctlMajor_e |
IOCTL base number.
enum Enet_IoctlPer_e |
enum Enet_IoctlType_e |
enum Enet_MacPort_e |
MAC port.
enum Enet_Speed_e |
enum Enet_Type_e |
Ethernet peripheral type.
enum Enet_VlanTagType_e |
void Enet_close | ( | Enet_Handle | hEnet | ) |
Close the Enet peripheral.
Closes the Ethernet Peripheral.
hEnet | Enet driver handle |
void Enet_deinit | ( | void | ) |
De-initialize Enet LLD.
One-time de-initialization of the Enet LLD driver. This function clears the OSAL and utils config parameters passed during Enet_init().
It's expected to be called once all Ethernet peripherals have been closed via Enet_close().
uint32_t Enet_getCoreId | ( | void | ) |
Get self core id.
Gets the core id of the calling core. The driver doesn't enforce any specific core id definitions, it's up to the Enet SoC layer to define it.
Enet_Handle Enet_getHandle | ( | Enet_Type | enetType, |
uint32_t | instId | ||
) |
Get the Enet handle of a peripheral.
Gets the driver handle of a peripheral identified by its type and instance id. If the driver hasn't been opened via Enet_open(), this function returns NULL.
enetType | Enet Peripheral type |
instId | Enet Peripheral instance id |
uint32_t Enet_getMacPortCnt | ( | Enet_Handle | hEnet | ) |
Get number of MAC ports available in the Ethernet peripheral.
Gets the number of MAC ports available in the Ethernet peripheral. This function is similar to Enet_getMacPortMax() except that it takes an Enet handle.
hEnet | Enet driver handle |
uint32_t Enet_getMacPortMax | ( | Enet_Type | enetType, |
uint32_t | instId | ||
) |
Get number of MAC ports available in the Ethernet peripheral.
Gets the number of MAC ports available in the Ethernet peripheral identified by its type and instance id.
enetType | Enet Peripheral type |
instId | Enet Peripheral instance id |
EnetTrace_TraceLevel Enet_getTraceLevel | ( | void | ) |
Get current trace level.
Get the current global trace level of the Enet LLD.
void Enet_init | ( | const EnetOsal_Cfg * | osalCfg, |
const EnetUtils_Cfg * | utilsCfg | ||
) |
Initialize Enet LLD.
One-time initialization of the Enet LLD driver. This function initializes the OSAL and utils infrastructure that the driver requires for handling multiple peripherals as well as logging and tracing.
The Enet LLD provides a default OSAL implementation which is based on PDK OSAL library if ENET_CFG_HAS_DEFAULT_OSAL config flag is enabled. The default OSAL implementation can be used if the caller passes a NULL osalCfg
.
Similarly, the Enet LLD provides a default utils implementation if ENET_CFG_HAS_DEFAULT_UTILS config flag is set. The default utils implemetnation can be used if the caller passes a NULL utilsCfg
.
osalCfg | OSAL configuration parameters |
utilsCfg | Utils configuration parameters |
void Enet_initCfg | ( | Enet_Type | enetType, |
uint32_t | instId, | ||
void * | cfg | ||
) |
Initialize the peripheral configuration parameters.
Initializes the peripheral configuration parameters with default values.
Configuration parameters are peripheral specific, so the Enet LLD doesn't enforce any definition. Instead, the application should use the configuration structure corresponding to the peripheral(s) available in the platform.
enetType | Enet Peripheral type |
instId | Enet Peripheral instance id |
cfg | Configuration parameters to be initialized |
void Enet_initOsalCfg | ( | EnetOsal_Cfg * | osalCfg | ) |
Initialize OSAL configuration.
Initializes the passed OSAL configuration structure with a default implementation which is based on the PDK OSAL library if ENET_CFG_HAS_DEFAULT_OSAL config flag is enabled. Otherwise, the configuration structure will be cleared.
The caller can overwrite any OSAL functions after calling this API.
osalCfg | OSAL configuration parameters |
void Enet_initUtilsCfg | ( | EnetUtils_Cfg * | utilsCfg | ) |
Initialize utils configuration.
Initializes the passed utils configuration structure with a default implementation if ENET_CFG_HAS_DEFAULT_OSAL config flag is enabled. Otherwise, the configuration structure will be cleared. The default utils implementation provides UART-based logging and one-to-one address translation.
The caller can overwrite any utils functions after calling this API.
utilsCfg | Utils configuration parameters |
int32_t Enet_ioctl | ( | Enet_Handle | hEnet, |
uint32_t | coreId, | ||
uint32_t | cmd, | ||
Enet_IoctlPrms * | prms | ||
) |
Issue an operation on the Enet Peripheral.
Issues a control operation on the Enet Peripheral. The IOCTL parameters should be built using the helper macros provided by the driver:
hEnet | Enet driver handle |
coreId | Caller's core id |
cmd | IOCTL command Id |
prms | IOCTL parameters |
Enet_Handle Enet_open | ( | Enet_Type | enetType, |
uint32_t | instId, | ||
const void * | cfg | ||
) |
Open and initializes the Enet driver for a peripheral.
Opens and initializes the Ethernet peripheral with the configuration parameters provided by the caller. The peripheral is identified by its type and instance id.
Configuration parameters are peripheral specific, so the Enet LLD doesn't enforce any definition. Instead, the application should use the configuration structure corresponding to the peripheral(s) available in the platform.
enetType | Enet Peripheral type |
instId | Enet Peripheral instance id |
cfg | Configuration parameters |
void Enet_periodicTick | ( | Enet_Handle | hEnet | ) |
Run periodic tick on the Ethernet peripheral.
Run PHY periodic tick on the Ethernet peripheral.
hEnet | Enet driver handle |
void Enet_poll | ( | Enet_Handle | hEnet, |
uint32_t | evtMask | ||
) |
Poll for Ethernet events.
Unblocking poll for the events specified in evtMask
. The event mask can be constructed using the types defined in Enet_Event. The callback function must be registered via Enet_registerEventCb() prior to calling Enet_poll().
Note that not all peripherals support poll mechanism.
hEnet | Enet driver handle |
evtMask | Event bit mask |
void Enet_registerEventCb | ( | Enet_Handle | hEnet, |
Enet_Event | evt, | ||
uint32_t | evtNum, | ||
Enet_EventCallback | evtCb, | ||
void * | evtCbArgs | ||
) |
Register a callback for an event.
Registers a callback for an event. The callback with be called either via Enet_poll() when interrupts are disabled or internally by the driver when servicing an interrupt in ISR context.
hEnet | Enet driver handle |
evt | Event being registered for |
evtNum | Event number. Use 0 for single event. |
evtCb | Callback function |
evtCbArgs | Callback function arguments |
Enet_Handle Enet_rejoin | ( | Enet_Type | enetType, |
uint32_t | instId | ||
) |
Rejoin a running Ethernet peripheral.
Reopens the Enet Peripheral, but doesn't perform any hardware initialization. This function is expected to be called to rejoin to a running peripheral. The peripheral is identified by its type and instance id.
enetType | Enet Peripheral type |
instId | Enet Peripheral instance id |
EnetTrace_TraceLevel Enet_setTraceLevel | ( | EnetTrace_TraceLevel | level | ) |
Set global trace level.
Sets the trace level of the Enet LLD. The driver provides the following trace levels: ERROR, WARN, INFO, DEBUG and VERBOSE.
This function returns the previous trace level, which comes in handy when restoring trace level, if needed.
level | Trace level |
void Enet_unregisterEventCb | ( | Enet_Handle | hEnet, |
Enet_Event | evt, | ||
uint32_t | evtNum | ||
) |
Unregister callback for an event.
Unregisters a callback for an event.
hEnet | Enet driver handle |
evt | Event being registered for |
evtNum | Event number. Use 0 for single event. |