From nobody Fri Jul 19 23:38:01 2024 X-Original-To: hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WQmM01bkBz5QbjY for ; Fri, 19 Jul 2024 23:38:04 +0000 (UTC) (envelope-from yonas.yanfa@gmail.com) Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "WR4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WQmLz6y0Gz4dKZ; Fri, 19 Jul 2024 23:38:03 +0000 (UTC) (envelope-from yonas.yanfa@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-qk1-x72b.google.com with SMTP id af79cd13be357-79ef8e0c294so140498985a.1; Fri, 19 Jul 2024 16:38:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721432283; x=1722037083; darn=freebsd.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=mAqxBIg/b5cjeOmoPwmgCFfwxbodKJ1lvAZ/gmoXRXM=; b=TO+kHKpTZSubhr+QvvjCKziygyUFCBaLzNsxxVHAsG0pumjJh5ih3WmDq0Na7teHbE 4mMjLOwQBFxe24cpjIEfQ9Px5g8CftA9SpS16vv7tYsdbnrAO0pMzFD85d9HM+aRlR1i Be1Kt9w1RIUK/a4iTXHd95UaNtoBZVxYzOSXcG9EITsCtur7AtBJxeswydMWKcMXy0kz f90T7lyCZVJOGHtP8ZF4d8OrOzhEOGbobwNbQEn31h/TFpMgpAGNiOJtLjiQZKrQ9arB VW2lNXOOA1B63ZiAtn4dRK2YqFebXxMl+500yj9Uvf7slIUdqw4U0vPhFzgapkoYY6F5 bmBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721432283; x=1722037083; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mAqxBIg/b5cjeOmoPwmgCFfwxbodKJ1lvAZ/gmoXRXM=; b=b9xzKR+mlTI/Ho8KwgMt0iJ/SNZCyjon6HLdAwU2hkLnok6dN/LX9/ts1UkZdvxqyk sbzswIUNgOW83LU43OCsi6nwZ1bh+gHJC5yRJK5rMk20FyerJ6pmQzsEeHriruYKG5OB +xD1SVkOZIK2zahpNzIlt2wvcoLGaxuL8qRuRRHLgW5VMRKCrEyRqiDwFMkQYDUBqLRG NMhNGCBCaL0WQxDe+b+udz4AfPGO6oSrry0YXDyHcoma+NBRPv7r0jWwENfgp29+22XW nEliGDnkenYtybmv6lBIQpEdnfCk8s6aIRw0HUB/at4lEsQj2ulD2HRgtN50SFSJe3FH S4pQ== X-Forwarded-Encrypted: i=1; AJvYcCVyLnXHOiTTtsmWwKjcOsno0LzDe+yneXTJB0c48Jjp9SVb2HiEu2oG5r6oMpwPY9vvpwU9PJvsngdoHNyTcgayHk6r X-Gm-Message-State: AOJu0YxmwcGiCF30ZkuTKFSrvwgRTmuu7LrVuQpRs9hB+wK2l6rJZcKP zz1dczbszkQG9ujGFm9ifFRMzV0mGstredouK16gU7WjB9Z+K2n66lFJcA== X-Google-Smtp-Source: AGHT+IEux2ikFnxKntsl5UMxaR/fEBvVcikEwpWN/qYxnh7sbh7/BvKZuIN22ivIMfXM03Pv0mNXyg== X-Received: by 2002:a05:620a:4415:b0:79e:f745:5445 with SMTP id af79cd13be357-7a1a1973c42mr237744485a.31.1721432282836; Fri, 19 Jul 2024 16:38:02 -0700 (PDT) Received: from [192.168.1.61] (pool-99-250-134-22.cpe.net.cable.rogers.com. [99.250.134.22]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a19900d413sm138370385a.70.2024.07.19.16.38.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 19 Jul 2024 16:38:02 -0700 (PDT) Message-ID: <028fd8a9-a7cf-4b55-b84c-a3baeb5a9270@gmail.com> Date: Fri, 19 Jul 2024 19:38:01 -0400 List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@FreeBSD.org MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: USB4/TBT3 support To: Joseph Mingrone , hackers@FreeBSD.org References: <864j8lmaub.fsf@phe.ftfl.ca> Content-Language: en-US From: Yonas Yanfa In-Reply-To: <864j8lmaub.fsf@phe.ftfl.ca> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; TAGGED_FROM(0.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US] X-Rspamd-Queue-Id: 4WQmLz6y0Gz4dKZ It would be nice to have Thunderbolt 4 support - and Thunderbolt 5 when it comes out - as well. The speeds are quite high. I imagine many people would love to have 40Gbps - 120Gbps / 80Gbps - 240Gbps on their laptop FreeBSD machine connected to their NAS. Perhaps the FreeBSD Foundation could help find sponsorship for this work. Cheers, Yonas On 2024-07-19 3:38 p.m., Joseph Mingrone wrote: > 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/dd85c216a2a6bee5361c7166595ba6ca461578b5 > > Here is an overview of what Scott shared with me. > > Mostly completed work: > > - Debug/Trace framework > - NHI controller driver > - PCIe bridge driver > - WMI driver > - Integrated Connection Manager handshake and authentication handling > - Router and Config Space layer handling (in progress, almost complete) > > Remaining work: > > - tbtconfig (userland tool) > - man pages > - DMAR/IOMMU integration, PCIe tunnelling control > - Support for resetting and firmware flashing on the NHI via out-of-band control > - Host Connection Manager > - Cross-domain login > - ThunderboltIP > > Here are the details that Scott shared. > > The driver originally targeted the Thunderbolt 3 controllers that > were sold under the names “AlpineRidge" and “Icelake”, 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 =-). 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’ll 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