This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

66AK2H14: 5-port gigabit Ethernet switch problem

Part Number: 66AK2H14

Hi

I'm working on a custom board based on EVMK2H.

I'm taking over software code that was developed by others, an ARM application that sends/receives UDP pkt
The custom board has 4 gigabit eth ports but the software works only when the cable is plugged into one port.
Also ping command (from an external pc) fails using other 3 ports.

My goal is to use indifferently one of the 4 ports, no matter where the cable is plugged

The 4 gigabit ports are connected to the internal 5-port Ethernet switch (Network Coprocessor), so I'm trying to figure out what is missing in my configuration

It seems to me that the switch is not working as espected.

Do I need to setup the switch somehow?

Please give me an example or something as starting point to deal with this problem.

Regards, Fabio

  • Hi Fabio,

    Is the ARM application running on Linux? Are you working on top of PLSDK release? Can you please provide some insight on this? 

    If you are looking for RTOS side, have you installed the Processor SDK RTOS and you can refer to NDK examples. You may be needed to tweak the NIMU code as this is your custom board, if you are working on RTOS.

    So, please let us know if you are working on Linux or RTOS?

    Thanks.

  • Hi Aravind,

    The application is running on RTOS, pdk_k2hk_4_0_10, ndk_2_26_00_08, my code is based on  NIMU_emacExample_EVMK2H_armBiosExampleProject 

    Should I modify  nimu_eth.c? 

    Thanks

    Fabio

  • Hi Fabio,

    Thanks for providing the details.

    Yes, you need to modify nimu_eth.c, which is currently setting one port.

    There may be some more tweaks needed for you, but as a starting point, you can update below for nimu_eth.c

    1. Init_cpsw() to initialize the SGMII for all of the eth ports
    2. Init_Mac() for all the port numbers

    Please note that I would be on vacation starting tomorrow and would be back on Jan 4th. So, please expect the response delayed for your next questions.

    Happy holidays!

    Thanks 

  • Hi

    I've done the following modification to nimu_eth.c

    - inside CSL_SgmiiDefSerdesSetup, change serdes_lane_enable_params.num_lanes = 2 ---> serdes_lane_enable_params.num_lanes = 4
    - modify Init_SGMII and call for all 4 ports:

    Init_SGMII(0);
    Init_SGMII(1);
    Init_SGMII(2);
    Init_SGMII(3);

    This is my Init_SGMII

    void Init_SGMII (uint32_t macPortNum)
    {
        CSL_SGMII_ADVABILITY    sgmiiCfg;
        CSL_SGMII_STATUS        sgmiiStatus;
        unsigned int timeout = 1000;
    
        /* Reset the port before configuring it */
        CSL_SGMII_doSoftReset (macPortNum);
    
        while (CSL_SGMII_getSoftResetStatus (macPortNum) != 0)
        {
    
        }
    
    
    //    To connect with an external PHY, the PHY will be the master, and the SGMII module needs to be
    //    configured in slave mode.
    
        
             if (macPortNum < 4) {
            /* Hold the port in soft reset and set up
             * the SGMII control register:
             *      (1) Disable Master Mode
             *      (2) Enable Auto-negotiation
             */
            CSL_SGMII_startRxTxSoftReset (macPortNum);
            CSL_SGMII_disableMasterMode (macPortNum);
            CSL_SGMII_enableAutoNegotiation (macPortNum);
            CSL_SGMII_endRxTxSoftReset (macPortNum);
    
            /* Setup the Advertised Ability register for this port:
             *      (1) Enable Full duplex mode
             *      (2) Enable Auto Negotiation
             *      (3) Enable the Link
             */
            sgmiiCfg.linkSpeed      =   CSL_SGMII_1000_MBPS;
            sgmiiCfg.duplexMode     =   CSL_SGMII_FULL_DUPLEX;
            CSL_SGMII_setAdvAbility (macPortNum, &sgmiiCfg);
    
            NIMU_drv_log1("Waiting SGMII-linkUp and negotiation....macPortNum:%d\n", macPortNum);
            do
            {
                CSL_SGMII_getStatus(macPortNum, &sgmiiStatus);
    	    timeout--;
               
            } while ((sgmiiStatus.bIsLinkUp != 1) && (timeout>0));
         
    
            /* Wait for SGMII Autonegotiation to complete without error */
            timeout = 1000;
            do
            {
                CSL_SGMII_getStatus(macPortNum, &sgmiiStatus);
    	    timeout--;
                if (sgmiiStatus.bIsAutoNegError != 0)
                {
                    NIMU_drv_log1("ERRORE bIsAutoNegError  macPortNum:%d\n", macPortNum);
                    return; /* This is an error condition */
                }
                
            } while ((sgmiiStatus.bIsAutoNegComplete != 1)&& (timeout>0));
    
           NIMU_drv_log1("SGMII-linkUp and negotiation succesfull macPortNum:%d\n", macPortNum);
            
        }
    
        
        /* All done with configuration. Return Now. */
        return;
    }

    Call Init_MAC for all the port numbers, but I dont have clear in mind what mac address use for each port.... I use different MAC for each port, is that right?

    uint8_t cppiMac [6] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05};

    Init_MAC (0, cppiMac, mtu);

    cppiMac[0] = 0x01;
    Init_MAC (1, cppiMac, mtu);

    cppiMac[0] = 0x02;
    Init_MAC (2, cppiMac, mtu);

    cppiMac[0] = 0x03;
    Init_MAC (3, cppiMac, mtu);

    I put the following code at the end of the function Init_Switch()

    int portNum;
    CSL_CPSW_ALE_PORTCONTROL        alePortControlCfg;
    for (portNum=0; portNum<4; portNum++)
    {
        
        alePortControlCfg.portState             =   ALE_PORTSTATE_FORWARD;
        alePortControlCfg.dropUntaggedEnable    =   0;
        alePortControlCfg.vidIngressCheckEnable =   0;
        alePortControlCfg.noLearnModeEnable     =   0;
        alePortControlCfg.mcastLimit            =   0;
        alePortControlCfg.bcastLimit            =   0;
    
        CSL_CPSW_setAlePortControlReg (portNum, &alePortControlCfg);
    }

    Running the software i have the following results:

    cable plugged into PORT_0: Board power on --> sgmiiStatus.bIsLinkUp = 1, gmiiStatus.bIsAutoNegComplete=1 --> ping ok!
    cable plugged into PORT_1: Board power on --> sgmiiStatus.bIsLinkUp = 1, gmiiStatus.bIsAutoNegComplete=1 --> ping NOT ok!
    cable plugged into PORT_2: Board power on --> sgmiiStatus.bIsLinkUp = 1, gmiiStatus.bIsAutoNegComplete=1 --> ping NOT ok!
    cable plugged into PORT_3: Board power on --> sgmiiStatus.bIsLinkUp = 1, gmiiStatus.bIsAutoNegComplete=1 --> ping NOT ok!

    I'm still not able to ping port 1,2,3

    other tweak to do?

    Thanks

    Fabio

  • Hi Fabio,

    I am comparing your changes with nimu_eth.c file. For K2H, the nimu_eth.c to be updated is under v2 folder "pdk<ver>\packages\ti\transport\ndk\nimu\src\v2". 

    Are you modifying the correct version of nimu_eth.c?

    Please let me know.

    Thanks

  • Hi Aravind

    Yes, I use nimu_eth.c  v2 as starting point

    Fabio

  • Hi Fabio,

    Another question.. Are you looking for concurrent usage on all eth ports OR any one port at a given time?

    Below NDK user guide would be useful for you to refer to update the NIMU layer.

    www.ti.com/.../spru524k.pdf

  • Hi

    I want to use one port at a given time

    For example:

    1) Eth cable plugged into port0 --> board power on --> send/receive pkt to/from ARM  ----> board power off

    2) Remove cable from port 0 and plug into port1  --> board power on --> send/receive pkt to/from ARM  ----> board power off

    Fabio

  • Hi Fabio,

    Thanks for providing the details. I see below gaps in your change.

    1. Regarding your question on different MAC for each port:
      1. Since you are looking for one port at a time after power up, I do not think you need different MAC to be used for each port. You can use the myMACAddress (variable set by reading the MAC ID register for the board) for all Eth Ports.
    2. Also, since you are looking for one interface at a time, you do not need to update the NIMUDeviceTable[] entry, (which is set to 1 interface for K2H)
    3. Currently under Nimu_eth.c for K2H TI EVM, in the EmacSend(), the PS flag is set based on the gTxPort value. This needs to be modified for your custom board, since you want to send the packet to the ethernet port that has the RJ45 hooked up. So, you would need to identify/detect the port number during EmacInit() function, instead of hard coding the gTxPort value to be 1 (always port 0), you can detect it based on the port that has the link up.
    4. To start with, you can hardcode gTxPort to 2 and see if you are able to get the functionality with Port 1 (instead of 1, which is working now for PORT 0). Then, you can have your detection logic to update the gTxPort to whatever port you would like to send the Eth Packets.
    5. I see inport element in ethInfo variable is not initialized in EmacStart(). Please initialize as below:

    paEthInfo_t ethInfo = {

    { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, /* Src mac = dont care */

    { 0x10, 0x11, 0x12, 0x13, 0x14, 0x15 }, /* Default Dest mac */

    0, /* vlan = dont care */

    0, /* ignore ether type */

    0, /* MPLS tag = don't care */

    0 /* input Emac port number, = don't care */

    };

    6. I see you have SGMII and MAC initializations done for all Eth ports, which should be okay. But you can also look into limiting the EMAC port initializations under Init_Cpsw() to  be for below:

    Init_SGMII (0);
    Init_MAC (0, myMACAddress, mtu);

    And the ethernet port that has RJ45 plugged in.

    Init_SGMII (gTxPort);
    Init_MAC (gTxPort, myMACAddress, mtu);

    I think these above modifications should help you to get the ping working on all the ports that you are trying to work on. 

    Please close the thread, if this resolved your issue.

  • Hi Aravind

    Thank you, solved