From cb14c780551ada70df4df1f26fe8d14b2f00c948 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Thu, 19 Dec 2019 14:44:46 +0800 Subject: [PATCH] devif_poll_tcp_timer shouldn't be skipped in the multiple card case devif_timer will be called multiple time in one period if the multiple card exist, the elapsed time calculated for the first callback is right, but the flowing callback in the same period is wrong(very short) because the global variable g_polltimer is used in the calculation. so let's pass the delay time to devif_timer and remove g_polltimer. Change-Id: I6ac3d1135e08cc0f34c51916fa713bd6e6892d04 Signed-off-by: Xiang Xiao --- arch/arm/src/c5471/c5471_ethernet.c | 2 +- arch/arm/src/imxrt/imxrt_enet.c | 2 +- arch/arm/src/kinetis/kinetis_enet.c | 2 +- arch/arm/src/lpc17xx_40xx/lpc17_40_ethernet.c | 2 +- arch/arm/src/lpc43xx/lpc43_ethernet.c | 2 +- arch/arm/src/lpc54xx/lpc54_ethernet.c | 2 +- arch/arm/src/s32k1xx/s32k1xx_enet.c | 2 +- arch/arm/src/sam34/sam_emac.c | 2 +- arch/arm/src/sama5/sam_emaca.c | 2 +- arch/arm/src/sama5/sam_emacb.c | 2 +- arch/arm/src/sama5/sam_gmac.c | 2 +- arch/arm/src/samv7/sam_emac.c | 2 +- arch/arm/src/stm32/stm32_eth.c | 2 +- arch/arm/src/stm32f7/stm32_ethernet.c | 2 +- arch/arm/src/stm32h7/stm32_ethernet.c | 2 +- arch/arm/src/tiva/lm/lm3s_ethernet.c | 2 +- arch/arm/src/tiva/tm4c/tm4c_ethernet.c | 2 +- arch/hc/src/m9s12/m9s12_ethernet.c | 2 +- arch/mips/src/pic32mx/pic32mx-ethernet.c | 2 +- arch/mips/src/pic32mz/pic32mz-ethernet.c | 2 +- arch/misoc/src/common/misoc_net.c | 2 +- arch/renesas/src/rx65n/rx65n_eth.c | 2 +- arch/sim/src/sim/up_netdriver.c | 2 +- arch/z80/src/ez80/ez80_emac.c | 2 +- drivers/net/dm90x0.c | 2 +- drivers/net/enc28j60.c | 2 +- drivers/net/encx24j600.c | 2 +- drivers/net/ftmac100.c | 2 +- drivers/net/lan91c111.c | 2 +- drivers/net/loopback.c | 2 +- drivers/net/rpmsgdrv.c | 2 +- drivers/net/skeleton.c | 2 +- drivers/net/slip.c | 2 +- drivers/net/tun.c | 2 +- drivers/usbdev/cdcecm.c | 2 +- drivers/usbdev/rndis.c | 2 +- .../wireless/ieee80211/bcm43xxx/bcmf_netdev.c | 2 +- .../wireless/ieee802154/xbee/xbee_netdev.c | 2 +- .../wireless/spirit/drivers/spirit_netdev.c | 2 +- include/nuttx/net/netdev.h | 2 +- net/devif/devif.h | 4 -- net/devif/devif_initialize.c | 7 --- net/devif/devif_poll.c | 59 ++++--------------- wireless/bluetooth/bt_netdev.c | 2 +- wireless/ieee802154/mac802154_loopback.c | 2 +- wireless/ieee802154/mac802154_netdev.c | 2 +- wireless/pktradio/pktradio_loopback.c | 2 +- 47 files changed, 56 insertions(+), 102 deletions(-) diff --git a/arch/arm/src/c5471/c5471_ethernet.c b/arch/arm/src/c5471/c5471_ethernet.c index ffbc5ae7f8391..d7d686866e3f8 100644 --- a/arch/arm/src/c5471/c5471_ethernet.c +++ b/arch/arm/src/c5471/c5471_ethernet.c @@ -1778,7 +1778,7 @@ static void c5471_poll_work(FAR void *arg) { /* If so, update TCP timing states and poll the network for new XMIT data */ - (void)devif_timer(&priv->c_dev, c5471_txpoll); + (void)devif_timer(&priv->c_dev, C5471_WDDELAY, c5471_txpoll); } /* Setup the watchdog poll timer again */ diff --git a/arch/arm/src/imxrt/imxrt_enet.c b/arch/arm/src/imxrt/imxrt_enet.c index 396edba0df9f5..423080f5b2caf 100644 --- a/arch/arm/src/imxrt/imxrt_enet.c +++ b/arch/arm/src/imxrt/imxrt_enet.c @@ -1231,7 +1231,7 @@ static void imxrt_poll_work(FAR void *arg) * transmit in progress, we will missing TCP time state updates? */ - (void)devif_timer(&priv->dev, imxrt_txpoll); + (void)devif_timer(&priv->dev, IMXRT_WDDELAY, imxrt_txpoll); } /* Setup the watchdog poll timer again in any case */ diff --git a/arch/arm/src/kinetis/kinetis_enet.c b/arch/arm/src/kinetis/kinetis_enet.c index 50361424b11ff..f90ac64ae694a 100644 --- a/arch/arm/src/kinetis/kinetis_enet.c +++ b/arch/arm/src/kinetis/kinetis_enet.c @@ -1083,7 +1083,7 @@ static void kinetis_poll_work(FAR void *arg) * in progress, we will missing TCP time state updates? */ - (void)devif_timer(&priv->dev, kinetis_txpoll); + (void)devif_timer(&priv->dev, KINETIS_WDDELAY, kinetis_txpoll); } /* Setup the watchdog poll timer again in any case */ diff --git a/arch/arm/src/lpc17xx_40xx/lpc17_40_ethernet.c b/arch/arm/src/lpc17xx_40xx/lpc17_40_ethernet.c index ac1e39f303661..6e8f02d3c0b4f 100644 --- a/arch/arm/src/lpc17xx_40xx/lpc17_40_ethernet.c +++ b/arch/arm/src/lpc17xx_40xx/lpc17_40_ethernet.c @@ -1480,7 +1480,7 @@ static void lpc17_40_poll_work(FAR void *arg) * transmit in progress, we will missing TCP time state updates? */ - (void)devif_timer(&priv->lp_dev, lpc17_40_txpoll); + (void)devif_timer(&priv->lp_dev, LPC17_40_WDDELAY, lpc17_40_txpoll); } /* Simulate a fake receive to relaunch the data exchanges when a receive diff --git a/arch/arm/src/lpc43xx/lpc43_ethernet.c b/arch/arm/src/lpc43xx/lpc43_ethernet.c index 520ea4953fe77..76ada7c43024b 100644 --- a/arch/arm/src/lpc43xx/lpc43_ethernet.c +++ b/arch/arm/src/lpc43xx/lpc43_ethernet.c @@ -2169,7 +2169,7 @@ static void lpc43_poll_work(FAR void *arg) /* Update TCP timing states and poll for new XMIT data. */ - (void)devif_timer(dev, lpc43_txpoll); + (void)devif_timer(dev, LPC43_WDDELAY, lpc43_txpoll); /* We will, most likely end up with a buffer to be freed. But it * might not be the same one that we allocated above. diff --git a/arch/arm/src/lpc54xx/lpc54_ethernet.c b/arch/arm/src/lpc54xx/lpc54_ethernet.c index bc45379353843..7fb2d68d2c9c1 100644 --- a/arch/arm/src/lpc54xx/lpc54_ethernet.c +++ b/arch/arm/src/lpc54xx/lpc54_ethernet.c @@ -1731,7 +1731,7 @@ static void lpc54_eth_dotimer(struct lpc54_ethdriver_s *priv) priv->eth_dev.d_buf = (uint8_t *)lpc54_pktbuf_alloc(priv); if (priv->eth_dev.d_buf != NULL) { - (void)devif_timer(&priv->eth_dev, lpc54_eth_txpoll); + (void)devif_timer(&priv->eth_dev, LPC54_WDDELAY, lpc54_eth_txpoll); /* Make sure that the Tx buffer remaining after the poll is * freed. diff --git a/arch/arm/src/s32k1xx/s32k1xx_enet.c b/arch/arm/src/s32k1xx/s32k1xx_enet.c index e991e79968a35..3fd10641bdd17 100644 --- a/arch/arm/src/s32k1xx/s32k1xx_enet.c +++ b/arch/arm/src/s32k1xx/s32k1xx_enet.c @@ -1230,7 +1230,7 @@ static void s32k1xx_poll_work(FAR void *arg) * transmit in progress, we will missing TCP time state updates? */ - (void)devif_timer(&priv->dev, s32k1xx_txpoll); + (void)devif_timer(&priv->dev, S32K1XX_WDDELAY, s32k1xx_txpoll); } /* Setup the watchdog poll timer again in any case */ diff --git a/arch/arm/src/sam34/sam_emac.c b/arch/arm/src/sam34/sam_emac.c index 1d3f4f6f9c515..dc0e4a4576179 100644 --- a/arch/arm/src/sam34/sam_emac.c +++ b/arch/arm/src/sam34/sam_emac.c @@ -1773,7 +1773,7 @@ static void sam_poll_work(FAR void *arg) { /* Update TCP timing states and poll the network for new XMIT data. */ - (void)devif_timer(dev, sam_txpoll); + (void)devif_timer(dev, SAM_WDDELAY, sam_txpoll); } /* Setup the watchdog poll timer again */ diff --git a/arch/arm/src/sama5/sam_emaca.c b/arch/arm/src/sama5/sam_emaca.c index 500d7e28c2914..7adbd832d3642 100644 --- a/arch/arm/src/sama5/sam_emaca.c +++ b/arch/arm/src/sama5/sam_emaca.c @@ -1808,7 +1808,7 @@ static void sam_poll_work(FAR void *arg) { /* Update TCP timing states and poll the network for new XMIT data. */ - (void)devif_timer(dev, sam_txpoll); + (void)devif_timer(dev, SAM_WDDELAY, sam_txpoll); } /* Setup the watchdog poll timer again */ diff --git a/arch/arm/src/sama5/sam_emacb.c b/arch/arm/src/sama5/sam_emacb.c index ff39f84ab5130..cd15d048dcfba 100644 --- a/arch/arm/src/sama5/sam_emacb.c +++ b/arch/arm/src/sama5/sam_emacb.c @@ -2169,7 +2169,7 @@ static void sam_poll_work(FAR void *arg) { /* Update TCP timing states and poll the network for new XMIT data. */ - (void)devif_timer(dev, sam_txpoll); + (void)devif_timer(dev, SAM_WDDELAY, sam_txpoll); } /* Setup the watchdog poll timer again */ diff --git a/arch/arm/src/sama5/sam_gmac.c b/arch/arm/src/sama5/sam_gmac.c index fe48935eaed03..a05cac8c4625d 100644 --- a/arch/arm/src/sama5/sam_gmac.c +++ b/arch/arm/src/sama5/sam_gmac.c @@ -1760,7 +1760,7 @@ static void sam_poll_work(FAR void *arg) { /* Update TCP timing states and poll the network for new XMIT data. */ - (void)devif_timer(dev, sam_txpoll); + (void)devif_timer(dev, SAM_WDDELAY, sam_txpoll); } /* Setup the watchdog poll timer again */ diff --git a/arch/arm/src/samv7/sam_emac.c b/arch/arm/src/samv7/sam_emac.c index 28e6781bce963..2e81773244180 100644 --- a/arch/arm/src/samv7/sam_emac.c +++ b/arch/arm/src/samv7/sam_emac.c @@ -2636,7 +2636,7 @@ static void sam_poll_work(FAR void *arg) { /* Update TCP timing states and poll the network for new XMIT data. */ - (void)devif_timer(dev, sam_txpoll); + (void)devif_timer(dev, SAM_WDDELAY, sam_txpoll); } /* Setup the watchdog poll timer again */ diff --git a/arch/arm/src/stm32/stm32_eth.c b/arch/arm/src/stm32/stm32_eth.c index 2f670b9f8bec4..929d32a4f165f 100644 --- a/arch/arm/src/stm32/stm32_eth.c +++ b/arch/arm/src/stm32/stm32_eth.c @@ -2275,7 +2275,7 @@ static void stm32_poll_work(FAR void *arg) /* Update TCP timing states and poll the network for new XMIT data. */ - (void)devif_timer(dev, stm32_txpoll); + (void)devif_timer(dev, STM32_WDDELAY, stm32_txpoll); /* We will, most likely end up with a buffer to be freed. But it * might not be the same one that we allocated above. diff --git a/arch/arm/src/stm32f7/stm32_ethernet.c b/arch/arm/src/stm32f7/stm32_ethernet.c index dfbf4fb5e2725..c35d05d3dff09 100644 --- a/arch/arm/src/stm32f7/stm32_ethernet.c +++ b/arch/arm/src/stm32f7/stm32_ethernet.c @@ -2380,7 +2380,7 @@ static void stm32_poll_work(void *arg) /* Update TCP timing states and poll the network for new XMIT data. */ - (void)devif_timer(dev, stm32_txpoll); + (void)devif_timer(dev, STM32_WDDELAY, stm32_txpoll); /* We will, most likely end up with a buffer to be freed. But it * might not be the same one that we allocated above. diff --git a/arch/arm/src/stm32h7/stm32_ethernet.c b/arch/arm/src/stm32h7/stm32_ethernet.c index 974fb90db35c8..4e445c5e37006 100644 --- a/arch/arm/src/stm32h7/stm32_ethernet.c +++ b/arch/arm/src/stm32h7/stm32_ethernet.c @@ -2469,7 +2469,7 @@ static void stm32_poll_work(void *arg) * data. */ - (void)devif_timer(dev, stm32_txpoll); + (void)devif_timer(dev, STM32_WDDELAY, stm32_txpoll); /* We will, most likely end up with a buffer to be freed. But it * might not be the same one that we allocated above. diff --git a/arch/arm/src/tiva/lm/lm3s_ethernet.c b/arch/arm/src/tiva/lm/lm3s_ethernet.c index a895259b201f3..ae73343e29437 100644 --- a/arch/arm/src/tiva/lm/lm3s_ethernet.c +++ b/arch/arm/src/tiva/lm/lm3s_ethernet.c @@ -1218,7 +1218,7 @@ static void tiva_poll_work(void *arg) * data. */ - (void)devif_timer(&priv->ld_dev, tiva_txpoll); + (void)devif_timer(&priv->ld_dev, TIVA_WDDELAY, tiva_txpoll); /* Setup the watchdog poll timer again */ diff --git a/arch/arm/src/tiva/tm4c/tm4c_ethernet.c b/arch/arm/src/tiva/tm4c/tm4c_ethernet.c index 68d83f475e33f..87cc2d9d0eb59 100644 --- a/arch/arm/src/tiva/tm4c/tm4c_ethernet.c +++ b/arch/arm/src/tiva/tm4c/tm4c_ethernet.c @@ -2283,7 +2283,7 @@ static void tiva_poll_work(FAR void *arg) /* Update TCP timing states and poll the network for new XMIT data. */ - (void)devif_timer(dev, tiva_txpoll); + (void)devif_timer(dev, TIVA_WDDELAY, tiva_txpoll); /* We will, most likely end up with a buffer to be freed. But it * might not be the same one that we allocated above. diff --git a/arch/hc/src/m9s12/m9s12_ethernet.c b/arch/hc/src/m9s12/m9s12_ethernet.c index 0ccb7cb083d60..daeb76a541261 100644 --- a/arch/hc/src/m9s12/m9s12_ethernet.c +++ b/arch/hc/src/m9s12/m9s12_ethernet.c @@ -530,7 +530,7 @@ static void emac_polltimer(int argc, uint32_t arg, ...) * we will missing TCP time state updates? */ - (void)devif_timer(&priv->d_dev, emac_txpoll); + (void)devif_timer(&priv->d_dev, HCS12_WDDELAY, emac_txpoll); /* Setup the watchdog poll timer again */ diff --git a/arch/mips/src/pic32mx/pic32mx-ethernet.c b/arch/mips/src/pic32mx/pic32mx-ethernet.c index a2861146f7fbe..962dafb39410c 100644 --- a/arch/mips/src/pic32mx/pic32mx-ethernet.c +++ b/arch/mips/src/pic32mx/pic32mx-ethernet.c @@ -1278,7 +1278,7 @@ static void pic32mx_timerpoll(struct pic32mx_driver_s *priv) /* And perform the poll */ priv->pd_polling = true; - (void)devif_timer(&priv->pd_dev, pic32mx_txpoll); + (void)devif_timer(&priv->pd_dev, PIC32MX_WDDELAY, pic32mx_txpoll); /* Free any buffer left attached after the poll */ diff --git a/arch/mips/src/pic32mz/pic32mz-ethernet.c b/arch/mips/src/pic32mz/pic32mz-ethernet.c index 61c34c65d37ad..cf99a0b81f12b 100644 --- a/arch/mips/src/pic32mz/pic32mz-ethernet.c +++ b/arch/mips/src/pic32mz/pic32mz-ethernet.c @@ -1396,7 +1396,7 @@ static void pic32mz_timerpoll(struct pic32mz_driver_s *priv) /* And perform the poll */ priv->pd_polling = true; - (void)devif_timer(&priv->pd_dev, pic32mz_txpoll); + (void)devif_timer(&priv->pd_dev, PIC32MZ_WDDELAY, pic32mz_txpoll); /* Free any buffer left attached after the poll */ diff --git a/arch/misoc/src/common/misoc_net.c b/arch/misoc/src/common/misoc_net.c index 6a0dcde8f18e1..bf04034061fbd 100644 --- a/arch/misoc/src/common/misoc_net.c +++ b/arch/misoc/src/common/misoc_net.c @@ -770,7 +770,7 @@ static void misoc_net_poll_work(FAR void *arg) * progress, we will missing TCP time state updates? */ - (void)devif_timer(&priv->misoc_net_dev, misoc_net_txpoll); + (void)devif_timer(&priv->misoc_net_dev, MISOC_NET_WDDELAY, misoc_net_txpoll); /* Setup the watchdog poll timer again */ diff --git a/arch/renesas/src/rx65n/rx65n_eth.c b/arch/renesas/src/rx65n/rx65n_eth.c index 6ccec8acfd935..e3fced5c52b5f 100644 --- a/arch/renesas/src/rx65n/rx65n_eth.c +++ b/arch/renesas/src/rx65n/rx65n_eth.c @@ -2176,7 +2176,7 @@ static void rx65n_poll_work(FAR void *arg) /* Update TCP timing states and poll the network for new XMIT data. */ - (void)devif_timer(dev, rx65n_txpoll); + (void)devif_timer(dev, CLK_TCK, rx65n_txpoll); /* We will, most likely end up with a buffer to be freed. But it * might not be the same one that we allocated above. diff --git a/arch/sim/src/sim/up_netdriver.c b/arch/sim/src/sim/up_netdriver.c index aaa9631227965..8cca610a3d99e 100644 --- a/arch/sim/src/sim/up_netdriver.c +++ b/arch/sim/src/sim/up_netdriver.c @@ -322,7 +322,7 @@ void netdriver_loop(void) else if (timer_expired(&g_periodic_timer)) { timer_reset(&g_periodic_timer); - devif_timer(&g_sim_dev, sim_txpoll); + devif_timer(&g_sim_dev, MSEC2TICK(g_periodic_timer.interval), sim_txpoll); } sched_unlock(); diff --git a/arch/z80/src/ez80/ez80_emac.c b/arch/z80/src/ez80/ez80_emac.c index da40aa55de048..e0548ff88b22f 100644 --- a/arch/z80/src/ez80/ez80_emac.c +++ b/arch/z80/src/ez80/ez80_emac.c @@ -1928,7 +1928,7 @@ static void ez80emac_poll_work(FAR void *arg) /* Poll the network for new XMIT data */ net_lock(); - (void)devif_timer(&priv->dev, ez80emac_txpoll); + (void)devif_timer(&priv->dev, EMAC_WDDELAY, ez80emac_txpoll); /* Setup the watchdog poll timer again */ diff --git a/drivers/net/dm90x0.c b/drivers/net/dm90x0.c index f5598617052f5..fed10442e95d8 100644 --- a/drivers/net/dm90x0.c +++ b/drivers/net/dm90x0.c @@ -1416,7 +1416,7 @@ static void dm9x_poll_work(FAR void *arg) { /* If so, update TCP timing states and poll the network for new XMIT data */ - (void)devif_timer(&priv->dm_dev, dm9x_txpoll); + (void)devif_timer(&priv->dm_dev, DM9X_WDDELAY, dm9x_txpoll); } /* Setup the watchdog poll timer again */ diff --git a/drivers/net/enc28j60.c b/drivers/net/enc28j60.c index 299febe90f10c..857e893f74c1b 100644 --- a/drivers/net/enc28j60.c +++ b/drivers/net/enc28j60.c @@ -2005,7 +2005,7 @@ static void enc_pollworker(FAR void *arg) * is a transmit in progress, we will missing TCP time state updates? */ - (void)devif_timer(&priv->dev, enc_txpoll); + (void)devif_timer(&priv->dev, ENC_WDDELAY, enc_txpoll); } /* Release lock on the SPI bus and the network */ diff --git a/drivers/net/encx24j600.c b/drivers/net/encx24j600.c index e1d5f6a04beb6..6f69f72c3cb64 100644 --- a/drivers/net/encx24j600.c +++ b/drivers/net/encx24j600.c @@ -2157,7 +2157,7 @@ static void enc_pollworker(FAR void *arg) * is a transmit in progress, we will missing TCP time state updates? */ - (void)devif_timer(&priv->dev, enc_txpoll); + (void)devif_timer(&priv->dev, ENC_WDDELAY, enc_txpoll); } /* Release lock on the SPI bus and the network */ diff --git a/drivers/net/ftmac100.c b/drivers/net/ftmac100.c index 45d230a385269..978b3ac633c9d 100644 --- a/drivers/net/ftmac100.c +++ b/drivers/net/ftmac100.c @@ -1130,7 +1130,7 @@ static void ftmac100_poll_work(FAR void *arg) * progress, we will missing TCP time state updates? */ - (void)devif_timer(&priv->ft_dev, ftmac100_txpoll); + (void)devif_timer(&priv->ft_dev, FTMAC100_WDDELAY, ftmac100_txpoll); /* Setup the watchdog poll timer again */ diff --git a/drivers/net/lan91c111.c b/drivers/net/lan91c111.c index d80bfe6e6c4aa..80ccd2fcc4163 100644 --- a/drivers/net/lan91c111.c +++ b/drivers/net/lan91c111.c @@ -1027,7 +1027,7 @@ static void lan91c111_poll_work(FAR void *arg) * transmit in progress, we will missing TCP time state updates? */ - devif_timer(dev, lan91c111_txpoll); + devif_timer(dev, LAN91C111_WDDELAY, lan91c111_txpoll); } /* Setup the watchdog poll timer again */ diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c index 30c2183ceb71c..c90f70c7c8904 100644 --- a/drivers/net/loopback.c +++ b/drivers/net/loopback.c @@ -234,7 +234,7 @@ static void lo_poll_work(FAR void *arg) net_lock(); priv->lo_txdone = false; - (void)devif_timer(&priv->lo_dev, lo_txpoll); + (void)devif_timer(&priv->lo_dev, LO_WDDELAY, lo_txpoll); /* Was something received and looped back? */ diff --git a/drivers/net/rpmsgdrv.c b/drivers/net/rpmsgdrv.c index 4346b1c47f31c..8bb3f38572c5f 100644 --- a/drivers/net/rpmsgdrv.c +++ b/drivers/net/rpmsgdrv.c @@ -847,7 +847,7 @@ static void net_rpmsg_drv_poll_work(FAR void *arg) * progress, we will missing TCP time state updates? */ - devif_timer(dev, net_rpmsg_drv_txpoll); + devif_timer(dev, NET_RPMSG_DRV_WDDELAY, net_rpmsg_drv_txpoll); } /* Setup the watchdog poll timer again */ diff --git a/drivers/net/skeleton.c b/drivers/net/skeleton.c index 33bf32b59acd2..4933a5a745fa8 100644 --- a/drivers/net/skeleton.c +++ b/drivers/net/skeleton.c @@ -740,7 +740,7 @@ static void skel_poll_work(FAR void *arg) * progress, we will missing TCP time state updates? */ - (void)devif_timer(&priv->sk_dev, skel_txpoll); + (void)devif_timer(&priv->sk_dev, skeleton_WDDELAY, skel_txpoll); /* Setup the watchdog poll timer again */ diff --git a/drivers/net/slip.c b/drivers/net/slip.c index 1b85ff93db6b8..39fc1ca1bc646 100644 --- a/drivers/net/slip.c +++ b/drivers/net/slip.c @@ -494,7 +494,7 @@ static void slip_txtask(int argc, FAR char *argv[]) { /* Yes, perform the timer poll */ - (void)devif_timer(&priv->dev, slip_txpoll); + (void)devif_timer(&priv->dev, hsec * TICK_PER_HSEC, slip_txpoll); start_ticks += hsec * TICK_PER_HSEC; } else diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 43b8e61bd9c3f..d3205a707ce08 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -846,7 +846,7 @@ static void tun_poll_work(FAR void *arg) /* If so, poll the network for new XMIT data. */ priv->dev.d_buf = priv->read_buf; - (void)devif_timer(&priv->dev, tun_txpoll); + (void)devif_timer(&priv->dev, TUN_WDDELAY, tun_txpoll); } /* Setup the watchdog poll timer again */ diff --git a/drivers/usbdev/cdcecm.c b/drivers/usbdev/cdcecm.c index d769f5288fa58..986428814c5ac 100644 --- a/drivers/usbdev/cdcecm.c +++ b/drivers/usbdev/cdcecm.c @@ -699,7 +699,7 @@ static void cdcecm_poll_work(FAR void *arg) * become available. */ - (void)devif_timer(&self->dev, cdcecm_txpoll); + (void)devif_timer(&self->dev, CDCECM_WDDELAY, cdcecm_txpoll); /* Setup the watchdog poll timer again */ diff --git a/drivers/usbdev/rndis.c b/drivers/usbdev/rndis.c index a185f802d6855..4c2ea244eefe9 100644 --- a/drivers/usbdev/rndis.c +++ b/drivers/usbdev/rndis.c @@ -1064,7 +1064,7 @@ static void rndis_pollworker(FAR void *arg) if (rndis_allocnetreq(priv)) { - devif_timer(&priv->netdev, rndis_txpoll); + devif_timer(&priv->netdev, RNDIS_WDDELAY, rndis_txpoll); if (priv->net_req != NULL) { diff --git a/drivers/wireless/ieee80211/bcm43xxx/bcmf_netdev.c b/drivers/wireless/ieee80211/bcm43xxx/bcmf_netdev.c index 01f0abd1dffa8..33b10e4e955e2 100644 --- a/drivers/wireless/ieee80211/bcm43xxx/bcmf_netdev.c +++ b/drivers/wireless/ieee80211/bcm43xxx/bcmf_netdev.c @@ -618,7 +618,7 @@ static void bcmf_poll_work(FAR void *arg) priv->bc_dev.d_buf = priv->cur_tx_frame->data; priv->bc_dev.d_len = 0; - (void)devif_timer(&priv->bc_dev, bcmf_txpoll); + (void)devif_timer(&priv->bc_dev, BCMF_WDDELAY, bcmf_txpoll); /* Setup the watchdog poll timer again */ diff --git a/drivers/wireless/ieee802154/xbee/xbee_netdev.c b/drivers/wireless/ieee802154/xbee/xbee_netdev.c index e04505786c04a..913efbd81c443 100644 --- a/drivers/wireless/ieee802154/xbee/xbee_netdev.c +++ b/drivers/wireless/ieee802154/xbee/xbee_netdev.c @@ -611,7 +611,7 @@ static void xbeenet_txpoll_work(FAR void *arg) /* Then perform the poll */ - (void)devif_timer(&priv->xd_dev.r_dev, xbeenet_txpoll_callback); + (void)devif_timer(&priv->xd_dev.r_dev, TXPOLL_WDDELAY, xbeenet_txpoll_callback); /* Setup the watchdog poll timer again */ diff --git a/drivers/wireless/spirit/drivers/spirit_netdev.c b/drivers/wireless/spirit/drivers/spirit_netdev.c index f7274d8ebd82a..a06e522cddcb5 100644 --- a/drivers/wireless/spirit/drivers/spirit_netdev.c +++ b/drivers/wireless/spirit/drivers/spirit_netdev.c @@ -1812,7 +1812,7 @@ static void spirit_txpoll_work(FAR void *arg) /* Perform the periodic poll */ priv->needpoll = false; - (void)devif_timer(&priv->radio.r_dev, spirit_txpoll_callback); + (void)devif_timer(&priv->radio.r_dev, SPIRIT_WDDELAY, spirit_txpoll_callback); /* Setup the watchdog poll timer again */ diff --git a/include/nuttx/net/netdev.h b/include/nuttx/net/netdev.h index c1afccc6147d0..e14f0fa982e3b 100644 --- a/include/nuttx/net/netdev.h +++ b/include/nuttx/net/netdev.h @@ -544,7 +544,7 @@ int sixlowpan_input(FAR struct radio_driver_s *ieee, ****************************************************************************/ int devif_poll(FAR struct net_driver_s *dev, devif_poll_callback_t callback); -int devif_timer(FAR struct net_driver_s *dev, devif_poll_callback_t callback); +int devif_timer(FAR struct net_driver_s *dev, int delay, devif_poll_callback_t callback); /**************************************************************************** * Name: neighbor_out diff --git a/net/devif/devif.h b/net/devif/devif.h index 8890ec5d29585..f3aef4e4dce44 100644 --- a/net/devif/devif.h +++ b/net/devif/devif.h @@ -281,10 +281,6 @@ extern "C" EXTERN uint8_t g_reassembly_timer; #endif -/* Time of last poll */ - -EXTERN clock_t g_polltime; - /**************************************************************************** * Public Function Prototypes ****************************************************************************/ diff --git a/net/devif/devif_initialize.c b/net/devif/devif_initialize.c index 864baa64b85d0..edd8bdd6a3fdb 100644 --- a/net/devif/devif_initialize.c +++ b/net/devif/devif_initialize.c @@ -44,9 +44,6 @@ #include #ifdef CONFIG_NET -#include - -#include #include #include "devif/devif.h" @@ -95,10 +92,6 @@ uint8_t g_reassembly_timer; void devif_initialize(void) { - /* Initialize the time of the last timer poll */ - - g_polltime = clock_systimer(); - /* Initialize callback support */ devif_callback_init(); diff --git a/net/devif/devif_poll.c b/net/devif/devif_poll.c index 4fb74ff36b179..62f21f930b10b 100644 --- a/net/devif/devif_poll.c +++ b/net/devif/devif_poll.c @@ -76,14 +76,6 @@ enum devif_packet_type DEVIF_ICMP6 }; -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/* Time of last poll */ - -clock_t g_polltime; - /**************************************************************************** * Private Functions ****************************************************************************/ @@ -770,55 +762,28 @@ int devif_poll(FAR struct net_driver_s *dev, devif_poll_callback_t callback) * ****************************************************************************/ -int devif_timer(FAR struct net_driver_s *dev, devif_poll_callback_t callback) +int devif_timer(FAR struct net_driver_s *dev, int delay, devif_poll_callback_t callback) { - clock_t now; - clock_t elapsed; + int hsec = TICK2HSEC(delay); int bstop = false; - /* Get the elapsed time since the last poll in units of half seconds - * (truncating). - */ - - now = clock_systimer(); - elapsed = now - g_polltime; - - /* Process time-related events only when more than one half second elapses. */ - - if (elapsed >= TICK_PER_HSEC) - { - /* Calculate the elpased time in units of half seconds (truncating to - * number of whole half seconds). - */ - - int hsec = (int)(elapsed / TICK_PER_HSEC); - - /* Update the current poll time (truncating to the last half second - * boundary to avoid error build-up). - */ - - g_polltime += (TICK_PER_HSEC * (clock_t)hsec); - - /* Perform periodic activitives that depend on hsec > 0 */ - #ifdef CONFIG_NET_IPv4_REASSEMBLY - /* Increment the timer used by the IP reassembly logic */ + /* Increment the timer used by the IP reassembly logic */ - if (g_reassembly_timer != 0 && - g_reassembly_timer < CONFIG_NET_IPv4_REASS_MAXAGE) - { - g_reassembly_timer += hsec; - } + if (g_reassembly_timer != 0 && + g_reassembly_timer < CONFIG_NET_IPv4_REASS_MAXAGE) + { + g_reassembly_timer += hsec; + } #endif #ifdef NET_TCP_HAVE_STACK - /* Traverse all of the active TCP connections and perform the - * timer action. - */ + /* Traverse all of the active TCP connections and perform the + * timer action. + */ - bstop = devif_poll_tcp_timer(dev, callback, hsec); + bstop = devif_poll_tcp_timer(dev, callback, hsec); #endif - } /* If possible, continue with a normal poll checking for pending * network driver actions. diff --git a/wireless/bluetooth/bt_netdev.c b/wireless/bluetooth/bt_netdev.c index 3f9536673b8f9..45c92ce9b137c 100644 --- a/wireless/bluetooth/bt_netdev.c +++ b/wireless/bluetooth/bt_netdev.c @@ -542,7 +542,7 @@ static void btnet_txpoll_work(FAR void *arg) /* Then perform the poll */ - (void)devif_timer(&priv->bd_dev.r_dev, btnet_txpoll_callback); + (void)devif_timer(&priv->bd_dev.r_dev, TXPOLL_WDDELAY, btnet_txpoll_callback); /* Setup the watchdog poll timer again */ diff --git a/wireless/ieee802154/mac802154_loopback.c b/wireless/ieee802154/mac802154_loopback.c index 84c3cd332a685..691de619e41be 100644 --- a/wireless/ieee802154/mac802154_loopback.c +++ b/wireless/ieee802154/mac802154_loopback.c @@ -476,7 +476,7 @@ static void lo_poll_work(FAR void *arg) /* Then perform the poll */ - (void)devif_timer(&priv->lo_radio.r_dev, lo_loopback); + (void)devif_timer(&priv->lo_radio.r_dev, LO_WDDELAY, lo_loopback); /* Setup the watchdog poll timer again */ diff --git a/wireless/ieee802154/mac802154_netdev.c b/wireless/ieee802154/mac802154_netdev.c index c3becd7378ce7..7c0f025e20bc2 100644 --- a/wireless/ieee802154/mac802154_netdev.c +++ b/wireless/ieee802154/mac802154_netdev.c @@ -579,7 +579,7 @@ static void macnet_txpoll_work(FAR void *arg) /* Then perform the poll */ - (void)devif_timer(&priv->md_dev.r_dev, macnet_txpoll_callback); + (void)devif_timer(&priv->md_dev.r_dev, TXPOLL_WDDELAY, macnet_txpoll_callback); /* Setup the watchdog poll timer again */ diff --git a/wireless/pktradio/pktradio_loopback.c b/wireless/pktradio/pktradio_loopback.c index 79b5b51e1da9a..96e043d83d4de 100644 --- a/wireless/pktradio/pktradio_loopback.c +++ b/wireless/pktradio/pktradio_loopback.c @@ -434,7 +434,7 @@ static void lo_poll_work(FAR void *arg) /* And perform the poll */ - (void)devif_timer(&priv->lo_radio.r_dev, lo_loopback); + (void)devif_timer(&priv->lo_radio.r_dev, LO_WDDELAY, lo_loopback); /* Setup the watchdog poll timer again */