1 /*
2  * Copyright (c) 2016 Nordic Semiconductor ASA
3  * Copyright (c) 2016 Vinayak Kariappa Chettimada
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 
8 #if defined(CONFIG_BT_HCI_ACL_FLOW_CONTROL)
9 extern int32_t    hci_hbuf_total;
10 extern uint32_t    hci_hbuf_sent;
11 extern uint32_t    hci_hbuf_acked;
12 extern atomic_t hci_state_mask;
13 
14 #define HCI_STATE_BIT_RESET 0
15 #endif
16 
17 #define HCI_CLASS_NONE            0 /* Invalid class */
18 #define HCI_CLASS_EVT_REQUIRED    1 /* Mesh and connection-{established,
19 				     * disconnected}
20 				     */
21 #define HCI_CLASS_EVT_DISCARDABLE 2 /* Best-effort reporting. Discardable
22 				     * over HCI in case of overflow
23 				     */
24 #define HCI_CLASS_EVT_CONNECTION  3 /* Connection management; e.g.
25 				     * terminate, update, encryption
26 				     */
27 #define HCI_CLASS_EVT_LLCP        4 /* LL Control Procedures */
28 #define HCI_CLASS_ACL_DATA        5 /* Asynchronous Connection Less (general
29 				     * data)
30 				     */
31 #define HCI_CLASS_ISO_DATA        6 /* Isochronous data */
32 
33 
34 void hci_init(struct k_poll_signal *signal_host_buf);
35 void hci_recv_fifo_reset(void);
36 struct net_buf *hci_cmd_handle(struct net_buf *cmd, void **node_rx);
37 void hci_evt_encode(struct node_rx_pdu *node_rx, struct net_buf *buf);
38 uint8_t hci_get_class(struct node_rx_pdu *node_rx);
39 void hci_disconn_complete_encode(struct pdu_data *pdu_data, uint16_t handle,
40 				 struct net_buf *buf);
41 void hci_disconn_complete_process(uint16_t handle);
42 void hci_num_cmplt_encode(struct net_buf *buf, uint16_t handle, uint8_t num);
43 int hci_acl_handle(struct net_buf *acl, struct net_buf **evt);
44 void hci_acl_encode(struct node_rx_pdu *node_rx, struct net_buf *buf);
45 int hci_iso_handle(struct net_buf *acl, struct net_buf **evt);
46 void hci_iso_encode(struct net_buf *buf, uint16_t handle, uint8_t flags);
47 int hci_vendor_cmd_handle(uint16_t ocf, struct net_buf *cmd,
48 			  struct net_buf **evt);
49 uint8_t hci_vendor_read_static_addr(struct bt_hci_vs_static_addr addrs[],
50 				 uint8_t size);
51 void hci_vendor_read_key_hierarchy_roots(uint8_t ir[16], uint8_t er[16]);
52 int hci_vendor_cmd_handle_common(uint16_t ocf, struct net_buf *cmd,
53 			     struct net_buf **evt);
54 uint8_t hci_vendor_read_std_codecs(
55 	const struct bt_hci_std_codec_info_v2 **codecs);
56 uint8_t hci_vendor_read_vs_codecs(
57 	const struct bt_hci_vs_codec_info_v2 **codecs);
58 uint8_t hci_vendor_read_codec_capabilities(uint8_t coding_format,
59 					   uint16_t company_id,
60 					   uint16_t vs_codec_id,
61 					   uint8_t transport,
62 					   uint8_t direction,
63 					   uint8_t *num_capabilities,
64 					   size_t *capabilities_bytes,
65 					   const uint8_t **capabilities);
66 uint8_t hci_vendor_read_ctlr_delay(uint8_t coding_format,
67 				   uint16_t company_id,
68 				   uint16_t vs_codec_id,
69 				   uint8_t transport,
70 				   uint8_t direction,
71 				   uint8_t codec_config_len,
72 				   const uint8_t *codec_config,
73 				   uint32_t *min_delay,
74 				   uint32_t *max_delay);
75