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, < [email protected]> 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 > [email protected] > https://lists.nongnu.org/mailman/listinfo/lwip-users > -- Pozdrawiam, Krzysztof Wesołowski +48 721 337 238
_______________________________________________ lwip-users mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/lwip-users
