From patchwork Thu Jul 22 05:26:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayush Garg X-Patchwork-Id: 484015 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 860D2C6377D for ; Thu, 22 Jul 2021 05:59:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6446060FE7 for ; Thu, 22 Jul 2021 05:59:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229931AbhGVFSu (ORCPT ); Thu, 22 Jul 2021 01:18:50 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:43673 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229636AbhGVFSt (ORCPT ); Thu, 22 Jul 2021 01:18:49 -0400 Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20210722055923epoutp044cab1af8c2eafd042de7ce12bbc73c11~UB3TZ8BIS0449404494epoutp04d for ; Thu, 22 Jul 2021 05:59:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20210722055923epoutp044cab1af8c2eafd042de7ce12bbc73c11~UB3TZ8BIS0449404494epoutp04d DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1626933563; bh=z8qo1DRvdeaa9Y6VJE/6/pYv3iElbhwzP1M8LlRop5Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JIIm7eNRR6rp3qEyQ77Mgy7Swf3rggpGcsVKFyfv18kqPwhnBJLxfwCsvLkHTps87 Sy+ZgFcSb8H1QWtlTKuRwVXHVgSELokXsJSuMmJzyVAThrOBr6mvHXjIEQIuReRA6X aa2vlcqIxVlcxCwVTtiQBlwxct+/EglireEzVp8c= Received: from epsmges5p3new.samsung.com (unknown [182.195.42.75]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20210722055923epcas5p2253770474b588230c66cb64c39aaac94~UB3S2YfBt0624106241epcas5p2E; Thu, 22 Jul 2021 05:59:23 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id F8.CA.11627.A3909F06; Thu, 22 Jul 2021 14:59:22 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20210722052738epcas5p3b6074e49f088159e8282bba3457d56ba~UBblEuFkt1662316623epcas5p3p; Thu, 22 Jul 2021 05:27:38 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20210722052738epsmtrp2f8c86706eabc85674b610cb46bc3f80f~UBblD0ur40040400404epsmtrp2e; Thu, 22 Jul 2021 05:27:38 +0000 (GMT) X-AuditID: b6c32a4b-04849a8000022d6b-9b-60f9093add3d Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 24.F8.08289.AC109F06; Thu, 22 Jul 2021 14:27:38 +0900 (KST) Received: from ayush.garg-20-10-15 (unknown [107.109.98.149]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20210722052737epsmtip2a08f797289b9e422c437643e15a776ae~UBbkUBwF-0848408484epsmtip2K; Thu, 22 Jul 2021 05:27:37 +0000 (GMT) From: Ayush Garg To: linux-bluetooth@vger.kernel.org Cc: anupam.r@samsung.com, nitin.j@samsung.com Subject: [PATCH BlueZ 1/7] doc/adapter-api: Add SupportedPhyConfiguration property Date: Thu, 22 Jul 2021 10:56:34 +0530 Message-Id: <20210722052640.5863-2-ayush.garg@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210722052640.5863-1-ayush.garg@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrEIsWRmVeSWpSXmKPExsWy7bCmlq4V588Eg45zZhZ3VltbzLnWx2yx bV07swOzR9+WVYwenzfJBTBFcdmkpOZklqUW6dslcGUsWnWGveAYe8WrPVsZGxifsHYxcnJI CJhI/Djwk6WLkYtDSGA3o8TtSSsZIZxPjBIv7z5nhnA+M0q0nVrMDtOycNEuNojELkaJv6vu sMG1bFl4lhGkik1AU+L1xy9MILaIgLLEs32HwWxmAV2JM+/XsYHYwgIhEnvbpgNN5eBgEVCV uHLfASTMK2Al0T3tHSPEMnmJ1RsOMIPYnALWEjN634BdJCEwnV2i7eA6JogiF4kfx1uhGoQl Xh3fAnWplMTnd3vZIBqaGSV2bN7IDuH0MEo8+NHNBlFlL3Gu6RkryBXMQFev36UPEZaVmHpq HdTRfBK9v59ALeOV2DEPxlaR2LCqE27Zx2MLmUHGSAh4SKw+GQ8JlD5GiZaHZ5knMMrNQtiw gJFxFaNkakFxbnpqsWmBcV5quV5xYm5xaV66XnJ+7iZGcDRree9gfPTgg94hRiYOxkOMEhzM SiK8KkVfE4R4UxIrq1KL8uOLSnNSiw8xSnOwKInzsscDpQTSE0tSs1NTC1KLYLJMHJxSDUxh D3xfOoQfVGO+KvXirsapmtyrbhcfJfLfuiEU+FLkR3rT47UF2X9rneu7XsSUB+2Qy2IO9L6/ d/6C8rbm91u5Ys7sinn5rCV8tU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XXJx4C1Ond9JL8tLdoTeidx8+FMsXk5h4W3 n2OZzz9DePvv7/pSSy3nLc9c99dHLXu9zeVzZ2x7JyqxFGckGmoxFxUnAgBD6RA7hAIAAA== X-CMS-MailID: 20210722052738epcas5p3b6074e49f088159e8282bba3457d56ba X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P X-CMS-RootMailID: 20210722052738epcas5p3b6074e49f088159e8282bba3457d56ba References: <20210722052640.5863-1-ayush.garg@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This change add a new property to retrieve the PHYs supported by the controller. Reviewed-by: Anupam Roy --- doc/adapter-api.txt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt index 464434a81..25e370d75 100644 --- a/doc/adapter-api.txt +++ b/doc/adapter-api.txt @@ -335,3 +335,24 @@ Properties string Address [readonly] "peripheral": Supports the peripheral role. "central-peripheral": Supports both roles concurrently. + + array{string} SupportedPhyConfiguration [readonly] + + List of PHYs supported by the controller. + + Possible values: + "BR1M1SLOT" + "BR1M3SLOT" + "BR1M5SLOT" + "EDR2M1SLOT" + "EDR2M3SLOT" + "EDR2M5SLOT" + "EDR3M1SLOT" + "EDR3M3SLOT" + "EDR3M5SLOT" + "LE1MTX" + "LE1MRX" + "LE2MTX" + "LE2MRX" + "LECODEDTX" + "LECODEDRX" From patchwork Thu Jul 22 05:26:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayush Garg X-Patchwork-Id: 484014 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 88ABCC6377D for ; Thu, 22 Jul 2021 05:59:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 648AB60FE7 for ; Thu, 22 Jul 2021 05:59:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229994AbhGVFS5 (ORCPT ); Thu, 22 Jul 2021 01:18:57 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:43777 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229955AbhGVFS4 (ORCPT ); Thu, 22 Jul 2021 01:18:56 -0400 Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20210722055931epoutp047ed3cba0a902c1885ef076da4a8c0984~UB3aUun000482404824epoutp04N for ; Thu, 22 Jul 2021 05:59:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20210722055931epoutp047ed3cba0a902c1885ef076da4a8c0984~UB3aUun000482404824epoutp04N DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1626933571; bh=8U5CBh6ZNg6S2y27qfyL25GAfE4R9EU8YGFjHonZbrQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h97EPTXfWfCZwE3ChVPmtjAlAH0oflNajmoVaMMAHK4RBvUdR9cquHj6OOQsklX5D O4t+LxaSXDyoTXKd5jiUZ2na/WWtfJBSrWOLejzEwig6LDjaMvj8tQM0WCNWdOOeV3 KzRlFVqEBz0SmhpeVWMBW11d/kDrHglTKjwmtIjM= Received: from epsmges5p1new.samsung.com (unknown [182.195.42.73]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20210722055930epcas5p45f14bdd66e56954538f130bd26ee512c~UB3ZxZAXR1890418904epcas5p4K; Thu, 22 Jul 2021 05:59:30 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 8A.72.55882.24909F06; Thu, 22 Jul 2021 14:59:30 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20210722052740epcas5p1fce869a24434f376d111e9e5d4b208eb~UBbnAK4ky2035920359epcas5p1I; Thu, 22 Jul 2021 05:27:40 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20210722052740epsmtrp20b4173b2eb91d40fc903a3c7c1f2d0ef~UBbm-coZU0094500945epsmtrp2B; Thu, 22 Jul 2021 05:27:40 +0000 (GMT) X-AuditID: b6c32a49-f65ff7000001da4a-63-60f909427cca Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 35.F8.08289.BC109F06; Thu, 22 Jul 2021 14:27:39 +0900 (KST) Received: from ayush.garg-20-10-15 (unknown [107.109.98.149]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20210722052739epsmtip23067e73199277b3a5ef702f5ed841b40~UBbmIIm000694006940epsmtip2U; Thu, 22 Jul 2021 05:27:39 +0000 (GMT) From: Ayush Garg To: linux-bluetooth@vger.kernel.org Cc: anupam.r@samsung.com, nitin.j@samsung.com Subject: [PATCH BlueZ 3/7] adapter: Add support for get/set phy configuration property Date: Thu, 22 Jul 2021 10:56:36 +0530 Message-Id: <20210722052640.5863-4-ayush.garg@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210722052640.5863-1-ayush.garg@samsung.com>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SWpSXmKPExsWy7bCSvO4Zxp8JBt1RFndWW1vMudbHbLFt XTuzA7NH35ZVjB6fN8kFMEVx2aSk5mSWpRbp2yVwZdxd+ICt4I5nxcn3i9gbGA/adDFyckgI mEjM/dHG1sXIxSEksINR4kznMsYuRg6ghJTE42U6EDXCEiv/PWeHqPnAKPHgdis7SIJNQFPi 9ccvTCC2iICyxLN9h8FsZgF9iacXrjOC2MICYRJN146BxVkEVCW+vrgE1ssrYCVx+tYrZogF 8hKrNxwAszkFrCVm9L4Bs4WAapZ+2cs2gZFvASPDKkbJ1ILi3PTcYsMCo7zUcr3ixNzi0rx0 veT83E2M4FDR0trBuGfVB71DjEwcjIcYJTiYlUR4VYq+JgjxpiRWVqUW5ccXleakFh9ilOZg URLnvdB1Ml5IID2xJDU7NbUgtQgmy8TBKdXAdIzhyqn4I6sVfFX4dGJaZ26LVmAuvPbjrLSx x/Vy1eK/TDIbJbdqXDsrV1qYskz3xYTdifzuu7geTL/TPLUmn7Mg1jU9vCXzPM+cI1Gy21XX tGSvfnBgb5PcrodnXKaIPzCoP8q470jDXWuuTMd5zyZy6uw3vx/Rs+X1i+3LPb9XnJ6mvJ7d o2HhvY/Xlu+INrhr9tJuSp5FwqWcRV0fPcpVTO+Vdjj9Op9661Sx8u5nCdMmnTL8lbR9n6uI Sp7rdIMlNxh52O1PMD4JWtXIWCUZHSHyv43RcRdvJ3vDxdAPdRNDVVLXvWCd0vlkst5Uhud7 vder/mNYGrVpr1OY2Zew850nfaZeaKh9qO7hq8RSnJFoqMVcVJwIANLDrw2EAgAA X-CMS-MailID: 20210722052740epcas5p1fce869a24434f376d111e9e5d4b208eb X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P X-CMS-RootMailID: 20210722052740epcas5p1fce869a24434f376d111e9e5d4b208eb References: <20210722052640.5863-1-ayush.garg@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This change introduces a new adapter property(PhyConfiguration) which will be used to read and set controller's PHY. This property is based upon MGMT_OP_GET_PHY_CONFIGURATION and MGMT_OP_SET_PHY_CONFIGURATION operations. Reviewed-by: Anupam Roy --- src/adapter.c | 282 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 282 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index 12e4ff5c0..fd4c654dc 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -285,6 +285,11 @@ struct btd_adapter { bool le_simult_roles_supported; bool quality_report_supported; + + uint32_t supported_phys; + uint32_t configurable_phys; + uint32_t selected_phys; + uint32_t pending_phys; }; typedef enum { @@ -3245,6 +3250,237 @@ static gboolean property_get_roles(const GDBusPropertyTable *property, return TRUE; } +static struct phys_config { + uint32_t flag; + const char *name; +} phys_str[] = { + { MGMT_PHY_BR_1M_1SLOT, "BR1M1SLOT" }, + { MGMT_PHY_BR_1M_3SLOT, "BR1M3SLOT" }, + { MGMT_PHY_BR_1M_5SLOT, "BR1M5SLOT" }, + { MGMT_PHY_EDR_2M_1SLOT, "EDR2M1SLOT" }, + { MGMT_PHY_EDR_2M_3SLOT, "EDR2M3SLOT" }, + { MGMT_PHY_EDR_2M_5SLOT, "EDR2M5SLOT" }, + { MGMT_PHY_EDR_3M_1SLOT, "EDR3M1SLOT" }, + { MGMT_PHY_EDR_3M_3SLOT, "EDR3M3SLOT" }, + { MGMT_PHY_EDR_3M_5SLOT, "EDR3M5SLOT" }, + { MGMT_PHY_LE_1M_TX, "LE1MTX" }, + { MGMT_PHY_LE_1M_RX, "LE1MRX" }, + { MGMT_PHY_LE_2M_TX, "LE2MTX" }, + { MGMT_PHY_LE_2M_RX, "LE2MRX" }, + { MGMT_PHY_LE_CODED_TX, "LECODEDTX" }, + { MGMT_PHY_LE_CODED_RX, "LECODEDRX" } +}; + +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 set_default_phy_complete(uint8_t status, uint16_t length, + const void *param, void *user_data) +{ + struct property_set_data *data = user_data; + struct btd_adapter *adapter = data->adapter; + + if (status != MGMT_STATUS_SUCCESS) { + adapter->pending_phys = 0; + btd_error(adapter->dev_id, + "Failed to set PHY configuration: %s (0x%02x)", + mgmt_errstr(status), status); + g_dbus_pending_property_error(data->id, ERROR_INTERFACE ".Failed", + mgmt_errstr(status)); + return; + } + + /* The default phys are successfully set. */ + btd_info(adapter->dev_id, "PHY configuration successfully set"); + + adapter->selected_phys = adapter->pending_phys; + adapter->pending_phys = 0; + + g_dbus_pending_property_success(data->id); + + g_dbus_emit_property_changed(dbus_conn, adapter->path, + ADAPTER_INTERFACE, "PhyConfiguration"); +} + +static int set_default_phy(struct btd_adapter *adapter, uint32_t phys, + GDBusPendingPropertySet id) +{ + struct mgmt_cp_set_phy_confguration cp; + struct property_set_data *data; + uint32_t unconfigure_phys; + + if (!phys) { + btd_error(adapter->dev_id, + "Set PHY configuration failed: No supplied phy(s)"); + return -EINVAL; + } + + if (phys & ~(adapter->supported_phys)) { + btd_error(adapter->dev_id, + "Set PHY configuration failed: supplied phy(s) is not supported"); + return -EINVAL; + } + + if (phys == adapter->selected_phys) { + DBG("PHYs are already set [0x%x]", phys); + g_dbus_pending_property_success(id); + return 0; + } + + unconfigure_phys = adapter->supported_phys & ~(adapter->configurable_phys); + + if ((phys & unconfigure_phys) != unconfigure_phys) { + btd_error(adapter->dev_id, + "Set PHY configuration failed: supplied phy(s) must include PHYs %u", + unconfigure_phys); + return -EINVAL; + } + + if (adapter->pending_phys) { + btd_error(adapter->dev_id, + "Set PHY configuration failed: Operation in progress"); + return -EINPROGRESS; + } + + adapter->pending_phys = phys; + + cp.selected_phys = cpu_to_le32(phys); + + data = g_try_new0(struct property_set_data, 1); + if (!data) + goto failed; + + data->adapter = adapter; + data->id = id; + + DBG("sending set phy configuration command for index %u", adapter->dev_id); + + if (mgmt_send(adapter->mgmt, MGMT_OP_SET_PHY_CONFIGURATION, + adapter->dev_id, sizeof(cp), &cp, + set_default_phy_complete, data, g_free) > 0) + return 0; + + g_free(data); + +failed: + btd_error(adapter->dev_id, "Failed to set PHY configuration for index %u", + adapter->dev_id); + adapter->pending_phys = 0; + + return -EIO; +} + +static gboolean property_get_phy_configuration( + const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct btd_adapter *adapter = user_data; + DBusMessageIter array; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, "s", &array); + + append_phys_str(&array, adapter->selected_phys); + + dbus_message_iter_close_container(iter, &array); + + return TRUE; +} + +static void property_set_phy_configuration( + const GDBusPropertyTable *property, + DBusMessageIter *iter, + GDBusPendingPropertySet id, void *user_data) +{ + struct btd_adapter *adapter = user_data; + DBusMessageIter array; + uint32_t phys; + int ret; + + if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY) { + ret = -EINVAL; + goto failed; + } + + dbus_message_iter_recurse(iter, &array); + + if (!(adapter->supported_settings & MGMT_SETTING_PHY_CONFIGURATION)) { + ret = -ENOTSUP; + goto failed; + } + + if (!parse_phys_str(&array, &phys)) { + ret = -EINVAL; + goto failed; + } + + ret = set_default_phy(adapter, phys, id); + + /* + * gdbus_pending_property_success event will be sent when success status + * will be received from mgmt. + */ + if (!ret) + 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 EINPROGRESS: + g_dbus_pending_property_error(id, + ERROR_INTERFACE ".InProgress", + "Operation is in progress"); + break; + default: + g_dbus_pending_property_error(id, ERROR_INTERFACE ".Failed", + strerror(-ret)); + break; + } +} + static DBusMessage *remove_device(DBusConnection *conn, DBusMessage *msg, void *user_data) { @@ -3517,6 +3753,8 @@ static const GDBusPropertyTable adapter_properties[] = { { "Modalias", "s", property_get_modalias, NULL, property_exists_modalias }, { "Roles", "as", property_get_roles }, + { "PhyConfiguration", "as", property_get_phy_configuration, + property_set_phy_configuration }, { } }; @@ -9389,6 +9627,43 @@ static void read_exp_features(struct btd_adapter *adapter) btd_error(adapter->dev_id, "Failed to read exp features info"); } +static void read_phy_configuration_resp(uint8_t status, uint16_t length, + const void *param, void *user_data) +{ + const struct mgmt_rp_get_phy_confguration *rp = param; + struct btd_adapter *adapter = user_data; + + if (status != MGMT_STATUS_SUCCESS) { + btd_error(adapter->dev_id, + "Failed to get PHY configuration info: %s (0x%02x)", + mgmt_errstr(status), status); + return; + } + + if (length < sizeof(*rp)) { + btd_error(adapter->dev_id, "Response too small"); + return; + } + + adapter->supported_phys = get_le32(&rp->supported_phys); + adapter->configurable_phys = get_le32(&rp->configurable_phys); + adapter->selected_phys = get_le32(&rp->selected_phys); + + DBG("Supported phys: [0x%x]", adapter->supported_phys); + DBG("Configurable phys: [0x%x]", adapter->configurable_phys); + DBG("Selected phys: [0x%x]", adapter->selected_phys); +} + +static void read_phy_configuration(struct btd_adapter *adapter) +{ + if (mgmt_send(adapter->mgmt, MGMT_OP_GET_PHY_CONFIGURATION, + adapter->dev_id, 0, NULL, read_phy_configuration_resp, + adapter, NULL) > 0) + return; + + btd_error(adapter->dev_id, "Failed to read phy configuration info"); +} + static void read_info_complete(uint8_t status, uint16_t length, const void *param, void *user_data) { @@ -9498,6 +9773,13 @@ static void read_info_complete(uint8_t status, uint16_t length, (missing_settings & MGMT_SETTING_FAST_CONNECTABLE)) set_mode(adapter, MGMT_OP_SET_FAST_CONNECTABLE, 0x01); + if (btd_opts.experimental && + btd_has_kernel_features(KERNEL_EXP_FEATURES)) + read_exp_features(adapter); + + if (adapter->supported_settings & MGMT_SETTING_PHY_CONFIGURATION) + read_phy_configuration(adapter); + err = adapter_register(adapter); if (err < 0) { btd_error(adapter->dev_id, "Unable to register new adapter"); From patchwork Thu Jul 22 05:26:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayush Garg X-Patchwork-Id: 484013 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 752E9C6377D for ; Thu, 22 Jul 2021 05:59:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 57ED861244 for ; Thu, 22 Jul 2021 05:59:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230088AbhGVFTE (ORCPT ); Thu, 22 Jul 2021 01:19:04 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:17714 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230048AbhGVFTD (ORCPT ); Thu, 22 Jul 2021 01:19:03 -0400 Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20210722055938epoutp02b2518824b564edfb229ef0f4c5cb3667~UB3grX3h31391413914epoutp02I for ; Thu, 22 Jul 2021 05:59:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20210722055938epoutp02b2518824b564edfb229ef0f4c5cb3667~UB3grX3h31391413914epoutp02I DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1626933578; bh=VYi8m00j+Zc7e8blA7w08sfGYaVxcsRHyuW/+Vw29hI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g0lbf3L9Njut7vZRxCZaib4PRPADksqYAgMn3Q0WCim4JRUESaLloPgKUbHNwQYML GDD+FqgmP6R2brEtYU6X+Ds9Esal1t6t0jUbVbj4yfvBEM6dAU4S2WEx/xFjXhOk35 s310ZHRCzy0IQFjPDkzLLovvskcoL+GlC/YWnGYU= Received: from epsmges5p1new.samsung.com (unknown [182.195.42.73]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20210722055937epcas5p4d66c2b9da389f37e00b9d1f1c7934d2c~UB3gCdkFW2202722027epcas5p4I; Thu, 22 Jul 2021 05:59:37 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id BD.72.55882.84909F06; Thu, 22 Jul 2021 14:59:36 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20210722052742epcas5p1b53db2cd68028170a86f291bd052bf14~UBbotMaDg1801618016epcas5p1g; Thu, 22 Jul 2021 05:27:42 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20210722052742epsmtrp2a46cd7161b8fe3adebc48c3490e39b4c~UBbosljIJ0094500945epsmtrp2D; Thu, 22 Jul 2021 05:27:42 +0000 (GMT) X-AuditID: b6c32a49-f4fff7000001da4a-7a-60f909482b58 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 95.F8.08289.DC109F06; Thu, 22 Jul 2021 14:27:41 +0900 (KST) Received: from ayush.garg-20-10-15 (unknown [107.109.98.149]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20210722052741epsmtip262374b4d09145238197a36e68e0a226b~UBbn8oVbT0848808488epsmtip2I; Thu, 22 Jul 2021 05:27:41 +0000 (GMT) From: Ayush Garg To: linux-bluetooth@vger.kernel.org Cc: anupam.r@samsung.com, nitin.j@samsung.com Subject: [PATCH BlueZ 5/7] adapter: Add support for PHY Configuration Changed event Date: Thu, 22 Jul 2021 10:56:38 +0530 Message-Id: <20210722052640.5863-6-ayush.garg@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210722052640.5863-1-ayush.garg@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrIIsWRmVeSWpSXmKPExsWy7bCmlq4n588EgzuuFndWW1vMudbHbLFt XTuzA7NH35ZVjB6fN8kFMEVx2aSk5mSWpRbp2yVwZdz9epC9YDNfxaKef0wNjJ+4uxg5OSQE TCS2n5vA2MXIxSEksJtRYvrfe+wQzidGiYbVy6Ccz4wSH18/ZIdpedB3HKplF6PEvFmfmeFa vnc8ZwapYhPQlHj98QsTiC0ioCzxbN9hMJtZQFfizPt1bCC2sECoxMVnC1m6GDk4WARUJQ49 TwIxeQWsJG6sgzpPXmL1hgNgEzkFrCVm9L4BWyUh0M0usf/YQzaIIheJQ3cXQtnCEq+Ob4E6 VEri87u9bBANzYwSOzZvZIdwehglHvzohuqwlzjX9IwVZDMz0NHrd+lDhGUlpp5aB3Uzn0Tv 7ydMEHFeiR3zYGwViQ2rOuGWfTy2kBnC9pBYfeM9NFD6GCXW/33FMoFRbhbCigWMjKsYJVML inPTU4tNCwzzUsv1ihNzi0vz0vWS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wr14b VYOyluSMdfYhO5p339sUPu/ALG/JLJ+Nmi9+TNu0UC0zSPya2Rth09bdWtbTV/UALUkwf1Jy syLga2LSmp8Ss85ayZrafWtcHb39i/n8/X+e1DOXSus+WNoQ2pT577JvjkqA2//SL2rbjkxc X14V8rheK9nEa9WxwFcTLT7dK3U+tingMOc09w9FE1Zqy7+YlP3zd97bgOeHl3kdWpwoebVt e6j6pytM/v+8KgRetbmc+qW47RVD9CYfJZbijERDLeai4kQAUoJf94ICAAA= X-CMS-MailID: 20210722052742epcas5p1b53db2cd68028170a86f291bd052bf14 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P X-CMS-RootMailID: 20210722052742epcas5p1b53db2cd68028170a86f291bd052bf14 References: <20210722052640.5863-1-ayush.garg@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This change will subscribe the MGTM PHY Configuration Changed event. This event will come whenever the controller PHYs changed. Upon receiving the event, it will notify the user by emitting "PhyConfiguration" property changed event. Reviewed-by: Anupam Roy --- src/adapter.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index c64a5333d..84dd2e5bd 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -9682,6 +9682,28 @@ static void read_phy_configuration(struct btd_adapter *adapter) btd_error(adapter->dev_id, "Failed to read phy configuration info"); } +static void phy_configuration_changed_callback(uint16_t index, + uint16_t length, const void *param, + void *user_data) +{ + const struct mgmt_ev_phy_configuration_changed *ev = param; + struct btd_adapter *adapter = user_data; + + if (length < sizeof(*ev)) { + btd_error(adapter->dev_id, + "Too small PHY configuration changed event"); + return; + } + + adapter->selected_phys = get_le32(&ev->selected_phys); + info("PHYs changed, New PHYs [0x%x]", adapter->selected_phys); + + adapter->pending_phys = 0; + + g_dbus_emit_property_changed(dbus_conn, adapter->path, + ADAPTER_INTERFACE, "PhyConfiguration"); +} + static void read_info_complete(uint8_t status, uint16_t length, const void *param, void *user_data) { @@ -9917,6 +9939,11 @@ static void read_info_complete(uint8_t status, uint16_t length, controller_resume_callback, adapter, NULL); + mgmt_register(adapter->mgmt, MGMT_EV_PHY_CONFIGURATION_CHANGED, + adapter->dev_id, + phy_configuration_changed_callback, + adapter, NULL); + set_dev_class(adapter); set_name(adapter, btd_adapter_get_name(adapter)); From patchwork Thu Jul 22 05:26:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayush Garg X-Patchwork-Id: 484012 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 AAC8EC6377D for ; Thu, 22 Jul 2021 05:59:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 934F660FE7 for ; Thu, 22 Jul 2021 05:59:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230330AbhGVFTN (ORCPT ); Thu, 22 Jul 2021 01:19:13 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:48114 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230283AbhGVFTK (ORCPT ); Thu, 22 Jul 2021 01:19:10 -0400 Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20210722055945epoutp01b00239ee135cc4af52ffc545d7e0f947~UB3nh4-BL1720917209epoutp01O for ; Thu, 22 Jul 2021 05:59:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20210722055945epoutp01b00239ee135cc4af52ffc545d7e0f947~UB3nh4-BL1720917209epoutp01O DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1626933585; bh=yvLhXLJo1gC7HS333Qbuv5u1JDJYWuVzLFpYxe56V20=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mZllkImtjMLq+H0gzLJr9bDIfTzDZMxwg4DUUYTStDi3hHSpVnVPtOWbAiXNES7fP uiTg+UE8UFZFIraYVStJKRkDA4EyPsdFMIHHEqUd1s5mUEkqL3zwNA772TR3EGJ4A3 t4HmxMNU3mZVfJumwqGk0/Ij6l8CuxaxA2Uw1Muo= Received: from epsmges5p3new.samsung.com (unknown [182.195.42.75]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20210722055944epcas5p40b71697b2264707675b2ddb5c57585b7~UB3m_q-6m1890418904epcas5p4d; Thu, 22 Jul 2021 05:59:44 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 78.DA.11627.05909F06; Thu, 22 Jul 2021 14:59:44 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20210722052744epcas5p46996d48d12500c39b4b63dfcecd30d37~UBbqkvSTs2470224702epcas5p46; Thu, 22 Jul 2021 05:27:44 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20210722052744epsmtrp2ea4a84d369d2fd698dcbba2fde7cb175~UBbqj1DrS0094500945epsmtrp2I; Thu, 22 Jul 2021 05:27:44 +0000 (GMT) X-AuditID: b6c32a4b-acdff70000022d6b-e0-60f90950e30c Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 46.F8.08289.FC109F06; Thu, 22 Jul 2021 14:27:43 +0900 (KST) Received: from ayush.garg-20-10-15 (unknown [107.109.98.149]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20210722052743epsmtip2ea20deabdf9a767dfa56b4d092af9aaa~UBbpwbzwe0848408484epsmtip2N; Thu, 22 Jul 2021 05:27:43 +0000 (GMT) From: Ayush Garg To: linux-bluetooth@vger.kernel.org Cc: anupam.r@samsung.com, nitin.j@samsung.com Subject: [PATCH BlueZ 7/7] adapter: Save PHY Configuration in storage and read it at init Date: Thu, 22 Jul 2021 10:56:40 +0530 Message-Id: <20210722052640.5863-8-ayush.garg@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210722052640.5863-1-ayush.garg@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrCIsWRmVeSWpSXmKPExsWy7bCmpm4A588Eg+Pd4hZ3VltbzLnWx2yx bV07swOzR9+WVYwenzfJBTBFcdmkpOZklqUW6dslcGU8uDGLpaBXsuLR7jksDYyfRLoYOTkk BEwkPpz8wNzFyMUhJLCbUeJT6y82COcTo8TuWdcYIZzPjBJTd2xjh2lZerkBqmoXo8S8E2eY 4Vp+XZ0OVsUmoCnx+uMXJhBbREBZ4tm+w2A2s4CuxJn369hAbGGBaIm70z6xgtgsAqoSp7qn g8V5Bawk7vdsgdomL7F6wwFmEJtTwFpiRu8bsGUSApPZJXau2ccKUeQicX/lX2YIW1ji1XGY ZimJz+/2skE0NDNK7Ni8kR3C6WGUePCjmw2iyl7iXNMzoEkcQOdpSqzfpQ8RlpWYemod1NV8 Er2/nzBBxHkldsyDsVUkNqzqhFv28dhCqCM8JBqvbmSBBEsfo8S2v3uYJzDKzUJYsYCRcRWj ZGpBcW56arFpgXFearlecWJucWleul5yfu4mRnBEa3nvYHz04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EjL8x+Kt194Cgft+vqx//qT240z94fGGIpwfxpUeHdmnt3ar/5ljjUN1y6x8KfueSeYnbh rsRfCa5r5Kf6/axbnLrl64ONIjd4frC6FibbGHaJnLf+M/H6+0e9AnFXHvF929lcGdso5DXl aol22u6sLRPWvd4X1vKgiTfq+aE7bkpz+yVf3OraVP9TMGz1dC6fszf/uy7zeDJZa/vCWOcf KpLPK3fG5/989+vo9s4kY2lf6w+FXWlGx3yWxCorsRRnJBpqMRcVJwIASwF8soUCAAA= X-CMS-MailID: 20210722052744epcas5p46996d48d12500c39b4b63dfcecd30d37 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P X-CMS-RootMailID: 20210722052744epcas5p46996d48d12500c39b4b63dfcecd30d37 References: <20210722052640.5863-1-ayush.garg@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This change will save the current selected PHY configuration in the storage when PHY Configuration Changed Event is received. It will also load and set the stored PHY configuration when controller initialized. Thus it enables the user to continue with the last selected PHYs on controller restart. Reviewed-by: Anupam Roy --- src/adapter.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/adapter.c b/src/adapter.c index 84dd2e5bd..3861ade8a 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -288,7 +288,8 @@ struct btd_adapter { uint32_t supported_phys; uint32_t configurable_phys; - uint32_t selected_phys; + uint32_t selected_phys; /* Current selected PHYs */ + uint32_t stored_phys; /* Stored last selected PHYs */ uint32_t pending_phys; }; @@ -508,6 +509,10 @@ static void store_adapter_info(struct btd_adapter *adapter) g_key_file_set_string(key_file, "General", "Alias", adapter->stored_alias); + if (adapter->stored_phys) + g_key_file_set_integer(key_file, "General", "PhyConfiguration", + adapter->stored_phys); + snprintf(filename, PATH_MAX, STORAGEDIR "/%s/settings", btd_adapter_get_storage_dir(adapter)); @@ -3329,10 +3334,13 @@ static void set_default_phy_complete(uint8_t status, uint16_t length, btd_info(adapter->dev_id, "PHY configuration successfully set"); adapter->selected_phys = adapter->pending_phys; + adapter->stored_phys = adapter->pending_phys; adapter->pending_phys = 0; g_dbus_pending_property_success(data->id); + store_adapter_info(adapter); + g_dbus_emit_property_changed(dbus_conn, adapter->path, ADAPTER_INTERFACE, "PhyConfiguration"); } @@ -6548,6 +6556,15 @@ static void load_config(struct btd_adapter *adapter) gerr = NULL; } + /* Get PHY Configuration */ + adapter->stored_phys = g_key_file_get_integer(key_file, + "General", "PhyConfiguration", &gerr); + if (gerr) { + adapter->stored_phys = 0; + g_error_free(gerr); + gerr = NULL; + } + g_key_file_free(key_file); } @@ -9670,6 +9687,13 @@ static void read_phy_configuration_resp(uint8_t status, uint16_t length, DBG("Supported phys: [0x%x]", adapter->supported_phys); DBG("Configurable phys: [0x%x]", adapter->configurable_phys); DBG("Selected phys: [0x%x]", adapter->selected_phys); + + /* + * Set the default PHYs to the last selected PHYs on which the + * controller was operating before shutting down. + */ + if (adapter->supported_settings & MGMT_SETTING_PHY_CONFIGURATION) + set_default_phy(adapter, adapter->stored_phys, -1); } static void read_phy_configuration(struct btd_adapter *adapter) @@ -9696,10 +9720,14 @@ static void phy_configuration_changed_callback(uint16_t index, } adapter->selected_phys = get_le32(&ev->selected_phys); + adapter->stored_phys = adapter->selected_phys; + info("PHYs changed, New PHYs [0x%x]", adapter->selected_phys); adapter->pending_phys = 0; + store_adapter_info(adapter); + g_dbus_emit_property_changed(dbus_conn, adapter->path, ADAPTER_INTERFACE, "PhyConfiguration"); }