Skip to content

Commit 6809547

Browse files
committed
[lwIP] Add ETHIF_LINK_AUTOUP/PHYUP flag to ethernet interface
1 parent 066ec6d commit 6809547

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

components/net/lwip-1.4.1/src/arch/sys_arch.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,10 @@ static void tcpip_init_done_callback(void *arg)
115115
netif_set_up(ethif->netif);
116116
}
117117

118-
#if LWIP_NETIF_LINK_CALLBACK
119-
netif_set_link_up(ethif->netif);
120-
#endif
118+
if (!(ethif->flags & ETHIF_LINK_PHYUP))
119+
{
120+
netif_set_link_up(ethif->netif);
121+
}
121122

122123
/* enter critical */
123124
rt_enter_critical();

components/net/lwip-1.4.1/src/include/netif/ethernetif.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
#define ETHERNET_MTU RT_LWIP_ETH_MTU
1212
#endif
1313

14+
/* eth flag with auto_linkup or phy_linkup */
15+
#define ETHIF_LINK_AUTOUP 0x0000
16+
#define ETHIF_LINK_PHYUP 0x0100
17+
1418
struct eth_device
1519
{
1620
/* inherit from rt_device */
@@ -20,9 +24,9 @@ struct eth_device
2024
struct netif *netif;
2125
struct rt_semaphore tx_ack;
2226

23-
rt_uint8_t flags;
27+
rt_uint16_t flags;
2428
rt_uint8_t link_changed;
25-
rt_uint16_t link_status;
29+
rt_uint8_t link_status;
2630

2731
/* eth device interface */
2832
struct pbuf* (*eth_rx)(rt_device_t dev);
@@ -31,7 +35,7 @@ struct eth_device
3135

3236
rt_err_t eth_device_ready(struct eth_device* dev);
3337
rt_err_t eth_device_init(struct eth_device * dev, char *name);
34-
rt_err_t eth_device_init_with_flag(struct eth_device *dev, char *name, rt_uint8_t flag);
38+
rt_err_t eth_device_init_with_flag(struct eth_device *dev, char *name, rt_uint16_t flag);
3539
rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up);
3640

3741
int eth_system_device_init(void);

components/net/lwip-1.4.1/src/netif/ethernetif.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ static err_t eth_netif_device_init(struct netif *netif)
154154
}
155155

156156
/* copy device flags to netif flags */
157-
netif->flags = ethif->flags;
157+
netif->flags = (ethif->flags & 0xff);
158158

159159
/* set default netif */
160160
if (netif_default == RT_NULL)
@@ -173,9 +173,11 @@ static err_t eth_netif_device_init(struct netif *netif)
173173
netif_set_up(ethif->netif);
174174
}
175175

176-
#ifdef LWIP_NETIF_LINK_CALLBACK
177-
netif_set_link_up(ethif->netif);
178-
#endif
176+
if (!(ethif->flags & ETHIF_LINK_PHYUP))
177+
{
178+
/* set link_up for this netif */
179+
netif_set_link_up(ethif->netif);
180+
}
179181

180182
return ERR_OK;
181183
}
@@ -184,7 +186,7 @@ static err_t eth_netif_device_init(struct netif *netif)
184186
}
185187

186188
/* Keep old drivers compatible in RT-Thread */
187-
rt_err_t eth_device_init_with_flag(struct eth_device *dev, char *name, rt_uint8_t flags)
189+
rt_err_t eth_device_init_with_flag(struct eth_device *dev, char *name, rt_uint16_t flags)
188190
{
189191
struct netif* netif;
190192

@@ -246,7 +248,7 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, char *name, rt_uint8_
246248

247249
rt_err_t eth_device_init(struct eth_device * dev, char *name)
248250
{
249-
rt_uint8_t flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP;
251+
rt_uint16_t flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP;
250252

251253
#if LWIP_DHCP
252254
/* DHCP support */

0 commit comments

Comments
 (0)