From nobody Tue Jun 14 09:40:22 2022 X-Original-To: dev-commits-src-branches@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 3F24C846523; Tue, 14 Jun 2022 09:40:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LMk1z187Mz3JmC; Tue, 14 Jun 2022 09:40:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655199623; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8SDrMa+bwluxkf8X0iF9M/yT9M+r82UCiR5W+dHHt18=; b=qM4FnG94tdg2vsncU+4Nno+fqFE2a3qOxKf5kncY9y23Q+F3oBMDqE9E3RkT9RBsnm3BBw PmhsYW6EMxCO4vMg+qPi/D/8K8mDK4NjbCrf9uzr/XW6vnmYM8UpKgUqqdZ1dBen2dgyKp Z1XTfTaQ+BG8Fltg6rejDcMfcN2xxgegiAUrfZ+BHOGz7zQRfSwbkbmne8R9KqoD+Y6Ia5 jJle+8LvHA+1RPpK/q1QQM5rMtOuf6ZECTi1HyGtwwGgay1H8tBkRscEHtzEr+jhh3Y7ef PExMyoQ0XPrdMoPGRrA8AXtiLwfgiMnQm5lR9Si5/O0diMpYMTca1+F+TETfHg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 074E127AB9; Tue, 14 Jun 2022 09:40:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 25E9eMT3066676; Tue, 14 Jun 2022 09:40:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25E9eMkN066675; Tue, 14 Jun 2022 09:40:22 GMT (envelope-from git) Date: Tue, 14 Jun 2022 09:40:22 GMT Message-Id: <202206140940.25E9eMkN066675@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Hans Petter Selasky Subject: git: ac91cbc1f500 - stable/13 - ng_ubt(4): Probe USB Bluetooth per USB interface and not per USB device. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ac91cbc1f50078a9062243764c10a9b34fb39b59 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655199623; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8SDrMa+bwluxkf8X0iF9M/yT9M+r82UCiR5W+dHHt18=; b=fXqzG/qMLFzbdbNXDhrwiJXU9KkSfTbM99+b6GvKPeu+9NeJ+etLP6tUuFVqh8Y+zR2xjX I5l+y79s5FfdWpiEjimbAgLpmnGNsXmhgxDeDMgzQ2SgRfSCymGvopkwlysDPdOA0Odyd7 c/J7yEjwTpbwyorDQh+FmrDGNy3Pddw7ZLHCjrofC/xX6pwCMKuhEsLAeC86A2VnZKUvxs uUb9KecvA9wEzeijo+WsF8+uKEGG3xlmcsQBw6q1QsiBHt+Em9nceuwcsbtCuL2SNonK8Y W5rq9TWPKaVOIYHJE36pHp5UTAOghcQ+9ogYRubgfFNkQFAuJ/Ybqg4DPQ85Fw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655199623; a=rsa-sha256; cv=none; b=WXlzRWZsm7e059biFQ6ANJkBJ1g+itH+0jnj4SbpdRbYqRQGIkYcNF+1yZirDUL+5d6Dx1 0wDNm5+cbgfyrnrj+Bbh2m7+ZntIA4I3XWU0zHKXP1MyUfoqdz9O16+slA+Rm20gRpobpA PMxaTKk9hZt3YqcJHZfjkwPi5Rb/QOCEjI5xONzOegtBSswIbGKHUz74xxeCn0VvWceyZN LR6WJ6JTCsDp0FnQxndzTrhCV4pPeJLJLQIOMxGVTuSZzNN+XhVGRVV9YNlKYpGOMn+Jd7 cvpltfgt7jIPOicBCjj8+Eg+K1JuswQtfoh10DWV0dJN5Kp/AwRduGZfXX66gw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=ac91cbc1f50078a9062243764c10a9b34fb39b59 commit ac91cbc1f50078a9062243764c10a9b34fb39b59 Author: Hans Petter Selasky AuthorDate: 2022-06-03 08:22:54 +0000 Commit: Hans Petter Selasky CommitDate: 2022-06-14 09:39:23 +0000 ng_ubt(4): Probe USB Bluetooth per USB interface and not per USB device. PR: 264416 Sponsored by: NVIDIA Networking (cherry picked from commit 9d28e15e7bbee7a809eb4ccab558d114d4343312) --- sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c | 67 +++++++++++++++++------------ 1 file changed, 40 insertions(+), 27 deletions(-) diff --git a/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c b/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c index dee829336331..9250af43566e 100644 --- a/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c +++ b/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c @@ -607,22 +607,31 @@ static int ubt_probe(device_t dev) { struct usb_attach_arg *uaa = device_get_ivars(dev); - int error; + const struct usb_device_id *id; if (uaa->usb_mode != USB_MODE_HOST) return (ENXIO); - if (uaa->info.bIfaceIndex != 0) - return (ENXIO); - if (usbd_lookup_id_by_uaa(ubt_ignore_devs, sizeof(ubt_ignore_devs), uaa) == 0) return (ENXIO); - error = usbd_lookup_id_by_uaa(ubt_devs, sizeof(ubt_devs), uaa); - if (error == 0) + id = usbd_lookup_id_by_info(ubt_devs, + sizeof(ubt_devs), &uaa->info); + if (id == NULL) + return (ENXIO); + + if (uaa->info.bIfaceIndex != 0) { + /* make sure we are matching the interface */ + if (id->match_flag_int_class && + id->match_flag_int_subclass && + id->match_flag_int_protocol) + return (BUS_PROBE_GENERIC); + else + return (ENXIO); + } else { return (BUS_PROBE_GENERIC); - return (error); + } } /* ubt_probe */ /* @@ -637,16 +646,32 @@ ubt_attach(device_t dev) struct ubt_softc *sc = device_get_softc(dev); struct usb_endpoint_descriptor *ed; struct usb_interface_descriptor *id; - struct usb_interface *iface; + struct usb_interface *iface[2]; uint32_t wMaxPacketSize; uint8_t alt_index, i, j; - uint8_t iface_index[2] = { 0, 1 }; + uint8_t iface_index[2]; device_set_usb_desc(dev); + iface_index[0] = uaa->info.bIfaceIndex; + iface_index[1] = uaa->info.bIfaceIndex + 1; + + iface[0] = usbd_get_iface(uaa->device, iface_index[0]); + iface[1] = usbd_get_iface(uaa->device, iface_index[1]); + sc->sc_dev = dev; sc->sc_debug = NG_UBT_WARN_LEVEL; + /* + * Sanity checks. + */ + + if (iface[0] == NULL || iface[1] == NULL || + iface[0]->idesc == NULL || iface[1]->idesc == NULL) { + UBT_ALERT(sc, "could not get two interfaces\n"); + return (ENXIO); + } + /* * Create Netgraph node */ @@ -720,13 +745,13 @@ ubt_attach(device_t dev) if ((ed->bDescriptorType == UDESC_INTERFACE) && (ed->bLength >= sizeof(*id))) { id = (struct usb_interface_descriptor *)ed; - i = id->bInterfaceNumber; + i = (id->bInterfaceNumber == iface[1]->idesc->bInterfaceNumber); j = id->bAlternateSetting; } if ((ed->bDescriptorType == UDESC_ENDPOINT) && (ed->bLength >= sizeof(*ed)) && - (i == 1)) { + (i != 0)) { uint32_t temp; temp = usbd_get_max_frame_length( @@ -740,7 +765,7 @@ ubt_attach(device_t dev) /* Set alt configuration on interface #1 only if we found it */ if (wMaxPacketSize > 0 && - usbd_set_alt_interface_index(uaa->device, 1, alt_index)) { + usbd_set_alt_interface_index(uaa->device, iface_index[1], alt_index)) { UBT_ALERT(sc, "could not set alternate setting %d " \ "for interface 1!\n", alt_index); goto detach; @@ -754,21 +779,9 @@ ubt_attach(device_t dev) goto detach; } - /* Claim all interfaces belonging to the Bluetooth part */ - for (i = 1;; i++) { - iface = usbd_get_iface(uaa->device, i); - if (iface == NULL) - break; - id = usbd_get_interface_descriptor(iface); - - if ((id != NULL) && - (id->bInterfaceClass == UICLASS_WIRELESS) && - (id->bInterfaceSubClass == UISUBCLASS_RF) && - (id->bInterfaceProtocol == UIPROTO_BLUETOOTH)) { - usbd_set_parent_iface(uaa->device, i, - uaa->info.bIfaceIndex); - } - } + /* Claim second interface belonging to the Bluetooth part */ + usbd_set_parent_iface(uaa->device, iface_index[1], uaa->info.bIfaceIndex); + return (0); /* success */ detach: