From 023c0984b3d31625cde7a7b9e06d5f62c22a2828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cenk=20G=C3=BCndo=C4=9Fan?= Date: Wed, 28 Oct 2015 21:03:09 +0100 Subject: [PATCH 1/4] sixlowpan: switch ltimer to be an xtimer --- sys/include/net/gnrc/sixlowpan/nd/router.h | 3 ++- .../sixlowpan/nd/router/gnrc_sixlowpan_nd_router.c | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/include/net/gnrc/sixlowpan/nd/router.h b/sys/include/net/gnrc/sixlowpan/nd/router.h index f1aee19406..8971f40803 100644 --- a/sys/include/net/gnrc/sixlowpan/nd/router.h +++ b/sys/include/net/gnrc/sixlowpan/nd/router.h @@ -70,7 +70,8 @@ typedef struct { uint16_t ltime; /**< the time in minutes until deletion */ BITFIELD(ctxs, GNRC_SIXLOWPAN_CTX_SIZE);/**< contexts associated with BR */ gnrc_sixlowpan_nd_router_prf_t *prfs; /**< prefixes associated with BR */ - vtimer_t ltimer; /**< timer for deletion */ + xtimer_t ltimer; /**< timer for deletion */ + msg_t ltimer_msg; /**< msg_t for gnrc_sixlowpan_nd_router_abr_t::ltimer */ } gnrc_sixlowpan_nd_router_abr_t; /** diff --git a/sys/net/gnrc/network_layer/sixlowpan/nd/router/gnrc_sixlowpan_nd_router.c b/sys/net/gnrc/network_layer/sixlowpan/nd/router/gnrc_sixlowpan_nd_router.c index 060863548a..a20a49b8e9 100644 --- a/sys/net/gnrc/network_layer/sixlowpan/nd/router/gnrc_sixlowpan_nd_router.c +++ b/sys/net/gnrc/network_layer/sixlowpan/nd/router/gnrc_sixlowpan_nd_router.c @@ -241,8 +241,10 @@ void gnrc_sixlowpan_nd_opt_abr_handle(kernel_pid_t iface, ndp_rtr_adv_t *rtr_adv t.seconds = abr->ltime * 60; - vtimer_set_msg(&abr->ltimer, t, gnrc_ipv6_pid, - GNRC_SIXLOWPAN_ND_MSG_ABR_TIMEOUT, abr); + xtimer_remove(&abr->ltimer); + abr->ltimer_msg.type = GNRC_SIXLOWPAN_ND_MSG_ABR_TIMEOUT; + abr->ltimer_msg.content.ptr = (char *) abr; + xtimer_set_msg(&abr->ltimer, (uint32_t) timex_uint64(t), &abr->ltimer_msg, gnrc_ipv6_pid); } gnrc_pktsnip_t *gnrc_sixlowpan_nd_opt_6ctx_build(uint8_t prefix_len, uint8_t flags, uint16_t ltime, From 3b825c2523bf51135f66129dd64d8fbcaa59b0d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cenk=20G=C3=BCndo=C4=9Fan?= Date: Wed, 28 Oct 2015 21:07:27 +0100 Subject: [PATCH 2/4] sixlowpan: use xtimer_now() instead of vtimer_now() --- .../sixlowpan/ctx/gnrc_sixlowpan_ctx.c | 5 ++--- sys/net/gnrc/network_layer/sixlowpan/frag/rbuf.c | 14 +++++--------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/sys/net/gnrc/network_layer/sixlowpan/ctx/gnrc_sixlowpan_ctx.c b/sys/net/gnrc/network_layer/sixlowpan/ctx/gnrc_sixlowpan_ctx.c index c1a186da2d..00717dfee8 100644 --- a/sys/net/gnrc/network_layer/sixlowpan/ctx/gnrc_sixlowpan_ctx.c +++ b/sys/net/gnrc/network_layer/sixlowpan/ctx/gnrc_sixlowpan_ctx.c @@ -18,6 +18,7 @@ #include "mutex.h" #include "net/gnrc/sixlowpan/ctx.h" #include "vtimer.h" +#include "xtimer.h" #define ENABLE_DEBUG (0) #include "debug.h" @@ -132,9 +133,7 @@ gnrc_sixlowpan_ctx_t *gnrc_sixlowpan_ctx_update(uint8_t id, const ipv6_addr_t *p static uint32_t _current_minute(void) { - timex_t now; - vtimer_now(&now); - return now.seconds / 60; + return xtimer_now() / (SEC_IN_USEC * 60); } static void _update_lifetime(uint8_t id) diff --git a/sys/net/gnrc/network_layer/sixlowpan/frag/rbuf.c b/sys/net/gnrc/network_layer/sixlowpan/frag/rbuf.c index c785248316..61dfb3af3f 100644 --- a/sys/net/gnrc/network_layer/sixlowpan/frag/rbuf.c +++ b/sys/net/gnrc/network_layer/sixlowpan/frag/rbuf.c @@ -231,17 +231,15 @@ static bool _rbuf_update_ints(rbuf_t *entry, uint16_t offset, size_t frag_size) static void _rbuf_gc(void) { rbuf_t *oldest = NULL; - timex_t now; + uint32_t now_sec = xtimer_now() / SEC_IN_USEC; unsigned int i; - vtimer_now(&now); - for (i = 0; i < RBUF_SIZE; i++) { if (rbuf[i].pkt == NULL) { /* leave GC early if there is still room */ return; } else if ((rbuf[i].pkt != NULL) && - ((now.seconds - rbuf[i].arrival) > RBUF_TIMEOUT)) { + ((now_sec - rbuf[i].arrival) > RBUF_TIMEOUT)) { DEBUG("6lo rfrag: entry (%s, ", gnrc_netif_addr_to_str(l2addr_str, sizeof(l2addr_str), rbuf[i].src, rbuf[i].src_len)); DEBUG("%s, %u, %u) timed out\n", @@ -269,9 +267,7 @@ static rbuf_t *_rbuf_get(const void *src, size_t src_len, size_t size, uint16_t tag) { rbuf_t *res = NULL; - timex_t now; - - vtimer_now(&now); + uint32_t now_sec = xtimer_now() / SEC_IN_USEC; for (unsigned int i = 0; i < RBUF_SIZE; i++) { /* check first if entry already available */ @@ -287,7 +283,7 @@ static rbuf_t *_rbuf_get(const void *src, size_t src_len, gnrc_netif_addr_to_str(l2addr_str, sizeof(l2addr_str), rbuf[i].dst, rbuf[i].dst_len), (unsigned)rbuf[i].pkt->size, rbuf[i].tag); - rbuf[i].arrival = now.seconds; + rbuf[i].arrival = now_sec; return &(rbuf[i]); } @@ -306,7 +302,7 @@ static rbuf_t *_rbuf_get(const void *src, size_t src_len, *((uint64_t *)res->pkt->data) = 0; /* clean first few bytes for later * look-ups */ - res->arrival = now.seconds; + res->arrival = now_sec; memcpy(res->src, src, src_len); memcpy(res->dst, dst, dst_len); res->src_len = src_len; From 47a02d9d07730731f472c12f602fec10e63fb5ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cenk=20G=C3=BCndo=C4=9Fan?= Date: Wed, 28 Oct 2015 21:09:29 +0100 Subject: [PATCH 3/4] ipv6: ndp: sixlowpan: remove vtimer includes --- sys/net/gnrc/network_layer/ipv6/nc/gnrc_ipv6_nc.c | 2 +- sys/net/gnrc/network_layer/ndp/gnrc_ndp.c | 2 +- sys/net/gnrc/network_layer/ndp/host/gnrc_ndp_host.c | 2 +- sys/net/gnrc/network_layer/ndp/internal/gnrc_ndp_internal.c | 2 +- sys/net/gnrc/network_layer/ndp/router/gnrc_ndp_router.c | 2 +- sys/net/gnrc/network_layer/sixlowpan/ctx/gnrc_sixlowpan_ctx.c | 1 - sys/net/gnrc/network_layer/sixlowpan/frag/rbuf.c | 2 +- 7 files changed, 6 insertions(+), 7 deletions(-) diff --git a/sys/net/gnrc/network_layer/ipv6/nc/gnrc_ipv6_nc.c b/sys/net/gnrc/network_layer/ipv6/nc/gnrc_ipv6_nc.c index d5658296ae..4926e1e97a 100644 --- a/sys/net/gnrc/network_layer/ipv6/nc/gnrc_ipv6_nc.c +++ b/sys/net/gnrc/network_layer/ipv6/nc/gnrc_ipv6_nc.c @@ -24,7 +24,7 @@ #include "net/gnrc/sixlowpan/nd.h" #include "thread.h" #include "timex.h" -#include "vtimer.h" +#include "xtimer.h" #define ENABLE_DEBUG (0) #include "debug.h" diff --git a/sys/net/gnrc/network_layer/ndp/gnrc_ndp.c b/sys/net/gnrc/network_layer/ndp/gnrc_ndp.c index 49954c9876..495a9afe64 100644 --- a/sys/net/gnrc/network_layer/ndp/gnrc_ndp.c +++ b/sys/net/gnrc/network_layer/ndp/gnrc_ndp.c @@ -30,7 +30,7 @@ #include "random.h" #include "utlist.h" #include "thread.h" -#include "vtimer.h" +#include "xtimer.h" #include "net/gnrc/ndp/internal.h" diff --git a/sys/net/gnrc/network_layer/ndp/host/gnrc_ndp_host.c b/sys/net/gnrc/network_layer/ndp/host/gnrc_ndp_host.c index 8e330e32ac..19c410e1f8 100644 --- a/sys/net/gnrc/network_layer/ndp/host/gnrc_ndp_host.c +++ b/sys/net/gnrc/network_layer/ndp/host/gnrc_ndp_host.c @@ -17,7 +17,7 @@ #include "net/gnrc/ipv6.h" #include "net/gnrc/ndp.h" #include "net/gnrc/ndp/internal.h" -#include "vtimer.h" +#include "xtimer.h" #include "net/gnrc/ndp/host.h" diff --git a/sys/net/gnrc/network_layer/ndp/internal/gnrc_ndp_internal.c b/sys/net/gnrc/network_layer/ndp/internal/gnrc_ndp_internal.c index e6d84ae2cc..ef8c6e60b0 100644 --- a/sys/net/gnrc/network_layer/ndp/internal/gnrc_ndp_internal.c +++ b/sys/net/gnrc/network_layer/ndp/internal/gnrc_ndp_internal.c @@ -21,7 +21,7 @@ #include "net/gnrc/sixlowpan/nd.h" #include "random.h" #include "timex.h" -#include "vtimer.h" +#include "xtimer.h" #include "net/gnrc/ndp/internal.h" diff --git a/sys/net/gnrc/network_layer/ndp/router/gnrc_ndp_router.c b/sys/net/gnrc/network_layer/ndp/router/gnrc_ndp_router.c index 48813e88ef..1302bb6452 100644 --- a/sys/net/gnrc/network_layer/ndp/router/gnrc_ndp_router.c +++ b/sys/net/gnrc/network_layer/ndp/router/gnrc_ndp_router.c @@ -17,7 +17,7 @@ #include "net/gnrc/ndp/internal.h" #include "random.h" #include "timex.h" -#include "vtimer.h" +#include "xtimer.h" #include "net/gnrc/ndp/router.h" diff --git a/sys/net/gnrc/network_layer/sixlowpan/ctx/gnrc_sixlowpan_ctx.c b/sys/net/gnrc/network_layer/sixlowpan/ctx/gnrc_sixlowpan_ctx.c index 00717dfee8..988b71426e 100644 --- a/sys/net/gnrc/network_layer/sixlowpan/ctx/gnrc_sixlowpan_ctx.c +++ b/sys/net/gnrc/network_layer/sixlowpan/ctx/gnrc_sixlowpan_ctx.c @@ -17,7 +17,6 @@ #include "mutex.h" #include "net/gnrc/sixlowpan/ctx.h" -#include "vtimer.h" #include "xtimer.h" #define ENABLE_DEBUG (0) diff --git a/sys/net/gnrc/network_layer/sixlowpan/frag/rbuf.c b/sys/net/gnrc/network_layer/sixlowpan/frag/rbuf.c index 61dfb3af3f..e27a63c384 100644 --- a/sys/net/gnrc/network_layer/sixlowpan/frag/rbuf.c +++ b/sys/net/gnrc/network_layer/sixlowpan/frag/rbuf.c @@ -24,7 +24,7 @@ #include "net/sixlowpan.h" #include "thread.h" #include "timex.h" -#include "vtimer.h" +#include "xtimer.h" #include "utlist.h" #define ENABLE_DEBUG (0) From 5fb104160edae3e0fe0d40c33268d3dff28d57a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cenk=20G=C3=BCndo=C4=9Fan?= Date: Wed, 28 Oct 2015 21:12:23 +0100 Subject: [PATCH 4/4] make: switch vtimer to xtimer for some modules --- Makefile.dep | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Makefile.dep b/Makefile.dep index 584830b6f4..57bda335f3 100644 --- a/Makefile.dep +++ b/Makefile.dep @@ -98,7 +98,7 @@ endif ifneq (,$(filter gnrc_sixlowpan_frag,$(USEMODULE))) USEMODULE += gnrc_sixlowpan - USEMODULE += vtimer + USEMODULE += xtimer endif ifneq (,$(filter gnrc_sixlowpan_iphc,$(USEMODULE))) @@ -114,7 +114,7 @@ endif ifneq (,$(filter gnrc_sixlowpan_ctx,$(USEMODULE))) USEMODULE += ipv6_addr - USEMODULE += vtimer + USEMODULE += xtimer endif ifneq (,$(filter gnrc_sixlowpan_nd_border_router,$(USEMODULE))) @@ -130,7 +130,7 @@ ifneq (,$(filter gnrc_sixlowpan_nd,$(USEMODULE))) USEMODULE += gnrc_ndp_internal USEMODULE += gnrc_sixlowpan_ctx USEMODULE += random - USEMODULE += vtimer + USEMODULE += xtimer endif ifneq (,$(filter gnrc_ipv6_default,$(USEMODULE))) @@ -160,13 +160,13 @@ endif ifneq (,$(filter gnrc_ndp_host,$(USEMODULE))) USEMODULE += gnrc_ndp_node USEMODULE += random - USEMODULE += vtimer + USEMODULE += xtimer endif ifneq (,$(filter gnrc_ndp_router,$(USEMODULE))) USEMODULE += gnrc_ndp_node USEMODULE += random - USEMODULE += vtimer + USEMODULE += xtimer endif ifneq (,$(filter gnrc_ndp_node,$(USEMODULE))) @@ -181,7 +181,7 @@ ifneq (,$(filter gnrc_ndp,$(USEMODULE))) USEMODULE += gnrc_icmpv6 USEMODULE += random USEMODULE += timex - USEMODULE += vtimer + USEMODULE += xtimer endif ifneq (,$(filter gnrc_icmpv6_echo,$(USEMODULE))) @@ -243,7 +243,7 @@ ifneq (,$(filter gnrc_ipv6_netif,$(USEMODULE))) USEMODULE += ipv6_addr USEMODULE += gnrc_netif USEMODULE += bitfield - USEMODULE += vtimer + USEMODULE += xtimer endif ifneq (,$(filter gnrc_udp,$(USEMODULE)))