AM335x ICSS Switch Driver API Guide

Introduction
ICSS Switch Driver API provides the interface to Stacks to use the cut-through switch based on ICSS in AM335x. These APIs are used for configuring and communicating with Switch firmware.

ICSSSwitchInit
Function

Int8 ICSSSwitchInit(void);

Parameters


 * void
 * Return value: 0 on Success, -1 on Failure

Description Initializes the ICSS based Switch

LoadPruFirmware
Function

Int8 LoadPruFirmware(unsigned int * firmware_load,unsigned int firmware_length,unsigned int pruinst);

Parameters


 * firmware_load: start address of firmware to be loaded
 * firmware_length: size of firmware in number of instructions
 * pruinst: the pru to which firmware is to be loaded. Valid values: 0,1
 * Return value: 0 on Success,-1 on Failure

Description Loads firmware to PRU instruction memory

LoadStaticTable
Function

Int32 LoadStaticTable(const unsigned int * staticTable, Uint8 staticTableLength, Uint8 staticTableType);

Parameters


 * static_table: start address of the static table
 * static_table_length: length of the static table
 * static_table_type: type of static table (forward table (0) or receive table (1))
 * Return value: 0 on Success;-1 on Failure

Description Loads multicast static table to ICSS memory

StartSwitch
Function

Int8 StartSwitch(void);

Parameters


 * void
 * Return value:0 on Success, -1 on Failure

Description Starts the switch by enabling both the PRUs

StopSwitch
Function

Int8 StopSwitch(void);

Parameters


 * void
 * Return value:0 on success, -1 on Failure

Description Stops the switch by disabling both the PRUs

GetLinkStatus
Function

Uint8 GetLinkStatus(Uint32 port);

Parameters


 * port: Port number whose status is to be checked.Valid values:
 * PORT1 (1)
 * PORT2 (2)
 * 0 - Checks for atleast one port is up
 * Return value:1 if link up,0 if link is down

Description Function to fetch the link status of a port

RegisterPort0ISRCallback
Function

void RegisterPort0ISRCallback(icssCallBack_t callBack, void *userArg);

Parameters


 * callBack	Callback function pointer
 * userArg	user specific parameter
 * Return value:none

Description Callback function to process protocol specific handler for link0 status ISR

RegisterPort1ISRCallback
Function

void RegisterPort1ISRCallback(icssCallBack_t callBack, void *userArg);

Parameters


 * callBack	Callback function pointer
 * userArg	user specific parameter
 * Return value:none

Description Callback function to process protocol specific handler for link1 status ISR

RegisterPeriodicCallback
Function

void RegisterPeriodicCallback(icssCallBack_t callBack);

Parameters


 * callBack	Callback function pointer
 * Return value:none

Description Function to register callback function to process periodic protocol processing

getSpeedStatus
Function

Uint8 getSpeedStatus(Uint8 portNum);

Parameters


 * portNum Port Number. 0/1


 * Return value:Status. 0 means 10mbps and 1 means 100 mbps. 2 means undefined.

Description returns the PHY speed status for a port

getDuplexStatus
Function

Uint8 getDuplexStatus(Uint8 portNum);

Parameters


 * portNum Port Number. 0/1


 * Return value:1 means Half Duplex and 0 means Full Duplex. 2 means not defined

Description returns the PHY duplex status for a port

SetPhyMDIX
Function

void SetPhyMDIX(Uint8 mdiState,Uint8 portNum);

Parameters


 * mdiState
 * MDIO_ENABLE_FORCE_MDI
 * MDIO_ENABLE_FORCE_MDIX
 * MDIO_ENABLE_AUTO_MDIX
 * portNum
 * HWPORT0(0)
 * HWPORT1(1)


 * Return value:none

Description API to Configure MDI/X Mode of PHY

SetPhyConfig
Function

void SetPhyConfig(Uint8 phyConfig,Uint8 portNum);

Parameters


 * phyConfig
 * PHY_CONFIG_AUTONEG
 * PHY_CONFIG_100FD
 * PHY_CONFIG_10FD
 * PHY_CONFIG_100HD
 * portNum
 * HWPORT0(0)
 * HWPORT1(1)


 * Return value:none

Description API to Change Phy Configuration

EnablePhyPowerSaveMode
Function

void EnablePhyPowerSaveMode(Uint8 portNum);

Parameters


 * portNum
 * HWPORT0(0)
 * HWPORT1(1)


 * Return value:none

Description API to Enable Power Saving mode in PHY

SetPhyPowerSaveMode
Function

void SetPhyPowerSaveMode(Uint8 phyPowerMode,Uint8 portNum);

Parameters


 * phyPowerMode
 * MDIO_POWERMODE_NORMAL
 * MDIO_POWERMODE_DOWN
 * MDIO_POWERMODE_ACTIVE_SLEEP
 * MDIO_POWERMODE_PASSIVE_SLEEP
 * portNum
 * HWPORT0(0)
 * HWPORT1(1)


 * Return value:none

Description API to force Power Saving mode in PHY

TxPacket
Function

Int32 TxPacket(const Uint8* srcAddress, Int32 portNumber, Int32 queuePriority, Int32 lengthOfPacket);

Parameters


 * src_address: Base address of the buffer where the frame to be transmitted resides
 * port_number: Port on which frame has to be transmitted. Valid values:
 * PORT1 (1)- Sends packet to port1
 * PORT2 (2)- Sends packet to port2
 * 0 - Driver uses Learning module to determine portnumber
 * queue_priority: Queue number in which frame will be queued for transmission. Valid values are:
 * QUEPRIO1(0)
 * QUEPRIO2(1)
 * QUEPRIO3(2)
 * QUEPRIO4(3)
 * length_of_packet: length of the frame in bytes
 * Return value:0 on Success, (&lt;0) on Failure

Description Queues a frame which has to be transmitted in the right port queue

RxPktGet
Function

Int32 RxPktGet(Uint32 destAddress, Int32 queueNumber, Int32* port, Int32* more);

Parameters


 * dest_address: Base address of data buffer where received frame has to be stored
 * queue_number: Receive queue from which frame has to be copied. Valid values are:
 * QUEPRIO1(0)
 * QUEPRIO2(1)
 * QUEPRIO3(2)
 * QUEPRIO4(3)
 * port: Returns port number on which frame was received
 * more: Returns more which is set to 1 if there are more frames in the queue
 * Return value: Length of the frame received in number of bytes or -1 on Failure

Description Retrieves a frame from a host queue and copies it in the allocated stack buffer

RxPktInfo
Function

Int32 RxPktInfo(Int32* portNumber, Int32* queueNumber);

Parameters


 * port_number: Return pointer of port number where frame was received
 * queue_number: Return pointer of host queue where the received frame is queued
 * Return value:length of the received frame in bytes

Description Retrieves the information about the received frame which is then used to dequeue the frame from the host queues

GetMaxQueueFillLevel
Function

Int32 GetMaxQueueFillLevel(Int32 portNumber, Int32 queuePriority, Int32* queueOverflowCount);

Parameters


 * port_number: Port on which queue resides. Valid values are:
 * PORT0(0)
 * PORT1(1)
 * PORT2(2)
 * queue_priority: Priority of the queue or queue number whose fill level has to be found
 * queue_overflow_count: Return pointer to number of times queue has overflown
 * Return value: maximum fill level of the queue or <0 if there was error in the input parameters

Description Finds the maximum fill level of the queue in terms of 32 byte blocks. For example, if there was only one 64 byte packet received when this API is called then it would return value of 2. It also returns number of times queue has overflown.

RegisterProtocolCallback
Function

void RegisterProtocolCallback(icssCallBack_t callBack);

Parameters


 * callBack: The function pointer which handles the protocol specific packet
 * Return value:null

Description API to register the function to process the protocol specific packets.This function will be called if packet is received in queues other than the ones used for ethernet packets.

RegisterTxExceptionCallback
Function

void RegisterTxExceptionCallback(icssCallBackRet_t callBack);

Parameters


 * callBack: Callback function pointer
 * Return value:null

Description Function to register callback function for TX exception.

RegisterLinkStatusCallback
Function

void RegisterLinkStatusCallback(icssCallBackLinkStat linkCallBack);

Parameters


 * linkCallBack: The function pointer which get the Link status
 * Return value:null

Description API to register the function to override the default GetLinkStatus function

ICSSIoctl
Function

Int8 ICSSIoctl(enum t_portNum port, enum t_portCmd command);

Parameters


 * port: port number . Valid values are:
 * PORT1(1)
 * PORT2(2)
 * command: command whether to disable or enable(0 -Enable,1 -disable)
 * Return value:0 on success

Description Enables or disables the Ethernet port

ICSSALEInit
Function

void ICSSALEInit;

Parameters


 * none
 * Return value: none

Description Initializes Learning module and clears ALE table

ICSSALEAgeOutNow
Function

void ICSSALEAgeOutNow;

Parameters


 * none
 * Return value: none

Description Removes (free up) any aged table entry

ICSSALEClearTable
Function

void ICSSALEClearTable;

Parameters


 * none
 * Return value: none

Description Clears ALE table entries

ICSSALECounter
Function

void ICSSALECounter;

Parameters


 * none
 * Return value: none

Description Increments time counters in both the port tables.It is called periodically to implement Ageing.

UpdateRxstats
Function

void UpdateRxstats(uint8_t* macAddr,UInt32 packet_len,Uint16 protIdent, UInt32 portNum);

Parameters


 * macAddr macAddr pointer to mac address
 * packet_len packet length in bytes
 * protIdent protocol type of the incoming packet
 * portNum incoming port number
 * Return value:none

Description Call every time a packet is received, updates Rx related statistics.

UpdateTxstats
Function

void UpdateTxstats(uint8_t* macAddr,UInt32 packet_len, UInt32 portNum);

Parameters


 * macAddr macAddr pointer to mac address
 * packet_len packet length in bytes
 * portNum port number on which the packet is sent out
 * Return value:none

Description Call every time a packet is transmitted, updates Tx related statistics

RegisterLearningCallBack
Function

void RegisterLearningCallBack(icssCallBackRet_t callBack);

Parameters


 * callBack The Learning exception function pointer
 * Return value:none

Description API to register the learning exception function.

updateHashTable
Function

void updateHashTable(uint8_t* macId, uint8_t portNum);

Parameters


 * macId MAC ID which is to be learned
 * portNum port number of incoming packet
 * Return value: none

Description Update the learning table used to map MAC Id's and ports

findMAC
Function

uint8_t findMAC(const uint8_t * macId);

Parameters


 * macId Destination macid of the packet to be transmitted.
 * Return value: Port number where the MAC ID exists, 0 means not found 1 means port 0 and 2 means port 1

Description Find given a MAC ID which port the packet need to be transmitted