diff --git a/components/net/lwip-1.4.1/src/arch/sys_arch.c b/components/net/lwip-1.4.1/src/arch/sys_arch.c index d3a69f9ac3b15ac1a61735d942ea1b768755616a..c0aed9d4f03a0ba8490107ba49f60d2830b3a6ea 100644 --- a/components/net/lwip-1.4.1/src/arch/sys_arch.c +++ b/components/net/lwip-1.4.1/src/arch/sys_arch.c @@ -115,9 +115,10 @@ static void tcpip_init_done_callback(void *arg) netif_set_up(ethif->netif); } -#if LWIP_NETIF_LINK_CALLBACK - netif_set_link_up(ethif->netif); -#endif + if (!(ethif->flags & ETHIF_LINK_PHYUP)) + { + netif_set_link_up(ethif->netif); + } /* enter critical */ rt_enter_critical(); diff --git a/components/net/lwip-1.4.1/src/include/netif/ethernetif.h b/components/net/lwip-1.4.1/src/include/netif/ethernetif.h index 2019df701721522f77cfb845b06d9e909ee2b63d..bdad32ec208741ac4f85b0945c442c81f3682c80 100644 --- a/components/net/lwip-1.4.1/src/include/netif/ethernetif.h +++ b/components/net/lwip-1.4.1/src/include/netif/ethernetif.h @@ -11,6 +11,10 @@ #define ETHERNET_MTU RT_LWIP_ETH_MTU #endif +/* eth flag with auto_linkup or phy_linkup */ +#define ETHIF_LINK_AUTOUP 0x0000 +#define ETHIF_LINK_PHYUP 0x0100 + struct eth_device { /* inherit from rt_device */ @@ -20,9 +24,9 @@ struct eth_device struct netif *netif; struct rt_semaphore tx_ack; - rt_uint8_t flags; + rt_uint16_t flags; rt_uint8_t link_changed; - rt_uint16_t link_status; + rt_uint8_t link_status; /* eth device interface */ struct pbuf* (*eth_rx)(rt_device_t dev); @@ -31,7 +35,7 @@ struct eth_device rt_err_t eth_device_ready(struct eth_device* dev); rt_err_t eth_device_init(struct eth_device * dev, char *name); -rt_err_t eth_device_init_with_flag(struct eth_device *dev, char *name, rt_uint8_t flag); +rt_err_t eth_device_init_with_flag(struct eth_device *dev, char *name, rt_uint16_t flag); rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up); int eth_system_device_init(void); diff --git a/components/net/lwip-1.4.1/src/netif/ethernetif.c b/components/net/lwip-1.4.1/src/netif/ethernetif.c index 2e0ef2f8bdb8f4dfc0fb3c33e455a0550c3e5b22..f0b2f814dccd0c4b1470f4280a161d27bc75c1d7 100644 --- a/components/net/lwip-1.4.1/src/netif/ethernetif.c +++ b/components/net/lwip-1.4.1/src/netif/ethernetif.c @@ -154,7 +154,7 @@ static err_t eth_netif_device_init(struct netif *netif) } /* copy device flags to netif flags */ - netif->flags = ethif->flags; + netif->flags = (ethif->flags & 0xff); /* set default netif */ if (netif_default == RT_NULL) @@ -173,9 +173,11 @@ static err_t eth_netif_device_init(struct netif *netif) netif_set_up(ethif->netif); } -#ifdef LWIP_NETIF_LINK_CALLBACK - netif_set_link_up(ethif->netif); -#endif + if (!(ethif->flags & ETHIF_LINK_PHYUP)) + { + /* set link_up for this netif */ + netif_set_link_up(ethif->netif); + } return ERR_OK; } @@ -184,7 +186,7 @@ static err_t eth_netif_device_init(struct netif *netif) } /* Keep old drivers compatible in RT-Thread */ -rt_err_t eth_device_init_with_flag(struct eth_device *dev, char *name, rt_uint8_t flags) +rt_err_t eth_device_init_with_flag(struct eth_device *dev, char *name, rt_uint16_t flags) { struct netif* netif; @@ -246,7 +248,7 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, char *name, rt_uint8_ rt_err_t eth_device_init(struct eth_device * dev, char *name) { - rt_uint8_t flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP; + rt_uint16_t flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP; #if LWIP_DHCP /* DHCP support */