Skip to content

Nanostack release for Mbed OS 6 #12481

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 7 commits into from
Feb 25, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ static rf_mode_e rf_mode = RF_MODE_NORMAL;
static bool rf_update_config = false;
static uint16_t cur_packet_len = 0xffff;
static uint32_t receiver_ready_timestamp;

static int16_t rssi_threshold = RSSI_THRESHOLD;
static uint32_t tx_start_time = 0;

/* Channel configurations for sub-GHz */
static phy_rf_channel_configuration_s phy_subghz = {
Expand Down Expand Up @@ -276,6 +276,20 @@ static uint32_t rf_get_timestamp(void)
return (uint32_t)rf->tx_timer.read_us();
}

static void rf_update_tx_active_time(void)
{
if (device_driver.phy_rf_statistics) {
device_driver.phy_rf_statistics->tx_active_time += rf_get_timestamp() - tx_start_time;
}
}

static void rf_update_rx_active_time(void)
{
if (device_driver.phy_rf_statistics) {
device_driver.phy_rf_statistics->rx_active_time += rf_get_timestamp() - rx_time;
}
}

static void rf_lock(void)
{
platform_enter_critical();
Expand Down Expand Up @@ -739,6 +753,7 @@ static void rf_tx_sent_handler(void)
rf_disable_interrupt(TX_DATA_SENT);
if (rf_state != RF_TX_ACK) {
tx_finnish_time = rf_get_timestamp();
rf_update_tx_active_time();
TEST_TX_DONE
rf_state = RF_IDLE;
rf_receive(rf_rx_channel);
Expand Down Expand Up @@ -771,6 +786,7 @@ static void rf_start_tx(void)
rf_disable_all_interrupts();
rf_poll_state_change(S2LP_STATE_READY);
rf_state_change(S2LP_STATE_TX, false);
tx_start_time = rf_get_timestamp();
// More TX data to be written in FIFO when TX threshold interrupt occurs
if (tx_data_ptr) {
rf_enable_interrupt(TX_FIFO_ALMOST_EMPTY);
Expand Down Expand Up @@ -805,6 +821,7 @@ static void rf_cca_timer_interrupt(void)
}
rf_flush_tx_fifo();
tx_finnish_time = rf_get_timestamp();
rf_update_tx_active_time();
if (device_driver.phy_tx_done_cb) {
device_driver.phy_tx_done_cb(rf_radio_driver_id, mac_tx_handle, PHY_LINK_CCA_FAIL, 0, 0);
}
Expand All @@ -825,6 +842,9 @@ static void rf_cca_timer_interrupt(void)
rf_start_tx();
rf_state = RF_TX_STARTED;
TEST_TX_STARTED
if (device_driver.phy_rf_statistics) {
device_driver.phy_rf_statistics->tx_bytes += tx_data_length;
}
}
}
}
Expand All @@ -843,10 +863,12 @@ static void rf_backup_timer_interrupt(void)
{
tx_finnish_time = rf_get_timestamp();
if (rf_state == RF_RX_STARTED) {
rf_update_rx_active_time();
if (device_driver.phy_rf_statistics) {
device_driver.phy_rf_statistics->rx_timeouts++;
}
} else {
rf_update_tx_active_time();
if (device_driver.phy_rf_statistics) {
device_driver.phy_rf_statistics->tx_timeouts++;
}
Expand Down Expand Up @@ -921,13 +943,17 @@ static void rf_send_ack(uint8_t seq)
rf_start_tx();
TEST_ACK_TX_STARTED
rf_backup_timer_start(ACK_SENDING_TIME);
if (device_driver.phy_rf_statistics) {
device_driver.phy_rf_statistics->tx_bytes += sizeof(ack_frame);
}
}

static void rf_handle_ack(uint8_t seq_number, uint8_t pending)
{
phy_link_tx_status_e phy_status;
if (tx_sequence == (uint16_t)seq_number) {
tx_finnish_time = rf_get_timestamp();
rf_update_tx_active_time();
if (pending) {
phy_status = PHY_LINK_TX_DONE_PENDING;
} else {
Expand Down Expand Up @@ -966,6 +992,9 @@ static void rf_rx_ready_handler(void)
rf_send_ack(rx_buffer[2]);
}
}
if (device_driver.phy_rf_statistics) {
device_driver.phy_rf_statistics->rx_bytes += rx_data_length;
}
} else {
rf_state = RF_IDLE;
int8_t rssi = (rf_read_register(RSSI_LEVEL) - RSSI_OFFSET);
Expand Down Expand Up @@ -1072,6 +1101,7 @@ static void rf_irq_task_process_irq(void)
if ((irq_status & (1 << TX_FIFO_UNF_OVF)) && (enabled_interrupts & (1 << TX_FIFO_UNF_OVF))) {
rf_backup_timer_stop();
tx_finnish_time = rf_get_timestamp();
rf_update_tx_active_time();
TEST_TX_DONE
device_driver.phy_tx_done_cb(rf_radio_driver_id, mac_tx_handle, PHY_LINK_CCA_FAIL, 1, 0);
rf_send_command(S2LP_CMD_SABORT);
Expand All @@ -1087,6 +1117,7 @@ static void rf_irq_task_process_irq(void)
}
} else if (rf_state == RF_RX_STARTED) {
if ((irq_status & (1 << RX_DATA_READY)) && (enabled_interrupts & (1 << RX_DATA_READY))) {
rf_update_rx_active_time();
if (!(irq_status & (1 << CRC_ERROR))) {
rf_rx_ready_handler();
} else {
Expand All @@ -1112,6 +1143,7 @@ static void rf_irq_task_process_irq(void)
}
}
if ((irq_status & (1 << RX_FIFO_UNF_OVF)) && (enabled_interrupts & (1 << RX_FIFO_UNF_OVF))) {
rf_update_rx_active_time();
TEST_RX_DONE
rf_backup_timer_stop();
rf_send_command(S2LP_CMD_SABORT);
Expand Down
3 changes: 2 additions & 1 deletion features/nanostack/sal-stack-nanostack/nanostack/fhss_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,10 @@ typedef void fhss_data_tx_done(const fhss_api_t *api, bool waiting_ack, bool tx_
* @param api FHSS instance.
* @param handle Handle of the data request.
* @param frame_type Frame type of packet (Frames types are defined by FHSS api).
* @param channel Channel wanted to black list temporarily.
* @return true if frame has to be queued for retransmission, false otherwise.
*/
typedef bool fhss_data_tx_fail(const fhss_api_t *api, uint8_t handle, int frame_type);
typedef bool fhss_data_tx_fail(const fhss_api_t *api, uint8_t handle, int frame_type, uint8_t channel);

/**
* @brief Change synchronization state.
Expand Down
46 changes: 46 additions & 0 deletions features/nanostack/sal-stack-nanostack/nanostack/fhss_test_api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2020, 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.
*/

/**
* \file fhss_test_api.h
* \brief
*/

#ifndef FHSS_TEST_API_H
#define FHSS_TEST_API_H


#ifdef __cplusplus
extern "C" {
#endif

/**
* \brief Set optimal packet length
*
* \param fhss_api FHSS instance.
* \param packet_length Optimal packet length
*
* \return 0 Success
* \return -1 Failure
*/
int8_t fhss_set_optimal_packet_length(const fhss_api_t *fhss_api, uint16_t packet_length);

#ifdef __cplusplus
}
#endif

#endif // FHSS_TEST_API_H
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ typedef enum {
CHANNEL_PAGE_5 = 5, ///< Page 5
CHANNEL_PAGE_6 = 6, ///< Page 6
CHANNEL_PAGE_9 = 9, ///< Page 9
CHANNEL_PAGE_10 = 10 ///< Page 10
CHANNEL_PAGE_10 = 10, ///< Page 10
CHANNEL_PAGE_UNDEFINED ///< Undefined
} channel_page_e;

/** Modulation index */
Expand Down Expand Up @@ -192,6 +193,10 @@ typedef struct phy_rf_statistics_s {
uint32_t crc_fails; ///< CRC failures
uint32_t tx_timeouts; ///< transmission timeouts
uint32_t rx_timeouts; ///< reception timeouts
uint64_t tx_active_time; ///< transmission active time
uint64_t rx_active_time; ///< reception active time
uint32_t tx_bytes; ///< transmitted bytes
uint32_t rx_bytes; ///< received bytes
} phy_rf_statistics_s;

/** Virtual data request */
Expand Down
7 changes: 7 additions & 0 deletions features/nanostack/sal-stack-nanostack/nanostack/sw_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ extern int8_t ns_sw_mac_virtual_client_unregister(struct mac_api_s *api);
*/
extern int ns_sw_mac_fhss_register(struct mac_api_s *mac_api, struct fhss_api *fhss_api);

/**
* @brief Unregister FHSS API instance from given software MAC instance.
* @param mac_api MAC instance.
* @return 0 on success, -1 on fail.
*/
extern int ns_sw_mac_fhss_unregister(struct mac_api_s *mac_api);

/**
* @brief Request registered FHSS API instance from software MAC instance.
* @param mac_api MAC instance.
Expand Down
12 changes: 4 additions & 8 deletions features/nanostack/sal-stack-nanostack/nanostack/ws_bbr_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,10 @@ int ws_bbr_start(int8_t interface_id, int8_t backbone_interface_id);
/**
* Border router configuration options
*/
#define BBR_ULA_C 0x0001 /**< Static ULA prefix created automatically */
#define BBR_GUA_ROUTE 0x0002 /**< More specific route is added for GUA prefix */
#define BBR_BB_WAIT 0x0004 /**< Wait backbone availability before starting Wi-SUN network */

/*Deprecated configuration values */
#define BBR_GUA_C 0x0000 /**< Routable prefix is learned from the backbone */
#define BBR_GUA_SLAAC 0x0000 /**< Use SLAAC addressing in routable prefix */
#define BBR_GUA_WAIT 0x0000 /**< Wait backbone availability before startingRPL dodag */
#define BBR_ULA_C 0x0001 /**< Static ULA prefix created automatically */
#define BBR_GUA_ROUTE 0x0002 /**< More specific route is added for GUA prefix */
#define BBR_BB_WAIT 0x0004 /**< Wait backbone availability before starting Wi-SUN network */
#define BBR_DEFAULT_ROUTE 0x0008 /**< Add default route parameter to DIO */

/**
* Configure border router features.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1379,6 +1379,8 @@ static int8_t arm_6lowpan_bootstrap_down(protocol_interface_info_entry_t *cur)
}
cur->if_lowpan_security_params->mle_security_frame_counter = mle_service_security_get_frame_counter(cur->id);
mle_service_interface_receiver_handler_update(cur->id, mle_6lowpan_message_handler);
// Reset MAC for safe upper layer memory free
protocol_mac_reset(cur);
return nwk_6lowpan_down(cur);
}
#ifdef HAVE_6LOWPAN_ND
Expand Down Expand Up @@ -1593,7 +1595,7 @@ static void lowpan_neighbor_entry_remove_notify(mac_neighbor_table_entry_t *entr
{

protocol_interface_info_entry_t *cur_interface = user_data;
lowpan_adaptation_remove_free_indirect_table(cur_interface, entry_ptr);
lowpan_adaptation_neigh_remove_free_tx_tables(cur_interface, entry_ptr);
// Sleepy host
if (cur_interface->lowpan_info & INTERFACE_NWK_CONF_MAC_RX_OFF_IDLE) {
mac_data_poll_protocol_poll_mode_decrement(cur_interface);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@
#include "6LoWPAN/Fragmentation/cipv6_fragmenter.h"
#include "libNET/src/net_load_balance_internal.h"

void protocol_mac_reset(protocol_interface_info_entry_t *cur)
{
if (cur->mac_api) {
mlme_reset_t reset;
reset.SetDefaultPIB = true;
cur->mac_api->mlme_req(cur->mac_api, MLME_RESET, &reset);
}
}



static int8_t set_6lowpan_nwk_down(protocol_interface_info_entry_t *cur)
Expand All @@ -96,15 +105,11 @@ static int8_t set_6lowpan_nwk_down(protocol_interface_info_entry_t *cur)
}

if (cur->interface_mode == INTERFACE_UP) {
if (cur->mac_api) {
mlme_reset_t reset;
reset.SetDefaultPIB = true;
cur->mac_parameters->pan_id = 0xffff;
cur->mac_parameters->SecurityEnabled = false;
cur->mac_parameters->security_frame_counter = 0;
cur->mac_parameters->mac_security_level = 0;
cur->mac_api->mlme_req(cur->mac_api, MLME_RESET, &reset);
}
cur->mac_parameters->pan_id = 0xffff;
cur->mac_parameters->SecurityEnabled = false;
cur->mac_parameters->security_frame_counter = 0;
cur->mac_parameters->mac_security_level = 0;
protocol_mac_reset(cur);
cur->interface_mode = INTERFACE_IDLE;
net_load_balance_internal_state_activate(cur, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@ extern int8_t nwk_6lowpan_up(struct protocol_interface_info_entry *cur);
*/
extern int8_t nwk_6lowpan_down(struct protocol_interface_info_entry *cur);

extern void protocol_mac_reset(struct protocol_interface_info_entry *cur);


#endif /* PROTOCOL_6LOWPAN_INTERFACE_H_ */
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,7 @@ int8_t mac_helper_key_link_frame_counter_set(int8_t interface_id, uint32_t seq_p

void mac_helper_devicetable_remove(mac_api_t *mac_api, uint8_t attribute_index, uint8_t *mac64)
{
(void) mac64;
if (!mac_api) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ void mcps_data_indication_handler(const mac_api_t *api, const mcps_data_ind_t *d
void mcps_purge_confirm_handler(const mac_api_t *api, mcps_purge_conf_t *data)
{
(void)api;
(void)data;
tr_info("MCPS Data Purge confirm status %u, for handle %u", data->status, data->msduHandle);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -856,9 +856,6 @@ 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) {
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);
Expand Down Expand Up @@ -931,11 +928,13 @@ bool nd_ns_aro_handler(protocol_interface_info_entry_t *cur_interface, const uin
}

/* TODO - check hard upper limit on registrations? */
if (ws_info(cur_interface) &&
!ws_common_allow_child_registration(cur_interface, aro_out->eui64)) {
aro_out->present = true;
aro_out->status = ARO_FULL;
return true;
if (ws_info(cur_interface)) {

aro_out->status = ws_common_allow_child_registration(cur_interface, aro_out->eui64);
if (aro_out->status != ARO_SUCCESS) {
aro_out->present = true;
return true;
}
}

/* We need to have entry in the Neighbour Cache */
Expand Down Expand Up @@ -1757,6 +1756,8 @@ void nd_6lowpan_set_radv_params(protocol_interface_info_entry_t *cur_interface)
cur_interface->adv_retrans_timer = nd_params.ra_retrans_timer;
cur_interface->max_initial_rtr_adv_interval = nd_params.ra_interval_min;
cur_interface->max_initial_rtr_advertisements = nd_params.ra_transmits;
#else
(void) cur_interface;
#endif
}
#endif // HAVE_6LOWPAN_ND
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ static void thread_bootstrap_pbbr_update_done(struct protocol_interface_info_ent
static void thread_neighbor_remove(mac_neighbor_table_entry_t *entry_ptr, void *user_data)
{
protocol_interface_info_entry_t *cur = user_data;
lowpan_adaptation_remove_free_indirect_table(cur, entry_ptr);
lowpan_adaptation_neigh_remove_free_tx_tables(cur, entry_ptr);

thread_reset_neighbour_info(cur, entry_ptr);
//Removes ETX neighbor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ int8_t thread_bootstrap_down(protocol_interface_info_entry_t *cur)
tr_debug("SET thread Idle");
//stop polling
mac_data_poll_disable(cur);
// Reset MAC for safe upper layer memory free
protocol_mac_reset(cur);
//Clean mle table
thread_neighbor_list_clean(cur);
// store frame counters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ int thread_dhcpv6_server_set_anonymous_addressing(int8_t interface_id, uint8_t *
return -1;
}

return DHCPv6_server_service_set_address_autonous_flag(interface_id, prefix_ptr, anonymous);
return DHCPv6_server_service_set_address_autonous_flag(interface_id, prefix_ptr, anonymous, false);
#else
(void) interface_id;
(void) prefix_ptr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ static void thread_update_mle_entry(protocol_interface_info_entry_t *cur, mle_me
if (short_address != entry_temp->mac16) {
if (thread_router_addr_from_addr(entry_temp->mac16) == cur->thread_info->routerShortAddress) {
thread_dynamic_storage_child_info_clear(cur->id, entry_temp);
protocol_6lowpan_release_short_link_address_from_neighcache(cur, entry_temp->mac16);

}
entry_temp->mac16 = short_address;
/* throw MLME_GET request, short address is changed automatically in get request callback */
Expand Down
Loading