@@ -135,6 +135,113 @@ Execution Priorities
135
135
136
136
- LLL is vendor ISR, ULL is Mayfly ISR concept, Host is kernel thread.
137
137
138
+ Link Layer Control Procedures
139
+ *****************************
140
+
141
+ Following is a brief fly in on the main concepts in the implementation of
142
+ control procedures handling in ULL.
143
+
144
+ Three main execution contexts
145
+ =============================
146
+
147
+ - HCI/LLCP API
148
+ * Miscellaneous procedure initiation API
149
+ * From ull_llcp.c::ull_cp_<proc>() for initiating local procedures
150
+ * Interface with running procedures, local and remote
151
+
152
+ - lll_prepare context to drive ull_cp_run()
153
+ * LLCP main state machine entry/tick'er
154
+ * From ull_peripheral.c/ull_central.c::ticker_cb via ull_conn_llcp()
155
+
156
+ - rx_demux context to drive ull_cp_tx_ack() and ull_cp_rx()
157
+ * LLCP tx ack handling and PDU reception
158
+ * From ull_conn.c::ull_conn_rx()
159
+ * Handles passing PDUs into running procedures as well as possibly initiating remote procedures
160
+
161
+ Data structures and PDU helpers
162
+ ===============================
163
+
164
+ - struct llcp_struct
165
+ * Main LLCP data store
166
+ * Defined in ull_conn_types.h and declared as part of struct ll_conn
167
+ * Holds local and remote procedure request queues as well as conn specific LLCP data
168
+ * Basic conn-level abstraction
169
+
170
+ - struct proc_ctx
171
+ * General procedure context data, contains miscellaneous procedure data and state as well as sys_snode_t for queueing
172
+ * Defined in ull_llcp_internal.h, declared/instantiated through ull_llcp.c::create_procedure()
173
+ * Also holds node references used in tx_ack as well as rx_node retention mechanisms
174
+
175
+ - struct llcp_mem_pool
176
+ * Mem pool used to implement procedure contexts resource - instantiated in both a local and a remote version
177
+ * Used through ull_llcp.c::create_procedure()
178
+
179
+ - Miscellaneous pdu gymnastics
180
+ * Encoding and decoding of control pdus done by ull_llcp_pdu.c::llcp_pdu_encode/decode_<PDU>()
181
+ * Miscellaneous pdu validation handled by ull_llcp.c::pdu_validate_<PDU>() via ull_llcp.c::pdu_is_valid()
182
+
183
+ LLCP local and remote request/procedure state machines
184
+ ======================================================
185
+
186
+ - ull_llcp_local.c
187
+ * State machine handling local initiated procedures
188
+ * Naming concept: lr _<...> => local request machine
189
+ * Local procedure queue handling
190
+ * Local run/rx/tx_ack switch
191
+
192
+ - ull_llcp_remote.c
193
+ * Remote versions of the above
194
+ * Naming concept: rr_<...> => remote request machine
195
+ * Also handling of remote procedure initiation by llcp_rx_new()
196
+ * Miscellaneous procedure collision handling (in rr_st_idle())
197
+
198
+ - ull_llcp_common/conn_upd/phy/enc/cc/chmu.c
199
+ * Individual procedure implementations (ull_llcp_common.c collects the simpler ones)
200
+ * Naming concept: lp_<...> => local initiated procedure, rp_<...> => remote initiated procedure
201
+ * Handling of procedure flow from init (possibly through instant) to completion and host notification if applicable
202
+
203
+ Miscellaneous concepts
204
+ ======================
205
+
206
+ - Procedure collision handling
207
+ * See BT spec for explanation
208
+ * Basically some procedures can exist in parallel but some can't - for instance only one instant based at a time
209
+ * Spec states rules for how to handle/resolve collisions when they happen
210
+
211
+ - Termination handling
212
+ * Specific rules apply re. how termination is handled.
213
+ * Since we have resource handling re. procedure contexts and terminate must always be available this is handled as a special case
214
+ * Note also - there are miscellaneous cases where connection termination is triggered on invalid peer behavior
215
+
216
+ - New remote procedure handling
217
+ * Table new_proc_lut[] maps LLCP PDUs to procedures/roles used in llcp_rr_new()
218
+ * Note - for any given connection, there can only ever be ONE remote procedure in the remote procedure queue
219
+
220
+ - Miscellaneous minors
221
+ * pause/resume concepts - there are two (see spec for details)
222
+ * procedure execution can be paused by the encryption procedure
223
+ * data TX can be paused by PHY, DLE and ENC procedure
224
+ * RX node retention - ensures no waiting for allocation of RX node when needed for notification
225
+
226
+
227
+ Miscellaneous unit test concepts
228
+ ================================
229
+
230
+ - Individual ZTEST unit test for each procedure
231
+ * zephyr/tests/bluetooth/controller/ctrl_<proc>
232
+
233
+ - Rx node handling is mocked
234
+ * Different configs are handled by separate conf files (see ctrl_conn_update for example)
235
+ * ZTEST(periph_rem_no_param_req, test_conn_update_periph_rem_accept_no_param_req)
236
+
237
+ - Emulated versions of rx_demux/prepare context used in unit tests - testing ONLY procedure PDU flow
238
+ * event_prepare()/event_done() helpers emulating LLL prepare/done flow
239
+ * lt_rx()/lt_tx() 'lower tester' emulation of rx/tx
240
+ * ut_rx_node() 'upper tester' emulation of notification flow handling
241
+ * Bunch of helpers to generate and parse PDUs, as well as miscellaneous mocked ull_stuff()
242
+
243
+
244
+
138
245
139
246
Lower Link Layer
140
247
****************
0 commit comments