From nobody Sun Dec 22 03:37:54 2024 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 4YG6LD48zkz5hwlD; Sun, 22 Dec 2024 03:37:56 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YG6LC0Qt0z4DQw; Sun, 22 Dec 2024 03:37:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734838675; 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=lMnUWiVbemMOUHHcx2ZZyXHO8e6qTwoS9goeihdDOFA=; b=A0Y3atABiOy2MBIf9K5pfEx/Zwz/S3YAxZF3XTwef6FznIujthH84vJlZi8TpVneg83suZ f3ffb8eTh+9OxceluPxhAc+B7s97o+jZaMK4TN7ylrG9ITlA0gU1TTNfjG2wrdwhlhTLn0 mhLtU3EsmZXZSZadX+ZvogqNC9np9tNQW4Zv1LmDadGnhLUXmlG8mYB8EoKTc3MNMWIz9h Ckdl937LlC7TmZOQl0Ohi+wxS7HER+rL93KmVZCyitWQoEUqliWlS4QAjYkdd05VXgGU92 7fPrkfoJAoTUMIrIQumRMsg8DX6MJwbRHMD6krkv+P7tLC8RRlH4GoFvGG7P8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734838675; 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=lMnUWiVbemMOUHHcx2ZZyXHO8e6qTwoS9goeihdDOFA=; b=jt/CZf4H7J/owgBJfC3MQbiXRzp2MeeTVnDZWXSxGcsJDutYD/e3Ukr0SVy+0neXab9SEA V4oMDyM0jBEyaZpyqc3Y8oeck3LfBfZ22ClIcSMbtuv6jJ5G9LimWmlXg9hUJa/F12xPdV 2iQ4psVH3E2Wu4bhzf8L+aaprxPV+8RXxgHCDXHEswnuZ790ktZYr92iLWZQf3j2aip169 NyS8wEgEvy2tBAEyK0e2m/+n548WBCcGiJSjagw4Sc3znatLrEk9+4uxmBoivjN2BhXEGE EAgoluB0eGSXy2RYhysy1WF39kWkpSX9FStdyMUIzhKeR5QefKfJWBBXPs+h4Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1734838675; a=rsa-sha256; cv=none; b=D89M8ZiYj0GwSeJGLQpMmPskNWZ7Pi1fmp+xTcn8Y9ArQ/8q4TSqtKbqLp+rRaZUPmpBYQ vJHPorAy+OJ/jxP3OVDJlBemZdfcNDNcFQ68edRQMTvySJFBttWAiRxjOJfNNcNyO8Vz0i Xg48ZD10e903uWsLBY4ivFAtDwXiF/KsnfF7BRGZ+0WiGg3XmHteRybILU+Bu3kB0y7iQW G0XTLp91EXQclydSXgIHBl1ZemFZe9LX4/KYFkGy7MZ9fmvTwNBZUzZxbCqGCCD73+nVYP Tl+n9Xwq90tBUD/xPtPCITKJOvQ71EVfBbYLp48JYP2YhB7KceiwZLZugR31QA== 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 4YG6LB65b8zrtZ; Sun, 22 Dec 2024 03:37:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4BM3bsYb053211; Sun, 22 Dec 2024 03:37:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4BM3bs0A053208; Sun, 22 Dec 2024 03:37:54 GMT (envelope-from git) Date: Sun, 22 Dec 2024 03:37:54 GMT Message-Id: <202412220337.4BM3bs0A053208@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 5ce844d3daa2 - stable/14 - ng_ubt_intel: Allow to attach to 9260 bluetooth adaptors 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 5ce844d3daa29ba0358e455d3723226d127a28af Auto-Submitted: auto-generated The branch stable/14 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=5ce844d3daa29ba0358e455d3723226d127a28af commit 5ce844d3daa29ba0358e455d3723226d127a28af Author: Vladimir Kondratyev AuthorDate: 2024-11-06 23:25:56 +0000 Commit: Vladimir Kondratyev CommitDate: 2024-12-22 03:34:24 +0000 ng_ubt_intel: Allow to attach to 9260 bluetooth adaptors with operational mode firmware. Sponsored by: Future Crew LLC MFC after: 1 month Reviewed by: bz Differential Revision: https://reviews.freebsd.org/D46734 (cherry picked from commit 19a577ea5cae1238065106de9080cb6f3e66034d) --- sys/netgraph/bluetooth/drivers/ubt/ng_ubt_intel.c | 69 ++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/sys/netgraph/bluetooth/drivers/ubt/ng_ubt_intel.c b/sys/netgraph/bluetooth/drivers/ubt/ng_ubt_intel.c index ad71cae5fa83..f93b74b264ad 100644 --- a/sys/netgraph/bluetooth/drivers/ubt/ng_ubt_intel.c +++ b/sys/netgraph/bluetooth/drivers/ubt/ng_ubt_intel.c @@ -6,6 +6,7 @@ * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2019, 2021 Vladimir Kondratyev + * Copyright (c) 2023 Future Crew LLC. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -56,9 +57,13 @@ #include #include +#define UBT_INTEL_HCICMD_TIMEOUT 2000 /* ms */ +#define UBT_INTEL_TLV_IMAGE_TYPE 0x1c + enum { UBT_INTEL_DEVICE_7260, UBT_INTEL_DEVICE_8260, + UBT_INTEL_DEVICE_9260, }; struct ubt_intel_version_rp { @@ -93,6 +98,9 @@ static const STRUCT_USB_HOST_ID ubt_intel_devs[] = { USB_VPI(USB_VENDOR_INTEL2, 0x0025, UBT_INTEL_DEVICE_8260) }, { USB_VPI(USB_VENDOR_INTEL2, 0x0026, UBT_INTEL_DEVICE_8260) }, { USB_VPI(USB_VENDOR_INTEL2, 0x0029, UBT_INTEL_DEVICE_8260) }, + /* Intel Wireless 9260/9560 and successors */ + { USB_VPI(USB_VENDOR_INTEL2, 0x0032, UBT_INTEL_DEVICE_9260) }, + { USB_VPI(USB_VENDOR_INTEL2, 0x0033, UBT_INTEL_DEVICE_9260) }, }; /* @@ -103,7 +111,6 @@ static usb_error_t ubt_intel_do_hci_request(struct usb_device *udev, uint16_t opcode, void *resp, uint8_t resp_len) { -#define UBT_INTEL_HCICMD_TIMEOUT 2000 /* ms */ struct ubt_hci_event_command_compl *evt; struct ubt_hci_cmd cmd; usb_error_t error; @@ -128,6 +135,53 @@ exit: return (error); } +static uint8_t +ubt_intel_get_img_type(struct usb_device *udev) +{ +#define UBT_INTEL_MAX_EVT_SIZE 256 + static struct ubt_hci_cmd cmd = { + .opcode = htole16(NG_HCI_OPCODE(NG_HCI_OGF_VENDOR, 0x05)), + .length = 1, + .data = { 0xff }, + }; + struct ubt_hci_event_command_compl *evt; + usb_error_t error; + uint8_t status, datalen, type, len, img_type = 0; + uint8_t *data; + + evt = malloc(UBT_INTEL_MAX_EVT_SIZE, M_TEMP, M_ZERO | M_WAITOK); + evt->header.length = + UBT_INTEL_MAX_EVT_SIZE - sizeof(struct ubt_hci_evhdr); + + error = ubt_do_hci_request(udev, &cmd, evt, UBT_INTEL_HCICMD_TIMEOUT); + if (error != USB_ERR_NORMAL_COMPLETION) + goto exit; + + datalen = evt->header.length - UBT_HCI_EVENT_COMPL_HEAD_SIZE; + data = evt->data; + status = *data++; + if (status != 0) + goto exit; + datalen--; + + while (datalen >= 2) { + type = *data++; + len = *data++; + datalen -= 2; + if (datalen < len) + break; + if (type == UBT_INTEL_TLV_IMAGE_TYPE && len == 1) { + img_type = *data; + break; + } + datalen -= len; + data += len; + } +exit: + free(evt, M_TEMP); + return (img_type); +} + /* * Probe for a Intel Wireless Bluetooth device. */ @@ -139,6 +193,7 @@ ubt_intel_probe(device_t dev) struct ubt_intel_version_rp version; ng_hci_reset_rp reset; int error; + uint8_t img_type; if (uaa->usb_mode != USB_MODE_HOST) return (ENXIO); @@ -193,6 +248,18 @@ ubt_intel_probe(device_t dev) return (ENXIO); break; + case UBT_INTEL_DEVICE_9260: + /* + * Find if the Intel Wireless 9260/9560 device is in bootloader + * mode or is running operational firmware with checking of + * image type byte of "Intel version" HCI command response. + * The value 0x03 identifies the operational firmware. + */ + img_type = ubt_intel_get_img_type(uaa->device); + if (img_type != 0x03) + return (ENXIO); + break; + default: KASSERT(0 == 1, ("Unknown DRIVER_INFO")); }