Commit graph

21541 commits

Author SHA1 Message Date
Robert Lubos
e718c8c2dc net: if: Leave all IPv4 mcast groups when interface goes down
In a similar way as its done for IPv6. This allows to rejoin the group
once the interface is up again.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-01-26 10:50:24 +01:00
Robert Lubos
4da1a75a6c net: llmnr: Rejoin IPv4 multicast group when iface is brought up
When network interface is brought up, rejoin the IPv4 multicast group
used by LLMNR service.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-01-26 10:50:24 +01:00
Robert Lubos
6f19b6e59e net: mdns: Rejoin IPv4 multicast group when iface is brought up
When network interface is brought up, rejoin the IPv4 multicast group
used by mDNS service.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-01-26 10:50:24 +01:00
Maureen Helm
1a7bc06086 debug: Remove deprecated CONFIG_OPENOCD_SUPPORT
CONFIG_OPENOCD_SUPPORT was deprecated in favor of
CONFIG_DEBUG_THREAD_INFO in Zephyr v2.6.0 and can now be removed.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-01-24 10:23:20 -05:00
Yong Cong Sin
4b40dce981 net: mgmt: Use mutex for net_mgmt_lock
Conceptually the net_mgmt_lock should be a mutex instead of a
semaphore. It is easier to identify the owner of a mutex and
debug when deadlock happens, so convert it.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-01-22 16:56:09 -05:00
Wealian Liao
7467dc4c12 tracing_user: Add ISR nest level parameter
For tracing_user, the sys_trace_isr_enter() & sys_trace_isr_exit()
block any nest interrupts & most SMP interrupts for the user. It is
hard to analyze the IRQ preemption(e.g., each IRQ counter and execution
time). This commit adds ISR nest level for each CPU to the user instead
of blocking user call back when nest interrupts.

Signed-off-by: Wealian Liao <WHLIAO@nuvoton.com>
2022-01-21 14:38:35 -05:00
Dominik Ermel
643e4d65c6 mgmt/mcumgr/lib: Fix bug in file download chunk size config
The commit fixes bug in compile time calculation of file download
chunk, FS_MGMT_DL_CHUNK_SIZE, that is permitted within selected
mcumgr buffer size, where the mcumgr header length has not been
taken into account.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-01-21 13:17:59 -05:00
Dominik Ermel
2f7c2333c8 mgmt/mcumg/lib: Use Kconfig options directly in img mgmt
The commit removes internal names given to Kconfig options,
in img_mgmt_config.h, and modifies code to use the Kconfig options
directly.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-01-21 11:34:38 -05:00
Dominik Ermel
6bbc261402 mgmt/mcumg/lib: Use Kconfig options directly in fs mgmt
The commit removes internal names given to Kconfig options,
in fs_mgmt_config.h, and modifies code to use the Kconfig options
directly.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-01-21 11:32:56 -05:00
Ryan Erickson
c6ace45a6c net: lwm2m: add uCIFI Battery object (3411)
Add the uCIFI Battery object to support
monitoring a devices battery.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2022-01-21 11:32:08 -05:00
Robert Lubos
4557d183b9 net: http_client: Set body_start pointer unconditionally
Set `body_start` pointer regardless of the body position in the recv
buffer. In result, the pointer shall indicate correctly position of the
body for each fragment, it's also explicit now that if the pointer is
not set for a fragment, there's no body in that particular fragment.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-01-21 11:31:49 -05:00
Robert Lubos
d002f8a524 net: lwm2m: Fix attribute sanity check
Validate the respective attribute parameters only if both are provided
at given level. This prevents from comparing for instance unset pmax
value (equal to 0) with some new pmin value sent by the server.

Additionally, fix the sanity check for the `pmax` value set on observer,
after fetching the attribute value at all levels (including the default
value at from the server object). Instead of using wrong max(pmin, pmax)
formula, set the pmax value only if it's a valid one (>= pmin),
otherwise ignore the value and set it to 0. This makes the notification
engine ignore the pmax value set for observation.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-01-21 11:31:20 -05:00
Piotr Pryga
4d3985f93c Bluetooth: Controller: Enable PDU CP bit when CTE RX is enabled
The CP bit is read in DF connected mode while interpreting
LL_CTE_RSP PDU, hence it must be available in struct pdu_data
type.

There were missing two Kconfig options in new LLCP tests.
They were reponsbile for disable of CP bit instruct pdu_data.
That caused tests to fail during compilation.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-21 09:30:23 -05:00
Piotr Pryga
32c9a01680 Bluetooth: Controller: df: Add disable support for CTE REQ and RSP proc
Add missing implementation for disabling CTE request and resposne
control procedures.
If any of these commands is active in LLL then ULL context has
to wait before return. The wait mechanism is based on semaphore.
The semaphore is initialized in ULL context and given by code
responsible for command completion.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-21 09:30:23 -05:00
Piotr Pryga
7895c069c4 Bluetooth: Controller: Add missing LLCP collision resolve
When there is pending local control procedure that has instant
it should be possible to run remote control procedure without
instant because there is no collision.

There were missing code to run this case in rr_st_idle() of
refactored LLCPs.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-21 09:30:23 -05:00
Piotr Pryga
aa4819994e Bluetooth: Controller: Add packet TX restrictions for CTE REQ/RSP PDUs
There are packet restrictions imposed by PHY update procedure
for PDU that includes CTE (BT Core 5.3 :
- central/peripheral can't send PDU with CTE after receive or send
LLPHY_UPDATE_IND until instant if the PHY after instant is CODED
- peripheral can't send PDU including CTE after it sends LL_PHY_REQ
PDU until receive LL_PHY_UPDATE_IND, LL_UNKNOWN_RSP, LL_REJECTED_EXT_-
IND_PDU if there is a CODE PHY in TX_PHYS
- peripheral can't send PDU including CTE after it sends LL_PHY_RSP
PDU until receive LL_PHY_UPDATE_IND if there is a CODED PHY in TX_PHYS
of LL_PHY_RSP PDU or RX_PHYS of LL_PHY_REQ PDU.

The BT 5.3 Core spec defines only one PDU that may include CTE, that is
LL_CTE_RSP PDU. To avoid a situation that there is such PDU enqueued
for transmission in LLL when packet transmission restrictions should
be applied, both procedures in almost all cases will not be executed
in parallel.

Current implementation always handles remote procedurerequest first.

There are possible three scenarios:
1. Remotely requested PHY update. Locally initiated CTE REQ.
   In this case there is no problem with LL_CTE_RSP waiting in a TX
   queue in LLL. Both procedures may be executed one after another.
2. Remotely requested CTE REQ. Locally initiated PHY update.
   In this case the CTE REQ is handled first and it will pause the
   PHY update procedure until LL_CTE_RSP PDU is acknowledged by
   remote. Then the CTE REQ procedure will be completed and PHY update
   continued.
3. Locally initiated PHY update is pending. Arrives remote CTE REQ.
   In this case the CTE REQ will be paused until localy initiated PHY
   update is completed. Then the CTE REQ will be continued.

Thanks to that there should be no PDU including CTE in LLL TX quueue.
That releases us from a situation there is a LL_CTE_RSP PDU in the
LLL TX qeueue that must be changed into LL_REJECT_EXT_IND PDU due to
change of PHY to CODED PHY after PHY update procedure completes.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-21 09:30:23 -05:00
Piotr Pryga
bb8a2da1fe Bluetooth: Controller: llcp: Fix PHY update FSM stale after instant
In peripheral role when:
 - data length update is enabled
 - the CONFIG_BT_MAX_CONN is set to 1
the PHY update control procedure after reaching instant sends two
notifications to host. It notifies host about PHY update and data
length change. Both notifications are send one after another, so two
free node rx are required. The number of available node rx in
provided conditions is one. The PHY update FSM is stalled in waiting
state for enough empty node rx. At the same time remote device is
allowed to send new remote control procedures. Received request are
handled by PHY update FSM that asserts due to unknown procedure opcode.

The commit changes number of allocated nodes to be two times a number
of LLCP connections.

This is a workaround for the issue. The best solution seems to be
sharing nodsx between connections. Though this solution requires
buffering remote control procedures until host notification is done.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-21 09:30:23 -05:00
Piotr Pryga
30ebda34cf Bluetooth: Controller: radio: Fix error in pkt conf macros
Macros responsible for preparation of packet configuration flags in
regard of PHY and CTE were wrong. PHY flags are not used as regular
integer values but bits in a bitfield, hence size of the field in
packet configuration flags is three instead of two.
In such case CTE presen filed should be moved to bit 4th.

The problem was spot when testing implementation with CODED PHY
enabled. When device was sending PDUs that had attached CTE the
radio was configured to use CODED PHY due to wrong bit set in
packet configuration flags variable (overlapping of CTE bit
with CODED PHY bit).

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-21 09:30:23 -05:00
Piotr Pryga
29c6b6e4dc Bluetooth: host: df: Add missing bt_conn_unref
There were missing bt_conn_unref after reporting IQ samples to
an application.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-21 09:30:23 -05:00
Piotr Pryga
2feedecdac Bluetooth: host: df: Add handling of HCI_LE_CTE_Request_Failed
There were no handling of HCI_LE_CTE_Request_Failed event.
The commit adds missing implementation. An application will
be notified about failed request by cte_report_cb. It is the
same callback that is used for reporting collected CTE IQ
samples. The same callback was used to avoid creation new callback.
To give an application possibility to distinguish between regular
IQ samples report and request failed additional member err was added
to bf_df_conn_iq_samples_report structure.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-21 09:30:23 -05:00
Piotr Pryga
41ad4f6880 Bluetooth: host: df: Fix wrong arguments order
Function valid_cte_req_params was called with cte_length and
cte_type in wrong order.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-21 09:30:23 -05:00
Piotr Pryga
1f3a1448f4 Bluetooth: host: df: Fix to wrong variable passed to net_buf_add
Wrong variable was passed to net_buff_add call. In could lead to
memory overwrite.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-21 09:30:23 -05:00
Piotr Pryga
85c4176446 Bluetooth: controller: Add handling of CTE request failed
CTE request control procedure may failed due to rejection by
peer device or due to receive of LL_CTE_RSP PDU without CTE.
These events has to be reported to host by HCI_LE_CTE_Request_Failed.

The commit adds missing functionalit.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-21 09:30:23 -05:00
Piotr Pryga
cb29f29cc9 Bluetooth: Controller: Integrate CTE req in ULL with refactored LLCPs
Integrate existing CTE request control procedure code in ULL with
implementation of refactor LLCPs.
The commit includes code responsible for:
- enabling CTE request and scheduling its execution by refactored
  LLCPs framework,
- running CTE request periodically
- disabling CTE reqest in case it is running periodic

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-21 09:30:23 -05:00
Piotr Pryga
f6f1ab9071 Bluetooth: Controller: Add storage for remote CTE request data
There are data received from peer device with CTE request.
These data are not part of local CTE request procedure and
they don't belong to CTE response configuration, hence separate
storage was provided.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-21 09:30:23 -05:00
Piotr Pryga
e25380b59f Bluetooth: Controller: Remove unused members from llcp_df_rsp_cfg
ant_sw_len and ant_ids members of the structure llcp_df_rsp_cfg
were not used. These data are stored in lll_df_conn_tx_cfg
that is member of lll_conn. Unused members are removed.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-21 09:30:23 -05:00
Piotr Pryga
6587336a5b Bluetooth: Controller: llcp: Make remote CTE REQ to compile with CTE RSP
Part of the CTE request procdure that is related with handling of
remote request should be compiled when CTE RSP is enabled.
Withouth it CTE response will not work. Local CTE request does not
need code reponsible for handling of remote reques.

The commit changes conditional compilation guards.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-21 09:30:23 -05:00
Piotr Pryga
e3eb224cd0 Bluetooth: Controller: Add init CTE REQ and RSP variables on conn create
There were missing initialization for CTX request and response conotrol
procedure related variables. The variables were zeored on system
startup but not initialized when a connection is established.
In case of re-use of connection instance for new connection it was not
possible to setup procedures again.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-21 09:30:23 -05:00
Piotr Pryga
0086e86153 Bluetooth: hci: Fix wrong CTE request interval type
Request interval is a number of connection events that
is used to periodically run CTE request control procedure.
BT 5.3 Core Specification defines it as 2 octets long.
It had wrong type uint8_t. Changed to correct one uint16_t.

The commit also changes type of cte_rsp_en field of lll_df_conn_tx_cfg
to state that it is a boolean flag.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-21 09:30:23 -05:00
Piotr Pryga
5e2211fa3c Bluetooth: Controller: df: Use PDUs CTEInfo to config radio TX
CTE type and length parameters in connected mode are dependent
on remote CTE request procedure. These parameters are required
to setup radio to correctly transmit CTE. The same parameters
are also included in CTEInfo byte of data channel PDU header.
The parameters were provided to LLL with PDU to be transmitted
and by lll_conn::df_tx_cfg, hence it was redundant.
The PDUs CTEInfo has to be set before transmission anyway.
The contents of the PDU are set in ULL by CTE RSP control
procedure. To remove redundancy CTE length and type from lll_df_-
conn_tx_cfg were removed from ll_df_conn_tx_cfg. It was better
option becuse it saves instructions in LLL.

Radio in connected mode was configured by lll_df_conn_cte_tx_enable.
The function just unpacked the lll_df_conn_tx_cfg mebmers and
called static function df_cte_tx_configure.
Instead of extending parameters list of lll_df_conn_cte_tx_enable,
the function was removed and df_cte_tx_configure was changed to
be global function - lll_df_cte_tx_configure.
Now LLL directly passes all parameters from pdu_data::cte_info
and ll_df_conn_tx_cfg to lll_df_cte_tx_configure.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-21 09:30:23 -05:00
Piotr Pryga
569cdaa58d Bluetooth: Controller: llcp: setting of CTE related content in pdu_data
The llcp_pdu_encode_cte_rsp functio didn't set pdu_data fields related
with CTE transmission. The commit fixes that.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-21 09:30:23 -05:00
Piotr Pryga
c50b474e01 BLuetooth: Controller: llcp: Fix wrong conditions in remote CTE req
There were wrong conditions in rp_comm_tx function for CTE request
that vefiry if:
- PHY is allowed one,
- CTE length is within allowed value.

The commit fixes it.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-21 09:30:23 -05:00
Piotr Pryga
c5812bab5e Bluetooth: Controller: Add Kconfig to enable CTE RX in conn mode
The CTE reception and sampling in connected mode was enabled
with CONFIG_BT_CTLR_DF_CONN_CTE_REQ. This is a separate fearure
tha can be enabled when CTE reqest procedure is disabled.
What more the CONFIG_BT_CTLR_DF_CONN_CTE_REQ is dependent
on CONFIG_BT_CTLR_DF_CONN_CTE_RX, not other way around.

The commit adds separate Kconfig to provide such possibility.
Also changes compilation guards for code related with the
CTE reception and sampling.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-21 09:30:23 -05:00
Piotr Pryga
4080b03b0b Bluetooth: Controller: ull: df: use new LLCP structus in conn CTE req
The implementation of the ll_df_set_conn_cte_req_enable function was
based on former implementation of LLCPs. The CTE request and response
control procedures are not implemented in former LLCPs framework.
The code has been updated to use data structues from refactored
implementation of LLCPs.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-21 09:30:23 -05:00
Piotr Pryga
b379bf99aa Bluetooth: Controller: ULL: Add impl for HCI connection CTE rsp enable
There were missing code responsible for execution of HCI_LE_Connection_-
CTE_Response_Enable HCI command.

The commit adds missing implementation into hci and upper link layer.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-21 09:30:23 -05:00
Emil Gydesen
eb2ae4c5a9 Bluetooth: ISO: Fix missing ISO type for peripheral ISO
For the peripheral ISO role, the iso->type was never set,
causing setup data path to fail.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-01-21 15:46:01 +02:00
Nazar Palamar
db1538e7cf Bluetooth: host: Update hci_init function to call setup function.
Updated hci_init function to call HCI vendor-specific Setup function
(bt_dev.drv->setup()) on beginning of HCI initialization.

This feature need when the BT Controller requires execution of the
vendor-specific commands sequence to initialize the BT Controller before
the BT Host executes a Reset sequence. To enable this feature the
CONFIG_BT_HCI_SETUP should be enable.

Fixes #41140

Signed-off-by: Nazar Palamar <nazar.palamar@infineon.com>
2022-01-21 15:04:15 +02:00
Yuval Peress
9c0b970bc2 ztest: run before function in test thread
A lot of tests need to be able to get their current tid and do some
action with it. It makes sense for the `before` function/rule to be
able to run in the same thread as the test. Note that the `after`
function does not run in the same thread because we need to guarantee
that it will run.

Signed-off-by: Yuval Peress <peress@google.com>
2022-01-20 14:20:03 -05:00
Krzysztof Chruscinski
18165b1d49 logging: Fix tracking of buffered messages
Algorithm was failing in case when overflow mode was enabled
but allocation of new message failed. It could happen if message
size exceeded buffer size. Losing track of buffered messages
can lead to logging processing freeze.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-01-20 08:52:08 -05:00
Flavio Ceolin
06bdd1001c pm: Better name for cpus state variable
A better name for array tracking cpus pm state.
s/z_power_states/z_cpus_pm_state/g

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-01-19 14:22:08 -05:00
Flavio Ceolin
baf50b5cdb pm: Proper initialize cpu power states
Do not make assumptions about the enum value for ACTIVE state and
explicitly set it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-01-19 14:22:08 -05:00
Eduardo Montoya
587d77a637 net: openthread: blank otPlatLog when logging is disabled
Implement an empty `otPlatLog` function when `CONFIG_LOG` is not
enabled. This also fixes the issue with `log_count_args` not being
available when logging is disabled.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2022-01-19 14:15:57 -05:00
Antony Pavlov
8379533bed mips: add testsuite support
This commit provides the timestamp_serialize() macro for the MIPS
architecture.

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
2022-01-19 13:48:21 -05:00
Antony Pavlov
0369998e61 arch: add MIPS architecture support
MIPS (Microprocessor without Interlocked Pipelined Stages) is a
instruction set architecture (ISA) developed by MIPS Computer
Systems, now MIPS Technologies.

This commit provides MIPS architecture support to Zephyr. It is
compatible with the MIPS32 Release 1 specification.

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
2022-01-19 13:48:21 -05:00
Vinayak Kariappa Chettimada
b5e749edfe Bluetooth: Controller: Apply suggestions from code review
Apply suggestions from code review.

Co-authored-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-01-19 13:45:09 -05:00
Vinayak Kariappa Chettimada
af5e6a1108 Bluetooth: Controller: Skip re-init of static initialized PDU fields
Skip re-initialization of statically initialized PDU struct
fields that are not modified at runtime.

When supporting connection oriented CTE, the cp bit and
resv field used for CTE info are modified, hence
re-initialized these and accordingly reset the values
when just-in-time HCI Tx Data fragmentation is performed
in the Lower Link Layer.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-01-19 13:45:09 -05:00
Flavio Ceolin
f6f710b142 pm: device: Properly handle -ENOTSUP
When a device returns -ENOTSUP for actions TURN_ON or TURN_OFF
the device state still has to be updated since the domain will
cut or restore the energy.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-01-19 13:35:32 -05:00
Jordan Yates
7101899328 pm: device_runtime: init into PM_DEVICE_STATE_OFF
Add a function to tell runtime power management that the device is
starting in the off state instead of active or suspended.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-01-19 13:35:32 -05:00
Jordan Yates
3f7f8d8f75 pm: device: helper to query power domain
Adds a helper for devices to check if they are on a power-domain or not.
Drivers can use this information to determine if they will be turned on
at some point in the future, or if they are already turned on.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-01-19 13:35:32 -05:00
Jordan Yates
9e9fb319a7 pm: device: helper for running actions on children
Adds a helper function for running PM actions on child devices. A custom
implementation of `device_supported_foreach` is used as we don't
necessarily want the early exit behaviour of that function in the power
domain context.

The early exit behaviour can be obained through a return value in the
failure callback if that is desired.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-01-19 13:35:32 -05:00