33 #ifndef __TSCH_QUEUE_H__
34 #define __TSCH_QUEUE_H__
41 #include "net/mac/tsch/tsch-schedule.h"
49 #ifdef TSCH_QUEUE_CONF_NUM_PER_NEIGHBOR
50 #define TSCH_QUEUE_NUM_PER_NEIGHBOR TSCH_QUEUE_CONF_NUM_PER_NEIGHBOR
54 #if QUEUEBUF_CONF_NUM <= 4
55 #define TSCH_QUEUE_NUM_PER_NEIGHBOR 4
56 #elif QUEUEBUF_CONF_NUM <= 8
57 #define TSCH_QUEUE_NUM_PER_NEIGHBOR 8
58 #elif QUEUEBUF_CONF_NUM <= 16
59 #define TSCH_QUEUE_NUM_PER_NEIGHBOR 16
60 #elif QUEUEBUF_CONF_NUM <= 32
61 #define TSCH_QUEUE_NUM_PER_NEIGHBOR 32
62 #elif QUEUEBUF_CONF_NUM <= 64
63 #define TSCH_QUEUE_NUM_PER_NEIGHBOR 64
64 #elif QUEUEBUF_CONF_NUM <= 128
65 #define TSCH_QUEUE_NUM_PER_NEIGHBOR 128
67 #define TSCH_QUEUE_NUM_PER_NEIGHBOR 256
73 #ifdef TSCH_QUEUE_CONF_MAX_NEIGHBOR_QUEUES
74 #define TSCH_QUEUE_MAX_NEIGHBOR_QUEUES TSCH_QUEUE_CONF_MAX_NEIGHBOR_QUEUES
76 #define TSCH_QUEUE_MAX_NEIGHBOR_QUEUES ((NBR_TABLE_CONF_MAX_NEIGHBORS) + 2)
81 #ifdef TSCH_CONF_MAC_MIN_BE
82 #define TSCH_MAC_MIN_BE TSCH_CONF_MAC_MIN_BE
84 #define TSCH_MAC_MIN_BE 1
87 #ifdef TSCH_CONF_MAC_MAX_BE
88 #define TSCH_MAC_MAX_BE TSCH_CONF_MAC_MAX_BE
90 #define TSCH_MAC_MAX_BE 7
93 #ifdef TSCH_CONF_MAC_MAX_FRAME_RETRIES
94 #define TSCH_MAC_MAX_FRAME_RETRIES TSCH_CONF_MAC_MAX_FRAME_RETRIES
96 #define TSCH_MAC_MAX_FRAME_RETRIES 8
102 #ifdef TSCH_CALLBACK_NEW_TIME_SOURCE
103 struct tsch_neighbor;
104 void TSCH_CALLBACK_NEW_TIME_SOURCE(
const struct tsch_neighbor *old,
const struct tsch_neighbor *
new);
108 #ifdef TSCH_CALLBACK_PACKET_READY
109 void TSCH_CALLBACK_PACKET_READY(
void);
119 uint8_t transmissions;
122 uint8_t tsch_sync_ie_offset;
126 struct tsch_neighbor {
128 struct tsch_neighbor *next;
130 uint8_t is_broadcast;
131 uint8_t is_time_source;
132 uint8_t backoff_exponent;
133 uint8_t backoff_window;
134 uint8_t last_backoff_window;
135 uint8_t tx_links_count;
136 uint8_t dedicated_tx_links_count;
139 struct tsch_packet *tx_array[TSCH_QUEUE_NUM_PER_NEIGHBOR];
141 struct ringbufindex tx_ringbuf;
147 extern struct tsch_neighbor *n_broadcast;
148 extern struct tsch_neighbor *n_eb;
153 struct tsch_neighbor *tsch_queue_add_nbr(
const linkaddr_t *
addr);
155 struct tsch_neighbor *tsch_queue_get_nbr(
const linkaddr_t *
addr);
157 struct tsch_neighbor *tsch_queue_get_time_source(
void);
159 int tsch_queue_update_time_source(
const linkaddr_t *new_addr);
161 struct tsch_packet *tsch_queue_add_packet(
const linkaddr_t *
addr, mac_callback_t sent,
void *ptr);
163 int tsch_queue_packet_count(
const linkaddr_t *
addr);
166 struct tsch_packet *tsch_queue_remove_packet_from_queue(
struct tsch_neighbor *n);
168 void tsch_queue_free_packet(
struct tsch_packet *p);
170 void tsch_queue_reset(
void);
172 void tsch_queue_free_unused_neighbors(
void);
174 int tsch_queue_is_empty(
const struct tsch_neighbor *n);
176 struct tsch_packet *tsch_queue_get_packet_for_nbr(
const struct tsch_neighbor *n,
struct tsch_link *link);
178 struct tsch_packet *tsch_queue_get_packet_for_dest_addr(
const linkaddr_t *
addr,
struct tsch_link *link);
181 struct tsch_packet *tsch_queue_get_unicast_packet_for_any(
struct tsch_neighbor **n,
struct tsch_link *link);
183 int tsch_queue_backoff_expired(
const struct tsch_neighbor *n);
185 void tsch_queue_backoff_reset(
struct tsch_neighbor *n);
187 void tsch_queue_backoff_inc(
struct tsch_neighbor *n);
189 void tsch_queue_update_all_backoff_windows(
const linkaddr_t *dest_addr);
191 void tsch_queue_init(
void);
static uip_ds6_addr_t * addr
Pointer to a router list entry.
Header file for the ringbufindex library
Header file for the Rime address representation