Lines Matching defs:hdev
62 /* This function requires the caller holds hdev->lock */
66 struct hci_dev *hdev = conn->hdev;
75 irk = hci_get_irk(hdev, bdaddr, bdaddr_type);
81 params = hci_pend_le_action_lookup(&hdev->pend_le_conns, bdaddr,
97 hci_conn_params_del(hdev, bdaddr, bdaddr_type);
102 list_add(¶ms->action, &hdev->pend_le_conns);
105 list_add(¶ms->action, &hdev->pend_le_reports);
111 hci_update_background_scan(hdev);
116 struct hci_dev *hdev = conn->hdev;
119 hci_conn_params_del(conn->hdev, &conn->dst, conn->dst_type);
123 hci_conn_hash_del(hdev, conn);
129 if (hdev->notify)
130 hdev->notify(hdev, HCI_NOTIFY_DISABLE_SCO);
134 if (hdev->notify)
135 hdev->notify(hdev, HCI_NOTIFY_CONN_DEL);
142 hci_dev_put(hdev);
149 struct hci_dev *hdev = conn->hdev;
152 BT_DBG("%s hcon %p", hdev->name, conn);
154 hci_dev_lock(hdev);
158 list_for_each_entry_rcu(c, &hdev->conn_hash.list, list) {
169 hci_dev_unlock(hdev);
170 hci_dev_put(hdev);
176 BT_DBG("%s hcon %p", conn->hdev->name, conn);
186 hci_dev_hold(conn->hdev);
189 /* Even though we hold a reference to the hdev, many other
190 * things might get cleaned up meanwhile, including the hdev's
198 struct hci_dev *hdev = conn->hdev;
210 conn->link_policy = hdev->link_policy;
216 ie = hci_inquiry_cache_lookup(hdev, &conn->dst);
229 if (lmp_rswitch_capable(hdev) && !(hdev->link_mode & HCI_LM_MASTER))
234 hci_send_cmd(hdev, HCI_OP_CREATE_CONN, sizeof(cp), &cp);
248 struct hci_dev *hdev = conn->hdev;
252 hci_send_cmd(hdev, HCI_OP_READ_CLOCK_OFFSET, sizeof(clkoff_cp),
261 struct hci_dev *hdev = conn->hdev;
274 hci_send_cmd(hdev, HCI_OP_ADD_SCO, sizeof(cp), &cp);
279 struct hci_dev *hdev = conn->hdev;
321 if (hci_send_cmd(hdev, HCI_OP_SETUP_SYNC_CONN, sizeof(cp), &cp) < 0)
330 struct hci_dev *hdev = conn->hdev;
334 hci_dev_lock(hdev);
336 params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type);
344 hci_dev_unlock(hdev);
355 hci_send_cmd(hdev, HCI_OP_LE_CONN_UPDATE, sizeof(cp), &cp);
366 struct hci_dev *hdev = conn->hdev;
378 hci_send_cmd(hdev, HCI_OP_LE_START_ENC, sizeof(cp), &cp);
392 if (lmp_esco_capable(conn->hdev))
437 struct hci_dev *hdev = conn->hdev;
441 if (!lmp_sniff_capable(hdev) || !lmp_sniff_capable(conn))
447 if (lmp_sniffsubr_capable(hdev) && lmp_sniffsubr_capable(conn)) {
453 hci_send_cmd(hdev, HCI_OP_SNIFF_SUBRATE, sizeof(cp), &cp);
459 cp.max_interval = cpu_to_le16(hdev->sniff_max_interval);
460 cp.min_interval = cpu_to_le16(hdev->sniff_min_interval);
463 hci_send_cmd(hdev, HCI_OP_SNIFF_MODE, sizeof(cp), &cp);
472 hci_send_cmd(conn->hdev, HCI_OP_USER_CONFIRM_REPLY, sizeof(conn->dst),
476 static void le_disable_advertising(struct hci_dev *hdev)
478 if (ext_adv_capable(hdev)) {
484 hci_send_cmd(hdev, HCI_OP_LE_SET_EXT_ADV_ENABLE, sizeof(cp),
488 hci_send_cmd(hdev, HCI_OP_LE_SET_ADV_ENABLE, sizeof(enable),
497 struct hci_dev *hdev = conn->hdev;
508 le_disable_advertising(hdev);
509 hci_dev_lock(hdev);
511 hci_dev_unlock(hdev);
518 struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst,
523 BT_DBG("%s dst %pMR", hdev->name, dst);
530 bacpy(&conn->src, &hdev->bdaddr);
531 conn->hdev = hdev;
537 conn->io_capability = hdev->io_capability;
555 conn->pkt_type = hdev->pkt_type & ACL_PTYPE_MASK;
559 hci_copy_identity_address(hdev, &conn->src, &conn->src_type);
562 if (lmp_esco_capable(hdev))
563 conn->pkt_type = (hdev->esco_type & SCO_ESCO_MASK) |
564 (hdev->esco_type & EDR_ESCO_MASK);
566 conn->pkt_type = hdev->pkt_type & SCO_PTYPE_MASK;
569 conn->pkt_type = hdev->esco_type & ~EDR_ESCO_MASK;
585 hci_dev_hold(hdev);
587 hci_conn_hash_add(hdev, conn);
594 if (hdev->notify)
595 hdev->notify(hdev, HCI_NOTIFY_CONN_ADD);
605 struct hci_dev *hdev = conn->hdev;
607 BT_DBG("%s hcon %p handle %d", hdev->name, conn, conn->handle);
619 hdev->acl_cnt += conn->sent;
623 if (hdev->le_pkts)
624 hdev->le_cnt += conn->sent;
626 hdev->acl_cnt += conn->sent;
653 struct hci_dev *hdev = NULL, *d;
694 hdev = d; break;
698 hdev = d; break;
703 if (hdev)
704 hdev = hci_dev_hold(hdev);
707 return hdev;
711 /* This function requires the caller holds hdev->lock */
714 struct hci_dev *hdev = conn->hdev;
717 params = hci_pend_le_action_lookup(&hdev->pend_le_conns, &conn->dst,
735 mgmt_connect_failed(hdev, &conn->dst, conn->type,
745 hci_update_background_scan(hdev);
750 hci_req_reenable_advertising(hdev);
753 static void create_le_conn_complete(struct hci_dev *hdev, u8 status, u16 opcode)
757 hci_dev_lock(hdev);
759 conn = hci_lookup_le_connect(hdev);
766 bt_dev_err(hdev, "request failed to create LE connection: "
775 hci_dev_unlock(hdev);
780 struct hci_dev *hdev = conn->hdev;
782 return hci_dev_test_flag(hdev, HCI_PRIVACY);
788 struct hci_dev *hdev = conn->hdev;
792 p->scan_interval = cpu_to_le16(hdev->le_scan_int_connect);
793 p->scan_window = cpu_to_le16(hdev->le_scan_window_connect);
806 struct hci_dev *hdev = conn->hdev;
813 if (bacmp(&req->hdev->random_addr, direct_rpa))
828 if (use_ext_conn(hdev)) {
845 if (scan_1m(hdev)) {
853 if (scan_2m(hdev)) {
861 if (scan_coded(hdev)) {
875 cp.scan_interval = cpu_to_le16(hdev->le_scan_int_connect);
876 cp.scan_window = cpu_to_le16(hdev->le_scan_window_connect);
898 struct hci_dev *hdev = req->hdev;
902 if (ext_adv_capable(hdev)) {
909 if (hci_get_random_address(hdev, false, conn_use_rpa(conn), NULL,
917 cp.channel_map = hdev->le_adv_channel_map;
940 bacmp(&random_addr, &hdev->random_addr)) {
962 hci_dev_clear_flag(hdev, HCI_LE_ADV);
984 cp.channel_map = hdev->le_adv_channel_map;
996 struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
1012 if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED)) {
1013 if (lmp_le_capable(hdev))
1022 if (hci_lookup_le_connect(hdev))
1030 conn = hci_conn_hash_lookup_le(hdev, dst, dst_type);
1044 irk = hci_find_irk_by_addr(hdev, dst, dst_type);
1053 conn = hci_conn_add(hdev, LE_LINK, dst, role);
1064 hci_req_init(&req, hdev);
1072 if (hci_dev_test_flag(hdev, HCI_LE_ADV))
1080 if (hci_dev_test_flag(hdev, HCI_LE_SCAN) &&
1081 hdev->le_scan_type == LE_SCAN_ACTIVE) {
1091 params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type);
1098 conn->le_conn_min_interval = hdev->le_conn_min_interval;
1099 conn->le_conn_max_interval = hdev->le_conn_max_interval;
1100 conn->le_conn_latency = hdev->le_conn_latency;
1101 conn->le_supv_timeout = hdev->le_supv_timeout;
1110 if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) {
1112 hci_dev_set_flag(hdev, HCI_LE_SCAN_INTERRUPTED);
1127 static bool is_connected(struct hci_dev *hdev, bdaddr_t *addr, u8 type)
1131 conn = hci_conn_hash_lookup_le(hdev, addr, type);
1141 /* This function requires the caller holds hdev->lock */
1142 static int hci_explicit_conn_params_set(struct hci_dev *hdev,
1147 if (is_connected(hdev, addr, addr_type))
1150 params = hci_conn_params_lookup(hdev, addr, addr_type);
1152 params = hci_conn_params_add(hdev, addr, addr_type);
1168 list_add(¶ms->action, &hdev->pend_le_conns);
1179 /* This function requires the caller holds hdev->lock */
1180 struct hci_conn *hci_connect_le_scan(struct hci_dev *hdev, bdaddr_t *dst,
1188 if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED)) {
1189 if (lmp_le_capable(hdev))
1204 conn = hci_conn_hash_lookup_le(hdev, dst, dst_type);
1213 conn = hci_conn_add(hdev, LE_LINK, dst, HCI_ROLE_MASTER);
1217 if (hci_explicit_conn_params_set(hdev, dst, dst_type) < 0) {
1230 hci_update_background_scan(hdev);
1237 struct hci_conn *hci_connect_acl(struct hci_dev *hdev, bdaddr_t *dst,
1243 if (!hci_dev_test_flag(hdev, HCI_BREDR_ENABLED)) {
1244 if (lmp_bredr_capable(hdev))
1253 if (!bacmp(&hdev->bdaddr, dst)) {
1254 bt_dev_dbg(hdev, "Reject connection with same BD_ADDR %pMR\n",
1259 acl = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst);
1261 acl = hci_conn_add(hdev, ACL_LINK, dst, HCI_ROLE_MASTER);
1279 struct hci_conn *hci_connect_sco(struct hci_dev *hdev, int type, bdaddr_t *dst,
1285 acl = hci_connect_acl(hdev, dst, BT_SECURITY_LOW, HCI_AT_NO_BONDING,
1290 sco = hci_conn_hash_lookup_ba(hdev, type, dst);
1292 sco = hci_conn_add(hdev, type, dst, HCI_ROLE_MASTER);
1332 if (hci_dev_test_flag(conn->hdev, HCI_SC_ONLY)) {
1351 bt_dev_err(conn->hdev,
1385 hci_send_cmd(conn->hdev, HCI_OP_AUTH_REQUESTED,
1407 hci_send_cmd(conn->hdev, HCI_OP_SET_CONN_ENCRYPT, sizeof(cp),
1528 hci_send_cmd(conn->hdev, HCI_OP_SWITCH_ROLE, sizeof(cp), &cp);
1538 struct hci_dev *hdev = conn->hdev;
1551 hci_send_cmd(hdev, HCI_OP_EXIT_SNIFF_MODE, sizeof(cp), &cp);
1555 if (hdev->idle_timeout > 0)
1556 queue_delayed_work(hdev->workqueue, &conn->idle_work,
1557 msecs_to_jiffies(hdev->idle_timeout));
1561 void hci_conn_hash_flush(struct hci_dev *hdev)
1563 struct hci_conn_hash *h = &hdev->conn_hash;
1566 BT_DBG("hdev %s", hdev->name);
1577 void hci_conn_check_pending(struct hci_dev *hdev)
1581 BT_DBG("hdev %s", hdev->name);
1583 hci_dev_lock(hdev);
1585 conn = hci_conn_hash_lookup_state(hdev, ACL_LINK, BT_CONNECT2);
1589 hci_dev_unlock(hdev);
1619 struct hci_dev *hdev;
1634 hdev = hci_dev_get(req.dev_id);
1635 if (!hdev) {
1642 hci_dev_lock(hdev);
1643 list_for_each_entry(c, &hdev->conn_hash.list, list) {
1653 hci_dev_unlock(hdev);
1655 cl->dev_id = hdev->id;
1659 hci_dev_put(hdev);
1667 int hci_get_conn_info(struct hci_dev *hdev, void __user *arg)
1677 hci_dev_lock(hdev);
1678 conn = hci_conn_hash_lookup_ba(hdev, req.type, &req.bdaddr);
1687 hci_dev_unlock(hdev);
1695 int hci_get_auth_info(struct hci_dev *hdev, void __user *arg)
1703 hci_dev_lock(hdev);
1704 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &req.bdaddr);
1707 hci_dev_unlock(hdev);
1717 struct hci_dev *hdev = conn->hdev;
1720 BT_DBG("%s hcon %p", hdev->name, conn);
1743 struct hci_dev *hdev = conn->hdev;
1745 BT_DBG("%s hcon %p chan %p", hdev->name, conn, chan);
1783 struct hci_chan *hci_chan_lookup_handle(struct hci_dev *hdev, __u16 handle)
1785 struct hci_conn_hash *h = &hdev->conn_hash;