Commit graph

8455 commits

Author SHA1 Message Date
Jakub Rzeszutko fb6155a242 shell: internal api update: help module
Add prefix z_ to internal functions printing help.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2021-01-14 12:07:25 +01:00
Jakub Rzeszutko 460995c810 shell: internal api update: fprintf
Add z_ prefix to internal fprintf functions and macros.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2021-01-14 12:07:25 +01:00
Markus Fuchs 041c80748a net: hostname: Update unique hostname on link address change
Add Kconfig option NET_HOSTNAME_UNIQUE_UPDATE to allow the unique
hostname - which is derived from the network interface's link
address - to be updated on both initial assignment and updates of
the link address.

Signed-off-by: Markus Fuchs <markus.fuchs@de.sauter-bc.com>
2021-01-13 17:50:32 +02:00
Enjia Mai a420cb4fd5 tests: ztest: add a common fatal and assert hook for special purpose
This is in order to reduce the redundancy code writing for fatal and
assert handler for error case testing. They can be used both in kernel
and userspace, and are also SMP safe.

Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
2021-01-13 09:05:31 -05:00
Robert Lubos 4851611d55 net: coap: Fix long options encoding
`delta_size` was incorrectly used to assess whether extended option
length field shall be used. In result, options larger than 268 bytes
were not encoded properly.

Fixes #31206

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-01-13 08:02:03 -05:00
Lukasz Maciejonczyk fb99ef639a net: openthread: Set a name for radio workqueue
Named workqueues are easier to identify for instance using Thread
Analyzer.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2021-01-13 11:29:30 +02:00
Lukasz Maciejonczyk ad360c42af net: openthread: Make radio workqueue stack size configurable
Add Kconfig option for configuring OpenThread radio transmit workqueue
stack size.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2021-01-13 11:29:30 +02:00
Jingru Wang d1665d32f4 gcov: Add coverage support for arc nsim platform
* add toolchain abstraction for coverage
* add select HAS_COVERAGE_SUPPORT to kconfig
* port gcov linker code to CKake for arc
* give user permission to gcov bss section
* expand the size of iccm and dccm to 1M

Signed-off-by: Jingru Wang <jingru@synopsys.com>
2021-01-12 07:16:19 -05:00
Michał Narajowski 419d2aa85b Bluetooth: Mesh: Fix heartbeat subscription tests
MESH/NODE/CFG/HBS/BV-01-C expects the MinHops to be 0x7f after
disabling subscription, but 0x00 for subsequent Get requests.

MESH/NODE/CFG/HBS/BV-02-C expects us to return previous
count value and then reset it to 0.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2021-01-12 06:49:38 -05:00
Emil Gydesen d661eb7605 net: tcp2: Fixed IS_ENABLED check for NET_TCP_MAX_SEND_WINDOW_SIZE
The #if statement used IS_ENABLED to check if it was defined.
IS_ENABLED will only return true if the value is 1, and false otherwise.
If the NET_TCP_MAX_SEND_WINDOW_SIZE value would be e.g. 8, then the
check would fail.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-01-12 13:40:42 +02:00
Jukka Rissanen ef801886b6 net: tcp2: Queue received out-of-order data
If we receive data that is out-of-order, queue sequential
TCP segments until we have received earlier segment or a timeout
happens.

Note that we only queue data sequentially in current version i.e.,
there should be no holes in the queue. For example, if we receive
SEQs 5,4,3,6 and are waiting SEQ 2, the data in segments 3,4,5,6 is
queued (in this order), and then given to application when we receive
SEQ 2. But if we receive SEQs 5,4,3,7 then the SEQ 7 is discarded
because the list would not be sequential as number 6 is be missing.

Fixes #30364

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-01-12 13:40:05 +02:00
chao an 1027b0e4f0 Bluetooth: host: add support for unregister scanner callback
This is a pairing function with bt_le_scan_cb_register()
to used for remove the scanner callback from callback list.

Signed-off-by: chao an <anchao@xiaomi.com>
2021-01-12 12:31:00 +02:00
chao.an bc7e86b9ec Bluetooth: host: Unified namespace of hci event
BT_HCI_EV_LE_REMOTE_FEAT_COMPLETE ->
BT_HCI_EVT_LE_REMOTE_FEAT_COMPLETE

Signed-off-by: chao an <anchao@xiaomi.com>
2021-01-12 12:30:11 +02:00
Joel Frazier 2d215484cc net: l2: openthread: join thread mcast addrs added to zephyr
Modifies openthread shim layer to automatically join multicast
addresses as they are added to zephyr from openthread, unless the
address is interface-local or link-local. This allows incoming
openthread multicast group messages to avoid being filtered by
zephyr ipv6 recv.

Fixes #31085

Signed-off-by: Joel Frazier <frazieje@gmail.com>
2021-01-11 10:48:26 +02:00
Marko Poljanić 2b92ae308b coverage: C++ fix loop in gcov_coverage_dump
During coverage reports generation in C++ code gcov_coverage_dump()
function would get stuck in endless loop. Fix by checking list head
pointer with current list pointer.

Signed-off-by: Marko Poljanić <mpoljanic@gmail.com>
2021-01-10 16:59:47 -05:00
Morten Priess 907a8377b3 Bluetooth: controller: Fixed conn_meta bitflag misalignment
Fixed misalignment of bitflag in ll_conn type causing unintentional
overwrite between unions. Common flag must be present in master/slave
uinons as well. Problem is only present when enabling feature
CONFIG_BT_CTLR_CONN_META, which is default disabled.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2021-01-10 15:40:05 -05:00
Vinayak Kariappa Chettimada e0ff2d0957 Bluetooth: controller: Reserve link Rx buffer to ISO sync
Reserve two link rx buffer for each supported Broadcast ISO
sync instance, for establishment and for sync lost node rx
generation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-10 15:39:42 -05:00
Aurora Sletnes Bjørlo 717687806c bluetooth: controller: radio: Add guards on TXPOWER
For tx_power_max_get and tx_power_floor, only allow for
positive values of txpower if they are defined.

Signed-off-by: Aurora Sletnes Bjørlo <aurora.sletnes@nordicsemi.no>
2021-01-10 15:39:22 -05:00
Maik Vermeulen f03d1177d0 net: lwm2m: Direct firmware_transfer() call instead of work-item
The LwM2M firmware pull object no longer uses the system workqueue
to execute firmware_transfer(), but directly executes it itself.
Previously, the workqueue would be blocked because firmware_transfer()
indirectly calls a blocking connect(). This would lead to problems
with e.g. modem drivers that use UART to interface with the modem
hardware, as some UART drivers use the workqueue.

Fixes #31053.

Signed-off-by: Maik Vermeulen <maik.vermeulen@innotractor.com>
2021-01-08 15:46:57 +02:00
Vasilyev, Pavel d593af30db Bluetooth: Mesh: Fix typo when deleting app key in CDB
This commit sets `net_idx` to `BT_MESH_KEY_UNUSED` when deleting app key in
cdb.

Signed-off-by: Vasilyev, Pavel <pavel.vasilyev@nordicsemi.no>
2021-01-08 13:16:46 +02:00
Jukka Rissanen d904f95562 net: tcp2: Mark tcphdr struct as packed
As the tcp header struct can be cast to unaligned memory, mark
it as packed and access fields using UNALIGNED_GET/PUT when
needed.

Fixes #31145

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-01-08 11:31:43 +02:00
Flavio Ceolin 2b49266861 power: Add notifier API
Get rid of weak functions adding a new API to register an object to
receive notifications when the system changes power state.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-01-07 12:40:19 -05:00
Vinayak Kariappa Chettimada 8a5154d71c Bluetooth: controller: Add missing initialization of ISO sync
Add missing initialization of ISO sync context to be
established.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-07 18:02:34 +01:00
Vinayak Kariappa Chettimada c709d4f85f Bluetooth: controller: Rename periodic adv rx enable flag
Rename the Periodic Advertising Rx Enable flag from
is_enabled to is_rx_enabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-07 18:01:44 +01:00
Vinayak Kariappa Chettimada 44492c8324 Bluetooth: controller: Rename supported ISO Sets Kconfig
Rename Kconfig BT_CTLR_SCAN_SYNC_ISO_MAX to
BT_CTLR_SCAN_SYNC_ISO_SET, to be consistent with other
Kconfig naming.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-07 18:01:10 +01:00
Vinayak Kariappa Chettimada 32a79dd7e3 Bluetooth: controller: Fix AUX_CONNECT_RSP PDU buffer size
AUX_CONNECT_RSP PDU static buffer definition was missing one
byte required for the Extended Header Flags.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-07 18:00:35 +01:00
Vinayak Kariappa Chettimada 5d3d9b7522 Bluetooth: controller: Internal documentation of node rx count
Document with comments, the explanation of node rx count and
the design of the free rx PDU management.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-07 17:59:59 +01:00
Vinayak Kariappa Chettimada bc71d39d81 Bluetooth: controller: Fix free Rx PDU queue starvation
Fix for scenarios where in active PHY Update Procedure or
Connection Update Procedure could cause temporary depletion
of the free Rx PDUs in the queue between LL/HCI thread
context to LLL context. Symptoms being on-air NACKing during
the above said procedures, causing supervision timeouts due
to procedures not completing at instants.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-07 17:59:59 +01:00
Vinayak Kariappa Chettimada 2a99857cad Bluetooth: controller: Refactor PA/LNA PPI configuration
Refactor the implementation of PA/LNA PPI configuration
which was done on every Tx or Rx as common code to be
executed once per radio reset. And only setup the timeout
and enabling of PPI at every Tx or Rx.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-07 17:59:20 +01:00
Vinayak Kariappa Chettimada 5470444e6a Bluetooth: controller: PA/LNA use NRF_P0/P1 define
For PA/LNA implementation use NRF_P0/P1 defines instead of
the deprecated NRF_GPIO to reference GPIO Port 0 registers.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-07 17:58:24 +01:00
Vinayak Kariappa Chettimada e51295a309 Bluetooth: controller: Fix missing GPIOTE channel disable
Fix the missing GPIOTE channel disable when GPIOTE channel
is alternately used between PA and LNA use.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-07 17:58:01 +01:00
Vinayak Kariappa Chettimada f265b178c3 Bluetooth: controller: Fix regression in PA/LNA support
Fix regression in PA/LNA support wherein the GPIO pins where
left in undefined state after each radio event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-07 17:57:29 +01:00
Vinayak Kariappa Chettimada e14be4477a Bluetooth: controller: Fix missing call to radio_setup interface
Fix regression, add back missing call to radio_setup HAL
interface. This is needed to setup the initial PA/LNA GPIO
states.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-07 17:56:57 +01:00
Vinayak Kariappa Chettimada 108d431902 Bluetooth: controller: nRF52811: Errata Id 164 not applicable
nRF52840 Engineering A Errata Id 164 is not applicable to
nRF52811 SoC.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-07 17:56:03 +01:00
Joakim Andersson 577cd82b0d Bluetooth: host: Fix crash when receiving response after ATT timeout
Fix crash in ATT when the response for a request is received after
the ATT timeout has fired and the ATT channel has been detached.
Add similar handling for all ATT channel operations.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-01-07 13:51:18 +01:00
Peter Bigot d510f1f84d net: if: tweak DAD and RS timeout handling
Both RS and DAD timeouts are simplified because the delay is a
constant, and by construction the list of timeouts is in increasing
time remaining.

Refactor to avoid repeating the expression that represents the time
until DAD state expires.  Uniformly use unsigned operands in deadline
calculation.

Note a case where the racy idiom for retaining an existing timeout is
required in the current work API, but can be replaced with a robust
solution in the proposed new API (the reschedule API replaces any
existing pending update, but the schedule API will leave an existing
scheduled submission in place).

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-01-07 11:14:38 +02:00
Peter Bigot 4882dd69af net: if: fix error in calculating router expiration
The existing implementation is inconsistent in that checking for
expired routers when a timeout is processed detects end-of-life
correctly (when the remaining duration exceeds the signed maximum),
but the calculation of time remaining before expiration uses only
unsigned calculation.  So when the set of routers is changed the newly
calculated timeout will not recognize routers that have expired, and
so those routers expired late.  In the worst case if the only
remaining router had expired the timer may be set for almost two
months in the future.

Refactor to calculate remaining time in one place and as a signed
value.  Change a function name to more clearly reflect what it does.
Avoid unnecessary race conditions in k_work API.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-01-07 11:14:38 +02:00
Peter Bigot acd43cbaac net: timeout: refactor to fix multiple problems
The net_timeout structure is documented to exist because of behavior
that is no longer true, i.e. that `k_delayed_work_submit()` supports
only delays up to INT32_MAX milliseconds.  Nonetheless, use of 32-bit
timestamps within the work handlers mean the restriction is still
present.

This infrastructure is currently used for two timers with long
durations:
* address for IPv6 addresses
* prefix for IPv6 prefixes

The handling of rollover was subtly different between these: address
wraps reset the start time while prefix wraps did not.

The calculation of remaining time in ipv6_nbr was incorrect when the
original requested time in seconds was a multiple of
NET_TIMEOUT_MAX_VALUE: the remainder value would be zero while the
wrap counter was positive, causing the calculation to indicate no time
remained.

The maximum value was set to allow a 100 ms latency between elapse of
the deadline and assessment of a given timer, but detection of
rollover assumed that the captured time in the work handler was
precisely the expected deadline, which is unlikely to be true.  Use of
the shared system work queue also risks observed latency exceeding 100
ms.  These calculations could produce delays to next event that
exceeded the maximum delay, which introduced special cases.

Refactor so all operations that use this structure are encapsulated
into API that is documented and has a full-coverage unit test.  Switch
to the standard mechanism of detecting completed deadlines by
calculating the signed difference between the deadline and the current
time, which eliminates some special cases.

Uniformly rely on the scanning the set of timers to determine the next
deadline, rather than assuming that the most recent update is always
next.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-01-07 11:14:38 +02:00
Vinayak Kariappa Chettimada db5270bd93 Bluetooth: controller: nRF53x: SWI mapping should use SOC define
SWI IRQ line mapping for nRF5340 shall use
CONFIG_SOC_NRF5340_CPUNET for conditional compilation
instead of the board define, so as to allow new boards to
use the BLE controller implementation.

Fixes #30488.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-06 16:25:52 +01:00
Enjia Mai 8d5a22c3c1 tests: enable the code coverage report for qemu_x86_64
Enable the code coverage report for qemu_x86_64 platform.
See issue #17991 please.

Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
2021-01-05 10:32:38 -08:00
Peter Bigot 0496f8cc88 usb: cdc_acm: select features required for use
If UART_INTERRUPT_DRIVEN isn't selected the CDC ACM class driver won't
build.  Don't require the user's intervention to avoid this.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-01-05 09:40:36 -06:00
Jordan Yates 7be105b86a net: buf: net_buf_remove_* API
Adds a new family of `struct net_buf` operations that remove data from
the end of the buffer.

The semantics of `net_buf_remove_mem` have been chosen to match those of
`net_buf_pull_mem`, i.e. the return value is a pointer to the memory
that was removed.

The opposite of this function, `net_buf_remove`, would need to return
the old end of the data buffer to be useful. However this value is
always an invalid target for reading or writing data to (It points to
the middle of unused data).The existance of the function would be
misleading, therefore it is not implemented.

Fixes #31069.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-01-05 14:31:13 +02:00
Jordan Yates a5cd0c0c51 net: buf: net_buf_push_mem function
Add function that copies in new data to the start of a `struct net_buf`.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-01-05 14:31:13 +02:00
Piotr Pryga 1c493b4a77 Bluetooth: host: direction: Add public API to set CTE TX params for adv.
Add publicly accessible function to set Constant Tone Extension
parameters for CTE transmission with periodic advertising.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-01-05 09:38:53 +01:00
Piotr Pryga 098f767298 Bluetooth: host: Add set connectionless CTE TX params wrapper function
Add implementation of a wrapper for HCI_LE_Set_-
Connectionless_CTE_Transmit_Parameters send command.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-01-05 09:38:53 +01:00
Piotr Pryga 9bfc095d4a Bluetooth: host: Add DF to initalization sequence
Add Direction Finding to host initialization sequence.
It allows to get information about Direction finding
optional CTE settings supported by controller.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-01-05 09:38:53 +01:00
Vinayak Kariappa Chettimada 0a23b1248f Bluetooth: controller: Remove is_enabled flag for BIS events
Remove is_enabled flag in LLL of BIS events context, as the
status returned from ticker_stop interface is sufficient to
determine if the Broadcast ISO Sync was established or not.
HCI Command Disallow as reason is to be returned if sync was
not established or sync was loss prior to call of HCI LE
BIG Terminate Command was called.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-04 16:27:58 +01:00
Vinayak Kariappa Chettimada 30740b4397 Bluetooth: controller: Move lll_sync_iso.h common to all vendors
Move lll_sync_iso.h as common to all vendors, as currently
there is nothing that is vendor specific.

Fixes #31044.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-04 16:27:58 +01:00
Flavio Ceolin 91715afa20 power: Reducing the scope of a private function
Setting pm_policy_mgr static.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-01-04 09:02:23 -05:00
Flavio Ceolin 8fe3866e19 power: rename _pm_power_state_ -> pm_power_state
Leftover from old renaming commits. This function is not private and
should not start with underscore.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-01-04 09:02:23 -05:00