hci_sync.h 7.8 KB

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