aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hci_request.c
Commit message (Collapse)AuthorAgeFilesLines
...
* | bluetooth: eliminate the potential race condition when removing the HCI ↵Lin Ma2021-04-231-4/+8
|/ | | | | | | | | | | | | | | | | | | | | | controller There is a possible race condition vulnerability between issuing a HCI command and removing the cont. Specifically, functions hci_req_sync() and hci_dev_do_close() can race each other like below: thread-A in hci_req_sync() | thread-B in hci_dev_do_close() | hci_req_sync_lock(hdev); test_bit(HCI_UP, &hdev->flags); | ... | test_and_clear_bit(HCI_UP, &hdev->flags) hci_req_sync_lock(hdev); | | In this commit we alter the sequence in function hci_req_sync(). Hence, the thread-A cannot issue th. Signed-off-by: Lin Ma <[email protected]> Cc: Marcel Holtmann <[email protected]> Fixes: 7c6a329e4447 ("[Bluetooth] Fix regression from using default link policy") Signed-off-by: Greg Kroah-Hartman <[email protected]>
* Bluetooth: disable advertisement filters during suspendHoward Chung2021-01-251-0/+29
| | | | | | | | | | This adds logic to disable and reenable advertisement filters during suspend and resume. After this patch, we would only receive packets from devices in allow list during suspend. Signed-off-by: Howard Chung <[email protected]> Reviewed-by: Abhishek Pandit-Subedi <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: advmon offload MSFT interleave scanning integrationArchie Pusaka2021-01-251-9/+11
| | | | | | | | | When MSFT extension is supported, we don't have to interleave the scan as we could just do allowlist scan. Signed-off-by: Archie Pusaka <[email protected]> Reviewed-by: Miao-chen Chou <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: Remove hci_req_le_suspend_configAbhishek Pandit-Subedi2020-12-181-17/+8
| | | | | | | | | | | Add a missing SUSPEND_SCAN_ENABLE in passive scan, remove the separate function for configuring le scan during suspend and update the request complete function to clear both enable and disable tasks. Fixes: dce0a4be8054 ("Bluetooth: Set missing suspend task bits") Reviewed-by: Alain Michaud <[email protected]> Signed-off-by: Abhishek Pandit-Subedi <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: Set missing suspend task bitsAbhishek Pandit-Subedi2020-12-071-0/+8
| | | | | | | | | | | When suspending, mark SUSPEND_SCAN_ENABLE and SUSPEND_SCAN_DISABLE tasks correctly when either classic or le scanning is modified. Signed-off-by: Abhishek Pandit-Subedi <[email protected]> Signed-off-by: Howard Chung <[email protected]> Reviewed-by: Alain Michaud <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]> Signed-off-by: Johan Hedberg <[email protected]>
* Bluetooth: Use intervals and tx power from mgmt cmdsDaniel Winkler2020-12-071-10/+19
| | | | | | | | | | | | | | | | | | | This patch takes the min/max intervals and tx power optionally provided in mgmt interface, stores them in the advertisement struct, and uses them when configuring the hci requests. While tx power is not used if extended advertising is unavailable, software rotation will use the min and max advertising intervals specified by the client. This change is validated manually by ensuring the min/max intervals are propagated to the controller on both hatch (extended advertising) and kukui (no extended advertising) chromebooks, and that tx power is propagated correctly on hatch. These tests are performed with multiple advertisements simultaneously. Reviewed-by: Sonny Sasaka <[email protected]> Signed-off-by: Daniel Winkler <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]> Signed-off-by: Johan Hedberg <[email protected]>
* Bluetooth: Add toggle to switch off interleave scanHoward Chung2020-12-071-1/+2
| | | | | | | | | | This patch add a configurable parameter to switch off the interleave scan feature. Signed-off-by: Howard Chung <[email protected]> Reviewed-by: Alain Michaud <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]> Signed-off-by: Johan Hedberg <[email protected]>
* Bluetooth: Handle active scan caseHoward Chung2020-12-071-1/+3
| | | | | | | | | | | | This patch adds code to handle the active scan during interleave scan. The interleave scan will be canceled when users start active scan, and it will be restarted after active scan stopped. Signed-off-by: Howard Chung <[email protected]> Reviewed-by: Alain Michaud <[email protected]> Reviewed-by: Manish Mandlik <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]> Signed-off-by: Johan Hedberg <[email protected]>
* Bluetooth: Handle system suspend resume caseHoward Chung2020-12-071-1/+3
| | | | | | | | | | | | | | This patch adds code to handle the system suspension during interleave scan. The interleave scan will be canceled when the system is going to sleep, and will be restarted after waking up. Signed-off-by: Howard Chung <[email protected]> Reviewed-by: Alain Michaud <[email protected]> Reviewed-by: Manish Mandlik <[email protected]> Reviewed-by: Abhishek Pandit-Subedi <[email protected]> Reviewed-by: Miao-chen Chou <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]> Signed-off-by: Johan Hedberg <[email protected]>
* Bluetooth: Interleave with allowlist scanHoward Chung2020-12-071-7/+121
| | | | | | | | | | | | | | | | | This patch implements the interleaving between allowlist scan and no-filter scan. It'll be used to save power when at least one monitor is registered and at least one pending connection or one device to be scanned for. The durations of the allowlist scan and the no-filter scan are controlled by MGMT command: Set Default System Configuration. The default values are set randomly for now. Signed-off-by: Howard Chung <[email protected]> Reviewed-by: Alain Michaud <[email protected]> Reviewed-by: Manish Mandlik <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]> Signed-off-by: Johan Hedberg <[email protected]>
* Bluetooth: Rename get_adv_instance_scan_rspLuiz Augusto von Dentz2020-12-071-23/+9
| | | | | | | | | | This renames get_adv_instance_scan_rsp to adv_instance_is_scannable and make it return a bool since it was not actually properly return the size of the scan response as one could expect. Signed-off-by: Luiz Augusto von Dentz <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]> Signed-off-by: Johan Hedberg <[email protected]>
* Bluetooth: Fix not sending Set Extended Scan ResponseLuiz Augusto von Dentz2020-12-071-8/+6
| | | | | | | | | | | Current code is actually failing on the following tests of mgmt-tester because get_adv_instance_scan_rsp_len did not account for flags that cause scan response data to be included resulting in non-scannable instance when in fact it should be scannable. Signed-off-by: Luiz Augusto von Dentz <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]> Signed-off-by: Johan Hedberg <[email protected]>
* Bluetooth: Replace BT_DBG with bt_dev_dbg in HCI requestHoward Chung2020-11-111-26/+26
| | | | | | | | This replaces the BT_DBG function to bt_dev_dbg as it is cleaner to show the controller index in the debug message. Signed-off-by: Howard Chung <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: Fix: LL PRivacy BLE device fails to connectSathish Narasimman2020-11-091-4/+8
| | | | | | | | | | | | | | When adding device to white list the device is added to resolving list also. It has to be added only when HCI_ENABLE_LL_PRIVACY flag is set. HCI_ENABLE_LL_PRIVACY flag has to be tested before adding/deleting devices to resolving list. use_ll_privacy macro is used only to check if controller supports LL_Privacy. https://bugzilla.kernel.org/show_bug.cgi?id=209745 Fixes: 0eee35bdfa3b ("Bluetooth: Update resolving list when updating whitelist") Signed-off-by: Sathish Narasimman <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: Resume advertising after LE connectionDaniel Winkler2020-11-091-5/+16
| | | | | | | | | | | | | | | | When an LE connection request is made, advertising is disabled and never resumed. When a client has an active advertisement, this is disruptive. This change adds resume logic for client-configured (non-directed) advertisements after the connection attempt. The patch was tested by registering an advertisement, initiating an LE connection from a remote peer, and verifying that the advertisement is re-activated after the connection is established. This is performed on Hatch and Kukui Chromebooks. Signed-off-by: Daniel Winkler <[email protected]> Reviewed-by: Abhishek Pandit-Subedi <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: Fix update of own_addr_type if ll_privacy supportedSathish Narasimman2020-09-251-1/+7
| | | | | | | | | During system powercycle when trying to get the random address hci_get_random_address set own_addr_type as 0x01. In which if we enable ll_privacy it is supposed to be 0x03. Signed-off-by: Sathish Narasimman <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: Set scan parameters for ADV MonitorHoward Chung2020-09-201-0/+3
| | | | | | | | | | | Set scan parameters when there is at least one Advertisement monitor. Signed-off-by: Howard Chung <[email protected]> Reviewed-by: Alain Michaud <[email protected]> Reviewed-by: Manish Mandlik <[email protected]> Reviewed-by: Abhishek Pandit-Subedi <[email protected]> Reviewed-by: Miao-chen Chou <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: pause/resume advertising around suspendDaniel Winkler2020-09-141-10/+57
| | | | | | | | | | | | | | | | | | | | | Currently, the controller will continue advertising when the system enters suspend. This patch makes sure that all advertising instances are paused when entering suspend, and resumed when suspend exits. The Advertising and Suspend/Resume test suites were both run on this change on 4.19 kernel with both hardware offloaded multi-advertising and software rotated multi-advertising. In addition, a new test was added that performs the following steps: * Register 3 advertisements via bluez RegisterAdvertisement * Verify reception of all advertisements by remote peer * Enter suspend on DUT * Verify failure to receive all advertisements by remote peer * Exit suspend on DUT * Verify reception of all advertisements by remote peer Signed-off-by: Daniel Winkler <[email protected]> Reviewed-by: Abhishek Pandit-Subedi <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: Set ext scan response only when it existsAbhishek Pandit-Subedi2020-09-131-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Only set extended scan response only when it exists. Otherwise, clear the scan response data. Per the core spec v5.2, Vol 4, Part E, 7.8.55 If the advertising set is non-scannable and the Host uses this command other than to discard existing data, the Controller shall return the error code Invalid HCI Command Parameters (0x12). On WCN3991, the controller correctly responds with Invalid Parameters when this is sent. That error causes __hci_req_hci_power_on to fail with -EINVAL and LE devices can't connect because background scanning isn't configured. Here is an hci trace of where this issue occurs during power on: < HCI Command: LE Set Extended Advertising Parameters (0x08|0x0036) plen 25 Handle: 0x00 Properties: 0x0010 Use legacy advertising PDUs: ADV_NONCONN_IND Min advertising interval: 181.250 msec (0x0122) Max advertising interval: 181.250 msec (0x0122) Channel map: 37, 38, 39 (0x07) Own address type: Random (0x01) Peer address type: Public (0x00) Peer address: 00:00:00:00:00:00 (OUI 00-00-00) Filter policy: Allow Scan Request from Any, Allow Connect... TX power: 127 dbm (0x7f) Primary PHY: LE 1M (0x01) Secondary max skip: 0x00 Secondary PHY: LE 1M (0x01) SID: 0x00 Scan request notifications: Disabled (0x00) > HCI Event: Command Complete (0x0e) plen 5 LE Set Extended Advertising Parameters (0x08|0x0036) ncmd 1 Status: Success (0x00) TX power (selected): 9 dbm (0x09) < HCI Command: LE Set Advertising Set Random Address (0x08|0x0035) plen 7 Advertising handle: 0x00 Advertising random address: 08:FD:55:ED:22:28 (OUI 08-FD-55) > HCI Event: Command Complete (0x0e) plen 4 LE Set Advertising Set Random Address (0x08|0x0035) ncmd Status: Success (0x00) < HCI Command: LE Set Extended Scan Response Data (0x08|0x0038) plen 35 Handle: 0x00 Operation: Complete scan response data (0x03) Fragment preference: Minimize fragmentation (0x01) Data length: 0x0d Name (short): Chromebook > HCI Event: Command Complete (0x0e) plen 4 LE Set Extended Scan Response Data (0x08|0x0038) ncmd 1 Status: Invalid HCI Command Parameters (0x12) Signed-off-by: Abhishek Pandit-Subedi <[email protected]> Reviewed-by: Daniel Winkler <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: use the proper scan params when conn is pendingAlain Michaud2020-07-311-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When an LE connection is requested and an RPA update is needed via hci_connect_le_scan, the default scanning parameters are used rather than the connect parameters. This leads to significant delays in the connection establishment process when using lower duty cycle scanning parameters. The patch simply looks at the pended connection list when trying to determine which scanning parameters should be used. Before: < HCI Command: LE Set Extended Scan Parameters (0x08|0x0041) plen 8                             #378 [hci0] 1659.247156         Own address type: Public (0x00)         Filter policy: Ignore not in white list (0x01)         PHYs: 0x01         Entry 0: LE 1M           Type: Passive (0x00)           Interval: 367.500 msec (0x024c)           Window: 37.500 msec (0x003c) After: < HCI Command: LE Set Extended Scan Parameters (0x08|0x0041) plen 8                               #39 [hci0] 7.422109         Own address type: Public (0x00)         Filter policy: Ignore not in white list (0x01)         PHYs: 0x01         Entry 0: LE 1M           Type: Passive (0x00)           Interval: 60.000 msec (0x0060)           Window: 60.000 msec (0x0060) Signed-off-by: Alain Michaud <[email protected]> Reviewed-by: Abhishek Pandit-Subedi <[email protected]> Reviewed-by: Yu Liu <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: Enable controller RPA resolution using Experimental featureSathish Narasimman2020-07-301-1/+6
| | | | | | | | This patch adds support to enable the use of RPA Address resolution using expermental feature mgmt command. Signed-off-by: Sathish Narasimman <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: Enable/Disable address resolution during le create connSathish Narasimman2020-07-301-11/+34
| | | | | | | | | In this patch if le_create_conn process is started restrict to disable address resolution and same is disabled during le_enh_connection_complete Signed-off-by: Sathish Narasimman <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: Let controller creates RPA during le create connSathish Narasimman2020-07-301-1/+7
| | | | | | | | When address resolution is enabled and set_privacy is enabled let's use own address type as 0x03 Signed-off-by: Sathish Narasimman <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: Update resolving list when updating whitelistMarcel Holtmann2020-07-301-2/+39
| | | | | | | | | When the whitelist is updated, then also update the entries of the resolving list for devices where IRKs are available. Signed-off-by: Marcel Holtmann <[email protected]> Signed-off-by: Sathish Narsimman <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: Configure controller address resolution if availableMarcel Holtmann2020-07-301-3/+23
| | | | | | | | | | | | | | When the LL Privacy support is available, then as part of enabling or disabling passive background scanning, it is required to set up the controller based address resolution as well. Since only passive background scanning is utilizing the whitelist, the address resolution is now bound to the whitelist and passive background scanning. All other resolution can be easily done by the host stack. Signed-off-by: Marcel Holtmann <[email protected]> Signed-off-by: Sathish Narsimman <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: Add per-instance adv disable/removeDaniel Winkler2020-07-151-9/+50
| | | | | | | | | | | | | | | | | | | | | | | Add functionality to disable and remove advertising instances, and use that functionality in MGMT add/remove advertising calls. Currently, advertising is globally-disabled, i.e. all instances are disabled together, even if hardware offloading is available. This patch adds functionality to disable and remove individual adv instances, solving two issues: 1. On new advertisement registration, a global disable was done, and then only the new instance was enabled. This meant only the newest instance was actually enabled. 2. On advertisement removal, the structure was removed, but the instance was never disabled or removed, which is incorrect with hardware offload support. Signed-off-by: Daniel Winkler <[email protected]> Reviewed-by: Shyh-In Hwang <[email protected]> Reviewed-by: Alain Michaud <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: Use whitelist for scan policy when suspendingMiao-chen Chou2020-07-081-2/+3
| | | | | | | | | | | | | | | Even with one advertisement monitor in place, the scan policy should use the whitelist while the system is going to suspend to prevent waking by random advertisement. The following test was performed. - With a paired device, register one advertisement monitor, suspend the system and verify that the host was not awaken by random advertisements. Signed-off-by: Miao-chen Chou <[email protected]> Reviewed-by: Abhishek Pandit-Subedi <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: use configured default params for active scansAlain Michaud2020-07-071-5/+6
| | | | | | | This patch fixes active scans to use the configured default parameters. Signed-off-by: Alain Michaud <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: Don't restart scanning if pausedAbhishek Pandit-Subedi2020-06-241-0/+10
| | | | | | | | When restarting LE scanning, check if it's currently paused before enabling passive scanning. Signed-off-by: Abhishek Pandit-Subedi <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: use configured params for ext advAlain Michaud2020-06-221-4/+3
| | | | | | | | | | | | | | | | | | | | | When the extended advertisement feature is enabled, a hardcoded min and max interval of 0x8000 is used. This patch fixes this issue by using the configured min/max value. This was validated by setting min/max in main.conf and making sure the right setting is applied: < HCI Command: LE Set Extended Advertising Parameters (0x08|0x0036) plen 25 #93 [hci0] 10.953011 … Min advertising interval: 181.250 msec (0x0122) Max advertising interval: 181.250 msec (0x0122) … Signed-off-by: Alain Michaud <[email protected]> Reviewed-by: Abhishek Pandit-Subedi <[email protected]> Reviewed-by: Daniel Winkler <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: Update background scan and report device based on advertisement ↵Miao-chen Chou2020-06-181-3/+14
| | | | | | | | | | | | | | | | | | | | | | | | | monitors This calls hci_update_background_scan() when there is any update on the advertisement monitors. If there is at least one advertisement monitor, the filtering policy of scan parameters should be 0x00. This also reports device found mgmt events if there is at least one monitor. The following cases were tested with btmgmt advmon-* commands. (1) add a ADV monitor and observe that the passive scanning is triggered. (2) remove the last ADV monitor and observe that the passive scanning is terminated. (3) with a LE peripheral paired, repeat (1) and observe the passive scanning continues. (4) with a LE peripheral paired, repeat (2) and observe the passive scanning continues. (5) with a ADV monitor, suspend/resume the host and observe the passive scanning continues. Signed-off-by: Miao-chen Chou <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]> Signed-off-by: Johan Hedberg <[email protected]>
* Bluetooth: Replace wakeable in hci_conn_paramsAbhishek Pandit-Subedi2020-06-181-1/+2
| | | | | | | | | | Replace the wakeable boolean with flags in hci_conn_params and all users of this boolean. This will be used by the get/set device flags mgmt op. Signed-off-by: Abhishek Pandit-Subedi <[email protected]> Reviewed-by: Alain Michaud <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]> Signed-off-by: Johan Hedberg <[email protected]>
* Bluetooth: Replace wakeable list with flagAbhishek Pandit-Subedi2020-06-181-4/+8
| | | | | | | | | | Since the classic device list now supports flags, convert the wakeable list into a flag on the existing device list. Signed-off-by: Abhishek Pandit-Subedi <[email protected]> Reviewed-by: Alain Michaud <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]> Signed-off-by: Johan Hedberg <[email protected]>
* Bluetooth: centralize default value initialization.Alain Michaud2020-06-121-10/+5
| | | | | | | | | | This patch centralized the initialization of default parameters. This is required to allow clients to more easily customize the default system parameters. Signed-off-by: Alain Michaud <[email protected]> Reviewed-by: Abhishek Pandit-Subedi <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: Check scan state before disabling during suspendManish Mandlik2020-06-031-4/+6
| | | | | | | | | | Check current scan state by checking HCI_LE_SCAN flag and send scan disable command only if scan is already enabled. Signed-off-by: Manish Mandlik <[email protected]> Reviewed-by: Abhishek Pandit-Subedi <[email protected]> Reviewed-by: Alain Michaud <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: Rename BT_SUSPEND_COMPLETEAbhishek Pandit-Subedi2020-05-131-1/+1
| | | | | | | | | Renamed BT_SUSPEND_COMPLETE to BT_SUSPEND_CONFIGURE_WAKE since it sets up the event filter and whitelist for wake-up. Signed-off-by: Abhishek Pandit-Subedi <[email protected]> Reviewed-by: Alain Michaud <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: Modify LE window and interval for suspendAbhishek Pandit-Subedi2020-05-131-1/+1
| | | | | | | | | | | | When a device is suspended, it doesn't need to be as responsive to connection events. Increase the interval to 640ms (creating a duty cycle of roughly 1.75%) so that passive scanning uses much less power (vs previous duty cycle of 18.75%). The new window + interval combination has been tested to work with HID devices (which are currently the only devices capable of wake up). Signed-off-by: Abhishek Pandit-Subedi <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: Fix incorrect type for window and intervalAbhishek Pandit-Subedi2020-05-131-1/+1
| | | | | | | The types for window and interval should be uint16, not uint8. Signed-off-by: Abhishek Pandit-Subedi <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: Fix advertising handle is set to 0Tedd Ho-Jeong An2020-05-111-3/+3
| | | | | | | | | | This patch fix the advertising handle is set to 0 regardless of actual instance value. The affected commands are LE Set Advertising Set Random Address, LE Set Extended Advertising Data, and LE Set Extended Scan Response Data commands. Signed-off-by: Tedd Ho-Jeong An <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: Use extra variable to make code more readableMarcel Holtmann2020-04-151-1/+3
| | | | | | | | | When starting active scanning for discovery the whitelist is not needed to be used. So the filter_policy is 0x00. To make the core more readable use a variable name instead of just setting 0 as paramter. Signed-off-by: Marcel Holtmann <[email protected]> Signed-off-by: Johan Hedberg <[email protected]>
* Bluetooth: Do not cancel advertising when starting a scanDmitry Grinberg2020-03-181-17/+0
| | | | | | | | | | | | | | BlueZ cancels adv when starting a scan, but does not cancel a scan when starting to adv. Neither is required, so this brings both to a consistent state (of not affecting each other). Some very rare (I've never seen one) BT 4.0 chips will fail to do both at once. Even this is ok since the command that will fail will be the second one, and thus the common sense logic of first-come-first-served is preserved for BLE requests. Signed-off-by: Dmitry Grinberg <[email protected]> Signed-off-by: Manish Mandlik <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: Pause discovery and advertising during suspendAbhishek Pandit-Subedi2020-03-111-0/+44
| | | | | | | | | To prevent spurious wake ups, we disable any discovery or advertising when we enter suspend and restore it when we exit suspend. While paused, we disable any management requests to modify discovery or advertising. Signed-off-by: Abhishek Pandit-Subedi <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: Handle LE devices during suspendAbhishek Pandit-Subedi2020-03-111-54/+112
| | | | | | | | | To handle LE devices, we must first disable passive scanning and disconnect all connected devices. Once that is complete, we update the whitelist and re-enable scanning Signed-off-by: Abhishek Pandit-Subedi <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: Handle BR/EDR devices during suspendAbhishek Pandit-Subedi2020-03-111-0/+106
| | | | | | | | | To handle BR/EDR devices, we first disable page scan and disconnect all connected devices. Once that is complete, we add event filters (for devices that can wake the system) and re-enable page scan. Signed-off-by: Abhishek Pandit-Subedi <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: Handle PM_SUSPEND_PREPARE and PM_POST_SUSPENDAbhishek Pandit-Subedi2020-03-111-0/+15
| | | | | | | | | | Register for PM_SUSPEND_PREPARE and PM_POST_SUSPEND to make sure the Bluetooth controller is prepared correctly for suspend/resume. Implement the registration, scheduling and task handling portions only in this patch. Signed-off-by: Abhishek Pandit-Subedi <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: Use bt_dev_err for RPA generation failure messageMarcel Holtmann2020-03-111-1/+1
| | | | | | | | When the RPA generation fails, indicate the error with a device specifc error message. Signed-off-by: Marcel Holtmann <[email protected]> Signed-off-by: Johan Hedberg <[email protected]>
* Bluetooth: Fix advertising duplicated flagsLuiz Augusto von Dentz2019-11-041-0/+9
| | | | | | | | | | | | | | | | | | | Instances may have flags set as part of its data in which case the code should not attempt to add it again otherwise it can cause duplication: < HCI Command: LE Set Extended Advertising Data (0x08|0x0037) plen 35 Handle: 0x00 Operation: Complete extended advertising data (0x03) Fragment preference: Minimize fragmentation (0x01) Data length: 0x06 Flags: 0x04 BR/EDR Not Supported Flags: 0x06 LE General Discoverable Mode BR/EDR Not Supported Signed-off-by: Luiz Augusto von Dentz <[email protected]> Signed-off-by: Johan Hedberg <[email protected]>
* Bluetooth: Fix not using LE_ADV_NONCONN_IND for instance 0Luiz Augusto von Dentz2019-10-261-4/+4
| | | | | | | | Instance 0 is controlled by stack itself and always set the local name in the scan response. Signed-off-by: Luiz Augusto von Dentz <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: Fix using advertising instance duration as timeoutLuiz Augusto von Dentz2019-10-261-1/+1
| | | | | | | | | | When using LE Set Extended Advertising Enable command the duration refers to the lifetime of instance not the length which is actually controlled by the interval_min and interval_max when setting the parameters. Signed-off-by: Luiz Augusto von Dentz <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
* Bluetooth: Add support for utilizing Fast Advertising IntervalSpoorthi Ravishankar Koppad2019-09-051-7/+22
| | | | | | | | | | | | | | | | | | Changes made to add support for fast advertising interval as per core 4.1 specification, section 9.3.11.2. A peripheral device entering any of the following GAP modes and sending either non-connectable advertising events or scannable undirected advertising events should use adv_fast_interval2 (100ms - 150ms) for adv_fast_period(30s). - Non-Discoverable Mode - Non-Connectable Mode - Limited Discoverable Mode - General Discoverable Mode Signed-off-by: Spoorthi Ravishankar Koppad <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>