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.

TMS320C6678: Gigabit Ethernet forced in 100Mbps mode fails to communicate (output) through internal switch

Part Number: TMS320C6678


Hi all,

I am working on a board with C6678 DSP and Marvell Alaska 88E1322 Gigabit Ethernet PHY over SGMII. My device uses one of MAC port (Port 2) in second stage bootloader mode and another one (Port 1) after application started. When Port 2 has a link, the program is never loaded by design. In typical configuration Port 1 is always connected to PC and Port 2 is left not connected.

I have noticed a problem when my device is negotiating with "100Mbps only" PC/Switch on the other side of cable. Bootloader works fine, but the application randomly fails to get communication. Link is active and auto-negotiated. ARP packets arrive to DSP and DSP responds, but they never get through internal DSP's switch.

Bootloader and the application has same Ethernet initialization code, but configures different Ethernet port.

Unplugging Port 1 and plugging again when application is working solves communication problem, but this is not a solution for me.

  • Compiler: TI v7.4.4 (ELF)
  • XDC: 3.25.2.70
  • IPC: 3.23.1.03
  • NDK: 2.22.3.20
  • SYS/BIOS: 6.35.1.29

Example of statistics got from DSP's switch:

Switch statistics: Host: MAC Ports:
Rx good frames: 95 655
Rx b-cast frames: 1 440
Rx undersized: 0 0
Rx CRC error: 0 0
Rx DMA overrun: 0 0
Tx good frames:   655 0
Tx b-cast frames: 440 0
Tx underrun: 0 0

Is there any bug in Silicon or libraries I do not know about but is related to my problem?

Best regards,

Jack

  • Hi Jack,

    I've forwarded this to the ethernet experts. Their feedback should be posted here.

    BR
    Tsvetolin Shulev
  • Any response? Tip?

    Is there a way to reset the switch?

  • Hi,

    Can you confirm if my understanding is correct:
    - MAC port 1 is intialized by an application
    - MAC port 2 is intialized by a bootloader
    Both MAC ports are connected to Marvell PHY via SGMII interface with the same code. Port 2 is alway stable and port 1 is unstable.

    What version of the MCSDK or Processor SDK code is used to initialize the SGMII? You use it as auto-negotiation instead of forced, correct? And both MAC ports are configured as slave? Can you point out the Switch/SGMII intialization code to make sure the same used on both ports?

    If you just swap the ports initialized by bootloader and application, will the problem also swap bewteen two ports? Will use forced to 100M instead of auto-negotiation help?

    There is SOFT_RESET register for SGMII port (section 3.3.2 of Keystone Gigbit switch user guide)

    Regards, Eric
  • Hi Eric,

    Thank You for your reply. You understanding is correct. To be more specific, port 2 is used only for user interaction with bootloader and application is not started that time.

    In normal operation Port 2 is initialized by bootloader but never used (no link, because Service Cable is not plugged in), then application starts and initializes Port 1 (using same source code, but for Port 1) and gets link on it. Port 2 works every time when Service Cable is plugged, but Port 1 sometimes fails when the application is started.

    I use MCSDK PDK in version 1.1.2.6. You are correct, I use auto-negotiation. Yes, both MAC ports are configured as slave.

    There is source code for initialization of Switch and SGMII:

    Void Init_Switch (uint32_t mtu)
    {
        CSL_CPSW_3GF_PORTSTAT               portStatCfg;
        uint32_t  rx_max_len = mtu + ETHHDR_SIZE + 4; /* 4 bytes of FCS */
    
        /* Enable the CPPI port, i.e., port 0 that does all
         * the data streaming in/out of EMAC.
         */
        CSL_CPSW_3GF_enablePort0 ();
        CSL_CPSW_3GF_disableVlanAware ();
        CSL_CPSW_3GF_setPort0VlanReg (0, 0, 0);
        CSL_CPSW_3GF_setPort0RxMaxLen (rx_max_len);
    
        /* Enable statistics on both the port groups:
         *
         * MAC Sliver ports -   Port 1, Port 2
         * CPPI Port        -   Port 0
         */
        portStatCfg.p0AStatEnable   =   1;
        portStatCfg.p0BStatEnable   =   1;
        portStatCfg.p1StatEnable    =   1;
        portStatCfg.p2StatEnable    =   1;
        CSL_CPSW_3GF_setPortStatsEnableReg (&portStatCfg);
    
        /* Setup the Address Lookup Engine (ALE) Configuration:
         *      (1) Enable ALE.
         *      (2) Clear stale ALE entries.
         *      (3) Disable VLAN Aware lookups in ALE since
         *          we are not using VLANs by default.
         *      (4) No Flow control
         *      (5) Configure the Unknown VLAN processing
         *          properties for the switch, i.e., which
         *          ports to send the packets to.
         */
        CSL_CPSW_3GF_enableAle ();
        CSL_CPSW_3GF_clearAleTable ();
        CSL_CPSW_3GF_disableAleVlanAware ();
        CSL_CPSW_3GF_disableAleTxRateLimit ();
    
        /* Setting the Switch MTU Size to more than needed */
        CSL_CPGMAC_SL_setRxMaxLen(0, rx_max_len);
        CSL_CPGMAC_SL_setRxMaxLen(1, rx_max_len);
    
    //#ifdef SIMULATOR_SUPPORT
        CSL_CPSW_3GF_enableAleBypass();
    //#endif
        /* Done with switch configuration */
        return;
    }
    void Init_SGMII (uint32_t macPortNum)
    {
        CSL_SGMII_ADVABILITY    sgmiiCfg;
        CSL_SGMII_STATUS        sgmiiStatus;
    
        /* Reset the port before configuring it */
        CSL_SGMII_doSoftReset (macPortNum);
        while (CSL_SGMII_getSoftResetStatus (macPortNum) != 0);
    
    //     if (macPortNum == 1)
         {
            /* 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.linkSpeed      =   CSL_SGMII_100_MBPS;
            sgmiiCfg.duplexMode     =   CSL_SGMII_FULL_DUPLEX;
            CSL_SGMII_setAdvAbility (macPortNum, &sgmiiCfg);
    
            do
            {
                CSL_SGMII_getStatus(macPortNum, &sgmiiStatus);
            } while (sgmiiStatus.bIsLinkUp != 1);
    
            /* Wait for SGMII Autonegotiation to complete without error */
    //        do
    //        {
    //            CSL_SGMII_getStatus(macPortNum, &sgmiiStatus);
    //            if (sgmiiStatus.bIsAutoNegError != 0)
    //                return; /* This is an error condition */
    //        } while (sgmiiStatus.bIsAutoNegComplete != 1);
            waitSGMIIAutonegotiation(macPortNum);
        }
    }
    
    void waitSGMIIAutonegotiation(uint32_t macPortNum){
    
    	CSL_SGMII_STATUS        sgmiiStatus ;
    	// Wait for SGMII Autonegotiation to complete without error
    	do
    	{
    		CSL_SGMII_getStatus(macPortNum, &sgmiiStatus);
    		if (sgmiiStatus.bIsAutoNegError){
    			printf("SGMII autonegotiation error");
    		}
    		Task_sleep(10);
    	} while (!sgmiiStatus.bIsAutoNegComplete);
    
    	Task_sleep(100);
    }

    When I swapped ports, the problem swapped as well. Every time problem affects application port.

    When I turn off 1000Mbps mode in MAC and Marvell, the problem seems not to appear. Im not sure about verdict (At the beginning of problem, sometimes it failed every second power-up, sometimes it was ok for many tries), but I tried about 40 times and it should fail by then.

    Regards,

    Jack