Merge tag 'rproc-v5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/andersson...
[linux-2.6-microblaze.git] / net / bluetooth / hci_event.c
index d739504..1c30182 100644 (file)
@@ -236,7 +236,7 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb)
 
        hdev->ssp_debug_mode = 0;
 
-       hci_bdaddr_list_clear(&hdev->le_white_list);
+       hci_bdaddr_list_clear(&hdev->le_accept_list);
        hci_bdaddr_list_clear(&hdev->le_resolv_list);
 }
 
@@ -1492,21 +1492,21 @@ static void hci_cc_le_read_num_adv_sets(struct hci_dev *hdev,
        hdev->le_num_of_adv_sets = rp->num_of_sets;
 }
 
-static void hci_cc_le_read_white_list_size(struct hci_dev *hdev,
-                                          struct sk_buff *skb)
+static void hci_cc_le_read_accept_list_size(struct hci_dev *hdev,
+                                           struct sk_buff *skb)
 {
-       struct hci_rp_le_read_white_list_size *rp = (void *) skb->data;
+       struct hci_rp_le_read_accept_list_size *rp = (void *)skb->data;
 
        BT_DBG("%s status 0x%2.2x size %u", hdev->name, rp->status, rp->size);
 
        if (rp->status)
                return;
 
-       hdev->le_white_list_size = rp->size;
+       hdev->le_accept_list_size = rp->size;
 }
 
-static void hci_cc_le_clear_white_list(struct hci_dev *hdev,
-                                      struct sk_buff *skb)
+static void hci_cc_le_clear_accept_list(struct hci_dev *hdev,
+                                       struct sk_buff *skb)
 {
        __u8 status = *((__u8 *) skb->data);
 
@@ -1515,13 +1515,13 @@ static void hci_cc_le_clear_white_list(struct hci_dev *hdev,
        if (status)
                return;
 
-       hci_bdaddr_list_clear(&hdev->le_white_list);
+       hci_bdaddr_list_clear(&hdev->le_accept_list);
 }
 
-static void hci_cc_le_add_to_white_list(struct hci_dev *hdev,
-                                       struct sk_buff *skb)
+static void hci_cc_le_add_to_accept_list(struct hci_dev *hdev,
+                                        struct sk_buff *skb)
 {
-       struct hci_cp_le_add_to_white_list *sent;
+       struct hci_cp_le_add_to_accept_list *sent;
        __u8 status = *((__u8 *) skb->data);
 
        BT_DBG("%s status 0x%2.2x", hdev->name, status);
@@ -1529,18 +1529,18 @@ static void hci_cc_le_add_to_white_list(struct hci_dev *hdev,
        if (status)
                return;
 
-       sent = hci_sent_cmd_data(hdev, HCI_OP_LE_ADD_TO_WHITE_LIST);
+       sent = hci_sent_cmd_data(hdev, HCI_OP_LE_ADD_TO_ACCEPT_LIST);
        if (!sent)
                return;
 
-       hci_bdaddr_list_add(&hdev->le_white_list, &sent->bdaddr,
-                          sent->bdaddr_type);
+       hci_bdaddr_list_add(&hdev->le_accept_list, &sent->bdaddr,
+                           sent->bdaddr_type);
 }
 
-static void hci_cc_le_del_from_white_list(struct hci_dev *hdev,
-                                         struct sk_buff *skb)
+static void hci_cc_le_del_from_accept_list(struct hci_dev *hdev,
+                                          struct sk_buff *skb)
 {
-       struct hci_cp_le_del_from_white_list *sent;
+       struct hci_cp_le_del_from_accept_list *sent;
        __u8 status = *((__u8 *) skb->data);
 
        BT_DBG("%s status 0x%2.2x", hdev->name, status);
@@ -1548,11 +1548,11 @@ static void hci_cc_le_del_from_white_list(struct hci_dev *hdev,
        if (status)
                return;
 
-       sent = hci_sent_cmd_data(hdev, HCI_OP_LE_DEL_FROM_WHITE_LIST);
+       sent = hci_sent_cmd_data(hdev, HCI_OP_LE_DEL_FROM_ACCEPT_LIST);
        if (!sent)
                return;
 
-       hci_bdaddr_list_del(&hdev->le_white_list, &sent->bdaddr,
+       hci_bdaddr_list_del(&hdev->le_accept_list, &sent->bdaddr,
                            sent->bdaddr_type);
 }
 
@@ -2367,7 +2367,7 @@ static void cs_le_create_conn(struct hci_dev *hdev, bdaddr_t *peer_addr,
        /* We don't want the connection attempt to stick around
         * indefinitely since LE doesn't have a page timeout concept
         * like BR/EDR. Set a timer for any connection that doesn't use
-        * the white list for connecting.
+        * the accept list for connecting.
         */
        if (filter_policy == HCI_LE_USE_PEER_ADDR)
                queue_delayed_work(conn->hdev->workqueue,
@@ -2623,7 +2623,7 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
                 * only used during suspend.
                 */
                if (ev->link_type == ACL_LINK &&
-                   hci_bdaddr_list_lookup_with_flags(&hdev->whitelist,
+                   hci_bdaddr_list_lookup_with_flags(&hdev->accept_list,
                                                      &ev->bdaddr,
                                                      BDADDR_BREDR)) {
                        conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr,
@@ -2745,19 +2745,19 @@ static void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
                return;
        }
 
-       if (hci_bdaddr_list_lookup(&hdev->blacklist, &ev->bdaddr,
+       if (hci_bdaddr_list_lookup(&hdev->reject_list, &ev->bdaddr,
                                   BDADDR_BREDR)) {
                hci_reject_conn(hdev, &ev->bdaddr);
                return;
        }
 
-       /* Require HCI_CONNECTABLE or a whitelist entry to accept the
+       /* Require HCI_CONNECTABLE or an accept list entry to accept the
         * connection. These features are only touched through mgmt so
         * only do the checks if HCI_MGMT is set.
         */
        if (hci_dev_test_flag(hdev, HCI_MGMT) &&
            !hci_dev_test_flag(hdev, HCI_CONNECTABLE) &&
-           !hci_bdaddr_list_lookup_with_flags(&hdev->whitelist, &ev->bdaddr,
+           !hci_bdaddr_list_lookup_with_flags(&hdev->accept_list, &ev->bdaddr,
                                               BDADDR_BREDR)) {
                hci_reject_conn(hdev, &ev->bdaddr);
                return;
@@ -2795,9 +2795,9 @@ static void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
                bacpy(&cp.bdaddr, &ev->bdaddr);
 
                if (lmp_rswitch_capable(hdev) && (mask & HCI_LM_MASTER))
-                       cp.role = 0x00; /* Become master */
+                       cp.role = 0x00; /* Become central */
                else
-                       cp.role = 0x01; /* Remain slave */
+                       cp.role = 0x01; /* Remain peripheral */
 
                hci_send_cmd(hdev, HCI_OP_ACCEPT_CONN_REQ, sizeof(cp), &cp);
        } else if (!(flags & HCI_PROTO_DEFER)) {
@@ -3538,20 +3538,20 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb,
                hci_cc_le_set_scan_enable(hdev, skb);
                break;
 
-       case HCI_OP_LE_READ_WHITE_LIST_SIZE:
-               hci_cc_le_read_white_list_size(hdev, skb);
+       case HCI_OP_LE_READ_ACCEPT_LIST_SIZE:
+               hci_cc_le_read_accept_list_size(hdev, skb);
                break;
 
-       case HCI_OP_LE_CLEAR_WHITE_LIST:
-               hci_cc_le_clear_white_list(hdev, skb);
+       case HCI_OP_LE_CLEAR_ACCEPT_LIST:
+               hci_cc_le_clear_accept_list(hdev, skb);
                break;
 
-       case HCI_OP_LE_ADD_TO_WHITE_LIST:
-               hci_cc_le_add_to_white_list(hdev, skb);
+       case HCI_OP_LE_ADD_TO_ACCEPT_LIST:
+               hci_cc_le_add_to_accept_list(hdev, skb);
                break;
 
-       case HCI_OP_LE_DEL_FROM_WHITE_LIST:
-               hci_cc_le_del_from_white_list(hdev, skb);
+       case HCI_OP_LE_DEL_FROM_ACCEPT_LIST:
+               hci_cc_le_del_from_accept_list(hdev, skb);
                break;
 
        case HCI_OP_LE_READ_SUPPORTED_STATES:
@@ -5131,8 +5131,8 @@ static void le_conn_complete_evt(struct hci_dev *hdev, u8 status,
                conn->dst_type = bdaddr_type;
 
                /* If we didn't have a hci_conn object previously
-                * but we're in master role this must be something
-                * initiated using a white list. Since white list based
+                * but we're in central role this must be something
+                * initiated using an accept list. Since accept list based
                 * connections are not "first class citizens" we don't
                 * have full tracking of them. Therefore, we go ahead
                 * with a "best effort" approach of determining the
@@ -5196,6 +5196,23 @@ static void le_conn_complete_evt(struct hci_dev *hdev, u8 status,
                conn->dst_type = irk->addr_type;
        }
 
+       /* When using controller based address resolution, then the new
+        * address types 0x02 and 0x03 are used. These types need to be
+        * converted back into either public address or random address type
+        */
+       if (use_ll_privacy(hdev) &&
+           hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY) &&
+           hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) {
+               switch (conn->dst_type) {
+               case ADDR_LE_DEV_PUBLIC_RESOLVED:
+                       conn->dst_type = ADDR_LE_DEV_PUBLIC;
+                       break;
+               case ADDR_LE_DEV_RANDOM_RESOLVED:
+                       conn->dst_type = ADDR_LE_DEV_RANDOM;
+                       break;
+               }
+       }
+
        if (status) {
                hci_le_conn_failed(conn, status);
                goto unlock;
@@ -5207,7 +5224,7 @@ static void le_conn_complete_evt(struct hci_dev *hdev, u8 status,
                addr_type = BDADDR_LE_RANDOM;
 
        /* Drop the connection if the device is blocked */
-       if (hci_bdaddr_list_lookup(&hdev->blacklist, &conn->dst, addr_type)) {
+       if (hci_bdaddr_list_lookup(&hdev->reject_list, &conn->dst, addr_type)) {
                hci_conn_drop(conn);
                goto unlock;
        }
@@ -5226,17 +5243,17 @@ static void le_conn_complete_evt(struct hci_dev *hdev, u8 status,
        hci_debugfs_create_conn(conn);
        hci_conn_add_sysfs(conn);
 
-       /* The remote features procedure is defined for master
+       /* The remote features procedure is defined for central
         * role only. So only in case of an initiated connection
         * request the remote features.
         *
-        * If the local controller supports slave-initiated features
-        * exchange, then requesting the remote features in slave
+        * If the local controller supports peripheral-initiated features
+        * exchange, then requesting the remote features in peripheral
         * role is possible. Otherwise just transition into the
         * connected state without requesting the remote features.
         */
        if (conn->out ||
-           (hdev->le_features[0] & HCI_LE_SLAVE_FEATURES)) {
+           (hdev->le_features[0] & HCI_LE_PERIPHERAL_FEATURES)) {
                struct hci_cp_le_read_remote_features cp;
 
                cp.handle = __cpu_to_le16(conn->handle);
@@ -5305,8 +5322,19 @@ static void hci_le_ext_adv_term_evt(struct hci_dev *hdev, struct sk_buff *skb)
 
        BT_DBG("%s status 0x%2.2x", hdev->name, ev->status);
 
-       if (ev->status)
+       if (ev->status) {
+               struct adv_info *adv;
+
+               adv = hci_find_adv_instance(hdev, ev->handle);
+               if (!adv)
+                       return;
+
+               /* Remove advertising as it has been terminated */
+               hci_remove_adv_instance(hdev, ev->handle);
+               mgmt_advertising_removed(NULL, hdev, ev->handle);
+
                return;
+       }
 
        conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->conn_handle));
        if (conn) {
@@ -5363,13 +5391,13 @@ static struct hci_conn *check_pending_le_conn(struct hci_dev *hdev,
                return NULL;
 
        /* Ignore if the device is blocked */
-       if (hci_bdaddr_list_lookup(&hdev->blacklist, addr, addr_type))
+       if (hci_bdaddr_list_lookup(&hdev->reject_list, addr, addr_type))
                return NULL;
 
        /* Most controller will fail if we try to create new connections
-        * while we have an existing one in slave role.
+        * while we have an existing one in peripheral role.
         */
-       if (hdev->conn_hash.le_num_slave > 0 &&
+       if (hdev->conn_hash.le_num_peripheral > 0 &&
            (!test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks) ||
             !(hdev->le_states[3] & 0x10)))
                return NULL;
@@ -5387,7 +5415,7 @@ static struct hci_conn *check_pending_le_conn(struct hci_dev *hdev,
                case HCI_AUTO_CONN_DIRECT:
                        /* Only devices advertising with ADV_DIRECT_IND are
                         * triggering a connection attempt. This is allowing
-                        * incoming connections from slave devices.
+                        * incoming connections from peripheral devices.
                         */
                        if (adv_type != LE_ADV_DIRECT_IND)
                                return NULL;
@@ -5395,8 +5423,8 @@ static struct hci_conn *check_pending_le_conn(struct hci_dev *hdev,
                case HCI_AUTO_CONN_ALWAYS:
                        /* Devices advertising with ADV_IND or ADV_DIRECT_IND
                         * are triggering a connection attempt. This means
-                        * that incoming connections from slave device are
-                        * accepted and also outgoing connections to slave
+                        * that incoming connections from peripheral device are
+                        * accepted and also outgoing connections to peripheral
                         * devices are established when found.
                         */
                        break;
@@ -5450,7 +5478,7 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
        struct hci_conn *conn;
        bool match;
        u32 flags;
-       u8 *ptr, real_len;
+       u8 *ptr;
 
        switch (type) {
        case LE_ADV_IND:
@@ -5481,14 +5509,10 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
                        break;
        }
 
-       real_len = ptr - data;
-
-       /* Adjust for actual length */
-       if (len != real_len) {
-               bt_dev_err_ratelimited(hdev, "advertising data len corrected %u -> %u",
-                                      len, real_len);
-               len = real_len;
-       }
+       /* Adjust for actual length. This handles the case when remote
+        * device is advertising with incorrect data length.
+        */
+       len = ptr - data;
 
        /* If the direct address is present, then this report is from
         * a LE Direct Advertising Report event. In that case it is
@@ -5761,7 +5785,7 @@ static void hci_le_remote_feat_complete_evt(struct hci_dev *hdev,
                if (conn->state == BT_CONFIG) {
                        __u8 status;
 
-                       /* If the local controller supports slave-initiated
+                       /* If the local controller supports peripheral-initiated
                         * features exchange, but the remote controller does
                         * not, then it is possible that the error code 0x1a
                         * for unsupported remote feature gets returned.
@@ -5770,8 +5794,8 @@ static void hci_le_remote_feat_complete_evt(struct hci_dev *hdev,
                         * transition into connected state and mark it as
                         * successful.
                         */
-                       if ((hdev->le_features[0] & HCI_LE_SLAVE_FEATURES) &&
-                           !conn->out && ev->status == 0x1a)
+                       if (!conn->out && ev->status == 0x1a &&
+                           (hdev->le_features[0] & HCI_LE_PERIPHERAL_FEATURES))
                                status = 0x00;
                        else
                                status = ev->status;