Skip to content

Commit

Permalink
Neighbour temporary entry update and Enhanced ACK tx update
Browse files Browse the repository at this point in the history
MAC will trig enhanced ACK now if it can allocate buffer for data and ACK TX is possible.

Removed Temporary entry instant remove and wait timeout.

Cleaned dead code.
  • Loading branch information
Juha Heiskanen committed Aug 26, 2020
1 parent 70244f6 commit 089fb3b
Show file tree
Hide file tree
Showing 15 changed files with 3 additions and 155 deletions.
1 change: 0 additions & 1 deletion nanostack/mlme.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ typedef enum {
macEdfeForceStop = 0xf2, /*< Use this command for Data wait timeout at LLC: Mac stop Edfe session data wait and enable normal FHSS mode */
macSetDataWhitening = 0xf3, /*< Enable or disable data whitening, boolean true for enable, false for disable */
macCCAThresholdStart = 0xf4, /*< Start automatic CCA threshold */
macDevicePendingAckTrig = 0xf5, /*< Trig Pending ACK for Accepted Data packet for temporary neighbour */
mac802_15_4Mode = 0xf6, /*<IEEE 802.15.4 mode*/
macDeviceDescriptionPanIDUpdate = 0xf7, /*<Thread pending link update case this will update device descrioton list pan-id to new one*/
macTXPower = 0xf8, /*<TX output power*/
Expand Down
15 changes: 0 additions & 15 deletions source/6LoWPAN/MAC/mac_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -947,21 +947,6 @@ void mac_helper_devicetable_direct_set(struct mac_api_s *mac_api, const mlme_dev
mac_api->mlme_req(mac_api, MLME_SET, &set_req);
}

void mac_helper_devicetable_ack_trig(const mlme_device_descriptor_t *device_desc, protocol_interface_info_entry_t *cur)
{
if (!cur->mac_api) {
return;
}

mlme_set_t set_req;
set_req.attr = macDevicePendingAckTrig;
set_req.attr_index = 0;
set_req.value_pointer = (void *)device_desc;
set_req.value_size = sizeof(mlme_device_descriptor_t);
cur->mac_api->mlme_req(cur->mac_api, MLME_SET, &set_req);
}


int8_t mac_helper_mac_mlme_max_retry_set(int8_t interface_id, uint8_t mac_retry_set)
{
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(interface_id);
Expand Down
2 changes: 0 additions & 2 deletions source/6LoWPAN/MAC/mac_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ void mac_helper_devicetable_set(const mlme_device_descriptor_t *device_dec, stru

void mac_helper_devicetable_direct_set(struct mac_api_s *mac_api, const mlme_device_descriptor_t *device_desc, uint8_t attribute_index);

void mac_helper_devicetable_ack_trig(const mlme_device_descriptor_t *device_desc, struct protocol_interface_info_entry *cur);

int8_t mac_helper_mac_mlme_max_retry_set(int8_t interface_id, uint8_t mac_retry_set);

int8_t mac_helper_mac_device_description_pan_id_update(int8_t interface_id, uint16_t pan_id);
Expand Down
18 changes: 0 additions & 18 deletions source/6LoWPAN/ws/ws_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,6 @@ static void ws_bootstrap_neighbor_delete(struct protocol_interface_info_entry *i
ws_neighbor_class_entry_remove(&interface->ws_info->neighbor_storage, entry_ptr->index);
}

void ws_bootstrap_mac_neighbor_temporary_remove(struct protocol_interface_info_entry *interface, const uint8_t *src64)
{
mac_neighbor_table_entry_t *neighbor = mac_neighbor_table_address_discover(mac_neighbor_info(interface), src64, MAC_ADDR_MODE_64_BIT);

if (neighbor && neighbor->link_lifetime != WS_NEIGHBOR_LINK_TIMEOUT) {
tr_debug("Remove temporary neighbour %s", trace_array(src64, 8));
mac_neighbor_table_neighbor_remove(mac_neighbor_info(interface), neighbor);
}
}

static void ws_bootstap_eapol_neigh_entry_allocate(struct protocol_interface_info_entry *interface)
{
uint8_t mac_64[8];
Expand All @@ -205,14 +195,6 @@ static void ws_bootstap_eapol_neigh_entry_allocate(struct protocol_interface_inf
interface->ws_info->eapol_tx_index = mac_entry->index;
}

void ws_bootstrap_eapol_rx_temporary_set(struct protocol_interface_info_entry *interface, const uint8_t *src64)
{
mlme_device_descriptor_t device_desc;

mac_helper_device_description_write(interface, &device_desc, src64, 0xffff, 0, false);
mac_helper_devicetable_ack_trig(&device_desc, interface);
}

ws_neighbor_class_entry_t *ws_bootstrap_eapol_tx_temporary_set(struct protocol_interface_info_entry *interface, const uint8_t *src64)
{
mlme_device_descriptor_t device_desc;
Expand Down
5 changes: 0 additions & 5 deletions source/6LoWPAN/ws/ws_bootstrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ bool ws_bootstrap_validate_channel_plan(struct ws_us_ie *ws_us, struct protocol_

bool ws_bootstrap_validate_channel_function(struct ws_us_ie *ws_us, struct ws_bs_ie *ws_bs);

void ws_bootstrap_eapol_rx_temporary_set(struct protocol_interface_info_entry *interface, const uint8_t *src64);

struct ws_neighbor_class_entry *ws_bootstrap_eapol_tx_temporary_set(struct protocol_interface_info_entry *interface, const uint8_t *src64);

void ws_bootstrap_eapol_tx_temporary_clear(struct protocol_interface_info_entry *interface);
Expand All @@ -98,8 +96,6 @@ int ws_bootstrap_get_info(protocol_interface_info_entry_t *cur, struct ws_stack_

void ws_bootstrap_mac_neighbor_short_time_set(struct protocol_interface_info_entry *interface, const uint8_t *src64, uint32_t valid_time);

void ws_bootstrap_mac_neighbor_temporary_remove(struct protocol_interface_info_entry *interface, const uint8_t *src64);

#else

#define ws_bootstrap_init(interface_id, bootstrap_mode) (-1)
Expand All @@ -108,7 +104,6 @@ void ws_bootstrap_mac_neighbor_temporary_remove(struct protocol_interface_info_e
#define ws_bootstrap_neighbor_remove(cur, ll_address)
#define ws_bootstrap_aro_failure(cur, ll_address)
#define ws_bootstrap_neighbor_set_stable(interface, src64)
#define ws_bootstrap_mac_neighbor_temporary_remove(interface, src64)
#define ws_bootstrap_primary_parent_update(interface, neighbor)
#define ws_bootstrap_secondary_parent_update(interface)
#define ws_bootstrap_get_info(cur, info_ptr)
Expand Down
7 changes: 0 additions & 7 deletions source/6LoWPAN/ws/ws_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,12 +498,5 @@ void ws_common_secondary_parent_update(protocol_interface_info_entry_t *interfac
{
ws_bootstrap_secondary_parent_update(interface);
}
void ws_common_link_temporary_remove(struct protocol_interface_info_entry *interface, const uint8_t *ll64)
{
uint8_t mac64[8];
memcpy(mac64, ll64 + 8, 8);
mac64[0] ^= 2;
ws_bootstrap_mac_neighbor_temporary_remove(interface, mac64);
}

#endif // HAVE_WS
2 changes: 0 additions & 2 deletions source/6LoWPAN/ws/ws_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ void ws_common_primary_parent_update(protocol_interface_info_entry_t *interface,

void ws_common_secondary_parent_update(protocol_interface_info_entry_t *interface);

void ws_common_link_temporary_remove(struct protocol_interface_info_entry *interface, const uint8_t *ll64);
uint8_t ws_common_temporary_entry_size(uint8_t mac_table_size);
#define ws_info(cur) ((cur)->ws_info)
#else
Expand All @@ -170,7 +169,6 @@ uint8_t ws_common_temporary_entry_size(uint8_t mac_table_size);
#define ws_common_latency_estimate_get(cur) 0
#define ws_common_datarate_get(cur) 0
#define ws_common_network_size_estimate_get(cur) 0
#define ws_common_link_temporary_remove(interface, ll64) ((void)0)
#define ws_common_primary_parent_update(interface, neighbor)
#define ws_common_secondary_parent_update(interface)

Expand Down
1 change: 0 additions & 1 deletion source/Common_Protocols/icmpv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -1648,7 +1648,6 @@ buffer_t *icmpv6_build_na(protocol_interface_info_entry_t *cur, bool solicited,
}
/* All other than ARO NA messages are omitted and MAC ACK is considered as success */
if (!tllao_required && (!aro && cur->ipv6_neighbour_cache.omit_na)) {
ws_common_link_temporary_remove(cur, src_addr);
return NULL;
}

Expand Down
1 change: 0 additions & 1 deletion source/MAC/IEEE802_15_4/mac_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ typedef struct protocol_interface_rf_mac_setup {
bool macBroadcastDisabled: 1;
bool scan_active: 1;
bool rf_csma_extension_supported: 1;
bool ack_tx_possible: 1;
uint16_t mac_short_address;
uint16_t pan_id;
uint8_t mac64[8];
Expand Down
41 changes: 1 addition & 40 deletions source/MAC/IEEE802_15_4/mac_mlme.c
Original file line number Diff line number Diff line change
Expand Up @@ -673,50 +673,13 @@ static int8_t mac_mlme_set_ack_wait_duration(protocol_interface_rf_mac_setup_s *
return 0;
}

static void mac_mlme_trig_pending_ack(protocol_interface_rf_mac_setup_s *rf_mac_setup, mlme_device_descriptor_t *device_ptr)
{
platform_enter_critical();
if (rf_mac_setup->mac_ack_tx_active && !rf_mac_setup->ack_tx_possible &&
device_ptr->PANId == rf_mac_setup->enhanced_ack_buffer.DstPANId) {

//Compare address for pending neigbour add
if (rf_mac_setup->enhanced_ack_buffer.fcf_dsn.DstAddrMode == MAC_ADDR_MODE_16_BIT) {
uint16_t short_id = common_read_16_bit(rf_mac_setup->enhanced_ack_buffer.DstAddr);
if (short_id == device_ptr->ShortAddress) {
rf_mac_setup->ack_tx_possible = true;
}
} else if (rf_mac_setup->enhanced_ack_buffer.fcf_dsn.DstAddrMode == MAC_ADDR_MODE_64_BIT) {
if (memcmp(device_ptr->ExtAddress, rf_mac_setup->enhanced_ack_buffer.DstAddr, 8) == 0) {
rf_mac_setup->ack_tx_possible = true;
}
}
}
platform_exit_critical();
}

static int8_t mac_mlme_device_description_set(protocol_interface_rf_mac_setup_s *rf_mac_setup, const mlme_set_t *set_req)
{

if (set_req->value_size != sizeof(mlme_device_descriptor_t)) {
return -1;
}
if (mac_sec_mib_device_description_set(set_req->attr_index, (mlme_device_descriptor_t *) set_req->value_pointer, rf_mac_setup) != 0) {
return -1;
}

mac_mlme_trig_pending_ack(rf_mac_setup, (mlme_device_descriptor_t *) set_req->value_pointer);
return 0;
}

static int8_t mac_mlme_device_pending_ack_trig(protocol_interface_rf_mac_setup_s *rf_mac_setup, const mlme_set_t *set_req)
{

if (set_req->value_size != sizeof(mlme_device_descriptor_t)) {
return -1;
}
mac_mlme_trig_pending_ack(rf_mac_setup, (mlme_device_descriptor_t *) set_req->value_pointer);

return 0;
return mac_sec_mib_device_description_set(set_req->attr_index, (mlme_device_descriptor_t *) set_req->value_pointer, rf_mac_setup);
}

static int8_t mac_mlme_key_description_set(protocol_interface_rf_mac_setup_s *rf_mac_setup, const mlme_set_t *set_req)
Expand Down Expand Up @@ -795,8 +758,6 @@ int8_t mac_mlme_set_req(protocol_interface_rf_mac_setup_s *rf_mac_setup, const m
return mac_mlme_set_ack_wait_duration(rf_mac_setup, set_req);
case macDeviceTable:
return mac_mlme_device_description_set(rf_mac_setup, set_req);
case macDevicePendingAckTrig:
return mac_mlme_device_pending_ack_trig(rf_mac_setup, set_req);
case macKeyTable:
return mac_mlme_key_description_set(rf_mac_setup, set_req);
case macDefaultKeySource:
Expand Down
29 changes: 1 addition & 28 deletions source/MAC/IEEE802_15_4/mac_pd_sap.c
Original file line number Diff line number Diff line change
Expand Up @@ -453,23 +453,8 @@ static int8_t mac_data_interface_tx_done_cb(protocol_interface_rf_mac_setup_s *r

if (status == PHY_LINK_CCA_PREPARE) {

if (rf_ptr->mac_ack_tx_active) {
//Accept direct non crypted acks and crypted only if neighbor is at list
if (rf_ptr->ack_tx_possible) {
goto VALIDATE_TX_TIME;
}

//Compare time to started time
if (mac_mcps_sap_get_phy_timestamp(rf_ptr) - rf_ptr->enhanced_ack_handler_timestamp > ENHANCED_ACK_NEIGHBOUR_POLL_MAX_TIME_US) {
mac_data_ack_tx_finish(rf_ptr);
} else if (mcps_generic_ack_build(rf_ptr, false) != 0) {
mac_data_ack_tx_finish(rf_ptr);
}

return PHY_TX_NOT_ALLOWED;
}

if (rf_ptr->mac_edfe_tx_active) {
if (rf_ptr->mac_ack_tx_active || rf_ptr->mac_edfe_tx_active) {
goto VALIDATE_TX_TIME;
}

Expand Down Expand Up @@ -864,18 +849,6 @@ static int8_t mac_pd_sap_generate_ack(protocol_interface_rf_mac_setup_s *rf_ptr,
return -1;
}


if (rf_ptr->enhanced_ack_buffer.fcf_dsn.securityEnabled == 0 || rf_ptr->enhanced_ack_buffer.aux_header.securityLevel == 0) {
//Unsecured data will be acked immediately
rf_ptr->ack_tx_possible = true;
} else {
if (mac_sec_mib_device_description_get(rf_ptr, rf_ptr->enhanced_ack_buffer.DstAddr, rf_ptr->enhanced_ack_buffer.fcf_dsn.DstAddrMode, rf_ptr->enhanced_ack_buffer.DstPANId)) {
rf_ptr->ack_tx_possible = true;
} else {
rf_ptr->ack_tx_possible = false;
}
}

return mcps_generic_ack_build(rf_ptr, true);
}

Expand Down
22 changes: 1 addition & 21 deletions test/nanostack/unittest/mac/mac_pd_sap/test_mac_pd_sap.c
Original file line number Diff line number Diff line change
Expand Up @@ -841,32 +841,12 @@ bool test_mac_cca_prepare_cb()
phy_message.message.mac15_4_pd_sap_confirm.status = PHY_LINK_CCA_PREPARE;

int8_t ret = mac_pd_sap_data_cb(&rf_ptr, &phy_message);
if (ret != -1) {
return false;
}

rf_ptr.ack_tx_possible = true;
ret = mac_pd_sap_data_cb(&rf_ptr, &phy_message);
if (ret != 0) {
return false;
}

rf_ptr.ack_tx_possible = false;

rf_ptr.enhanced_ack_handler_timestamp = 10;

ret = mac_pd_sap_data_cb(&rf_ptr, &phy_message);
if (ret != -1 || rf_ptr.mac_ack_tx_active) {
return false;
}

ret = mac_pd_sap_data_cb(&rf_ptr, &phy_message);
if (ret != -1) {
return false;
}

mac_pre_build_frame_t test_packet;

rf_ptr.mac_ack_tx_active = false;
memset(&test_packet, 0, sizeof(mac_pre_build_frame_t));
rf_ptr.active_pd_data_request = &test_packet;
test_packet.csma_periods_left = 0;
Expand Down
5 changes: 0 additions & 5 deletions test/nanostack/unittest/stub/mac_helper_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,6 @@ void mac_helper_devicetable_direct_set(struct mac_api_s *mac_api, const mlme_dev

}

void mac_helper_devicetable_ack_trig(const mlme_device_descriptor_t *device_desc, struct protocol_interface_info_entry *cur)
{

}

int8_t mac_helper_mac_mlme_max_retry_set(int8_t interface_id, uint8_t mac_retry_set)
{

Expand Down
4 changes: 0 additions & 4 deletions test/nanostack/unittest/stub/ws_bootstrap_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,6 @@ struct ws_neighbor_class_entry *ws_bootstrap_eapol_tx_temporary_set(struct proto
return NULL;
}

void ws_bootstrap_eapol_rx_temporary_set(struct protocol_interface_info_entry *interface, const uint8_t *src64)
{

}
void ws_bootstrap_eapol_tx_temporary_clear(struct protocol_interface_info_entry *interface)
{

Expand Down
5 changes: 0 additions & 5 deletions test/nanostack/unittest/stub/ws_common_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,3 @@ void ws_common_primary_parent_update(protocol_interface_info_entry_t *interface,
void ws_common_secondary_parent_update(protocol_interface_info_entry_t *interface)
{
}

void ws_common_link_temporary_remove(struct protocol_interface_info_entry *interface, const uint8_t *ll64)
{

}

0 comments on commit 089fb3b

Please sign in to comment.