NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.
AM335x NDK Driver API Guide
Contents
Introduction[edit]
NDK Driver interfaces Network Developers Kit (NDK) with underlying architecture on AM335x. This driver provides interfacing with both Industrial Communication SubSystem(ICSS) and Common Platform Ethernet Switch (CPSW). Driver APIs section define APIs used by both ICSS and CPSW drivers. Individual ICSS and CPSW APIs are explained further below.
Driver APIs[edit]
Initialization of driver[edit]
AddNetifEntryFn[edit]
Function
int AddNetifEntryFn(int init_fn_type);
Parameters
- init_fn_type: CPSW_NETIF_INIT/ICSS_NETIF_INIT
- Return value: 0: Invalid mode 1: Successfully selected mode
Description Initialize the driver
Select the mode the driver works - ICSS or CPSW
Select the corresponding Init function and registers it to NIMUDeviceTable
Should be called before BIOS_start
SetMacConfiguration[edit]
Function
void SetMacConfiguration(MAC_CONFIG* config);
Parameters
- config: defines the hardware
- Return value: none
Description Initialize the hardware dependent values in driver
Struct to configure MAC
/* Hardware dependent values. Set from application */ typedef struct mac_config { Uint32 phyAddr[MAX_PORT_NUMBER]; /**< Phy Address */ Uint32 macModeFlags; /**< MAC Control Flags(CPSW) */ Uint32 numberPorts; /**< Number of supported ports(CPSW) IDK - 1 ICE - 2 */ Uint32 resvd; /**< If values set by User, resvd set to 1 */ Uint8 tlk110Flag; /**< if set to 1 TLK110 Workaroud task will be created */ }MAC_CONFIG;
Should be called before BIOS_start
SetIcssSwitchConfiguration[edit]
Function
void SetIcssSwitchConfiguration(ICSS_SWITCH_CONFIG* switchConfig);
Parameters
- switchConfig: defines the Switch Configuration parameters
- Return value: none
Description The function is used to setup the ICSS Switch configurations
Struct to configure ICSS Switch
/* ICSS Switch Configuration options available for users */ typedef struct icss_switch_config { Uint8 ethPrioQueue; /**< Priority Queue used for ethernet packets */ Uint32 halfDuplexEnable; /**< Set to 1 to enable Halfduplex support.Supported for Ethernet/IP only */ Uint32 enableIntrPacing; /**< Enables Interrupt Pacing.This is only supported by Profinet Firmware.Uses intrPacing enum */ Uint32 resvd; /**< If values set by User, resvd set to 1 */ }ICSS_SWITCH_CONFIG;
Should be called before BIOS_start
If the tlk110Flag is set, the driver creates a task which will continuously check for correct MDIX setting if the phy is in forced mode
ICSS Driver APIs[edit]
NIMUIoctl[edit]
Function
int NIMUIoctl(uint cmd, NIMU_IF_REQ* ptr_nimu_ifreq, void* pBuf, uint size);
Parameters
- cmd: Command Id to be executed by NDK Driver
- ptr_nimu_ifreq: NIMU network interface object which is being referred. NDK Reference Guide[1]
- pBuf: Depending on command, used to return values or provide additional commands
- Return value: The function returns the 0 on success and a negative value on error.
Description This function is used to get and set configuration parameters from either the NIMU module or to the NIMU network interface objects driver attached to the NIMU module.
Struct for user to handle ICSS_IOCTL_SWITCH_CMD
typedef struct _PORT_CMD_T { Uint32 threshold; Uint8 port; /*Port number*/ Uint32 value; /* Value */ Uint32 bl; /* broadcast limit */ Uint32 ml; /* multicast limit */ Uint8 EnDis; /* 1 -enable/0- Disable */ Uint8 add[6]; /* Mac address */ } PORT_CMD;
Struct for user to handle ICSS_IOCTL_SWITCH_CMD
/* The following structure is used as param for all IOCTL of type switch command */ typedef struct SWITCHCONSCMD { Uint32 opcode; /* opcode for switch control operation */ /* Function pointer to a print function */ int (*consolePrint)(const char*,...); Uint8 usePrintFn; /* indicates that the provided Printfn must be used Must be set to 1(Not used currently) */ union{ ALE_VLANCMD AleVlanCmd; /* Not currently Used */ PORT_CMD PortCmd; PRIO_CMD PrioCmd; /* Not currently Used */ }CmdType; Uint32 ret_type; } SwitchConsCmd;
Struct for user to handle ICSS_IOCTL_STAT_CMD
/* The following structure is used as param for all IOCTL related to STATS */ typedef struct STATSCMD { Uint32 opcode ; /* opcode for stats operations */ Uint8 portNum ; /* stats portnum */ IcssSwitchStatistics statsObj; /* used with get stats command */ } StatsCmd;
cmd |
Id |
pBuf |
size |
Remarks |
---|---|---|---|---|
ICSS_IOCTL_SWITCH_CMD |
0 |
SwitchConsCmd Object with PORT_CMD defined accordingly |
sizeof(SwitchConsCmd *) |
The opcode can be ICSS_IOCTL_RATELIMIT or ICSS_IOCTL_GET_PORT_CONFIG |
ICSS_IOCTL_STAT_CMD |
1 |
StatsCmd Object defined accordingly |
sizeof(StatsCmd *) |
The StatsCmd opcode can be ICSS_IOCTL_STAT_GET or ICSS_IOCTL_STAT_CLEAR |
CPSW Driver APIs[edit]
NIMUIoctl[edit]
Function
int NIMUIoctl(uint cmd, NIMU_IF_REQ* ptr_nimu_ifreq, void* pBuf, uint size);
Parameters
- cmd: Command Id to be executed by NDK Driver
- ptr_nimu_ifreq: NIMU network interface object which is being referred. NDK Reference Guide[2]
- pBuf: Depending on command, used to return values or provide additional commands
- Return value: The function returns the 0 on success and a negative value on error.
Description This function is used to get and set configuration parameters from either the NIMU module or to the NIMU network interface objects driver attached to the NIMU module.
Struct for user to handle CPSW3G_IOCTL_SWITCH_CMD
typedef struct _PORT_CMD_T { Uint32 threshold; Uint8 port; /*Port number*/ Uint32 value; /* Value */ Uint32 bl; /* broadcast limit */ Uint32 ml; /* multicast limit */ Uint8 EnDis; /* 1 -enable/0- Disable */ Uint8 add[6]; /* Mac address */ } PORT_CMD;
Struct for user to handle CPSW3G_IOCTL_SWITCH_CMD
/* The following structure is used as param for all IOCTL of type switch command */ typedef struct SWITCHCONSCMD { Uint32 opcode; /* opcode for switch control operation */ /* Function pointer to a print function */ int (*consolePrint)(const char*,...); Uint8 usePrintFn; /* indicates that the provided Printfn must be used(Not used currently) */ PORT_CMD PortCmd; Uint32 ret_type; /* Return Success/Failure */ } SwitchConsCmd;
Struct for user to handle CPSW3G_IOCTL_STAT_GET
/* The following structure is used as param for all IOCTL related to STATS */ typedef struct CPSWSTATSCMD { Uint32 opcode ; /* opcode for stats operations */ Cpsw3gStatistics statsObj; /* used with get stats command */ } CpswStatsCmd;
cmd |
Id |
pBuf |
size |
Remarks |
---|---|---|---|---|
CPSW3G_IOCTL_SWITCH_CMD |
0 |
SwitchConsCmd Object with Port_cmd defined accordingly |
sizeof(SwitchConsCmd *) |
The opcode can be CPSW3G_IOCTL_PORT_STATISTICS_ENABLE /CPSW3G_IOCTL_SET_PORT_CONFIG /CPSW3G_IOCTL_GET_PORT_CONFIG |
CPSW3G_IOCTL_STAT_CMD |
1 |
StatsCmd Object defined accordingly |
sizeof(StatsCmd *) |
The StatsCmd opcode can be CPSW3G_IOCTL_STAT_GET |
opcode |
Id |
params |
Remarks |
---|---|---|---|
CPSW3G_IOCTL_PORT_STATISTICS_ENABLE |
0 |
PortCmd defines value(1 - Enable) |
Used to configure statistics |
CPSW3G_IOCTL_SET_PORT_CONFIG |
1 |
PortCmd defines value/EnDis. value(10/100/1000), EnDis(0 - Half Duplex, 1 - Full Duplex) |
Port numbers start from 0 |
CPSW3G_IOCTL_GET_PORT_CONFIG |
2 |
portnum |
Values returned in statsObj |
CPSW3G_IOCTL_STAT_GET |
3 |
portnum |
Return Stats in statsObj |
cpsw_register_link_change_notification[edit]
Function
void cpsw_register_link_change_notification(cpsw_link_change_notification_t routine);
Parameters
- routine: cpsw_register_link_change_notification routine allows the registration of a notification routine called by the driver on a link change on an ethernet port.
- Return value: none
Description User can register callback function for Link change. The callback has params Link status and port number(starting from 0)
Array for Linkstatus
/* This string array corresponds to link state */ static Uint8 *LinkStr[] = { "No Link", "None", "10Mb/s Half Duplex", "10Mb/s Full Duplex", "100Mb/s Half Duplex", "100Mb/s Full Duplex" };