提交 68095474 编写于 作者: B Bernard Xiong

[lwIP] Add ETHIF_LINK_AUTOUP/PHYUP flag to ethernet interface

上级 066ec6dc
......@@ -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();
......
......@@ -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);
......
......@@ -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 */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册