You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2022/03/10 11:52:53 UTC
[mynewt-nimble] 02/07: nimble/ll: Optimize CSA2 perm for Thumb2
This is an automated email from the ASF dual-hosted git repository.
andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
commit 21628969837beb9fa36f90817da0c00542a9cf1d
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Mon Feb 28 11:19:57 2022 +0100
nimble/ll: Optimize CSA2 perm for Thumb2
Thumb2 has dedicated instructions for reversing bit and byte order so
CSA2 permutation can be computed in 2 simple instructions.
Also using uint32 for parameters means we skip zero-extending value
every second instruction.
---
nimble/controller/src/ble_ll_utils.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/nimble/controller/src/ble_ll_utils.c b/nimble/controller/src/ble_ll_utils.c
index c312626..7b3a863 100644
--- a/nimble/controller/src/ble_ll_utils.c
+++ b/nimble/controller/src/ble_ll_utils.c
@@ -202,10 +202,22 @@ ble_ll_utils_calc_num_used_chans(const uint8_t *chan_map)
}
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_CSA2)
-static uint16_t
-ble_ll_utils_csa2_perm(uint16_t in)
+#if __thumb2__
+static inline uint32_t
+ble_ll_utils_csa2_perm(uint32_t val)
{
- uint16_t out = 0;
+ __asm__ volatile (".syntax unified \n"
+ "rbit %[val], %[val] \n"
+ "rev %[val], %[val] \n"
+ : [val] "+r" (val));
+
+ return val;
+}
+#else
+static uint32_t
+ble_ll_utils_csa2_perm(uint32_t in)
+{
+ uint32_t out = 0;
int i;
for (i = 0; i < 8; i++) {
@@ -218,6 +230,7 @@ ble_ll_utils_csa2_perm(uint16_t in)
return out;
}
+#endif
static uint16_t
ble_ll_utils_csa2_prng(uint16_t counter, uint16_t ch_id)