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
+5 -1
View File
@@ -11444,4 +11444,8 @@
these are MCU-specific interfaces used only be MCU-specific code. The these are MCU-specific interfaces used only be MCU-specific code. The
the correct naming is xyz_i2cbus_initialize and xzy_i2cbus_uninitialize the correct naming is xyz_i2cbus_initialize and xzy_i2cbus_uninitialize
where xzy is the MCU mnemonic (2016-02-02). 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).
+1 -1
Submodule arch updated: be6af64502...757fb2224a
+1 -2
View File
@@ -76,7 +76,6 @@
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */ /* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */
#define CS89x0_WDDELAY (1*CLK_TCK) #define CS89x0_WDDELAY (1*CLK_TCK)
#define CS89x0_POLLHSEC (1*2)
/* TX timeout = 1 minute */ /* 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 */ /* 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 */ /* Setup the watchdog poll timer again */
+1 -2
View File
@@ -266,7 +266,6 @@
/* TX poll deley = 1 seconds. CLK_TCK is the number of clock ticks per second */ /* TX poll deley = 1 seconds. CLK_TCK is the number of clock ticks per second */
#define DM6X_WDDELAY (1*CLK_TCK) #define DM6X_WDDELAY (1*CLK_TCK)
#define DM6X_POLLHSEC (1*2)
/* TX timeout = 1 minute */ /* 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 */ /* 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 */ /* Setup the watchdog poll timer again */
+1 -2
View File
@@ -78,7 +78,6 @@
/* TX poll deley = 1 seconds. CLK_TCK is the number of clock ticks per second */ /* TX poll deley = 1 seconds. CLK_TCK is the number of clock ticks per second */
#define E1000_WDDELAY (1*CLK_TCK) #define E1000_WDDELAY (1*CLK_TCK)
#define E1000_POLLHSEC (1*2)
/* TX timeout = 1 minute */ /* TX timeout = 1 minute */
@@ -770,7 +769,7 @@ static void e1000_polltimer(int argc, uint32_t arg, ...)
* we will missing TCP time state updates? * 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 */ /* Setup the watchdog poll timer again */
+1 -2
View File
@@ -144,7 +144,6 @@
/* TX poll deley = 1 seconds. CLK_TCK is the number of clock ticks per second */ /* TX poll deley = 1 seconds. CLK_TCK is the number of clock ticks per second */
#define ENC_WDDELAY (1*CLK_TCK) #define ENC_WDDELAY (1*CLK_TCK)
#define ENC_POLLHSEC (1*2)
/* TX timeout = 1 minute */ /* TX timeout = 1 minute */
@@ -1990,7 +1989,7 @@ static void enc_pollworker(FAR void *arg)
* in progress, we will missing TCP time state updates? * 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 */ /* Release lock on the SPI bus and uIP */
+1 -2
View File
@@ -149,7 +149,6 @@
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */ /* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */
#define ENC_WDDELAY (1*CLK_TCK) #define ENC_WDDELAY (1*CLK_TCK)
#define ENC_POLLHSEC (1*2)
/* TX timeout = 1 minute */ /* TX timeout = 1 minute */
@@ -2156,7 +2155,7 @@ static void enc_pollworker(FAR void *arg)
* in progress, we will missing TCP time state updates? * 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 */ /* Release lock on the SPI bus and uIP */
+1 -2
View File
@@ -91,7 +91,6 @@
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */ /* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */
#define FTMAC100_WDDELAY (1*CLK_TCK) #define FTMAC100_WDDELAY (1*CLK_TCK)
#define FTMAC100_POLLHSEC (1*2)
/* TX timeout = 1 minute */ /* 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? * 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 */ /* Setup the watchdog poll timer again */
+1 -2
View File
@@ -78,7 +78,6 @@
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */ /* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */
#define LO_WDDELAY (1*CLK_TCK) #define LO_WDDELAY (1*CLK_TCK)
#define LO_POLLHSEC (1*2)
/* This is a helper pointer for accessing the contents of the Ethernet header */ /* 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(); state = net_lock();
priv->lo_txdone = false; 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? */ /* Was something received and looped back? */
+1 -2
View File
@@ -86,7 +86,6 @@
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */ /* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */
#define skeleton_WDDELAY (1*CLK_TCK) #define skeleton_WDDELAY (1*CLK_TCK)
#define skeleton_POLLHSEC (1*2)
/* TX timeout = 1 minute */ /* 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? * 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 */ /* Setup the watchdog poll timer again */
+1 -1
View File
@@ -490,7 +490,7 @@ static void slip_txtask(int argc, FAR char *argv[])
{ {
/* Yes, perform the timer poll */ /* 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); msec_start += hsec * (MSEC_PER_SEC / 2);
} }
else else
+1 -2
View File
@@ -96,7 +96,6 @@
*/ */
#define TUN_WDDELAY (1*CLK_TCK) #define TUN_WDDELAY (1*CLK_TCK)
#define TUN_POLLHSEC (1*2)
/**************************************************************************** /****************************************************************************
* Private Types * 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. */ /* If so, poll uIP for new XMIT data. */
priv->dev.d_buf = priv->read_buf; 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 */ /* Setup the watchdog poll timer again */
+1 -2
View File
@@ -81,7 +81,6 @@
/* TX poll deley = 1 seconds. CLK_TCK is the number of clock ticks per second */ /* TX poll deley = 1 seconds. CLK_TCK is the number of clock ticks per second */
#define VNET_WDDELAY (1*CLK_TCK) #define VNET_WDDELAY (1*CLK_TCK)
#define VNET_POLLHSEC (1*2)
/* TX timeout = 1 minute */ /* 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? * 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 */ /* Setup the watchdog poll timer again */
+16 -4
View File
@@ -99,16 +99,25 @@
/* Timing constants *********************************************************/ /* Timing constants *********************************************************/
#define NSEC_PER_SEC 1000000000L #define NSEC_PER_SEC 1000000000L /* Seconds */
#define USEC_PER_SEC 1000000L #define USEC_PER_SEC 1000000L
#define MSEC_PER_SEC 1000L #define MSEC_PER_SEC 1000L
#define DSEC_PER_SEC 10L #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 USEC_PER_DSEC 100000L
#define MSEC_PER_DSEC 100L #define MSEC_PER_DSEC 100L
#define NSEC_PER_MSEC 1000000L
#define NSEC_PER_MSEC 1000000L /* Milliseconds */
#define USEC_PER_MSEC 1000L #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 /* 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 * 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_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_SEC (USEC_PER_SEC / USEC_PER_TICK) /* Truncates! */
#define TICK_PER_MSEC (USEC_PER_MSEC / 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! */ #define MSEC_PER_TICK (USEC_PER_TICK / USEC_PER_MSEC) /* Truncates! */
@@ -151,6 +161,7 @@
#endif #endif
#define DSEC2TICK(dsec) MSEC2TICK((dsec) * MSEC_PER_DSEC) /* Rounds */ #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 SEC2TICK(sec) MSEC2TICK((sec) * MSEC_PER_SEC) /* Rounds */
#define TICK2NSEC(tick) ((tick) * NSEC_PER_TICK) /* Exact */ #define TICK2NSEC(tick) ((tick) * NSEC_PER_TICK) /* Exact */
@@ -163,6 +174,7 @@
#endif #endif
#define TICK2DSEC(tick) (((tick)+(TICK_PER_DSEC/2))/TICK_PER_DSEC) /* Rounds */ #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 */ #define TICK2SEC(tick) (((tick)+(TICK_PER_SEC/2))/TICK_PER_SEC) /* Rounds */
/**************************************************************************** /****************************************************************************
+2 -3
View File
@@ -2,7 +2,7 @@
* include/nuttx/net/netdev.h * include/nuttx/net/netdev.h
* Defines architecture-specific device driver interfaces to the uIP network. * 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> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Derived largely from portions of uIP with has a similar BSD-styple license: * 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_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, devif_poll_callback_t callback);
int hsec);
/**************************************************************************** /****************************************************************************
* Name: neighbor_out * Name: neighbor_out
-8
View File
@@ -48,14 +48,6 @@
#ifdef CONFIG_NET_ARP_SEND #ifdef CONFIG_NET_ARP_SEND
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
+5
View File
@@ -51,6 +51,7 @@
#include <errno.h> #include <errno.h>
#include <arch/irq.h> #include <arch/irq.h>
#include <nuttx/clock.h>
#include <nuttx/net/ip.h> #include <nuttx/net/ip.h>
/**************************************************************************** /****************************************************************************
@@ -256,6 +257,10 @@ extern uint16_t g_ipid;
extern uint8_t g_reassembly_timer; extern uint8_t g_reassembly_timer;
#endif #endif
/* Time of last poll */
extern systime_t g_polltime;
/**************************************************************************** /****************************************************************************
* Public Function Prototypes * Public Function Prototypes
****************************************************************************/ ****************************************************************************/
+5 -8
View File
@@ -46,6 +46,7 @@
#include <stdint.h> #include <stdint.h>
#include <nuttx/clock.h>
#include <nuttx/net/netstats.h> #include <nuttx/net/netstats.h>
#include <nuttx/net/ip.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_ICMPv6_AUTOCONF || CONFIG_NET_ICMPv6_ROUTER */
#endif /* CONFIG_NET_IPv4 */ #endif /* CONFIG_NET_IPv4 */
/****************************************************************************
* Private Variables
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -167,6 +160,10 @@ const struct ether_addr g_ipv6_ethallrouters = /* All link local routers */
void devif_initialize(void) void devif_initialize(void)
{ {
/* Initialize the time of the last timer poll */
g_polltime = clock_systimer();
/* Initialize callback support */ /* Initialize callback support */
devif_callback_init(); devif_callback_init();
+54 -19
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* net/devif/devif_poll.c * 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> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -42,6 +42,7 @@
#include <debug.h> #include <debug.h>
#include <nuttx/clock.h>
#include <nuttx/net/netconfig.h> #include <nuttx/net/netconfig.h>
#include <nuttx/net/netdev.h> #include <nuttx/net/netdev.h>
@@ -56,9 +57,13 @@
#include "igmp/igmp.h" #include "igmp/igmp.h"
/**************************************************************************** /****************************************************************************
* Private Data * Public Data
****************************************************************************/ ****************************************************************************/
/* Time of last poll */
systime_t g_polltime;
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
@@ -258,22 +263,30 @@ static inline int devif_poll_tcp_connections(FAR struct net_driver_s *dev,
#ifdef CONFIG_NET_TCP #ifdef CONFIG_NET_TCP
static inline int devif_poll_tcp_timer(FAR struct net_driver_s *dev, 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; FAR struct tcp_conn_s *conn = NULL;
int bstop = 0; 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; 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 devif_timer(FAR struct net_driver_s *dev, devif_poll_callback_t callback)
int hsec)
{ {
systime_t now;
systime_t elpased;
int bstop = false; 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 defined(CONFIG_NET_TCP_REASSEMBLY) && defined(CONFIG_NET_IPv4)
if (g_reassembly_timer != 0 && /* Increment the timer used by the IP reassembly logic */
g_reassembly_timer < CONFIG_NET_TCP_REASS_MAXAGE)
{ if (g_reassembly_timer != 0 &&
g_reassembly_timer += hsec; g_reassembly_timer < CONFIG_NET_TCP_REASS_MAXAGE)
} {
g_reassembly_timer += hsec;
}
#endif #endif
#ifdef CONFIG_NET_IPv6 #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 #endif
}
/* Traverse all of the active packet connections and perform the poll /* Traverse all of the active packet connections and perform the poll
* action. * 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 /* Traverse all of the active TCP connections and perform the
* timer action. * timer action.
*
* NOTE: devif_poll_tcp_timer will handle the case where hsec <= 0.
*/ */
bstop = devif_poll_tcp_timer(dev, callback, hsec); bstop = devif_poll_tcp_timer(dev, callback, hsec);
+3 -27
View File
@@ -99,16 +99,12 @@ struct neighbor_entry
extern struct neighbor_entry g_neighbors[CONFIG_NET_IPv6_NCONF_ENTRIES]; 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 * Public Function Prototypes
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Name: neighbor_setup * Name: neighbor_initialize
* *
* Description: * Description:
* Initialize Neighbor table data structures. This function is called * 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); void neighbor_initialize(void);
/**************************************************************************** /****************************************************************************
@@ -226,14 +202,14 @@ void neighbor_update(const net_ipv6addr_t ipaddr);
* entries in the Neighbor Table * entries in the Neighbor Table
* *
* Input Parameters: * Input Parameters:
* None * hsec - Elapsed time in half seconds since the last check
* *
* Returned Value: * Returned Value:
* None * None
* *
****************************************************************************/ ****************************************************************************/
void neighbor_periodic(void); void neighbor_periodic(int hsec);
#endif /* CONFIG_NET_IPv6 */ #endif /* CONFIG_NET_IPv6 */
#endif /* __NET_NEIGHBOR_NEIGHBOR_H */ #endif /* __NET_NEIGHBOR_NEIGHBOR_H */
+2 -31
View File
@@ -56,16 +56,12 @@
struct neighbor_entry g_neighbors[CONFIG_NET_IPv6_NCONF_ENTRIES]; 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 * Public Functions
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Name: neighbor_setup * Name: neighbor_initialize
* *
* Description: * Description:
* Initialize Neighbor table data structures. This function is called * 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; int i;
@@ -90,28 +86,3 @@ void neighbor_setup(void)
g_neighbors[i].ne_time = NEIGHBOR_MAXTIME; 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();
}
+18 -35
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* net/neighbor/neighbor_periodic.c * 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> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* A leverage of logic from uIP which also has a BSD style license * A leverage of logic from uIP which also has a BSD style license
@@ -42,18 +42,9 @@
****************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <nuttx/clock.h>
#include "neighbor/neighbor.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 * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -66,42 +57,34 @@
* entries in the Neighbor Table * entries in the Neighbor Table
* *
* Input Parameters: * Input Parameters:
* None * hsec - Elapsed time in half seconds since the last check
* *
* Returned Value: * Returned Value:
* None * None
* *
****************************************************************************/ ****************************************************************************/
void neighbor_periodic(void) void neighbor_periodic(int hsec)
{ {
systime_t now;
systime_t ticks;
uint32_t hsecs;
int i; 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(); if (hsec > 0)
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)
{ {
uint32_t newtime = g_neighbors[i].ne_time + hsecs; /* Add the elapsed half seconds from each activate entry in the
if (newtime > NEIGHBOR_MAXTIME) * Neighbor table.
{ */
newtime = NEIGHBOR_MAXTIME;
}
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;
}
} }
} }
+1 -7
View File
@@ -118,7 +118,7 @@ void net_setup(void)
#ifdef CONFIG_NET_IPv6 #ifdef CONFIG_NET_IPv6
/* Initialize the Neighbor Table data structures */ /* Initialize the Neighbor Table data structures */
neighbor_setup(); neighbor_initialize();
#endif #endif
#ifdef CONFIG_NET_IOB #ifdef CONFIG_NET_IOB
@@ -197,12 +197,6 @@ void net_setup(void)
void net_initialize(void) void net_initialize(void)
{ {
#ifdef CONFIG_NET_IPv6
/* Configure Neighbor Table ageing */
neighbor_initialize();
#endif
/* Initialize the periodic ARP timer */ /* Initialize the periodic ARP timer */
arp_timer_initialize(); arp_timer_initialize();