Skip to content

Commit

Permalink
fixup! fixup! gnrc_sixlowpan_frag_sfr: provide CongURE support
Browse files Browse the repository at this point in the history
  • Loading branch information
miri64 committed Oct 25, 2022
1 parent cbf2b58 commit 3e616d3
Showing 1 changed file with 29 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1676,30 +1676,35 @@ static void _send_ack(gnrc_netif_t *netif, const uint8_t *dst, uint8_t dst_len,

static void _sched_next_frame(gnrc_sixlowpan_frag_fb_t *fbuf)
{
if (gnrc_sixlowpan_frag_sfr_congure_snd_has_inter_frame_gap()) {
int state = irq_disable(); /* make timer check atomic */
bool already_set = xtimer_is_set(&_if_gap_timer);

irq_restore(state);
if (!already_set) {
uint32_t last_sent_since = (_last_frame_sent - xtimer_now_usec());
uint32_t if_gap = gnrc_sixlowpan_frag_sfr_congure_snd_inter_frame_gap(fbuf);

if (last_sent_since <= if_gap) {
uint32_t offset = if_gap - last_sent_since;
DEBUG("6lo sfr: arming inter-frame timer in %" PRIu32 " us\n",
last_sent_since);
_if_gap_msg.content.ptr = fbuf;
xtimer_set_msg(&_if_gap_timer, offset, &_if_gap_msg, _getpid());
}
else {
DEBUG("6lo sfr: send frame immediately\n");
gnrc_sixlowpan_frag_sfr_inter_frame_gap(fbuf);
}
}
else {
DEBUG("6lo sfr: inter-frame timer was already set\n");
}
if (!gnrc_sixlowpan_frag_sfr_congure_snd_has_inter_frame_gap()) {
return;
}
int state = irq_disable(); /* make timer check atomic */
bool already_set = xtimer_is_set(&_if_gap_timer);

irq_restore(state);
if (already_set) {
DEBUG("6lo sfr: inter-frame timer was already set\n");
return;
}
uint32_t last_sent_since = (_last_frame_sent - xtimer_now_usec());
uint32_t if_gap = gnrc_sixlowpan_frag_sfr_congure_snd_inter_frame_gap(fbuf);

if (last_sent_since <= if_gap) {
uint32_t offset = if_gap - last_sent_since;
DEBUG("6lo sfr: arming inter-frame timer in %" PRIu32 " us\n",
last_sent_since);
_if_gap_msg.content.ptr = fbuf;
xtimer_set_msg(&_if_gap_timer, offset, &_if_gap_msg, _getpid());
}
else {
DEBUG("6lo sfr: send frame immediately\n");
/* there is no risk of infinite recursion due to the call of `_sched_next_frame` since
* we only get here when (_last_frame_sent - now) > if_gap.
* Since gnrc_sixlowpan_frag_sfr_inter_frame_gap updates _last_frame_sent when the list is
* empty and only calls _sched_next_frame() when the list is still not empty after that this
* can not be the case if we came from there (except for misconfigured if_gap). */
gnrc_sixlowpan_frag_sfr_inter_frame_gap(fbuf);
}
}

Expand Down

0 comments on commit 3e616d3

Please sign in to comment.