net: if: Refactor because of timeout overhaul
Convert to use k_timeout_t Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
e56fa75ade
commit
63a7b92fd8
2 changed files with 25 additions and 21 deletions
|
@ -25,7 +25,7 @@ LOG_MODULE_REGISTER(net_if, CONFIG_NET_IF_LOG_LEVEL);
|
|||
|
||||
#include "net_stats.h"
|
||||
|
||||
#define REACHABLE_TIME K_SECONDS(30) /* in ms */
|
||||
#define REACHABLE_TIME (MSEC_PER_SEC * 30) /* in ms */
|
||||
/*
|
||||
* split the min/max random reachable factors into numerator/denominator
|
||||
* so that integer-based math works better
|
||||
|
@ -598,13 +598,13 @@ static void iface_router_run_timer(u32_t current_time)
|
|||
SYS_SLIST_FOR_EACH_CONTAINER_SAFE(&active_router_timers,
|
||||
router, next, node) {
|
||||
u32_t current_timer = router->life_start +
|
||||
K_SECONDS(router->lifetime) - current_time;
|
||||
(MSEC_PER_SEC * router->lifetime) - current_time;
|
||||
|
||||
new_timer = MIN(current_timer, new_timer);
|
||||
}
|
||||
|
||||
if (new_timer != UINT_MAX) {
|
||||
k_delayed_work_submit(&router_timer, new_timer);
|
||||
k_delayed_work_submit(&router_timer, K_MSEC(new_timer));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -620,7 +620,8 @@ static void iface_router_expired(struct k_work *work)
|
|||
router, next, node) {
|
||||
|
||||
if ((s32_t)(router->life_start +
|
||||
K_SECONDS(router->lifetime) - current_time) > 0) {
|
||||
(MSEC_PER_SEC * router->lifetime) -
|
||||
current_time) > 0) {
|
||||
/* We have to loop on all active routers as their
|
||||
* lifetime differ from each other.
|
||||
*/
|
||||
|
@ -881,7 +882,7 @@ static void join_mcast_nodes(struct net_if *iface, struct in6_addr *addr)
|
|||
#endif /* CONFIG_NET_IPV6_MLD */
|
||||
|
||||
#if defined(CONFIG_NET_IPV6_DAD)
|
||||
#define DAD_TIMEOUT K_MSEC(100)
|
||||
#define DAD_TIMEOUT 100 /* ms */
|
||||
|
||||
static void dad_timeout(struct k_work *work)
|
||||
{
|
||||
|
@ -932,8 +933,8 @@ static void dad_timeout(struct k_work *work)
|
|||
|
||||
if (ifaddr) {
|
||||
k_delayed_work_submit(&dad_timer,
|
||||
ifaddr->dad_start +
|
||||
DAD_TIMEOUT - current_time);
|
||||
K_MSEC(ifaddr->dad_start +
|
||||
DAD_TIMEOUT - current_time));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -958,7 +959,8 @@ static void net_if_ipv6_start_dad(struct net_if *iface,
|
|||
sys_slist_append(&active_dad_timers, &ifaddr->dad_node);
|
||||
|
||||
if (!k_delayed_work_remaining_get(&dad_timer)) {
|
||||
k_delayed_work_submit(&dad_timer, DAD_TIMEOUT);
|
||||
k_delayed_work_submit(&dad_timer,
|
||||
K_MSEC(DAD_TIMEOUT));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -1046,7 +1048,7 @@ static inline void net_if_ipv6_start_dad(struct net_if *iface,
|
|||
#endif /* CONFIG_NET_IPV6_DAD */
|
||||
|
||||
#if defined(CONFIG_NET_IPV6_ND)
|
||||
#define RS_TIMEOUT K_SECONDS(1)
|
||||
#define RS_TIMEOUT (1 * MSEC_PER_SEC)
|
||||
#define RS_COUNT 3
|
||||
|
||||
static void rs_timeout(struct k_work *work)
|
||||
|
@ -1091,8 +1093,8 @@ static void rs_timeout(struct k_work *work)
|
|||
|
||||
if (ipv6) {
|
||||
k_delayed_work_submit(&rs_timer,
|
||||
ipv6->rs_start +
|
||||
RS_TIMEOUT - current_time);
|
||||
K_MSEC(ipv6->rs_start +
|
||||
RS_TIMEOUT - current_time));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1111,7 +1113,7 @@ void net_if_start_rs(struct net_if *iface)
|
|||
sys_slist_append(&active_rs_timers, &ipv6->rs_node);
|
||||
|
||||
if (!k_delayed_work_remaining_get(&rs_timer)) {
|
||||
k_delayed_work_submit(&rs_timer, RS_TIMEOUT);
|
||||
k_delayed_work_submit(&rs_timer, K_MSEC(RS_TIMEOUT));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1320,7 +1322,8 @@ static void address_lifetime_timeout(struct k_work *work)
|
|||
|
||||
NET_DBG("Waiting for %d ms", (s32_t)timeout_update);
|
||||
|
||||
k_delayed_work_submit(&address_lifetime_timer, timeout_update);
|
||||
k_delayed_work_submit(&address_lifetime_timer,
|
||||
K_MSEC(timeout_update));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1342,10 +1345,10 @@ static void address_submit_work(struct net_if_addr *ifaddr)
|
|||
|
||||
if (ifaddr->lifetime.wrap_counter > 0 && remaining == 0) {
|
||||
k_delayed_work_submit(&address_lifetime_timer,
|
||||
NET_TIMEOUT_MAX_VALUE);
|
||||
K_MSEC(NET_TIMEOUT_MAX_VALUE));
|
||||
} else {
|
||||
k_delayed_work_submit(&address_lifetime_timer,
|
||||
ifaddr->lifetime.timer_timeout);
|
||||
K_MSEC(ifaddr->lifetime.timer_timeout));
|
||||
}
|
||||
|
||||
NET_DBG("Next wakeup in %d ms",
|
||||
|
@ -1355,7 +1358,7 @@ static void address_submit_work(struct net_if_addr *ifaddr)
|
|||
|
||||
static void address_start_timer(struct net_if_addr *ifaddr, u32_t vlifetime)
|
||||
{
|
||||
u64_t expire_timeout = K_SECONDS((u64_t)vlifetime);
|
||||
u64_t expire_timeout = (u64_t)MSEC_PER_SEC * (u64_t)vlifetime;
|
||||
|
||||
sys_slist_append(&active_address_lifetime_timers,
|
||||
&ifaddr->lifetime.node);
|
||||
|
@ -1880,7 +1883,8 @@ static void prefix_lifetime_timeout(struct k_work *work)
|
|||
|
||||
NET_DBG("Waiting for %d ms", (u32_t)timeout_update);
|
||||
|
||||
k_delayed_work_submit(&prefix_lifetime_timer, timeout_update);
|
||||
k_delayed_work_submit(&prefix_lifetime_timer,
|
||||
K_MSEC(timeout_update));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1895,10 +1899,10 @@ static void prefix_submit_work(struct net_if_ipv6_prefix *ifprefix)
|
|||
|
||||
if (ifprefix->lifetime.wrap_counter > 0 && remaining == 0) {
|
||||
k_delayed_work_submit(&prefix_lifetime_timer,
|
||||
NET_TIMEOUT_MAX_VALUE);
|
||||
K_MSEC(NET_TIMEOUT_MAX_VALUE));
|
||||
} else {
|
||||
k_delayed_work_submit(&prefix_lifetime_timer,
|
||||
ifprefix->lifetime.timer_timeout);
|
||||
K_MSEC(ifprefix->lifetime.timer_timeout));
|
||||
}
|
||||
|
||||
NET_DBG("Next wakeup in %d ms",
|
||||
|
@ -1909,7 +1913,7 @@ static void prefix_submit_work(struct net_if_ipv6_prefix *ifprefix)
|
|||
static void prefix_start_timer(struct net_if_ipv6_prefix *ifprefix,
|
||||
u32_t lifetime)
|
||||
{
|
||||
u64_t expire_timeout = K_SECONDS((u64_t)lifetime);
|
||||
u64_t expire_timeout = (u64_t)MSEC_PER_SEC * (u64_t)lifetime;
|
||||
|
||||
sys_slist_append(&active_prefix_lifetime_timers,
|
||||
&ifprefix->lifetime.node);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue