[lwIP] Add ETHIF_LINK_AUTOUP/PHYUP flag to ethernet interface

This commit is contained in:
Bernard Xiong 2015-10-15 23:10:59 +08:00
parent 066ec6dc91
commit 6809547491
3 changed files with 19 additions and 12 deletions

View File

@ -115,9 +115,10 @@ static void tcpip_init_done_callback(void *arg)
netif_set_up(ethif->netif); netif_set_up(ethif->netif);
} }
#if LWIP_NETIF_LINK_CALLBACK if (!(ethif->flags & ETHIF_LINK_PHYUP))
netif_set_link_up(ethif->netif); {
#endif netif_set_link_up(ethif->netif);
}
/* enter critical */ /* enter critical */
rt_enter_critical(); rt_enter_critical();

View File

@ -11,6 +11,10 @@
#define ETHERNET_MTU RT_LWIP_ETH_MTU #define ETHERNET_MTU RT_LWIP_ETH_MTU
#endif #endif
/* eth flag with auto_linkup or phy_linkup */
#define ETHIF_LINK_AUTOUP 0x0000
#define ETHIF_LINK_PHYUP 0x0100
struct eth_device struct eth_device
{ {
/* inherit from rt_device */ /* inherit from rt_device */
@ -20,9 +24,9 @@ struct eth_device
struct netif *netif; struct netif *netif;
struct rt_semaphore tx_ack; struct rt_semaphore tx_ack;
rt_uint8_t flags; rt_uint16_t flags;
rt_uint8_t link_changed; rt_uint8_t link_changed;
rt_uint16_t link_status; rt_uint8_t link_status;
/* eth device interface */ /* eth device interface */
struct pbuf* (*eth_rx)(rt_device_t dev); 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_ready(struct eth_device* dev);
rt_err_t eth_device_init(struct eth_device * dev, char *name); 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); rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up);
int eth_system_device_init(void); int eth_system_device_init(void);

View File

@ -154,7 +154,7 @@ static err_t eth_netif_device_init(struct netif *netif)
} }
/* copy device flags to netif flags */ /* copy device flags to netif flags */
netif->flags = ethif->flags; netif->flags = (ethif->flags & 0xff);
/* set default netif */ /* set default netif */
if (netif_default == RT_NULL) if (netif_default == RT_NULL)
@ -173,9 +173,11 @@ static err_t eth_netif_device_init(struct netif *netif)
netif_set_up(ethif->netif); netif_set_up(ethif->netif);
} }
#ifdef LWIP_NETIF_LINK_CALLBACK if (!(ethif->flags & ETHIF_LINK_PHYUP))
netif_set_link_up(ethif->netif); {
#endif /* set link_up for this netif */
netif_set_link_up(ethif->netif);
}
return ERR_OK; return ERR_OK;
} }
@ -184,7 +186,7 @@ static err_t eth_netif_device_init(struct netif *netif)
} }
/* Keep old drivers compatible in RT-Thread */ /* 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; 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_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 #if LWIP_DHCP
/* DHCP support */ /* DHCP support */