-
Notifications
You must be signed in to change notification settings - Fork 7.4k
bluetooth: improve the controller address resolution enablement #90705
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
base: main
Are you sure you want to change the base?
bluetooth: improve the controller address resolution enablement #90705
Conversation
If the controller resolving list is cleared by HCI_LE_Clear_Resolving_List, don't need to enable the controller address resolution. Signed-off-by: Mark Wang <yichang.wang@nxp.com>
|
/* if fail to disable, it should already be enabled, | ||
* don't need to enable gain. | ||
*/ | ||
enable_controller_res = false; |
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.
Wouldn't this depend on what the HCI error code is?
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 any HCI error code mean the disabling "controller addr resolution" fail. so I think don't need to check the HCI error value. If you still think we need to check the HCI error code, could you help to explain more details? Thanks.
if (bt_dev.le.rl_entries == bt_dev.le.rl_size) { | ||
LOG_WRN("Resolving list size exceeded. Switching to host."); | ||
|
||
/* since the controller resolving list is cleared, | ||
* don't need to enable the Address Resolution. | ||
*/ | ||
enable_controller_res = false; |
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 wonder if the if
should be changed to bt_dev.le.rl_entries >= bt_dev.le.rl_size
.
e.g. if bt_dev.le.rl_size=2
and bt_dev.le.rl_entries=0
then
First call to bt_id_add
=> bt_dev.le.rl_entries=1
and Controller resolution is re-enabled
Second call to bt_id_add
=> bt_dev.le.rl_entries=2
and Controller resolution is disabled
Third call to bt_id_add
=> bt_dev.le.rl_entries=3
and Controller resolution is re-enabled
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.
In second call, the bt_dev.le.rl_entries
is 1 before the if
, the controller resolution is still enabled. After the call, bt_dev.le.rl_entries
is 2.
In third call, the bt_dev.le.rl_entries
is 2 before the if
, so if
is True
, then the address resolution is switched to host and controller resolution is disabled. After the call, bt_dev.le.rl_entries
is 3.
In fourth call, the bt_dev.le.rl_entries
is 3 at the begin of the function. there is the follow code at the begin of the function, so it will return directly.
/* Nothing to be done if host-side resolving is used */
if (!bt_dev.le.rl_size || bt_dev.le.rl_entries > bt_dev.le.rl_size) {
bt_dev.le.rl_entries++;
keys->state |= BT_KEYS_ID_ADDED;
return;
}
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.
Ah, missed that early return
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.
Pull Request Overview
This PR refines when the Bluetooth controller’s address resolution is re-enabled by introducing a flag to skip re-enabling if disabling failed or the resolving list was cleared.
- Add
enable_controller_res
flag initialized to true. - Set the flag to false on disable failure or after clearing the resolving list.
- Wrap the final
addr_res_enable(BT_HCI_ADDR_RES_ENABLE)
call in a conditional based on the flag.
Comments suppressed due to low confidence (2)
subsys/bluetooth/host/id.c:1014
- [nitpick] Consider renaming
enable_controller_res
toshould_enable_controller_res
orreenable_controller_res
for clearer intent.
bool enable_controller_res = true;
subsys/bluetooth/host/id.c:1085
- Add a test case to cover the scenario where the resolving list is cleared so that address resolution is not re-enabled.
enable_controller_res = false;
@@ -1067,13 +1068,21 @@ void bt_id_add(struct bt_keys *keys) | |||
err = addr_res_enable(BT_HCI_ADDR_RES_DISABLE); | |||
if (err) { | |||
LOG_WRN("Failed to disable address resolution"); | |||
/* if fail to disable, it should already be enabled, | |||
* don't need to enable gain. |
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.
The comment has a typo: 'enable gain' should be 'enable again'.
* don't need to enable gain. | |
* don't need to enable again. |
Copilot uses AI. Check for mistakes.
If the controller resolving list is cleared by HCI_LE_Clear_Resolving_List, don't need to enable the controller address resolution.
I think it is one improvement, please help to review.