Commit graph

21541 commits

Author SHA1 Message Date
Andrzej Kaczmarek
c6db3c275a Bluetooth: controller: Remove redundant flags for advertising set
There's not need to mark advertising set as created by either legacy
or advertising command since this is determined by current so-called
HCI advertising mode which determines whether host uses legacy or
extended advertising commands.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-08-13 16:14:29 +02:00
Andrzej Kaczmarek
ae987f3f3a Bluetooth: controller: Disallow mixing legacy/ext adv HCI commands
As per Core 5.2, Part B, section 3.1.1 controller should not allow
mixing of legacy and extended advertising commands. Once 1st command
is received from host, we should only allow commands of the same type
and return an error on other commands.

If legacy advertising interface is selected by 1st command received,
we need to make sure that set with handle=0 is created since it's
used by all legacy commands.

When not using external host, we assume that only extended advertising
interface will be used thus all checks can be skipped (optimized and
compiled-out).

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-08-13 16:14:29 +02:00
Andrzej Kaczmarek
dd1ac8d0a6 Bluetooth: controller: Add helper for CC event with status only
A lot of commands return CC event with status parameter only, especially
when error is returned. This patch adds a helper to create such event,
similar to cmd_status.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-08-13 16:14:29 +02:00
Andrzej Kaczmarek
c088b02872 Bluetooth: controller: Fix error code on invalid adv set handle
Proper error code should be returned if advertising set with given
handle does not exist instead of generic "invalid parameters" one.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-08-13 16:14:29 +02:00
Andrzej Kaczmarek
5f8dd00a6a Bluetooth: controller: Fix return value type
This should match prototype in ll.h.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-08-13 16:14:29 +02:00
Andrzej Kaczmarek
11cf7ad3ff Bluetooth: controller: Fix set_ext_adv_param returned status
Should not always return success.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-08-13 16:14:29 +02:00
Jui-Chou Chung
fa29e1a1f8 subsys/fs/fatfs: Add kconfig option for enabling exFAT support
Expose the exFAT support option to Kconfig, so developer can
enable/disable the exFAT support on FatFs through Kconfig, no need to
touch ffconf.h.

Signed-off-by: Jui-Chou Chung <jui-chou.chung@nordicsemi.no>
2020-08-13 14:15:40 +02:00
Marcin Niestroj
22f43a5e50 net: l2: ppp: drop unused PPP_TIMEOUT macro
This macro has no use in code and was most probably replaced by
FSM_TIMEOUT (which resolves to CONFIG_NET_L2_PPP_TIMEOUT) with the same
default value.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-08-13 07:52:19 -04:00
Marcin Niestroj
221f1143ba net: l2: ppp: drop unused MAX_IP{,V6}CP_OPTIONS macros
Those macros are not used anymore after commit 35a2519091 ("net: l2:
ppp: add generic function for handling Conf-Req"), because we no longer
need preallocated table on stack for parsing option information.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-08-13 07:52:19 -04:00
Marcin Niestroj
bfb1b45fd3 net: l2: ppp: drop unused NET_L2_PPP_MAX_OPTIONS option
This option is not used after commit 50b2cafc42 ("net: l2: ppp: use
net_pkt API for replying to Configure-Req") has been applied. We don't
need to preallocate table on stack for parsing option information, so
information about maximum number of supported options is useless.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-08-13 07:52:19 -04:00
Andrzej Kaczmarek
ca99404832 Bluetooth: controller: Update scan request handling for ext adv
AdvA in extended advertising PDUs is put at different offset than in
legacy PDUs thus it's better to let caller calculate and pass AdvA and
TxAdd explicitly. This way we won't need to check whether scan request
was on legacy or extended PDU every time.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-08-13 12:26:31 +02:00
Erik Brockhoff
94d5f0854e Bluetooth: controller: fixing error re. all zero chmap in conn-ind
When a connect indication contains a channel map of all zeros, the
adv->conn is left NULL'ed after return and next connect attempt leads
to a crash.

This was identified via the Sweyntooth test suite executing the script
re. issue 6.14 towards an Oticon target.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2020-08-13 12:24:28 +02:00
Emil Obalski
c6f7d87142 samples: openthread: Call usb_enable() by the app.
This commit updates openthread sample to call usb_enable() from
the application.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2020-08-13 11:49:47 +02:00
Emil Obalski
57084f32a1 samples: zperf: usb: Enable USB by the application.
This commit allows let build zperf sample with overlay-netusb.conf.
USB subsystem must be enabled by the application.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2020-08-13 11:49:47 +02:00
Emil Obalski
3758a3d4f9 samples: tracing: Enable USB by the application
usb_enable() must be called by the application.
The application may want to register usb_dc_status_callback
and trace usb status codes (usb_dc_status_code).

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2020-08-13 11:49:47 +02:00
Emil Obalski
1d7505cd7a tracing: Check if init funciton is present.
Tracing backed is not checking if the chosen backed specifies
the init function and is asuming its always present which could
not be true.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2020-08-13 11:49:47 +02:00
Siddharth Chandrasekaran
9a91b4adf9 mgmt/osdp: Add support for OSDP in PD mode of operation
Open Supervised Device Protocol (OSDP) describes the communication
protocol for interfacing one or more Peripheral Devices (PD) to a
Control Panel (CP). The PDs are slave devices that waits for commands
from a CP. The communication happens over a RS485 multi-drop connection
with specification for a secure channel communication.

This patch adds initial support for OSDP in PD mode without secure
channel.

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-08-13 11:48:28 +02:00
Emil Obalski
27f207694c usb: hid: Allow to send data only if CONFIGURED.
USB device shall be able to send only in CONFIGURED state.
Zephyr USB HID device class allows to send the data no matter
of the USB state what is wrong. Attempting to write to endpoint
buffer in state != CONFIGURED may lead to driver error.

This patch introduces state tracing for USB HID class and
allows to send data using hid_int_ep_write() class API
only if the device remains in CONFIGURED state.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2020-08-13 11:45:31 +02:00
Peter Bigot
dfb9f11be3 ztest: make arc/cpu.h override C++ safe
This override header declares structures and inline functions, which
must be given C language linkage to avoid conflicting declaration
errors with other headers.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-08-12 16:39:37 -05:00
Joakim Andersson
b0d8758fb6 Bluetooth: host: Split SSP to it's own module
Refactor the BR/EDR SSP feature out into it's own source file.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-08-11 19:32:35 +02:00
Joakim Andersson
487d2be749 Bluetooth: host: Move reset_pairing call to bt_conn_security_changed
Move call to reset_pairing to bt_conn_security_changed, since this
should always be done at the same time, and should be done in the same
order for all calls. For auth_complete this was reset after the
callbacks, which is inconsistent with the other events.

Also call it even if not connected anymore, the disconnection complete
event will be delivered after this event. Callback should alway be
called if security was initiated.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-08-11 19:32:35 +02:00
Tomasz Bursztyka
98d9b01322 device: Apply driver_api/data attributes rename everywhere
Via coccinelle:

@r_device_driver_api_and_data_1@
struct device *D;
@@
(
D->
-	driver_api
+	api
|
D->
-	driver_data
+	data
)

@r_device_driver_api_and_data_2@
expression E;
@@
(
net_if_get_device(E)->
-	driver_api
+	api
|
net_if_get_device(E)->
-	driver_data
+	data
)

And grep/sed rules for macros:

git grep -rlz 'dev)->driver_data' |
	xargs -0 sed -i 's/dev)->driver_data/dev)->data/g'

git grep -rlz 'dev->driver_data' |
	xargs -0 sed -i 's/dev->driver_data/dev->data/g'

git grep -rlz 'device->driver_data' |
	xargs -0 sed -i 's/device->driver_data/device->data/g'

Fixes #27397

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-08-11 19:30:53 +02:00
Tomasz Bursztyka
af6140cc0d device: Apply config_info rename everywhere
Via coccinelle:

@r_device_config@
struct device *D;
@@

D->
-	config_info
+	config

And 2 grep/sed rules for macros:

git grep -rlz 'dev)->config_info' |
	xargs -0 sed -i 's/dev)->config_info/dev)->config/g'

git grep -rlz 'dev->config_info' |
	xargs -0 sed -i 's/dev->config_info/dev->config/g'

Fixes #27397

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-08-11 19:30:53 +02:00
Dominik Ermel
ca7a6f4a45 shell: kconfig: Clarify dependency of UART option from DTS
This commit adds comment clarifying how does DTS chosen node,
'zephyr,shell-uart', impacts default value of option assigning UART
port to the shell.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-08-11 19:30:05 +02:00
Vincent Wan
26696a4efa net: tcp2: compile out net_tcp_init() in tcp2.h for non-native stacks
For platforms using non-native stacks, net_tcp_init() should be
compiled out, similar to how it is done in tcp_internal.h.

Fixes #27463

Signed-off-by: Vincent Wan <vwan@ti.com>
2020-08-11 07:23:59 -05:00
Emil Gydesen
5580cb4391 Bluetooth: host: Periodic adv sync shell support
Added shell support to create and delete a periodic adv sync
object.

Signed-off-by: Emil Gydesen <emil_gydesen@bose.com>
2020-08-11 14:17:19 +02:00
Emil Gydesen
aea6afe3fa Bluetooth: host: Perodic advertisement synchronization
Added support for syncing to periodic advetisements.
The API and usage is heavily inspired by the extended advertisement
and connection APIs.

Signed-off-by: Emil Gydesen <emil_gydesen@bose.com>
2020-08-11 14:17:19 +02:00
Emil Gydesen
262a0501de Bluetooth: host: Added scan support for periodic advertisement
Added the ext adv report interval to bt_le_scan_recv_info which
denotes whether or not there is periodic advertisement data
associated with the advertisement report.

Signed-off-by: Emil Gydesen <emil_gydesen@bose.com>
2020-08-11 14:17:19 +02:00
Emil Gydesen
d5801316d7 Bluetooth: host: periodic adv shell support
Added shell support for periodic advertisement params,
data and enable.

Signed-off-by: Emil Gydesen <emil_gydesen@bose.com>
2020-08-11 14:17:19 +02:00
Emil Gydesen
8cf01ab590 Bluetooth: host: Add periodic advertising API
Added API to set periodic adv parameters, periodic adv data
and to enable/disable periodic advertisement.

Signed-off-by: Emil Gydesen <emil_gydesen@bose.com>
2020-08-11 14:17:19 +02:00
Dominik Ermel
b74ed8fecb kconfig: Move FAT FS options closer to enable
When FAT FS option is enabled, then the FAT FS sub-menu will appear
next to it, instead of appearing far down the list.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-08-11 07:47:08 -04:00
Rubin Gerritsen
38295e0b73 bluetooth: controller: Add BT_QUIRK_NO_AUTO_DLE for BT_LL_SW_SPLIT
It does not auto-initiate the DLE procedure if the default data length
parameters are not equal to the initial parameters.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2020-08-10 12:14:49 +02:00
Rubin Gerritsen
5b034e103f bluetooth: hci_driver: Add BT_QUIRK_NO_AUTO_DLE
Some controllers do not follow the recommendation of auto-initiating
a data length update if the host writes default data length parameters.

If the controller follows this recommendation, calling
LE Write Suggested Default Data Length command is sufficient
to ensure that the LL will auto-initiate the DLE procedure. Performing
a second procedure is unecessary.

In Core v5.2, Vol 4, Part E, Section 7.8.35:
The HCI_LE_Write_Suggested_Default_Data_Length command allows the
Host to specify its suggested values for the Controller's maximum
transmission number of payload octets and maximum packet
transmission time for packets containing LL Data PDUs to be used
for new connections. The Controller may use smaller or larger values
for connInitialMaxTxOctets and connInitialMaxTxTime based on local
information.

In short, this command sets connInitialMaxTxOctets
and connInitialMaxTxTime.

In Core v5.2, Vol 6, Part B, Section 4.5.10:

For a new connection: connMaxTxOctets shall be set to
connInitialMaxTxOctets and connMaxRxOctets shall be chosen by the
Controller. If either value is not 27 then the Controller should
initiate the Data Length Update Procedure at the earliest practical
opportunity.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2020-08-10 12:14:49 +02:00
Joakim Andersson
35201d86ba Bluetooth: GATT: Unregister CCC when unregistering services
Fix issue with bt_gatt_service_unregister not clearing CCC information.

If the service is unregistered while an unbonded peer is connected and
subscribed then this CCC would be restored again when registering the
service even if the peer is now disconnected.

If the service is unregistered with bonded peers CCCs stored in settings
then this value would never be cleared. If the service is registered
again then the peer would receive a service changed for this service,
but it's CCC value would still be enabled.

Fixes: #26924

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-08-10 12:11:57 +02:00
Joakim Andersson
b2d852be95 Bluetooth: GATT: Extract en queuing of GATT CCC write to a function
Extract enqueue of GATT CCC when CONFIG_BT_SETTINGS_CCC_STORE_ON_WRITE
is enabled to a helper function gatt_ccc_conn_enqueue so that it can be
reused.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-08-10 12:11:57 +02:00
Joakim Andersson
2919eac891 Bluetooth: GATT: Move clear_ccc_cfg for reuse
Move the clear_ccc_cfg function further up to be re-used without a
forward declaration in bt_gatt_service_unregister.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-08-10 12:11:57 +02:00
Marcin Niestroj
fcabe3a506 logging: fix immediate logging with multiple backends
va_list was initialized once and passed to log_backend_put_sync_string()
for each logging backend. State of such va_list was changed in each
execution, resulting in different va_list state to be passed for
consecutive log_backend_put_sync_string() calls. This results in
undefined behavior and program crashes.

Use va_copy() to copy va_list state to temporary variable for each
logging backend and keep original va_list untouched. Pass such temporary
state to log_backend_put_sync_string() to make sure state for all
consecutive calls does not change.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-08-10 10:58:43 +02:00
Jukka Rissanen
0ca346f0b9 net: config: Print interface index with pointer
Instead of just showing network interface pointer, print also
network interface index. This helps debugging.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-08-10 09:07:42 +03:00
Trond Einar Snekvik
af944ff665 Bluetooth: Mesh: Heartbeat period starts at tx
Starts the periodic heartbeat publish period at the end of the
publication, instead of at the ordering time. This ensures that the
heartbeat period doesn't get shortened by other enqueued messages.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-08-09 09:33:00 -04:00
Kamil Kasperczyk
be372872ea net: openthread: radio: Added sleep to tx as hw radio cap.
OT_RADIO_CAPS_SLEEP_TO_TX was added as a radio capability
for ieee802154 radio. Waiting on RX state before transmission
is alternative condition to OT_RADIO_CAPS_SLEEP_TO_TX support
as it was a result of OpenThread architecture and is actually
not needed in the Zephyr. Such change lets to start transmission
faster and lower SED device power consumption in active state
about 30%.

Signed-off-by: Kamil Kasperczyk <kamil.kasperczyk@nordicsemi.no>
2020-08-09 09:32:37 -04:00
Jukka Rissanen
70dae094ba net: tcp2: Make new TCP stack the default
Enable the new TCP stack as a default one in order to get people
to use it before Zephyr 2.4 is released.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-08-09 09:32:15 -04:00
Kamil Kasperczyk
27ed1c3e13 net: openthread: radio: Removed retranssmisions from radio caps.
Zephyr platform does not support MAC retransmissions on its own,
so OT_RADIO_CAPS_TRANSMIT_RETRIES capability was removed.
It should not be enabled basing on IEEE802154_HW_CSMA support,
as these are quite seperate features. Current implementation
assumes that platform performs retransmissions on its own,
what is not provided and leads to lack of MAC retransmissions.

Signed-off-by: Kamil Kasperczyk <kamil.kasperczyk@nordicsemi.no>
2020-08-07 12:35:20 +02:00
Jukka Rissanen
b143213dc1 net: tcp2: Remove the temporary connection handler
We need to remove the temporary connection handler after the
connection is established.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-08-07 10:35:48 +03:00
Jukka Rissanen
47090cbbe2 net: stats: Allow TXTIME and statistics at the same time
Allow user to enable CONFIG_NET_PKT_TXTIME and
CONFIG_NET_PKT_TXTIME_STATS at the same time. This will increase
memory consumption but as the CONFIG_NET_PKT_TXTIME_STATS is
only meant to be enabled for debugging purposes this overhead
can be accepted.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-08-07 10:12:51 +03:00
Jukka Rissanen
0f5fdec0d7 net: tcp: Reset net_pkt creation time if packet is resent
In TCP, we increase the net_pkt refcount in order to resend
it later if we do not receive ACK in time. Because we are not
getting a new net_pkt, the TXTIME statistics would be calculated
incorrectly. So if we re-send, reset the net_pkt creation time.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-08-07 10:12:51 +03:00
Jukka Rissanen
066a402a28 net: shell: Add extra net_pkt RX timing statistics
Add extra net_pkt RX timing information to "net stats" command.
You neeed to enable CONFIG_NET_PKT_RXTIME_STATS and
CONFIG_NET_PKT_RXTIME_STATS_DETAIL config options.
The "net stats" command will print something like this:

Avg RX net_pkt (7) time 459 us	[0->23->16->257->160=456 us]

The extra stats is the end of line inside brackets.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-08-07 10:12:51 +03:00
Jukka Rissanen
4dfc589904 net: Collect net_pkt RX detailed timing stats when passing IP stack
This adds RX support to get detailed net_pkt timing statistics.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-08-07 10:12:51 +03:00
Jukka Rissanen
5cb6398bbd net: shell: Add extra net_pkt TX timing statistics
Add extra net_pkt TX timing information to "net stats" command.
You neeed to enable CONFIG_NET_PKT_TXTIME_STATS and
CONFIG_NET_PKT_TXTIME_STATS_DETAIL config options.
The "net stats" command will print something like this:

Avg TX net_pkt (5867) time 82 us   [0->33->20->27=80 us]

The extra stats information is the end of line inside brackets.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-08-07 10:12:51 +03:00
Jukka Rissanen
76398945c3 net: Collect net_pkt TX timing statistics when passing IP stack
Collect information how long net_pkt has travelled in IP stack
in certain points. See network documentation what these points
are and how to get information about the timings. This initial
commit adds support to TX timing collection.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-08-07 10:12:51 +03:00
Philémon Jaermann
970a9a02ad shell: backend: Uninit shell backend if shell is uninit
When shell_uninit is called, the backend
	should also be uninit.

Signed-off-by: Philémon Jaermann <p.jaermann@gmail.com>
2020-08-06 12:16:21 -05:00