Back to home page

OSCL-LXR

 
 

    


0001 /*
0002    BlueZ - Bluetooth protocol stack for Linux
0003    Copyright (C) 2014 Intel Corporation
0004 
0005    This program is free software; you can redistribute it and/or modify
0006    it under the terms of the GNU General Public License version 2 as
0007    published by the Free Software Foundation;
0008 
0009    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
0010    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0011    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
0012    IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
0013    CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
0014    WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
0015    ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
0016    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
0017 
0018    ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
0019    COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
0020    SOFTWARE IS DISCLAIMED.
0021 */
0022 
0023 #include <asm/unaligned.h>
0024 
0025 #define HCI_REQ_DONE      0
0026 #define HCI_REQ_PEND      1
0027 #define HCI_REQ_CANCELED  2
0028 
0029 #define hci_req_sync_lock(hdev)   mutex_lock(&hdev->req_lock)
0030 #define hci_req_sync_unlock(hdev) mutex_unlock(&hdev->req_lock)
0031 
0032 #define HCI_REQ_DONE      0
0033 #define HCI_REQ_PEND      1
0034 #define HCI_REQ_CANCELED  2
0035 
0036 struct hci_request {
0037     struct hci_dev      *hdev;
0038     struct sk_buff_head cmd_q;
0039 
0040     /* If something goes wrong when building the HCI request, the error
0041      * value is stored in this field.
0042      */
0043     int         err;
0044 };
0045 
0046 void hci_req_init(struct hci_request *req, struct hci_dev *hdev);
0047 void hci_req_purge(struct hci_request *req);
0048 bool hci_req_status_pend(struct hci_dev *hdev);
0049 int hci_req_run(struct hci_request *req, hci_req_complete_t complete);
0050 int hci_req_run_skb(struct hci_request *req, hci_req_complete_skb_t complete);
0051 void hci_req_sync_complete(struct hci_dev *hdev, u8 result, u16 opcode,
0052                struct sk_buff *skb);
0053 void hci_req_add(struct hci_request *req, u16 opcode, u32 plen,
0054          const void *param);
0055 void hci_req_add_ev(struct hci_request *req, u16 opcode, u32 plen,
0056             const void *param, u8 event);
0057 void hci_req_cmd_complete(struct hci_dev *hdev, u16 opcode, u8 status,
0058               hci_req_complete_t *req_complete,
0059               hci_req_complete_skb_t *req_complete_skb);
0060 
0061 int hci_req_sync(struct hci_dev *hdev, int (*req)(struct hci_request *req,
0062                           unsigned long opt),
0063          unsigned long opt, u32 timeout, u8 *hci_status);
0064 int __hci_req_sync(struct hci_dev *hdev, int (*func)(struct hci_request *req,
0065                              unsigned long opt),
0066            unsigned long opt, u32 timeout, u8 *hci_status);
0067 
0068 struct sk_buff *hci_prepare_cmd(struct hci_dev *hdev, u16 opcode, u32 plen,
0069                 const void *param);
0070 
0071 void __hci_req_write_fast_connectable(struct hci_request *req, bool enable);
0072 void __hci_req_update_name(struct hci_request *req);
0073 void __hci_req_update_eir(struct hci_request *req);
0074 
0075 void hci_req_add_le_scan_disable(struct hci_request *req, bool rpa_le_conn);
0076 void hci_req_add_le_passive_scan(struct hci_request *req);
0077 
0078 void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next);
0079 
0080 void hci_req_disable_address_resolution(struct hci_dev *hdev);
0081 void hci_req_reenable_advertising(struct hci_dev *hdev);
0082 void __hci_req_enable_advertising(struct hci_request *req);
0083 void __hci_req_disable_advertising(struct hci_request *req);
0084 void __hci_req_update_adv_data(struct hci_request *req, u8 instance);
0085 int hci_req_update_adv_data(struct hci_dev *hdev, u8 instance);
0086 int hci_req_start_per_adv(struct hci_dev *hdev, u8 instance, u32 flags,
0087               u16 min_interval, u16 max_interval,
0088               u16 sync_interval);
0089 void __hci_req_update_scan_rsp_data(struct hci_request *req, u8 instance);
0090 
0091 int __hci_req_schedule_adv_instance(struct hci_request *req, u8 instance,
0092                     bool force);
0093 void hci_req_clear_adv_instance(struct hci_dev *hdev, struct sock *sk,
0094                 struct hci_request *req, u8 instance,
0095                 bool force);
0096 
0097 int __hci_req_setup_ext_adv_instance(struct hci_request *req, u8 instance);
0098 int __hci_req_setup_per_adv_instance(struct hci_request *req, u8 instance,
0099                      u16 min_interval, u16 max_interval);
0100 int __hci_req_start_ext_adv(struct hci_request *req, u8 instance);
0101 int __hci_req_start_per_adv(struct hci_request *req, u8 instance, u32 flags,
0102                 u16 min_interval, u16 max_interval,
0103                 u16 sync_interval);
0104 int __hci_req_enable_ext_advertising(struct hci_request *req, u8 instance);
0105 int __hci_req_enable_per_advertising(struct hci_request *req, u8 instance);
0106 int __hci_req_disable_ext_adv_instance(struct hci_request *req, u8 instance);
0107 int __hci_req_remove_ext_adv_instance(struct hci_request *req, u8 instance);
0108 void __hci_req_clear_ext_adv_sets(struct hci_request *req);
0109 int hci_get_random_address(struct hci_dev *hdev, bool require_privacy,
0110                bool use_rpa, struct adv_info *adv_instance,
0111                u8 *own_addr_type, bdaddr_t *rand_addr);
0112 
0113 void __hci_req_update_class(struct hci_request *req);
0114 
0115 /* Returns true if HCI commands were queued */
0116 bool hci_req_stop_discovery(struct hci_request *req);
0117 
0118 int hci_req_configure_datapath(struct hci_dev *hdev, struct bt_codec *codec);
0119 
0120 void __hci_req_update_scan(struct hci_request *req);
0121 
0122 int hci_update_random_address(struct hci_request *req, bool require_privacy,
0123                   bool use_rpa, u8 *own_addr_type);
0124 
0125 int hci_abort_conn(struct hci_conn *conn, u8 reason);
0126 void __hci_abort_conn(struct hci_request *req, struct hci_conn *conn,
0127               u8 reason);
0128 
0129 void hci_request_setup(struct hci_dev *hdev);
0130 void hci_request_cancel_all(struct hci_dev *hdev);