Commit Graph

160 Commits

Author SHA1 Message Date
Gopal Tiwari 54d8fbc3b7 Bluetooth: hci_sync: Convert MGMT_OP_GET_CONN_INFO
Bugzilla: http://bugzilla.redhat.com/2066188

commit 47db6b42991e6d5645d0938e43085aaf88cdfba4
Author: Brian Gix <brian.gix@intel.com>
Date:   Wed Oct 27 16:58:48 2021 -0700

    Bluetooth: hci_sync: Convert MGMT_OP_GET_CONN_INFO

    Synchronous version of MGMT_OP_GET_CONN_INFO

    Implements:
      hci_read_rssi_sync
      hci_read_tx_power_sync

    Signed-off-by: Brian Gix <brian.gix@intel.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

Signed-off-by: Gopal Tiwari <gtiwari@redhat.com>
2022-04-27 11:49:00 +05:30
Gopal Tiwari 789e5bacea Bluetooth: hci_sync: Enable synch'd set_bredr
Bugzilla: http://bugzilla.redhat.com/2066188

commit 451d95a98c5a350da2f2c5447cc17115a5b94c8e
Author: Brian Gix <brian.gix@intel.com>
Date:   Wed Oct 27 16:58:47 2021 -0700

    Bluetooth: hci_sync: Enable synch'd set_bredr

    Uses previously written:
      hci_write_fast_connectable_sync
      hci_update_scan_sync
      hci_update_adv_data_sync

    Signed-off-by: Brian Gix <brian.gix@intel.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

Signed-off-by: Gopal Tiwari <gtiwari@redhat.com>
2022-04-27 11:49:00 +05:30
Gopal Tiwari 742580ae9e Bluetooth: hci_sync: Convert MGMT_OP_SET_FAST_CONNECTABLE
Bugzilla: http://bugzilla.redhat.com/2066188

commit 353a0249c3f60365c55d53e2d068de4f43669a22
Author: Brian Gix <brian.gix@intel.com>
Date:   Wed Oct 27 16:58:46 2021 -0700

    Bluetooth: hci_sync: Convert MGMT_OP_SET_FAST_CONNECTABLE

    This creates a synchronized Write Fast Connectable call and attaches it
    to the MGMT_OP_SET_FAST_CONNECTABLE management opcode.

    Signed-off-by: Brian Gix <brian.gix@intel.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

Signed-off-by: Gopal Tiwari <gtiwari@redhat.com>
2022-04-27 11:49:00 +05:30
Gopal Tiwari d7fdf397ed Bluetooth: hci_sync: Rework background scan
Bugzilla: http://bugzilla.redhat.com/2066188

commit 5bee2fd6bcaaaa9f8f415afc48ed8c1083d8a303
Author: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Date:   Wed Oct 27 16:58:43 2021 -0700

    Bluetooth: hci_sync: Rework background scan

    This replaces the use of hci_update_background_scan with
    hci_update_passive_scan which runs from cmd_work_sync and deal properly
    with resolving list when LL privacy is enabled.

    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

Signed-off-by: Gopal Tiwari <gtiwari@redhat.com>
2022-04-27 11:49:00 +05:30
Gopal Tiwari 9ba515542d Bluetooth: hci_sync: Convert MGMT_SET_POWERED
Bugzilla: http://bugzilla.redhat.com/2066188

commit cf75ad8b41d2aa06f98f365d42a3ae8b059daddd
Author: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Date:   Wed Oct 27 16:58:44 2021 -0700

    Bluetooth: hci_sync: Convert MGMT_SET_POWERED

    This make use of hci_cmd_sync_queue when MGMT_SET_POWERED is used so all
    commands are run within hdev->cmd_sync_work instead of
    hdev->power_on_work and hdev->power_off_work.

    In addition to that the power on sequence now takes into account if
    local IRK needs to be programmed in the resolving list.

    Tested with:

    tools/mgmt-tester -s "Set powered"

    Test Summary
    ------------
    Set powered on - Success                             Passed
    Set powered on - Invalid parameters 1                Passed
    Set powered on - Invalid parameters 2                Passed
    Set powered on - Invalid parameters 3                Passed
    Set powered on - Invalid index                       Passed
    Set powered on - Privacy and Advertising             Passed
    Set powered off - Success                            Passed
    Set powered off - Class of Device                    Passed
    Set powered off - Invalid parameters 1               Passed
    Set powered off - Invalid parameters 2               Passed
    Set powered off - Invalid parameters 3               Passed
    Total: 11, Passed: 11 (100.0%), Failed: 0, Not Run: 0

    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

Signed-off-by: Gopal Tiwari <gtiwari@redhat.com>
2022-04-27 11:49:00 +05:30
Gopal Tiwari 34a3e7a934 Bluetooth: hci_sync: Enable advertising when LL privacy is enabled
Bugzilla: http://bugzilla.redhat.com/2066188

commit ad383c2c65a5baf16e334cd40a013cc302176891
Author: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Date:   Wed Oct 27 16:58:42 2021 -0700

    Bluetooth: hci_sync: Enable advertising when LL privacy is enabled

    This enables advertising when LL privacy is enabled and changes the
    command sequence when resolving list is updated to also account for when
    advertising is enabled using the following sequence:

    If there are devices to scan:

    Disable Scanning -> Update Accept List ->
    use_ll_privacy((Disable Advertising) -> Disable Resolving List ->
    Update Resolving List -> Enable Resolving List -> (Enable Advertising)) ->
    Enable Scanning

    Otherwise:

    Disable Scanning

    Errors during the Update Accept List stage are handled gracefully by
    restoring any previous state (e.g. advertising) and disabling the use of
    accept list as either accept list or resolving list could not be
    updated.

    Tested with:

    mgmt-tester -s "LL Privacy"

    Test Summary
    ------------
    LL Privacy - Add Device 1 (Add to WL)                Passed
    LL Privacy - Add Device 2 (Add to RL)                Passed
    LL Privacy - Add Device 3 (Enable RL)                Passed
    LL Privacy - Add Device 4 (2 Devices to WL)          Passed
    LL Privacy - Add Device 5 (2 Devices to RL)          Passed
    LL Privacy - Add Device 6 (RL is full)               Passed
    LL Privacy - Add Device 7 (WL is full)               Passed
    LL Privacy - Add Device 8 (Disable Adv)              Passed
    LL Privacy - Add Device 9 (Multi Adv)                Passed
    LL Privacy - Add Device 10 (Multi Dev and Multi Adv) Passed
    LL Privacy - Remove Device 1 (Remove from WL)        Passed
    LL Privacy - Remove Device 2 (Remove from RL)        Passed
    LL Privacy - Remove Device 3 (Disable RL)            Passed
    LL Privacy - Remove Device 4 (Disable Adv)           Passed
    LL Privacy - Remove Device 5 (Multi Adv)             Passed
    LL Privacy - Start Discovery 1 (Disable RL)          Passed
    LL Privacy - Start Discovery 2 (Disable RL)          Passed
    Total: 18, Passed: 18 (100.0%), Failed: 0, Not Run: 0

    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

Signed-off-by: Gopal Tiwari <gtiwari@redhat.com>
2022-04-27 11:49:00 +05:30
Gopal Tiwari 64122ee349 Bluetooth: hci_sync: Make use of hci_cmd_sync_queue set 3
Bugzilla: http://bugzilla.redhat.com/2066188

commit e8907f76544ffe225ab95d70f7313267b1d0c76d
Author: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Date:   Wed Oct 27 16:58:41 2021 -0700

    Bluetooth: hci_sync: Make use of hci_cmd_sync_queue set 3

    This make use of hci_cmd_sync_queue for the following MGMT commands:

        Add Device
        Remove Device

    Tested with:

    mgmt-tester -s "Add Device"

    Test Summary
    ------------
    Add Device - Invalid Params 1                        Passed
    Add Device - Invalid Params 2                        Passed
    Add Device - Invalid Params 3                        Passed
    Add Device - Invalid Params 4                        Passed
    Add Device - Success 1                               Passed
    Add Device - Success 2                               Passed
    Add Device - Success 3                               Passed
    Add Device - Success 4                               Passed
    Add Device - Success 5                               Passed
    Add Device - Success 6 - Add to whitelist            Passed
    Add Device - Success 7 - Add to resolv list          Passed
    Add Device - Success 8 - Enable resolv list          Passed
    Total: 12, Passed: 12 (100.0%), Failed: 0, Not Run: 0
    Overall execution time: 0.209 seconds

    mgmt-tester -s "Remove Device"

    Test Summary
    ------------
    Remove Device - Invalid Params 1                     Passed
    Remove Device - Invalid Params 2                     Passed
    Remove Device - Invalid Params 3                     Passed
    Remove Device - Success 1                            Passed
    Remove Device - Success 2                            Passed
    Remove Device - Success 3                            Passed
    Remove Device - Success 4                            Passed
    Remove Device - Success 5                            Passed
    Remove Device - Success 6 - All Devices              Passed
    Remove Device - Success 7 - Remove from whitelist    Passed
    Remove Device - Success 8 - Remove from resolv list  Passed
    Total: 11, Passed: 11 (100.0%), Failed: 0, Not Run: 0
    Overall execution time: 4.26 seconds

    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

Signed-off-by: Gopal Tiwari <gtiwari@redhat.com>
2022-04-27 11:49:00 +05:30
Gopal Tiwari bd45fc5556 Bluetooth: hci_sync: Make use of hci_cmd_sync_queue set 2
Bugzilla: http://bugzilla.redhat.com/2066188

commit cba6b758711cab946c787f7c15be92cc749b8e1f
Author: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Date:   Wed Oct 27 16:58:40 2021 -0700

    Bluetooth: hci_sync: Make use of hci_cmd_sync_queue set 2

    This make use of hci_cmd_sync_queue for the following MGMT commands:

    Add Advertising
    Remove Advertising
    Add Extended Advertising Parameters
    Add Extended Advertising Data

    mgmt-tester -s "Add Advertising"

    Test Summary
    ------------
    Add Advertising - Failure: LE off                    Passed
    Add Advertising - Invalid Params 1 (AD too long)     Passed
    Add Advertising - Invalid Params 2 (Malformed len)   Passed
    Add Advertising - Invalid Params 3 (Malformed len)   Passed
    Add Advertising - Invalid Params 4 (Malformed len)   Passed
    Add Advertising - Invalid Params 5 (AD too long)     Passed
    Add Advertising - Invalid Params 6 (ScRsp too long)  Passed
    Add Advertising - Invalid Params 7 (Malformed len)   Passed
    Add Advertising - Invalid Params 8 (Malformed len)   Passed
    Add Advertising - Invalid Params 9 (Malformed len)   Passed
    Add Advertising - Invalid Params 10 (ScRsp too long) Passed
    Add Advertising - Rejected (Timeout, !Powered)       Passed
    Add Advertising - Success 1 (Powered, Add Adv Inst)  Passed
    Add Advertising - Success 2 (!Powered, Add Adv Inst) Passed
    Add Advertising - Success 3 (!Powered, Adv Enable)   Passed
    Add Advertising - Success 4 (Set Adv on override)    Passed
    Add Advertising - Success 5 (Set Adv off override)   Passed
    Add Advertising - Success 6 (Scan Rsp Dta, Adv ok)   Passed
    Add Advertising - Success 7 (Scan Rsp Dta, Scan ok)  Passed
    Add Advertising - Success 8 (Connectable Flag)       Passed
    Add Advertising - Success 9 (General Discov Flag)    Passed
    Add Advertising - Success 10 (Limited Discov Flag)   Passed
    Add Advertising - Success 11 (Managed Flags)         Passed
    Add Advertising - Success 12 (TX Power Flag)         Passed
    Add Advertising - Success 13 (ADV_SCAN_IND)          Passed
    Add Advertising - Success 14 (ADV_NONCONN_IND)       Passed
    Add Advertising - Success 15 (ADV_IND)               Passed
    Add Advertising - Success 16 (Connectable -> on)     Passed
    Add Advertising - Success 17 (Connectable -> off)    Passed
    Add Advertising - Success 18 (Power -> off, Remove)  Passed
    Add Advertising - Success 19 (Power -> off, Keep)    Passed
    Add Advertising - Success 20 (Add Adv override)      Passed
    Add Advertising - Success 21 (Timeout expires)       Passed
    Add Advertising - Success 22 (LE -> off, Remove)     Passed
    Add Advertising - Success (Empty ScRsp)              Passed
    Add Advertising - Success (ScRsp only)               Passed
    Add Advertising - Invalid Params (ScRsp too long)    Passed
    Add Advertising - Success (ScRsp appear)             Passed
    Add Advertising - Invalid Params (ScRsp appear long) Passed
    Add Advertising - Success (Appear is null)           Passed
    Add Advertising - Success (Name is null)             Passed
    Add Advertising - Success (Complete name)            Passed
    Add Advertising - Success (Shortened name)           Passed
    Add Advertising - Success (Short name)               Passed
    Add Advertising - Success (Name + data)              Passed
    Add Advertising - Invalid Params (Name + data)       Passed
    Add Advertising - Success (Name+data+appear)         Passed
    Total: 47, Passed: 47 (100.0%), Failed: 0, Not Run: 0
    Overall execution time: 2.17 seconds

    mgmt-tester -s "Remove Advertising"

    Test Summary
    ------------
    Remove Advertising - Invalid Params 1                Passed
    Remove Advertising - Success 1                       Passed
    Remove Advertising - Success 2                       Passed
    Total: 3, Passed: 3 (100.0%), Failed: 0, Not Run: 0
    Overall execution time: 0.0585 seconds

    mgmt-tester -s "Ext Adv MGMT Params"

    Test Summary:
    ------------
    Ext Adv MGMT Params - Unpowered                      Passed
    Ext Adv MGMT Params - Invalid parameters             Passed
    Ext Adv MGMT Params - Success                        Passed
    Ext Adv MGMT Params - (5.0) Success                  Passed
    Total: 4, Passed: 4 (100.0%), Failed: 0, Not Run: 0
    Overall execution time: 0.0746 seconds

    mgmt-tester -s "Ext Adv MGMT -"

    Test Summary
    ------------
    Ext Adv MGMT - Data set without Params               Passed
    Ext Adv MGMT - AD Data (5.0) Invalid parameters      Passed
    Ext Adv MGMT - AD Data (5.0) Success                 Passed
    Ext Adv MGMT - AD Scan Response (5.0) Success        Passed
    Total: 4, Passed: 4 (100.0%), Failed: 0, Not Run: 0
    Overall execution time: 0.0805 seconds

    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

Signed-off-by: Gopal Tiwari <gtiwari@redhat.com>
2022-04-27 11:49:00 +05:30
Gopal Tiwari 8b5661c87d Bluetooth: hci_sync: Make use of hci_cmd_sync_queue set 1
Bugzilla: http://bugzilla.redhat.com/2066188

commit 161510ccf91c961638940b03abb1ee804be53a97
Author: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Date:   Wed Oct 27 16:58:39 2021 -0700

    Bluetooth: hci_sync: Make use of hci_cmd_sync_queue set 1

    This make use of hci_cmd_sync_queue for the following MGMT commands:

    Set Device Class
    Set Device ID
    Add UUID
    Remove UUID

    tools/mgmt-tester -s "Set Device Class"

    Test Summary
    ------------
    Set Device Class - Success 1                         Passed
    Set Device Class - Success 2                         Passed
    Set Device Class - Invalid parameters 1              Passed
    Total: 3, Passed: 3 (100.0%), Failed: 0, Not Run: 0
    Overall execution time: 0.0599 seconds

    tools/mgmt-tester -s "Set Device ID"

    Test Summary
    ------------
    Set Device ID - Success 1                            Passed
    Set Device ID - Success 2                            Passed
    Set Device ID - Disable                              Passed
    Set Device ID - Power off and Power on               Passed
    Set Device ID - SSP off and Power on                 Passed
    Set Device ID - Invalid Parameter                    Passed
    Total: 6, Passed: 6 (100.0%), Failed: 0, Not Run: 0
    Overall execution time: 0.107 seconds

    tools/mgmt-tester -s "Add UUID"

    Test Summary
    ------------
    Add UUID - UUID-16 1                                 Passed
    Add UUID - UUID-16 multiple 1                        Passed
    Add UUID - UUID-16 partial 1                         Passed
    Add UUID - UUID-32 1                                 Passed
    Add UUID - UUID-32 multiple 1                        Passed
    Add UUID - UUID-32 partial 1                         Passed
    Add UUID - UUID-128 1                                Passed
    Add UUID - UUID-128 multiple 1                       Passed
    Add UUID - UUID-128 partial 1                        Passed
    Add UUID - UUID mix                                  Passed
    Total: 10, Passed: 10 (100.0%), Failed: 0, Not Run: 0
    Overall execution time: 0.198 seconds

    tools/mgmt-tester -s "Remove UUID"

    Test Summary
    ------------
    Remove UUID - Success 1                              Passed
    Remove UUID - All UUID - Success 2                   Passed
    Remove UUID - Power Off - Success 3                  Passed
    Remove UUID - Power Off and On - Success 4           Passed
    Remove UUID - Not Exist - Invalid Params 1           Passed
    Total: 5, Passed: 5 (100.0%), Failed: 0, Not Run: 0
    Overall execution time: 0.0908 seconds

    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

Signed-off-by: Gopal Tiwari <gtiwari@redhat.com>
2022-04-27 11:49:00 +05:30
Gopal Tiwari f41872e1ab Bluetooth: Add helper for serialized HCI command execution
Bugzilla: http://bugzilla.redhat.com/2066188

commit 6a98e3836fa2077b169f10a35c2ca9952d53f987
Author: Marcel Holtmann <marcel@holtmann.org>
Date:   Wed Oct 27 16:58:38 2021 -0700

    Bluetooth: Add helper for serialized HCI command execution

    The usage of __hci_cmd_sync() within the hdev->setup() callback allows for
    a nice and simple serialized execution of HCI commands. More importantly
    it allows for result processing before issueing the next command.

    With the current usage of hci_req_run() it is possible to batch up
    commands and execute them, but it is impossible to react to their
    results or errors.

    This is an attempt to generalize the hdev->setup() handling and provide
    a simple way of running multiple HCI commands from a single function
    context.

    There are multiple struct work that are decdicated to certain tasks
    already used right now. It is add a lot of bloat to hci_dev struct and
    extra handling code. So it might be possible to put all of these behind
    a common HCI command infrastructure and just execute the HCI commands
    from the same work context in a serialized fashion.

    For example updating the white list and resolving list can be done now
    without having to know the list size ahead of time. Also preparing for
    suspend or resume shouldn't require a state machine anymore. There are
    other tasks that should be simplified as well.

    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

Signed-off-by: Gopal Tiwari <gtiwari@redhat.com>
2022-04-27 11:48:59 +05:30