Skip to content

Commit 445745a

Browse files
Juha Heiskanenjuhhei01
authored andcommitted
LLC Neighbor, Mac packet rebuild, mac timer update and phy Extension.
Added PHY_LINK_CCA_PREPARE RF event type to indicate RX Tx timeout prepare operation like channel switch to Tx channel from Receive one. Packet build process splitted to common functions and main packet build have been splitted Init and rebuild. FHSS support now packet rebuild if aftre every CCA Process Start. MAC_TIMER_CCA is not used anymore with FHSS and that affect that RF driver must support tx_time set and new radio drivent callback event for chennel switch. LLC create updated by neighbour request information for allocate and discover neighbor. Change-Id: I41553ac5e5c945a188bc168426bd94b16eddbe74
1 parent 6cb78ff commit 445745a

File tree

14 files changed

+435
-141
lines changed

14 files changed

+435
-141
lines changed

nanostack/platform/arm_hal_phy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ typedef enum {
4545
PHY_LINK_TX_SUCCESS, /**< MAC TX complete. MAC will a make decision to enter wait ACK or TX done state. */
4646
PHY_LINK_TX_FAIL, /**< Link TX process fail. */
4747
PHY_LINK_CCA_FAIL, /**< RF link CCA process fail. */
48+
PHY_LINK_CCA_PREPARE, /**< RX Tx timeout prepare operation like channel switch to Tx channel from Receive one If operation fail must return not zero*/
4849
} phy_link_tx_status_e;
4950

5051
/** Extension types */

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 54 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,16 @@ static bool ws_bootstrap_state_discovery(struct protocol_interface_info_entry *c
8484
static bool ws_bootstrap_state_wait_rpl(struct protocol_interface_info_entry *cur);
8585
static int8_t ws_bootsrap_event_trig(ws_bootsrap_event_type_e event_type, int8_t interface_id, arm_library_event_priority_e priority, void *event_data);
8686

87-
static mac_neighbor_table_entry_t * ws_bootstrap_mac_neighbor_add(struct protocol_interface_info_entry *interface, const uint8_t *src64)
87+
static bool ws_bootstrap_neighbor_info_request(struct protocol_interface_info_entry *interface, const uint8_t *mac_64, llc_neighbour_req_t * neighbor_buffer, bool request_new);
88+
89+
mac_neighbor_table_entry_t * ws_bootstrap_mac_neighbor_add(struct protocol_interface_info_entry *interface, const uint8_t *src64)
8890
{
8991
mac_neighbor_table_entry_t *neighbor = mac_neighbor_table_address_discover(interface->mac_parameters->mac_neighbor_table, src64, MAC_ADDR_MODE_64_BIT);
90-
if (!neighbor) {
91-
neighbor = mac_neighbor_table_entry_allocate(interface->mac_parameters->mac_neighbor_table, src64);
92+
if (neighbor) {
93+
return neighbor;
9294
}
95+
96+
neighbor = mac_neighbor_table_entry_allocate(interface->mac_parameters->mac_neighbor_table, src64);
9397
if (!neighbor) {
9498
return NULL;
9599
}
@@ -101,21 +105,6 @@ static mac_neighbor_table_entry_t * ws_bootstrap_mac_neighbor_add(struct protoco
101105
return neighbor;
102106
}
103107

104-
static ws_neighbor_class_entry_t * ws_bootstrap_neighbor_add(struct protocol_interface_info_entry *interface, const uint8_t *src64)
105-
{
106-
mac_neighbor_table_entry_t *neighbor = ws_bootstrap_mac_neighbor_add(interface, src64);
107-
if (!neighbor) {
108-
return NULL;
109-
}
110-
111-
ws_neighbor_class_entry_t *ws_neighbor = ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, neighbor->index);
112-
if (!ws_neighbor) {
113-
mac_neighbor_table_neighbor_remove(interface->mac_parameters->mac_neighbor_table, neighbor);
114-
return NULL;
115-
}
116-
return ws_neighbor;
117-
}
118-
119108
static void ws_bootstrap_neighbor_delete(struct protocol_interface_info_entry *interface, uint8_t attribute_index)
120109
{
121110
mac_helper_devicetable_remove(interface->mac_api, attribute_index);
@@ -487,18 +476,17 @@ static void ws_bootstrap_pan_config_analyse(struct protocol_interface_info_entry
487476
tr_error("No broadcast schedule");
488477
return;
489478
}
490-
491-
ws_neighbor_class_entry_t *neighbor = ws_bootstrap_neighbor_add(cur, data->SrcAddr);
492-
if (!neighbor) {
479+
llc_neighbour_req_t neighbor_info;
480+
if (!ws_bootstrap_neighbor_info_request(cur, data->SrcAddr, &neighbor_info, true) ) {
493481
return;
494482
}
495483

496-
etx_lqi_dbm_update(cur->id, data->mpduLinkQuality, data->signal_dbm, ws_neighbor_class_entry_index_get(&cur->ws_info->neighbor_storage,neighbor));
484+
etx_lqi_dbm_update(cur->id, data->mpduLinkQuality, data->signal_dbm, neighbor_info.neighbor->index);
497485
//Update Neighbor Broadcast and Unicast Parameters
498-
ws_neighbor_class_neighbor_unicast_time_info_update(neighbor, ws_utt, data->timestamp);
499-
ws_neighbor_class_neighbor_unicast_schedule_set(neighbor, ws_us);
500-
ws_neighbor_class_neighbor_broadcast_time_info_update(neighbor, &ws_bt_ie, data->timestamp);
501-
ws_neighbor_class_neighbor_broadcast_schedule_set(neighbor, &ws_bs_ie);
486+
ws_neighbor_class_neighbor_unicast_time_info_update(neighbor_info.ws_neighbor, ws_utt, data->timestamp);
487+
ws_neighbor_class_neighbor_unicast_schedule_set(neighbor_info.ws_neighbor, ws_us);
488+
ws_neighbor_class_neighbor_broadcast_time_info_update(neighbor_info.ws_neighbor, &ws_bt_ie, data->timestamp);
489+
ws_neighbor_class_neighbor_broadcast_schedule_set(neighbor_info.ws_neighbor, &ws_bs_ie);
502490

503491
if (cur->ws_info->configuration_learned &&
504492
common_serial_number_greater_16(cur->ws_info->pan_configuration.pan_version, pan_version)) {
@@ -537,7 +525,7 @@ static void ws_bootstrap_pan_config_analyse(struct protocol_interface_info_entry
537525

538526
cur->ws_info->hopping_schdule.channel_function = ws_bs_ie.channel_function;
539527
// TODO: Restart unicast schedule if configuration changed
540-
ns_fhss_ws_set_parent(cur->ws_info->fhss_api, data->SrcAddr, &neighbor->fhss_data.bc_timing_info);
528+
ns_fhss_ws_set_parent(cur->ws_info->fhss_api, data->SrcAddr, &neighbor_info.ws_neighbor->fhss_data.bc_timing_info);
541529

542530
if (!cur->ws_info->configuration_learned) {
543531
// Generate own hopping schedules Follow first parent broadcast and plans and also use same unicast dwell
@@ -563,13 +551,14 @@ static void ws_bootstrap_pan_config_solicit_analyse(struct protocol_interface_in
563551
*
564552
*/
565553

566-
ws_neighbor_class_entry_t *neighbor = ws_bootstrap_neighbor_add(cur, data->SrcAddr);
567-
if (!neighbor) {
554+
llc_neighbour_req_t neighbor_info;
555+
if (!ws_bootstrap_neighbor_info_request(cur, data->SrcAddr, &neighbor_info, true) ) {
568556
return;
569557
}
570558

571-
ws_neighbor_class_neighbor_unicast_time_info_update(neighbor, ws_utt, data->timestamp);
572-
ws_neighbor_class_neighbor_unicast_schedule_set(neighbor, ws_us);
559+
etx_lqi_dbm_update(cur->id, data->mpduLinkQuality, data->signal_dbm, neighbor_info.neighbor->index);
560+
ws_neighbor_class_neighbor_unicast_time_info_update(neighbor_info.ws_neighbor, ws_utt, data->timestamp);
561+
ws_neighbor_class_neighbor_unicast_schedule_set(neighbor_info.ws_neighbor, ws_us);
573562

574563
/*
575564
* A consistent transmission is defined as a PAN Configuration Solicit with
@@ -665,6 +654,35 @@ static void ws_bootstrap_asynch_confirm(struct protocol_interface_info_entry *in
665654
(void)asynch_message;
666655
}
667656

657+
static bool ws_bootstrap_neighbor_info_request(struct protocol_interface_info_entry *interface, const uint8_t *mac_64, llc_neighbour_req_t * neighbor_buffer, bool request_new)
658+
{
659+
neighbor_buffer->neighbor = mac_neighbor_table_address_discover(interface->mac_parameters->mac_neighbor_table, mac_64, ADDR_802_15_4_LONG);
660+
if (neighbor_buffer->neighbor) {
661+
neighbor_buffer->ws_neighbor = ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, neighbor_buffer->neighbor->index);
662+
if (!neighbor_buffer->ws_neighbor) {
663+
return false;
664+
}
665+
return true;
666+
}
667+
if (!request_new) {
668+
return false;
669+
}
670+
671+
neighbor_buffer->neighbor = ws_bootstrap_mac_neighbor_add(interface, mac_64);
672+
673+
if (!neighbor_buffer->neighbor) {
674+
return false;
675+
}
676+
677+
neighbor_buffer->ws_neighbor = ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, neighbor_buffer->neighbor->index);
678+
if (!neighbor_buffer->ws_neighbor) {
679+
mac_helper_devicetable_remove(interface->mac_api, neighbor_buffer->neighbor->index);
680+
mac_neighbor_table_neighbor_remove(interface->mac_parameters->mac_neighbor_table, neighbor_buffer->neighbor);
681+
return false;
682+
}
683+
return true;
684+
}
685+
668686

669687
static void ws_neighbor_entry_remove_notify(mac_neighbor_table_entry_t *entry_ptr, void *user_data)
670688
{
@@ -761,7 +779,7 @@ int ws_bootstrap_init(int8_t interface_id, net_6lowpan_mode_e bootstrap_mode)
761779
goto init_fail;
762780
}
763781

764-
ws_llc_create(cur, &ws_bootstrap_asynch_ind, &ws_bootstrap_asynch_confirm);
782+
ws_llc_create(cur, &ws_bootstrap_asynch_ind, &ws_bootstrap_asynch_confirm, &ws_bootstrap_neighbor_info_request);
765783

766784
mpx_api_t *mpx_api = ws_llc_mpx_api_get(cur);
767785
if (!mpx_api) {
@@ -1227,13 +1245,13 @@ void ws_bootstrap_network_scan_process(protocol_interface_info_entry_t *cur)
12271245
tr_info("select network");
12281246

12291247
// Add EAPOL neighbour
1230-
ws_neighbor_class_entry_t *neighbor = ws_bootstrap_neighbor_add(cur, cur->ws_info->parent_info.addr);
1231-
if (!neighbor) {
1248+
llc_neighbour_req_t neighbor_info;
1249+
if (!ws_bootstrap_neighbor_info_request(cur, cur->ws_info->parent_info.addr, &neighbor_info, true) ) {
12321250
return;
12331251
}
12341252

1235-
ws_neighbor_class_neighbor_unicast_time_info_update(neighbor, &cur->ws_info->parent_info.ws_utt, cur->ws_info->parent_info.timestamp);
1236-
ws_neighbor_class_neighbor_unicast_schedule_set(neighbor, &cur->ws_info->parent_info.ws_us);
1253+
ws_neighbor_class_neighbor_unicast_time_info_update(neighbor_info.ws_neighbor, &cur->ws_info->parent_info.ws_utt, cur->ws_info->parent_info.timestamp);
1254+
ws_neighbor_class_neighbor_unicast_schedule_set(neighbor_info.ws_neighbor, &cur->ws_info->parent_info.ws_us);
12371255

12381256
ws_bootstrap_network_information_learn(cur);
12391257
ws_bootstrap_fhss_activate(cur);

source/6LoWPAN/ws/ws_llc.h

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,18 @@
1818
#ifndef WS_LLC_H_
1919
#define WS_LLC_H_
2020

21+
#include "6LoWPAN/ws/ws_neighbor_class.h"
22+
#include "Service_Libs/mac_neighbor_table/mac_neighbor_table.h"
23+
2124
struct protocol_interface_info_entry;
2225
struct mcps_data_ind_s;
2326
struct mcps_data_ie_list;
2427
struct channel_list_s;
2528
struct ws_pan_information_s;
2629
struct mlme_security_s;
2730
struct ws_hopping_schedule_s;
31+
struct ws_neighbor_class_entry;
32+
struct mac_neighbor_table_entry;
2833

2934

3035
/**
@@ -62,6 +67,15 @@ typedef struct asynch_request_s {
6267
struct channel_list_s channel_list; /**< Channel List. */
6368
} asynch_request_t;
6469

70+
71+
/**
72+
* @brief LLC neighbour info request parameters
73+
*/
74+
typedef struct llc_neighbour_req {
75+
struct mac_neighbor_table_entry *neighbor; /**< Generic Link Layer Neighbor information entry. */
76+
struct ws_neighbor_class_entry *ws_neighbor; /**< Wi-sun Neighbor information entry. */
77+
} llc_neighbour_req_t;
78+
6579
/**
6680
* @brief ws_asynch_ind ws asynch data indication
6781
* @param interface Interface pointer
@@ -78,15 +92,27 @@ typedef void ws_asynch_ind(struct protocol_interface_info_entry *interface, cons
7892
*/
7993
typedef void ws_asynch_confirm(struct protocol_interface_info_entry *interface, uint8_t asynch_message);
8094

95+
/**
96+
* @brief ws_asynch_confirm ws asynch data confirmation to asynch message request
97+
* @param interface The interface pointer
98+
* @param mac_64 Neighbor 64-bit address
99+
* @param neighbor_buffer Buffer where neighbor infor is buffered
100+
* @param request_new true if is possible to allocate new entry
101+
*
102+
* @return true when neighbor info is available
103+
* @return false when no neighbor info
104+
*/
105+
typedef bool ws_neighbor_info_request(struct protocol_interface_info_entry *interface, const uint8_t *mac_64, llc_neighbour_req_t * neighbor_buffer, bool request_new);
106+
81107
/**
82108
* @brief ws_llc_create ws LLC module create
83109
* @param interface Interface pointer
84-
* @param data MCPS-DATA.indication specific values
110+
* @param asynch_ind_cb Asynch indication
85111
* @param ie_ext Information element list
86112
*
87113
* Function allocate and init LLC class and init it 2 supported 2 API: ws asynch and MPX user are internally registered.
88114
*/
89-
int8_t ws_llc_create(struct protocol_interface_info_entry *interface, ws_asynch_ind *asynch_ind_cb, ws_asynch_confirm *asynch_cnf_cb);
115+
int8_t ws_llc_create(struct protocol_interface_info_entry *interface, ws_asynch_ind *asynch_ind_cb, ws_asynch_confirm *asynch_cnf_cb, ws_neighbor_info_request *ws_neighbor_info_request_cb);
90116

91117
/**
92118
* @brief ws_llc_reset Reset ws LLC parametrs and clean messages

0 commit comments

Comments
 (0)