Skip to content

Commit

Permalink
Adaptation layer: Do not push CCA failed packet back to MAC (Wi-SUN) (A…
Browse files Browse the repository at this point in the history
…RMmbed#2487)

Feature update: Improved MAC CCA failure handling
  • Loading branch information
Jarkko Paso committed Nov 10, 2020
1 parent 42c9807 commit 579f756
Showing 1 changed file with 36 additions and 48 deletions.
84 changes: 36 additions & 48 deletions source/6LoWPAN/adaptation_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1229,64 +1229,52 @@ int8_t lowpan_adaptation_interface_tx_confirm(protocol_interface_info_entry_t *c
buf->link_specific.ieee802_15_4.rf_channel_switch = false;
}

switch (confirm->status) {

case MLME_BUSY_CHAN:
lowpan_data_request_to_mac(cur, buf, tx_ptr, interface_ptr);
break;
case MLME_SUCCESS:

//Check is there more packets
if (lowpan_adaptation_tx_process_ready(tx_ptr)) {
bool triggered_from_indirect_cache = false;
if (tx_ptr->fragmented_data && active_direct_confirm) {
//Clean
interface_ptr->fragmenter_active = false;
}

if (tx_ptr->buf->link_specific.ieee802_15_4.indirectTxProcess) {
triggered_from_indirect_cache = lowpan_adaptation_indirect_cache_trigger(cur, interface_ptr, tx_ptr);
}

lowpan_adaptation_data_process_clean(interface_ptr, tx_ptr, map_mlme_status_to_socket_event(confirm->status));
if (confirm->status == MLME_SUCCESS) {
//Check is there more packets
if (lowpan_adaptation_tx_process_ready(tx_ptr)) {
bool triggered_from_indirect_cache = false;
if (tx_ptr->fragmented_data && active_direct_confirm) {
interface_ptr->fragmenter_active = false;
}

if (triggered_from_indirect_cache) {
return 0;
}
} else {
lowpan_data_request_to_mac(cur, buf, tx_ptr, interface_ptr);
if (tx_ptr->buf->link_specific.ieee802_15_4.indirectTxProcess) {
triggered_from_indirect_cache = lowpan_adaptation_indirect_cache_trigger(cur, interface_ptr, tx_ptr);
}

break;
case MLME_TX_NO_ACK:
case MLME_SECURITY_FAIL:
case MLME_TRANSACTION_EXPIRED:
default:
tr_error("MCPS Data fail by status %u", confirm->status);
if (buf->dst_sa.addr_type == ADDR_802_15_4_SHORT) {
tr_info("Dest addr: %x", common_read_16_bit(buf->dst_sa.address + 2));
} else if (buf->dst_sa.addr_type == ADDR_802_15_4_LONG) {
tr_info("Dest addr: %s", trace_array(buf->dst_sa.address + 2, 8));
lowpan_adaptation_data_process_clean(interface_ptr, tx_ptr, map_mlme_status_to_socket_event(confirm->status));

if (triggered_from_indirect_cache) {
return 0;
}
} else {
lowpan_data_request_to_mac(cur, buf, tx_ptr, interface_ptr);
}
} else if ((confirm->status == MLME_BUSY_CHAN) && !ws_info(cur)) {
lowpan_data_request_to_mac(cur, buf, tx_ptr, interface_ptr);
} else {
tr_error("MCPS Data fail by status %u", confirm->status);
if (buf->dst_sa.addr_type == ADDR_802_15_4_SHORT) {
tr_info("Dest addr: %x", common_read_16_bit(buf->dst_sa.address + 2));
} else if (buf->dst_sa.addr_type == ADDR_802_15_4_LONG) {
tr_info("Dest addr: %s", trace_array(buf->dst_sa.address + 2, 8));
}

#ifdef HAVE_RPL
if (confirm->status == MLME_TX_NO_ACK || confirm->status == MLME_UNAVAILABLE_KEY) {
if (buf->route && rpl_data_is_rpl_parent_route(buf->route->route_info.source)) {
protocol_stats_update(STATS_RPL_PARENT_TX_FAIL, 1);
}
if (confirm->status == MLME_TX_NO_ACK || confirm->status == MLME_UNAVAILABLE_KEY) {
if (buf->route && rpl_data_is_rpl_parent_route(buf->route->route_info.source)) {
protocol_stats_update(STATS_RPL_PARENT_TX_FAIL, 1);
}
}
#endif
if (tx_ptr->fragmented_data) {
tx_ptr->buf->buf_ptr = tx_ptr->buf->buf_end;
tx_ptr->buf->buf_ptr -= tx_ptr->orig_size;
if (active_direct_confirm) {
interface_ptr->fragmenter_active = false;
}
if (tx_ptr->fragmented_data) {
tx_ptr->buf->buf_ptr = tx_ptr->buf->buf_end;
tx_ptr->buf->buf_ptr -= tx_ptr->orig_size;
if (active_direct_confirm) {
interface_ptr->fragmenter_active = false;
}
}

lowpan_adaptation_data_process_clean(interface_ptr, tx_ptr, map_mlme_status_to_socket_event(confirm->status));
break;

lowpan_adaptation_data_process_clean(interface_ptr, tx_ptr, map_mlme_status_to_socket_event(confirm->status));
}
// When confirmation is for direct transmission, push all allowed buffers to MAC
if (active_direct_confirm == true) {
Expand Down

0 comments on commit 579f756

Please sign in to comment.