Skip to content

Nanostack patch release for Mbed OS 5.13.x #11156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions features/nanostack/coap-service/source/coap_message_handler.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2017, Arm Limited and affiliates.
* Copyright (c) 2015-2019, Arm Limited and affiliates.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -192,14 +192,16 @@ static int8_t coap_rx_function(sn_coap_hdr_s *resp_ptr, sn_nsdl_addr_s *address_
coap_transaction_t *this = NULL;
(void)param;

if (resp_ptr->coap_status == COAP_STATUS_BUILDER_BLOCK_SENDING_DONE) {
return 0;
if (!resp_ptr || !address_ptr) {
return -1;
}

tr_warn("transaction was not handled %d", resp_ptr->msg_id);
if (!resp_ptr || !address_ptr) {
return -1;

if (resp_ptr->coap_status == COAP_STATUS_BUILDER_BLOCK_SENDING_DONE) {
return 0;
}

if (resp_ptr->token_ptr) {
this = transaction_find_client_by_token(resp_ptr->token_ptr, resp_ptr->token_len, address_ptr->addr_ptr, address_ptr->port);
}
Expand Down
1 change: 1 addition & 0 deletions features/nanostack/sal-stack-nanostack/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ $(TESTDIRS):

$(CLEANTESTDIRS):
@make -C $(@:clean-%=%) clean
@rm -fr results

.PHONY: release
release:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ typedef struct fhss_statistics {

/** FHSS synchronization lost counter. */
uint32_t fhss_synch_lost;

/** FHSS TX to unknown neighbour counter. */
uint32_t fhss_unknown_neighbor;

/** FHSS channel retry counter. */
uint32_t fhss_channel_retry;
} fhss_statistics_t;

/**
Expand Down
8 changes: 8 additions & 0 deletions features/nanostack/sal-stack-nanostack/nanostack/net_fhss.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ extern int ns_fhss_ws_configuration_set(const fhss_api_t *fhss_api, const fhss_w
*/
extern int ns_fhss_delete(fhss_api_t *fhss_api);

/**
* @brief Starts collecting FHSS statistics.
* @param fhss_api FHSS instance.
* @param fhss_statistics Pointer to stored statistics.
* @return 0 on success, -1 on fail.
*/
extern int ns_fhss_statistics_start(const fhss_api_t *fhss_api, fhss_statistics_t *fhss_statistics);


#ifdef __cplusplus
}
Expand Down
62 changes: 62 additions & 0 deletions features/nanostack/sal-stack-nanostack/nanostack/ns_conf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2019, Arm Limited and affiliates.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef _NS_CONF_H_
#define _NS_CONF_H_

#ifdef __cplusplus
extern "C" {
#endif

/**
* \file ns_conf.h
* \brief Nanostack configuration API.
*/

/**
* \brief Set threshold for memory garbage collection.
*
* Nanostack heap usage is monitored in regular intervals. If too much memory has been used then garbage collection (GC)
* is triggered. GC has two adjustable thresholds: HIGH and CRITICAL. HIGH threshold is lower one and once exceeded
* a GC will try to release memory that is used for caching. When CRITTICAL threshold is exceeded them GC will try to release
* memory more aggressiveliy.
*
* Nanostack memory monitoring can only work if memory statistics are enabled in nsdynmemLIB.

*
* \param percentage_high Percentage of total heap when garbage collection is first time triggered
* \param percentage_critical Percentage of total heap when critical garbage collection is triggered
*
* \return 0 in success, negative value in case of error.
*
*/
int ns_conf_gc_threshold_set(uint8_t percentage_high, uint8_t percentage_critical);

/**
* \brief Limit amount of incoming packets if system does not have enough free memory.
* Memory statistics must been initialized in nsdynmemLIB to get this feature working.
*
* \param free_heap_percentage Percentage of free heap that must be available when packet arrives to MAC layer.
* \return 0 in case of success, <0 otherwise.
*/
int ns_conf_packet_ingress_rate_limit_by_mem(uint8_t free_heap_percentage);

#ifdef __cplusplus
}
#endif

#endif /* _NS_CONF_H_ */
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
#ifndef _NS_FILE_SYSTEM_H_
#define _NS_FILE_SYSTEM_H_

#ifdef __cplusplus
extern "C" {
#endif

/**
* \file ns_file_system.h
* \brief Nanostack file system API.
Expand All @@ -35,9 +39,7 @@
* \return 0 in success, negative value in case of error.
*
*/
#ifdef __cplusplus
extern "C" {
#endif

int ns_file_system_set_root_path(const char *root_path);

/**
Expand All @@ -47,6 +49,7 @@ int ns_file_system_set_root_path(const char *root_path);
*
*/
char *ns_file_system_get_root_path(void);

#ifdef __cplusplus
}
#endif
Expand Down
9 changes: 8 additions & 1 deletion features/nanostack/sal-stack-nanostack/nanostack/sw_mac.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2018, Arm Limited and affiliates.
* Copyright (c) 2016-2019, Arm Limited and affiliates.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -81,6 +81,13 @@ extern struct fhss_api *ns_sw_mac_get_fhss_api(struct mac_api_s *mac_api);
*/
extern int ns_sw_mac_statistics_start(struct mac_api_s *mac_api, struct mac_statistics_s *mac_statistics);

/**
* @brief Read current timestamp.
* @param mac_api MAC instance.
* @return Current timestamp in us
*/
extern uint32_t ns_sw_mac_read_current_timestamp(struct mac_api_s *mac_api);

#ifdef __cplusplus
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ extern "C" {

#define NETWORK_SIZE_AUTOMATIC 0x00
#define NETWORK_SIZE_SMALL 0x01
#define NETWORK_SIZE_MEDIUM 0x08
#define NETWORK_SIZE_LARGE 0x10


Expand All @@ -85,6 +86,16 @@ extern "C" {
*/
#define WS_MANAGEMENT_API_VER_2

/**
* \brief Struct ws_statistics defines the Wi-SUN statistics storage structure.
*/
typedef struct ws_statistics {
/** Asynch TX counter */
uint32_t asynch_tx_count;
/** Asynch RX counter */
uint32_t asynch_rx_count;
} ws_statistics_t;

/**
* Initialize Wi-SUN stack.
*
Expand Down Expand Up @@ -255,6 +266,30 @@ int ws_management_fhss_broadcast_channel_function_configure(
uint8_t dwell_interval,
uint32_t broadcast_interval);

/**
* Start collecting Wi-SUN statistics.
*
* \param interface_id Network interface ID.
* \param stats_ptr Pointer to stored statistics.
*
* \return 0 Success.
* \return <0 Failure.
*/
int ws_statistics_start(
int8_t interface_id,
ws_statistics_t *stats_ptr);

/**
* Stop collecting Wi-SUN statistics.
*
* \param interface_id Network interface ID.
*
* \return 0 Success.
* \return <0 Failure.
*/
int ws_statistics_stop(
int8_t interface_id);

#ifdef __cplusplus
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1605,7 +1605,7 @@ static void lowpan_neighbor_entry_remove_notify(mac_neighbor_table_entry_t *entr
protocol_6lowpan_release_short_link_address_from_neighcache(cur_interface, entry_ptr->mac16);
protocol_6lowpan_release_long_link_address_from_neighcache(cur_interface, entry_ptr->mac64);
}
mac_helper_devicetable_remove(cur_interface->mac_api, entry_ptr->index);
mac_helper_devicetable_remove(cur_interface->mac_api, entry_ptr->index, entry_ptr->mac64);
//Removes ETX neighbor
etx_neighbor_remove(cur_interface->id, entry_ptr->index);
//Remove MLE frame counter info
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ int8_t mac_helper_link_frame_counter_set(int8_t interface_id, uint32_t seq_ptr)
return 0;
}

void mac_helper_devicetable_remove(mac_api_t *mac_api, uint8_t attribute_index)
void mac_helper_devicetable_remove(mac_api_t *mac_api, uint8_t attribute_index, uint8_t *mac64)
{
if (!mac_api) {
return;
Expand All @@ -880,7 +880,7 @@ void mac_helper_devicetable_remove(mac_api_t *mac_api, uint8_t attribute_index)
set_req.attr_index = attribute_index;
set_req.value_pointer = (void *)&device_desc;
set_req.value_size = sizeof(mlme_device_descriptor_t);
tr_debug("unRegister Device");
tr_debug("Unregister Device %u, mac64: %s", attribute_index, trace_array(mac64, 8));
mac_api->mlme_req(mac_api, MLME_SET, &set_req);
}

Expand Down Expand Up @@ -910,7 +910,7 @@ void mac_helper_devicetable_set(const mlme_device_descriptor_t *device_desc, pro
set_req.attr_index = attribute_index;
set_req.value_pointer = (void *)device_desc;
set_req.value_size = sizeof(mlme_device_descriptor_t);
tr_debug("Register Device");
tr_debug("Register Device %u, mac16 %x mac64: %s, %"PRIu32, attribute_index, device_desc->ShortAddress, trace_array(device_desc->ExtAddress, 8), device_desc->FrameCounter);
cur->mac_api->mlme_req(cur->mac_api, MLME_SET, &set_req);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ int8_t mac_helper_link_frame_counter_read(int8_t interface_id, uint32_t *seq_ptr

int8_t mac_helper_link_frame_counter_set(int8_t interface_id, uint32_t seq_ptr);

void mac_helper_devicetable_remove(struct mac_api_s *mac_api, uint8_t attribute_index);
void mac_helper_devicetable_remove(struct mac_api_s *mac_api, uint8_t attribute_index, uint8_t *mac64);

void mac_helper_device_description_write(struct protocol_interface_info_entry *cur, mlme_device_descriptor_t *device_desc, uint8_t *mac64, uint16_t mac16, uint32_t frame_counter, bool exempt);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -855,8 +855,14 @@ static void nd_update_registration(protocol_interface_info_entry_t *cur_interfac
*/
mac_neighbor_table_entry_t *entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur_interface), ipv6_neighbour_eui64(&cur_interface->ipv6_neighbour_cache, neigh), ADDR_802_15_4_LONG);

if (entry && !entry->ffd_device) {
rpl_control_publish_host_address(protocol_6lowpan_rpl_domain, neigh->ip_address, neigh->lifetime);
if (entry) {
if (ws_info(cur_interface)) {
ws_common_etx_validate(cur_interface, entry);
}

if (!entry->ffd_device) {
rpl_control_publish_host_address(protocol_6lowpan_rpl_domain, neigh->ip_address, neigh->lifetime);
}
}
protocol_6lowpan_neighbor_address_state_synch(cur_interface, aro->eui64, neigh->ip_address + 8);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2015,7 +2015,7 @@ void thread_reset_neighbour_info(protocol_interface_info_entry_t *cur, mac_neigh
thread_routing_remove_link(cur, neighbour->mac16);
thread_router_bootstrap_reset_child_info(cur, neighbour);
protocol_6lowpan_release_long_link_address_from_neighcache(cur, neighbour->mac64);
mac_helper_devicetable_remove(cur->mac_api, neighbour->index);
mac_helper_devicetable_remove(cur->mac_api, neighbour->index, neighbour->mac64);
thread_neighbor_class_entry_remove(&cur->thread_info->neighbor_class, neighbour->index);
}

Expand Down
Loading