1
0
Fork 0
forked from nuttx/nuttx-update

Networking: Remove the HSEC argument from devif_timer.

This commit is contained in:
Gregory Nutt 2016-02-03 12:12:41 -06:00
parent ff1e057364
commit dea24c503a
23 changed files with 123 additions and 165 deletions

View file

@ -11444,4 +11444,8 @@
these are MCU-specific interfaces used only be MCU-specific code. The
the correct naming is xyz_i2cbus_initialize and xzy_i2cbus_uninitialize
where xzy is the MCU mnemonic (2016-02-02).
* Networking drivers that support CONFIG_NET_NOINTS: Fix a race condition
that can cause the TX poll timer to stop running. From Manuel Stuhn
(2016-02-03).
* All Network drivers: Remove the hsec parameter from devif_timer().
We can get better timing accuracy without it (2016-02-03).

2
arch

@ -1 +1 @@
Subproject commit be6af64502d5520799fcba3ed20b6fff13f88ca0
Subproject commit 757fb2224ae99916b8b46695a007a6be06f33dfb

View file

@ -76,7 +76,6 @@
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */
#define CS89x0_WDDELAY (1*CLK_TCK)
#define CS89x0_POLLHSEC (1*2)
/* TX timeout = 1 minute */
@ -790,7 +789,7 @@ static void cs89x0_polltimer(int argc, uint32_t arg, ...)
/* If so, update TCP timing states and poll uIP for new XMIT data */
(void)devif_timer(&cs89x0->cs_dev, cs89x0_txpoll, CS89x0_POLLHSEC);
(void)devif_timer(&cs89x0->cs_dev, cs89x0_txpoll);
/* Setup the watchdog poll timer again */

View file

@ -266,7 +266,6 @@
/* TX poll deley = 1 seconds. CLK_TCK is the number of clock ticks per second */
#define DM6X_WDDELAY (1*CLK_TCK)
#define DM6X_POLLHSEC (1*2)
/* TX timeout = 1 minute */
@ -1266,7 +1265,7 @@ static void dm9x_polltimer(int argc, uint32_t arg, ...)
{
/* If so, update TCP timing states and poll uIP for new XMIT data */
(void)devif_timer(&dm9x->dm_dev, dm9x_txpoll, DM6X_POLLHSEC);
(void)devif_timer(&dm9x->dm_dev, dm9x_txpoll);
}
/* Setup the watchdog poll timer again */

View file

@ -78,7 +78,6 @@
/* TX poll deley = 1 seconds. CLK_TCK is the number of clock ticks per second */
#define E1000_WDDELAY (1*CLK_TCK)
#define E1000_POLLHSEC (1*2)
/* TX timeout = 1 minute */
@ -770,7 +769,7 @@ static void e1000_polltimer(int argc, uint32_t arg, ...)
* we will missing TCP time state updates?
*/
(void)devif_timer(&e1000->netdev, e1000_txpoll, E1000_POLLHSEC);
(void)devif_timer(&e1000->netdev, e1000_txpoll);
/* Setup the watchdog poll timer again */

View file

@ -144,7 +144,6 @@
/* TX poll deley = 1 seconds. CLK_TCK is the number of clock ticks per second */
#define ENC_WDDELAY (1*CLK_TCK)
#define ENC_POLLHSEC (1*2)
/* TX timeout = 1 minute */
@ -1990,7 +1989,7 @@ static void enc_pollworker(FAR void *arg)
* in progress, we will missing TCP time state updates?
*/
(void)devif_timer(&priv->dev, enc_txpoll, ENC_POLLHSEC);
(void)devif_timer(&priv->dev, enc_txpoll);
}
/* Release lock on the SPI bus and uIP */

View file

@ -149,7 +149,6 @@
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */
#define ENC_WDDELAY (1*CLK_TCK)
#define ENC_POLLHSEC (1*2)
/* TX timeout = 1 minute */
@ -2156,7 +2155,7 @@ static void enc_pollworker(FAR void *arg)
* in progress, we will missing TCP time state updates?
*/
(void)devif_timer(&priv->dev, enc_txpoll, ENC_POLLHSEC);
(void)devif_timer(&priv->dev, enc_txpoll);
}
/* Release lock on the SPI bus and uIP */

View file

@ -91,7 +91,6 @@
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */
#define FTMAC100_WDDELAY (1*CLK_TCK)
#define FTMAC100_POLLHSEC (1*2)
/* TX timeout = 1 minute */
@ -1200,7 +1199,7 @@ static inline void ftmac100_poll_process(FAR struct ftmac100_driver_s *priv)
* we will missing TCP time state updates?
*/
(void)devif_timer(&priv->ft_dev, ftmac100_txpoll, FTMAC100_POLLHSEC);
(void)devif_timer(&priv->ft_dev, ftmac100_txpoll);
/* Setup the watchdog poll timer again */

View file

@ -78,7 +78,6 @@
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */
#define LO_WDDELAY (1*CLK_TCK)
#define LO_POLLHSEC (1*2)
/* This is a helper pointer for accessing the contents of the Ethernet header */
@ -242,7 +241,7 @@ static void lo_poll_work(FAR void *arg)
state = net_lock();
priv->lo_txdone = false;
(void)devif_timer(&priv->lo_dev, lo_txpoll, LO_POLLHSEC);
(void)devif_timer(&priv->lo_dev, lo_txpoll);
/* Was something received and looped back? */

View file

@ -86,7 +86,6 @@
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */
#define skeleton_WDDELAY (1*CLK_TCK)
#define skeleton_POLLHSEC (1*2)
/* TX timeout = 1 minute */
@ -746,7 +745,7 @@ static inline void skel_poll_process(FAR struct skel_driver_s *priv)
* progress, we will missing TCP time state updates?
*/
(void)devif_timer(&priv->sk_dev, skel_txpoll, skeleton_POLLHSEC);
(void)devif_timer(&priv->sk_dev, skel_txpoll);
/* Setup the watchdog poll timer again */

View file

@ -490,7 +490,7 @@ static void slip_txtask(int argc, FAR char *argv[])
{
/* Yes, perform the timer poll */
(void)devif_timer(&priv->dev, slip_txpoll, hsec);
(void)devif_timer(&priv->dev, slip_txpoll);
msec_start += hsec * (MSEC_PER_SEC / 2);
}
else

View file

@ -96,7 +96,6 @@
*/
#define TUN_WDDELAY (1*CLK_TCK)
#define TUN_POLLHSEC (1*2)
/****************************************************************************
* Private Types
@ -533,7 +532,7 @@ static void tun_poll_process(FAR struct tun_device_s *priv)
/* If so, poll uIP for new XMIT data. */
priv->dev.d_buf = priv->read_buf;
(void)devif_timer(&priv->dev, tun_txpoll, TUN_POLLHSEC);
(void)devif_timer(&priv->dev, tun_txpoll);
}
/* Setup the watchdog poll timer again */

View file

@ -81,7 +81,6 @@
/* TX poll deley = 1 seconds. CLK_TCK is the number of clock ticks per second */
#define VNET_WDDELAY (1*CLK_TCK)
#define VNET_POLLHSEC (1*2)
/* TX timeout = 1 minute */
@ -518,7 +517,7 @@ static void vnet_polltimer(int argc, uint32_t arg, ...)
* progress, we will missing TCP time state updates?
*/
(void)devif_timer(&vnet->sk_dev, vnet_txpoll, VNET_POLLHSEC);
(void)devif_timer(&vnet->sk_dev, vnet_txpoll);
/* Setup the watchdog poll timer again */

View file

@ -99,16 +99,25 @@
/* Timing constants *********************************************************/
#define NSEC_PER_SEC 1000000000L
#define NSEC_PER_SEC 1000000000L /* Seconds */
#define USEC_PER_SEC 1000000L
#define MSEC_PER_SEC 1000L
#define DSEC_PER_SEC 10L
#define NSEC_PER_DSEC 100000000L
#define HSEC_PER_SEC 2L
#define NSEC_PER_HSEC 500000000L /* Half seconds */
#define USEC_PER_HSEC 500000L
#define MSEC_PER_HSEC 500L
#define DSEC_PER_HSEC 5L
#define NSEC_PER_DSEC 100000000L /* Deciseconds */
#define USEC_PER_DSEC 100000L
#define MSEC_PER_DSEC 100L
#define NSEC_PER_MSEC 1000000L
#define NSEC_PER_MSEC 1000000L /* Milliseconds */
#define USEC_PER_MSEC 1000L
#define NSEC_PER_USEC 1000L
#define NSEC_PER_USEC 1000L /* Microseconds */
/* If CONFIG_SCHED_TICKLESS is not defined, then the interrupt interval of
* the system timer is given by USEC_PER_TICK. This is the expected number
@ -136,6 +145,7 @@
*/
#define TICK_PER_DSEC (USEC_PER_DSEC / USEC_PER_TICK) /* Truncates! */
#define TICK_PER_HSEC (USEC_PER_HSEC / USEC_PER_TICK) /* Truncates! */
#define TICK_PER_SEC (USEC_PER_SEC / USEC_PER_TICK) /* Truncates! */
#define TICK_PER_MSEC (USEC_PER_MSEC / USEC_PER_TICK) /* Truncates! */
#define MSEC_PER_TICK (USEC_PER_TICK / USEC_PER_MSEC) /* Truncates! */
@ -151,6 +161,7 @@
#endif
#define DSEC2TICK(dsec) MSEC2TICK((dsec) * MSEC_PER_DSEC) /* Rounds */
#define HSEC2TICK(dsec) MSEC2TICK((dsec) * MSEC_PER_HSEC) /* Rounds */
#define SEC2TICK(sec) MSEC2TICK((sec) * MSEC_PER_SEC) /* Rounds */
#define TICK2NSEC(tick) ((tick) * NSEC_PER_TICK) /* Exact */
@ -163,6 +174,7 @@
#endif
#define TICK2DSEC(tick) (((tick)+(TICK_PER_DSEC/2))/TICK_PER_DSEC) /* Rounds */
#define TICK2HSEC(tick) (((tick)+(TICK_PER_HSEC/2))/TICK_PER_HSEC) /* Rounds */
#define TICK2SEC(tick) (((tick)+(TICK_PER_SEC/2))/TICK_PER_SEC) /* Rounds */
/****************************************************************************

View file

@ -2,7 +2,7 @@
* include/nuttx/net/netdev.h
* Defines architecture-specific device driver interfaces to the uIP network.
*
* Copyright (C) 2007, 2009, 2011-2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2007, 2009, 2011-2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Derived largely from portions of uIP with has a similar BSD-styple license:
@ -475,8 +475,7 @@ int ipv6_input(FAR struct net_driver_s *dev);
****************************************************************************/
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 hsec);
int devif_timer(FAR struct net_driver_s *dev, devif_poll_callback_t callback);
/****************************************************************************
* Name: neighbor_out

View file

@ -48,14 +48,6 @@
#ifdef CONFIG_NET_ARP_SEND
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/

View file

@ -51,6 +51,7 @@
#include <errno.h>
#include <arch/irq.h>
#include <nuttx/clock.h>
#include <nuttx/net/ip.h>
/****************************************************************************
@ -256,6 +257,10 @@ extern uint16_t g_ipid;
extern uint8_t g_reassembly_timer;
#endif
/* Time of last poll */
extern systime_t g_polltime;
/****************************************************************************
* Public Function Prototypes
****************************************************************************/

View file

@ -46,6 +46,7 @@
#include <stdint.h>
#include <nuttx/clock.h>
#include <nuttx/net/netstats.h>
#include <nuttx/net/ip.h>
@ -139,14 +140,6 @@ const struct ether_addr g_ipv6_ethallrouters = /* All link local routers */
#endif /* CONFIG_NET_ICMPv6_AUTOCONF || CONFIG_NET_ICMPv6_ROUTER */
#endif /* CONFIG_NET_IPv4 */
/****************************************************************************
* Private Variables
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -167,6 +160,10 @@ const struct ether_addr g_ipv6_ethallrouters = /* All link local routers */
void devif_initialize(void)
{
/* Initialize the time of the last timer poll */
g_polltime = clock_systimer();
/* Initialize callback support */
devif_callback_init();

View file

@ -1,7 +1,7 @@
/****************************************************************************
* net/devif/devif_poll.c
*
* Copyright (C) 2007-2010, 2012, 2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2010, 2012, 2014, 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -42,6 +42,7 @@
#include <debug.h>
#include <nuttx/clock.h>
#include <nuttx/net/netconfig.h>
#include <nuttx/net/netdev.h>
@ -56,9 +57,13 @@
#include "igmp/igmp.h"
/****************************************************************************
* Private Data
* Public Data
****************************************************************************/
/* Time of last poll */
systime_t g_polltime;
/****************************************************************************
* Private Functions
****************************************************************************/
@ -258,22 +263,30 @@ static inline int devif_poll_tcp_connections(FAR struct net_driver_s *dev,
#ifdef CONFIG_NET_TCP
static inline int devif_poll_tcp_timer(FAR struct net_driver_s *dev,
devif_poll_callback_t callback, int hsec)
devif_poll_callback_t callback,
int hsec)
{
FAR struct tcp_conn_s *conn = NULL;
int bstop = 0;
/* Traverse all of the active TCP connections and perform the poll action */
/* Don't do anything is less a half second has elapsed */
while (!bstop && (conn = tcp_nextconn(conn)))
if (hsec > 0)
{
/* Perform the TCP timer poll */
/* Traverse all of the active TCP connections and perform the poll
* action.
*/
tcp_timer(dev, conn, hsec);
while (!bstop && (conn = tcp_nextconn(conn)))
{
/* Perform the TCP timer poll */
/* Call back into the driver */
tcp_timer(dev, conn, hsec);
bstop = callback(dev);
/* Call back into the driver */
bstop = callback(dev);
}
}
return bstop;
@ -414,26 +427,46 @@ 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 hsec)
int devif_timer(FAR struct net_driver_s *dev, devif_poll_callback_t callback)
{
systime_t now;
systime_t elpased;
int bstop = false;
int hsec;
/* Increment the timer used by the IP reassembly logic */
/* Get the elapsed time since the last poll in units of half seconds
* (truncating).
*/
now = clock_systimer();
hsec = (now - g_polltime) / TICK_PER_HSEC;
/* Update the time only when more than one half second elapses */
if (hsec > 0)
{
/* Save the current time */
g_polltime = now;
/* Perform periodic activitives that depend on hsec > 0 */
#if defined(CONFIG_NET_TCP_REASSEMBLY) && defined(CONFIG_NET_IPv4)
if (g_reassembly_timer != 0 &&
g_reassembly_timer < CONFIG_NET_TCP_REASS_MAXAGE)
{
g_reassembly_timer += hsec;
}
/* Increment the timer used by the IP reassembly logic */
if (g_reassembly_timer != 0 &&
g_reassembly_timer < CONFIG_NET_TCP_REASS_MAXAGE)
{
g_reassembly_timer += hsec;
}
#endif
#ifdef CONFIG_NET_IPv6
/* Perform ageing on the entries in the Neighbor Table */
/* Perform aging on the entries in the Neighbor Table */
neighbor_periodic();
neighbor_periodic(hsec);
#endif
}
/* Traverse all of the active packet connections and perform the poll
* action.
@ -467,6 +500,8 @@ int devif_timer(FAR struct net_driver_s *dev, devif_poll_callback_t callback,
{
/* Traverse all of the active TCP connections and perform the
* timer action.
*
* NOTE: devif_poll_tcp_timer will handle the case where hsec <= 0.
*/
bstop = devif_poll_tcp_timer(dev, callback, hsec);

View file

@ -99,16 +99,12 @@ struct neighbor_entry
extern struct neighbor_entry g_neighbors[CONFIG_NET_IPv6_NCONF_ENTRIES];
/* This is the time, in clock ticks, of the last poll */
extern systime_t g_neighbor_polltime;
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: neighbor_setup
* Name: neighbor_initialize
*
* Description:
* Initialize Neighbor table data structures. This function is called
@ -124,26 +120,6 @@ extern systime_t g_neighbor_polltime;
*
****************************************************************************/
void neighbor_setup(void);
/****************************************************************************
* Name: neighbor_initialize
*
* Description:
* Initialize Neighbor ageing. This function is called from the OS
* initialization logic at power-up reset AFTER initialization of hardware
* facilities such as timers and interrupts. This logic completes the
* initialization started by neighbor_setup.
*
*
* Input Parameters:
* None
*
* Returned Value:
* None
*
****************************************************************************/
void neighbor_initialize(void);
/****************************************************************************
@ -226,14 +202,14 @@ void neighbor_update(const net_ipv6addr_t ipaddr);
* entries in the Neighbor Table
*
* Input Parameters:
* None
* hsec - Elapsed time in half seconds since the last check
*
* Returned Value:
* None
*
****************************************************************************/
void neighbor_periodic(void);
void neighbor_periodic(int hsec);
#endif /* CONFIG_NET_IPv6 */
#endif /* __NET_NEIGHBOR_NEIGHBOR_H */

View file

@ -56,16 +56,12 @@
struct neighbor_entry g_neighbors[CONFIG_NET_IPv6_NCONF_ENTRIES];
/* This is the time, in clock ticks, of the last poll */
systime_t g_neighbor_polltime;
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: neighbor_setup
* Name: neighbor_initialize
*
* Description:
* Initialize Neighbor table data structures. This function is called
@ -81,7 +77,7 @@ systime_t g_neighbor_polltime;
*
****************************************************************************/
void neighbor_setup(void)
void neighbor_initialize(void)
{
int i;
@ -90,28 +86,3 @@ void neighbor_setup(void)
g_neighbors[i].ne_time = NEIGHBOR_MAXTIME;
}
}
/****************************************************************************
* Name: neighbor_initialize
*
* Description:
* Initialize Neighbor ageing. This function is called from the OS
* initialization logic at power-up reset AFTER initialization of hardware
* facilities such as timers and interrupts. This logic completes the
* initialization started by neighbor_setup.
*
*
* Input Parameters:
* None
*
* Returned Value:
* None
*
****************************************************************************/
void neighbor_initialize(void)
{
/* Initialize the time of the last poll */
g_neighbor_polltime = clock_systimer();
}

View file

@ -1,7 +1,7 @@
/****************************************************************************
* net/neighbor/neighbor_periodic.c
*
* Copyright (C) 2007-2009, 2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2009, 2015-2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* A leverage of logic from uIP which also has a BSD style license
@ -42,18 +42,9 @@
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/clock.h>
#include "neighbor/neighbor.h"
/****************************************************************************
* Public Functions
****************************************************************************/
#define USEC_PER_HSEC 500000
#define TICK_PER_HSEC (USEC_PER_HSEC / USEC_PER_TICK) /* Truncates! */
#define TICK2HSEC(tick) (((tick)+(TICK_PER_HSEC/2))/TICK_PER_HSEC) /* Rounds */
/****************************************************************************
* Public Functions
****************************************************************************/
@ -66,42 +57,34 @@
* entries in the Neighbor Table
*
* Input Parameters:
* None
* hsec - Elapsed time in half seconds since the last check
*
* Returned Value:
* None
*
****************************************************************************/
void neighbor_periodic(void)
void neighbor_periodic(int hsec)
{
systime_t now;
systime_t ticks;
uint32_t hsecs;
int i;
/* Get the elapsed time in units of half seconds */
/* Only perform the aging when more than a half second has elapsed */
now = clock_systimer();
ticks = now - g_neighbor_polltime;
hsecs = (uint32_t)TICK2HSEC(ticks);
/* Reset the time of the last poll */
g_neighbor_polltime = now;
/* Add the elapsed half seconds from each activate entry in the
* Neighbor table.
*/
for (i = 0; i < CONFIG_NET_IPv6_NCONF_ENTRIES; ++i)
if (hsec > 0)
{
uint32_t newtime = g_neighbors[i].ne_time + hsecs;
if (newtime > NEIGHBOR_MAXTIME)
{
newtime = NEIGHBOR_MAXTIME;
}
/* Add the elapsed half seconds from each activate entry in the
* Neighbor table.
*/
g_neighbors[i].ne_time = newtime;
for (i = 0; i < CONFIG_NET_IPv6_NCONF_ENTRIES; ++i)
{
uint32_t newtime = g_neighbors[i].ne_time + hsec;
if (newtime > NEIGHBOR_MAXTIME)
{
newtime = NEIGHBOR_MAXTIME;
}
g_neighbors[i].ne_time = newtime;
}
}
}

View file

@ -118,7 +118,7 @@ void net_setup(void)
#ifdef CONFIG_NET_IPv6
/* Initialize the Neighbor Table data structures */
neighbor_setup();
neighbor_initialize();
#endif
#ifdef CONFIG_NET_IOB
@ -197,12 +197,6 @@ void net_setup(void)
void net_initialize(void)
{
#ifdef CONFIG_NET_IPv6
/* Configure Neighbor Table ageing */
neighbor_initialize();
#endif
/* Initialize the periodic ARP timer */
arp_timer_initialize();