TSCH: some rework on tsch-queue
This commit is contained in:
parent
bf5bea583e
commit
c297c89f8d
@ -313,6 +313,49 @@ tsch_queue_free_packet(struct tsch_packet *p)
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Updates neighbor queue state after a transmission */
|
||||
int
|
||||
tsch_queue_packet_sent(struct tsch_neighbor *n, struct tsch_packet *p,
|
||||
struct tsch_link *link, uint8_t mac_tx_status)
|
||||
{
|
||||
int in_queue = 1;
|
||||
int is_shared_link = link->link_options & LINK_OPTION_SHARED;
|
||||
int is_unicast = !n->is_broadcast;
|
||||
|
||||
if(mac_tx_status == MAC_TX_OK) {
|
||||
/* Successful transmission */
|
||||
tsch_queue_remove_packet_from_queue(n);
|
||||
in_queue = 0;
|
||||
|
||||
/* Update CSMA state in the unicast case */
|
||||
if(is_unicast) {
|
||||
if(is_shared_link || tsch_queue_is_empty(n)) {
|
||||
/* If this is a shared link, reset backoff on success.
|
||||
* Otherwise, do so only is the queue is empty */
|
||||
tsch_queue_backoff_reset(n);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Failed transmission */
|
||||
if(p->transmissions >= TSCH_MAC_MAX_FRAME_RETRIES + 1) {
|
||||
/* Drop packet */
|
||||
tsch_queue_remove_packet_from_queue(n);
|
||||
in_queue = 0;
|
||||
}
|
||||
/* Update CSMA state in the unicast case */
|
||||
if(is_unicast) {
|
||||
/* Failures on dedicated (== non-shared) leave the backoff
|
||||
* window nor exponent unchanged */
|
||||
if(is_shared_link) {
|
||||
/* Shared link: increment backoff exponent, pick a new window */
|
||||
tsch_queue_backoff_inc(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return in_queue;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Flush all neighbor queues */
|
||||
void
|
||||
tsch_queue_reset(void)
|
||||
|
@ -94,7 +94,7 @@
|
||||
#ifdef TSCH_CONF_MAC_MAX_FRAME_RETRIES
|
||||
#define TSCH_MAC_MAX_FRAME_RETRIES TSCH_CONF_MAC_MAX_FRAME_RETRIES
|
||||
#else
|
||||
#define TSCH_MAC_MAX_FRAME_RETRIES 8
|
||||
#define TSCH_MAC_MAX_FRAME_RETRIES 7
|
||||
#endif
|
||||
|
||||
/*********** Callbacks *********/
|
||||
@ -169,6 +169,8 @@ int tsch_queue_packet_count(const linkaddr_t *addr);
|
||||
struct tsch_packet *tsch_queue_remove_packet_from_queue(struct tsch_neighbor *n);
|
||||
/* Free a packet */
|
||||
void tsch_queue_free_packet(struct tsch_packet *p);
|
||||
/* Updates neighbor queue state after a transmission */
|
||||
int tsch_queue_packet_sent(struct tsch_neighbor *n, struct tsch_packet *p, struct tsch_link *link, uint8_t mac_tx_status);
|
||||
/* Reset neighbor queues */
|
||||
void tsch_queue_reset(void);
|
||||
/* Deallocate neighbors with empty queue */
|
||||
|
@ -349,49 +349,6 @@ get_packet_and_neighbor_for_link(struct tsch_link *link, struct tsch_neighbor **
|
||||
return p;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Post TX: Update neighbor state after a transmission */
|
||||
static int
|
||||
update_neighbor_state(struct tsch_neighbor *n, struct tsch_packet *p,
|
||||
struct tsch_link *link, uint8_t mac_tx_status)
|
||||
{
|
||||
int in_queue = 1;
|
||||
int is_shared_link = link->link_options & LINK_OPTION_SHARED;
|
||||
int is_unicast = !n->is_broadcast;
|
||||
|
||||
if(mac_tx_status == MAC_TX_OK) {
|
||||
/* Successful transmission */
|
||||
tsch_queue_remove_packet_from_queue(n);
|
||||
in_queue = 0;
|
||||
|
||||
/* Update CSMA state in the unicast case */
|
||||
if(is_unicast) {
|
||||
if(is_shared_link || tsch_queue_is_empty(n)) {
|
||||
/* If this is a shared link, reset backoff on success.
|
||||
* Otherwise, do so only is the queue is empty */
|
||||
tsch_queue_backoff_reset(n);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Failed transmission */
|
||||
if(p->transmissions >= TSCH_MAC_MAX_FRAME_RETRIES + 1) {
|
||||
/* Drop packet */
|
||||
tsch_queue_remove_packet_from_queue(n);
|
||||
in_queue = 0;
|
||||
}
|
||||
/* Update CSMA state in the unicast case */
|
||||
if(is_unicast) {
|
||||
/* Failures on dedicated (== non-shared) leave the backoff
|
||||
* window nor exponent unchanged */
|
||||
if(is_shared_link) {
|
||||
/* Shared link: increment backoff exponent, pick a new window */
|
||||
tsch_queue_backoff_inc(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return in_queue;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* This function turns on the radio. Its semantics is dependent on
|
||||
* the value of TSCH_RADIO_ON_DURING_TIMESLOT constant:
|
||||
@ -678,8 +635,8 @@ PT_THREAD(tsch_tx_slot(struct pt *pt, struct rtimer *t))
|
||||
current_packet->transmissions++;
|
||||
current_packet->ret = mac_tx_status;
|
||||
|
||||
/* Post TX: Update neighbor state */
|
||||
in_queue = update_neighbor_state(current_neighbor, current_packet, current_link, mac_tx_status);
|
||||
/* Post TX: Update neighbor queue state */
|
||||
in_queue = tsch_queue_packet_sent(current_neighbor, current_packet, current_link, mac_tx_status);
|
||||
|
||||
/* The packet was dequeued, add it to dequeued_ringbuf for later processing */
|
||||
if(in_queue == 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user