^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) BlueZ - Bluetooth protocol stack for Linux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) Copyright (c) 2000-2001, 2010, Code Aurora Forum. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) This program is free software; you can redistribute it and/or modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) it under the terms of the GNU General Public License version 2 as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) published by the Free Software Foundation;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) SOFTWARE IS DISCLAIMED.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) /* Bluetooth HCI event handling. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <asm/unaligned.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include <net/bluetooth/bluetooth.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include <net/bluetooth/hci_core.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include <net/bluetooth/mgmt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #include "hci_request.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #include "hci_debugfs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #include "a2mp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #include "amp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #include "smp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #include "msft.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #define ZERO_KEY "\x00\x00\x00\x00\x00\x00\x00\x00" \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) "\x00\x00\x00\x00\x00\x00\x00\x00"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) /* Handle HCI Event packets */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) u8 *new_status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) __u8 status = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) /* It is possible that we receive Inquiry Complete event right
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * before we receive Inquiry Cancel Command Complete event, in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * which case the latter event should have status of Command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * Disallowed (0x0c). This should not be treated as error, since
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * we actually achieve what Inquiry Cancel wants to achieve,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) * which is to end the last Inquiry session.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) if (status == 0x0c && !test_bit(HCI_INQUIRY, &hdev->flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) bt_dev_warn(hdev, "Ignoring error of Inquiry Cancel command");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) status = 0x00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) *new_status = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) clear_bit(HCI_INQUIRY, &hdev->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) smp_mb__after_atomic(); /* wake_up_bit advises about this barrier */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) wake_up_bit(&hdev->flags, HCI_INQUIRY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) /* Set discovery state to stopped if we're not doing LE active
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * scanning.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) if (!hci_dev_test_flag(hdev, HCI_LE_SCAN) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) hdev->le_scan_type != LE_SCAN_ACTIVE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) hci_discovery_set_state(hdev, DISCOVERY_STOPPED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) hci_conn_check_pending(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) static void hci_cc_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) __u8 status = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) hci_dev_set_flag(hdev, HCI_PERIODIC_INQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) static void hci_cc_exit_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) __u8 status = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) hci_dev_clear_flag(hdev, HCI_PERIODIC_INQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) hci_conn_check_pending(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) static void hci_cc_remote_name_req_cancel(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) BT_DBG("%s", hdev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) static void hci_cc_role_discovery(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) struct hci_rp_role_discovery *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) if (conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) conn->role = rp->role;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) static void hci_cc_read_link_policy(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) struct hci_rp_read_link_policy *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) if (conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) conn->link_policy = __le16_to_cpu(rp->policy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) static void hci_cc_write_link_policy(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) struct hci_rp_write_link_policy *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) void *sent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_LINK_POLICY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) if (!sent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) if (conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) conn->link_policy = get_unaligned_le16(sent + 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) static void hci_cc_read_def_link_policy(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) struct hci_rp_read_def_link_policy *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) hdev->link_policy = __le16_to_cpu(rp->policy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) static void hci_cc_write_def_link_policy(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) __u8 status = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) void *sent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_DEF_LINK_POLICY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) if (!sent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) hdev->link_policy = get_unaligned_le16(sent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) __u8 status = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) clear_bit(HCI_RESET, &hdev->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) /* Reset all non-persistent flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) hci_dev_clear_volatile_flags(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) hci_discovery_set_state(hdev, DISCOVERY_STOPPED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) hdev->inq_tx_power = HCI_TX_POWER_INVALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) hdev->adv_tx_power = HCI_TX_POWER_INVALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) memset(hdev->adv_data, 0, sizeof(hdev->adv_data));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) hdev->adv_data_len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) memset(hdev->scan_rsp_data, 0, sizeof(hdev->scan_rsp_data));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) hdev->scan_rsp_data_len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) hdev->le_scan_type = LE_SCAN_PASSIVE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) hdev->ssp_debug_mode = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) hci_bdaddr_list_clear(&hdev->le_white_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) hci_bdaddr_list_clear(&hdev->le_resolv_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) static void hci_cc_read_stored_link_key(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) struct hci_rp_read_stored_link_key *rp = (void *)skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) struct hci_cp_read_stored_link_key *sent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) sent = hci_sent_cmd_data(hdev, HCI_OP_READ_STORED_LINK_KEY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) if (!sent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) if (!rp->status && sent->read_all == 0x01) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) hdev->stored_max_keys = rp->max_keys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) hdev->stored_num_keys = rp->num_keys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) static void hci_cc_delete_stored_link_key(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) struct hci_rp_delete_stored_link_key *rp = (void *)skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) if (rp->num_keys <= hdev->stored_num_keys)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) hdev->stored_num_keys -= rp->num_keys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) hdev->stored_num_keys = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) __u8 status = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) void *sent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_LOCAL_NAME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) if (!sent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) if (hci_dev_test_flag(hdev, HCI_MGMT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) mgmt_set_local_name_complete(hdev, sent, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) else if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) memcpy(hdev->dev_name, sent, HCI_MAX_NAME_LENGTH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) static void hci_cc_read_local_name(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) struct hci_rp_read_local_name *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) if (hci_dev_test_flag(hdev, HCI_SETUP) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) hci_dev_test_flag(hdev, HCI_CONFIG))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) memcpy(hdev->dev_name, rp->name, HCI_MAX_NAME_LENGTH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) static void hci_cc_write_auth_enable(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) __u8 status = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) void *sent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_AUTH_ENABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) if (!sent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) if (!status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) __u8 param = *((__u8 *) sent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) if (param == AUTH_ENABLED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) set_bit(HCI_AUTH, &hdev->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) clear_bit(HCI_AUTH, &hdev->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) if (hci_dev_test_flag(hdev, HCI_MGMT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) mgmt_auth_enable_complete(hdev, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) static void hci_cc_write_encrypt_mode(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) __u8 status = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) __u8 param;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) void *sent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_ENCRYPT_MODE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) if (!sent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) param = *((__u8 *) sent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) if (param)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) set_bit(HCI_ENCRYPT, &hdev->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) clear_bit(HCI_ENCRYPT, &hdev->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) static void hci_cc_write_scan_enable(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) __u8 status = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) __u8 param;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) void *sent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_SCAN_ENABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) if (!sent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) param = *((__u8 *) sent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) if (status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) hdev->discov_timeout = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) if (param & SCAN_INQUIRY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) set_bit(HCI_ISCAN, &hdev->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) clear_bit(HCI_ISCAN, &hdev->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) if (param & SCAN_PAGE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) set_bit(HCI_PSCAN, &hdev->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) clear_bit(HCI_PSCAN, &hdev->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) static void hci_cc_read_class_of_dev(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) struct hci_rp_read_class_of_dev *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) memcpy(hdev->dev_class, rp->dev_class, 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) BT_DBG("%s class 0x%.2x%.2x%.2x", hdev->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) hdev->dev_class[2], hdev->dev_class[1], hdev->dev_class[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) static void hci_cc_write_class_of_dev(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) __u8 status = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) void *sent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_CLASS_OF_DEV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) if (!sent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) if (status == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) memcpy(hdev->dev_class, sent, 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) if (hci_dev_test_flag(hdev, HCI_MGMT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) mgmt_set_class_of_dev_complete(hdev, sent, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) static void hci_cc_read_voice_setting(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) struct hci_rp_read_voice_setting *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) __u16 setting;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) setting = __le16_to_cpu(rp->voice_setting);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) if (hdev->voice_setting == setting)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) hdev->voice_setting = setting;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) BT_DBG("%s voice setting 0x%4.4x", hdev->name, setting);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) if (hdev->notify)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) static void hci_cc_write_voice_setting(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) __u8 status = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) __u16 setting;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) void *sent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_VOICE_SETTING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) if (!sent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) setting = get_unaligned_le16(sent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) if (hdev->voice_setting == setting)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) hdev->voice_setting = setting;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) BT_DBG("%s voice setting 0x%4.4x", hdev->name, setting);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) if (hdev->notify)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) static void hci_cc_read_num_supported_iac(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) struct hci_rp_read_num_supported_iac *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) hdev->num_iac = rp->num_iac;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) BT_DBG("%s num iac %d", hdev->name, hdev->num_iac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) __u8 status = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) struct hci_cp_write_ssp_mode *sent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_SSP_MODE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) if (!sent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) if (!status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) if (sent->mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) hdev->features[1][0] |= LMP_HOST_SSP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) hdev->features[1][0] &= ~LMP_HOST_SSP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) if (hci_dev_test_flag(hdev, HCI_MGMT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) mgmt_ssp_enable_complete(hdev, sent->mode, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) else if (!status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) if (sent->mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) hci_dev_set_flag(hdev, HCI_SSP_ENABLED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) hci_dev_clear_flag(hdev, HCI_SSP_ENABLED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) static void hci_cc_write_sc_support(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) u8 status = *((u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) struct hci_cp_write_sc_support *sent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_SC_SUPPORT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) if (!sent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) if (!status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) if (sent->support)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) hdev->features[1][0] |= LMP_HOST_SC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) hdev->features[1][0] &= ~LMP_HOST_SC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) if (!hci_dev_test_flag(hdev, HCI_MGMT) && !status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) if (sent->support)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) hci_dev_set_flag(hdev, HCI_SC_ENABLED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) hci_dev_clear_flag(hdev, HCI_SC_ENABLED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) static void hci_cc_read_local_version(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) struct hci_rp_read_local_version *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) if (hci_dev_test_flag(hdev, HCI_SETUP) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) hci_dev_test_flag(hdev, HCI_CONFIG)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) hdev->hci_ver = rp->hci_ver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) hdev->hci_rev = __le16_to_cpu(rp->hci_rev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) hdev->lmp_ver = rp->lmp_ver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) hdev->manufacturer = __le16_to_cpu(rp->manufacturer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) hdev->lmp_subver = __le16_to_cpu(rp->lmp_subver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) static void hci_cc_read_local_commands(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) struct hci_rp_read_local_commands *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) if (hci_dev_test_flag(hdev, HCI_SETUP) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) hci_dev_test_flag(hdev, HCI_CONFIG))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) memcpy(hdev->commands, rp->commands, sizeof(hdev->commands));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) static void hci_cc_read_auth_payload_timeout(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) struct hci_rp_read_auth_payload_to *rp = (void *)skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) if (conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) conn->auth_payload_timeout = __le16_to_cpu(rp->timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) static void hci_cc_write_auth_payload_timeout(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) struct hci_rp_write_auth_payload_to *rp = (void *)skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) void *sent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_AUTH_PAYLOAD_TO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) if (!sent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) if (conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) conn->auth_payload_timeout = get_unaligned_le16(sent + 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) static void hci_cc_read_local_features(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) struct hci_rp_read_local_features *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) memcpy(hdev->features, rp->features, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) /* Adjust default settings according to features
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) * supported by device. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) if (hdev->features[0][0] & LMP_3SLOT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) hdev->pkt_type |= (HCI_DM3 | HCI_DH3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) if (hdev->features[0][0] & LMP_5SLOT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) hdev->pkt_type |= (HCI_DM5 | HCI_DH5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) if (hdev->features[0][1] & LMP_HV2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) hdev->pkt_type |= (HCI_HV2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) hdev->esco_type |= (ESCO_HV2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) if (hdev->features[0][1] & LMP_HV3) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) hdev->pkt_type |= (HCI_HV3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) hdev->esco_type |= (ESCO_HV3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) if (lmp_esco_capable(hdev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) hdev->esco_type |= (ESCO_EV3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) if (hdev->features[0][4] & LMP_EV4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) hdev->esco_type |= (ESCO_EV4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) if (hdev->features[0][4] & LMP_EV5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) hdev->esco_type |= (ESCO_EV5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) if (hdev->features[0][5] & LMP_EDR_ESCO_2M)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) hdev->esco_type |= (ESCO_2EV3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) if (hdev->features[0][5] & LMP_EDR_ESCO_3M)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) hdev->esco_type |= (ESCO_3EV3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) if (hdev->features[0][5] & LMP_EDR_3S_ESCO)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) hdev->esco_type |= (ESCO_2EV5 | ESCO_3EV5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) static void hci_cc_read_local_ext_features(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) struct hci_rp_read_local_ext_features *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) if (hdev->max_page < rp->max_page)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) hdev->max_page = rp->max_page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) if (rp->page < HCI_MAX_PAGES)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) memcpy(hdev->features[rp->page], rp->features, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) static void hci_cc_read_flow_control_mode(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) struct hci_rp_read_flow_control_mode *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) hdev->flow_ctl_mode = rp->mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) static void hci_cc_read_buffer_size(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) struct hci_rp_read_buffer_size *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) hdev->acl_mtu = __le16_to_cpu(rp->acl_mtu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) hdev->sco_mtu = rp->sco_mtu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) hdev->acl_pkts = __le16_to_cpu(rp->acl_max_pkt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) hdev->sco_pkts = __le16_to_cpu(rp->sco_max_pkt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) if (test_bit(HCI_QUIRK_FIXUP_BUFFER_SIZE, &hdev->quirks)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) hdev->sco_mtu = 64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) hdev->sco_pkts = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) hdev->acl_cnt = hdev->acl_pkts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) hdev->sco_cnt = hdev->sco_pkts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) BT_DBG("%s acl mtu %d:%d sco mtu %d:%d", hdev->name, hdev->acl_mtu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) hdev->acl_pkts, hdev->sco_mtu, hdev->sco_pkts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) static void hci_cc_read_bd_addr(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) struct hci_rp_read_bd_addr *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) if (test_bit(HCI_INIT, &hdev->flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) bacpy(&hdev->bdaddr, &rp->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) if (hci_dev_test_flag(hdev, HCI_SETUP))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) bacpy(&hdev->setup_addr, &rp->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) static void hci_cc_read_local_pairing_opts(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) struct hci_rp_read_local_pairing_opts *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) if (hci_dev_test_flag(hdev, HCI_SETUP) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) hci_dev_test_flag(hdev, HCI_CONFIG)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) hdev->pairing_opts = rp->pairing_opts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) hdev->max_enc_key_size = rp->max_key_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) static void hci_cc_read_page_scan_activity(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) struct hci_rp_read_page_scan_activity *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) if (test_bit(HCI_INIT, &hdev->flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) hdev->page_scan_interval = __le16_to_cpu(rp->interval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) hdev->page_scan_window = __le16_to_cpu(rp->window);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) static void hci_cc_write_page_scan_activity(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) u8 status = *((u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) struct hci_cp_write_page_scan_activity *sent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_PAGE_SCAN_ACTIVITY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) if (!sent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) hdev->page_scan_interval = __le16_to_cpu(sent->interval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) hdev->page_scan_window = __le16_to_cpu(sent->window);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) static void hci_cc_read_page_scan_type(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) struct hci_rp_read_page_scan_type *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) if (test_bit(HCI_INIT, &hdev->flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) hdev->page_scan_type = rp->type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) static void hci_cc_write_page_scan_type(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) u8 status = *((u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) u8 *type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) type = hci_sent_cmd_data(hdev, HCI_OP_WRITE_PAGE_SCAN_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) if (type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) hdev->page_scan_type = *type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) static void hci_cc_read_data_block_size(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) struct hci_rp_read_data_block_size *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) hdev->block_mtu = __le16_to_cpu(rp->max_acl_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) hdev->block_len = __le16_to_cpu(rp->block_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) hdev->num_blocks = __le16_to_cpu(rp->num_blocks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) hdev->block_cnt = hdev->num_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) BT_DBG("%s blk mtu %d cnt %d len %d", hdev->name, hdev->block_mtu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) hdev->block_cnt, hdev->block_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) static void hci_cc_read_clock(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) struct hci_rp_read_clock *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) struct hci_cp_read_clock *cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) BT_DBG("%s", hdev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) if (skb->len < sizeof(*rp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) cp = hci_sent_cmd_data(hdev, HCI_OP_READ_CLOCK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) if (!cp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) if (cp->which == 0x00) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) hdev->clock = le32_to_cpu(rp->clock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) if (conn) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) conn->clock = le32_to_cpu(rp->clock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) conn->clock_accuracy = le16_to_cpu(rp->accuracy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) static void hci_cc_read_local_amp_info(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) struct hci_rp_read_local_amp_info *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) hdev->amp_status = rp->amp_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) hdev->amp_total_bw = __le32_to_cpu(rp->total_bw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) hdev->amp_max_bw = __le32_to_cpu(rp->max_bw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) hdev->amp_min_latency = __le32_to_cpu(rp->min_latency);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) hdev->amp_max_pdu = __le32_to_cpu(rp->max_pdu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) hdev->amp_type = rp->amp_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) hdev->amp_pal_cap = __le16_to_cpu(rp->pal_cap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) hdev->amp_assoc_size = __le16_to_cpu(rp->max_assoc_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) hdev->amp_be_flush_to = __le32_to_cpu(rp->be_flush_to);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) hdev->amp_max_flush_to = __le32_to_cpu(rp->max_flush_to);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) static void hci_cc_read_inq_rsp_tx_power(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) struct hci_rp_read_inq_rsp_tx_power *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) hdev->inq_tx_power = rp->tx_power;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) static void hci_cc_read_def_err_data_reporting(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) struct hci_rp_read_def_err_data_reporting *rp = (void *)skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) hdev->err_data_reporting = rp->err_data_reporting;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950) static void hci_cc_write_def_err_data_reporting(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) __u8 status = *((__u8 *)skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) struct hci_cp_write_def_err_data_reporting *cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) cp = hci_sent_cmd_data(hdev, HCI_OP_WRITE_DEF_ERR_DATA_REPORTING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) if (!cp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) hdev->err_data_reporting = cp->err_data_reporting;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) static void hci_cc_pin_code_reply(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) struct hci_rp_pin_code_reply *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) struct hci_cp_pin_code_reply *cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) if (hci_dev_test_flag(hdev, HCI_MGMT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) mgmt_pin_code_reply_complete(hdev, &rp->bdaddr, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) cp = hci_sent_cmd_data(hdev, HCI_OP_PIN_CODE_REPLY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) if (!cp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988) conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) if (conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) conn->pin_length = cp->pin_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) static void hci_cc_pin_code_neg_reply(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) struct hci_rp_pin_code_neg_reply *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) if (hci_dev_test_flag(hdev, HCI_MGMT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) mgmt_pin_code_neg_reply_complete(hdev, &rp->bdaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) static void hci_cc_le_read_buffer_size(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) struct hci_rp_le_read_buffer_size *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) hdev->le_mtu = __le16_to_cpu(rp->le_mtu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) hdev->le_pkts = rp->le_max_pkt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) hdev->le_cnt = hdev->le_pkts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) BT_DBG("%s le mtu %d:%d", hdev->name, hdev->le_mtu, hdev->le_pkts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) static void hci_cc_le_read_local_features(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) struct hci_rp_le_read_local_features *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) memcpy(hdev->le_features, rp->features, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) static void hci_cc_le_read_adv_tx_power(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) struct hci_rp_le_read_adv_tx_power *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) hdev->adv_tx_power = rp->tx_power;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) static void hci_cc_user_confirm_reply(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) struct hci_rp_user_confirm_reply *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) if (hci_dev_test_flag(hdev, HCI_MGMT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) mgmt_user_confirm_reply_complete(hdev, &rp->bdaddr, ACL_LINK, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) static void hci_cc_user_confirm_neg_reply(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) struct hci_rp_user_confirm_reply *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) if (hci_dev_test_flag(hdev, HCI_MGMT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) mgmt_user_confirm_neg_reply_complete(hdev, &rp->bdaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) ACL_LINK, 0, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) static void hci_cc_user_passkey_reply(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) struct hci_rp_user_confirm_reply *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) if (hci_dev_test_flag(hdev, HCI_MGMT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) mgmt_user_passkey_reply_complete(hdev, &rp->bdaddr, ACL_LINK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) 0, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) static void hci_cc_user_passkey_neg_reply(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) struct hci_rp_user_confirm_reply *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) if (hci_dev_test_flag(hdev, HCI_MGMT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) mgmt_user_passkey_neg_reply_complete(hdev, &rp->bdaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) ACL_LINK, 0, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) static void hci_cc_read_local_oob_data(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) struct hci_rp_read_local_oob_data *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) static void hci_cc_read_local_oob_ext_data(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) struct hci_rp_read_local_oob_ext_data *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) static void hci_cc_le_set_random_addr(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) __u8 status = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) bdaddr_t *sent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) sent = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_RANDOM_ADDR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) if (!sent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) bacpy(&hdev->random_addr, sent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) static void hci_cc_le_set_default_phy(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) __u8 status = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) struct hci_cp_le_set_default_phy *cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_DEFAULT_PHY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) if (!cp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) hdev->le_tx_def_phys = cp->tx_phys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) hdev->le_rx_def_phys = cp->rx_phys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) static void hci_cc_le_set_adv_set_random_addr(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) __u8 status = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) struct hci_cp_le_set_adv_set_rand_addr *cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) struct adv_info *adv_instance;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_ADV_SET_RAND_ADDR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) if (!cp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) if (!hdev->cur_adv_instance) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) /* Store in hdev for instance 0 (Set adv and Directed advs) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) bacpy(&hdev->random_addr, &cp->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) adv_instance = hci_find_adv_instance(hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) hdev->cur_adv_instance);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) if (adv_instance)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) bacpy(&adv_instance->random_addr, &cp->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) static void hci_cc_le_set_adv_enable(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) __u8 *sent, status = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) sent = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_ADV_ENABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) if (!sent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) /* If we're doing connection initiation as peripheral. Set a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) * timeout in case something goes wrong.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) if (*sent) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) hci_dev_set_flag(hdev, HCI_LE_ADV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) conn = hci_lookup_le_connect(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) if (conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) queue_delayed_work(hdev->workqueue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) &conn->le_conn_timeout,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) conn->conn_timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) hci_dev_clear_flag(hdev, HCI_LE_ADV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) static void hci_cc_le_set_ext_adv_enable(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) struct hci_cp_le_set_ext_adv_enable *cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) __u8 status = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_EXT_ADV_ENABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) if (!cp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) if (cp->enable) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) hci_dev_set_flag(hdev, HCI_LE_ADV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) conn = hci_lookup_le_connect(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) if (conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) queue_delayed_work(hdev->workqueue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) &conn->le_conn_timeout,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) conn->conn_timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) hci_dev_clear_flag(hdev, HCI_LE_ADV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) static void hci_cc_le_set_scan_param(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) struct hci_cp_le_set_scan_param *cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) __u8 status = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_SCAN_PARAM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) if (!cp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) hdev->le_scan_type = cp->type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) static void hci_cc_le_set_ext_scan_param(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) struct hci_cp_le_set_ext_scan_params *cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) __u8 status = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) struct hci_cp_le_scan_phy_params *phy_param;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_EXT_SCAN_PARAMS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) if (!cp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) phy_param = (void *)cp->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) hdev->le_scan_type = phy_param->type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) static bool has_pending_adv_report(struct hci_dev *hdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) struct discovery_state *d = &hdev->discovery;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) return bacmp(&d->last_adv_addr, BDADDR_ANY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) static void clear_pending_adv_report(struct hci_dev *hdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) struct discovery_state *d = &hdev->discovery;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) bacpy(&d->last_adv_addr, BDADDR_ANY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) d->last_adv_data_len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) static void store_pending_adv_report(struct hci_dev *hdev, bdaddr_t *bdaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) u8 bdaddr_type, s8 rssi, u32 flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) u8 *data, u8 len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) struct discovery_state *d = &hdev->discovery;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) if (len > HCI_MAX_AD_LENGTH)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) bacpy(&d->last_adv_addr, bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) d->last_adv_addr_type = bdaddr_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) d->last_adv_rssi = rssi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) d->last_adv_flags = flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) memcpy(d->last_adv_data, data, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) d->last_adv_data_len = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) static void le_set_scan_enable_complete(struct hci_dev *hdev, u8 enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) switch (enable) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) case LE_SCAN_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) hci_dev_set_flag(hdev, HCI_LE_SCAN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) if (hdev->le_scan_type == LE_SCAN_ACTIVE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) clear_pending_adv_report(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) case LE_SCAN_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) /* We do this here instead of when setting DISCOVERY_STOPPED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) * since the latter would potentially require waiting for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) * inquiry to stop too.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) if (has_pending_adv_report(hdev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) struct discovery_state *d = &hdev->discovery;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) d->last_adv_addr_type, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) d->last_adv_rssi, d->last_adv_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) d->last_adv_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) d->last_adv_data_len, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) /* Cancel this timer so that we don't try to disable scanning
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) * when it's already disabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) cancel_delayed_work(&hdev->le_scan_disable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) hci_dev_clear_flag(hdev, HCI_LE_SCAN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) /* The HCI_LE_SCAN_INTERRUPTED flag indicates that we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) * interrupted scanning due to a connect request. Mark
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) * therefore discovery as stopped. If this was not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) * because of a connect request advertising might have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) * been disabled because of active scanning, so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) * re-enable it again if necessary.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) if (hci_dev_test_and_clear_flag(hdev, HCI_LE_SCAN_INTERRUPTED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) hci_discovery_set_state(hdev, DISCOVERY_STOPPED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) else if (!hci_dev_test_flag(hdev, HCI_LE_ADV) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) hdev->discovery.state == DISCOVERY_FINDING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) hci_req_reenable_advertising(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) bt_dev_err(hdev, "use of reserved LE_Scan_Enable param %d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) static void hci_cc_le_set_scan_enable(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) struct hci_cp_le_set_scan_enable *cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) __u8 status = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_SCAN_ENABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) if (!cp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) le_set_scan_enable_complete(hdev, cp->enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) static void hci_cc_le_set_ext_scan_enable(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) struct hci_cp_le_set_ext_scan_enable *cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) __u8 status = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_EXT_SCAN_ENABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) if (!cp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) le_set_scan_enable_complete(hdev, cp->enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) static void hci_cc_le_read_num_adv_sets(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) struct hci_rp_le_read_num_supported_adv_sets *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) BT_DBG("%s status 0x%2.2x No of Adv sets %u", hdev->name, rp->status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) rp->num_of_sets);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) hdev->le_num_of_adv_sets = rp->num_of_sets;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) static void hci_cc_le_read_white_list_size(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) struct hci_rp_le_read_white_list_size *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) BT_DBG("%s status 0x%2.2x size %u", hdev->name, rp->status, rp->size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) hdev->le_white_list_size = rp->size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) static void hci_cc_le_clear_white_list(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) __u8 status = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) hci_bdaddr_list_clear(&hdev->le_white_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) static void hci_cc_le_add_to_white_list(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) struct hci_cp_le_add_to_white_list *sent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) __u8 status = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) sent = hci_sent_cmd_data(hdev, HCI_OP_LE_ADD_TO_WHITE_LIST);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) if (!sent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) hci_bdaddr_list_add(&hdev->le_white_list, &sent->bdaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) sent->bdaddr_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) static void hci_cc_le_del_from_white_list(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) struct hci_cp_le_del_from_white_list *sent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) __u8 status = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) sent = hci_sent_cmd_data(hdev, HCI_OP_LE_DEL_FROM_WHITE_LIST);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) if (!sent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) hci_bdaddr_list_del(&hdev->le_white_list, &sent->bdaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) sent->bdaddr_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) static void hci_cc_le_read_supported_states(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) struct hci_rp_le_read_supported_states *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) memcpy(hdev->le_states, rp->le_states, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) static void hci_cc_le_read_def_data_len(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) struct hci_rp_le_read_def_data_len *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) hdev->le_def_tx_len = le16_to_cpu(rp->tx_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) hdev->le_def_tx_time = le16_to_cpu(rp->tx_time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) static void hci_cc_le_write_def_data_len(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) struct hci_cp_le_write_def_data_len *sent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) __u8 status = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) sent = hci_sent_cmd_data(hdev, HCI_OP_LE_WRITE_DEF_DATA_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) if (!sent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) hdev->le_def_tx_len = le16_to_cpu(sent->tx_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) hdev->le_def_tx_time = le16_to_cpu(sent->tx_time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) static void hci_cc_le_add_to_resolv_list(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) struct hci_cp_le_add_to_resolv_list *sent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573) __u8 status = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) sent = hci_sent_cmd_data(hdev, HCI_OP_LE_ADD_TO_RESOLV_LIST);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581) if (!sent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584) hci_bdaddr_list_add_with_irk(&hdev->le_resolv_list, &sent->bdaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585) sent->bdaddr_type, sent->peer_irk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586) sent->local_irk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589) static void hci_cc_le_del_from_resolv_list(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592) struct hci_cp_le_del_from_resolv_list *sent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593) __u8 status = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600) sent = hci_sent_cmd_data(hdev, HCI_OP_LE_DEL_FROM_RESOLV_LIST);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) if (!sent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604) hci_bdaddr_list_del_with_irk(&hdev->le_resolv_list, &sent->bdaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605) sent->bdaddr_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608) static void hci_cc_le_clear_resolv_list(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611) __u8 status = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1616) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618) hci_bdaddr_list_clear(&hdev->le_resolv_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621) static void hci_cc_le_read_resolv_list_size(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1622) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1623) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1624) struct hci_rp_le_read_resolv_list_size *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1625)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1626) BT_DBG("%s status 0x%2.2x size %u", hdev->name, rp->status, rp->size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1627)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1628) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1629) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1630)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1631) hdev->le_resolv_list_size = rp->size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1632) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1633)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1634) static void hci_cc_le_set_addr_resolution_enable(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1635) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1636) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1637) __u8 *sent, status = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1638)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1639) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1640)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1641) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1642) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1643)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1644) sent = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1645) if (!sent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1646) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1647)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1648) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1649)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1650) if (*sent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1651) hci_dev_set_flag(hdev, HCI_LL_RPA_RESOLUTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1652) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1653) hci_dev_clear_flag(hdev, HCI_LL_RPA_RESOLUTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1654)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1655) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1656) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1657)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1658) static void hci_cc_le_read_max_data_len(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1659) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1660) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1661) struct hci_rp_le_read_max_data_len *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1662)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1663) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1664)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1665) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1666) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1667)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1668) hdev->le_max_tx_len = le16_to_cpu(rp->tx_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1669) hdev->le_max_tx_time = le16_to_cpu(rp->tx_time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1670) hdev->le_max_rx_len = le16_to_cpu(rp->rx_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1671) hdev->le_max_rx_time = le16_to_cpu(rp->rx_time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1672) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1673)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1674) static void hci_cc_write_le_host_supported(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1675) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1676) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1677) struct hci_cp_write_le_host_supported *sent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1678) __u8 status = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1679)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1680) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1681)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1682) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1683) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1684)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1685) sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1686) if (!sent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1687) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1688)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1689) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1690)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1691) if (sent->le) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1692) hdev->features[1][0] |= LMP_HOST_LE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1693) hci_dev_set_flag(hdev, HCI_LE_ENABLED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1694) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1695) hdev->features[1][0] &= ~LMP_HOST_LE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1696) hci_dev_clear_flag(hdev, HCI_LE_ENABLED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1697) hci_dev_clear_flag(hdev, HCI_ADVERTISING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1698) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1699)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1700) if (sent->simul)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1701) hdev->features[1][0] |= LMP_HOST_LE_BREDR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1702) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1703) hdev->features[1][0] &= ~LMP_HOST_LE_BREDR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1704)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1705) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1706) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1707)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1708) static void hci_cc_set_adv_param(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1709) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1710) struct hci_cp_le_set_adv_param *cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1711) u8 status = *((u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1712)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1713) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1714)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1715) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1716) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1717)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1718) cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_ADV_PARAM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1719) if (!cp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1720) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1721)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1722) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1723) hdev->adv_addr_type = cp->own_address_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1724) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1725) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1726)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1727) static void hci_cc_set_ext_adv_param(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1728) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1729) struct hci_rp_le_set_ext_adv_params *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1730) struct hci_cp_le_set_ext_adv_params *cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1731) struct adv_info *adv_instance;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1732)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1733) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1734)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1735) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1736) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1737)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1738) cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_EXT_ADV_PARAMS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1739) if (!cp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1740) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1741)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1742) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1743) hdev->adv_addr_type = cp->own_addr_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1744) if (!hdev->cur_adv_instance) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1745) /* Store in hdev for instance 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1746) hdev->adv_tx_power = rp->tx_power;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1747) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1748) adv_instance = hci_find_adv_instance(hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1749) hdev->cur_adv_instance);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1750) if (adv_instance)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1751) adv_instance->tx_power = rp->tx_power;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1752) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1753) /* Update adv data as tx power is known now */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1754) hci_req_update_adv_data(hdev, hdev->cur_adv_instance);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1755) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1756) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1757)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1758) static void hci_cc_read_rssi(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1759) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1760) struct hci_rp_read_rssi *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1761) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1762)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1763) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1764)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1765) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1766) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1767)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1768) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1769)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1770) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1771) if (conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1772) conn->rssi = rp->rssi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1773)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1774) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1775) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1776)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1777) static void hci_cc_read_tx_power(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1778) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1779) struct hci_cp_read_tx_power *sent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1780) struct hci_rp_read_tx_power *rp = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1781) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1782)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1783) BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1784)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1785) if (rp->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1786) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1787)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1788) sent = hci_sent_cmd_data(hdev, HCI_OP_READ_TX_POWER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1789) if (!sent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1790) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1791)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1792) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1793)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1794) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1795) if (!conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1796) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1797)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1798) switch (sent->type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1799) case 0x00:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1800) conn->tx_power = rp->tx_power;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1801) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1802) case 0x01:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1803) conn->max_tx_power = rp->tx_power;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1804) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1805) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1806)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1807) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1808) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1809) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1810)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1811) static void hci_cc_write_ssp_debug_mode(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1812) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1813) u8 status = *((u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1814) u8 *mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1815)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1816) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1817)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1818) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1819) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1820)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1821) mode = hci_sent_cmd_data(hdev, HCI_OP_WRITE_SSP_DEBUG_MODE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1822) if (mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1823) hdev->ssp_debug_mode = *mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1824) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1825)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1826) static void hci_cs_inquiry(struct hci_dev *hdev, __u8 status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1827) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1828) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1829)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1830) if (status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1831) hci_conn_check_pending(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1832) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1833) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1834)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1835) set_bit(HCI_INQUIRY, &hdev->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1836) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1837)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1838) static void hci_cs_create_conn(struct hci_dev *hdev, __u8 status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1839) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1840) struct hci_cp_create_conn *cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1841) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1842)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1843) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1844)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1845) cp = hci_sent_cmd_data(hdev, HCI_OP_CREATE_CONN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1846) if (!cp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1847) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1848)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1849) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1850)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1851) conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1852)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1853) BT_DBG("%s bdaddr %pMR hcon %p", hdev->name, &cp->bdaddr, conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1854)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1855) if (status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1856) if (conn && conn->state == BT_CONNECT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1857) if (status != 0x0c || conn->attempt > 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1858) conn->state = BT_CLOSED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1859) hci_connect_cfm(conn, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1860) hci_conn_del(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1861) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1862) conn->state = BT_CONNECT2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1863) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1864) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1865) if (!conn) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1866) conn = hci_conn_add(hdev, ACL_LINK, &cp->bdaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1867) HCI_ROLE_MASTER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1868) if (!conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1869) bt_dev_err(hdev, "no memory for new connection");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1870) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1871) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1872)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1873) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1874) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1875)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1876) static void hci_cs_add_sco(struct hci_dev *hdev, __u8 status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1877) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1878) struct hci_cp_add_sco *cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1879) struct hci_conn *acl, *sco;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1880) __u16 handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1881)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1882) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1883)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1884) if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1885) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1886)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1887) cp = hci_sent_cmd_data(hdev, HCI_OP_ADD_SCO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1888) if (!cp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1889) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1890)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1891) handle = __le16_to_cpu(cp->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1892)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1893) BT_DBG("%s handle 0x%4.4x", hdev->name, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1894)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1895) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1896)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1897) acl = hci_conn_hash_lookup_handle(hdev, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1898) if (acl) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1899) sco = acl->link;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1900) if (sco) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1901) sco->state = BT_CLOSED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1902)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1903) hci_connect_cfm(sco, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1904) hci_conn_del(sco);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1905) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1906) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1907)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1908) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1909) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1910)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1911) static void hci_cs_auth_requested(struct hci_dev *hdev, __u8 status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1912) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1913) struct hci_cp_auth_requested *cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1914) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1915)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1916) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1917)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1918) if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1919) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1920)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1921) cp = hci_sent_cmd_data(hdev, HCI_OP_AUTH_REQUESTED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1922) if (!cp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1923) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1924)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1925) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1926)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1927) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1928) if (conn) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1929) if (conn->state == BT_CONFIG) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1930) hci_connect_cfm(conn, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1931) hci_conn_drop(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1932) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1933) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1934)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1935) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1936) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1937)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1938) static void hci_cs_set_conn_encrypt(struct hci_dev *hdev, __u8 status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1939) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1940) struct hci_cp_set_conn_encrypt *cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1941) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1942)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1943) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1944)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1945) if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1946) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1947)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1948) cp = hci_sent_cmd_data(hdev, HCI_OP_SET_CONN_ENCRYPT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1949) if (!cp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1950) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1951)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1952) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1953)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1954) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1955) if (conn) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1956) if (conn->state == BT_CONFIG) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1957) hci_connect_cfm(conn, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1958) hci_conn_drop(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1959) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1960) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1961)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1962) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1963) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1964)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1965) static int hci_outgoing_auth_needed(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1966) struct hci_conn *conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1967) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1968) if (conn->state != BT_CONFIG || !conn->out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1969) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1970)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1971) if (conn->pending_sec_level == BT_SECURITY_SDP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1972) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1973)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1974) /* Only request authentication for SSP connections or non-SSP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1975) * devices with sec_level MEDIUM or HIGH or if MITM protection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1976) * is requested.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1977) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1978) if (!hci_conn_ssp_enabled(conn) && !(conn->auth_type & 0x01) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1979) conn->pending_sec_level != BT_SECURITY_FIPS &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1980) conn->pending_sec_level != BT_SECURITY_HIGH &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1981) conn->pending_sec_level != BT_SECURITY_MEDIUM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1982) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1983)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1984) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1985) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1986)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1987) static int hci_resolve_name(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1988) struct inquiry_entry *e)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1989) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1990) struct hci_cp_remote_name_req cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1991)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1992) memset(&cp, 0, sizeof(cp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1993)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1994) bacpy(&cp.bdaddr, &e->data.bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1995) cp.pscan_rep_mode = e->data.pscan_rep_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1996) cp.pscan_mode = e->data.pscan_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1997) cp.clock_offset = e->data.clock_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1998)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1999) return hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ, sizeof(cp), &cp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2000) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2001)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2002) static bool hci_resolve_next_name(struct hci_dev *hdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2003) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2004) struct discovery_state *discov = &hdev->discovery;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2005) struct inquiry_entry *e;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2006)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2007) if (list_empty(&discov->resolve))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2008) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2009)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2010) e = hci_inquiry_cache_lookup_resolve(hdev, BDADDR_ANY, NAME_NEEDED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2011) if (!e)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2012) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2013)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2014) if (hci_resolve_name(hdev, e) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2015) e->name_state = NAME_PENDING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2016) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2017) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2018)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2019) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2020) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2021)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2022) static void hci_check_pending_name(struct hci_dev *hdev, struct hci_conn *conn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2023) bdaddr_t *bdaddr, u8 *name, u8 name_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2024) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2025) struct discovery_state *discov = &hdev->discovery;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2026) struct inquiry_entry *e;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2027)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2028) /* Update the mgmt connected state if necessary. Be careful with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2029) * conn objects that exist but are not (yet) connected however.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2030) * Only those in BT_CONFIG or BT_CONNECTED states can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2031) * considered connected.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2032) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2033) if (conn &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2034) (conn->state == BT_CONFIG || conn->state == BT_CONNECTED) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2035) !test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2036) mgmt_device_connected(hdev, conn, 0, name, name_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2037)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2038) if (discov->state == DISCOVERY_STOPPED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2039) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2040)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2041) if (discov->state == DISCOVERY_STOPPING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2042) goto discov_complete;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2043)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2044) if (discov->state != DISCOVERY_RESOLVING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2045) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2046)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2047) e = hci_inquiry_cache_lookup_resolve(hdev, bdaddr, NAME_PENDING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2048) /* If the device was not found in a list of found devices names of which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2049) * are pending. there is no need to continue resolving a next name as it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2050) * will be done upon receiving another Remote Name Request Complete
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2051) * Event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2052) if (!e)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2053) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2054)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2055) list_del(&e->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2056) if (name) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2057) e->name_state = NAME_KNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2058) mgmt_remote_name(hdev, bdaddr, ACL_LINK, 0x00,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2059) e->data.rssi, name, name_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2060) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2061) e->name_state = NAME_NOT_KNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2062) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2063)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2064) if (hci_resolve_next_name(hdev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2065) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2066)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2067) discov_complete:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2068) hci_discovery_set_state(hdev, DISCOVERY_STOPPED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2069) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2070)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2071) static void hci_cs_remote_name_req(struct hci_dev *hdev, __u8 status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2072) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2073) struct hci_cp_remote_name_req *cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2074) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2075)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2076) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2077)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2078) /* If successful wait for the name req complete event before
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2079) * checking for the need to do authentication */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2080) if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2081) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2082)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2083) cp = hci_sent_cmd_data(hdev, HCI_OP_REMOTE_NAME_REQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2084) if (!cp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2085) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2086)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2087) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2088)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2089) conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2090)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2091) if (hci_dev_test_flag(hdev, HCI_MGMT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2092) hci_check_pending_name(hdev, conn, &cp->bdaddr, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2093)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2094) if (!conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2095) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2096)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2097) if (!hci_outgoing_auth_needed(hdev, conn))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2098) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2099)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2100) if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2101) struct hci_cp_auth_requested auth_cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2103) set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2105) auth_cp.handle = __cpu_to_le16(conn->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2106) hci_send_cmd(hdev, HCI_OP_AUTH_REQUESTED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2107) sizeof(auth_cp), &auth_cp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2108) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2110) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2111) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2112) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2114) static void hci_cs_read_remote_features(struct hci_dev *hdev, __u8 status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2115) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2116) struct hci_cp_read_remote_features *cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2117) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2119) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2121) if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2122) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2124) cp = hci_sent_cmd_data(hdev, HCI_OP_READ_REMOTE_FEATURES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2125) if (!cp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2126) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2128) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2130) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2131) if (conn) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2132) if (conn->state == BT_CONFIG) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2133) hci_connect_cfm(conn, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2134) hci_conn_drop(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2135) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2136) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2138) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2139) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2141) static void hci_cs_read_remote_ext_features(struct hci_dev *hdev, __u8 status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2142) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2143) struct hci_cp_read_remote_ext_features *cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2144) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2146) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2148) if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2149) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2151) cp = hci_sent_cmd_data(hdev, HCI_OP_READ_REMOTE_EXT_FEATURES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2152) if (!cp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2153) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2155) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2157) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2158) if (conn) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2159) if (conn->state == BT_CONFIG) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2160) hci_connect_cfm(conn, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2161) hci_conn_drop(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2162) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2163) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2165) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2166) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2168) static void hci_cs_setup_sync_conn(struct hci_dev *hdev, __u8 status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2169) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2170) struct hci_cp_setup_sync_conn *cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2171) struct hci_conn *acl, *sco;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2172) __u16 handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2174) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2176) if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2177) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2179) cp = hci_sent_cmd_data(hdev, HCI_OP_SETUP_SYNC_CONN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2180) if (!cp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2181) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2183) handle = __le16_to_cpu(cp->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2185) BT_DBG("%s handle 0x%4.4x", hdev->name, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2187) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2189) acl = hci_conn_hash_lookup_handle(hdev, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2190) if (acl) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2191) sco = acl->link;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2192) if (sco) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2193) sco->state = BT_CLOSED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2195) hci_connect_cfm(sco, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2196) hci_conn_del(sco);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2197) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2198) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2200) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2201) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2203) static void hci_cs_sniff_mode(struct hci_dev *hdev, __u8 status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2204) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2205) struct hci_cp_sniff_mode *cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2206) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2208) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2210) if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2211) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2213) cp = hci_sent_cmd_data(hdev, HCI_OP_SNIFF_MODE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2214) if (!cp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2215) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2217) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2219) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2220) if (conn) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2221) clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2223) if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2224) hci_sco_setup(conn, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2225) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2227) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2228) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2230) static void hci_cs_exit_sniff_mode(struct hci_dev *hdev, __u8 status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2231) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2232) struct hci_cp_exit_sniff_mode *cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2233) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2235) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2237) if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2238) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2240) cp = hci_sent_cmd_data(hdev, HCI_OP_EXIT_SNIFF_MODE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2241) if (!cp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2242) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2244) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2246) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2247) if (conn) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2248) clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2250) if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2251) hci_sco_setup(conn, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2252) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2254) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2255) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2257) static void hci_cs_disconnect(struct hci_dev *hdev, u8 status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2258) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2259) struct hci_cp_disconnect *cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2260) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2262) if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2263) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2265) cp = hci_sent_cmd_data(hdev, HCI_OP_DISCONNECT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2266) if (!cp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2267) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2269) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2271) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2272) if (conn) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2273) u8 type = conn->type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2275) mgmt_disconnect_failed(hdev, &conn->dst, conn->type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2276) conn->dst_type, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2278) /* If the disconnection failed for any reason, the upper layer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2279) * does not retry to disconnect in current implementation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2280) * Hence, we need to do some basic cleanup here and re-enable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2281) * advertising if necessary.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2282) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2283) hci_conn_del(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2284) if (type == LE_LINK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2285) hci_req_reenable_advertising(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2286) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2288) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2289) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2291) static void cs_le_create_conn(struct hci_dev *hdev, bdaddr_t *peer_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2292) u8 peer_addr_type, u8 own_address_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2293) u8 filter_policy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2294) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2295) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2296)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2297) conn = hci_conn_hash_lookup_le(hdev, peer_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2298) peer_addr_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2299) if (!conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2300) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2302) /* When using controller based address resolution, then the new
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2303) * address types 0x02 and 0x03 are used. These types need to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2304) * converted back into either public address or random address type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2305) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2306) if (use_ll_privacy(hdev) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2307) hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2308) switch (own_address_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2309) case ADDR_LE_DEV_PUBLIC_RESOLVED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2310) own_address_type = ADDR_LE_DEV_PUBLIC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2311) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2312) case ADDR_LE_DEV_RANDOM_RESOLVED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2313) own_address_type = ADDR_LE_DEV_RANDOM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2314) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2315) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2316) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2318) /* Store the initiator and responder address information which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2319) * is needed for SMP. These values will not change during the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2320) * lifetime of the connection.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2321) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2322) conn->init_addr_type = own_address_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2323) if (own_address_type == ADDR_LE_DEV_RANDOM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2324) bacpy(&conn->init_addr, &hdev->random_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2325) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2326) bacpy(&conn->init_addr, &hdev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2328) conn->resp_addr_type = peer_addr_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2329) bacpy(&conn->resp_addr, peer_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2331) /* We don't want the connection attempt to stick around
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2332) * indefinitely since LE doesn't have a page timeout concept
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2333) * like BR/EDR. Set a timer for any connection that doesn't use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2334) * the white list for connecting.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2335) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2336) if (filter_policy == HCI_LE_USE_PEER_ADDR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2337) queue_delayed_work(conn->hdev->workqueue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2338) &conn->le_conn_timeout,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2339) conn->conn_timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2340) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2341)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2342) static void hci_cs_le_create_conn(struct hci_dev *hdev, u8 status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2343) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2344) struct hci_cp_le_create_conn *cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2345)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2346) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2348) /* All connection failure handling is taken care of by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2349) * hci_le_conn_failed function which is triggered by the HCI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2350) * request completion callbacks used for connecting.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2351) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2352) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2353) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2354)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2355) cp = hci_sent_cmd_data(hdev, HCI_OP_LE_CREATE_CONN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2356) if (!cp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2357) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2358)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2359) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2360)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2361) cs_le_create_conn(hdev, &cp->peer_addr, cp->peer_addr_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2362) cp->own_address_type, cp->filter_policy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2363)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2364) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2365) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2366)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2367) static void hci_cs_le_ext_create_conn(struct hci_dev *hdev, u8 status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2368) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2369) struct hci_cp_le_ext_create_conn *cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2371) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2372)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2373) /* All connection failure handling is taken care of by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2374) * hci_le_conn_failed function which is triggered by the HCI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2375) * request completion callbacks used for connecting.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2376) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2377) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2378) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2379)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2380) cp = hci_sent_cmd_data(hdev, HCI_OP_LE_EXT_CREATE_CONN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2381) if (!cp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2382) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2384) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2385)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2386) cs_le_create_conn(hdev, &cp->peer_addr, cp->peer_addr_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2387) cp->own_addr_type, cp->filter_policy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2389) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2390) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2391)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2392) static void hci_cs_le_read_remote_features(struct hci_dev *hdev, u8 status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2393) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2394) struct hci_cp_le_read_remote_features *cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2395) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2396)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2397) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2398)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2399) if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2400) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2401)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2402) cp = hci_sent_cmd_data(hdev, HCI_OP_LE_READ_REMOTE_FEATURES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2403) if (!cp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2404) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2405)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2406) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2407)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2408) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2409) if (conn) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2410) if (conn->state == BT_CONFIG) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2411) hci_connect_cfm(conn, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2412) hci_conn_drop(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2413) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2414) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2415)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2416) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2417) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2419) static void hci_cs_le_start_enc(struct hci_dev *hdev, u8 status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2420) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2421) struct hci_cp_le_start_enc *cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2422) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2423)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2424) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2425)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2426) if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2427) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2428)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2429) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2431) cp = hci_sent_cmd_data(hdev, HCI_OP_LE_START_ENC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2432) if (!cp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2433) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2434)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2435) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2436) if (!conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2437) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2438)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2439) if (conn->state != BT_CONNECTED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2440) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2441)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2442) hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2443) hci_conn_drop(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2444)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2445) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2446) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2447) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2448)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2449) static void hci_cs_switch_role(struct hci_dev *hdev, u8 status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2450) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2451) struct hci_cp_switch_role *cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2452) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2454) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2455)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2456) if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2457) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2458)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2459) cp = hci_sent_cmd_data(hdev, HCI_OP_SWITCH_ROLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2460) if (!cp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2461) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2462)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2463) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2464)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2465) conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2466) if (conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2467) clear_bit(HCI_CONN_RSWITCH_PEND, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2468)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2469) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2470) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2471)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2472) static void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2473) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2474) __u8 status = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2475) struct discovery_state *discov = &hdev->discovery;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2476) struct inquiry_entry *e;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2477)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2478) BT_DBG("%s status 0x%2.2x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2479)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2480) hci_conn_check_pending(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2481)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2482) if (!test_and_clear_bit(HCI_INQUIRY, &hdev->flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2483) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2485) smp_mb__after_atomic(); /* wake_up_bit advises about this barrier */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2486) wake_up_bit(&hdev->flags, HCI_INQUIRY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2487)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2488) if (!hci_dev_test_flag(hdev, HCI_MGMT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2489) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2490)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2491) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2492)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2493) if (discov->state != DISCOVERY_FINDING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2494) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2495)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2496) if (list_empty(&discov->resolve)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2497) /* When BR/EDR inquiry is active and no LE scanning is in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2498) * progress, then change discovery state to indicate completion.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2499) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2500) * When running LE scanning and BR/EDR inquiry simultaneously
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2501) * and the LE scan already finished, then change the discovery
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2502) * state to indicate completion.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2503) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2504) if (!hci_dev_test_flag(hdev, HCI_LE_SCAN) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2505) !test_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2506) hci_discovery_set_state(hdev, DISCOVERY_STOPPED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2507) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2508) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2509)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2510) e = hci_inquiry_cache_lookup_resolve(hdev, BDADDR_ANY, NAME_NEEDED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2511) if (e && hci_resolve_name(hdev, e) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2512) e->name_state = NAME_PENDING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2513) hci_discovery_set_state(hdev, DISCOVERY_RESOLVING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2514) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2515) /* When BR/EDR inquiry is active and no LE scanning is in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2516) * progress, then change discovery state to indicate completion.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2517) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2518) * When running LE scanning and BR/EDR inquiry simultaneously
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2519) * and the LE scan already finished, then change the discovery
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2520) * state to indicate completion.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2521) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2522) if (!hci_dev_test_flag(hdev, HCI_LE_SCAN) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2523) !test_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2524) hci_discovery_set_state(hdev, DISCOVERY_STOPPED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2525) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2526)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2527) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2528) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2529) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2530)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2531) static void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2532) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2533) struct inquiry_data data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2534) struct inquiry_info *info = (void *) (skb->data + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2535) int num_rsp = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2536)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2537) BT_DBG("%s num_rsp %d", hdev->name, num_rsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2538)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2539) if (!num_rsp || skb->len < num_rsp * sizeof(*info) + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2540) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2541)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2542) if (hci_dev_test_flag(hdev, HCI_PERIODIC_INQ))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2543) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2544)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2545) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2546)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2547) for (; num_rsp; num_rsp--, info++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2548) u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2549)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2550) bacpy(&data.bdaddr, &info->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2551) data.pscan_rep_mode = info->pscan_rep_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2552) data.pscan_period_mode = info->pscan_period_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2553) data.pscan_mode = info->pscan_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2554) memcpy(data.dev_class, info->dev_class, 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2555) data.clock_offset = info->clock_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2556) data.rssi = HCI_RSSI_INVALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2557) data.ssp_mode = 0x00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2558)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2559) flags = hci_inquiry_cache_update(hdev, &data, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2560)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2561) mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2562) info->dev_class, HCI_RSSI_INVALID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2563) flags, NULL, 0, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2564) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2565)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2566) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2567) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2568)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2569) static void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2570) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2571) struct hci_ev_conn_complete *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2572) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2573)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2574) BT_DBG("%s", hdev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2575)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2576) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2577)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2578) conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2579) if (!conn) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2580) /* Connection may not exist if auto-connected. Check the bredr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2581) * allowlist to see if this device is allowed to auto connect.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2582) * If link is an ACL type, create a connection class
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2583) * automatically.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2584) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2585) * Auto-connect will only occur if the event filter is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2586) * programmed with a given address. Right now, event filter is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2587) * only used during suspend.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2588) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2589) if (ev->link_type == ACL_LINK &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2590) hci_bdaddr_list_lookup_with_flags(&hdev->whitelist,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2591) &ev->bdaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2592) BDADDR_BREDR)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2593) conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2594) HCI_ROLE_SLAVE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2595) if (!conn) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2596) bt_dev_err(hdev, "no memory for new conn");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2597) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2598) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2599) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2600) if (ev->link_type != SCO_LINK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2601) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2602)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2603) conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2604) &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2605) if (!conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2606) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2607)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2608) conn->type = SCO_LINK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2609) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2610) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2611)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2612) if (!ev->status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2613) conn->handle = __le16_to_cpu(ev->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2614)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2615) if (conn->type == ACL_LINK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2616) conn->state = BT_CONFIG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2617) hci_conn_hold(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2618)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2619) if (!conn->out && !hci_conn_ssp_enabled(conn) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2620) !hci_find_link_key(hdev, &ev->bdaddr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2621) conn->disc_timeout = HCI_PAIRING_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2622) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2623) conn->disc_timeout = HCI_DISCONN_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2624) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2625) conn->state = BT_CONNECTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2626)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2627) hci_debugfs_create_conn(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2628) hci_conn_add_sysfs(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2629)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2630) if (test_bit(HCI_AUTH, &hdev->flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2631) set_bit(HCI_CONN_AUTH, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2632)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2633) if (test_bit(HCI_ENCRYPT, &hdev->flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2634) set_bit(HCI_CONN_ENCRYPT, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2635)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2636) /* Get remote features */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2637) if (conn->type == ACL_LINK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2638) struct hci_cp_read_remote_features cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2639) cp.handle = ev->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2640) hci_send_cmd(hdev, HCI_OP_READ_REMOTE_FEATURES,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2641) sizeof(cp), &cp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2642)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2643) hci_req_update_scan(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2644) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2645)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2646) /* Set packet type for incoming connection */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2647) if (!conn->out && hdev->hci_ver < BLUETOOTH_VER_2_0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2648) struct hci_cp_change_conn_ptype cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2649) cp.handle = ev->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2650) cp.pkt_type = cpu_to_le16(conn->pkt_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2651) hci_send_cmd(hdev, HCI_OP_CHANGE_CONN_PTYPE, sizeof(cp),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2652) &cp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2653) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2654) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2655) conn->state = BT_CLOSED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2656) if (conn->type == ACL_LINK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2657) mgmt_connect_failed(hdev, &conn->dst, conn->type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2658) conn->dst_type, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2659) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2660)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2661) if (conn->type == ACL_LINK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2662) hci_sco_setup(conn, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2663)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2664) if (ev->status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2665) hci_connect_cfm(conn, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2666) hci_conn_del(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2667) } else if (ev->link_type == SCO_LINK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2668) switch (conn->setting & SCO_AIRMODE_MASK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2669) case SCO_AIRMODE_CVSD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2670) if (hdev->notify)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2671) hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_CVSD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2672) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2673) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2674)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2675) hci_connect_cfm(conn, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2676) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2677)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2678) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2679) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2680)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2681) hci_conn_check_pending(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2682) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2683)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2684) static void hci_reject_conn(struct hci_dev *hdev, bdaddr_t *bdaddr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2685) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2686) struct hci_cp_reject_conn_req cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2687)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2688) bacpy(&cp.bdaddr, bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2689) cp.reason = HCI_ERROR_REJ_BAD_ADDR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2690) hci_send_cmd(hdev, HCI_OP_REJECT_CONN_REQ, sizeof(cp), &cp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2691) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2692)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2693) static void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2694) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2695) struct hci_ev_conn_request *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2696) int mask = hdev->link_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2697) struct inquiry_entry *ie;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2698) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2699) __u8 flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2700)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2701) BT_DBG("%s bdaddr %pMR type 0x%x", hdev->name, &ev->bdaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2702) ev->link_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2703)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2704) mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ev->link_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2705) &flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2706)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2707) if (!(mask & HCI_LM_ACCEPT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2708) hci_reject_conn(hdev, &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2709) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2710) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2711)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2712) if (hci_bdaddr_list_lookup(&hdev->blacklist, &ev->bdaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2713) BDADDR_BREDR)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2714) hci_reject_conn(hdev, &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2715) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2716) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2717)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2718) /* Require HCI_CONNECTABLE or a whitelist entry to accept the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2719) * connection. These features are only touched through mgmt so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2720) * only do the checks if HCI_MGMT is set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2721) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2722) if (hci_dev_test_flag(hdev, HCI_MGMT) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2723) !hci_dev_test_flag(hdev, HCI_CONNECTABLE) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2724) !hci_bdaddr_list_lookup_with_flags(&hdev->whitelist, &ev->bdaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2725) BDADDR_BREDR)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2726) hci_reject_conn(hdev, &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2727) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2728) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2729)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2730) /* Connection accepted */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2731)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2732) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2733)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2734) ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2735) if (ie)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2736) memcpy(ie->data.dev_class, ev->dev_class, 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2737)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2738) conn = hci_conn_hash_lookup_ba(hdev, ev->link_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2739) &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2740) if (!conn) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2741) conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2742) HCI_ROLE_SLAVE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2743) if (!conn) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2744) bt_dev_err(hdev, "no memory for new connection");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2745) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2746) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2747) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2748) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2749)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2750) memcpy(conn->dev_class, ev->dev_class, 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2751)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2752) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2753)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2754) if (ev->link_type == ACL_LINK ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2755) (!(flags & HCI_PROTO_DEFER) && !lmp_esco_capable(hdev))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2756) struct hci_cp_accept_conn_req cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2757) conn->state = BT_CONNECT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2758)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2759) bacpy(&cp.bdaddr, &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2760)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2761) if (lmp_rswitch_capable(hdev) && (mask & HCI_LM_MASTER))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2762) cp.role = 0x00; /* Become master */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2763) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2764) cp.role = 0x01; /* Remain slave */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2765)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2766) hci_send_cmd(hdev, HCI_OP_ACCEPT_CONN_REQ, sizeof(cp), &cp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2767) } else if (!(flags & HCI_PROTO_DEFER)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2768) struct hci_cp_accept_sync_conn_req cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2769) conn->state = BT_CONNECT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2770)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2771) bacpy(&cp.bdaddr, &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2772) cp.pkt_type = cpu_to_le16(conn->pkt_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2773)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2774) cp.tx_bandwidth = cpu_to_le32(0x00001f40);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2775) cp.rx_bandwidth = cpu_to_le32(0x00001f40);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2776) cp.max_latency = cpu_to_le16(0xffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2777) cp.content_format = cpu_to_le16(hdev->voice_setting);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2778) cp.retrans_effort = 0xff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2779)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2780) hci_send_cmd(hdev, HCI_OP_ACCEPT_SYNC_CONN_REQ, sizeof(cp),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2781) &cp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2782) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2783) conn->state = BT_CONNECT2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2784) hci_connect_cfm(conn, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2785) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2786) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2787)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2788) static u8 hci_to_mgmt_reason(u8 err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2789) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2790) switch (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2791) case HCI_ERROR_CONNECTION_TIMEOUT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2792) return MGMT_DEV_DISCONN_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2793) case HCI_ERROR_REMOTE_USER_TERM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2794) case HCI_ERROR_REMOTE_LOW_RESOURCES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2795) case HCI_ERROR_REMOTE_POWER_OFF:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2796) return MGMT_DEV_DISCONN_REMOTE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2797) case HCI_ERROR_LOCAL_HOST_TERM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2798) return MGMT_DEV_DISCONN_LOCAL_HOST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2799) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2800) return MGMT_DEV_DISCONN_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2801) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2802) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2803)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2804) static void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2805) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2806) struct hci_ev_disconn_complete *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2807) u8 reason;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2808) struct hci_conn_params *params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2809) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2810) bool mgmt_connected;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2811) u8 type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2812)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2813) BT_DBG("%s status 0x%2.2x", hdev->name, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2814)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2815) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2816)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2817) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2818) if (!conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2819) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2820)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2821) if (ev->status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2822) mgmt_disconnect_failed(hdev, &conn->dst, conn->type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2823) conn->dst_type, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2824) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2825) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2826)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2827) conn->state = BT_CLOSED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2828)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2829) mgmt_connected = test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2830)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2831) if (test_bit(HCI_CONN_AUTH_FAILURE, &conn->flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2832) reason = MGMT_DEV_DISCONN_AUTH_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2833) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2834) reason = hci_to_mgmt_reason(ev->reason);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2835)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2836) mgmt_device_disconnected(hdev, &conn->dst, conn->type, conn->dst_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2837) reason, mgmt_connected);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2838)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2839) if (conn->type == ACL_LINK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2840) if (test_bit(HCI_CONN_FLUSH_KEY, &conn->flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2841) hci_remove_link_key(hdev, &conn->dst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2842)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2843) hci_req_update_scan(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2844) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2845)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2846) params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2847) if (params) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2848) switch (params->auto_connect) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2849) case HCI_AUTO_CONN_LINK_LOSS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2850) if (ev->reason != HCI_ERROR_CONNECTION_TIMEOUT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2851) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2852) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2853)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2854) case HCI_AUTO_CONN_DIRECT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2855) case HCI_AUTO_CONN_ALWAYS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2856) list_del_init(¶ms->action);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2857) list_add(¶ms->action, &hdev->pend_le_conns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2858) hci_update_background_scan(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2859) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2860)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2861) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2862) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2863) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2864) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2865)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2866) type = conn->type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2867)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2868) hci_disconn_cfm(conn, ev->reason);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2869) hci_conn_del(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2870)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2871) /* The suspend notifier is waiting for all devices to disconnect so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2872) * clear the bit from pending tasks and inform the wait queue.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2873) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2874) if (list_empty(&hdev->conn_hash.list) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2875) test_and_clear_bit(SUSPEND_DISCONNECTING, hdev->suspend_tasks)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2876) wake_up(&hdev->suspend_wait_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2877) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2878)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2879) /* Re-enable advertising if necessary, since it might
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2880) * have been disabled by the connection. From the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2881) * HCI_LE_Set_Advertise_Enable command description in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2882) * the core specification (v4.0):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2883) * "The Controller shall continue advertising until the Host
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2884) * issues an LE_Set_Advertise_Enable command with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2885) * Advertising_Enable set to 0x00 (Advertising is disabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2886) * or until a connection is created or until the Advertising
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2887) * is timed out due to Directed Advertising."
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2888) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2889) if (type == LE_LINK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2890) hci_req_reenable_advertising(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2891)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2892) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2893) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2894) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2895)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2896) static void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2897) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2898) struct hci_ev_auth_complete *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2899) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2900)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2901) BT_DBG("%s status 0x%2.2x", hdev->name, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2902)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2903) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2904)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2905) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2906) if (!conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2907) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2908)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2909) if (!ev->status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2910) clear_bit(HCI_CONN_AUTH_FAILURE, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2911)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2912) if (!hci_conn_ssp_enabled(conn) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2913) test_bit(HCI_CONN_REAUTH_PEND, &conn->flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2914) bt_dev_info(hdev, "re-auth of legacy device is not possible.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2915) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2916) set_bit(HCI_CONN_AUTH, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2917) conn->sec_level = conn->pending_sec_level;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2918) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2919) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2920) if (ev->status == HCI_ERROR_PIN_OR_KEY_MISSING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2921) set_bit(HCI_CONN_AUTH_FAILURE, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2922)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2923) mgmt_auth_failed(conn, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2924) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2925)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2926) clear_bit(HCI_CONN_AUTH_PEND, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2927) clear_bit(HCI_CONN_REAUTH_PEND, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2928)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2929) if (conn->state == BT_CONFIG) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2930) if (!ev->status && hci_conn_ssp_enabled(conn)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2931) struct hci_cp_set_conn_encrypt cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2932) cp.handle = ev->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2933) cp.encrypt = 0x01;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2934) hci_send_cmd(hdev, HCI_OP_SET_CONN_ENCRYPT, sizeof(cp),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2935) &cp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2936) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2937) conn->state = BT_CONNECTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2938) hci_connect_cfm(conn, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2939) hci_conn_drop(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2940) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2941) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2942) hci_auth_cfm(conn, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2943)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2944) hci_conn_hold(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2945) conn->disc_timeout = HCI_DISCONN_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2946) hci_conn_drop(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2947) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2948)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2949) if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2950) if (!ev->status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2951) struct hci_cp_set_conn_encrypt cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2952) cp.handle = ev->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2953) cp.encrypt = 0x01;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2954) hci_send_cmd(hdev, HCI_OP_SET_CONN_ENCRYPT, sizeof(cp),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2955) &cp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2956) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2957) clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2958) hci_encrypt_cfm(conn, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2959) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2960) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2961)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2962) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2963) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2964) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2965)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2966) static void hci_remote_name_evt(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2967) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2968) struct hci_ev_remote_name *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2969) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2970)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2971) BT_DBG("%s", hdev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2972)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2973) hci_conn_check_pending(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2974)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2975) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2976)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2977) conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2978)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2979) if (!hci_dev_test_flag(hdev, HCI_MGMT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2980) goto check_auth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2981)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2982) if (ev->status == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2983) hci_check_pending_name(hdev, conn, &ev->bdaddr, ev->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2984) strnlen(ev->name, HCI_MAX_NAME_LENGTH));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2985) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2986) hci_check_pending_name(hdev, conn, &ev->bdaddr, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2987)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2988) check_auth:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2989) if (!conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2990) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2991)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2992) if (!hci_outgoing_auth_needed(hdev, conn))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2993) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2994)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2995) if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2996) struct hci_cp_auth_requested cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2997)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2998) set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2999)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3000) cp.handle = __cpu_to_le16(conn->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3001) hci_send_cmd(hdev, HCI_OP_AUTH_REQUESTED, sizeof(cp), &cp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3002) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3003)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3004) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3005) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3006) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3007)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3008) static void read_enc_key_size_complete(struct hci_dev *hdev, u8 status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3009) u16 opcode, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3010) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3011) const struct hci_rp_read_enc_key_size *rp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3012) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3013) u16 handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3014)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3015) BT_DBG("%s status 0x%02x", hdev->name, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3016)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3017) if (!skb || skb->len < sizeof(*rp)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3018) bt_dev_err(hdev, "invalid read key size response");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3019) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3020) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3021)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3022) rp = (void *)skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3023) handle = le16_to_cpu(rp->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3024)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3025) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3026)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3027) conn = hci_conn_hash_lookup_handle(hdev, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3028) if (!conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3029) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3030)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3031) /* While unexpected, the read_enc_key_size command may fail. The most
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3032) * secure approach is to then assume the key size is 0 to force a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3033) * disconnection.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3034) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3035) if (rp->status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3036) bt_dev_err(hdev, "failed to read key size for handle %u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3037) handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3038) conn->enc_key_size = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3039) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3040) conn->enc_key_size = rp->key_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3041) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3042)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3043) hci_encrypt_cfm(conn, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3044)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3045) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3046) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3047) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3048)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3049) static void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3050) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3051) struct hci_ev_encrypt_change *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3052) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3053)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3054) BT_DBG("%s status 0x%2.2x", hdev->name, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3055)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3056) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3057)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3058) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3059) if (!conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3060) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3061)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3062) if (!ev->status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3063) if (ev->encrypt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3064) /* Encryption implies authentication */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3065) set_bit(HCI_CONN_AUTH, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3066) set_bit(HCI_CONN_ENCRYPT, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3067) conn->sec_level = conn->pending_sec_level;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3068)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3069) /* P-256 authentication key implies FIPS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3070) if (conn->key_type == HCI_LK_AUTH_COMBINATION_P256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3071) set_bit(HCI_CONN_FIPS, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3072)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3073) if ((conn->type == ACL_LINK && ev->encrypt == 0x02) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3074) conn->type == LE_LINK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3075) set_bit(HCI_CONN_AES_CCM, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3076) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3077) clear_bit(HCI_CONN_ENCRYPT, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3078) clear_bit(HCI_CONN_AES_CCM, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3079) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3080) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3081)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3082) /* We should disregard the current RPA and generate a new one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3083) * whenever the encryption procedure fails.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3084) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3085) if (ev->status && conn->type == LE_LINK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3086) hci_dev_set_flag(hdev, HCI_RPA_EXPIRED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3087) hci_adv_instances_set_rpa_expired(hdev, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3088) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3089)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3090) clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3091)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3092) /* Check link security requirements are met */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3093) if (!hci_conn_check_link_mode(conn))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3094) ev->status = HCI_ERROR_AUTH_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3095)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3096) if (ev->status && conn->state == BT_CONNECTED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3097) if (ev->status == HCI_ERROR_PIN_OR_KEY_MISSING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3098) set_bit(HCI_CONN_AUTH_FAILURE, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3099)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3100) /* Notify upper layers so they can cleanup before
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3101) * disconnecting.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3102) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3103) hci_encrypt_cfm(conn, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3104) hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3105) hci_conn_drop(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3106) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3107) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3109) /* Try reading the encryption key size for encrypted ACL links */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3110) if (!ev->status && ev->encrypt && conn->type == ACL_LINK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3111) struct hci_cp_read_enc_key_size cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3112) struct hci_request req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3114) /* Only send HCI_Read_Encryption_Key_Size if the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3115) * controller really supports it. If it doesn't, assume
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3116) * the default size (16).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3117) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3118) if (!(hdev->commands[20] & 0x10)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3119) conn->enc_key_size = HCI_LINK_KEY_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3120) goto notify;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3121) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3123) hci_req_init(&req, hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3125) cp.handle = cpu_to_le16(conn->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3126) hci_req_add(&req, HCI_OP_READ_ENC_KEY_SIZE, sizeof(cp), &cp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3128) if (hci_req_run_skb(&req, read_enc_key_size_complete)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3129) bt_dev_err(hdev, "sending read key size failed");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3130) conn->enc_key_size = HCI_LINK_KEY_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3131) goto notify;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3132) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3134) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3135) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3137) /* Set the default Authenticated Payload Timeout after
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3138) * an LE Link is established. As per Core Spec v5.0, Vol 2, Part B
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3139) * Section 3.3, the HCI command WRITE_AUTH_PAYLOAD_TIMEOUT should be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3140) * sent when the link is active and Encryption is enabled, the conn
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3141) * type can be either LE or ACL and controller must support LMP Ping.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3142) * Ensure for AES-CCM encryption as well.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3143) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3144) if (test_bit(HCI_CONN_ENCRYPT, &conn->flags) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3145) test_bit(HCI_CONN_AES_CCM, &conn->flags) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3146) ((conn->type == ACL_LINK && lmp_ping_capable(hdev)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3147) (conn->type == LE_LINK && (hdev->le_features[0] & HCI_LE_PING)))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3148) struct hci_cp_write_auth_payload_to cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3150) cp.handle = cpu_to_le16(conn->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3151) cp.timeout = cpu_to_le16(hdev->auth_payload_timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3152) hci_send_cmd(conn->hdev, HCI_OP_WRITE_AUTH_PAYLOAD_TO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3153) sizeof(cp), &cp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3154) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3156) notify:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3157) hci_encrypt_cfm(conn, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3159) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3160) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3161) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3163) static void hci_change_link_key_complete_evt(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3164) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3165) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3166) struct hci_ev_change_link_key_complete *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3167) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3169) BT_DBG("%s status 0x%2.2x", hdev->name, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3171) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3173) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3174) if (conn) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3175) if (!ev->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3176) set_bit(HCI_CONN_SECURE, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3178) clear_bit(HCI_CONN_AUTH_PEND, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3180) hci_key_change_cfm(conn, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3181) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3183) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3184) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3186) static void hci_remote_features_evt(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3187) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3188) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3189) struct hci_ev_remote_features *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3190) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3192) BT_DBG("%s status 0x%2.2x", hdev->name, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3194) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3196) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3197) if (!conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3198) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3200) if (!ev->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3201) memcpy(conn->features[0], ev->features, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3203) if (conn->state != BT_CONFIG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3204) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3206) if (!ev->status && lmp_ext_feat_capable(hdev) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3207) lmp_ext_feat_capable(conn)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3208) struct hci_cp_read_remote_ext_features cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3209) cp.handle = ev->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3210) cp.page = 0x01;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3211) hci_send_cmd(hdev, HCI_OP_READ_REMOTE_EXT_FEATURES,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3212) sizeof(cp), &cp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3213) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3216) if (!ev->status && !test_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3217) struct hci_cp_remote_name_req cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3218) memset(&cp, 0, sizeof(cp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3219) bacpy(&cp.bdaddr, &conn->dst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3220) cp.pscan_rep_mode = 0x02;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3221) hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ, sizeof(cp), &cp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3222) } else if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3223) mgmt_device_connected(hdev, conn, 0, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3225) if (!hci_outgoing_auth_needed(hdev, conn)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3226) conn->state = BT_CONNECTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3227) hci_connect_cfm(conn, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3228) hci_conn_drop(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3229) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3231) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3232) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3233) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3235) static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3236) u16 *opcode, u8 *status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3237) hci_req_complete_t *req_complete,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3238) hci_req_complete_skb_t *req_complete_skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3239) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3240) struct hci_ev_cmd_complete *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3242) *opcode = __le16_to_cpu(ev->opcode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3243) *status = skb->data[sizeof(*ev)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3245) skb_pull(skb, sizeof(*ev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3247) switch (*opcode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3248) case HCI_OP_INQUIRY_CANCEL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3249) hci_cc_inquiry_cancel(hdev, skb, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3250) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3252) case HCI_OP_PERIODIC_INQ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3253) hci_cc_periodic_inq(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3254) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3256) case HCI_OP_EXIT_PERIODIC_INQ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3257) hci_cc_exit_periodic_inq(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3258) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3260) case HCI_OP_REMOTE_NAME_REQ_CANCEL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3261) hci_cc_remote_name_req_cancel(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3262) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3264) case HCI_OP_ROLE_DISCOVERY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3265) hci_cc_role_discovery(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3266) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3268) case HCI_OP_READ_LINK_POLICY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3269) hci_cc_read_link_policy(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3270) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3272) case HCI_OP_WRITE_LINK_POLICY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3273) hci_cc_write_link_policy(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3274) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3276) case HCI_OP_READ_DEF_LINK_POLICY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3277) hci_cc_read_def_link_policy(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3278) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3280) case HCI_OP_WRITE_DEF_LINK_POLICY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3281) hci_cc_write_def_link_policy(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3282) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3284) case HCI_OP_RESET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3285) hci_cc_reset(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3286) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3288) case HCI_OP_READ_STORED_LINK_KEY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3289) hci_cc_read_stored_link_key(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3290) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3292) case HCI_OP_DELETE_STORED_LINK_KEY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3293) hci_cc_delete_stored_link_key(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3294) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3296) case HCI_OP_WRITE_LOCAL_NAME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3297) hci_cc_write_local_name(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3298) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3300) case HCI_OP_READ_LOCAL_NAME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3301) hci_cc_read_local_name(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3302) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3304) case HCI_OP_WRITE_AUTH_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3305) hci_cc_write_auth_enable(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3306) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3308) case HCI_OP_WRITE_ENCRYPT_MODE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3309) hci_cc_write_encrypt_mode(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3310) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3312) case HCI_OP_WRITE_SCAN_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3313) hci_cc_write_scan_enable(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3314) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3316) case HCI_OP_READ_CLASS_OF_DEV:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3317) hci_cc_read_class_of_dev(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3318) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3320) case HCI_OP_WRITE_CLASS_OF_DEV:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3321) hci_cc_write_class_of_dev(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3322) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3324) case HCI_OP_READ_VOICE_SETTING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3325) hci_cc_read_voice_setting(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3326) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3328) case HCI_OP_WRITE_VOICE_SETTING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3329) hci_cc_write_voice_setting(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3330) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3332) case HCI_OP_READ_NUM_SUPPORTED_IAC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3333) hci_cc_read_num_supported_iac(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3334) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3336) case HCI_OP_WRITE_SSP_MODE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3337) hci_cc_write_ssp_mode(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3338) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3340) case HCI_OP_WRITE_SC_SUPPORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3341) hci_cc_write_sc_support(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3342) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3343)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3344) case HCI_OP_READ_AUTH_PAYLOAD_TO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3345) hci_cc_read_auth_payload_timeout(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3346) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3348) case HCI_OP_WRITE_AUTH_PAYLOAD_TO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3349) hci_cc_write_auth_payload_timeout(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3350) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3352) case HCI_OP_READ_LOCAL_VERSION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3353) hci_cc_read_local_version(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3354) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3355)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3356) case HCI_OP_READ_LOCAL_COMMANDS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3357) hci_cc_read_local_commands(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3358) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3359)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3360) case HCI_OP_READ_LOCAL_FEATURES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3361) hci_cc_read_local_features(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3362) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3363)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3364) case HCI_OP_READ_LOCAL_EXT_FEATURES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3365) hci_cc_read_local_ext_features(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3366) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3367)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3368) case HCI_OP_READ_BUFFER_SIZE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3369) hci_cc_read_buffer_size(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3370) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3371)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3372) case HCI_OP_READ_BD_ADDR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3373) hci_cc_read_bd_addr(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3374) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3376) case HCI_OP_READ_LOCAL_PAIRING_OPTS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3377) hci_cc_read_local_pairing_opts(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3378) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3379)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3380) case HCI_OP_READ_PAGE_SCAN_ACTIVITY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3381) hci_cc_read_page_scan_activity(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3382) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3384) case HCI_OP_WRITE_PAGE_SCAN_ACTIVITY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3385) hci_cc_write_page_scan_activity(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3386) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3387)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3388) case HCI_OP_READ_PAGE_SCAN_TYPE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3389) hci_cc_read_page_scan_type(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3390) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3391)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3392) case HCI_OP_WRITE_PAGE_SCAN_TYPE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3393) hci_cc_write_page_scan_type(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3394) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3395)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3396) case HCI_OP_READ_DATA_BLOCK_SIZE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3397) hci_cc_read_data_block_size(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3398) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3399)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3400) case HCI_OP_READ_FLOW_CONTROL_MODE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3401) hci_cc_read_flow_control_mode(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3402) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3403)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3404) case HCI_OP_READ_LOCAL_AMP_INFO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3405) hci_cc_read_local_amp_info(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3406) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3407)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3408) case HCI_OP_READ_CLOCK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3409) hci_cc_read_clock(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3410) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3411)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3412) case HCI_OP_READ_INQ_RSP_TX_POWER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3413) hci_cc_read_inq_rsp_tx_power(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3414) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3415)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3416) case HCI_OP_READ_DEF_ERR_DATA_REPORTING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3417) hci_cc_read_def_err_data_reporting(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3418) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3420) case HCI_OP_WRITE_DEF_ERR_DATA_REPORTING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3421) hci_cc_write_def_err_data_reporting(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3422) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3423)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3424) case HCI_OP_PIN_CODE_REPLY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3425) hci_cc_pin_code_reply(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3426) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3427)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3428) case HCI_OP_PIN_CODE_NEG_REPLY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3429) hci_cc_pin_code_neg_reply(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3430) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3431)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3432) case HCI_OP_READ_LOCAL_OOB_DATA:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3433) hci_cc_read_local_oob_data(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3434) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3435)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3436) case HCI_OP_READ_LOCAL_OOB_EXT_DATA:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3437) hci_cc_read_local_oob_ext_data(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3438) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3439)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3440) case HCI_OP_LE_READ_BUFFER_SIZE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3441) hci_cc_le_read_buffer_size(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3442) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3443)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3444) case HCI_OP_LE_READ_LOCAL_FEATURES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3445) hci_cc_le_read_local_features(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3446) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3448) case HCI_OP_LE_READ_ADV_TX_POWER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3449) hci_cc_le_read_adv_tx_power(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3450) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3451)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3452) case HCI_OP_USER_CONFIRM_REPLY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3453) hci_cc_user_confirm_reply(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3454) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3455)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3456) case HCI_OP_USER_CONFIRM_NEG_REPLY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3457) hci_cc_user_confirm_neg_reply(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3458) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3459)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3460) case HCI_OP_USER_PASSKEY_REPLY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3461) hci_cc_user_passkey_reply(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3462) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3463)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3464) case HCI_OP_USER_PASSKEY_NEG_REPLY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3465) hci_cc_user_passkey_neg_reply(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3466) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3468) case HCI_OP_LE_SET_RANDOM_ADDR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3469) hci_cc_le_set_random_addr(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3470) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3471)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3472) case HCI_OP_LE_SET_ADV_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3473) hci_cc_le_set_adv_enable(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3474) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3476) case HCI_OP_LE_SET_SCAN_PARAM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3477) hci_cc_le_set_scan_param(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3478) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3479)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3480) case HCI_OP_LE_SET_SCAN_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3481) hci_cc_le_set_scan_enable(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3482) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3483)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3484) case HCI_OP_LE_READ_WHITE_LIST_SIZE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3485) hci_cc_le_read_white_list_size(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3486) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3487)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3488) case HCI_OP_LE_CLEAR_WHITE_LIST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3489) hci_cc_le_clear_white_list(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3490) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3491)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3492) case HCI_OP_LE_ADD_TO_WHITE_LIST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3493) hci_cc_le_add_to_white_list(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3494) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3495)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3496) case HCI_OP_LE_DEL_FROM_WHITE_LIST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3497) hci_cc_le_del_from_white_list(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3498) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3499)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3500) case HCI_OP_LE_READ_SUPPORTED_STATES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3501) hci_cc_le_read_supported_states(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3502) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3503)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3504) case HCI_OP_LE_READ_DEF_DATA_LEN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3505) hci_cc_le_read_def_data_len(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3506) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3507)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3508) case HCI_OP_LE_WRITE_DEF_DATA_LEN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3509) hci_cc_le_write_def_data_len(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3510) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3511)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3512) case HCI_OP_LE_ADD_TO_RESOLV_LIST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3513) hci_cc_le_add_to_resolv_list(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3514) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3515)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3516) case HCI_OP_LE_DEL_FROM_RESOLV_LIST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3517) hci_cc_le_del_from_resolv_list(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3518) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3519)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3520) case HCI_OP_LE_CLEAR_RESOLV_LIST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3521) hci_cc_le_clear_resolv_list(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3522) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3523)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3524) case HCI_OP_LE_READ_RESOLV_LIST_SIZE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3525) hci_cc_le_read_resolv_list_size(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3526) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3527)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3528) case HCI_OP_LE_SET_ADDR_RESOLV_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3529) hci_cc_le_set_addr_resolution_enable(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3530) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3531)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3532) case HCI_OP_LE_READ_MAX_DATA_LEN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3533) hci_cc_le_read_max_data_len(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3534) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3535)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3536) case HCI_OP_WRITE_LE_HOST_SUPPORTED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3537) hci_cc_write_le_host_supported(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3538) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3539)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3540) case HCI_OP_LE_SET_ADV_PARAM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3541) hci_cc_set_adv_param(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3542) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3543)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3544) case HCI_OP_READ_RSSI:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3545) hci_cc_read_rssi(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3546) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3547)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3548) case HCI_OP_READ_TX_POWER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3549) hci_cc_read_tx_power(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3550) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3551)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3552) case HCI_OP_WRITE_SSP_DEBUG_MODE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3553) hci_cc_write_ssp_debug_mode(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3554) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3555)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3556) case HCI_OP_LE_SET_EXT_SCAN_PARAMS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3557) hci_cc_le_set_ext_scan_param(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3558) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3559)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3560) case HCI_OP_LE_SET_EXT_SCAN_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3561) hci_cc_le_set_ext_scan_enable(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3562) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3563)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3564) case HCI_OP_LE_SET_DEFAULT_PHY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3565) hci_cc_le_set_default_phy(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3566) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3567)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3568) case HCI_OP_LE_READ_NUM_SUPPORTED_ADV_SETS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3569) hci_cc_le_read_num_adv_sets(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3570) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3571)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3572) case HCI_OP_LE_SET_EXT_ADV_PARAMS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3573) hci_cc_set_ext_adv_param(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3574) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3575)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3576) case HCI_OP_LE_SET_EXT_ADV_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3577) hci_cc_le_set_ext_adv_enable(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3578) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3579)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3580) case HCI_OP_LE_SET_ADV_SET_RAND_ADDR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3581) hci_cc_le_set_adv_set_random_addr(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3582) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3583)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3584) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3585) BT_DBG("%s opcode 0x%4.4x", hdev->name, *opcode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3586) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3587) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3588)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3589) if (*opcode != HCI_OP_NOP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3590) cancel_delayed_work(&hdev->cmd_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3591)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3592) if (ev->ncmd && !test_bit(HCI_RESET, &hdev->flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3593) atomic_set(&hdev->cmd_cnt, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3594)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3595) hci_req_cmd_complete(hdev, *opcode, *status, req_complete,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3596) req_complete_skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3597)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3598) if (hci_dev_test_flag(hdev, HCI_CMD_PENDING)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3599) bt_dev_err(hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3600) "unexpected event for opcode 0x%4.4x", *opcode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3601) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3602) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3603)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3604) if (atomic_read(&hdev->cmd_cnt) && !skb_queue_empty(&hdev->cmd_q))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3605) queue_work(hdev->workqueue, &hdev->cmd_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3606) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3607)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3608) static void hci_cmd_status_evt(struct hci_dev *hdev, struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3609) u16 *opcode, u8 *status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3610) hci_req_complete_t *req_complete,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3611) hci_req_complete_skb_t *req_complete_skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3612) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3613) struct hci_ev_cmd_status *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3614)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3615) skb_pull(skb, sizeof(*ev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3616)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3617) *opcode = __le16_to_cpu(ev->opcode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3618) *status = ev->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3619)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3620) switch (*opcode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3621) case HCI_OP_INQUIRY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3622) hci_cs_inquiry(hdev, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3623) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3624)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3625) case HCI_OP_CREATE_CONN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3626) hci_cs_create_conn(hdev, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3627) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3628)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3629) case HCI_OP_DISCONNECT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3630) hci_cs_disconnect(hdev, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3631) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3632)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3633) case HCI_OP_ADD_SCO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3634) hci_cs_add_sco(hdev, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3635) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3636)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3637) case HCI_OP_AUTH_REQUESTED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3638) hci_cs_auth_requested(hdev, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3639) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3640)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3641) case HCI_OP_SET_CONN_ENCRYPT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3642) hci_cs_set_conn_encrypt(hdev, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3643) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3644)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3645) case HCI_OP_REMOTE_NAME_REQ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3646) hci_cs_remote_name_req(hdev, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3647) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3648)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3649) case HCI_OP_READ_REMOTE_FEATURES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3650) hci_cs_read_remote_features(hdev, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3651) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3652)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3653) case HCI_OP_READ_REMOTE_EXT_FEATURES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3654) hci_cs_read_remote_ext_features(hdev, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3655) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3656)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3657) case HCI_OP_SETUP_SYNC_CONN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3658) hci_cs_setup_sync_conn(hdev, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3659) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3660)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3661) case HCI_OP_SNIFF_MODE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3662) hci_cs_sniff_mode(hdev, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3663) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3664)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3665) case HCI_OP_EXIT_SNIFF_MODE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3666) hci_cs_exit_sniff_mode(hdev, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3667) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3668)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3669) case HCI_OP_SWITCH_ROLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3670) hci_cs_switch_role(hdev, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3671) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3672)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3673) case HCI_OP_LE_CREATE_CONN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3674) hci_cs_le_create_conn(hdev, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3675) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3676)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3677) case HCI_OP_LE_READ_REMOTE_FEATURES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3678) hci_cs_le_read_remote_features(hdev, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3679) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3680)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3681) case HCI_OP_LE_START_ENC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3682) hci_cs_le_start_enc(hdev, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3683) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3684)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3685) case HCI_OP_LE_EXT_CREATE_CONN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3686) hci_cs_le_ext_create_conn(hdev, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3687) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3688)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3689) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3690) BT_DBG("%s opcode 0x%4.4x", hdev->name, *opcode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3691) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3692) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3693)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3694) if (*opcode != HCI_OP_NOP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3695) cancel_delayed_work(&hdev->cmd_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3696)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3697) if (ev->ncmd && !test_bit(HCI_RESET, &hdev->flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3698) atomic_set(&hdev->cmd_cnt, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3699)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3700) /* Indicate request completion if the command failed. Also, if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3701) * we're not waiting for a special event and we get a success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3702) * command status we should try to flag the request as completed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3703) * (since for this kind of commands there will not be a command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3704) * complete event).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3705) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3706) if (ev->status ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3707) (hdev->sent_cmd && !bt_cb(hdev->sent_cmd)->hci.req_event))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3708) hci_req_cmd_complete(hdev, *opcode, ev->status, req_complete,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3709) req_complete_skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3710)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3711) if (hci_dev_test_flag(hdev, HCI_CMD_PENDING)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3712) bt_dev_err(hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3713) "unexpected event for opcode 0x%4.4x", *opcode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3714) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3715) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3716)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3717) if (atomic_read(&hdev->cmd_cnt) && !skb_queue_empty(&hdev->cmd_q))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3718) queue_work(hdev->workqueue, &hdev->cmd_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3719) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3720)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3721) static void hci_hardware_error_evt(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3722) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3723) struct hci_ev_hardware_error *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3724)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3725) hdev->hw_error_code = ev->code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3726)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3727) queue_work(hdev->req_workqueue, &hdev->error_reset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3728) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3729)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3730) static void hci_role_change_evt(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3731) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3732) struct hci_ev_role_change *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3733) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3734)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3735) BT_DBG("%s status 0x%2.2x", hdev->name, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3736)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3737) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3738)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3739) conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3740) if (conn) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3741) if (!ev->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3742) conn->role = ev->role;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3743)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3744) clear_bit(HCI_CONN_RSWITCH_PEND, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3745)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3746) hci_role_switch_cfm(conn, ev->status, ev->role);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3747) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3748)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3749) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3750) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3751)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3752) static void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3753) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3754) struct hci_ev_num_comp_pkts *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3755) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3756)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3757) if (hdev->flow_ctl_mode != HCI_FLOW_CTL_MODE_PACKET_BASED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3758) bt_dev_err(hdev, "wrong event for mode %d", hdev->flow_ctl_mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3759) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3760) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3761)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3762) if (skb->len < sizeof(*ev) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3763) skb->len < struct_size(ev, handles, ev->num_hndl)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3764) BT_DBG("%s bad parameters", hdev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3765) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3766) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3767)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3768) BT_DBG("%s num_hndl %d", hdev->name, ev->num_hndl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3769)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3770) for (i = 0; i < ev->num_hndl; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3771) struct hci_comp_pkts_info *info = &ev->handles[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3772) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3773) __u16 handle, count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3774)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3775) handle = __le16_to_cpu(info->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3776) count = __le16_to_cpu(info->count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3777)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3778) conn = hci_conn_hash_lookup_handle(hdev, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3779) if (!conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3780) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3781)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3782) conn->sent -= count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3783)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3784) switch (conn->type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3785) case ACL_LINK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3786) hdev->acl_cnt += count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3787) if (hdev->acl_cnt > hdev->acl_pkts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3788) hdev->acl_cnt = hdev->acl_pkts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3789) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3790)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3791) case LE_LINK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3792) if (hdev->le_pkts) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3793) hdev->le_cnt += count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3794) if (hdev->le_cnt > hdev->le_pkts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3795) hdev->le_cnt = hdev->le_pkts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3796) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3797) hdev->acl_cnt += count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3798) if (hdev->acl_cnt > hdev->acl_pkts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3799) hdev->acl_cnt = hdev->acl_pkts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3800) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3801) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3802)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3803) case SCO_LINK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3804) hdev->sco_cnt += count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3805) if (hdev->sco_cnt > hdev->sco_pkts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3806) hdev->sco_cnt = hdev->sco_pkts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3807) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3808)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3809) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3810) bt_dev_err(hdev, "unknown type %d conn %p",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3811) conn->type, conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3812) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3813) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3814) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3815)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3816) queue_work(hdev->workqueue, &hdev->tx_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3817) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3818)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3819) static struct hci_conn *__hci_conn_lookup_handle(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3820) __u16 handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3821) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3822) struct hci_chan *chan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3823)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3824) switch (hdev->dev_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3825) case HCI_PRIMARY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3826) return hci_conn_hash_lookup_handle(hdev, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3827) case HCI_AMP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3828) chan = hci_chan_lookup_handle(hdev, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3829) if (chan)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3830) return chan->conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3831) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3832) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3833) bt_dev_err(hdev, "unknown dev_type %d", hdev->dev_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3834) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3835) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3836)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3837) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3838) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3839)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3840) static void hci_num_comp_blocks_evt(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3841) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3842) struct hci_ev_num_comp_blocks *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3843) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3844)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3845) if (hdev->flow_ctl_mode != HCI_FLOW_CTL_MODE_BLOCK_BASED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3846) bt_dev_err(hdev, "wrong event for mode %d", hdev->flow_ctl_mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3847) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3848) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3849)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3850) if (skb->len < sizeof(*ev) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3851) skb->len < struct_size(ev, handles, ev->num_hndl)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3852) BT_DBG("%s bad parameters", hdev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3853) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3854) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3855)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3856) BT_DBG("%s num_blocks %d num_hndl %d", hdev->name, ev->num_blocks,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3857) ev->num_hndl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3858)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3859) for (i = 0; i < ev->num_hndl; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3860) struct hci_comp_blocks_info *info = &ev->handles[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3861) struct hci_conn *conn = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3862) __u16 handle, block_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3863)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3864) handle = __le16_to_cpu(info->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3865) block_count = __le16_to_cpu(info->blocks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3866)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3867) conn = __hci_conn_lookup_handle(hdev, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3868) if (!conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3869) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3870)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3871) conn->sent -= block_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3872)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3873) switch (conn->type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3874) case ACL_LINK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3875) case AMP_LINK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3876) hdev->block_cnt += block_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3877) if (hdev->block_cnt > hdev->num_blocks)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3878) hdev->block_cnt = hdev->num_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3879) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3880)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3881) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3882) bt_dev_err(hdev, "unknown type %d conn %p",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3883) conn->type, conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3884) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3885) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3886) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3887)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3888) queue_work(hdev->workqueue, &hdev->tx_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3889) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3890)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3891) static void hci_mode_change_evt(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3892) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3893) struct hci_ev_mode_change *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3894) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3895)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3896) BT_DBG("%s status 0x%2.2x", hdev->name, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3897)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3898) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3899)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3900) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3901) if (conn) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3902) conn->mode = ev->mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3903)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3904) if (!test_and_clear_bit(HCI_CONN_MODE_CHANGE_PEND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3905) &conn->flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3906) if (conn->mode == HCI_CM_ACTIVE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3907) set_bit(HCI_CONN_POWER_SAVE, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3908) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3909) clear_bit(HCI_CONN_POWER_SAVE, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3910) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3911)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3912) if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3913) hci_sco_setup(conn, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3914) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3915)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3916) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3917) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3918)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3919) static void hci_pin_code_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3920) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3921) struct hci_ev_pin_code_req *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3922) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3923)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3924) BT_DBG("%s", hdev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3925)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3926) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3927)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3928) conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3929) if (!conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3930) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3931)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3932) if (conn->state == BT_CONNECTED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3933) hci_conn_hold(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3934) conn->disc_timeout = HCI_PAIRING_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3935) hci_conn_drop(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3936) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3937)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3938) if (!hci_dev_test_flag(hdev, HCI_BONDABLE) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3939) !test_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3940) hci_send_cmd(hdev, HCI_OP_PIN_CODE_NEG_REPLY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3941) sizeof(ev->bdaddr), &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3942) } else if (hci_dev_test_flag(hdev, HCI_MGMT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3943) u8 secure;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3944)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3945) if (conn->pending_sec_level == BT_SECURITY_HIGH)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3946) secure = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3947) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3948) secure = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3949)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3950) mgmt_pin_code_request(hdev, &ev->bdaddr, secure);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3951) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3952)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3953) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3954) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3955) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3956)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3957) static void conn_set_key(struct hci_conn *conn, u8 key_type, u8 pin_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3958) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3959) if (key_type == HCI_LK_CHANGED_COMBINATION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3960) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3961)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3962) conn->pin_length = pin_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3963) conn->key_type = key_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3964)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3965) switch (key_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3966) case HCI_LK_LOCAL_UNIT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3967) case HCI_LK_REMOTE_UNIT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3968) case HCI_LK_DEBUG_COMBINATION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3969) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3970) case HCI_LK_COMBINATION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3971) if (pin_len == 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3972) conn->pending_sec_level = BT_SECURITY_HIGH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3973) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3974) conn->pending_sec_level = BT_SECURITY_MEDIUM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3975) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3976) case HCI_LK_UNAUTH_COMBINATION_P192:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3977) case HCI_LK_UNAUTH_COMBINATION_P256:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3978) conn->pending_sec_level = BT_SECURITY_MEDIUM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3979) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3980) case HCI_LK_AUTH_COMBINATION_P192:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3981) conn->pending_sec_level = BT_SECURITY_HIGH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3982) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3983) case HCI_LK_AUTH_COMBINATION_P256:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3984) conn->pending_sec_level = BT_SECURITY_FIPS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3985) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3986) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3987) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3988)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3989) static void hci_link_key_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3990) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3991) struct hci_ev_link_key_req *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3992) struct hci_cp_link_key_reply cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3993) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3994) struct link_key *key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3995)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3996) BT_DBG("%s", hdev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3997)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3998) if (!hci_dev_test_flag(hdev, HCI_MGMT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3999) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4001) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4002)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4003) key = hci_find_link_key(hdev, &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4004) if (!key) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4005) BT_DBG("%s link key not found for %pMR", hdev->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4006) &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4007) goto not_found;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4008) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4009)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4010) BT_DBG("%s found key type %u for %pMR", hdev->name, key->type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4011) &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4012)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4013) conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4014) if (conn) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4015) clear_bit(HCI_CONN_NEW_LINK_KEY, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4016)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4017) if ((key->type == HCI_LK_UNAUTH_COMBINATION_P192 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4018) key->type == HCI_LK_UNAUTH_COMBINATION_P256) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4019) conn->auth_type != 0xff && (conn->auth_type & 0x01)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4020) BT_DBG("%s ignoring unauthenticated key", hdev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4021) goto not_found;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4022) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4023)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4024) if (key->type == HCI_LK_COMBINATION && key->pin_len < 16 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4025) (conn->pending_sec_level == BT_SECURITY_HIGH ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4026) conn->pending_sec_level == BT_SECURITY_FIPS)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4027) BT_DBG("%s ignoring key unauthenticated for high security",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4028) hdev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4029) goto not_found;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4030) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4031)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4032) conn_set_key(conn, key->type, key->pin_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4033) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4034)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4035) bacpy(&cp.bdaddr, &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4036) memcpy(cp.link_key, key->val, HCI_LINK_KEY_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4037)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4038) hci_send_cmd(hdev, HCI_OP_LINK_KEY_REPLY, sizeof(cp), &cp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4039)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4040) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4041)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4042) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4043)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4044) not_found:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4045) hci_send_cmd(hdev, HCI_OP_LINK_KEY_NEG_REPLY, 6, &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4046) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4047) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4048)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4049) static void hci_link_key_notify_evt(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4050) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4051) struct hci_ev_link_key_notify *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4052) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4053) struct link_key *key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4054) bool persistent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4055) u8 pin_len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4056)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4057) BT_DBG("%s", hdev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4058)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4059) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4060)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4061) conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4062) if (!conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4063) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4064)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4065) hci_conn_hold(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4066) conn->disc_timeout = HCI_DISCONN_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4067) hci_conn_drop(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4068)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4069) set_bit(HCI_CONN_NEW_LINK_KEY, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4070) conn_set_key(conn, ev->key_type, conn->pin_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4071)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4072) if (!hci_dev_test_flag(hdev, HCI_MGMT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4073) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4074)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4075) key = hci_add_link_key(hdev, conn, &ev->bdaddr, ev->link_key,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4076) ev->key_type, pin_len, &persistent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4077) if (!key)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4078) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4079)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4080) /* Update connection information since adding the key will have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4081) * fixed up the type in the case of changed combination keys.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4082) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4083) if (ev->key_type == HCI_LK_CHANGED_COMBINATION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4084) conn_set_key(conn, key->type, key->pin_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4085)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4086) mgmt_new_link_key(hdev, key, persistent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4087)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4088) /* Keep debug keys around only if the HCI_KEEP_DEBUG_KEYS flag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4089) * is set. If it's not set simply remove the key from the kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4090) * list (we've still notified user space about it but with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4091) * store_hint being 0).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4092) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4093) if (key->type == HCI_LK_DEBUG_COMBINATION &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4094) !hci_dev_test_flag(hdev, HCI_KEEP_DEBUG_KEYS)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4095) list_del_rcu(&key->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4096) kfree_rcu(key, rcu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4097) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4098) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4099)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4100) if (persistent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4101) clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4102) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4103) set_bit(HCI_CONN_FLUSH_KEY, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4105) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4106) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4107) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4109) static void hci_clock_offset_evt(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4110) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4111) struct hci_ev_clock_offset *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4112) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4114) BT_DBG("%s status 0x%2.2x", hdev->name, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4116) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4118) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4119) if (conn && !ev->status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4120) struct inquiry_entry *ie;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4122) ie = hci_inquiry_cache_lookup(hdev, &conn->dst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4123) if (ie) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4124) ie->data.clock_offset = ev->clock_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4125) ie->timestamp = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4126) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4127) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4129) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4130) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4132) static void hci_pkt_type_change_evt(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4133) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4134) struct hci_ev_pkt_type_change *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4135) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4137) BT_DBG("%s status 0x%2.2x", hdev->name, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4139) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4141) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4142) if (conn && !ev->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4143) conn->pkt_type = __le16_to_cpu(ev->pkt_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4145) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4148) static void hci_pscan_rep_mode_evt(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4149) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4150) struct hci_ev_pscan_rep_mode *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4151) struct inquiry_entry *ie;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4153) BT_DBG("%s", hdev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4155) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4157) ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4158) if (ie) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4159) ie->data.pscan_rep_mode = ev->pscan_rep_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4160) ie->timestamp = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4161) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4163) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4164) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4166) static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4167) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4168) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4169) struct inquiry_data data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4170) int num_rsp = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4172) BT_DBG("%s num_rsp %d", hdev->name, num_rsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4174) if (!num_rsp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4175) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4177) if (hci_dev_test_flag(hdev, HCI_PERIODIC_INQ))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4178) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4180) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4182) if ((skb->len - 1) / num_rsp != sizeof(struct inquiry_info_with_rssi)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4183) struct inquiry_info_with_rssi_and_pscan_mode *info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4184) info = (void *) (skb->data + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4186) if (skb->len < num_rsp * sizeof(*info) + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4187) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4189) for (; num_rsp; num_rsp--, info++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4190) u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4192) bacpy(&data.bdaddr, &info->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4193) data.pscan_rep_mode = info->pscan_rep_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4194) data.pscan_period_mode = info->pscan_period_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4195) data.pscan_mode = info->pscan_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4196) memcpy(data.dev_class, info->dev_class, 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4197) data.clock_offset = info->clock_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4198) data.rssi = info->rssi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4199) data.ssp_mode = 0x00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4201) flags = hci_inquiry_cache_update(hdev, &data, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4203) mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4204) info->dev_class, info->rssi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4205) flags, NULL, 0, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4206) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4207) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4208) struct inquiry_info_with_rssi *info = (void *) (skb->data + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4210) if (skb->len < num_rsp * sizeof(*info) + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4211) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4213) for (; num_rsp; num_rsp--, info++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4214) u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4216) bacpy(&data.bdaddr, &info->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4217) data.pscan_rep_mode = info->pscan_rep_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4218) data.pscan_period_mode = info->pscan_period_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4219) data.pscan_mode = 0x00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4220) memcpy(data.dev_class, info->dev_class, 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4221) data.clock_offset = info->clock_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4222) data.rssi = info->rssi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4223) data.ssp_mode = 0x00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4225) flags = hci_inquiry_cache_update(hdev, &data, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4227) mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4228) info->dev_class, info->rssi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4229) flags, NULL, 0, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4230) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4231) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4233) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4234) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4235) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4237) static void hci_remote_ext_features_evt(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4238) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4239) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4240) struct hci_ev_remote_ext_features *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4241) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4243) BT_DBG("%s", hdev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4245) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4247) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4248) if (!conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4249) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4251) if (ev->page < HCI_MAX_PAGES)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4252) memcpy(conn->features[ev->page], ev->features, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4254) if (!ev->status && ev->page == 0x01) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4255) struct inquiry_entry *ie;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4257) ie = hci_inquiry_cache_lookup(hdev, &conn->dst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4258) if (ie)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4259) ie->data.ssp_mode = (ev->features[0] & LMP_HOST_SSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4260)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4261) if (ev->features[0] & LMP_HOST_SSP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4262) set_bit(HCI_CONN_SSP_ENABLED, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4263) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4264) /* It is mandatory by the Bluetooth specification that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4265) * Extended Inquiry Results are only used when Secure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4266) * Simple Pairing is enabled, but some devices violate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4267) * this.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4268) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4269) * To make these devices work, the internal SSP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4270) * enabled flag needs to be cleared if the remote host
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4271) * features do not indicate SSP support */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4272) clear_bit(HCI_CONN_SSP_ENABLED, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4273) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4275) if (ev->features[0] & LMP_HOST_SC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4276) set_bit(HCI_CONN_SC_ENABLED, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4277) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4279) if (conn->state != BT_CONFIG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4280) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4282) if (!ev->status && !test_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4283) struct hci_cp_remote_name_req cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4284) memset(&cp, 0, sizeof(cp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4285) bacpy(&cp.bdaddr, &conn->dst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4286) cp.pscan_rep_mode = 0x02;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4287) hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ, sizeof(cp), &cp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4288) } else if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4289) mgmt_device_connected(hdev, conn, 0, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4291) if (!hci_outgoing_auth_needed(hdev, conn)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4292) conn->state = BT_CONNECTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4293) hci_connect_cfm(conn, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4294) hci_conn_drop(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4295) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4296)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4297) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4298) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4299) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4301) static void hci_sync_conn_complete_evt(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4302) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4303) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4304) struct hci_ev_sync_conn_complete *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4305) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4307) BT_DBG("%s status 0x%2.2x", hdev->name, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4309) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4311) conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4312) if (!conn) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4313) if (ev->link_type == ESCO_LINK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4314) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4316) /* When the link type in the event indicates SCO connection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4317) * and lookup of the connection object fails, then check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4318) * if an eSCO connection object exists.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4319) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4320) * The core limits the synchronous connections to either
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4321) * SCO or eSCO. The eSCO connection is preferred and tried
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4322) * to be setup first and until successfully established,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4323) * the link type will be hinted as eSCO.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4324) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4325) conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK, &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4326) if (!conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4327) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4328) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4329)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4330) switch (ev->status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4331) case 0x00:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4332) /* The synchronous connection complete event should only be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4333) * sent once per new connection. Receiving a successful
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4334) * complete event when the connection status is already
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4335) * BT_CONNECTED means that the device is misbehaving and sent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4336) * multiple complete event packets for the same new connection.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4337) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4338) * Registering the device more than once can corrupt kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4339) * memory, hence upon detecting this invalid event, we report
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4340) * an error and ignore the packet.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4341) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4342) if (conn->state == BT_CONNECTED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4343) bt_dev_err(hdev, "Ignoring connect complete event for existing connection");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4344) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4345) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4346)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4347) conn->handle = __le16_to_cpu(ev->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4348) conn->state = BT_CONNECTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4349) conn->type = ev->link_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4351) hci_debugfs_create_conn(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4352) hci_conn_add_sysfs(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4353) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4354)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4355) case 0x10: /* Connection Accept Timeout */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4356) case 0x0d: /* Connection Rejected due to Limited Resources */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4357) case 0x11: /* Unsupported Feature or Parameter Value */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4358) case 0x1c: /* SCO interval rejected */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4359) case 0x1a: /* Unsupported Remote Feature */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4360) case 0x1e: /* Invalid LMP Parameters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4361) case 0x1f: /* Unspecified error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4362) case 0x20: /* Unsupported LMP Parameter value */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4363) if (conn->out) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4364) conn->pkt_type = (hdev->esco_type & SCO_ESCO_MASK) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4365) (hdev->esco_type & EDR_ESCO_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4366) if (hci_setup_sync(conn, conn->link->handle))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4367) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4368) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4369) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4371) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4372) conn->state = BT_CLOSED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4373) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4374) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4376) bt_dev_dbg(hdev, "SCO connected with air mode: %02x", ev->air_mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4377)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4378) switch (ev->air_mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4379) case 0x02:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4380) if (hdev->notify)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4381) hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_CVSD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4382) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4383) case 0x03:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4384) if (hdev->notify)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4385) hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_TRANSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4386) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4387) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4389) hci_connect_cfm(conn, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4390) if (ev->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4391) hci_conn_del(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4392)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4393) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4394) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4395) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4396)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4397) static inline size_t eir_get_length(u8 *eir, size_t eir_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4398) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4399) size_t parsed = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4400)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4401) while (parsed < eir_len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4402) u8 field_len = eir[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4403)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4404) if (field_len == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4405) return parsed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4406)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4407) parsed += field_len + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4408) eir += field_len + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4409) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4410)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4411) return eir_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4412) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4413)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4414) static void hci_extended_inquiry_result_evt(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4415) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4416) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4417) struct inquiry_data data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4418) struct extended_inquiry_info *info = (void *) (skb->data + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4419) int num_rsp = *((__u8 *) skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4420) size_t eir_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4421)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4422) BT_DBG("%s num_rsp %d", hdev->name, num_rsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4423)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4424) if (!num_rsp || skb->len < num_rsp * sizeof(*info) + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4425) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4426)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4427) if (hci_dev_test_flag(hdev, HCI_PERIODIC_INQ))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4428) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4429)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4430) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4431)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4432) for (; num_rsp; num_rsp--, info++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4433) u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4434) bool name_known;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4435)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4436) bacpy(&data.bdaddr, &info->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4437) data.pscan_rep_mode = info->pscan_rep_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4438) data.pscan_period_mode = info->pscan_period_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4439) data.pscan_mode = 0x00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4440) memcpy(data.dev_class, info->dev_class, 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4441) data.clock_offset = info->clock_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4442) data.rssi = info->rssi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4443) data.ssp_mode = 0x01;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4444)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4445) if (hci_dev_test_flag(hdev, HCI_MGMT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4446) name_known = eir_get_data(info->data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4447) sizeof(info->data),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4448) EIR_NAME_COMPLETE, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4449) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4450) name_known = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4451)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4452) flags = hci_inquiry_cache_update(hdev, &data, name_known);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4454) eir_len = eir_get_length(info->data, sizeof(info->data));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4455)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4456) mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4457) info->dev_class, info->rssi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4458) flags, info->data, eir_len, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4459) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4460)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4461) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4462) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4463)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4464) static void hci_key_refresh_complete_evt(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4465) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4466) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4467) struct hci_ev_key_refresh_complete *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4468) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4469)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4470) BT_DBG("%s status 0x%2.2x handle 0x%4.4x", hdev->name, ev->status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4471) __le16_to_cpu(ev->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4472)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4473) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4474)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4475) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4476) if (!conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4477) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4478)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4479) /* For BR/EDR the necessary steps are taken through the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4480) * auth_complete event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4481) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4482) if (conn->type != LE_LINK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4483) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4485) if (!ev->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4486) conn->sec_level = conn->pending_sec_level;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4487)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4488) clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4490) if (ev->status && conn->state == BT_CONNECTED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4491) hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4492) hci_conn_drop(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4493) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4494) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4495)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4496) if (conn->state == BT_CONFIG) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4497) if (!ev->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4498) conn->state = BT_CONNECTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4499)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4500) hci_connect_cfm(conn, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4501) hci_conn_drop(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4502) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4503) hci_auth_cfm(conn, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4504)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4505) hci_conn_hold(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4506) conn->disc_timeout = HCI_DISCONN_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4507) hci_conn_drop(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4508) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4509)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4510) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4511) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4512) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4513)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4514) static u8 hci_get_auth_req(struct hci_conn *conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4515) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4516) /* If remote requests no-bonding follow that lead */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4517) if (conn->remote_auth == HCI_AT_NO_BONDING ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4518) conn->remote_auth == HCI_AT_NO_BONDING_MITM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4519) return conn->remote_auth | (conn->auth_type & 0x01);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4520)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4521) /* If both remote and local have enough IO capabilities, require
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4522) * MITM protection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4523) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4524) if (conn->remote_cap != HCI_IO_NO_INPUT_OUTPUT &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4525) conn->io_capability != HCI_IO_NO_INPUT_OUTPUT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4526) return conn->remote_auth | 0x01;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4527)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4528) /* No MITM protection possible so ignore remote requirement */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4529) return (conn->remote_auth & ~0x01) | (conn->auth_type & 0x01);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4530) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4531)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4532) static u8 bredr_oob_data_present(struct hci_conn *conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4533) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4534) struct hci_dev *hdev = conn->hdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4535) struct oob_data *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4536)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4537) data = hci_find_remote_oob_data(hdev, &conn->dst, BDADDR_BREDR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4538) if (!data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4539) return 0x00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4540)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4541) if (bredr_sc_enabled(hdev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4542) /* When Secure Connections is enabled, then just
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4543) * return the present value stored with the OOB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4544) * data. The stored value contains the right present
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4545) * information. However it can only be trusted when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4546) * not in Secure Connection Only mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4547) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4548) if (!hci_dev_test_flag(hdev, HCI_SC_ONLY))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4549) return data->present;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4550)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4551) /* When Secure Connections Only mode is enabled, then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4552) * the P-256 values are required. If they are not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4553) * available, then do not declare that OOB data is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4554) * present.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4555) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4556) if (!memcmp(data->rand256, ZERO_KEY, 16) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4557) !memcmp(data->hash256, ZERO_KEY, 16))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4558) return 0x00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4559)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4560) return 0x02;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4561) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4562)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4563) /* When Secure Connections is not enabled or actually
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4564) * not supported by the hardware, then check that if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4565) * P-192 data values are present.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4566) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4567) if (!memcmp(data->rand192, ZERO_KEY, 16) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4568) !memcmp(data->hash192, ZERO_KEY, 16))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4569) return 0x00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4570)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4571) return 0x01;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4572) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4573)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4574) static void hci_io_capa_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4575) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4576) struct hci_ev_io_capa_request *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4577) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4578)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4579) BT_DBG("%s", hdev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4580)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4581) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4582)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4583) conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4584) if (!conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4585) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4586)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4587) hci_conn_hold(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4588)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4589) if (!hci_dev_test_flag(hdev, HCI_MGMT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4590) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4591)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4592) /* Allow pairing if we're pairable, the initiators of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4593) * pairing or if the remote is not requesting bonding.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4594) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4595) if (hci_dev_test_flag(hdev, HCI_BONDABLE) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4596) test_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4597) (conn->remote_auth & ~0x01) == HCI_AT_NO_BONDING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4598) struct hci_cp_io_capability_reply cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4599)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4600) bacpy(&cp.bdaddr, &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4601) /* Change the IO capability from KeyboardDisplay
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4602) * to DisplayYesNo as it is not supported by BT spec. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4603) cp.capability = (conn->io_capability == 0x04) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4604) HCI_IO_DISPLAY_YESNO : conn->io_capability;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4605)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4606) /* If we are initiators, there is no remote information yet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4607) if (conn->remote_auth == 0xff) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4608) /* Request MITM protection if our IO caps allow it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4609) * except for the no-bonding case.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4610) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4611) if (conn->io_capability != HCI_IO_NO_INPUT_OUTPUT &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4612) conn->auth_type != HCI_AT_NO_BONDING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4613) conn->auth_type |= 0x01;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4614) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4615) conn->auth_type = hci_get_auth_req(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4616) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4617)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4618) /* If we're not bondable, force one of the non-bondable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4619) * authentication requirement values.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4620) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4621) if (!hci_dev_test_flag(hdev, HCI_BONDABLE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4622) conn->auth_type &= HCI_AT_NO_BONDING_MITM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4623)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4624) cp.authentication = conn->auth_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4625) cp.oob_data = bredr_oob_data_present(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4626)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4627) hci_send_cmd(hdev, HCI_OP_IO_CAPABILITY_REPLY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4628) sizeof(cp), &cp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4629) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4630) struct hci_cp_io_capability_neg_reply cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4631)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4632) bacpy(&cp.bdaddr, &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4633) cp.reason = HCI_ERROR_PAIRING_NOT_ALLOWED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4634)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4635) hci_send_cmd(hdev, HCI_OP_IO_CAPABILITY_NEG_REPLY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4636) sizeof(cp), &cp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4637) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4638)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4639) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4640) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4641) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4642)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4643) static void hci_io_capa_reply_evt(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4644) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4645) struct hci_ev_io_capa_reply *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4646) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4647)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4648) BT_DBG("%s", hdev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4649)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4650) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4651)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4652) conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4653) if (!conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4654) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4655)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4656) conn->remote_cap = ev->capability;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4657) conn->remote_auth = ev->authentication;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4658)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4659) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4660) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4661) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4662)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4663) static void hci_user_confirm_request_evt(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4664) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4665) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4666) struct hci_ev_user_confirm_req *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4667) int loc_mitm, rem_mitm, confirm_hint = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4668) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4669)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4670) BT_DBG("%s", hdev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4671)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4672) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4673)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4674) if (!hci_dev_test_flag(hdev, HCI_MGMT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4675) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4676)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4677) conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4678) if (!conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4679) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4680)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4681) loc_mitm = (conn->auth_type & 0x01);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4682) rem_mitm = (conn->remote_auth & 0x01);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4683)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4684) /* If we require MITM but the remote device can't provide that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4685) * (it has NoInputNoOutput) then reject the confirmation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4686) * request. We check the security level here since it doesn't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4687) * necessarily match conn->auth_type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4688) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4689) if (conn->pending_sec_level > BT_SECURITY_MEDIUM &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4690) conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4691) BT_DBG("Rejecting request: remote device can't provide MITM");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4692) hci_send_cmd(hdev, HCI_OP_USER_CONFIRM_NEG_REPLY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4693) sizeof(ev->bdaddr), &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4694) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4695) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4696)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4697) /* If no side requires MITM protection; auto-accept */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4698) if ((!loc_mitm || conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4699) (!rem_mitm || conn->io_capability == HCI_IO_NO_INPUT_OUTPUT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4700)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4701) /* If we're not the initiators request authorization to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4702) * proceed from user space (mgmt_user_confirm with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4703) * confirm_hint set to 1). The exception is if neither
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4704) * side had MITM or if the local IO capability is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4705) * NoInputNoOutput, in which case we do auto-accept
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4706) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4707) if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4708) conn->io_capability != HCI_IO_NO_INPUT_OUTPUT &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4709) (loc_mitm || rem_mitm)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4710) BT_DBG("Confirming auto-accept as acceptor");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4711) confirm_hint = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4712) goto confirm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4713) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4714)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4715) /* If there already exists link key in local host, leave the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4716) * decision to user space since the remote device could be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4717) * legitimate or malicious.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4718) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4719) if (hci_find_link_key(hdev, &ev->bdaddr)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4720) bt_dev_dbg(hdev, "Local host already has link key");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4721) confirm_hint = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4722) goto confirm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4723) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4724)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4725) BT_DBG("Auto-accept of user confirmation with %ums delay",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4726) hdev->auto_accept_delay);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4727)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4728) if (hdev->auto_accept_delay > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4729) int delay = msecs_to_jiffies(hdev->auto_accept_delay);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4730) queue_delayed_work(conn->hdev->workqueue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4731) &conn->auto_accept_work, delay);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4732) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4733) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4734)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4735) hci_send_cmd(hdev, HCI_OP_USER_CONFIRM_REPLY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4736) sizeof(ev->bdaddr), &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4737) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4738) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4739)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4740) confirm:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4741) mgmt_user_confirm_request(hdev, &ev->bdaddr, ACL_LINK, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4742) le32_to_cpu(ev->passkey), confirm_hint);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4743)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4744) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4745) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4746) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4747)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4748) static void hci_user_passkey_request_evt(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4749) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4750) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4751) struct hci_ev_user_passkey_req *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4752)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4753) BT_DBG("%s", hdev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4754)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4755) if (hci_dev_test_flag(hdev, HCI_MGMT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4756) mgmt_user_passkey_request(hdev, &ev->bdaddr, ACL_LINK, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4757) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4758)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4759) static void hci_user_passkey_notify_evt(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4760) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4761) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4762) struct hci_ev_user_passkey_notify *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4763) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4764)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4765) BT_DBG("%s", hdev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4766)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4767) conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4768) if (!conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4769) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4770)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4771) conn->passkey_notify = __le32_to_cpu(ev->passkey);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4772) conn->passkey_entered = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4773)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4774) if (hci_dev_test_flag(hdev, HCI_MGMT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4775) mgmt_user_passkey_notify(hdev, &conn->dst, conn->type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4776) conn->dst_type, conn->passkey_notify,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4777) conn->passkey_entered);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4778) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4779)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4780) static void hci_keypress_notify_evt(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4781) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4782) struct hci_ev_keypress_notify *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4783) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4784)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4785) BT_DBG("%s", hdev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4786)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4787) conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4788) if (!conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4789) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4790)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4791) switch (ev->type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4792) case HCI_KEYPRESS_STARTED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4793) conn->passkey_entered = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4794) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4795)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4796) case HCI_KEYPRESS_ENTERED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4797) conn->passkey_entered++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4798) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4799)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4800) case HCI_KEYPRESS_ERASED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4801) conn->passkey_entered--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4802) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4803)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4804) case HCI_KEYPRESS_CLEARED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4805) conn->passkey_entered = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4806) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4807)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4808) case HCI_KEYPRESS_COMPLETED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4809) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4810) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4811)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4812) if (hci_dev_test_flag(hdev, HCI_MGMT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4813) mgmt_user_passkey_notify(hdev, &conn->dst, conn->type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4814) conn->dst_type, conn->passkey_notify,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4815) conn->passkey_entered);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4816) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4817)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4818) static void hci_simple_pair_complete_evt(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4819) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4820) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4821) struct hci_ev_simple_pair_complete *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4822) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4823)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4824) BT_DBG("%s", hdev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4825)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4826) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4827)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4828) conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4829) if (!conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4830) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4831)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4832) /* Reset the authentication requirement to unknown */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4833) conn->remote_auth = 0xff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4834)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4835) /* To avoid duplicate auth_failed events to user space we check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4836) * the HCI_CONN_AUTH_PEND flag which will be set if we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4837) * initiated the authentication. A traditional auth_complete
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4838) * event gets always produced as initiator and is also mapped to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4839) * the mgmt_auth_failed event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4840) if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && ev->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4841) mgmt_auth_failed(conn, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4842)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4843) hci_conn_drop(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4844)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4845) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4846) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4847) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4848)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4849) static void hci_remote_host_features_evt(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4850) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4851) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4852) struct hci_ev_remote_host_features *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4853) struct inquiry_entry *ie;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4854) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4855)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4856) BT_DBG("%s", hdev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4857)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4858) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4859)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4860) conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4861) if (conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4862) memcpy(conn->features[1], ev->features, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4863)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4864) ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4865) if (ie)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4866) ie->data.ssp_mode = (ev->features[0] & LMP_HOST_SSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4867)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4868) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4869) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4870)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4871) static void hci_remote_oob_data_request_evt(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4872) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4873) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4874) struct hci_ev_remote_oob_data_request *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4875) struct oob_data *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4876)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4877) BT_DBG("%s", hdev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4878)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4879) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4880)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4881) if (!hci_dev_test_flag(hdev, HCI_MGMT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4882) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4883)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4884) data = hci_find_remote_oob_data(hdev, &ev->bdaddr, BDADDR_BREDR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4885) if (!data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4886) struct hci_cp_remote_oob_data_neg_reply cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4887)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4888) bacpy(&cp.bdaddr, &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4889) hci_send_cmd(hdev, HCI_OP_REMOTE_OOB_DATA_NEG_REPLY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4890) sizeof(cp), &cp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4891) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4892) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4893)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4894) if (bredr_sc_enabled(hdev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4895) struct hci_cp_remote_oob_ext_data_reply cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4896)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4897) bacpy(&cp.bdaddr, &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4898) if (hci_dev_test_flag(hdev, HCI_SC_ONLY)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4899) memset(cp.hash192, 0, sizeof(cp.hash192));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4900) memset(cp.rand192, 0, sizeof(cp.rand192));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4901) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4902) memcpy(cp.hash192, data->hash192, sizeof(cp.hash192));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4903) memcpy(cp.rand192, data->rand192, sizeof(cp.rand192));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4904) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4905) memcpy(cp.hash256, data->hash256, sizeof(cp.hash256));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4906) memcpy(cp.rand256, data->rand256, sizeof(cp.rand256));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4907)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4908) hci_send_cmd(hdev, HCI_OP_REMOTE_OOB_EXT_DATA_REPLY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4909) sizeof(cp), &cp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4910) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4911) struct hci_cp_remote_oob_data_reply cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4912)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4913) bacpy(&cp.bdaddr, &ev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4914) memcpy(cp.hash, data->hash192, sizeof(cp.hash));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4915) memcpy(cp.rand, data->rand192, sizeof(cp.rand));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4916)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4917) hci_send_cmd(hdev, HCI_OP_REMOTE_OOB_DATA_REPLY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4918) sizeof(cp), &cp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4919) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4920)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4921) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4922) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4923) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4924)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4925) #if IS_ENABLED(CONFIG_BT_HS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4926) static void hci_chan_selected_evt(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4927) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4928) struct hci_ev_channel_selected *ev = (void *)skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4929) struct hci_conn *hcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4930)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4931) BT_DBG("%s handle 0x%2.2x", hdev->name, ev->phy_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4932)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4933) skb_pull(skb, sizeof(*ev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4934)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4935) hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4936) if (!hcon)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4937) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4938)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4939) amp_read_loc_assoc_final_data(hdev, hcon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4940) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4941)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4942) static void hci_phy_link_complete_evt(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4943) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4944) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4945) struct hci_ev_phy_link_complete *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4946) struct hci_conn *hcon, *bredr_hcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4947)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4948) BT_DBG("%s handle 0x%2.2x status 0x%2.2x", hdev->name, ev->phy_handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4949) ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4950)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4951) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4952)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4953) hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4954) if (!hcon) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4955) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4956) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4957) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4958)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4959) if (!hcon->amp_mgr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4960) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4961) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4962) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4963)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4964) if (ev->status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4965) hci_conn_del(hcon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4966) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4967) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4968) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4969)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4970) bredr_hcon = hcon->amp_mgr->l2cap_conn->hcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4971)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4972) hcon->state = BT_CONNECTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4973) bacpy(&hcon->dst, &bredr_hcon->dst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4974)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4975) hci_conn_hold(hcon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4976) hcon->disc_timeout = HCI_DISCONN_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4977) hci_conn_drop(hcon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4978)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4979) hci_debugfs_create_conn(hcon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4980) hci_conn_add_sysfs(hcon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4981)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4982) amp_physical_cfm(bredr_hcon, hcon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4983)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4984) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4985) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4986)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4987) static void hci_loglink_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4988) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4989) struct hci_ev_logical_link_complete *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4990) struct hci_conn *hcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4991) struct hci_chan *hchan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4992) struct amp_mgr *mgr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4993)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4994) BT_DBG("%s log_handle 0x%4.4x phy_handle 0x%2.2x status 0x%2.2x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4995) hdev->name, le16_to_cpu(ev->handle), ev->phy_handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4996) ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4997)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4998) hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4999) if (!hcon)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5000) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5001)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5002) /* Create AMP hchan */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5003) hchan = hci_chan_create(hcon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5004) if (!hchan)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5005) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5006)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5007) hchan->handle = le16_to_cpu(ev->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5008) hchan->amp = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5009)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5010) BT_DBG("hcon %p mgr %p hchan %p", hcon, hcon->amp_mgr, hchan);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5011)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5012) mgr = hcon->amp_mgr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5013) if (mgr && mgr->bredr_chan) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5014) struct l2cap_chan *bredr_chan = mgr->bredr_chan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5015)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5016) l2cap_chan_lock(bredr_chan);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5017)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5018) bredr_chan->conn->mtu = hdev->block_mtu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5019) l2cap_logical_cfm(bredr_chan, hchan, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5020) hci_conn_hold(hcon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5021)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5022) l2cap_chan_unlock(bredr_chan);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5023) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5024) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5025)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5026) static void hci_disconn_loglink_complete_evt(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5027) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5028) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5029) struct hci_ev_disconn_logical_link_complete *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5030) struct hci_chan *hchan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5031)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5032) BT_DBG("%s log handle 0x%4.4x status 0x%2.2x", hdev->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5033) le16_to_cpu(ev->handle), ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5034)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5035) if (ev->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5036) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5037)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5038) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5039)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5040) hchan = hci_chan_lookup_handle(hdev, le16_to_cpu(ev->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5041) if (!hchan || !hchan->amp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5042) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5043)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5044) amp_destroy_logical_link(hchan, ev->reason);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5045)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5046) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5047) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5048) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5049)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5050) static void hci_disconn_phylink_complete_evt(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5051) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5052) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5053) struct hci_ev_disconn_phy_link_complete *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5054) struct hci_conn *hcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5055)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5056) BT_DBG("%s status 0x%2.2x", hdev->name, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5057)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5058) if (ev->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5059) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5060)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5061) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5062)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5063) hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5064) if (hcon) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5065) hcon->state = BT_CLOSED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5066) hci_conn_del(hcon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5067) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5068)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5069) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5070) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5071) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5072)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5073) static void le_conn_update_addr(struct hci_conn *conn, bdaddr_t *bdaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5074) u8 bdaddr_type, bdaddr_t *local_rpa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5075) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5076) if (conn->out) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5077) conn->dst_type = bdaddr_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5078) conn->resp_addr_type = bdaddr_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5079) bacpy(&conn->resp_addr, bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5080)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5081) /* Check if the controller has set a Local RPA then it must be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5082) * used instead or hdev->rpa.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5083) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5084) if (local_rpa && bacmp(local_rpa, BDADDR_ANY)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5085) conn->init_addr_type = ADDR_LE_DEV_RANDOM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5086) bacpy(&conn->init_addr, local_rpa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5087) } else if (hci_dev_test_flag(conn->hdev, HCI_PRIVACY)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5088) conn->init_addr_type = ADDR_LE_DEV_RANDOM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5089) bacpy(&conn->init_addr, &conn->hdev->rpa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5090) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5091) hci_copy_identity_address(conn->hdev, &conn->init_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5092) &conn->init_addr_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5093) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5094) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5095) conn->resp_addr_type = conn->hdev->adv_addr_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5096) /* Check if the controller has set a Local RPA then it must be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5097) * used instead or hdev->rpa.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5098) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5099) if (local_rpa && bacmp(local_rpa, BDADDR_ANY)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5100) conn->resp_addr_type = ADDR_LE_DEV_RANDOM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5101) bacpy(&conn->resp_addr, local_rpa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5102) } else if (conn->hdev->adv_addr_type == ADDR_LE_DEV_RANDOM) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5103) /* In case of ext adv, resp_addr will be updated in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5104) * Adv Terminated event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5105) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5106) if (!ext_adv_capable(conn->hdev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5107) bacpy(&conn->resp_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5108) &conn->hdev->random_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5109) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5110) bacpy(&conn->resp_addr, &conn->hdev->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5113) conn->init_addr_type = bdaddr_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5114) bacpy(&conn->init_addr, bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5116) /* For incoming connections, set the default minimum
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5117) * and maximum connection interval. They will be used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5118) * to check if the parameters are in range and if not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5119) * trigger the connection update procedure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5120) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5121) conn->le_conn_min_interval = conn->hdev->le_conn_min_interval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5122) conn->le_conn_max_interval = conn->hdev->le_conn_max_interval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5123) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5124) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5126) static void le_conn_complete_evt(struct hci_dev *hdev, u8 status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5127) bdaddr_t *bdaddr, u8 bdaddr_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5128) bdaddr_t *local_rpa, u8 role, u16 handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5129) u16 interval, u16 latency,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5130) u16 supervision_timeout)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5131) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5132) struct hci_conn_params *params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5133) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5134) struct smp_irk *irk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5135) u8 addr_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5137) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5139) /* All controllers implicitly stop advertising in the event of a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5140) * connection, so ensure that the state bit is cleared.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5141) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5142) hci_dev_clear_flag(hdev, HCI_LE_ADV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5144) conn = hci_lookup_le_connect(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5145) if (!conn) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5146) conn = hci_conn_add(hdev, LE_LINK, bdaddr, role);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5147) if (!conn) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5148) bt_dev_err(hdev, "no memory for new connection");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5149) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5152) conn->dst_type = bdaddr_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5154) /* If we didn't have a hci_conn object previously
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5155) * but we're in master role this must be something
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5156) * initiated using a white list. Since white list based
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5157) * connections are not "first class citizens" we don't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5158) * have full tracking of them. Therefore, we go ahead
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5159) * with a "best effort" approach of determining the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5160) * initiator address based on the HCI_PRIVACY flag.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5161) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5162) if (conn->out) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5163) conn->resp_addr_type = bdaddr_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5164) bacpy(&conn->resp_addr, bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5165) if (hci_dev_test_flag(hdev, HCI_PRIVACY)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5166) conn->init_addr_type = ADDR_LE_DEV_RANDOM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5167) bacpy(&conn->init_addr, &hdev->rpa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5168) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5169) hci_copy_identity_address(hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5170) &conn->init_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5171) &conn->init_addr_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5172) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5173) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5174) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5175) cancel_delayed_work(&conn->le_conn_timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5176) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5178) le_conn_update_addr(conn, bdaddr, bdaddr_type, local_rpa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5180) /* Lookup the identity address from the stored connection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5181) * address and address type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5182) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5183) * When establishing connections to an identity address, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5184) * connection procedure will store the resolvable random
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5185) * address first. Now if it can be converted back into the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5186) * identity address, start using the identity address from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5187) * now on.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5188) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5189) irk = hci_get_irk(hdev, &conn->dst, conn->dst_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5190) if (irk) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5191) bacpy(&conn->dst, &irk->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5192) conn->dst_type = irk->addr_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5193) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5195) if (status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5196) hci_le_conn_failed(conn, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5197) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5198) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5200) if (conn->dst_type == ADDR_LE_DEV_PUBLIC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5201) addr_type = BDADDR_LE_PUBLIC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5202) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5203) addr_type = BDADDR_LE_RANDOM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5205) /* Drop the connection if the device is blocked */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5206) if (hci_bdaddr_list_lookup(&hdev->blacklist, &conn->dst, addr_type)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5207) hci_conn_drop(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5208) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5209) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5211) if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5212) mgmt_device_connected(hdev, conn, 0, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5214) conn->sec_level = BT_SECURITY_LOW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5215) conn->handle = handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5216) conn->state = BT_CONFIG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5218) conn->le_conn_interval = interval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5219) conn->le_conn_latency = latency;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5220) conn->le_supv_timeout = supervision_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5222) hci_debugfs_create_conn(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5223) hci_conn_add_sysfs(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5225) /* The remote features procedure is defined for master
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5226) * role only. So only in case of an initiated connection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5227) * request the remote features.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5228) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5229) * If the local controller supports slave-initiated features
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5230) * exchange, then requesting the remote features in slave
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5231) * role is possible. Otherwise just transition into the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5232) * connected state without requesting the remote features.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5233) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5234) if (conn->out ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5235) (hdev->le_features[0] & HCI_LE_SLAVE_FEATURES)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5236) struct hci_cp_le_read_remote_features cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5238) cp.handle = __cpu_to_le16(conn->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5240) hci_send_cmd(hdev, HCI_OP_LE_READ_REMOTE_FEATURES,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5241) sizeof(cp), &cp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5243) hci_conn_hold(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5244) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5245) conn->state = BT_CONNECTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5246) hci_connect_cfm(conn, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5247) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5249) params = hci_pend_le_action_lookup(&hdev->pend_le_conns, &conn->dst,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5250) conn->dst_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5251) if (params) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5252) list_del_init(¶ms->action);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5253) if (params->conn) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5254) hci_conn_drop(params->conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5255) hci_conn_put(params->conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5256) params->conn = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5257) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5258) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5260) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5261) hci_update_background_scan(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5262) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5263) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5265) static void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5266) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5267) struct hci_ev_le_conn_complete *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5269) BT_DBG("%s status 0x%2.2x", hdev->name, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5271) le_conn_complete_evt(hdev, ev->status, &ev->bdaddr, ev->bdaddr_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5272) NULL, ev->role, le16_to_cpu(ev->handle),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5273) le16_to_cpu(ev->interval),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5274) le16_to_cpu(ev->latency),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5275) le16_to_cpu(ev->supervision_timeout));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5276) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5278) static void hci_le_enh_conn_complete_evt(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5279) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5280) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5281) struct hci_ev_le_enh_conn_complete *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5283) BT_DBG("%s status 0x%2.2x", hdev->name, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5285) le_conn_complete_evt(hdev, ev->status, &ev->bdaddr, ev->bdaddr_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5286) &ev->local_rpa, ev->role, le16_to_cpu(ev->handle),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5287) le16_to_cpu(ev->interval),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5288) le16_to_cpu(ev->latency),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5289) le16_to_cpu(ev->supervision_timeout));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5291) if (use_ll_privacy(hdev) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5292) hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5293) hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5294) hci_req_disable_address_resolution(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5295) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5296)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5297) static void hci_le_ext_adv_term_evt(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5298) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5299) struct hci_evt_le_ext_adv_set_term *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5300) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5302) BT_DBG("%s status 0x%2.2x", hdev->name, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5304) if (ev->status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5305) struct adv_info *adv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5307) adv = hci_find_adv_instance(hdev, ev->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5308) if (!adv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5309) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5311) /* Remove advertising as it has been terminated */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5312) hci_remove_adv_instance(hdev, ev->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5313) mgmt_advertising_removed(NULL, hdev, ev->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5315) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5316) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5318) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->conn_handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5319) if (conn) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5320) struct adv_info *adv_instance;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5322) if (hdev->adv_addr_type != ADDR_LE_DEV_RANDOM ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5323) bacmp(&conn->resp_addr, BDADDR_ANY))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5324) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5326) if (!hdev->cur_adv_instance) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5327) bacpy(&conn->resp_addr, &hdev->random_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5328) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5329) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5331) adv_instance = hci_find_adv_instance(hdev, hdev->cur_adv_instance);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5332) if (adv_instance)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5333) bacpy(&conn->resp_addr, &adv_instance->random_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5334) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5335) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5336)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5337) static void hci_le_conn_update_complete_evt(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5338) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5339) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5340) struct hci_ev_le_conn_update_complete *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5341) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5343) BT_DBG("%s status 0x%2.2x", hdev->name, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5345) if (ev->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5346) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5348) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5349)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5350) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5351) if (conn) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5352) conn->le_conn_interval = le16_to_cpu(ev->interval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5353) conn->le_conn_latency = le16_to_cpu(ev->latency);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5354) conn->le_supv_timeout = le16_to_cpu(ev->supervision_timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5355) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5357) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5358) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5359)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5360) /* This function requires the caller holds hdev->lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5361) static struct hci_conn *check_pending_le_conn(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5362) bdaddr_t *addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5363) u8 addr_type, u8 adv_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5364) bdaddr_t *direct_rpa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5365) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5366) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5367) struct hci_conn_params *params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5368)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5369) /* If the event is not connectable don't proceed further */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5370) if (adv_type != LE_ADV_IND && adv_type != LE_ADV_DIRECT_IND)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5371) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5372)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5373) /* Ignore if the device is blocked */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5374) if (hci_bdaddr_list_lookup(&hdev->blacklist, addr, addr_type))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5375) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5377) /* Most controller will fail if we try to create new connections
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5378) * while we have an existing one in slave role.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5379) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5380) if (hdev->conn_hash.le_num_slave > 0 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5381) (!test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5382) !(hdev->le_states[3] & 0x10)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5383) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5385) /* If we're not connectable only connect devices that we have in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5386) * our pend_le_conns list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5387) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5388) params = hci_pend_le_action_lookup(&hdev->pend_le_conns, addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5389) addr_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5390) if (!params)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5391) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5392)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5393) if (!params->explicit_connect) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5394) switch (params->auto_connect) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5395) case HCI_AUTO_CONN_DIRECT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5396) /* Only devices advertising with ADV_DIRECT_IND are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5397) * triggering a connection attempt. This is allowing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5398) * incoming connections from slave devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5399) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5400) if (adv_type != LE_ADV_DIRECT_IND)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5401) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5402) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5403) case HCI_AUTO_CONN_ALWAYS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5404) /* Devices advertising with ADV_IND or ADV_DIRECT_IND
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5405) * are triggering a connection attempt. This means
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5406) * that incoming connections from slave device are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5407) * accepted and also outgoing connections to slave
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5408) * devices are established when found.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5409) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5410) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5411) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5412) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5413) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5414) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5415)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5416) conn = hci_connect_le(hdev, addr, addr_type, BT_SECURITY_LOW,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5417) hdev->def_le_autoconnect_timeout, HCI_ROLE_MASTER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5418) direct_rpa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5419) if (!IS_ERR(conn)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5420) /* If HCI_AUTO_CONN_EXPLICIT is set, conn is already owned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5421) * by higher layer that tried to connect, if no then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5422) * store the pointer since we don't really have any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5423) * other owner of the object besides the params that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5424) * triggered it. This way we can abort the connection if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5425) * the parameters get removed and keep the reference
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5426) * count consistent once the connection is established.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5427) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5428)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5429) if (!params->explicit_connect)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5430) params->conn = hci_conn_get(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5431)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5432) return conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5433) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5434)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5435) switch (PTR_ERR(conn)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5436) case -EBUSY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5437) /* If hci_connect() returns -EBUSY it means there is already
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5438) * an LE connection attempt going on. Since controllers don't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5439) * support more than one connection attempt at the time, we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5440) * don't consider this an error case.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5441) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5442) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5443) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5444) BT_DBG("Failed to connect: err %ld", PTR_ERR(conn));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5445) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5446) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5448) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5449) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5450)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5451) static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5452) u8 bdaddr_type, bdaddr_t *direct_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5453) u8 direct_addr_type, s8 rssi, u8 *data, u8 len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5454) bool ext_adv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5455) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5456) struct discovery_state *d = &hdev->discovery;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5457) struct smp_irk *irk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5458) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5459) bool match;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5460) u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5461) u8 *ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5462)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5463) switch (type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5464) case LE_ADV_IND:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5465) case LE_ADV_DIRECT_IND:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5466) case LE_ADV_SCAN_IND:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5467) case LE_ADV_NONCONN_IND:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5468) case LE_ADV_SCAN_RSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5469) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5470) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5471) bt_dev_err_ratelimited(hdev, "unknown advertising packet "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5472) "type: 0x%02x", type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5473) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5474) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5476) if (!ext_adv && len > HCI_MAX_AD_LENGTH) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5477) bt_dev_err_ratelimited(hdev, "legacy adv larger than 31 bytes");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5478) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5479) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5480)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5481) /* Find the end of the data in case the report contains padded zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5482) * bytes at the end causing an invalid length value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5483) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5484) * When data is NULL, len is 0 so there is no need for extra ptr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5485) * check as 'ptr < data + 0' is already false in such case.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5486) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5487) for (ptr = data; ptr < data + len && *ptr; ptr += *ptr + 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5488) if (ptr + 1 + *ptr > data + len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5489) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5490) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5491)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5492) /* Adjust for actual length. This handles the case when remote
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5493) * device is advertising with incorrect data length.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5494) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5495) len = ptr - data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5496)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5497) /* If the direct address is present, then this report is from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5498) * a LE Direct Advertising Report event. In that case it is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5499) * important to see if the address is matching the local
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5500) * controller address.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5501) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5502) if (direct_addr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5503) /* Only resolvable random addresses are valid for these
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5504) * kind of reports and others can be ignored.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5505) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5506) if (!hci_bdaddr_is_rpa(direct_addr, direct_addr_type))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5507) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5508)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5509) /* If the controller is not using resolvable random
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5510) * addresses, then this report can be ignored.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5511) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5512) if (!hci_dev_test_flag(hdev, HCI_PRIVACY))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5513) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5514)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5515) /* If the local IRK of the controller does not match
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5516) * with the resolvable random address provided, then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5517) * this report can be ignored.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5518) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5519) if (!smp_irk_matches(hdev, hdev->irk, direct_addr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5520) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5521) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5522)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5523) /* Check if we need to convert to identity address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5524) irk = hci_get_irk(hdev, bdaddr, bdaddr_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5525) if (irk) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5526) bdaddr = &irk->bdaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5527) bdaddr_type = irk->addr_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5528) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5529)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5530) /* Check if we have been requested to connect to this device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5531) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5532) * direct_addr is set only for directed advertising reports (it is NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5533) * for advertising reports) and is already verified to be RPA above.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5534) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5535) conn = check_pending_le_conn(hdev, bdaddr, bdaddr_type, type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5536) direct_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5537) if (!ext_adv && conn && type == LE_ADV_IND && len <= HCI_MAX_AD_LENGTH) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5538) /* Store report for later inclusion by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5539) * mgmt_device_connected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5540) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5541) memcpy(conn->le_adv_data, data, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5542) conn->le_adv_data_len = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5543) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5544)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5545) /* Passive scanning shouldn't trigger any device found events,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5546) * except for devices marked as CONN_REPORT for which we do send
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5547) * device found events, or advertisement monitoring requested.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5548) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5549) if (hdev->le_scan_type == LE_SCAN_PASSIVE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5550) if (type == LE_ADV_DIRECT_IND)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5551) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5552)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5553) if (!hci_pend_le_action_lookup(&hdev->pend_le_reports,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5554) bdaddr, bdaddr_type) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5555) idr_is_empty(&hdev->adv_monitors_idr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5556) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5557)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5558) if (type == LE_ADV_NONCONN_IND || type == LE_ADV_SCAN_IND)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5559) flags = MGMT_DEV_FOUND_NOT_CONNECTABLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5560) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5561) flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5562) mgmt_device_found(hdev, bdaddr, LE_LINK, bdaddr_type, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5563) rssi, flags, data, len, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5564) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5565) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5566)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5567) /* When receiving non-connectable or scannable undirected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5568) * advertising reports, this means that the remote device is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5569) * not connectable and then clearly indicate this in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5570) * device found event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5571) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5572) * When receiving a scan response, then there is no way to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5573) * know if the remote device is connectable or not. However
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5574) * since scan responses are merged with a previously seen
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5575) * advertising report, the flags field from that report
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5576) * will be used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5577) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5578) * In the really unlikely case that a controller get confused
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5579) * and just sends a scan response event, then it is marked as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5580) * not connectable as well.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5581) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5582) if (type == LE_ADV_NONCONN_IND || type == LE_ADV_SCAN_IND ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5583) type == LE_ADV_SCAN_RSP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5584) flags = MGMT_DEV_FOUND_NOT_CONNECTABLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5585) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5586) flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5587)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5588) /* If there's nothing pending either store the data from this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5589) * event or send an immediate device found event if the data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5590) * should not be stored for later.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5591) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5592) if (!ext_adv && !has_pending_adv_report(hdev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5593) /* If the report will trigger a SCAN_REQ store it for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5594) * later merging.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5595) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5596) if (type == LE_ADV_IND || type == LE_ADV_SCAN_IND) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5597) store_pending_adv_report(hdev, bdaddr, bdaddr_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5598) rssi, flags, data, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5599) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5600) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5601)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5602) mgmt_device_found(hdev, bdaddr, LE_LINK, bdaddr_type, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5603) rssi, flags, data, len, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5604) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5605) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5606)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5607) /* Check if the pending report is for the same device as the new one */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5608) match = (!bacmp(bdaddr, &d->last_adv_addr) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5609) bdaddr_type == d->last_adv_addr_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5610)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5611) /* If the pending data doesn't match this report or this isn't a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5612) * scan response (e.g. we got a duplicate ADV_IND) then force
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5613) * sending of the pending data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5614) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5615) if (type != LE_ADV_SCAN_RSP || !match) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5616) /* Send out whatever is in the cache, but skip duplicates */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5617) if (!match)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5618) mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5619) d->last_adv_addr_type, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5620) d->last_adv_rssi, d->last_adv_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5621) d->last_adv_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5622) d->last_adv_data_len, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5623)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5624) /* If the new report will trigger a SCAN_REQ store it for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5625) * later merging.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5626) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5627) if (!ext_adv && (type == LE_ADV_IND ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5628) type == LE_ADV_SCAN_IND)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5629) store_pending_adv_report(hdev, bdaddr, bdaddr_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5630) rssi, flags, data, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5631) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5632) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5633)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5634) /* The advertising reports cannot be merged, so clear
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5635) * the pending report and send out a device found event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5636) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5637) clear_pending_adv_report(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5638) mgmt_device_found(hdev, bdaddr, LE_LINK, bdaddr_type, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5639) rssi, flags, data, len, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5640) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5641) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5642)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5643) /* If we get here we've got a pending ADV_IND or ADV_SCAN_IND and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5644) * the new event is a SCAN_RSP. We can therefore proceed with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5645) * sending a merged device found event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5646) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5647) mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5648) d->last_adv_addr_type, NULL, rssi, d->last_adv_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5649) d->last_adv_data, d->last_adv_data_len, data, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5650) clear_pending_adv_report(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5651) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5652)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5653) static void hci_le_adv_report_evt(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5654) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5655) u8 num_reports = skb->data[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5656) void *ptr = &skb->data[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5657)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5658) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5659)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5660) while (num_reports--) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5661) struct hci_ev_le_advertising_info *ev = ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5662) s8 rssi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5663)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5664) if (ptr > (void *)skb_tail_pointer(skb) - sizeof(*ev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5665) bt_dev_err(hdev, "Malicious advertising data.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5666) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5667) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5668)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5669) if (ev->length <= HCI_MAX_AD_LENGTH &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5670) ev->data + ev->length <= skb_tail_pointer(skb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5671) rssi = ev->data[ev->length];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5672) process_adv_report(hdev, ev->evt_type, &ev->bdaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5673) ev->bdaddr_type, NULL, 0, rssi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5674) ev->data, ev->length, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5675) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5676) bt_dev_err(hdev, "Dropping invalid advertising data");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5677) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5678)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5679) ptr += sizeof(*ev) + ev->length + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5680) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5681)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5682) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5683) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5684)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5685) static u8 ext_evt_type_to_legacy(struct hci_dev *hdev, u16 evt_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5686) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5687) if (evt_type & LE_EXT_ADV_LEGACY_PDU) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5688) switch (evt_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5689) case LE_LEGACY_ADV_IND:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5690) return LE_ADV_IND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5691) case LE_LEGACY_ADV_DIRECT_IND:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5692) return LE_ADV_DIRECT_IND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5693) case LE_LEGACY_ADV_SCAN_IND:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5694) return LE_ADV_SCAN_IND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5695) case LE_LEGACY_NONCONN_IND:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5696) return LE_ADV_NONCONN_IND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5697) case LE_LEGACY_SCAN_RSP_ADV:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5698) case LE_LEGACY_SCAN_RSP_ADV_SCAN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5699) return LE_ADV_SCAN_RSP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5700) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5701)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5702) goto invalid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5703) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5704)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5705) if (evt_type & LE_EXT_ADV_CONN_IND) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5706) if (evt_type & LE_EXT_ADV_DIRECT_IND)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5707) return LE_ADV_DIRECT_IND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5708)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5709) return LE_ADV_IND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5710) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5711)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5712) if (evt_type & LE_EXT_ADV_SCAN_RSP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5713) return LE_ADV_SCAN_RSP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5714)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5715) if (evt_type & LE_EXT_ADV_SCAN_IND)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5716) return LE_ADV_SCAN_IND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5717)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5718) if (evt_type == LE_EXT_ADV_NON_CONN_IND ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5719) evt_type & LE_EXT_ADV_DIRECT_IND)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5720) return LE_ADV_NONCONN_IND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5721)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5722) invalid:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5723) bt_dev_err_ratelimited(hdev, "Unknown advertising packet type: 0x%02x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5724) evt_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5725)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5726) return LE_ADV_INVALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5727) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5728)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5729) static void hci_le_ext_adv_report_evt(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5730) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5731) u8 num_reports = skb->data[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5732) void *ptr = &skb->data[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5733)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5734) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5735)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5736) while (num_reports--) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5737) struct hci_ev_le_ext_adv_report *ev = ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5738) u8 legacy_evt_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5739) u16 evt_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5740)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5741) evt_type = __le16_to_cpu(ev->evt_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5742) legacy_evt_type = ext_evt_type_to_legacy(hdev, evt_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5743) if (legacy_evt_type != LE_ADV_INVALID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5744) process_adv_report(hdev, legacy_evt_type, &ev->bdaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5745) ev->bdaddr_type, NULL, 0, ev->rssi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5746) ev->data, ev->length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5747) !(evt_type & LE_EXT_ADV_LEGACY_PDU));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5748) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5749)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5750) ptr += sizeof(*ev) + ev->length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5751) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5752)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5753) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5754) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5755)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5756) static void hci_le_remote_feat_complete_evt(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5757) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5758) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5759) struct hci_ev_le_remote_feat_complete *ev = (void *)skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5760) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5761)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5762) BT_DBG("%s status 0x%2.2x", hdev->name, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5763)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5764) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5765)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5766) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5767) if (conn) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5768) if (!ev->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5769) memcpy(conn->features[0], ev->features, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5770)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5771) if (conn->state == BT_CONFIG) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5772) __u8 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5773)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5774) /* If the local controller supports slave-initiated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5775) * features exchange, but the remote controller does
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5776) * not, then it is possible that the error code 0x1a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5777) * for unsupported remote feature gets returned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5778) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5779) * In this specific case, allow the connection to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5780) * transition into connected state and mark it as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5781) * successful.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5782) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5783) if ((hdev->le_features[0] & HCI_LE_SLAVE_FEATURES) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5784) !conn->out && ev->status == 0x1a)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5785) status = 0x00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5786) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5787) status = ev->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5788)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5789) conn->state = BT_CONNECTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5790) hci_connect_cfm(conn, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5791) hci_conn_drop(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5792) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5793) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5794)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5795) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5796) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5797)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5798) static void hci_le_ltk_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5799) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5800) struct hci_ev_le_ltk_req *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5801) struct hci_cp_le_ltk_reply cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5802) struct hci_cp_le_ltk_neg_reply neg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5803) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5804) struct smp_ltk *ltk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5805)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5806) BT_DBG("%s handle 0x%4.4x", hdev->name, __le16_to_cpu(ev->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5807)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5808) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5809)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5810) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5811) if (conn == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5812) goto not_found;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5813)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5814) ltk = hci_find_ltk(hdev, &conn->dst, conn->dst_type, conn->role);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5815) if (!ltk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5816) goto not_found;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5817)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5818) if (smp_ltk_is_sc(ltk)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5819) /* With SC both EDiv and Rand are set to zero */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5820) if (ev->ediv || ev->rand)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5821) goto not_found;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5822) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5823) /* For non-SC keys check that EDiv and Rand match */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5824) if (ev->ediv != ltk->ediv || ev->rand != ltk->rand)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5825) goto not_found;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5826) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5827)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5828) memcpy(cp.ltk, ltk->val, ltk->enc_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5829) memset(cp.ltk + ltk->enc_size, 0, sizeof(cp.ltk) - ltk->enc_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5830) cp.handle = cpu_to_le16(conn->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5831)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5832) conn->pending_sec_level = smp_ltk_sec_level(ltk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5833)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5834) conn->enc_key_size = ltk->enc_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5835)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5836) hci_send_cmd(hdev, HCI_OP_LE_LTK_REPLY, sizeof(cp), &cp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5837)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5838) /* Ref. Bluetooth Core SPEC pages 1975 and 2004. STK is a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5839) * temporary key used to encrypt a connection following
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5840) * pairing. It is used during the Encrypted Session Setup to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5841) * distribute the keys. Later, security can be re-established
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5842) * using a distributed LTK.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5843) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5844) if (ltk->type == SMP_STK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5845) set_bit(HCI_CONN_STK_ENCRYPT, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5846) list_del_rcu(<k->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5847) kfree_rcu(ltk, rcu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5848) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5849) clear_bit(HCI_CONN_STK_ENCRYPT, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5850) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5851)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5852) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5853)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5854) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5855)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5856) not_found:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5857) neg.handle = ev->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5858) hci_send_cmd(hdev, HCI_OP_LE_LTK_NEG_REPLY, sizeof(neg), &neg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5859) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5860) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5861)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5862) static void send_conn_param_neg_reply(struct hci_dev *hdev, u16 handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5863) u8 reason)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5864) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5865) struct hci_cp_le_conn_param_req_neg_reply cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5866)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5867) cp.handle = cpu_to_le16(handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5868) cp.reason = reason;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5869)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5870) hci_send_cmd(hdev, HCI_OP_LE_CONN_PARAM_REQ_NEG_REPLY, sizeof(cp),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5871) &cp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5872) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5873)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5874) static void hci_le_remote_conn_param_req_evt(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5875) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5876) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5877) struct hci_ev_le_remote_conn_param_req *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5878) struct hci_cp_le_conn_param_req_reply cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5879) struct hci_conn *hcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5880) u16 handle, min, max, latency, timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5881)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5882) handle = le16_to_cpu(ev->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5883) min = le16_to_cpu(ev->interval_min);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5884) max = le16_to_cpu(ev->interval_max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5885) latency = le16_to_cpu(ev->latency);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5886) timeout = le16_to_cpu(ev->timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5887)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5888) hcon = hci_conn_hash_lookup_handle(hdev, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5889) if (!hcon || hcon->state != BT_CONNECTED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5890) return send_conn_param_neg_reply(hdev, handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5891) HCI_ERROR_UNKNOWN_CONN_ID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5892)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5893) if (hci_check_conn_params(min, max, latency, timeout))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5894) return send_conn_param_neg_reply(hdev, handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5895) HCI_ERROR_INVALID_LL_PARAMS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5896)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5897) if (hcon->role == HCI_ROLE_MASTER) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5898) struct hci_conn_params *params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5899) u8 store_hint;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5900)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5901) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5902)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5903) params = hci_conn_params_lookup(hdev, &hcon->dst,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5904) hcon->dst_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5905) if (params) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5906) params->conn_min_interval = min;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5907) params->conn_max_interval = max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5908) params->conn_latency = latency;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5909) params->supervision_timeout = timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5910) store_hint = 0x01;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5911) } else{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5912) store_hint = 0x00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5913) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5914)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5915) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5916)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5917) mgmt_new_conn_param(hdev, &hcon->dst, hcon->dst_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5918) store_hint, min, max, latency, timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5919) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5920)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5921) cp.handle = ev->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5922) cp.interval_min = ev->interval_min;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5923) cp.interval_max = ev->interval_max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5924) cp.latency = ev->latency;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5925) cp.timeout = ev->timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5926) cp.min_ce_len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5927) cp.max_ce_len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5928)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5929) hci_send_cmd(hdev, HCI_OP_LE_CONN_PARAM_REQ_REPLY, sizeof(cp), &cp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5930) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5931)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5932) static void hci_le_direct_adv_report_evt(struct hci_dev *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5933) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5934) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5935) u8 num_reports = skb->data[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5936) struct hci_ev_le_direct_adv_info *ev = (void *)&skb->data[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5937)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5938) if (!num_reports || skb->len < num_reports * sizeof(*ev) + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5939) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5940)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5941) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5942)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5943) for (; num_reports; num_reports--, ev++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5944) process_adv_report(hdev, ev->evt_type, &ev->bdaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5945) ev->bdaddr_type, &ev->direct_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5946) ev->direct_addr_type, ev->rssi, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5947) false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5948)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5949) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5950) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5951)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5952) static void hci_le_phy_update_evt(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5953) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5954) struct hci_ev_le_phy_update_complete *ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5955) struct hci_conn *conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5956)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5957) BT_DBG("%s status 0x%2.2x", hdev->name, ev->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5958)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5959) if (ev->status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5960) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5961)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5962) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5963)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5964) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5965) if (!conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5966) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5967)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5968) conn->le_tx_phy = ev->tx_phy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5969) conn->le_rx_phy = ev->rx_phy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5970)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5971) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5972) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5973) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5974)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5975) static void hci_le_meta_evt(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5976) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5977) struct hci_ev_le_meta *le_ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5978)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5979) skb_pull(skb, sizeof(*le_ev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5980)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5981) switch (le_ev->subevent) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5982) case HCI_EV_LE_CONN_COMPLETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5983) hci_le_conn_complete_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5984) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5985)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5986) case HCI_EV_LE_CONN_UPDATE_COMPLETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5987) hci_le_conn_update_complete_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5988) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5989)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5990) case HCI_EV_LE_ADVERTISING_REPORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5991) hci_le_adv_report_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5992) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5993)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5994) case HCI_EV_LE_REMOTE_FEAT_COMPLETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5995) hci_le_remote_feat_complete_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5996) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5997)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5998) case HCI_EV_LE_LTK_REQ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5999) hci_le_ltk_request_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6000) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6001)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6002) case HCI_EV_LE_REMOTE_CONN_PARAM_REQ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6003) hci_le_remote_conn_param_req_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6004) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6005)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6006) case HCI_EV_LE_DIRECT_ADV_REPORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6007) hci_le_direct_adv_report_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6008) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6009)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6010) case HCI_EV_LE_PHY_UPDATE_COMPLETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6011) hci_le_phy_update_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6012) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6013)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6014) case HCI_EV_LE_EXT_ADV_REPORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6015) hci_le_ext_adv_report_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6016) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6017)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6018) case HCI_EV_LE_ENHANCED_CONN_COMPLETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6019) hci_le_enh_conn_complete_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6020) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6021)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6022) case HCI_EV_LE_EXT_ADV_SET_TERM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6023) hci_le_ext_adv_term_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6024) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6025)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6026) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6027) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6028) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6029) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6030)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6031) static bool hci_get_cmd_complete(struct hci_dev *hdev, u16 opcode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6032) u8 event, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6033) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6034) struct hci_ev_cmd_complete *ev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6035) struct hci_event_hdr *hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6036)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6037) if (!skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6038) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6039)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6040) if (skb->len < sizeof(*hdr)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6041) bt_dev_err(hdev, "too short HCI event");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6042) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6043) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6044)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6045) hdr = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6046) skb_pull(skb, HCI_EVENT_HDR_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6047)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6048) if (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6049) if (hdr->evt != event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6050) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6051) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6052) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6053)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6054) /* Check if request ended in Command Status - no way to retreive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6055) * any extra parameters in this case.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6056) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6057) if (hdr->evt == HCI_EV_CMD_STATUS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6058) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6059)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6060) if (hdr->evt != HCI_EV_CMD_COMPLETE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6061) bt_dev_err(hdev, "last event is not cmd complete (0x%2.2x)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6062) hdr->evt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6063) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6064) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6065)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6066) if (skb->len < sizeof(*ev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6067) bt_dev_err(hdev, "too short cmd_complete event");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6068) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6069) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6070)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6071) ev = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6072) skb_pull(skb, sizeof(*ev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6073)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6074) if (opcode != __le16_to_cpu(ev->opcode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6075) BT_DBG("opcode doesn't match (0x%2.2x != 0x%2.2x)", opcode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6076) __le16_to_cpu(ev->opcode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6077) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6078) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6079)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6080) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6081) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6082)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6083) static void hci_store_wake_reason(struct hci_dev *hdev, u8 event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6084) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6085) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6086) struct hci_ev_le_advertising_info *adv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6087) struct hci_ev_le_direct_adv_info *direct_adv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6088) struct hci_ev_le_ext_adv_report *ext_adv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6089) const struct hci_ev_conn_complete *conn_complete = (void *)skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6090) const struct hci_ev_conn_request *conn_request = (void *)skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6091)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6092) hci_dev_lock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6093)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6094) /* If we are currently suspended and this is the first BT event seen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6095) * save the wake reason associated with the event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6096) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6097) if (!hdev->suspended || hdev->wake_reason)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6098) goto unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6099)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6100) /* Default to remote wake. Values for wake_reason are documented in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6101) * Bluez mgmt api docs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6102) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6103) hdev->wake_reason = MGMT_WAKE_REASON_REMOTE_WAKE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6105) /* Once configured for remote wakeup, we should only wake up for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6106) * reconnections. It's useful to see which device is waking us up so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6107) * keep track of the bdaddr of the connection event that woke us up.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6108) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6109) if (event == HCI_EV_CONN_REQUEST) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6110) bacpy(&hdev->wake_addr, &conn_complete->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6111) hdev->wake_addr_type = BDADDR_BREDR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6112) } else if (event == HCI_EV_CONN_COMPLETE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6113) bacpy(&hdev->wake_addr, &conn_request->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6114) hdev->wake_addr_type = BDADDR_BREDR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6115) } else if (event == HCI_EV_LE_META) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6116) struct hci_ev_le_meta *le_ev = (void *)skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6117) u8 subevent = le_ev->subevent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6118) u8 *ptr = &skb->data[sizeof(*le_ev)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6119) u8 num_reports = *ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6121) if ((subevent == HCI_EV_LE_ADVERTISING_REPORT ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6122) subevent == HCI_EV_LE_DIRECT_ADV_REPORT ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6123) subevent == HCI_EV_LE_EXT_ADV_REPORT) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6124) num_reports) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6125) adv = (void *)(ptr + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6126) direct_adv = (void *)(ptr + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6127) ext_adv = (void *)(ptr + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6129) switch (subevent) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6130) case HCI_EV_LE_ADVERTISING_REPORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6131) bacpy(&hdev->wake_addr, &adv->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6132) hdev->wake_addr_type = adv->bdaddr_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6133) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6134) case HCI_EV_LE_DIRECT_ADV_REPORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6135) bacpy(&hdev->wake_addr, &direct_adv->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6136) hdev->wake_addr_type = direct_adv->bdaddr_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6137) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6138) case HCI_EV_LE_EXT_ADV_REPORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6139) bacpy(&hdev->wake_addr, &ext_adv->bdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6140) hdev->wake_addr_type = ext_adv->bdaddr_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6141) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6142) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6143) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6144) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6145) hdev->wake_reason = MGMT_WAKE_REASON_UNEXPECTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6148) unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6149) hci_dev_unlock(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6152) void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6153) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6154) struct hci_event_hdr *hdr = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6155) hci_req_complete_t req_complete = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6156) hci_req_complete_skb_t req_complete_skb = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6157) struct sk_buff *orig_skb = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6158) u8 status = 0, event = hdr->evt, req_evt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6159) u16 opcode = HCI_OP_NOP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6161) if (!event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6162) bt_dev_warn(hdev, "Received unexpected HCI Event 00000000");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6163) goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6164) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6166) if (hdev->sent_cmd && bt_cb(hdev->sent_cmd)->hci.req_event == event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6167) struct hci_command_hdr *cmd_hdr = (void *) hdev->sent_cmd->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6168) opcode = __le16_to_cpu(cmd_hdr->opcode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6169) hci_req_cmd_complete(hdev, opcode, status, &req_complete,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6170) &req_complete_skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6171) req_evt = event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6172) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6174) /* If it looks like we might end up having to call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6175) * req_complete_skb, store a pristine copy of the skb since the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6176) * various handlers may modify the original one through
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6177) * skb_pull() calls, etc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6178) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6179) if (req_complete_skb || event == HCI_EV_CMD_STATUS ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6180) event == HCI_EV_CMD_COMPLETE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6181) orig_skb = skb_clone(skb, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6183) skb_pull(skb, HCI_EVENT_HDR_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6185) /* Store wake reason if we're suspended */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6186) hci_store_wake_reason(hdev, event, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6188) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6189) case HCI_EV_INQUIRY_COMPLETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6190) hci_inquiry_complete_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6191) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6193) case HCI_EV_INQUIRY_RESULT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6194) hci_inquiry_result_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6195) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6197) case HCI_EV_CONN_COMPLETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6198) hci_conn_complete_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6199) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6201) case HCI_EV_CONN_REQUEST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6202) hci_conn_request_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6203) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6205) case HCI_EV_DISCONN_COMPLETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6206) hci_disconn_complete_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6207) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6209) case HCI_EV_AUTH_COMPLETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6210) hci_auth_complete_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6211) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6213) case HCI_EV_REMOTE_NAME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6214) hci_remote_name_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6215) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6217) case HCI_EV_ENCRYPT_CHANGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6218) hci_encrypt_change_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6219) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6221) case HCI_EV_CHANGE_LINK_KEY_COMPLETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6222) hci_change_link_key_complete_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6223) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6225) case HCI_EV_REMOTE_FEATURES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6226) hci_remote_features_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6227) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6229) case HCI_EV_CMD_COMPLETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6230) hci_cmd_complete_evt(hdev, skb, &opcode, &status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6231) &req_complete, &req_complete_skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6232) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6234) case HCI_EV_CMD_STATUS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6235) hci_cmd_status_evt(hdev, skb, &opcode, &status, &req_complete,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6236) &req_complete_skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6237) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6239) case HCI_EV_HARDWARE_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6240) hci_hardware_error_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6241) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6243) case HCI_EV_ROLE_CHANGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6244) hci_role_change_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6245) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6247) case HCI_EV_NUM_COMP_PKTS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6248) hci_num_comp_pkts_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6249) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6251) case HCI_EV_MODE_CHANGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6252) hci_mode_change_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6253) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6255) case HCI_EV_PIN_CODE_REQ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6256) hci_pin_code_request_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6257) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6259) case HCI_EV_LINK_KEY_REQ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6260) hci_link_key_request_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6261) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6263) case HCI_EV_LINK_KEY_NOTIFY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6264) hci_link_key_notify_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6265) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6267) case HCI_EV_CLOCK_OFFSET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6268) hci_clock_offset_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6269) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6271) case HCI_EV_PKT_TYPE_CHANGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6272) hci_pkt_type_change_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6273) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6275) case HCI_EV_PSCAN_REP_MODE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6276) hci_pscan_rep_mode_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6277) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6279) case HCI_EV_INQUIRY_RESULT_WITH_RSSI:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6280) hci_inquiry_result_with_rssi_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6281) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6283) case HCI_EV_REMOTE_EXT_FEATURES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6284) hci_remote_ext_features_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6285) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6287) case HCI_EV_SYNC_CONN_COMPLETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6288) hci_sync_conn_complete_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6289) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6291) case HCI_EV_EXTENDED_INQUIRY_RESULT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6292) hci_extended_inquiry_result_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6293) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6295) case HCI_EV_KEY_REFRESH_COMPLETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6296) hci_key_refresh_complete_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6297) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6299) case HCI_EV_IO_CAPA_REQUEST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6300) hci_io_capa_request_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6301) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6302)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6303) case HCI_EV_IO_CAPA_REPLY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6304) hci_io_capa_reply_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6305) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6307) case HCI_EV_USER_CONFIRM_REQUEST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6308) hci_user_confirm_request_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6309) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6311) case HCI_EV_USER_PASSKEY_REQUEST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6312) hci_user_passkey_request_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6313) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6315) case HCI_EV_USER_PASSKEY_NOTIFY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6316) hci_user_passkey_notify_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6317) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6318)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6319) case HCI_EV_KEYPRESS_NOTIFY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6320) hci_keypress_notify_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6321) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6322)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6323) case HCI_EV_SIMPLE_PAIR_COMPLETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6324) hci_simple_pair_complete_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6325) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6327) case HCI_EV_REMOTE_HOST_FEATURES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6328) hci_remote_host_features_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6329) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6331) case HCI_EV_LE_META:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6332) hci_le_meta_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6333) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6335) case HCI_EV_REMOTE_OOB_DATA_REQUEST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6336) hci_remote_oob_data_request_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6337) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6339) #if IS_ENABLED(CONFIG_BT_HS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6340) case HCI_EV_CHANNEL_SELECTED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6341) hci_chan_selected_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6342) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6343)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6344) case HCI_EV_PHY_LINK_COMPLETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6345) hci_phy_link_complete_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6346) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6348) case HCI_EV_LOGICAL_LINK_COMPLETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6349) hci_loglink_complete_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6350) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6352) case HCI_EV_DISCONN_LOGICAL_LINK_COMPLETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6353) hci_disconn_loglink_complete_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6354) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6355)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6356) case HCI_EV_DISCONN_PHY_LINK_COMPLETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6357) hci_disconn_phylink_complete_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6358) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6359) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6360)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6361) case HCI_EV_NUM_COMP_BLOCKS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6362) hci_num_comp_blocks_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6363) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6364)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6365) case HCI_EV_VENDOR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6366) msft_vendor_evt(hdev, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6367) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6368)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6369) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6370) BT_DBG("%s event 0x%2.2x", hdev->name, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6371) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6372) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6373)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6374) if (req_complete) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6375) req_complete(hdev, status, opcode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6376) } else if (req_complete_skb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6377) if (!hci_get_cmd_complete(hdev, opcode, req_evt, orig_skb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6378) kfree_skb(orig_skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6379) orig_skb = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6380) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6381) req_complete_skb(hdev, status, opcode, orig_skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6382) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6384) done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6385) kfree_skb(orig_skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6386) kfree_skb(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6387) hdev->stat.evt_rx++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6388) }