Bluetooth: Report num supported adv instances for hw offloading
authorDaniel Winkler <danielwinkler@google.com>
Tue, 25 Aug 2020 23:31:50 +0000 (16:31 -0700)
committerMarcel Holtmann <marcel@holtmann.org>
Fri, 11 Sep 2020 07:17:25 +0000 (09:17 +0200)
Here we make sure we properly report the number of supported
advertising slots when we are using hardware offloading. If no
hardware offloading is available, we default this value to
HCI_MAX_ADV_INSTANCES for use in software rotation as before.

This change has been tested on kukui (no ext adv) and hatch (ext adv)
chromebooks by verifying "SupportedInstances" shows 5 (the default) and
6 (slots supported by controller), respectively.

Signed-off-by: Daniel Winkler <danielwinkler@google.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
net/bluetooth/hci_core.c
net/bluetooth/mgmt.c

index be9cdf5dabe5dcecc1229adfeec46d84037b6e84..ef32b12f150cd1d8e1c1ce6dbb6490fb6d6a6515 100644 (file)
@@ -2963,7 +2963,7 @@ int hci_add_adv_instance(struct hci_dev *hdev, u8 instance, u32 flags,
                       sizeof(adv_instance->scan_rsp_data));
        } else {
                if (hdev->adv_instance_cnt >= hdev->le_num_of_adv_sets ||
-                   instance < 1 || instance > HCI_MAX_ADV_INSTANCES)
+                   instance < 1 || instance > hdev->le_num_of_adv_sets)
                        return -EOVERFLOW;
 
                adv_instance = kzalloc(sizeof(*adv_instance), GFP_KERNEL);
index f96251f818fc7dc7f1f63ba0905fdcc48a755027..e9f4ce2bbb94858cf8928a4c54862b0ee1311673 100644 (file)
@@ -7254,7 +7254,7 @@ static int read_adv_features(struct sock *sk, struct hci_dev *hdev,
        rp->supported_flags = cpu_to_le32(supported_flags);
        rp->max_adv_data_len = HCI_MAX_AD_LENGTH;
        rp->max_scan_rsp_len = HCI_MAX_AD_LENGTH;
-       rp->max_instances = HCI_MAX_ADV_INSTANCES;
+       rp->max_instances = hdev->le_num_of_adv_sets;
        rp->num_instances = hdev->adv_instance_cnt;
 
        instance = rp->instance;
@@ -7450,7 +7450,7 @@ static int add_advertising(struct sock *sk, struct hci_dev *hdev,
                return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_ADVERTISING,
                                       MGMT_STATUS_NOT_SUPPORTED);
 
-       if (cp->instance < 1 || cp->instance > HCI_MAX_ADV_INSTANCES)
+       if (cp->instance < 1 || cp->instance > hdev->le_num_of_adv_sets)
                return mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_ADVERTISING,
                                       MGMT_STATUS_INVALID_PARAMS);
 
@@ -7703,7 +7703,7 @@ static int get_adv_size_info(struct sock *sk, struct hci_dev *hdev,
                return mgmt_cmd_status(sk, hdev->id, MGMT_OP_GET_ADV_SIZE_INFO,
                                       MGMT_STATUS_REJECTED);
 
-       if (cp->instance < 1 || cp->instance > HCI_MAX_ADV_INSTANCES)
+       if (cp->instance < 1 || cp->instance > hdev->le_num_of_adv_sets)
                return mgmt_cmd_status(sk, hdev->id, MGMT_OP_GET_ADV_SIZE_INFO,
                                       MGMT_STATUS_INVALID_PARAMS);