Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp554618pxk; Fri, 11 Sep 2020 14:08:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwE7p2cQPipw+kKPIgCSHf2sGiYnxBI9CdAay7grkYFX7lLX6kaXSirpKrgeT0iOj7euiK7 X-Received: by 2002:a17:906:e4f:: with SMTP id q15mr3978101eji.155.1599858531336; Fri, 11 Sep 2020 14:08:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599858531; cv=none; d=google.com; s=arc-20160816; b=yOxr5QIesMTvM3qxbarDST/CkuGar8C3BYJcZbk788UEG08Uljk01i3A2Z1UrfN4VS Z/Kk2cWP0h0hJBVayijuT6ig6MDyVw85EkesizckiUvntvm/Sd+ehoWd3vEMboonryD4 Gg5mVtEVY3FZpNyzPYqnGc06P5OZW/6gq6Ojo201hA4JHjmY8rUywkSNH1ANP5InNBY5 ZePC/4+Z7Y0NoEShINbKKlJoakqTcWz2jejdx//wItzTClcsUtckuqnLMZXUvGesXraz 2T5tEj9vndc5Ls/7Lz0omG26ELfWadJWUzAtRW1YfBcHhWH5c4SyMfZW3PND9GCtDhhE Xx6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=q0EDfG7U4ZsAEWdz2bw53WcEhGvs/CQ/qZmbkCldzx8=; b=rV57zX/mEcOd27O87rCMr6GtsEyS3yEd5oxTqtcglxFAyFRzH1ooMgAVU21q4izgIM /Ipi/Nk5Ba2yx4rytx2mko6qLiW97d3Pi/kjIjNxqElcPJ9wOSMNiCiBamiqH6SJZINu yy8hf6rBu4GcH+fBaCHLDxEplc+po08Sl9KrlMGPVB13TxbENWuflYZwItdER9n11CYF LMsYseEXLmqhhQSOh4/xMy48Du0lagCUyw3tsOMYzgWxAMsddDeTUXFYssYoaIihPEMN RFslc5jxQjz2WRkLIkKfLgxdELNZvknhuxCYdBeZXCBY2BsVuhrc1Agy0zS8LQ5peYa1 kzhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ex1Sl7Uz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k21si2060297eje.480.2020.09.11.14.08.27; Fri, 11 Sep 2020 14:08:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ex1Sl7Uz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1725887AbgIKVHl (ORCPT + 99 others); Fri, 11 Sep 2020 17:07:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725817AbgIKVHY (ORCPT ); Fri, 11 Sep 2020 17:07:24 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CE1EC061786 for ; Fri, 11 Sep 2020 14:07:24 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id g21so132904plq.1 for ; Fri, 11 Sep 2020 14:07:24 -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=q0EDfG7U4ZsAEWdz2bw53WcEhGvs/CQ/qZmbkCldzx8=; b=ex1Sl7Uz5mh12J+bs6llV1eFKhakw2Wom2mdEmwWqf4rpbgzAw6QYWoOCFiSwnHERc vAJ62kngwukDM245INL9WqPLR0P6gIK29OQ6KgOvoCi24Jo9Co0APBvPZA6oVai92dSS 5t2S/Ii+brIAbQrzJ77wQKErW0gUIeORvBgsc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=q0EDfG7U4ZsAEWdz2bw53WcEhGvs/CQ/qZmbkCldzx8=; b=OLu9j/+ZXY1fKaoWVzBYhbC/+u5HvNcIXOVBxudftgX5EK3njeW1KQIkpaDBKKnqDn FwaNroRn0RMGV/FwEaKPqeHS56fcyyQ1UVSTeB81wRHOQhrUFrTWH4yaXNHaa/6qw70o bm0cWKQLcWtiXluX4qBQDpK8GGuhUGd5R7Me/tKdTt819gS/xFJWkF3URANF7zrsUcXy b9W4r/vE1AXl6NTs91u/m4MHEJejDDwDzokNVTT4hmSRk9lxqqzPo5YXChstyWb/drRr Q/Z6dbjIwreyb9JbJrpEF9dINIhWjfS9YPS5IpixwzhObDn7O3R5iJSoz9mwjW6fq1EO PQJw== X-Gm-Message-State: AOAM532Ig7fWCmyV/+AjTwMqRQkQcNlC67woHcyhOuMR7Mz78GMqazMx PKBl2LGUlG8RoIisuIMN0gdORQ== X-Received: by 2002:a17:90a:ebd7:: with SMTP id cf23mr3817171pjb.126.1599858443601; Fri, 11 Sep 2020 14:07:23 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id c128sm3308764pfb.126.2020.09.11.14.07.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 14:07:23 -0700 (PDT) From: Abhishek Pandit-Subedi To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi , Miao-chen Chou , Sonny Sasaka , "David S. Miller" , Johan Hedberg , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski Subject: [PATCH v2 1/3] Bluetooth: Add mgmt suspend and resume events Date: Fri, 11 Sep 2020 14:07:11 -0700 Message-Id: <20200911140700.v2.1.I1b721ef9da5c79d8515018d806801da4eacaf563@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog In-Reply-To: <20200911210713.4066465-1-abhishekpandit@chromium.org> References: <20200911210713.4066465-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add the controller suspend and resume events, which will signal when Bluetooth has completed preparing for suspend and when it's ready for resume. Signed-off-by: Abhishek Pandit-Subedi Reviewed-by: Miao-chen Chou Reviewed-by: Sonny Sasaka --- Changes in v2: - Added suspend/resume events to list of mgmt events include/net/bluetooth/hci_core.h | 3 +++ include/net/bluetooth/mgmt.h | 11 +++++++++++ net/bluetooth/mgmt.c | 26 ++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 8caac20556b499..02a6ee056b2374 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1750,6 +1750,9 @@ void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, void mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type, s8 rssi, u8 *name, u8 name_len); void mgmt_discovering(struct hci_dev *hdev, u8 discovering); +void mgmt_suspending(struct hci_dev *hdev, u8 state); +void mgmt_resuming(struct hci_dev *hdev, u8 reason, bdaddr_t *bdaddr, + u8 addr_type); bool mgmt_powering_down(struct hci_dev *hdev); void mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, bool persistent); void mgmt_new_irk(struct hci_dev *hdev, struct smp_irk *irk, bool persistent); diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 9ad505b9e694e4..e19e33c7b65c34 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -1030,3 +1030,14 @@ struct mgmt_ev_adv_monitor_added { struct mgmt_ev_adv_monitor_removed { __le16 monitor_handle; } __packed; + +#define MGMT_EV_CONTROLLER_SUSPEND 0x002d +struct mgmt_ev_controller_suspend { + __u8 suspend_state; +} __packed; + +#define MGMT_EV_CONTROLLER_RESUME 0x002e +struct mgmt_ev_controller_resume { + __u8 wake_reason; + struct mgmt_addr_info addr; +} __packed; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index e1d12494d16e14..db48ee3c213cbd 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -163,6 +163,8 @@ static const u16 mgmt_events[] = { MGMT_EV_PHY_CONFIGURATION_CHANGED, MGMT_EV_EXP_FEATURE_CHANGED, MGMT_EV_DEVICE_FLAGS_CHANGED, + MGMT_EV_CONTROLLER_SUSPEND, + MGMT_EV_CONTROLLER_RESUME, }; static const u16 mgmt_untrusted_commands[] = { @@ -8874,6 +8876,30 @@ void mgmt_discovering(struct hci_dev *hdev, u8 discovering) mgmt_event(MGMT_EV_DISCOVERING, hdev, &ev, sizeof(ev), NULL); } +void mgmt_suspending(struct hci_dev *hdev, u8 state) +{ + struct mgmt_ev_controller_suspend ev; + + ev.suspend_state = state; + mgmt_event(MGMT_EV_CONTROLLER_SUSPEND, hdev, &ev, sizeof(ev), NULL); +} + +void mgmt_resuming(struct hci_dev *hdev, u8 reason, bdaddr_t *bdaddr, + u8 addr_type) +{ + struct mgmt_ev_controller_resume ev; + + ev.wake_reason = reason; + if (bdaddr) { + bacpy(&ev.addr.bdaddr, bdaddr); + ev.addr.type = addr_type; + } else { + memset(&ev.addr, 0, sizeof(ev.addr)); + } + + mgmt_event(MGMT_EV_CONTROLLER_RESUME, hdev, &ev, sizeof(ev), NULL); +} + static struct hci_mgmt_chan chan = { .channel = HCI_CHANNEL_CONTROL, .handler_count = ARRAY_SIZE(mgmt_handlers), -- 2.28.0.618.gf4bc123cb7-goog