EMAC Functions
[EMAC]

Functions

Uint32 EMAC_enumerate (void)
 EMACInterfaces EMAC Interfaces.
Uint32 EMAC_open (int instNum, Handle hApplication, EMAC_Config *pEMACConfig, Handle hEMAC, Handle hCore)
Uint32 EMAC_commonInit (int instNum, EMAC_Common_Config *pEMACCommonConfig, Handle hEMAC)
Uint32 EMAC_coreInit (Handle hEMAC, Handle hApplication, EMAC_Core_Config *pEMACCoreConfig, Handle hCore)
Uint32 EMAC_commonDeInit (Handle hEMAC)
Uint32 EMAC_coreDeInit (Handle hEMAC)
Uint32 EMAC_close (Handle hEMAC)
Uint32 EMAC_getStatus (Handle hEMAC, EMAC_Status *pStatus)
Uint32 EMAC_setReceiveFilter (Handle hEMAC, Uint32 ReceiveFilter, Uint8 masterChannel)
Uint32 EMAC_getReceiveFilter (Handle hEMAC, Uint32 *pReceiveFilter)
Uint32 EMAC_getStatistics (Handle hEMAC, EMAC_Statistics *pStatistics)
Uint32 EMAC_setMulticast (Handle hEMAC, Uint32 AddrCnt, Uint8 *pMCastList)
Uint32 EMAC_sendPacket (Handle hEMAC, EMAC_Pkt *pPkt)
Uint32 EMAC_RxServiceCheck (Handle hEMAC)
Uint32 EMAC_TxServiceCheck (Handle hEMAC)
Uint32 EMAC_timerTick (Handle hEMAC)
static int EMAC_txChannelTeardown (Handle hEMAC, Uint32 val)
static int EMAC_rxChannelTeardown (Handle hEMAC, Uint32 val)

Function Documentation

Uint32 EMAC_close ( Handle  hEMAC  ) 

============================================================================
EMAC_close()

Description
When called by a core, free all pending transmit and receive packets, and release Tx/Rx channels used and MAC addresses assigned via.calling EMAC_coreDeInit(). When called by the master core, furhter close the EMAC peripheral indicated by the supplied EMAC device handle, shutdown both send and receive operations, and bring down the MDIO link via calling EMAC_commonDeInit(). The function returns zero on success, or an error code on failure.

Possible error code include: EMAC_ERROR_INVALID - A calling parameter is invalid

Arguments

        hEMAC   handle to opened the EMAC device
    

Return Value Success (0)
EMAC_ERROR_INVALID - A calling parameter is invalid

Pre Condition
EMAC_open (on the master core) or EMAC_commonInit function must be called before calling this API.

Post Condition
For any core, the EMAC device will free all pending transmit and receive packets, release Tx/Rx channels used and MAC addresses assigned. For master core, the EMAC device will further shutdown both send and receive operations and bring down the MDIO link.

Example

        EMAC_Config  ecfg;
        EMAC_Device     EMACObj;
        EMAC_Core       EMACCore;
        ...

        //Open the EMAC peripheral
        EMAC_open(0, (Handle)0x12345678, &ecfg, &EMACObj, &EMACCore);

        ...

        //Close the EMAC peripheral
        EMAC_close( &EMACObj );
    

============================================================================

Uint32 EMAC_commonDeInit ( Handle  hEMAC  ) 

============================================================================
EMAC_commonDeInit()

Description
Shut down EMAC peripheral indicated by the supplied EMAC device handle: tear down both send and receive operations, resets common configuration, and bring down the MDIO link. Called by the master core only. The function returns zero on success, or an error code on failure.

Possible error code include: EMAC_ERROR_INVALID - A calling parameter is invalid

Arguments

        hEMAC       handle to opened the EMAC device
    

Return Value Success (0)
EMAC_ERROR_INVALID - A calling parameter is invalid

Pre Condition
EMAC_open (on the master core) or EMAC_commonInit function must be called before calling this API.

Post Condition
The EMAC device will shutdown both send and receive operations, resets common configuration, and bring down the MDIO link.

Example

        EMAC_Config     ecfg;
        EMAC_Device     EMACObj;
        EMAC_Core       EMACCore;
        ...

        //Open the EMAC peripheral
        EMAC_open(0, (Handle)0x12345678, &ecfg, &EMACObj, &EMACCore);

        ...

        //Shut down EMAC operation for a core
        EMAC_coreDeInit( &EMACObj );

        ...

        //Shut down the EMAC peripheral
        EMAC_commonDeInit( &EMACObj );
    

============================================================================

Uint32 EMAC_commonInit ( int  instNum,
EMAC_Common_Config pEMACCommonConfig,
Handle  hEMAC 
)

============================================================================
EMAC_commonInit()

Description
Open the EMAC peripheral at the given physical index and perform initialization common to all the cores, including resetting the EMAC control module and stats, initializing DMA, configuring common registers such as the MACCONTROL register, initializing MDIO, and etc. This function has to be called only once by the master core.

The calling application must supply an operating configuration. Data from this config structure is copied into the device's internal instance structure so the structure may be discarded after EMAC_commonInit() returns. In order to change an item in the configuration, the EMAC device must be de-initialized by EMAC_commonDeInit() and then re-initialized by calling EMAC_commonInit() with the new configuration.

A valid EMAC device handle should be passed to this API to which the configuration and operating state of the EMAC device common to all the cores will be written. The EMAC device structure for the handle needs to be initialized before calling EMAC_commonInit().

The default receive filter prevents normal packets from being received until the receive filter is specified by calling EMAC_receiveFilter().

A device reset is achieved by calling EMAC_commonDeInit() followed by EMAC_commonInit().

The function returns zero on success, or an error code on failure.

Possible error code include: EMAC_ERROR_INVALID - A calling parameter is invalid

Arguments

        instNum           EMAC Peripheral ID to identify the EMAC controller to be
                          initialized.
        pEMACCommonConfig EMAC's configuration common to all cores.
        hEMAC             Handle to the EMAC device which needs to be initialized.
    

Return Value Success (0)
EMAC_ERROR_INVALID - A calling parameter is invalid

Pre Condition
None

Post Condition
Open the EMAC peripheral at the given physical index and perform initialization common to all the cores.

Example

        EMAC_Device            EMACObj; // In multi-core scenario, this must be placed in shared memory,
                                           and initialized by application. Refer to "emac_core_restart"
                                           example project for more details.

        EMAC_Common_Config     commonCfg;

        // Initialize our EMAC Dev structure.
        memset(&EMACObj, 0, sizeof(EMAC_Device));

        // Not using the MDIO configuration
        commonCfg.UseMdio = 0;
        // core 0 is master core performing common initialization of the EMAC
        commonCfg.CoreNum = 0; 
        //packet size
        commonCfg.PktMTU = 1600;

        // Setup the EMAC local loopback
        commonCfg.ModeFlags      = EMAC_CONFIG_MODEFLG_MACLOOPBACK | EMAC_CONFIG_MODEFLG_GMIIEN
                                 | EMAC_CONFIG_MODEFLG_FULLDUPLEX;
        commonCfg.MdioModeFlags  = MDIO_MODEFLG_FD1000;

        //Common initialization of the EMAC peripheral
        EMAC_commonInit(0, &commonCfg, &EMACObj);
    

============================================================================

Uint32 EMAC_coreDeInit ( Handle  hEMAC  ) 

============================================================================
EMAC_coreDeInit()

Description
Shut down EMAC operation for a core. When called, free all pending transmit and receive packets for the core, and release Tx/Rx channels used and MAC addresses assigned The function returns zero on success, or an error code on failure.

Possible error code include: EMAC_ERROR_INVALID - A calling parameter is invalid

Arguments

        hEMAC       handle to opened the EMAC device
    

Return Value Success (0)
EMAC_ERROR_INVALID - A calling parameter is invalid

Pre Condition
EMAC_open (on the master core) or EMAC_commonInit function must be called before calling this API.

Post Condition
The EMAC device will free all pending transmit and receive packets for the core, and also release Tx/Rx channels used and MAC addresses assigned.

Example

        EMAC_Config     ecfg;
        EMAC_Device     EMACObj;
        EMAC_Core       EMACCore;

        ...

        //Open the EMAC peripheral
        EMAC_open(0, (Handle)0x12345678, &ecfg, &EMACObj, &EMACCore);

        ...

        //Shut down EMAC operation for a core
        EMAC_coreDeInit( &EMACObj );
    

============================================================================

Uint32 EMAC_coreInit ( Handle  hEMAC,
Handle  hApplication,
EMAC_Core_Config pEMACCoreConfig,
Handle  hCore 
)

============================================================================
EMAC_coreInit()

Description
Core specific initialization to use the EMAC peripheral at the given physical index when every core starts/restarts. The per core configuration includes setting up Tx/Rx channels, allocating MAC addresses, enabling interrupts in the EMAC control module for the channels that this core uses, and etc.

The calling application must supply an operating configuration. Data from this config structure is copied into the device's internal instance structure so the structure may be discarded after EMAC_coreInit() returns. In order to change an item in the configuration, the core must be de-initialized from the EMAC device by calling EMAC_coreDeInit() and then re-initialized by calling EMAC_coreInit() with the new configuration.

A valid EMAC core instance handle should be passed to this API to which the operating state of the EMAC device specific to individual cores will be written. The EMAC core instance structure for the handle needs to be initialized before calling EMAC_coreInit().

The application layer may pass in an hApplication callback handle, that will be supplied by the EMAC device for the core when making calls to the core's application callback functions.

A valid EMAC device handle should be passed to this API to which the per core configuration and operating state of the EMAC device will be written.

A core reset for EMAC operation is achieved by calling EMAC_coreDeInit() followed by EMAC_coreInit().

The function returns zero on success, or an error code on failure.

Possible error code include: EMAC_ERROR_INVALID - A calling parameter is invalid

Arguments

        hEMAC           Handle to the EMAC device which needs to be initialized.
        hApplication    Application handle
        pEMACCoreConfig EMAC's configuration specific to the core
        hCore           Handle to the EMAC core instance which needs to be initialized.
    

Return Value Success (0)
EMAC_ERROR_INVALID - A calling parameter is invalid

Pre Condition
Before calling this API, EMAC_commonInit function must be called on the master core and then EMAC_coreDeInit must be called for this particular core.

Post Condition
Core specific initialization to use the EMAC peripheral at the given physical index.

Example

        #define MASTER_CORE 0           // Which core is responsible for EMAC common initialization

        Uint32                 coreNum;
        Uint32                 i = 0, j = 0;
        EMAC_Common_Config     commonCfg;
        EMAC_Core_Config       coreCfg;
        EMAC_Device            EMACObj;
        EMAC_Core              EMACCore;
        EMAC_AddrConfig*       addrCfg;

        ...

        if (coreNum == MASTER_CORE)
		{
            // Initialize our EMAC Dev structure.
            memset(&EMACObj, 0, sizeof(EMAC_Device));
            // Common initialization of the EMAC peripheral
            EMAC_commonInit(0, &commonCfg, &EMACObj);
		}
        // Initialize EMAC core instance structure.
        memset(&EMACCore, 0, sizeof(EMAC_Core));

        //Total 3 MAC addresses allocated for the receive channel 
        coreCfg.NumOfMacAddrs = 3;
        // selects CPPI RAM for Descriptor memory 
        coreCfg.DescBase = EMAC_DESC_BASE_CPPI;

        coreCfg.RxMaxPktPool              = 8;
        coreCfg.pfcbGetPacket             = &GetPacket;
        coreCfg.pfcbFreePacket            = &FreePacket;
        coreCfg.pfcbRxPacket              = &RxPacket;
        coreCfg.pfcbStatus                = &StatusUpdate;
        coreCfg.pfcbStatistics            = &StatisticsUpdate;

        switch(coreNum) {
            default:
            case 0:                   // core 0 use channel 0 
                coreCfg.ChannelInfo.TxChanEnable = 1;
                coreCfg.ChannelInfo.RxChanEnable = 1;
                break;
            case 1:                   // core 1 use channel 1 
                coreCfg.ChannelInfo.TxChanEnable = 2;
                coreCfg.ChannelInfo.RxChanEnable = 2;
                break;
            case 2:                   // core 2 use channel 2 
                coreCfg.ChannelInfo.TxChanEnable = 4;
                coreCfg.ChannelInfo.RxChanEnable = 4;
                break;
        }

        //Configure the number of MAC addresses per channel
        //Hardware gives support for 32 MAC addresses for 8 receive channels
        //Here total 9 MAC addresses are assigned to 3 receive channels
        //3 MAC addresses per channel
        //MAC addresses and channels allocated are like mentioned below
        //  core no	   channel assigned       MAC address
        //   core0         channel 0        00.01.02.03.04.05
        //						            10.11.12.13.14.15
        //								    20.21.22.23.24.25(address used for loopback test)
        //
        //   core1         channel 1		30.31.32.33.34.35
        //									40.41.42.43.44.45
        //									50.51.52.53.54.55(address used for loopback test)
        //
        //	 core2         channel 2		60.61.62.63.64.65
        //									70.71.72.73.74.75
        //									80.81.82.83.84.85(address used for loopback test)

        coreCfg.MacAddr = (EMAC_AddrConfig **)
                          malloc(coreCfg.NumOfMacAddrs * sizeof(EMAC_AddrConfig *));

        for (j=0; j<coreCfg.NumOfMacAddrs; j++){
            coreCfg.MacAddr[j] = (EMAC_AddrConfig *)malloc(sizeof(EMAC_AddrConfig));
        }

        for(j=0; (Uint8)j<(coreCfg.NumOfMacAddrs); j++){
            addrCfg = coreCfg.MacAddr[j];
            addrCfg->ChannelNum = coreNum;
            for (i=0; i<6; i++)
            {
                addrCfg->Addr[i] = j * 0x10 + i + coreNum * 0x30;
            }
        }

        EMAC_coreDeInit(&EMACObj);
        EMAC_coreInit(&EMACObj, (Handle)0x12345678, &coreCfg, &EMACCore);
    

============================================================================

Uint32 EMAC_enumerate ( void   ) 

EMACInterfaces EMAC Interfaces.

Interfaces for EMAC module.

Note: The application is charged with verifying that only one of the following API calls may be executing at a given time across all threads and all interrupt functions.
Hence, when used in an multitasking environment, no EMAC function may be called while another EMAC function is operating on the same device handle in another thread. It is the responsibility of the application to assure adherence to this restriction. ============================================================================
EMAC_enumerate()

Description
Enumerates the EMAC peripherals installed in the system and returns an integer count. The EMAC devices are enumerated in a consistent fashion so that each device can be later referenced by its physical index value ranging from "1" to "n" where "n" is the count returned by this function.

Return Value None

Pre Condition
None

Post Condition
None

Example

        EMAC_enumerate( );
    

============================================================================

Uint32 EMAC_getReceiveFilter ( Handle  hEMAC,
Uint32 *  pReceiveFilter 
)

============================================================================
EMAC_getReceiveFilter()

Description
Called to get the current packet filter setting for received packets. The filter values are the same as those used in EMAC_setReceiveFilter().

The current filter value is written to the pointer supplied in pReceiveFilter.

The function returns zero on success, or an error code on failure.

Possible error code include: EMAC_ERROR_INVALID - A calling parameter is invalid

Arguments

        hEMAC           handle to the opened EMAC device
        pReceiveFilter  Current receive packet filter
    

Return Value Success (0)
EMAC_ERROR_INVALID - A calling parameter is invalid

Pre Condition
EMAC peripheral instance must be opened before calling this API and must be set the packet filter value.

Post Condition
The current filter value is written to the pointer supplied

Example

        #define EMAC_RXFILTER_DIRECT       1
        EMAC_Config     ecfg;
        Uint32          pReceiveFilter;
        EMAC_Device     EMACObj;
        EMAC_Core       EMACCore;

        ...

        //Open the EMAC peripheral
        EMAC_open(0, (Handle)0x12345678, &ecfg, &EMACObj, &EMACCore);

        ...

        EMAC_setReceiveFilter(&EMACObj, EMAC_RXFILTER_DIRECT, 0);

        EMAC_getReceiveFilter(&EMACObj, &pReceiveFilter );
    

============================================================================

Uint32 EMAC_getStatistics ( Handle  hEMAC,
EMAC_Statistics pStatistics 
)

============================================================================
EMAC_getStatistics()

Description
Called to get the current device statistics. The statistics structure contains a collection of event counts for various packet sent and receive properties. Reading the statistics also clears the current statistic counters, so the values read represent a delta from the last call.

The statistics information is copied into the structure pointed to by the pStatistics argument.

The function returns zero on success, or an error code on failure.

Possible error code include: EMAC_ERROR_INVALID - A calling parameter is invalid

Arguments

        hEMAC       handle to the opened EMAC device
        pStatistics Get the device statistics
    

Return Value Success (0)
EMAC_ERROR_INVALID - A calling parameter is invalid

Pre Condition
EMAC peripheral instance must be opened before calling this API

Post Condition

  1. Statistics are read for various packects sent and received.
    1. Reading the statistics also clears the current statistic counters, so the values read represent a delta from the last call.

Example

        EMAC_Config      ecfg;
        EMAC_Statistics  pStatistics;
        EMAC_Device     EMACObj;
        EMAC_Core       EMACCore;

        ...

        //Open the EMAC peripheral
        EMAC_open(0, (Handle)0x12345678, &ecfg, &EMACObj, &EMACCore);

        ...

        EMAC_getStatistics(&EMACObj, &pStatistics );
    

============================================================================

Uint32 EMAC_getStatus ( Handle  hEMAC,
EMAC_Status pStatus 
)

============================================================================
EMAC_getStatus()

Description
Called to get the current status of the device. The device status is copied into the supplied data structure.

The function returns zero on success, or an error code on failure.

Possible error code include: EMAC_ERROR_INVALID - A calling parameter is invalid

Arguments

        hEMAC   handle to the opened EMAC device
        pStatus Status of the EMAC
    

Return Value Success (0)
EMAC_ERROR_INVALID - A calling parameter is invalid

Pre Condition
EMAC peripheral instance must be opened before calling this API.

Post Condition
The current status of the device is copied into the supplied data structure.

Example

        EMAC_Status     pStatus;
        EMAC_Config  ecfg;
        EMAC_Device     EMACObj;
        EMAC_Core       EMACCore;

        ...

        //Open the EMAC peripheral
        EMAC_open(0, (Handle)0x12345678, &ecfg, &EMACObj, &EMACCore);

        ...

        EMAC_getStatus( &EMACObj, &pStatus);
    

============================================================================

Uint32 EMAC_open ( int  instNum,
Handle  hApplication,
EMAC_Config pEMACConfig,
Handle  hEMAC,
Handle  hCore 
)

============================================================================
EMAC_open()

Description
Opens the EMAC peripheral at the given physical index and initializes it to an embryonic state.

The calling application must supply operating configurations that includes the ones common to all the cores if on the master core and also those specific to individual cores. The EMAC device must be closed and then re-opened when new configuration is required.

The application layer may pass in an hApplication callback handle, that will be supplied by the EMAC device for the core when making calls to the core's application callback functions.

A valid EMAC device handle should be passed to this API to which the configuration and operating state of the EMAC device will be written.

A valid EMAC core instance handle should be passed to this API to which the operating state of the EMAC device specific to individual cores will be written.

The default receive filter prevents normal packets from being received until the receive filter is specified by calling EMAC_receiveFilter().

By calling EMAC_close() followed by EMAC_open() on the master core, EMAC device reset is achieved. When the same sequence is called on a non-master core, a core reset for EMAC operation is achieved

The function returns zero on success, or an error code on failure.

Possible error codes include: EMAC_ERROR_INVALID - A calling parameter is invalid

Arguments

        instNum         EMAC Peripheral ID to identify the EMAC controller to be'
                        initialized.
        hApplication    Application handle
        pEMACConfig     EMAC's configuration structure
        hEMAC           Handle to the EMAC device which needs to be initialized.
        hCore           Handle to the EMAC core instance which needs to be initialized.
    

Return Value Success (0)
EMAC_ERROR_INVALID - A calling parameter is invalid

Pre Condition
None

Post Condition
Opens the EMAC peripheral at the given physical index and initializes it.

Example

 
        #define MASTER_CORE 0           // Which core is responsible for EMAC common initialization

        EMAC_Device            EMACObj; // In multi-core scenario, this must be placed in shared memory,
                                           and initialized by application.
        EMAC_Core              EMACCore;// In multi-core scenario, it is desirable to place EMACCore in local memory
                                           so that run-time cache operation on EMACCore can be avoided
        Uint32                 coreNum;
        Uint32                 i = 0, j = 0;
        EMAC_Config            ecfg;
        EMAC_AddrConfig*       addrCfg;

        // Initialize our EMAC Dev structure.
	    if(coreNum == MASTER_CORE) 
	    {
			memset(&EMACObj, 0, sizeof(EMAC_Device));

			// Not using the MDIO configuration
			ecfg.EMACCommonConfig.UseMdio = 0;
			// core 0 is master core performing common initialization of the EMAC
			ecfg.EMACCommonConfig.CoreNum = 0; 
			//packet size
			ecfg.EMACCommonConfig.PktMTU = 1600;

			// Setup the EMAC local loopback
			ecfg.EMACCommonConfig.ModeFlags      = EMAC_CONFIG_MODEFLG_MACLOOPBACK | EMAC_CONFIG_MODEFLG_GMIIEN
												 | EMAC_CONFIG_MODEFLG_FULLDUPLEX;
			ecfg.EMACCommonConfig.MdioModeFlags  = MDIO_MODEFLG_FD1000;
		}

        // Initialize EMAC core instance structure.
        memset(&EMACCore, 0, sizeof(EMAC_Core));

        //Total 3 MAC addresses allocated for the receive channel 
        ecfg.EMACCoreConfig.NumOfMacAddrs = 3;
        // selects CPPI RAM for Descriptor memory 
        ecfg.EMACCoreConfig.DescBase = EMAC_DESC_BASE_CPPI;

        ecfg.EMACCoreConfig.RxMaxPktPool              = 8;
        ecfg.EMACCoreConfig.pfcbGetPacket             = &GetPacket;
        ecfg.EMACCoreConfig.pfcbFreePacket            = &FreePacket;
        ecfg.EMACCoreConfig.pfcbRxPacket              = &RxPacket;
        ecfg.EMACCoreConfig.pfcbStatus                = &StatusUpdate;
        ecfg.EMACCoreConfig.pfcbStatistics            = &StatisticsUpdate;

        switch(coreNum) {
            default:
            case 0:                   // core 0 use channel 0 
                ecfg.EMACCoreConfig.ChannelInfo.TxChanEnable = 1;
                ecfg.EMACCoreConfig.ChannelInfo.RxChanEnable = 1;
                break;
            case 1:                   // core 1 use channel 1 
                ecfg.EMACCoreConfig.ChannelInfo.TxChanEnable = 2;
                ecfg.EMACCoreConfig.ChannelInfo.RxChanEnable = 2;
                break;
            case 2:                   // core 2 use channel 2 
                ecfg.EMACCoreConfig.ChannelInfo.TxChanEnable = 4;
                ecfg.EMACCoreConfig.ChannelInfo.RxChanEnable = 4;
                break;
        }

        //Configure the number of MAC addresses per channel
        //Hardware gives support for 32 MAC addresses for 8 receive channels
        //Here total 9 MAC addresses are assigned to 3 receive channels
        //3 MAC addresses per channel
        //MAC addresses and channels allocated are like mentioned below
        //  core no	   channel assigned       MAC address
        //   core0         channel 0        00.01.02.03.04.05
        //						            10.11.12.13.14.15
        //								    20.21.22.23.24.25(address used for loopback test)
        //
        //   core1         channel 1		30.31.32.33.34.35
        //									40.41.42.43.44.45
        //									50.51.52.53.54.55(address used for loopback test)
        //
        //	 core2         channel 2		60.61.62.63.64.65
        //									70.71.72.73.74.75
        //									80.81.82.83.84.85(address used for loopback test)

        ecfg.EMACCoreConfig.MacAddr = (EMAC_AddrConfig **)
                                      malloc(ecfg.EMACCoreConfig.NumOfMacAddrs * sizeof(EMAC_AddrConfig *));

        for (j=0; j<ecfg.EMACCoreConfig.NumOfMacAddrs; j++){
            ecfg.EMACCoreConfig.MacAddr[j] = (EMAC_AddrConfig *)malloc(sizeof(EMAC_AddrConfig));
        }

        for(j=0; (Uint8)j<(ecfg.EMACCoreConfig.NumOfMacAddrs); j++){
            addrCfg = ecfg.EMACCoreConfig.MacAddr[j];
            addrCfg->ChannelNum = coreNum;
            for (i=0; i<6; i++)
            {
                addrCfg->Addr[i] = j * 0x10 + i + coreNum * 0x30;
            }
        }

        EMAC_open(0, (Handle)0x12345678, &ecfg, &EMACObj, &EMACCore);
    

============================================================================

static int EMAC_rxChannelTeardown ( Handle  hEMAC,
Uint32  val 
) [inline, static]

============================================================================
EMAC_rxChannelTeardown

Description Tear down selective receive channel/channels

Arguments

            val        mask of selective rx channels to be torn down.
        hEMAC      handle to the opened EMAC device
     

Return Value None

Pre Condition
None

Post Condition
Tear down specific rx channels

Modifies
EMAC registers

Example

        Uint32             val = EMAC_TEARDOWN_CHANNEL(0) | EMAC_TEARDOWN_CHANNEL(1);
        EMAC_Device        EMACObj;
        EMAC_Config        ecfg;

        ...

        //Open the EMAC peripheral
        EMAC_open(0, (Handle)0x12345678, &ecfg, &EMACObj);

        ...


        EMAC_rxChannelTeardown (&EMACObj, val);
     

=============================================================================

Uint32 EMAC_RxServiceCheck ( Handle  hEMAC  ) 

============================================================================
EMAC_RxServiceCheck()

Description
This function should be called every time there is an EMAC device Rx interrupt. It maintains the status the EMAC.

Note that the application has the responsibility for mapping the physical device index to the correct EMAC_serviceCheck() function. If more than one EMAC device is on the same interrupt, the function must be called for each device.

Possible error codes include: EMAC_ERROR_INVALID - A calling parameter is invalid EMAC_ERROR_MACFATAL - Fatal error in the MAC - Call EMAC_close()

Arguments

        hEMAC       handle to the opened EMAC device
    

Return Value Success (0)
EMAC_ERROR_INVALID - A calling parameter is invalid
EMAC_ERROR_MACFATAL - Fatal error in the MAC - Call EMAC_close()

Pre Condition
EMAC_open function must be called before calling this API.

Post Condition
None

Example

        static CSL_IntcContext context;
        static CSL_IntcEventHandlerRecord Record[13];
        static CSL_IntcObj intcEMACRx;
        static CSL_IntcHandle hIntcEMACRx;

        //CSL_IntcParam vectId1;
        CSL_IntcParam vectId2;

        CSL_IntcGlobalEnableState state;

        // Setup the global Interrupt
        context.numEvtEntries = 13;
        context.eventhandlerRecord = Record;

        // VectorID for the Event
        vectId2 = CSL_INTC_VECTID_6;

        CSL_intcInit(&context);
        // Enable NMIs
        CSL_intcGlobalNmiEnable();
        // Enable Global Interrupts
        CSL_intcGlobalEnable(&state);

        // Opening a handle for EMAC Rx interrupt
        hIntcEMACRx=CSL_intcOpen(&intcEMACRx,CSL_INTC_EVENTID_6,&vectId2,NULL);

        //Hook the ISRs
        CSL_intcHookIsr(vectId2,&HwRxInt);

        CSL_intcHwControl(hIntcEMACRx, CSL_INTC_CMD_EVTENABLE, NULL);

        // This function is called when Rx interrupt occurs
        Void HwRxInt (void)
        {
            EMAC_Device     EMACObj;
            EMAC_Core       EMACCore;

            ...

            //Open the EMAC peripheral
            EMAC_open(0, (Handle)0x12345678, &ecfg, &EMACObj, &EMACCore);

            ...
	        
            EMAC_RxServiceCheck(&EMACObj);
        }

    

============================================================================

Uint32 EMAC_sendPacket ( Handle  hEMAC,
EMAC_Pkt pPkt 
)

============================================================================
EMAC_sendPacket()

Description
Sends a Ethernet data packet out the EMAC device. On a non-error return, the EMAC device takes ownership of the packet. The packet is returned to the application's free pool once it has been transmitted.

The function returns zero on success, or an error code on failure. When an error code is returned, the EMAC device has not taken ownership of the packet.

Possible error codes include: EMAC_ERROR_INVALID - A calling parameter is invalid EMAC_ERROR_BADPACKET - The packet structure is invalid

Arguments

        hEMAC       handle to the opened EMAC device
        pPkt        EMAC packet structure
    

Return Value Success (0)
EMAC_ERROR_INVALID - A calling parameter is invalid
EMAC_ERROR_BADPACKET - The packet structure is invalid

Pre Condition
EMAC peripheral instance must be opened and get a packet buffer from private queue

Post Condition
Sends a ethernet data packet out the EMAC device and is returned to the application's free pool once it has been transmitted.

Example

        #define EMAC_RXFILTER_DIRECT       1
        #define EMAC_PKT_FLAGS_SOP         0x80000000u
        #define EMAC_PKT_FLAGS_EOP         0x40000000u

        EMAC_Config     ecfg;
        EMAC_Pkt        *pPkt;
        Uint32          size, TxCount = 0;
        EMAC_Device     EMACObj;
        EMAC_Core       EMACCore;

        ...

        //Open the EMAC peripheral
        EMAC_open(0, (Handle)0x12345678, &ecfg, &EMACObj, &EMACCore);

        ...

        //set the receive filter
        EMAC_setReceiveFilter( &EMACObj, EMAC_RXFILTER_DIRECT, 0);

        //Fill the packet options fields
        size = TxCount + 60;
        pPkt->Flags      = EMAC_PKT_FLAGS_SOP | EMAC_PKT_FLAGS_EOP;
        pPkt->ValidLen   = size;
        pPkt->DataOffset = 0;
        pPkt->PktChannel = 0;
        pPkt->PktLength  = size;
        pPkt->PktFrags   = 1;

        EMAC_sendPacket( &EMACObj, pPkt );

    

============================================================================

Uint32 EMAC_setMulticast ( Handle  hEMAC,
Uint32  AddrCnt,
Uint8 *  pMCastList 
)

============================================================================
EMAC_setMulticast()

Description
This function is called to install a list of multicast addresses for use in multicast address filtering. Each time this function is called, any current multicast configuration is discarded in favor of the new list. Thus a set with a list size of zero will remove all multicast addresses from the device.

Note that the multicast list configuration is stateless in that the list of multicast addresses used to build the configuration is not retained. Thus it is impossible to examine a list of currently installed addresses.

The addresses to install are pointed to by pMCastList. The length of this list in bytes is 6 times the value of AddrCnt. When AddrCnt is zero, the pMCastList parameter can be NULL.

The function returns zero on success, or an error code on failure. The multicast list settings are not altered in the event of a failure code.

Possible error code include: EMAC_ERROR_INVALID - A calling parameter is invalid

Arguments

        hEMAC       handle to the opened EMAC device
        AddrCount   number of addresses to multicast
        pMCastList  pointer to the multi cast list
    

Return Value Success (0)
EMAC_ERROR_INVALID - A calling parameter is invalid

Pre Condition
EMAC peripheral instance must be opened and set multicast filter.

Post Condition

  1. Install a list of multicast addresses for use in multicast address filtering.
  2. A set with a list size of zero will remove all multicast addresses from the device.

Example

        #define EMAC_RXFILTER_ALLMULTICAST 4

        Uint32          AddrCnt;
        Uint8           pMCastList;
        EMAC_Config     ecfg;
        EMAC_Device     EMACObj;
        EMAC_Core       EMACCore;

        ...

        //Open the EMAC peripheral
        EMAC_open(0, (Handle)0x12345678, &ecfg, &EMACObj, &EMACCore);

        ...

        EMAC_setReceiveFilter( &EMACObj, EMAC_RXFILTER_ALLMULTICAST, 0);

        EMAC_setMulticast( &EMACObj, AddrCnt, &pMCastList );
    

============================================================================

Uint32 EMAC_setReceiveFilter ( Handle  hEMAC,
Uint32  ReceiveFilter,
Uint8  masterChannel 
)

============================================================================
EMAC_setReceiveFilter()

Description
Called to set the packet filter for received packets. The filtering level is inclusive, so BROADCAST would include both BROADCAST and DIRECTED (UNICAST) packets.

Available filtering modes include the following:

  • EMAC_RXFILTER_NOTHING - Receive nothing
  • EMAC_RXFILTER_DIRECT - Receive only Unicast to local MAC addr
  • EMAC_RXFILTER_BROADCAST - Receive direct and Broadcast
  • EMAC_RXFILTER_MULTICAST - Receive above plus multicast in mcast list
  • EMAC_RXFILTER_ALLMULTICAST - Receive above plus all multicast
  • EMAC_RXFILTER_ALL - Receive all packets

Note that if error frames and control frames are desired, reception of these must be specified in the device configuration.

The function returns zero on success, or an error code on failure.

Possible error code include: EMAC_ERROR_INVALID - A calling parameter is invalid

Arguments

         hEMAC           handle to the opened EMAC device
         ReceiveFilter   Filtering modes
         masterChannel   master core channel which receives broadcast frames
    

Return Value Success (0)
EMAC_ERROR_INVALID - A calling parameter is invalid

Pre Condition
EMAC peripheral instance must be opened before calling this API

Post Condition
Sets the packet filter for received packets

Example

        #define EMAC_RXFILTER_DIRECT       1
        EMAC_Config  ecfg;
        EMAC_Device     EMACObj;
        EMAC_Core       EMACCore;

        ...

        //Open the EMAC peripheral
        EMAC_open(0, (Handle)0x12345678, &ecfg, &EMACObj, &EMACCore);

        ...

        EMAC_setReceiveFilter(&EMACObj, EMAC_RXFILTER_DIRECT, 0);

    

============================================================================

Uint32 EMAC_timerTick ( Handle  hEMAC  ) 

============================================================================
EMAC_timerTick()

Description
This function should be called for each device in the system on a periodic basis of 100mS (10 times a second). It is used to check the status of the EMAC and MDIO device, and to potentially recover from low Rx buffer conditions.

Strict timing is not required, but the application should make a reasonable attempt to adhere to the 100mS mark. A missed call should not be "made up" by making multiple sequential calls.

A "polling" driver (one that calls EMAC_serviceCheck() in a tight loop), must also adhere to the 100mS timing on this function.

Possible error codes include: EMAC_ERROR_INVALID - A calling parameter is invalid

Arguments

        hEMAC       handle to the opened EMAC device
    

Return Value Success (0)
EMAC_ERROR_INVALID - A calling parameter is invalid

Pre Condition
EMAC peripheral instance must be opened

Post Condition
Re-fill Rx buffer queue if needed and modifies EMAC CONTROL register.

Example

        EMAC_Config ecfg;
        EMAC_Device     EMACObj;
        EMAC_Core       EMACCore;

        ...

        //Open the EMAC peripheral
        EMAC_open(0, (Handle)0x12345678, &ecfg, &EMACObj, &EMACCore);

        ...


        EMAC_timerTick( &EMACObj );
    

============================================================================

static int EMAC_txChannelTeardown ( Handle  hEMAC,
Uint32  val 
) [inline, static]

============================================================================
EMAC_txChannelTeardown

Description Tear down selective transmit channel/channels

Arguments

        hEMAC      handle to the opened EMAC device
            val        mask of selective tx channels to be torn down.
     

Return Value EMAC_ERROR_INVALID - Invalid instance number

Pre Condition
None

Post Condition
Tear down specific tx channels

Modifies
EMAC registers

Example

        Uint32             val = EMAC_TEARDOWN_CHANNEL(0) | EMAC_TEARDOWN_CHANNEL(1);
        EMAC_Device        EMACObj;
        EMAC_Config        ecfg;

        ...

        //Open the EMAC peripheral
        EMAC_open(0, (Handle)0x12345678, &ecfg, &EMACObj);

        ...


        EMAC_txChannelTeardown (&EMACObj, val);
     

=============================================================================

Uint32 EMAC_TxServiceCheck ( Handle  hEMAC  ) 

============================================================================
EMAC_TxServiceCheck()

Description
This function should be called every time there is an EMAC device Tx interrupt. It maintains the status the EMAC.

Note that the application has the responsibility for mapping the physical device index to the correct EMAC_serviceCheck() function. If more than one EMAC device is on the same interrupt, the function must be called for each device.

Possible error codes include: EMAC_ERROR_INVALID - A calling parameter is invalid EMAC_ERROR_MACFATAL - Fatal error in the MAC - Call EMAC_close()

Arguments

        hEMAC       handle to the opened EMAC device
    

Return Value Success (0)
EMAC_ERROR_INVALID - A calling parameter is invalid
EMAC_ERROR_MACFATAL - Fatal error in the MAC - Call EMAC_close()

Pre Condition
EMAC_open function must be called before calling this API.

Post Condition
None

Example

        static CSL_IntcContext context;
        static CSL_IntcEventHandlerRecord Record[13];
        static CSL_IntcObj intcEMACTx;
        static CSL_IntcHandle hIntcEMACTx;

        //CSL_IntcParam vectId1;
        CSL_IntcParam vectId2;

        CSL_IntcGlobalEnableState state;

        // Setup the global Interrupt
        context.numEvtEntries = 13;
        context.eventhandlerRecord = Record;

        // VectorID for the Event
        vectId2 = CSL_INTC_VECTID_6;

        CSL_intcInit(&context);
        // Enable NMIs
        CSL_intcGlobalNmiEnable();
        // Enable Global Interrupts
        CSL_intcGlobalEnable(&state);

        // Opening a handle for EMAC Tx interrupt
        hIntcEMACTx=CSL_intcOpen(&intcEMACTx,CSL_INTC_EVENTID_6,&vectId2,NULL);

        //Hook the ISRs
        CSL_intcHookIsr(vectId2,&HwTxInt);

        CSL_intcHwControl(hIntcEMACTx, CSL_INTC_CMD_EVTENABLE, NULL);

        // This function is called when Rx interrupt occurs
        Void HwTxInt (void)
        {
            EMAC_Device     EMACObj;
            EMAC_Core       EMACCore;

            ...

            //Open the EMAC peripheral
            EMAC_open(0, (Handle)0x12345678, &ecfg, &EMACObj, &EMACCore);

            ...

            EMAC_TxServiceCheck(&EMACObj);
        }

    

============================================================================


Copyright 2012, Texas Instruments Incorporated