Skip to contentSkip to conversation

profile: Add support for experimental flag

PATCH In review Luiz Augusto von Dentz 3 participants 12 messages May 16, 2023 – May 17, 2023 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH v2 1/10 profile: Add support for experimental flag

From: Luiz Augusto von Dentz <[email protected]>

This adds experimental field to btd_profile so the plugin can indicate drivers that depends on experimental to be enabled.

---
 src/profile.c | 6 ++++++
 src/profile.h | 5 +++++
 2 files changed, 11 insertions(+)
src/profile.c +6 -0
index e1bebf1ee19c..ea188f36b6dd 100644
@@ -775,6 +775,12 @@ static struct btd_profile *btd_profile_find_uuid(const char *uuid)
 
 int btd_profile_register(struct btd_profile *profile)
 {
+	if (profile->experimental && !(g_dbus_get_flags() &
+					G_DBUS_FLAG_ENABLE_EXPERIMENTAL)) {
+		DBG("D-Bus experimental not enabled");
+		return -ENOTSUP;
+	}
+
 	profiles = g_slist_append(profiles, profile);
 	return 0;
 }
src/profile.h +5 -0
index 6827f848148c..6871f2f0d7d8 100644
@@ -28,6 +28,11 @@ struct btd_profile {
 	 */
 	bool external;
 
+	/* Indicates the profile is experimental and shall only be registered
+	 * when experimental has been enabled (see: main.conf:Experimental).
+	 */
+	bool experimental;
+
 	int (*device_probe) (struct btd_service *service);
 	void (*device_remove) (struct btd_service *service);
 
Signature · 1 line
2.40.1
author maintainer
#1 lore raw

PATCH v2 2/10 bap: Mark driver as experimental

From: Luiz Augusto von Dentz <[email protected]>

This uses the btd_profile.experimental to mark the driver as experimental.

---
 profiles/audio/bap.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
profiles/audio/bap.c +8 -9
index 8f12fc410f67..1a543a9ce99b 100644
@@ -1354,18 +1354,19 @@ static struct btd_profile bap_profile = {
 	.accept		= bap_accept,
 	.disconnect	= bap_disconnect,
 	.auto_connect	= true,
+	.experimental	= true,
 };
 
 static unsigned int bap_id = 0;
 
 static int bap_init(void)
 {
-	if (!(g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL)) {
-		warn("D-Bus experimental not enabled");
-		return -ENOTSUP;
-	}
+	int err;
+
+	err = btd_profile_register(&bap_profile);
+	if (err)
+		return err;
 
-	btd_profile_register(&bap_profile);
 	bap_id = bt_bap_register(bap_attached, bap_detached, NULL);
 
 	return 0;
@@ -1373,10 +1374,8 @@ static int bap_init(void)
 
 static void bap_exit(void)
 {
-	if (g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL) {
-		btd_profile_unregister(&bap_profile);
-		bt_bap_unregister(bap_id);
-	}
+	btd_profile_unregister(&bap_profile);
+	bt_bap_unregister(bap_id);
 }
 
 BLUETOOTH_PLUGIN_DEFINE(bap, VERSION, BLUETOOTH_PLUGIN_PRIORITY_DEFAULT,
Signature · 1 line
2.40.1
author maintainer
#2 lore raw

PATCH v2 3/10 bass: Mark driver as experimental

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

This uses the btd_profile.experimental to mark the driver as experimental.

---
 profiles/audio/bass.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
profiles/audio/bass.c +8 -9
index a7fcc9718d56..fae7fe00412a 100644
@@ -276,18 +276,19 @@ static struct btd_profile bass_service = {
 	.device_remove	= bass_remove,
 	.accept		= bass_accept,
 	.disconnect	= bass_disconnect,
+	.experimental	= true,
 };
 
 static unsigned int bass_id;
 
 static int bass_init(void)
 {
-	if (!(g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL)) {
-		warn("D-Bus experimental not enabled");
-		return -ENOTSUP;
-	}
+	int err;
+
+	err = btd_profile_register(&bass_service);
+	if (err)
+		return err;
 
-	btd_profile_register(&bass_service);
 	bass_id = bt_bass_register(bass_attached, bass_detached, NULL);
 
 	return 0;
@@ -295,10 +296,8 @@ static int bass_init(void)
 
 static void bass_exit(void)
 {
-	if (g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL) {
-		btd_profile_unregister(&bass_service);
-		bt_bass_unregister(bass_id);
-	}
+	btd_profile_unregister(&bass_service);
+	bt_bass_unregister(bass_id);
 }
 
 BLUETOOTH_PLUGIN_DEFINE(bass, VERSION, BLUETOOTH_PLUGIN_PRIORITY_DEFAULT,
Signature · 1 line
2.40.1
author maintainer
#3 lore raw

PATCH v2 4/10 csip: Mark driver as experimental

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

This uses the btd_profile.experimental to mark the driver as experimental.

---
 profiles/audio/csip.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
profiles/audio/csip.c +9 -9
index c273c02b8e76..ec042afd54eb 100644
@@ -334,18 +334,20 @@ static struct btd_profile csip_profile = {
 
 	.adapter_probe	= csip_server_probe,
 	.adapter_remove	= csip_server_remove,
+
+	.experimental	= true,
 };
 
 static unsigned int csip_id;
 
 static int csip_init(void)
 {
-	if (!(g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL)) {
-		warn("D-Bus experimental not enabled");
-		return -ENOTSUP;
-	}
+	int err;
+
+	err = btd_profile_register(&csip_profile);
+	if (err)
+		return err;
 
-	btd_profile_register(&csip_profile);
 	csip_id = bt_csip_register(csip_attached, csip_detached, NULL);
 
 	return 0;
@@ -353,10 +355,8 @@ static int csip_init(void)
 
 static void csip_exit(void)
 {
-	if (g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL) {
-		btd_profile_unregister(&csip_profile);
-		bt_csip_unregister(csip_id);
-	}
+	btd_profile_unregister(&csip_profile);
+	bt_csip_unregister(csip_id);
 }
 
 BLUETOOTH_PLUGIN_DEFINE(csip, VERSION, BLUETOOTH_PLUGIN_PRIORITY_DEFAULT,
Signature · 1 line
2.40.1
author maintainer
#4 lore raw

PATCH v2 5/10 mcp: Mark driver as experimental

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

This uses the btd_profile.experimental to mark the driver as experimental.

---
 profiles/audio/mcp.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)
profiles/audio/mcp.c +4 -13
index f3ea330f9839..b410b3d2aa03 100644
@@ -403,27 +403,18 @@ static struct btd_profile mcp_profile = {
 
 	.adapter_probe	= media_control_server_probe,
 	.adapter_remove = media_control_server_remove,
+
+	.experimental	= true,
 };
 
 static int mcp_init(void)
 {
-	DBG("");
-
-	if (!(g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL)) {
-		warn("D-Bus experimental not enabled");
-		return -ENOTSUP;
-	}
-
-	btd_profile_register(&mcp_profile);
-	return 0;
+	return btd_profile_register(&mcp_profile);
 }
 
 static void mcp_exit(void)
 {
-	DBG("");
-
-	if (g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL)
-		btd_profile_unregister(&mcp_profile);
+	btd_profile_unregister(&mcp_profile);
 }
 
 BLUETOOTH_PLUGIN_DEFINE(mcp, VERSION, BLUETOOTH_PLUGIN_PRIORITY_DEFAULT,
Signature · 1 line
2.40.1
author maintainer
#5 lore raw

PATCH v2 6/10 vcp: Mark driver as experimental

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

This uses the btd_profile.experimental to mark the driver as experimental.

---
 profiles/audio/vcp.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
profiles/audio/vcp.c +9 -9
index b42b0a4f79dd..175275f2e977 100644
@@ -289,18 +289,20 @@ static struct btd_profile vcp_profile = {
 
 	.adapter_probe = vcp_server_probe,
 	.adapter_remove = vcp_server_remove,
+
+	.experimental	= true,
 };
 
 static unsigned int vcp_id = 0;
 
 static int vcp_init(void)
 {
-	if (!(g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL)) {
-		warn("D-Bus experimental not enabled");
-		return -ENOTSUP;
-	}
+	int err;
+
+	err = btd_profile_register(&vcp_profile);
+	if (err)
+		return err;
 
-	btd_profile_register(&vcp_profile);
 	vcp_id = bt_vcp_register(vcp_attached, vcp_detached, NULL);
 
 	return 0;
@@ -308,10 +310,8 @@ static int vcp_init(void)
 
 static void vcp_exit(void)
 {
-	if (g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL) {
-		btd_profile_unregister(&vcp_profile);
-		bt_vcp_unregister(vcp_id);
-	}
+	btd_profile_unregister(&vcp_profile);
+	bt_vcp_unregister(vcp_id);
 }
 
 BLUETOOTH_PLUGIN_DEFINE(vcp, VERSION, BLUETOOTH_PLUGIN_PRIORITY_DEFAULT,
Signature · 1 line
2.40.1
author maintainer
#6 lore raw

PATCH v2 7/10 plugin: Treat -ENOTSUP as -ENOSYS

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

If plugin .init returns -ENOTSUP treat it as the system doesn't support the driver since that is the error returned by btd_profile_register when experimental is disabled.

---
 src/plugin.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/plugin.c +1 -1
index dd7b406c857b..80990f8c3c7e 100644
@@ -186,7 +186,7 @@ start:
 
 		err = plugin->desc->init();
 		if (err < 0) {
-			if (err == -ENOSYS)
+			if (err == -ENOSYS || err == -ENOTSUP)
 				warn("System does not support %s plugin",
 							plugin->desc->name);
 			else
Signature · 1 line
2.40.1
author maintainer
#7 lore raw

PATCH v2 8/10 adapter: Add support for experimental flag

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

This adds experimental field to btd_adapter_driver so the plugin can indicate drivers that depends on experimental to be enabled.

---
 src/adapter.c | 6 ++++++
 src/adapter.h | 5 +++++
 2 files changed, 11 insertions(+)
src/adapter.c +6 -0
index cc7f891d96d9..74ed52468b81 100644
@@ -7447,6 +7447,12 @@ static void adapter_stop(struct btd_adapter *adapter)
 
 int btd_register_adapter_driver(struct btd_adapter_driver *driver)
 {
+	if (driver->experimental && !(g_dbus_get_flags() &
+					G_DBUS_FLAG_ENABLE_EXPERIMENTAL)) {
+		DBG("D-Bus experimental not enabled");
+		return -ENOTSUP;
+	}
+
 	adapter_drivers = g_slist_append(adapter_drivers, driver);
 
 	if (driver->probe == NULL)
src/adapter.h +5 -0
index a45ac1bab00e..32e49a933b13 100644
@@ -127,6 +127,11 @@ struct btd_adapter_driver {
 						struct btd_device *device);
 	void (*device_resolved)(struct btd_adapter *adapter,
 						struct btd_device *device);
+
+	/* Indicates the driver is experimental and shall only be registered
+	 * when experimental has been enabled (see: main.conf:Experimental).
+	 */
+	bool experimental;
 };
 
 void device_resolved_drivers(struct btd_adapter *adapter,
Signature · 1 line
2.40.1
author maintainer
#8 lore raw

PATCH v2 9/10 admin: Mark driver as experimental

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

This uses the btd_profile.experimental to mark the driver as experimental.

---
 plugins/admin.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
plugins/admin.c +2 -5
index 0787e8381ed7..68e9237d3fbd 100644
@@ -618,13 +618,12 @@ static struct btd_adapter_driver admin_policy_driver = {
 	.resume = NULL,
 	.remove = admin_policy_remove,
 	.device_resolved = admin_policy_device_added,
-	.device_removed = admin_policy_device_removed
+	.device_removed = admin_policy_device_removed,
+	.experimental = true,
 };
 
 static int admin_init(void)
 {
-	DBG("");
-
 	dbus_conn = btd_get_dbus_connection();
 
 	return btd_register_adapter_driver(&admin_policy_driver);
@@ -632,8 +631,6 @@ static int admin_init(void)
 
 static void admin_exit(void)
 {
-	DBG("");
-
 	btd_unregister_adapter_driver(&admin_policy_driver);
 }
 
Signature · 1 line
2.40.1
author maintainer
#9 lore raw

PATCH v2 10/10 main: Rework config option parsing

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

This rework config option parsing adding helper function to make it simpler to parse new options.

---
 src/btd.h  |  14 +-
 src/main.c | 848 +++++++++++++++++++++++++++--------------------------
 2 files changed, 442 insertions(+), 420 deletions(-)
src/btd.h +7 -7
index 70051c71c7c1..b7e7ebd618cf 100644
@@ -111,7 +111,7 @@ struct btd_advmon_opts {
 struct btd_opts {
 	char		*name;
 	uint32_t	class;
-	gboolean	pairable;
+	bool		pairable;
 	uint32_t	pairto;
 	uint32_t	discovto;
 	uint32_t	tmpto;
@@ -122,12 +122,12 @@ struct btd_opts {
 
 	struct btd_defaults defaults;
 
-	gboolean	reverse_discovery;
-	gboolean	name_resolv;
-	gboolean	debug_keys;
-	gboolean	fast_conn;
-	gboolean	refresh_discovery;
-	gboolean	experimental;
+	bool		reverse_discovery;
+	bool		name_resolv;
+	bool		debug_keys;
+	bool		fast_conn;
+	bool		refresh_discovery;
+	bool		experimental;
 	struct queue	*kernel;
 
 	uint16_t	did_source;
src/main.c +435 -413

893 lines not on this page · raw message

Signature · 1 line
2.40.1
#10 lore raw
In reply to Luiz Augusto von Dentz

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=748169

---Test result---

Test Summary:

CheckPatch                    FAIL      6.73 seconds
GitLint                       PASS      3.96 seconds
BuildEll                      PASS      35.64 seconds
BluezMake                     PASS      1248.12 seconds
MakeCheck                     PASS      12.92 seconds
MakeDistcheck                 PASS      205.33 seconds
CheckValgrind                 PASS      331.37 seconds
CheckSmatch                   PASS      451.09 seconds
bluezmakeextell               PASS      135.40 seconds
IncrementalBuild              PASS      10357.78 seconds
ScanBuild                     PASS      1362.35 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[v2,07/10] plugin: Treat -ENOTSUP as -ENOSYS WARNING:ENOSYS: ENOSYS means 'invalid syscall nr' and nothing else #101: FILE: src/plugin.c:189:
+ if (err == -ENOSYS || err == -ENOTSUP)

/github/workspace/src/src/13243878.patch total: 0 errors, 1 warnings, 8 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.

/github/workspace/src/src/13243878.patch has style problems, please review.

NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO

NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.

---
Regards,
Linux Bluetooth

#11 lore raw
In reply to Luiz Augusto von Dentz
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 8 lines · On Tue, 16 May 2023 13:59:15 -0700 you wrote:

From: Luiz Augusto von Dentz <[email protected]>

This adds experimental field to btd_profile so the plugin can indicate drivers that depends on experimental to be enabled.

---
 src/profile.c | 6 ++++++
 src/profile.h | 5 +++++
 2 files changed, 11 insertions(+)

Here is the summary with links:
- [v2,01/10] profile: Add support for experimental flag

    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=67c5824fd071
  - [v2,02/10] bap: Mark driver as experimental
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=da762dfa0255
  - [v2,03/10] bass: Mark driver as experimental
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=bd14ad2e1f50
  - [v2,04/10] csip: Mark driver as experimental
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=16da92601f4a
  - [v2,05/10] mcp: Mark driver as experimental
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=62cbb2a9f57d
  - [v2,06/10] vcp: Mark driver as experimental
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=2fa20fe9fc4a
  - [v2,07/10] plugin: Treat -ENOTSUP as -ENOSYS
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=ce7cd9fb0611
  - [v2,08/10] adapter: Add support for experimental flag
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=28917a3c7a4e
  - [v2,09/10] admin: Mark driver as experimental
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=943be6271d77

- [v2,10/10] main: Rework config option parsing
(no matching commit)

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html