Skip to content

Commit

Permalink
bluetooth: host: LE CS subevent result reassembly
Browse files Browse the repository at this point in the history
Adds HCI support for LE CS subevent result continue
event and the reassembly logic for the partial results.

When subevent results are completed or the subevent is
aborted, the user callback is invoked with a buffer
pointing to the HCI event buffer, so no copy is done.

When subevent results are incomplete, then a reassembly
buffer is allocated from a fixed sized pool. This buffer
is used for the reassembling of the subevent result
containing all of the step data, which is then passed
to the user via the callback. kconfigs have been added
to set the size and the count of the reassembly buffer.

Signed-off-by: Burak Gorduk <[email protected]>
  • Loading branch information
bugo-nordic authored and nashif committed Oct 15, 2024
1 parent ac98d0e commit c5a126c
Show file tree
Hide file tree
Showing 6 changed files with 446 additions and 34 deletions.
20 changes: 18 additions & 2 deletions include/zephyr/bluetooth/conn.h
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,6 @@ enum bt_conn_le_cs_procedure_done_status {
/** Subevent done status */
enum bt_conn_le_cs_subevent_done_status {
BT_CONN_LE_CS_SUBEVENT_COMPLETE = BT_HCI_LE_CS_SUBEVENT_DONE_STATUS_COMPLETE,
BT_CONN_LE_CS_SUBEVENT_INCOMPLETE = BT_HCI_LE_CS_SUBEVENT_DONE_STATUS_PARTIAL,
BT_CONN_LE_CS_SUBEVENT_ABORTED = BT_HCI_LE_CS_SUBEVENT_DONE_STATUS_ABORTED,
};

Expand Down Expand Up @@ -618,7 +617,19 @@ struct bt_conn_le_cs_subevent_result {
int8_t reference_power_level;
/** Procedure status. */
enum bt_conn_le_cs_procedure_done_status procedure_done_status;
/** Subevent status. */
/** Subevent status
*
* For aborted subevents, this will be set to @ref BT_CONN_LE_CS_SUBEVENT_ABORTED
* and abort_step will contain the step number on which the subevent was aborted.
* Consider the following example:
*
* subevent_done_status = @ref BT_CONN_LE_CS_SUBEVENT_ABORTED
* num_steps_reported = 160
* abort_step = 100
*
* this would mean that steps from 0 to 99 are complete and steps from 100 to 159
* are aborted.
*/
enum bt_conn_le_cs_subevent_done_status subevent_done_status;
/** Abort reason.
*
Expand All @@ -640,6 +651,11 @@ struct bt_conn_le_cs_subevent_result {
/** Number of CS steps in the subevent.
*/
uint8_t num_steps_reported;
/** Step number, on which the subevent was aborted
* if subevent_done_status is @ref BT_CONN_LE_CS_SUBEVENT_COMPLETE
* then abort_step will be unused and set to 255
*/
uint8_t abort_step;
} header;
struct net_buf_simple *step_data_buf;
};
Expand Down
20 changes: 20 additions & 0 deletions include/zephyr/bluetooth/hci_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -3636,6 +3636,25 @@ struct bt_hci_evt_le_cs_subevent_result {
uint8_t steps[];
} __packed;

#define BT_HCI_EVT_LE_CS_SUBEVENT_RESULT_CONTINUE 0x32

struct bt_hci_evt_le_cs_subevent_result_continue {
uint16_t conn_handle;
uint8_t config_id;
uint8_t procedure_done_status;
uint8_t subevent_done_status;
#ifdef CONFIG_LITTLE_ENDIAN
uint8_t procedure_abort_reason: 4;
uint8_t subevent_abort_reason: 4;
#else
uint8_t subevent_abort_reason: 4;
uint8_t procedure_abort_reason: 4;
#endif /* CONFIG_LITTLE_ENDIAN */
uint8_t num_antenna_paths;
uint8_t num_steps_reported;
uint8_t steps[];
} __packed;

#define BT_HCI_EVT_LE_CS_TEST_END_COMPLETE 0x33
struct bt_hci_evt_le_cs_test_end_complete {
uint8_t status;
Expand Down Expand Up @@ -3734,6 +3753,7 @@ struct bt_hci_evt_le_cs_test_end_complete {
#define BT_EVT_MASK_LE_CS_READ_REMOTE_FAE_TABLE_COMPLETE BT_EVT_BIT(44)
#define BT_EVT_MASK_LE_CS_CONFIG_COMPLETE BT_EVT_BIT(46)
#define BT_EVT_MASK_LE_CS_SUBEVENT_RESULT BT_EVT_BIT(48)
#define BT_EVT_MASK_LE_CS_SUBEVENT_RESULT_CONTINUE BT_EVT_BIT(49)
#define BT_EVT_MASK_LE_CS_TEST_END_COMPLETE BT_EVT_BIT(50)

/** HCI Error Codes, BT Core Spec v5.4 [Vol 1, Part F]. */
Expand Down
20 changes: 20 additions & 0 deletions subsys/bluetooth/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,26 @@ config BT_CHANNEL_SOUNDING_TEST
help
Enable support for Channel Sounding test mode.

config BT_CHANNEL_SOUNDING_REASSEMBLY_BUFFER_SIZE
int "Subevent result reassembly buffer size"
depends on BT_CHANNEL_SOUNDING
range 239 5600
default 5600
help
When the results for a CS subevent cannot fit into a single HCI event,
it will be split up into multiple events and consequently, reassembled into a
full CS subevent. This config sets the size of the reassembly buffer.

config BT_CHANNEL_SOUNDING_REASSEMBLY_BUFFER_CNT
int "Subevent result reassembly buffer count"
depends on BT_CHANNEL_SOUNDING
range 1 BT_MAX_CONN
default 1
help
Controls the number of the reassembly buffers for CS subevent
results. Each running CS procedure is allocated one buffer and the
number of concurrent CS procedures is limited by this value.

endif # BT_CONN

rsource "Kconfig.iso"
Expand Down
Loading

0 comments on commit c5a126c

Please sign in to comment.