Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4666562rwl; Tue, 28 Mar 2023 09:38:06 -0700 (PDT) X-Google-Smtp-Source: AKy350YxmEouPckZyZ14usfCvKZZhFjMoCJwOxZ4aeV/hlORYEyRvxgtTS3c2Iw8BnMHRAEW/ieU X-Received: by 2002:a05:6402:1005:b0:501:caae:e0de with SMTP id c5-20020a056402100500b00501caaee0demr16592984edu.4.1680021486193; Tue, 28 Mar 2023 09:38:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680021486; cv=none; d=google.com; s=arc-20160816; b=TX2vf96v8Vyqp0QJ83JBx/XOFCS92b3aYVsB/HwkGEaRr4BsVLMEKmTA+Uu1kBiBmz eu6dP6/q6Vj0jW0ELCTP3hPmjMPG+4bX69wWN9Af7EFuvlz1nW5kKDPS6VyRWUjBnhnQ uAgwfvlAr73wXPpOGH0v54dPfaiblUqjOTNdMELjtIuWEXkPUebZ1FcScQtb8wxP6LHm MqJUYpltg8sdBy31hmn+OLx+AWmNIyPRP9uNLIil+1bVIZUw0dBWN9v/rb8gRqmwgJMC JqK5W6IEIZKlAey/eMuGf3OVFd/ZmVx/iOgye+F+zwPeD/rUucWzU/1jXRsfvMaRM4xJ QTDQ== 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=sVqYiqqONgJinnmUNat86CZDMiZZiJLuOgYyNlqZ0G4=; b=q5vncnt0PJphqWTTHF54UOCQv1LW8n/z25YqwvSVqvYOsQoyFFRlxc/XT7hTnVc4vF KcdKE1y9BOuY56RnjkzGYrR2Pa9xZQXbxs3g78Tiz4VGttKr8W4OUaK7HoBCl9GqKlaz qUqJ8NqF0N824jklJW9jGH4tciu46qW+mYwNZFervTfn5C7n0CaTb2uMxOLn546xzhvk eTT0gRcTIdaJ2pdwMnJFMubdKEjyN6jZxCFVtVCI/AmLqrT6j/nDTPkcZMoGBDXS9TMf mtgJI6jtB+pueY07telUPo+I66DkG7s4hR18cKJskBZD9Lzc5au0q19l5/YYtPrCFi9L eBJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="LP2JH1/h"; 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 s10-20020a056402164a00b005004ce1b26fsi17011813edx.593.2023.03.28.09.37.39; Tue, 28 Mar 2023 09:38:06 -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="LP2JH1/h"; 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 S233227AbjC1Qal (ORCPT + 99 others); Tue, 28 Mar 2023 12:30:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233254AbjC1Qa1 (ORCPT ); Tue, 28 Mar 2023 12:30:27 -0400 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A477B446 for ; Tue, 28 Mar 2023 09:30:26 -0700 (PDT) Received: by mail-pg1-x54a.google.com with SMTP id e15-20020a65678f000000b0050f9e396342so3392227pgr.5 for ; Tue, 28 Mar 2023 09:30:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680021026; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=sVqYiqqONgJinnmUNat86CZDMiZZiJLuOgYyNlqZ0G4=; b=LP2JH1/h7tcgzYCUI8SVxWvVevFsuhPAFOGD0UMm28p0GOSF7qsbuFk1YryWGoucKc pUB+rVpAyeht5JL2DWUne2HbBYviLccsU/L6WaDcgCHO636JkjRqS3Bda18reMmA7dZg vDtzF2/sYwXsd7PGNEXvdtbB+mM/Wz9REbcE9P+hTVWDJeGf6R8NipvWfvvHh4SztX+F pHw1H31eOrtPTklrmSXrZi+nmpox13UqHEM8Ij2/kSETpatfpjpO5Lu1CzhTc0iER8NL dBNq0p2IgVkJv7VnRehU6lsg72vnQ5UgP995GES08EZJQ7HQqkHZqyPqfvSGJNstMYze fcVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680021026; 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=sVqYiqqONgJinnmUNat86CZDMiZZiJLuOgYyNlqZ0G4=; b=0xXDEQalvhL2YMgjfrHvFIYEcmKdwa1a9moaG11uK5Gy9HkpT2fugcpJH2Z0AIVHPA Z75FTDNgoTlS2RiP+kfOkh+6nS8+2JhNSExH26uolyt4IR+hW/fALDTQaeF8oc02X3vL VynHxdWedfuRO4UhdABBV4+Nu+w1ozcB/9Ag9pKotw8Gj/abAe1pj+Gj2bmCM6wuVxx9 c5/O3W/sv2YZW+1XBXhG2NaNqAA0p49WOEvpbcMslMN76ZeTmpUjCYhQBInfduHp5Kvx zrozk7JH59kQZBhQv7zD0dTBjshejZpyTZ23vVt0f7t3YtnjjPzy+Z0qxbutU4O9egCH Xkgw== X-Gm-Message-State: AAQBX9db2F7LHXF/kK+qI5DmcwoIEEvV8bRXXGRj/qZYZJ9enQYzz6ym MTQ54p4WtTF++tRrm1V0mkrsWGMQ7UQp3A== X-Received: from mmandlik-cloudtop.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:2893]) (user=mmandlik job=sendgmr) by 2002:a05:6a00:2e9a:b0:624:1261:918f with SMTP id fd26-20020a056a002e9a00b006241261918fmr7951619pfb.1.1680021026093; Tue, 28 Mar 2023 09:30:26 -0700 (PDT) Date: Tue, 28 Mar 2023 09:30:17 -0700 In-Reply-To: <20230328093000.v10.1.I9b4e4818bab450657b19cda3497d363c9baa616e@changeid> Mime-Version: 1.0 References: <20230328093000.v10.1.I9b4e4818bab450657b19cda3497d363c9baa616e@changeid> X-Mailer: git-send-email 2.40.0.348.gf938b09366-goog Message-ID: <20230328093000.v10.2.Ief9a81a3643d2291f6db2b3695c3a6e0159467dc@changeid> Subject: [PATCH v10 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 --- (no changes since v9) 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