AM335x NDK Driver API Guide

   

Table of Contents

= Introduction =

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 =

AddNetifEntryFn
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
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]; /**&lt; Phy Address                                                 */ Uint32 macModeFlags; /**&lt; MAC Control Flags(CPSW)                                     */ Uint32 numberPorts; /**&lt; Number of supported ports(CPSW) IDK - 1 ICE - 2             */ Uint32 resvd; /**&lt; If values set by User, resvd set to 1	              	      */ Uint8 tlk110Flag; /**&lt; if set to 1 TLK110 Workaroud task will be created	     */ }MAC_CONFIG;

Should be called before BIOS_start

SetIcssSwitchConfiguration
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; /**&lt; Priority Queue used for ethernet packets                                                 */ Uint32 halfDuplexEnable; /**&lt; Set to 1 to enable Halfduplex support.Supported for Ethernet/IP only                     */ Uint32 enableIntrPacing; /**&lt; Enables Interrupt Pacing.This is only supported by Profinet Firmware.Uses intrPacing enum */ Uint32 resvd; /**&lt; If values set by User, resvd set to 1	              	                                */ }ICSS_SWITCH_CONFIG;

Should be called before BIOS_start NOTE1   The TLK110 Phy has a known limitation when the PHY is forced to any seting and connected to a NIC in Autoneg. In this case, the AutoMDIX configuration doesnot work and as a result the link is detected very late or not detected at all. As a workaround Software MDIX is implemented whenever the TLK110 PHY is forced. 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 NOTE2   ICSS Switch driver supports Interrupt pacing. The driver uses DMTimer3 in AM335x to implement the pacing mechanism.In this scheme,the Rx interrupt is disabled for a configured period (DEFAULT_PACING_TIMER_VAL in us).

NIMUIoctl
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
 * 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;

NIMUIoctl
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
 * 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;

cpsw_register_link_change_notification
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" };