aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hci_event.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-07-14 14:13:46 -0400
committerMarcel Holtmann <marcel@holtmann.org>2008-07-14 14:13:46 -0400
commita8746417e864da1ed36dd2432a399fbeb843c2a0 (patch)
treee0e392e8b76d53748f357e888483bced2de24e2b /net/bluetooth/hci_event.c
parent9dc0a3afc08d6c20c284994dcd84531787d00ec2 (diff)
[Bluetooth] Track connection packet type changes
The connection packet type can be changed after the connection has been established and thus needs to be properly tracked to ensure that the host stack has always correct and valid information about it. On incoming connections the Bluetooth core switches the supported packet types to the configured list for this controller. However the usefulness of this feature has been questioned a lot. The general consent is that every Bluetooth host stack should enable as many packet types as the hardware actually supports and leave the decision to the link manager software running on the Bluetooth chip. When running on Bluetooth 2.0 or later hardware, don't change the packet type for incoming connections anymore. This hardware likely supports Enhanced Data Rate and thus leave it completely up to the link manager to pick the best packet type. Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/hci_event.c')
-rw-r--r--net/bluetooth/hci_event.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 6bc5a0506c6c..d4d2dcc40fc7 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -699,14 +699,12 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s
699 } 699 }
700 700
701 /* Set packet type for incoming connection */ 701 /* Set packet type for incoming connection */
702 if (!conn->out) { 702 if (!conn->out && hdev->hci_ver < 3) {
703 struct hci_cp_change_conn_ptype cp; 703 struct hci_cp_change_conn_ptype cp;
704 cp.handle = ev->handle; 704 cp.handle = ev->handle;
705 cp.pkt_type = (conn->type == ACL_LINK) ? 705 cp.pkt_type = cpu_to_le16(conn->pkt_type);
706 cpu_to_le16(hdev->pkt_type & ACL_PTYPE_MASK): 706 hci_send_cmd(hdev, HCI_OP_CHANGE_CONN_PTYPE,
707 cpu_to_le16(hdev->pkt_type & SCO_PTYPE_MASK); 707 sizeof(cp), &cp);
708
709 hci_send_cmd(hdev, HCI_OP_CHANGE_CONN_PTYPE, sizeof(cp), &cp);
710 } else { 708 } else {
711 /* Update disconnect timer */ 709 /* Update disconnect timer */
712 hci_conn_hold(conn); 710 hci_conn_hold(conn);
@@ -786,7 +784,7 @@ static inline void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *sk
786 struct hci_cp_accept_sync_conn_req cp; 784 struct hci_cp_accept_sync_conn_req cp;
787 785
788 bacpy(&cp.bdaddr, &ev->bdaddr); 786 bacpy(&cp.bdaddr, &ev->bdaddr);
789 cp.pkt_type = cpu_to_le16(hdev->esco_type); 787 cp.pkt_type = cpu_to_le16(conn->pkt_type);
790 788
791 cp.tx_bandwidth = cpu_to_le32(0x00001f40); 789 cp.tx_bandwidth = cpu_to_le32(0x00001f40);
792 cp.rx_bandwidth = cpu_to_le32(0x00001f40); 790 cp.rx_bandwidth = cpu_to_le32(0x00001f40);
@@ -1237,6 +1235,22 @@ static inline void hci_clock_offset_evt(struct hci_dev *hdev, struct sk_buff *sk
1237 hci_dev_unlock(hdev); 1235 hci_dev_unlock(hdev);
1238} 1236}
1239 1237
1238static inline void hci_pkt_type_change_evt(struct hci_dev *hdev, struct sk_buff *skb)
1239{
1240 struct hci_ev_pkt_type_change *ev = (void *) skb->data;
1241 struct hci_conn *conn;
1242
1243 BT_DBG("%s status %d", hdev->name, ev->status);
1244
1245 hci_dev_lock(hdev);
1246
1247 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle));
1248 if (conn && !ev->status)
1249 conn->pkt_type = __le16_to_cpu(ev->pkt_type);
1250
1251 hci_dev_unlock(hdev);
1252}
1253
1240static inline void hci_pscan_rep_mode_evt(struct hci_dev *hdev, struct sk_buff *skb) 1254static inline void hci_pscan_rep_mode_evt(struct hci_dev *hdev, struct sk_buff *skb)
1241{ 1255{
1242 struct hci_ev_pscan_rep_mode *ev = (void *) skb->data; 1256 struct hci_ev_pscan_rep_mode *ev = (void *) skb->data;
@@ -1480,6 +1494,10 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
1480 hci_clock_offset_evt(hdev, skb); 1494 hci_clock_offset_evt(hdev, skb);
1481 break; 1495 break;
1482 1496
1497 case HCI_EV_PKT_TYPE_CHANGE:
1498 hci_pkt_type_change_evt(hdev, skb);
1499 break;
1500
1483 case HCI_EV_PSCAN_REP_MODE: 1501 case HCI_EV_PSCAN_REP_MODE:
1484 hci_pscan_rep_mode_evt(hdev, skb); 1502 hci_pscan_rep_mode_evt(hdev, skb);
1485 break; 1503 break;