Skip to content

Commit

Permalink
fixup! gnrc_sixlowpan_frag_sfr: add support for queue-based ECN
Browse files Browse the repository at this point in the history
  • Loading branch information
miri64 committed Mar 25, 2021
1 parent 78480e0 commit 73e1712
Showing 1 changed file with 45 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -549,59 +549,14 @@ void gnrc_sixlowpan_frag_sfr_arq_timeout(gnrc_sixlowpan_frag_fb_t *fbuf)
_clean_up_fbuf(fbuf, error_no);
}

static void _6lo_dispatch_send(gnrc_pktsnip_t *frame, void *ctx, unsigned page)
{
if (IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR_ECN) &&
(sixlowpan_sfr_rfrag_is(frame->next->data))) {
int queue_state = 0;
int queue_size = 0;

if (IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR_ECN_IF_IN)) {
gnrc_netif_t *netif = gnrc_netif_hdr_get_netif(frame->data);

assert(frame->type == GNRC_NETTYPE_NETIF);
assert(frame->next->type == GNRC_NETTYPE_SIXLOWPAN);
queue_state = msg_avail_thread(netif->pid);
queue_size = msg_queue_capacity(netif->pid);
assert(queue_size > 0);

if ((queue_state * CONFIG_GNRC_SIXLOWPAN_SFR_ECN_IF_IN_DEN) >
(queue_size * CONFIG_GNRC_SIXLOWPAN_SFR_ECN_IF_IN_NUM)) {
sixlowpan_sfr_set_ecn(frame->next->data);
}
}

if (IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR_ECN_IF_OUT)) {
queue_state = gnrc_netif_pktq_usage();
queue_size = CONFIG_GNRC_NETIF_PKTQ_POOL_SIZE;

if ((queue_state * CONFIG_GNRC_SIXLOWPAN_SFR_ECN_IF_OUT_DEN) >
(queue_size * CONFIG_GNRC_SIXLOWPAN_SFR_ECN_IF_OUT_NUM)) {
sixlowpan_sfr_set_ecn(frame->next->data);
}
}

if (IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR_ECN_FQUEUE)) {
queue_state = clist_count(&_frame_queue);
queue_size = FRAME_QUEUE_POOL_SIZE;

if ((queue_state * CONFIG_GNRC_SIXLOWPAN_SFR_ECN_FQUEUE_DEN) >
(queue_size * CONFIG_GNRC_SIXLOWPAN_SFR_ECN_FQUEUE_NUM)) {
sixlowpan_sfr_set_ecn(frame->next->data);
}
}
}
gnrc_sixlowpan_dispatch_send(frame, ctx, page);
}

void gnrc_sixlowpan_frag_sfr_inter_frame_gap(void)
{
if (CONFIG_GNRC_SIXLOWPAN_SFR_INTER_FRAME_GAP_US > 0) {
_frame_queue_t *node = (_frame_queue_t *)clist_lpop(&_frame_queue);

if (node != NULL) {
_last_frame_sent = xtimer_now_usec();
_6lo_dispatch_send(node->frame, NULL, node->page);
gnrc_sixlowpan_dispatch_send(node->frame, NULL, node->page);
/* unset packet just to be safe */
node->frame = NULL;
clist_rpush(&_frame_queue_free, &node->super);
Expand Down Expand Up @@ -787,13 +742,55 @@ static uint16_t _find_offset_and_copy_rest(uint8_t *data, gnrc_pktsnip_t **pkt,

static bool _send_frame(gnrc_pktsnip_t *frame, void *ctx, unsigned page)
{
uint32_t now = xtimer_now_usec();
uint32_t now;
uint32_t if_gap;

if (IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR_ECN) &&
(sixlowpan_sfr_rfrag_is(frame->next->data))) {
int queue_state = 0;
int queue_size = 0;

if (IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR_ECN_IF_IN)) {
gnrc_netif_t *netif = gnrc_netif_hdr_get_netif(frame->data);

assert(frame->type == GNRC_NETTYPE_NETIF);
assert(frame->next->type == GNRC_NETTYPE_SIXLOWPAN);
queue_state = msg_avail_thread(netif->pid);
queue_size = msg_queue_capacity(netif->pid);
assert(queue_size > 0);

if ((queue_state * CONFIG_GNRC_SIXLOWPAN_SFR_ECN_IF_IN_DEN) >
(queue_size * CONFIG_GNRC_SIXLOWPAN_SFR_ECN_IF_IN_NUM)) {
sixlowpan_sfr_set_ecn(frame->next->data);
}
}

if (IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR_ECN_IF_OUT)) {
queue_state = gnrc_netif_pktq_usage();
queue_size = CONFIG_GNRC_NETIF_PKTQ_POOL_SIZE;

if ((queue_state * CONFIG_GNRC_SIXLOWPAN_SFR_ECN_IF_OUT_DEN) >
(queue_size * CONFIG_GNRC_SIXLOWPAN_SFR_ECN_IF_OUT_NUM)) {
sixlowpan_sfr_set_ecn(frame->next->data);
}
}

if (IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR_ECN_FQUEUE)) {
queue_state = clist_count(&_frame_queue);
queue_size = FRAME_QUEUE_POOL_SIZE;

if ((queue_state * CONFIG_GNRC_SIXLOWPAN_SFR_ECN_FQUEUE_DEN) >
(queue_size * CONFIG_GNRC_SIXLOWPAN_SFR_ECN_FQUEUE_NUM)) {
sixlowpan_sfr_set_ecn(frame->next->data);
}
}
}
now = xtimer_now_usec();
if ((CONFIG_GNRC_SIXLOWPAN_SFR_INTER_FRAME_GAP_US == 0) ||
((now - _last_frame_sent) > CONFIG_GNRC_SIXLOWPAN_SFR_INTER_FRAME_GAP_US)) {
DEBUG("6lo sfr: dispatch frame to network interface\n");
_last_frame_sent = now;
_6lo_dispatch_send(frame, ctx, page);
gnrc_sixlowpan_dispatch_send(frame, ctx, page);
return true;
}
else {
Expand Down

0 comments on commit 73e1712

Please sign in to comment.