Skip to content

Commit 5615ad6

Browse files
committed
[nrf fromtree] bluetooth: host: Allow for ECDH operations through system workq
Change allows performing ECDH operations through system workq. This is done to allow reducing memory consumption by disabling the long workq on small SoCs. Signed-off-by: Marek Pieta <[email protected]> (cherry picked from commit c7f3ad6)
1 parent c8aea90 commit 5615ad6

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

subsys/bluetooth/host/Kconfig

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,10 +1002,11 @@ config BT_ECC
10021002
select PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT
10031003
select PSA_WANT_ECC_SECP_R1_256
10041004
imply MBEDTLS_PSA_P256M_DRIVER_ENABLED if MBEDTLS_PSA_CRYPTO_C
1005-
select BT_LONG_WQ
1005+
imply BT_LONG_WQ
10061006
help
1007-
If this option is set, internal APIs will be available to perform ECDH operations
1008-
through the long work queue. operations needed e.g. by LE Secure Connections.
1007+
If this option is set, internal APIs will be available to perform ECDH operations through
1008+
the long work queue (or system work queue). The operations are used e.g. by LE Secure
1009+
Connections.
10091010

10101011
endif # BT_HCI_HOST
10111012

subsys/bluetooth/host/ecc.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,11 @@ int bt_pub_key_gen(struct bt_pub_key_cb *new_cb)
279279

280280
atomic_clear_bit(bt_dev.flags, BT_DEV_HAS_PUB_KEY);
281281

282-
bt_long_wq_submit(&pub_key_work);
282+
if (IS_ENABLED(CONFIG_BT_LONG_WQ)) {
283+
bt_long_wq_submit(&pub_key_work);
284+
} else {
285+
k_work_submit(&pub_key_work);
286+
}
283287

284288
return 0;
285289
}
@@ -338,7 +342,11 @@ int bt_dh_key_gen(const uint8_t remote_pk[BT_PUB_KEY_LEN], bt_dh_key_cb_t cb)
338342
sys_memcpy_swap(&ecc.public_key_be[BT_PUB_KEY_COORD_LEN],
339343
&remote_pk[BT_PUB_KEY_COORD_LEN], BT_PUB_KEY_COORD_LEN);
340344

341-
bt_long_wq_submit(&dh_key_work);
345+
if (IS_ENABLED(CONFIG_BT_LONG_WQ)) {
346+
bt_long_wq_submit(&dh_key_work);
347+
} else {
348+
k_work_submit(&dh_key_work);
349+
}
342350

343351
return 0;
344352
}

0 commit comments

Comments
 (0)