Bluetooth: Read LE Max data length command
[platform/kernel/linux-rpi.git] / include / net / bluetooth / hci_core.h
index c33348b..2d17fc7 100644 (file)
@@ -189,6 +189,7 @@ struct blocked_key {
 struct smp_csrk {
        bdaddr_t bdaddr;
        u8 bdaddr_type;
+       u8 link_type;
        u8 type;
        u8 val[16];
 };
@@ -198,6 +199,7 @@ struct smp_ltk {
        struct rcu_head rcu;
        bdaddr_t bdaddr;
        u8 bdaddr_type;
+       u8 link_type;
        u8 authenticated;
        u8 type;
        u8 enc_size;
@@ -212,6 +214,7 @@ struct smp_irk {
        bdaddr_t rpa;
        bdaddr_t bdaddr;
        u8 addr_type;
+       u8 link_type;
        u8 val[16];
 };
 
@@ -219,6 +222,8 @@ struct link_key {
        struct list_head list;
        struct rcu_head rcu;
        bdaddr_t bdaddr;
+       u8 bdaddr_type;
+       u8 link_type;
        u8 type;
        u8 val[HCI_LINK_KEY_SIZE];
        u8 pin_len;
@@ -346,10 +351,16 @@ struct amp_assoc {
 
 #define HCI_MAX_PAGES  3
 
+#ifdef TIZEN_BT
+#define HCI_MAX_EIR_MANUFACTURER_DATA_LENGTH   100
+#endif
+
 struct hci_dev {
        struct list_head list;
        struct mutex    lock;
 
+       struct ida      unset_handle_ida;
+
        const char      *name;
        unsigned long   flags;
        __u16           id;
@@ -565,6 +576,9 @@ struct hci_dev {
        u8                      wake_reason;
        bdaddr_t                wake_addr;
        u8                      wake_addr_type;
+#ifdef TIZEN_BT
+       struct discovery_state  le_discovery;
+#endif
 
        struct hci_conn_hash    conn_hash;
 
@@ -652,6 +666,13 @@ struct hci_dev {
        bool                    aosp_quality_report;
 #endif
 
+#ifdef TIZEN_BT
+       __u8                    adv_filter_policy;
+       __u8                    adv_type;
+       __u8                    manufacturer_len;
+       __u8                    manufacturer_data[HCI_MAX_EIR_MANUFACTURER_DATA_LENGTH];
+#endif
+
        int (*open)(struct hci_dev *hdev);
        int (*close)(struct hci_dev *hdev);
        int (*flush)(struct hci_dev *hdev);
@@ -769,6 +790,11 @@ struct hci_conn {
        void            *iso_data;
        struct amp_mgr  *amp_mgr;
 
+#ifdef TIZEN_BT
+       bool            rssi_monitored;
+       __u8            sco_role;
+       __u16           voice_setting;
+#endif
        struct list_head link_list;
        struct hci_conn *parent;
        struct hci_link *link;
@@ -948,9 +974,12 @@ u32 hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data,
 void hci_inquiry_cache_flush(struct hci_dev *hdev);
 
 /* ----- HCI Connections ----- */
+#ifdef TIZEN_BT
+#define LINK_SUPERVISION_TIMEOUT       0x1F40   /* n * 0.625 = 5 seconds */
+#endif /* TIZEN_BT */
+
 enum {
        HCI_CONN_AUTH_PEND,
-       HCI_CONN_REAUTH_PEND,
        HCI_CONN_ENCRYPT_PEND,
        HCI_CONN_RSWITCH_PEND,
        HCI_CONN_MODE_CHANGE_PEND,
@@ -1225,11 +1254,11 @@ static inline struct hci_conn *hci_conn_hash_lookup_cis(struct hci_dev *hdev,
                        continue;
 
                /* Match CIG ID if set */
-               if (cig != BT_ISO_QOS_CIG_UNSET && cig != c->iso_qos.ucast.cig)
+               if (cig != c->iso_qos.ucast.cig)
                        continue;
 
                /* Match CIS ID if set */
-               if (id != BT_ISO_QOS_CIS_UNSET && id != c->iso_qos.ucast.cis)
+               if (id != c->iso_qos.ucast.cis)
                        continue;
 
                /* Match destination address if set */
@@ -1314,7 +1343,7 @@ static inline struct hci_conn *hci_conn_hash_lookup_big_any_dst(struct hci_dev *
 }
 
 static inline struct hci_conn *
-hci_conn_hash_lookup_pa_sync(struct hci_dev *hdev, __u8 big)
+hci_conn_hash_lookup_pa_sync_big_handle(struct hci_dev *hdev, __u8 big)
 {
        struct hci_conn_hash *h = &hdev->conn_hash;
        struct hci_conn  *c;
@@ -1336,6 +1365,29 @@ hci_conn_hash_lookup_pa_sync(struct hci_dev *hdev, __u8 big)
        return NULL;
 }
 
+static inline struct hci_conn *
+hci_conn_hash_lookup_pa_sync_handle(struct hci_dev *hdev, __u16 sync_handle)
+{
+       struct hci_conn_hash *h = &hdev->conn_hash;
+       struct hci_conn  *c;
+
+       rcu_read_lock();
+
+       list_for_each_entry_rcu(c, &h->list, list) {
+               if (c->type != ISO_LINK ||
+                       !test_bit(HCI_CONN_PA_SYNC, &c->flags))
+                       continue;
+
+               if (c->sync_handle == sync_handle) {
+                       rcu_read_unlock();
+                       return c;
+               }
+       }
+       rcu_read_unlock();
+
+       return NULL;
+}
+
 static inline struct hci_conn *hci_conn_hash_lookup_state(struct hci_dev *hdev,
                                                        __u8 type, __u16 state)
 {
@@ -1418,6 +1470,91 @@ static inline bool hci_is_le_conn_scanning(struct hci_dev *hdev)
        return false;
 }
 
+#ifdef TIZEN_BT
+static inline bool hci_conn_rssi_state_set(struct hci_dev *hdev,
+                                       __u8 type, bdaddr_t *ba, bool value)
+{
+       struct hci_conn_hash *h = &hdev->conn_hash;
+       struct hci_conn  *c;
+       __u8 conn_type;
+
+       if (type == 0x01)
+               conn_type = LE_LINK;
+       else
+               conn_type = ACL_LINK;
+
+       rcu_read_lock();
+
+       list_for_each_entry_rcu(c, &h->list, list) {
+               if (c->type == conn_type && !bacmp(&c->dst, ba)) {
+                       c->rssi_monitored = value;
+                       rcu_read_unlock();
+                       return true;
+               }
+       }
+
+       rcu_read_unlock();
+       return false;
+}
+
+static inline void hci_conn_rssi_unset_all(struct hci_dev *hdev,
+                                       __u8 type)
+{
+       struct hci_conn_hash *h = &hdev->conn_hash;
+       struct hci_conn  *c;
+       __u8 conn_type;
+
+       if (type == 0x01)
+               conn_type = LE_LINK;
+       else
+               conn_type = ACL_LINK;
+
+       rcu_read_lock();
+       list_for_each_entry_rcu(c, &h->list, list) {
+               if (c->type == conn_type)
+                       c->rssi_monitored = false;
+}
+       rcu_read_unlock();
+}
+
+static inline int hci_conn_hash_lookup_rssi_count(struct hci_dev *hdev)
+{
+       struct hci_conn_hash *h = &hdev->conn_hash;
+       struct hci_conn  *c;
+       int count = 0;
+
+       rcu_read_lock();
+       list_for_each_entry_rcu(c, &h->list, list) {
+               if (c->rssi_monitored == true)
+                       ++count;
+       }
+       rcu_read_unlock();
+
+       return count;
+}
+
+int hci_conn_change_supervision_timeout(struct hci_conn *conn, __u16 timeout);
+bool hci_le_discovery_active(struct hci_dev *hdev);
+void hci_le_discovery_set_state(struct hci_dev *hdev, int state);
+
+static inline struct hci_conn *hci_conn_hash_lookup_sco(struct hci_dev *hdev)
+{
+       struct hci_conn_hash *h = &hdev->conn_hash;
+       struct hci_conn  *c;
+
+       rcu_read_lock();
+       list_for_each_entry_rcu(c, &h->list, list) {
+               if (c->type == SCO_LINK || c->type == ESCO_LINK) {
+                       rcu_read_unlock();
+                       return c;
+               }
+       }
+       rcu_read_unlock();
+
+       return NULL;
+}
+#endif
+
 int hci_disconnect(struct hci_conn *conn, __u8 reason);
 bool hci_setup_sync(struct hci_conn *conn, __u16 handle);
 void hci_sco_setup(struct hci_conn *conn, __u8 status);
@@ -1426,7 +1563,9 @@ int hci_le_create_cis_pending(struct hci_dev *hdev);
 int hci_conn_check_create_cis(struct hci_conn *conn);
 
 struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst,
-                             u8 role);
+                             u8 role, u16 handle);
+struct hci_conn *hci_conn_add_unset(struct hci_dev *hdev, int type,
+                                   bdaddr_t *dst, u8 role);
 void hci_conn_del(struct hci_conn *conn);
 void hci_conn_hash_flush(struct hci_dev *hdev);
 void hci_conn_check_pending(struct hci_dev *hdev);
@@ -1648,6 +1787,9 @@ int hci_get_dev_info(void __user *arg);
 int hci_get_conn_list(void __user *arg);
 int hci_get_conn_info(struct hci_dev *hdev, void __user *arg);
 int hci_get_auth_info(struct hci_dev *hdev, void __user *arg);
+#ifdef TIZEN_BT
+u32 get_link_mode(struct hci_conn *conn);
+#endif
 int hci_inquiry(void __user *arg);
 
 struct bdaddr_list *hci_bdaddr_list_lookup(struct list_head *list,
@@ -2140,6 +2282,10 @@ struct hci_mgmt_chan {
        unsigned short channel;
        size_t handler_count;
        const struct hci_mgmt_handler *handlers;
+#ifdef TIZEN_BT
+       size_t tizen_handler_count;
+       const struct hci_mgmt_handler *tizen_handlers;
+#endif
        void (*hdev_init) (struct sock *sk, struct hci_dev *hdev);
 };
 
@@ -2250,6 +2396,40 @@ int mgmt_phy_configuration_changed(struct hci_dev *hdev, struct sock *skip);
 void mgmt_adv_monitor_device_lost(struct hci_dev *hdev, u16 handle,
                                  bdaddr_t *bdaddr, u8 addr_type);
 
+#ifdef TIZEN_BT
+void mgmt_rssi_enable_success(struct sock *sk, struct hci_dev *hdev,
+               void *data, struct hci_cc_rsp_enable_rssi *rp, int success);
+void mgmt_rssi_disable_success(struct sock *sk, struct hci_dev *hdev,
+               void *data, struct hci_cc_rsp_enable_rssi *rp, int success);
+int mgmt_set_rssi_threshold(struct sock *sk, struct hci_dev *hdev,
+               void *data, u16 len);
+void mgmt_rssi_alert_evt(struct hci_dev *hdev, u16 conn_handle,
+               s8 alert_type, s8 rssi_dbm);
+void mgmt_raw_rssi_response(struct hci_dev *hdev,
+               struct hci_cc_rp_get_raw_rssi *rp, int success);
+void mgmt_enable_rssi_cc(struct hci_dev *hdev, void *response, u8 status);
+int mgmt_device_name_update(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *name,
+               u8 name_len);
+void mgmt_le_discovering(struct hci_dev *hdev, u8 discovering);
+int mgmt_le_conn_updated(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type,
+               u8 dst_type, u16 conn_interval, u16 conn_latency,
+               u16 supervision_timeout);
+int mgmt_le_conn_update_failed(struct hci_dev *hdev, bdaddr_t *bdaddr,
+               u8 link_type, u8 addr_type, u8 status);
+void mgmt_hardware_error(struct hci_dev *hdev, u8 err_code);
+void mgmt_tx_timeout_error(struct hci_dev *hdev);
+/*  Pass adv type in the le device found */
+void mgmt_le_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
+               u8 addr_type, u8 *dev_class, s8 rssi, u32 flags, u8 *eir,
+               u16 eir_len, u8 *scan_rsp, u8 scan_rsp_len, u8 adv_type);
+void mgmt_multi_adv_state_change_evt(struct hci_dev *hdev, u8 adv_instance,
+               u8 state_change_reason, u16 connection_handle);
+void mgmt_6lowpan_conn_changed(struct hci_dev *hdev, char if_name[16],
+               bdaddr_t *bdaddr, u8 addr_type, bool connected);
+void mgmt_le_read_maximum_data_length_complete(struct hci_dev *hdev,
+               u8 status);
+#endif
+
 int hci_abort_conn(struct hci_conn *conn, u8 reason);
 u8 hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max, u16 latency,
                      u16 to_multiplier);