Data Structures | Macros | Typedefs | Enumerations
cpsw_types.h File Reference

This file contains the generic definitions and structure definitions of the CPSW driver. More...

#include <ti/drv/udma/udma.h>
#include <stdint.h>
#include <stdbool.h>

Data Structures

struct  Cpsw_Version_s
 CPSW hardware version. More...
 
struct  Cpsw_IoctlPrms_s
 CPSW IOCTL param. More...
 

Macros

#define CPSW_SET_BIT(n)   (1U << (n))
 
#define CPSW_GET_BIT(val, n)   ((val & (1 << n)) >> n)
 
#define CPSW_IS_BIT_SET(val, n)   (((val) & (1U << (n))) != 0U)
 
#define CPSW_FEXT(reg, PER_REG_FIELD)   (((reg) & PER_REG_FIELD##_MASK) >> PER_REG_FIELD##_SHIFT)
 Field EXTract macro. We can't use CSL macro as it appends shift/mask with CSL_.
 
#define CPSW_FINS(reg, PER_REG_FIELD, val)
 Field INSert macro. We can't use CSL macro as it appends shift/mask with CSL_. More...
 
#define CPSW_IOCTL_TYPE_OFFSET   (24U)
 IOCTL major number bit offset.
 
#define CPSW_IOCTL_MAJOR_OFFSET   (16U)
 IOCTL major number bit offset.
 
#define CPSW_IOCTL_MINOR_OFFSET   (0U)
 IOCTL minor number bit offset.
 
#define CPSW_IOCTL_GET_TYPE(x)   ((x) & 0xFF000000U)
 Helper macro to get the IOCTL type (public/private)
 
#define CPSW_IOCTL_GET_MAJ(x)   ((x) & 0x00FF0000U)
 Helper macro to get the IOCTL major number.
 
#define CPSW_IOCTL_GET_MIN(x)   ((x) & 0x0000FFFFU)
 Helper macro to get the IOCTL major number.
 
#define CPSW_IOCTL_TYPE(x)   ((x) << CPSW_IOCTL_TYPE_OFFSET)
 Helper macro to set the IOCTL type.
 
#define CPSW_IOCTL_MAJ(x)   ((x) << CPSW_IOCTL_MAJOR_OFFSET)
 Helper macro to set the IOCTL major number.
 
#define CPSW_IOCTL_MIN(x)   ((x) << CPSW_IOCTL_MINOR_OFFSET)
 Helper macro to set the IOCTL minor number.
 
#define CPSW_MAC_ADDR_LEN   (6U)
 MAC address length (in bytes)
 
#define CPSW_PRIORITY_NUM   (8U)
 CPSW priority levels.
 
#define CPSW_TOS_PRIORITY_NUM   (64U)
 Type of Service (ToS) priority.
 
#define CPSW_VLAN_ID_MAX   (4095U)
 Maximum value for VLAN ID.
 
#define CPSW_LINK_CAP_HD10   CPSW_SET_BIT(1)
 10-Mbps, half-duplex capability mask
 
#define CPSW_LINK_CAP_FD10   CPSW_SET_BIT(2)
 10-Mbps, full-duplex capability mask
 
#define CPSW_LINK_CAP_HD100   CPSW_SET_BIT(3)
 100-Mbps, half-duplex capability mask
 
#define CPSW_LINK_CAP_FD100   CPSW_SET_BIT(4)
 100-Mbps, full-duplex capability mask
 
#define CPSW_LINK_CAP_HD1000   CPSW_SET_BIT(5)
 1-Gbps, half-duplex capability mask
 
#define CPSW_LINK_CAP_FD1000   CPSW_SET_BIT(6)
 1-Gbps, full-duplex capability mask
 
#define CPSW_LINK_CAP_10
 10-Mbps, full and half-duplex capability mask More...
 
#define CPSW_LINK_CAP_100
 100-Mbps, full and half-duplex capability mask More...
 
#define CPSW_LINK_CAP_1000
 1-Gbps, full and half-duplex capability mask More...
 
#define CPSW_LINK_CAP_ALL
 Auto-negotiation mask with all duplexity and speed values set. More...
 
#define CPSW_ETHERTYPE_PTP   (0x88F7U)
 Ethertype value for PTP over Ethernet Annex F (IEEE 802.3)
 
#define CPSW_REMOTE_CLIENT_CORES_MAX   (6U)
 Maximum number of client core that the CPSW driver can serve.
 
#define CPSW_COUNT   (CPSW_TYPE_LAST + 1U)
 Number of supported CPSW types.
 
#define CPSW_MAC_PORT_NUM   (CPSW_MAC_PORT_LAST + 1U)
 
#define CPSW_NORMALIZE_MACPORT(macPort)   ((macPort) - CPSW_MAC_PORT_FIRST)
 
#define CPSW_MAC_PORT_INV   ((Cpsw_MacPort)0xFFFFU)
 
CPSW Error Codes

Error codes returned by the CPSW driver APIs

#define CPSW_SOK   (UDMA_SOK)
 Success.
 
#define CPSW_EFAIL   (UDMA_EFAIL)
 Generic failure error condition (typically caused by hardware)
 
#define CPSW_EBADARGS   (UDMA_EBADARGS)
 Bad arguments (i.e. NULL pointer)
 
#define CPSW_EINVALID_PARAMS   (UDMA_EINVALID_PARAMS)
 Invalid parameters (i.e. value out-of-range)
 
#define CPSW_ETIMEOUT   (UDMA_ETIMEOUT)
 Time out while waiting for a given condition to happen.
 
#define CPSW_EALLOC   (UDMA_EALLOC)
 Allocation failure.
 
#define CPSW_EUNEXPECTED   (UDMA_EALLOC - 1)
 Unexpected condition occurred (sometimes unrecoverable)
 
#define CPSW_EBUSY   (UDMA_EALLOC - 2)
 The resource is currently busy performing an operation.
 
#define CPSW_EMALFORMED_IOCTL   (UDMA_EALLOC - 3)
 Malformed IOCTL (args pointer or size not as expected)
 
#define CPSW_EALREADY_OPEN   (UDMA_EALLOC - 4)
 Already open error.
 
#define CPSW_EPERM   (UDMA_EALLOC - 5)
 Operation not permitted.
 
#define CPSW_ENOTSUPPORTED   (UDMA_EALLOC - 6)
 Operation not supported.
 
#define CPSW_EUNKNOWN_IOCTL   (UDMA_EALLOC - 7)
 Unknown IOCTL.
 
#define CPSW_EALE_TABLE_FULL   (UDMA_EALLOC - 8)
 ALE Table full.
 
#define CPSW_EALE_VLAN_UNAWARE_MODE   (UDMA_EALLOC - 9)
 ALE is in VLAN Unaware mode.
 
#define CPSW_EALE_ADDRESS_NOT_FOUND   (UDMA_EALLOC - 10)
 Address not found in ALE entries.
 
#define CPSW_EALE_VLAN_NOT_FOUND   (UDMA_EALLOC - 11)
 VLAN Entry not found.
 
#define CPSW_EALE_VLANMASK_NOT_FOUND   (UDMA_EALLOC - 12)
 VLAN Mask Mux Entry not found.
 
#define CPSW_EALE_POLICER_TABLE_FULL   (UDMA_EALLOC - 13)
 Policer entry table is full.
 
#define CPSW_ENOTFOUND   (UDMA_EALLOC - 14)
 Resource not found.
 

Typedefs

typedef uint64_t(* Cpsw_VirtToPhyFxn )(const void *virtAddr, void *appData)
 CPSW virtual-to-physical address translation callback function. More...
 
typedef void *(* Cpsw_PhyToVirtFxn )(uint64_t phyAddr, void *appData)
 CPSW physical-to-virtual address translation callback function. More...
 
typedef void(* Cpsw_PrintFxnCb )(const char *str,...)
 CPSW info/debug print function prototype. More...
 
typedef void(* Cpsw_TraceFxnCb )(const char *str,...)
 CPSW log trace function prototype. More...
 
typedef uintptr_t(* CpswOsal_DisableAllIntrFxn )(void)
 CPSW OSAL intr disable function prototype. More...
 
typedef void(* CpswOsal_RestoreAllIntrFxn )(uintptr_t cookie)
 CPSW OSAL intr restore function prototype. More...
 
typedef void(* CpswOsal_RestoreIntrFxn )(uint32_t coreIntrNum)
 CPSW OSAL intr restore function prototype. More...
 
typedef void(* CpswOsal_DisableIntrFxn )(uint32_t coreIntrNum)
 CPSW OSAL intr disable function prototype. More...
 
typedef void *(* CpswOsal_MutexCreateFxn )(void)
 CPSW OSAL mutex create function prototype to protect critical section. More...
 
typedef void(* CpswOsal_MutexDeleteFxn )(void *mutexHandle)
 CPSW OSAL mutex delete function prototype. More...
 
typedef void(* CpswOsal_MutexLockFxn )(void *mutexHandle)
 CPSW OSAL mutex lock function prototype. More...
 
typedef void(* CpswOsal_MutexUnlockFxn )(void *mutexHandle)
 CPSW OSAL mutex lock function prototype. More...
 
typedef void(* CpswOsal_IsrFxn )(uintptr_t arg)
 CPSW OSAL ISR callback function prototype. More...
 
typedef void *(* CpswOsal_RegisterIntrFxn )(CpswOsal_IsrFxn isrFxn, uint32_t coreIntrNum, uint32_t intrPriority, void *arg)
 CPSW OSAL ISR register function prototype. More...
 
typedef void(* CpswOsal_UnRegisterIntrFxn )(void *hwiHandle)
 CPSW OSAL ISR unregister function prototype. More...
 
typedef void(* CpswOsal_CacheInv )(const void *addr, int32_t size)
 CPSW OSAL cache invalidate function prototype. More...
 
typedef void(* CpswOsal_CacheWb )(const void *addr, int32_t size)
 CPSW OSAL cache writeback function prototype. More...
 
typedef void(* CpswOsal_CacheWbInv )(const void *addr, int32_t size)
 CPSW OSAL cache writeback invalidate function prototype. More...
 
typedef uint32_t(* CpswOsal_TimerReadFxn )(void)
 CPSW OSAL timer read function prototype. More...
 
typedef enum Cpsw_Type_e Cpsw_Type
 CPSW instance type. More...
 
typedef enum Cpsw_MacPort_e Cpsw_MacPort
 CPSW MAC port.
 
typedef enum Cpsw_CrcType_e Cpsw_CrcType
 CRC type.
 
typedef enum Cpsw_Speed_e Cpsw_Speed
 MAC interface speed.
 
typedef enum Cpsw_Duplexity_e Cpsw_Duplexity
 MAC interface duplexity.
 
typedef enum Cpsw_VlanSwitch_e Cpsw_VlanSwitch
 Double VLAN switch.
 
typedef struct Cpsw_Version_s Cpsw_Version
 CPSW hardware version. More...
 
typedef struct Cpsw_IoctlPrms_s Cpsw_IoctlPrms
 CPSW IOCTL param. More...
 
typedef Cpsw_VersionCpsw_GetVersionOutArgs
 Output args for CPSW_*_IOCTL_GET_VERSION commands.
 

Enumerations

enum  Cpsw_IoctlType_e { CPSW_IOCTL_TYPE_PUBLIC = CPSW_IOCTL_TYPE(0U), CPSW_IOCTL_TYPE_PRIVATE = CPSW_IOCTL_TYPE(1U) }
 IOCTL types. More...
 
enum  Cpsw_IoctlMajor_e {
  CPSW_IOCTL_CPSW_BASE = CPSW_IOCTL_MAJ(1U), CPSW_IOCTL_ALE_BASE = CPSW_IOCTL_MAJ(2U), CPSW_IOCTL_CPTS_BASE = CPSW_IOCTL_MAJ(3U), CPSW_IOCTL_HOSTPORT_BASE = CPSW_IOCTL_MAJ(5U),
  CPSW_IOCTL_MACPORT_BASE = CPSW_IOCTL_MAJ(6U), CPSW_IOCTL_MDIO_BASE = CPSW_IOCTL_MAJ(7U), CPSW_IOCTL_SGMII_BASE = CPSW_IOCTL_MAJ(8U), CPSW_IOCTL_STATS_BASE = CPSW_IOCTL_MAJ(9U),
  CPSW_IOCTL_SS_BASE = CPSW_IOCTL_MAJ(10U), CPSW_IOCTL_PHY_BASE = CPSW_IOCTL_MAJ(11U), CPSW_IOCTL_RM_BASE = CPSW_IOCTL_MAJ(12U)
}
 IOCTL base number. More...
 
enum  Cpsw_Type_e { CPSW_2G, CPSW_9G, CPSW_TYPE_LAST = CPSW_9G }
 CPSW instance type. More...
 
enum  Cpsw_MacPort_e {
  CPSW_MAC_PORT_FIRST = 0U, CPSW_MAC_PORT_0 = CPSW_MAC_PORT_FIRST, CPSW_MAC_PORT_1 = 1U, CPSW_MAC_PORT_2 = 2U,
  CPSW_MAC_PORT_3 = 3U, CPSW_MAC_PORT_4 = 4U, CPSW_MAC_PORT_5 = 5U, CPSW_MAC_PORT_6 = 6U,
  CPSW_MAC_PORT_7 = 7U, CPSW_MAC_PORT_LAST = CPSW_MAC_PORT_7
}
 CPSW MAC port. More...
 
enum  Cpsw_CrcType_e { CPSW_CRC_ETHERNET = 0U, CPSW_CRC_CASTAGNOLI = 1U }
 CRC type. More...
 
enum  Cpsw_Speed_e {
  CPSW_SPEED_10MBIT = 0U, CPSW_SPEED_100MBIT = 1U, CPSW_SPEED_1GBIT = 2U, CPSW_SPEED_2p5GBIT = 3U,
  CPSW_SPEED_10GBIT = 4U, CPSW_SPEED_AUTO = 5U
}
 MAC interface speed. More...
 
enum  Cpsw_Duplexity_e { CPSW_DUPLEX_HALF = 0U, CPSW_DUPLEX_FULL = 1U, CPSW_DUPLEX_AUTO = 2U }
 MAC interface duplexity. More...
 
enum  Cpsw_VlanSwitch_e { CPSW_VLAN_SWITCH_CUSTOMER = 0U, CPSW_VLAN_SWITCH_SERVICE = 1U }
 Double VLAN switch. More...
 
enum  Cpsw_RestartType { CPSW_RESTART_DOMAINRESET = 0U, CPSW_RESTART_COREREBOOT = 1U }
 CPSW Restart type. More...
 

Detailed Description

This file contains the generic definitions and structure definitions of the CPSW driver.


Copyright 2020, Texas Instruments Incorporated