Skip to contentSkip to conversation

Bluetooth: btusb: Move btusb_recv_event_intel to btintel

PATCH Applied Luiz Augusto von Dentz 3 participants 3 messages Jul 20, 2023 – Aug 2, 2023 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/1 Bluetooth: btusb: Move btusb_recv_event_intel to btintel

From: Luiz Augusto von Dentz <[email protected]>

btusb_recv_event_intel is specific to Intel controllers therefore it shall be placed inside btintel.c so btusb don't have a mix of vendor specific code with the generic parts.

---
 drivers/bluetooth/btintel.c | 74 ++++++++++++++++++++++++++++++++++++
 drivers/bluetooth/btintel.h |  1 +
 drivers/bluetooth/btusb.c   | 75 +------------------------------------
 3 files changed, 76 insertions(+), 74 deletions(-)
drivers/bluetooth/btintel.c +74 -0
index b32277cb045d..633e8d9bf58f 100644
@@ -2948,6 +2948,80 @@ int btintel_configure_setup(struct hci_dev *hdev, const char *driver_name)
 }
 EXPORT_SYMBOL_GPL(btintel_configure_setup);
 
+static int btintel_diagnostics(struct hci_dev *hdev, struct sk_buff *skb)
+{
+	struct intel_tlv *tlv = (void *)&skb->data[5];
+
+	/* The first event is always an event type TLV */
+	if (tlv->type != INTEL_TLV_TYPE_ID)
+		goto recv_frame;
+
+	switch (tlv->val[0]) {
+	case INTEL_TLV_SYSTEM_EXCEPTION:
+	case INTEL_TLV_FATAL_EXCEPTION:
+	case INTEL_TLV_DEBUG_EXCEPTION:
+	case INTEL_TLV_TEST_EXCEPTION:
+		/* Generate devcoredump from exception */
+		if (!hci_devcd_init(hdev, skb->len)) {
+			hci_devcd_append(hdev, skb);
+			hci_devcd_complete(hdev);
+		} else {
+			bt_dev_err(hdev, "Failed to generate devcoredump");
+			kfree_skb(skb);
+		}
+		return 0;
+	default:
+		bt_dev_err(hdev, "Invalid exception type %02X", tlv->val[0]);
+	}
+
+recv_frame:
+	return hci_recv_frame(hdev, skb);
+}
+
+int btintel_recv_event(struct hci_dev *hdev, struct sk_buff *skb)
+{
+	struct hci_event_hdr *hdr = (void *)skb->data;
+	const char diagnostics_hdr[] = { 0x87, 0x80, 0x03 };
+
+	if (skb->len > HCI_EVENT_HDR_SIZE && hdr->evt == 0xff &&
+	    hdr->plen > 0) {
+		const void *ptr = skb->data + HCI_EVENT_HDR_SIZE + 1;
+		unsigned int len = skb->len - HCI_EVENT_HDR_SIZE - 1;
+
+		if (btintel_test_flag(hdev, INTEL_BOOTLOADER)) {
+			switch (skb->data[2]) {
+			case 0x02:
+				/* When switching to the operational firmware
+				 * the device sends a vendor specific event
+				 * indicating that the bootup completed.
+				 */
+				btintel_bootup(hdev, ptr, len);
+				break;
+			case 0x06:
+				/* When the firmware loading completes the
+				 * device sends out a vendor specific event
+				 * indicating the result of the firmware
+				 * loading.
+				 */
+				btintel_secure_send_result(hdev, ptr, len);
+				break;
+			}
+		}
+
+		/* Handle all diagnostics events separately. May still call
+		 * hci_recv_frame.
+		 */
+		if (len >= sizeof(diagnostics_hdr) &&
+		    memcmp(&skb->data[2], diagnostics_hdr,
+			   sizeof(diagnostics_hdr)) == 0) {
+			return btintel_diagnostics(hdev, skb);
+		}
+	}
+
+	return hci_recv_frame(hdev, skb);
+}
+EXPORT_SYMBOL_GPL(btintel_recv_event);
+
 void btintel_bootup(struct hci_dev *hdev, const void *ptr, unsigned int len)
 {
 	const struct intel_bootup *evt = ptr;
drivers/bluetooth/btintel.h +1 -0
index 7fd29ef038bd..2ed646609dee 100644
@@ -222,6 +222,7 @@ int btintel_read_boot_params(struct hci_dev *hdev,
 int btintel_download_firmware(struct hci_dev *dev, struct intel_version *ver,
 			      const struct firmware *fw, u32 *boot_param);
 int btintel_configure_setup(struct hci_dev *hdev, const char *driver_name);
+int btintel_recv_event(struct hci_dev *hdev, struct sk_buff *skb);
 void btintel_bootup(struct hci_dev *hdev, const void *ptr, unsigned int len);
 void btintel_secure_send_result(struct hci_dev *hdev,
 				const void *ptr, unsigned int len);
drivers/bluetooth/btusb.c +1 -74

87 lines not on this page · raw message

Signature · 1 line
2.41.0
#1 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=767998

---Test result---

Test Summary:

CheckPatch                    PASS      1.09 seconds
GitLint                       PASS      0.25 seconds
SubjectPrefix                 PASS      0.06 seconds
BuildKernel                   PASS      39.56 seconds
CheckAllWarning               PASS      43.31 seconds
CheckSparse                   PASS      49.59 seconds
CheckSmatch                   PASS      133.43 seconds
BuildKernel32                 PASS      38.20 seconds
TestRunnerSetup               PASS      580.86 seconds
TestRunner_l2cap-tester       PASS      27.15 seconds
TestRunner_iso-tester         PASS      64.40 seconds
TestRunner_bnep-tester        PASS      12.78 seconds
TestRunner_mgmt-tester        FAIL      242.32 seconds
TestRunner_rfcomm-tester      PASS      19.39 seconds
TestRunner_sco-tester         PASS      19.88 seconds
TestRunner_ioctl-tester       PASS      22.11 seconds
TestRunner_mesh-tester        PASS      16.00 seconds
TestRunner_smp-tester         PASS      17.17 seconds
TestRunner_userchan-tester    PASS      13.16 seconds
IncrementalBuild              PASS      35.68 seconds

Details
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner Output:
Total: 497, Passed: 496 (99.8%), Failed: 1, Not Run: 0

Failed Test Cases
LL Privacy - Unpair 1 Timed out 1.891 seconds

---
Regards,
Linux Bluetooth

#2 lore raw
In reply to Luiz Augusto von Dentz
This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 9 lines · On Thu, 20 Jul 2023 15:19:54 -0700 you wrote:

From: Luiz Augusto von Dentz <[email protected]>

btusb_recv_event_intel is specific to Intel controllers therefore it shall be placed inside btintel.c so btusb don't have a mix of vendor specific code with the generic parts.

[...]

Here is the summary with links:
- Bluetooth: btusb: Move btusb_recv_event_intel to btintel

    https://git.kernel.org/bluetooth/bluetooth-next/c/458853310845

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html