Commit graph

11410 commits

Author SHA1 Message Date
Sjors Hettinga 4855e8ded1 net: ppp: Properly terminate LCP state at modem side when closing down
Takes the modem state machine by calling lcp_close instead of lcp_down
Using this method the LCP layer sends a TERMINATE_REQ to the modem and the
network interface is only taken down when the LCP layer has properly
finished.
Moved the ppp_mgmt_raise_carrier_off_event and net_if_carrier_down
to lcp.c to avoid breaking the interface.
Tested on a real modem.

Fixes: zephyrproject-rtos#41627

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-02-09 13:56:54 +01:00
Aleksander Wasaznik ae9380d996 Bluetooth: Host: L2CAP: Don't send credits if chan is disconnected
Fixes bug where Host sends L2CAP Flow Control Credit after receiving a
L2CAP Disconnect Response.

The when the callback in l2cap_chan_le_recv_sdu is handed a Disconnect
Reponse, the connnection becomes disconnected, as illustrated by the
asserts. The function should now trigger sending credits if the
connection is disconnected after the callback returns.

Fixes #42112

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-02-09 13:22:47 +01:00
Vinayak Kariappa Chettimada 31c6a9cf18 Bluetooth: Controller: Fix Periodic Sync lost implementation
Fix Periodic Advertising Synchronization lost implementation
to avoid processing done event twice in cases of overlapping
events or race between sync terminate being requested.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-09 11:02:37 +01:00
Vinayak Kariappa Chettimada fc9f976485 Bluetooth: Controller: Add sync established code comment
Add code comment related to sync context field used to
indicate the sync established event being generated towards
HCI Layer.

Co-authored-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-08 14:50:17 +01:00
Vinayak Kariappa Chettimada bebc7a0df8 Bluetooth: Controller: Fix Sync Failed to be Established on no memory
Update implementation to generate Periodic Sync Failed to be
Established when Sync Established message could not be
generate due to lack of free node rx buffers and when there
is sync lost before sync established message could be
generated.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-08 14:50:17 +01:00
Piotr Pryga 66312b0e34 Bluetooth: Host: df: Fix uninit per adv sync and IQ report passed to app
In case of error in hci_df_prepare_connectionless_iq_report function
e.g. due to wrong periodic advertising sync handle, uninitilized
per_adv_sync and IQ report object were passed by cte_report_cb callback
to an application.

Correct behavior in such situation is to not to cal cte_report_cb callback.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-02-08 14:49:43 +01:00
Vinayak Kariappa Chettimada a5fb434705 Bluetooth: Controller: Fix to stop Extended Auxiliary Scan context
Fix any stray Extended Auxiliary PDU from being scanned
when disabling Extended Scanning.

Updated Extended Scan disable implementation to find any
active auxiliary scan context and stop them.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-08 13:53:07 +01:00
Vinayak Kariappa Chettimada ffeee6ce1f Bluetooth: Controller: Update ull_disable with -EALREADY return
Update ull_disable implementation to return -EALREADY if
LLL event is already disabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-08 13:53:07 +01:00
Vinayak Kariappa Chettimada 179fe06a80 Bluetooth: Controller: Fix advertising pdu latest get
Fix advertising pdu latest get to defer release of stale
PDU chain buffers. Returning NULL after some buffers where
released causes LLL to assert when chained PDUs are
switched.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-08 13:51:56 +01:00
Henning Fleddermann 3018279c30 net: lib: lwm2m: make pathstr parameter const correct
many functions in the lwm2m librarys api take a pathstr argument
that is never written to, so make it const

Signed-off-by: Henning Fleddermann <henning.fleddermann@grandcentrix.net>
2022-02-08 07:27:30 -05:00
Piotr Pryga d04456f4d9 Bluetooth: Controller: df: Fix IQ sample data saturation info drop
Nordic Semiconductor Radio peripheral provides IQ samples as
12 bits signed integer with sign extended to 16 bits.
Where out of range IQ samples (saturated) have value -32768.

Due to conversion of IQ samples to 8 bit signed integer, required by
BT 5.3 Core Vol 4, Part E sections 7.7.65.21 and 7.7.65.22 the
saturation information was lost.

The PR fixes that issue by use of value -128 to mark saturated
IQ samples. Note that BT 5.3 Core does not give any particular
value of IQ sample a special meaning.

This is a vendor specific solution and does not affect other
implementations of lower link layer.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-02-07 17:22:49 +01:00
Jarno Lamsa 98f99a37a2 net: lib: lwm2m: Use snprintk instead of snprintf
Use kernel print function to reduce the memory impact.

Signed-off-by: Jarno Lamsa <jarno.lamsa@nordicsemi.no>
2022-02-07 17:22:38 +01:00
Jarno Lamsa c2550d56c8 net: lib: lwm2m: Correct path for update result
The path was erroneously pointing to update state
resource instead of update result causing a wrong
resource value to be updated.

Signed-off-by: Jarno Lamsa <jarno.lamsa@nordicsemi.no>
2022-02-07 17:22:38 +01:00
Rubin Gerritsen 18171bc774 Bluetooth: Host: Non-discardable event buffer size is 255 for ext adv
After https://github.com/zephyrproject-rtos/zephyr/pull/41337, extended
advertising reports are no longer discardable. Ensure the
non-discardable events are large enough.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2022-02-07 17:22:13 +01:00
Aleksander Wasaznik d54ae955a2 Bluetooth: ATT: Fix conn parameter to req cb in att_reset
The conn pointer is still valid / not reused at this time and can be
used further up the stack as an identifer. This simplifies the API of
ATT, and fixes callbacks in GATT that pass on this value directly since
their API does not allow conn to be NULL.

Fixes #41794

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-02-07 17:00:51 +01:00
Daniel Nejezchleb e7489d8de7 net: tcp: Fix possible deadlock in tcp_conn_unref()
Unlock tcp_lock when calling the recv_cb. In case when
a connection is being closed from both the tcp stack
and the application, a race condition can happen resulting
in locking each other out on tcp_lock and socket lock.

Signed-off-by: Daniel Nejezchleb <dnejezchleb@hwg.cz>
2022-02-07 09:28:25 -05:00
Johann Fischer 1e3f7ca433 usb: add option to initialize USB device support at boot
Possibility to initialize USB device support is useful when
only CDC ACM class is enabled and CDC ACM UART is used as
backend for console, shell, or logging.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-02-07 13:06:35 +01:00
Andries Kruithof 43ed49c1e6 Bluetooth: tests: edtt: fix buffer overflow error
HCI/GEV/BV-01-C tries to send 255 bytes over HCI, as part of sending
an unknown/unsupported command, but the default buffer size
is 65, which results in a buffer overflow and undefined behaviour.
Instead of crashing hard we now check the buffer length.
In order for EDTT tests to pass we set the buffer size to 255

Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
2022-02-05 06:19:00 -05:00
Jacob Caughfield 2abc8cf3b2 usb: Handle USB_DC_RESET event notifications
This patch fixes an issue where mcux usb devices may stop
functioning after a reset event, because they do not
provide a USB_DC_DISCONNECTED event and USB_DC_RESET
events were not handled by the forward status callback.

Signed-off-by: Jacob Caughfield <mlsvrts@protonmail.com>
2022-02-04 22:58:06 +01:00
Carles Cufi d0ebeee0aa modbus: Get rid of custom CRC16 function
In previous commits the crc16_ansi() function has been made compliant
with the CRC-16-ANSI aka CRC-16-MODBUS standard. Use that standard
function instead of a custom one.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-02-04 12:33:22 -05:00
Carles Cufi 07c78e515c mgmt: mcumgr: Replace use of crc16 with crc16_itu_t
Since this CRC uses the 0x1021 poly with no reflection, a faster
implementation is available in the crc16_itu_t() function, which is
O(n).

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-02-04 12:33:22 -05:00
Vinayak Kariappa Chettimada 32e812c944 Bluetooth: Controller: Fix Periodic Sync Terminate race condition
Fix Periodic Sync Terminate implementation for race
conditions with ULL scheduling by using a flag to stop any
new ULL scheduling to receive chain PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-04 15:03:09 +01:00
Piotr Pryga 87bd890dc3 Bluetooth: Controller: llcp: Add missing PDU initialization
There was missing a PDU initialization. CP bit in data channel
PDU heder was not cleared. Also cte_info byte was not crelader.
That lead to malformed control procedures PDUs and issues
with connection maintenance.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-02-04 14:32:42 +01:00
Piotr Pryga 4fc0bfb0e8 Bluetooth: Controller: df: CP bit not cleared in DF conn mode RX
In direction finding connected mode there is a CP bit that is set
data PDU header. The bit was initialized only if CTE transmission
was enabled. In case of reception of a CTE the bit was available
in PDUs but not initialized.
That caused issues in connection maintenance if PDU memory buffers
were reused. PDU were malformed and connections were lost.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-02-04 14:32:42 +01:00
Berend Ozceri 9edb8e2afb mgmt: smp: Fix NULL pointer dereferences in UDP transport.
Guard call to k_thread_abort() to ensure it's not called with an
uninitialized thread and fix improper use of inet_pton() with
INADDR_ANY passed in place of a dotted-decimal string. Both of these
would otherwise lead to NULL pointer dereferences.

Signed-off-by: Berend Ozceri <berend@recogni.com>
2022-02-04 11:23:16 +01:00
Vinayak Kariappa Chettimada 8f444e490c Bluetooth: Controller: Fix missing offset adjust field assignment
Fix missing offset adjust field assignment in the Periodic
Advertising's sync_info struct that is present in the
Extended Advertising PDU.

When the sync offset is equal or over 2.4576 seconds from
the Extended Advertising PDU, then the sync offset has to
be reduced by 2.4576 seconds and the offs_adjust flag be
set in the sync_info field.

This fixes a bug where Periodic Synchronization could not
be established for Periodic Advertisings with intervals
greater than 2.4576 seconds as the sync offset was
incorrect due to rollover in the 13-bit offset field.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-04 11:19:14 +01:00
Marin Jurjević 2f4ab97168 net: lwm2m: add missing optional resource to firmware object
Firmware Update Protocol Support resource initialization
has been left out in #41402.
Initialise the resource in object creation function.

Signed-off-by: Marin Jurjević <marin.jurjevic@hotmail.com>
2022-02-04 11:19:07 +01:00
Herman Berget c537ac6aa3 Bluetooth: Host: Disallow sending unsupported MTU Exchange
The Exchange MTU sub-procedure shall only be supported on the
LE Fixed Channel Unenhanced ATT bearer.

This was checked when receiving, but sending was allowed.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-02-04 11:18:13 +01:00
Abe Kohandel 4ce354a382 bluetooth: ots: directory listing record length
The directory listing's record length should not reflect the size of the
directory listing object. This field is only the size of the directory
listing entry in the directory object and is intended to help a client
find the next record entry in the list.

Signed-off-by: Abe Kohandel <abe.kohandel@gmail.com>
2022-02-04 11:15:37 +01:00
Vinayak Kariappa Chettimada 7570af6c94 Bluetooth: Controller: Avoid reporting IQ samples after terminate
Avoid reporting IQ samples after terminate.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-04 11:15:07 +01:00
Daniel Leung 579829776a logging: syst: fix logging v2 with strings as arguments
The packaged string coming from logging subsys requires some
additional processing if there are string arguments.
These strings are actually embedded inside the package so
the string pointers inside the argument list must be
replaced with pointers to strings inside the package.
Without this extra step of processing, MIPI Sys-T's printf
function would process these arguments directly which may be
NULL pointers or invalid one pointing to somewhere.

This utilizes the new cbpprintf_external() for the processing
before feeding data to the MIPI library.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-02-04 11:14:55 +01:00
Dominik Ermel 0905e8e32f mgmt/mcumgr/lib: Fix message_size not updated
The commit fixes smp_process_request_packet failing to decrement
message_size, of read stream, by number of bytes it trims from
an input buffer.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-02-04 11:14:08 +01:00
Daniel Nejezchleb 208927d640 net: tcp: Fixed forever loop in tcp_resend_data
Increments send retry every time
after the tcp_send_data when resending.
That way unhandled return values can time
out after set amount of tcp_retries.

Signed-off-by: Daniel Nejezchleb <dnejezchleb@hwg.cz>
2022-02-04 10:56:25 +01:00
Alexander Mihajlovic bd4ddec0c8 usb: Add macro for user defined string descriptors
The new macro USBD_STRING_DESCR_USER_DEFINE works like
USBD_STRING_DESCR_DEFINE with the exception of being
ordered strictly after it. The new macro is needed to
ensures that user defined string descriptors can be added
without disturbing the order of string descriptors
defined by the usb subsystem.

Signed-off-by: Alexander Mihajlovic <a@abxy.se>
2022-02-03 14:57:42 +01:00
Piotr Pryga 281ad2102e Bluetooth: Controller: Make PHY check in conn mode Kconf dependent
Constant Tone Extension may not be transmittied with PHY CODED.
There were check to avoid situation that controller tries to
transmit or receive CTE when PHY is set to CODED.
These check were not conditionally compilated, hence when
PHY Update feature is disabled code did build.

The commit fixes the issue.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-02-03 14:57:17 +01:00
Piotr Pryga 8f59477dc6 Bluetooth: host: df: Fix wrong HCI cmd buf size for RX params set
In case the direction finding RX is enabled but without Angle
of Arrival functionality enabled, there HCI command buffer
had wrong command length assigned. It didn't take into account
two dummy antenna IDs provided to fulfil requirement from
BT 5.3 Core Vol 4, Part E sections: 7.7.82, 7.7.85.

HCI driver when received such command buffer, didn't handle it
due to wrong command length.

The commit fixes the problem.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-02-03 14:57:17 +01:00
Piotr Pryga 48313ef4df Bluetooth: common: Kconfig: Extend EVT buf size to store IQ samples
BT_BUF_EVT_RX_SIZE size by default was set to 68 bytes.
In case of build with direction finding connected mode receiver
enabled the size of event buffer was not enough to store all
IQ samples. In such situation IQ samples reports were not delivered
to Host.

The commit changes default size of event RX buffer to 255 in
case the BT_DF_CONNECTION_CTE_RX is enabled.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-02-03 14:57:17 +01:00
Piotr Pryga 8f56d4ee19 samples: Bluetooth: df: Remove dep on CTLR Kconf in sample sources
Direction finding samples had dependency on KConfig option defined
in Controller. That caused a problem for split builds where
an application and host are not part of the same binary as
controller. The code dependend on the Kconfig option
was always disabled.

To fix that issue new Kconfig options were introduced to
Host. The dependency is removed. Unwanted features may stil be
disabled and samples binaier will be smaller.

The commit aligns all direction finding samples code.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-02-03 14:57:17 +01:00
Yong Cong Sin 731241f8d0 kernel: workq: Fix type errors in delayable work handlers
A common pattern here was to take the work item as the subfield of a
containing object. But the contained field is not a k_work, it's a
k_work_delayable.

Things were working only because the work field was first, so the
pointers had the same value. Do things right and fix things to
produce correct code if/when that field ever moves within delayable.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-02-02 18:43:12 -05:00
Julien Massot f5f61ac605 debug: Add back openocd alias
OpenOCD is still using these alias, until we fix OpenOCD
upstream we should keep them.

This partially reverts commit
1a7bc06086.

Signed-off-by: Julien Massot <julien.massot@iot.bzh>
2022-02-02 14:34:41 -05:00
Vinayak Kariappa Chettimada fc348614e6 Bluetooth: Controller: Fix duplicate incomplete data status
Fix duplicate incomplete data status generated for Periodic
Advertising Report when LLL scheduling is used but auxiliary
context failed to be allocated in ULL.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-02 16:59:08 +01:00
Vinayak Kariappa Chettimada a7d0b5e980 Bluetooth: Controller: Fix race condition in sync create cancel
Fix race condition in sync create cancel that assigned NULL
scan context's associated periodic sync context which caused
ULL to dereference NULL pointer.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-02 16:59:02 +01:00
Vinayak Kariappa Chettimada 0cfcc56d9d Bluetooth: Controller: Fix duplicate release of auxiliary context
Fix duplicate release of auxiliary context when scanning
uses LLL scheduling for reception of auxiliary PDU but the
reception fails.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-02 16:58:31 +01:00
Marin Jurjević 57a66648ae net: lwm2m: fix context close race condition
Calling lwm2m_rd_client_stop causes the client context to be closed.
Doing this from arbitrary thread other than internal lwm2m engine thread
causes racing condition on lwm2m engine context pointers.

Fixes #42358

Signed-off-by: Marin Jurjević <marin.jurjevic@hotmail.com>
2022-02-02 08:58:40 -05:00
Vinayak Kariappa Chettimada f5a2b05b0d Bluetooth: Controller: Fix same peer periodic sync check
Move the same peer periodic sync check to after check for
existing periodic sync create on both 1M  and Coded PHY.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-02 12:11:21 +01:00
Vinayak Kariappa Chettimada c474e374a7 Bluetooth: Controller: Fix Periodic Sync memq link leak
Fix memq link buffer leak on Periodic Sync failed to be
established.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-02 12:11:14 +01:00
Vinayak Kariappa Chettimada 79e3be3c63 Bluetooth: Controller: Fix extended scan rx flush for continous scan
Fix missing progression of the rx_last pointer when
appending rx buffers before flushing them towards Host.
Under continuous scanning, as the disabled_cb would only
be called when reference count reaches zero, the rx_last
pointer needs to progress when appending the rx buffers.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-02 12:11:08 +01:00
Vinayak Kariappa Chettimada 5f4d6e34bc Bluetooth: Controller: Fix missing Periodic ULL sched incomplete report
Fix missing Periodic Advertising Report with incomplete
data status when ULL scheduled chain reception is aborted.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-02 12:11:00 +01:00
Vinayak Kariappa Chettimada 03f74c7ec2 Bluetooth: Controller: Fix missing Periodic LLL sched incomplete report
Fix missing Periodic Advertising Report with incomplete
data status when LLL scheduled chain reception is aborted.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-02 12:11:00 +01:00
Vinayak Kariappa Chettimada d43435a727 Bluetooth: Controller: Fix Periodic Sync Aux context leak on -ENOMEM
Fix Controller implementation to release auxiliary context
when there is no node rx buffer available to receive
Periodic Advertising Sync AUX_CHAIN_IND PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-02-02 12:11:00 +01:00