2 BlueZ - Bluetooth protocol stack for Linux
3 Copyright (C) 2000-2001 Qualcomm Incorporated
5 Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License version 2 as
9 published by the Free Software Foundation;
11 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
12 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
14 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
15 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
16 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
21 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
22 SOFTWARE IS DISCLAIMED.
28 * $Id: hci_event.c,v 1.3 2002/04/17 17:37:16 maxk Exp $
31 #include <linux/config.h>
32 #include <linux/module.h>
34 #include <linux/types.h>
35 #include <linux/errno.h>
36 #include <linux/kernel.h>
37 #include <linux/major.h>
38 #include <linux/sched.h>
39 #include <linux/slab.h>
40 #include <linux/poll.h>
41 #include <linux/fcntl.h>
42 #include <linux/init.h>
43 #include <linux/skbuff.h>
44 #include <linux/interrupt.h>
45 #include <linux/notifier.h>
48 #include <asm/system.h>
49 #include <asm/uaccess.h>
50 #include <asm/unaligned.h>
52 #include <net/bluetooth/bluetooth.h>
53 #include <net/bluetooth/hci_core.h>
55 #ifndef CONFIG_BT_HCI_CORE_DEBUG
57 #define BT_DBG( A... )
60 /* Handle HCI Event packets */
62 /* Command Complete OGF LINK_CTL */
63 static void hci_cc_link_ctl(struct hci_dev *hdev, __u16 ocf, struct sk_buff *skb)
67 BT_DBG("%s ocf 0x%x", hdev->name, ocf);
70 case OCF_INQUIRY_CANCEL:
71 status = *((__u8 *) skb->data);
74 BT_DBG("%s Inquiry cancel error: status 0x%x", hdev->name, status);
76 clear_bit(HCI_INQUIRY, &hdev->flags);
77 hci_req_complete(hdev, status);
82 BT_DBG("%s Command complete: ogf LINK_CTL ocf %x", hdev->name, ocf);
87 /* Command Complete OGF LINK_POLICY */
88 static void hci_cc_link_policy(struct hci_dev *hdev, __u16 ocf, struct sk_buff *skb)
90 struct hci_conn *conn;
91 struct hci_rp_role_discovery *rd;
93 BT_DBG("%s ocf 0x%x", hdev->name, ocf);
96 case OCF_ROLE_DISCOVERY:
97 rd = (void *) skb->data;
104 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rd->handle));
107 conn->link_mode &= ~HCI_LM_MASTER;
109 conn->link_mode |= HCI_LM_MASTER;
112 hci_dev_unlock(hdev);
116 BT_DBG("%s: Command complete: ogf LINK_POLICY ocf %x",
122 /* Command Complete OGF HOST_CTL */
123 static void hci_cc_host_ctl(struct hci_dev *hdev, __u16 ocf, struct sk_buff *skb)
127 struct hci_rp_read_voice_setting *vs;
130 BT_DBG("%s ocf 0x%x", hdev->name, ocf);
134 status = *((__u8 *) skb->data);
135 hci_req_complete(hdev, status);
138 case OCF_SET_EVENT_FLT:
139 status = *((__u8 *) skb->data);
141 BT_DBG("%s SET_EVENT_FLT failed %d", hdev->name, status);
143 BT_DBG("%s SET_EVENT_FLT succeseful", hdev->name);
147 case OCF_WRITE_AUTH_ENABLE:
148 sent = hci_sent_cmd_data(hdev, OGF_HOST_CTL, OCF_WRITE_AUTH_ENABLE);
152 status = *((__u8 *) skb->data);
153 param = *((__u8 *) sent);
156 if (param == AUTH_ENABLED)
157 set_bit(HCI_AUTH, &hdev->flags);
159 clear_bit(HCI_AUTH, &hdev->flags);
161 hci_req_complete(hdev, status);
164 case OCF_WRITE_ENCRYPT_MODE:
165 sent = hci_sent_cmd_data(hdev, OGF_HOST_CTL, OCF_WRITE_ENCRYPT_MODE);
169 status = *((__u8 *) skb->data);
170 param = *((__u8 *) sent);
174 set_bit(HCI_ENCRYPT, &hdev->flags);
176 clear_bit(HCI_ENCRYPT, &hdev->flags);
178 hci_req_complete(hdev, status);
181 case OCF_WRITE_CA_TIMEOUT:
182 status = *((__u8 *) skb->data);
184 BT_DBG("%s OCF_WRITE_CA_TIMEOUT failed %d", hdev->name, status);
186 BT_DBG("%s OCF_WRITE_CA_TIMEOUT succeseful", hdev->name);
190 case OCF_WRITE_PG_TIMEOUT:
191 status = *((__u8 *) skb->data);
193 BT_DBG("%s OCF_WRITE_PG_TIMEOUT failed %d", hdev->name, status);
195 BT_DBG("%s: OCF_WRITE_PG_TIMEOUT succeseful", hdev->name);
199 case OCF_WRITE_SCAN_ENABLE:
200 sent = hci_sent_cmd_data(hdev, OGF_HOST_CTL, OCF_WRITE_SCAN_ENABLE);
204 status = *((__u8 *) skb->data);
205 param = *((__u8 *) sent);
207 BT_DBG("param 0x%x", param);
210 clear_bit(HCI_PSCAN, &hdev->flags);
211 clear_bit(HCI_ISCAN, &hdev->flags);
212 if (param & SCAN_INQUIRY)
213 set_bit(HCI_ISCAN, &hdev->flags);
215 if (param & SCAN_PAGE)
216 set_bit(HCI_PSCAN, &hdev->flags);
218 hci_req_complete(hdev, status);
221 case OCF_READ_VOICE_SETTING:
222 vs = (struct hci_rp_read_voice_setting *) skb->data;
225 BT_DBG("%s READ_VOICE_SETTING failed %d", hdev->name, vs->status);
229 setting = __le16_to_cpu(vs->voice_setting);
231 if (hdev->voice_setting != setting ) {
232 hdev->voice_setting = setting;
234 BT_DBG("%s: voice setting 0x%04x", hdev->name, setting);
237 hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING);
241 case OCF_WRITE_VOICE_SETTING:
242 sent = hci_sent_cmd_data(hdev, OGF_HOST_CTL, OCF_WRITE_VOICE_SETTING);
246 status = *((__u8 *) skb->data);
247 setting = __le16_to_cpu(get_unaligned((__u16 *) sent));
249 if (!status && hdev->voice_setting != setting) {
250 hdev->voice_setting = setting;
252 BT_DBG("%s: voice setting 0x%04x", hdev->name, setting);
255 hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING);
257 hci_req_complete(hdev, status);
260 case OCF_HOST_BUFFER_SIZE:
261 status = *((__u8 *) skb->data);
263 BT_DBG("%s OCF_BUFFER_SIZE failed %d", hdev->name, status);
264 hci_req_complete(hdev, status);
269 BT_DBG("%s Command complete: ogf HOST_CTL ocf %x", hdev->name, ocf);
274 /* Command Complete OGF INFO_PARAM */
275 static void hci_cc_info_param(struct hci_dev *hdev, __u16 ocf, struct sk_buff *skb)
277 struct hci_rp_read_loc_features *lf;
278 struct hci_rp_read_buffer_size *bs;
279 struct hci_rp_read_bd_addr *ba;
281 BT_DBG("%s ocf 0x%x", hdev->name, ocf);
284 case OCF_READ_LOCAL_FEATURES:
285 lf = (struct hci_rp_read_loc_features *) skb->data;
288 BT_DBG("%s READ_LOCAL_FEATURES failed %d", hdev->name, lf->status);
292 memcpy(hdev->features, lf->features, sizeof(hdev->features));
294 /* Adjust default settings according to features
295 * supported by device. */
296 if (hdev->features[0] & LMP_3SLOT)
297 hdev->pkt_type |= (HCI_DM3 | HCI_DH3);
299 if (hdev->features[0] & LMP_5SLOT)
300 hdev->pkt_type |= (HCI_DM5 | HCI_DH5);
302 if (hdev->features[1] & LMP_HV2)
303 hdev->pkt_type |= (HCI_HV2);
305 if (hdev->features[1] & LMP_HV3)
306 hdev->pkt_type |= (HCI_HV3);
308 BT_DBG("%s: features 0x%x 0x%x 0x%x", hdev->name, lf->features[0], lf->features[1], lf->features[2]);
312 case OCF_READ_BUFFER_SIZE:
313 bs = (struct hci_rp_read_buffer_size *) skb->data;
316 BT_DBG("%s READ_BUFFER_SIZE failed %d", hdev->name, bs->status);
317 hci_req_complete(hdev, bs->status);
321 hdev->acl_mtu = __le16_to_cpu(bs->acl_mtu);
322 hdev->sco_mtu = bs->sco_mtu ? bs->sco_mtu : 64;
323 hdev->acl_pkts = hdev->acl_cnt = __le16_to_cpu(bs->acl_max_pkt);
324 hdev->sco_pkts = hdev->sco_cnt = __le16_to_cpu(bs->sco_max_pkt);
326 BT_DBG("%s mtu: acl %d, sco %d max_pkt: acl %d, sco %d", hdev->name,
327 hdev->acl_mtu, hdev->sco_mtu, hdev->acl_pkts, hdev->sco_pkts);
330 case OCF_READ_BD_ADDR:
331 ba = (struct hci_rp_read_bd_addr *) skb->data;
334 bacpy(&hdev->bdaddr, &ba->bdaddr);
336 BT_DBG("%s: READ_BD_ADDR failed %d", hdev->name, ba->status);
339 hci_req_complete(hdev, ba->status);
343 BT_DBG("%s Command complete: ogf INFO_PARAM ocf %x", hdev->name, ocf);
348 /* Command Status OGF LINK_CTL */
349 static inline void hci_cs_create_conn(struct hci_dev *hdev, __u8 status)
351 struct hci_conn *conn;
352 struct hci_cp_create_conn *cp = hci_sent_cmd_data(hdev, OGF_LINK_CTL, OCF_CREATE_CONN);
359 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr);
361 BT_DBG("%s status 0x%x bdaddr %s conn %p", hdev->name,
362 status, batostr(&cp->bdaddr), conn);
366 conn->state = BT_CLOSED;
367 hci_proto_connect_cfm(conn, status);
372 conn = hci_conn_add(hdev, ACL_LINK, &cp->bdaddr);
375 conn->link_mode |= HCI_LM_MASTER;
377 BT_ERR("No memmory for new connection");
381 hci_dev_unlock(hdev);
384 static void hci_cs_link_ctl(struct hci_dev *hdev, __u16 ocf, __u8 status)
386 BT_DBG("%s ocf 0x%x", hdev->name, ocf);
389 case OCF_CREATE_CONN:
390 hci_cs_create_conn(hdev, status);
395 struct hci_conn *acl, *sco;
396 struct hci_cp_add_sco *cp = hci_sent_cmd_data(hdev, OGF_LINK_CTL, OCF_ADD_SCO);
402 handle = __le16_to_cpu(cp->handle);
404 BT_DBG("%s Add SCO error: handle %d status 0x%x", hdev->name, handle, status);
408 acl = hci_conn_hash_lookup_handle(hdev, handle);
409 if (acl && (sco = acl->link)) {
410 sco->state = BT_CLOSED;
412 hci_proto_connect_cfm(sco, status);
416 hci_dev_unlock(hdev);
422 BT_DBG("%s Inquiry error: status 0x%x", hdev->name, status);
423 hci_req_complete(hdev, status);
425 set_bit(HCI_INQUIRY, &hdev->flags);
430 BT_DBG("%s Command status: ogf LINK_CTL ocf %x status %d",
431 hdev->name, ocf, status);
436 /* Command Status OGF LINK_POLICY */
437 static void hci_cs_link_policy(struct hci_dev *hdev, __u16 ocf, __u8 status)
439 BT_DBG("%s ocf 0x%x", hdev->name, ocf);
443 BT_DBG("%s Command status: ogf HOST_POLICY ocf %x", hdev->name, ocf);
448 /* Command Status OGF HOST_CTL */
449 static void hci_cs_host_ctl(struct hci_dev *hdev, __u16 ocf, __u8 status)
451 BT_DBG("%s ocf 0x%x", hdev->name, ocf);
455 BT_DBG("%s Command status: ogf HOST_CTL ocf %x", hdev->name, ocf);
460 /* Command Status OGF INFO_PARAM */
461 static void hci_cs_info_param(struct hci_dev *hdev, __u16 ocf, __u8 status)
463 BT_DBG("%s: hci_cs_info_param: ocf 0x%x", hdev->name, ocf);
467 BT_DBG("%s Command status: ogf INFO_PARAM ocf %x", hdev->name, ocf);
472 /* Inquiry Complete */
473 static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
475 __u8 status = *((__u8 *) skb->data);
477 BT_DBG("%s status %d", hdev->name, status);
479 clear_bit(HCI_INQUIRY, &hdev->flags);
480 hci_req_complete(hdev, status);
484 static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb)
486 struct inquiry_info *info = (struct inquiry_info *) (skb->data + 1);
487 int num_rsp = *((__u8 *) skb->data);
489 BT_DBG("%s num_rsp %d", hdev->name, num_rsp);
492 for (; num_rsp; num_rsp--)
493 inquiry_cache_update(hdev, info++);
494 hci_dev_unlock(hdev);
497 /* Inquiry Result With RSSI */
498 static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct sk_buff *skb)
500 struct inquiry_info_with_rssi *info = (struct inquiry_info_with_rssi *) (skb->data + 1);
501 int num_rsp = *((__u8 *) skb->data);
503 BT_DBG("%s num_rsp %d", hdev->name, num_rsp);
506 for (; num_rsp; num_rsp--) {
507 struct inquiry_info tmp;
508 bacpy(&tmp.bdaddr, &info->bdaddr);
509 tmp.pscan_rep_mode = info->pscan_rep_mode;
510 tmp.pscan_period_mode = info->pscan_period_mode;
511 tmp.pscan_mode = 0x00;
512 memcpy(tmp.dev_class, &info->dev_class, 3);
513 tmp.clock_offset = info->clock_offset;
515 inquiry_cache_update(hdev, &tmp);
517 hci_dev_unlock(hdev);
520 /* Connect Request */
521 static inline void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
523 struct hci_ev_conn_request *ev = (struct hci_ev_conn_request *) skb->data;
524 int mask = hdev->link_mode;
526 BT_DBG("%s Connection request: %s type 0x%x", hdev->name,
527 batostr(&ev->bdaddr), ev->link_type);
529 mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ev->link_type);
531 if (mask & HCI_LM_ACCEPT) {
532 /* Connection accepted */
533 struct hci_conn *conn;
534 struct hci_cp_accept_conn_req cp;
537 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr);
539 if (!(conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr))) {
540 BT_ERR("No memmory for new connection");
541 hci_dev_unlock(hdev);
545 conn->state = BT_CONNECT;
546 hci_dev_unlock(hdev);
548 bacpy(&cp.bdaddr, &ev->bdaddr);
550 if (lmp_rswitch_capable(hdev) && (mask & HCI_LM_MASTER))
551 cp.role = 0x00; /* Become master */
553 cp.role = 0x01; /* Remain slave */
555 hci_send_cmd(hdev, OGF_LINK_CTL, OCF_ACCEPT_CONN_REQ, sizeof(cp), &cp);
557 /* Connection rejected */
558 struct hci_cp_reject_conn_req cp;
560 bacpy(&cp.bdaddr, &ev->bdaddr);
562 hci_send_cmd(hdev, OGF_LINK_CTL, OCF_REJECT_CONN_REQ, sizeof(cp), &cp);
566 /* Connect Complete */
567 static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
569 struct hci_ev_conn_complete *ev = (struct hci_ev_conn_complete *) skb->data;
570 struct hci_conn *conn = NULL;
572 BT_DBG("%s", hdev->name);
576 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr);
578 hci_dev_unlock(hdev);
583 conn->handle = __le16_to_cpu(ev->handle);
584 conn->state = BT_CONNECTED;
586 if (test_bit(HCI_AUTH, &hdev->flags))
587 conn->link_mode |= HCI_LM_AUTH;
589 if (test_bit(HCI_ENCRYPT, &hdev->flags))
590 conn->link_mode |= HCI_LM_ENCRYPT;
593 /* Set link policy */
594 if (conn->type == ACL_LINK && hdev->link_policy) {
595 struct hci_cp_write_link_policy cp;
596 cp.handle = ev->handle;
597 cp.policy = __cpu_to_le16(hdev->link_policy);
598 hci_send_cmd(hdev, OGF_LINK_POLICY, OCF_WRITE_LINK_POLICY, sizeof(cp), &cp);
601 /* Set packet type for incoming connection */
603 struct hci_cp_change_conn_ptype cp;
604 cp.handle = ev->handle;
605 cp.pkt_type = (conn->type == ACL_LINK) ?
606 __cpu_to_le16(hdev->pkt_type & ACL_PTYPE_MASK):
607 __cpu_to_le16(hdev->pkt_type & SCO_PTYPE_MASK);
609 hci_send_cmd(hdev, OGF_LINK_CTL, OCF_CHANGE_CONN_PTYPE, sizeof(cp), &cp);
612 conn->state = BT_CLOSED;
614 if (conn->type == ACL_LINK) {
615 struct hci_conn *sco = conn->link;
618 hci_add_sco(sco, conn->handle);
620 hci_proto_connect_cfm(sco, ev->status);
626 hci_proto_connect_cfm(conn, ev->status);
630 hci_dev_unlock(hdev);
633 /* Disconnect Complete */
634 static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
636 struct hci_ev_disconn_complete *ev = (struct hci_ev_disconn_complete *) skb->data;
637 struct hci_conn *conn = NULL;
638 __u16 handle = __le16_to_cpu(ev->handle);
640 BT_DBG("%s status %d", hdev->name, ev->status);
647 conn = hci_conn_hash_lookup_handle(hdev, handle);
649 conn->state = BT_CLOSED;
650 hci_proto_disconn_ind(conn, ev->reason);
654 hci_dev_unlock(hdev);
657 /* Number of completed packets */
658 static inline void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *skb)
660 struct hci_ev_num_comp_pkts *ev = (struct hci_ev_num_comp_pkts *) skb->data;
664 skb_pull(skb, sizeof(*ev));
666 BT_DBG("%s num_hndl %d", hdev->name, ev->num_hndl);
668 if (skb->len < ev->num_hndl * 4) {
669 BT_DBG("%s bad parameters", hdev->name);
673 tasklet_disable(&hdev->tx_task);
675 for (i = 0, ptr = (__u16 *) skb->data; i < ev->num_hndl; i++) {
676 struct hci_conn *conn;
679 handle = __le16_to_cpu(get_unaligned(ptr++));
680 count = __le16_to_cpu(get_unaligned(ptr++));
682 conn = hci_conn_hash_lookup_handle(hdev, handle);
686 if (conn->type == SCO_LINK) {
687 if ((hdev->sco_cnt += count) > hdev->sco_pkts)
688 hdev->sco_cnt = hdev->sco_pkts;
690 if ((hdev->acl_cnt += count) > hdev->acl_pkts)
691 hdev->acl_cnt = hdev->acl_pkts;
697 tasklet_enable(&hdev->tx_task);
701 static inline void hci_role_change_evt(struct hci_dev *hdev, struct sk_buff *skb)
703 struct hci_ev_role_change *ev = (struct hci_ev_role_change *) skb->data;
704 struct hci_conn *conn = NULL;
706 BT_DBG("%s status %d", hdev->name, ev->status);
713 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
716 conn->link_mode &= ~HCI_LM_MASTER;
718 conn->link_mode |= HCI_LM_MASTER;
721 hci_dev_unlock(hdev);
724 /* Authentication Complete */
725 static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
727 struct hci_ev_auth_complete *ev = (struct hci_ev_auth_complete *) skb->data;
728 struct hci_conn *conn = NULL;
729 __u16 handle = __le16_to_cpu(ev->handle);
731 BT_DBG("%s status %d", hdev->name, ev->status);
735 conn = hci_conn_hash_lookup_handle(hdev, handle);
738 conn->link_mode |= HCI_LM_AUTH;
739 clear_bit(HCI_CONN_AUTH_PEND, &conn->pend);
741 hci_proto_auth_cfm(conn, ev->status);
743 if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) {
745 struct hci_cp_set_conn_encrypt cp;
746 cp.handle = __cpu_to_le16(conn->handle);
748 hci_send_cmd(conn->hdev, OGF_LINK_CTL,
749 OCF_SET_CONN_ENCRYPT,
752 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend);
753 hci_proto_encrypt_cfm(conn, ev->status);
758 hci_dev_unlock(hdev);
761 /* Encryption Change */
762 static inline void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff *skb)
764 struct hci_ev_encrypt_change *ev = (struct hci_ev_encrypt_change *) skb->data;
765 struct hci_conn *conn = NULL;
766 __u16 handle = __le16_to_cpu(ev->handle);
768 BT_DBG("%s status %d", hdev->name, ev->status);
772 conn = hci_conn_hash_lookup_handle(hdev, handle);
776 conn->link_mode |= HCI_LM_ENCRYPT;
778 conn->link_mode &= ~HCI_LM_ENCRYPT;
780 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend);
782 hci_proto_encrypt_cfm(conn, ev->status);
785 hci_dev_unlock(hdev);
788 void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
790 struct hci_event_hdr *hdr = (struct hci_event_hdr *) skb->data;
791 struct hci_ev_cmd_complete *ec;
792 struct hci_ev_cmd_status *cs;
793 u16 opcode, ocf, ogf;
795 skb_pull(skb, HCI_EVENT_HDR_SIZE);
797 BT_DBG("%s evt 0x%x", hdev->name, hdr->evt);
800 case HCI_EV_NUM_COMP_PKTS:
801 hci_num_comp_pkts_evt(hdev, skb);
804 case HCI_EV_INQUIRY_COMPLETE:
805 hci_inquiry_complete_evt(hdev, skb);
808 case HCI_EV_INQUIRY_RESULT:
809 hci_inquiry_result_evt(hdev, skb);
812 case HCI_EV_INQUIRY_RESULT_WITH_RSSI:
813 hci_inquiry_result_with_rssi_evt(hdev, skb);
816 case HCI_EV_CONN_REQUEST:
817 hci_conn_request_evt(hdev, skb);
820 case HCI_EV_CONN_COMPLETE:
821 hci_conn_complete_evt(hdev, skb);
824 case HCI_EV_DISCONN_COMPLETE:
825 hci_disconn_complete_evt(hdev, skb);
828 case HCI_EV_ROLE_CHANGE:
829 hci_role_change_evt(hdev, skb);
832 case HCI_EV_AUTH_COMPLETE:
833 hci_auth_complete_evt(hdev, skb);
836 case HCI_EV_ENCRYPT_CHANGE:
837 hci_encrypt_change_evt(hdev, skb);
840 case HCI_EV_CMD_STATUS:
841 cs = (struct hci_ev_cmd_status *) skb->data;
842 skb_pull(skb, sizeof(cs));
844 opcode = __le16_to_cpu(cs->opcode);
845 ogf = hci_opcode_ogf(opcode);
846 ocf = hci_opcode_ocf(opcode);
850 hci_cs_info_param(hdev, ocf, cs->status);
854 hci_cs_host_ctl(hdev, ocf, cs->status);
858 hci_cs_link_ctl(hdev, ocf, cs->status);
861 case OGF_LINK_POLICY:
862 hci_cs_link_policy(hdev, ocf, cs->status);
866 BT_DBG("%s Command Status OGF %x", hdev->name, ogf);
871 atomic_set(&hdev->cmd_cnt, 1);
872 if (!skb_queue_empty(&hdev->cmd_q))
877 case HCI_EV_CMD_COMPLETE:
878 ec = (struct hci_ev_cmd_complete *) skb->data;
879 skb_pull(skb, sizeof(*ec));
881 opcode = __le16_to_cpu(ec->opcode);
882 ogf = hci_opcode_ogf(opcode);
883 ocf = hci_opcode_ocf(opcode);
887 hci_cc_info_param(hdev, ocf, skb);
891 hci_cc_host_ctl(hdev, ocf, skb);
895 hci_cc_link_ctl(hdev, ocf, skb);
898 case OGF_LINK_POLICY:
899 hci_cc_link_policy(hdev, ocf, skb);
903 BT_DBG("%s Command Completed OGF %x", hdev->name, ogf);
908 atomic_set(&hdev->cmd_cnt, 1);
909 if (!skb_queue_empty(&hdev->cmd_q))
919 /* Generate internal stack event */
920 void hci_si_event(struct hci_dev *hdev, int type, int dlen, void *data)
922 struct hci_event_hdr *hdr;
923 struct hci_ev_stack_internal *ev;
926 skb = bt_skb_alloc(HCI_EVENT_HDR_SIZE + sizeof(*ev) + dlen, GFP_ATOMIC);
930 hdr = (void *) skb_put(skb, HCI_EVENT_HDR_SIZE);
931 hdr->evt = HCI_EV_STACK_INTERNAL;
932 hdr->plen = sizeof(*ev) + dlen;
934 ev = (void *) skb_put(skb, sizeof(*ev) + dlen);
936 memcpy(ev->data, data, dlen);
938 skb->pkt_type = HCI_EVENT_PKT;
939 skb->dev = (void *) hdev;
940 hci_send_to_sock(hdev, skb);