1 /*
2 * Copyright (c) 2017-2021 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 struct ll_conn *ll_conn_acquire(void);
8 void ll_conn_release(struct ll_conn *conn);
9 uint16_t ll_conn_handle_get(struct ll_conn *conn);
10 struct ll_conn *ll_conn_get(uint16_t handle);
11 struct ll_conn *ll_connected_get(uint16_t handle);
12 uint16_t ll_conn_free_count_get(void);
13 void ll_tx_ack_put(uint16_t handle, struct node_tx *node_tx);
14 int ull_conn_init(void);
15 int ull_conn_reset(void);
16 uint16_t ull_conn_default_tx_octets_get(void);
17 uint16_t ull_conn_default_tx_time_get(void);
18 uint8_t ull_conn_default_phy_tx_get(void);
19 uint8_t ull_conn_default_phy_rx_get(void);
20 void ull_conn_default_past_param_set(uint8_t mode, uint16_t skip, uint16_t timeout,
21 uint8_t cte_type);
22 struct past_params ull_conn_default_past_param_get(void);
23 bool ull_conn_peer_connected(uint8_t const own_id_addr_type,
24 uint8_t const *const own_id_addr,
25 uint8_t const peer_id_addr_type,
26 uint8_t const *const peer_id_addr);
27 void ull_conn_setup(memq_link_t *rx_link, struct node_rx_pdu *rx);
28 void ull_conn_rx(memq_link_t *link, struct node_rx_pdu **rx);
29 int ull_conn_llcp(struct ll_conn *conn, uint32_t ticks_at_expire,
30 uint32_t remainder, uint16_t lazy);
31 void ull_conn_done(struct node_rx_event_done *done);
32 void ull_conn_tx_demux(uint8_t count);
33 void ull_conn_tx_lll_enqueue(struct ll_conn *conn, uint8_t count);
34 void ull_conn_link_tx_release(void *link);
35 uint8_t ull_conn_ack_last_idx_get(void);
36 memq_link_t *ull_conn_ack_peek(uint8_t *ack_last, uint16_t *handle,
37 struct node_tx **tx);
38 memq_link_t *ull_conn_ack_by_last_peek(uint8_t last, uint16_t *handle,
39 struct node_tx **tx);
40 void *ull_conn_ack_dequeue(void);
41 void ull_conn_tx_ack(uint16_t handle, memq_link_t *link, struct node_tx *tx);
42 uint8_t ull_conn_llcp_req(void *conn);
43
44 void ull_pdu_data_init(struct pdu_data *pdu);
45
46 #if defined(CONFIG_BT_CTLR_CONN_PARAM_REQ)
47 /* Connection context pointer used as CPR mutex to serialize connection
48 * parameter requests procedures across simultaneous connections so that
49 * offsets exchanged to the peer do not get changed.
50 */
51 extern struct ll_conn *conn_upd_curr;
52
cpr_active_check_and_set(struct ll_conn * conn)53 static inline void cpr_active_check_and_set(struct ll_conn *conn)
54 {
55 if (!conn_upd_curr) {
56 conn_upd_curr = conn;
57 }
58 }
59
cpr_active_set(struct ll_conn * conn)60 static inline void cpr_active_set(struct ll_conn *conn)
61 {
62 conn_upd_curr = conn;
63 }
64
cpr_active_is_set(struct ll_conn * conn)65 static inline bool cpr_active_is_set(struct ll_conn *conn)
66 {
67 return conn_upd_curr && (conn_upd_curr != conn);
68 }
69
cpr_active_check_and_reset(struct ll_conn * conn)70 static inline void cpr_active_check_and_reset(struct ll_conn *conn)
71 {
72 if (conn == conn_upd_curr) {
73 conn_upd_curr = NULL;
74 }
75 }
76
cpr_active_reset(void)77 static inline void cpr_active_reset(void)
78 {
79 conn_upd_curr = NULL;
80 }
81 #endif /* CONFIG_BT_CTLR_CONN_PARAM_REQ */
82
83 #if defined(CONFIG_BT_CTLR_SYNC_TRANSFER_SENDER)
84 void ull_conn_past_sender_offset_request(struct ll_conn *conn);
85 #endif /* CONFIG_BT_CTLR_SYNC_TRANSFER_SENDER */
86
87 uint16_t ull_conn_event_counter(struct ll_conn *conn);
88
89 void ull_conn_update_parameters(struct ll_conn *conn, uint8_t is_cu_proc,
90 uint8_t win_size, uint32_t win_offset_us,
91 uint16_t interval, uint16_t latency,
92 uint16_t timeout, uint16_t instant);
93
94 void ull_conn_update_peer_sca(struct ll_conn *conn);
95
96 void ull_conn_default_tx_octets_set(uint16_t tx_octets);
97
98 void ull_conn_default_tx_time_set(uint16_t tx_time);
99
100 uint8_t ull_conn_lll_phy_active(struct ll_conn *conn, uint8_t phy);
101
102 void ull_dle_init(struct ll_conn *conn, uint8_t phy);
103
104 void ull_dle_max_time_get(struct ll_conn *conn, uint16_t *max_rx_time,
105 uint16_t *max_tx_time);
106
107 uint8_t ull_dle_update_eff(struct ll_conn *conn);
108 uint8_t ull_dle_update_eff_tx(struct ll_conn *conn);
109 uint8_t ull_dle_update_eff_rx(struct ll_conn *conn);
110
111 void ull_dle_local_tx_update(struct ll_conn *conn, uint16_t tx_octets, uint16_t tx_time);
112
113 void ull_conn_default_phy_tx_set(uint8_t tx);
114
115 void ull_conn_default_phy_rx_set(uint8_t rx);
116
117 void ull_conn_chan_map_set(struct ll_conn *conn, const uint8_t chm[5]);
118
119 void *ull_conn_tx_mem_acquire(void);
120
121 void ull_conn_tx_mem_release(void *tx);
122
123 uint8_t ull_conn_mfifo_get_tx(void **lll_tx);
124
125 void ull_conn_mfifo_enqueue_tx(uint8_t idx);
126
127 /**
128 * @brief Pause the data path of a rx queue.
129 */
130 void ull_conn_pause_rx_data(struct ll_conn *conn);
131
132 /**
133 * @brief Resume the data path of a rx queue.
134 */
135 void ull_conn_resume_rx_data(struct ll_conn *conn);
136
137 /**
138 * @brief Check if the lower link layer transmit queue is empty
139 */
140 uint8_t ull_is_lll_tx_queue_empty(struct ll_conn *conn);
141