Commit Graph

4669 Commits

Author SHA1 Message Date
Andrzej Kaczmarek e2f3e92d03 Update mailmap 2022-09-30 08:42:25 +02:00
Andrzej Kaczmarek 4c5c48e70b nimble/ll: Fix MIC failure during encryption start
This fixes unexpected MIC failure when retransmission happens during
encryption start procedure as follows:
- peripheral sends LL_START_ENC_REQ unencrypted, central acks
- central sends LL_START_ENC_RSP encrypted, peripheral acks
- central retransmits LL_START_ENC_RSP for whatever reason

The problem is that peripheral increments rx packet counter after 1st
LL_START_ENC_RSP is received, so retransmission is decrypted with
different rx packet counter and thus is not valid. We properly ignore
MIC failure for retransmission, but then code checks if received PDU is
valid in currect state, i.e. encryption start procedure. Since it was
not properly decrypted, the PDU type is likely garbage and thus
considered as not allowed so we terminate connection with MIC failure.

The "ultimate" fix for such issues is to simply ignore any retransmitted
PDU with MIC failure since basically contents of such PDUs are garbage
and not really useful for any checks.
2022-09-29 19:23:56 +02:00
Andrzej Kaczmarek ef7c30dcbe nimble/ll: Fix aux_data leak
We should mark hci stream if ext adv report event is either disabled or
cannot be allocated, otherwise we will never free aux_data.
2022-09-29 19:22:54 +02:00
Andrzej Kaczmarek 0c3e1b728c nimble/ll: Fix active scan on aux
We should not allow to free aux_data from pkt_in if there was
AUX_SCAN_REQ sent for that pdu as this will result in use-after-free of
aux_data when AUX_SCAN_RSP is received.

This can happen if we send AUX_SCAN_REQ from isr and then in pkt_in
figure out this is a duplicate so we don't want to scan this chain
anymore. We should just wait for AUX_SCAN_RSP and stop there.
2022-09-29 19:22:54 +02:00
Andrzej Kaczmarek 9257bfecf2 nimble/ll: Fix backoff handling for aux scan
We should update backoff after receiving scan response PDU instead of
waiting for complete chain to be received.

This also fixes problem where we try to update backoff in an invalid
state, i.e. backoff_count is non-zero. It happens if we start to scan
response chain with backoff_count=0 and before complete chain is scanned
we scan another pdu which fails. This updates backoff_count to non-zero
value so when we finish scanning chain and try to update backoff, the
backoff_count value is non-zero which is considered an invalid state.

[Core 5.3, Vol 6, Part B, 4.4.3.2]
2022-09-29 19:22:54 +02:00
Andrzej Kaczmarek ef03c7c1c6 nimble/ll: Always send assert vs event if enabled
We should always send assert vs event if enabled, regardless if we'll
break due to attached debugger or not. This is useful when using monitor
over RTT since using RTT means debugger is attached even though we may
not actually have sw debugger running.
2022-09-29 10:07:30 +02:00
Michal Gorecki b36ce21bc1 host: Add defines for Key Distribution settings
Add key distribution masks defines. This can be used to initialize sm_our_key_dist
and sm_their_key_dist fields in ble_hs_cfg struct.
2022-09-28 10:01:55 +02:00
Andrzej Kaczmarek d7ae17e2eb nimble/ll: Fix failed CRC on AUX_CONNECT_RSP
If CRC does not match on AUX_CONNECT_RSP, we should cancel already
scheduled connection as otherwise there will be spurious connection
timeout as scheduler will run uninitialized connection.
2022-09-27 22:12:45 +02:00
Andrzej Kaczmarek 465ffa69b8 nimble/ll: Fix initiator on aux with RPA and no peer IRK
This is follow up on 8447ec2969. We allow peer RPA to be used in the
same way as identity address if we do not have peer IRK, so we also need
to update checks for AUX_CONNECT_RSP.
2022-09-27 22:12:25 +02:00
Andrzej Kaczmarek 1429289797 nimble/ll: Fix skipping chain pdus
Since chain pdus are scheduled from LL while previous aux/chain pdu is
already in scheduler, it's possible that previous pdu will be already
processed before LL can schedule chain. In such case previous pdu will
be sent with AuxPtr offset=0 and we should simply drop subseqent pdus.
2022-09-27 22:12:16 +02:00
Hang Fan d21a386e96 porting/examples: Fix build error
Add default macro of MYNEWT_VAL_BLE_L2CAP_COC_SDU_BUFF_COUNT
to avoid build error.
2022-09-27 08:32:45 +02:00
Jakub Rotkiewicz 154bdd46ac btshell and blestress: update l2cap coc rx buffers
Updated apps to support setting the RX SDU buffers number.
2022-09-26 14:51:29 +02:00
Jakub Rotkiewicz d3dc966fc7 nimble/host: fix l2cap coc rx endpoint buffs alloc
Dissallow current vs next sdu index check when only one buffer is used.
2022-09-26 14:51:29 +02:00
Bas van den Berg 0cdfaa8622 fix: make include cm4 dependant on SERIES, not MYNEWT only 2022-09-26 14:49:18 +02:00
Bas van den Berg 00d10c2d99 refactor: move ble_hs_misc_null_addr to only usage, make static 2022-09-26 14:49:18 +02:00
Bas van den Berg 10beb51ea4 refactor: ble_gap_conn_broken can be private, make static 2022-09-26 14:49:18 +02:00
Szymon Janc d4f945d973 README: Add some notes about external projects using NimBLE
Point to known external projects that use NimBLE.
2022-09-26 09:06:37 +02:00
Andrzej Kaczmarek 0d7ae1bc18 nimble/phy/nrf5x: Enable LNA on "start now" rx
LNA was not enabled properly if RX was started "now".
2022-09-21 17:46:27 +02:00
Andrzej Kaczmarek 8519ba4dc3 nimble/phy: Make private functions static
Some functions are never used by LL and can be considered private so
let's make them static.
2022-09-21 10:33:15 +02:00
Andrzej Kaczmarek 35583ac325 babblesim: Print script errors to stderr 2022-09-19 11:42:50 +02:00
Andrzej Kaczmarek ce36b50ae5 babblesim: Update dependency to phy 2022-09-19 11:42:50 +02:00
Andrzej Kaczmarek 3b02d6ba2f nimble/ll: Remove nrf52 and nrf5340 phys 2022-09-14 12:52:29 +02:00
Andrzej Kaczmarek eaa56fa7e7 nimble/phy/nrf5x: Adjust scheduling offset for FEM turn on
Radio enable takes 2 ticks, so if FEM turn on time is more than that we
need to account for extra tick in scheduling offset.
2022-09-14 12:52:29 +02:00
Andrzej Kaczmarek f396441898 nimble/phy/nrf5x: Add support for FEM turn on time
This adds proper support for FEM turn on time. Max supported turn on
time is 90us due to some optimizations in code, but that should be
enough - we can change it later if needed.
2022-09-14 12:52:29 +02:00
Andrzej Kaczmarek 9ea411fbe6 nimble/phy/nrf5x: Add nRF53 support
This adds code for nRF5340 net core.
2022-09-14 12:52:29 +02:00
Andrzej Kaczmarek 0024679216 nimble/phy/nrf5x: Force FEM disable on ble_phy_disable 2022-09-14 12:52:29 +02:00
Andrzej Kaczmarek 9dd64d2903 nimble/phy/nrf5x: Move out TX power rounding 2022-09-14 12:52:29 +02:00
Andrzej Kaczmarek e4b9864514 nimble/phy/nrf5x: Rework nRF52 erratas 2022-09-14 12:52:29 +02:00
Andrzej Kaczmarek 4d3b302fa6 nimble/phy/nrf5x: Move out nRF52 code
This moves most of code specific to nRF52 series to separate file and
creates private phy APIs to call that code.

The moved code is anything related to PPI: FEM, GPIO debug and PPI
itself.
2022-09-14 12:52:29 +02:00
Andrzej Kaczmarek a7b016ebac nimble/phy: Introduce common phy for nRF52 and nRF53
This is starting point for common phy for nRF52 and nRF53 which will
make maintaining both much easier. For now this is just c&p of nrf52
phy to make changes easier to follow.

Note that nrf5x phy will not support nRF51 since, apart from other
differences, it does not support hardware tifs which is required for
nRF51.
2022-09-14 12:52:29 +02:00
Andrzej Kaczmarek 084eb382c5 nimble/ll: Fix scheduling adv PDUs
We schedule consecutive PDUs in advertising event at "now" timestamp,
but to make sure we do not miss the slow we should account for an extra
tick that can happen during processing.
2022-09-12 21:26:14 +02:00
Andrzej Kaczmarek fbeb4b7506 nimble/ll: Fix calculations for aux scheduling
We need to take scheduling offset into account when calculating
advertising event duration.
2022-09-12 21:26:14 +02:00
Szymon Janc 2c3c3bf82c nimble/ll: Add generic interface for controlling FEM antenna
This allows to select active antenna if supported by FEM.
0 means default antenna, while any other value is FEM specific.
2022-09-12 09:28:45 +02:00
Szymon Janc fb1ae2ec75 nimble/fem: Add support for runtime configuration of SKY66112
This allows to configure FEM operation mode at runtime.
2022-09-12 09:28:45 +02:00
Szymon Janc 2a50a58da6 nimble/ll: Rename PLNA to FEM
This is in preparation to extend generic API with additions like
multiple antenna support which is offered by some FEMs.
2022-09-12 09:28:45 +02:00
Andrzej Kaczmarek 1101fecc85 nimble/ll: Fix txend callback
We should call txend before transition as otherwise called code may mess
up transition.
2022-09-09 13:25:02 +02:00
Andrzej Kaczmarek c562999bc3 nimble/phy: Add support for variable T_ifs
This enables APIs to support variable T_ifs in PHY. By default 150us is
used but this value can be changed before each transition. After
transition value is reset to default so LL does not need to care about
setting T_ifs everywhere.

This may be useful for scheduling of related events with tight timings.

Disabled by default since it allows for compile-time optimizations.
2022-09-08 11:59:37 +02:00
Szymon Janc 60b51b0b80 nimble/ports: Refresh syscfg 2022-09-08 11:58:53 +02:00
Szymon Janc fbe82de8f7 nimble/ll: Set default ACL buffer size to 251
This controls only data part of packet and thus should not include
ACL header size. Set default to 251 to avoid unnecessary packets
fragmentation.
2022-09-08 11:58:53 +02:00
Jakub 12bd3d1e8b tools/hci_throughput: updated README.md file, help descriptions 2022-09-08 11:57:32 +02:00
Andrzej Kaczmarek 0b983a52d5 babblesim: Fix blehci target 2022-09-08 11:44:24 +02:00
Andrzej Kaczmarek e74371c06f nimble/ll: Disable vnd assert on BabbleSim
BabbleSim does not understand __BKPT(0) and we can simply assert instead.
2022-09-08 11:44:24 +02:00
Andrzej Kaczmarek 886597f223 babblesim: Fix EDTT transport nad target 2022-09-06 14:27:36 +02:00
Andrzej Kaczmarek 77cf738074 nimble/phy/nrf52: Add tx-tx transition
This adds TX-TX transition, initially supported only on nRF52 PHY.
2022-09-06 14:27:15 +02:00
Szymon Janc f85bbda005 nimble/ll: Fix BLE_HCI_OCF_VS_SET_DATA_LEN OCF
This was duplicating BLE_HCI_OCF_VS_CSS_ENABLE and caused assert
on register.
2022-09-06 14:26:01 +02:00
Jakub Rotkiewicz 46df736023 nimble/host/ble_l2cap_coc: coding style fixes 2022-09-05 09:46:07 +02:00
Jakub Rotkiewicz c1a2c99498 nimble/host/ble_l2cap_coc: SDUs for faster data rx
Added list of SDUs for faster data rx.
This allows to process more data while receiving another.
2022-09-05 09:46:07 +02:00
Andrzej Kaczmarek 5ea8badc46 nimble/ll: Add vs command to change all data length parameters 2022-09-02 16:08:06 +02:00
Michal Gorecki 3de15c9615 apps/peripheral: Fix not saving conn_handle after connection
Even though conn_handle is defined and later used in
connection params update request event callback, it was
never initialized with a proper value.
2022-08-31 17:22:04 +02:00
Szymon Janc ca3e598270 nimble/ll: Fix not setting TX power in HCI VS command
PHY was not configured to use new TX power immediatelly. This resulted
in new TX power being used only after advertising event ended.
2022-08-31 12:00:19 +02:00