Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp415195pxk; Fri, 11 Sep 2020 10:14:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFKYh2giVg2jAg92kxrbT3/ywQBKyb7iEypzeUWg8XcBfI0vTJdzE1rw+VupwXDs2iL56J X-Received: by 2002:a50:fc87:: with SMTP id f7mr3208871edq.162.1599844492473; Fri, 11 Sep 2020 10:14:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599844492; cv=none; d=google.com; s=arc-20160816; b=wMsI/+71kvpUrxWo6HanghSmPDTKlMmCq3DDP7Ybm3q05gC5Nsabo4HOcLCvw8a+VO TPRr+F4qdLP2vyag/9vrcfqZC1HuA8+AfV1M9uiPUNEEaw7Ym/92YQovifwmubrMtI/9 y3id20ZHJ0iNXncqIZ+Hars7VOSclvLgd6nJKrlHHJepNR0bjcA2641RR1iah47AoY6C 26vH9BLLv36pYhk4sj/U4B3LA2k1yZR5iEz/zJkHJZuR2I30BgxrT/vQJdhWjNz5mNR3 PDP6o4FvLKZTmcP3wMxRompBIqMNiKKqaYQqmW4YF1VGPdrgBQw64ltYxQCdyyf8y56p rceA== 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=Mbot9ybxN7CEBjkJx2/zfixlDiQJfoliZ9FJfemsvkc=; b=Walvp9tWtpE922YVFn3eIqSLMDcoL/YUhf0MIf1jSsDODAk0VERCbI0XbE6LvEMypV 8sTaqBtrEB+RWJDg0/4XEHY4tDfYHvjQBnMj7nbWhGRAkJcsBZV5wWlHPSBqCVMoNhoh vbl8+xEwtdV1DRA2yk76q1EZ5YSomiz8SYfiq9+qFxi/3ydlauRzFjXbMmJwCFLidsSq xryS/Adkzl2D7/VjU8KO/eY3kj1ERcwJP3Y0slcMOIpOLhsQHihxzu4lCu/6WgisMsl9 rksDb3iR3oz0qlWC+rQ/JWW1r9i9KAcISxfZBzhpTGO6vxcQOEp11k3+JsSCcWxZbnBA h5KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=dkngZxcJ; 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 m3si1541980ejk.485.2020.09.11.10.14.29; Fri, 11 Sep 2020 10:14:52 -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=dkngZxcJ; 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 S1726339AbgIKRNw (ORCPT + 99 others); Fri, 11 Sep 2020 13:13:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726040AbgIKRNR (ORCPT ); Fri, 11 Sep 2020 13:13:17 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5009C061796 for ; Fri, 11 Sep 2020 10:13:12 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id z19so7845386pfn.8 for ; Fri, 11 Sep 2020 10:13:12 -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=Mbot9ybxN7CEBjkJx2/zfixlDiQJfoliZ9FJfemsvkc=; b=dkngZxcJsfiwaoaeeA5ivGItvOj+ltwumQrEg2V2Fb6waCKmwZnjPEH4f4GucgxVLB 5dw95RVIXR7dHD+f1E9ucpz2A3/rbkTFTnco1FwjNge2jtemQnNxvrRRKr+KfkzRDqJQ +oLDdyDVAapClSi2quq12dscrXXbs1KAohowQ= 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=Mbot9ybxN7CEBjkJx2/zfixlDiQJfoliZ9FJfemsvkc=; b=SStc+DswlsI1MVSsUbP0d/K2HhPId8Ts73BANI8IvCBGvrkULN90k0Ch0z1Ty+nksq 3jCtu6pJ0Aa145+Y8rdJc6DuU0y8bt9W/6y4o7q1o9Uo3XNbXZAAxZaMoQPIZ0jYps5Q oiEkWASUUrA5SOzV5eh/w1fvK8IaKtIDLhpXlqY4SShmVXfPRCL94iuU/rS3YD0ljNmj 3ZjJ4n0rINZ74X80lci7Vju4NhvlCJB01jsRR+xplrinMFLtZGQtPScQo/SW66W64IcT r5LWZuHymtZfqbhi8YFkew3MMMgY3xb+FPP502aYYOu4b0CYNNMpL+zP2452FSi+/Znf XUQw== X-Gm-Message-State: AOAM530r7LySLlzLU5AG3B9iChP1oZVrP9PgzvKNBsfyoJbm4jygJQNW knT8Xb6DMAe/fjDh29vdZV1dfQ== X-Received: by 2002:a63:b20d:: with SMTP id x13mr385059pge.136.1599844392256; Fri, 11 Sep 2020 10:13:12 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id h9sm2787452pfc.28.2020.09.11.10.13.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 10:13:11 -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: [RESEND PATCH 1/3] Bluetooth: Add mgmt suspend and resume events Date: Fri, 11 Sep 2020 10:13:04 -0700 Message-Id: <20200911101255.RESEND.1.I1b721ef9da5c79d8515018d806801da4eacaf563@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog In-Reply-To: <20200911171306.3758642-1-abhishekpandit@chromium.org> References: <20200911171306.3758642-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 --- include/net/bluetooth/hci_core.h | 3 +++ include/net/bluetooth/mgmt.h | 11 +++++++++++ net/bluetooth/mgmt.c | 24 ++++++++++++++++++++++++ 3 files changed, 38 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..1475a47edb080b 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -8874,6 +8874,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