Contiki-NG
tsch-queue.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014, SICS Swedish ICT.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the Institute nor the names of its contributors
14  * may be used to endorse or promote products derived from this software
15  * without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * This file is part of the Contiki operating system.
30  *
31  */
32 
33 /**
34  * \file
35  * Per-neighbor packet queues for TSCH MAC.
36  * The list of neighbors uses the TSCH lock, but per-neighbor packet array are lock-free.
37  * Read-only operation on neighbor and packets are allowed from interrupts and outside of them.
38  * *Other operations are allowed outside of interrupt only.*
39  * \author
40  * Simon Duquennoy <simonduq@sics.se>
41  * Beshr Al Nahas <beshr@sics.se>
42  * Domenico De Guglielmo <d.deguglielmo@iet.unipi.it >
43  */
44 
45 /**
46  * \addtogroup tsch
47  * @{
48 */
49 
50 #include "contiki.h"
51 #include "lib/list.h"
52 #include "lib/memb.h"
53 #include "lib/random.h"
54 #include "net/queuebuf.h"
55 #include "net/mac/tsch/tsch.h"
56 #include <string.h>
57 
58 /* Log configuration */
59 #include "sys/log.h"
60 #define LOG_MODULE "TSCH Queue"
61 #define LOG_LEVEL LOG_LEVEL_MAC
62 
63 /* Check if TSCH_QUEUE_NUM_PER_NEIGHBOR is power of two */
64 #if (TSCH_QUEUE_NUM_PER_NEIGHBOR & (TSCH_QUEUE_NUM_PER_NEIGHBOR - 1)) != 0
65 #error TSCH_QUEUE_NUM_PER_NEIGHBOR must be power of two
66 #endif
67 
68 /* We have as many packets are there are queuebuf in the system */
69 MEMB(packet_memb, struct tsch_packet, QUEUEBUF_NUM);
70 MEMB(neighbor_memb, struct tsch_neighbor, TSCH_QUEUE_MAX_NEIGHBOR_QUEUES);
71 LIST(neighbor_list);
72 
73 /* Broadcast and EB virtual neighbors */
74 struct tsch_neighbor *n_broadcast;
75 struct tsch_neighbor *n_eb;
76 
77 /*---------------------------------------------------------------------------*/
78 /* Add a TSCH neighbor */
79 struct tsch_neighbor *
80 tsch_queue_add_nbr(const linkaddr_t *addr)
81 {
82  struct tsch_neighbor *n = NULL;
83  /* If we have an entry for this neighbor already, we simply update it */
84  n = tsch_queue_get_nbr(addr);
85  if(n == NULL) {
86  if(tsch_get_lock()) {
87  /* Allocate a neighbor */
88  n = memb_alloc(&neighbor_memb);
89  if(n != NULL) {
90  /* Initialize neighbor entry */
91  memset(n, 0, sizeof(struct tsch_neighbor));
92  ringbufindex_init(&n->tx_ringbuf, TSCH_QUEUE_NUM_PER_NEIGHBOR);
93  linkaddr_copy(&n->addr, addr);
94  n->is_broadcast = linkaddr_cmp(addr, &tsch_eb_address)
95  || linkaddr_cmp(addr, &tsch_broadcast_address);
97  /* Add neighbor to the list */
98  list_add(neighbor_list, n);
99  }
101  }
102  }
103  return n;
104 }
105 /*---------------------------------------------------------------------------*/
106 /* Get a TSCH neighbor */
107 struct tsch_neighbor *
108 tsch_queue_get_nbr(const linkaddr_t *addr)
109 {
110  if(!tsch_is_locked()) {
111  struct tsch_neighbor *n = list_head(neighbor_list);
112  while(n != NULL) {
113  if(linkaddr_cmp(&n->addr, addr)) {
114  return n;
115  }
116  n = list_item_next(n);
117  }
118  }
119  return NULL;
120 }
121 /*---------------------------------------------------------------------------*/
122 /* Get a TSCH time source (we currently assume there is only one) */
123 struct tsch_neighbor *
125 {
126  if(!tsch_is_locked()) {
127  struct tsch_neighbor *curr_nbr = list_head(neighbor_list);
128  while(curr_nbr != NULL) {
129  if(curr_nbr->is_time_source) {
130  return curr_nbr;
131  }
132  curr_nbr = list_item_next(curr_nbr);
133  }
134  }
135  return NULL;
136 }
137 /*---------------------------------------------------------------------------*/
138 /* Update TSCH time source */
139 int
140 tsch_queue_update_time_source(const linkaddr_t *new_addr)
141 {
142  if(!tsch_is_locked()) {
143  if(!tsch_is_coordinator) {
144  struct tsch_neighbor *old_time_src = tsch_queue_get_time_source();
145  struct tsch_neighbor *new_time_src = NULL;
146 
147  if(new_addr != NULL) {
148  /* Get/add neighbor, return 0 in case of failure */
149  new_time_src = tsch_queue_add_nbr(new_addr);
150  if(new_time_src == NULL) {
151  return 0;
152  }
153  }
154 
155  if(new_time_src != old_time_src) {
156  LOG_INFO("update time source: ");
157  LOG_INFO_LLADDR(old_time_src ? &old_time_src->addr : NULL);
158  LOG_INFO_(" -> ");
159  LOG_INFO_LLADDR(new_time_src ? &new_time_src->addr : NULL);
160  LOG_INFO_("\n");
161 
162  /* Update time source */
163  if(new_time_src != NULL) {
164  new_time_src->is_time_source = 1;
165  /* (Re)set keep-alive timeout */
166  tsch_set_ka_timeout(TSCH_KEEPALIVE_TIMEOUT);
167  } else {
168  /* Stop sending keepalives */
170  }
171 
172  if(old_time_src != NULL) {
173  old_time_src->is_time_source = 0;
174  }
175 
176 #ifdef TSCH_CALLBACK_NEW_TIME_SOURCE
177  TSCH_CALLBACK_NEW_TIME_SOURCE(old_time_src, new_time_src);
178 #endif
179  }
180 
181  return 1;
182  }
183  }
184  return 0;
185 }
186 /*---------------------------------------------------------------------------*/
187 /* Flush a neighbor queue */
188 static void
189 tsch_queue_flush_nbr_queue(struct tsch_neighbor *n)
190 {
191  while(!tsch_queue_is_empty(n)) {
193  if(p != NULL) {
194  /* Set return status for packet_sent callback */
195  p->ret = MAC_TX_ERR;
196  LOG_WARN("! flushing packet\n");
197  /* Call packet_sent callback */
198  mac_call_sent_callback(p->sent, p->ptr, p->ret, p->transmissions);
199  /* Free packet queuebuf */
201  }
202  }
203 }
204 /*---------------------------------------------------------------------------*/
205 /* Remove TSCH neighbor queue */
206 static void
207 tsch_queue_remove_nbr(struct tsch_neighbor *n)
208 {
209  if(n != NULL) {
210  if(tsch_get_lock()) {
211 
212  /* Remove neighbor from list */
213  list_remove(neighbor_list, n);
214 
216 
217  /* Flush queue */
218  tsch_queue_flush_nbr_queue(n);
219 
220  /* Free neighbor */
221  memb_free(&neighbor_memb, n);
222  }
223  }
224 }
225 /*---------------------------------------------------------------------------*/
226 /* Add packet to neighbor queue. Use same lockfree implementation as ringbuf.c (put is atomic) */
227 struct tsch_packet *
228 tsch_queue_add_packet(const linkaddr_t *addr, uint8_t max_transmissions,
229  mac_callback_t sent, void *ptr)
230 {
231  struct tsch_neighbor *n = NULL;
232  int16_t put_index = -1;
233  struct tsch_packet *p = NULL;
234  if(!tsch_is_locked()) {
235  n = tsch_queue_add_nbr(addr);
236  if(n != NULL) {
237  put_index = ringbufindex_peek_put(&n->tx_ringbuf);
238  if(put_index != -1) {
239  p = memb_alloc(&packet_memb);
240  if(p != NULL) {
241  /* Enqueue packet */
242 #ifdef TSCH_CALLBACK_PACKET_READY
243  TSCH_CALLBACK_PACKET_READY();
244 #endif
245  p->qb = queuebuf_new_from_packetbuf();
246  if(p->qb != NULL) {
247  p->sent = sent;
248  p->ptr = ptr;
249  p->ret = MAC_TX_DEFERRED;
250  p->transmissions = 0;
251  p->max_transmissions = max_transmissions;
252  /* Add to ringbuf (actual add committed through atomic operation) */
253  n->tx_array[put_index] = p;
254  ringbufindex_put(&n->tx_ringbuf);
255  LOG_DBG("packet is added put_index %u, packet %p\n",
256  put_index, p);
257  return p;
258  } else {
259  memb_free(&packet_memb, p);
260  }
261  }
262  }
263  }
264  }
265  LOG_ERR("! add packet failed: %u %p %d %p %p\n", tsch_is_locked(), n, put_index, p, p ? p->qb : NULL);
266  return 0;
267 }
268 /*---------------------------------------------------------------------------*/
269 /* Returns the number of packets currently in any TSCH queue */
270 int
272 {
273  return QUEUEBUF_NUM - memb_numfree(&packet_memb);
274 }
275 /*---------------------------------------------------------------------------*/
276 /* Returns the number of packets currently in the queue */
277 int
278 tsch_queue_packet_count(const linkaddr_t *addr)
279 {
280  struct tsch_neighbor *n = NULL;
281  if(!tsch_is_locked()) {
282  n = tsch_queue_add_nbr(addr);
283  if(n != NULL) {
284  return ringbufindex_elements(&n->tx_ringbuf);
285  }
286  }
287  return -1;
288 }
289 /*---------------------------------------------------------------------------*/
290 /* Remove first packet from a neighbor queue */
291 struct tsch_packet *
293 {
294  if(!tsch_is_locked()) {
295  if(n != NULL) {
296  /* Get and remove packet from ringbuf (remove committed through an atomic operation */
297  int16_t get_index = ringbufindex_get(&n->tx_ringbuf);
298  if(get_index != -1) {
299  return n->tx_array[get_index];
300  } else {
301  return NULL;
302  }
303  }
304  }
305  return NULL;
306 }
307 /*---------------------------------------------------------------------------*/
308 /* Free a packet */
309 void
311 {
312  if(p != NULL) {
313  queuebuf_free(p->qb);
314  memb_free(&packet_memb, p);
315  }
316 }
317 /*---------------------------------------------------------------------------*/
318 /* Updates neighbor queue state after a transmission */
319 int
321  struct tsch_link *link, uint8_t mac_tx_status)
322 {
323  int in_queue = 1;
324  int is_shared_link = link->link_options & LINK_OPTION_SHARED;
325  int is_unicast = !n->is_broadcast;
326 
327  if(mac_tx_status == MAC_TX_OK) {
328  /* Successful transmission */
330  in_queue = 0;
331 
332  /* Update CSMA state in the unicast case */
333  if(is_unicast) {
334  if(is_shared_link || tsch_queue_is_empty(n)) {
335  /* If this is a shared link, reset backoff on success.
336  * Otherwise, do so only is the queue is empty */
338  }
339  }
340  } else {
341  /* Failed transmission */
342  if(p->transmissions >= p->max_transmissions) {
343  /* Drop packet */
345  in_queue = 0;
346  }
347  /* Update CSMA state in the unicast case */
348  if(is_unicast) {
349  /* Failures on dedicated (== non-shared) leave the backoff
350  * window nor exponent unchanged */
351  if(is_shared_link) {
352  /* Shared link: increment backoff exponent, pick a new window */
354  }
355  }
356  }
357 
358  return in_queue;
359 }
360 /*---------------------------------------------------------------------------*/
361 /* Flush all neighbor queues */
362 void
364 {
365  /* Deallocate unneeded neighbors */
366  if(!tsch_is_locked()) {
367  struct tsch_neighbor *n = list_head(neighbor_list);
368  while(n != NULL) {
369  struct tsch_neighbor *next_n = list_item_next(n);
370  /* Flush queue */
371  tsch_queue_flush_nbr_queue(n);
372  /* Reset backoff exponent */
374  n = next_n;
375  }
376  }
377 }
378 /*---------------------------------------------------------------------------*/
379 /* Deallocate neighbors with empty queue */
380 void
382 {
383  /* Deallocate unneeded neighbors */
384  if(!tsch_is_locked()) {
385  struct tsch_neighbor *n = list_head(neighbor_list);
386  while(n != NULL) {
387  struct tsch_neighbor *next_n = list_item_next(n);
388  /* Queue is empty, no tx link to this neighbor: deallocate.
389  * Always keep time source and virtual broadcast neighbors. */
390  if(!n->is_broadcast && !n->is_time_source && !n->tx_links_count
391  && tsch_queue_is_empty(n)) {
392  tsch_queue_remove_nbr(n);
393  }
394  n = next_n;
395  }
396  }
397 }
398 /*---------------------------------------------------------------------------*/
399 /* Is the neighbor queue empty? */
400 int
402 {
403  return !tsch_is_locked() && n != NULL && ringbufindex_empty(&n->tx_ringbuf);
404 }
405 /*---------------------------------------------------------------------------*/
406 /* Returns the first packet from a neighbor queue */
407 struct tsch_packet *
409 {
410  if(!tsch_is_locked()) {
411  int is_shared_link = link != NULL && link->link_options & LINK_OPTION_SHARED;
412  if(n != NULL) {
413  int16_t get_index = ringbufindex_peek_get(&n->tx_ringbuf);
414  if(get_index != -1 &&
415  !(is_shared_link && !tsch_queue_backoff_expired(n))) { /* If this is a shared link,
416  make sure the backoff has expired */
417 #if TSCH_WITH_LINK_SELECTOR
418  int packet_attr_slotframe = queuebuf_attr(n->tx_array[get_index]->qb, PACKETBUF_ATTR_TSCH_SLOTFRAME);
419  int packet_attr_timeslot = queuebuf_attr(n->tx_array[get_index]->qb, PACKETBUF_ATTR_TSCH_TIMESLOT);
420  if(packet_attr_slotframe != 0xffff && packet_attr_slotframe != link->slotframe_handle) {
421  return NULL;
422  }
423  if(packet_attr_timeslot != 0xffff && packet_attr_timeslot != link->timeslot) {
424  return NULL;
425  }
426 #endif
427  return n->tx_array[get_index];
428  }
429  }
430  }
431  return NULL;
432 }
433 /*---------------------------------------------------------------------------*/
434 /* Returns the head packet from a neighbor queue (from neighbor address) */
435 struct tsch_packet *
436 tsch_queue_get_packet_for_dest_addr(const linkaddr_t *addr, struct tsch_link *link)
437 {
438  if(!tsch_is_locked()) {
440  }
441  return NULL;
442 }
443 /*---------------------------------------------------------------------------*/
444 /* Returns the head packet of any neighbor queue with zero backoff counter.
445  * Writes pointer to the neighbor in *n */
446 struct tsch_packet *
448 {
449  if(!tsch_is_locked()) {
450  struct tsch_neighbor *curr_nbr = list_head(neighbor_list);
451  struct tsch_packet *p = NULL;
452  while(curr_nbr != NULL) {
453  if(!curr_nbr->is_broadcast && curr_nbr->tx_links_count == 0) {
454  /* Only look up for non-broadcast neighbors we do not have a tx link to */
455  p = tsch_queue_get_packet_for_nbr(curr_nbr, link);
456  if(p != NULL) {
457  if(n != NULL) {
458  *n = curr_nbr;
459  }
460  return p;
461  }
462  }
463  curr_nbr = list_item_next(curr_nbr);
464  }
465  }
466  return NULL;
467 }
468 /*---------------------------------------------------------------------------*/
469 /* May the neighbor transmit over a shared link? */
470 int
472 {
473  return n->backoff_window == 0;
474 }
475 /*---------------------------------------------------------------------------*/
476 /* Reset neighbor backoff */
477 void
479 {
480  n->backoff_window = 0;
481  n->backoff_exponent = TSCH_MAC_MIN_BE;
482 }
483 /*---------------------------------------------------------------------------*/
484 /* Increment backoff exponent, pick a new window */
485 void
487 {
488  /* Increment exponent */
489  n->backoff_exponent = MIN(n->backoff_exponent + 1, TSCH_MAC_MAX_BE);
490  /* Pick a window (number of shared slots to skip). Ignore least significant
491  * few bits, which, on some embedded implementations of rand (e.g. msp430-libc),
492  * are known to have poor pseudo-random properties. */
493  n->backoff_window = (random_rand() >> 6) % (1 << n->backoff_exponent);
494  /* Add one to the window as we will decrement it at the end of the current slot
495  * through tsch_queue_update_all_backoff_windows */
496  n->backoff_window++;
497 }
498 /*---------------------------------------------------------------------------*/
499 /* Decrement backoff window for all queues directed at dest_addr */
500 void
501 tsch_queue_update_all_backoff_windows(const linkaddr_t *dest_addr)
502 {
503  if(!tsch_is_locked()) {
504  int is_broadcast = linkaddr_cmp(dest_addr, &tsch_broadcast_address);
505  struct tsch_neighbor *n = list_head(neighbor_list);
506  while(n != NULL) {
507  if(n->backoff_window != 0 /* Is the queue in backoff state? */
508  && ((n->tx_links_count == 0 && is_broadcast)
509  || (n->tx_links_count > 0 && linkaddr_cmp(dest_addr, &n->addr)))) {
510  n->backoff_window--;
511  }
512  n = list_item_next(n);
513  }
514  }
515 }
516 /*---------------------------------------------------------------------------*/
517 /* Initialize TSCH queue module */
518 void
520 {
521  list_init(neighbor_list);
522  memb_init(&neighbor_memb);
523  memb_init(&packet_memb);
524  /* Add virtual EB and the broadcast neighbors */
525  n_eb = tsch_queue_add_nbr(&tsch_eb_address);
526  n_broadcast = tsch_queue_add_nbr(&tsch_broadcast_address);
527 }
528 /*---------------------------------------------------------------------------*/
529 /** @} */
TSCH packet information.
Definition: tsch-types.h:97
int tsch_queue_global_packet_count(void)
Returns the number of packets currently in all TSCH queues.
Definition: tsch-queue.c:271
struct tsch_neighbor * tsch_queue_get_nbr(const linkaddr_t *addr)
Get a TSCH neighbor.
Definition: tsch-queue.c:108
void ringbufindex_init(struct ringbufindex *r, uint8_t size)
Initialize a ring buffer.
Definition: ringbufindex.c:50
static uip_ds6_addr_t * addr
Pointer to a nbr cache entry.
Definition: uip-nd6.c:115
int ringbufindex_peek_get(const struct ringbufindex *r)
Return the index of the first element which will be removed if calling ringbufindex_get.
Definition: ringbufindex.c:115
int tsch_get_lock(void)
Takes the TSCH lock.
void tsch_release_lock(void)
Releases the TSCH lock.
TSCH neighbor information.
Definition: tsch-types.h:109
void tsch_queue_init(void)
Initialize TSCH queue module.
Definition: tsch-queue.c:519
void tsch_queue_update_all_backoff_windows(const linkaddr_t *dest_addr)
Decrement backoff window for the queue(s) able to Tx to a given address.
Definition: tsch-queue.c:501
struct tsch_neighbor * tsch_queue_get_time_source(void)
Get the TSCH time source (we currently assume there is only one)
Definition: tsch-queue.c:124
void tsch_set_ka_timeout(uint32_t timeout)
Set the desynchronization timeout after which a node sends a unicasst keep-alive (KA) to its time sou...
Definition: tsch.c:199
struct tsch_packet * tsch_queue_get_packet_for_dest_addr(const linkaddr_t *addr, struct tsch_link *link)
Returns the first packet that can be sent to a given address on a given link.
Definition: tsch-queue.c:436
The MAC layer transmission was OK.
Definition: mac.h:84
void tsch_queue_free_unused_neighbors(void)
Deallocate all neighbors with empty queue.
Definition: tsch-queue.c:381
The MAC layer transmission could not be performed because of an error.
Definition: mac.h:94
int tsch_queue_backoff_expired(const struct tsch_neighbor *n)
Is the neighbor backoff timer expired?
Definition: tsch-queue.c:471
struct tsch_neighbor * tsch_queue_add_nbr(const linkaddr_t *addr)
Add a TSCH neighbor queue.
Definition: tsch-queue.c:80
Header file for the Packet queue buffer management
Linked list manipulation routines.
void tsch_queue_backoff_inc(struct tsch_neighbor *n)
Increment backoff exponent of a given neighbor queue, pick a new window.
Definition: tsch-queue.c:486
void * list_head(list_t list)
Get a pointer to the first element of a list.
Definition: list.c:82
int tsch_queue_update_time_source(const linkaddr_t *new_addr)
Update TSCH time source.
Definition: tsch-queue.c:140
Main API declarations for TSCH.
The MAC layer transmission could not be performed because of a fatal error.
Definition: mac.h:98
struct tsch_packet * tsch_queue_get_packet_for_nbr(const struct tsch_neighbor *n, struct tsch_link *link)
Returns the first packet that can be sent from a queue on a given link.
Definition: tsch-queue.c:408
int ringbufindex_elements(const struct ringbufindex *r)
Return the number of elements currently in the ring buffer.
Definition: ringbufindex.c:134
Memory block allocation routines.
int tsch_is_locked(void)
Checks if the TSCH lock is set.
void linkaddr_copy(linkaddr_t *dest, const linkaddr_t *src)
Copy a link-layer address.
Definition: linkaddr.c:63
void list_add(list_t list, void *item)
Add an item at the end of a list.
Definition: list.c:142
int tsch_queue_packet_sent(struct tsch_neighbor *n, struct tsch_packet *p, struct tsch_link *link, uint8_t mac_tx_status)
Updates neighbor queue state after a transmission.
Definition: tsch-queue.c:320
struct tsch_packet * tsch_queue_remove_packet_from_queue(struct tsch_neighbor *n)
Remove first packet from a neighbor queue.
Definition: tsch-queue.c:292
int linkaddr_cmp(const linkaddr_t *addr1, const linkaddr_t *addr2)
Compare two link-layer addresses.
Definition: linkaddr.c:69
void tsch_queue_reset(void)
Reset neighbor queues module.
Definition: tsch-queue.c:363
void list_init(list_t list)
Initialize a list.
Definition: list.c:65
int tsch_queue_is_empty(const struct tsch_neighbor *n)
Is the neighbor queue empty?
Definition: tsch-queue.c:401
#define LIST(name)
Declare a linked list.
Definition: list.h:88
int tsch_queue_packet_count(const linkaddr_t *addr)
Returns the number of packets currently a given neighbor queue.
Definition: tsch-queue.c:278
void * memb_alloc(struct memb *m)
Allocate a memory block from a block of memory declared with MEMB().
Definition: memb.c:59
int ringbufindex_get(struct ringbufindex *r)
Remove the first element and return its index.
Definition: ringbufindex.c:90
int ringbufindex_peek_put(const struct ringbufindex *r)
Check if there is space to put an element.
Definition: ringbufindex.c:78
struct tsch_packet * tsch_queue_get_unicast_packet_for_any(struct tsch_neighbor **n, struct tsch_link *link)
Gets the head packet of any neighbor queue with zero backoff counter.
Definition: tsch-queue.c:447
void tsch_queue_free_packet(struct tsch_packet *p)
Free a packet.
Definition: tsch-queue.c:310
void memb_init(struct memb *m)
Initialize a memory block that was declared with MEMB().
Definition: memb.c:52
unsigned short random_rand(void)
Generates a new random number using the cc2538 RNG.
Definition: random.c:58
struct tsch_packet * tsch_queue_add_packet(const linkaddr_t *addr, uint8_t max_transmissions, mac_callback_t sent, void *ptr)
Add packet to neighbor queue.
Definition: tsch-queue.c:228
char memb_free(struct memb *m, void *ptr)
Deallocate a memory block from a memory block previously declared with MEMB().
Definition: memb.c:79
Header file for the logging system
int ringbufindex_put(struct ringbufindex *r)
Put one element to the ring buffer.
Definition: ringbufindex.c:58
void list_remove(list_t list, void *item)
Remove a specific element from a list.
Definition: list.c:237
void * list_item_next(void *item)
Get the next item following this item.
Definition: list.c:322
void tsch_queue_backoff_reset(struct tsch_neighbor *n)
Reset neighbor backoff.
Definition: tsch-queue.c:478
#define MEMB(name, structure, num)
Declare a memory block.
Definition: memb.h:89
int ringbufindex_empty(const struct ringbufindex *r)
Is the ring buffer empty?
Definition: ringbufindex.c:146