From nobody Fri Jun 03 10:10:01 2022 X-Original-To: dev-commits-src-all@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 894CA1B674A7; Fri, 3 Jun 2022 10:10:01 +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 4LDzCF3QHNz4WNB; Fri, 3 Jun 2022 10:10:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1654251001; 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=w1lfjrJ+n3Yi1GolCvsvdicQM18UEQzII+2YUtl497o=; b=tqZNMkCAI8A1AvOQTIFnGmJ8h8EEcZCEs6lCaC3RSgn+yi+h5pfHCX5NFcM/QOumct67// nViOpRb79jF4ngih8G5avyT7Xes033yEOr3FGI/vjcSghkS5QyPSvuNjGqY+zdKD5q2Ua/ PKXirNhnxvStaBnLBDhmszR7Ch921g3mzoTC/T7nZb9vfbNqY/idZR+obsqAjg0gYUHmsB USr3yytnqsALlz2H+ZkFRvL51BDlOKrpE+AWZsMp6f29ltZBB8IyQayOOyGK2WuTgM/jcV lRMTUP3gBeOePNteOcptgeR0jxJkF8H7sh4Mrb2SWI6jW9EPg5jfV6yS5jmkug== 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 5506527124; Fri, 3 Jun 2022 10:10:01 +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 253AA1f9078945; Fri, 3 Jun 2022 10:10:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 253AA1xA078930; Fri, 3 Jun 2022 10:10:01 GMT (envelope-from git) Date: Fri, 3 Jun 2022 10:10:01 GMT Message-Id: <202206031010.253AA1xA078930@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: 9d28e15e7bbe - main - ng_ubt(4): Probe USB Bluetooth per USB interface and not per USB device. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/main X-Git-Reftype: branch X-Git-Commit: 9d28e15e7bbee7a809eb4ccab558d114d4343312 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1654251001; 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=w1lfjrJ+n3Yi1GolCvsvdicQM18UEQzII+2YUtl497o=; b=EvOxf4yCYNRK6j7w44brqoaCfDwbvPLaujqGZ2EEv197eDAH0xPwZLAaHBtoMgz7/50v0z 9YS6iQC9hOQSAcezevLh6JWtrSqhWm2SNstl0/cxNbmgPLtYuIRmNXdlwNc0YbzT/96LJl +5i9M4n1Gqj3DPGPns2C238JS7eqYNcWCeclUnK/Lb20aCl+Wbd4HQDEhcF8S9K7vbrE5l cnnd+nr9Df1ybtWomih2edCAuksvhvdR5GNGWjV6w+1mFI6hOI8BM0J6ihUCAR8ethPxhj L7pmb3RPgyzrlAfGd5IxRbqJf86lMlR/0nOGUKl24qkKfK2yUo672hmgkA4gKQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1654251001; a=rsa-sha256; cv=none; b=WDwI3axDFAiW+jWaPvlfRtYFgdiXcfBoFHobu5bEHuICiroGGV2YscJE/vjotJo7n8ew9z p+mCCtBKZn0nFsY/gVgN/jc6fJdwWJL8Z/W+I8hZhIfP7vSxvick1CgR2uV9MuhjH1CBQt Rrg4ix7mA7WyYOoyF9We79ICrOGmuIVLtXQ6RgmnD55V//QsN1gp0PYZ37WoYPEf7EukyA xn8p4k1H31aEkp9ENqc44Bw4X73QLJ2NdOv45AlFxj9JtFjpl2PIb0v0zlosFyh2sTEAYr UsOXRBhIS1LCjiJotKgw/GSri5KGbzLr1zzDouat6982pf8VqGgklaQWH4dwKg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=9d28e15e7bbee7a809eb4ccab558d114d4343312 commit 9d28e15e7bbee7a809eb4ccab558d114d4343312 Author: Hans Petter Selasky AuthorDate: 2022-06-03 08:22:54 +0000 Commit: Hans Petter Selasky CommitDate: 2022-06-03 08:49:17 +0000 ng_ubt(4): Probe USB Bluetooth per USB interface and not per USB device. PR: 264416 MFC after: 1 week Sponsored by: NVIDIA Networking --- 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 d1c2b3a83072..87cca84f7d7a 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: