Page 1 of 1

EtherLinkCallback doesn't execute on ethernet down

Posted: Wed Feb 12, 2014 2:08 pm
by John.Ohl
Using MOD5270, if you set the EtherLinkCallback in the start of the main function or anywhere else for that matter, it appears to never be executed when the ethernet link goes down.

Looking @ ethernet.cpp I am assuming it's because @ line 239 bEthLink is set to false, and the function is only called if it was set to true. Moving line 239 after the callback is executed solves the problem.

Before:

Code: Select all

      ...
      else // There was no link detected
      {
         bEthLink = FALSE;
         if( PHY_OUI_ID == DAVICOM_OUI_ID )
         {
            sim.fec.mdata = phy_read_mdata11; // Set to have read Davicom reg 0x11 in next check for parallel link fault ( Gigabit negotiation fix )
            last_phy_read = 0x11;
         }
         else
         {
            sim.fec.mdata = phy_read_mdata1; // Set to read phy reg 1 for next link check
            last_phy_read = 1;
         }
         if (bEthLink && EtherLinkCallback)
         {
            (*EtherLinkCallback)(FALSE);
         }
      }
      ...
After:

Before:

Code: Select all

      ...
      else // There was no link detected
      {
         if( PHY_OUI_ID == DAVICOM_OUI_ID )
         {
            sim.fec.mdata = phy_read_mdata11; // Set to have read Davicom reg 0x11 in next check for parallel link fault ( Gigabit negotiation fix )
            last_phy_read = 0x11;
         }
         else
         {
            sim.fec.mdata = phy_read_mdata1; // Set to read phy reg 1 for next link check
            last_phy_read = 1;
         }
         if (bEthLink && EtherLinkCallback)
         {
            (*EtherLinkCallback)(FALSE);
         }
         bEthLink = FALSE;
      }
      ...

Re: EtherLinkCallback doesn't execute on ethernet down

Posted: Thu Feb 13, 2014 9:47 am
by dciliske
Well... that shouldn't be there... actually, the correct thing to do is to remove the check for link status from the condition (like it is on the 54415 parts). This has now been fixed.

-Dan