* [PATCH v2 0/2] Bluetooth: Add a new mgmt_set_bredr command
From: johan.hedberg @ 2013-10-02 10:43 UTC (permalink / raw)
To: linux-bluetooth
Hi,
Yet another update with error code fixes in both patches based on
feedback. I also removed the unnecessary val and enabled variables as
suggested by Andrei Emeltchenko.
Johan
----------------------------------------------------------------
Johan Hedberg (2):
Bluetooth: Introduce a new HCI_BREDR_ENABLED flag
Bluetooth: Add a new mgmt_set_bredr command
include/net/bluetooth/hci.h | 1 +
include/net/bluetooth/mgmt.h | 2 +
net/bluetooth/hci_conn.c | 3 +
net/bluetooth/hci_core.c | 21 +++++-
net/bluetooth/hci_event.c | 5 ++
net/bluetooth/mgmt.c | 144 ++++++++++++++++++++++++++++++++++++++----
6 files changed, 163 insertions(+), 13 deletions(-)
^ permalink raw reply
* Re: [PATCH 4/8] Bluetooth: Add Write Synchronization Train Parameters Command
From: Marcel Holtmann @ 2013-10-02 9:34 UTC (permalink / raw)
To: Dohyun Pyun; +Cc: linux-bluetooth, steve.jun, DoHyun Pyun, C S Bhargava
In-Reply-To: <1380705078-22154-5-git-send-email-dh79.pyun@samsung.com>
Hi Dohyun,
> The Write_Synchronization_Train_Parameters command configures
> the Synchronization Train functionality in the BR/EDR Controller.
>
> The Core Spec Addendum 4 adds this command in part B Connectionless
> Slave Broadcast.
>
> Bluetooth Core Specification Addendum 4 - Page 97
>
> "7.3.90 Write Synchronization Train Parameters Command [New Section]
> ...
> Note: The AFH_Channel_Map used in the Synchronization Train packets is
> configured by the Set_AFH_Channel_Classification command and the local
> channel classification in the BR/EDR Controller.
>
> Interval_Min and Interval_Max specify the allowed range of
> Sync_Train_Interval. Refer to [Vol. 2], Part B, section 2.7.2 for
> a detailed description of Sync_Train_Interval. The BR/EDR Controller shall
> select an interval from this range and return it in Sync_Train_Interval.
> If the Controller is unable to select a value from this range, it shall
> return the Invalid HCI Command Parameters (0x12) error code.
>
> Once started (via the Start_Synchronization_Train Command) the
> Synchronization Train will continue until synchronization_trainTO slots have
> passed or Connectionless Slave Broadcast has been disabled."
>
> Signed-off-by: Dohyun Pyun <dh79.pyun@samsung.com>
> Signed-off-by: C S Bhargava <cs.bhargava@samsung.com>
> ---
> include/net/bluetooth/hci.h | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> index d5a0da0..6579bd3 100644
> --- a/include/net/bluetooth/hci.h
> +++ b/include/net/bluetooth/hci.h
> @@ -870,6 +870,18 @@ struct hci_rp_set_clb_data {
> __u8 lt_addr;
> } __packed;
>
> +#define HCI_OP_WRITE_SYNC_TRAIN_PARAMS 0x0c78
> +struct hci_cp_write_sync_train_params {
> + __le16 interval_min;
> + __le16 interval_max;
> + __le32 sync_train_tout;
> + __u8 service_data;
> +} __packed;
> +struct hci_rp_write_sync_train_params {
> + __u8 status;
> + __le16 sync_train_int;
> +} __packed;
> +
> #define HCI_OP_READ_SYNC_TRAIN_PARAMS 0x0c77
we sort commands in order and 0c78 comes after 0xc77.
Regards
Marcel
^ permalink raw reply
* Re: [PATCH 3/8] Bluetooth: Add Set Connectionless Slave Broadcast Data Command
From: Marcel Holtmann @ 2013-10-02 9:33 UTC (permalink / raw)
To: Dohyun Pyun; +Cc: linux-bluetooth, steve.jun, DoHyun Pyun, C S Bhargava
In-Reply-To: <1380705078-22154-4-git-send-email-dh79.pyun@samsung.com>
Hi Dohyun,
> The Set_Connectionless_Slave_Broadcast_Data command provides the
> ability for the Host to set Connectionless Slave Broadcast data in
> the BR/EDR Controller.
>
> The Core Spec Addendum 4 adds this command in part B Connectionless
> Slave Broadcast.
>
> Bluetooth Core Specification Addendum 4 - Page 93
>
> "7.3.88 Set Connectionless Slave Broadcast Data Command [New Section]
> ...
> If connectionless slave broadcast mode is disabled, this data shall be
> kept by the BR/EDR Controller and used once connectionless slave broadcast
> mode is enabled. If connectionless slave broadcast mode is enabled,
> and this command is successful, this data will be sent starting with
> the next Connectionless Slave Broadcast instant.
>
> The Data_Length field may be zero, in which case no data needs to be
> provided.
>
> The Host may fragment the data using the Fragment field in the command. If
> the combined length of the fragments exceeds the capacity of the largest
> allowed packet size specified in the Set Connectionless Slave Broadcast
> command, all fragments associated with the data being assembled shall be
> discarded and the Invalid HCI Command Parameters error (0x12) shall be
> returned."
>
> Signed-off-by: Dohyun Pyun <dh79.pyun@samsung.com>
> Signed-off-by: C S Bhargava <cs.bhargava@samsung.com>
> ---
> include/net/bluetooth/hci.h | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> index 28294ac..d5a0da0 100644
> --- a/include/net/bluetooth/hci.h
> +++ b/include/net/bluetooth/hci.h
> @@ -35,6 +35,8 @@
>
> #define HCI_MAX_AMP_ASSOC_SIZE 672
>
> +#define HCI_MAX_CLB_DATA_SIZE 252
> +
I have no idea what CLB stands for and how that got derived from connection slave broadcast.
Regards
Marcel
^ permalink raw reply
* Re: [PATCH 1/8] Bluetooth: Add Set Reserved LT_ADDR Command
From: Marcel Holtmann @ 2013-10-02 9:31 UTC (permalink / raw)
To: Dohyun Pyun; +Cc: linux-bluetooth, steve.jun, DoHyun Pyun, C S Bhargava
In-Reply-To: <1380705078-22154-2-git-send-email-dh79.pyun@samsung.com>
Hi Dohyun,
your adding the structures and definitions for this command. Not that actual command. That should be clear in the subject.
> The Set_Reserved_LT_ADDR command allows the host to request that the
> BR/EDR Controller reserve a specific LT_ADDR for Connectionless Slave
> Broadcast.
>
> The Core Spec Addendum 4 adds this command in part B Connectionless
> Slave Broadcast.
>
> Bluetooth Core Specification Addendum 4 - Page 90
>
> "7.3.86 Set Reserved LT_ADDR Command [New Section]
> ...
> If the LT_ADDR indicated in the LT_ADDR parameter is already in use by the
> BR/EDR Controller, it shall return the ACL Connection Already Exists (0x0B)
> error code. If the LT_ADDR indicated in the LT_ADDR parameter is out of
> range, the controller shall return the Invalid HCI Command Parameters (0x12)
> error code. If the command succeeds, then the reserved LT_ADDR shall be
> used when issuing subsequent Set Connectionless Slave Broadcast Data and
> Set Connectionless Slave Broadcast commands.
> To ensure that the reserved LT_ADDR is not already allocated, it is
> recommended that this command be issued at some point after HCI_Reset is
> issued but before page scanning is enabled or paging is initiated."
>
> Signed-off-by: Dohyun Pyun <dh79.pyun@samsung.com>
> Signed-off-by: C S Bhargava <cs.bhargava@samsung.com>
> ---
> include/net/bluetooth/hci.h | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> index 7ede266..dead0b0 100644
> --- a/include/net/bluetooth/hci.h
> +++ b/include/net/bluetooth/hci.h
> @@ -838,6 +838,15 @@ struct hci_cp_write_le_host_supported {
> __u8 simul;
> } __packed;
>
> +#define HCI_OP_SET_RESERVED_LT_ADDR 0x0c74
> +struct hci_cp_set_reserved_lt_addr {
> + __u8 lt_addr;
> +} __packed;
> +struct hci_rp_set_reserved_lt_addr {
> + __u8 status;
> + __u8 lt_addr;
> +} __packed;
> +
Please follow the coding style of all the other structs in this area. They clearly have a tab between the type and the variable name.
Regards
Marcel
^ permalink raw reply
* Re: [PATCH 2/2] Bluetooth: Add a new mgmt_set_bredr command
From: Marcel Holtmann @ 2013-10-02 9:27 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <1380705040-16300-3-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
> This patch introduces a new mgmt command for enabling/disabling BR/EDR
> functionality. This can be convenient when one wants to make a dual-mode
> controller behave like a single-mode one. The command is only available
> for dual-mode controllers and requires that LE is enabled before using
> it. The BR/EDR setting can be enabled at any point, however disabling it
> requires the controller to be powered off (otherwise a "rejected"
> response will be sent).
>
> Disabling the BR/EDR setting will automatically disable all other BR/EDR
> related settings.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> include/net/bluetooth/mgmt.h | 2 +
> net/bluetooth/hci_event.c | 5 ++
> net/bluetooth/mgmt.c | 124 +++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 131 insertions(+)
>
> diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
> index 421d763..7347df8 100644
> --- a/include/net/bluetooth/mgmt.h
> +++ b/include/net/bluetooth/mgmt.h
> @@ -354,6 +354,8 @@ struct mgmt_cp_set_device_id {
>
> #define MGMT_OP_SET_ADVERTISING 0x0029
>
> +#define MGMT_OP_SET_BREDR 0x002A
> +
> #define MGMT_EV_CMD_COMPLETE 0x0001
> struct mgmt_ev_cmd_complete {
> __le16 opcode;
> diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> index d171c04b..4785ab0 100644
> --- a/net/bluetooth/hci_event.c
> +++ b/net/bluetooth/hci_event.c
> @@ -297,6 +297,11 @@ static void hci_cc_write_scan_enable(struct hci_dev *hdev, struct sk_buff *skb)
> goto done;
> }
>
> + /* We need to ensure that we set this back on if someone changed
> + * the scan mode through a raw HCI socket.
> + */
> + set_bit(HCI_BREDR_ENABLED, &hdev->dev_flags);
> +
> old_pscan = test_and_clear_bit(HCI_PSCAN, &hdev->flags);
> old_iscan = test_and_clear_bit(HCI_ISCAN, &hdev->flags);
>
> diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
> index e1c41b0..8b9b337 100644
> --- a/net/bluetooth/mgmt.c
> +++ b/net/bluetooth/mgmt.c
> @@ -75,6 +75,7 @@ static const u16 mgmt_commands[] = {
> MGMT_OP_UNBLOCK_DEVICE,
> MGMT_OP_SET_DEVICE_ID,
> MGMT_OP_SET_ADVERTISING,
> + MGMT_OP_SET_BREDR,
> };
>
> static const u16 mgmt_events[] = {
> @@ -3337,6 +3338,125 @@ unlock:
> return err;
> }
>
> +static void set_bredr_complete(struct hci_dev *hdev, u8 status)
> +{
> + struct pending_cmd *cmd;
> +
> + BT_DBG("status 0x%02x", status);
> +
> + hci_dev_lock(hdev);
> +
> + cmd = mgmt_pending_find(MGMT_OP_SET_BREDR, hdev);
> + if (!cmd)
> + goto unlock;
> +
> + if (status) {
> + u8 mgmt_err = mgmt_status(status);
> +
> + /* We need to restore the flag if related HCI commands
> + * failed.
> + */
> + clear_bit(HCI_BREDR_ENABLED, &hdev->dev_flags);
> +
> + cmd_status(cmd->sk, cmd->index, cmd->opcode, mgmt_err);
> + } else {
> + send_settings_rsp(cmd->sk, MGMT_OP_SET_BREDR, hdev);
> + new_settings(hdev, cmd->sk);
> + }
> +
> + mgmt_pending_remove(cmd);
> +
> +unlock:
> + hci_dev_unlock(hdev);
> +}
> +
> +static int set_bredr(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
> +{
> + struct mgmt_mode *cp = data;
> + struct pending_cmd *cmd;
> + struct hci_request req;
> + u8 val, enabled;
> + int err;
> +
> + BT_DBG("request for %s", hdev->name);
> +
> + if (!lmp_bredr_capable(hdev) || !lmp_le_capable(hdev))
> + return cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR,
> + MGMT_STATUS_REJECTED);
this should MGMT_STATUS_NOT_SUPPORTED to be in sync with how we do it for other commands.
> +
> + if (!test_bit(HCI_LE_ENABLED, &hdev->dev_flags))
> + return cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR,
> + MGMT_STATUS_REJECTED);
> +
> + if (cp->val != 0x00 && cp->val != 0x01)
> + return cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR,
> + MGMT_STATUS_INVALID_PARAMS);
> +
> + hci_dev_lock(hdev);
> +
> + val = !!cp->val;
> + enabled = test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags);
> +
> + if (val == enabled) {
> + err = send_settings_rsp(sk, MGMT_OP_SET_BREDR, hdev);
> + goto unlock;
> + }
> +
> + if (!hdev_is_powered(hdev)) {
> + if (!val) {
> + clear_bit(HCI_CONNECTABLE, &hdev->dev_flags);
> + clear_bit(HCI_DISCOVERABLE, &hdev->dev_flags);
> + clear_bit(HCI_SSP_ENABLED, &hdev->dev_flags);
> + clear_bit(HCI_LINK_SECURITY, &hdev->dev_flags);
> + clear_bit(HCI_FAST_CONNECTABLE, &hdev->dev_flags);
> + clear_bit(HCI_HS_ENABLED, &hdev->dev_flags);
> + }
> +
> + change_bit(HCI_BREDR_ENABLED, &hdev->dev_flags);
> +
> + err = send_settings_rsp(sk, MGMT_OP_SET_BREDR, hdev);
> + if (err < 0)
> + goto unlock;
> +
> + err = new_settings(hdev, sk);
> + goto unlock;
> + }
> +
> + /* Reject disabling when powered on */
> + if (!val) {
> + err = cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR,
> + MGMT_STATUS_REJECTED);
> + goto unlock;
> + }
I would have done this the other way around with the if clauses.
if (val) {
…
} else {
if (hdev_is_powered())
fail
…
}
> +
> + if (mgmt_pending_find(MGMT_OP_SET_BREDR, hdev)) {
> + err = cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR,
> + MGMT_STATUS_BUSY);
> + goto unlock;
> + }
> +
> + cmd = mgmt_pending_add(sk, MGMT_OP_SET_BREDR, hdev, data, len);
> + if (!cmd) {
> + err = -ENOMEM;
> + goto unlock;
> + }
> +
> + /* We need to flip the bit already here so that hci_update_ad
> + * generates the correct flags.
> + */
> + set_bit(HCI_BREDR_ENABLED, &hdev->dev_flags);
> +
> + hci_req_init(&req, hdev);
> + hci_update_ad(&req);
> + err = hci_req_run(&req, set_bredr_complete);
> + if (err < 0)
> + mgmt_pending_remove(cmd);
> +
> +unlock:
> + hci_dev_unlock(hdev);
> + return err;
> +}
> +
> static bool ltk_is_valid(struct mgmt_ltk_info *key)
> {
> if (key->authenticated != 0x00 && key->authenticated != 0x01)
> @@ -3452,6 +3572,7 @@ static const struct mgmt_handler {
> { unblock_device, false, MGMT_UNBLOCK_DEVICE_SIZE },
> { set_device_id, false, MGMT_SET_DEVICE_ID_SIZE },
> { set_advertising, false, MGMT_SETTING_SIZE },
> + { set_bredr, false, MGMT_SETTING_SIZE },
> };
>
>
> @@ -3633,6 +3754,9 @@ static int powered_update_hci(struct hci_dev *hdev)
> cp.simul != lmp_host_le_br_capable(hdev))
> hci_req_add(&req, HCI_OP_WRITE_LE_HOST_SUPPORTED,
> sizeof(cp), &cp);
> +
> + /* In case BR/EDR was toggled during the AUTO_OFF phase */
> + hci_update_ad(&req);
> }
>
> if (test_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags)) {
Regards
Marcel
^ permalink raw reply
* Re: [PATCH 1/2] Bluetooth: Introduce a new HCI_BREDR_ENABLED flag
From: Marcel Holtmann @ 2013-10-02 9:23 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <1380705040-16300-2-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
> To allow treating dual-mode (BR/EDR/LE) controllers as single-mode ones
> (LE-only) we want to introduce a new HCI_BREDR_ENABLED flag to track
> whether BR/EDR is enabled or not (previously we simply looked at the
> feature bit with lmp_bredr_enabled).
>
> This patch add the new flag and updates the relevant places to test
> against it instead of using lmp_bredr_enabled. The flag is by default
> enabled when registering an adapter and only cleared if necessary once
> the local features have been read during the HCI init procedure.
>
> We cannot completely block BR/EDR usage in case user space uses raw HCI
> sockets but the patch tries to block this in places where possible, such
> as the various BR/EDR specific ioctls.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> Acked-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> include/net/bluetooth/hci.h | 1 +
> net/bluetooth/hci_conn.c | 3 +++
> net/bluetooth/hci_core.c | 21 +++++++++++++++++++--
> net/bluetooth/mgmt.c | 24 +++++++++++++-----------
> 4 files changed, 36 insertions(+), 13 deletions(-)
>
> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> index 7ede266..4fa08d7 100644
> --- a/include/net/bluetooth/hci.h
> +++ b/include/net/bluetooth/hci.h
> @@ -122,6 +122,7 @@ enum {
> HCI_LINK_SECURITY,
> HCI_PERIODIC_INQ,
> HCI_FAST_CONNECTABLE,
> + HCI_BREDR_ENABLED,
> };
>
> /* A mask for the flags that are supposed to remain when a reset happens
> diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
> index d2380e0..514148b 100644
> --- a/net/bluetooth/hci_conn.c
> +++ b/net/bluetooth/hci_conn.c
> @@ -581,6 +581,9 @@ static struct hci_conn *hci_connect_acl(struct hci_dev *hdev, bdaddr_t *dst,
> {
> struct hci_conn *acl;
>
> + if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags))
> + return ERR_PTR(-ENOTSUPP);
> +
> acl = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst);
> if (!acl) {
> acl = hci_conn_add(hdev, ACL_LINK, dst);
> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> index 7cbdd33..ed310e9 100644
> --- a/net/bluetooth/hci_core.c
> +++ b/net/bluetooth/hci_core.c
> @@ -519,6 +519,8 @@ static void hci_init2_req(struct hci_request *req, unsigned long opt)
>
> if (lmp_bredr_capable(hdev))
> bredr_setup(req);
> + else
> + clear_bit(HCI_BREDR_ENABLED, &hdev->dev_flags);
>
> if (lmp_le_capable(hdev))
> le_setup(req);
> @@ -1034,6 +1036,11 @@ int hci_inquiry(void __user *arg)
> goto done;
> }
>
> + if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) {
> + err = -ENOTSUPP;
> + goto done;
> + }
> +
> hci_dev_lock(hdev);
> if (inquiry_cache_age(hdev) > INQUIRY_CACHE_AGE_MAX ||
> inquiry_cache_empty(hdev) || ir.flags & IREQ_CACHE_FLUSH) {
> @@ -1101,7 +1108,7 @@ static u8 create_ad(struct hci_dev *hdev, u8 *ptr)
> if (test_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags))
> flags |= LE_AD_GENERAL;
>
> - if (!lmp_bredr_capable(hdev))
> + if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags))
> flags |= LE_AD_NO_BREDR;
>
> if (lmp_le_br_capable(hdev))
> @@ -1493,6 +1500,11 @@ int hci_dev_cmd(unsigned int cmd, void __user *arg)
> goto done;
> }
>
> + if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) {
> + err = -ENOTSUPP;
> + goto done;
> + }
> +
quick question, shouldn't these be EOPNOTSUPP.
Regards
Marcel
^ permalink raw reply
* [0/8] Add CSA 4 commands and events in hci.h
From: Dohyun Pyun @ 2013-10-02 9:17 UTC (permalink / raw)
To: linux-bluetooth; +Cc: steve.jun
Hi all,
This patchset contains several HCI commands and events addition.
These HCI commands and events are included in Bluetooth Core
Specification Addendum 4, and it will be used to implement 3DS
profile.
Also I'm still implementing 3DS profile's master role in the BR/EDR
controller. Summit and I'll send the patchsets about 3DS MGMT APIs
soon.
Regards,
Pyun
----------------------------------------------------------------
Dohyun Pyun (8):
Bluetooth: Add Set Reserved LT_ADDR Command
Bluetooth: Add Delete Reserved LT_ADDR Command
Bluetooth: Add Set Connectionless Slave Broadcast Data Command
Bluetooth: Add Write Synchronization Train Parameters Command
Bluetooth: Add Set Connectionless Slave Broadcast Command
Bluetooth: Add Start Synchronization Train Command
Bluetooth: Add Synchronization Train Complete Event
Bluetooth: Add Slave Page Response Timeout Event
include/net/bluetooth/hci.h | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 69 insertions(+)
^ permalink raw reply
* [PATCH 8/8] Bluetooth: Add Slave Page Response Timeout Event
From: Dohyun Pyun @ 2013-10-02 9:11 UTC (permalink / raw)
To: linux-bluetooth; +Cc: steve.jun, DoHyun Pyun, C S Bhargava
In-Reply-To: <1380705078-22154-1-git-send-email-dh79.pyun@samsung.com>
From: DoHyun Pyun <dh79.pyun@samsung.com>
The Slave Page Response Timeout event indicates to the Host that a
slave page response timeout has occurred in the BR/EDR Controller.
The Core Spec Addendum 4 adds this command in part B Connectionless
Slave Broadcast.
Bluetooth Core Specification Addendum 4 - Page 110
"7.7.67 Synchronization Train Complete Event [New Section]
...
Note: this event will be generated if the slave BR/EDR Controller
responds to a page but does not receive the master FHS packet
(see Baseband, Section 8.3.3) within pagerespTO.
Event Parameters: NONE"
Signed-off-by: Dohyun Pyun <dh79.pyun@samsung.com>
Signed-off-by: C S Bhargava <cs.bhargava@samsung.com>
---
include/net/bluetooth/hci.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 022d44f..809c9ee 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -1507,6 +1507,8 @@ struct hci_ev_sync_train_complete {
__u8 status;
} __packed;
+#define HCI_EV_SLAVE_PAGE_RESP_TIMEOUT 0x54
+
/* Low energy meta events */
#define LE_CONN_ROLE_MASTER 0x00
--
1.8.1.2
^ permalink raw reply related
* [PATCH 7/8] Bluetooth: Add Synchronization Train Complete Event
From: Dohyun Pyun @ 2013-10-02 9:11 UTC (permalink / raw)
To: linux-bluetooth; +Cc: steve.jun, DoHyun Pyun, C S Bhargava
In-Reply-To: <1380705078-22154-1-git-send-email-dh79.pyun@samsung.com>
From: DoHyun Pyun <dh79.pyun@samsung.com>
The Synchronization Train Complete event indicates that the Start
Synchronization Train command has completed.
The Core Spec Addendum 4 adds this command in part B Connectionless
Slave Broadcast.
Bluetooth Core Specification Addendum 4 - Page 103
"7.7.67 Synchronization Train Complete Event [New Section]
...
Event Parameters:
Status 0x00 Start Synchronization Train command completed
successfully.
0x01-0xFF Start Synchronization Train command failed.
See Part D, Error Codes, for error codes and
descriptions."
Signed-off-by: Dohyun Pyun <dh79.pyun@samsung.com>
Signed-off-by: C S Bhargava <cs.bhargava@samsung.com>
---
include/net/bluetooth/hci.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 3bd316f..022d44f 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -1502,6 +1502,11 @@ struct hci_ev_num_comp_blocks {
struct hci_comp_blocks_info handles[0];
} __packed;
+#define HCI_EV_SYNC_TRAIN_COMPLETE 0x4F
+struct hci_ev_sync_train_complete {
+ __u8 status;
+} __packed;
+
/* Low energy meta events */
#define LE_CONN_ROLE_MASTER 0x00
--
1.8.1.2
^ permalink raw reply related
* [PATCH 6/8] Bluetooth: Add Start Synchronization Train Command
From: Dohyun Pyun @ 2013-10-02 9:11 UTC (permalink / raw)
To: linux-bluetooth; +Cc: steve.jun, DoHyun Pyun, C S Bhargava
In-Reply-To: <1380705078-22154-1-git-send-email-dh79.pyun@samsung.com>
From: DoHyun Pyun <dh79.pyun@samsung.com>
The Start_Synchronization_Train command controls the Synchronization
Train functionality in the BR/EDR Controller.
The Core Spec Addendum 4 adds this command in part B Connectionless
Slave Broadcast.
Bluetooth Core Specification Addendum 4 - Page 86
"7.1.51 Start Synchronization Train Command [New Section]
...
If connectionless slave broadcast mode is not enabled, the Command
Disallowed (0x0C) error code shall be returned. After receiving this
command and returning a Command Status event, the Baseband starts
attempting to send synchronization train packets containing information
related to the enabled Connectionless Slave Broadcast packet timing.
Note: The AFH_Channel_Map used in the synchronization train packets is
configured by the Set_AFH_Channel_Classification command and the local
channel classification in the BR/EDR Controller.
The synchronization train packets will be sent using the parameters
specified by the latest Write_Synchronization_Train_Parameters command.
The Synchronization Train will continue until synchronization_trainTO
slots (as specified in the last Write_Synchronization_Train command)
have passed or until the Host disables the Connectionless Slave Broadcast
logical transport."
Signed-off-by: Dohyun Pyun <dh79.pyun@samsung.com>
Signed-off-by: C S Bhargava <cs.bhargava@samsung.com>
---
include/net/bluetooth/hci.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index ebdc7cc..3bd316f 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -643,6 +643,8 @@ struct hci_rp_set_clb {
__le16 interval;
} __packed;
+#define HCI_OP_START_SYNC_TRAIN 0x0443
+
#define HCI_OP_SNIFF_MODE 0x0803
struct hci_cp_sniff_mode {
__le16 handle;
--
1.8.1.2
^ permalink raw reply related
* [PATCH 5/8] Bluetooth: Add Set Connectionless Slave Broadcast Command
From: Dohyun Pyun @ 2013-10-02 9:11 UTC (permalink / raw)
To: linux-bluetooth; +Cc: steve.jun, DoHyun Pyun, C S Bhargava
In-Reply-To: <1380705078-22154-1-git-send-email-dh79.pyun@samsung.com>
From: DoHyun Pyun <dh79.pyun@samsung.com>
he Set_Connectionless_Slave_Broadcast command controls the
Connectionless Slave Broadcast functionality in the BR/EDR
Controller.
The Core Spec Addendum 4 adds this command in part B Connectionless
Slave Broadcast.
Bluetooth Core Specification Addendum 4 - Page 78
"7.1.49 Set Connectionless Slave Broadcast Command [New Section]
...
The LT_ADDR indicated in the Set_Connectionless_Slave_Broadcast shall be
pre-allocated using the HCI_Set_Reserved_LT_ADDR command. If the
LT_ADDR has not been reserved, the Unknown Connection Identifier (0x02)
error code shall be returned. If the controller is unable to reserve
sufficient bandwidth for the requested activity, the Connection Rejected
Due to Limited Resources (0x0D) error code shall be returned.
The LPO_Allowed parameter informs the BR/EDR Controller whether it is
allowed to sleep.
The Packet_Type parameter specifies which packet types are allowed. The
Host shall either enable BR packet types only, or shall enable EDR and DM1
packet types only.
The Interval_Min and Interval_Max parameters specify the range from which
the BR/EDR Controller must select the Connectionless Slave Broadcast
Interval. The selected Interval is returned."
Signed-off-by: Dohyun Pyun <dh79.pyun@samsung.com>
Signed-off-by: C S Bhargava <cs.bhargava@samsung.com>
---
include/net/bluetooth/hci.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 6579bd3..ebdc7cc 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -627,6 +627,22 @@ struct hci_rp_logical_link_cancel {
__u8 flow_spec_id;
} __packed;
+#define HCI_OP_SET_CLB 0x0441
+struct hci_cp_set_clb {
+ __u8 enable;
+ __u8 lt_addr;
+ __u8 lpo_allowed;
+ __le16 packet_type;
+ __le16 interval_min;
+ __le16 interval_max;
+ __le16 csb_sv_tout;
+} __packed;
+struct hci_rp_set_clb {
+ __u8 status;
+ __u8 lt_addr;
+ __le16 interval;
+} __packed;
+
#define HCI_OP_SNIFF_MODE 0x0803
struct hci_cp_sniff_mode {
__le16 handle;
--
1.8.1.2
^ permalink raw reply related
* [PATCH 4/8] Bluetooth: Add Write Synchronization Train Parameters Command
From: Dohyun Pyun @ 2013-10-02 9:11 UTC (permalink / raw)
To: linux-bluetooth; +Cc: steve.jun, DoHyun Pyun, C S Bhargava
In-Reply-To: <1380705078-22154-1-git-send-email-dh79.pyun@samsung.com>
From: DoHyun Pyun <dh79.pyun@samsung.com>
The Write_Synchronization_Train_Parameters command configures
the Synchronization Train functionality in the BR/EDR Controller.
The Core Spec Addendum 4 adds this command in part B Connectionless
Slave Broadcast.
Bluetooth Core Specification Addendum 4 - Page 97
"7.3.90 Write Synchronization Train Parameters Command [New Section]
...
Note: The AFH_Channel_Map used in the Synchronization Train packets is
configured by the Set_AFH_Channel_Classification command and the local
channel classification in the BR/EDR Controller.
Interval_Min and Interval_Max specify the allowed range of
Sync_Train_Interval. Refer to [Vol. 2], Part B, section 2.7.2 for
a detailed description of Sync_Train_Interval. The BR/EDR Controller shall
select an interval from this range and return it in Sync_Train_Interval.
If the Controller is unable to select a value from this range, it shall
return the Invalid HCI Command Parameters (0x12) error code.
Once started (via the Start_Synchronization_Train Command) the
Synchronization Train will continue until synchronization_trainTO slots have
passed or Connectionless Slave Broadcast has been disabled."
Signed-off-by: Dohyun Pyun <dh79.pyun@samsung.com>
Signed-off-by: C S Bhargava <cs.bhargava@samsung.com>
---
include/net/bluetooth/hci.h | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index d5a0da0..6579bd3 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -870,6 +870,18 @@ struct hci_rp_set_clb_data {
__u8 lt_addr;
} __packed;
+#define HCI_OP_WRITE_SYNC_TRAIN_PARAMS 0x0c78
+struct hci_cp_write_sync_train_params {
+ __le16 interval_min;
+ __le16 interval_max;
+ __le32 sync_train_tout;
+ __u8 service_data;
+} __packed;
+struct hci_rp_write_sync_train_params {
+ __u8 status;
+ __le16 sync_train_int;
+} __packed;
+
#define HCI_OP_READ_SYNC_TRAIN_PARAMS 0x0c77
#define HCI_OP_READ_LOCAL_VERSION 0x1001
--
1.8.1.2
^ permalink raw reply related
* [PATCH 3/8] Bluetooth: Add Set Connectionless Slave Broadcast Data Command
From: Dohyun Pyun @ 2013-10-02 9:11 UTC (permalink / raw)
To: linux-bluetooth; +Cc: steve.jun, DoHyun Pyun, C S Bhargava
In-Reply-To: <1380705078-22154-1-git-send-email-dh79.pyun@samsung.com>
From: DoHyun Pyun <dh79.pyun@samsung.com>
The Set_Connectionless_Slave_Broadcast_Data command provides the
ability for the Host to set Connectionless Slave Broadcast data in
the BR/EDR Controller.
The Core Spec Addendum 4 adds this command in part B Connectionless
Slave Broadcast.
Bluetooth Core Specification Addendum 4 - Page 93
"7.3.88 Set Connectionless Slave Broadcast Data Command [New Section]
...
If connectionless slave broadcast mode is disabled, this data shall be
kept by the BR/EDR Controller and used once connectionless slave broadcast
mode is enabled. If connectionless slave broadcast mode is enabled,
and this command is successful, this data will be sent starting with
the next Connectionless Slave Broadcast instant.
The Data_Length field may be zero, in which case no data needs to be
provided.
The Host may fragment the data using the Fragment field in the command. If
the combined length of the fragments exceeds the capacity of the largest
allowed packet size specified in the Set Connectionless Slave Broadcast
command, all fragments associated with the data being assembled shall be
discarded and the Invalid HCI Command Parameters error (0x12) shall be
returned."
Signed-off-by: Dohyun Pyun <dh79.pyun@samsung.com>
Signed-off-by: C S Bhargava <cs.bhargava@samsung.com>
---
include/net/bluetooth/hci.h | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 28294ac..d5a0da0 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -35,6 +35,8 @@
#define HCI_MAX_AMP_ASSOC_SIZE 672
+#define HCI_MAX_CLB_DATA_SIZE 252
+
/* HCI dev events */
#define HCI_DEV_REG 1
#define HCI_DEV_UNREG 2
@@ -856,6 +858,18 @@ struct hci_rp_delete_reserved_lt_addr {
__u8 lt_addr;
} __packed;
+#define HCI_OP_SET_CLB_DATA 0x0c76
+struct hci_cp_set_clb_data {
+ __u8 lt_addr;
+ __u8 fragment;
+ __u8 data_length;
+ __u8 data[HCI_MAX_CLB_DATA_SIZE];
+} __packed;
+struct hci_rp_set_clb_data {
+ __u8 status;
+ __u8 lt_addr;
+} __packed;
+
#define HCI_OP_READ_SYNC_TRAIN_PARAMS 0x0c77
#define HCI_OP_READ_LOCAL_VERSION 0x1001
--
1.8.1.2
^ permalink raw reply related
* [PATCH 2/8] Bluetooth: Add Delete Reserved LT_ADDR Command
From: Dohyun Pyun @ 2013-10-02 9:11 UTC (permalink / raw)
To: linux-bluetooth; +Cc: steve.jun, DoHyun Pyun, C S Bhargava
In-Reply-To: <1380705078-22154-1-git-send-email-dh79.pyun@samsung.com>
From: DoHyun Pyun <dh79.pyun@samsung.com>
The Delete_Reserved_LT_ADDR command requests that the BR/EDR
Controller cancel the reservation for a specific LT_ADDR reserved for the
purposes of Connectionless Slave Broadcast.
The Core Spec Addendum 4 adds this command in part B Connectionless
Slave Broadcast.
Bluetooth Core Specification Addendum 4 - Page 92
"7.3.87 Delete Reserved LT_ADDR Command [New Section]
...
If the LT_ADDR indicated in the LT_ADDR parameter is not reserved by the
BR/EDR Controller, it shall return the Unknown Connection Identifier (0x02)
error code.
If connectionless slave broadcast mode is still active, then the Controller
shall return the Command Disallowed (0x0C) error code."
Signed-off-by: Dohyun Pyun <dh79.pyun@samsung.com>
Signed-off-by: C S Bhargava <cs.bhargava@samsung.com>
---
include/net/bluetooth/hci.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index dead0b0..28294ac 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -847,6 +847,15 @@ struct hci_rp_set_reserved_lt_addr {
__u8 lt_addr;
} __packed;
+#define HCI_OP_DELETE_RESERVED_LT_ADDR 0x0c75
+struct hci_cp_delete_reserved_lt_addr {
+ __u8 lt_addr;
+} __packed;
+struct hci_rp_delete_reserved_lt_addr {
+ __u8 status;
+ __u8 lt_addr;
+} __packed;
+
#define HCI_OP_READ_SYNC_TRAIN_PARAMS 0x0c77
#define HCI_OP_READ_LOCAL_VERSION 0x1001
--
1.8.1.2
^ permalink raw reply related
* [PATCH 1/8] Bluetooth: Add Set Reserved LT_ADDR Command
From: Dohyun Pyun @ 2013-10-02 9:11 UTC (permalink / raw)
To: linux-bluetooth; +Cc: steve.jun, DoHyun Pyun, C S Bhargava
In-Reply-To: <1380705078-22154-1-git-send-email-dh79.pyun@samsung.com>
From: DoHyun Pyun <dh79.pyun@samsung.com>
The Set_Reserved_LT_ADDR command allows the host to request that the
BR/EDR Controller reserve a specific LT_ADDR for Connectionless Slave
Broadcast.
The Core Spec Addendum 4 adds this command in part B Connectionless
Slave Broadcast.
Bluetooth Core Specification Addendum 4 - Page 90
"7.3.86 Set Reserved LT_ADDR Command [New Section]
...
If the LT_ADDR indicated in the LT_ADDR parameter is already in use by the
BR/EDR Controller, it shall return the ACL Connection Already Exists (0x0B)
error code. If the LT_ADDR indicated in the LT_ADDR parameter is out of
range, the controller shall return the Invalid HCI Command Parameters (0x12)
error code. If the command succeeds, then the reserved LT_ADDR shall be
used when issuing subsequent Set Connectionless Slave Broadcast Data and
Set Connectionless Slave Broadcast commands.
To ensure that the reserved LT_ADDR is not already allocated, it is
recommended that this command be issued at some point after HCI_Reset is
issued but before page scanning is enabled or paging is initiated."
Signed-off-by: Dohyun Pyun <dh79.pyun@samsung.com>
Signed-off-by: C S Bhargava <cs.bhargava@samsung.com>
---
include/net/bluetooth/hci.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 7ede266..dead0b0 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -838,6 +838,15 @@ struct hci_cp_write_le_host_supported {
__u8 simul;
} __packed;
+#define HCI_OP_SET_RESERVED_LT_ADDR 0x0c74
+struct hci_cp_set_reserved_lt_addr {
+ __u8 lt_addr;
+} __packed;
+struct hci_rp_set_reserved_lt_addr {
+ __u8 status;
+ __u8 lt_addr;
+} __packed;
+
#define HCI_OP_READ_SYNC_TRAIN_PARAMS 0x0c77
#define HCI_OP_READ_LOCAL_VERSION 0x1001
--
1.8.1.2
^ permalink raw reply related
* Add CSA 4 commands and events in hci.h
From: Dohyun Pyun @ 2013-10-02 9:11 UTC (permalink / raw)
To: linux-bluetooth; +Cc: steve.jun
Hi all,
This patchset contains several HCI commands and events addition.
These HCI commands and events are included in Bluetooth Core
Specification Addendum 4, and it will be used to implement 3DS
profile.
Also I'm still implementing 3DS profile's master role in the BR/EDR
controller. Summit and I'll send the patchsets about 3DS MGMT APIs
soon.
Regards,
Pyun
^ permalink raw reply
* [PATCH 2/2] Bluetooth: Add a new mgmt_set_bredr command
From: Johan Hedberg @ 2013-10-02 9:10 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1380705040-16300-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
This patch introduces a new mgmt command for enabling/disabling BR/EDR
functionality. This can be convenient when one wants to make a dual-mode
controller behave like a single-mode one. The command is only available
for dual-mode controllers and requires that LE is enabled before using
it. The BR/EDR setting can be enabled at any point, however disabling it
requires the controller to be powered off (otherwise a "rejected"
response will be sent).
Disabling the BR/EDR setting will automatically disable all other BR/EDR
related settings.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/mgmt.h | 2 +
net/bluetooth/hci_event.c | 5 ++
net/bluetooth/mgmt.c | 124 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 131 insertions(+)
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index 421d763..7347df8 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -354,6 +354,8 @@ struct mgmt_cp_set_device_id {
#define MGMT_OP_SET_ADVERTISING 0x0029
+#define MGMT_OP_SET_BREDR 0x002A
+
#define MGMT_EV_CMD_COMPLETE 0x0001
struct mgmt_ev_cmd_complete {
__le16 opcode;
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index d171c04b..4785ab0 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -297,6 +297,11 @@ static void hci_cc_write_scan_enable(struct hci_dev *hdev, struct sk_buff *skb)
goto done;
}
+ /* We need to ensure that we set this back on if someone changed
+ * the scan mode through a raw HCI socket.
+ */
+ set_bit(HCI_BREDR_ENABLED, &hdev->dev_flags);
+
old_pscan = test_and_clear_bit(HCI_PSCAN, &hdev->flags);
old_iscan = test_and_clear_bit(HCI_ISCAN, &hdev->flags);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index e1c41b0..8b9b337 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -75,6 +75,7 @@ static const u16 mgmt_commands[] = {
MGMT_OP_UNBLOCK_DEVICE,
MGMT_OP_SET_DEVICE_ID,
MGMT_OP_SET_ADVERTISING,
+ MGMT_OP_SET_BREDR,
};
static const u16 mgmt_events[] = {
@@ -3337,6 +3338,125 @@ unlock:
return err;
}
+static void set_bredr_complete(struct hci_dev *hdev, u8 status)
+{
+ struct pending_cmd *cmd;
+
+ BT_DBG("status 0x%02x", status);
+
+ hci_dev_lock(hdev);
+
+ cmd = mgmt_pending_find(MGMT_OP_SET_BREDR, hdev);
+ if (!cmd)
+ goto unlock;
+
+ if (status) {
+ u8 mgmt_err = mgmt_status(status);
+
+ /* We need to restore the flag if related HCI commands
+ * failed.
+ */
+ clear_bit(HCI_BREDR_ENABLED, &hdev->dev_flags);
+
+ cmd_status(cmd->sk, cmd->index, cmd->opcode, mgmt_err);
+ } else {
+ send_settings_rsp(cmd->sk, MGMT_OP_SET_BREDR, hdev);
+ new_settings(hdev, cmd->sk);
+ }
+
+ mgmt_pending_remove(cmd);
+
+unlock:
+ hci_dev_unlock(hdev);
+}
+
+static int set_bredr(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
+{
+ struct mgmt_mode *cp = data;
+ struct pending_cmd *cmd;
+ struct hci_request req;
+ u8 val, enabled;
+ int err;
+
+ BT_DBG("request for %s", hdev->name);
+
+ if (!lmp_bredr_capable(hdev) || !lmp_le_capable(hdev))
+ return cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR,
+ MGMT_STATUS_REJECTED);
+
+ if (!test_bit(HCI_LE_ENABLED, &hdev->dev_flags))
+ return cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR,
+ MGMT_STATUS_REJECTED);
+
+ if (cp->val != 0x00 && cp->val != 0x01)
+ return cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR,
+ MGMT_STATUS_INVALID_PARAMS);
+
+ hci_dev_lock(hdev);
+
+ val = !!cp->val;
+ enabled = test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags);
+
+ if (val == enabled) {
+ err = send_settings_rsp(sk, MGMT_OP_SET_BREDR, hdev);
+ goto unlock;
+ }
+
+ if (!hdev_is_powered(hdev)) {
+ if (!val) {
+ clear_bit(HCI_CONNECTABLE, &hdev->dev_flags);
+ clear_bit(HCI_DISCOVERABLE, &hdev->dev_flags);
+ clear_bit(HCI_SSP_ENABLED, &hdev->dev_flags);
+ clear_bit(HCI_LINK_SECURITY, &hdev->dev_flags);
+ clear_bit(HCI_FAST_CONNECTABLE, &hdev->dev_flags);
+ clear_bit(HCI_HS_ENABLED, &hdev->dev_flags);
+ }
+
+ change_bit(HCI_BREDR_ENABLED, &hdev->dev_flags);
+
+ err = send_settings_rsp(sk, MGMT_OP_SET_BREDR, hdev);
+ if (err < 0)
+ goto unlock;
+
+ err = new_settings(hdev, sk);
+ goto unlock;
+ }
+
+ /* Reject disabling when powered on */
+ if (!val) {
+ err = cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR,
+ MGMT_STATUS_REJECTED);
+ goto unlock;
+ }
+
+ if (mgmt_pending_find(MGMT_OP_SET_BREDR, hdev)) {
+ err = cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR,
+ MGMT_STATUS_BUSY);
+ goto unlock;
+ }
+
+ cmd = mgmt_pending_add(sk, MGMT_OP_SET_BREDR, hdev, data, len);
+ if (!cmd) {
+ err = -ENOMEM;
+ goto unlock;
+ }
+
+ /* We need to flip the bit already here so that hci_update_ad
+ * generates the correct flags.
+ */
+ set_bit(HCI_BREDR_ENABLED, &hdev->dev_flags);
+
+ hci_req_init(&req, hdev);
+ hci_update_ad(&req);
+ err = hci_req_run(&req, set_bredr_complete);
+ if (err < 0)
+ mgmt_pending_remove(cmd);
+
+unlock:
+ hci_dev_unlock(hdev);
+ return err;
+}
+
static bool ltk_is_valid(struct mgmt_ltk_info *key)
{
if (key->authenticated != 0x00 && key->authenticated != 0x01)
@@ -3452,6 +3572,7 @@ static const struct mgmt_handler {
{ unblock_device, false, MGMT_UNBLOCK_DEVICE_SIZE },
{ set_device_id, false, MGMT_SET_DEVICE_ID_SIZE },
{ set_advertising, false, MGMT_SETTING_SIZE },
+ { set_bredr, false, MGMT_SETTING_SIZE },
};
@@ -3633,6 +3754,9 @@ static int powered_update_hci(struct hci_dev *hdev)
cp.simul != lmp_host_le_br_capable(hdev))
hci_req_add(&req, HCI_OP_WRITE_LE_HOST_SUPPORTED,
sizeof(cp), &cp);
+
+ /* In case BR/EDR was toggled during the AUTO_OFF phase */
+ hci_update_ad(&req);
}
if (test_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags)) {
--
1.8.3.1
^ permalink raw reply related
* [PATCH 1/2] Bluetooth: Introduce a new HCI_BREDR_ENABLED flag
From: Johan Hedberg @ 2013-10-02 9:10 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1380705040-16300-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
To allow treating dual-mode (BR/EDR/LE) controllers as single-mode ones
(LE-only) we want to introduce a new HCI_BREDR_ENABLED flag to track
whether BR/EDR is enabled or not (previously we simply looked at the
feature bit with lmp_bredr_enabled).
This patch add the new flag and updates the relevant places to test
against it instead of using lmp_bredr_enabled. The flag is by default
enabled when registering an adapter and only cleared if necessary once
the local features have been read during the HCI init procedure.
We cannot completely block BR/EDR usage in case user space uses raw HCI
sockets but the patch tries to block this in places where possible, such
as the various BR/EDR specific ioctls.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
---
include/net/bluetooth/hci.h | 1 +
net/bluetooth/hci_conn.c | 3 +++
net/bluetooth/hci_core.c | 21 +++++++++++++++++++--
net/bluetooth/mgmt.c | 24 +++++++++++++-----------
4 files changed, 36 insertions(+), 13 deletions(-)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 7ede266..4fa08d7 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -122,6 +122,7 @@ enum {
HCI_LINK_SECURITY,
HCI_PERIODIC_INQ,
HCI_FAST_CONNECTABLE,
+ HCI_BREDR_ENABLED,
};
/* A mask for the flags that are supposed to remain when a reset happens
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index d2380e0..514148b 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -581,6 +581,9 @@ static struct hci_conn *hci_connect_acl(struct hci_dev *hdev, bdaddr_t *dst,
{
struct hci_conn *acl;
+ if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags))
+ return ERR_PTR(-ENOTSUPP);
+
acl = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst);
if (!acl) {
acl = hci_conn_add(hdev, ACL_LINK, dst);
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 7cbdd33..ed310e9 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -519,6 +519,8 @@ static void hci_init2_req(struct hci_request *req, unsigned long opt)
if (lmp_bredr_capable(hdev))
bredr_setup(req);
+ else
+ clear_bit(HCI_BREDR_ENABLED, &hdev->dev_flags);
if (lmp_le_capable(hdev))
le_setup(req);
@@ -1034,6 +1036,11 @@ int hci_inquiry(void __user *arg)
goto done;
}
+ if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) {
+ err = -ENOTSUPP;
+ goto done;
+ }
+
hci_dev_lock(hdev);
if (inquiry_cache_age(hdev) > INQUIRY_CACHE_AGE_MAX ||
inquiry_cache_empty(hdev) || ir.flags & IREQ_CACHE_FLUSH) {
@@ -1101,7 +1108,7 @@ static u8 create_ad(struct hci_dev *hdev, u8 *ptr)
if (test_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags))
flags |= LE_AD_GENERAL;
- if (!lmp_bredr_capable(hdev))
+ if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags))
flags |= LE_AD_NO_BREDR;
if (lmp_le_br_capable(hdev))
@@ -1493,6 +1500,11 @@ int hci_dev_cmd(unsigned int cmd, void __user *arg)
goto done;
}
+ if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) {
+ err = -ENOTSUPP;
+ goto done;
+ }
+
switch (cmd) {
case HCISETAUTH:
err = hci_req_sync(hdev, hci_auth_req, dr.dev_opt,
@@ -2318,8 +2330,13 @@ int hci_register_dev(struct hci_dev *hdev)
set_bit(HCI_SETUP, &hdev->dev_flags);
- if (hdev->dev_type != HCI_AMP)
+ if (hdev->dev_type != HCI_AMP) {
set_bit(HCI_AUTO_OFF, &hdev->dev_flags);
+ /* Assume BR/EDR support until proven otherwise (such as
+ * through reading supported features during init.
+ */
+ set_bit(HCI_BREDR_ENABLED, &hdev->dev_flags);
+ }
write_lock(&hci_dev_list_lock);
list_add(&hdev->list, &hci_dev_list);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index ad38629..e1c41b0 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -408,7 +408,7 @@ static u32 get_current_settings(struct hci_dev *hdev)
if (test_bit(HCI_PAIRABLE, &hdev->dev_flags))
settings |= MGMT_SETTING_PAIRABLE;
- if (lmp_bredr_capable(hdev))
+ if (test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags))
settings |= MGMT_SETTING_BREDR;
if (test_bit(HCI_LE_ENABLED, &hdev->dev_flags))
@@ -929,7 +929,7 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data,
BT_DBG("request for %s", hdev->name);
- if (!lmp_bredr_capable(hdev))
+ if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags))
return cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE,
MGMT_STATUS_NOT_SUPPORTED);
@@ -1085,7 +1085,7 @@ static int set_connectable(struct sock *sk, struct hci_dev *hdev, void *data,
BT_DBG("request for %s", hdev->name);
- if (!lmp_bredr_capable(hdev))
+ if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags))
return cmd_status(sk, hdev->id, MGMT_OP_SET_CONNECTABLE,
MGMT_STATUS_NOT_SUPPORTED);
@@ -1208,7 +1208,7 @@ static int set_link_security(struct sock *sk, struct hci_dev *hdev, void *data,
BT_DBG("request for %s", hdev->name);
- if (!lmp_bredr_capable(hdev))
+ if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags))
return cmd_status(sk, hdev->id, MGMT_OP_SET_LINK_SECURITY,
MGMT_STATUS_NOT_SUPPORTED);
@@ -1342,7 +1342,7 @@ static int set_hs(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
BT_DBG("request for %s", hdev->name);
- if (!lmp_bredr_capable(hdev))
+ if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags))
return cmd_status(sk, hdev->id, MGMT_OP_SET_HS,
MGMT_STATUS_NOT_SUPPORTED);
@@ -1409,7 +1409,7 @@ static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
MGMT_STATUS_INVALID_PARAMS);
/* LE-only devices do not allow toggling LE on/off */
- if (!lmp_bredr_capable(hdev))
+ if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags))
return cmd_status(sk, hdev->id, MGMT_OP_SET_LE,
MGMT_STATUS_REJECTED);
@@ -1720,7 +1720,7 @@ static int set_dev_class(struct sock *sk, struct hci_dev *hdev, void *data,
BT_DBG("request for %s", hdev->name);
- if (!lmp_bredr_capable(hdev))
+ if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags))
return cmd_status(sk, hdev->id, MGMT_OP_SET_DEV_CLASS,
MGMT_STATUS_NOT_SUPPORTED);
@@ -2803,7 +2803,7 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev,
switch (hdev->discovery.type) {
case DISCOV_TYPE_BREDR:
- if (!lmp_bredr_capable(hdev)) {
+ if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) {
err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY,
MGMT_STATUS_NOT_SUPPORTED);
mgmt_pending_remove(cmd);
@@ -2835,7 +2835,7 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev,
}
if (hdev->discovery.type == DISCOV_TYPE_INTERLEAVED &&
- !lmp_bredr_capable(hdev)) {
+ !test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) {
err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY,
MGMT_STATUS_NOT_SUPPORTED);
mgmt_pending_remove(cmd);
@@ -3282,7 +3282,8 @@ static int set_fast_connectable(struct sock *sk, struct hci_dev *hdev,
BT_DBG("%s", hdev->name);
- if (!lmp_bredr_capable(hdev) || hdev->hci_ver < BLUETOOTH_VER_1_2)
+ if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags) ||
+ hdev->hci_ver < BLUETOOTH_VER_1_2)
return cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE,
MGMT_STATUS_NOT_SUPPORTED);
@@ -3646,7 +3647,8 @@ static int powered_update_hci(struct hci_dev *hdev)
sizeof(link_sec), &link_sec);
if (lmp_bredr_capable(hdev)) {
- set_bredr_scan(&req);
+ if (test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags))
+ set_bredr_scan(&req);
update_class(&req);
update_name(&req);
update_eir(&req);
--
1.8.3.1
^ permalink raw reply related
* [PATCH 0/2] Bluetooth: Add a new mgmt_set_bredr command
From: Johan Hedberg @ 2013-10-02 9:10 UTC (permalink / raw)
To: linux-bluetooth
Hi,
This is a new revision of the previous RFC with all feedback taken into
account. Additionally, the setting can now only be disabled while
powered off which means that the second patch from my previous set
becomes unnecessary (and has therefore been dropped).
Johan
----------------------------------------------------------------
Johan Hedberg (2):
Bluetooth: Introduce a new HCI_BREDR_ENABLED flag
Bluetooth: Add a new mgmt_set_bredr command
include/net/bluetooth/hci.h | 1 +
include/net/bluetooth/mgmt.h | 2 +
net/bluetooth/hci_conn.c | 3 +
net/bluetooth/hci_core.c | 21 +++++-
net/bluetooth/hci_event.c | 5 ++
net/bluetooth/mgmt.c | 148 ++++++++++++++++++++++++++++++++++++++----
6 files changed, 167 insertions(+), 13 deletions(-)
^ permalink raw reply
* Re: [PATCH v6 0/4] Bluetooth: btmrvl cal data downloading
From: Marcel Holtmann @ 2013-10-02 7:37 UTC (permalink / raw)
To: Bing Zhao
Cc: linux-bluetooth, Gustavo Padovan, Johan Hedberg, linux-wireless,
Mike Frysinger, Hyuckjoo Lee, Amitkumar Karwar
In-Reply-To: <1380655155-10007-1-git-send-email-bzhao@marvell.com>
Hi Bing,
> This series adds the calibration data downloading support
> along with improvements in sending commands and setup handler.
>
> Amitkumar Karwar (4):
> Bluetooth: btmrvl: add btmrvl_send_sync_cmd() function
> Bluetooth: btmrvl: get rid of struct btmrvl_cmd
> Bluetooth: btmrvl: add setup handler
> Bluetooth: btmrvl: add calibration data download support
>
> drivers/bluetooth/btmrvl_drv.h | 12 +-
> drivers/bluetooth/btmrvl_main.c | 269 ++++++++++++++++++++++++++--------------
> drivers/bluetooth/btmrvl_sdio.c | 15 +--
> drivers/bluetooth/btmrvl_sdio.h | 2 +
> 4 files changed, 193 insertions(+), 105 deletions(-)
I have decided to apply all 4 patches to bluetooth-next. However please send a follow up patch that changes the code to operate on 16-bit opcodes and not the OGC/OCF and its packing.
Regards
Marcel
^ permalink raw reply
* [PATCH] Bluetooth: Restrict disabling of HS when controller is powered off
From: Marcel Holtmann @ 2013-10-02 7:27 UTC (permalink / raw)
To: linux-bluetooth
Disabling the high speed setting when the controller is powered on has
too many side effects that are not taken care of. And in general it
is not an useful operation anyway. So just make such a command fail
with a rejection error message.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/mgmt.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index ad38629..35d3c12 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1352,10 +1352,17 @@ static int set_hs(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
hci_dev_lock(hdev);
- if (cp->val)
+ if (cp->val) {
changed = !test_and_set_bit(HCI_HS_ENABLED, &hdev->dev_flags);
- else
+ } else {
+ if (hdev_is_powered(hdev)) {
+ err = cmd_status(sk, hdev->id, MGMT_OP_SET_HS,
+ MGMT_STATUS_REJECTED);
+ goto unlock;
+ }
+
changed = test_and_clear_bit(HCI_HS_ENABLED, &hdev->dev_flags);
+ }
err = send_settings_rsp(sk, MGMT_OP_SET_HS, hdev);
if (err < 0)
--
1.8.3.1
^ permalink raw reply related
* Re: [RFC 3/3] Bluetooth: Add a new mgmt_set_bredr command
From: Andrei Emeltchenko @ 2013-10-02 7:07 UTC (permalink / raw)
To: johan.hedberg; +Cc: linux-bluetooth
In-Reply-To: <1380640922-18647-4-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
On Tue, Oct 01, 2013 at 06:22:02PM +0300, johan.hedberg@gmail.com wrote:
> From: Johan Hedberg <johan.hedberg@intel.com>
>
> This patch introduces a new mgmt command for enabling/disabling BR/EDR
> functionality. This can be convenient when one wants to make a dual-mode
> controller behave like a single-mode one. The command is only available
> for dual-mode controllers and requires that LE is enabled before using
> it.
...
> +
> + if (cp->val != 0x00 && cp->val != 0x01)
> + return cmd_status(sk, hdev->id, MGMT_OP_SET_ADVERTISING,
> + MGMT_STATUS_INVALID_PARAMS);
> +
> + hci_dev_lock(hdev);
> +
> + val = !!cp->val;
You have already checked that cp->val is 0x0 or 0x1, right?
Best regards
Andrei Emeltchenko
^ permalink raw reply
* Re: [PATCH] Bluetooth: Enable -D__CHECK_ENDIAN__ for sparse by default
From: Johan Hedberg @ 2013-10-02 6:41 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1380694007-7946-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Tue, Oct 01, 2013, Marcel Holtmann wrote:
> The Bluetooth protocol and hardware is pretty much all little endian
> and so when running sparse via "make C=2" for example, enable the
> endian checks by default.
>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> drivers/bluetooth/Makefile | 2 ++
> net/bluetooth/Makefile | 2 ++
> 2 files changed, 4 insertions(+)
Applied to bluetooth-next. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH] Bluetooth: Require CAP_NET_ADMIN for HCI User Channel operation
From: Johan Hedberg @ 2013-10-02 6:40 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1380638401-39890-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Tue, Oct 01, 2013, Marcel Holtmann wrote:
> The HCI User Channel operation is an admin operation that puts the
> device into promiscuous mode for single use. It is more suitable
> to require CAP_NET_ADMIN than CAP_NET_RAW.
>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> net/bluetooth/hci_sock.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Applied to bluetooth-next. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH] Bluetooth: Send new settings event when changing high speed option
From: Johan Hedberg @ 2013-10-02 6:40 UTC (permalink / raw)
To: Marcel Holtmann, linux-bluetooth
In-Reply-To: <20131001062829.GA5699@x220.p-661hnu-f1>
Hi Marcel,
On Tue, Oct 01, 2013, Johan Hedberg wrote:
> On Mon, Sep 30, 2013, Marcel Holtmann wrote:
> > When enabling or disabling high speed setting it is required to send
> > a new settings event to inform other management interface users about
> > the changed settings.
> >
> > Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> > ---
> > net/bluetooth/mgmt.c | 19 ++++++++++++++++---
> > 1 file changed, 16 insertions(+), 3 deletions(-)
>
> Acked-by: Johan Hedberg <johan.hedberg@intel.com>
Applied to bluetooth-next. Thanks.
Johan
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox