From patchwork Thu Jul 22 05:49:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayush Garg X-Patchwork-Id: 484008 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80A1AC63793 for ; Thu, 22 Jul 2021 06:00:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 676BD6127C for ; Thu, 22 Jul 2021 06:00:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230376AbhGVFUU (ORCPT ); Thu, 22 Jul 2021 01:20:20 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:41591 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230343AbhGVFUU (ORCPT ); Thu, 22 Jul 2021 01:20:20 -0400 Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20210722060054epoutp03ff929ccb8b5bbf768136c69b6257430c~UB4oA60cf0824508245epoutp03B for ; Thu, 22 Jul 2021 06:00:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20210722060054epoutp03ff929ccb8b5bbf768136c69b6257430c~UB4oA60cf0824508245epoutp03B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1626933654; bh=VhAUX2KaLhcD0nEsXOQiKQD6baHytHOBPwc2nY0Hr9o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wm4HjPXOh2qmpZz3KoQG6mA6tdeFKbiZrxEDiNdQLmcj1m918MLmDCN0ixlskeo2l mMeLONooD480bSV3xTRNdcV4XDETiJB2qg3TtKVXbIiULanEVg8bzylJvxhczfg/lI dHD7+QZSzyGuj/ptkleMx9lvDrZGVMU7k6s6tDVQ= Received: from epsmges5p2new.samsung.com (unknown [182.195.42.74]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20210722060050epcas5p190ce885f3ed971de687fde4dc3ce24c6~UB4jxa9aa2840328403epcas5p1a; Thu, 22 Jul 2021 06:00:50 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 57.0B.09595.F8909F06; Thu, 22 Jul 2021 15:00:48 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20210722055009epcas5p25e4997aa7e53cb2a6e3780fdb7301785~UBvPGCgsX1311413114epcas5p2g; Thu, 22 Jul 2021 05:50:09 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20210722055009epsmtrp136c979ae9ef2327e87a48a66370ac37f~UBvPFQRT03119631196epsmtrp1e; Thu, 22 Jul 2021 05:50:09 +0000 (GMT) X-AuditID: b6c32a4a-eebff7000000257b-8b-60f9098fd051 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 08.6B.08289.11709F06; Thu, 22 Jul 2021 14:50:09 +0900 (KST) Received: from ayush.garg-20-10-15 (unknown [107.109.98.149]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20210722055008epsmtip16e6be481b399800959be0f4b7b4eb380~UBvOWkjlC1099710997epsmtip1d; Thu, 22 Jul 2021 05:50:08 +0000 (GMT) From: Ayush Garg To: linux-bluetooth@vger.kernel.org Cc: anupam.r@samsung.com, nitin.j@samsung.com Subject: [PATCH BlueZ 1/8] doc/device-api: Add Phy property Date: Thu, 22 Jul 2021 11:19:44 +0530 Message-Id: <20210722054951.8291-2-ayush.garg@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210722054951.8291-1-ayush.garg@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrMIsWRmVeSWpSXmKPExsWy7bCmhu4Ezp8JBu3TmSzurLa2mHOtj9li 27p2Zgdmj74tqxg9Pm+SC2CK4rJJSc3JLEst0rdL4MrovrmereAwR8X6A4eYGxi3sXUxcnJI CJhI3Fv+kL2LkYtDSGA3o8SJFTfZIJxPjBI7191jhnA+M0r0/G5kh2l5MfkYM4gtJLCLUeL1 ekO4jiWd/WAJNgFNidcfvzCB2CICyhLP9h0Gs5kFdCXOvF8HtltYwFpi/qc9YDaLgKrEiunL WUBsXgEriZ3XTzJCLJOXWL3hANhMTqD6A49ugt0qITCdXWL/mZVQRS4S7zatZ4GwhSVeHd8C damUxMv+NqiGZkaJHZs3Qjk9jBIPfnRDg8Be4lzTM9YuRg6g8zQl1u/ShwjLSkw9tQ7qaj6J 3t9PmCDivBI75sHYKhIbVnXCLft4bCEzhO0h0XHrEjQg+xglFu3bxzyBUW4WwooFjIyrGCVT C4pz01OLTQuM8lLL9YoTc4tL89L1kvNzNzGC41nLawfjwwcf9A4xMnEwHmKU4GBWEuFVKfqa IMSbklhZlVqUH19UmpNafIhRmoNFSZyXPR4oJZCeWJKanZpakFoEk2Xi4JRqYNrZmcivvWGl GWOrzqFfF9i+sH2rF8k16wlv4ojyuHcqMt/8hqWM6jtPvqAPGm8+PtUsn3fg6hYjsb6dPnOm 8Vn6zcvefGy3tMrGJRLregR4jebZTHSQ948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nx2u6Ai2ikxjWP04YYq/Qt6/q7W7fv6rXPflZpQSS3FGoqEWc1FxIgBcm/0ehQIAAA== X-CMS-MailID: 20210722055009epcas5p25e4997aa7e53cb2a6e3780fdb7301785 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P X-CMS-RootMailID: 20210722055009epcas5p25e4997aa7e53cb2a6e3780fdb7301785 References: <20210722054951.8291-1-ayush.garg@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This will allow to set the LE PHY preferences for a connected device. Reviewed-by: Anupam Roy --- doc/device-api.txt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/doc/device-api.txt b/doc/device-api.txt index 4e824d2de..d0e108f74 100644 --- a/doc/device-api.txt +++ b/doc/device-api.txt @@ -272,3 +272,25 @@ Properties string Address [readonly] Example: 0x26 0x01 0x01... + + array{string} Phy [readwrite, optional] + + PHY Preferences for a connected device. + + Note: The controller might not be able to make the + change because of reasons like peer not supporting + the requested PHY or it couldnot schedule due to + other activites. + + This is only available for LE capable controllers. + It will return Not Supported Otherwise. + + Possible values: + "LE1MTX" + "LE1MRX" + "LE2MTX" + "LE2MRX" + "LECODEDTX" + "LECODEDRX" + "LECODEDS2" + "LECODEDS8" From patchwork Thu Jul 22 05:49:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayush Garg X-Patchwork-Id: 484007 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2207C63793 for ; Thu, 22 Jul 2021 06:01:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 878716127C for ; Thu, 22 Jul 2021 06:01:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230371AbhGVFU3 (ORCPT ); Thu, 22 Jul 2021 01:20:29 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:19594 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230143AbhGVFU2 (ORCPT ); Thu, 22 Jul 2021 01:20:28 -0400 Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20210722060103epoutp02e393e7df816488f17375a565431903f5~UB4v8CWk41764317643epoutp02M for ; Thu, 22 Jul 2021 06:01:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20210722060103epoutp02e393e7df816488f17375a565431903f5~UB4v8CWk41764317643epoutp02M DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1626933663; bh=GgWyk2DnZQ4LcpuBfoNND2z6/+1ylic5BsNXwwY1Fqo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UXsV9xhslWgBtH2+FYaBklAQeaOtzzyZrXHhLOijCDuFFI8PpmpchRPO27S+jM/KD VgaXSEBZ+dtxm98cUoj9LL1NVyrHtdaA898PQd154uDFnnCkqf5AdxpVVVb1kbQlhG c7Blj/E5UutQmJfDGmK529RofA/rMkAZ1KhPhq2E= Received: from epsmges5p3new.samsung.com (unknown [182.195.42.75]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20210722060053epcas5p3e32e5f4f09d84d8875391a9df6aa82eb~UB4nVnA300434204342epcas5p3S; Thu, 22 Jul 2021 06:00:53 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id BC.7B.11627.59909F06; Thu, 22 Jul 2021 15:00:53 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20210722055012epcas5p1bb92b3e31233da03906c4f562b22b4fc~UBvSRZr6w1933919339epcas5p1q; Thu, 22 Jul 2021 05:50:12 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20210722055012epsmtrp135c35128e087c34e213c420cd6cf438d~UBvSQOwNJ3087030870epsmtrp1e; Thu, 22 Jul 2021 05:50:12 +0000 (GMT) X-AuditID: b6c32a4b-acdff70000022d6b-4c-60f90995b469 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id B3.14.08394.41709F06; Thu, 22 Jul 2021 14:50:12 +0900 (KST) Received: from ayush.garg-20-10-15 (unknown [107.109.98.149]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20210722055011epsmtip19d0dda9537b3b9bb20424af634788ccb~UBvRXX1Go1099710997epsmtip1h; Thu, 22 Jul 2021 05:50:11 +0000 (GMT) From: Ayush Garg To: linux-bluetooth@vger.kernel.org Cc: anupam.r@samsung.com, nitin.j@samsung.com Subject: [PATCH BlueZ 4/8] device: Add support for get/set PHY property Date: Thu, 22 Jul 2021 11:19:47 +0530 Message-Id: <20210722054951.8291-5-ayush.garg@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210722054951.8291-1-ayush.garg@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrIIsWRmVeSWpSXmKPExsWy7bCmlu5Uzp8JBv9bRSzurLa2mHOtj9li 27p2Zg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dL4MpoWdvAXtDjUvH8+Ur2BsY+8y5GTg4J AROJji1fmLsYuTiEBHYzSux9vAfI4QBKSEk8XqYDUSMssfLfc3aImg+MEndW72cBSbAJaEq8 /viFCcQWEVCWeLbvMJjNLKAv8fTCdUYQW1jAXWLKo8lsIDaLgKrEue7JYDW8AlYSq2ZcYIdY IC+xesMBZhCbU8Ba4sCjm2BxIaCae6+3ME9g5FvAyLCKUTK1oDg3PbfYsMAwL7Vcrzgxt7g0 L10vOT93EyM4WLQ0dzBuX/VB7xAjEwfjIUYJDmYlEV6Voq8JQrwpiZVVqUX58UWlOanFhxil OViUxHkvdJ2MFxJITyxJzU5NLUgtgskycXBKNTD1yMztmd4bIyHOF31yrv9/llVCb4WlUqf7 XNK9tXHPKvsLEWsf690/9q652IuH/Z72Hf7Nv9+EzsxelsS7UMfu9JE+XXdulxuvzkinOUYn 3X2aO3GNrW1bQ9Ln9l1FeX92Zx8OmbmtbpJznenDtqeqR6wKPVcuWvPP/qdvp1JSsbgzq/qG 3PxELfVqq6dLp8/f8f0uy9J3VzSqZwTMFOkP2sSwOf6KZIHZ77+rdRZ/2HpEX+LlqxelR5N5 rJiu35DOUn3rPqumRlr37xNB30PFuybsfcS9tDzgsvXzcL4/C86ui1ii3yog+jJVeH4Hq/9a mU9vjvNcuP93q8pSeRm2d1ouP8LsVN+Izzz251qzEktxRqKhFnNRcSIA3gHaVYUCAAA= X-CMS-MailID: 20210722055012epcas5p1bb92b3e31233da03906c4f562b22b4fc X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P X-CMS-RootMailID: 20210722055012epcas5p1bb92b3e31233da03906c4f562b22b4fc References: <20210722054951.8291-1-ayush.garg@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This change introduces a new device property which will enable user to get PHYs of the current LE Connection. It will also allow to set preferred PHYs for a particular LE connection. Reviewed-by: Anupam Roy --- lib/bluetooth.h | 9 ++ src/adapter.c | 8 ++ src/adapter.h | 1 + src/device.c | 220 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 238 insertions(+) diff --git a/lib/bluetooth.h b/lib/bluetooth.h index 9ab033ec4..a6afaa753 100644 --- a/lib/bluetooth.h +++ b/lib/bluetooth.h @@ -127,6 +127,15 @@ struct bt_voice { #define BT_PHY_LE_2M_RX 0x00001000 #define BT_PHY_LE_CODED_TX 0x00002000 #define BT_PHY_LE_CODED_RX 0x00004000 +#define BT_PHY_LE_CODED_S2 0x00008000 +#define BT_PHY_LE_CODED_S8 0x00010000 + +#define BT_PHY_LE_MASK (BT_PHY_LE_1M_TX | BT_PHY_LE_1M_RX | \ + BT_PHY_LE_2M_TX | BT_PHY_LE_2M_RX | \ + BT_PHY_LE_CODED_TX | BT_PHY_LE_CODED_RX) + +#define BT_PHY_LE_CODED_MASK (BT_PHY_LE_CODED_TX | \ + BT_PHY_LE_CODED_RX) #define BT_MODE 15 diff --git a/src/adapter.c b/src/adapter.c index 3861ade8a..5de92a570 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -6661,6 +6661,14 @@ const char *adapter_get_path(struct btd_adapter *adapter) return adapter->path; } +uint32_t adapter_get_supported_phys(struct btd_adapter *adapter) +{ + if (!adapter) + return 0; + + return adapter->supported_phys; +} + const bdaddr_t *btd_adapter_get_address(struct btd_adapter *adapter) { return &adapter->bdaddr; diff --git a/src/adapter.h b/src/adapter.h index 60b5e3bcc..21046ceaa 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -87,6 +87,7 @@ struct btd_device *btd_adapter_find_device_by_path(struct btd_adapter *adapter, const char *path); const char *adapter_get_path(struct btd_adapter *adapter); +uint32_t adapter_get_supported_phys(struct btd_adapter *adapter); const bdaddr_t *btd_adapter_get_address(struct btd_adapter *adapter); uint8_t btd_adapter_get_address_type(struct btd_adapter *adapter); const char *btd_adapter_get_storage_dir(struct btd_adapter *adapter); diff --git a/src/device.c b/src/device.c index b29aa195d..6f74989c7 100644 --- a/src/device.c +++ b/src/device.c @@ -272,6 +272,9 @@ struct btd_device { GIOChannel *att_io; guint store_id; + + uint32_t phys; + bool pending_phys; }; static const uint16_t uuid_list[] = { @@ -1470,6 +1473,212 @@ static gboolean dev_property_wake_allowed_exist( return device_get_wake_support(device); } +static struct phys_config { + uint32_t flag; + const char *name; +} phys_str[] = { + { BT_PHY_LE_1M_TX, "LE1MTX" }, + { BT_PHY_LE_1M_RX, "LE1MRX" }, + { BT_PHY_LE_2M_TX, "LE2MTX" }, + { BT_PHY_LE_2M_RX, "LE2MRX" }, + { BT_PHY_LE_CODED_TX, "LECODEDTX" }, + { BT_PHY_LE_CODED_RX, "LECODEDRX" }, + { BT_PHY_LE_CODED_S2, "LECODEDS2" }, + { BT_PHY_LE_CODED_S8, "LECODEDS8" } +}; + +static void append_phys_str(DBusMessageIter *array, uint32_t phys) +{ + unsigned int i; + + for (i = 0; i < NELEM(phys_str); i++) { + if (phys & phys_str[i].flag) + dbus_message_iter_append_basic(array, DBUS_TYPE_STRING, + &phys_str[i].name); + } +} + +static bool parse_phys_str(DBusMessageIter *array, uint32_t *phys) +{ + const char *str; + unsigned int i; + + *phys = 0; + + do { + if (dbus_message_iter_get_arg_type(array) != DBUS_TYPE_STRING) + return false; + + dbus_message_iter_get_basic(array, &str); + + for (i = 0; i < NELEM(phys_str); i++) { + if (!strcmp(str, phys_str[i].name)) { + *phys |= phys_str[i].flag; + break; + } + } + + if (i == NELEM(phys_str)) + return false; + } while (dbus_message_iter_next(array)); + + return true; +} + +static void device_set_phy(struct btd_device *device, uint32_t phys) +{ + if (!device) + return; + + DBG("Device PHYs %u", phys); + + device->phys = phys; + + g_dbus_emit_property_changed(dbus_conn, device->path, + DEVICE_INTERFACE, "Phy"); + +} + +static int set_preferred_phy(struct btd_device *device, uint32_t phys) +{ + GIOChannel *io; + GError *gerr = NULL; + uint32_t supported_phys = 0; + int ret; + + if (!device || !phys) { + error("Invalid arguments in method call"); + return -EINVAL; + } + + if (!device->le) { + error("Operation is not supported"); + return -ENOTSUP; + } + + if (!device->le_state.connected || !device->attrib) { + error("Device Not Connected"); + return -ENOTCONN; + } + + io = g_attrib_get_channel(device->attrib); + + if (!io) { + error("Device Not Connected"); + return -ENOTCONN; + } + + supported_phys = adapter_get_supported_phys(device->adapter) & + BT_PHY_LE_MASK; + + if (supported_phys & BT_PHY_LE_CODED_MASK) { + supported_phys |= BT_PHY_LE_CODED_S2; + supported_phys |= BT_PHY_LE_CODED_S8; + } + + if (phys & ~supported_phys) { + error("Supplied phy(s) are not supported"); + return -EINVAL; + } + + if (device->pending_phys) { + error("Operation already in progress"); + return -EINPROGRESS; + } + + device->pending_phys = true; + + if (device->phys == phys) { + device->pending_phys = false; + return 0; + } + + bt_io_set(io, &gerr, BT_IO_OPT_PHY, phys, BT_IO_OPT_INVALID); + + if (gerr) { + error("bt_io_set: %s", gerr->message); + device->pending_phys = false; + ret = gerr->code; + g_error_free(gerr); + return ret; + } + + return 0; +} + +static gboolean dev_property_get_phy(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct btd_device *device = data; + DBusMessageIter array; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, "s", &array); + + append_phys_str(&array, device->phys); + + dbus_message_iter_close_container(iter, &array); + + return TRUE; +} + +static void dev_property_set_phy(const GDBusPropertyTable *property, + DBusMessageIter *value, + GDBusPendingPropertySet id, void *data) +{ + struct btd_device *device = data; + DBusMessageIter array; + uint32_t phys; + int ret; + + if (dbus_message_iter_get_arg_type(value) != DBUS_TYPE_ARRAY) { + ret = -EINVAL; + goto failed; + } + + dbus_message_iter_recurse(value, &array); + + if (!parse_phys_str(&array, &phys)) { + ret = -EINVAL; + goto failed; + } + + ret = set_preferred_phy(device, phys); + + if (ret >= 0) { + g_dbus_pending_property_success(id); + return; + } + +failed: + switch (-ret) { + case EINVAL: + g_dbus_pending_property_error(id, + ERROR_INTERFACE ".InvalidArguments", + "Invalid arguments in method call"); + break; + case ENOTSUP: + g_dbus_pending_property_error(id, + ERROR_INTERFACE ".NotSupported", + "Operation is not supported"); + break; + case ENOTCONN: + g_dbus_pending_property_error(id, + ERROR_INTERFACE ".NotConnected", + "Device Not Connected"); + break; + case EINPROGRESS: + g_dbus_pending_property_error(id, + ERROR_INTERFACE ".InProgress", + "Operation already in progress"); + break; + default: + g_dbus_pending_property_error(id, ERROR_INTERFACE ".Failed", + strerror(-ret)); + break; + } + +} + static bool disconnect_all(gpointer user_data) { struct btd_device *device = user_data; @@ -2950,6 +3159,7 @@ static const GDBusPropertyTable device_properties[] = { { "WakeAllowed", "b", dev_property_get_wake_allowed, dev_property_set_wake_allowed, dev_property_wake_allowed_exist }, + { "Phy", "as", dev_property_get_phy, dev_property_set_phy }, { } }; @@ -3017,6 +3227,12 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) state->connected = false; device->general_connect = FALSE; + /* Reset PHYs if LE connection is disconnected */ + if (bdaddr_type != BDADDR_BREDR) { + device->pending_phys = false; + device_set_phy(device, 0); + } + device_set_svc_refreshed(device, false); if (device->disconn_timer > 0) { @@ -5305,10 +5521,12 @@ bool device_attach_att(struct btd_device *dev, GIOChannel *io) struct btd_gatt_database *database; const bdaddr_t *dst; char dstaddr[18]; + uint32_t phys; bt_io_get(io, &gerr, BT_IO_OPT_SEC_LEVEL, &sec_level, BT_IO_OPT_IMTU, &mtu, BT_IO_OPT_CID, &cid, + BT_IO_OPT_PHY, &phys, BT_IO_OPT_INVALID); if (gerr) { @@ -5358,6 +5576,8 @@ bool device_attach_att(struct btd_device *dev, GIOChannel *io) dev->attrib = attrib; dev->att = g_attrib_get_att(attrib); + device_set_phy(dev, phys); + bt_att_ref(dev->att); bt_att_set_debug(dev->att, BT_ATT_DEBUG, gatt_debug, NULL, NULL); From patchwork Thu Jul 22 05:49:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayush Garg X-Patchwork-Id: 484006 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1439AC6377D for ; Thu, 22 Jul 2021 06:01:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EE17961283 for ; Thu, 22 Jul 2021 06:01:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230402AbhGVFUk (ORCPT ); Thu, 22 Jul 2021 01:20:40 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:41977 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229994AbhGVFUi (ORCPT ); Thu, 22 Jul 2021 01:20:38 -0400 Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20210722060110epoutp0314506dee29e79bcb56a87f8b8c5613fe~UB42v7wcZ1006110061epoutp03y for ; Thu, 22 Jul 2021 06:01:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20210722060110epoutp0314506dee29e79bcb56a87f8b8c5613fe~UB42v7wcZ1006110061epoutp03y DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1626933670; bh=vZJ5YsLRm+TaNStqvt11eEi1/zcqwQc1xxbOq52U9+8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QfheJMdME89Eg3BOe0CYwXue2BgqpxcICjGcr1gV4AWsQxtsO0v6WrnvTajWlS6YZ U2MSfmm+U7YLUM/jNKQLUA9erI6kfU1x3GcRHSoms3yz2ughTlBv8IMODVh94BvRwP 102E9Vs0r5zqxToAFh8aJ0mvNWQeSwadPiCqfbLY= Received: from epsmges5p2new.samsung.com (unknown [182.195.42.74]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20210722060108epcas5p207518e1eb91d02a89dedfee61ccf463c~UB40eoSgS0861908619epcas5p2l; Thu, 22 Jul 2021 06:01:08 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 4D.1B.09595.2A909F06; Thu, 22 Jul 2021 15:01:06 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20210722055016epcas5p267b70f0da3b5c1991d29ca47d685ab6d~UBvVeUvLe0519705197epcas5p2c; Thu, 22 Jul 2021 05:50:16 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20210722055016epsmtrp1d68eb3d80bba2ae437539030db7fe39b~UBvVdAcGv3119631196epsmtrp11; Thu, 22 Jul 2021 05:50:16 +0000 (GMT) X-AuditID: b6c32a4a-eebff7000000257b-de-60f909a2980e Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 62.7B.08289.81709F06; Thu, 22 Jul 2021 14:50:16 +0900 (KST) Received: from ayush.garg-20-10-15 (unknown [107.109.98.149]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20210722055015epsmtip1de5ecd70dbb90deed93f8dcfe63ee946~UBvUlmjzS1278412784epsmtip1B; Thu, 22 Jul 2021 05:50:15 +0000 (GMT) From: Ayush Garg To: linux-bluetooth@vger.kernel.org Cc: anupam.r@samsung.com, nitin.j@samsung.com Subject: [PATCH BlueZ 7/8] device: Save device PHY in storage and read it at init Date: Thu, 22 Jul 2021 11:19:50 +0530 Message-Id: <20210722054951.8291-8-ayush.garg@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210722054951.8291-1-ayush.garg@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrEIsWRmVeSWpSXmKPExsWy7bCmlu4izp8JBp0XLS3urLa2mHOtj9li 27p2Zgdmj74tqxg9Pm+SC2CK4rJJSc3JLEst0rdL4Mq4cPgna8Fxvoo7jXuZGxjvcHcxcnJI CJhIPH59m7GLkYtDSGA3o8Sy98dYIZxPjBJLu6ayg1QJCXxmlJj+wLeLkQOsY+9iNoiaXYwS O1asYodreLB5PgtIA5uApsTrj1+YQGwRAWWJZ/sOg9nMAroSZ96vYwOxhQWCJU7+ncIIYrMI qEps+3ECLM4rYCXR0PGRFeI8eYnVGw4wg9icAtYSBx7dBFsmITCZXeLJ2t9MEEUuEg2XGxgh bGGJV8e3sEPYUhIv+9ugGpqBTt28EcrpATr1RzcbRJW9xLmmZ6wgvzEDnb1+lz5EWFZi6ql1 UFfzSfT+fgK1jFdixzwYW0Viw6pOuGUfjy1khrA9JNobrkDDsY9R4tGnbpYJjHKzEFYsYGRc xSiZWlCcm55abFpglJdarlecmFtcmpeul5yfu4kRHM1aXjsYHz74oHeIkYmD8RCjBAezkgiv StHXBCHelMTKqtSi/Pii0pzU4kOM0hwsSuK87PFAKYH0xJLU7NTUgtQimCwTB6dUA9Nm2YzQ ph3nOgOTl8oE5XrGd8z/3rNr/uq3PDyLzItfGx+fnNj6P+6w5dvPDpXcsodUUxTOH9r+Z0v+ m8UCM1TvvVp6XJbR2uBxMMeMovq8/XuW98vuL9fOeJn5ILpew51x3s79G8/6nb+TkZptHv1l x29GE7bo/8HM049nvTJXt5I06nE3zeKSWG0avtP/9R+Ryz3PDG5rvm/tDvsVciLUsudY2fpo q5fVTa8vxa5stSqOTxZt+qN8SehK28vyNIdcmbtPJi6bHujGmb/4Z7ie+MPVsxjD568//yGy WVi++6D9+lk3mjYwzU2OXeHG55Xs2rs4RjvCJqGpe/exQofTV91MHvb0qr2zCO3ep8RSnJFo qMVcVJwIACc7Z7dVAwAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrIJMWRmVeSWpSXmKPExsWy7bCSnK4E+88Egx9XuS3urLa2mHOtj9li 27p2Zgdmj74tqxg9Pm+SC2CK4rJJSc3JLEst0rdL4Mq4cPgna8Fxvoo7jXuZGxjvcHcxcnBI CJhI7F3M1sXIxSEksINRYtnDD2wQcSmJx8t0uhg5gUxhiZX/nrND1HxglNi35TUTSIJNQFPi 9ccvYLaIgLLEs32HwWxmAX2JpxeuM4LYwgKBEpvXHQGLswioSmz7cYINxOYVsJJo6PjICrFA XmL1hgPMIDangLXEgUc32UFsIaCae6+3ME9g5FvAyLCKUTK1oDg3PbfYsMAoL7Vcrzgxt7g0 L10vOT93EyM4VLS0djDuWfVB7xAjEwfjIUYJDmYlEV6Voq8JQrwpiZVVqUX58UWlOanFhxil OViUxHkvdJ2MFxJITyxJzU5NLUgtgskycXBKNTApBk00evzk91MbW77vx3YZblr4c+aGgKOH ts5e4u321b9jpeFV7sIlEkuO3zo9o//PFZXUMyfkraTZHh0J/R2y5vSHHzZ1DYZ2B65Jyc+y 2xHmaLniznGzbNn6/QE7b0+65rXK2dvpSo3QhCkWpm0vNVxeLOQUSvu59EqDS7JK8LP6tSwz 9+urKn7q3vKnI9GfOS+xY90x/axzh07us35SXXt68pvVx89nvPqSc9hCJeppdltfatKFJxHS xzzqorK4+8++iDK7b3H8kcal12lM9+r+/WpmvxiuyLhy8bGbS+4cF/L+7vpqIedhhgUuPQVn bvFGfeJa+1zQQufE6qiXZ/j4pi6Nj+qZe7jm/CzZ50osxRmJhlrMRcWJAILGE/CEAgAA X-CMS-MailID: 20210722055016epcas5p267b70f0da3b5c1991d29ca47d685ab6d X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P X-CMS-RootMailID: 20210722055016epcas5p267b70f0da3b5c1991d29ca47d685ab6d References: <20210722054951.8291-1-ayush.garg@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This change will save the current LE connection PHY in the storage when LE PHY Updated Event is received. It will also load and set the last stored LE PHY when that device is re-connected. Reviewed-by: Anupam Roy --- src/device.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/device.c b/src/device.c index 4b11772b8..b708fc822 100644 --- a/src/device.c +++ b/src/device.c @@ -275,6 +275,7 @@ struct btd_device { uint32_t phys; bool pending_phys; + uint32_t stored_phys; }; static const uint16_t uuid_list[] = { @@ -448,6 +449,12 @@ static gboolean store_device_info_cb(gpointer user_data) g_key_file_remove_key(key_file, "General", "Services", NULL); } + if (device->stored_phys) + g_key_file_set_integer(key_file, "General", "Phy", + device->stored_phys); + else + g_key_file_remove_key(key_file, "General", "Phy", NULL); + if (device->vendor_src) { g_key_file_set_integer(key_file, "DeviceID", "Source", device->vendor_src); @@ -3576,6 +3583,14 @@ next: gerr = NULL; } + /* Get PHY */ + device->stored_phys = g_key_file_get_integer(key_file, + "General", "Phy", &gerr); + if (gerr) { + g_error_free(gerr); + gerr = NULL; + } + if (store_needed) store_device_info(device); } @@ -5578,6 +5593,9 @@ bool device_attach_att(struct btd_device *dev, GIOChannel *io) device_set_phy(dev, phys); + if (dev->stored_phys) + set_preferred_phy(dev, dev->stored_phys); + bt_att_ref(dev->att); bt_att_set_debug(dev->att, BT_ATT_DEBUG, gatt_debug, NULL, NULL); @@ -5688,6 +5706,9 @@ void device_le_phy_updated(struct btd_device *dev, uint32_t phy) { dev->pending_phys = false; + dev->stored_phys = phy; + store_device_info(dev); + device_set_phy(dev, phy); } From patchwork Thu Jul 22 05:49:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayush Garg X-Patchwork-Id: 484005 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7AA8C63797 for ; Thu, 22 Jul 2021 06:01:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C520861283 for ; Thu, 22 Jul 2021 06:01:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230418AbhGVFUl (ORCPT ); Thu, 22 Jul 2021 01:20:41 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:19892 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230437AbhGVFUj (ORCPT ); Thu, 22 Jul 2021 01:20:39 -0400 Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20210722060114epoutp02317fdbed6fd289a92af616a85635f2b4~UB46Pe8_i1764317643epoutp02T for ; Thu, 22 Jul 2021 06:01:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20210722060114epoutp02317fdbed6fd289a92af616a85635f2b4~UB46Pe8_i1764317643epoutp02T DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1626933674; bh=SAwXS1k1o4yo5Auivr4AhoDjySgx+LKBBteqHFADDks=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QpXj7ozycHsJhwjD2qLWkYFxlnQsc2ac+mDld4jbPFqB1nNsaIzRUQjYUZ+Zrt+VJ WFIrkADo9Se4CxlYzXZZGJtsOdbZdW9iS1buygpuVslMb/JpK61rfkuGqv/aurhBEj Nkoy89VXsCRtfeuym5STlh+5QqF82KJ+wpAFrm3c= Received: from epsmges5p1new.samsung.com (unknown [182.195.42.73]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20210722060113epcas5p21054d9e9332a933e3c46fa4d2bf43cb6~UB45TZ7kI0861508615epcas5p20; Thu, 22 Jul 2021 06:01:13 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 2D.33.55882.8A909F06; Thu, 22 Jul 2021 15:01:12 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20210722055017epcas5p4da91b311c34a5fb869148b369338ed07~UBvWmN6NT2536725367epcas5p4S; Thu, 22 Jul 2021 05:50:17 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20210722055017epsmtrp10a46a9e16cd5e37f85eb9d3904f6ceba~UBvWk--v63119631196epsmtrp16; Thu, 22 Jul 2021 05:50:17 +0000 (GMT) X-AuditID: b6c32a49-f4fff7000001da4a-41-60f909a8d3aa Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 68.14.08394.91709F06; Thu, 22 Jul 2021 14:50:17 +0900 (KST) Received: from ayush.garg-20-10-15 (unknown [107.109.98.149]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20210722055016epsmtip13f66d616a4cb9a62b862955bf6e75a91~UBvVoxwtG1278812788epsmtip1C; Thu, 22 Jul 2021 05:50:16 +0000 (GMT) From: Ayush Garg To: linux-bluetooth@vger.kernel.org Cc: anupam.r@samsung.com, nitin.j@samsung.com Subject: [PATCH BlueZ 8/8] monitor: Add support for LE PHY Update event Date: Thu, 22 Jul 2021 11:19:51 +0530 Message-Id: <20210722054951.8291-9-ayush.garg@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210722054951.8291-1-ayush.garg@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrEIsWRmVeSWpSXmKPExsWy7bCmlu4Kzp8JBvPmmFvcWW1tMedaH7PF tnXtzA7MHn1bVjF6fN4kF8AUxWWTkpqTWZZapG+XwJWxa+E61oJrPBX/Ppo2MM7h6mLk5JAQ MJHYsWsdUxcjF4eQwG5GiVNNN6GcT4wS87e8YINwvjFKNNxcxQLT8v77SVYQW0hgL6PErCdp cB1HX14AS7AJaEq8/viFCcQWEVCWeLbvMJjNLKArceb9OjYQW1jAXeL5xPdg9SwCqhKfjk4A W8ArYCVx9u0DZohl8hKrNxwAszkFrCUOPLrJDrJMQmAyu8SBT/fYIYpcJGZOmg1lC0u8Or4F ypaSeNnfBtXQzCixY/NGKKeHUeLBj242iCp7iXNNz4DO4AA6T1Ni/S59iLCsxNRT66Cu5pPo /f2ECSLOK7FjHoytIrFhVSfcso/HFkJd7SHxZ+FxaED2MUpMev+WeQKj3CyEFQsYGVcxSqYW FOempxabFhjmpZbrFSfmFpfmpesl5+duYgRHs5bnDsa7Dz7oHWJk4mA8xCjBwawkwqtS9DVB iDclsbIqtSg/vqg0J7X4EKM0B4uSOC97PFBKID2xJDU7NbUgtQgmy8TBKdXA5JZ4Q+e+lpLr p+46k2bXhpM7ikK45F04qn9PPHo8ffve3r2lM81tP16cseDo8+nsDdq8F9lbQiekLN28b+v2 ORkdcjVX56sFPr7kuaBnxTTRx4nG5zZOXtf/Ipxx3R2vOy6vW1qrHoVz5M19XubMXZpa1TN/ dlx2drbCnFeS5gsZ3pY//vDaNzfuYLrWWcPCBbPDOw5xu5xkE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91b311c34a5fb869148b369338ed07 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P X-CMS-RootMailID: 20210722055017epcas5p4da91b311c34a5fb869148b369338ed07 References: <20210722054951.8291-1-ayush.garg@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Verification logs: ========================================= > HCI Event: LE Meta Event (0x3e) plen 6 LE PHY Update Complete (0x0c) Status: Success (0x00) Handle: 0 TX PHY: LE 2M (0x02) RX PHY: LE 2M (0x02) @ MGMT Event: LE PHY Update Complete (0x002f) plen 12 LE Address: 45:18:F8:CF:23:7E (Resolvable) Status: Success (0x00) Updated PHYs: 0x1800 LE 2M TX LE 2M RX Reviewed-by: Anupam Roy --- monitor/packet.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/monitor/packet.c b/monitor/packet.c index 52d22ab21..eaa3070de 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -14304,6 +14304,18 @@ static void mgmt_controller_resume_evt(const void *data, uint16_t size) mgmt_print_address(data, addr_type); } +static void mgmt_le_phy_update_complete_evt(const void *data, + uint16_t size) +{ + uint8_t address_type = get_u8(data + 6); + uint8_t status = get_u8(data + 7); + uint32_t selected_phys = get_le32(data + 8); + + mgmt_print_address(data, address_type); + mgmt_print_status(status); + mgmt_print_phys("Updated PHYs", selected_phys); +} + static const struct mgmt_data mgmt_event_table[] = { { 0x0001, "Command Complete", mgmt_command_complete_evt, 3, false }, @@ -14393,6 +14405,8 @@ static const struct mgmt_data mgmt_event_table[] = { mgmt_controller_suspend_evt, 1, true }, { 0x002e, "Controller Resumed", mgmt_controller_resume_evt, 8, true }, + { 0x002f, "LE PHY Update Complete", + mgmt_le_phy_update_complete_evt, 12, true }, { } };