Bluetooth: Add HCI Read Data Block Size function
authorAndrei Emeltchenko <andrei.emeltchenko@intel.com>
Wed, 7 Dec 2011 13:56:51 +0000 (15:56 +0200)
committerGustavo F. Padovan <padovan@profusion.mobi>
Sun, 18 Dec 2011 23:34:56 +0000 (21:34 -0200)
Implement block size read function. Use different variables for
packet-based and block-based flow control.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
include/net/bluetooth/hci.h
include/net/bluetooth/hci_core.h
net/bluetooth/hci_event.c

index c9ad56fe58f48558c9cb0d645935cf5a1bc31985..2e48d326e3654680b6faea972e0c47a52afd04e3 100644 (file)
@@ -746,6 +746,14 @@ struct hci_rp_read_bd_addr {
        bdaddr_t bdaddr;
 } __packed;
 
+#define HCI_OP_READ_DATA_BLOCK_SIZE    0x100a
+struct hci_rp_read_data_block_size {
+       __u8     status;
+       __le16   max_acl_len;
+       __le16   block_len;
+       __le16   num_blocks;
+} __packed;
+
 #define HCI_OP_WRITE_PAGE_SCAN_ACTIVITY        0x0c1c
 struct hci_cp_write_page_scan_activity {
        __le16   interval;
index 105eaa251034c263423e385a312ab2a5deaf34d3..74f8356b9ff109100debbc643cc8a3439046c408 100644 (file)
@@ -181,6 +181,11 @@ struct hci_dev {
        unsigned int    sco_pkts;
        unsigned int    le_pkts;
 
+       __u16           block_len;
+       __u16           block_mtu;
+       __u16           num_blocks;
+       __u16           block_cnt;
+
        unsigned long   acl_last_tx;
        unsigned long   sco_last_tx;
        unsigned long   le_last_tx;
index 74f758363c2ddc2002a48600de9ca1d891d0a97d..48796832fdf098fd1e57452d6877a205761d51db 100644 (file)
@@ -767,6 +767,28 @@ static void hci_cc_read_bd_addr(struct hci_dev *hdev, struct sk_buff *skb)
        hci_req_complete(hdev, HCI_OP_READ_BD_ADDR, rp->status);
 }
 
+static void hci_cc_read_data_block_size(struct hci_dev *hdev,
+                                                       struct sk_buff *skb)
+{
+       struct hci_rp_read_data_block_size *rp = (void *) skb->data;
+
+       BT_DBG("%s status 0x%x", hdev->name, rp->status);
+
+       if (rp->status)
+               return;
+
+       hdev->block_mtu = __le16_to_cpu(rp->max_acl_len);
+       hdev->block_len = __le16_to_cpu(rp->block_len);
+       hdev->num_blocks = __le16_to_cpu(rp->num_blocks);
+
+       hdev->block_cnt = hdev->num_blocks;
+
+       BT_DBG("%s blk mtu %d cnt %d len %d", hdev->name, hdev->block_mtu,
+                                       hdev->block_cnt, hdev->block_len);
+
+       hci_req_complete(hdev, HCI_OP_READ_DATA_BLOCK_SIZE, rp->status);
+}
+
 static void hci_cc_write_ca_timeout(struct hci_dev *hdev, struct sk_buff *skb)
 {
        __u8 status = *((__u8 *) skb->data);
@@ -2018,6 +2040,10 @@ static inline void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *sk
                hci_cc_read_bd_addr(hdev, skb);
                break;
 
+       case HCI_OP_READ_DATA_BLOCK_SIZE:
+               hci_cc_read_data_block_size(hdev, skb);
+               break;
+
        case HCI_OP_WRITE_CA_TIMEOUT:
                hci_cc_write_ca_timeout(hdev, skb);
                break;