Lines Matching defs:hdev

70 /* This function requires the caller holds hdev->lock */
74 struct hci_dev *hdev = conn->hdev;
83 irk = hci_get_irk(hdev, bdaddr, bdaddr_type);
89 params = hci_pend_le_action_lookup(&hdev->pend_le_conns, bdaddr,
110 mgmt_connect_failed(hdev, &conn->dst, conn->type,
124 hci_conn_params_del(hdev, bdaddr, bdaddr_type);
129 hci_pend_le_list_add(params, &hdev->pend_le_conns);
132 hci_pend_le_list_add(params, &hdev->pend_le_reports);
138 hci_update_passive_scan(hdev);
143 struct hci_dev *hdev = conn->hdev;
146 hci_conn_params_del(conn->hdev, &conn->dst, conn->dst_type);
149 hci_remove_link_key(hdev, &conn->dst);
153 hci_conn_hash_del(hdev, conn);
156 ida_free(&hdev->unset_handle_ida, conn->handle);
165 if (hdev->notify)
166 hdev->notify(hdev, HCI_NOTIFY_DISABLE_SCO);
170 if (hdev->notify)
171 hdev->notify(hdev, HCI_NOTIFY_CONN_DEL);
178 hci_dev_put(hdev);
192 struct hci_dev *hdev = conn->hdev;
196 hci_send_cmd(hdev, HCI_OP_READ_CLOCK_OFFSET, sizeof(clkoff_cp),
205 struct hci_dev *hdev = conn->hdev;
218 hci_send_cmd(hdev, HCI_OP_ADD_SCO, sizeof(cp), &cp);
238 static int configure_datapath_sync(struct hci_dev *hdev, struct bt_codec *codec)
248 if (!codec->data_path || !hdev->get_codec_config_data)
251 err = hdev->get_codec_config_data(hdev, ESCO_LINK, codec, &vnd_len,
262 err = hdev->get_data_path_id(hdev, &cmd->data_path_id);
270 __hci_cmd_sync_status(hdev, HCI_CONFIGURE_DATA_PATH,
274 err = __hci_cmd_sync_status(hdev, HCI_CONFIGURE_DATA_PATH,
284 static int hci_enhanced_setup_sync(struct hci_dev *hdev, void *data)
294 bt_dev_dbg(hdev, "hcon %p", conn);
296 configure_datapath_sync(hdev, &conn->codec);
400 if (hci_send_cmd(hdev, HCI_OP_ENHANCED_SETUP_SYNC_CONN, sizeof(cp), &cp) < 0)
408 struct hci_dev *hdev = conn->hdev;
412 bt_dev_dbg(hdev, "hcon %p", conn);
452 if (hci_send_cmd(hdev, HCI_OP_SETUP_SYNC_CONN, sizeof(cp), &cp) < 0)
463 if (enhanced_sync_conn_capable(conn->hdev)) {
471 result = hci_cmd_sync_queue(conn->hdev, hci_enhanced_setup_sync,
485 struct hci_dev *hdev = conn->hdev;
489 hci_dev_lock(hdev);
491 params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type);
499 hci_dev_unlock(hdev);
510 hci_send_cmd(hdev, HCI_OP_LE_CONN_UPDATE, sizeof(cp), &cp);
521 struct hci_dev *hdev = conn->hdev;
533 hci_send_cmd(hdev, HCI_OP_LE_START_ENC, sizeof(cp), &cp);
548 if (lmp_esco_capable(conn->hdev))
586 struct hci_dev *hdev = conn->hdev;
590 if (!lmp_sniff_capable(hdev) || !lmp_sniff_capable(conn))
596 if (lmp_sniffsubr_capable(hdev) && lmp_sniffsubr_capable(conn)) {
602 hci_send_cmd(hdev, HCI_OP_SNIFF_SUBRATE, sizeof(cp), &cp);
608 cp.max_interval = cpu_to_le16(hdev->sniff_max_interval);
609 cp.min_interval = cpu_to_le16(hdev->sniff_min_interval);
612 hci_send_cmd(hdev, HCI_OP_SNIFF_MODE, sizeof(cp), &cp);
621 hci_send_cmd(conn->hdev, HCI_OP_USER_CONFIRM_REPLY, sizeof(conn->dst),
625 static void le_disable_advertising(struct hci_dev *hdev)
627 if (ext_adv_capable(hdev)) {
633 hci_send_cmd(hdev, HCI_OP_LE_SET_EXT_ADV_ENABLE, sizeof(cp),
637 hci_send_cmd(hdev, HCI_OP_LE_SET_ADV_ENABLE, sizeof(enable),
646 struct hci_dev *hdev = conn->hdev;
657 le_disable_advertising(hdev);
658 hci_dev_lock(hdev);
660 hci_dev_unlock(hdev);
698 static int terminate_big_sync(struct hci_dev *hdev, void *data)
702 bt_dev_dbg(hdev, "big 0x%2.2x bis 0x%2.2x", d->big, d->bis);
704 hci_disable_per_advertising_sync(hdev, d->bis);
705 hci_remove_ext_adv_instance_sync(hdev, d->bis, NULL);
711 return hci_le_terminate_big_sync(hdev, d->big,
715 static void terminate_big_destroy(struct hci_dev *hdev, void *data, int err)
720 static int hci_le_terminate_big(struct hci_dev *hdev, struct hci_conn *conn)
725 bt_dev_dbg(hdev, "big 0x%2.2x bis 0x%2.2x", conn->iso_qos.bcast.big,
736 ret = hci_cmd_sync_queue(hdev, terminate_big_sync, d,
744 static int big_terminate_sync(struct hci_dev *hdev, void *data)
748 bt_dev_dbg(hdev, "big 0x%2.2x sync_handle 0x%4.4x", d->big,
752 hci_le_big_terminate_sync(hdev, d->big);
755 return hci_le_pa_terminate_sync(hdev, d->sync_handle);
771 static int hci_le_big_terminate(struct hci_dev *hdev, u8 big, struct hci_conn *conn)
776 bt_dev_dbg(hdev, "big 0x%2.2x sync_handle 0x%4.4x", big, conn->sync_handle);
787 hci_conn_hash_list_flag(hdev, find_bis, ISO_LINK,
797 hci_conn_hash_list_flag(hdev, find_bis, ISO_LINK,
804 ret = hci_cmd_sync_queue(hdev, big_terminate_sync, d,
820 struct hci_dev *hdev = conn->hdev;
823 bt_dev_dbg(hdev, "conn %p", conn);
832 bis = hci_conn_hash_lookup_big(hdev, conn->iso_qos.bcast.big);
836 hci_le_terminate_big(hdev, conn);
838 hci_le_big_terminate(hdev, conn->iso_qos.bcast.big,
843 static int remove_cig_sync(struct hci_dev *hdev, void *data)
847 return hci_le_remove_cig_sync(hdev, handle);
850 static int hci_le_remove_cig(struct hci_dev *hdev, u8 handle)
852 bt_dev_dbg(hdev, "handle 0x%2.2x", handle);
854 return hci_cmd_sync_queue(hdev, remove_cig_sync, UINT_PTR(handle),
875 struct hci_dev *hdev = conn->hdev;
887 hci_conn_hash_list_state(hdev, find_cis, ISO_LINK, BT_BOUND, &d);
888 hci_conn_hash_list_state(hdev, find_cis, ISO_LINK, BT_CONNECT, &d);
889 hci_conn_hash_list_state(hdev, find_cis, ISO_LINK, BT_CONNECTED, &d);
893 hci_le_remove_cig(hdev, conn->iso_qos.ucast.cig);
896 static int hci_conn_hash_alloc_unset(struct hci_dev *hdev)
898 return ida_alloc_range(&hdev->unset_handle_ida, HCI_CONN_HANDLE_MAX + 1,
902 struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst,
909 if (!hdev->acl_mtu)
913 if (hdev->iso_mtu)
918 if (hdev->le_mtu && hdev->le_mtu < HCI_MIN_LE_MTU)
920 if (!hdev->le_mtu && hdev->acl_mtu < HCI_MIN_LE_MTU)
925 if (!hdev->sco_pkts)
933 bt_dev_dbg(hdev, "dst %pMR handle 0x%4.4x", dst, handle);
940 bacpy(&conn->src, &hdev->bdaddr);
942 conn->hdev = hdev;
948 conn->io_capability = hdev->io_capability;
967 conn->pkt_type = hdev->pkt_type & ACL_PTYPE_MASK;
968 conn->mtu = hdev->acl_mtu;
972 hci_copy_identity_address(hdev, &conn->src, &conn->src_type);
973 conn->mtu = hdev->le_mtu ? hdev->le_mtu : hdev->acl_mtu;
977 hci_copy_identity_address(hdev, &conn->src, &conn->src_type);
985 conn->mtu = hdev->iso_mtu ? hdev->iso_mtu :
986 hdev->le_mtu ? hdev->le_mtu : hdev->acl_mtu;
989 if (lmp_esco_capable(hdev))
990 conn->pkt_type = (hdev->esco_type & SCO_ESCO_MASK) |
991 (hdev->esco_type & EDR_ESCO_MASK);
993 conn->pkt_type = hdev->pkt_type & SCO_PTYPE_MASK;
995 conn->mtu = hdev->sco_mtu;
998 conn->pkt_type = hdev->esco_type & ~EDR_ESCO_MASK;
999 conn->mtu = hdev->sco_mtu;
1015 hci_dev_hold(hdev);
1017 hci_conn_hash_add(hdev, conn);
1024 if (hdev->notify)
1025 hdev->notify(hdev, HCI_NOTIFY_CONN_ADD);
1033 struct hci_conn *hci_conn_add_unset(struct hci_dev *hdev, int type,
1038 bt_dev_dbg(hdev, "dst %pMR", dst);
1040 handle = hci_conn_hash_alloc_unset(hdev);
1044 return hci_conn_add(hdev, type, dst, role, handle);
1073 struct hci_dev *hdev = conn->hdev;
1075 bt_dev_dbg(hdev, "hcon %p", conn);
1085 /* If hdev is down it means
1090 if (!test_bit(HCI_UP, &hdev->flags))
1115 struct hci_dev *hdev = conn->hdev;
1117 BT_DBG("%s hcon %p handle %d", hdev->name, conn, conn->handle);
1127 hdev->acl_cnt += conn->sent;
1131 if (hdev->le_pkts)
1132 hdev->le_cnt += conn->sent;
1134 hdev->acl_cnt += conn->sent;
1138 if (hdev->iso_pkts)
1139 hdev->iso_cnt += conn->sent;
1140 else if (hdev->le_pkts)
1141 hdev->le_cnt += conn->sent;
1143 hdev->acl_cnt += conn->sent;
1157 hci_cmd_sync_dequeue(hdev, NULL, conn, NULL);
1163 struct hci_dev *hdev = NULL, *d;
1203 hdev = d; break;
1207 hdev = d; break;
1212 if (hdev)
1213 hdev = hci_dev_hold(hdev);
1216 return hdev;
1220 /* This function requires the caller holds hdev->lock */
1223 struct hci_dev *hdev = conn->hdev;
1230 hci_enable_advertising(hdev);
1233 /* This function requires the caller holds hdev->lock */
1236 struct hci_dev *hdev = conn->hdev;
1238 bt_dev_dbg(hdev, "status 0x%2.2x", status);
1245 mgmt_connect_failed(hdev, &conn->dst, conn->type,
1261 /* This function requires the caller holds hdev->lock */
1264 struct hci_dev *hdev = conn->hdev;
1266 bt_dev_dbg(hdev, "hcon %p handle 0x%4.4x", conn, handle);
1272 bt_dev_err(hdev, "Invalid handle: 0x%4.4x > 0x%4.4x",
1284 ida_free(&hdev->unset_handle_ida, conn->handle);
1291 struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
1300 if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED)) {
1301 if (lmp_le_capable(hdev))
1310 if (hci_lookup_le_connect(hdev))
1318 conn = hci_conn_hash_lookup_le(hdev, dst, dst_type);
1336 irk = hci_find_irk_by_addr(hdev, dst, dst_type);
1346 conn = hci_conn_add_unset(hdev, LE_LINK, dst, role);
1359 err = hci_connect_le_sync(hdev, conn);
1368 static bool is_connected(struct hci_dev *hdev, bdaddr_t *addr, u8 type)
1372 conn = hci_conn_hash_lookup_le(hdev, addr, type);
1382 /* This function requires the caller holds hdev->lock */
1383 static int hci_explicit_conn_params_set(struct hci_dev *hdev,
1388 if (is_connected(hdev, addr, addr_type))
1391 params = hci_conn_params_lookup(hdev, addr, addr_type);
1393 params = hci_conn_params_add(hdev, addr, addr_type);
1409 hci_pend_le_list_add(params, &hdev->pend_le_conns);
1420 static int qos_set_big(struct hci_dev *hdev, struct bt_iso_qos *qos)
1429 conn = hci_conn_hash_lookup_big(hdev, big);
1444 static int qos_set_bis(struct hci_dev *hdev, struct bt_iso_qos *qos)
1452 conn = hci_conn_hash_lookup_big(hdev, qos->bcast.big);
1466 for (bis = 0x01; bis < hdev->le_num_of_adv_sets;
1469 conn = hci_conn_hash_lookup_bis(hdev, BDADDR_ANY, bis);
1474 if (bis == hdev->le_num_of_adv_sets)
1484 /* This function requires the caller holds hdev->lock */
1485 static struct hci_conn *hci_add_bis(struct hci_dev *hdev, bdaddr_t *dst,
1493 if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED)) {
1494 if (lmp_le_capable(hdev))
1499 err = qos_set_big(hdev, qos);
1503 err = qos_set_bis(hdev, qos);
1508 conn = hci_conn_hash_lookup_per_adv_bis(hdev, dst, qos->bcast.big,
1516 conn = hci_conn_hash_lookup_big(hdev, qos->bcast.big);
1523 conn = hci_conn_add_unset(hdev, ISO_LINK, dst, HCI_ROLE_MASTER);
1533 /* This function requires the caller holds hdev->lock */
1534 struct hci_conn *hci_connect_le_scan(struct hci_dev *hdev, bdaddr_t *dst,
1542 if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED)) {
1543 if (lmp_le_capable(hdev))
1558 conn = hci_conn_hash_lookup_le(hdev, dst, dst_type);
1567 conn = hci_conn_add_unset(hdev, LE_LINK, dst, HCI_ROLE_MASTER);
1571 if (hci_explicit_conn_params_set(hdev, dst, dst_type) < 0) {
1584 hci_update_passive_scan(hdev);
1591 struct hci_conn *hci_connect_acl(struct hci_dev *hdev, bdaddr_t *dst,
1597 if (!hci_dev_test_flag(hdev, HCI_BREDR_ENABLED)) {
1598 if (lmp_bredr_capable(hdev))
1607 if (!bacmp(&hdev->bdaddr, dst)) {
1608 bt_dev_dbg(hdev, "Reject connection with same BD_ADDR %pMR\n",
1613 acl = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst);
1615 acl = hci_conn_add_unset(hdev, ACL_LINK, dst, HCI_ROLE_MASTER);
1631 err = hci_connect_acl_sync(hdev, acl);
1644 struct hci_dev *hdev = parent->hdev;
1647 bt_dev_dbg(hdev, "parent %p hcon %p", parent, conn);
1669 struct hci_conn *hci_connect_sco(struct hci_dev *hdev, int type, bdaddr_t *dst,
1677 acl = hci_connect_acl(hdev, dst, BT_SECURITY_LOW, HCI_AT_NO_BONDING,
1682 sco = hci_conn_hash_lookup_ba(hdev, type, dst);
1684 sco = hci_conn_add_unset(hdev, type, dst, HCI_ROLE_MASTER);
1720 struct hci_dev *hdev = conn->hdev;
1731 hci_conn_hash_list_state(hdev, bis_list, ISO_LINK,
1747 return hci_send_cmd(hdev, HCI_OP_LE_CREATE_BIG, sizeof(cp), &cp);
1750 static int set_cig_params_sync(struct hci_dev *hdev, void *data)
1759 conn = hci_conn_hash_lookup_cig(hdev, cig_id);
1781 conn = hci_conn_hash_lookup_cis(hdev, NULL, 0, cig_id, cis_id);
1803 return __hci_cmd_sync_status(hdev, HCI_OP_LE_SET_CIG_PARAMS,
1810 struct hci_dev *hdev = conn->hdev;
1820 hci_conn_hash_list_state(hdev, find_cis, ISO_LINK,
1825 hci_conn_hash_list_state(hdev, find_cis, ISO_LINK,
1839 if (hci_conn_hash_lookup_cis(hdev, NULL, 0, qos->ucast.cig,
1848 if (!hci_conn_hash_lookup_cis(hdev, NULL, 0, data.cig,
1860 if (hci_cmd_sync_queue(hdev, set_cig_params_sync,
1867 struct hci_conn *hci_bind_cis(struct hci_dev *hdev, bdaddr_t *dst,
1872 cis = hci_conn_hash_lookup_cis(hdev, dst, dst_type, qos->ucast.cig,
1875 cis = hci_conn_add_unset(hdev, ISO_LINK, dst, HCI_ROLE_MASTER);
1935 struct hci_dev *hdev = conn->hdev;
1946 if (hci_send_cmd(hdev, HCI_OP_LE_SETUP_ISO_PATH, sizeof(cmd),
1957 if (hci_send_cmd(hdev, HCI_OP_LE_SETUP_ISO_PATH, sizeof(cmd),
1977 static int hci_create_cis_sync(struct hci_dev *hdev, void *data)
1979 return hci_le_create_cis_sync(hdev);
1982 int hci_le_create_cis_pending(struct hci_dev *hdev)
1989 list_for_each_entry_rcu(conn, &hdev->conn_hash.list, list) {
2005 return hci_cmd_sync_queue(hdev, hci_create_cis_sync, NULL, NULL);
2008 static void hci_iso_qos_setup(struct hci_dev *hdev, struct hci_conn *conn,
2029 static int create_big_sync(struct hci_dev *hdev, void *data)
2046 err = hci_start_per_adv_sync(hdev, qos->bcast.bis, conn->le_per_adv_data_len,
2055 static void create_pa_complete(struct hci_dev *hdev, void *data, int err)
2059 bt_dev_dbg(hdev, "");
2062 bt_dev_err(hdev, "Unable to create PA: %d", err);
2067 static int create_pa_sync(struct hci_dev *hdev, void *data)
2072 err = __hci_cmd_sync_status(hdev, HCI_OP_LE_PA_CREATE_SYNC,
2075 hci_dev_clear_flag(hdev, HCI_PA_SYNC);
2079 return hci_update_passive_scan_sync(hdev);
2082 struct hci_conn *hci_pa_create_sync(struct hci_dev *hdev, bdaddr_t *dst,
2090 if (hci_dev_test_and_set_flag(hdev, HCI_PA_SYNC))
2093 conn = hci_conn_add_unset(hdev, ISO_LINK, dst, HCI_ROLE_SLAVE);
2104 hci_dev_clear_flag(hdev, HCI_PA_SYNC);
2118 err = hci_cmd_sync_queue(hdev, create_pa_sync, cp, create_pa_complete);
2128 int hci_le_big_create_sync(struct hci_dev *hdev, struct hci_conn *hcon,
2138 err = qos_set_big(hdev, qos);
2154 return hci_send_cmd(hdev, HCI_OP_LE_BIG_CREATE_SYNC,
2158 static void create_big_complete(struct hci_dev *hdev, void *data, int err)
2162 bt_dev_dbg(hdev, "conn %p", conn);
2165 bt_dev_err(hdev, "Unable to create BIG: %d", err);
2171 struct hci_conn *hci_bind_bis(struct hci_dev *hdev, bdaddr_t *dst,
2181 conn = hci_conn_hash_lookup_big_state(hdev, qos->bcast.big, BT_OPEN);
2193 conn = hci_add_bis(hdev, dst, qos, base_len, eir);
2207 hci_iso_qos_setup(hdev, conn, &qos->bcast.out,
2209 hdev->le_tx_def_phys);
2215 parent = hci_conn_hash_lookup_big(hdev,
2247 struct hci_conn *hci_connect_bis(struct hci_dev *hdev, bdaddr_t *dst,
2255 conn = hci_bind_bis(hdev, dst, qos, base_len, base);
2269 hci_conn_hash_list_state(hdev, bis_mark_per_adv, ISO_LINK,
2273 err = hci_cmd_sync_queue(hdev, create_big_sync, conn,
2283 struct hci_conn *hci_connect_cis(struct hci_dev *hdev, bdaddr_t *dst,
2290 if (hci_dev_test_flag(hdev, HCI_ADVERTISING))
2291 le = hci_connect_le(hdev, dst, dst_type, false,
2296 le = hci_connect_le_scan(hdev, dst, dst_type,
2303 hci_iso_qos_setup(hdev, le, &qos->ucast.out,
2304 le->le_tx_phy ? le->le_tx_phy : hdev->le_tx_def_phys);
2305 hci_iso_qos_setup(hdev, le, &qos->ucast.in,
2306 le->le_rx_phy ? le->le_rx_phy : hdev->le_rx_def_phys);
2308 cis = hci_bind_cis(hdev, dst, dst_type, qos);
2326 hci_le_create_cis_pending(hdev);
2340 if (hci_dev_test_flag(conn->hdev, HCI_SC_ONLY)) {
2359 bt_dev_err(conn->hdev,
2393 hci_send_cmd(conn->hdev, HCI_OP_AUTH_REQUESTED,
2415 hci_send_cmd(conn->hdev, HCI_OP_SET_CONN_ENCRYPT, sizeof(cp),
2536 hci_send_cmd(conn->hdev, HCI_OP_SWITCH_ROLE, sizeof(cp), &cp);
2546 struct hci_dev *hdev = conn->hdev;
2559 hci_send_cmd(hdev, HCI_OP_EXIT_SNIFF_MODE, sizeof(cp), &cp);
2563 if (hdev->idle_timeout > 0)
2564 queue_delayed_work(hdev->workqueue, &conn->idle_work,
2565 msecs_to_jiffies(hdev->idle_timeout));
2569 void hci_conn_hash_flush(struct hci_dev *hdev)
2571 struct list_head *head = &hdev->conn_hash.list;
2574 BT_DBG("hdev %s", hdev->name);
2616 struct hci_dev *hdev;
2631 hdev = hci_dev_get(req.dev_id);
2632 if (!hdev) {
2639 hci_dev_lock(hdev);
2640 list_for_each_entry(c, &hdev->conn_hash.list, list) {
2650 hci_dev_unlock(hdev);
2652 cl->dev_id = hdev->id;
2656 hci_dev_put(hdev);
2664 int hci_get_conn_info(struct hci_dev *hdev, void __user *arg)
2674 hci_dev_lock(hdev);
2675 conn = hci_conn_hash_lookup_ba(hdev, req.type, &req.bdaddr);
2684 hci_dev_unlock(hdev);
2692 int hci_get_auth_info(struct hci_dev *hdev, void __user *arg)
2700 hci_dev_lock(hdev);
2701 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &req.bdaddr);
2704 hci_dev_unlock(hdev);
2714 struct hci_dev *hdev = conn->hdev;
2717 BT_DBG("%s hcon %p", hdev->name, conn);
2740 struct hci_dev *hdev = conn->hdev;
2742 BT_DBG("%s hcon %p chan %p", hdev->name, conn, chan);
2780 struct hci_chan *hci_chan_lookup_handle(struct hci_dev *hdev, __u16 handle)
2782 struct hci_conn_hash *h = &hdev->conn_hash;
2902 static int abort_conn_sync(struct hci_dev *hdev, void *data)
2906 if (!hci_conn_valid(hdev, conn))
2909 return hci_abort_conn_sync(hdev, conn, conn->abort_reason);
2914 struct hci_dev *hdev = conn->hdev;
2922 bt_dev_dbg(hdev, "handle 0x%2.2x reason 0x%2.2x", conn->handle, reason);
2933 if (conn->state == BT_CONNECT && hdev->req_status == HCI_REQ_PEND) {
2934 switch (hci_skb_event(hdev->sent_cmd)) {
2939 hci_cmd_sync_cancel(hdev, ECANCELED);
2943 } else if (!hci_cancel_connect_sync(hdev, conn)) {
2947 return hci_cmd_sync_queue_once(hdev, abort_conn_sync, conn, NULL);