* [PATCH v2] Bluetooth: use the proper scan params when conn is pending
@ 2020-07-31 1:05 Alain Michaud
2020-07-31 6:29 ` Marcel Holtmann
0 siblings, 1 reply; 2+ messages in thread
From: Alain Michaud @ 2020-07-31 1:05 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Alain Michaud, Abhishek Pandit-Subedi, Yu Liu
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)
Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Reviewed-by: Yu Liu <yudiliu@google.com>
Signed-off-by: Alain Michaud <alainm@chromium.org>
---
Changes in v2:
- Fixing Yu's email tag
net/bluetooth/hci_request.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index 435400a43a78..e0269192f2e5 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -953,6 +953,27 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval,
}
}
+/* Returns true if an le connection is in the scanning state */
+static inline bool hci_is_le_conn_scanning(struct hci_dev *hdev)
+{
+ struct hci_conn_hash *h = &hdev->conn_hash;
+ struct hci_conn *c;
+
+ rcu_read_lock();
+
+ list_for_each_entry_rcu(c, &h->list, list) {
+ if (c->type == LE_LINK && c->state == BT_CONNECT &&
+ test_bit(HCI_CONN_SCANNING, &c->flags)) {
+ rcu_read_unlock();
+ return true;
+ }
+ }
+
+ rcu_read_unlock();
+
+ return false;
+}
+
/* Ensure to call hci_req_add_le_scan_disable() first to disable the
* controller based address resolution to be able to reconfigure
* resolving list.
@@ -1003,6 +1024,9 @@ void hci_req_add_le_passive_scan(struct hci_request *req)
if (hdev->suspended) {
window = hdev->le_scan_window_suspend;
interval = hdev->le_scan_int_suspend;
+ } else if (hci_is_le_conn_scanning(hdev)) {
+ window = hdev->le_scan_window_connect;
+ interval = hdev->le_scan_int_connect;
} else {
window = hdev->le_scan_window;
interval = hdev->le_scan_interval;
--
2.28.0.163.g6104cc2f0b6-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] Bluetooth: use the proper scan params when conn is pending
2020-07-31 1:05 [PATCH v2] Bluetooth: use the proper scan params when conn is pending Alain Michaud
@ 2020-07-31 6:29 ` Marcel Holtmann
0 siblings, 0 replies; 2+ messages in thread
From: Marcel Holtmann @ 2020-07-31 6:29 UTC (permalink / raw)
To: Alain Michaud
Cc: Bluetooth Kernel Mailing List, Abhishek Pandit-Subedi, Yu Liu
Hi Alain,
> 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)
>
> Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
> Reviewed-by: Yu Liu <yudiliu@google.com>
> Signed-off-by: Alain Michaud <alainm@chromium.org>
please swap these around, the signed-off-by from the author should come first.
>
> ---
>
> Changes in v2:
> - Fixing Yu's email tag
>
> net/bluetooth/hci_request.c | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
Patch has been applied to bluetooth-next tree.
Regards
Marcel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-07-31 6:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-31 1:05 [PATCH v2] Bluetooth: use the proper scan params when conn is pending Alain Michaud
2020-07-31 6:29 ` Marcel Holtmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).