Skip to content

Commit

Permalink
Adaptation layer update
Browse files Browse the repository at this point in the history
Added limit for active unicast TX process to MAC to 10.

Traffic flow priority support added to buffer queue optimize.
  • Loading branch information
Juha Heiuskanen committed Nov 20, 2020
1 parent 13fb2bf commit afbe906
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
31 changes: 30 additions & 1 deletion source/6LoWPAN/adaptation_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "MLE/mle.h"
#include "Service_Libs/mle_service/mle_service_api.h"
#include "Common_Protocols/icmpv6.h"
#include "Common_Protocols/ip.h"
#ifdef HAVE_RPL
#include "RPL/rpl_data.h"
#endif
Expand Down Expand Up @@ -93,6 +94,7 @@ typedef struct {
fragmenter_tx_list_t activeUnicastList; //Unicast packets waiting data confirmation from MAC
buffer_list_t directTxQueue; //Waiting free tx process
uint16_t directTxQueue_size;
uint16_t activeTxList_size;
uint16_t indirect_big_packet_threshold;
uint16_t max_indirect_big_packets_total;
uint16_t max_indirect_small_packets_per_child;
Expand All @@ -103,6 +105,8 @@ typedef struct {
ns_list_link_t link; /*!< List link entry */
} fragmenter_interface_t;

#define LOWPAN_ACTIVE_UNICAST_ONGOING_MAX 10

static NS_LIST_DEFINE(fragmenter_interface_list, fragmenter_interface_t, link);

/* Adaptation interface local functions */
Expand Down Expand Up @@ -365,6 +369,8 @@ int8_t lowpan_adaptation_interface_init(int8_t interface_id, uint16_t mac_mtu_si
ns_list_init(&interface_ptr->indirect_tx_queue);
ns_list_init(&interface_ptr->directTxQueue);
ns_list_init(&interface_ptr->activeUnicastList);
interface_ptr->activeTxList_size = 0;
interface_ptr->directTxQueue_size = 0;

ns_list_add_to_end(&fragmenter_interface_list, interface_ptr);

Expand All @@ -390,13 +396,14 @@ int8_t lowpan_adaptation_interface_free(int8_t interface_id)
ns_list_remove(&fragmenter_interface_list, interface_ptr);
//free active tx process
lowpan_list_free(&interface_ptr->activeUnicastList, false);
interface_ptr->activeTxList_size = 0;
lowpan_active_buffer_state_reset(&interface_ptr->active_broadcast_tx_buf);

//Free Indirect entry
lowpan_list_free(&interface_ptr->indirect_tx_queue, true);

buffer_free_list(&interface_ptr->directTxQueue);

interface_ptr->directTxQueue_size = 0;
//Free Dynamic allocated entries
ns_dyn_mem_free(interface_ptr->fragment_indirect_tx_buffer);
ns_dyn_mem_free(interface_ptr);
Expand All @@ -415,6 +422,7 @@ int8_t lowpan_adaptation_interface_reset(int8_t interface_id)

//free active tx process
lowpan_list_free(&interface_ptr->activeUnicastList, false);
interface_ptr->activeTxList_size = 0;
lowpan_active_buffer_state_reset(&interface_ptr->active_broadcast_tx_buf);
//Clean fragmented message flag
interface_ptr->fragmenter_active = false;
Expand All @@ -423,6 +431,7 @@ int8_t lowpan_adaptation_interface_reset(int8_t interface_id)
lowpan_list_free(&interface_ptr->indirect_tx_queue, true);

buffer_free_list(&interface_ptr->directTxQueue);
interface_ptr->directTxQueue_size = 0;

return 0;
}
Expand Down Expand Up @@ -597,6 +606,7 @@ static fragmenter_tx_entry_t *lowpan_adaptation_tx_process_init(fragmenter_inter
return NULL;
}
ns_list_add_to_end(&interface_ptr->activeUnicastList, tx_entry);
interface_ptr->activeTxList_size++;
} else {
tx_entry = &interface_ptr->active_broadcast_tx_buf;
}
Expand Down Expand Up @@ -969,6 +979,10 @@ static bool lowpan_buffer_tx_allowed(fragmenter_interface_t *interface_ptr, buff
if (!is_unicast && interface_ptr->active_broadcast_tx_buf.buf) {
return false;
}

if (is_unicast && interface_ptr->activeTxList_size >= LOWPAN_ACTIVE_UNICAST_ONGOING_MAX) {
return false;
}
// Do not accept more than one active unicast TX per destination
if (is_unicast && lowpan_adaptation_is_destination_tx_active(&interface_ptr->activeUnicastList, buf)) {
return false;
Expand All @@ -992,6 +1006,20 @@ int8_t lowpan_adaptation_interface_tx(protocol_interface_info_entry_t *cur, buff
goto tx_error_handler;
}

uint8_t traffic_class = buf->options.traffic_class >> IP_TCLASS_DSCP_SHIFT;
if (traffic_class) {
tr_debug("TC %u, prority update", traffic_class);
}
if (traffic_class == IP_DSCP_EF) {
buffer_priority_set(buf, QOS_EXPEDITE_FORWARD);
} else if (traffic_class == IP_DSCP_CS6) {
//Network Control
buffer_priority_set(buf, QOS_NETWORK_CTRL);
} else if (traffic_class) {
buffer_priority_set(buf, QOS_HIGH);
}


//Check packet size
bool fragmented_needed = lowpan_adaptation_request_longer_than_mtu(cur, buf, interface_ptr);
if (fragmented_needed) {
Expand Down Expand Up @@ -1166,6 +1194,7 @@ static void lowpan_adaptation_data_process_clean(fragmenter_interface_t *interfa
} else if (buf->link_specific.ieee802_15_4.requestAck) {
ns_list_remove(&interface_ptr->activeUnicastList, tx_ptr);
ns_dyn_mem_free(tx_ptr);
interface_ptr->activeTxList_size--;
}

socket_tx_buffer_event_and_free(buf, socket_event);
Expand Down
4 changes: 3 additions & 1 deletion source/Core/include/ns_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ typedef enum {
typedef enum {
QOS_NORMAL = 0,
QOS_HIGH = 1,
QOS_MAC_BEACON = 2
QOS_NETWORK_CTRL = 2,
QOS_EXPEDITE_FORWARD = 3,
QOS_MAC_BEACON = 4
} buffer_priority_t;

#define B_TO_MAC_MLME_MASK (B_DIR_MASK + B_FROM_MASK + B_TO_MASK )
Expand Down

0 comments on commit afbe906

Please sign in to comment.