Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp171056rwl; Thu, 23 Mar 2023 14:21:24 -0700 (PDT) X-Google-Smtp-Source: AKy350Z4NM/wP01OU3lIBWUVf+pMzo2dj294miOPzQWamJvY/n2kQNhpeRQPjQfRcLi7ZQTPCipk X-Received: by 2002:a17:902:f353:b0:199:1160:956c with SMTP id q19-20020a170902f35300b001991160956cmr165426ple.31.1679606484396; Thu, 23 Mar 2023 14:21:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679606484; cv=none; d=google.com; s=arc-20160816; b=TcOSHb1qel7KHXdTIrP0ZfNZAK/QIB6s6bmL7n4MQDuJlxUEMoq8ajy6Bj3+h0ehH8 uiZsF1TDUJWGO/8Uesj1uaPuLOzORFzt4zjvuJi6edwRsrD4eq1zXhKhJFymaaUBUJh0 ncHozmpY1BA0rENIkyKruTm4A2UPUJYG0zsRRBeINvEz20SAwBpUPnlCdlMehJ1pwHB2 24+mgaM81eyxHE4I0FY0e2Ua9IQ8zNee/vEP55aCWA/QKGn5kiPjHr1BFZVKfcPn1T32 9whaAM8bswuNzxm+arXEakXxJnqOCFd+VYEPS/jMaLQHd9o6GcMRnV/4SUE6Aq8slNkb ioPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=vb8xGekqLZEVswI0VXnWBbiOZDnEjcKbHS0+1g7cZR4=; b=MJtDtoP7/s4dhCX6dXxr0fMBB7/TJMoHLIe6MLukTG224/36pB97pKXFAHvap7F/ZQ cgTfFPUWAPzA4hhTN3MVEjcT0QGWDTEWnTbAuFbW+OmPDNTZU+ZxkBuf8/E3MDvbx+8j dJOXMtcoUh/g9uIFW+Nr83Lqdgudj1N6LszOZQmeLjlgApmX4/4/x3fJXcINrK6HeaUH zLF8somxp+us0E7m9/QWiNfqX9Z01HkDskav3VTYf5WMEeNOEov4nW4t4kTt68BCHxEl kadKr7IQoKz+DnRRtxr5kp+n0YQ7JCzXM9ZxNC4x7uIca9gabxZH4Nhew3YE8/7FruT1 UISg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=L+DAp2MO; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id iz4-20020a170902ef8400b00192721d6a97si18660475plb.499.2023.03.23.14.21.12; Thu, 23 Mar 2023 14:21:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=L+DAp2MO; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229644AbjCWVKa (ORCPT + 99 others); Thu, 23 Mar 2023 17:10:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231128AbjCWVK3 (ORCPT ); Thu, 23 Mar 2023 17:10:29 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 903A624CAD for ; Thu, 23 Mar 2023 14:10:27 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id i11-20020a256d0b000000b0086349255277so23829945ybc.8 for ; Thu, 23 Mar 2023 14:10:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1679605827; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=vb8xGekqLZEVswI0VXnWBbiOZDnEjcKbHS0+1g7cZR4=; b=L+DAp2MOt1+8vAsdO/zxTmqAUl6PsMPqtBeQXy0P2jSvlukJIyVJjOqgOPy+UKV0H1 x8mmXxHbULbceu1L/ka66cuA4w8ZH/XyUJ44nLaTPk7I9F//Ec4Wo6lS8yM9lkJN3ypB l1f0sysmj7ibeMdHoDuVJQhymiW98UsjMmaM+yvpS2So+/jfS44Ufv2LizHWFmuZULEV VmubLNxsmTe3nS8ksdXCCb9k1Ue5Etede03yupybyDCPn0AtuvPa42GQciMCtb8rWtff T56hLVMzbANMVRr9jAYbjE0Hhp41GCzLeGyLKVbaJjl1U3dpdeLdjuhn0ZwyItVTW5Pj uNGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679605827; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vb8xGekqLZEVswI0VXnWBbiOZDnEjcKbHS0+1g7cZR4=; b=qm/clA8nMedDiy8KZBf5wjvlxA9HJpbi+/p45/5g8SL+UesHXXnEmgoc8eyWu00JpF F8HAfmUo0Sq1ec+YbJKVb1LAW3EsX/QCJDh1uPptw3BFqY2TlglypaCCnXvNVF0Nyppz kNUasjBSYnl/KeCuYXaaSfQofAaGd7LtxrZEqS0NhWiJBZ44pk2DAwQN72LVvgF1mhDl 2tBLRvAejEOVLFwoYkYIRD7ke1MxKyx+ZIpT8xvMdEUZznZM6DrnogbGcI+qJk8Rsa2s PYwYDHKxHsCNUsQYnWHGMnMdzkl3LPs2doWOr1XvVytyzzNvn5MKVY1Z3RRDlkwOgKTu d04g== X-Gm-Message-State: AAQBX9c8SQxNA7LcRdCbzEPIfCqDnBoFME1tltTKU+PF77NHCoX8GI+Q SBKApmmXz8Y0Nt1tH8dx5F8g9jBgV9hm8g== X-Received: from mmandlik-cloudtop.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:2893]) (user=mmandlik job=sendgmr) by 2002:a81:a782:0:b0:541:a17f:c77d with SMTP id e124-20020a81a782000000b00541a17fc77dmr2498836ywh.10.1679605826783; Thu, 23 Mar 2023 14:10:26 -0700 (PDT) Date: Thu, 23 Mar 2023 14:10:16 -0700 In-Reply-To: <20230323140942.v8.1.I9b4e4818bab450657b19cda3497d363c9baa616e@changeid> Mime-Version: 1.0 References: <20230323140942.v8.1.I9b4e4818bab450657b19cda3497d363c9baa616e@changeid> X-Mailer: git-send-email 2.40.0.348.gf938b09366-goog Message-ID: <20230323140942.v8.2.Ief9a81a3643d2291f6db2b3695c3a6e0159467dc@changeid> Subject: [PATCH v8 2/4] Bluetooth: Add vhci devcoredump support From: Manish Mandlik To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, Manish Mandlik , Johan Hedberg , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.7 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Add devcoredump support for vhci that creates forcce_devcoredump debugfs entry. This is used for mgmt-tester tests. Signed-off-by: Manish Mandlik --- Changes in v8: - Update vhci_coredump_hdr() to use skb Changes in v7: - New patch in the series drivers/bluetooth/Kconfig | 1 + drivers/bluetooth/hci_vhci.c | 64 ++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig index 5a1a7bec3c42..7bc7a765ad69 100644 --- a/drivers/bluetooth/Kconfig +++ b/drivers/bluetooth/Kconfig @@ -363,6 +363,7 @@ config BT_HCIBLUECARD config BT_HCIVHCI tristate "HCI VHCI (Virtual HCI device) driver" + select WANT_DEV_COREDUMP help Bluetooth Virtual HCI device driver. This driver is required if you want to use HCI Emulation software. diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c index c443c3b0a4da..1c3c27b7e9b6 100644 --- a/drivers/bluetooth/hci_vhci.c +++ b/drivers/bluetooth/hci_vhci.c @@ -278,6 +278,67 @@ static int vhci_setup(struct hci_dev *hdev) return 0; } +static void vhci_coredump(struct hci_dev *hdev) +{ + /* No need to do anything */ +} + +static void vhci_coredump_hdr(struct hci_dev *hdev, struct sk_buff *skb) +{ + char buf[80]; + + snprintf(buf, sizeof(buf), "Controller Name: vhci_ctrl\n"); + skb_put_data(skb, buf, strlen(buf)); + + snprintf(buf, sizeof(buf), "Firmware Version: vhci_fw\n"); + skb_put_data(skb, buf, strlen(buf)); + + snprintf(buf, sizeof(buf), "Driver: vhci_drv\n"); + skb_put_data(skb, buf, strlen(buf)); + + snprintf(buf, sizeof(buf), "Vendor: vhci\n"); + skb_put_data(skb, buf, strlen(buf)); +} + +static ssize_t force_devcoredump_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct vhci_data *data = file->private_data; + struct hci_dev *hdev = data->hdev; + struct sk_buff *skb = NULL; + char buf[512]; + int ret; + + ret = simple_write_to_buffer(&buf, sizeof(buf), ppos, user_buf, count); + if (ret < count) + return ret; + + skb = alloc_skb(count, GFP_ATOMIC); + if (!skb) + return -ENOMEM; + skb_put_data(skb, &buf, count); + + hci_devcoredump_register(hdev, vhci_coredump, vhci_coredump_hdr, NULL); + + ret = hci_devcoredump_init(hdev, skb->len); + if (ret) { + BT_ERR("Failed to generate devcoredump"); + kfree_skb(skb); + return ret; + } + + hci_devcoredump_append(hdev, skb); + hci_devcoredump_complete(hdev); + + return count; +} + +static const struct file_operations force_devcoredump_fops = { + .open = simple_open, + .write = force_devcoredump_write, +}; + static int __vhci_create_device(struct vhci_data *data, __u8 opcode) { struct hci_dev *hdev; @@ -355,6 +416,9 @@ static int __vhci_create_device(struct vhci_data *data, __u8 opcode) debugfs_create_file("aosp_capable", 0644, hdev->debugfs, data, &aosp_capable_fops); + debugfs_create_file("force_devcoredump", 0644, hdev->debugfs, data, + &force_devcoredump_fops); + hci_skb_pkt_type(skb) = HCI_VENDOR_PKT; skb_put_u8(skb, 0xff); -- 2.40.0.348.gf938b09366-goog