From 813b175ca34f05b13ee8b7da4a5c3dac19b85c11 Mon Sep 17 00:00:00 2001 From: Liu_Weichao Date: Thu, 20 Jul 2023 11:13:33 +0800 Subject: [PATCH] fix Ethernet input task error and add hardware-checksum for xidatong/ok1052-c/xiwangtong board --- .../ethernet/enet_ethernetif.c | 20 ++++++++++--------- .../ethernet/enet_ethernetif_kinetis.c | 2 ++ .../ethernet/enet_ethernetif.c | 20 ++++++++++--------- .../ethernet/enet_ethernetif_kinetis.c | 2 ++ .../ethernet/enet_ethernetif.c | 20 ++++++++++--------- .../ethernet/enet_ethernetif_kinetis.c | 2 ++ .../resources/ethernet/LwIP/arch/lwipopts.h | 4 ++-- .../resources/ethernet/LwIP/arch/sys_arch.h | 2 +- 8 files changed, 42 insertions(+), 30 deletions(-) diff --git a/Ubiquitous/XiZi_IIoT/board/ok1052-c/third_party_driver/ethernet/enet_ethernetif.c b/Ubiquitous/XiZi_IIoT/board/ok1052-c/third_party_driver/ethernet/enet_ethernetif.c index 47039f742..40f0b6beb 100755 --- a/Ubiquitous/XiZi_IIoT/board/ok1052-c/third_party_driver/ethernet/enet_ethernetif.c +++ b/Ubiquitous/XiZi_IIoT/board/ok1052-c/third_party_driver/ethernet/enet_ethernetif.c @@ -206,16 +206,18 @@ void ethernetif_input(void *netif_arg) LWIP_ASSERT("netif != NULL", (netif != NULL)); - /* move received packet into a new pbuf */ - while ((p = ethernetif_linkinput(netif)) != NULL) - { - /* pass all packets to ethernet_input, which decides what packets it supports */ - if ((ret = netif->input(p, netif)) != ERR_OK) + while (1) { + /* move received packet into a new pbuf */ + while ((p = ethernetif_linkinput(netif)) != NULL) { - LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n")); - lw_print("lw: [%s] ret %d p %p\n", __func__, ret, p); - pbuf_free(p); - p = NULL; + /* pass all packets to ethernet_input, which decides what packets it supports */ + if ((ret = netif->input(p, netif)) != ERR_OK) + { + LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n")); + lw_print("lw: [%s] ret %d p %p\n", __func__, ret, p); + pbuf_free(p); + p = NULL; + } } } } diff --git a/Ubiquitous/XiZi_IIoT/board/ok1052-c/third_party_driver/ethernet/enet_ethernetif_kinetis.c b/Ubiquitous/XiZi_IIoT/board/ok1052-c/third_party_driver/ethernet/enet_ethernetif_kinetis.c index 10364a0cb..60f5774fc 100755 --- a/Ubiquitous/XiZi_IIoT/board/ok1052-c/third_party_driver/ethernet/enet_ethernetif_kinetis.c +++ b/Ubiquitous/XiZi_IIoT/board/ok1052-c/third_party_driver/ethernet/enet_ethernetif_kinetis.c @@ -364,6 +364,8 @@ void ethernetif_enet_init(struct netif *netif, struct ethernetif *ethernetif, LWIP_ASSERT("Input Ethernet base error!", (instance != ARRAY_SIZE(enetBases))); #endif /* USE_RTOS */ + config.txAccelerConfig = kENET_TxAccelIpCheckEnabled | kENET_TxAccelProtoCheckEnabled; + /* Initialize the ENET module.*/ ENET_Init(ethernetif->base, ðernetif->handle, &config, &buffCfg[0], netif->hwaddr, sysClock); diff --git a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/ethernet/enet_ethernetif.c b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/ethernet/enet_ethernetif.c index 292ee307b..fd16fb033 100755 --- a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/ethernet/enet_ethernetif.c +++ b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/ethernet/enet_ethernetif.c @@ -209,16 +209,18 @@ void ethernetif_input(void *netif_arg) LWIP_ASSERT("netif != NULL", (netif != NULL)); - /* move received packet into a new pbuf */ - while ((p = ethernetif_linkinput(netif)) != NULL) - { - /* pass all packets to ethernet_input, which decides what packets it supports */ - if ((ret = netif->input(p, netif)) != ERR_OK) + while (1) { + /* move received packet into a new pbuf */ + while ((p = ethernetif_linkinput(netif)) != NULL) { - LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n")); - lw_print("lw: [%s] ret %d p %p\n", __func__, ret, p); - pbuf_free(p); - p = NULL; + /* pass all packets to ethernet_input, which decides what packets it supports */ + if ((ret = netif->input(p, netif)) != ERR_OK) + { + LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n")); + lw_print("lw: [%s] ret %d p %p\n", __func__, ret, p); + pbuf_free(p); + p = NULL; + } } } } diff --git a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/ethernet/enet_ethernetif_kinetis.c b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/ethernet/enet_ethernetif_kinetis.c index fe8f7c3d1..c14663286 100755 --- a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/ethernet/enet_ethernetif_kinetis.c +++ b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/ethernet/enet_ethernetif_kinetis.c @@ -363,6 +363,8 @@ void ethernetif_enet_init(struct netif *netif, struct ethernetif *ethernetif, LWIP_ASSERT("Input Ethernet base error!", (instance != ARRAY_SIZE(enetBases))); #endif /* USE_RTOS */ + config.txAccelerConfig = kENET_TxAccelIpCheckEnabled | kENET_TxAccelProtoCheckEnabled; + /* Initialize the ENET module.*/ ENET_Init(ethernetif->base, ðernetif->handle, &config, &buffCfg[0], netif->hwaddr, sysClock); diff --git a/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/third_party_driver/ethernet/enet_ethernetif.c b/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/third_party_driver/ethernet/enet_ethernetif.c index 292ee307b..fd16fb033 100755 --- a/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/third_party_driver/ethernet/enet_ethernetif.c +++ b/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/third_party_driver/ethernet/enet_ethernetif.c @@ -209,16 +209,18 @@ void ethernetif_input(void *netif_arg) LWIP_ASSERT("netif != NULL", (netif != NULL)); - /* move received packet into a new pbuf */ - while ((p = ethernetif_linkinput(netif)) != NULL) - { - /* pass all packets to ethernet_input, which decides what packets it supports */ - if ((ret = netif->input(p, netif)) != ERR_OK) + while (1) { + /* move received packet into a new pbuf */ + while ((p = ethernetif_linkinput(netif)) != NULL) { - LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n")); - lw_print("lw: [%s] ret %d p %p\n", __func__, ret, p); - pbuf_free(p); - p = NULL; + /* pass all packets to ethernet_input, which decides what packets it supports */ + if ((ret = netif->input(p, netif)) != ERR_OK) + { + LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n")); + lw_print("lw: [%s] ret %d p %p\n", __func__, ret, p); + pbuf_free(p); + p = NULL; + } } } } diff --git a/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/third_party_driver/ethernet/enet_ethernetif_kinetis.c b/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/third_party_driver/ethernet/enet_ethernetif_kinetis.c index fe8f7c3d1..c14663286 100755 --- a/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/third_party_driver/ethernet/enet_ethernetif_kinetis.c +++ b/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/third_party_driver/ethernet/enet_ethernetif_kinetis.c @@ -363,6 +363,8 @@ void ethernetif_enet_init(struct netif *netif, struct ethernetif *ethernetif, LWIP_ASSERT("Input Ethernet base error!", (instance != ARRAY_SIZE(enetBases))); #endif /* USE_RTOS */ + config.txAccelerConfig = kENET_TxAccelIpCheckEnabled | kENET_TxAccelProtoCheckEnabled; + /* Initialize the ENET module.*/ ENET_Init(ethernetif->base, ðernetif->handle, &config, &buffCfg[0], netif->hwaddr, sysClock); diff --git a/Ubiquitous/XiZi_IIoT/resources/ethernet/LwIP/arch/lwipopts.h b/Ubiquitous/XiZi_IIoT/resources/ethernet/LwIP/arch/lwipopts.h index 6409f50f1..cdf5a61d9 100644 --- a/Ubiquitous/XiZi_IIoT/resources/ethernet/LwIP/arch/lwipopts.h +++ b/Ubiquitous/XiZi_IIoT/resources/ethernet/LwIP/arch/lwipopts.h @@ -535,10 +535,10 @@ The STM32F4x7 allows computing and verifying the IP, UDP, TCP and ICMP checksums #define DEFAULT_ACCEPTMBOX_SIZE 10 #define DEFAULT_THREAD_PRIO 20 -#define DEFAULT_THREAD_STACKSIZE 1024 +#define DEFAULT_THREAD_STACKSIZE 2048 #define TCPIP_THREAD_NAME "tcp" -#define TCPIP_THREAD_STACKSIZE 1024 +#define TCPIP_THREAD_STACKSIZE 2048 #define TCPIP_MBOX_SIZE 16 #define TCPIP_THREAD_PRIO 20 diff --git a/Ubiquitous/XiZi_IIoT/resources/ethernet/LwIP/arch/sys_arch.h b/Ubiquitous/XiZi_IIoT/resources/ethernet/LwIP/arch/sys_arch.h index e606c710b..384b85b1a 100644 --- a/Ubiquitous/XiZi_IIoT/resources/ethernet/LwIP/arch/sys_arch.h +++ b/Ubiquitous/XiZi_IIoT/resources/ethernet/LwIP/arch/sys_arch.h @@ -54,7 +54,7 @@ #define LWIP_TARGET_PORT LWIP_LOCAL_PORT #define LWIP_DEMO_TIMES 10 -#define LWIP_TASK_STACK_SIZE 1536 +#define LWIP_TASK_STACK_SIZE 4096 #define LWIP_DEMO_TASK_PRIO 20 // /* MAC address configuration. */