From nobody Wed Nov 6 23:31:51 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 4XkM136y7Bz5c0WV; Wed, 06 Nov 2024 23:31:51 +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 4XkM1361lkz4LqR; Wed, 6 Nov 2024 23:31:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730935911; 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=KPrzk5K1tYzUWoHFEtVd0bhzZAvIaLZmA8K5r4VzNjc=; b=hJfvq0DoEJMFxxC/ycOhhcZL5Bony6NZH+e09jdU2cfV3IGVaxUt8NQK3w1e22iX+6W90Q lmzyAk1MCy8czeWqCa459Zq/K6HLeL5Jp2XtidSImaiSFpeOmHvXJ6VcZvYCEhSOh/HRg9 LBYMLZuFCCi7rKeVcw+mW19ERuaNF3Ebry1YAAS1Hc3wTUhFXR2G7PQlBBt+voJMvhGHM1 Wnxi9oJc6qLp/nBqrYaUZpCuc3ScML1f4Pb3BHitFYmDeb2ichNu8GuBqULfk0Too438WJ Im4GkGtVsuU/qE9fDM0kf2AVpBxKhvRH5HhI8k92WoZ24sgo+pIr8aCRCrdkjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730935911; 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=KPrzk5K1tYzUWoHFEtVd0bhzZAvIaLZmA8K5r4VzNjc=; b=L9LptVC3YKYWwHxF+ZjRQHki0inajwmFUpPuATfmR+XMo/B71yhqlLF/um1AV6o/3CYCIC QSHMrnk55vjRc1VkMHxXyBQUe/dEBSb5vbou5CLVlq7ewLqV0b/O4T3vRORU6PLGSiQs95 x90L4K/B82J9hMJCOICiRqpwtxldNk7a/zdEg3VoMLf1a7TDm2Ycm7pYNZfqBAHbdgiBX0 2SELPWzBrEZ3yC2XgvEmm2EK1dux5B5m185ucZyG6DhZQ1KaI19/sFBSXxVYf6lxVCBAKO tG7HdUXB9kwZL3oselZVRh/rQJmvA7Bb+frWfkUJkN5TGZW7hdlJa2kWADKl3Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730935911; a=rsa-sha256; cv=none; b=tBy/M573eNg751d547ZZI5qCK1NA0fRmWkA9R1LklivZWa7M0/HO2ZPli3ynthgXn76erO pWXDiXCpr+rfGzdLoLMv/3KKtaOH0EEsXABeF+K2xVeYydyZYzvJvkqOOw7GU+jE0oswk9 o2LTrfD5E8r+BsyL/Z79n0kRUaJ2u1z2dR1S8bttZ9hb0OIwOfW3+L37GlWyA0SbxFTYoF Mrm7nUU624jYkN6aV1rY483ksfyPqylHp8lhaedcItL1qvuhPdIphOhBnf/tQ6zc79OnPo TTHOl7vihD2REhOvQyV/rlGSnHDgU75DVlWKlpnr2q990jHh9LBCXcuiTpQzvQ== 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 4XkM135K9jzLn7; Wed, 6 Nov 2024 23:31:51 +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 4A6NVpYd069814; Wed, 6 Nov 2024 23:31:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4A6NVptU069811; Wed, 6 Nov 2024 23:31:51 GMT (envelope-from git) Date: Wed, 6 Nov 2024 23:31:51 GMT Message-Id: <202411062331.4A6NVptU069811@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: 19a577ea5cae - main - 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/main X-Git-Reftype: branch X-Git-Commit: 19a577ea5cae1238065106de9080cb6f3e66034d Auto-Submitted: auto-generated The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=19a577ea5cae1238065106de9080cb6f3e66034d commit 19a577ea5cae1238065106de9080cb6f3e66034d Author: Vladimir Kondratyev AuthorDate: 2024-11-06 23:25:56 +0000 Commit: Vladimir Kondratyev CommitDate: 2024-11-06 23:25:56 +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 --- 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")); }