AM64x MCU+ SDK  10.00.00
enet_utils.h File Reference

Introduction

This file contains the type definitions and function prototypes of the Enet Utils functionality.

Go to the source code of this file.

Data Structures

struct  EnetUtils_Cfg
 Enet utils parameters. More...
 

Macros

#define container_of(ptr, type, member)
 Macro to get container structure from one of its members' addresses. More...
 
#define ENET_UNUSED(x)   (x = x)
 Unused variable. More...
 
#define ENET_MK_ONES(c_ebit, c_sbit)   (((1U << (((c_ebit) - (c_sbit)) + 1U)) - 1U) << (c_sbit))
 Macro to create a bit mask. More...
 
#define ENET_UTILS_ALIGN(x, y)   ((((x) + ((y) - 1)) / (y)) * (y))
 Align a value by performing a round-up operation. More...
 
#define ENET_UTILS_IS_ALIGNED(addr, alignSz)   (((uintptr_t)addr & ((alignSz) - 1U)) == 0U)
 Macro to determine if an address is aligned to a given size. More...
 
#define ENET_UTILS_ARRAY_COPY(dst, src)
 Macro to copy arrays. They must be of the same size. More...
 
#define Enet_assert(cond, ...)   (void)(cond)
 Assertion. More...
 
#define Enet_devAssert(cond, ...)   (void)(cond)
 Development-time assertion. More...
 
#define ENET_UTILS_COMPILETIME_ASSERT(cond)
 Compile-time assertion. More...
 
#define ENET_NUM_NANOSECS_PER_SEC   (1000000000ULL)
 

Typedefs

typedef void(* Enet_Print) (const char *fmt,...)
 Info/debug print function prototype. More...
 
typedef uint64_t(* Enet_VirtToPhys) (const void *virtAddr, void *appData)
 Virtual-to-physical address translation callback function. More...
 
typedef void *(* Enet_PhysToVirt) (uint64_t phyAddr, void *appData)
 Physical-to-virtual address translation callback function. More...
 

Functions

void EnetUtils_init (const EnetUtils_Cfg *cfg)
 Initialize utils module. More...
 
void EnetUtils_deinit (void)
 De-initialize utils module. More...
 
void EnetUtils_printf (const char *fmt,...)
 Print function. More...
 
void EnetUtils_vprintf (const char *fmt, va_list args)
 Print function for va_list. More...
 
uint32_t EnetUtils_min (uint32_t num1, uint32_t num2)
 Returns minimum of two numbers. More...
 
uint32_t EnetUtils_max (uint32_t num1, uint32_t num2)
 Returns minimum of two numbers. More...
 
void EnetUtils_delayTicks (const uint32_t delayTicks)
 Busy loop for a given amount of delay in CPU clock ticks. More...
 
void EnetUtils_delayNs (const uint32_t delayNs)
 Busy loop for a given amount of delay in nano seconds. More...
 
uint64_t EnetUtils_virtToPhys (const void *virtAddr, void *appData)
 Convert a virtual address to physical address. More...
 
void * EnetUtils_physToVirt (uint64_t physAddr, void *appData)
 Convert a physical address to virtual address. More...
 
EnetPhy_Mii EnetUtils_macToPhyMii (const EnetMacPort_Interface *macMii)
 Convert MAC port MII to PHY MII types. More...
 
static void EnetUtils_copyMacAddr (uint8_t *dst, const uint8_t *src)
 Copy MAC address. More...
 
static bool EnetUtils_cmpMacAddr (const uint8_t *addr1, const uint8_t *addr2)
 Compare two MAC address. More...
 
static void EnetUtils_clearMacAddr (uint8_t *addr)
 Clear MAC address. More...
 
static bool EnetUtils_isMcastAddr (const uint8_t *addr)
 Check if address is multicast. More...
 

Macro Definition Documentation

◆ container_of

#define container_of (   ptr,
  type,
  member 
)
Value:
({ \
const typeof(((type *)0)->member) * __mptr = (ptr); \
(type *)((char *)__mptr - offsetof(type, member)); \
})

Macro to get container structure from one of its members' addresses.

◆ ENET_UNUSED

#define ENET_UNUSED (   x)    (x = x)

Unused variable.

◆ ENET_MK_ONES

#define ENET_MK_ONES (   c_ebit,
  c_sbit 
)    (((1U << (((c_ebit) - (c_sbit)) + 1U)) - 1U) << (c_sbit))

Macro to create a bit mask.

◆ ENET_UTILS_ALIGN

#define ENET_UTILS_ALIGN (   x,
 
)    ((((x) + ((y) - 1)) / (y)) * (y))

Align a value by performing a round-up operation.

◆ ENET_UTILS_IS_ALIGNED

#define ENET_UTILS_IS_ALIGNED (   addr,
  alignSz 
)    (((uintptr_t)addr & ((alignSz) - 1U)) == 0U)

Macro to determine if an address is aligned to a given size.

◆ ENET_UTILS_ARRAY_COPY

#define ENET_UTILS_ARRAY_COPY (   dst,
  src 
)
Value:
do \
{ \
/* dst argument of macro should be array and not pointer.*/ \
ENET_UTILS_COMPILETIME_ASSERT(sizeof(dst) != sizeof(uintptr_t)); \
memcpy(dst, src, (ENET_ARRAYSIZE(dst) * sizeof(dst[0]))); \
} while (0)

Macro to copy arrays. They must be of the same size.

◆ Enet_assert

#define Enet_assert (   cond,
  ... 
)    (void)(cond)

Assertion.

◆ Enet_devAssert

#define Enet_devAssert (   cond,
  ... 
)    (void)(cond)

Development-time assertion.

◆ ENET_UTILS_COMPILETIME_ASSERT

#define ENET_UTILS_COMPILETIME_ASSERT (   cond)
Value:
do { \
typedef char ErrorCheck[((cond) == true) ? 1 : -1]; \
ErrorCheck a = {0}; \
a[0U] = a[0U]; \
} while (0)

Compile-time assertion.

◆ ENET_NUM_NANOSECS_PER_SEC

#define ENET_NUM_NANOSECS_PER_SEC   (1000000000ULL)

Typedef Documentation

◆ Enet_Print

typedef void(* Enet_Print) (const char *fmt,...)

Info/debug print function prototype.

This function is used by the driver to print info/debug messages.

Parameters
fmtFormatted string followed by variable arguments

◆ Enet_VirtToPhys

typedef uint64_t(* Enet_VirtToPhys) (const void *virtAddr, void *appData)

Virtual-to-physical address translation callback function.

This function is used by the driver to convert virtual address to physical address.

Parameters
virtAddrVirtual address
appDataCallback pointer passed during translation
Returns
Translated physical address

◆ Enet_PhysToVirt

typedef void*(* Enet_PhysToVirt) (uint64_t phyAddr, void *appData)

Physical-to-virtual address translation callback function.

This function is used by the driver to convert physical address to virtual address.

Parameters
phyAddrPhysical address
appDataCallback pointer passed during translation
Returns
Translated virtual address

Function Documentation

◆ EnetUtils_init()

void EnetUtils_init ( const EnetUtils_Cfg cfg)

Initialize utils module.

Utils module initialization function. Should be only called from the Enet top-level module.

Parameters
cfgPointer to the initialization parameters

◆ EnetUtils_deinit()

void EnetUtils_deinit ( void  )

De-initialize utils module.

◆ EnetUtils_printf()

void EnetUtils_printf ( const char *  fmt,
  ... 
)

Print function.

Prints the provided formatted string.

Parameters
fmtFormatted string followed by variable arguments

◆ EnetUtils_vprintf()

void EnetUtils_vprintf ( const char *  fmt,
va_list  args 
)

Print function for va_list.

Prints the provided formatted string.

Parameters
fmtFormatted string
argsArg list pointing to the arguments in the format string

◆ EnetUtils_min()

uint32_t EnetUtils_min ( uint32_t  num1,
uint32_t  num2 
)

Returns minimum of two numbers.

Parameters
num1First number
num2Second number
Returns
Minimum number

◆ EnetUtils_max()

uint32_t EnetUtils_max ( uint32_t  num1,
uint32_t  num2 
)

Returns minimum of two numbers.

Parameters
num1First number
num2Second number
Returns
Maximum number

◆ EnetUtils_delayTicks()

void EnetUtils_delayTicks ( const uint32_t  delayTicks)

Busy loop for a given amount of delay in CPU clock ticks.

Parameters
delayTicksDelay time in CPU clock ticks

◆ EnetUtils_delayNs()

void EnetUtils_delayNs ( const uint32_t  delayNs)

Busy loop for a given amount of delay in nano seconds.

Parameters
delayNsDelay time in nano seconds

◆ EnetUtils_virtToPhys()

uint64_t EnetUtils_virtToPhys ( const void *  virtAddr,
void *  appData 
)

Convert a virtual address to physical address.

Parameters
virtAddrVirtual address
appDataAuxiliary data
Returns
Physical address

◆ EnetUtils_physToVirt()

void* EnetUtils_physToVirt ( uint64_t  physAddr,
void *  appData 
)

Convert a physical address to virtual address.

Parameters
physAddrPhysical address
appDataAuxiliary data
Returns
Virtual address

◆ EnetUtils_macToPhyMii()

EnetPhy_Mii EnetUtils_macToPhyMii ( const EnetMacPort_Interface macMii)

Convert MAC port MII to PHY MII types.

Converts MII type definition from EnetMacPort_Interface to EnetPhy_Mii.

Parameters
macMiiMAC port MII interface type
Returns
ENETPHY MII interface

◆ EnetUtils_copyMacAddr()

static void EnetUtils_copyMacAddr ( uint8_t *  dst,
const uint8_t *  src 
)
inlinestatic

Copy MAC address.

Copies 6-byte MAC address.

Parameters
dstPointer to MAC address memory being copied into
srcPointer to MAC address memory to be copied from

◆ EnetUtils_cmpMacAddr()

static bool EnetUtils_cmpMacAddr ( const uint8_t *  addr1,
const uint8_t *  addr2 
)
inlinestatic

Compare two MAC address.

Compares two MAC address to determine if they are equal.

Parameters
addr1MAC address being compared
addr2MAC address being compared
Returns
true if MAC addresses are same, false otherwise.

◆ EnetUtils_clearMacAddr()

static void EnetUtils_clearMacAddr ( uint8_t *  addr)
inlinestatic

Clear MAC address.

Clear 6-byte MAC address memory.

Parameters
addrPointer to MAC address memory to be cleared

◆ EnetUtils_isMcastAddr()

static bool EnetUtils_isMcastAddr ( const uint8_t *  addr)
inlinestatic

Check if address is multicast.

Checks if MAC address is multicast.

Parameters
addrMAC address
Returns
Whether MAC address is multicast or not.
ENET_ARRAYSIZE
#define ENET_ARRAYSIZE(x)
Macro to get the size of an array.
Definition: enet_types.h:123
type
uint16_t type
Definition: tisci_rm_core.h:1