From: Jaganath Kanakkassery <jaganath.k.os@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: marcel@holtmann.org,
Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
Subject: [PATCH v4 04/13] Bluetooth: Set Scan PHYs based on selected PHYs by user
Date: Wed, 11 Jul 2018 15:01:26 +0530 [thread overview]
Message-ID: <1531301495-14479-5-git-send-email-jaganathx.kanakkassery@intel.com> (raw)
In-Reply-To: <1531301495-14479-1-git-send-email-jaganathx.kanakkassery@intel.com>
Use the PHYs selected in Set Phy Configuration management command
while scanning.
< HCI Command: LE Set Extended Scan Parameters (0x08|0x0041) plen 13
Own address type: Random (0x01)
Filter policy: Accept all advertisement (0x00)
PHYs: 0x05
Entry 0: LE 1M
Type: Active (0x01)
Interval: 11.250 msec (0x0012)
Window: 11.250 msec (0x0012)
Entry 1: LE Coded
Type: Active (0x01)
Interval: 11.250 msec (0x0012)
Window: 11.250 msec (0x0012)
> HCI Event: Command Complete (0x0e) plen 4
LE Set Extended Scan Parameters (0x08|0x0041) ncmd 1
Status: Success (0x00)
< HCI Command: LE Set Extended Scan Enable (0x08|0x0042) plen 6
Extended scan: Enabled (0x01)
Filter duplicates: Enabled (0x01)
Duration: 0 msec (0x0000)
Period: 0.00 sec (0x0000)
> HCI Event: Command Complete (0x0e) plen 4
LE Set Extended Scan Enable (0x08|0x0042) ncmd 2
Status: Success (0x00)
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
---
include/net/bluetooth/hci.h | 4 +++-
include/net/bluetooth/hci_core.h | 9 +++++++++
net/bluetooth/hci_request.c | 42 ++++++++++++++++++++++++++++------------
3 files changed, 42 insertions(+), 13 deletions(-)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index d0f7657..3584632 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -1541,7 +1541,9 @@ struct hci_cp_le_set_ext_scan_params {
__u8 data[0];
} __packed;
-#define LE_SCAN_PHY_1M 0x01
+#define LE_SCAN_PHY_1M 0x01
+#define LE_SCAN_PHY_2M 0x02
+#define LE_SCAN_PHY_CODED 0x04
struct hci_cp_le_scan_phy_params {
__u8 type;
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index ab5d494..33aab89e 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -1165,6 +1165,15 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
#define bredr_sc_enabled(dev) (lmp_sc_capable(dev) && \
hci_dev_test_flag(dev, HCI_SC_ENABLED))
+#define scan_1m(dev) (((dev)->le_tx_def_phys & HCI_LE_SET_PHY_1M) || \
+ ((dev)->le_rx_def_phys & HCI_LE_SET_PHY_1M))
+
+#define scan_2m(dev) (((dev)->le_tx_def_phys & HCI_LE_SET_PHY_2M) || \
+ ((dev)->le_rx_def_phys & HCI_LE_SET_PHY_2M))
+
+#define scan_coded(dev) (((dev)->le_tx_def_phys & HCI_LE_SET_PHY_CODED) || \
+ ((dev)->le_rx_def_phys & HCI_LE_SET_PHY_CODED))
+
/* Use ext scanning if set ext scan param and ext scan enable is supported */
#define use_ext_scan(dev) (((dev)->commands[37] & 0x20) && \
((dev)->commands[37] & 0x40))
diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index faf7c71..7f5950e 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -783,15 +783,13 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval,
{
struct hci_dev *hdev = req->hdev;
- /* Use ext scanning if set ext scan param and ext scan enable is
- * supported
- */
if (use_ext_scan(hdev)) {
struct hci_cp_le_set_ext_scan_params *ext_param_cp;
struct hci_cp_le_set_ext_scan_enable ext_enable_cp;
struct hci_cp_le_scan_phy_params *phy_params;
- /* Ony single PHY (1M) is supported as of now */
- u8 data[sizeof(*ext_param_cp) + sizeof(*phy_params) * 1];
+ u8 data[sizeof(*ext_param_cp) + sizeof(*phy_params) * 2];
+ u32 plen;
+ u8 scan_phys;
ext_param_cp = (void *)data;
phy_params = (void *)ext_param_cp->data;
@@ -799,16 +797,36 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval,
memset(ext_param_cp, 0, sizeof(*ext_param_cp));
ext_param_cp->own_addr_type = own_addr_type;
ext_param_cp->filter_policy = filter_policy;
- ext_param_cp->scanning_phys = LE_SCAN_PHY_1M;
- memset(phy_params, 0, sizeof(*phy_params));
- phy_params->type = type;
- phy_params->interval = cpu_to_le16(interval);
- phy_params->window = cpu_to_le16(window);
+ plen = sizeof(*ext_param_cp);
+
+ if (scan_1m(hdev) || scan_2m(hdev))
+ ext_param_cp->scanning_phys |= LE_SCAN_PHY_1M;
+
+ if (scan_coded(hdev))
+ ext_param_cp->scanning_phys |= LE_SCAN_PHY_CODED;
+
+ scan_phys = ext_param_cp->scanning_phys;
+
+ while (scan_phys) {
+ if (!(scan_phys & 0x01)) {
+ scan_phys >>= 0x01;
+ continue;
+ }
+
+ memset(phy_params, 0, sizeof(*phy_params));
+ phy_params->type = type;
+ phy_params->interval = cpu_to_le16(interval);
+ phy_params->window = cpu_to_le16(window);
+
+ plen += sizeof(*phy_params);
+ phy_params++;
+
+ scan_phys >>= 0x01;
+ }
hci_req_add(req, HCI_OP_LE_SET_EXT_SCAN_PARAMS,
- sizeof(*ext_param_cp) + sizeof(*phy_params),
- ext_param_cp);
+ plen, ext_param_cp);
memset(&ext_enable_cp, 0, sizeof(ext_enable_cp));
ext_enable_cp.enable = LE_SCAN_ENABLE;
--
2.7.4
next prev parent reply other threads:[~2018-07-11 9:31 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-11 9:31 [PATCH v4 00/13] Bluetooth: Extended Adv, Scan, Connection and PHY support Jaganath Kanakkassery
2018-07-11 9:31 ` [PATCH v4 01/13] Bluetooth: Define default phys in hdev and set 1M as default Jaganath Kanakkassery
2018-07-14 16:47 ` Marcel Holtmann
2018-07-11 9:31 ` [PATCH v4 02/13] Bluetooth: Implement Get PHY Configuration mgmt command Jaganath Kanakkassery
2018-07-14 17:00 ` Marcel Holtmann
2018-07-15 7:56 ` Jaganath K
2018-07-16 13:08 ` Marcel Holtmann
2018-07-16 13:46 ` Jaganath K
2018-07-11 9:31 ` [PATCH v4 03/13] Bluetooth: Implement Set PHY Confguration command Jaganath Kanakkassery
2018-07-14 17:18 ` Marcel Holtmann
2018-07-15 9:36 ` Jaganath K
2018-07-16 13:14 ` Marcel Holtmann
2018-07-11 9:31 ` Jaganath Kanakkassery [this message]
2018-07-14 17:24 ` [PATCH v4 04/13] Bluetooth: Set Scan PHYs based on selected PHYs by user Marcel Holtmann
2018-07-11 9:31 ` [PATCH v4 05/13] Bluetooth: Handle extended ADV PDU types Jaganath Kanakkassery
2018-07-14 17:28 ` Marcel Holtmann
2018-07-15 9:52 ` Jaganath K
2018-07-16 13:09 ` Marcel Holtmann
2018-07-11 9:31 ` [PATCH v4 06/13] Bluetooth: Use selected PHYs in extended connect Jaganath Kanakkassery
2018-07-14 17:30 ` Marcel Holtmann
2018-07-11 9:31 ` [PATCH v4 07/13] Bluetooth: Read no of adv sets during init Jaganath Kanakkassery
2018-07-14 17:32 ` Marcel Holtmann
2018-07-16 6:27 ` Jaganath K
2018-07-16 13:18 ` Marcel Holtmann
2018-07-16 13:51 ` Jaganath K
2018-07-11 9:31 ` [PATCH v4 08/13] Bluetooth: Impmlement extended adv enable Jaganath Kanakkassery
2018-07-14 18:38 ` Marcel Holtmann
2018-07-16 8:12 ` Jaganath K
2018-07-11 9:31 ` [PATCH v4 09/13] Bluetooth: Use Set ext adv/scan rsp data if controller supports Jaganath Kanakkassery
2018-07-14 18:47 ` Marcel Holtmann
2018-07-11 9:31 ` [PATCH v4 10/13] Bluetooth: Implement disable and removal of adv instance Jaganath Kanakkassery
2018-07-14 18:50 ` Marcel Holtmann
2018-07-16 8:21 ` Jaganath K
2018-07-11 9:31 ` [PATCH v4 11/13] Bluetooth: Use ext adv for directed adv Jaganath Kanakkassery
2018-07-14 18:56 ` Marcel Holtmann
2018-07-11 9:31 ` [PATCH v4 12/13] Bluetooth: Implement Set ADV set random address Jaganath Kanakkassery
2018-07-14 20:52 ` Marcel Holtmann
2018-07-16 9:57 ` Jaganath K
2018-07-11 9:31 ` [PATCH v4 13/13] Bluetooth: Implement secondary advertising on different PHYs Jaganath Kanakkassery
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1531301495-14479-5-git-send-email-jaganathx.kanakkassery@intel.com \
--to=jaganath.k.os@gmail.com \
--cc=jaganathx.kanakkassery@intel.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=marcel@holtmann.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).