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: ISO: Add additional information for ISO streams #45077

Merged
merged 1 commit into from
Apr 26, 2022

Conversation

Thalley
Copy link
Collaborator

@Thalley Thalley commented Apr 22, 2022

Add all information from the ISO established events
and provide the information in the get_info function.

The use cases of each field heavily depends on what
the ISO streams are used for.

Most, if not all, of the field can be used by the
higher layers to improve quality and/or reliability
of e.g. audio streams that use ISO.

Signed-off-by: Emil Gydesen [email protected]

fixes #44546

@github-actions github-actions bot added area: API Changes to public APIs area: Bluetooth area: Bluetooth Host Bluetooth Host (excluding BR/EDR) labels Apr 22, 2022
Comment on lines 631 to 638
/** The transport PHY */
uint8_t phy;

/** The burst number */
uint8_t bn;

/** The maximum PDU size in octets */
uint16_t max_pdu;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

PHY and PDU size is already stored as part of the struct bt_iso_chan_io_qos struct. Should we omit them from these structs?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I like that you get all the values from the established event in the same structure, hence I prefer this implementation. But do agree that it could be confusing that you have the value two places.

uint16_t interval;
};

struct bt_iso_sync_receiver_info {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the same as bt_iso_broadcaster_info just without the sync_delay. Should we use the same struct for both, and then just document that sync_delay is for the broadcaster only?

Copy link
Collaborator

Choose a reason for hiding this comment

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

From an application data path point of view there is no difference between a broadcast and a unicast. Perhaps it would make sense to have the data common between unicast and broadcast in one structure (BN, PHY, max_pdu, number_of_subevents and interval) to have a generic data path handler - but there is also value in having simple structures with only valid members. Even if the documentation mentions a value is only valid in some cases a developer might miss that - especially during maintenance where you only modify the code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The difference between unicast and broadcast is taht unicast may have 2 pairs of latency, flush timeout, etc. as it can be bidirectional.

Comment on lines 628 to 629
/** The flush timeout in ms */
uint32_t flush_timeout;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The flush timeout is typically given as a value in units of iso_interval, but thought it made more sense to provide the value as a unit of MS by doing iso_interval * flush_timeout

Copy link
Collaborator

Choose a reason for hiding this comment

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

If we supply the value in time, I don't think ms is sufficient unless it is a float. 7.5ms is a standard iso-interval and that cannot be expressed in units of ms - except for even FT :-)
Unit could be micro seconds.

Copy link
Collaborator Author

@Thalley Thalley Apr 25, 2022

Choose a reason for hiding this comment

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

The units from the event is 1.25ms. Using microseconds would unfortunately require a 64-bit value to hold this value (max FT * max iso_interval > 2^32-1).

Change to use unit of 1.25ms (we do that for many other interval issues).

Comment on lines 715 to 716
/** The ISO interval in ms */
uint16_t interval;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Values such as PHY, BN and interval are common between the 3 structs. Should we move them out of these and store them directly in struct bt_iso_info?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I like that - then you always have the values available where you need them (in the data path) and don't need for each application to implement it's own mapping from connection instance to connection parameters.
But again the unit of interval shall support x.25ms and x.5ms hence perhaps use micro seconds?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I move the NSE and interval to the outer struct, but the remaining fields are not easily moved. While all have e.g. max_pdu, the unicast struct have 2 values for that (given that it can be bidirectional).

The unicast and broadcast data path values (PDU, bn, latency, etc.) are also not the same, as e.g. broadcast has PTO and unicast has flush timeout

@Thalley Thalley force-pushed the iso_additional_info branch from e432a41 to 88179cd Compare April 22, 2022 16:27
@Thalley Thalley marked this pull request as ready for review April 22, 2022 18:12
Comment on lines 883 to 886
central->phy = evt->c_phy;
central->latency = sys_get_le16(evt->c_latency);
Copy link
Collaborator

@Casper-Bonde-Bose Casper-Bonde-Bose Apr 25, 2022

Choose a reason for hiding this comment

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

I think PHY is relevant even if c_max_pdu is 0. For example the phy in use is relevant to know when evaluating the link budget - you might need to increase TX power if a 2 mbit link is used for ACK/NACK, which might not be needed for a 1mbit link.
I expect a typical unidirectional stream will use 2mbit for upstream (audio data) whereas downstream (ack's) should be 1mbit to have robust acks/nack transfers.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right. I'll just leave the values as they come from the event then :)

info->irc = evt->irc;
info->interval = sys_le16_to_cpu(evt->iso_interval);
/* Transform to ms */
info->pto = info->interval * evt->pto;
Copy link
Collaborator

Choose a reason for hiding this comment

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

for intervals of x.25, x.5 and x.75ms this calculation multiplies the error if the unit of evt->iso_interval is ms - but I think the unit of that is slot-pairs (1.25ms). hence you need to multiply by 1.25ms to get ms. Maybe micro seconds is a better unit to use?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

info->irc = evt->irc;
info->interval = sys_le16_to_cpu(evt->iso_interval);
/* Transform to ms */
info->pto = info->interval * evt->pto;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above - need to multiply by 1.25.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

@Casper-Bonde-Bose Casper-Bonde-Bose left a comment

Choose a reason for hiding this comment

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

Ups, left my comments as independent comments rather than review comments - sorry.
Unit needs to be fixed - remaining is up to you.

@Thalley Thalley force-pushed the iso_additional_info branch 3 times, most recently from 4357773 to 6b94e29 Compare April 25, 2022 12:40
@Thalley Thalley force-pushed the iso_additional_info branch from 6b94e29 to 0044688 Compare April 25, 2022 14:34
Copy link
Collaborator

@Casper-Bonde-Bose Casper-Bonde-Bose left a comment

Choose a reason for hiding this comment

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

Great work Emil!

Copy link
Contributor

@cvinayak cvinayak left a comment

Choose a reason for hiding this comment

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

Minor nitpick otherwise LGTM.

unicast_info->cig_sync_delay = sys_get_le24(evt->cig_sync_delay);
unicast_info->cis_sync_delay = sys_get_le24(evt->cis_sync_delay);


Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

Add all information from the ISO established events
and provide the information in the get_info function.

The use cases of each field heavily depends on what
the ISO streams are used for.

Most, if not all, of the field can be used by the
higher layers to improve quality and/or reliability
of e.g. audio streams that use ISO.

Signed-off-by: Emil Gydesen <[email protected]>
@carlescufi carlescufi merged commit c972ffd into zephyrproject-rtos:main Apr 26, 2022
@Thalley Thalley deleted the iso_additional_info branch July 8, 2022 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: API Changes to public APIs area: Bluetooth Host Bluetooth Host (excluding BR/EDR) area: Bluetooth
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bluetooth: ISO: Provide stream established information
4 participants