From patchwork Tue Sep 7 22:30:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 507998 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=-10.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, 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 39580C433EF for ; Tue, 7 Sep 2021 22:30:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2119761101 for ; Tue, 7 Sep 2021 22:30:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346427AbhIGWbR (ORCPT ); Tue, 7 Sep 2021 18:31:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344382AbhIGWbR (ORCPT ); Tue, 7 Sep 2021 18:31:17 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C14AC061575 for ; Tue, 7 Sep 2021 15:30:10 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id m21-20020a17090a859500b00197688449c4so100336pjn.0 for ; Tue, 07 Sep 2021 15:30:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=i3F0z84ohA3gaRU7vi+1lhrskpPB6p/jomHClZ+pLRo=; b=P5hPvn0Ix5xYNy8gy17/CwJtd1ToB8LW+W/yFaFU42fhFyaf1bsc/Mrp7Fz7blkIqz gU/mNtfYZa2y4NYjQogPr7StfbNt8IqI++1iEdX/iSxcuKtBNNXoR9nIEVlSRJ21RZcS iZcQOTuzDUEtZ+MZPsQSZwaLaSkhZcOL8NWsFCwmRwhJkhT4D3FtiOO4iDkR7HP2Pbeu zSodc/CA+1KzD77MJihsZJzqodluS00Eor8IxIrfFfeFHQzurnhAj1G+ouV3I9MR+qZK AWbcp9Ihjg5SfGEPFl2PeA/CpRpHaqlzpGY4mCTMug+gkcwKWKXWcZbm9AoEYUpWlyB9 cW4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=i3F0z84ohA3gaRU7vi+1lhrskpPB6p/jomHClZ+pLRo=; b=nZa3oppRfc0d5M0BwvsbCg7bOtEnENqUsCaM97llQSVKSlKb6IvHqEed0rSCc7Ggrb lbShYzVQacC4bftL4e9ukpCuDM81V73Xr4709Y9U+omC319o3dt3leAnskFJyRCRhLoK HndZCl9CJGHWIbBPu+iNmm9tJ6PKugr0oYstILW93EHt8JdeJxbxLlrJg3WEH9UlIqKp qz1B/OEbrSW1PH4kLHNPwSOkWoe2pOfYbft3jbKC7zXm0GeWAEtX7OYXllEzOWRGWIRx B3JLYh+MGoShWgRodIgyg+edBRUw7WViBuXf4ND6pKJVfaYA/1IyK0R6qa7WpS6E837C cvlg== X-Gm-Message-State: AOAM531KMXa90rMIMOGNerlEftJkpR82KhL4LycU97Djm9qDbOs9fEFN 49eCoZD5Y2mEYIXnEPs6XTST5Sq/V3E= X-Google-Smtp-Source: ABdhPJxYo/WalW8B9K42cPcOtO6yz2Jo3OUOCZkre5vtaXqPw6WK68Fyw2i/XwHEdPoNdn/P/FzQPQ== X-Received: by 2002:a17:90a:2:: with SMTP id 2mr666115pja.77.1631053809593; Tue, 07 Sep 2021 15:30:09 -0700 (PDT) Received: from lvondent-mobl4.intel.com (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id x19sm153811pgk.37.2021.09.07.15.30.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Sep 2021 15:30:09 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 1/5] adapter-api: Add Experimental property Date: Tue, 7 Sep 2021 15:30:04 -0700 Message-Id: <20210907223008.2322035-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This adds Experimental property which indicates what experimental features are currently enabled. --- doc/adapter-api.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt index 464434a81..490608e8d 100644 --- a/doc/adapter-api.txt +++ b/doc/adapter-api.txt @@ -335,3 +335,8 @@ Properties string Address [readonly] "peripheral": Supports the peripheral role. "central-peripheral": Supports both roles concurrently. + + array{string} ExperimentalFeatures [readonly, optional] + + List of 128-bit UUIDs that represents the experimental + features currently enabled. From patchwork Tue Sep 7 22:30:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 507602 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=-10.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, 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 5570AC433FE for ; Tue, 7 Sep 2021 22:30:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3B29461101 for ; Tue, 7 Sep 2021 22:30:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346455AbhIGWbT (ORCPT ); Tue, 7 Sep 2021 18:31:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346568AbhIGWbS (ORCPT ); Tue, 7 Sep 2021 18:31:18 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D016C061575 for ; Tue, 7 Sep 2021 15:30:11 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id mj9-20020a17090b368900b001965618d019so64690pjb.4 for ; Tue, 07 Sep 2021 15:30:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=7xg6SaaM9cHstJFNVJ96AgoVDc0H+fJgQ7FWInOPCnI=; b=f2cHs6JMUx/y9B2rO1cECsrhg4W/XFdnjc83rYXmWmYX4WBLY3OTYG+9TTLh6ESl6o /e6YMfvjiswQUtlcSWW3Ael3wumDh9HKjp3kJeRuA3TcWMLP2lcc4Vd/qIQjTuUWyEYr F3Kqtz/+rWgiIqHEaZIlXBaBmfKkhZN0lmvGIbvF0zxM/vIwTiOWLPkssTSCgi9s9gNM 6pr59R8dLDwT1ObMK1kxDCmRsdxuQkQsR9vQdBBcIpA5LxH5zTZGfCnDifLj81paxFps tgLgfPRdmtlTKUooZQqqsU82/PF7/SDqMFMiMiJpowbizPL9VcdlKflBCjGooRNVe1sE mv9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7xg6SaaM9cHstJFNVJ96AgoVDc0H+fJgQ7FWInOPCnI=; b=T5z6MG22GKDQAOh/YBlgkb+PtPQ+uEVsW/+eByalsUgDqj/ume2sHhG83DlMLzWiVq bQuV9bWpjzo5yGROsezAEci0jVKisLhs2gQTQgsdAclUQtpyjfAKbYS9AbACkF6pWstp h/xJXkyZHjJcvb+f1S6ehFNjQbX8fyuHj2Qd7Ufh/Tt1p/WszwGXYa752XddbffXmxT7 fzgdAVkPycSIXx3dqbwD8iT/4vY6nLonIYEaLdthdKbvN5KM0P0qAyyY2O8VcqEAIgNl YfM2zd7lQEar3p6uYhl4Xf5hNEVt4bUUMzc02jLx1qNCeI5AufPa/iIUCb7rFD2/ufS6 d28A== X-Gm-Message-State: AOAM532ZF2F1XCDvanMGRy72C8GG77guiPVzeDoYmK2hgY87qnl2neDY KpCAYFarGGgYRbhomAIAGcGX+U1/u7A= X-Google-Smtp-Source: ABdhPJxmLKoRl1CwRKOexpzaNLD8zW1rC0bhlnd5s7IWiNJWa2dXfIbKNG+tBgCzP+favWt4WkWspA== X-Received: by 2002:a17:90b:1b46:: with SMTP id nv6mr686881pjb.228.1631053810443; Tue, 07 Sep 2021 15:30:10 -0700 (PDT) Received: from lvondent-mobl4.intel.com (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id x19sm153811pgk.37.2021.09.07.15.30.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Sep 2021 15:30:09 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 2/5] adapter: Implement Experimental property Date: Tue, 7 Sep 2021 15:30:05 -0700 Message-Id: <20210907223008.2322035-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210907223008.2322035-1-luiz.dentz@gmail.com> References: <20210907223008.2322035-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This implements Experimental property which indicates the list of UUIDs that represents the experimental features currently enabled. --- src/adapter.c | 149 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 109 insertions(+), 40 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index ddd896751..dd187f847 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -102,6 +102,30 @@ static const struct mgmt_blocked_key_info blocked_keys[] = { 0x22, 0x8e, 0x07, 0x56, 0xb4, 0xe8, 0x5f, 0x01}}, }; +/* d4992530-b9ec-469f-ab01-6c481c47da1c */ +static const uint8_t debug_uuid[16] = { + 0x1c, 0xda, 0x47, 0x1c, 0x48, 0x6c, 0x01, 0xab, + 0x9f, 0x46, 0xec, 0xb9, 0x30, 0x25, 0x99, 0xd4, +}; + +/* 671b10b5-42c0-4696-9227-eb28d1b049d6 */ +static const uint8_t le_simult_central_peripheral_uuid[16] = { + 0xd6, 0x49, 0xb0, 0xd1, 0x28, 0xeb, 0x27, 0x92, + 0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67, +}; + +/* 330859bc-7506-492d-9370-9a6f0614037f */ +static const uint8_t quality_report_uuid[16] = { + 0x7f, 0x03, 0x14, 0x06, 0x6f, 0x9a, 0x70, 0x93, + 0x2d, 0x49, 0x06, 0x75, 0xbc, 0x59, 0x08, 0x33, +}; + +/* 15c0a148-c273-11ea-b3de-0242ac130004 */ +static const uint8_t rpa_resolution_uuid[16] = { + 0x04, 0x00, 0x13, 0xac, 0x42, 0x02, 0xde, 0xb3, + 0xea, 0x11, 0x73, 0xc2, 0x48, 0xa1, 0xc0, 0x15, +}; + static DBusConnection *dbus_conn = NULL; static uint32_t kernel_features = 0; @@ -285,8 +309,7 @@ struct btd_adapter { bool is_default; /* true if adapter is default one */ - bool le_simult_roles_supported; - bool quality_report_supported; + struct queue *exps; }; typedef enum { @@ -3250,7 +3273,8 @@ static gboolean property_get_roles(const GDBusPropertyTable *property, dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &str); } - if (adapter->le_simult_roles_supported) { + if (queue_find(adapter->exps, NULL, + le_simult_central_peripheral_uuid)) { const char *str = "central-peripheral"; dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &str); } @@ -3260,6 +3284,48 @@ static gboolean property_get_roles(const GDBusPropertyTable *property, return TRUE; } +static void property_append_experimental(void *data, void *user_data) +{ + uint8_t *feature = data; + DBusMessageIter *iter = user_data; + uint128_t value; + bt_uuid_t uuid; + char str[MAX_LEN_UUID_STR + 1]; + char *ptr; + + bswap_128(feature, &value); + bt_uuid128_create(&uuid, value); + bt_uuid_to_string(&uuid, str, sizeof(str)); + + ptr = str; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &ptr); +} + +static gboolean property_get_experimental(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct btd_adapter *adapter = user_data; + DBusMessageIter entry; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_TYPE_STRING_AS_STRING, &entry); + + queue_foreach(adapter->exps, property_append_experimental, &entry); + + dbus_message_iter_close_container(iter, &entry); + + return TRUE; +} + +static gboolean property_experimental_exits(const GDBusPropertyTable *property, + void *data) +{ + struct btd_adapter *adapter = data; + + return !queue_isempty(adapter->exps); +} + static DBusMessage *remove_device(DBusConnection *conn, DBusMessage *msg, void *user_data) { @@ -3619,6 +3685,8 @@ static const GDBusPropertyTable adapter_properties[] = { { "Modalias", "s", property_get_modalias, NULL, property_exists_modalias }, { "Roles", "as", property_get_roles }, + { "ExperimentalFeatures", "as", property_get_experimental, NULL, + property_experimental_exits }, { } }; @@ -5526,6 +5594,7 @@ static void adapter_free(gpointer user_data) g_queue_foreach(adapter->auths, free_service_auth, NULL); g_queue_free(adapter->auths); + queue_destroy(adapter->exps, NULL); /* * Unregister all handlers for this specific index since @@ -6496,6 +6565,7 @@ static struct btd_adapter *btd_adapter_new(uint16_t index) DBG("Pairable timeout: %u seconds", adapter->pairable_timeout); adapter->auths = g_queue_new(); + adapter->exps = queue_new(); return btd_adapter_ref(adapter); } @@ -9394,38 +9464,22 @@ static bool set_blocked_keys(struct btd_adapter *adapter) .func = _func, \ } -/* d4992530-b9ec-469f-ab01-6c481c47da1c */ -static const uint8_t debug_uuid[16] = { - 0x1c, 0xda, 0x47, 0x1c, 0x48, 0x6c, 0x01, 0xab, - 0x9f, 0x46, 0xec, 0xb9, 0x30, 0x25, 0x99, 0xd4, -}; - -/* 671b10b5-42c0-4696-9227-eb28d1b049d6 */ -static const uint8_t le_simult_central_peripheral_uuid[16] = { - 0xd6, 0x49, 0xb0, 0xd1, 0x28, 0xeb, 0x27, 0x92, - 0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67, -}; - -/* 330859bc-7506-492d-9370-9a6f0614037f */ -static const uint8_t quality_report_uuid[16] = { - 0x7f, 0x03, 0x14, 0x06, 0x6f, 0x9a, 0x70, 0x93, - 0x2d, 0x49, 0x06, 0x75, 0xbc, 0x59, 0x08, 0x33, -}; - -/* 15c0a148-c273-11ea-b3de-0242ac130004 */ -static const uint8_t rpa_resolution_uuid[16] = { - 0x04, 0x00, 0x13, 0xac, 0x42, 0x02, 0xde, 0xb3, - 0xea, 0x11, 0x73, 0xc2, 0x48, 0xa1, 0xc0, 0x15, -}; - static void set_exp_debug_complete(uint8_t status, uint16_t len, const void *param, void *user_data) { - if (status != 0) + struct btd_adapter *adapter = user_data; + uint8_t action = btd_opts.experimental ? 0x01 : 0x00; + + if (status != 0) { error("Set Experimental Debug failed with status 0x%02x (%s)", status, mgmt_errstr(status)); - else - DBG("Experimental Debug successfully set"); + return; + } + + DBG("Experimental Debug successfully set"); + + if (action) + queue_push_tail(adapter->exps, (void *)debug_uuid); } static void exp_debug_func(struct btd_adapter *adapter, uint32_t flags) @@ -9434,8 +9488,11 @@ static void exp_debug_func(struct btd_adapter *adapter, uint32_t flags) uint8_t action = btd_opts.experimental ? 0x01 : 0x00; /* If already set don't attempt to set it again */ - if (action == (flags & BIT(0))) + if (action == (flags & BIT(0))) { + if (action) + queue_push_tail(adapter->exps, (void *)debug_uuid); return; + } memset(&cp, 0, sizeof(cp)); memcpy(cp.uuid, debug_uuid, 16); @@ -9452,25 +9509,33 @@ static void exp_debug_func(struct btd_adapter *adapter, uint32_t flags) static void le_simult_central_peripheral_func(struct btd_adapter *adapter, uint32_t flags) { - adapter->le_simult_roles_supported = flags & 0x01; + if (flags & 0x01) + queue_push_tail(adapter->exps, + (void *)le_simult_central_peripheral_uuid); } static void quality_report_func(struct btd_adapter *adapter, uint32_t flags) { - adapter->quality_report_supported = le32_to_cpu(flags) & 0x01; - - btd_info(adapter->dev_id, "quality_report_supported %d", - adapter->quality_report_supported); + if (flags & 0x01) + queue_push_tail(adapter->exps, (void *)quality_report_uuid); } static void set_rpa_resolution_complete(uint8_t status, uint16_t len, const void *param, void *user_data) { - if (status != 0) + struct btd_adapter *adapter = user_data; + uint8_t action = btd_opts.experimental ? 0x01 : 0x00; + + if (status != 0) { error("Set RPA Resolution failed with status 0x%02x (%s)", status, mgmt_errstr(status)); - else - DBG("RPA Resolution successfully set"); + return; + } + + DBG("RPA Resolution successfully set"); + + if (action) + queue_push_tail(adapter->exps, (void *)rpa_resolution_uuid); } static void rpa_resolution_func(struct btd_adapter *adapter, uint32_t flags) @@ -9479,8 +9544,12 @@ static void rpa_resolution_func(struct btd_adapter *adapter, uint32_t flags) uint8_t action = btd_opts.experimental ? 0x01 : 0x00; /* If already set don't attempt to set it again */ - if (action == (flags & BIT(0))) + if (action == (flags & BIT(0))) { + if (action) + queue_push_tail(adapter->exps, + (void *)rpa_resolution_uuid); return; + } memset(&cp, 0, sizeof(cp)); memcpy(cp.uuid, rpa_resolution_uuid, 16); From patchwork Tue Sep 7 22:30:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 507997 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=-10.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, 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 0124FC433EF for ; Tue, 7 Sep 2021 22:30:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DE3E461101 for ; Tue, 7 Sep 2021 22:30:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346568AbhIGWbT (ORCPT ); Tue, 7 Sep 2021 18:31:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346573AbhIGWbS (ORCPT ); Tue, 7 Sep 2021 18:31:18 -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 D1699C061757 for ; Tue, 7 Sep 2021 15:30:11 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id v1so42725plo.10 for ; Tue, 07 Sep 2021 15:30:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=J8y9srhLy7xXZr208e3K7aYbMXh6OJHw41vPHmgwaoY=; b=IdWnBcoyaDwAAVrosH8E7oiDm1qxPjEgc+Tn3Mg0vQeXDRhnSARDt81uxxTfedKs89 hXL7iH3qY0V+EZsoFdNMI6MyHla2fNvxWluljHfG7K/VfY3+TB+/V18tIkyGff3ngzi8 OHZjXcpd+NxuFjvYIAnQeRQhnNJxkHrvv1pbs4yG3X+bSD+r+C/kDbsJT5rOWl5V/WHI QxjNXnM+M1qx48MhCHnOdTEGoWIy9ok3PHOceA/PrTuCAg5m2V4ClxFYTuEL88RskJAd FPxdMn3nKKERlfBNlQA8IT2obwgSq+Hg9hPvEd+GJBfbD+sm5H7rV9044f3yTxY1LuGX fG0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=J8y9srhLy7xXZr208e3K7aYbMXh6OJHw41vPHmgwaoY=; b=sKz3SVJnmAEvxPd5EjmyZgL9uXpT/5Qet0gYj/2ebEOB3z8/o+Ho2RMmc2GTn7egIp 2QpLBEQXmIhPq4/og4oTvpW60JA0sqBnHhy6+maAPrZBHffYUiy7sodH455N/n2819cz DD35aMS4bkUKpYlA5oL7bTPEs3+W0eC+B8KC8ZRt3YHxUJ55XrPXoMBx93QKTkJeNuRf Vt+3K9Syl9p4s9LXJ6CVKqJ/rCxHem37rE67gYDvPSYAu0waiR1Fkl5aeWOSelxa7Ip9 7Fo5mA/FcHnHDfBpppzOPu2P3qrz1y+U6gwJgBLIHwRxOpj1mjKYnxoBtyl7hv71qImu 9h7w== X-Gm-Message-State: AOAM531NUmfXUFVHmmrjGZm9RPfLAHd43ts2eVhSAExuhNR/FWeVreF3 iKLaYesVnzmYj0rMhx1GCbd5gmU3s2w= X-Google-Smtp-Source: ABdhPJz4LLcbZPiyem0UjIINgGvRNc926kTkaANrpzbyuNjIQcrCHqADGLtQkDKbTIysfsDS0ileSQ== X-Received: by 2002:a17:90b:1801:: with SMTP id lw1mr701788pjb.162.1631053811091; Tue, 07 Sep 2021 15:30:11 -0700 (PDT) Received: from lvondent-mobl4.intel.com (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id x19sm153811pgk.37.2021.09.07.15.30.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Sep 2021 15:30:10 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 3/5] client: Add support for printing ExperimentalFeatures property Date: Tue, 7 Sep 2021 15:30:06 -0700 Message-Id: <20210907223008.2322035-3-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210907223008.2322035-1-luiz.dentz@gmail.com> References: <20210907223008.2322035-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz Thid adds support to show command to print ExperimentalFeatures property: [bluetooth]# show Controller ... Experimental: BlueZ Experimental LL p.. (15c0a148-c273-11ea-b3de-0242ac130004) --- client/main.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/client/main.c b/client/main.c index 506602bbd..9a36a8c65 100644 --- a/client/main.c +++ b/client/main.c @@ -319,7 +319,7 @@ static void print_property(GDBusProxy *proxy, const char *name) print_property_with_label(proxy, name, NULL); } -static void print_uuid(const char *uuid) +static void print_uuid(const char *label, const char *uuid) { const char *text; @@ -340,9 +340,10 @@ static void print_uuid(const char *uuid) n = sizeof(str) - 1; } - bt_shell_printf("\tUUID: %s%*c(%s)\n", str, 26 - n, ' ', uuid); + bt_shell_printf("\t%s: %s%*c(%s)\n", label, str, 26 - n, ' ', + uuid); } else - bt_shell_printf("\tUUID: %*c(%s)\n", 26, ' ', uuid); + bt_shell_printf("\t%s: %*c(%s)\n", label, 26, ' ', uuid); } static void print_uuids(GDBusProxy *proxy) @@ -359,7 +360,28 @@ static void print_uuids(GDBusProxy *proxy) dbus_message_iter_get_basic(&value, &uuid); - print_uuid(uuid); + print_uuid("UUID", uuid); + + dbus_message_iter_next(&value); + } +} + +static void print_experimental(GDBusProxy *proxy) +{ + DBusMessageIter iter, value; + + if (g_dbus_proxy_get_property(proxy, "ExperimentalFeatures", + &iter) == FALSE) + return; + + dbus_message_iter_recurse(&iter, &value); + + while (dbus_message_iter_get_arg_type(&value) == DBUS_TYPE_STRING) { + const char *uuid; + + dbus_message_iter_get_basic(&value, &uuid); + + print_uuid("ExperimentalFeatures", uuid); dbus_message_iter_next(&value); } @@ -984,6 +1006,7 @@ static void cmd_show(int argc, char *argv[]) print_property(adapter->proxy, "Modalias"); print_property(adapter->proxy, "Discovering"); print_property(adapter->proxy, "Roles"); + print_experimental(adapter->proxy); if (adapter->ad_proxy) { bt_shell_printf("Advertising Features:\n"); @@ -1424,7 +1447,7 @@ static void cmd_scan_filter_uuids(int argc, char *argv[]) char **uuid; for (uuid = filter.uuids; uuid && *uuid; uuid++) - print_uuid(*uuid); + print_uuid("UUID", *uuid); return bt_shell_noninteractive_quit(EXIT_SUCCESS); } From patchwork Tue Sep 7 22:30:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 507996 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=-10.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, 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 CF11BC433F5 for ; Tue, 7 Sep 2021 22:30:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B75AB6056C for ; Tue, 7 Sep 2021 22:30:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346722AbhIGWbU (ORCPT ); Tue, 7 Sep 2021 18:31:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346560AbhIGWbT (ORCPT ); Tue, 7 Sep 2021 18:31:19 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9231C061575 for ; Tue, 7 Sep 2021 15:30:12 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id 18so315940pfh.9 for ; Tue, 07 Sep 2021 15:30:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=5TLpHh7AV47SXf2E1p7hnAJxna0z8dGBhd+Zc3p5H40=; b=jXXRvcXs8nh4IboFJ0VA1uymGiyzcx0MzwAnZCLgVwqFrBtpTmtNIqwtClKd5yEDmU 0V2XvdYbCk7+WX3bKUki28Ddoxdlc8JFb/8tGC/SV8PHIwPxC8rdupnmqT//cSuBzEXx DKooG/Jr2qKNonuxeXX6X9dhfQj36AQHb7laMjuTP0z2/MhwB4RJks0Uk1+Qjn2/6dCq DCerQmPn0Yd3498/QIXB1kMYd2o1YUmwKInJBOrh+LFHQANXL+pk21OsNDt+TrFH3gWO QfV2+sVTU4dTf2yDhPipnbeXqeFRDVVLlKdouEcyALAMYZb6y/suQ6ThOfmnaXMbRh49 hcvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5TLpHh7AV47SXf2E1p7hnAJxna0z8dGBhd+Zc3p5H40=; b=LgAdmphMg3JwJnPzOkNd6WmfBw1TAXGzy299Pmrp22tW+GKTplvXQBe7HQzRo9kjsn tBH7VUSGmCFMT9ek82CdHh20ZZcifYtbytDXXWCynvrBYRkx9k4EWpfeGn3GXRS40OPW 6VEdxG7wQSVCtrvCxsl1uFWy1AO275VXHiiUWVZluPPsfmZLCDSk12Zsf3FCJanAmhb5 geZ19k5kPxeC4btdd8LZnypGJc6UOzYeSQWvPUVS8jCFfroIz23QTW29LNnT4HN9OPQe neWl1t8svRE/DbJ2+FWRBgolkEdcHP4+s73jzHoo7ysBJf1oqXpaWgxsA7hxm42bGJMd U6Jg== X-Gm-Message-State: AOAM532LIPiRTog610HkStBqSe6Ta/VcjsJPkoIpgO0z23Jazu3icgQB iaBFSPPQINb8khJLb9+TSY3mNT5wQBQ= X-Google-Smtp-Source: ABdhPJz2YC4e9FQ9lpKFBppf3zV7kuVOp0rOoZLDl783rxcVfkKJ71ajcV9gt7P2iuOPeOFzgRDQtg== X-Received: by 2002:a63:3753:: with SMTP id g19mr567252pgn.328.1631053811922; Tue, 07 Sep 2021 15:30:11 -0700 (PDT) Received: from lvondent-mobl4.intel.com (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id x19sm153811pgk.37.2021.09.07.15.30.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Sep 2021 15:30:11 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 4/5] main.conf: Allow passing a list of UUIDs to Experimental Date: Tue, 7 Sep 2021 15:30:07 -0700 Message-Id: <20210907223008.2322035-4-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210907223008.2322035-1-luiz.dentz@gmail.com> References: <20210907223008.2322035-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This allows the user to enable a subset of the experimental features to be enabled instead of all of them and also change -E to work in the same way so a list of UUIDs can also be given at the command line. --- src/adapter.c | 106 ++++++++++++++++++++++++++----------------------- src/btd.h | 5 ++- src/main.c | 108 ++++++++++++++++++++++++++++++++++++++++++++++---- src/main.conf | 10 ++++- 4 files changed, 169 insertions(+), 60 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index dd187f847..bc6469e0a 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -102,28 +102,37 @@ static const struct mgmt_blocked_key_info blocked_keys[] = { 0x22, 0x8e, 0x07, 0x56, 0xb4, 0xe8, 0x5f, 0x01}}, }; +struct mgmt_exp_uuid { + uint8_t val[16]; + const char *str; +}; + /* d4992530-b9ec-469f-ab01-6c481c47da1c */ -static const uint8_t debug_uuid[16] = { - 0x1c, 0xda, 0x47, 0x1c, 0x48, 0x6c, 0x01, 0xab, - 0x9f, 0x46, 0xec, 0xb9, 0x30, 0x25, 0x99, 0xd4, +static const struct mgmt_exp_uuid debug_uuid = { + .val = { 0x1c, 0xda, 0x47, 0x1c, 0x48, 0x6c, 0x01, 0xab, + 0x9f, 0x46, 0xec, 0xb9, 0x30, 0x25, 0x99, 0xd4 }, + .str = "d4992530-b9ec-469f-ab01-6c481c47da1c" }; /* 671b10b5-42c0-4696-9227-eb28d1b049d6 */ -static const uint8_t le_simult_central_peripheral_uuid[16] = { - 0xd6, 0x49, 0xb0, 0xd1, 0x28, 0xeb, 0x27, 0x92, - 0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67, +static const struct mgmt_exp_uuid le_simult_central_peripheral_uuid = { + .val = { 0xd6, 0x49, 0xb0, 0xd1, 0x28, 0xeb, 0x27, 0x92, + 0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67 }, + .str = "671b10b5-42c0-4696-9227-eb28d1b049d6" }; /* 330859bc-7506-492d-9370-9a6f0614037f */ -static const uint8_t quality_report_uuid[16] = { - 0x7f, 0x03, 0x14, 0x06, 0x6f, 0x9a, 0x70, 0x93, - 0x2d, 0x49, 0x06, 0x75, 0xbc, 0x59, 0x08, 0x33, +static const struct mgmt_exp_uuid quality_report_uuid = { + .val = { 0x7f, 0x03, 0x14, 0x06, 0x6f, 0x9a, 0x70, 0x93, + 0x2d, 0x49, 0x06, 0x75, 0xbc, 0x59, 0x08, 0x33 }, + .str = "330859bc-7506-492d-9370-9a6f0614037f" }; /* 15c0a148-c273-11ea-b3de-0242ac130004 */ -static const uint8_t rpa_resolution_uuid[16] = { - 0x04, 0x00, 0x13, 0xac, 0x42, 0x02, 0xde, 0xb3, - 0xea, 0x11, 0x73, 0xc2, 0x48, 0xa1, 0xc0, 0x15, +static const struct mgmt_exp_uuid rpa_resolution_uuid = { + .val = { 0x04, 0x00, 0x13, 0xac, 0x42, 0x02, 0xde, 0xb3, + 0xea, 0x11, 0x73, 0xc2, 0x48, 0xa1, 0xc0, 0x15 }, + .str = "15c0a148-c273-11ea-b3de-0242ac130004" }; static DBusConnection *dbus_conn = NULL; @@ -3274,7 +3283,7 @@ static gboolean property_get_roles(const GDBusPropertyTable *property, } if (queue_find(adapter->exps, NULL, - le_simult_central_peripheral_uuid)) { + le_simult_central_peripheral_uuid.val)) { const char *str = "central-peripheral"; dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &str); } @@ -9479,23 +9488,15 @@ static void set_exp_debug_complete(uint8_t status, uint16_t len, DBG("Experimental Debug successfully set"); if (action) - queue_push_tail(adapter->exps, (void *)debug_uuid); + queue_push_tail(adapter->exps, (void *)debug_uuid.val); } -static void exp_debug_func(struct btd_adapter *adapter, uint32_t flags) +static void exp_debug_func(struct btd_adapter *adapter, uint8_t action) { struct mgmt_cp_set_exp_feature cp; - uint8_t action = btd_opts.experimental ? 0x01 : 0x00; - - /* If already set don't attempt to set it again */ - if (action == (flags & BIT(0))) { - if (action) - queue_push_tail(adapter->exps, (void *)debug_uuid); - return; - } memset(&cp, 0, sizeof(cp)); - memcpy(cp.uuid, debug_uuid, 16); + memcpy(cp.uuid, debug_uuid.val, 16); cp.action = action; if (mgmt_send(adapter->mgmt, MGMT_OP_SET_EXP_FEATURE, @@ -9507,17 +9508,17 @@ static void exp_debug_func(struct btd_adapter *adapter, uint32_t flags) } static void le_simult_central_peripheral_func(struct btd_adapter *adapter, - uint32_t flags) + uint8_t action) { - if (flags & 0x01) + if (action) queue_push_tail(adapter->exps, - (void *)le_simult_central_peripheral_uuid); + (void *)le_simult_central_peripheral_uuid.val); } -static void quality_report_func(struct btd_adapter *adapter, uint32_t flags) +static void quality_report_func(struct btd_adapter *adapter, uint8_t action) { - if (flags & 0x01) - queue_push_tail(adapter->exps, (void *)quality_report_uuid); + if (action) + queue_push_tail(adapter->exps, (void *)quality_report_uuid.val); } static void set_rpa_resolution_complete(uint8_t status, uint16_t len, @@ -9535,24 +9536,15 @@ static void set_rpa_resolution_complete(uint8_t status, uint16_t len, DBG("RPA Resolution successfully set"); if (action) - queue_push_tail(adapter->exps, (void *)rpa_resolution_uuid); + queue_push_tail(adapter->exps, (void *)rpa_resolution_uuid.val); } -static void rpa_resolution_func(struct btd_adapter *adapter, uint32_t flags) +static void rpa_resolution_func(struct btd_adapter *adapter, uint8_t action) { struct mgmt_cp_set_exp_feature cp; - uint8_t action = btd_opts.experimental ? 0x01 : 0x00; - - /* If already set don't attempt to set it again */ - if (action == (flags & BIT(0))) { - if (action) - queue_push_tail(adapter->exps, - (void *)rpa_resolution_uuid); - return; - } memset(&cp, 0, sizeof(cp)); - memcpy(cp.uuid, rpa_resolution_uuid, 16); + memcpy(cp.uuid, rpa_resolution_uuid.val, 16); cp.action = action; if (mgmt_send(adapter->mgmt, MGMT_OP_SET_EXP_FEATURE, @@ -9564,14 +9556,14 @@ static void rpa_resolution_func(struct btd_adapter *adapter, uint32_t flags) } static const struct exp_feat { - const uint8_t *uuid; - void (*func)(struct btd_adapter *adapter, uint32_t flags); + const struct mgmt_exp_uuid *uuid; + void (*func)(struct btd_adapter *adapter, uint8_t action); } exp_table[] = { - EXP_FEAT(debug_uuid, exp_debug_func), - EXP_FEAT(le_simult_central_peripheral_uuid, + EXP_FEAT(&debug_uuid, exp_debug_func), + EXP_FEAT(&le_simult_central_peripheral_uuid, le_simult_central_peripheral_func), - EXP_FEAT(quality_report_uuid, quality_report_func), - EXP_FEAT(rpa_resolution_uuid, rpa_resolution_func), + EXP_FEAT(&quality_report_uuid, quality_report_func), + EXP_FEAT(&rpa_resolution_uuid, rpa_resolution_func), }; static void read_exp_features_complete(uint8_t status, uint16_t length, @@ -9608,13 +9600,27 @@ static void read_exp_features_complete(uint8_t status, uint16_t length, for (j = 0; j < ARRAY_SIZE(exp_table); j++) { const struct exp_feat *feat = &exp_table[j]; + uint8_t action; - if (memcmp(rp->features[i].uuid, feat->uuid, + if (memcmp(rp->features[i].uuid, feat->uuid->val, sizeof(rp->features[i].uuid))) continue; + action = btd_experimental_enabled(feat->uuid->str); + + DBG("%s flags %u action %u", feat->uuid->str, + rp->features[i].flags, action); + + /* If already set don't attempt to set it again */ + if (action == (rp->features[i].flags & BIT(0))) { + if (action) + queue_push_tail(adapter->exps, + (void *)feat->uuid->val); + continue; + } + if (feat->func) - feat->func(adapter, rp->features[i].flags); + feat->func(adapter, action); } } } diff --git a/src/btd.h b/src/btd.h index d72883546..f83591f8f 100644 --- a/src/btd.h +++ b/src/btd.h @@ -10,6 +10,8 @@ * */ +#include + typedef enum { BT_MODE_DUAL, BT_MODE_BREDR, @@ -109,7 +111,7 @@ struct btd_opts { gboolean debug_keys; gboolean fast_conn; gboolean refresh_discovery; - gboolean experimental; + struct queue *experimental; uint16_t did_source; uint16_t did_vendor; @@ -140,5 +142,6 @@ void rfkill_init(void); void rfkill_exit(void); GKeyFile *btd_get_main_conf(void); +bool btd_experimental_enabled(const char *uuid); void btd_exit(void); diff --git a/src/main.c b/src/main.c index bf8b8dca7..5ca8d5644 100644 --- a/src/main.c +++ b/src/main.c @@ -42,6 +42,7 @@ #include "shared/att-types.h" #include "shared/mainloop.h" #include "shared/timeout.h" +#include "shared/queue.h" #include "lib/uuid.h" #include "shared/util.h" #include "btd.h" @@ -545,10 +546,78 @@ static void parse_le_config(GKeyFile *config) parse_mode_config(config, "LE", params, ARRAY_SIZE(params)); } +static bool match_experimental(const void *data, const void *match_data) +{ + const char *value = data; + const char *uuid = match_data; + + if (!strcmp(value, "*")) + return true; + + return !strcasecmp(value, uuid); +} + +bool btd_experimental_enabled(const char *uuid) +{ + if (!btd_opts.experimental) + false; + + return queue_find(btd_opts.experimental, match_experimental, uuid); +} + +static const char *valid_uuids[] = { + "d4992530-b9ec-469f-ab01-6c481c47da1c", + "671b10b5-42c0-4696-9227-eb28d1b049d6", + "15c0a148-c273-11ea-b3de-0242ac130004", + "330859bc-7506-492d-9370-9a6f0614037f", + "a6695ace-ee7f-4fb9-881a-5fac66c629af", + "*" +}; + +static void btd_parse_experimental(char **list) +{ + int i; + + if (btd_opts.experimental) { + warn("Unable to parse Experimental: list already set"); + return; + } + + btd_opts.experimental = queue_new(); + + for (i = 0; list[i]; i++) { + size_t j; + const char *uuid = list[i]; + + if (!strcasecmp("false", uuid) || !strcasecmp("off", uuid)) { + queue_destroy(btd_opts.experimental, free); + btd_opts.experimental = NULL; + } + + if (!strcasecmp("true", uuid) || !strcasecmp("on", uuid)) + uuid = "*"; + + for (j = 0; j < ARRAY_SIZE(valid_uuids); j++) { + if (!strcasecmp(valid_uuids[j], uuid)) + break; + } + + /* Ignored if UUID is considered invalid */ + if (j == ARRAY_SIZE(valid_uuids)) { + warn("Invalid Experimental UUID: %s", uuid); + continue; + } + + DBG("%s", uuid); + + queue_push_tail(btd_opts.experimental, strdup(uuid)); + } +} + static void parse_config(GKeyFile *config) { GError *err = NULL; - char *str; + char *str, **strlist; int val; gboolean boolean; @@ -722,12 +791,14 @@ static void parse_config(GKeyFile *config) else btd_opts.refresh_discovery = boolean; - boolean = g_key_file_get_boolean(config, "General", - "Experimental", &err); + strlist = g_key_file_get_string_list(config, "General", "Experimental", + NULL, &err); if (err) g_clear_error(&err); - else - btd_opts.experimental = boolean; + else { + btd_parse_experimental(strlist); + g_strfreev(strlist); + } str = g_key_file_get_string(config, "GATT", "Cache", &err); if (err) { @@ -840,7 +911,6 @@ static void init_defaults(void) btd_opts.name_resolv = TRUE; btd_opts.debug_keys = FALSE; btd_opts.refresh_discovery = TRUE; - btd_opts.experimental = false; btd_opts.defaults.num_entries = 0; btd_opts.defaults.br.page_scan_type = 0xFFFF; @@ -993,6 +1063,24 @@ static gboolean parse_debug(const char *key, const char *value, return TRUE; } +static gboolean parse_experimental(const char *key, const char *value, + gpointer user_data, GError **error) +{ + char **strlist; + + if (value) { + strlist = g_strsplit(value, ",", -1); + btd_parse_experimental(strlist); + g_strfreev(strlist); + } else { + if (!btd_opts.experimental) + btd_opts.experimental = queue_new(); + queue_push_head(btd_opts.experimental, strdup("*")); + } + + return TRUE; +} + static GOptionEntry options[] = { { "debug", 'd', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK, parse_debug, @@ -1005,8 +1093,9 @@ static GOptionEntry options[] = { "Specify an explicit path to the config file", "FILE"}, { "compat", 'C', 0, G_OPTION_ARG_NONE, &option_compat, "Provide deprecated command line interfaces" }, - { "experimental", 'E', 0, G_OPTION_ARG_NONE, &btd_opts.experimental, - "Enable experimental interfaces" }, + { "experimental", 'E', G_OPTION_FLAG_OPTIONAL_ARG, + G_OPTION_ARG_CALLBACK, parse_experimental, + "Enable experimental features/interfaces" }, { "nodetach", 'n', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &option_detach, "Run with logging in foreground" }, @@ -1135,6 +1224,9 @@ int main(int argc, char *argv[]) if (btd_opts.mode != BT_MODE_LE) stop_sdp_server(); + if (btd_opts.experimental) + queue_destroy(btd_opts.experimental, free); + if (main_conf) g_key_file_free(main_conf); diff --git a/src/main.conf b/src/main.conf index 71924cb17..e05291d8e 100644 --- a/src/main.conf +++ b/src/main.conf @@ -86,7 +86,15 @@ # profile is connected. Defaults to true. #RefreshDiscovery = true -# Enables experimental features and interfaces. +# Enables experimental features and interfaces, alternatively a list of UUIDs +# can be given. +# Possible values: true,false, +# Possible UUIDS: +# d4992530-b9ec-469f-ab01-6c481c47da1c (BlueZ Experimental Debug) +# 671b10b5-42c0-4696-9227-eb28d1b049d6 (BlueZ Experimental Simultaneous Central and Peripheral) +# 15c0a148-c273-11ea-b3de-0242ac130004 (BlueZ Experimental LL privacy) +# 330859bc-7506-492d-9370-9a6f0614037f (BlueZ Experimental Bluetooth Quality Report) +# a6695ace-ee7f-4fb9-881a-5fac66c629af (BlueZ Experimental Offload Codecs) # Defaults to false. #Experimental = false From patchwork Tue Sep 7 22:30:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 507601 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=-10.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, 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 154ACC4332F for ; Tue, 7 Sep 2021 22:30:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 009386056C for ; Tue, 7 Sep 2021 22:30:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346573AbhIGWbU (ORCPT ); Tue, 7 Sep 2021 18:31:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346660AbhIGWbU (ORCPT ); Tue, 7 Sep 2021 18:31:20 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CCA2C061575 for ; Tue, 7 Sep 2021 15:30:13 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id 17so372517pgp.4 for ; Tue, 07 Sep 2021 15:30:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=V9aKXTmWmkGWqZBXTW8WnMhZLSLPCzs303ngGj763SA=; b=VjITV71R8EJ9jajVjuxyhQ+eAYUPb8KAsGwSQb+SVu2bq1DJRUDsaZpd05tFE0Ae9h RnKo2Mz6H8IljXml3n8lkUqarqU6SFclbcOufi9PM/LHVHk2WRYWUSMu1hcuTH9lgMwv 66JiwrTKP33WXUVPcIdW2GHJBFe8ANo2lMjkbzre9xXVWYZG1T2cDIlc0UDGedtD8MA/ 04eHLOWnVWBTsCbUpbCK+IlyU545fWiJeiBBqjJVWZwKFE0aVi+XhSUdJ+LJI13yqMfT dMVH/Jp8ej8wp2cvRW8ywX4Jo9bcfU9XLBixhNbpKWwYAdZyUseDWY8a03oHZREQGDlm y71w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=V9aKXTmWmkGWqZBXTW8WnMhZLSLPCzs303ngGj763SA=; b=o6hZbnXaBXeSht12qbKBkhub/XX2YHQwRsmTtslv6vIwz2fxvgXPMaGJO7JuWdlEtH TpGS0Wmqda3q1Dbu2T6xBVt8RHuLjbWJAiX+uaPWOilYeh6CANzpYNEmPO1sqtJdAC/a xDtkXeOdKKwUv2p2z1XHxtNIrqWT7HVF4NG7srWqyUYj7CeJ14FS9KxUQU2H4mHV2iOw tPLi7XwtQsU6tUpK4wlrWcfPgqSOmSY/c1P/RkNNyrYPemGvCwUIqEdSjD6NrCiL8bIO fO6V56LXJ9Lyob3YsNokCqcqImer+5286MzbfU52Od+Gn5o1biPWvzsBTJsymlBt50hq azLA== X-Gm-Message-State: AOAM530oebQ4BtUzshkcP9KUcVZmLtXH7VX/QZK0EGKK/9Oyi3YSIM3O zsYZvDVnp3u7G+O8bOEhfskFr3fQMJ4= X-Google-Smtp-Source: ABdhPJxb/TqAtQNo7ooWiINH8YLbPkP+mhUQwJ23yeW+IhJ62IQWLafZnBJEebVwadY99NuRbnjuHA== X-Received: by 2002:a63:7c58:: with SMTP id l24mr543619pgn.464.1631053812730; Tue, 07 Sep 2021 15:30:12 -0700 (PDT) Received: from lvondent-mobl4.intel.com (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id x19sm153811pgk.37.2021.09.07.15.30.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Sep 2021 15:30:12 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 5/5] adapter: Enable codec offload when Experimental is set Date: Tue, 7 Sep 2021 15:30:08 -0700 Message-Id: <20210907223008.2322035-5-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210907223008.2322035-1-luiz.dentz@gmail.com> References: <20210907223008.2322035-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This enables codec offload experimental feature if its UUIDs has been enabled by main.conf:Experimental or -E has been passed in the command line. --- src/adapter.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index bc6469e0a..ce715766c 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -135,6 +135,13 @@ static const struct mgmt_exp_uuid rpa_resolution_uuid = { .str = "15c0a148-c273-11ea-b3de-0242ac130004" }; +/* a6695ace-ee7f-4fb9-881a-5fac66c629af */ +static const struct mgmt_exp_uuid codec_offload_uuid = { + .val = { 0xaf, 0x29, 0xc6, 0x66, 0xac, 0x5f, 0x1a, 0x88, + 0xb9, 0x4f, 0x7f, 0xee, 0xce, 0x5a, 0x69, 0xa6 }, + .str = "a6695ace-ee7f-4fb9-881a-5fac66c629af" +}; + static DBusConnection *dbus_conn = NULL; static uint32_t kernel_features = 0; @@ -9555,6 +9562,40 @@ static void rpa_resolution_func(struct btd_adapter *adapter, uint8_t action) btd_error(adapter->dev_id, "Failed to set RPA Resolution"); } +static void codec_offload_complete(uint8_t status, uint16_t len, + const void *param, void *user_data) +{ + struct btd_adapter *adapter = user_data; + uint8_t action = btd_opts.experimental ? 0x01 : 0x00; + + if (status != 0) { + error("Set Codec Offload failed with status 0x%02x (%s)", + status, mgmt_errstr(status)); + return; + } + + DBG("Codec Offload successfully set"); + + if (action) + queue_push_tail(adapter->exps, (void *)codec_offload_uuid.val); +} + +static void codec_offload_func(struct btd_adapter *adapter, uint8_t action) +{ + struct mgmt_cp_set_exp_feature cp; + + memset(&cp, 0, sizeof(cp)); + memcpy(cp.uuid, codec_offload_uuid.val, 16); + cp.action = action; + + if (mgmt_send(adapter->mgmt, MGMT_OP_SET_EXP_FEATURE, + adapter->dev_id, sizeof(cp), &cp, + codec_offload_complete, adapter, NULL) > 0) + return; + + btd_error(adapter->dev_id, "Failed to set Codec Offload"); +} + static const struct exp_feat { const struct mgmt_exp_uuid *uuid; void (*func)(struct btd_adapter *adapter, uint8_t action); @@ -9564,6 +9605,7 @@ static const struct exp_feat { le_simult_central_peripheral_func), EXP_FEAT(&quality_report_uuid, quality_report_func), EXP_FEAT(&rpa_resolution_uuid, rpa_resolution_func), + EXP_FEAT(&codec_offload_uuid, codec_offload_func), }; static void read_exp_features_complete(uint8_t status, uint16_t length,