Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3676119rwl; Mon, 27 Mar 2023 18:19:50 -0700 (PDT) X-Google-Smtp-Source: AKy350YB6UWW+TzSjmiV6eVSrs6OtrW81ZxHsQunTLf82CLNke8MmtqgLqudKADe5Y2Rn9+Jjux2 X-Received: by 2002:a17:902:d052:b0:19e:65db:7ac3 with SMTP id l18-20020a170902d05200b0019e65db7ac3mr11020110pll.68.1679966389962; Mon, 27 Mar 2023 18:19:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679966389; cv=none; d=google.com; s=arc-20160816; b=FRU5o91epwZ2to7yXrykv3NFgYU8Is9cYUN2DS/njTV9TLv4lijacZUJnHwJGwS4da X/JTfHhViD1te9gQqL5bPcgdhd2W9Snw/0utxYNjphVNuNnahVFt6YCtSK2su2zaVyxc pKmY93hbSKZ3auMrpADYizUDgx+atXXMkON4MNb1VHfYJxo9XxLZRiOe0KRfNrKTt7VV ST3Xpw9luwjIqX3R6GTVBxAtdullHfDHPNKbV4LN6h9mrI2bOnUnIxl19WSBh5L5G779 U/kK6lip0pvQyosK0AGxaMYQGIA3DbjXuaKmYDF91YE1ljY8/rw3puFJQJFajQyhs30n S/GA== 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=3y5WqOT376pI2yRKqgV9p9VlTctVEmeHkeRgXExZUGQ=; b=d2pjKYjKR5A+In2qLL+wmEVb/34szCB+Tp1cyYLCTW8TLLhcpS03TT+NNokARu01iH EY89P5nwof7PdpAwy+tHDp/ec7IW3Vdfqr1iEgMDgmOZb38zZkFVX5olAfHBlxIELblG ugT8Eg/20zPtfRd0NzLy/jZoRlEYjAbHzmLa7xa4DjwmIa72Ok05//PHAm8kRJaD6QWY jmyLCn9F5JgDZehDn/j0tjxgw5XgFupcbn42aZeGS4GjNBB6KQ6z8vwEo+DhBFlaFQMJ Tf98ApJAlOyL201T6AybKi6GAop/1mcP/do4ecUOhAmxKSwgJ9fXBjdPEZHnlKX3GsHS ZEQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Jlb3o+cI; 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 s8-20020a170902988800b001a1a0db7f61si27139560plp.336.2023.03.27.18.19.25; Mon, 27 Mar 2023 18:19:49 -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=Jlb3o+cI; 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 S229658AbjC1BTL (ORCPT + 99 others); Mon, 27 Mar 2023 21:19:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231833AbjC1BTK (ORCPT ); Mon, 27 Mar 2023 21:19:10 -0400 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96C031BCE for ; Mon, 27 Mar 2023 18:19:03 -0700 (PDT) Received: by mail-pf1-x44a.google.com with SMTP id y186-20020a62cec3000000b00627df3d6ec4so5078552pfg.12 for ; Mon, 27 Mar 2023 18:19:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1679966343; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=3y5WqOT376pI2yRKqgV9p9VlTctVEmeHkeRgXExZUGQ=; b=Jlb3o+cIX/JTlohbvx55JnUIDP6UK/SWtEIs21vdoiknObjL8amU3TFklUywGR+Toj GzlQN2Vmgb2zmnHeGLuR+tqOJlr1XndkByBNSlgjxEiR2u1utYmSgo601lBSEJSOxlkW fEArAgOo3ZGiq4QKxudAN9QArd2bOf7QoLqqUlzSkGj/0Fg9LQgCs0K5EtqjnTrwa0+L XjrktI7/YDv2os252VZfQds0R1PmGxcRMXiWIuaSpvX+HIcQwfuF1l/CBdyxVgOmgS5W UyROk993eM7PJ6VdS9s03ltGWh2K2Vp5duVnfIIKg6v9taRHufVWrV5LvyJHBvMlqVi+ YD+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679966343; 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=3y5WqOT376pI2yRKqgV9p9VlTctVEmeHkeRgXExZUGQ=; b=Kf+3mNFiS4IhAb4madQGWubHfQDLgW5smocKQAaeHkXJ0zOprdtLkYG9hTc6AAgTfU 54Ysby2LqGdAgX8lAzG7ohymVHlkNhptSZBEnW9yStBSeeTUFucyRMhwQMdVx2clpoVi 3gx454o5fezJlgDxMoqfjUXOAjK6dxKqpXhfOTZSUFkPNhl/6m/ZFqgaPMmmLfNV3Fdh 6kJf3qd7j46zf3Z42PM0MjWl4M6sOZgc+E8TEWC4b7InKI4MmCqhOrODeDzDsEGUMIET 6P5adXiQdmqWezjJgnTQNCvuJMgaVR2nOR92t+IE7gzRn/u5Whzr0C22+IhqWiOBtbxw Hbyw== X-Gm-Message-State: AAQBX9dsUVC147AnRgek8NlNXTbhjIEKJdUtTD4VucJFghCKTx1+5sfy hxMxeArlG3zUyK4Kg9DKW3CVCGS1uwIrVA== X-Received: from mmandlik-cloudtop.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:2893]) (user=mmandlik job=sendgmr) by 2002:a17:903:22c6:b0:1a0:6000:7fd0 with SMTP id y6-20020a17090322c600b001a060007fd0mr5434223plg.5.1679966343113; Mon, 27 Mar 2023 18:19:03 -0700 (PDT) Date: Mon, 27 Mar 2023 18:18:55 -0700 In-Reply-To: <20230327181825.v9.1.I9b4e4818bab450657b19cda3497d363c9baa616e@changeid> Mime-Version: 1.0 References: <20230327181825.v9.1.I9b4e4818bab450657b19cda3497d363c9baa616e@changeid> X-Mailer: git-send-email 2.40.0.348.gf938b09366-goog Message-ID: <20230327181825.v9.2.Ief9a81a3643d2291f6db2b3695c3a6e0159467dc@changeid> Subject: [PATCH v9 2/4] Bluetooth: Add vhci devcoredump support From: Manish Mandlik To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.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 v9: - Rename hci_devcoredump_*() to hci_devcd_*() 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..a265dcaf8275 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_devcd_register(hdev, vhci_coredump, vhci_coredump_hdr, NULL); + + ret = hci_devcd_init(hdev, skb->len); + if (ret) { + BT_ERR("Failed to generate devcoredump"); + kfree_skb(skb); + return ret; + } + + hci_devcd_append(hdev, skb); + hci_devcd_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