Skip to content

Conversation

@jfischer-no
Copy link
Contributor

Add Bluetooth HCI USB transport layer implementation for the new USB device support,
porting of subsys/usb/device/class/bluetooth.c without H4 bloat.

jhedberg
jhedberg previously approved these changes Jan 17, 2023
Copy link
Member

@jhedberg jhedberg left a comment

Choose a reason for hiding this comment

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

Looks pretty good

Comment on lines +457 to +589
Copy link
Member

Choose a reason for hiding this comment

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

I think this relates to #51503 too. Along with making the HCI driver DTS-based, it becomes more natural to declare multiple instances. That said, the host stack treats the controller as singleton. There's a single bt_dev struct that's accessed as a global variable in several places of the host. To make the host truly multi-HCI aware there would need to be this bt_dev context per controller instance that's then passed around as a parameter in most existing Bluetooth APIs.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jhedberg @jfischer-no does anything need to be done here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I understood @carlescufi, not in the near future.

Copy link
Contributor

@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.

Mostly code style comments, and some questions

Copy link
Contributor

Choose a reason for hiding this comment

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

Why these specific numbers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Three endpoints, maximum three transfers used synchronously, 512 is the maximum packet size of a high speed bulk endpoint. I will add a comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

If 512 is a maximum defined by the USB specification, then I'd suggest to #define that value and use that

Copy link

Choose a reason for hiding this comment

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

BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 4, Part B page 1667 suggests 16 bytes Max Packet Size as the default.

Copy link
Contributor

Choose a reason for hiding this comment

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

When the intention is to clear a struct like here, it may be more readable to use the pointer to the struct for the sizeof

Suggested change
memset(bi, 0, sizeof(struct udc_buf_info));
memset(bi, 0, sizeof(*bi));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No it is not more readable.

Comment on lines +251 to +292
Copy link
Contributor

Choose a reason for hiding this comment

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

Given that this driver otherwise doesn't support ISO, should this be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe, but then it must later be added for H4 support.

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems odd to only partially add ISO/H4 support

Zero data payload size for isochronous endpoints is a
is a valid setting for default interface.
Also do not update MPS of control endpoint since it is
set by the driver.

Signed-off-by: Johann Fischer <[email protected]>
@jfischer-no
Copy link
Contributor Author

Cherry-picked first commit from #53998 and added interface descriptor for ISO endpoints (still unused).

desowin
desowin previously approved these changes Jan 25, 2023
Add Bluetooth HCI USB transport layer implementation for the new
experimental USB device support based on the existing implementation
subsys/usb/device/class/bluetooth.c.

This implementation, unlike existing one, contains the interface
descriptors for isochronous endpoints. Since we do not support voice
channels, these are just there to avoid issues with Linux kernel btusb
driver when this implementation is part of a composite configuration.

Signed-off-by: Johann Fischer <[email protected]>
Enable Bluetooth HCI USB tranport layer from new experimental
USB device support.

Signed-off-by: Johann Fischer <[email protected]>
Copy link
Contributor

@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 minor suggestions left, otherwise LGTM

Copy link
Contributor

Choose a reason for hiding this comment

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

Minor:

Suggested change
struct usbd_bt_hci_desc *desc = c_nd->data->desc;
const struct usbd_bt_hci_desc *desc = c_nd->data->desc;

Copy link
Contributor

Choose a reason for hiding this comment

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

Minor:

Suggested change
struct usbd_bt_hci_desc *desc = c_nd->data->desc;
const struct usbd_bt_hci_desc *desc = c_nd->data->desc;

Copy link
Contributor

Choose a reason for hiding this comment

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

Minor:

Suggested change
struct usbd_bt_hci_desc *desc = c_nd->data->desc;
const struct usbd_bt_hci_desc *desc = c_nd->data->desc;

Comment on lines +457 to +589
Copy link
Contributor

Choose a reason for hiding this comment

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

@jhedberg @jfischer-no does anything need to be done here?

@jfischer-no jfischer-no added this to the v3.3.0 milestone Jan 25, 2023
@stephanosio stephanosio merged commit cad8ae7 into zephyrproject-rtos:main Jan 26, 2023
@jfischer-no jfischer-no deleted the pr-device-next-bt branch January 26, 2023 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Bluetooth area: USB Universal Serial Bus Experimental Experimental features not enabled by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants