Date: Fri, 19 Jul 2024 16:38:04 -0300 From: Joseph Mingrone <jrm@FreeBSD.org> To: hackers@FreeBSD.org Subject: USB4/TBT3 support Message-ID: <864j8lmaub.fsf@phe.ftfl.ca>
next in thread | raw e-mail | index | archive | help
--=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello, Is anyone working on USB4 / Thunderbolt 3 (TBT3) support? Scott Long did a lot of work on this a few years ago, but he had to move on to other things, so he passed things on to Hans Petter Selasky. Fortunately, Hans Petter dropped the code in a public repository. https://github.com/hselasky/usb4 https://github.com/hselasky/usb4/commit/dd85c216a2a6bee5361c7166595ba6ca461= 578b5 Here is an overview of what Scott shared with me. Mostly completed work: =2D Debug/Trace framework =2D NHI controller driver =2D PCIe bridge driver =2D WMI driver =2D Integrated Connection Manager handshake and authentication handling =2D Router and Config Space layer handling (in progress, almost complete) Remaining work: =2D tbtconfig (userland tool) =2D man pages =2D DMAR/IOMMU integration, PCIe tunnelling control =2D Support for resetting and firmware flashing on the NHI via out-of-band = control =2D Host Connection Manager =2D Cross-domain login =2D ThunderboltIP Here are the details that Scott shared. The driver originally targeted the Thunderbolt 3 controllers that were sold under the names =E2=80=9CAlpineRidge" and =E2=80=9CIcelake= =E2=80=9D, in the late 2010's, before the USB standards group publicly released the USB4 spec. The driver set I wrote was complete enough to activate Thunderbolt3 peripherals that otherwise would be disabled by default when plugged in. The driver also attempted to make it easier to identify things like PCIe tunnels in the topology, but that was mostly cosmetic. Unfortunately, the AlpineRidge chips proved to be extremely hard to work with despite their wide availability, and I spent way too much time fighting them and not enough time developing more useful functionality. The WMI driver was written to work around vexing problems with the Alpine Ridge controller that I never figured out. Much of the infrastructure from the TBT3 support extends to modern USB4 controllers, but there are still a lot of missing pieces. The NHI driver doesn't know how to probe a USB4 controller yet, but that should be easy to fix. Even more important, though, is that the code lacks a functional USB4 Connection Manager. Most of the pieces required to traverse the topology, discover routers and adapters, read and write their properties, and build routes between endpoints exists now, but there's no state machine yet that integrates those pieces together into a real Connection Manager. Without that, no attached peripherals will actually run. The TBT3 controllers like AlpineRidge and IceLake have a connection manager in firmware, so that's why those controllers function even with minimal host OS support. This isn't especially hard code to write, but it's missing nonetheless. Once the connection manager is written, it'll need to configure connections with the USB3, PCIe, and DisplayPort devices that operate over tunnels, and it'll need a cross domain handler for connecting to another host. USB3 tunnel support might require significant changes in the USB3 stack in order to work with USB4. Additionally you might need to write a USB-PD driver. Without it, negotiation on USB-C connectors for power delivery advertisements, cable orientation, alt mode configuration, and USB3 vs USB4 lane assignment might not work. If those negotiations are not handled then nothing that you plug into the port will even be seen by the controller. I'd totally stay away from spending time on supporting Falcon Ridge, Alpine Ridge, and Titan Ridge controllers. They're old, they're extremely difficult to work with, and they're not worth the headache. In fact, just ignore all TBT3 controllers, and remove the Internal Connection Manager code. The ICM module isn't code that I'm all that proud of anyways =3D-). Focus on writing an HCM, supporting PCIe and DP tunneling, and integrating IOMMU protections into both the NHI driver and the PCIe tunnel drivers. One thing that would be pretty awesome is ThunderboltIP support. It turns out that these controllers are really cheap 40Gbps devices, and have the potential to perform pretty well at line rate as a replacement for traditional 40Gb ethernet controllers, at least in a point-to-point configuration. In short, a lot of work has been done, but a lot of work remains to be done. The USB4 spec is complicated, and requires intimate knowledge of the USB-PD, USB-C, and USB3 specs. There's also a spec for writing a Host Connection Manager that you=E2=80=99ll need to get familiar = with. If anyone has already started or would like to continue Scott's work, could you please let me know? Joe --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQKkBAEBCgCOFiEEVbCTpybDiFVxIrrVNqQMg7DW754FAmaawJxfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDU1 QjA5M0E3MjZDMzg4NTU3MTIyQkFENTM2QTQwQzgzQjBENkVGOUUQHGpybUBmcmVl YnNkLm9yZwAKCRA2pAyDsNbvnh70EACih+efU1InLLmkeMkx20cGYgKM7IYB+EUm rmRABm9usV0iSPPlvXffr47Pb8z4A/Q5eesf/cGux5RhcThosJB7pU9Kzs2C1LFl eSm0R3IYtcii7S+/8EhheAladjHTNsOqqP0IXNiCbwYqS/qaUFKJ946jPX1Lqs8V gzEeENta6ZJJP8yFghnIXl3XH5BD48SvrR3GC3O4Cerb+yZXNtDEKrwGhHkoRsWe 7JnPfjnFL8JQh4Tcr67ZxW6QNQ1m8InFQFvzBt6zTFKD7IeUCX65JWN1ScL0Jmk9 Bfh7znXqHmsfSMdlAtvnbHKZDFtrJNYeWBVaxzSWlVVD5j/lgmq85Qy9pMfubMkG UxEPtmmgRSc26lZz7EjemYaysaIckydiKr6PSBKCpmPNO013U14DZsPy1m+/AZ5a SXEXecZ6NMDUnMvHwyb06Xcf/Z8xjpuBr1Uf4MTEd1oJHqbt3P3Ody7/EMmI2NNy 2r3XCqDrEEDqsqpbCFCR+/kMjjAQFroIzE1xbhWEdtFLxDl5sTKS6Almf22wVGd+ +KD+sfHPk4KrTbTfsws49vac28tSwwRTcfcwOfqZ3Lxu2fqfGzCwlHdIWLhKdxlx 6F4c89vz/Nb787ZXDvpxb38QqPUkWeOauyMwz52RsDKj4iLYZZbPjsRniS1oBYhE r1UBfHvH3A== =tIcj -----END PGP SIGNATURE----- --=-=-=--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?864j8lmaub.fsf>