-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Bluetooth: Controller: build assert if comand buffer is too small #19869
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -877,6 +877,46 @@ static uint8_t link_control_cmd_put(uint8_t const * const cmd) | |||||
} | ||||||
#endif | ||||||
|
||||||
#if defined(CONFIG_BT_HCI_ACL_FLOW_CONTROL) | ||||||
/* | ||||||
* The Host will generate up to acl_pkts number of Host Number of Completed Packets command plus a | ||||||
* number of normal HCI commands, as such we need to ensure the tx command buffer count is big | ||||||
* enough to not block incoming ACKs from the host. | ||||||
* | ||||||
* When Controller to Host data flow control is supported, ensure that BT_BUF_CMD_TX_COUNT is | ||||||
* greater than or equal to (BT_BUF_ACL_RX_COUNT + Ncmd), where Ncmd is the supported maximum | ||||||
* Num_HCI_Command_Packets. | ||||||
* | ||||||
* The SDC controller (currently) does not support Num_HCI_Command_Packets > 1, which means Ncmd | ||||||
* is always 1. | ||||||
*/ | ||||||
#if defined(CONFIG_BT_CONN) && defined(CONFIG_BT_HCI_HOST) | ||||||
BUILD_ASSERT(BT_BUF_ACL_RX_COUNT < CONFIG_BT_BUF_CMD_TX_COUNT, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When OTOH, when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I meant |
||||||
"Too low HCI command buffers compared to ACL Rx buffers, \ | ||||||
reduce CONFIG_BT_BUF_ACL_RX_COUNT_EXTRA or increase CONFIG_BT_BUF_CMD_TX_COUNT."); | ||||||
#else /* controller-only build */ | ||||||
BUILD_ASSERT(CONFIG_BT_BUF_CMD_TX_COUNT - 1 > 0, | ||||||
"We need at least two HCI command buffers to avoid deadlocks."); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Semantically, this wants |
||||||
#endif /* CONFIG_BT_CONN && CONFIG_BT_HCI_HOST */ | ||||||
|
||||||
/* Note: When host and controller are built separately, the RX Buffer Count communicated here from | ||||||
* the host might be exeeding the controller's TX command buffer count. This may result in the | ||||||
* controller sending up to host_total_num_acl_data_packets, it cannot receive the acknoledgements | ||||||
* via its TX command buffers for. | ||||||
* As we do not propagate the TX command buffer count information to the controller, the simplest | ||||||
* approach is to align the communicated host RX Buffer Count to it here. | ||||||
*/ | ||||||
static int sdc_hci_cmd_cb_host_buffer_size_wrapper(void *cmd_params) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does indeed form a guaranteed K_NO_WAIT allocation in HCI samples, with some added assumptions which need to be documented:
Consider if some of these assumptions should be turned into specification by adding them to the Zephyr HCI interface specification |
||||||
{ | ||||||
sdc_hci_cmd_cb_host_buffer_size_t ctrl_cmd_params = | ||||||
*(const sdc_hci_cmd_cb_host_buffer_size_t *)cmd_params; | ||||||
KyraLengfeld marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
ctrl_cmd_params.host_total_num_acl_data_packets = MIN( | ||||||
ctrl_cmd_params.host_total_num_acl_data_packets, (CONFIG_BT_BUF_CMD_TX_COUNT - 1)); | ||||||
|
||||||
return sdc_hci_cmd_cb_host_buffer_size((const void *)&ctrl_cmd_params); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
#endif /* CONFIG_BT_HCI_ACL_FLOW_CONTROL */ | ||||||
|
||||||
static uint8_t controller_and_baseband_cmd_put(uint8_t const * const cmd, | ||||||
uint8_t * const raw_event_out, | ||||||
uint8_t *param_length_out) | ||||||
|
@@ -903,7 +943,7 @@ static uint8_t controller_and_baseband_cmd_put(uint8_t const * const cmd, | |||||
case SDC_HCI_OPCODE_CMD_CB_SET_CONTROLLER_TO_HOST_FLOW_CONTROL: | ||||||
return sdc_hci_cmd_cb_set_controller_to_host_flow_control((void *)cmd_params); | ||||||
case SDC_HCI_OPCODE_CMD_CB_HOST_BUFFER_SIZE: | ||||||
return sdc_hci_cmd_cb_host_buffer_size((void *)cmd_params); | ||||||
return sdc_hci_cmd_cb_host_buffer_size_wrapper((void *)cmd_params); | ||||||
case SDC_HCI_OPCODE_CMD_CB_HOST_NUMBER_OF_COMPLETED_PACKETS: | ||||||
return sdc_hci_cmd_cb_host_number_of_completed_packets((void *)cmd_params); | ||||||
#endif | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be moved to the .conf files in
boards
and be set along with the rest of the BT options