Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3985940ioo; Wed, 25 May 2022 12:09:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLbw838nFeRpxv0ryRb6QftyKnMT2oc7nGviBni1bB/Aqhl9P0zzIe13u69+yqJPJltAWT X-Received: by 2002:a17:903:230c:b0:163:6c15:fc32 with SMTP id d12-20020a170903230c00b001636c15fc32mr1463145plh.120.1653505792053; Wed, 25 May 2022 12:09:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653505792; cv=none; d=google.com; s=arc-20160816; b=RQtou+mf33RnfsCiCZzNLugiC9hsGNgrocwdvO9V95DEs3alOuYwMde4+we9JW+LPG 5UNTlUfXPFAayGWfncclzRH9rMcgG8ACUNJcEJs2s6ZTJPlbj0MlZsmhX7AHr0vXGjby wfQt+K4gaNTBg3UVcl1RKYLUCP5ZYPzbLy63VYW5wS/lBwU4UJWlt8WMFRuIwUhtfV2g NrjmcG1j0XBiFPgs1oQfXtPLWVXu0Ab1vjr2tlPOgPTEhRq+k4123T+ipjwVuL5Rqs4M qaChv/VpED9p8JIt49/SKcWncAOuAT5+HC77AR+//Af8YK2QZyTYYs8DWgPWwypxaSFn K1xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2Ofo/7h9jTqDyo9qc7SprA/31bAIMjSHKkGlFIJBjtU=; b=orF1VS2WXpAWojCB/DsdFPZQIzAkeMyokmEeK+1zGRKTLKVwr8TAW+F6PnlsBWeNRG effnWp927J2TTUEtEVEUTW6T9x5a7zeID0mHKgT21FhbSUxj5HOuoWj3oQf81M1xMSaf DikBur+9PPIUsgqcW2Aq21kuRfu2FA8EYPEw0xEq/j6cb73oLs6+wU+0tD2X9B3Vhdlv 71Rga7/bQxKQTCiku+UrmMs3SMNOpxJhr7SuV+DPo7YV3WTHrqq8WbCG0mrwP2rovdT+ +bq9VdonsnQzHp3jUsoUslqiGAKPM3OpEuLfl2iLqiA7EiKfl89mTGEpezvAfeB5aojY GKLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=TeUELpsl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lr1-20020a17090b4b8100b001d991dfad30si4046296pjb.153.2022.05.25.12.09.38; Wed, 25 May 2022 12:09:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@chromium.org header.s=google header.b=TeUELpsl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242755AbiEYKqb (ORCPT + 99 others); Wed, 25 May 2022 06:46:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242360AbiEYKqD (ORCPT ); Wed, 25 May 2022 06:46:03 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC7299AE6A for ; Wed, 25 May 2022 03:46:01 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id s14so18214128plk.8 for ; Wed, 25 May 2022 03:46:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2Ofo/7h9jTqDyo9qc7SprA/31bAIMjSHKkGlFIJBjtU=; b=TeUELpsl0qygv6an9+IanVzO/AhwABBrwsmA/RI7ueZ/CeYY3B1AOxvpqAJobMZsAt x6vNP4zOYGH+sIE+GQHuf3wZwpvHZ07KZ+//P/0tQQJ3mS7M8H/OdOAO9xbMGZOhPzGX UdZqFteuTa9gn6NpDkrVNlr0Ytm4a9RgDbyao= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2Ofo/7h9jTqDyo9qc7SprA/31bAIMjSHKkGlFIJBjtU=; b=ZmoAo5sm6kUOhou5Wx5+J9YJVOnKc4k7QLCHvke+N3CXtYSOXr2wPt/BOAsG2G8C2X sz+M8jYYiXzA+S12tDQaUK892CjXvduZBBbewAMfCtfY+q/X0sBNMvAA6bo/r2BU3aYk Tdo+tWIgrJgZkgha/ibPG98i1iDfokC38t527v++ymWAWzjDv1WbdCd7Mp7R/gfD0cGY ED9FXRf0B6AKKwdxcqATbBJjdqE58aBSQKoguRsiu5geevbILLEyBpkzkAAY8/d5IR5Y LyYWs5I6HVYp0ZpY3UqlQ8XFzIVNrQaWwzclpKa1F+AbM4mflSZVE6VneqWGsnFtWQI3 y7YA== X-Gm-Message-State: AOAM533Nbl6/4oAxrs4f7IQpK9wNv/9JLYZo/YIpyYGDjr9XqMqB8PFs C0Nwn4jwWSs8tzu9NkFr1vdqv6XNgQnZqw== X-Received: by 2002:a17:902:b90b:b0:15f:bd0:18b5 with SMTP id bf11-20020a170902b90b00b0015f0bd018b5mr32864403plb.97.1653475561444; Wed, 25 May 2022 03:46:01 -0700 (PDT) Received: from localhost (174.71.80.34.bc.googleusercontent.com. [34.80.71.174]) by smtp.gmail.com with UTF8SMTPSA id b8-20020a6541c8000000b003f64036e699sm8155876pgq.24.2022.05.25.03.45.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 25 May 2022 03:46:01 -0700 (PDT) From: Joseph Hwang To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com, pali@kernel.org Cc: josephsih@google.com, chromeos-bluetooth-upstreaming@chromium.org, Joseph Hwang , Archie Pusaka , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Johan Hedberg , Paolo Abeni , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v5 3/5] Bluetooth: hci_event: Add vendor functions to handle vendor events Date: Wed, 25 May 2022 18:45:43 +0800 Message-Id: <20220525184510.v5.3.I63681490281b2392aa1ac05dff91a126394ab649@changeid> X-Mailer: git-send-email 2.36.1.124.g0e6072fb45-goog In-Reply-To: <20220525104545.2314653-1-josephsih@chromium.org> References: <20220525104545.2314653-1-josephsih@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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-kernel@vger.kernel.org This patch adds vendor_get_prefix and vendor_evt in the evt_prefixes table so that any vendor driver can set up the functions to handle particular vendor events. The hci_vendor_evt function checks if a vendor event matches the vendor prefix returned by vendor_get_prefix. If yes, the event is pushed down to the driver's vendor_evt function to handle. The driver function will call hdev->hci_recv_quality_report to pass data through mgmt if needed. Signed-off-by: Joseph Hwang Reviewed-by: Archie Pusaka --- Changes in v5: - Use vendor_get_ext_prefix and vendor_evt to invoke callbacks from drivers to handle vendor events. - Use hdev->hci_recv_quality_report to pass vendor event data from drivers back to the kernel. The mgmt_quality_report is then used to surface the data through the mgmt socket. - Remove the unnecessary "void *data" portion from vendor_evt. - The Intel specifics are pushed down to the driver and are implemented in a separate subsequent patch. Changes in v3: - Move intel_vendor_evt() from hci_event.c to the btintel driver. Changes in v2: - Drop the pull_quality_report_data function from hci_dev. Do not bother hci_dev with it. Do not bleed the details into the core. include/net/bluetooth/hci_core.h | 5 +++++ net/bluetooth/hci_core.c | 1 + net/bluetooth/hci_event.c | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index f89738c6b973..9e48d606591e 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -642,6 +642,11 @@ struct hci_dev { void (*cmd_timeout)(struct hci_dev *hdev); bool (*wakeup)(struct hci_dev *hdev); int (*set_quality_report)(struct hci_dev *hdev, bool enable); + struct ext_vendor_prefix *(*vendor_get_ext_prefix)( + struct hci_dev *hdev); + void (*vendor_evt)(struct hci_dev *hdev, struct sk_buff *skb); + int (*hci_recv_quality_report)(struct hci_dev *hdev, void *data, + u32 data_len, u8 quality_spec); int (*get_data_path_id)(struct hci_dev *hdev, __u8 *data_path); int (*get_codec_config_data)(struct hci_dev *hdev, __u8 type, struct bt_codec *codec, __u8 *vnd_len, diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index ad4f4ab0afca..3e22b4b452f1 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -2650,6 +2650,7 @@ int hci_register_dev(struct hci_dev *hdev) idr_init(&hdev->adv_monitors_idr); msft_register(hdev); + hdev->hci_recv_quality_report = mgmt_quality_report; return id; diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index c2c6725678ec..f9b03d7b4a22 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -4260,6 +4260,20 @@ static void hci_num_comp_blocks_evt(struct hci_dev *hdev, void *data, queue_work(hdev->workqueue, &hdev->tx_work); } +static struct ext_vendor_prefix *vendor_get_ext_prefix(struct hci_dev *hdev) +{ + if (hdev->vendor_get_ext_prefix) + return hdev->vendor_get_ext_prefix(hdev); + + return NULL; +} + +static void vendor_evt(struct hci_dev *hdev, struct sk_buff *skb) +{ + if (hdev->vendor_evt) + hdev->vendor_evt(hdev, skb); +} + /* Every distinct vendor specification must have a well-defined vendor * event prefix to determine if a vendor event meets the specification. * Some vendor prefixes are fixed values while some other vendor prefixes @@ -4276,6 +4290,11 @@ struct ext_vendor_event_prefix { { aosp_get_ext_prefix, aosp_vendor_evt }, { msft_get_ext_prefix, msft_vendor_evt }, + /* Any vendor driver that handles particular vendor events should set + * up hdev->vendor_get_prefix and hdev->vendor_evt callbacks in driver. + */ + { vendor_get_ext_prefix, vendor_evt }, + /* end with a null entry */ {}, }; -- 2.36.1.124.g0e6072fb45-goog