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

Bluetooth: Host: Fix GATT Long Read for EATT #62782

Merged
merged 1 commit into from
Oct 23, 2023

Conversation

alwa-nordic
Copy link
Collaborator

@alwa-nordic alwa-nordic commented Sep 18, 2023

When EATT is established, the value returned from bt_att_get_mtu is not useful to determine the ATT_MTU that applies to an ATT response. This is because bt_att_get_mtu may return the value for a different bearer than the request is serviced on.

A second, related issue is that it's not correct to use the current ATT_MTU of a bearer as the ATT_MTU for a response. That's because it may have changed in-between sending the request and receiving the response. The ATT_MTU applicable for the response is the ATT_MTU of the request (as it was when it was sent).

To fix both of issues, the params struct for the GATT read operation is given a new field that will record the ATT_MTU that applies to this ATT operation. This value is then used to determine if the GATT long read operation is concluded.

The ATT_MTU is recorded from the correct ATT bearer at the moment the ATT request is put on the connection TX queue. Putting the request on the connection TX queue serves to sequence the ATT request TX with any MTU change RSP. This works both for sufficient for UATT, which sends the MTU exchange on the same L2CAP channels, and necessary for EATT, which sends the MTU exchange on the L2CAP control channels.

Fixes: #61741

For reference, Core 5.4 3 F 3.4.2.2 fig 3.1 follows. It illustrates how a bearer's ATT_MTU propagates to requests/responses.
image

@Thalley
Copy link
Collaborator

Thalley commented Sep 26, 2023

For additional verification of this, please also add CONFIG_BT_EATT=y to https://github.com/zephyrproject-rtos/zephyr/blob/main/tests/bsim/bluetooth/audio/prj.conf

@alwa-nordic alwa-nordic force-pushed the att-req-mtu branch 3 times, most recently from cb413f4 to 2a55931 Compare October 4, 2023 10:37
@alwa-nordic alwa-nordic force-pushed the att-req-mtu branch 4 times, most recently from 50a18d8 to 4e8089f Compare October 9, 2023 09:20
Copy link
Collaborator

@jori-nordic jori-nordic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

naking on the assert.
edit: else it's fine

@Thalley
Copy link
Collaborator

Thalley commented Oct 11, 2023

@alwa-nordic What is the reason why you didn't enable EATT in the LE Audio tests? Is it then failing on the write long (since this is only fixing read long)?

@alwa-nordic
Copy link
Collaborator Author

@alwa-nordic What is the reason why you didn't enable EATT in the LE Audio tests? Is it then failing on the write long (since this is only fixing read long)?

I need to get the tests to pass on CI without the LE audio EATT in the first place :). For some reason the test I added in this PR is hanging in CI even though it works perfectly for me locally.

I will try the LE Audio EATT for you after that works. But I don't have any high hopes on this being a silver bullet for whatever EATT problems that affect LE audio. This PR is indeed only affecting the long read API.

Is there maybe a discussion or list of EATT problems that have been observed with LE Audio?

@Thalley
Copy link
Collaborator

Thalley commented Oct 12, 2023

Is there maybe a discussion or list of EATT problems that have been observed with LE Audio?

No, but I can work towards creating additional issue after this gets merged, to see what might still be missing/causing issues. It's of course also not impossible that the the LE Audio stack needs to do more to properly use EATT

@alwa-nordic
Copy link
Collaborator Author

@Thalley I am aware of your feedback on #61170 that also applies here. Like you suggest, I would like to make a test code lib to remove the duplication. I also think that moment will be a good time to fix all the stylistic issues in the code that goes in that lib. I will create an issue on this.

jhedberg
jhedberg previously approved these changes Oct 12, 2023
Copy link
Collaborator

@Thalley Thalley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some generic comments, but may not need any change requests

include/zephyr/bluetooth/gatt.h Show resolved Hide resolved
tests/bsim/bluetooth/host/att/long_read/main.c Outdated Show resolved Hide resolved
tests/bsim/bluetooth/host/att/long_read/testlib/att_read.c Outdated Show resolved Hide resolved
tests/bsim/bluetooth/host/att/long_read/testlib/att_read.c Outdated Show resolved Hide resolved
@Thalley
Copy link
Collaborator

Thalley commented Oct 12, 2023

Didn't finish my review, but will continue tomorrow if this hasn't been merged by then :)

include/zephyr/bluetooth/gatt.h Show resolved Hide resolved
tests/bsim/bluetooth/host/att/long_read/main.c Outdated Show resolved Hide resolved
tests/bsim/bluetooth/host/att/long_read/main.c Outdated Show resolved Hide resolved
tests/bsim/bluetooth/host/att/long_read/main.c Outdated Show resolved Hide resolved
tests/bsim/bluetooth/host/att/long_read/testlib/att_read.c Outdated Show resolved Hide resolved
tests/bsim/bluetooth/host/att/long_read/testlib/bs_macro.h Outdated Show resolved Hide resolved
tests/bsim/bluetooth/host/att/long_read/testlib/bs_macro.h Outdated Show resolved Hide resolved
@Thalley
Copy link
Collaborator

Thalley commented Oct 13, 2023

@alwa-nordic While some of my comments have been related to code formatting, the fact is that the current coding guidelines are not granular enough to provide precise expectations, and none of those formatting comments are blockers for this PR :) So please do not spend too much time on them, and focus on the non-format comments instead

@zephyrproject-rtos zephyrproject-rtos deleted a comment from erbr-ot Oct 16, 2023
@zephyrproject-rtos zephyrproject-rtos deleted a comment from erbr-ot Oct 16, 2023
@zephyrproject-rtos zephyrproject-rtos deleted a comment from erbr-ot Oct 16, 2023
@alwa-nordic alwa-nordic dismissed stale reviews from jhedberg and jori-nordic via 1f26560 October 19, 2023 11:40
@alwa-nordic alwa-nordic force-pushed the att-req-mtu branch 2 times, most recently from 1f26560 to 3581a15 Compare October 19, 2023 12:02
Thalley
Thalley previously approved these changes Oct 19, 2023
Copy link
Collaborator

@Thalley Thalley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All blocking comments have been resolved

theob-pro
theob-pro previously approved these changes Oct 19, 2023
Copy link
Collaborator

@Thalley Thalley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor comments, otherwise LGTM

theob-pro
theob-pro previously approved these changes Oct 19, 2023
When EATT is established, the value returned from `bt_att_get_mtu` is
not useful to determine the ATT_MTU that applies to a ATT response. This
is because `bt_att_get_mtu` may return the value for a different bearer
than the request is serviced on.

To fix this, the params struct for the GATT read operation is given a
new field that will record the ATT_MTU that applies to this ATT
operation. This value is then used to determine if the GATT long read
operation is concluded.

Fixes: zephyrproject-rtos#61741

Signed-off-by: Aleksander Wasaznik <[email protected]>
@carlescufi carlescufi merged commit 9f42c92 into zephyrproject-rtos:main Oct 23, 2023
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EATT does not play well with MTU values
7 participants