linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Winkler <danielwinkler@google.com>
To: luiz.von.dentz@intel.com
Cc: linux-bluetooth@vger.kernel.org,
	chromeos-bluetooth-upstreaming@chromium.org,
	Daniel Winkler <danielwinkler@google.com>,
	Sonny Sasaka <sonnysasaka@chromium.org>,
	Alain Michaud <alainm@chromium.org>
Subject: [Bluez PATCH v4 04/10] advertising: Detect if extended advertising mgmt commands are supported
Date: Thu,  1 Oct 2020 16:01:46 -0700	[thread overview]
Message-ID: <20201001155738.Bluez.v4.4.I50d9faa25e9da6e71d77c83c7d47a5b135e88799@changeid> (raw)
In-Reply-To: <20201001230152.2422908-1-danielwinkler@google.com>

We need to know if kernel supports the new MGMT interface. To do so, we
check the return from adapter's MGMT_OP_READ_COMMANDS call for the new
commands. This will later be used to route our requests for new
advertisements.

The change is tested by manually verifying that the correct MGMT
commands are used when the feature is and is not available in kernel.

Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org>
Reviewed-by: Alain Michaud <alainm@chromium.org>
---

Changes in v4: None
Changes in v3: None
Changes in v2:
- Uses btd_has_kernel_features to detect kernel command support

 src/adapter.c     | 4 ++++
 src/adapter.h     | 1 +
 src/advertising.c | 3 +++
 3 files changed, 8 insertions(+)

diff --git a/src/adapter.c b/src/adapter.c
index c0053000a..0e035172e 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -9640,6 +9640,10 @@ static void read_commands_complete(uint8_t status, uint16_t length,
 			DBG("kernel supports exp features");
 			kernel_features |= KERNEL_EXP_FEATURES;
 			break;
+		case MGMT_OP_ADD_EXT_ADV_PARAMS:
+			DBG("kernel supports ext adv commands");
+			kernel_features |= KERNEL_HAS_EXT_ADV_ADD_CMDS;
+			break;
 		default:
 			break;
 		}
diff --git a/src/adapter.h b/src/adapter.h
index dcc574857..ace72affd 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -233,6 +233,7 @@ enum kernel_features {
 	KERNEL_SET_SYSTEM_CONFIG	= 1 << 2,
 	KERNEL_EXP_FEATURES		= 1 << 3,
 	KERNEL_HAS_RESUME_EVT		= 1 << 4,
+	KERNEL_HAS_EXT_ADV_ADD_CMDS	= 1 << 5,
 };
 
 bool btd_has_kernel_features(uint32_t feature);
diff --git a/src/advertising.c b/src/advertising.c
index c03869e50..7c7599552 100644
--- a/src/advertising.c
+++ b/src/advertising.c
@@ -48,6 +48,7 @@ struct btd_adv_manager {
 	uint8_t max_ads;
 	uint32_t supported_flags;
 	unsigned int instance_bitmap;
+	bool extended_add_cmds;
 };
 
 #define AD_TYPE_BROADCAST 0
@@ -1417,6 +1418,8 @@ static struct btd_adv_manager *manager_create(struct btd_adapter *adapter,
 	manager->mgmt_index = btd_adapter_get_index(adapter);
 	manager->clients = queue_new();
 	manager->supported_flags = MGMT_ADV_FLAG_LOCAL_NAME;
+	manager->extended_add_cmds =
+			btd_has_kernel_features(KERNEL_HAS_EXT_ADV_ADD_CMDS);
 
 	if (!g_dbus_register_interface(btd_get_dbus_connection(),
 					adapter_get_path(manager->adapter),
-- 
2.28.0.709.gb0816b6eb0-goog


  parent reply	other threads:[~2020-10-01 23:02 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-01 23:01 [Bluez PATCH v4 00/10] Bluetooth: Add new MGMT interface for advertising add Daniel Winkler
2020-10-01 23:01 ` [Bluez PATCH v4 01/10] doc/advertising-api: update API with new interface Daniel Winkler
2020-10-27 21:59   ` Luiz Augusto von Dentz
2020-10-01 23:01 ` [Bluez PATCH v4 02/10] doc/mgmt-api: Add new Advertising MGMT interfaces to mgmt-api Daniel Winkler
2020-10-01 23:01 ` [Bluez PATCH v4 03/10] doc/mgmt-api: Update controller capabilities MGMT command in mgmt-api Daniel Winkler
2020-10-01 23:01 ` Daniel Winkler [this message]
2020-10-01 23:01 ` [Bluez PATCH v4 05/10] advertising: Parse intervals and tx power from adv Daniel Winkler
2020-10-27 22:03   ` Luiz Augusto von Dentz
2020-10-01 23:01 ` [Bluez PATCH v4 06/10] advertising: Use new mgmt interface for advertising add Daniel Winkler
2020-10-01 23:01 ` [Bluez PATCH v4 07/10] advertising: Query LE TX range at manager initialization Daniel Winkler
2020-10-27 22:08   ` Luiz Augusto von Dentz
2020-10-01 23:01 ` [Bluez PATCH v4 08/10] advertising: Expose SupportedCapabilities for advertising Daniel Winkler
2020-10-27 22:05   ` Luiz Augusto von Dentz
2020-10-01 23:01 ` [Bluez PATCH v4 09/10] client: Add SupportedCapabilities to bluetoothctl Daniel Winkler
2020-10-01 23:01 ` [Bluez PATCH v4 10/10] monitor: Add new MGMT adv commands and events to monitor Daniel Winkler
2020-10-12 15:53 ` [Bluez PATCH v4 00/10] Bluetooth: Add new MGMT interface for advertising add Daniel Winkler
2020-10-26 22:02 ` Daniel Winkler
2020-10-27 22:13   ` Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201001155738.Bluez.v4.4.I50d9faa25e9da6e71d77c83c7d47a5b135e88799@changeid \
    --to=danielwinkler@google.com \
    --cc=alainm@chromium.org \
    --cc=chromeos-bluetooth-upstreaming@chromium.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.von.dentz@intel.com \
    --cc=sonnysasaka@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).