| 1 |
|
| 2 | |
| 3 | * BlueZ - Bluetooth protocol stack for Linux
|
| 4 | *
|
| 5 | * Copyright (C) 2021 Intel Corporation
|
| 6 |
|
| 7 |
|
| 8 | #define UINT_PTR(_handle) ((void *)((uintptr_t)_handle))
|
| 9 | #define PTR_UINT(_ptr) ((uintptr_t)((void *)_ptr))
|
| 10 |
|
| 11 | #define HCI_REQ_DONE 0
|
| 12 | #define HCI_REQ_PEND 1
|
| 13 | #define HCI_REQ_CANCELED 2
|
| 14 |
|
| 15 | #define hci_req_sync_lock(hdev) mutex_lock(&hdev->req_lock)
|
| 16 | #define hci_req_sync_unlock(hdev) mutex_unlock(&hdev->req_lock)
|
| 17 |
|
| 18 | struct hci_request {
|
| 19 | struct hci_dev *hdev;
|
| 20 | struct sk_buff_head cmd_q;
|
| 21 |
|
| 22 | |
| 23 | * value is stored in this field.
|
| 24 |
|
| 25 | int err;
|
| 26 | };
|
| 27 |
|
| 28 | typedef int (*hci_cmd_sync_work_func_t)(struct hci_dev *hdev, void *data);
|
| 29 | typedef void (*hci_cmd_sync_work_destroy_t)(struct hci_dev *hdev, void *data,
|
| 30 | int err);
|
| 31 |
|
| 32 | struct hci_cmd_sync_work_entry {
|
| 33 | struct list_head list;
|
| 34 | hci_cmd_sync_work_func_t func;
|
| 35 | void *data;
|
| 36 | hci_cmd_sync_work_destroy_t destroy;
|
| 37 | };
|
| 38 |
|
| 39 | struct adv_info;
|
| 40 |
|
| 41 | struct sk_buff *hci_cmd_sync_alloc(struct hci_dev *hdev, u16 opcode, u32 plen,
|
| 42 | const void *param, struct sock *sk);
|
| 43 |
|
| 44 | |
| 45 | * wait the command to complete and in the meantime an event could be received
|
| 46 | * which could attempt to acquire hdev->lock causing a deadlock.
|
| 47 |
|
| 48 | struct sk_buff *__hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen,
|
| 49 | const void *param, u32 timeout);
|
| 50 | struct sk_buff *hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen,
|
| 51 | const void *param, u32 timeout);
|
| 52 | struct sk_buff *__hci_cmd_sync_ev(struct hci_dev *hdev, u16 opcode, u32 plen,
|
| 53 | const void *param, u8 event, u32 timeout);
|
| 54 | struct sk_buff *__hci_cmd_sync_sk(struct hci_dev *hdev, u16 opcode, u32 plen,
|
| 55 | const void *param, u8 event, u32 timeout,
|
| 56 | struct sock *sk);
|
| 57 | int __hci_cmd_sync_status(struct hci_dev *hdev, u16 opcode, u32 plen,
|
| 58 | const void *param, u32 timeout);
|
| 59 | int __hci_cmd_sync_status_sk(struct hci_dev *hdev, u16 opcode, u32 plen,
|
| 60 | const void *param, u8 event, u32 timeout,
|
| 61 | struct sock *sk);
|
| 62 | int __hci_reset_sync(struct hci_dev *hdev);
|
| 63 | int hci_cmd_sync_status(struct hci_dev *hdev, u16 opcode, u32 plen,
|
| 64 | const void *param, u32 timeout);
|
| 65 |
|
| 66 | void hci_cmd_sync_init(struct hci_dev *hdev);
|
| 67 | void hci_cmd_sync_clear(struct hci_dev *hdev);
|
| 68 | void hci_cmd_sync_cancel(struct hci_dev *hdev, int err);
|
| 69 | void hci_cmd_sync_cancel_sync(struct hci_dev *hdev, int err);
|
| 70 |
|
| 71 | int hci_cmd_sync_submit(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
|
| 72 | void *data, hci_cmd_sync_work_destroy_t destroy);
|
| 73 | int hci_cmd_sync_queue(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
|
| 74 | void *data, hci_cmd_sync_work_destroy_t destroy);
|
| 75 | int hci_cmd_sync_queue_once(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
|
| 76 | void *data, hci_cmd_sync_work_destroy_t destroy);
|
| 77 | int hci_cmd_sync_run(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
|
| 78 | void *data, hci_cmd_sync_work_destroy_t destroy);
|
| 79 | int hci_cmd_sync_run_once(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
|
| 80 | void *data, hci_cmd_sync_work_destroy_t destroy);
|
| 81 | struct hci_cmd_sync_work_entry *
|
| 82 | hci_cmd_sync_lookup_entry(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
|
| 83 | void *data, hci_cmd_sync_work_destroy_t destroy);
|
| 84 | void hci_cmd_sync_cancel_entry(struct hci_dev *hdev,
|
| 85 | struct hci_cmd_sync_work_entry *entry);
|
| 86 | bool hci_cmd_sync_dequeue(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
|
| 87 | void *data, hci_cmd_sync_work_destroy_t destroy);
|
| 88 |
|
| 89 | int hci_update_eir_sync(struct hci_dev *hdev);
|
| 90 | int hci_update_class_sync(struct hci_dev *hdev);
|
| 91 |
|
| 92 | int hci_update_eir_sync(struct hci_dev *hdev);
|
| 93 | int hci_update_class_sync(struct hci_dev *hdev);
|
| 94 | int hci_update_name_sync(struct hci_dev *hdev, const u8 *name);
|
| 95 | int hci_write_ssp_mode_sync(struct hci_dev *hdev, u8 mode);
|
| 96 |
|
| 97 | int hci_get_random_address(struct hci_dev *hdev, bool require_privacy,
|
| 98 | bool use_rpa, struct adv_info *adv_instance,
|
| 99 | u8 *own_addr_type, bdaddr_t *rand_addr);
|
| 100 |
|
| 101 | int hci_update_random_address_sync(struct hci_dev *hdev, bool require_privacy,
|
| 102 | bool rpa, u8 *own_addr_type);
|
| 103 |
|
| 104 | int hci_update_scan_rsp_data_sync(struct hci_dev *hdev, u8 instance);
|
| 105 | int hci_update_adv_data_sync(struct hci_dev *hdev, u8 instance);
|
| 106 | int hci_update_adv_data(struct hci_dev *hdev, u8 instance);
|
| 107 | int hci_schedule_adv_instance_sync(struct hci_dev *hdev, u8 instance,
|
| 108 | bool force);
|
| 109 |
|
| 110 | int hci_setup_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance);
|
| 111 | int hci_start_ext_adv_sync(struct hci_dev *hdev, u8 instance);
|
| 112 | int hci_enable_ext_advertising_sync(struct hci_dev *hdev, u8 instance);
|
| 113 | int hci_enable_advertising_sync(struct hci_dev *hdev);
|
| 114 | int hci_enable_advertising(struct hci_dev *hdev);
|
| 115 |
|
| 116 | int hci_start_per_adv_sync(struct hci_dev *hdev, u8 instance, u8 sid,
|
| 117 | u8 data_len, u8 *data, u32 flags, u16 min_interval,
|
| 118 | u16 max_interval, u16 sync_interval);
|
| 119 |
|
| 120 | int hci_disable_per_advertising_sync(struct hci_dev *hdev, u8 instance);
|
| 121 |
|
| 122 | int hci_remove_advertising_sync(struct hci_dev *hdev, struct sock *sk,
|
| 123 | u8 instance, bool force);
|
| 124 | int hci_disable_advertising_sync(struct hci_dev *hdev);
|
| 125 | int hci_clear_adv_instance_sync(struct hci_dev *hdev, struct sock *sk,
|
| 126 | u8 instance, bool force);
|
| 127 | int hci_update_passive_scan_sync(struct hci_dev *hdev);
|
| 128 | int hci_update_passive_scan(struct hci_dev *hdev);
|
| 129 | int hci_read_rssi_sync(struct hci_dev *hdev, __le16 handle);
|
| 130 | int hci_read_tx_power_sync(struct hci_dev *hdev, __le16 handle, u8 type);
|
| 131 | int hci_write_sc_support_sync(struct hci_dev *hdev, u8 val);
|
| 132 | int hci_read_clock_sync(struct hci_dev *hdev, struct hci_cp_read_clock *cp);
|
| 133 |
|
| 134 | int hci_write_fast_connectable_sync(struct hci_dev *hdev, bool enable);
|
| 135 | int hci_update_scan_sync(struct hci_dev *hdev);
|
| 136 | int hci_update_scan(struct hci_dev *hdev);
|
| 137 |
|
| 138 | int hci_write_le_host_supported_sync(struct hci_dev *hdev, u8 le, u8 simul);
|
| 139 | int hci_remove_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance,
|
| 140 | struct sock *sk);
|
| 141 | struct sk_buff *hci_read_local_oob_data_sync(struct hci_dev *hdev, bool ext,
|
| 142 | struct sock *sk);
|
| 143 |
|
| 144 | int hci_reset_sync(struct hci_dev *hdev);
|
| 145 | int hci_dev_open_sync(struct hci_dev *hdev);
|
| 146 | int hci_dev_close_sync(struct hci_dev *hdev);
|
| 147 |
|
| 148 | int hci_powered_update_sync(struct hci_dev *hdev);
|
| 149 | int hci_set_powered_sync(struct hci_dev *hdev, u8 val);
|
| 150 |
|
| 151 | int hci_update_discoverable_sync(struct hci_dev *hdev);
|
| 152 | int hci_update_discoverable(struct hci_dev *hdev);
|
| 153 |
|
| 154 | int hci_update_connectable_sync(struct hci_dev *hdev);
|
| 155 |
|
| 156 | int hci_inquiry_sync(struct hci_dev *hdev, u8 length, u8 num_rsp);
|
| 157 |
|
| 158 | int hci_start_discovery_sync(struct hci_dev *hdev);
|
| 159 | int hci_stop_discovery_sync(struct hci_dev *hdev);
|
| 160 |
|
| 161 | int hci_suspend_sync(struct hci_dev *hdev);
|
| 162 | int hci_resume_sync(struct hci_dev *hdev);
|
| 163 |
|
| 164 | struct hci_conn;
|
| 165 | struct hci_conn_params;
|
| 166 |
|
| 167 | int hci_abort_conn_sync(struct hci_dev *hdev, struct hci_conn *conn, u8 reason);
|
| 168 |
|
| 169 | int hci_le_create_cis_sync(struct hci_dev *hdev);
|
| 170 |
|
| 171 | int hci_le_remove_cig_sync(struct hci_dev *hdev, u8 handle);
|
| 172 |
|
| 173 | int hci_le_terminate_big_sync(struct hci_dev *hdev, u8 handle, u8 reason);
|
| 174 |
|
| 175 | int hci_le_big_terminate_sync(struct hci_dev *hdev, u8 handle);
|
| 176 |
|
| 177 | int hci_le_pa_terminate_sync(struct hci_dev *hdev, u16 handle);
|
| 178 |
|
| 179 | int hci_connect_acl_sync(struct hci_dev *hdev, struct hci_conn *conn);
|
| 180 |
|
| 181 | int hci_connect_le_sync(struct hci_dev *hdev, struct hci_conn *conn);
|
| 182 |
|
| 183 | int hci_cancel_connect_sync(struct hci_dev *hdev, struct hci_conn *conn);
|
| 184 | int hci_le_conn_update_sync(struct hci_dev *hdev, struct hci_conn *conn,
|
| 185 | struct hci_conn_params *params);
|
| 186 | int hci_le_conn_rate_request(struct hci_dev *hdev, struct hci_conn *conn);
|
| 187 |
|
| 188 | int hci_connect_pa_sync(struct hci_dev *hdev, struct hci_conn *conn);
|
| 189 | int hci_connect_big_sync(struct hci_dev *hdev, struct hci_conn *conn);
|
| 190 | int hci_past_sync(struct hci_conn *conn, struct hci_conn *le);
|
| 191 |
|
| 192 | int hci_le_read_remote_features(struct hci_conn *conn);
|
| 193 |
|
| 194 | int hci_acl_change_pkt_type(struct hci_conn *conn, u16 pkt_type);
|
| 195 | int hci_le_set_phy(struct hci_conn *conn, u8 tx_phys, u8 rx_phys);
|