lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] how to set the link up


From: Noam Weissman
Subject: Re: [lwip-users] how to set the link up
Date: Sun, 9 Jul 2017 06:39:01 +0000

Hi Max,

 

I just read your comments. In my case I have two tasks… one that poll the link and one handling

the application DHCP. The link task changes the DHCP task state when link is established and therefore

they are independent and no deadlock happens.

 

The link call back is used to update parameters or do special operations at the application level.

I am for example call announce for my discovery protocol.

 

BR,

Noam.

 

 

From: lwip-users [mailto:lwip-users-bounces+address@hidden On Behalf Of Krzysztof Wesolowski
Sent: Friday, July 07, 2017 8:22 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] how to set the link up

 

One simplification would be to do those link monitoring operations on timer running on LwIP thread, it removes threading issues (ie. Modifying stack data, accessing PHY). Only dhcp/ip setup would need to come from external memory/queue.

 

On Fri, 7 Jul 2017, 18:52 massimiliano cialdi, <address@hidden> wrote:

On 07/07/2017 18:04, Noam Weissman wrote:
>
> Speed, duplex, link etc... is low level handling and the TCP stack is
> not aware of that.
>
>
> This is why you call the set_link_up/down in your task, informing the
> stack !.
>
Yes, of course

> The MDIO interface between your micro and PHY has no relation with
> netif so why do you
>
> pass it as argument ?
>
because, in our implementation (NXP), netif->state is pointer to
structure containing information to interface with PHY.

> You several options to get the link state. You can connect the link
> led in the ETH connector
>
> to your micro and read it as a simple IO.
>
>
> If your PHY supports MII and it is connected as an MII you can hook an
> interrupt to the link line.
>
We are compliant to RMII, except interrupt signal that is not routed, so
we have to poll PHY.

> The third option is what I suggested to read the PHY basic register
> and check for the link bit.
>
Is what I do.

> Your link task should not only check if link is up or down but also
> know if it has changed !!. In your
>
> code is constantly calling the netifapi functions unless I missed
> something ?
>
Yes, I have further modified the task:

static void PhyStatus_Task( struct netif *netif )
{
     enum { link_up, link_down } linkstatus = link_down;
     phy_speed_t physpeed;
     phy_duplex_t phyduplex;
     bool link;
     status_t result;

     ETHSPDOFF();
     netifapi_netif_set_link_down(netif);
     while(1)
     {
         result = ethernetif_GetLinkStatus(netif, &link);
         if(result == kStatus_Success)
         {
             switch(linkstatus)
             {
             case link_down:
                 if(true == link)
                 {
                     linkstatus = link_up;
                     netifapi_netif_set_link_up(netif);
                 }
                 break;
             case link_up:
                 if(false == link)
                 {
                     linkstatus = link_down;
                     netifapi_netif_set_link_down(netif);
                     ETHSPDOFF();
                 }
                 else
                 {
                     result = ethernetif_GetLinkSpeedDuplex(netif,
&physpeed, &phyduplex);
                     if(result == kStatus_Success)
                     {
                         ETHSPD(physpeed);
                     }
                 }
                 break;
             }
         }
         vTaskDelay(100);
     }
}


I have investigated the problems: netifapi_netif_set_link_up() is called
and it cause call to link callback, in this function I call another
function in netifapi (netifapi_dhcp_start()), so I have a deadlock.

best regards
Max

_______________________________________________
lwip-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users

--

Pozdrawiam,

Krzysztof Wesołowski

+48 721 337 238


reply via email to

[Prev in Thread] Current Thread [Next in Thread]