|
From: | Noam Weissman |
Subject: | Re: [lwip-users] how to set the link up |
Date: | Fri, 7 Jul 2017 16:04:57 +0000 |
Hi Max,
I am missing something here. TCP stack is software and has no direct access to the
physical part, the PHY.
The connection between the two from what I know is by DMA and nothing else. Data collected by the low level is transferred to the TCP stack for processing and any data sent from the TCP stack is passed to the physical layer. The two are encapsulated by the driver.
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 !.
The MDIO interface between your micro and PHY has no relation with netif so why do you
pass it as argument ? 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.
The third option is what I suggested to read the PHY basic register and check for the link bit.
If you have a UART connected and can print out messages please add debug prints in your code.
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 ?
From: lwip-users <lwip-users-bounces+address@hidden> on behalf of massimiliano cialdi <address@hidden>
Sent: Friday, July 7, 2017 6:27 PM To: address@hidden Subject: Re: [lwip-users] how to set the link up I have implement a task to check phy status (similar to what you do),
and also I use netifapi_* functions: static void PhyStatus_Task( struct netif *netif ) { phy_speed_t physpeed; phy_duplex_t phyduplex; bool linkstatus; status_t result; ETHSPDOFF(); while(1) { result = ethernetif_GetLinkStatus(netif, &linkstatus); if(result == kStatus_Success) { if(linkstatus == true) { result = ethernetif_GetLinkSpeedDuplex(netif, &physpeed, &phyduplex); if(result == kStatus_Success) { ETHSPD(physpeed); } netifapi_netif_set_link_up(netif); } else { ETHSPDOFF(); netifapi_netif_set_link_down(netif); } } else { ETHSPDOFF(); netifapi_netif_set_link_down(netif); } vTaskDelay(100); } } unfortunately I have a problem: when netif_set_link_up() is finally called always return immediately: void netif_set_link_up(struct netif *netif) { if (!(netif->flags & NETIF_FLAG_LINK_UP)) { netif->flags |= NETIF_FLAG_LINK_UP; #if LWIP_DHCP dhcp_network_changed(netif); #endif /* LWIP_DHCP */ #if LWIP_AUTOIP autoip_network_changed(netif); #endif /* LWIP_AUTOIP */ if (netif->flags & NETIF_FLAG_UP) { netif_issue_reports(netif, NETIF_REPORT_TYPE_IPV4|NETIF_REPORT_TYPE_IPV6); } NETIF_LINK_CALLBACK(netif); } } first 'if' is always false, and I wonder why best regads Max On 05/07/2017 19:21, Noam Weissman wrote: > > Yes Sylvain 😊 > > I already changed the code according to your comments 😊 > > > Thanks. > > > > ------------------------------------------------------------------------ > *From:* lwip-users <lwip-users-bounces+address@hidden> on > behalf of Sylvain Rochet <address@hidden> > *Sent:* Wednesday, July 5, 2017 8:08 PM > *To:* Mailing list for lwIP users > *Subject:* Re: [lwip-users] how to set the link up > Hi, > > On Wed, Jul 05, 2017 at 04:55:24PM +0000, Noam Weissman wrote: > > > > My DHCP task calls dhcp_start and wait for an IP. If there is a > > timeout the task will assign a static default IP. You can do something > > similar. > > Erm, should I add that dhcp_start() is not thread safe ? > > Sylvain > _______________________________________________ lwip-users mailing list address@hidden https://lists.nongnu.org/mailman/listinfo/lwip-users
|
[Prev in Thread] | Current Thread | [Next in Thread] |