Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] nimble/ll: Add initial Channel Sounding scheduling #1789

Draft
wants to merge 33 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d8dcb7c
nimble/ll: Add DRBG for Channel Sounding
mkasenberg Apr 11, 2024
ec2959e
nimble/ll: Add unit tests for CS DRBG
mkasenberg Feb 27, 2024
2a7ef5a
nimble/host: ble_cs: Fix 'defined but not used' warning
mkasenberg Mar 14, 2024
f22a4ad
nimble/hci: Update Channel Sounding HCI
mkasenberg Apr 14, 2024
f4801f8
nimble/ll: Add Channel Sounding state machine
mkasenberg Apr 14, 2024
e43b560
nimble/ll: Add Channel Sounding LL CTRL opcodes
mkasenberg Apr 14, 2024
83702c4
nimble/ll: Add Channel Sounding capabilities
mkasenberg Apr 14, 2024
2e84451
nimble/ll: Add CS Capabilities Exchange procedure
mkasenberg Apr 14, 2024
e57b5b8
nimble/ll: Add LE CS Set Default Settings command
mkasenberg Apr 15, 2024
87343fa
nimble/ll: Add CS Mode-0 FAE Table Request procedure
mkasenberg Apr 15, 2024
58ea93f
nimble/ll: Add CS Configuration procedure
mkasenberg Apr 15, 2024
7ffaf72
nimble/ll: Add CS Security Start procedure
mkasenberg Apr 16, 2024
84d508f
nimble/ll: Add LE CS Set Channel Classification command
mkasenberg Apr 16, 2024
e5c19a3
nimble/ll: Add LE CS Set Procedure Parameters command
mkasenberg Apr 16, 2024
5e68123
nimble/ll: Add CS Start procedure
mkasenberg Apr 16, 2024
681232e
nimble/ll: Add initial Channel Sounding scheduling
mkasenberg Apr 18, 2024
d205439
nimble/ll: Add CS step modes and states
mkasenberg Apr 19, 2024
9913b20
nimble/ll: Add to CS states support for multiple antenna paths
mkasenberg Apr 19, 2024
c3ab86a
nimble/ll: Add CS subevent states
mkasenberg Apr 19, 2024
8a432b4
nimble/ll: Add CS channel generation
mkasenberg Apr 23, 2024
e54a25e
nimble/ll: Add packets durations to CS scheduling
mkasenberg Apr 24, 2024
f7088cc
nimble/ll: Add CS_SYNC transmission/reception
mkasenberg Apr 24, 2024
7792bf8
nimble/ll: Add CS Procedure Repeat Termination procedure
mkasenberg Jun 3, 2024
8e94cb7
nimble/ll: Add CS backtracking resistance
mkasenberg Jun 3, 2024
d46d95c
nimble/phy: babblesim: Add missing g_ble_phy_t_txaddrdelay
mkasenberg Aug 22, 2024
993a8cd
babblesim: Configure TIMER3 to 16MHz
mkasenberg Aug 22, 2024
6fa75b9
nimble: host: CS fixes
mkasenberg Aug 22, 2024
fa8152a
nimble/apps: Add sample apps for CS initiator and reflector
mkasenberg Feb 5, 2024
56cea23
babblesim: targets: Add targets for CS apps
mkasenberg Feb 5, 2024
dbf1985
[wip] Quasi CS
mkasenberg Jun 5, 2024
d3b280d
[wip] nimble/phy: Add Channel Sounding to PHY
mkasenberg Jun 5, 2024
8bff1d8
[wip] nimble/ll: Add usage of CS PHY
mkasenberg Aug 22, 2024
db6987d
[wip]nimble/ll: Add HCI Subevent Result (Continue) events
mkasenberg Aug 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
nimble/ll: Add CS backtracking resistance
  • Loading branch information
mkasenberg committed Dec 25, 2024
commit 8e94cb75b5ee9b3cc6a5696c37b0b358df67a848
28 changes: 26 additions & 2 deletions nimble/controller/src/ble_ll_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,8 @@ ble_ll_cs_rx_security_req(struct ble_ll_conn_sm *connsm, uint8_t *dptr,

ble_ll_cs_drbg_init(&connsm->cssm->drbg_ctx);

connsm->cssm->start_procedure_count = 0;

return BLE_LL_CTRL_CS_SEC_RSP;
}

Expand Down Expand Up @@ -454,6 +456,8 @@ ble_ll_cs_rx_security_rsp(struct ble_ll_conn_sm *connsm, uint8_t *dptr)

rc = ble_ll_cs_drbg_init(drbg_ctx);

connsm->cssm->start_procedure_count = 0;

/* Stop the control procedure and send an event to the host */
ble_ll_ctrl_proc_stop(connsm, BLE_LL_CTRL_PROC_CS_SEC_START);
ble_ll_cs_ev_sec_enable_complete(connsm, rc ? BLE_ERR_INV_LMP_LL_PARM :
Expand Down Expand Up @@ -1758,7 +1762,7 @@ ble_ll_cs_terminate_req_make(struct ble_ll_conn_sm *connsm, uint8_t *dptr)
assert(config_id < ARRAY_SIZE(cssm->config));

*dptr = config_id;
put_le16(dptr + 1, cssm->procedure_count);
put_le16(dptr + 1, cssm->start_procedure_count + cssm->procedure_count);
dptr[3] = cssm->terminate_error_code;
}

Expand All @@ -1768,17 +1772,28 @@ ble_ll_cs_rx_cs_terminate_req(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
{
struct ble_ll_cs_sm *cssm = connsm->cssm;
uint8_t config_id = *dptr & 0b00111111;
uint16_t procedure_count = get_le16(dptr + 1);
struct ble_ll_cs_proc_params *params;

if (config_id >= ARRAY_SIZE(cssm->config)) {
ble_ll_ctrl_rej_ext_ind_make(BLE_LL_CTRL_CS_TERMINATE_REQ,
BLE_ERR_INV_LMP_LL_PARM, rspbuf);
return BLE_LL_CTRL_REJECT_IND_EXT;
}

params = &cssm->config[config_id].proc_params;

if (procedure_count > cssm->start_procedure_count + params->max_procedure_count ||
procedure_count < cssm->start_procedure_count) {
ble_ll_ctrl_rej_ext_ind_make(BLE_LL_CTRL_CS_TERMINATE_REQ,
BLE_ERR_CMD_DISALLOWED, rspbuf);
return BLE_LL_CTRL_REJECT_IND_EXT;
}

cssm->terminate_measurement = 1;

*rspbuf = config_id;
put_le16(rspbuf + 1, cssm->procedure_count);
put_le16(rspbuf + 1, cssm->start_procedure_count + cssm->procedure_count);
rspbuf[3] = BLE_ERR_SUCCESS;

return BLE_LL_CTRL_CS_TERMINATE_RSP;
Expand All @@ -1790,12 +1805,21 @@ ble_ll_cs_rx_cs_terminate_rsp(struct ble_ll_conn_sm *connsm, uint8_t *dptr)
struct ble_ll_cs_sm *cssm = connsm->cssm;
uint8_t config_id = *dptr & 0b00111111;
uint8_t error_code = dptr[3];
uint16_t procedure_count = get_le16(dptr + 1);
uint16_t total_procedure_count;

if (config_id != cssm->config_req_id ||
!IS_PENDING_CTRL_PROC(connsm, BLE_LL_CTRL_PROC_CS_TERMINATE)) {
return;
}

total_procedure_count = cssm->start_procedure_count + cssm->procedure_count;
if (total_procedure_count < procedure_count) {
cssm->start_procedure_count = procedure_count;
} else {
cssm->start_procedure_count = total_procedure_count;
}

ble_ll_ctrl_proc_stop(connsm, BLE_LL_CTRL_PROC_CS_TERMINATE);

/* TODO: In d1.0r06 the LL_CS_TERMINATE_IND was replaced with
Expand Down
3 changes: 3 additions & 0 deletions nimble/controller/src/ble_ll_cs_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,9 @@ struct ble_ll_cs_sm {
uint8_t non_mode0_channels[72];
uint8_t mode0_next_chan_id;
uint8_t non_mode0_next_chan_id;

/* Procedure counter for backtracking resistance */
uint16_t start_procedure_count;
};

int ble_ll_cs_proc_scheduling_start(struct ble_ll_conn_sm *connsm, uint8_t config_id);
Expand Down
11 changes: 10 additions & 1 deletion nimble/controller/src/ble_ll_cs_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ ble_ll_cs_generate_channel(struct ble_ll_cs_sm *cssm)
return 0;
}

static int
ble_ll_cs_backtracking_resistance(struct ble_ll_cs_sm *cssm)
{
cssm->drbg_ctx.nonce_v[1] += BLE_LL_CS_DRBG_BACKTRACKING_RESISTANCE;

return ble_ll_cs_drbg_f9(0, cssm->drbg_ctx.key, cssm->drbg_ctx.nonce_v);
}

/**
* Called when scheduled event needs to be halted. This normally should not be called
* and is only called when a scheduled item executes but scanning for sync/chain
Expand Down Expand Up @@ -346,7 +354,7 @@ ble_ll_cs_setup_next_procedure(struct ble_ll_cs_sm *cssm)
cssm->step_anchor_usecs = cssm->procedure_anchor_usecs;
cssm->subevent_anchor_usecs = cssm->step_anchor_usecs;

return 0;
return ble_ll_cs_backtracking_resistance(cssm);
}

static int
Expand Down Expand Up @@ -934,6 +942,7 @@ ble_ll_cs_proc_scheduling_start(struct ble_ll_conn_sm *connsm, uint8_t config_id

cssm->steps_in_procedure_count = ~0;
cssm->steps_in_subevent_count = ~0;
cssm->procedure_count = 0;

cssm->mode0_next_chan_id = 0xFF;
cssm->non_mode0_next_chan_id = 0xFF;
Expand Down