advertising: Detect if extended advertising mgmt commands are supported
authorDaniel Winkler <danielwinkler@google.com>
Thu, 29 Oct 2020 23:06:16 +0000 (16:06 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:33 +0000 (19:08 +0530)
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.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
lib/mgmt.h
src/adapter.c
src/adapter.h
src/advertising.c

index 28e9b6a..31006e3 100644 (file)
@@ -710,6 +710,10 @@ struct mgmt_rp_remove_adv_monitor {
        uint16_t monitor_handle;
 } __packed;
 
+#define MGMT_OP_ADD_EXT_ADV_PARAMS             0x0054
+
+#define MGMT_OP_ADD_EXT_ADV_DATA               0x0055
+
 #define MGMT_EV_CMD_COMPLETE           0x0001
 struct mgmt_ev_cmd_complete {
        uint16_t opcode;
index eddfeb2..e530943 100644 (file)
@@ -15948,6 +15948,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;
                }
index 3b5573c..8e6eaf3 100644 (file)
@@ -326,6 +326,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);
index 30c0015..2b15b3b 100644 (file)
@@ -43,6 +43,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
@@ -1412,6 +1413,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),