summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorSudha Bheemanna <b.sudha@samsung.com>2016-09-16 10:38:30 +0530
committerSeung-Woo Kim <sw0312.kim@samsung.com>2016-12-14 13:53:26 +0900
commitd7bb17adc9cb35f9cbb093e3e71fcc3a9f46ffc1 (patch)
tree8e6faa573283ff89fe4019b8a869a6132c2a8f9c /net
parentedd61f95d599c4be8b2616f437f0a25f5c8a33db (diff)
Bluetooth: Read LE Max data length command
This patch adds the MGMT command and code to support reading the maximum data length supported command for LE. Change-Id: I4dc0041f2070de2ccb6a4164c8823612863c941e Signed-off-by: Sudha Bheemanna <b.sudha@samsung.com>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/hci_event.c9
-rw-r--r--net/bluetooth/mgmt.c79
2 files changed, 88 insertions, 0 deletions
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index f1308d5ab07a..d907b138b079 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1368,13 +1368,22 @@ static void hci_cc_le_read_max_data_len(struct hci_dev *hdev,
BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
+#ifndef TIZEN_BT
if (rp->status)
return;
+#else
+ hci_dev_lock(hdev);
+#endif
hdev->le_max_tx_len = le16_to_cpu(rp->tx_len);
hdev->le_max_tx_time = le16_to_cpu(rp->tx_time);
hdev->le_max_rx_len = le16_to_cpu(rp->rx_len);
hdev->le_max_rx_time = le16_to_cpu(rp->rx_time);
+
+#ifdef TIZEN_BT
+ mgmt_le_read_maximum_data_length_complete(hdev, rp->status);
+ hci_dev_unlock(hdev);
+#endif
}
static void hci_cc_write_le_host_supported(struct hci_dev *hdev,
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 13777872af3c..317b7ba96cc2 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -7476,6 +7476,83 @@ void mgmt_6lowpan_conn_changed(struct hci_dev *hdev, char if_name[16],
mgmt_event(MGMT_EV_6LOWPAN_CONN_STATE_CHANGED, hdev, ev, ev_size, NULL);
}
+
+void mgmt_le_read_maximum_data_length_complete(struct hci_dev *hdev, u8 status)
+{
+ struct mgmt_pending_cmd *cmd;
+ struct mgmt_rp_le_read_maximum_data_length rp;
+
+ BT_DBG("%s status %u", hdev->name, status);
+
+ cmd = pending_find(MGMT_OP_LE_READ_MAXIMUM_DATA_LENGTH, hdev);
+ if (!cmd)
+ return;
+
+ if (status)
+ mgmt_cmd_status(cmd->sk, hdev->id,
+ MGMT_OP_LE_READ_MAXIMUM_DATA_LENGTH,
+ mgmt_status(status));
+
+ memset(&rp, 0, sizeof(rp));
+
+ rp.max_tx_octets = cpu_to_le16(hdev->le_max_tx_len);
+ rp.max_tx_time = cpu_to_le16(hdev->le_max_tx_time);
+ rp.max_rx_octets = cpu_to_le16(hdev->le_max_rx_len);
+ rp.max_rx_time = cpu_to_le16(hdev->le_max_rx_time);
+
+ mgmt_cmd_complete(cmd->sk, hdev->id,
+ MGMT_OP_LE_READ_MAXIMUM_DATA_LENGTH, 0,
+ &rp, sizeof(rp));
+
+ mgmt_pending_remove(cmd);
+}
+
+static int read_maximum_le_data_length(struct sock *sk,
+ struct hci_dev *hdev, void *data, u16 len)
+{
+ struct mgmt_pending_cmd *cmd;
+ int err;
+
+ BT_DBG("read_maximum_le_data_length %s", hdev->name);
+
+ hci_dev_lock(hdev);
+
+ if (!hdev_is_powered(hdev)) {
+ err = mgmt_cmd_status(sk, hdev->id,
+ MGMT_OP_LE_READ_MAXIMUM_DATA_LENGTH,
+ MGMT_STATUS_NOT_POWERED);
+ goto unlock;
+ }
+
+ if (!lmp_le_capable(hdev)) {
+ err = mgmt_cmd_status(sk, hdev->id,
+ MGMT_OP_LE_READ_MAXIMUM_DATA_LENGTH,
+ MGMT_STATUS_NOT_SUPPORTED);
+ goto unlock;
+ }
+
+ if (pending_find(MGMT_OP_LE_READ_MAXIMUM_DATA_LENGTH, hdev)) {
+ err = mgmt_cmd_status(sk, hdev->id,
+ MGMT_OP_LE_READ_MAXIMUM_DATA_LENGTH,
+ MGMT_STATUS_BUSY);
+ goto unlock;
+ }
+
+ cmd = mgmt_pending_add(sk, MGMT_OP_LE_READ_MAXIMUM_DATA_LENGTH,
+ hdev, data, len);
+ if (!cmd) {
+ err = -ENOMEM;
+ goto unlock;
+ }
+
+ err = hci_send_cmd(hdev, HCI_OP_LE_READ_MAX_DATA_LEN, 0, NULL);
+ if (err < 0)
+ mgmt_pending_remove(cmd);
+
+unlock:
+ hci_dev_unlock(hdev);
+ return err;
+}
#endif /* TIZEN_BT */
static bool ltk_is_valid(struct mgmt_ltk_info *key)
@@ -9369,6 +9446,8 @@ static const struct hci_mgmt_handler tizen_mgmt_handlers[] = {
{ enable_bt_6lowpan, MGMT_ENABLE_BT_6LOWPAN_SIZE },
{ connect_bt_6lowpan, MGMT_CONNECT_6LOWPAN_SIZE },
{ disconnect_bt_6lowpan, MGMT_DISCONNECT_6LOWPAN_SIZE },
+ { read_maximum_le_data_length,
+ MGMT_LE_READ_MAXIMUM_DATA_LENGTH_SIZE },
};
#endif