Skip to content

Commit 8f1f9d5

Browse files
author
Juha Heiskanen
committed
EDFE error handling update
Added EDFE data wait timeout and functionality skip data packet send for testing data wait timeout. Added spossibility to test EDFE sender re-send logic. EDFE is not ccaepted for brodcast traffic.
1 parent 51bf94e commit 8f1f9d5

File tree

10 files changed

+156
-3
lines changed

10 files changed

+156
-3
lines changed

nanostack/mlme.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ typedef enum {
264264
macAutoRequestKeyIndex = 0x7b, /*<The index of the key used for automatic data*/
265265
macDefaultKeySource = 0x7c, /*<Default key source*/
266266
//NON standard extension
267+
macEdfeForceStop = 0xf2, /*< Use this command for Data wait timeout at LLC: Mac stop Edfe session data wait and enable normal FHSS mode */
267268
macSetDataWhitening = 0xf3, /*< Enable or disable data whitening, boolean true for enable, false for disable */
268269
macCCAThresholdStart = 0xf4, /*< Start automatic CCA threshold */
269270
macDevicePendingAckTrig = 0xf5, /*< Trig Pending ACK for Accepted Data packet for temporary neighbour */

nanostack/net_ws_test.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,32 @@ int ws_test_next_gtk_set(int8_t interface_id, uint8_t *gtk[4]);
178178
*/
179179
int ws_test_6lowpan_fragmentation_mtu_size_set(int8_t interface_id, uint16_t mtu_size);
180180

181+
/**
182+
* Disable First EDFE data packet send.
183+
*
184+
* Made only for test purpose for test EDFE client Data wait timeout.
185+
*
186+
* \param interface_id Network interface ID.
187+
* \param skip True for skip first data packet false disable unused flag.
188+
*
189+
* \return 0 Success
190+
* \return <0 Failure
191+
*/
192+
void ws_test_skip_edfe_data_send(int8_t interface_id, bool skip);
193+
194+
/**
195+
* Drop configured EDFE data packets.
196+
*
197+
* Made only for test purpose for test EDFE data sender retry send logic.
198+
*
199+
* \param interface_id Network interface ID.
200+
* \param number_of_dropped_frames How many packets will be dropped.
201+
*
202+
* \return 0 Success
203+
* \return <0 Failure
204+
*/
205+
int8_t ws_test_drop_edfe_data_frames(int8_t interface_id, uint8_t number_of_dropped_frames);
206+
181207
#ifdef __cplusplus
182208
}
183209
#endif

source/6LoWPAN/ws/ws_common.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@
2323
#include <ns_list.h>
2424
#include <nsdynmemLIB.h>
2525
#include "Common_Protocols/icmpv6.h"
26+
#include "mac_common_defines.h"
27+
#include "net_interface.h"
28+
#include "6LoWPAN/MAC/mpx_api.h"
2629
#include "6LoWPAN/ws/ws_config.h"
2730
#include "6LoWPAN/ws/ws_common_defines.h"
31+
#include "6LoWPAN/ws/ws_llc.h"
2832
#include "6LoWPAN/ws/ws_common.h"
2933
#include "6LoWPAN/ws/ws_bootstrap.h"
3034
#include "6LoWPAN/ws/ws_bbr_api_internal.h"
@@ -349,6 +353,7 @@ void ws_common_fast_timer(protocol_interface_info_entry_t *cur, uint16_t ticks)
349353
{
350354
ws_bootstrap_trickle_timer(cur, ticks);
351355
ws_nud_active_timer(cur, ticks);
356+
ws_llc_fast_timer(cur, ticks);
352357
}
353358

354359

source/6LoWPAN/ws/ws_llc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ void ws_llc_hopping_schedule_config(struct protocol_interface_info_entry *interf
226226

227227
void ws_llc_timer_seconds(struct protocol_interface_info_entry *interface, uint16_t seconds_update);
228228

229+
void ws_llc_fast_timer(struct protocol_interface_info_entry *interface, uint16_t ticks);
230+
229231
bool ws_llc_eapol_relay_forward_filter(struct protocol_interface_info_entry *interface, const uint8_t *joiner_eui64, uint8_t mac_sequency, uint32_t rx_timestamp);
230232

231233
ws_neighbor_temp_class_t *ws_llc_get_multicast_temp_entry(struct protocol_interface_info_entry *interface, const uint8_t *mac64);

source/6LoWPAN/ws/ws_llc_data_service.c

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ typedef struct {
119119
typedef struct {
120120
uint8_t mac_handle_base; /**< Mac handle id base this will be updated by 1 after use */
121121
uint8_t llc_message_list_size; /**< llc_message_list list size */
122+
uint16_t edfe_rx_wait_timer;
122123
mpx_class_t mpx_data_base; /**< MPX data be including USER API Class and user call backs */
124+
123125
llc_message_list_t llc_message_list; /**< Active Message list */
124126
llc_ie_params_t ie_params; /**< LLC IE header and Payload data configuration */
125127
temp_entriest_t *temp_entries;
@@ -171,6 +173,30 @@ static ws_neighbor_temp_class_t *ws_allocate_eapol_temp_entry(temp_entriest_t *b
171173

172174
static void ws_llc_mpx_eapol_send(llc_data_base_t *base, llc_message_t *message);
173175

176+
static bool test_skip_first_init_response = false;
177+
static uint8_t test_drop_data_message = 0;
178+
179+
180+
int8_t ws_test_skip_edfe_data_send(int8_t interface_id, bool skip)
181+
{
182+
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(interface_id);
183+
if (!cur || !ws_info(cur)) {
184+
return -1;
185+
}
186+
test_skip_first_init_response = skip;
187+
return 0;
188+
}
189+
190+
int8_t ws_test_drop_edfe_data_frames(int8_t interface_id, uint8_t number_of_dropped_frames)
191+
{
192+
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(interface_id);
193+
if (!cur || !ws_info(cur)) {
194+
return -1;
195+
}
196+
test_drop_data_message = number_of_dropped_frames;
197+
return 0;
198+
}
199+
174200
/** Discover Message by message handle id */
175201
static llc_message_t *llc_message_discover_by_mac_handle(uint8_t handle, llc_message_list_t *list)
176202
{
@@ -949,7 +975,7 @@ static void ws_llc_lowpan_mpx_data_request(llc_data_base_t *base, mpx_user_t *us
949975
nested_wp_id.vp_ie = true;
950976
}
951977

952-
if (data->ExtendedFrameExchange) {
978+
if (data->ExtendedFrameExchange && data->TxAckReq) {
953979
ie_header_mask.fc_ie = true;
954980
}
955981
if (!data->TxAckReq) {
@@ -996,11 +1022,12 @@ static void ws_llc_lowpan_mpx_data_request(llc_data_base_t *base, mpx_user_t *us
9961022
data_req.msduLength = 0;
9971023
data_req.msduHandle = message->msg_handle;
9981024

999-
if (data->ExtendedFrameExchange) {
1025+
if (data->ExtendedFrameExchange && data->TxAckReq) {
10001026
data_req.SeqNumSuppressed = true;
10011027
data_req.PanIdSuppressed = true;
10021028
data_req.TxAckReq = true; // This will be changed inside MAC
10031029
} else {
1030+
data_req.ExtendedFrameExchange = false; //Do not accept EDFE for non unicast traffic
10041031
if (!data->TxAckReq) {
10051032
data_req.PanIdSuppressed = false;
10061033
data_req.DstAddrMode = MAC_ADDR_MODE_NONE;
@@ -1500,20 +1527,36 @@ static void ws_llc_mcps_edfe_handler(const mac_api_t *api, mcps_edfe_response_t
15001527

15011528
if (!message) {
15021529
//tr_debug("FC:Send a Final Frame");
1530+
if (test_drop_data_message) {
1531+
test_drop_data_message--;
1532+
base->edfe_rx_wait_timer += 99;
1533+
response_message->edfe_message_status = MCPS_EDFE_MALFORMED_FRAME;
1534+
return;
1535+
}
15031536
fc_ie.rx_flow_ctrl = 0;
1537+
base->edfe_rx_wait_timer = 0;
15041538
ws_llc_build_edfe_response(base, response_message, fc_ie);
15051539
response_message->edfe_message_status = MCPS_EDFE_FINAL_FRAME_TX;
15061540
} else {
1541+
if (test_skip_first_init_response) {
1542+
//Skip data send and test timeout at Slave side
1543+
test_skip_first_init_response = false;
1544+
response_message->edfe_message_status = MCPS_EDFE_FINAL_FRAME_RX;
1545+
return;
1546+
}
15071547
ws_llc_build_edfe_frame(message, response_message, fc_ie);
15081548
}
15091549

15101550
} else if (fc_ie.tx_flow_ctrl == 0 && fc_ie.rx_flow_ctrl == 0) {
15111551
//tr_debug("FC:Received a Final Frame");
1552+
base->edfe_rx_wait_timer = 0;
15121553
response_message->edfe_message_status = MCPS_EDFE_FINAL_FRAME_RX;
15131554
} else if (fc_ie.tx_flow_ctrl && fc_ie.rx_flow_ctrl) {
1555+
base->edfe_rx_wait_timer = fc_ie.tx_flow_ctrl + 99;
15141556
fc_ie.tx_flow_ctrl = 0;
15151557
fc_ie.rx_flow_ctrl = 255;
15161558
//tr_debug("FC:Send a response");
1559+
//Enable or refesh timeout timer
15171560
ws_llc_build_edfe_response(base, response_message, fc_ie);
15181561
response_message->edfe_message_status = MCPS_EDFE_RESPONSE_FRAME;
15191562
}
@@ -1771,6 +1814,39 @@ void ws_llc_hopping_schedule_config(struct protocol_interface_info_entry *interf
17711814
base->ie_params.hopping_schedule = hopping_schedule;
17721815
}
17731816

1817+
void ws_llc_fast_timer(struct protocol_interface_info_entry *interface, uint16_t ticks)
1818+
{
1819+
llc_data_base_t *base = ws_llc_discover_by_interface(interface);
1820+
if (!base || !base->edfe_rx_wait_timer) {
1821+
return;
1822+
}
1823+
1824+
if (ticks > 0xffff / 100) {
1825+
ticks = 0xffff;
1826+
} else if (ticks == 0) {
1827+
ticks = 1;
1828+
} else {
1829+
ticks *= 100;
1830+
}
1831+
1832+
if (base->edfe_rx_wait_timer > ticks) {
1833+
base->edfe_rx_wait_timer -= ticks;
1834+
} else {
1835+
base->edfe_rx_wait_timer = 0;
1836+
tr_debug("EDFE Data Wait Timeout");
1837+
//MAC edfe wait data timeout
1838+
if (interface->mac_api && interface->mac_api->mlme_req) {
1839+
mlme_set_t set_req;
1840+
uint8_t value = 0;
1841+
set_req.attr = macEdfeForceStop;
1842+
set_req.attr_index = 0;
1843+
set_req.value_pointer = &value;
1844+
set_req.value_size = 1;
1845+
interface->mac_api->mlme_req(interface->mac_api, MLME_SET, &set_req);
1846+
}
1847+
}
1848+
}
1849+
17741850
void ws_llc_timer_seconds(struct protocol_interface_info_entry *interface, uint16_t seconds_update)
17751851
{
17761852
llc_data_base_t *base = ws_llc_discover_by_interface(interface);

source/MAC/IEEE802_15_4/mac_mcps_sap.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1474,6 +1474,22 @@ static void mac_data_interface_internal_tx_confirm_handle(protocol_interface_rf_
14741474

14751475
}
14761476

1477+
static bool mcps_buffer_edfe_data_failure(protocol_interface_rf_mac_setup_s *rf_ptr, mac_pre_build_frame_t *buffer)
1478+
{
1479+
if (!rf_ptr->mac_edfe_enabled || !buffer->ExtendedFrameExchange) {
1480+
return false;
1481+
}
1482+
1483+
if (rf_ptr->mac_edfe_info->state > MAC_EDFE_FRAME_CONNECTING) {
1484+
//Set to idle
1485+
tr_debug("Edfe Data send fail");
1486+
return true;
1487+
}
1488+
1489+
return false;
1490+
}
1491+
1492+
14771493
static void mcps_data_confirm_handle(protocol_interface_rf_mac_setup_s *rf_ptr, mac_pre_build_frame_t *buffer, mac_pre_parsed_frame_t *ack_buf)
14781494
{
14791495

@@ -1482,7 +1498,7 @@ static void mcps_data_confirm_handle(protocol_interface_rf_mac_setup_s *rf_ptr,
14821498
mcps_data_conf_t confirm;
14831499
if (rf_ptr->fhss_api && !buffer->asynch_request) {
14841500
// FHSS checks if this failed buffer needs to be pushed back to TX queue and retransmitted
1485-
if ((rf_ptr->mac_tx_result == MAC_TX_FAIL) || (rf_ptr->mac_tx_result == MAC_CCA_FAIL)) {
1501+
if (!mcps_buffer_edfe_data_failure(rf_ptr, buffer) && ((rf_ptr->mac_tx_result == MAC_TX_FAIL) || (rf_ptr->mac_tx_result == MAC_CCA_FAIL))) {
14861502
if (rf_ptr->fhss_api->data_tx_fail(rf_ptr->fhss_api, buffer->msduHandle, mac_convert_frame_type_to_fhss(buffer->fcf_dsn.frametype), rf_ptr->mac_tx_start_channel) == true) {
14871503

14881504
if (rf_ptr->mac_tx_result == MAC_TX_FAIL) {
@@ -1495,6 +1511,11 @@ static void mcps_data_confirm_handle(protocol_interface_rf_mac_setup_s *rf_ptr,
14951511
return;
14961512
}
14971513
}
1514+
1515+
if (rf_ptr->mac_edfe_enabled && buffer->ExtendedFrameExchange) {
1516+
rf_ptr->mac_edfe_info->state = MAC_EDFE_FRAME_IDLE;
1517+
}
1518+
14981519
}
14991520
confirm.cca_retries = rf_ptr->mac_tx_status.cca_cnt + buffer->fhss_cca_retry_count;
15001521
confirm.tx_retries = rf_ptr->mac_tx_status.retry + buffer->fhss_retry_count;

source/MAC/IEEE802_15_4/mac_mlme.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,10 @@ static int8_t mac_mlme_boolean_set(protocol_interface_rf_mac_setup_s *rf_mac_set
512512
rf_mac_setup->dev_driver->phy_driver->extension(PHY_EXTENSION_ACCEPT_ANY_BEACON, (uint8_t *)&value);
513513
}
514514
break;
515+
516+
case macEdfeForceStop:
517+
return mac_data_edfe_force_stop(rf_mac_setup);
518+
515519
case macAcceptByPassUnknowDevice:
516520
rf_mac_setup->mac_security_bypass_unknow_device = value;
517521
break;

source/MAC/IEEE802_15_4/mac_pd_sap.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,17 @@ static void mac_data_ack_tx_finish(protocol_interface_rf_mac_setup_s *rf_ptr)
432432
}
433433
}
434434

435+
int8_t mac_data_edfe_force_stop(protocol_interface_rf_mac_setup_s *rf_ptr)
436+
{
437+
if (!rf_ptr->mac_edfe_enabled || rf_ptr->mac_edfe_info->state != MAC_EDFE_FRAME_WAIT_DATA) {
438+
return -1;
439+
}
440+
//Set to idle
441+
rf_ptr->mac_edfe_info->state = MAC_EDFE_FRAME_IDLE;
442+
mac_data_ack_tx_finish(rf_ptr);
443+
return 0;
444+
}
445+
435446
static int8_t mac_data_interface_tx_done_cb(protocol_interface_rf_mac_setup_s *rf_ptr, phy_link_tx_status_e status, uint8_t cca_retry, uint8_t tx_retry)
436447
{
437448

source/MAC/IEEE802_15_4/mac_pd_sap.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,6 @@ void mac_csma_backoff_start(struct protocol_interface_rf_mac_setup *rf_mac_setup
5959
*/
6060
void mac_pd_sap_state_machine(struct protocol_interface_rf_mac_setup *rf_mac_setup);
6161

62+
int8_t mac_data_edfe_force_stop(struct protocol_interface_rf_mac_setup *rf_ptr);
63+
6264
#endif /* MAC_PD_SAP_H_ */

test/nanostack/unittest/stub/mac_pd_sap_stub.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,8 @@ void mac_csma_backoff_start(protocol_interface_rf_mac_setup_s *rf_mac_setup)
8282
{
8383

8484
}
85+
86+
int8_t mac_data_edfe_force_stop(struct protocol_interface_rf_mac_setup *rf_ptr)
87+
{
88+
return 0;
89+
}

0 commit comments

Comments
 (0)