1 /* SPDX-License-Identifier: GPL-2.0 */ 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 typedef int (*hci_cmd_sync_work_func_t)(struct hci_dev *hdev, void *data); 12 typedef void (*hci_cmd_sync_work_destroy_t)(struct hci_dev *hdev, void *data, 13 int err); 14 15 struct hci_cmd_sync_work_entry { 16 struct list_head list; 17 hci_cmd_sync_work_func_t func; 18 void *data; 19 hci_cmd_sync_work_destroy_t destroy; 20 }; 21 22 struct adv_info; 23 /* Function with sync suffix shall not be called with hdev->lock held as they 24 * wait the command to complete and in the meantime an event could be received 25 * which could attempt to acquire hdev->lock causing a deadlock. 26 */ 27 struct sk_buff *__hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen, 28 const void *param, u32 timeout); 29 struct sk_buff *hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen, 30 const void *param, u32 timeout); 31 struct sk_buff *__hci_cmd_sync_ev(struct hci_dev *hdev, u16 opcode, u32 plen, 32 const void *param, u8 event, u32 timeout); 33 struct sk_buff *__hci_cmd_sync_sk(struct hci_dev *hdev, u16 opcode, u32 plen, 34 const void *param, u8 event, u32 timeout, 35 struct sock *sk); 36 int __hci_cmd_sync_status(struct hci_dev *hdev, u16 opcode, u32 plen, 37 const void *param, u32 timeout); 38 int __hci_cmd_sync_status_sk(struct hci_dev *hdev, u16 opcode, u32 plen, 39 const void *param, u8 event, u32 timeout, 40 struct sock *sk); 41 42 void hci_cmd_sync_init(struct hci_dev *hdev); 43 void hci_cmd_sync_clear(struct hci_dev *hdev); 44 void hci_cmd_sync_cancel(struct hci_dev *hdev, int err); 45 void hci_cmd_sync_cancel_sync(struct hci_dev *hdev, int err); 46 47 int hci_cmd_sync_submit(struct hci_dev *hdev, hci_cmd_sync_work_func_t func, 48 void *data, hci_cmd_sync_work_destroy_t destroy); 49 int hci_cmd_sync_queue(struct hci_dev *hdev, hci_cmd_sync_work_func_t func, 50 void *data, hci_cmd_sync_work_destroy_t destroy); 51 52 int hci_update_eir_sync(struct hci_dev *hdev); 53 int hci_update_class_sync(struct hci_dev *hdev); 54 55 int hci_update_eir_sync(struct hci_dev *hdev); 56 int hci_update_class_sync(struct hci_dev *hdev); 57 int hci_update_name_sync(struct hci_dev *hdev); 58 int hci_write_ssp_mode_sync(struct hci_dev *hdev, u8 mode); 59 60 int hci_get_random_address(struct hci_dev *hdev, bool require_privacy, 61 bool use_rpa, struct adv_info *adv_instance, 62 u8 *own_addr_type, bdaddr_t *rand_addr); 63 64 int hci_update_random_address_sync(struct hci_dev *hdev, bool require_privacy, 65 bool rpa, u8 *own_addr_type); 66 67 int hci_update_scan_rsp_data_sync(struct hci_dev *hdev, u8 instance); 68 int hci_update_adv_data_sync(struct hci_dev *hdev, u8 instance); 69 int hci_update_adv_data(struct hci_dev *hdev, u8 instance); 70 int hci_schedule_adv_instance_sync(struct hci_dev *hdev, u8 instance, 71 bool force); 72 73 int hci_setup_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance); 74 int hci_start_ext_adv_sync(struct hci_dev *hdev, u8 instance); 75 int hci_enable_ext_advertising_sync(struct hci_dev *hdev, u8 instance); 76 int hci_enable_advertising_sync(struct hci_dev *hdev); 77 int hci_enable_advertising(struct hci_dev *hdev); 78 79 int hci_start_per_adv_sync(struct hci_dev *hdev, u8 instance, u8 data_len, 80 u8 *data, u32 flags, u16 min_interval, 81 u16 max_interval, u16 sync_interval); 82 83 int hci_remove_advertising_sync(struct hci_dev *hdev, struct sock *sk, 84 u8 instance, bool force); 85 int hci_disable_advertising_sync(struct hci_dev *hdev); 86 int hci_clear_adv_instance_sync(struct hci_dev *hdev, struct sock *sk, 87 u8 instance, bool force); 88 int hci_update_passive_scan_sync(struct hci_dev *hdev); 89 int hci_update_passive_scan(struct hci_dev *hdev); 90 int hci_read_rssi_sync(struct hci_dev *hdev, __le16 handle); 91 int hci_read_tx_power_sync(struct hci_dev *hdev, __le16 handle, u8 type); 92 int hci_write_sc_support_sync(struct hci_dev *hdev, u8 val); 93 int hci_read_clock_sync(struct hci_dev *hdev, struct hci_cp_read_clock *cp); 94 95 int hci_write_fast_connectable_sync(struct hci_dev *hdev, bool enable); 96 int hci_update_scan_sync(struct hci_dev *hdev); 97 int hci_update_scan(struct hci_dev *hdev); 98 99 int hci_write_le_host_supported_sync(struct hci_dev *hdev, u8 le, u8 simul); 100 int hci_remove_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance, 101 struct sock *sk); 102 int hci_remove_ext_adv_instance(struct hci_dev *hdev, u8 instance); 103 struct sk_buff *hci_read_local_oob_data_sync(struct hci_dev *hdev, bool ext, 104 struct sock *sk); 105 106 int hci_reset_sync(struct hci_dev *hdev); 107 int hci_dev_open_sync(struct hci_dev *hdev); 108 int hci_dev_close_sync(struct hci_dev *hdev); 109 110 int hci_powered_update_sync(struct hci_dev *hdev); 111 int hci_set_powered_sync(struct hci_dev *hdev, u8 val); 112 113 int hci_update_discoverable_sync(struct hci_dev *hdev); 114 int hci_update_discoverable(struct hci_dev *hdev); 115 116 int hci_update_connectable_sync(struct hci_dev *hdev); 117 118 int hci_start_discovery_sync(struct hci_dev *hdev); 119 int hci_stop_discovery_sync(struct hci_dev *hdev); 120 121 int hci_suspend_sync(struct hci_dev *hdev); 122 int hci_resume_sync(struct hci_dev *hdev); 123 124 struct hci_conn; 125 126 int hci_abort_conn_sync(struct hci_dev *hdev, struct hci_conn *conn, u8 reason); 127 128 int hci_le_create_conn_sync(struct hci_dev *hdev, struct hci_conn *conn); 129 130 int hci_le_create_cis_sync(struct hci_dev *hdev); 131 132 int hci_le_remove_cig_sync(struct hci_dev *hdev, u8 handle); 133 134 int hci_le_terminate_big_sync(struct hci_dev *hdev, u8 handle, u8 reason); 135 136 int hci_le_big_terminate_sync(struct hci_dev *hdev, u8 handle); 137 138 int hci_le_pa_terminate_sync(struct hci_dev *hdev, u16 handle); 139