Commit graph

7273 commits

Author SHA1 Message Date
Vinayak Kariappa Chettimada 18e916b22e Bluetooth: controller: split: Handle SyncInfo in Aux Data set
Handle using existing SyncInfo when updating Aux PDU AD Data.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-06-12 15:50:34 +02:00
Vinayak Kariappa Chettimada a43c3be2b9 Bluetooth: controller: split: Added SyncInfo into Aux Packet
Added SyncInfo population in Aux packet.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-06-12 15:50:34 +02:00
Vinayak Kariappa Chettimada a126850c15 Bluetooth: controller: split: Use correct secondary PHY, AA and CRC
Implement use of correct secondary PHY for transmission,
access address and CRC setup.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-06-12 15:50:34 +02:00
Vinayak Kariappa Chettimada 1773274118 Bluetooth: controller: split: Moved chan map helper functions
Moved Channel Map helper functions into separate file.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-06-12 15:50:34 +02:00
Vinayak Kariappa Chettimada 5c512d6e9a Bluetooth: controller: Move access address helper to util.c
Move the access address helper function to util.c file.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-06-12 15:50:34 +02:00
Vinayak Kariappa Chettimada bb720d68ce Bluetooth: controller: split: Refactor to reuse common ISR code
Refactor to reuse common repeated code in ISR that reset
status, and performed abort, done and cleanup.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-06-12 15:50:34 +02:00
Vinayak Kariappa Chettimada 5949205315 Bluetooth: controller: split: Add periodic adv LLL implementation
Add LLL implementation to perform periodic advertising.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-06-12 15:50:34 +02:00
Vinayak Kariappa Chettimada 3eac6c3a52 Bluetooth: controller: split: Add periodic adv ULL implementation
Add ULL implementation to perform periodic advertising.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-06-12 15:50:34 +02:00
Vinayak Kariappa Chettimada 5ebbac32d9 Bluetooth: controller: split: Fill bdaddr in aux packet
Fill the bdaddr on advertising enable in the aux packet.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-06-12 15:50:34 +02:00
Vinayak Kariappa Chettimada 0b99773037 Bluetooth: controller: Minor refactor of SyncInfo structure
Minor refactor of SyncInfo structure field names.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-06-12 15:50:34 +02:00
Vinayak Kariappa Chettimada be3dd3687b Bluetooth: controller: split: non-conn non-scan with aux packets
Added implementation to advertise non-connectable
non-scannable advertising with auxiliary packets.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-06-12 15:50:34 +02:00
Vinayak Kariappa Chettimada 365774da7c Bluetooth: controller: Move Adv Ext interface to ll interface
Move Advertising Extensions interface to LL interface header
file.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-06-12 15:50:34 +02:00
Vinayak Kariappa Chettimada fdd91bb116 Bluetooth: controller: split: Add AuxPtr to ADV_EXT_IND PDU
Add implementation to support ADV_EXT_IND PDU with AuxPtr.
Changes in this commit only prepares the ADV_EXT_IND PDU
in the primary channel.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-06-12 15:50:34 +02:00
Vinayak Kariappa Chettimada eec42ca522 Bluetooth: controller: split: Added le_set_ext_adv_param interface
Added le_set_ext_adv_param functional interface to integrate
HCI with controller's functional interface.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-06-12 15:50:34 +02:00
Vinayak Kariappa Chettimada 5f1301245c Bluetooth: shell: Updated advx command to use Adv Data Set
Updated the shell commands related to Advertising Extensions
to call the LE Set Extended Advertising Data command
functional interface for testing purposes.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-06-12 15:50:34 +02:00
Vinayak Kariappa Chettimada 505fdadef2 Bluetooth: controller: split: Add Adv. Ext. HCI debug informations
Added debug information print outs in HCI code related to
Advertising Extensions events.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-06-12 15:50:34 +02:00
Vinayak Kariappa Chettimada c4b6fd0248 Bluetooth: controller: nRF5x: Introduce sw_switch_cleanup function
Refactor and introduce hal_radio_sw_switch_cleanup interface.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-06-12 12:22:29 +02:00
Flavio Ceolin 77bc3815af mgmt: fs: Add security warning
Add a warning in fs mgmt option about security risks.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-06-12 11:15:24 +02:00
Vinayak Kariappa Chettimada 428799295d Bluetooth: controller: Add support for nRF5340 debug pins
Add support for Bluetooth Controller GPIO Debug Pins for
nRF5340 PDK board. GPIO Pin toggling can be captured on the
P3 pinhead of the PDK.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-06-12 11:13:39 +02:00
Lingao Meng 7239dc1cbd Bluetooth: Mesh: Add key-value concept to store model data
Previous mode store function only can store single data,
change this to store as KV model, let's app-layer to manager
model data, other than by stack when node reset.

Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
2020-06-12 11:09:11 +02:00
Kumar Gala 59708769ea net: lwm2m: Remove deprecated functions
Remove deprecated functions that have been marked deprecated since
Zephyr 2.0.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-11 15:50:48 +03:00
Robert Lubos 7f9b85e8c3 net: openthread: Fix u16_t usage
PR #25936 introduced u16_t type usage and was merged after the type
transition in Zephyr.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-06-10 19:24:20 -04:00
Xavier Chapron 57db336b98 dfu: flash_img: Constify flash_img_buffered_write() data parameter
The data passed has no reason to be changed and can therefore be passed
as read only.

Signed-off-by: Xavier Chapron <xavier.chapron@stimio.fr>
2020-06-10 09:30:08 +02:00
Gerson Fernando Budke ebe5345e87 net: lwm2m: Refactor to use coap_get_option_int
Small clean-up to use coap_get_option_int.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-06-09 21:25:11 +03:00
Gerson Fernando Budke 1ca95e7bc4 net: coap: Rem macros that uses coap_get_option_int
Clean up and remove macros that uses coap_get_option_int.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-06-09 21:25:11 +03:00
Gerson Fernando Budke 76e32ba32b net: coap: Add coap_get_option_int public method
Any CoAP implementation when use at least block transfer or is a server
side need access some CoAP options as integer values. This add a method
at public interface and defines for block wise operations to avoid code
useless code duplication.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-06-09 21:25:11 +03:00
Emil Gydesen 299ef2e5fe cpp: Fixed compile warning with extern array declaration
The extern array declaration of size 0 gives a warning when
compiling with GCC. Updated to use [] rather than [0].

Signed-off-by: Emil Gydesen <emil_gydesen@bose.com>
2020-06-09 14:42:16 +02:00
Emil Gydesen adc5fab141 shell: Fixed compile warning with extern array declaration
The extern array declaration of size 0 gives a warning when
compiling with GCC. Updated to use [] rather than [0].

Signed-off-by: Emil Gydesen <emil_gydesen@bose.com>
2020-06-09 14:42:16 +02:00
Markus Becker 2291de6abf subsys/fs/littlefs: initialize LittleFS at POST_KERNEL
Initialize LittleFS at POST_KERNEL and not at APPLICATION stage.

When using LittleFS as settings backend for OpenThread, LittleFS needs
to be available when net_init is performed.

Arguably, FS is an OS kernel component that should be ready when
applications are starting.

Possibly, the same change should be applied to FAT fs as well.

Signed-off-by: Markus Becker <markus.becker@tridonic.com>
2020-06-09 13:48:34 +02:00
Vinayak Kariappa Chettimada d96a1a5fef Bluetooth: controller: split: Fix endianness in ull_sched
Use sys_put_le16 and sys_get_le16 in populating PDU with
offset values.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-06-09 10:43:58 +02:00
Vinayak Kariappa Chettimada 6dce205b95 Bluetooth: controller: split: Port advanced scheduling
Port advanced scheduling implementation from legacy
controller.

This implementation schedules
- non-overlapping scan window when there are simulataneous
central connections active
- central connection establishment with similar connection
intervals be placed in a non-overlapping  group, temporally
- connection parameter request with calculated window offset
hints to have non-overlapping BLE radio events.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-06-09 10:43:58 +02:00
Vinayak Kariappa Chettimada 0b6664fc3d Bluetooth: controller: split: Add function to reset conn upd mutex
Add a function to reset the variable holding the connection
context of the currently active Connection Parameter Request
Procedure.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-06-09 10:43:58 +02:00
Vinayak Kariappa Chettimada da95c08977 USB: Bluetooth: Fix rx_thread_stack size
Increase rx_thread_stack size to follow BT_HCI_TX_STACK_SIZE
value defined by the Bluetooth subsystem.

Below, thread 0x20000d28, the hci_rx_thread earlier had 512
bytes which could be insufficient under edge cases like an
interrupt being asserted at the deepest stack usage.

Logging output as part of update to stack size:
<inf> thread_analyzer: Thread analyze:
<inf> thread_analyzer:  workqueue           : unused 648 usage 376 /
	1024 (36 %)
<inf> thread_analyzer:  thread_analyzer     : unused 264 usage 248 /
	512 (48 %)
<inf> thread_analyzer:  0x20000e30          : unused 280 usage 232 /
	512 (45 %)
<inf> thread_analyzer:  0x20000d28          : unused 584 usage 440 /
	1024 (42 %)
<inf> thread_analyzer:  BT RX               : unused 320 usage 192 /
	512 (37 %)
<inf> thread_analyzer:  BT RX pri           : unused 284 usage 164 /
	448 (36 %)
<inf> thread_analyzer:  sysworkq            : unused 824 usage 200 /
	1024 (19 %)
<inf> thread_analyzer:  logging             : unused 200 usage 568 /
	768 (73 %)
<inf> thread_analyzer:  idle 00             : unused 272 usage 48 /
	320 (15 %)

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-06-09 10:43:35 +02:00
Lukasz Maciejonczyk ff8b864f48 net: openthread: Make OT thread priority class be configurable
It add an option to configure openthread thread priority class
by the application if there is a such need.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2020-06-09 11:00:17 +03:00
Andrew Boie 5d1ce47ef6 net: sockets: fix zsock_gethostname_ctx()
The SET_ERRNO() macro does nothing if a positive value is provided
to it, and the functions were not returning -1 or setting errno
as expected.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-06-09 10:58:02 +03:00
Andrew Boie 71d4aeb1c2 net: sockets: set errno EBADF on bad fd
APIs were returning -1 without setting errno if the file
descriptor looked up a null object or there was no function
installed in the vtable. Set to EBADF for this case.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-06-09 10:58:02 +03:00
Lukasz Maciejonczyk 3fa2fa9a50 net: openthread: Fix the order of adding net pkt in ot_receive_handler
Net pkt is added into the ot net list after queued net pkt into
the net_rx which bases on it. It affects in losting net pkt when for
instance ot thread is preemptive.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2020-06-09 10:57:00 +03:00
Lukasz Majewski 0e32a84bcc net: eth: Add check if passed iface pointer is NULL
The eth_stats_update_errors_rx() implicitly assumes that passed pointer
to struct net_if is not NULL.

This is not true for MCUX's eth_rx() (in eth_mcux.c), where we can
execute eth_stats_update_errors_rx() after net_recv_data() returning
-EINVAL because of passed NULL iface pointer.

This change fixes this problem with adding extra check on iface not
being NULL before it is dereferenced.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
2020-06-09 10:54:29 +03:00
Jukka Rissanen 043400ce89 net: context: Remove obsolete goto in net_context_put()
Some cleanup earlier left unnecessary goto. Cleaning the code
and removing it.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-06-09 10:21:47 +03:00
Christian Taedcke 768968a445 net: ipv6: Also look for nexthop in nbr list
This change fixes routing for routes when the nexthop is a link-local
address of a connected peer.

The issue was that nexthop was correctly set from the routes, but the
code did not detect that the nexthop address (link local of the pc on
ppp interface) was on the ppp interface, because
net_if_ipv6_addr_onlink() only evaluated the network prefix and not
any other information (like the nbr list).

Signed-off-by: Christian Taedcke <christian.taedcke@lemonbeat.com>
2020-06-09 10:19:42 +03:00
Lukasz Majewski 38d38ed90a net: shell: Allow to set interface for ping (add -I option)
This change adds new, optional switch to 'net ping' command - to
be more specific the '-I <iface index>', where the <iface index>
is the number of supported network interface.

One can discover this number from the Zephyr shell after running
'net iface'.

The default interface stays the same - just the switch is added to
override the used interface for 'net ping' invocation.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
2020-06-09 10:10:23 +03:00
Xavier Naveira 0fd16f8b78 net: mqtt: Make client "cleansession" flag configurable.
Cleansession is hardcoded to 1 but some use case might require 0
to make the sessions persistent (ie get messages sent while the
client was offline)

Signed-off-by: Xavier Naveira <xnaveira@gmail.com>
2020-06-09 10:09:04 +03:00
Michael Hope ff50ca1974 fs: nvs: fail on >= 256 B block sizes
The current code truncates the size_t block size to a u8_t, which
causes a 256 or 512 byte block size to be truncated to zero and
passing the size check.

Check as a size_t then truncate once the check passes.

Signed-off-by: Michael Hope <mlhx@google.com>
2020-06-08 23:03:21 -04:00
Vinayak Kariappa Chettimada 3cabacce9a Bluetooth: controller: Address nRF5340 Engineering A Errata 16
Address the nRF5340 Engineering A Errata 16, RADIO: POWER
register is not functional.

This affects the dependency of controller's HAL
implementation that expected correct reset values being
set in the Radio peripheral.

As the SUBSCRIBE_TXEN and SUBSCRIBE_RXEN where not in their
reset value, Radio transmission and reception start using
DPPI was broken.

Fixes #25942.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-06-08 22:04:25 +02:00
Eduardo Montoya 75a69b940e net: openthread: cli: Align config of OT and Zephyr shell max cmd size
This PR enables the user to configure the maximum command length for
OpenThread's CLI using Zephyr's shell, which is currently fixed to
256 characteres. This limitation was not enough for certain allowed
OpenThread commands, like some variants of 'ot dataset mgmtsetcommand'.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2020-06-08 21:45:29 +03:00
Eduardo Montoya fc1d0635df net: l2: openthread: Add config option to enable OpenThread ref. device
This option enables specific features used by Thread Certification
reference devices.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2020-06-08 21:41:40 +03:00
Marcin Niestroj 747f20720a net: wifi: shell: store shell in context before scan
Right now shell pointer is not assigned before doing a scan, so scan
results are printed using printk(). Save shell instance in context, so
results are printed using shell_fprintf(), thus better aligned in the
console output.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-06-08 21:37:33 +03:00
Jukka Rissanen 2c66525b7b net: stats: Priority field was used instead of traffic class
The network statistics is stored for each traffic class, but the
collecting function was given net_pkt priority. The priority
must be first converted to traffic class and then the statistics
stored to correct place in the stats array.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-06-08 21:35:18 +03:00
Jukka Rissanen 43287d2323 net: socket: Add sendmsg() support to AF_PACKET
The AF_PACKET was missing support for sendmsg() socket call.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-06-08 21:34:35 +03:00
Markus Becker 2115b575a4 net: ieee802154: Allow to disable auto-start of 802.15.4 interfaces
Some radio drivers need configuration before start-up. Up to now only
the RF2XX drivers allowed this, but other radio drivers need this as
well. In particular for setting EUI64 addresses.

Signed-off-by: Markus Becker <markus.becker@tridonic.com>
2020-06-08 19:55:19 +03:00
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Robert Lubos 370dfe088f net: sockets: Fix socket ctx check in usermode
When `z_get_fd_obj_and_vtable()` function returns NULL (no valid entry
in the FD table for the socket), there is no need for further usermode
checks on the `ctx` pointer, as there is nothing to invalidate in that
case.

Fixes #25990
Fixes #25991

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-06-05 18:34:25 +02:00
Andrew Boie c951d71eba net: check permissions on net contexts
The original sockets system calls used file descriptors which
were actually net_context pointers. For all socket system calls,
any calls from user mode would check if the caller had permission
to use the net context.

This was later changed to not stuff net_context pointers into file
descriptors, but all the permission checking was unintentionally
lost, allowing all threads on the system to
read/write all socket file descriptors in the system at will, with
no way to isolate applications running on the same microcontroller
from each other's network activity.

This patch restores the permission checks on network context objects
for socket system calls that originated from user mode.

The call to z_object_recycle() was never removed from
zsock_socket_internal(); this is again leveraged to grant the
caller who opened the socket permission on the net_context
associated with the returned file descriptor.

To ensure that all socket calls do this checking, all uses of
z_get_fd_obj_and_vtable() have been routed through get_sock_vtable().

Objects have initialization state set and thread permissions
reset to just the caller in common zsock_socket() code.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-06-03 22:33:32 +02:00
Andrew Boie 8ea273b44a net: socketpair: fix user mode access
The socketpair file descriptor context objects are heap allocated
and not drawn from a static pool. Register these as kernel objects
when we create them if user mode is enabled.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-06-03 22:33:32 +02:00
Andrew Boie 9f63a0a0a0 net: lib: remove socket-specific recycle calls
This is just done in common code now.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-06-03 22:33:32 +02:00
Andrew Boie 04bba6772b net: sockets: add API to fetch an fd's ctx object
Zephyr running on MPU devices have a different memory model than
process-oriented OSes like Linux and require a method to set
kernel object permissions on a file descriptor's underlying
context object. Add this, and a test to show that it is working.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-06-03 22:33:32 +02:00
Andrew Boie fed960b94a net: tag net socket objects
Used for permission validation when accessing the associated file
descriptors from user mode.

There often get defined in implementation code, expand the search
to look in drivers/ and subsys/net/.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-06-03 22:33:32 +02:00
Kumar Gala ff29d306c9 net: tcp2: Fix compile failure on native_posix_64
Need to use %zd in formatter string for net_pkt_get_len since it returns
a size_t otherwise we get something like:

	error: format ‘%d’ expects argument of type ‘int’, but argument
	3 has type ‘size_t’ {aka ‘long unsigned int’} [-Werror=format=]

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-03 22:29:16 +02:00
Jukka Rissanen a2f0a9effe net: sockets: Fix sendmsg() user mode param checks for aux data
If we are calling sendmsg() without any aux data, then msg_controllen
is 0 and msg_control is NULL. Check these allowed values properly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-06-03 18:33:59 +02:00
Jukka Rissanen d3dde1ad1c net: sockets: Fix sendmsg() user mode param checks for dst address
If we are calling sendmsg() for a connected socket, then msg_namelen
is 0 and msg_name is NULL. Check these allowed values properly.

Also modify unit tests so that we test this scenario.

Fixes #25925

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-06-03 18:33:59 +02:00
Christopher Friedt 2715357e63 net: socket: socketpair: initialize after NULL check
Fixes #25788
Coverity-CID: 210581

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-06-03 18:33:19 +02:00
Christopher Friedt 195a536073 net: socket: socketpair: remove dead code
In this, case is_nonblock is false and will_block is true.
Therefore, we *may* block, and furthermore we *expect* to
block. Checking is_nonblock is, in fact, redundant, and
passing K_FOREVER to k_sem_take() is justified.

Fixes #25727
Coverity-CID: 210611

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-06-03 18:33:19 +02:00
Marcin Niestroj 62b985409e shell: fix showing 'command not found'
After recent changes to shell, there is no more "no_such_command:
command not found" message when executing non-existing command. Restore
that message, so users are warned once again about wrong command,
instead of silently ignoring their request.

Fixes: 512de5ecac ("shell: Refactor command execution to enable raw
  arguments")
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-06-03 10:23:24 +02:00
Robert Lubos bc5b05f223 modules: mbedtls: Add Kconfig entry for MBEDTLS_MD and MBEDTLS_CIPHER
Due to new checks in mbedTLS config sanitizer, TLS option can no longer
be left enabled, when TLS is not used. OpenThread needs MBEDTLS_MD_C
and MBEDTLS_CIPHER_C even without TLS being used, so we need an option
to enable them manually.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-06-02 15:24:36 +02:00
Jukka Rissanen 35f4ffb186 net: sockets: Add sendmsg() parameter verification
If run in usermode, the sendmsg() parameters were not verified.

Fixes #25702

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-06-02 15:22:47 +02:00
Oleg Zhurakivskyy cbea5c81bb net: tcp2: Fix pointer to local outside scope in th_get()
Fix pointer to local outside scope in th_get().

Coverity CID :209942

Fixes #25779

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-06-01 14:59:54 +02:00
Jim Luther ffd15131d2 bluetooth: host: fix unpacked l2cap struct
The bt_l2cap_le_conn_rsp struct in l2cap_internal.h has not been
declared __packed. This can cause alignment problems on some
platforms if the struct is placed on an unaligned address.

A __packed declaration solves this issue by forcing the compiler to
use store instructions that do not required alignment.

Signed-off-by: Jim Luther <jilu@oticon.com>
2020-05-29 17:43:32 +02:00
Vinayak Kariappa Chettimada ba487feb0f Bluetooth: controller: split: Workaround nRF52832 CCM overrun
Implemented an intermediate decrypt buffer to cover the CCM
overrun under CRC error conditions. The workaround is
applicable to nRF52832 SoC only, which is missing the
MAXPACKETSIZE register in the NRF_CCM peripheral.

Fixes #21107 for nRF52832 SoC.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-05-29 13:12:28 +02:00
Jukka Rissanen bc40177020 net: ipv6: RA prefix option length not checked
The Router Advertisement can have prefix option. It's length
is 4 but the code did not check that which meant that we could
accept malformed packet. See RFC 4861 chapter 4.6.2 for details.

Fixes #25694

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-05-29 13:11:48 +02:00
Jukka Rissanen 71686dde4b net: ipv6: Do not add same prefix multiple times to timer list
Make sure that we do not add same IPv6 prefix, received from RA,
multiple times to prefix timer list. This avoids possible
denial-of-service issue if we receive suitably crafted RA packet.

Fixes #25698

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-05-28 17:49:03 +02:00
Andrew Fernandes 4653b4e63f logging: set 'log_backend_rtt:panic_mode' before 'log_backend_std_panic'
Set 'log_backend_rtt:panic_mode' before calling 'log_backend_std_panic',
because otherwise the RTT backend behaves as if the system is NOT
panicking and tries to do asynchronous writes via RTT_LOCK/UNLOCK.

Signed-Off-By: Andrew Fernandes <andrew@fernandes.org>
2020-05-28 11:45:42 +02:00
Trond Einar Snekvik a385873336 Bluetooth: Mesh: Fail init on model init error
Adds propagation of error returns from the model init callbacks in
Access, and removing any other checks for successful init in the
foundation models.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-05-27 18:45:18 +02:00
Vinayak Kariappa Chettimada cd7a73c20a Bluetooth: controller: split: Fix NRF_CCM overrun
Fix missing assignment of NRF_CCM->MAXPACKETSIZE register
for PDU sizes smaller than 251 bytes. If there is CRC errors
causing PDU length fields to be higher than configured PDU
buffer sizes in the controller, without the MAXPACKETSIZE
register set to correct PDU size, CCM module could overrun
the PDU buffer and cause memory corruption. This fix is
applicable for all nRF52 Series SoCs except nRF52832 SoC.

Fixes #21107.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-05-27 18:06:17 +02:00
Tomasz Bursztyka d2a139ee9b power: Let's have core device setup in case of CONFIG_NET_TEST
This will be useful to test network stack's power management support.
There is no other way to do it, so far, but to hardcode such config
option test there.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-05-26 21:41:00 +02:00
Andrzej Puzdrowski 06827ecd14 storage/stream: fix possible unaligned write on buffer flush
On buffer flush request it is very probably that write buffer
contains amount of data which is non write-block-size aligned.
Flash memory need to be write at minimal by write-block-size chunks.
This patch addresses mechanism which ensure such behavior by adding
missing bytes.

fixes #25471

streamer buffer size should be multiple write-block-size of
the flash device in order to avoid unaligned flash write
request.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2020-05-26 16:35:19 +02:00
Andries Kruithof 3a91f35893 Bluetooth: controller: split: include proper header file
After removal of legacy controller ll_adv_aux.h does not exist anymore.
This is fixed in this PR by including ull_adv_aux.h instead.
The error only shows up when Advertisement Extensions are enabled
in the LL (CONFIG_BT_CTLR_ADV_EXT=y)

Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
2020-05-26 15:28:12 +02:00
chao an 2f15e3901a Bluetooth: Mesh: correct the return type
CC:  mesh/access.c
mesh/access.c: In function 'model_has_dst':
mesh/access.c:483:10:
	warning: returning 'u16_t *' {aka 'short unsigned int *'} from
	a function with return type '_Bool8' {aka 'unsigned char'} makes
	integer from pointer without a cast [-Wint-conversion]
  483 |   return bt_mesh_model_find_group(&mod, dst);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: chao an <anchao@xiaomi.com>
2020-05-26 14:36:40 +02:00
chao an bb5ce8ae30 Bluetooth: Mesh: fix shadow declare
CC:  mesh/adv.c
mesh/adv.c: In function 'bt_mesh_scan_cb':
mesh/adv.c:247:13: warning: declaration of 'adv_type'
                   shadows a global declaration [-Wshadow]
  247 |        u8_t adv_type, struct net_buf_simple *buf)
      |        ~~~~~^~~~~~~~
mesh/adv.c:58:19: note: shadowed declaration is here
   58 | static const u8_t adv_type[] = {
      |                   ^~~~~~~~

CC:  mesh/prov.c
mesh/prov.c: In function 'bt_mesh_prov_enable':
mesh/prov.c:1203:30: warning: declaration of 'prov'
                     shadows a global declaration [-Wshadow]
 1203 |   const struct bt_mesh_prov *prov = bt_mesh_prov_get();
      |                              ^~~~
mesh/prov.c:129:35: note: shadowed declaration is here
  129 | static const struct bt_mesh_prov *prov;
      |                                   ^~~~

Signed-off-by: chao an <anchao@xiaomi.com>
2020-05-26 14:36:40 +02:00
Andries Kruithof 6a2f50aba2 Bluetooth: controller: split: Update feature exchange to BTCore V5.0
The existing feature exchange procedure does not give the proper
response as specified in the BT core spec 5.0.
The old behaviour is that the feature-response returns the logical and
of the features for both peers.
The behaviour implemented here is that the feature-response returns the
featureset of the peer, except for octet 0 which is the logical and of
the supported features.
Tested by using the bt shell, and having different featuresets
on the 2 peers.

This fixes #25483

Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
2020-05-26 14:34:39 +02:00
Eduardo Montoya dd1a71f0c4 net: config: align Kconfig debug levels with OpenThread ones
OpenThread moved from 4 to 5 debug levels and it was not possible
to configure all of them with Kconfig.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2020-05-25 20:41:42 +02:00
Henrik Brix Andersen 4e4139cf9e canbus: canopen: program: add missing include for FLASH_AREA
Add missing include after the conversion from DT_FLASH_AREA to
FLASH_AREA.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-05-25 13:26:28 +02:00
Oleg Zhurakivskyy 6096efb3da net: tcp2: Implement the retransmission for the outgoing data
In order to support the retransmission for the outgoing data:

1. The outgoing data packet is appended to the send_data queue
   in net_tcp_queue_data().

2. tcp_send_queued_data() is called and will use tcp_send_data()
   to sends queued but unsent data packet by packet
   until there's an unsent data and the receiver's window isn't full.

   tcp_send_queued_data() subscribes send_data_timer
   that will handle retrasmissions with tcp_resend_data().

3. tcp_send_data() peeks a single chunk of data from the send_data
   queue that will not exceed the maximum segment size
   until the the receiver's window is full.

   tcp_send_data() uses conn->seq and conn->unack_len as the sequence
   number for the TCP packet.

   conn->unacked_len is advanced on each send.

4. On data acknowledgment:

   - acknowledged amount of data is removed from the beginning
     of the send_data queue
   - conn->seq is advanced by the acknowledged amount
   - conn->unacked_len is decremented by the acknowledged amount
   - send_data_timer is cancelled
   - tcp_send_queued_data() is called to send queued but
     prevoiusly unsent data

5. On timeout, tcp_resend_data() will reset conn->unack_len,
   peek one packet from the beginning of the send_queue and resend,
   terminating the connection on retries exceeded.

   Meanwhile the outgoing data tcp_send_queued_data() is just
   appended to the send_data but not sent.

   In case of the acknowledgement, tcp_send_queued_data() will
   start sending multiple packets until the receiver's window
   is full.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-05-25 12:42:22 +02:00
Oleg Zhurakivskyy f779678ff4 net: tcp2: Add send_data queue into the TCP connection
In order to support the retransmission for the outgoind data,
add the following into the TCP connection:

- struct net_pkt *send_data (used as a queue)
- send_data_total
- unack_len
- send_data_timer
- send_data_retries

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-05-25 12:42:22 +02:00
Oleg Zhurakivskyy 58b7847afb net: tcp2: Extract the MSS from the TCP option value
Extract the maximum segment size (MSS) from the TCP option value.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-05-25 12:42:22 +02:00
Oleg Zhurakivskyy 9efdbe19dd net: tcp2: Add send_win into the TCP connection
In order to support the send window, add send_win into
the TCP connection.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-05-25 12:42:22 +02:00
Oleg Zhurakivskyy 5b54daea36 net: tcp2: Refactor tcp_out()
In order to support the data retransmission, refactor tcp_out()
into tcp_out_ext() which supports passing the sequence number.

In addition drop modifications of the connection sequence number
from tcp_out_ext(), this is the responsibility of data retransmission.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-05-25 12:42:22 +02:00
Oleg Zhurakivskyy 762b0aeb5a net: tcp2: Update tcp_pkt_alloc() macros
In order to use struct net_pkt for the outgoing data queue,
update tcp_pkt_alloc() macros, so they support allocation
without buffer.

Additionally, merge tcp_pkt_alloc() macros macros into one.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-05-25 12:42:22 +02:00
Oleg Zhurakivskyy aac4261e73 net: tcp2: Handle the packet clone failure
Handle the packet clone failure in tcp_send_process() and
terminate the connection.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-05-25 12:42:22 +02:00
Oleg Zhurakivskyy 13bcfc165a net: tcp2: Handle the packet clone error in tcp_data_get()
Unsuccessfull packet clone in tcp_data_get() isn't handled,
add an error handling and don't ACK the incoming data in this case.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-05-25 12:42:22 +02:00
Oleg Zhurakivskyy d65e654766 net: tcp2: Update the sequence compare on peer resend
In order to handle sequence overflow cases, use
net_tcp_seq_greater() to check if the sequence is greater/lower.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-05-25 12:42:22 +02:00
Oleg Zhurakivskyy 42ef3861d4 net: tcp2: Randomize the initial sequence number
The initial sequence number for a connection should be randomized
to prevent easy guesses.

Do not randomize the sequence number if network test or
test protocol is enabled.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-05-25 12:42:22 +02:00
Oleg Zhurakivskyy 502842297e net: tcp2: Eliminate/remove extra prototypes
To improve readability, eliminate/remove extra prototypes.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-05-25 12:42:22 +02:00
Erwan Gouriou 2716cbcaa6 drivers: susbsys: Check errors on devices selected using dt macro
Some Kconfig defined devices may be defined using dt_chosen_label
function. Since there is no way to ensure a device enabled in dts
is also defined in Kconfig, it may happen that instance is not
actually defined.
In this case device_get_binding might return 0, leading to undefined
behavior in the function that calls it.
When not already done, systematically check return of function
device_get_binding on devices defined through dt_chosen_label macro.
Trigger ASSERT when required and return error when possible.

Fixes #20068

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-05-25 11:43:14 +02:00
François Delawarde 24729bb7c6 bluetooth: host: fix wrong bt/cf settings loading
This commits fixes the loading of bt/cf settings into memory. Only data
was loaded and not the address.

Signed-off-by: François Delawarde <fnde@demant.com>
2020-05-23 22:42:25 +02:00
Peter Bigot d99aa367f6 power: device: adapt to new behavior for devices with nop pm ctrl
For backwards compatibility ignore not-supported errors for devices
that don't support power management.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-05-21 20:32:12 +02:00
Marek Pieta 775b2457d7 settings_fcb: Fix storing the data
Change fixes storing the data by adding missing write retry after
the last compression. Without the change error was returned instead
of retrying.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2020-05-21 17:42:20 +02:00
Joel Westerberg b2da4e24cb tracing: cpu_stats: add missing macro
add missing macro K_MSEC() for CONFIG_TRACING_CPU_STATS_INTERVAL

Signed-off-by: Joel Westerberg <joel@teenage.engineering>
2020-05-21 11:01:50 +02:00
chao an 32e6347f42 Bluetooth: host: foreach bond only SMP is enabled
build breakage if SMP is disabled

In function `bt_unpair':
bluetooth/host/hci_core.c:2640: undefined reference to `bt_foreach_bond'

Signed-off-by: chao an <anchao@xiaomi.com>
2020-05-20 15:36:10 +02:00
Christopher Friedt 6161ea2542 net: socket: socketpair: mitigate possible race condition
There was a possible race condition between sock_is_nonblock()
and k_sem_take() in spair_read() and spair_write() that was
mitigated.

Also clarified some of the conditional branching in those
functions.

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-05-20 10:34:07 +02:00
Johan Hedberg a7f3875134 debug: Fix BOOT_TIME_MEASUREMENT dependencies
The boot time measurement can also run with the HPET timer so there's
no reason to restrict it to APIC.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2020-05-19 17:25:36 +02:00
Jukka Rissanen dd516650d3 net: context: log_strup() missing from AF_PACKET bind() call
The link address was not printed correctly as log_strdup() was
missing from the debug print.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-05-19 14:48:08 +02:00
Trond Einar Snekvik 4a2e56d42a Bluetooth: Mesh: Transport tx fields overflow
The transport segmented TX nack and seg_pending fields must be at least
6 bits to avoid overflow for 32 segment messages. This change rearranges
the seg_tx fields to gather all state flag fields in one byte, while
making the counter fields whole bytes.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-05-19 14:44:51 +02:00
Vinayak Kariappa Chettimada 122c43562e Bluetooth: controller: split: Fix slave latency cancel race
Fix missing transmit buffer demutiplexing before checking if
slave latency needs to be maintained or cancelled.

This bug was detected when new transmit buffer was enqueued
overlapping with on-air radio transmission of empty PDU
preceding the handling of radio event done.

Symptoms of this bug being data transmission latency of upto
slave latency plus one times connection interval.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-05-15 17:07:33 +02:00
Trond Einar Snekvik e1c6ea9241 Bluetooth: Mesh: Transport tx seg_o overflow
Increases the transport segmentented tx seg_o counter to 6 bits to avoid
overflow when sending 32 segments. The check in the send loop would
previously never be false, which causes segments to repeat
unnecessarily.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-05-15 17:04:45 +02:00
Trond Einar Snekvik 0aeba0eb12 Bluetooth: Mesh: Transport seg with few adv bufs
Fixes bug where the transport segmented tx would decrement the attempt
counter every time it ran out of buffers. If transport ran out of
buffers 4 times before the sending could complete, the transfer would
end prematurely.

Moves the attempt decrement to only execute when all segments have been
sent.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-05-15 17:04:24 +02:00
Trond Einar Snekvik 266e3f27da Bluetooth: Mesh: Friend with unknown appkey
Ensures that friend messages are enqueued, even if the packet is
received with an appkey is unknown to the friend. Previously, sdu_recv
would return EINVAL if the appkey was unknown, which would prevent the
lower transport layer from adding the packet to the friend queue. This
is irrelevant for the logic in lower transport, and should not be
returned as an error.

Fixes #24014.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-05-15 17:04:07 +02:00
Luiz Augusto von Dentz ef25b864e2 Bluetooth: hci_core: Fix invalid if LE Read PHY
If LE Read PHY fails the code was still trying to parse the buffer as a
valid response.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-05-15 11:29:41 +03:00
Joakim Andersson a1b8cc2671 Bluetooth: host: Fix extended advertiser address with privacy disabled
Fix extended advertiser not using correct set random address command
to set private (NRPA) address when privacy feature has been disabled.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-05-13 21:23:20 +02:00
Kumar Gala ff579a3af3 flash: Convert DT_FLASH_AREA to FLASH_AREA macros
Convert with a combo of scripts and by hand fixups:

git grep -l DT_FLASH_AREA_.*_ID | \
 xargs sed -i -r 's/DT_FLASH_AREA_(.*)_ID/FLASH_AREA_ID(\L\1)/'

git grep -l DT_FLASH_AREA_.*_OFFSET | \
 xargs sed -i -r 's/DT_FLASH_AREA_(.*)_OFFSET/FLASH_AREA_OFFSET(\L\1)/'

git grep -l DT_FLASH_AREA_.*_SIZE | \
 xargs sed -i -r 's/DT_FLASH_AREA_(.*)_SIZE/FLASH_AREA_SIZE(\L\1)/'

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-13 21:22:53 +02:00
Kumar Gala 7310eb9e4a storage: flash_map_default: Convert to new dts macros
Convert to use new DTS macros to populate default flash map

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-13 21:22:53 +02:00
Martí Bolívar 6e8775ff84 devicetree: remove DT_HAS_NODE_STATUS_OKAY
Several reviewers agreed that DT_HAS_NODE_STATUS_OKAY(...) was an
undesirable API for the following reasons:

- it's inconsistent with the rest of the DT_NODE_HAS_FOO names
- DT_NODE_HAS_FOO_BAR_BAZ(node) was agreed upon as a shorthand
  for macros which are equivalent to
  DT_NODE_HAS_FOO(node) && DT_NODE_HAS_BAR(node) &&
- DT_NODE_HAS_BAZ(node), and DT_HAS_NODE_STATUS_OKAY is an odd duck
- DT_NODE_HAS_STATUS(..., okay) was viewed as more readable anyway
- it is seen as a somewhat aesthetically challenged name

Replace all users with DT_NODE_HAS_STATUS(..., okay), which is
semantically equivalent.

This is mostly done with sed, but a few remaining cases were done by
hand, along with whitespace, docs, and comment changes. These special
cases include the Nordic SOC static assert files.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-13 18:24:42 +02:00
Simon Glass 4b2c413e13 subsys/testsuite: Shorten the assertion messages
At present these can be very long since they include the full path of
the filename with the error.

    Assertion failed at /home/sglass/cosarm/zephry/zephyrproject/
	zephyr/tests/drivers/flash_simulator/src/main.c:102:
	test_write_read: (0 not equal to rc)

Reduce the length by omitting the current directory (where the tests
are being run) from the output:

    Assertion failed at tests/drivers/flash_simulator/src/main.c:102:
	test_write_read: (0 not equal to rc)

This improves usability for people running tests locally.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-13 16:23:39 +02:00
Krzysztof Chruscinski 1fb61ea01e shell: Move default terminal width and height to Kconfig
Default values were fixed in the code. Moved to Kconfig to allow
customized configuration. Custom configuration may be used to prevent
line breaking injected on terminal width.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-05-13 11:28:41 +02:00
Joakim Andersson 831ffcd4c2 Bluetooth: host: Fix Service Changed not cleared from flash
Fix Service Changed configuration stored in flash not deleted in flash
when calling bt_gatt_clear from bt_unpair.
When clearing the check for "is bonded" should not be made. If the
bond information is already removed this check will fail.
When clearing the check for "modified" should not be made, clearing
is in itself a modification, and should always be made.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-05-12 21:00:58 +03:00
Joakim Andersson 6de4294aed Bluetooth: host: Fix CCC cfg not cleared when overwriting oldest bond
Fix CCC cfg not cleared when overwriting oldest bond. Calling
bt_unpair with a pointer to the key will result in the key addr being
memset to zero and bt_gatt_clear is called with an zero-set address.
This happens because unpair (hci_core.c) calls bt_keys_clear before
calling bt_gatt_clear.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-05-12 21:00:58 +03:00
Emil Obalski 0c9331993f usb: dt: Update USB audio class to recent changes in DT
This commit updates USB audio class implementation with
DT changes introduced in 7e0eed9235. In particular rename
DT_NUM_INST to DT_NUM_INST_STATUS_OKAY.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2020-05-12 17:18:14 +02:00
Jukka Rissanen d940a813b1 net: lldp: Write LLDPDU data to pkt correctly
Make sure that net_pkt_write() sets the LLDPDU data correctly
in net_pkt.

Fixes #25184

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-05-11 17:11:23 +02:00
Christopher Friedt 3bfc765aad tests: socket: socketpair: tests for socketpair(2) syscall
Tests for issue #24366

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-05-10 17:46:43 +02:00
Christopher Friedt 09f957c47a net: socket: syscall for socketpair(2)
Working:

* non-blocking reads / writes
* blocking reads / writes
* send(2) / recv(2) / sendto(2) / recvfrom(2) / sendmsg(2)
* select(2)
* poll(2)

Fixes #24366

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-05-10 17:46:43 +02:00
Alexey Brodkin bf981135a0 OpenOCD: Make incompatible with SMP
In case of SMP (i.e. multiple execution units processing
the same list of tasks) we cannot use the same data structures for
getting data about active tasks as with just one processor (UP).

So until explicit support of SMP is added make sure we don't allow
to select both OPENOCD & SMP simultaneously.

Moreover starting from
commit a203d21962 ("kernel: remove legacy fields in _kernel")
this will lead to build-time error if MP_NUM_CPUS > 1.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
2020-05-10 16:18:27 +02:00
Peter A. Bigot cca0b79c27 Bluetooth: host: fix warning on unused function
get_phy is referenced by BT_EXT_ADV only when BT_OBSERVER is also
selected.  Avoid defined-but-not-used warnings in that situation.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-05-10 11:07:35 +03:00
Xavier Chapron e5aaf21a73 subsys: Replace printf by printk when applicable
Signed-off-by: Xavier Chapron <xavier.chapron@stimio.fr>
2020-05-09 21:25:33 +02:00
Tomasz Bursztyka 97326c0445 device: Fix structure attributes access
Since struct devconfig was merged earlier into struct device, let's fix
accessing config_info, name, ... attributes everywhere via:

grep -rlZ 'dev->config->' | xargs -0 sed -i 's/dev->config->/dev->/g'

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-05-08 23:07:44 +02:00
Tomasz Bursztyka 8d7bb8ffd8 device: Refactor device structures
When the device driver model got introduced, there were no concept of
SYS_INIT() which can be seen as software service. These were introduced
afterwards and reusing the device infrastructure for simplicity.
However, it meant to allocate a bit too much for something that only
required an initialization function to be called at right time.

Thus refactoring the devices structures relevantly:
- introducing struct init_entry which is a generic init end-point
- struct deviceconfig is removed and struct device owns everything now.
- SYS_INIT() generates only a struct init_entry via calling
  INIT_ENTRY_DEFINE()
- DEVICE_AND_API_INIT() generates a struct device and calls
  INIT_ENTRY_DEFINE()
- init objects sections are in ROM
- device objects sections are in RAM (but will end up in ROM once they
  will be 'constified')

It also generate a tiny memory gain on both ROM and RAM, which is nice.

Perhaps kernel/device.c could be renamed to something more relevant.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-05-08 23:07:44 +02:00
Wentong Wu ab8392fb8f logging: syst: enable protocol timestamp in SyS-T message
Enable protocol timestamp in SyS-T message.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2020-05-08 17:47:30 +02:00
Wentong Wu 450f21ff42 logging: syst: enable length field for SyS-T message
Enable generation of length field for SyS-T message.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2020-05-08 17:47:30 +02:00
Wentong Wu c3f38db5cb logging: add syst initialization code to zephyr tree
Add syst initialization code to zephyr tree.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2020-05-08 17:47:30 +02:00
Andrew Boie a203d21962 kernel: remove legacy fields in _kernel
UP should just use _kernel.cpus[0].

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-05-08 17:42:49 +02:00
Emil Obalski 8d2f13c203 usb: Add USB audio implementation
By this commit USB audio class implementation is introduced
to Zephyr.

The Zephyr USB audio device class follows bellow
documentations:

- Universal Serial Bus specification rev2.0 (usb20.pdf)
- Universal Serial Bus Device Class Definition for Audio Devices
  (audio10.pdf)
- Universal Serial Bus Device Class Definition for Audio Data Formats
  (frmts10.pdf)
- Universal Serial Bus Device Class Definition for Terminal Types
  (termt10.pdf)

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2020-05-08 15:12:27 +02:00
Emil Obalski 38aea280e7 usb: Sync receiving data from ISO OUT endpoint with SOF
This commit adds support for receiveing data from ISO OUT endpoint
for NRF devices. NRF USB IP core does not generate IRQ when
data are received on ISO OUT endpoint and it must be synchronized
with SOF event.

Enable SOF handling by default if usb audio is configured
with NRF devices.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2020-05-08 15:12:27 +02:00
Emil Obalski 98c9cebfac usb: Add Audio class related files
This commit adds files related to USB audio device class.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2020-05-08 15:12:27 +02:00
Carles Cufi b67a31e411 Bluetooth: controller: Remove legacy LL
Remove the legacy Link Layer implementation.

Closes #24187.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-05-08 15:07:00 +02:00
Mieszko Mierunski f93924c689 bluetooth: Add bluetooth support for nRF52820
This commit adds support for bluetooth in nRF52820 SoC.
Bluetooth radio related files created and added to Zephyr.

Signed-off-by: Mieszko Mierunski <mieszko.mierunski@nordicsemi.no>
2020-05-08 15:00:41 +02:00
Jukka Rissanen 601b972700 net: shell: Add command to print information about net_pkt
Print detailed information about a given net_pkt. This is
useful if there is a memory leak and you want to see more
detailed information about the data inside the buffer.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-05-08 13:24:42 +03:00
Stephanos Ioannidis aaf93205bb kconfig: Rename CONFIG_FP_SHARING to CONFIG_FPU_SHARING
This commit renames the Kconfig `FP_SHARING` symbol to `FPU_SHARING`,
since this symbol specifically refers to the hardware FPU sharing
support by means of FPU context preservation, and the "FP" prefix is
not fully descriptive of that; leaving room for ambiguity.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-05-08 10:58:33 +02:00
Henrik Brix Andersen bbc1928dd1 canbus: canopen: add program download support
Add program download (firmware update) support according to the CAN in
Automation (CiA) 302-3 draft standard proposal v4.1.0.

The implementation supports a Zephyr specific vendor command allowing
external confirmation of a newly booted firmware image. If this is not
desired, the application can confirm the image by other means.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-05-08 10:53:42 +02:00
Anthony Brandon 631cad428b disk: add stm32 sdmmc disk access driver
Add a disk access driver for the stm32 sdmmc component. The driver is
based around the stm32 cube HAL and uses the blocking API.

Signed-off-by: Anthony Brandon <anthony@amarulasolutions.com>
2020-05-08 10:53:10 +02:00
Bilal Wasim 54550c04eb net: qemu: Adding support for User Networking
Added support for Qemu User Networking and tested with
qemu_x86 model. The support is kept simple assuming that
the TAP interface will always be preferred for more
sophisticated / practical use cases.

QEMU User Networking is implemented using "slirp", which
provides a full TCP/IP stack within QEMU and uses that
stack to implement a virtual NAT'd network. As this
support is built into QEMU, it can be used with any model
and requires no admin privileges on the host machine,
unlike TAP.

Added documentation to facilitate the user.

Signed-off-by: Bilal Wasim <bilalwasim676@gmail.com>
2020-05-08 10:47:38 +02:00
Jukka Rissanen ad9f32a4e9 net: lldp: Sent LLDP packet was missing proper net_pkt type
The LLDP packet was created but its type was not set to LLDP
and was sent as ARP message.

Fixes #25084

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-05-08 11:43:00 +03:00
Robert Lubos 139da50e3c net: openthread: Allow to disable automatic network attachment
Add OpenThread configuration option, which allows to configure and start
OpenThread stack operation manually. This mode should be used in NCP
devices, as well as is needed for certification purposes, where
OpenTread stack have to be configured by the test framework and not
initialize and join the network on its own.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-05-08 10:44:27 +03:00
Jukka Rissanen 34b7a6c81c testsuite: Allow user to override minimal logging
The testsuite was always forcing minimal logging. This is problematic
as it does not allow user to see full logging string. Allow user to
override the minimal logging if needed, the default is still to
enable minimal logging.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-05-07 23:47:55 -05:00
Krzysztof Chruscinski 512de5ecac shell: Refactor command execution to enable raw arguments
Added special flag that can be used to indicate that optional
arguments are passed without any parsing (e.g. quotation marks
removal). Modified execute command to parse command line buffer
argument by argument.

After this change it is possible to forward whole command to
command handler (using select).

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-05-07 23:47:39 -05:00
Robert Lubos 3fa97df43c net: openthread: Update mbedTLS configuration
After the update, CMAC is also required when DTLS is not used.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-05-07 23:27:49 -05:00
Andrew Boie 1ff066548a ztest: end tests more robustly
If a ztest test case creates child thread(s), and one of the
descendent threads invokes ztest_test_pass(), ztest_test_fail(),
or ztest_thread_skip(), only that descendent thread will be
aborted.

Then ztest will try to run the next scenario on the ztest_thread
which is already in use. This was causing corruption issues on
SMP systems, and possibly other subtle, hard-to-debug
situations.

This patch ensures that ztest_thread is always dead before
re-using it, as run_test() now attempts to join on it instead
of using a semaphore.

The ztest_test_* functions now ensure that the ztest_thread
is always aborted, in addition to the current thread.

This isn't perfect. If the testcase spawned other threads,
they will keep running. The most robust way to fix this is to
iterate over all non-essential threads in the system and abort
them. Unfortunately, Zephyr doesn't have a facility to do
this safely.

It would also be simpler to re-use thread objects if
k_thread_create() could detect whether the thread was already
active and abort it, but this is currently not possible
since k_thread_create() can be used with uninitialzed
thread object memory and no checks are possible. This
may be improved in the future, see #23030.

Fixes: #22738
Partial fix for: #24713

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-05-07 19:21:16 -04:00
Joakim Andersson 21a42f3b67 Bluetooth: shell: Add phy handling to the shell
Add phy update callback and command to the shell.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-05-07 20:12:29 +02:00
Joakim Andersson 322f70243e Bluetooth: shell: Add data length handling in the shell
Add data length callback and command to the shell.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-05-07 20:12:29 +02:00
Joakim Andersson 0ccee9ba60 Bluetooth: host: Read current PHY when using extended advertising
When using extended advertising the connection can be established on
different PHY. In order to have an updated value of the current PHY
we need to read the PHY of the connection in the connection complete
event.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-05-07 20:12:29 +02:00
Joakim Andersson 6f0b8c1421 Bluetooth: host: Add application control of PHY change procedure
Add application control of initiating phy change procedure and it's
parameters.
The reasons for allowing the application control over the PHY:
 - Allow changing to Coded PHY.
 - Application may change PHY to react to changes in environment
   to balance throughput and range.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-05-07 20:12:29 +02:00
Joakim Andersson d9e228a4b0 Bluetooth: host: Add application control of data length procedure
Add application control of initiating data length procedure and it's
parameters.
The reasons for allowing the application control over the data length:
 - Bandwidth control adjusted based on number of active connections.
 - Changing data length before switching to coded phy.
 - Applying workarounds for interoperability problems.
 - Controlling order of ATT MTU and data length procedures.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-05-07 20:12:29 +02:00
Joakim Andersson 69dfcc6fca Bluetooth: host: Add Kconfig option for auto data length procedure
Add Kconfig option so that the application can disable automatic
initiation of the data length procedure. This is symmetric with the
PHY auto initiation kconfig option.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-05-07 20:12:29 +02:00
Joakim Andersson f85433c4a9 Bluetooth: host: Refactor setting maximum data length
Refactor setting the maximum data length parameters supported on in
auto data length procedure. This makes setting the data length of the
connection a re-usable function.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-05-07 20:12:29 +02:00
Vinayak Kariappa Chettimada aa60a51a66 Bluetooth: controller: Update Bluetooth version to 5.2
Update the Bluetooth HCI Version to 5.2.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-05-07 19:26:13 +03:00
Morten Priess 3ed658e9ed Bluetooth: controller: Added support for vendor ticker nodes
With BT_CTLR_USER_TICKER_ID_RANGE it is possible for vendors to add a
number of ticker nodes for proprietary purposes. The feature depends on
BT_CTLR_USER_EXT.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2020-05-07 17:34:21 +02:00
Tomasz Bursztyka 38970c07ab net/ieee802154: Validate length on received frames
Frame format was validated, but its length should be also validated
relevantly against the format.

Fixes #24970

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-05-07 13:20:46 +03:00
Emil Obalski 45bdb23005 usb: Special return values for custom_handler
This commit introduces dedicated return type for custom_handler.
Relevant code is updated to fulfill the API documentation.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2020-05-07 11:20:27 +02:00
Emil Obalski 8fa51bca58 usb: Allow Audio Class to handle custom_hander for all interfaces
This exception allows USB Audio Class to properly respond to the
interface requests.

This commit is temporary solution and shall not be considered as
valid solution for other classes.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2020-05-07 11:20:27 +02:00
Carles Cufi 04d1104ee5 timeouts: Fix power _sys_suspend invocation
Use K_TICKS_FOREVER instead of K_FOREVER after the timeout API rework.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-05-07 11:01:55 +02:00
Carles Cufi 8e297e87b3 console: Port to the new timeout API
Port the code so that it uses the new timeout API.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-05-07 11:01:55 +02:00
Carles Cufi 0d2b74bc6f power: ti: Port to the new timeouts API
Port the TI-related code in subsys/power so it complies with the new
timeouts API.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-05-07 11:01:55 +02:00
Peter Bigot e052c7991c settings: add const qualifier for unmodified data source
Code using this API to set a key to a value that is a string literal
produces errors in C++ because the passed pointer is not const
qualified, allowing the possibility that the callee modifies the
referenced string literal memory.  Add the required const qualifiers
since the set function does not change the passed to it.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-05-07 10:51:49 +02:00
Simon Glass fc0e10d064 shell: Support output using a va_list
At present it is not possible to write a printf()-like function in
board code which outputs to the shell. Add shell_vfprintf() to permit
this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-07 10:04:28 +02:00
Simon Glass 2a8463e2b8 shell: Extend dummy backend to record for testing
It is useful to run tests which generate shell output and check that it
is correct. Update the existing 'dummy' backend to support this.

It works by retaining the output in a small buffer so that it can be
read and checked by the test.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-07 10:04:28 +02:00
Luiz Augusto von Dentz 1c35cc18fe Bluetooth: hci_raw: Split TX into ACL and CMD pools
This might reduce the footprint if the supported sizes are different.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-05-07 10:31:36 +03:00
Luiz Augusto von Dentz f9d1b7ed63 Bluetooth: hci_raw: Fix number of TX buffers
The numbers should have been the sum of HCI commands count and ACL TX
buffers but instead the buffer size was used which makes the pool holds
substatially more buffer than necessary.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-05-07 10:31:36 +03:00
Joakim Andersson c6edfa0971 Bluetooth: shell: Add name option control to advertise parameters.
Add control over the use name option to advertise shell parameters as
an optional argument.
The argument count for extended advertise parameters had not been
updated for the maximum directed advertise parameter count.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-05-06 17:08:49 +03:00
Joakim Andersson 4592cb64ea Bluetooth: host: Add BT_LE_ADV_OPT_USE_NAME for new advertising API
Implement the BT_LE_ADV_OPT_USE_NAME when using bt_le_ext_adv_* APIs
to start the advertiser.
When starting an extended connectable advertiser the name must be
included in the advertising data, since scan response data is
not allowed in this configuration.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-05-06 17:08:49 +03:00
Joakim Andersson e9002a4fb4 Bluetooth: host: remove duplicate flags set.
Remove setting state flags in bt_le_adv_start_ext since they are set
by le_ext_adv_param_set, except for BT_ADV_PERSIST flag.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-05-06 17:08:49 +03:00
Joakim Andersson a2a7cc9fe6 Bluetooth: host: Only persist advertising with bt_le_adv_start API
Only persist advertising when the bt_le_adv_start API is used to start
the advertiser. For multiple advertising set a connectable advertiser
can only be started if there is a connection object available for the
advertiser. Leave the decision on which advertising set should be
advertising up to the application instead of suspending advertising
when no connection object is available.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-05-06 17:08:49 +03:00
Kumar Gala fdd85d5ad7 dts: Rename DT_HAS_NODE macro to DT_HAS_NODE_STATUS_OKAY
Rename DT_HAS_NODE to DT_HAS_NODE_STATUS_OKAY so the semantics are
clear.  As going forward DT_HAS_NODE will report if a NODE exists
regardless of its status.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-06 05:25:41 -05:00
Peter A. Bigot 2b33467a61 disk: disk_access_flash: align buffer
Flash drivers may impose alignment requirements on the destination
buffers due to use of DMA transfers.  In particular Nordic QSPI flash
API requires that addresses, sizes, and buffers all be 4-byte aligned.
Align the ready/copy buffer to satisfy this requirement.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-05-06 11:31:44 +02:00
Peter A. Bigot ebd19ad10b usb: mass_storage: align page buffer
Flash drivers may impose alignment requirements on the destination
buffers due to use of DMA transfers.  In particular Nordic QSPI flash
API requires that addresses, sizes, and buffers all by 4-byte aligned.
Align the page buffer to satisfy this requirement.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-05-06 11:31:44 +02:00
Håkon Øye Amundsen 0aa21a632a dfu: use stream_flash in flash_img
Leverage strem_flash in flash_img.c to reduce code size.

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2020-05-06 11:14:00 +02:00
Håkon Øye Amundsen a9676831cb storage: add stream flash library
This library supports stream writes to flash with
optinal progressive erase.

This module is a direct copy of the functionality found in
subsys/dfu/img_util/flash_img.c

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2020-05-06 11:14:00 +02:00
Alexander Wachter 464f135ce6 canbus: Convert canbus driver and subsys to new timeout API
Convert all canbus related API/samples/tests/subsys
to the new timeout API with k_timeout_t.

Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
2020-05-06 10:19:13 +02:00
Marcin Niestroj 6fdb9e6ded shell: dump characters in shell_hexdump
Improve hexdump output of shell_hexdump() to match what is currently
printed by LOG_HEXDUMP*() family of functions. That way string buffers
that are sent/received using shell commands can be easily presented
using shell_hexdump() without loosing user experience (with previous
shell_hexdump() that printed only hex bytes) and code validity (printed
buffers are not always NULL terminated with only printable characters).

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-05-06 09:42:02 +02:00
Lukasz Maciejonczyk ae68354428 net: l2: openthread: Add function for getting openthread default instance
The new function simplifies use of OpenThread API in Zephyr.

Signed-off-by: Lukasz Maciejonczyk <Lukasz.Maciejonczyk@nordicsemi.no>
2020-05-05 16:30:20 +03:00
Jukka Rissanen 65a1bebe85 net: Replace NET_WAIT_FOREVER by SYS_FOREVER_MS
As we now have SYS_FOREVER_MS, use that instead of network
specific NET_WAIT_FOREVER.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-05-05 16:29:23 +03:00
Jukka Rissanen 1fea82c125 net: ipv6_fragment: Remove extra net_pkt_cursor_init() call
The net_pkt_pull() will reset the cursor after its call so no
need to call it here.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-05-05 13:39:45 +03:00
Jukka Rissanen 8160385b57 net: pkt: Fix removal of empty buffers in net_pkt_pull()
If we have removed first net_buf, then we must not restore the
original cursor as that will point to wrong head net_buf.
Add also unit test to check that the packets are removed
properly.
Clarify the documentation that we are removing data from
beginning of the function, also document that the cursor
is reset after this call.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-05-05 13:39:45 +03:00
Joakim Andersson fdb3da8aff Bluetooth: host: Rename BT_LE_CONN_OPT to BT_CONN_LE_OPT
Rename connection options to be consistent with the rest of the API
names in conn.h

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-05-04 17:48:22 +03:00
Joakim Andersson 8b70079ebe Bluetooth: host: Remove BT_LE_CONN_OPT_2M option
Remove the BT_LE_CONN_OPT_2M option and update documentation.
This was a misunderstand about the init PHY HCI parameter.
The init PHY in the extended connection create command does not
determine which PHYs are accepted as the initial PHY of the
connection. This is instead determined by the secondary PHY of the
extended advertiser.
The init PHY parameter only specifies which conn parameters are
provided, and since we only provide one conn parameter this option
has no effect.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-05-04 17:48:22 +03:00
Kumar Gala 8101a0f661 flash: dts: replace DT_FLASH_{ERASE,WRITE}_BLOCK_SIZE with new macros
Replace:
	DT_FLASH_ERASE_BLOCK_SIZE ->
	DT_PROP(DT_CHOSEN(zephyr_flash), erase_block_size)

	DT_FLASH_WRITE_BLOCK_SIZE ->
	DT_PROP(DT_CHOSEN(zephyr_flash), write_block_size)

As this allows us to phase out the old generator.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-04 13:26:04 +02:00
Marek Porwisz d9f8a6f8e9 subsys/testsuite: Extended mocking API to support arrays
I was missing mocking api to compare data under an address pointed
by a parameter as some functions may copy buffers before passing
further.
Created ztest_expect_data and ztest_check_expected_data.

Signed-off-by: Marek Porwisz <marek.porwisz@nordicsemi.no>
2020-05-04 12:00:02 +02:00
Johan Hedberg e1dddf7bef Bluetooth: Fix NULL pointer dereference when bt_send() fails
The last parameter to hci_cmd_done() is expected to be a valid net_buf
since the function immediately tries to dereference it. Fix this by
passing the appropriate buffer reference to the function.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2020-05-04 10:59:39 +03:00
Luiz Augusto von Dentz ec5603da8d Bluetooth: L2CAP: Add status flag to track encrypt pending
This adds a new flag to track if the L2CAP channel is pending waiting
for encryption to be changed to resume connecting.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-05-02 15:59:14 +03:00
Luiz Augusto von Dentz e0cbdf3b87 Bluetooth: GATT: Add support for new PDUs
This adds support for ATT_MULTIPLE_HANDLE_VALUE_NTF,
ATT_READ_MULTIPLE_VARIABLE_REQ and ATT_READ_MULTIPLE_VARIABLE_RSP.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-05-02 15:59:14 +03:00
Luiz Augusto von Dentz f4192bda26 Bluetooth: ATT: Add support EATT bearer
This adds support for EATT bearer which was introduced in 5.2, they work
as extra channels to have GATT traffic, at the moment it is completely
transparent to application when they are in use since the allocation
happens automatically.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-05-02 15:59:14 +03:00
Luiz Augusto von Dentz d148f8648b Bluetooth: ATT: Add definitions from 5.2
This adds the definitions for Enhanced ATT along with new PDUs and UUIDs
introduced in 5.2.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-05-02 15:59:14 +03:00
Luiz Augusto von Dentz 14d6c00b9b Bluetooth: L2CAP: Add released callback
This adds a callback to indicate when the stack has released all
references to a given channel so the owner free up any resources
associated with that.

This is requires since EATT channels cannot rely on the destroy callback
as it does not use a fixed channel like ATT.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-05-02 15:59:14 +03:00
Luiz Augusto von Dentz 0473b436b5 Bluetooth: L2CAP: Process channel with fixed PSM on RX thread
This leaves only channels on the dynamic range to be offloaded to the
system queue so ATT and EATT handling are handling in the same context.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-05-02 15:59:14 +03:00
Luiz Augusto von Dentz f7586b0b04 Bluetooth: L2CAP: Add initial implementation of ECRED mode
This adds the initial implementation of ECRED mode which can connect up
to 5 channels simultaneously and is required by EATT.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-05-02 15:59:14 +03:00
Luiz Augusto von Dentz 72d4f06bf0 Bluetooth: L2CAP: Use spaces to align defines
This replaces the use of tabs with spaces to align defines.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-05-02 15:59:14 +03:00
Luiz Augusto von Dentz 95e109bc8e Bluetooth: L2CAP: Add definitions introduced in 5.2
This introduces new Enhanced Credit Based Flow Control PDUs and related
definitions which were introduced in 5.2.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-05-02 15:59:14 +03:00
Kumar Gala 05f21619e3 usb: Convert vbus-gpio usage to new devicetree macros
Convert the usb_vbus_set function to utilize a chosen property
('zephyr,usb-device') to determine the device node that should have a
'vbus-gpios' property set for usb_vbus_set to be more than just a noop.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-01 07:49:31 -05:00
Jukka Rissanen 0fa86cbbf1 net: Remove CONFIG_LEGACY_TIMEOUT_API dependency
Allow networking to work without legacy timeout API.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-05-01 10:50:03 +03:00
Jukka Rissanen 5284b597b1 net: stats: Convert to use k_timeout_t
Statistics was still using timeouts incorrectly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-05-01 10:50:03 +03:00
Jukka Rissanen 54864d063d net: gptp: Convert to use k_timeout_t
One k_timer_start() was missing k_timeout_t conversion.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-05-01 10:50:03 +03:00
Kumar Gala 8316818739 bluetooth: controller: openisa/RV32M1: Convert irqs to new dts macros
Convert old style defines for IRQ numbers to using DT_IRQN and
DT_NODELABEL to extract IRQ numbers.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-30 11:26:59 -05:00
Peter Bigot 52885d0576 coccinelle: run ms_timeout conversion semantic patch
Substitute integral constants where call sites passed named constants
that have timeout values as arguments to parameters that expect
millisecond durations.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-04-30 18:26:26 +02:00
Kumar Gala a45ea3806f x86: Rework rework x86 related code to use new DTS macros
Replace DT_PHYS_RAM_ADDR and DT_RAM_SIZE with DT_REG_ADDR/DT_REG_SIZE
for the DT_CHOSEN(zephyr_sram) node.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-30 08:37:18 -05:00
Joakim Andersson eba6265ac3 Bluetooth: controller: Add BT_CTLR_CONN_RSSI_EVENT option
Split BT_CTLR_CONN_RSSI option into two, the base option enables the
Read RSSI command, while the new BT_CTLR_CONN_RSSI_EVENT enables the
connection RSSI events. There is no handling of RSSI events, only a
BT_INFO log.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-30 13:33:16 +02:00
Bilal Wasim 220b664617 net: tftp: Adding support for TFTP Client.
Adding RFC1350 compliant support for TFTP Client in Zephyr. The
current implementation is minimal and only supports the ability
to get a file from the server.

Things for the future include support for putting files to
server and adding support for RFC2347.

Signed-off-by: Bilal Wasim <bilalwasim676@gmail.com>
2020-04-30 14:19:46 +03:00
Joakim Andersson 91c20e313d Bluetooth: Remove LEGACY_TIMEOUT_API selection from bluetooth
The bluetooth subsystem is now fully compatible with the new timeout
API, so remove the selection of the legacy API.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-30 13:46:48 +03:00
Joakim Andersson ac2ce863ef Bluetooth: shell: Convert bluetooth shell to using k_timeout struct
Convert bluetooth shell to using k_timeout struct.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-30 13:46:48 +03:00
Joakim Andersson 87d9eadf50 Bluetooth: mesh: Convert bluetooth mesh to using k_timeout struct
Convert bluetooth mesh to using k_timeout struct. Many of the mesh
modules uses timeout calculations, so it is most practical to keep
the s32_t type and only initialize a k_timeout_t struct when
calling the kernel.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-30 13:46:48 +03:00
Joakim Andersson d858264d9e Bluetooth: host: Convert bluetooth host to using k_timeout_t struct
Convert bluetooth host to using k_timeout_struct for the timeout values.
This is mostly replacing s32_t with k_timeout_t.
In l2cap the handling of no timeout in send channel request was removed
since the timeout is both documented as minimum of 1 second and never
given any no timeout value.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-30 13:46:48 +03:00
Joakim Andersson 05e5db74cf Bluetooth: controller: Convert bluetooth controller to using k_timeout_t
Convert bluetooth controller to using the new k_timeout_t API so that
CONFIG_LEGACY_TIMEOUT_API can be turned off.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-30 13:46:48 +03:00
Ravi kumar Veeramally 91de50cb37 net: tcp2: Fix FIN+ACK retransmissions in ESTABLISHED
In order to avoid retransmissions from the peer's side
on full-close, handle states properly.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2020-04-30 12:52:11 +03:00
Jukka Rissanen ae87a7177d net: pkt: Add empty buffer removal to net_pkt_pull()
If net_pkt_pull() would cause an empty net_buf, then unref
those empty buffers from the list.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-04-30 09:27:16 +03:00
Robert Lubos 358dcc1bde net: lwm2m: Handle socket errors
So far socket errors reported by poll/recvfrom were ignored, which could
lead to an unexpected behavior when socket was left in an undefined
state.

Fix this, by requesting a re-registration in the LWM2M state machine,
which will close the faulty socket and open a new one. Note, that simply
closing and re-opening a socket in the lwm2m engine would not work,
since this would silently invalidate any open observations on the
lwm2m server side (due to port number change). Triggering a fresh
registration will notify the server to update its observations.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-04-30 08:57:18 +03:00
Anas Nashif 051602f4f3 sanitycheck: support coverage with unit tests
Fix setting coverage for unit tests and link against gcov when coverage
is enabled.

Fixes #24674

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-04-29 09:01:06 -04:00
Paul Sokolovsky af3defd34e net: sntp: Namespace private SNTP definitions
SNTP implementation defined symbols like "MODE_MASK", which can easily
conflict with similary laxly defined symbols in other modules, and
indeed, we hit a case like that (below). So, prefix these symbols
consistently with "SNTP_", until more clear private namespacing
convention are made pervasive in Zephyr.

subsys/net/lib/sntp/sntp_pkt.h:14: error: "MODE_MASK" redefined
include/arch/arm/aarch32/cortex_a_r/cpu.h:17: note: this is the
  location of the previous definition

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2020-04-29 09:09:04 +03:00
Kiril Petrov ea072341d5 net: lwm2m: init pendings and replies on lwm2m_engine_start
On OT network with poor coverage, very often request/observe packets
doesn't get it's ACK and consumes from pendings/replies/message stacks.
In such cases when LWM2M engine tries to recover by resetting its state,
it fails because of lack of free messages.

Signed-off-by: Kiril Petrov <retfie@gmail.com>
2020-04-28 20:46:35 +03:00
Kiril Petrov 7305e7b4a2 net: coap: add coap_pendings_clear and coap_replies_clear
Clears whole stack of pendins and replies.

Signed-off-by: Kiril Petrov <retfie@gmail.com>
2020-04-28 20:46:35 +03:00
Joakim Andersson e9375a2814 Bluetooth: Remove bluetooth thread stack size analysis
Remove logging of individual threads spread out throughout the
bluetooth subsystem. The stacks can be analysed by enabling the
following options.

CONFIG_THREAD_ANALYZER=y
CONFIG_THREAD_ANALYZER_AUTO=y
CONFIG_THREAD_ANALYZER_RUN_UNLOCKED=y
Optional:
CONFIG_THREAD_NAME=y

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-28 09:11:13 -04:00
Joakim Andersson 27ef15b8f5 debug: thread_analyzer: Implement thread analyzer
Thread analyzer is simple module that helps in printing thread
information, like stacks usage statistics.

Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
Signed-off-by: Bartosz Gentkowski <bartosz.gentkowski@nordicsemi.no>
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-28 09:11:13 -04:00
Robert Lubos ae4ddc77cc net: lwm2m: Lower log level for duplicate response
In networks with high latencies (like NB-IoT), it's quite common to
recieve duplicated response. It's not an error condition, a correct way
to handle it is to simply ignore the duplicate. Lower the log level for
this event, not to disturb users.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-04-28 09:50:45 +03:00
Robert Lubos afb73d1d09 net: lwm2m: Fix retransmission logic
The retaransmission logic was not correct in the lwm2m_engine, and could
lead to faulty behavior in case multiple messages were pending for
retransmission in the queue.

1. Since there is a singe delayed work item for entire retransmission
   queue, `coap_pending_next_to_expire` should be called before
   scheduling next timeout, to identify which message is going to expire
   next (and when). Currently, the engine always set next timeout, based
   on timeout from the message being currently re-transmitted.
2. In case the message was re-transmitted several times, and is removed
   from the retansmission queue due to a timeout, next retransmission
   should be scheduled, in case there are other messages on the queue.
3. Verify the timeout of the earliest message to expire in the
   retransmission handler. In case messages from the beginning of the
   queue were removed, we might need to schedule the retransmission
   again, instead of sending message rightaway.
4. `lwm2m_send_message` is not handling retransmissions anyway, so
   there's no need to check send attempts. Instead, verify
   retransmission work item is already pending, and update its timeout
   if needed.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-04-28 09:50:45 +03:00
Robert Lubos df152ab59f net: coap: Add initial tx time to coap_pending structure
So far, coap_pending structure kept track only of the timeout interval
between two consecutive retransmissions. Calculations inside
`coap_pending_next_to_expire` relied only on this value. This approach
gives incorrect results though, in case multiple messages are pending
for retransmission.

For instance, assuming initial retransmission timeout is set to 2
seconds. If some message had been retransmitted already, its timeout
would be increased to 4 seconds. Any new message added to the pending
list would have a retransmission timeout set to 2 seconds, and will be
returned as a first message to expire, no matter how long the initial
message was already on the list.

To resolve this, add a `t0` field to the coap_pending structure. This
field is initialized to the initial transmission time, and is increased
on each retransmission by the retransmission timeout.
`coap_pending_next_to_expire` uses this value to calculate absolute
time, when the next retransmission should take place, and based on this
information returns correctly first pending message to expire.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-04-28 09:50:45 +03:00
Robert Lubos 40ac0a7a7d net: lwm2m: Convert to new timeout API
Align LWM2M stack implementation with the new timeout API.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-04-28 09:50:45 +03:00
Kumar Gala 7a15afc1d4 drivers: flash: replace DT_FLASH_DEV_NAME with DT macro
Replace DT_FLASH_DEV_NAME with DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL.
We now set zephyr,flash-controller in the chosen node of the device
tree to the flash controller device.

NOTE: For a SoCs with on die flash, this points to the controller and
      not the 'soc-nv-flash' node.  Typically the controller is the
      parent of the 'soc-nv-flash' node).

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-27 18:43:20 -05:00
Stephanos Ioannidis 0e6ede8929 kconfig: Rename CONFIG_FLOAT to CONFIG_FPU
This commit renames the Kconfig `FLOAT` symbol to `FPU`, since this
symbol only indicates that the hardware Floating Point Unit (FPU) is
used and does not imply and/or indicate the general availability of
toolchain-level floating point support (i.e. this symbol is not
selected when building for an FPU-less platform that supports floating
point operations through the toolchain-provided software floating point
library).

Moreover, given that the symbol that indicates the availability of FPU
is named `CPU_HAS_FPU`, it only makes sense to use "FPU" in the name of
the symbol that enables the FPU.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-04-27 19:03:44 +02:00
Joakim Andersson 3230a85590 Bluetooth: host: Include RPAs in enhanced conn complete logging
Include the RPA addresses in the enhanced connection complete debug
log. This makes it easier to debug privacy failures.
Use a new debug statement so that the debug print will work correctly
when log_strdup does not copy the string.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-27 19:02:48 +02:00
Joakim Andersson 578f2a582f Bluetooth: controller: Set local RPA field only when generated legacy
Fix local RPA field for the legacy controller. This failed without
compilation errors because of blind pointer cast between two
structs of similar definition.
Set the local RPA field of the enhanced connection complete event only
when the address was generated by the controller. If the host has
set an RPA and this one was used the controller should return all
zeroes.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-27 19:02:48 +02:00
Joakim Andersson e9b39cd304 Bluetooth: controller: Set local RPA field only when generated
Set the local RPA field of the enhanced connection complete event only
when the address was generated by the controller. If the host has
set an RPA and this one was used the controller should return all
zeroes.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-27 19:02:48 +02:00
Joakim Andersson 0d9db89dde Bluetooth: host: Fix compilation issue for extended advertising beacon
Fix compilation issue for extended advertising beacon. Adv pool was
mistakenly put under BT_OBSERVER define.
Both observer and broadcaster use the bt_lookup_id_addr. SMP cannot
be enabled without connections, so for broadcaster and observer there
will not be a lookup.
Fix compilation warning for extended scanner-only build.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-27 19:02:48 +02:00
Joakim Andersson 203d13c1a4 Bluetooth: host: Handle zero-set local RPA in enhanced conn complete
According to the BT Core spec. The local RPA field in the enhanced
connection complete event should be set if the own-address type was
set to 0x02/0x03 and the controller generated an RPA using a non-zero
IRK, otherwise the controller should return all zeroes.
In the case where we generate the RPA in the host instead we need to
handle set the on-air RPA address based on the random address set by
the host.
If this is not handled then pairing will fail because the on-air
addresses are used as input to the pairing procedure.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-27 19:02:48 +02:00
Joakim Andersson a3161ef58e Bluetooth: host: Remove extended advertising from connection complete
Remove handling of extended advertising from connection complete
event. If extended advertising has been enabled and is supported by
the controller then enhanced connection complete must be supported.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-27 19:02:48 +02:00
Peter Bigot cce7165ea4 power: device: reduce space required to identify pm-capable devices
Use a smaller ordinal type than int to hold the global index
identifying devices that support power management.

Use an upper bound instead of an array of flags to identify the
devices that were successfully suspended.

Only attempt pm on devices that provide a non-default pm control
function.

Use shorter more descriptive names for state variables.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-04-27 15:36:48 +02:00
Peter A. Bigot e3d613e1f4 subsys/cfb: move MSB_FIRST down to font capabilities
Font capabilities currently indicate whether font data is packed
horizontally or vertically, and this is used to control frame buffer
updates.  The font bit ordering should likewise be recorded in the font
description, and any reversal to match the display applied when text is
being set in the frame buffer.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-04-27 13:27:03 +02:00
Alex Porosanu 4c4f07e0dc bluetooth: controller: openisa: Fix densely scheduled event preemption
This is a rework for OpenISA SW LL of
"b7220cef86 Bluetooth: controller: split: Fix densely scheduled event
preemption"

Fix LLL implementation handling preemption of currently
active radio event with densely scheduled events in the
pipeline.

Preempt timeout was stopped without consideration to there
being more queued events in the pipeline. Also, added
chaining of preemption timeouts one after the other expiry
so as to preempt currently active events by the densely
scheduled events in the pipeline.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com>
2020-04-27 11:31:31 +02:00
Alex Porosanu 678f0296c8 bluetooth: controller: openisa: Reduce time to setup tIFS switch
This is a rework for OpenISA SW LL of
"b0826a7f65 Bluetooth: controller: split: Reduce time to setup tIFS
switch"

Refactor to reduce the setup next tIFS switch within tIFS
period of the Radio ISR.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com>
2020-04-27 11:31:31 +02:00
Alex Porosanu d6710257bd bluetooth: controller: openisa: handle latency for cancelled conn events
This is a rework for OpenISA SW LL of
"4547bfb452 Bluetooth: controller: split: handle latency for cancelled
conn events" as well as subsequent fixes

Update implementation of master and slave LLL's to correctly
handle event counter values when latencies introduced due to
connection events cancelled by active events operating in
unreserved time space.

When an active radio event extends into unreserved time
space, and a connection event prepare is scheduled but at
the time of pre-emption timeout if the connection event is
cancelled then the event count and latencies needs to be
continiued to get acummulated.

In the current controller usecases the above scenarios does
not get exercised, the changes in this commit is needed for
future roles that can extend into unreserved time space and
would cancel a scheduled connection event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com>
2020-04-27 11:31:31 +02:00
Alex Porosanu e08ceec584 bluetooth: controller: openisa: fix assert on invalid packet sequence
This is a rework for OpenISA SW LL of
"62c1e1a52b Bluetooth: controller: split: Fix assert on invalid packet
sequence"

Fix to remove assertion failure check on detecting invalid
packet sequence used by peer central and that no non-empty
packet was transmitted.

Fixes #22967.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com>
2020-04-27 11:31:31 +02:00
Luiz Augusto von Dentz 440f647013 Bluetooth: hci_raw: Fix pushing H4 headers in bt_buf_get_rx
User of bt_buf_get_rx may attempt to push their own headers, e.g. ACL
headers, so move the H4 header logic to bt_recv after logging into the
monitor since otherwise the buffer would contain H4 headers which is
not expected by the monitor.

Fixes #24646

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-04-24 10:00:02 +03:00
Kumar Gala 8b6acb5e91 soc: arm: replace DT_CPU_CLOCK_FREQUENCY with new dt macros
Replace DT_CPU_CLOCK_FREQUENCY with a PATH based reference to cpu@0
(DT_PATH(cpus, cpu_0)) and than getting the clock_frequency property:

DT_CPU_CLOCK_FREQUENCY -> DT_PROP(DT_PATH(cpus, cpu_0), clock_frequency)

This lets us remove DT_CPU_CLOCK_FREQUENCY from dts_fixup.h.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-23 23:55:37 -05:00
Krzysztof Chruscinski 53b5bae41b shell: Refactor command getters
Refactor and simplified fetching commands from the tree
of commands.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-04-23 18:30:41 +02:00
Kumar Gala 9c6c1f966c drivers: ethernet: eth_mcux: Convert to using DT_INST macros
Convert driver to use instance macro's instead of dts_fixup.h based
macros.  This moves us closer to removing both dts_fixup.h and per
instance Kconfig symbols.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-23 07:40:37 -05:00
Trond Einar Snekvik 86137c3a62 Bluetooth: Mesh: Add cfg cli list getters
Adds config client getters for all list commands:
- mod_app_get
- mod_sub_get
- net_key_get
- app_key_get

Closes #24505.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-04-23 14:03:17 +03:00
Oleg Zhurakivskyy ccb5a01fc1 net: tcp2: Refactor tcp_pkt_alloc()
In order to fix the line tracking of the TCP packet allocation
with the test protocol enabled, refactor tcp_pkt_alloc(),
so the line of the allocation can be tracked properly.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-04-23 12:40:33 +03:00
Lingao Meng be33f913ac Bluetooth: Mesh: Remove net_idx params when with app key
According Mesh Profile 1.0.1. A application key shall
binding single network key. And Device key shall bind all
network key, and dev key only known by cfg_cli and node self,
only used by cfg_cli & cfg_srv.

Fixes: #21088

Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
2020-04-23 11:30:41 +03:00
Trond Einar Snekvik 00ba872769 Bluetooth: Mesh: net_key_status only pull one key idx
Fixes bug where the config client's net_key_status handler would attempt
to pull two key indexes from a message which only holds one.

Fixes #24601.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-04-23 11:26:29 +03:00
Göran Weinholt 32864ecbcc net: lwm2m: support for reading OPAQUE resources with OMA TLV
The LwM2M stack would previously ignore all OPAQUE resources when
reading them. This meant that it was impossible to read them, even if
there was a custom read callback.

Signed-off-by: Göran Weinholt <goran.weinholt@endian.se>
2020-04-23 10:16:52 +03:00
Loic Poulain f1a7a53850 net: if: Fix net_if_send_data for non-l2 iface
Some services like DHCHPv4 directly send raw packets to the iface.
This causes issue when the iface does not implement l2, e.g.
because it is a socket offload interface. fix that.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2020-04-22 21:40:38 +03:00
Jukka Rissanen 291a4b2bd1 net: tcp2: Parse TCP options only once
Make sure we only parse the received TCP options only once. Store
the options to tcp conn struct for later use.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-04-22 20:40:02 +03:00
Ruslan Mstoi 59c21ad3cf net: tcp2: Fix reading TCP options
This patch fixes an issue with TCP options reading. Previous approach
was accessing the options with pointers (th + 1). This does not work if
TCP options span multiple net_pkt buffer fragments. Instead net_pkt
functions must be used.

Signed-off-by: Ruslan Mstoi <ruslan.mstoi@intel.com>
2020-04-22 13:15:58 +03:00
Ravi kumar Veeramally 184a2d5197 net: tcp2: Handle FIN_WAIT_2 and CLOSING
Added support for FIN_WAIT_2 and CLOSING states.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2020-04-22 12:41:39 +03:00
Robert Lubos 8d984b336e net: lwm2m: Initialize socket FD to an invalid value
During registration, first thing LWM2M does is trying to close a socket
indicated by sock_fd stored in its context. In case it is not
initialized to some invalid value (-1 in this case), LWM2M may close an
ambigous socket.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-04-21 20:58:56 +02:00
Trond Einar Snekvik e5d9291d1a Bluetooth: Zero-initialize adv params
After #22013, bt_le_adv_param got additional fields which were passed to
the bluetooth API uninitialized in the BT Mesh module. This
zero-initializes the entire structure in all usages to avoid passing
uninitialized data now and in the future.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-04-21 18:26:37 +02:00
Oleg Zhurakivskyy 61a1dc934c net: tcp2: Acknowledge the incoming FIN+ACK in FIN_WAIT_1
In order to avoid retransmissions from the peer's side
on active connection close, acknowledge the incoming FIN+ACK
in FIN_WAIT_1 state.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-04-21 16:57:22 +03:00