|
|
@ -23,7 +23,6 @@ |
|
|
|
* 1.1 liuzhihong 2022/11/7 function and variable naming adjustment |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
#include <string.h> |
|
|
|
|
|
|
|
#include "sdkconfig.h" |
|
|
@ -67,7 +66,6 @@ |
|
|
|
#define LWIP_RX_THREAD_NAME "_lwip_rx" |
|
|
|
#define LWIP_MAX_NAME_LENGTH 32 |
|
|
|
|
|
|
|
|
|
|
|
#if !NO_SYS |
|
|
|
#define THREAD_STACKSIZE 4096 |
|
|
|
#define LINK_DETECT_THREAD_INTERVAL_MSEC 1000 |
|
|
@ -78,17 +76,31 @@ void link_detect_thread(void *p); |
|
|
|
#else |
|
|
|
static u32 dhcp_trans_timeout_msec_cnt = 0 ; |
|
|
|
static u32 dhcp_lease_renewal_msec_cnt = 0 ; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
/* Define those to better describe your network interface. */ |
|
|
|
#if defined(CONFIG_LWIP_FGMAC) |
|
|
|
extern err_t ethernetif_gmac_init(struct netif *netif); |
|
|
|
/* GMAC创建一个计数信号量,信号量的最大值是1,初始值为0 */ |
|
|
|
#define SEMAPHORE_MAXCOUNT 1 |
|
|
|
#define SEMAPHORE_INITIALCOUNT 0 |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined(CONFIG_LWIP_FXMAC) |
|
|
|
extern err_t ethernetif_xmac_init(struct netif *netif); |
|
|
|
/* XMAC创建一个计数信号量,信号量的最大值是128,初始值为0 */ |
|
|
|
#define SEMAPHORE_MAXCOUNT 128 |
|
|
|
#define SEMAPHORE_INITIALCOUNT 0 |
|
|
|
#endif |
|
|
|
|
|
|
|
#ifndef SEMAPHORE_MAXCOUNT |
|
|
|
#define SEMAPHORE_MAXCOUNT 1 |
|
|
|
#endif |
|
|
|
|
|
|
|
#ifndef SEMAPHORE_INITIALCOUNT |
|
|
|
#define SEMAPHORE_INITIALCOUNT 0 |
|
|
|
#endif |
|
|
|
|
|
|
|
/*
|
|
|
|
* LwipPortAdd: this is a wrapper around lwIP's netif_add function. |
|
|
|
* The objective is to provide portability between the different MAC's |
|
|
@ -172,31 +184,30 @@ struct netif *LwipPortAdd(struct netif *netif, |
|
|
|
/* Start thread to detect link periodically for Hot Plug autodetect */ |
|
|
|
if(netif_p) |
|
|
|
{ |
|
|
|
|
|
|
|
#if defined(CONFIG_LWIP_PORT_USE_LINK_DETECT_THREAD) |
|
|
|
#if defined(CONFIG_LWIP_PORT_USE_LINK_DETECT_THREAD) |
|
|
|
memcpy(detect_thread_name, netif->name, 2); |
|
|
|
strcpy(&detect_thread_name[2], LWIP_PHY_DETECT_THREAD_NAME); |
|
|
|
|
|
|
|
lwip_port = (struct LwipPort *)netif_p->state; |
|
|
|
lwip_port->detect_thread_handle = sys_thread_new(detect_thread_name, link_detect_thread, netif, |
|
|
|
CONFIG_LWIP_PORT_LINK_DETECT_STACKSIZE, CONFIG_LWIP_PORT_LINK_DETECT_PRIORITY); |
|
|
|
#endif |
|
|
|
/* create semaphore for rx thread */ |
|
|
|
#if defined(CONFIG_LWIP_PORT_USE_RECEIVE_THREAD) |
|
|
|
sys_sem_new(&lwip_port->sem_rx_data_available, 0); |
|
|
|
#endif |
|
|
|
/* create semaphore for rx thread */ |
|
|
|
#if defined(CONFIG_LWIP_PORT_USE_RECEIVE_THREAD) |
|
|
|
sys_countingsem_create(&lwip_port->sem_rx_data_available,SEMAPHORE_MAXCOUNT,SEMAPHORE_INITIALCOUNT); |
|
|
|
|
|
|
|
memcpy(rx_thread_name, netif->name, 2); |
|
|
|
strcpy(&rx_thread_name[2], LWIP_RX_THREAD_NAME); |
|
|
|
|
|
|
|
lwip_port->rx_thread_handle = sys_thread_new(rx_thread_name, (lwip_thread_fn)LwipPortInputThread, netif, |
|
|
|
CONFIG_LWIP_PORT_RECEIVE_THREAD_STACKSIZE, CONFIG_LWIP_PORT_RECEIVE_THREAD_PRIORITY); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
if(lwip_port->ops.eth_start) |
|
|
|
{ |
|
|
|
if(lwip_port->ops.eth_start) |
|
|
|
{ |
|
|
|
/* start mac controller */ |
|
|
|
lwip_port->ops.eth_start(netif_p); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
@ -229,7 +240,6 @@ void LwipPortInputThread(struct netif *netif) |
|
|
|
struct LwipPort *emac; |
|
|
|
FASSERT(netif != NULL); |
|
|
|
emac = (struct LwipPort *)netif->state; |
|
|
|
FDriverSdelay(1); |
|
|
|
while (1) |
|
|
|
{ |
|
|
|
/* sleep until there are packets to process
|
|
|
@ -237,16 +247,6 @@ void LwipPortInputThread(struct netif *netif) |
|
|
|
* routine. |
|
|
|
*/ |
|
|
|
sys_arch_sem_wait(&emac->sem_rx_data_available,0); |
|
|
|
#if defined(CONFIG_LWIP_FXMAC) |
|
|
|
if(emac->ops.eth_poll) |
|
|
|
{ |
|
|
|
emac->ops.eth_poll(netif); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
LWIP_PORT_ERROR("emac->ops.eth_poll is null"); |
|
|
|
} |
|
|
|
#endif |
|
|
|
/* move all received packets to lwIP */ |
|
|
|
if(emac->ops.eth_input) |
|
|
|
{ |
|
|
@ -571,18 +571,3 @@ void LwipPortDebug(const char *name) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void LwipEthProcessLoop(struct netif *netif) |
|
|
|
{ |
|
|
|
struct LwipPort *emac; |
|
|
|
FASSERT(netif != NULL); |
|
|
|
FASSERT(netif->state != NULL); |
|
|
|
emac = (struct LwipPort *)netif->state; |
|
|
|
if(emac->ops.eth_poll) |
|
|
|
{ |
|
|
|
emac->ops.eth_poll(netif); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
LWIP_PORT_ERROR("emac->ops.eth_poll is null"); |
|
|
|
} |
|
|
|
} |
|
|
|