1 /*
2 * Copyright (c) 2020 Demant
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #include <zephyr/types.h>
8 #include <zephyr/ztest.h>
9
10 #define ULL_LLCP_UNITTEST
11
12 #include <zephyr/bluetooth/hci.h>
13 #include <zephyr/sys/byteorder.h>
14 #include <zephyr/sys/slist.h>
15 #include <zephyr/sys/util.h>
16 #include "hal/ccm.h"
17
18 #include "util/util.h"
19 #include "util/mem.h"
20 #include "util/memq.h"
21 #include "util/dbuf.h"
22
23 #include "pdu_df.h"
24 #include "lll/pdu_vendor.h"
25 #include "pdu.h"
26 #include "ll.h"
27 #include "ll_settings.h"
28
29 #include "lll.h"
30 #include "lll/lll_df_types.h"
31 #include "lll_conn.h"
32 #include "lll_conn_iso.h"
33
34 #include "ull_tx_queue.h"
35
36 #include "isoal.h"
37 #include "ull_iso_types.h"
38 #include "ull_conn_iso_types.h"
39 #include "ull_conn_types.h"
40 #include "ull_llcp.h"
41 #include "ull_conn_internal.h"
42 #include "ull_llcp_internal.h"
43
44 #include "helper_pdu.h"
45 #include "helper_util.h"
46
47 /* Default connection values */
48 #define INTVL_MIN 6U /* multiple of 1.25 ms (min 6, max 3200) */
49 #define INTVL_MAX 6U /* multiple of 1.25 ms (min 6, max 3200) */
50 #define LATENCY 1U
51 #define TIMEOUT 10U /* multiple of 10 ms (min 10, max 3200) */
52
53 /* Default conn_update_ind PDU */
54 struct pdu_data_llctrl_conn_update_ind conn_update_ind = { .win_size = 1U,
55 .win_offset = 0U,
56 .interval = INTVL_MAX,
57 .latency = LATENCY,
58 .timeout = TIMEOUT,
59 .instant = 6U };
60
61 /* Default conn_param_req PDU */
62 struct pdu_data_llctrl_conn_param_req conn_param_req = { .interval_min = INTVL_MIN,
63 .interval_max = INTVL_MAX,
64 .latency = LATENCY,
65 .timeout = TIMEOUT,
66 .preferred_periodicity = 0U,
67 .reference_conn_event_count = 0u,
68 .offset0 = 0x0000U,
69 .offset1 = 0xffffU,
70 .offset2 = 0xffffU,
71 .offset3 = 0xffffU,
72 .offset4 = 0xffffU,
73 .offset5 = 0xffffU };
74
75 #if defined(CONFIG_BT_CTLR_CONN_PARAM_REQ)
76 /* Default conn_param_rsp PDU */
77 struct pdu_data_llctrl_conn_param_rsp conn_param_rsp = { .interval_min = INTVL_MIN,
78 .interval_max = INTVL_MAX,
79 .latency = LATENCY,
80 .timeout = TIMEOUT,
81 .preferred_periodicity = 0U,
82 .reference_conn_event_count = 0u,
83 .offset0 = 0x0000U,
84 .offset1 = 0xffffU,
85 .offset2 = 0xffffU,
86 .offset3 = 0xffffU,
87 .offset4 = 0xffffU,
88 .offset5 = 0xffffU };
89
90 /* Invalid conn_param_req PDU */
91 struct pdu_data_llctrl_conn_param_req conn_param_req_invalid = { .interval_min = INTVL_MIN - 1,
92 .interval_max = INTVL_MAX + 1,
93 .latency = LATENCY,
94 .timeout = TIMEOUT - 1,
95 .preferred_periodicity = 0U,
96 .reference_conn_event_count = 0u,
97 .offset0 = 0x0000U,
98 .offset1 = 0xffffU,
99 .offset2 = 0xffffU,
100 .offset3 = 0xffffU,
101 .offset4 = 0xffffU,
102 .offset5 = 0xffffU };
103 /* Invalid conn_param_rsp PDU */
104 struct pdu_data_llctrl_conn_param_rsp conn_param_rsp_invalid = { .interval_min = INTVL_MIN - 1,
105 .interval_max = INTVL_MAX + 1,
106 .latency = LATENCY,
107 .timeout = TIMEOUT - 1,
108 .preferred_periodicity = 0U,
109 .reference_conn_event_count = 0u,
110 .offset0 = 0x0000U,
111 .offset1 = 0xffffU,
112 .offset2 = 0xffffU,
113 .offset3 = 0xffffU,
114 .offset4 = 0xffffU,
115 .offset5 = 0xffffU };
116 /* Different PDU contents for (B) */
117
118 /* Default conn_param_req PDU (B) */
119 struct pdu_data_llctrl_conn_param_req conn_param_req_B = {
120 .interval_min = INTVL_MIN,
121 .interval_max = INTVL_MAX,
122 .latency = LATENCY + 1U, /* differentiate parameter */
123 .timeout = TIMEOUT + 1U, /* differentiate parameter */
124 .preferred_periodicity = 0U,
125 .reference_conn_event_count = 0u,
126 .offset0 = 0x0000U,
127 .offset1 = 0xffffU,
128 .offset2 = 0xffffU,
129 .offset3 = 0xffffU,
130 .offset4 = 0xffffU,
131 .offset5 = 0xffffU
132 };
133
134 /* Default conn_param_rsp PDU (B) */
135 struct pdu_data_llctrl_conn_param_rsp conn_param_rsp_B = {
136 .interval_min = INTVL_MIN,
137 .interval_max = INTVL_MAX,
138 .latency = LATENCY + 1U, /* differentiate parameter */
139 .timeout = TIMEOUT + 1U, /* differentiate parameter */
140 .preferred_periodicity = 0U,
141 .reference_conn_event_count = 0u,
142 .offset0 = 0x0000U,
143 .offset1 = 0xffffU,
144 .offset2 = 0xffffU,
145 .offset3 = 0xffffU,
146 .offset4 = 0xffffU,
147 .offset5 = 0xffffU
148 };
149 #endif /* CONFIG_BT_CTLR_CONN_PARAM_REQ */
150
151 /* Default conn_update_ind PDU (B) */
152 struct pdu_data_llctrl_conn_update_ind conn_update_ind_B = {
153 .win_size = 1U,
154 .win_offset = 0U,
155 .interval = INTVL_MAX,
156 .latency = LATENCY + 1U, /* differentiate parameter */
157 .timeout = TIMEOUT + 1U, /* differentiate parameter */
158 .instant = 6U
159 };
160
161 #if defined(CONFIG_BT_CTLR_CONN_PARAM_REQ)
162 struct pdu_data_llctrl_conn_param_req *req_B = &conn_param_req_B;
163 struct pdu_data_llctrl_conn_param_rsp *rsp_B = &conn_param_rsp_B;
164 #endif /* CONFIG_BT_CTLR_CONN_PARAM_REQ */
165
166 struct pdu_data_llctrl_conn_update_ind *cu_ind_B = &conn_update_ind_B;
167
168 static struct ll_conn conn;
169
170
171 #if defined(CONFIG_BT_CTLR_CONN_PARAM_REQ)
172 #if defined(CONFIG_BT_CTLR_USER_CPR_ANCHOR_POINT_MOVE)
ull_handle_cpr_anchor_point_move(struct ll_conn * conn,uint16_t * offsets,uint8_t * status)173 bool ull_handle_cpr_anchor_point_move(struct ll_conn *conn, uint16_t *offsets, uint8_t *status)
174 {
175 ztest_copy_return_data(status, 1);
176 return ztest_get_return_value();
177 }
178 #endif /* CONFIG_BT_CTLR_USER_CPR_ANCHOR_POINT_MOVE */
179
test_unmask_feature_conn_param_req(struct ll_conn * conn)180 static void test_unmask_feature_conn_param_req(struct ll_conn *conn)
181 {
182 conn->llcp.fex.features_used &= ~BIT64(BT_LE_FEAT_BIT_CONN_PARAM_REQ);
183 }
184
test_get_feature_conn_param_req(struct ll_conn * conn)185 static bool test_get_feature_conn_param_req(struct ll_conn *conn)
186 {
187 return (conn->llcp.fex.features_used & BIT64(BT_LE_FEAT_BIT_CONN_PARAM_REQ));
188 }
189 #endif /* CONFIG_BT_CTLR_CONN_PARAM_REQ */
190
conn_update_setup(void * data)191 static void conn_update_setup(void *data)
192 {
193 test_setup(&conn);
194
195 conn_param_req.reference_conn_event_count = -1;
196 #if defined(CONFIG_BT_CTLR_CONN_PARAM_REQ)
197 conn_param_rsp.reference_conn_event_count = -1;
198 #endif
199
200 /* Initialize lll conn parameters (different from new) */
201 struct lll_conn *lll = &conn.lll;
202
203 lll->interval = 0;
204 lll->latency = 0;
205 conn.supervision_timeout = 1U;
206 lll->event_counter = 0;
207 }
208
is_instant_reached(struct ll_conn * conn,uint16_t instant)209 static bool is_instant_reached(struct ll_conn *conn, uint16_t instant)
210 {
211 return ((event_counter(conn) - instant) & 0xFFFF) <= 0x7FFF;
212 }
213
214 #if defined(CONFIG_BT_CTLR_CONN_PARAM_REQ)
215 /*
216 * Central-initiated Connection Parameters Request procedure.
217 * Central requests change in LE connection parameters, peripheral’s Host accepts.
218 *
219 * +-----+ +-------+ +-----+
220 * | UT | | LL_C | | LT |
221 * +-----+ +-------+ +-----+
222 * | | |
223 * | LE Connection Update | |
224 * |-------------------------->| |
225 * | | LL_CONNECTION_PARAM_REQ |
226 * | |-------------------------->|
227 * | | |
228 * | | LL_CONNECTION_PARAM_RSP |
229 * | |<--------------------------|
230 * | | |
231 * | | LL_CONNECTION_UPDATE_IND |
232 * | |-------------------------->|
233 * | | |
234 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
235 * | | |
236 * | LE Connection Update | |
237 * | Complete | |
238 * |<--------------------------| |
239 * | | |
240 */
ZTEST(central_loc,test_conn_update_central_loc_accept)241 ZTEST(central_loc, test_conn_update_central_loc_accept)
242 {
243 uint8_t err;
244 struct node_tx *tx;
245 struct node_rx_pdu *ntf;
246 struct pdu_data *pdu;
247 uint16_t instant;
248
249 struct node_rx_pu cu = { .status = BT_HCI_ERR_SUCCESS };
250
251 /* Role */
252 test_set_role(&conn, BT_HCI_ROLE_CENTRAL);
253
254 /* Connect */
255 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
256
257 /* Initiate a Connection Parameter Request Procedure */
258 err = ull_cp_conn_update(&conn, INTVL_MIN, INTVL_MAX, LATENCY, TIMEOUT, NULL);
259 zassert_equal(err, BT_HCI_ERR_SUCCESS);
260
261 /* Prepare */
262 event_prepare(&conn);
263
264 /* Tx Queue should have one LL Control PDU */
265 conn_param_req.reference_conn_event_count = event_counter(&conn);
266 lt_rx(LL_CONNECTION_PARAM_REQ, &conn, &tx, &conn_param_req);
267 lt_rx_q_is_empty(&conn);
268
269 /* Rx */
270 conn_param_rsp.reference_conn_event_count = conn_param_req.reference_conn_event_count;
271 lt_tx(LL_CONNECTION_PARAM_RSP, &conn, &conn_param_rsp);
272
273 /* Done */
274 event_done(&conn);
275
276 /* Release Tx */
277 ull_cp_release_tx(&conn, tx);
278
279 /* Prepare */
280 event_prepare(&conn);
281
282 /* Tx Queue should have one LL Control PDU */
283 conn_update_ind.instant = event_counter(&conn) + 6U;
284 lt_rx(LL_CONNECTION_UPDATE_IND, &conn, &tx, &conn_update_ind);
285 lt_rx_q_is_empty(&conn);
286
287 /* Done */
288 event_done(&conn);
289
290 /* Save Instant */
291 pdu = (struct pdu_data *)tx->pdu;
292 instant = sys_le16_to_cpu(pdu->llctrl.conn_update_ind.instant);
293
294 /* Release Tx */
295 ull_cp_release_tx(&conn, tx);
296
297 /* */
298 while (!is_instant_reached(&conn, instant)) {
299 /* Prepare */
300 event_prepare(&conn);
301
302 /* Tx Queue should NOT have a LL Control PDU */
303 lt_rx_q_is_empty(&conn);
304
305 /* Done */
306 event_done(&conn);
307
308 /* There should NOT be a host notification */
309 ut_rx_q_is_empty();
310 }
311
312 /* Prepare */
313 event_prepare(&conn);
314
315 /* Tx Queue should NOT have a LL Control PDU */
316 lt_rx_q_is_empty(&conn);
317
318 /* Done */
319 event_done(&conn);
320
321 /* There should be one host notification */
322 ut_rx_node(NODE_CONN_UPDATE, &ntf, &cu);
323 ut_rx_q_is_empty();
324
325 /* Release Ntf */
326 release_ntf(ntf);
327 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
328 "Free CTX buffers %d", llcp_ctx_buffers_free());
329 }
330
331
332 /*
333 * Central-initiated Connection Parameters Request procedure.
334 * Central requests change in LE connection parameters, peripheral’s Host accepts.
335 * Parallel CPRs attemtped and rejected/cached
336 *
337 * +-----+ +-------+ +-----+
338 * | UT | | LL_C | | LT |
339 * +-----+ +-------+ +-----+
340 * | | |
341 * | LE Connection Update | |
342 * |-------------------------->| |
343 * | | LL_CONNECTION_PARAM_REQ |
344 * | |-------------------------->|
345 * | | |
346 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
347 * ~~~~~ parallel remote CPR is attempted and rejected ~~~~~~~
348 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
349 * | | |
350 * | | LL_CONNECTION_PARAM_RSP |
351 * | |<--------------------------|
352 * | | |
353 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
354 * ~~~~~ parallel remote CPR is attempted and rejected ~~~~~~~
355 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
356 * | | |
357 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
358 * ~~~~~ parallel local CPR is attempted and cached ~~~~~~~
359 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
360 * | | |
361 * | | LL_CONNECTION_UPDATE_IND |
362 * | |-------------------------->|
363 * | | |
364 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
365 * | | |
366 * | LE Connection Update | |
367 * | Complete | |
368 * |<--------------------------| |
369 * | | |
370 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
371 * ~~~~~~~~~ parallel local CPR is now started ~~~~~~~~~~~~
372 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
373 * | | |
374 */
ZTEST(central_loc,test_conn_update_central_loc_accept_reject_2nd_cpr)375 ZTEST(central_loc, test_conn_update_central_loc_accept_reject_2nd_cpr)
376 {
377 struct ll_conn conn_2nd;
378 struct ll_conn conn_3rd;
379 uint8_t err;
380 struct node_tx *tx;
381 struct node_rx_pdu *ntf;
382 struct pdu_data *pdu;
383 uint16_t instant;
384 struct pdu_data_llctrl_reject_ext_ind reject_ext_ind = {
385 .reject_opcode = PDU_DATA_LLCTRL_TYPE_CONN_PARAM_REQ,
386 .error_code = BT_HCI_ERR_UNSUPP_LL_PARAM_VAL
387 };
388 struct node_rx_pu cu = { .status = BT_HCI_ERR_SUCCESS };
389
390 /* Initialize extra connections */
391 test_setup_idx(&conn_2nd, 1);
392 test_setup_idx(&conn_3rd, 2);
393
394 /* Role */
395 test_set_role(&conn, BT_HCI_ROLE_CENTRAL);
396 /* Role */
397 test_set_role(&conn_2nd, BT_HCI_ROLE_PERIPHERAL);
398 /* Role */
399 test_set_role(&conn_3rd, BT_HCI_ROLE_PERIPHERAL);
400 /* Connect */
401 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
402
403 /* Connect */
404 ull_cp_state_set(&conn_2nd, ULL_CP_CONNECTED);
405
406 /* Connect */
407 ull_cp_state_set(&conn_3rd, ULL_CP_CONNECTED);
408 /* Initiate a Connection Parameter Request Procedure */
409 err = ull_cp_conn_update(&conn, INTVL_MIN, INTVL_MAX, LATENCY, TIMEOUT, NULL);
410 zassert_equal(err, BT_HCI_ERR_SUCCESS);
411
412 /* Prepare */
413 event_prepare(&conn);
414
415 /* Tx Queue should have one LL Control PDU */
416 conn_param_req.reference_conn_event_count = event_counter(&conn);
417 lt_rx(LL_CONNECTION_PARAM_REQ, &conn, &tx, &conn_param_req);
418 lt_rx_q_is_empty(&conn);
419
420 /* Done */
421 event_done(&conn);
422
423 /* Release Tx */
424 ull_cp_release_tx(&conn, tx);
425
426 /* Now CPR is active on 'conn' so let 'conn_2nd' attempt to start a CPR */
427 /* Prepare */
428 event_prepare(&conn_2nd);
429
430 /* Tx Queue should NOT have a LL Control PDU */
431 lt_rx_q_is_empty(&conn_2nd);
432
433 /* Rx */
434 lt_tx(LL_CONNECTION_PARAM_REQ, &conn_2nd, &conn_param_req);
435
436 /* Done */
437 event_done(&conn_2nd);
438
439 /* Prepare */
440 event_prepare(&conn_2nd);
441
442 /* Tx Queue should have one LL Control PDU */
443 lt_rx(LL_REJECT_EXT_IND, &conn_2nd, &tx, &reject_ext_ind);
444 lt_rx_q_is_empty(&conn_2nd);
445
446 /* Done */
447 event_done(&conn_2nd);
448
449 /* Release Tx */
450 ull_cp_release_tx(&conn_2nd, tx);
451
452 /* Rx */
453 conn_param_rsp.reference_conn_event_count = conn_param_req.reference_conn_event_count;
454 lt_tx(LL_CONNECTION_PARAM_RSP, &conn, &conn_param_rsp);
455
456 /* Prepare */
457 event_prepare(&conn);
458
459 /* Tx Queue should NOT have a LL Control PDU */
460 lt_rx_q_is_empty(&conn);
461
462 /* Done */
463 event_done(&conn);
464
465 /* Now CPR is active on 'conn' so let 'conn_2nd' attempt to start a CPR again */
466 /* Prepare */
467 event_prepare(&conn_3rd);
468
469 /* Tx Queue should NOT have a LL Control PDU */
470 lt_rx_q_is_empty(&conn_3rd);
471
472 /* Rx */
473 lt_tx(LL_CONNECTION_PARAM_REQ, &conn_3rd, &conn_param_req);
474
475 /* Done */
476 event_done(&conn_3rd);
477
478 /* Prepare */
479 event_prepare(&conn_3rd);
480
481 /* Tx Queue should have one LL Control PDU */
482 lt_rx(LL_REJECT_EXT_IND, &conn_3rd, &tx, &reject_ext_ind);
483 lt_rx_q_is_empty(&conn_3rd);
484
485 /* Done */
486 event_done(&conn_3rd);
487
488 /* Release Tx */
489 ull_cp_release_tx(&conn_3rd, tx);
490
491 /* Initiate a parallel Connection Parameter Request Procedure */
492 err = ull_cp_conn_update(&conn_3rd, INTVL_MIN, INTVL_MAX, LATENCY, TIMEOUT, NULL);
493 zassert_equal(err, BT_HCI_ERR_SUCCESS);
494
495 /* Prepare */
496 event_prepare(&conn_3rd);
497
498 /* Tx Queue should have no LL Control PDU */
499 lt_rx_q_is_empty(&conn_3rd);
500
501 /* Done */
502 event_done(&conn_3rd);
503
504 /* Prepare */
505 event_prepare(&conn_3rd);
506
507 /* Tx Queue should have no LL Control PDU */
508 lt_rx_q_is_empty(&conn_3rd);
509
510 /* Done */
511 event_done(&conn_3rd);
512
513 /* Prepare */
514 event_prepare(&conn);
515
516 /* Tx Queue should have one LL Control PDU */
517 conn_update_ind.instant = event_counter(&conn) + 6U;
518 lt_rx(LL_CONNECTION_UPDATE_IND, &conn, &tx, &conn_update_ind);
519 lt_rx_q_is_empty(&conn);
520
521 /* Done */
522 event_done(&conn);
523
524 /* Save Instant */
525 pdu = (struct pdu_data *)tx->pdu;
526 instant = sys_le16_to_cpu(pdu->llctrl.conn_update_ind.instant);
527
528 /* Release Tx */
529 ull_cp_release_tx(&conn, tx);
530
531 /* */
532 while (!is_instant_reached(&conn, instant)) {
533 /* Prepare */
534 event_prepare(&conn);
535
536 /* Tx Queue should NOT have a LL Control PDU */
537 lt_rx_q_is_empty(&conn);
538
539 /* Done */
540 event_done(&conn);
541
542 /* There should NOT be a host notification */
543 ut_rx_q_is_empty();
544
545 /* Prepare on conn_3rd for parallel CPR */
546 event_prepare(&conn_3rd);
547
548 /* Tx Queue should have no LL Control PDU */
549 lt_rx_q_is_empty(&conn_3rd);
550
551 /* Done on conn_3rd for parallel CPR */
552 event_done(&conn_3rd);
553 }
554
555 /* Prepare */
556 event_prepare(&conn);
557
558 /* Tx Queue should NOT have a LL Control PDU */
559 lt_rx_q_is_empty(&conn);
560
561 /* Done */
562 event_done(&conn);
563
564 /* There should be one host notification */
565 ut_rx_node(NODE_CONN_UPDATE, &ntf, &cu);
566 ut_rx_q_is_empty();
567
568 /* Now the locally initiated CPR on conn_3rd should be allowed to run */
569 /* Prepare */
570 event_prepare(&conn_3rd);
571
572 /* Tx Queue should have one LL Control PDU, indicating parallel CPR is now active */
573 conn_param_req.reference_conn_event_count = event_counter(&conn_3rd);
574 lt_rx(LL_CONNECTION_PARAM_REQ, &conn_3rd, &tx, &conn_param_req);
575 lt_rx_q_is_empty(&conn_3rd);
576
577 /* Done */
578 event_done(&conn_3rd);
579
580 /* Release Tx */
581 ull_cp_release_tx(&conn_3rd, tx);
582
583 /* Release Ntf */
584 release_ntf(ntf);
585
586 /* One less CTXs as the conn_3rd CPR is still 'running' */
587 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt()-1,
588 "Free CTX buffers %d", llcp_ctx_buffers_free());
589 }
590
591 /*
592 * Central-initiated Connection Parameters Request procedure.
593 * Central requests change in LE connection parameters, peripheral
594 * responds with invalid params
595 *
596 * +-----+ +-------+ +-----+
597 * | UT | | LL_C | | LT |
598 * +-----+ +-------+ +-----+
599 * | | |
600 * | LE Connection Update | |
601 * |-------------------------->| |
602 * | | LL_CONNECTION_PARAM_REQ |
603 * | |-------------------------->|
604 * | | |
605 * | | LL_CONNECTION_PARAM_RSP |
606 * | |<--------------------------|
607 * | | |
608 * | | LL_REJECT_EXT_IND |
609 * | |-------------------------->|
610 * | | |
611 * | | |
612 * | | |
613 */
ZTEST(central_loc,test_conn_update_central_loc_invalid_param_rsp)614 ZTEST(central_loc, test_conn_update_central_loc_invalid_param_rsp)
615 {
616 uint8_t err;
617 struct node_tx *tx;
618 struct pdu_data_llctrl_reject_ext_ind reject_ext_ind = {
619 .reject_opcode = PDU_DATA_LLCTRL_TYPE_CONN_PARAM_RSP,
620 .error_code = BT_HCI_ERR_INVALID_LL_PARAM
621 };
622
623 /* Role */
624 test_set_role(&conn, BT_HCI_ROLE_CENTRAL);
625
626 /* Connect */
627 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
628
629 /* Initiate a Connection Parameter Request Procedure */
630 err = ull_cp_conn_update(&conn, INTVL_MIN, INTVL_MAX, LATENCY, TIMEOUT, NULL);
631 zassert_equal(err, BT_HCI_ERR_SUCCESS);
632
633 /* Prepare */
634 event_prepare(&conn);
635
636 /* Tx Queue should have one LL Control PDU */
637 conn_param_req.reference_conn_event_count = event_counter(&conn);
638 lt_rx(LL_CONNECTION_PARAM_REQ, &conn, &tx, &conn_param_req);
639 lt_rx_q_is_empty(&conn);
640
641 /* Rx */
642 lt_tx(LL_CONNECTION_PARAM_RSP, &conn, &conn_param_rsp_invalid);
643
644 /* Done */
645 event_done(&conn);
646
647 /* Release Tx */
648 ull_cp_release_tx(&conn, tx);
649
650 /* Prepare */
651 event_prepare(&conn);
652
653 /* Tx Queue should have one LL Control PDU */
654 lt_rx(LL_REJECT_EXT_IND, &conn, &tx, &reject_ext_ind);
655 lt_rx_q_is_empty(&conn);
656
657 /* Done */
658 event_done(&conn);
659
660 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
661 "Free CTX buffers %d", llcp_ctx_buffers_free());
662 }
663
664 /*
665 * Central-initiated Connection Parameters Request procedure.
666 * Central requests change in LE connection parameters, peripheral’s Host accepts.
667 *
668 * +-----+ +-------+ +-----+
669 * | UT | | LL_C | | LT |
670 * +-----+ +-------+ +-----+
671 * | | |
672 * | LE Connection Update | |
673 * |-------------------------->| |
674 * | | LL_CONNECTION_PARAM_REQ |
675 * | |-------------------------->|
676 * | | |
677 * | | LL_REJECT_IND |
678 * | |<--------------------------|
679 * | | |
680 * ~~~~~~~~~~~~~~~~~~ TERMINATE CONNECTION ~~~~~~~~~~~~~~~~~
681 * | | |
682 * | | |
683 */
ZTEST(central_loc,test_conn_update_central_loc_invalid_rsp)684 ZTEST(central_loc, test_conn_update_central_loc_invalid_rsp)
685 {
686 uint8_t err;
687 struct node_tx *tx;
688 struct pdu_data_llctrl_reject_ind reject_ind = {
689 .error_code = BT_HCI_ERR_LL_PROC_COLLISION
690 };
691
692 /* Role */
693 test_set_role(&conn, BT_HCI_ROLE_CENTRAL);
694
695 /* Connect */
696 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
697
698 /* Initiate a Connection Parameter Request Procedure */
699 err = ull_cp_conn_update(&conn, INTVL_MIN, INTVL_MAX, LATENCY, TIMEOUT, NULL);
700 zassert_equal(err, BT_HCI_ERR_SUCCESS);
701
702 /* Prepare */
703 event_prepare(&conn);
704
705 /* Tx Queue should have one LL Control PDU */
706 conn_param_req.reference_conn_event_count = event_counter(&conn);
707 lt_rx(LL_CONNECTION_PARAM_REQ, &conn, &tx, &conn_param_req);
708 lt_rx_q_is_empty(&conn);
709
710 /* Rx */
711 lt_tx(LL_REJECT_IND, &conn, &reject_ind);
712
713 /* Done */
714 event_done(&conn);
715
716 /* Release Tx */
717 ull_cp_release_tx(&conn, tx);
718
719 /* Termination 'triggered' */
720 zassert_equal(conn.llcp_terminate.reason_final, BT_HCI_ERR_LMP_PDU_NOT_ALLOWED,
721 "Terminate reason %d", conn.llcp_terminate.reason_final);
722
723 /* There should be no host notifications */
724 ut_rx_q_is_empty();
725
726 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
727 "Free CTX buffers %d", llcp_ctx_buffers_free());
728
729 }
730
731 /*
732 * Central-initiated Connection Parameters Request procedure.
733 * Central requests change in LE connection parameters, peripheral’s Host rejects.
734 *
735 * +-----+ +-------+ +-----+
736 * | UT | | LL_C | | LT |
737 * +-----+ +-------+ +-----+
738 * | | |
739 * | LE Connection Update | |
740 * |-------------------------->| |
741 * | | LL_CONNECTION_PARAM_REQ |
742 * | |-------------------------->|
743 * | | |
744 * | | LL_REJECT_EXT_IND |
745 * | |<--------------------------|
746 * | | |
747 * | LE Connection Update | |
748 * | Complete | |
749 * |<--------------------------| |
750 * | | |
751 */
ZTEST(central_loc,test_conn_update_central_loc_reject)752 ZTEST(central_loc, test_conn_update_central_loc_reject)
753 {
754 uint8_t err;
755 struct node_tx *tx;
756 struct node_rx_pdu *ntf;
757
758 struct pdu_data_llctrl_reject_ext_ind reject_ext_ind = {
759 .reject_opcode = PDU_DATA_LLCTRL_TYPE_CONN_PARAM_REQ,
760 .error_code = BT_HCI_ERR_UNACCEPT_CONN_PARAM
761 };
762
763 struct node_rx_pu cu = { .status = BT_HCI_ERR_UNACCEPT_CONN_PARAM };
764
765 /* Role */
766 test_set_role(&conn, BT_HCI_ROLE_CENTRAL);
767
768 /* Connect */
769 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
770
771 /* Initiate a Connection Parameter Request Procedure */
772 err = ull_cp_conn_update(&conn, INTVL_MIN, INTVL_MAX, LATENCY, TIMEOUT, NULL);
773 zassert_equal(err, BT_HCI_ERR_SUCCESS);
774
775 /* Prepare */
776 event_prepare(&conn);
777
778 /* Tx Queue should have one LL Control PDU */
779 conn_param_req.reference_conn_event_count = event_counter(&conn);
780 lt_rx(LL_CONNECTION_PARAM_REQ, &conn, &tx, &conn_param_req);
781 lt_rx_q_is_empty(&conn);
782
783 /* Rx */
784 lt_tx(LL_REJECT_EXT_IND, &conn, &reject_ext_ind);
785
786 /* Done */
787 event_done(&conn);
788
789 /* Release Tx */
790 ull_cp_release_tx(&conn, tx);
791
792 /* There should be one host notification */
793 ut_rx_node(NODE_CONN_UPDATE, &ntf, &cu);
794 ut_rx_q_is_empty();
795
796 /* Release Ntf */
797 release_ntf(ntf);
798 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
799 "Free CTX buffers %d", llcp_ctx_buffers_free());
800 }
801
802 /*
803 * Central-initiated Connection Parameters Request procedure.
804 * Central requests change in LE connection parameters, peripheral’s Host is legacy.
805 *
806 * +-----+ +-------+ +-----+
807 * | UT | | LL_C | | LT |
808 * +-----+ +-------+ +-----+
809 * | | |
810 * | LE Connection Update | |
811 * |-------------------------->| |
812 * | | LL_CONNECTION_PARAM_REQ |
813 * | |-------------------------->|
814 * | | |
815 * | | LL_REJECT_EXT_IND |
816 * | |<--------------------------|
817 * | | |
818 * | | LL_CONNECTION_UPDATE_IND |
819 * | |-------------------------->|
820 * | | |
821 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
822 * | | |
823 * | LE Connection Update | |
824 * | Complete | |
825 * |<--------------------------| |
826 * | | |
827 */
ZTEST(central_loc,test_conn_update_central_loc_remote_legacy)828 ZTEST(central_loc, test_conn_update_central_loc_remote_legacy)
829 {
830 bool feature_bit_param_req;
831 uint8_t err;
832 struct node_tx *tx;
833 struct node_rx_pdu *ntf;
834 struct pdu_data *pdu;
835 uint16_t instant;
836
837 struct pdu_data_llctrl_reject_ext_ind reject_ext_ind = {
838 .reject_opcode = PDU_DATA_LLCTRL_TYPE_CONN_PARAM_REQ,
839 .error_code = BT_HCI_ERR_UNSUPP_REMOTE_FEATURE
840 };
841
842 struct node_rx_pu cu = { .status = BT_HCI_ERR_SUCCESS };
843
844 /* Role */
845 test_set_role(&conn, BT_HCI_ROLE_CENTRAL);
846
847 /* Connect */
848 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
849
850 /* Initiate a Connection Parameter Request Procedure */
851 err = ull_cp_conn_update(&conn, INTVL_MIN, INTVL_MAX, LATENCY, TIMEOUT, NULL);
852 zassert_equal(err, BT_HCI_ERR_SUCCESS);
853
854 /* Prepare */
855 event_prepare(&conn);
856
857 /* Tx Queue should have one LL Control PDU */
858 conn_param_req.reference_conn_event_count = event_counter(&conn);
859 lt_rx(LL_CONNECTION_PARAM_REQ, &conn, &tx, &conn_param_req);
860 lt_rx_q_is_empty(&conn);
861
862 /* Rx */
863 lt_tx(LL_REJECT_EXT_IND, &conn, &reject_ext_ind);
864
865 /* Done */
866 event_done(&conn);
867
868 /* Release Tx */
869 ull_cp_release_tx(&conn, tx);
870
871 /* Prepare */
872 event_prepare(&conn);
873
874 /* Check that feature Param Reg. is unmasked */
875 feature_bit_param_req = test_get_feature_conn_param_req(&conn);
876 zassert_equal(feature_bit_param_req, false, "Feature bit not unmasked");
877
878 /* Tx Queue should have one LL Control PDU */
879 conn_update_ind.instant = event_counter(&conn) + 6U;
880 lt_rx(LL_CONNECTION_UPDATE_IND, &conn, &tx, &conn_update_ind);
881 lt_rx_q_is_empty(&conn);
882
883 /* Done */
884 event_done(&conn);
885
886 /* Save Instant */
887 pdu = (struct pdu_data *)tx->pdu;
888 instant = sys_le16_to_cpu(pdu->llctrl.conn_update_ind.instant);
889
890 /* Release Tx */
891 ull_cp_release_tx(&conn, tx);
892
893 /* */
894 while (!is_instant_reached(&conn, instant)) {
895 /* Prepare */
896 event_prepare(&conn);
897
898 /* Tx Queue should NOT have a LL Control PDU */
899 lt_rx_q_is_empty(&conn);
900
901 /* Done */
902 event_done(&conn);
903
904 /* There should NOT be a host notification */
905 ut_rx_q_is_empty();
906 }
907
908 /* Prepare */
909 event_prepare(&conn);
910
911 /* Tx Queue should NOT have a LL Control PDU */
912 lt_rx_q_is_empty(&conn);
913
914 /* Done */
915 event_done(&conn);
916
917 /* There should be one host notification */
918 ut_rx_node(NODE_CONN_UPDATE, &ntf, &cu);
919 ut_rx_q_is_empty();
920
921 /* Release Ntf */
922 release_ntf(ntf);
923 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
924 "Free CTX buffers %d", llcp_ctx_buffers_free());
925 }
926
927 /*
928 * Central-initiated Connection Parameters Request procedure.
929 * Central requests change in LE connection parameters, peripheral’s Controller do not
930 * support Connection Parameters Request procedure, features not exchanged.
931 *
932 * +-----+ +-------+ +-----+
933 * | UT | | LL_C | | LT |
934 * +-----+ +-------+ +-----+
935 * | | |
936 * | LE Connection Update | |
937 * |-------------------------->| |
938 * | | LL_CONNECTION_PARAM_REQ |
939 * | |-------------------------->|
940 * | | |
941 * | | LL_UNKNOWN_RSP |
942 * | |<--------------------------|
943 * | | |
944 * | | LL_CONNECTION_UPDATE_IND |
945 * | |-------------------------->|
946 * | | |
947 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
948 * | | |
949 * | LE Connection Update | |
950 * | Complete | |
951 * |<--------------------------| |
952 * | | |
953 */
ZTEST(central_loc,test_conn_update_central_loc_unsupp_wo_feat_exch)954 ZTEST(central_loc, test_conn_update_central_loc_unsupp_wo_feat_exch)
955 {
956 bool feature_bit_param_req;
957 uint8_t err;
958 struct node_tx *tx;
959 struct node_rx_pdu *ntf;
960 struct pdu_data *pdu;
961 uint16_t instant;
962
963 struct pdu_data_llctrl_unknown_rsp unknown_rsp = {
964 .type = PDU_DATA_LLCTRL_TYPE_CONN_PARAM_REQ
965 };
966
967 struct node_rx_pu cu = { .status = BT_HCI_ERR_SUCCESS };
968
969 /* Role */
970 test_set_role(&conn, BT_HCI_ROLE_CENTRAL);
971
972 /* Connect */
973 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
974
975 /* Initiate a Connection Parameter Request Procedure */
976 err = ull_cp_conn_update(&conn, INTVL_MIN, INTVL_MAX, LATENCY, TIMEOUT, NULL);
977 zassert_equal(err, BT_HCI_ERR_SUCCESS);
978
979 /* Prepare */
980 event_prepare(&conn);
981
982 /* Tx Queue should have one LL Control PDU */
983 conn_param_req.reference_conn_event_count = event_counter(&conn);
984 lt_rx(LL_CONNECTION_PARAM_REQ, &conn, &tx, &conn_param_req);
985 lt_rx_q_is_empty(&conn);
986
987 /* Rx */
988 lt_tx(LL_UNKNOWN_RSP, &conn, &unknown_rsp);
989
990 /* Done */
991 event_done(&conn);
992
993 /* Release Tx */
994 ull_cp_release_tx(&conn, tx);
995
996 /* Prepare */
997 event_prepare(&conn);
998
999 /* Check that feature Param Reg. is unmasked */
1000 feature_bit_param_req = test_get_feature_conn_param_req(&conn);
1001 zassert_equal(feature_bit_param_req, false, "Feature bit not unmasked");
1002
1003 /* Tx Queue should have one LL Control PDU */
1004 conn_update_ind.instant = event_counter(&conn) + 6U;
1005 lt_rx(LL_CONNECTION_UPDATE_IND, &conn, &tx, &conn_update_ind);
1006 lt_rx_q_is_empty(&conn);
1007
1008 /* Done */
1009 event_done(&conn);
1010
1011 /* Save Instant */
1012 pdu = (struct pdu_data *)tx->pdu;
1013 instant = sys_le16_to_cpu(pdu->llctrl.conn_update_ind.instant);
1014
1015 /* Release Tx */
1016 ull_cp_release_tx(&conn, tx);
1017
1018 /* */
1019 while (!is_instant_reached(&conn, instant)) {
1020 /* Prepare */
1021 event_prepare(&conn);
1022
1023 /* Tx Queue should NOT have a LL Control PDU */
1024 lt_rx_q_is_empty(&conn);
1025
1026 /* Done */
1027 event_done(&conn);
1028
1029 /* There should NOT be a host notification */
1030 ut_rx_q_is_empty();
1031 }
1032
1033 /* Prepare */
1034 event_prepare(&conn);
1035
1036 /* Tx Queue should NOT have a LL Control PDU */
1037 lt_rx_q_is_empty(&conn);
1038
1039 /* Done */
1040 event_done(&conn);
1041
1042 /* There should be one host notification */
1043 ut_rx_node(NODE_CONN_UPDATE, &ntf, &cu);
1044 ut_rx_q_is_empty();
1045
1046 /* Release Ntf */
1047 release_ntf(ntf);
1048 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
1049 "Free CTX buffers %d", llcp_ctx_buffers_free());
1050 }
1051
1052 /*
1053 * Central-initiated Connection Parameters Request procedure.
1054 * Central requests change in LE connection parameters, peripheral’s Controller do not
1055 * support Connection Parameters Request procedure, features exchanged.
1056 *
1057 * +-----+ +-------+ +-----+
1058 * | UT | | LL_C | | LT |
1059 * +-----+ +-------+ +-----+
1060 * | | |
1061 * | LE Connection Update | |
1062 * |-------------------------->| |
1063 * | | LL_CONNECTION_UPDATE_IND |
1064 * | |-------------------------->|
1065 * | | |
1066 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1067 * | | |
1068 * | LE Connection Update | |
1069 * | Complete | |
1070 * |<--------------------------| |
1071 * | | |
1072 */
ZTEST(central_loc,test_conn_update_central_loc_unsupp_w_feat_exch)1073 ZTEST(central_loc, test_conn_update_central_loc_unsupp_w_feat_exch)
1074 {
1075 uint8_t err;
1076 struct node_tx *tx;
1077 struct node_rx_pdu *ntf;
1078 struct pdu_data *pdu;
1079 uint16_t instant;
1080
1081 struct node_rx_pu cu = { .status = BT_HCI_ERR_SUCCESS };
1082
1083 /* Disable feature */
1084 test_unmask_feature_conn_param_req(&conn);
1085
1086 /* Role */
1087 test_set_role(&conn, BT_HCI_ROLE_CENTRAL);
1088
1089 /* Connect */
1090 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
1091
1092 /* Initiate a Connection Parameter Request Procedure */
1093 err = ull_cp_conn_update(&conn, INTVL_MIN, INTVL_MAX, LATENCY, TIMEOUT, NULL);
1094 zassert_equal(err, BT_HCI_ERR_SUCCESS);
1095
1096 /* Prepare */
1097 event_prepare(&conn);
1098
1099 /* Tx Queue should have one LL Control PDU */
1100 conn_update_ind.instant = event_counter(&conn) + 6U;
1101 lt_rx(LL_CONNECTION_UPDATE_IND, &conn, &tx, &conn_update_ind);
1102 lt_rx_q_is_empty(&conn);
1103
1104 /* Done */
1105 event_done(&conn);
1106
1107 /* Release Tx */
1108 ull_cp_release_tx(&conn, tx);
1109
1110 /* Save Instant */
1111 pdu = (struct pdu_data *)tx->pdu;
1112 instant = sys_le16_to_cpu(pdu->llctrl.conn_update_ind.instant);
1113
1114 /* */
1115 while (!is_instant_reached(&conn, instant)) {
1116 /* Prepare */
1117 event_prepare(&conn);
1118
1119 /* Tx Queue should NOT have a LL Control PDU */
1120 lt_rx_q_is_empty(&conn);
1121
1122 /* Done */
1123 event_done(&conn);
1124
1125 /* There should NOT be a host notification */
1126 ut_rx_q_is_empty();
1127 }
1128
1129 /* Prepare */
1130 event_prepare(&conn);
1131
1132 /* Tx Queue should NOT have a LL Control PDU */
1133 lt_rx_q_is_empty(&conn);
1134
1135 /* Done */
1136 event_done(&conn);
1137
1138 /* There should be one host notification */
1139 ut_rx_node(NODE_CONN_UPDATE, &ntf, &cu);
1140 ut_rx_q_is_empty();
1141
1142 /* Release Ntf */
1143 release_ntf(ntf);
1144 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
1145 "Free CTX buffers %d", llcp_ctx_buffers_free());
1146 }
1147
1148 /*
1149 * (A)
1150 * Central-initiated Connection Parameters Request procedure.
1151 * Central requests change in LE connection parameters, peripheral’s Host accepts.
1152 *
1153 * and
1154 *
1155 * (B)
1156 * Peripheral-initiated Connection Parameters Request procedure.
1157 * Procedure collides and is rejected.
1158 *
1159 * +-----+ +-------+ +-----+
1160 * | UT | | LL_C | | LT |
1161 * +-----+ +-------+ +-----+
1162 * | | |
1163 * | LE Connection Update | |
1164 * |-------------------------->| |
1165 * | | LL_CONNECTION_PARAM_REQ | (A)
1166 * | |-------------------------->|
1167 * | | |
1168 * | | LL_CONNECTION_PARAM_REQ | (B)
1169 * | |<--------------------------|
1170 * | | |
1171 * | <---------------------> |
1172 * | < PROCEDURE COLLISION > |
1173 * | <---------------------> |
1174 * | | |
1175 * | | LL_REJECT_EXT_IND | (B)
1176 * | |-------------------------->|
1177 * | | |
1178 * | | LL_CONNECTION_PARAM_RSP | (A)
1179 * | |<--------------------------|
1180 * | | |
1181 * | | LL_CONNECTION_UPDATE_IND | (A)
1182 * | |-------------------------->|
1183 * | | |
1184 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1185 * | | |
1186 * | LE Connection Update | |
1187 * | Complete | |
1188 * |<--------------------------| |
1189 * | | |
1190 */
ZTEST(central_loc,test_conn_update_central_loc_collision)1191 ZTEST(central_loc, test_conn_update_central_loc_collision)
1192 {
1193 uint8_t err;
1194 struct node_tx *tx;
1195 struct node_rx_pdu *ntf;
1196 struct pdu_data *pdu;
1197 uint16_t instant;
1198
1199 struct node_rx_pu cu = { .status = BT_HCI_ERR_SUCCESS };
1200
1201 struct pdu_data_llctrl_reject_ext_ind reject_ext_ind = {
1202 .reject_opcode = PDU_DATA_LLCTRL_TYPE_CONN_PARAM_REQ,
1203 .error_code = BT_HCI_ERR_LL_PROC_COLLISION
1204 };
1205
1206 /* Role */
1207 test_set_role(&conn, BT_HCI_ROLE_CENTRAL);
1208
1209 /* Emulate valid feature exchange */
1210 conn.llcp.fex.valid = 1;
1211
1212 /* Connect */
1213 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
1214
1215 /* (A) Initiate a Connection Parameter Request Procedure */
1216 err = ull_cp_conn_update(&conn, INTVL_MIN, INTVL_MAX, LATENCY, TIMEOUT, NULL);
1217 zassert_equal(err, BT_HCI_ERR_SUCCESS);
1218
1219 /* Prepare */
1220 event_prepare(&conn);
1221
1222 /* (A) Tx Queue should have one LL Control PDU */
1223 conn_param_req.reference_conn_event_count = event_counter(&conn);
1224 lt_rx(LL_CONNECTION_PARAM_REQ, &conn, &tx, &conn_param_req);
1225 lt_rx_q_is_empty(&conn);
1226
1227 /* (B) Rx */
1228 lt_tx(LL_CONNECTION_PARAM_REQ, &conn, req_B);
1229
1230 /* Done */
1231 event_done(&conn);
1232
1233 /* Release Tx */
1234 ull_cp_release_tx(&conn, tx);
1235
1236 /* Prepare */
1237 event_prepare(&conn);
1238
1239 /* (B) Tx Queue should have one LL Control PDU */
1240 lt_rx(LL_REJECT_EXT_IND, &conn, &tx, &reject_ext_ind);
1241 lt_rx_q_is_empty(&conn);
1242
1243 /* Done */
1244 event_done(&conn);
1245
1246 /* Release Tx */
1247 ull_cp_release_tx(&conn, tx);
1248
1249 /**/
1250
1251 /* Prepare */
1252 event_prepare(&conn);
1253
1254 /* (B) Tx Queue should NOT have a LL Control PDU */
1255 lt_rx_q_is_empty(&conn);
1256
1257 /* (A) Rx */
1258 lt_tx(LL_CONNECTION_PARAM_RSP, &conn, &conn_param_rsp);
1259
1260 /* Done */
1261 event_done(&conn);
1262
1263 /* Prepare */
1264 event_prepare(&conn);
1265
1266 /* (A) Tx Queue should have one LL Control PDU */
1267 conn_update_ind.instant = event_counter(&conn) + 6U;
1268 lt_rx(LL_CONNECTION_UPDATE_IND, &conn, &tx, &conn_update_ind);
1269 lt_rx_q_is_empty(&conn);
1270
1271 /* Done */
1272 event_done(&conn);
1273
1274 /* Save Instant */
1275 pdu = (struct pdu_data *)tx->pdu;
1276 instant = sys_le16_to_cpu(pdu->llctrl.conn_update_ind.instant);
1277
1278 /* Release Tx */
1279 ull_cp_release_tx(&conn, tx);
1280
1281 /* */
1282 while (!is_instant_reached(&conn, instant)) {
1283 /* Prepare */
1284 event_prepare(&conn);
1285
1286 /* (A) Tx Queue should NOT have a LL Control PDU */
1287 lt_rx_q_is_empty(&conn);
1288
1289 /* Done */
1290 event_done(&conn);
1291
1292 /* (A) There should NOT be a host notification */
1293 ut_rx_q_is_empty();
1294 }
1295
1296 /* Prepare */
1297 event_prepare(&conn);
1298
1299 /* (A) Tx Queue should NOT have a LL Control PDU */
1300 lt_rx_q_is_empty(&conn);
1301
1302 /* Done */
1303 event_done(&conn);
1304
1305 /* (A) There should be one host notification */
1306 ut_rx_node(NODE_CONN_UPDATE, &ntf, &cu);
1307 ut_rx_q_is_empty();
1308
1309 /* Release Ntf */
1310 release_ntf(ntf);
1311 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
1312 "Free CTX buffers %d", llcp_ctx_buffers_free());
1313 }
1314
1315 /*
1316 * Peripheral-initiated Connection Parameters Request procedure.
1317 * Peripheral requests change in LE connection parameters, central’s Host accepts.
1318 *
1319 * +-----+ +-------+ +-----+
1320 * | UT | | LL_C | | LT |
1321 * +-----+ +-------+ +-----+
1322 * | | |
1323 * | | LL_CONNECTION_PARAM_REQ |
1324 * | |<--------------------------|
1325 * | | |
1326 * | LE Remote Connection | |
1327 * | Parameter Request | |
1328 * |<--------------------------| |
1329 * | LE Remote Connection | |
1330 * | Parameter Request | |
1331 * | Reply | |
1332 * |-------------------------->| |
1333 * | | |
1334 * | | LL_CONNECTION_UPDATE_IND |
1335 * | |-------------------------->|
1336 * | | |
1337 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1338 * | | |
1339 * | LE Connection Update | |
1340 * | Complete | |
1341 * |<--------------------------| |
1342 * | | |
1343 */
ZTEST(central_rem,test_conn_update_central_rem_accept)1344 ZTEST(central_rem, test_conn_update_central_rem_accept)
1345 {
1346 struct node_tx *tx;
1347 struct node_rx_pdu *ntf;
1348 struct pdu_data *pdu;
1349 uint16_t instant;
1350
1351 struct node_rx_pu cu = { .status = BT_HCI_ERR_SUCCESS };
1352
1353 /* Role */
1354 test_set_role(&conn, BT_HCI_ROLE_CENTRAL);
1355
1356 /* Connect */
1357 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
1358
1359 /* Prepare */
1360 event_prepare(&conn);
1361
1362 /* Rx */
1363 lt_tx(LL_CONNECTION_PARAM_REQ, &conn, &conn_param_req);
1364
1365 /* Done */
1366 event_done(&conn);
1367
1368 /*******************/
1369
1370 /* There should be one host notification */
1371 ut_rx_pdu(LL_CONNECTION_PARAM_REQ, &ntf, &conn_param_req);
1372 ut_rx_q_is_empty();
1373
1374 /* Release Ntf */
1375 release_ntf(ntf);
1376
1377 /*******************/
1378
1379 ull_cp_conn_param_req_reply(&conn);
1380
1381 /*******************/
1382
1383 /* Prepare */
1384 event_prepare(&conn);
1385
1386 /* Tx Queue should have one LL Control PDU */
1387 conn_update_ind.instant = event_counter(&conn) + 6U;
1388 lt_rx(LL_CONNECTION_UPDATE_IND, &conn, &tx, &conn_update_ind);
1389 lt_rx_q_is_empty(&conn);
1390
1391 /* Done */
1392 event_done(&conn);
1393
1394 /* Save Instant */
1395 pdu = (struct pdu_data *)tx->pdu;
1396 instant = sys_le16_to_cpu(pdu->llctrl.conn_update_ind.instant);
1397
1398 /* Release Tx */
1399 ull_cp_release_tx(&conn, tx);
1400
1401 /* */
1402 while (!is_instant_reached(&conn, instant)) {
1403 /* Prepare */
1404 event_prepare(&conn);
1405
1406 /* Tx Queue should NOT have a LL Control PDU */
1407 lt_rx_q_is_empty(&conn);
1408
1409 /* Done */
1410 event_done(&conn);
1411
1412 /* There should NOT be a host notification */
1413 ut_rx_q_is_empty();
1414 }
1415
1416 /* Prepare */
1417 event_prepare(&conn);
1418
1419 /* Tx Queue should NOT have a LL Control PDU */
1420 lt_rx_q_is_empty(&conn);
1421
1422 /* Done */
1423 event_done(&conn);
1424
1425 /* There should be one host notification */
1426 ut_rx_node(NODE_CONN_UPDATE, &ntf, &cu);
1427 ut_rx_q_is_empty();
1428
1429 /* Release Ntf */
1430 release_ntf(ntf);
1431 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
1432 "Free CTX buffers %d", llcp_ctx_buffers_free());
1433 }
1434
1435 /*
1436 * Peripheral-initiated Connection Parameters Request procedure.
1437 * Peripheral requests change in LE connection with invalid parameters,
1438 *
1439 * +-----+ +-------+ +-----+
1440 * | UT | | LL_C | | LT |
1441 * +-----+ +-------+ +-----+
1442 * | | |
1443 * | | LL_CONNECTION_PARAM_REQ |
1444 * | |<--------------------------|
1445 * | | |
1446 * | | |
1447 * | | LL_REJECT_EXT_IND |
1448 * | |-------------------------->|
1449 * | | |
1450 * | | |
1451 */
ZTEST(central_rem,test_conn_update_central_rem_invalid_req)1452 ZTEST(central_rem, test_conn_update_central_rem_invalid_req)
1453 {
1454 struct node_tx *tx;
1455 struct pdu_data_llctrl_reject_ext_ind reject_ext_ind = {
1456 .reject_opcode = PDU_DATA_LLCTRL_TYPE_CONN_PARAM_REQ,
1457 .error_code = BT_HCI_ERR_INVALID_LL_PARAM
1458 };
1459
1460 /* Role */
1461 test_set_role(&conn, BT_HCI_ROLE_CENTRAL);
1462
1463 /* Connect */
1464 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
1465
1466 /* Prepare */
1467 event_prepare(&conn);
1468
1469 /* Rx */
1470 lt_tx(LL_CONNECTION_PARAM_REQ, &conn, &conn_param_req_invalid);
1471
1472 /* Done */
1473 event_done(&conn);
1474
1475 /* Prepare */
1476 event_prepare(&conn);
1477
1478 /* Tx Queue should have one LL Control PDU */
1479 lt_rx(LL_REJECT_EXT_IND, &conn, &tx, &reject_ext_ind);
1480 lt_rx_q_is_empty(&conn);
1481
1482 /* Done */
1483 event_done(&conn);
1484
1485 /* Release Tx */
1486 ull_cp_release_tx(&conn, tx);
1487 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
1488 "Free CTX buffers %d", llcp_ctx_buffers_free());
1489
1490 }
1491
1492 /*
1493 * Peripheral-initiated Connection Parameters Request procedure.
1494 * Peripheral requests change in LE connection parameters, central’s Host rejects.
1495 *
1496 * +-----+ +-------+ +-----+
1497 * | UT | | LL_C | | LT |
1498 * +-----+ +-------+ +-----+
1499 * | | |
1500 * | | LL_CONNECTION_PARAM_REQ |
1501 * | |<--------------------------|
1502 * | | |
1503 * | LE Remote Connection | |
1504 * | Parameter Request | |
1505 * |<--------------------------| |
1506 * | LE Remote Connection | |
1507 * | Parameter Request | |
1508 * | Negative Reply | |
1509 * |-------------------------->| |
1510 * | | |
1511 * | | LL_REJECT_EXT_IND |
1512 * | |-------------------------->|
1513 * | | |
1514 */
ZTEST(central_rem,test_conn_update_central_rem_reject)1515 ZTEST(central_rem, test_conn_update_central_rem_reject)
1516 {
1517 struct node_tx *tx;
1518 struct node_rx_pdu *ntf;
1519
1520 struct pdu_data_llctrl_reject_ext_ind reject_ext_ind = {
1521 .reject_opcode = PDU_DATA_LLCTRL_TYPE_CONN_PARAM_REQ,
1522 .error_code = BT_HCI_ERR_UNACCEPT_CONN_PARAM
1523 };
1524
1525 /* Role */
1526 test_set_role(&conn, BT_HCI_ROLE_CENTRAL);
1527
1528 /* Connect */
1529 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
1530
1531 /* Prepare */
1532 event_prepare(&conn);
1533
1534 /* Rx */
1535 lt_tx(LL_CONNECTION_PARAM_REQ, &conn, &conn_param_req);
1536
1537 /* Done */
1538 event_done(&conn);
1539
1540 /*******************/
1541
1542 /* There should be one host notification */
1543 ut_rx_pdu(LL_CONNECTION_PARAM_REQ, &ntf, &conn_param_req);
1544 ut_rx_q_is_empty();
1545
1546 /* Release Ntf */
1547 release_ntf(ntf);
1548
1549 /*******************/
1550
1551 ull_cp_conn_param_req_neg_reply(&conn, BT_HCI_ERR_UNACCEPT_CONN_PARAM);
1552
1553 /*******************/
1554
1555 /* Prepare */
1556 event_prepare(&conn);
1557
1558 /* Tx Queue should have one LL Control PDU */
1559 lt_rx(LL_REJECT_EXT_IND, &conn, &tx, &reject_ext_ind);
1560 lt_rx_q_is_empty(&conn);
1561
1562 /* Done */
1563 event_done(&conn);
1564
1565 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
1566 "Free CTX buffers %d", llcp_ctx_buffers_free());
1567 }
1568
1569 /*
1570 * (A)
1571 * Peripheral-initiated Connection Parameters Request procedure.
1572 * Peripheral requests change in LE connection parameters, central’s Host accepts.
1573 *
1574 * and
1575 *
1576 * (B)
1577 * Central-initiated Connection Parameters Request procedure.
1578 * Central requests change in LE connection parameters, peripheral’s Host accepts.
1579 *
1580 * NOTE:
1581 * Central-initiated Connection Parameters Request procedure is paused.
1582 * Peripheral-initiated Connection Parameters Request procedure is finished.
1583 * Central-initiated Connection Parameters Request procedure is resumed.
1584 *
1585 * +-----+ +-------+ +-----+
1586 * | UT | | LL_C | | LT |
1587 * +-----+ +-------+ +-----+
1588 * | | |
1589 * | | LL_CONNECTION_PARAM_REQ |
1590 * | |<--------------------------| (A)
1591 * | | |
1592 * | LE Connection Update | |
1593 * |-------------------------->| | (B)
1594 * | | |
1595 * | <------------------------> |
1596 * | < LOCAL PROCEDURE PAUSED > |
1597 * | <------------------------> |
1598 * | | |
1599 * | LE Remote Connection | |
1600 * | Parameter Request | |
1601 * |<--------------------------| | (A)
1602 * | LE Remote Connection | |
1603 * | Parameter Request | |
1604 * | Reply | |
1605 * |-------------------------->| | (A)
1606 * | | |
1607 * | | LL_CONNECTION_UPDATE_IND |
1608 * | |-------------------------->| (A)
1609 * | | |
1610 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1611 * | | |
1612 * | LE Connection Update | |
1613 * | Complete | |
1614 * |<--------------------------| | (A)
1615 * | | |
1616 * | <-------------------------> |
1617 * | < LOCAL PROCEDURE RESUMED > |
1618 * | <-------------------------> |
1619 * | | |
1620 * | | LL_CONNECTION_PARAM_REQ |
1621 * | |-------------------------->| (B)
1622 * | | |
1623 * | | LL_CONNECTION_PARAM_RSP |
1624 * | |<--------------------------| (B)
1625 * | | |
1626 * | | LL_CONNECTION_UPDATE_IND |
1627 * | |-------------------------->| (B)
1628 * | | |
1629 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1630 * | | |
1631 * | LE Connection Update | |
1632 * | Complete | |
1633 * |<--------------------------| | (B)
1634 * | | |
1635 */
ZTEST(central_rem,test_conn_update_central_rem_collision)1636 ZTEST(central_rem, test_conn_update_central_rem_collision)
1637 {
1638 uint8_t err;
1639 struct node_tx *tx;
1640 struct node_rx_pdu *ntf;
1641 struct pdu_data *pdu;
1642 uint16_t instant;
1643
1644 struct node_rx_pu cu = { .status = BT_HCI_ERR_SUCCESS };
1645
1646 /* Role */
1647 test_set_role(&conn, BT_HCI_ROLE_CENTRAL);
1648
1649 /* Connect */
1650 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
1651
1652 /*******************/
1653
1654 /* Prepare */
1655 event_prepare(&conn);
1656
1657 /* (A) Rx */
1658 lt_tx(LL_CONNECTION_PARAM_REQ, &conn, &conn_param_req);
1659
1660 /* Done */
1661 event_done(&conn);
1662
1663 /*******************/
1664
1665 /* (B) Initiate a Connection Parameter Request Procedure */
1666 err = ull_cp_conn_update(&conn, req_B->interval_min, req_B->interval_max, req_B->latency,
1667 req_B->timeout, NULL);
1668 zassert_equal(err, BT_HCI_ERR_SUCCESS);
1669
1670 /* Prepare */
1671 event_prepare(&conn);
1672
1673 /* (B) Tx Queue should NOT have a LL Control PDU */
1674 lt_rx_q_is_empty(&conn);
1675
1676 /* Done */
1677 event_done(&conn);
1678
1679 /*******************/
1680
1681 /* (A) There should be one host notification */
1682 ut_rx_pdu(LL_CONNECTION_PARAM_REQ, &ntf, &conn_param_req);
1683 ut_rx_q_is_empty();
1684
1685 /* Release Ntf */
1686 release_ntf(ntf);
1687
1688 /*******************/
1689
1690 /* (A) */
1691 ull_cp_conn_param_req_reply(&conn);
1692
1693 /*******************/
1694
1695 /* Prepare */
1696 event_prepare(&conn);
1697
1698 /* (A) Tx Queue should have one LL Control PDU */
1699 conn_update_ind.instant = event_counter(&conn) + 6U;
1700 lt_rx(LL_CONNECTION_UPDATE_IND, &conn, &tx, &conn_update_ind);
1701 lt_rx_q_is_empty(&conn);
1702
1703 /* Done */
1704 event_done(&conn);
1705
1706 /* Save Instant */
1707 pdu = (struct pdu_data *)tx->pdu;
1708 instant = sys_le16_to_cpu(pdu->llctrl.conn_update_ind.instant);
1709
1710 /* Release Tx */
1711 ull_cp_release_tx(&conn, tx);
1712
1713 /* */
1714 while (!is_instant_reached(&conn, instant)) {
1715 /* Prepare */
1716 event_prepare(&conn);
1717
1718 /* (A) Tx Queue should NOT have a LL Control PDU */
1719 lt_rx_q_is_empty(&conn);
1720
1721 /* Done */
1722 event_done(&conn);
1723
1724 /* (A) There should NOT be a host notification */
1725 ut_rx_q_is_empty();
1726 }
1727
1728 /* Prepare */
1729 event_prepare(&conn);
1730
1731 /* (B) Tx Queue should have one LL Control PDU */
1732 req_B->reference_conn_event_count = event_counter(&conn) - 1;
1733 lt_rx(LL_CONNECTION_PARAM_REQ, &conn, &tx, req_B);
1734 lt_rx_q_is_empty(&conn);
1735
1736 /* Done */
1737 event_done(&conn);
1738
1739 /* Release Tx */
1740 ull_cp_release_tx(&conn, tx);
1741
1742 /* (A) There should be one host notification */
1743 ut_rx_node(NODE_CONN_UPDATE, &ntf, &cu);
1744 ut_rx_q_is_empty();
1745
1746 /* Release Ntf */
1747 release_ntf(ntf);
1748
1749 /* Prepare */
1750 event_prepare(&conn);
1751
1752 /* (B) Rx */
1753 lt_tx(LL_CONNECTION_PARAM_RSP, &conn, rsp_B);
1754
1755 /* Done */
1756 event_done(&conn);
1757
1758 /* Prepare */
1759 event_prepare(&conn);
1760
1761 /* (B) Tx Queue should have one LL Control PDU */
1762 conn_update_ind_B.instant = event_counter(&conn) + 6U;
1763 lt_rx(LL_CONNECTION_UPDATE_IND, &conn, &tx, &conn_update_ind_B);
1764 lt_rx_q_is_empty(&conn);
1765
1766 /* Done */
1767 event_done(&conn);
1768
1769 /* Save Instant */
1770 pdu = (struct pdu_data *)tx->pdu;
1771 instant = sys_le16_to_cpu(pdu->llctrl.conn_update_ind.instant);
1772
1773 /* Release Tx */
1774 ull_cp_release_tx(&conn, tx);
1775
1776 /* */
1777 while (!is_instant_reached(&conn, instant)) {
1778 /* Prepare */
1779 event_prepare(&conn);
1780
1781 /* (B) Tx Queue should NOT have a LL Control PDU */
1782 lt_rx_q_is_empty(&conn);
1783
1784 /* Done */
1785 event_done(&conn);
1786
1787 /* (B) There should NOT be a host notification */
1788 ut_rx_q_is_empty();
1789 }
1790
1791 /* Prepare */
1792 event_prepare(&conn);
1793
1794 /* (B) Tx Queue should NOT have a LL Control PDU */
1795 lt_rx_q_is_empty(&conn);
1796
1797 /* Done */
1798 event_done(&conn);
1799
1800 /* (B) There should be one host notification */
1801 ut_rx_node(NODE_CONN_UPDATE, &ntf, &cu);
1802 ut_rx_q_is_empty();
1803
1804 /* Release Ntf */
1805 release_ntf(ntf);
1806 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
1807 "Free CTX buffers %d", llcp_ctx_buffers_free());
1808 }
1809
1810 /*
1811 * Peripheral-initiated Connection Parameters Request procedure.
1812 * Peripheral requests change in LE connection parameters, central’s Host accepts.
1813 *
1814 * +-----+ +-------+ +-----+
1815 * | UT | | LL_P | | LT |
1816 * +-----+ +-------+ +-----+
1817 * | | |
1818 * | LE Connection Update | |
1819 * |-------------------------->| |
1820 * | | LL_CONNECTION_PARAM_REQ |
1821 * | |-------------------------->|
1822 * | | |
1823 * | | LL_CONNECTION_UPDATE_IND |
1824 * | |<--------------------------|
1825 * | | |
1826 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1827 * | | |
1828 * | LE Connection Update | |
1829 * | Complete | |
1830 * |<--------------------------| |
1831 * | | |
1832 */
ZTEST(periph_loc,test_conn_update_periph_loc_accept)1833 ZTEST(periph_loc, test_conn_update_periph_loc_accept)
1834 {
1835 uint8_t err;
1836 struct node_tx *tx;
1837 struct node_rx_pdu *ntf;
1838 uint16_t instant;
1839
1840 struct node_rx_pu cu = { .status = BT_HCI_ERR_SUCCESS };
1841
1842 /* Role */
1843 test_set_role(&conn, BT_HCI_ROLE_PERIPHERAL);
1844
1845 /* Connect */
1846 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
1847
1848 /* Initiate a Connection Parameter Request Procedure */
1849 err = ull_cp_conn_update(&conn, INTVL_MIN, INTVL_MAX, LATENCY, TIMEOUT, NULL);
1850 zassert_equal(err, BT_HCI_ERR_SUCCESS);
1851
1852 /* Prepare */
1853 event_prepare(&conn);
1854 conn_param_req.reference_conn_event_count = event_counter(&conn);
1855
1856 /* Tx Queue should have one LL Control PDU */
1857 lt_rx(LL_CONNECTION_PARAM_REQ, &conn, &tx, &conn_param_req);
1858 lt_rx_q_is_empty(&conn);
1859
1860 /* Done */
1861 event_done(&conn);
1862
1863 /* Release Tx */
1864 ull_cp_release_tx(&conn, tx);
1865
1866 /* Prepare */
1867 event_prepare(&conn);
1868
1869 /* Tx Queue should NOT have a LL Control PDU */
1870 lt_rx_q_is_empty(&conn);
1871
1872 /* Rx */
1873 conn_update_ind.instant = event_counter(&conn) + 6U;
1874 instant = conn_update_ind.instant;
1875 lt_tx(LL_CONNECTION_UPDATE_IND, &conn, &conn_update_ind);
1876
1877 /* Done */
1878 event_done(&conn);
1879
1880 /* */
1881 while (!is_instant_reached(&conn, instant)) {
1882 /* Prepare */
1883 event_prepare(&conn);
1884
1885 /* Tx Queue should NOT have a LL Control PDU */
1886 lt_rx_q_is_empty(&conn);
1887
1888 /* Done */
1889 event_done(&conn);
1890
1891 /* There should NOT be a host notification */
1892 ut_rx_q_is_empty();
1893 }
1894
1895 /* Prepare */
1896 event_prepare(&conn);
1897
1898 /* Tx Queue should NOT have a LL Control PDU */
1899 lt_rx_q_is_empty(&conn);
1900
1901 /* Done */
1902 event_done(&conn);
1903
1904 /* There should be one host notification */
1905 ut_rx_node(NODE_CONN_UPDATE, &ntf, &cu);
1906 ut_rx_q_is_empty();
1907
1908 /* Release Ntf */
1909 release_ntf(ntf);
1910 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
1911 "Free CTX buffers %d", llcp_ctx_buffers_free());
1912 }
1913
1914 /*
1915 * Peripheral-initiated Connection Parameters Request procedure.
1916 * Peripheral requests change in LE connection parameters, central’s Host rejects.
1917 *
1918 * +-----+ +-------+ +-----+
1919 * | UT | | LL_P | | LT |
1920 * +-----+ +-------+ +-----+
1921 * | | |
1922 * | LE Connection Update | |
1923 * |-------------------------->| |
1924 * | | LL_CONNECTION_PARAM_REQ |
1925 * | |-------------------------->|
1926 * | | |
1927 * | | LL_REJECT_EXT_IND |
1928 * | |<--------------------------|
1929 * | | |
1930 * | LE Connection Update | |
1931 * | Complete | |
1932 * |<--------------------------| |
1933 * | | |
1934 */
ZTEST(periph_loc,test_conn_update_periph_loc_reject)1935 ZTEST(periph_loc, test_conn_update_periph_loc_reject)
1936 {
1937 uint8_t err;
1938 struct node_tx *tx;
1939 struct node_rx_pdu *ntf;
1940
1941 struct node_rx_pu cu = { .status = BT_HCI_ERR_UNACCEPT_CONN_PARAM };
1942
1943 struct pdu_data_llctrl_reject_ext_ind reject_ext_ind = {
1944 .reject_opcode = PDU_DATA_LLCTRL_TYPE_CONN_PARAM_REQ,
1945 .error_code = BT_HCI_ERR_UNACCEPT_CONN_PARAM
1946 };
1947
1948 /* Role */
1949 test_set_role(&conn, BT_HCI_ROLE_PERIPHERAL);
1950
1951 /* Connect */
1952 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
1953
1954 /* Initiate a Connection Parameter Request Procedure */
1955 err = ull_cp_conn_update(&conn, INTVL_MIN, INTVL_MAX, LATENCY, TIMEOUT, NULL);
1956 zassert_equal(err, BT_HCI_ERR_SUCCESS);
1957
1958 /* Prepare */
1959 event_prepare(&conn);
1960 conn_param_req.reference_conn_event_count = event_counter(&conn);
1961
1962 /* Tx Queue should have one LL Control PDU */
1963 lt_rx(LL_CONNECTION_PARAM_REQ, &conn, &tx, &conn_param_req);
1964 lt_rx_q_is_empty(&conn);
1965
1966 /* Done */
1967 event_done(&conn);
1968
1969 /* Release Tx */
1970 ull_cp_release_tx(&conn, tx);
1971
1972 /* Prepare */
1973 event_prepare(&conn);
1974
1975 /* Tx Queue should NOT have a LL Control PDU */
1976 lt_rx_q_is_empty(&conn);
1977
1978 /* Rx */
1979 lt_tx(LL_REJECT_EXT_IND, &conn, &reject_ext_ind);
1980
1981 /* Done */
1982 event_done(&conn);
1983
1984 /* There should be one host notification */
1985 ut_rx_node(NODE_CONN_UPDATE, &ntf, &cu);
1986 ut_rx_q_is_empty();
1987
1988 /* Release Ntf */
1989 release_ntf(ntf);
1990 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
1991 "Free CTX buffers %d", llcp_ctx_buffers_free());
1992 }
1993
1994 /*
1995 * Peripheral-initiated Connection Parameters Request procedure. (A)
1996 * Peripheral requests change in LE connection parameters, central rejects due to
1997 * Central-initiated Connection Update procedure (B) overlapping.
1998 * Central rejects peripheral init and assumes 'own' connection update to complete
1999 *
2000 * +-----+ +-------+ +-----+
2001 * | UT | | LL_P | | LT |
2002 * +-----+ +-------+ +-----+
2003 * | | |
2004 * | LE Connection Update (A) | |
2005 * |-------------------------->| |
2006 * | | LL_CONNECTION_PARAM_REQ | (A)
2007 * | |-------------------------------->|
2008 * | | |
2009 * | |<--------------------------------|
2010 * | | LL_CONNECTION_UPDATE_IND | (B)
2011 * | | |
2012 * | | LL_REJECT_EXT_IND | (A)
2013 * | |<--------------------------------|
2014 * | | |
2015 * | | |
2016 * | LE Connection Update | |
2017 * | Complete | | (A/B)
2018 * |<--------------------------| |
2019 * | | |
2020 */
ZTEST(periph_loc,test_conn_update_periph_loc_reject_central_overlap)2021 ZTEST(periph_loc, test_conn_update_periph_loc_reject_central_overlap)
2022 {
2023 uint8_t err;
2024 uint16_t instant;
2025 struct node_tx *tx;
2026 struct node_rx_pdu *ntf;
2027 struct node_rx_pu cu2 = { .status = BT_HCI_ERR_SUCCESS };
2028 struct pdu_data_llctrl_reject_ext_ind reject_ext_ind = {
2029 .reject_opcode = PDU_DATA_LLCTRL_TYPE_CONN_PARAM_REQ,
2030 .error_code = BT_HCI_ERR_LL_PROC_COLLISION
2031 };
2032
2033 /* Role */
2034 test_set_role(&conn, BT_HCI_ROLE_PERIPHERAL);
2035
2036 /* Connect */
2037 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
2038
2039 /* Initiate a Connection Parameter Request Procedure */
2040 err = ull_cp_conn_update(&conn, INTVL_MIN, INTVL_MAX, LATENCY, TIMEOUT, NULL);
2041 zassert_equal(err, BT_HCI_ERR_SUCCESS);
2042
2043 /* Prepare */
2044 event_prepare(&conn);
2045 conn_param_req.reference_conn_event_count = event_counter(&conn);
2046
2047 /* Tx Queue should have one LL Control PDU */
2048 lt_rx(LL_CONNECTION_PARAM_REQ, &conn, &tx, &conn_param_req);
2049 lt_rx_q_is_empty(&conn);
2050
2051 /* Done */
2052 event_done(&conn);
2053
2054 /* Release Tx */
2055 ull_cp_release_tx(&conn, tx);
2056
2057 /* Prepare */
2058 event_prepare(&conn);
2059
2060 cu_ind_B->instant = instant = event_counter(&conn) + 6;
2061 lt_tx(LL_CONNECTION_UPDATE_IND, &conn, cu_ind_B);
2062
2063 /* Done */
2064 event_done(&conn);
2065
2066 /* Release Tx */
2067 ull_cp_release_tx(&conn, tx);
2068
2069 /* Tx Queue should NOT have a LL Control PDU */
2070 lt_rx_q_is_empty(&conn);
2071
2072 /* Prepare */
2073 event_prepare(&conn);
2074
2075 /* Rx */
2076 lt_tx(LL_REJECT_EXT_IND, &conn, &reject_ext_ind);
2077
2078 /* Done */
2079 event_done(&conn);
2080
2081 /* There should be no host notification */
2082 ut_rx_q_is_empty();
2083
2084 /* */
2085 while (!is_instant_reached(&conn, instant)) {
2086 /* Prepare */
2087 event_prepare(&conn);
2088
2089 /* (B) Tx Queue should NOT have a LL Control PDU */
2090 lt_rx_q_is_empty(&conn);
2091
2092 /* Done */
2093 event_done(&conn);
2094
2095 /* (B) There should NOT be a host notification */
2096 ut_rx_q_is_empty();
2097 }
2098
2099 /* Prepare */
2100 event_prepare(&conn);
2101
2102 /* (B) Tx Queue should NOT have a LL Control PDU */
2103 lt_rx_q_is_empty(&conn);
2104
2105 /* Done */
2106 event_done(&conn);
2107
2108 /* (B) There should be one host notification */
2109 ut_rx_node(NODE_CONN_UPDATE, &ntf, &cu2);
2110 ut_rx_q_is_empty();
2111
2112 /* Release Ntf */
2113 release_ntf(ntf);
2114 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
2115 "Free CTX buffers %d", llcp_ctx_buffers_free());
2116 }
2117
2118 /*
2119 * Peripheral-initiated Connection Parameters Request procedure.
2120 * Peripheral requests change in LE connection parameters, central’s Controller do not
2121 * support Connection Parameters Request procedure, features not exchanged.
2122 *
2123 * +-----+ +-------+ +-----+
2124 * | UT | | LL_P | | LT |
2125 * +-----+ +-------+ +-----+
2126 * | | |
2127 * | LE Connection Update | |
2128 * |-------------------------->| |
2129 * | | LL_CONNECTION_PARAM_REQ |
2130 * | |-------------------------->|
2131 * | | |
2132 * | | LL_UNKNOWN_RSP |
2133 * | |<--------------------------|
2134 * | | |
2135 * | LE Connection Update | |
2136 * | Complete | |
2137 * |<--------------------------| |
2138 * | | |
2139 */
ZTEST(periph_loc,test_conn_update_periph_loc_unsupp_feat_wo_feat_exch)2140 ZTEST(periph_loc, test_conn_update_periph_loc_unsupp_feat_wo_feat_exch)
2141 {
2142 uint8_t err;
2143 struct node_tx *tx;
2144 struct node_rx_pdu *ntf;
2145
2146 struct node_rx_pu cu = { .status = BT_HCI_ERR_UNSUPP_REMOTE_FEATURE };
2147
2148 struct pdu_data_llctrl_unknown_rsp unknown_rsp = {
2149 .type = PDU_DATA_LLCTRL_TYPE_CONN_PARAM_REQ
2150 };
2151
2152 /* Role */
2153 test_set_role(&conn, BT_HCI_ROLE_PERIPHERAL);
2154
2155 /* Connect */
2156 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
2157
2158 /* Initiate a Connection Parameter Request Procedure */
2159 err = ull_cp_conn_update(&conn, INTVL_MIN, INTVL_MAX, LATENCY, TIMEOUT, NULL);
2160 zassert_equal(err, BT_HCI_ERR_SUCCESS);
2161
2162 /* Prepare */
2163 event_prepare(&conn);
2164 conn_param_req.reference_conn_event_count = event_counter(&conn);
2165
2166 /* Tx Queue should have one LL Control PDU */
2167 lt_rx(LL_CONNECTION_PARAM_REQ, &conn, &tx, &conn_param_req);
2168 lt_rx_q_is_empty(&conn);
2169
2170 /* Done */
2171 event_done(&conn);
2172
2173 /* Release Tx */
2174 ull_cp_release_tx(&conn, tx);
2175
2176 /* Prepare */
2177 event_prepare(&conn);
2178
2179 /* Tx Queue should NOT have a LL Control PDU */
2180 lt_rx_q_is_empty(&conn);
2181
2182 /* Rx */
2183 lt_tx(LL_UNKNOWN_RSP, &conn, &unknown_rsp);
2184
2185 /* Done */
2186 event_done(&conn);
2187
2188 /* There should be one host notification */
2189 ut_rx_node(NODE_CONN_UPDATE, &ntf, &cu);
2190 ut_rx_q_is_empty();
2191
2192 /* Release Ntf */
2193 release_ntf(ntf);
2194 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
2195 "Free CTX buffers %d", llcp_ctx_buffers_free());
2196 }
2197
2198 /*
2199 * Peripheral-initiated Connection Parameters Request procedure.
2200 * Peripheral requests change in LE connection parameters, central’s Controller do not
2201 * support Connection Parameters Request procedure, features exchanged.
2202 *
2203 * +-----+ +-------+ +-----+
2204 * | UT | | LL_P | | LT |
2205 * +-----+ +-------+ +-----+
2206 * | | |
2207 * | LE Connection Update | |
2208 * |-------------------------->| |
2209 * | | LL_CONNECTION_UPDATE_IND |
2210 * | |-------------------------->|
2211 * | | |
2212 */
ZTEST(periph_loc,test_conn_update_periph_loc_unsupp_feat_w_feat_exch)2213 ZTEST(periph_loc, test_conn_update_periph_loc_unsupp_feat_w_feat_exch)
2214 {
2215 uint8_t err;
2216
2217 /* Disable feature */
2218 test_unmask_feature_conn_param_req(&conn);
2219
2220 /* Role */
2221 test_set_role(&conn, BT_HCI_ROLE_PERIPHERAL);
2222
2223 /* Connect */
2224 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
2225
2226 /* Initiate a Connection Parameter Request Procedure */
2227 err = ull_cp_conn_update(&conn, INTVL_MIN, INTVL_MAX, LATENCY, TIMEOUT, NULL);
2228 zassert_equal(err, BT_HCI_ERR_UNSUPP_REMOTE_FEATURE);
2229
2230 /* Prepare */
2231 event_prepare(&conn);
2232
2233 /* Tx Queue should have no LL Control PDU */
2234 lt_rx_q_is_empty(&conn);
2235
2236 /* Done */
2237 event_done(&conn);
2238
2239 /* There should be no host notification */
2240 ut_rx_q_is_empty();
2241
2242 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
2243 "Free CTX buffers %d", llcp_ctx_buffers_free());
2244 }
2245
2246 /*
2247 * (A)
2248 * Peripheral-initiated Connection Parameters Request procedure.
2249 * Procedure collides and is rejected.
2250 *
2251 * and
2252 *
2253 * (B)
2254 * Central-initiated Connection Parameters Request procedure.
2255 * Central requests change in LE connection parameters, peripheral’s Host accepts.
2256 *
2257 * +-----+ +-------+ +-----+
2258 * | UT | | LL_P | | LT |
2259 * +-----+ +-------+ +-----+
2260 * | | |
2261 * | LE Connection Update | |
2262 * |-------------------------->| | (A)
2263 * | | LL_CONNECTION_PARAM_REQ |
2264 * | |-------------------------->| (A)
2265 * | | |
2266 * | | LL_CONNECTION_PARAM_REQ |
2267 * | |<--------------------------| (B)
2268 * | | |
2269 * | <---------------------> |
2270 * | < PROCEDURE COLLISION > |
2271 * | <---------------------> |
2272 * | | |
2273 * | LE Remote Connection | |
2274 * | Parameter Request | |
2275 * |<--------------------------| | (B)
2276 * | | |
2277 * | LE Remote Connection | |
2278 * | Parameter Request | |
2279 * | Reply | |
2280 * |-------------------------->| | (B)
2281 * | | |
2282 * | | LL_REJECT_EXT_IND |
2283 * | |<--------------------------| (A)
2284 * | | |
2285 * | LE Connection Update | |
2286 * | Complete | |
2287 * |<--------------------------| | (A)
2288 * | | |
2289 * | | LL_CONNECTION_UPDATE_IND |
2290 * | |<--------------------------| (B)
2291 * | | |
2292 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2293 * | | |
2294 * | LE Connection Update | |
2295 * | Complete | |
2296 * |<--------------------------| | (B)
2297 */
ZTEST(periph_loc,test_conn_update_periph_loc_collision)2298 ZTEST(periph_loc, test_conn_update_periph_loc_collision)
2299 {
2300 uint8_t err;
2301 struct node_tx *tx;
2302 struct node_rx_pdu *ntf;
2303 uint16_t instant;
2304
2305 struct node_rx_pu cu1 = { .status = BT_HCI_ERR_LL_PROC_COLLISION };
2306
2307 struct node_rx_pu cu2 = { .status = BT_HCI_ERR_SUCCESS };
2308
2309 struct pdu_data_llctrl_reject_ext_ind reject_ext_ind = {
2310 .reject_opcode = PDU_DATA_LLCTRL_TYPE_CONN_PARAM_REQ,
2311 .error_code = BT_HCI_ERR_LL_PROC_COLLISION
2312 };
2313
2314 /* Role */
2315 test_set_role(&conn, BT_HCI_ROLE_PERIPHERAL);
2316
2317 /* Connect */
2318 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
2319
2320 /* (A) Initiate a Connection Parameter Request Procedure */
2321 err = ull_cp_conn_update(&conn, INTVL_MIN, INTVL_MAX, LATENCY, TIMEOUT, NULL);
2322 zassert_equal(err, BT_HCI_ERR_SUCCESS);
2323
2324 /* Prepare */
2325 event_prepare(&conn);
2326
2327 /* (A) Tx Queue should have one LL Control PDU */
2328 conn_param_req.reference_conn_event_count = event_counter(&conn);
2329 lt_rx(LL_CONNECTION_PARAM_REQ, &conn, &tx, &conn_param_req);
2330 lt_rx_q_is_empty(&conn);
2331
2332 /* (B) Rx */
2333 lt_tx(LL_CONNECTION_PARAM_REQ, &conn, req_B);
2334
2335 /* Done */
2336 event_done(&conn);
2337
2338 /* Prepare */
2339 event_prepare(&conn);
2340
2341 /* Done */
2342 event_done(&conn);
2343
2344 /* Prepare */
2345 event_prepare(&conn);
2346
2347 /* Done */
2348 event_done(&conn);
2349
2350
2351 /* Release Tx */
2352 ull_cp_release_tx(&conn, tx);
2353
2354 /*******************/
2355
2356 /* (B) There should be one host notification */
2357 ut_rx_pdu(LL_CONNECTION_PARAM_REQ, &ntf, req_B);
2358 ut_rx_q_is_empty();
2359
2360 /* Release Ntf */
2361 release_ntf(ntf);
2362
2363 /*******************/
2364
2365 /* (B) */
2366 ull_cp_conn_param_req_reply(&conn);
2367
2368 /*******************/
2369
2370 /* Prepare */
2371 event_prepare(&conn);
2372
2373 /* (B) Tx Queue should have one LL Control PDU */
2374 rsp_B->reference_conn_event_count = req_B->reference_conn_event_count;
2375 lt_rx(LL_CONNECTION_PARAM_RSP, &conn, &tx, rsp_B);
2376 lt_rx_q_is_empty(&conn);
2377
2378 /* (A) Rx */
2379 lt_tx(LL_REJECT_EXT_IND, &conn, &reject_ext_ind);
2380
2381 /* Done */
2382 event_done(&conn);
2383
2384 /* (A) There should be one host notification */
2385 ut_rx_node(NODE_CONN_UPDATE, &ntf, &cu1);
2386 ut_rx_q_is_empty();
2387
2388 /* Release Ntf */
2389 release_ntf(ntf);
2390
2391 /* Prepare */
2392 event_prepare(&conn);
2393
2394 /* (B) Rx */
2395 cu_ind_B->instant = instant = event_counter(&conn) + 6;
2396 lt_tx(LL_CONNECTION_UPDATE_IND, &conn, cu_ind_B);
2397
2398 /* Done */
2399 event_done(&conn);
2400
2401 /* Release Tx */
2402 ull_cp_release_tx(&conn, tx);
2403
2404 /* */
2405 while (!is_instant_reached(&conn, instant)) {
2406 /* Prepare */
2407 event_prepare(&conn);
2408
2409 /* (B) Tx Queue should NOT have a LL Control PDU */
2410 lt_rx_q_is_empty(&conn);
2411
2412 /* Done */
2413 event_done(&conn);
2414
2415 /* (B) There should NOT be a host notification */
2416 ut_rx_q_is_empty();
2417 }
2418
2419 /* Prepare */
2420 event_prepare(&conn);
2421
2422 /* (B) Tx Queue should NOT have a LL Control PDU */
2423 lt_rx_q_is_empty(&conn);
2424
2425 /* Done */
2426 event_done(&conn);
2427
2428 /* (B) There should be one host notification */
2429 ut_rx_node(NODE_CONN_UPDATE, &ntf, &cu2);
2430 ut_rx_q_is_empty();
2431
2432 /* Release Ntf */
2433 release_ntf(ntf);
2434 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
2435 "Free CTX buffers %d", llcp_ctx_buffers_free());
2436 }
2437
2438 /*
2439 * Central-initiated Connection Parameters Request procedure.
2440 * Central requests change in LE connection parameters, peripheral’s Host accepts.
2441 *
2442 * +-----+ +-------+ +-----+
2443 * | UT | | LL_P | | LT |
2444 * +-----+ +-------+ +-----+
2445 * | | |
2446 * | | LL_CONNECTION_PARAM_REQ |
2447 * | |<--------------------------|
2448 * | | |
2449 * | LE Remote Connection | |
2450 * | Parameter Request | |
2451 * |<--------------------------| |
2452 * | LE Remote Connection | |
2453 * | Parameter Request | |
2454 * | Reply | |
2455 * |-------------------------->| |
2456 * | | |
2457 * | | LL_CONNECTION_PARAM_RSP |
2458 * | |-------------------------->|
2459 * | | |
2460 * | | LL_CONNECTION_UPDATE_IND |
2461 * | |<--------------------------|
2462 * | | |
2463 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2464 * | | |
2465 * | LE Connection Update | |
2466 * | Complete | |
2467 * |<--------------------------| |
2468 * | | |
2469 */
ZTEST(periph_rem,test_conn_update_periph_rem_accept)2470 ZTEST(periph_rem, test_conn_update_periph_rem_accept)
2471 {
2472 struct node_tx *tx;
2473 struct node_rx_pdu *ntf;
2474 uint16_t instant;
2475
2476 struct node_rx_pu cu = { .status = BT_HCI_ERR_SUCCESS };
2477
2478 /* Role */
2479 test_set_role(&conn, BT_HCI_ROLE_PERIPHERAL);
2480
2481 /* Connect */
2482 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
2483
2484 /* Prepare */
2485 event_prepare(&conn);
2486
2487 /* Tx Queue should NOT have a LL Control PDU */
2488 lt_rx_q_is_empty(&conn);
2489
2490 /* Rx */
2491 lt_tx(LL_CONNECTION_PARAM_REQ, &conn, &conn_param_req);
2492
2493 /* Done */
2494 event_done(&conn);
2495
2496 /*******************/
2497
2498 /* There should be one host notification */
2499 ut_rx_pdu(LL_CONNECTION_PARAM_REQ, &ntf, &conn_param_req);
2500 ut_rx_q_is_empty();
2501
2502 /* Release Ntf */
2503 release_ntf(ntf);
2504
2505 /*******************/
2506
2507 ull_cp_conn_param_req_reply(&conn);
2508
2509 /*******************/
2510
2511 /* Prepare */
2512 event_prepare(&conn);
2513
2514 /* Tx Queue should have one LL Control PDU */
2515 lt_rx(LL_CONNECTION_PARAM_RSP, &conn, &tx, &conn_param_rsp);
2516 lt_rx_q_is_empty(&conn);
2517
2518 /* Done */
2519 event_done(&conn);
2520
2521 /* Prepare */
2522 event_prepare(&conn);
2523
2524 /* Rx */
2525 conn_update_ind.instant = event_counter(&conn) + 6U;
2526 instant = conn_update_ind.instant;
2527 lt_tx(LL_CONNECTION_UPDATE_IND, &conn, &conn_update_ind);
2528
2529 /* Done */
2530 event_done(&conn);
2531
2532 /* Release Tx */
2533 ull_cp_release_tx(&conn, tx);
2534
2535 /* */
2536 while (!is_instant_reached(&conn, instant)) {
2537 /* Prepare */
2538 event_prepare(&conn);
2539
2540 /* Tx Queue should NOT have a LL Control PDU */
2541 lt_rx_q_is_empty(&conn);
2542
2543 /* Done */
2544 event_done(&conn);
2545
2546 /* There should NOT be a host notification */
2547 ut_rx_q_is_empty();
2548 }
2549
2550 /* Prepare */
2551 event_prepare(&conn);
2552
2553 /* Tx Queue should NOT have a LL Control PDU */
2554 lt_rx_q_is_empty(&conn);
2555
2556 /* Done */
2557 event_done(&conn);
2558
2559 /* There should be one host notification */
2560 ut_rx_node(NODE_CONN_UPDATE, &ntf, &cu);
2561 ut_rx_q_is_empty();
2562
2563 /* Release Ntf */
2564 release_ntf(ntf);
2565 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
2566 "Free CTX buffers %d", llcp_ctx_buffers_free());
2567 }
2568 #define RADIO_CONN_EVENTS(x, y) ((uint16_t)DIV_ROUND_UP(x, y))
2569
2570 /*
2571 * Central-initiated Connection Parameters Request procedure - only anchor point move.
2572 * Central requests change in anchor point only on LE connection, peripheral’s Host accepts.
2573 *
2574 * +-----+ +-------+ +-----+
2575 * | UT | | LL_P | | LT |
2576 * +-----+ +-------+ +-----+
2577 * | | |
2578 * | | LL_CONNECTION_PARAM_REQ |
2579 * | | (only apm) |
2580 * | |<--------------------------|
2581 * | | |
2582 * | Defered APM disabled | |
2583 * | '<---------' | |
2584 * | So accepted right away | |
2585 * | '--------->' | |
2586 * | | |
2587 * | | LL_CONNECTION_PARAM_RSP |
2588 * | |-------------------------->|
2589 * | | |
2590 * | | LL_CONNECTION_UPDATE_IND |
2591 * | |<--------------------------|
2592 * | | |
2593 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2594 * | | |
2595 * | | |
2596 */
ZTEST(periph_rem,test_conn_update_periph_rem_apm_accept_right_away)2597 ZTEST(periph_rem, test_conn_update_periph_rem_apm_accept_right_away)
2598 {
2599 #if defined(CONFIG_BT_CTLR_USER_CPR_ANCHOR_POINT_MOVE)
2600 struct node_tx *tx;
2601 uint16_t instant;
2602 uint8_t error = 0U;
2603 /* Default conn_param_req PDU */
2604 struct pdu_data_llctrl_conn_param_req conn_param_req_apm = { .interval_min = INTVL_MIN,
2605 .interval_max = INTVL_MAX,
2606 .latency = LATENCY,
2607 .timeout = TIMEOUT,
2608 .preferred_periodicity = 0U,
2609 .reference_conn_event_count = 0u,
2610 .offset0 = 0x0008U,
2611 .offset1 = 0xffffU,
2612 .offset2 = 0xffffU,
2613 .offset3 = 0xffffU,
2614 .offset4 = 0xffffU,
2615 .offset5 = 0xffffU };
2616
2617 /* Default conn_param_rsp PDU */
2618 struct pdu_data_llctrl_conn_param_rsp conn_param_rsp_apm = { .interval_min = INTVL_MIN,
2619 .interval_max = INTVL_MAX,
2620 .latency = LATENCY,
2621 .timeout = TIMEOUT,
2622 .preferred_periodicity = 0U,
2623 .reference_conn_event_count = 0u,
2624 .offset0 = 0x008U,
2625 .offset1 = 0xffffU,
2626 .offset2 = 0xffffU,
2627 .offset3 = 0xffffU,
2628 .offset4 = 0xffffU,
2629 .offset5 = 0xffffU };
2630
2631 /* Prepare mocked call to ull_handle_cpr_anchor_point_move */
2632 /* No APM deferance, accept with error == 0 */
2633 ztest_returns_value(ull_handle_cpr_anchor_point_move, false);
2634 ztest_return_data(ull_handle_cpr_anchor_point_move, status, &error);
2635
2636 /* Role */
2637 test_set_role(&conn, BT_HCI_ROLE_PERIPHERAL);
2638
2639 /* Connect */
2640 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
2641
2642 conn.lll.interval = conn_param_req_apm.interval_max;
2643 conn.lll.latency = conn_param_req_apm.latency;
2644 conn.supervision_timeout = TIMEOUT;
2645
2646 /* Prepare */
2647 event_prepare(&conn);
2648
2649 /* Tx Queue should NOT have a LL Control PDU */
2650 lt_rx_q_is_empty(&conn);
2651
2652 /* Rx */
2653 lt_tx(LL_CONNECTION_PARAM_REQ, &conn, &conn_param_req_apm);
2654
2655 /* Done */
2656 event_done(&conn);
2657
2658 /*******************/
2659
2660 /* There should be no host notification */
2661 ut_rx_q_is_empty();
2662
2663 /* Prepare */
2664 event_prepare(&conn);
2665
2666 /* Tx Queue should have one LL Control PDU */
2667 lt_rx(LL_CONNECTION_PARAM_RSP, &conn, &tx, &conn_param_rsp_apm);
2668 lt_rx_q_is_empty(&conn);
2669
2670 /* Done */
2671 event_done(&conn);
2672
2673 /* Prepare */
2674 event_prepare(&conn);
2675
2676 /* Rx */
2677 conn_update_ind.instant = event_counter(&conn) + 6U;
2678 instant = conn_update_ind.instant;
2679 lt_tx(LL_CONNECTION_UPDATE_IND, &conn, &conn_update_ind);
2680
2681 /* Done */
2682 event_done(&conn);
2683
2684 /* Release Tx */
2685 ull_cp_release_tx(&conn, tx);
2686
2687 /* */
2688 while (!is_instant_reached(&conn, instant)) {
2689 /* Prepare */
2690 event_prepare(&conn);
2691
2692 /* Tx Queue should NOT have a LL Control PDU */
2693 lt_rx_q_is_empty(&conn);
2694
2695 /* Done */
2696 event_done(&conn);
2697
2698 /* There should NOT be a host notification */
2699 ut_rx_q_is_empty();
2700 }
2701
2702 /* Prepare */
2703 event_prepare(&conn);
2704
2705 /* Tx Queue should NOT have a LL Control PDU */
2706 lt_rx_q_is_empty(&conn);
2707
2708 /* Done */
2709 event_done(&conn);
2710
2711 /* There should be no host notification */
2712 ut_rx_q_is_empty();
2713
2714 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
2715 "Free CTX buffers %d", llcp_ctx_buffers_free());
2716 #endif
2717 }
2718
2719 /*
2720 * Central-initiated Connection Parameters Request procedure - only anchor point move.
2721 * Central requests change in anchor point only on LE connection, peripheral’s Host accepts.
2722 *
2723 * +-----+ +-------+ +-----+
2724 * | UT | | LL_P | | LT |
2725 * +-----+ +-------+ +-----+
2726 * | | |
2727 * | | LL_CONNECTION_PARAM_REQ |
2728 * | | (only apm) |
2729 * | |<--------------------------|
2730 * | | |
2731 * | Defered APM disabled | |
2732 * | '<---------' | |
2733 * | So accepted right away | |
2734 * | but with error | |
2735 * | '--------->' | |
2736 * | | |
2737 * | | LL_REJECT_EXT_IND |
2738 * | |-------------------------->|
2739 * | | |
2740 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2741 * | | |
2742 * | | |
2743 */
ZTEST(periph_rem,test_conn_update_periph_rem_apm_reject_right_away)2744 ZTEST(periph_rem, test_conn_update_periph_rem_apm_reject_right_away)
2745 {
2746 #if defined(CONFIG_BT_CTLR_USER_CPR_ANCHOR_POINT_MOVE)
2747 struct node_tx *tx;
2748 /* Default conn_param_req PDU */
2749 struct pdu_data_llctrl_conn_param_req conn_param_req_apm = { .interval_min = INTVL_MIN,
2750 .interval_max = INTVL_MAX,
2751 .latency = LATENCY,
2752 .timeout = TIMEOUT,
2753 .preferred_periodicity = 0U,
2754 .reference_conn_event_count = 0u,
2755 .offset0 = 0x0008U,
2756 .offset1 = 0xffffU,
2757 .offset2 = 0xffffU,
2758 .offset3 = 0xffffU,
2759 .offset4 = 0xffffU,
2760 .offset5 = 0xffffU };
2761 struct pdu_data_llctrl_reject_ext_ind reject_ext_ind = {
2762 .reject_opcode = PDU_DATA_LLCTRL_TYPE_CONN_PARAM_REQ,
2763 .error_code = BT_HCI_ERR_UNSUPP_LL_PARAM_VAL + 1
2764 };
2765 uint8_t error = reject_ext_ind.error_code;
2766
2767 /* Prepare mocked call to ull_handle_cpr_anchor_point_move */
2768 /* No APM deferance, reject with some error code */
2769 ztest_returns_value(ull_handle_cpr_anchor_point_move, false);
2770 ztest_return_data(ull_handle_cpr_anchor_point_move, status, &error);
2771
2772 /* Role */
2773 test_set_role(&conn, BT_HCI_ROLE_PERIPHERAL);
2774
2775 /* Connect */
2776 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
2777
2778 conn.lll.interval = conn_param_req_apm.interval_max;
2779 conn.lll.latency = conn_param_req_apm.latency;
2780 conn.supervision_timeout = TIMEOUT;
2781
2782 /* Prepare */
2783 event_prepare(&conn);
2784
2785 /* Tx Queue should NOT have a LL Control PDU */
2786 lt_rx_q_is_empty(&conn);
2787
2788 /* Rx */
2789 lt_tx(LL_CONNECTION_PARAM_REQ, &conn, &conn_param_req_apm);
2790
2791 /* Done */
2792 event_done(&conn);
2793
2794 /*******************/
2795
2796 /* There should be no host notification */
2797 ut_rx_q_is_empty();
2798
2799 /* Prepare */
2800 event_prepare(&conn);
2801
2802 /* Tx Queue should have one LL Control PDU */
2803 lt_rx(LL_REJECT_EXT_IND, &conn, &tx, &reject_ext_ind);
2804 lt_rx_q_is_empty(&conn);
2805
2806 /* Release Tx */
2807 ull_cp_release_tx(&conn, tx);
2808
2809 /* Done */
2810 event_done(&conn);
2811
2812 /* Prepare */
2813 event_prepare(&conn);
2814
2815 /* Tx Queue should NOT have a LL Control PDU */
2816 lt_rx_q_is_empty(&conn);
2817
2818 /* Done */
2819 event_done(&conn);
2820
2821 /* There should be no host notification */
2822 ut_rx_q_is_empty();
2823
2824 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
2825 "Free CTX buffers %d", llcp_ctx_buffers_free());
2826 #endif
2827 }
2828
2829 /*
2830 * Central-initiated Connection Parameters Request procedure - only anchor point move.
2831 * Central requests change in anchor point only on LE connection, peripheral’s Host accepts.
2832 *
2833 * +-----+ +-------+ +-----+
2834 * | UT | | LL_P | | LT |
2835 * +-----+ +-------+ +-----+
2836 * | | |
2837 * | | LL_CONNECTION_PARAM_REQ |
2838 * | | (only apm) |
2839 * | |<--------------------------|
2840 * | | |
2841 * | Defered APM | |
2842 * | '<---------' | |
2843 * | | |
2844 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2845 * | | |
2846 * | Defered accept | |
2847 * | '--------->' | |
2848 * | | |
2849 * | | LL_CONNECTION_PARAM_RSP |
2850 * | |-------------------------->|
2851 * | | |
2852 * | | LL_CONNECTION_UPDATE_IND |
2853 * | |<--------------------------|
2854 * | | |
2855 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2856 * | | |
2857 * | | |
2858 */
ZTEST(periph_rem,test_conn_update_periph_rem_apm_accept_defered)2859 ZTEST(periph_rem, test_conn_update_periph_rem_apm_accept_defered)
2860 {
2861 #if defined(CONFIG_BT_CTLR_USER_CPR_ANCHOR_POINT_MOVE)
2862 uint16_t offsets[6] = {
2863 0x0008U,
2864 0xffffU,
2865 0xffffU,
2866 0xffffU,
2867 0xffffU,
2868 0xffffU
2869 };
2870 struct node_tx *tx;
2871 uint16_t instant;
2872 uint8_t error = 0U;
2873 /* Default conn_param_req PDU */
2874 struct pdu_data_llctrl_conn_param_req conn_param_req_apm = { .interval_min = INTVL_MIN,
2875 .interval_max = INTVL_MAX,
2876 .latency = LATENCY,
2877 .timeout = TIMEOUT,
2878 .preferred_periodicity = 0U,
2879 .reference_conn_event_count = 0u,
2880 .offset0 = 0x0004U,
2881 .offset1 = 0xffffU,
2882 .offset2 = 0xffffU,
2883 .offset3 = 0xffffU,
2884 .offset4 = 0xffffU,
2885 .offset5 = 0xffffU };
2886
2887 /* Default conn_param_rsp PDU */
2888 struct pdu_data_llctrl_conn_param_rsp conn_param_rsp_apm = { .interval_min = INTVL_MIN,
2889 .interval_max = INTVL_MAX,
2890 .latency = LATENCY,
2891 .timeout = TIMEOUT,
2892 .preferred_periodicity = 0U,
2893 .reference_conn_event_count = 0u,
2894 .offset0 = 0x008U,
2895 .offset1 = 0xffffU,
2896 .offset2 = 0xffffU,
2897 .offset3 = 0xffffU,
2898 .offset4 = 0xffffU,
2899 .offset5 = 0xffffU };
2900
2901 /* Prepare mocked call to ull_handle_cpr_anchor_point_move */
2902 /* Defer APM */
2903 ztest_returns_value(ull_handle_cpr_anchor_point_move, true);
2904 ztest_return_data(ull_handle_cpr_anchor_point_move, status, &error);
2905
2906 /* Role */
2907 test_set_role(&conn, BT_HCI_ROLE_PERIPHERAL);
2908
2909 /* Connect */
2910 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
2911
2912 conn.lll.interval = conn_param_req_apm.interval_max;
2913 conn.lll.latency = conn_param_req_apm.latency;
2914 conn.supervision_timeout = TIMEOUT;
2915
2916 /* Prepare */
2917 event_prepare(&conn);
2918
2919 /* Tx Queue should NOT have a LL Control PDU */
2920 lt_rx_q_is_empty(&conn);
2921
2922 /* Rx */
2923 lt_tx(LL_CONNECTION_PARAM_REQ, &conn, &conn_param_req_apm);
2924
2925 /* Done */
2926 event_done(&conn);
2927
2928 /* Run a few events */
2929 for (int i = 0; i < 10; i++) {
2930
2931 /* Prepare */
2932 event_prepare(&conn);
2933
2934 zassert_equal(true, ull_cp_remote_cpr_apm_awaiting_reply(&conn), NULL);
2935
2936 /* There should be no host notification */
2937 ut_rx_q_is_empty();
2938
2939 /* Done */
2940 event_done(&conn);
2941 }
2942
2943 ull_cp_remote_cpr_apm_reply(&conn, offsets);
2944
2945 /* There should be no host notification */
2946 ut_rx_q_is_empty();
2947
2948 /* Prepare */
2949 event_prepare(&conn);
2950
2951 /* Tx Queue should have one LL Control PDU */
2952 lt_rx(LL_CONNECTION_PARAM_RSP, &conn, &tx, &conn_param_rsp_apm);
2953 lt_rx_q_is_empty(&conn);
2954
2955 /* Done */
2956 event_done(&conn);
2957
2958 /* Prepare */
2959 event_prepare(&conn);
2960
2961 /* Rx */
2962 conn_update_ind.instant = event_counter(&conn) + 6U;
2963 instant = conn_update_ind.instant;
2964 lt_tx(LL_CONNECTION_UPDATE_IND, &conn, &conn_update_ind);
2965
2966 /* Done */
2967 event_done(&conn);
2968
2969 /* Release Tx */
2970 ull_cp_release_tx(&conn, tx);
2971
2972 /* */
2973 while (!is_instant_reached(&conn, instant)) {
2974 /* Prepare */
2975 event_prepare(&conn);
2976
2977 /* Tx Queue should NOT have a LL Control PDU */
2978 lt_rx_q_is_empty(&conn);
2979
2980 /* Done */
2981 event_done(&conn);
2982
2983 /* There should NOT be a host notification */
2984 ut_rx_q_is_empty();
2985 }
2986
2987 /* Prepare */
2988 event_prepare(&conn);
2989
2990 /* Tx Queue should NOT have a LL Control PDU */
2991 lt_rx_q_is_empty(&conn);
2992
2993 /* Done */
2994 event_done(&conn);
2995
2996 /* There should be no host notification */
2997 ut_rx_q_is_empty();
2998
2999 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
3000 "Free CTX buffers %d", llcp_ctx_buffers_free());
3001 #endif
3002 }
3003
3004 /*
3005 * Central-initiated Connection Parameters Request procedure - only anchor point move.
3006 * Central requests change in anchor point only on LE connection, peripheral’s Host accepts.
3007 *
3008 * +-----+ +-------+ +-----+
3009 * | UT | | LL_P | | LT |
3010 * +-----+ +-------+ +-----+
3011 * | | |
3012 * | | LL_CONNECTION_PARAM_REQ |
3013 * | | (only apm) |
3014 * | |<--------------------------|
3015 * | | |
3016 * | Defered APM | |
3017 * | '<---------' | |
3018 * | | |
3019 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3020 * | | |
3021 * | Defered accept | |
3022 * | but with error | |
3023 * | '--------->' | |
3024 * | | |
3025 * | | LL_REJECT_EXT_IND |
3026 * | |-------------------------->|
3027 * | | |
3028 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3029 * | | |
3030 * | | |
3031 */
ZTEST(periph_rem,test_conn_update_periph_rem_apm_reject_defered)3032 ZTEST(periph_rem, test_conn_update_periph_rem_apm_reject_defered)
3033 {
3034 #if defined(CONFIG_BT_CTLR_USER_CPR_ANCHOR_POINT_MOVE)
3035 struct node_tx *tx;
3036 uint8_t error = 0U;
3037 /* Default conn_param_req PDU */
3038 struct pdu_data_llctrl_conn_param_req conn_param_req_apm = { .interval_min = INTVL_MIN,
3039 .interval_max = INTVL_MAX,
3040 .latency = LATENCY,
3041 .timeout = TIMEOUT,
3042 .preferred_periodicity = 0U,
3043 .reference_conn_event_count = 0u,
3044 .offset0 = 0x0008U,
3045 .offset1 = 0xffffU,
3046 .offset2 = 0xffffU,
3047 .offset3 = 0xffffU,
3048 .offset4 = 0xffffU,
3049 .offset5 = 0xffffU };
3050 struct pdu_data_llctrl_reject_ext_ind reject_ext_ind = {
3051 .reject_opcode = PDU_DATA_LLCTRL_TYPE_CONN_PARAM_REQ,
3052 .error_code = BT_HCI_ERR_UNSUPP_LL_PARAM_VAL
3053 };
3054
3055 /* Prepare mocked call to ull_handle_cpr_anchor_point_move */
3056 /* Defer APM */
3057 ztest_returns_value(ull_handle_cpr_anchor_point_move, true);
3058 ztest_return_data(ull_handle_cpr_anchor_point_move, status, &error);
3059
3060 /* Role */
3061 test_set_role(&conn, BT_HCI_ROLE_PERIPHERAL);
3062
3063 /* Connect */
3064 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
3065
3066 conn.lll.interval = conn_param_req_apm.interval_max;
3067 conn.lll.latency = conn_param_req_apm.latency;
3068 conn.supervision_timeout = TIMEOUT;
3069
3070 /* Prepare */
3071 event_prepare(&conn);
3072
3073 /* Tx Queue should NOT have a LL Control PDU */
3074 lt_rx_q_is_empty(&conn);
3075
3076 /* Rx */
3077 lt_tx(LL_CONNECTION_PARAM_REQ, &conn, &conn_param_req_apm);
3078
3079 /* Done */
3080 event_done(&conn);
3081
3082 /* Run a few events */
3083 for (int i = 0; i < 10; i++) {
3084
3085 /* Prepare */
3086 event_prepare(&conn);
3087
3088 zassert_equal(true, ull_cp_remote_cpr_apm_awaiting_reply(&conn), NULL);
3089
3090 /* There should be no host notification */
3091 ut_rx_q_is_empty();
3092
3093 /* Done */
3094 event_done(&conn);
3095 }
3096
3097 ull_cp_remote_cpr_apm_neg_reply(&conn, BT_HCI_ERR_UNSUPP_LL_PARAM_VAL);
3098
3099 /* Prepare */
3100 event_prepare(&conn);
3101
3102 /* Done */
3103 event_done(&conn);
3104
3105 /*******************/
3106
3107 /* There should be no host notification */
3108 ut_rx_q_is_empty();
3109
3110 /* Prepare */
3111 event_prepare(&conn);
3112
3113 /* Tx Queue should have one LL Control PDU */
3114 lt_rx(LL_REJECT_EXT_IND, &conn, &tx, &reject_ext_ind);
3115 lt_rx_q_is_empty(&conn);
3116
3117 /* Release Tx */
3118 ull_cp_release_tx(&conn, tx);
3119
3120 /* Done */
3121 event_done(&conn);
3122
3123 /* Prepare */
3124 event_prepare(&conn);
3125
3126 /* Tx Queue should NOT have a LL Control PDU */
3127 lt_rx_q_is_empty(&conn);
3128
3129 /* Done */
3130 event_done(&conn);
3131
3132 /* There should be no host notification */
3133 ut_rx_q_is_empty();
3134
3135 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
3136 "Free CTX buffers %d", llcp_ctx_buffers_free());
3137 #endif /* CONFIG_BT_CTLR_USER_CPR_ANCHOR_POINT_MOVE */
3138 }
3139
3140 /*
3141 * (A)
3142 * Peripheral-initiated Connection Parameters Request procedure.
3143 * Procedure collides and is rejected.
3144 *
3145 * and
3146 *
3147 * (B)
3148 * Central-initiated Connection Parameters Request procedure.
3149 * Central requests change in LE connection parameters, peripheral’s Host accepts.
3150 *
3151 * +-----+ +-------+ +-----+
3152 * | UT | | LL_P | | LT |
3153 * +-----+ +-------+ +-----+
3154 * | | |
3155 * | LE Connection Update | |
3156 * |-------------------------->| | (A)
3157 * | | LL_CONNECTION_PARAM_REQ |
3158 * | |-------------------------->| (A)
3159 * | | |
3160 * | | LL_CONNECTION_PARAM_REQ |
3161 * | |<--------------------------| (B)
3162 * | | |
3163 * | <---------------------> |
3164 * | < PROCEDURE COLLISION > |
3165 * | <---------------------> |
3166 * | | |
3167 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3168 * ~~~~~ parallel remote CPRs attempted and rejected ~~~~~~~
3169 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3170 * | | |
3171 * | | |
3172 * | LE Remote Connection | |
3173 * | Parameter Request | |
3174 * |<--------------------------| | (B)
3175 * | | |
3176 * | LE Remote Connection | |
3177 * | Parameter Request | |
3178 * | Reply | |
3179 * |-------------------------->| | (B)
3180 * | | |
3181 * | | LL_REJECT_EXT_IND |
3182 * | |<--------------------------| (A)
3183 * | | |
3184 * | LE Connection Update | |
3185 * | Complete | |
3186 * |<--------------------------| | (A)
3187 * | | |
3188 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3189 * ~~~~~ parallel local CPR is attempted and cached ~~~~~~~
3190 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3191 * | | LL_CONNECTION_UPDATE_IND |
3192 * | |<--------------------------| (B)
3193 * | | |
3194 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3195 * | | |
3196 * | LE Connection Update | |
3197 * | Complete | |
3198 * |<--------------------------| | (B)
3199 * | | |
3200 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3201 * ~~~~~~~~~ parallel local CPR is now started ~~~~~~~~~~~~
3202 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3203 * | | |
3204 */
ZTEST(periph_loc,test_conn_update_periph_loc_collision_reject_2nd_cpr)3205 ZTEST(periph_loc, test_conn_update_periph_loc_collision_reject_2nd_cpr)
3206 {
3207 struct ll_conn conn_2nd;
3208 struct ll_conn conn_3rd;
3209 uint8_t err;
3210 struct node_tx *tx, *tx1;
3211 struct node_rx_pdu *ntf;
3212 uint16_t instant;
3213
3214 struct node_rx_pu cu1 = { .status = BT_HCI_ERR_LL_PROC_COLLISION };
3215 struct node_rx_pu cu2 = { .status = BT_HCI_ERR_SUCCESS };
3216 struct pdu_data_llctrl_reject_ext_ind reject_ext_ind = {
3217 .reject_opcode = PDU_DATA_LLCTRL_TYPE_CONN_PARAM_REQ,
3218 .error_code = BT_HCI_ERR_LL_PROC_COLLISION
3219 };
3220 struct pdu_data_llctrl_reject_ext_ind parallel_reject_ext_ind = {
3221 .reject_opcode = PDU_DATA_LLCTRL_TYPE_CONN_PARAM_REQ,
3222 .error_code = BT_HCI_ERR_UNSUPP_LL_PARAM_VAL
3223 };
3224
3225 /* Initialize extra connections */
3226 test_setup_idx(&conn_2nd, 1);
3227 test_setup_idx(&conn_3rd, 2);
3228
3229 /* Role */
3230 test_set_role(&conn, BT_HCI_ROLE_PERIPHERAL);
3231 /* Role */
3232 test_set_role(&conn_2nd, BT_HCI_ROLE_PERIPHERAL);
3233 /* Role */
3234 test_set_role(&conn_3rd, BT_HCI_ROLE_CENTRAL);
3235
3236 /* Connect */
3237 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
3238 /* Connect */
3239 ull_cp_state_set(&conn_2nd, ULL_CP_CONNECTED);
3240 /* Connect */
3241 ull_cp_state_set(&conn_3rd, ULL_CP_CONNECTED);
3242
3243 /* (A) Initiate a Connection Parameter Request Procedure */
3244 err = ull_cp_conn_update(&conn, INTVL_MIN, INTVL_MAX, LATENCY, TIMEOUT, NULL);
3245 zassert_equal(err, BT_HCI_ERR_SUCCESS);
3246
3247 /* Prepare */
3248 event_prepare(&conn);
3249 conn_param_req.reference_conn_event_count = event_counter(&conn);
3250
3251 /* (A) Tx Queue should have one LL Control PDU */
3252 lt_rx(LL_CONNECTION_PARAM_REQ, &conn, &tx1, &conn_param_req);
3253 lt_rx_q_is_empty(&conn);
3254
3255 /* (B) Rx */
3256 lt_tx(LL_CONNECTION_PARAM_REQ, &conn, req_B);
3257
3258 /* Done */
3259 event_done(&conn);
3260
3261 {
3262 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt()-2,
3263 "Free CTX buffers %d", llcp_ctx_buffers_free());
3264 /* Parallel CPR from central */
3265 /* Now CPR is active on 'conn' so let 'conn_2nd' attempt to start a CPR */
3266 /* Prepare */
3267 event_prepare(&conn_2nd);
3268
3269 /* Tx Queue should NOT have a LL Control PDU */
3270 lt_rx_q_is_empty(&conn_2nd);
3271
3272 /* Rx */
3273 lt_tx(LL_CONNECTION_PARAM_REQ, &conn_2nd, &conn_param_req);
3274
3275 /* Done */
3276 event_done(&conn_2nd);
3277
3278 /* Tx Queue should have one LL Control PDU */
3279 lt_rx(LL_REJECT_EXT_IND, &conn_2nd, &tx, ¶llel_reject_ext_ind);
3280 lt_rx_q_is_empty(&conn_2nd);
3281
3282 /* Release Tx */
3283 ull_cp_release_tx(&conn_2nd, tx);
3284
3285 /* There should be no 'extra' procedure on acount of the parallel CPR */
3286 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt()-2,
3287 "Free CTX buffers %d", llcp_ctx_buffers_free());
3288 }
3289
3290 /* Prepare */
3291 event_prepare(&conn);
3292
3293 /* Done */
3294 event_done(&conn);
3295
3296 {
3297 /* Parallel CPR from peripheral */
3298 /* Now CPR is active on 'conn' so let 'conn_3rd' attempt to start a CPR */
3299 /* Prepare */
3300 event_prepare(&conn_3rd);
3301
3302 /* Tx Queue should NOT have a LL Control PDU */
3303 lt_rx_q_is_empty(&conn_3rd);
3304
3305 /* Rx */
3306 lt_tx(LL_CONNECTION_PARAM_REQ, &conn_3rd, &conn_param_req);
3307
3308 /* Done */
3309 event_done(&conn_3rd);
3310
3311 /* Tx Queue should have one LL Control PDU */
3312 lt_rx(LL_REJECT_EXT_IND, &conn_3rd, &tx, ¶llel_reject_ext_ind);
3313 lt_rx_q_is_empty(&conn_3rd);
3314
3315 /* Release Tx */
3316 ull_cp_release_tx(&conn_3rd, tx);
3317
3318 /* There should be no 'extra' procedure on acount of the parallel CPR */
3319 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt()-2,
3320 "Free CTX buffers %d", llcp_ctx_buffers_free());
3321 }
3322
3323 /* Prepare */
3324 event_prepare(&conn);
3325
3326 /* Done */
3327 event_done(&conn);
3328
3329
3330 /* Release Tx */
3331 ull_cp_release_tx(&conn, tx1);
3332
3333 /*******************/
3334
3335 /* (B) There should be one host notification */
3336 ut_rx_pdu(LL_CONNECTION_PARAM_REQ, &ntf, req_B);
3337 ut_rx_q_is_empty();
3338
3339 /* Release Ntf */
3340 release_ntf(ntf);
3341
3342 /*******************/
3343
3344 /* (B) */
3345 ull_cp_conn_param_req_reply(&conn);
3346
3347 /*******************/
3348
3349 /* Prepare */
3350 event_prepare(&conn);
3351
3352 /* (B) Tx Queue should have one LL Control PDU */
3353 rsp_B->reference_conn_event_count = req_B->reference_conn_event_count;
3354 lt_rx(LL_CONNECTION_PARAM_RSP, &conn, &tx, rsp_B);
3355 lt_rx_q_is_empty(&conn);
3356
3357 /* (A) Rx */
3358 lt_tx(LL_REJECT_EXT_IND, &conn, &reject_ext_ind);
3359
3360 /* Done */
3361 event_done(&conn);
3362
3363 /* (A) There should be one host notification */
3364 ut_rx_node(NODE_CONN_UPDATE, &ntf, &cu1);
3365 ut_rx_q_is_empty();
3366
3367 /* Release Ntf */
3368 release_ntf(ntf);
3369
3370 {
3371 /* Initiate a parallel local Connection Parameter Request Procedure */
3372 err = ull_cp_conn_update(&conn_2nd, INTVL_MIN, INTVL_MAX, LATENCY, TIMEOUT, NULL);
3373 zassert_equal(err, BT_HCI_ERR_SUCCESS);
3374
3375 /* Prepare */
3376 event_prepare(&conn_2nd);
3377
3378 /* Tx Queue should have no LL Control PDU */
3379 lt_rx_q_is_empty(&conn_2nd);
3380
3381 /* Done */
3382 event_done(&conn_2nd);
3383
3384 /* Prepare */
3385 event_prepare(&conn_2nd);
3386
3387 /* Tx Queue should have no LL Control PDU */
3388 lt_rx_q_is_empty(&conn_2nd);
3389
3390 /* Done */
3391 event_done(&conn_2nd);
3392 }
3393
3394 /* Prepare */
3395 event_prepare(&conn);
3396
3397 /* (B) Rx */
3398 cu_ind_B->instant = instant = event_counter(&conn) + 6;
3399 lt_tx(LL_CONNECTION_UPDATE_IND, &conn, cu_ind_B);
3400
3401 /* Done */
3402 event_done(&conn);
3403
3404 /* Release Tx */
3405 ull_cp_release_tx(&conn, tx);
3406
3407 /* */
3408 while (!is_instant_reached(&conn, instant)) {
3409 /* Prepare */
3410 event_prepare(&conn);
3411
3412 /* (B) Tx Queue should NOT have a LL Control PDU */
3413 lt_rx_q_is_empty(&conn);
3414
3415 /* Done */
3416 event_done(&conn);
3417
3418 /* (B) There should NOT be a host notification */
3419 ut_rx_q_is_empty();
3420 }
3421
3422 /* Prepare */
3423 event_prepare(&conn);
3424
3425 /* (B) Tx Queue should NOT have a LL Control PDU */
3426 lt_rx_q_is_empty(&conn);
3427
3428 /* Done */
3429 event_done(&conn);
3430
3431 /* (B) There should be one host notification */
3432 ut_rx_node(NODE_CONN_UPDATE, &ntf, &cu2);
3433 ut_rx_q_is_empty();
3434
3435 {
3436 /* Now the locally initiated CPR on conn_3rd should be allowed to run */
3437 /* Prepare */
3438 event_prepare(&conn_2nd);
3439
3440 /* Tx Queue should have one LL Control PDU, indicating parallel CPR is now active */
3441 conn_param_req.reference_conn_event_count = event_counter(&conn_2nd);
3442 lt_rx(LL_CONNECTION_PARAM_REQ, &conn_2nd, &tx, &conn_param_req);
3443 lt_rx_q_is_empty(&conn_2nd);
3444
3445 /* Done */
3446 event_done(&conn_2nd);
3447
3448 /* Release Tx */
3449 ull_cp_release_tx(&conn_2nd, tx);
3450 }
3451
3452 /* Release Ntf */
3453 release_ntf(ntf);
3454
3455 /* One less CTXs as the conn_2nd CPR is still 'running' */
3456 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt()-1,
3457 "Free CTX buffers %d", llcp_ctx_buffers_free());
3458 }
3459
3460 /*
3461 * Central-initiated Connection Parameters Request procedure.
3462 * Central requests change in LE connection parameters, peripheral’s Host accepts.
3463 *
3464 * +-----+ +-------+ +-----+
3465 * | UT | | LL_P | | LT |
3466 * +-----+ +-------+ +-----+
3467 * | | |
3468 * | | LL_CONNECTION_PARAM_REQ |
3469 * | |<--------------------------|
3470 * | | |
3471 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3472 * ~~~~~ parallel remote CPR is attempted and rejected ~~~~~~~
3473 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3474 * | | |
3475 * | LE Remote Connection | |
3476 * | Parameter Request | |
3477 * |<--------------------------| |
3478 * | LE Remote Connection | |
3479 * | Parameter Request | |
3480 * | Reply | |
3481 * |-------------------------->| |
3482 * | | |
3483 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3484 * ~~~~~ parallel local CPR is attempted and cached ~~~~~~~
3485 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3486 * | | |
3487 * | | LL_CONNECTION_PARAM_RSP |
3488 * | |-------------------------->|
3489 * | | |
3490 * | | LL_CONNECTION_UPDATE_IND |
3491 * | |<--------------------------|
3492 * | | |
3493 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3494 * | | |
3495 * | LE Connection Update | |
3496 * | Complete | |
3497 * |<--------------------------| |
3498 * | | |
3499 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3500 * ~~~~~~~~~ parallel local CPR is now started ~~~~~~~~~~~~
3501 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3502 * | | |
3503 */
ZTEST(periph_rem,test_conn_update_periph_rem_accept_reject_2nd_cpr)3504 ZTEST(periph_rem, test_conn_update_periph_rem_accept_reject_2nd_cpr)
3505 {
3506 uint8_t err;
3507 struct ll_conn conn_2nd;
3508 struct ll_conn conn_3rd;
3509 struct node_tx *tx;
3510 struct node_rx_pdu *ntf;
3511 uint16_t instant;
3512 struct pdu_data_llctrl_reject_ext_ind parallel_reject_ext_ind = {
3513 .reject_opcode = PDU_DATA_LLCTRL_TYPE_CONN_PARAM_REQ,
3514 .error_code = BT_HCI_ERR_UNSUPP_LL_PARAM_VAL
3515 };
3516
3517 struct node_rx_pu cu = { .status = BT_HCI_ERR_SUCCESS };
3518
3519 /* Initialize extra connections */
3520 test_setup_idx(&conn_2nd, 1);
3521 test_setup_idx(&conn_3rd, 2);
3522
3523 /* Role */
3524 test_set_role(&conn, BT_HCI_ROLE_PERIPHERAL);
3525 /* Role */
3526 test_set_role(&conn_2nd, BT_HCI_ROLE_PERIPHERAL);
3527 /* Role */
3528 test_set_role(&conn_3rd, BT_HCI_ROLE_CENTRAL);
3529
3530 /* Connect */
3531 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
3532 /* Connect */
3533 ull_cp_state_set(&conn_2nd, ULL_CP_CONNECTED);
3534 /* Connect */
3535 ull_cp_state_set(&conn_3rd, ULL_CP_CONNECTED);
3536
3537 /* Prepare */
3538 event_prepare(&conn);
3539
3540 /* Tx Queue should NOT have a LL Control PDU */
3541 lt_rx_q_is_empty(&conn);
3542
3543 /* Rx */
3544 lt_tx(LL_CONNECTION_PARAM_REQ, &conn, &conn_param_req);
3545
3546 /* Done */
3547 event_done(&conn);
3548
3549 {
3550 /* Parallel CPR from central */
3551 /* Now CPR is active on 'conn' so let 'conn_2nd' attempt to start a CPR */
3552 /* Prepare */
3553 event_prepare(&conn_2nd);
3554
3555 /* Tx Queue should NOT have a LL Control PDU */
3556 lt_rx_q_is_empty(&conn_2nd);
3557
3558 /* Rx */
3559 lt_tx(LL_CONNECTION_PARAM_REQ, &conn_2nd, &conn_param_req);
3560
3561 /* Done */
3562 event_done(&conn_2nd);
3563
3564 /* Tx Queue should have one LL Control PDU */
3565 lt_rx(LL_REJECT_EXT_IND, &conn_2nd, &tx, ¶llel_reject_ext_ind);
3566 lt_rx_q_is_empty(&conn_2nd);
3567
3568 /* Release Tx */
3569 ull_cp_release_tx(&conn_2nd, tx);
3570
3571 /* There should be no 'extra' procedure on acount of the parallel CPR */
3572 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt()-1,
3573 "Free CTX buffers %d", llcp_ctx_buffers_free());
3574 }
3575
3576 /* Prepare */
3577 event_prepare(&conn);
3578
3579 /* Done */
3580 event_done(&conn);
3581
3582 {
3583 /* Parallel CPR from peripheral */
3584 /* Now CPR is active on 'conn' so let 'conn_3rd' attempt to start a CPR */
3585 /* Prepare */
3586 event_prepare(&conn_3rd);
3587
3588 /* Tx Queue should NOT have a LL Control PDU */
3589 lt_rx_q_is_empty(&conn_3rd);
3590
3591 /* Rx */
3592 lt_tx(LL_CONNECTION_PARAM_REQ, &conn_3rd, &conn_param_req);
3593
3594 /* Done */
3595 event_done(&conn_3rd);
3596
3597 /* Tx Queue should have one LL Control PDU */
3598 lt_rx(LL_REJECT_EXT_IND, &conn_3rd, &tx, ¶llel_reject_ext_ind);
3599 lt_rx_q_is_empty(&conn_3rd);
3600
3601 /* Release Tx */
3602 ull_cp_release_tx(&conn_3rd, tx);
3603
3604 /* There should be no 'extra' procedure on acount of the parallel CPR */
3605 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt()-1,
3606 "Free CTX buffers %d", llcp_ctx_buffers_free());
3607 }
3608
3609 /* There should be one host notification */
3610 ut_rx_pdu(LL_CONNECTION_PARAM_REQ, &ntf, &conn_param_req);
3611 ut_rx_q_is_empty();
3612
3613 /* Release Ntf */
3614 release_ntf(ntf);
3615
3616 /*******************/
3617
3618 ull_cp_conn_param_req_reply(&conn);
3619
3620 {
3621 /* Initiate a parallel local Connection Parameter Request Procedure */
3622 err = ull_cp_conn_update(&conn_2nd, INTVL_MIN, INTVL_MAX, LATENCY, TIMEOUT, NULL);
3623 zassert_equal(err, BT_HCI_ERR_SUCCESS);
3624
3625 /* Prepare */
3626 event_prepare(&conn_2nd);
3627
3628 /* Tx Queue should have no LL Control PDU */
3629 lt_rx_q_is_empty(&conn_2nd);
3630
3631 /* Done */
3632 event_done(&conn_2nd);
3633
3634 /* Prepare */
3635 event_prepare(&conn_2nd);
3636
3637 /* Tx Queue should have no LL Control PDU */
3638 lt_rx_q_is_empty(&conn_2nd);
3639
3640 /* Done */
3641 event_done(&conn_2nd);
3642 }
3643
3644 /* Prepare */
3645 event_prepare(&conn);
3646
3647 /* Tx Queue should have one LL Control PDU */
3648 lt_rx(LL_CONNECTION_PARAM_RSP, &conn, &tx, &conn_param_rsp);
3649 lt_rx_q_is_empty(&conn);
3650
3651 /* Done */
3652 event_done(&conn);
3653
3654 /* Prepare */
3655 event_prepare(&conn);
3656
3657 /* Rx */
3658 conn_update_ind.instant = event_counter(&conn) + 6U;
3659 instant = conn_update_ind.instant;
3660 lt_tx(LL_CONNECTION_UPDATE_IND, &conn, &conn_update_ind);
3661
3662 /* Done */
3663 event_done(&conn);
3664
3665 /* Release Tx */
3666 ull_cp_release_tx(&conn, tx);
3667
3668 /* */
3669 while (!is_instant_reached(&conn, instant)) {
3670 /* Prepare */
3671 event_prepare(&conn);
3672
3673 /* Tx Queue should NOT have a LL Control PDU */
3674 lt_rx_q_is_empty(&conn);
3675
3676 /* Done */
3677 event_done(&conn);
3678
3679 /* There should NOT be a host notification */
3680 ut_rx_q_is_empty();
3681 }
3682
3683 /* Prepare */
3684 event_prepare(&conn);
3685
3686 /* Tx Queue should NOT have a LL Control PDU */
3687 lt_rx_q_is_empty(&conn);
3688
3689 /* Done */
3690 event_done(&conn);
3691
3692 /* There should be one host notification */
3693 ut_rx_node(NODE_CONN_UPDATE, &ntf, &cu);
3694 ut_rx_q_is_empty();
3695
3696 {
3697 /* Now the locally initiated CPR on conn_3rd should be allowed to run */
3698 /* Prepare */
3699 event_prepare(&conn_2nd);
3700
3701 /* Tx Queue should have one LL Control PDU, indicating parallel CPR is now active */
3702 conn_param_req.reference_conn_event_count = event_counter(&conn_2nd);
3703 lt_rx(LL_CONNECTION_PARAM_REQ, &conn_2nd, &tx, &conn_param_req);
3704 lt_rx_q_is_empty(&conn_2nd);
3705
3706 /* Done */
3707 event_done(&conn_2nd);
3708
3709 /* Release Tx */
3710 ull_cp_release_tx(&conn_2nd, tx);
3711 }
3712
3713 /* Release Ntf */
3714 release_ntf(ntf);
3715
3716 /* One less CTXs as the conn_2nd CPR is still 'running' */
3717 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt()-1,
3718 "Free CTX buffers %d", llcp_ctx_buffers_free());
3719 }
3720
3721 /*
3722 * Central-initiated Connection Parameters Request procedure.
3723 * Central requests change in LE connection with invalid parameters,
3724 *
3725 * +-----+ +-------+ +-----+
3726 * | UT | | LL_P | | LT |
3727 * +-----+ +-------+ +-----+
3728 * | | |
3729 * | | LL_CONNECTION_PARAM_REQ |
3730 * | |<--------------------------|
3731 * | | |
3732 * | | |
3733 * | | LL_REJECT_EXT_IND |
3734 * | |-------------------------->|
3735 * | | |
3736 * | | |
3737 */
ZTEST(periph_rem,test_conn_update_periph_rem_invalid_req)3738 ZTEST(periph_rem, test_conn_update_periph_rem_invalid_req)
3739 {
3740 struct node_tx *tx;
3741 struct pdu_data_llctrl_reject_ext_ind reject_ext_ind = {
3742 .reject_opcode = PDU_DATA_LLCTRL_TYPE_CONN_PARAM_REQ,
3743 .error_code = BT_HCI_ERR_INVALID_LL_PARAM
3744 };
3745
3746 /* Role */
3747 test_set_role(&conn, BT_HCI_ROLE_PERIPHERAL);
3748
3749 /* Connect */
3750 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
3751
3752 /* Prepare */
3753 event_prepare(&conn);
3754
3755 /* Rx */
3756 lt_tx(LL_CONNECTION_PARAM_REQ, &conn, &conn_param_req_invalid);
3757
3758 /* Done */
3759 event_done(&conn);
3760
3761 /* Prepare */
3762 event_prepare(&conn);
3763
3764 /* Tx Queue should have one LL Control PDU */
3765 lt_rx(LL_REJECT_EXT_IND, &conn, &tx, &reject_ext_ind);
3766 lt_rx_q_is_empty(&conn);
3767
3768 /* Done */
3769 event_done(&conn);
3770
3771 /* Release Tx */
3772 ull_cp_release_tx(&conn, tx);
3773 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
3774 "Free CTX buffers %d", llcp_ctx_buffers_free());
3775
3776 }
3777
3778 /*
3779 * Central-initiated Connection Parameters Request procedure.
3780 * Central requests change in LE connection parameters, peripheral’s Host accepts.
3781 *
3782 * +-----+ +-------+ +-----+
3783 * | UT | | LL_S | | LT |
3784 * +-----+ +-------+ +-----+
3785 * | | |
3786 * | | LL_CONNECTION_PARAM_REQ |
3787 * | |<--------------------------|
3788 * | | |
3789 * | LE Remote Connection | |
3790 * | Parameter Request | |
3791 * |<--------------------------| |
3792 * | LE Remote Connection | |
3793 * | Parameter Request | |
3794 * | Reply | |
3795 * |-------------------------->| |
3796 * | | |
3797 * | | LL_CONNECTION_PARAM_RSP |
3798 * | |-------------------------->|
3799 * | | |
3800 * | | LL_<INVALID_IND> |
3801 * | |<--------------------------|
3802 * | | |
3803 * ~~~~~~~~~~~~~~~~~ TERMINATE CONNECTION ~~~~~~~~~~~~~~~~~~
3804 * | | |
3805 * | | |
3806 */
ZTEST(periph_rem,test_conn_update_periph_rem_invalid_ind)3807 ZTEST(periph_rem, test_conn_update_periph_rem_invalid_ind)
3808 {
3809 struct node_tx *tx;
3810 struct node_rx_pdu *ntf;
3811 struct pdu_data_llctrl_reject_ind reject_ind = {
3812 .error_code = BT_HCI_ERR_LL_PROC_COLLISION
3813 };
3814 struct pdu_data_llctrl_reject_ext_ind reject_ext_ind = {
3815 .reject_opcode = PDU_DATA_LLCTRL_TYPE_CONN_PARAM_RSP,
3816 .error_code = BT_HCI_ERR_LL_PROC_COLLISION
3817 };
3818 struct pdu_data_llctrl_unknown_rsp unknown_rsp = {
3819 .type = PDU_DATA_LLCTRL_TYPE_CONN_PARAM_RSP
3820 };
3821
3822 /* Role */
3823 test_set_role(&conn, BT_HCI_ROLE_PERIPHERAL);
3824
3825 /* Connect */
3826 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
3827
3828 /* Prepare */
3829 event_prepare(&conn);
3830
3831 /* Tx Queue should NOT have a LL Control PDU */
3832 lt_rx_q_is_empty(&conn);
3833
3834 /* Rx */
3835 lt_tx(LL_CONNECTION_PARAM_REQ, &conn, &conn_param_req);
3836
3837 /* Done */
3838 event_done(&conn);
3839
3840 /*******************/
3841
3842 /* There should be one host notification */
3843 ut_rx_pdu(LL_CONNECTION_PARAM_REQ, &ntf, &conn_param_req);
3844 ut_rx_q_is_empty();
3845
3846 /* Release Ntf */
3847 release_ntf(ntf);
3848
3849 /*******************/
3850
3851 ull_cp_conn_param_req_reply(&conn);
3852
3853 /*******************/
3854
3855 /* Prepare */
3856 event_prepare(&conn);
3857
3858 /* Tx Queue should have one LL Control PDU */
3859 lt_rx(LL_CONNECTION_PARAM_RSP, &conn, &tx, &conn_param_rsp);
3860 lt_rx_q_is_empty(&conn);
3861
3862 /* Done */
3863 event_done(&conn);
3864
3865 /* Prepare */
3866 event_prepare(&conn);
3867
3868 /* Rx */
3869 lt_tx(LL_REJECT_IND, &conn, &reject_ind);
3870
3871 /* Done */
3872 event_done(&conn);
3873
3874 /* Release Tx */
3875 ull_cp_release_tx(&conn, tx);
3876
3877 /* Termination 'triggered' */
3878 zassert_equal(conn.llcp_terminate.reason_final, BT_HCI_ERR_LMP_PDU_NOT_ALLOWED,
3879 "Terminate reason %d", conn.llcp_terminate.reason_final);
3880
3881 /* Clear termination flag for subsequent test cycle */
3882 conn.llcp_terminate.reason_final = 0;
3883
3884 /* There should be no host notifications */
3885 ut_rx_q_is_empty();
3886
3887 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
3888 "Free CTX buffers %d", llcp_ctx_buffers_free());
3889
3890 event_prepare(&conn);
3891
3892 /* Tx Queue should NOT have a LL Control PDU */
3893 lt_rx_q_is_empty(&conn);
3894
3895 /* Rx */
3896 lt_tx(LL_CONNECTION_PARAM_REQ, &conn, &conn_param_req);
3897
3898 /* Done */
3899 event_done(&conn);
3900
3901 /*******************/
3902
3903 /* There should be one host notification */
3904 ut_rx_pdu(LL_CONNECTION_PARAM_REQ, &ntf, &conn_param_req);
3905 ut_rx_q_is_empty();
3906
3907 /* Release Ntf */
3908 release_ntf(ntf);
3909
3910 /*******************/
3911
3912 ull_cp_conn_param_req_reply(&conn);
3913
3914 /*******************/
3915
3916 /* Prepare */
3917 event_prepare(&conn);
3918
3919 /* Tx Queue should have one LL Control PDU */
3920 lt_rx(LL_CONNECTION_PARAM_RSP, &conn, &tx, &conn_param_rsp);
3921 lt_rx_q_is_empty(&conn);
3922
3923 /* Done */
3924 event_done(&conn);
3925
3926 /* Prepare */
3927 event_prepare(&conn);
3928
3929 /* Rx */
3930 lt_tx(LL_REJECT_EXT_IND, &conn, &reject_ext_ind);
3931
3932 /* Done */
3933 event_done(&conn);
3934
3935 /* Release Tx */
3936 ull_cp_release_tx(&conn, tx);
3937
3938 /* Termination 'triggered' */
3939 zassert_equal(conn.llcp_terminate.reason_final, BT_HCI_ERR_LMP_PDU_NOT_ALLOWED,
3940 "Terminate reason %d", conn.llcp_terminate.reason_final);
3941
3942 /* Clear termination flag for subsequent test cycle */
3943 conn.llcp_terminate.reason_final = 0;
3944
3945 /* There should be no host notifications */
3946 ut_rx_q_is_empty();
3947
3948 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
3949 "Free CTX buffers %d", llcp_ctx_buffers_free());
3950
3951 /* Prepare */
3952 event_prepare(&conn);
3953
3954 /* Tx Queue should NOT have a LL Control PDU */
3955 lt_rx_q_is_empty(&conn);
3956
3957 /* Rx */
3958 lt_tx(LL_CONNECTION_PARAM_REQ, &conn, &conn_param_req);
3959
3960 /* Done */
3961 event_done(&conn);
3962
3963 /*******************/
3964
3965 /* There should be one host notification */
3966 ut_rx_pdu(LL_CONNECTION_PARAM_REQ, &ntf, &conn_param_req);
3967 ut_rx_q_is_empty();
3968
3969 /* Release Ntf */
3970 release_ntf(ntf);
3971
3972 /*******************/
3973
3974 ull_cp_conn_param_req_reply(&conn);
3975
3976 /*******************/
3977
3978 /* Prepare */
3979 event_prepare(&conn);
3980
3981 /* Tx Queue should have one LL Control PDU */
3982 lt_rx(LL_CONNECTION_PARAM_RSP, &conn, &tx, &conn_param_rsp);
3983 lt_rx_q_is_empty(&conn);
3984
3985 /* Done */
3986 event_done(&conn);
3987
3988 /* Prepare */
3989 event_prepare(&conn);
3990
3991 /* Rx */
3992 lt_tx(LL_UNKNOWN_RSP, &conn, &unknown_rsp);
3993
3994 /* Done */
3995 event_done(&conn);
3996
3997 /* Release Tx */
3998 ull_cp_release_tx(&conn, tx);
3999
4000 /* Termination 'triggered' */
4001 zassert_equal(conn.llcp_terminate.reason_final, BT_HCI_ERR_LMP_PDU_NOT_ALLOWED,
4002 "Terminate reason %d", conn.llcp_terminate.reason_final);
4003
4004 /* There should be no host notifications */
4005 ut_rx_q_is_empty();
4006
4007 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
4008 "Free CTX buffers %d", llcp_ctx_buffers_free());
4009 }
4010
4011 /*
4012 * Central-initiated Connection Parameters Request procedure.
4013 * Central requests change in LE connection parameters, peripheral’s Host rejects.
4014 *
4015 * +-----+ +-------+ +-----+
4016 * | UT | | LL_P | | LT |
4017 * +-----+ +-------+ +-----+
4018 * | | |
4019 * | | LL_CONNECTION_PARAM_REQ |
4020 * | |<--------------------------|
4021 * | | |
4022 * | LE Remote Connection | |
4023 * | Parameter Request | |
4024 * |<--------------------------| |
4025 * | LE Remote Connection | |
4026 * | Parameter Request | |
4027 * | Negative Reply | |
4028 * |-------------------------->| |
4029 * | | |
4030 * | | LL_REJECT_EXT_IND |
4031 * | |-------------------------->|
4032 * | | |
4033 */
ZTEST(periph_rem,test_conn_update_periph_rem_reject)4034 ZTEST(periph_rem, test_conn_update_periph_rem_reject)
4035 {
4036 struct node_tx *tx;
4037 struct node_rx_pdu *ntf;
4038
4039 struct pdu_data_llctrl_reject_ext_ind reject_ext_ind = {
4040 .reject_opcode = PDU_DATA_LLCTRL_TYPE_CONN_PARAM_REQ,
4041 .error_code = BT_HCI_ERR_UNACCEPT_CONN_PARAM
4042 };
4043
4044 /* Role */
4045 test_set_role(&conn, BT_HCI_ROLE_PERIPHERAL);
4046
4047 /* Connect */
4048 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
4049
4050 /* Prepare */
4051 event_prepare(&conn);
4052
4053 /* Tx Queue should NOT have a LL Control PDU */
4054 lt_rx_q_is_empty(&conn);
4055
4056 /* Rx */
4057 lt_tx(LL_CONNECTION_PARAM_REQ, &conn, &conn_param_req);
4058
4059 /* Done */
4060 event_done(&conn);
4061
4062 /*******************/
4063
4064 /* There should be one host notification */
4065 ut_rx_pdu(LL_CONNECTION_PARAM_REQ, &ntf, &conn_param_req);
4066 ut_rx_q_is_empty();
4067
4068 /* Release Ntf */
4069 release_ntf(ntf);
4070
4071 /*******************/
4072
4073 ull_cp_conn_param_req_neg_reply(&conn, BT_HCI_ERR_UNACCEPT_CONN_PARAM);
4074
4075 /*******************/
4076
4077 /* Prepare */
4078 event_prepare(&conn);
4079
4080 /* Tx Queue should have one LL Control PDU */
4081 lt_rx(LL_REJECT_EXT_IND, &conn, &tx, &reject_ext_ind);
4082 lt_rx_q_is_empty(&conn);
4083
4084 /* Done */
4085 event_done(&conn);
4086
4087 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
4088 "Free CTX buffers %d", llcp_ctx_buffers_free());
4089 }
4090
4091 /*
4092 * (A)
4093 * Central-initiated Connection Parameters Request procedure.
4094 * Central requests change in LE connection parameters, peripheral’s Host accepts.
4095 *
4096 * and
4097 *
4098 * (B)
4099 * Peripheral-initiated Connection Parameters Request procedure.
4100 * Peripheral requests change in LE connection parameters, central’s Host accepts.
4101 *
4102 * NOTE:
4103 * Peripheral-initiated Connection Parameters Request procedure is paused.
4104 * Central-initiated Connection Parameters Request procedure is finished.
4105 * Peripheral-initiated Connection Parameters Request procedure is resumed.
4106 *
4107 * +-----+ +-------+ +-----+
4108 * | UT | | LL_P | | LT |
4109 * +-----+ +-------+ +-----+
4110 * | | |
4111 * | | LL_CONNECTION_PARAM_REQ |
4112 * | |<--------------------------| (A)
4113 * | | |
4114 * | LE Connection Update | |
4115 * |-------------------------->| | (B)
4116 * | | |
4117 * | <------------------------> |
4118 * | < LOCAL PROCEDURE PAUSED > |
4119 * | <------------------------> |
4120 * | | |
4121 * | LE Remote Connection | |
4122 * | Parameter Request | |
4123 * |<--------------------------| | (A)
4124 * | LE Remote Connection | |
4125 * | Parameter Request | |
4126 * | Reply | |
4127 * |-------------------------->| | (A)
4128 * | | |
4129 * | | LL_CONNECTION_PARAM_RSP |
4130 * | |-------------------------->| (A)
4131 * | | |
4132 * | | LL_CONNECTION_UPDATE_IND |
4133 * | |<--------------------------| (A)
4134 * | | |
4135 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4136 * | | |
4137 * | LE Connection Update | |
4138 * | Complete | |
4139 * |<--------------------------| | (A)
4140 * | | |
4141 * | <-------------------------> |
4142 * | < LOCAL PROCEDURE RESUMED > |
4143 * | <-------------------------> |
4144 * | | |
4145 * | | LL_CONNECTION_PARAM_REQ |
4146 * | |-------------------------->| (B)
4147 * | | |
4148 * | | LL_CONNECTION_UPDATE_IND |
4149 * | |<--------------------------| (B)
4150 * | | |
4151 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4152 * | | |
4153 * | LE Connection Update | |
4154 * | Complete | |
4155 * |<--------------------------| | (B)
4156 * | | |
4157 */
ZTEST(periph_rem,test_conn_update_periph_rem_collision)4158 ZTEST(periph_rem, test_conn_update_periph_rem_collision)
4159 {
4160 uint8_t err;
4161 struct node_tx *tx;
4162 struct node_rx_pdu *ntf;
4163 uint16_t instant;
4164
4165 struct node_rx_pu cu = { .status = BT_HCI_ERR_SUCCESS };
4166
4167 /* Role */
4168 test_set_role(&conn, BT_HCI_ROLE_PERIPHERAL);
4169
4170 /* Connect */
4171 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
4172
4173 /*******************/
4174
4175 /* Prepare */
4176 event_prepare(&conn);
4177
4178 /* (A) Rx */
4179 lt_tx(LL_CONNECTION_PARAM_REQ, &conn, &conn_param_req);
4180
4181 /* Done */
4182 event_done(&conn);
4183
4184 /*******************/
4185
4186 /* (B) Initiate a Connection Parameter Request Procedure */
4187 err = ull_cp_conn_update(&conn, req_B->interval_min, req_B->interval_max, req_B->latency,
4188 req_B->timeout, NULL);
4189 zassert_equal(err, BT_HCI_ERR_SUCCESS);
4190
4191 /*******************/
4192
4193 /* Prepare */
4194 event_prepare(&conn);
4195
4196 /* (B) Tx Queue should NOT have a LL Control PDU */
4197 lt_rx_q_is_empty(&conn);
4198
4199 /* Done */
4200 event_done(&conn);
4201
4202 /*******************/
4203 /* (A) There should be one host notification */
4204 ut_rx_pdu(LL_CONNECTION_PARAM_REQ, &ntf, &conn_param_req);
4205 ut_rx_q_is_empty();
4206
4207 /* Release Ntf */
4208 release_ntf(ntf);
4209
4210 /*******************/
4211
4212 /* (A) */
4213 ull_cp_conn_param_req_reply(&conn);
4214
4215 /*******************/
4216
4217 /* Prepare */
4218 event_prepare(&conn);
4219 conn_param_rsp.reference_conn_event_count = conn_param_req.reference_conn_event_count;
4220
4221 /* (A) Tx Queue should have one LL Control PDU */
4222 lt_rx(LL_CONNECTION_PARAM_RSP, &conn, &tx, &conn_param_rsp);
4223 lt_rx_q_is_empty(&conn);
4224
4225 /* Done */
4226 event_done(&conn);
4227
4228 /* Prepare */
4229 event_prepare(&conn);
4230
4231 /* (A) Rx */
4232 conn_update_ind.instant = event_counter(&conn) + 6U;
4233 instant = conn_update_ind.instant;
4234 lt_tx(LL_CONNECTION_UPDATE_IND, &conn, &conn_update_ind);
4235
4236 /* Done */
4237 event_done(&conn);
4238
4239 /* Release Tx */
4240 ull_cp_release_tx(&conn, tx);
4241
4242 /* */
4243 while (!is_instant_reached(&conn, instant)) {
4244 /* Prepare */
4245 event_prepare(&conn);
4246
4247 /* (A) Tx Queue should NOT have a LL Control PDU */
4248 lt_rx_q_is_empty(&conn);
4249
4250 /* Done */
4251 event_done(&conn);
4252
4253 /* (A) There should NOT be a host notification */
4254 ut_rx_q_is_empty();
4255 }
4256
4257 /* Prepare */
4258 event_prepare(&conn);
4259
4260 /* (B) Tx Queue should have one LL Control PDU */
4261 req_B->reference_conn_event_count = event_counter(&conn) - 1;
4262 lt_rx(LL_CONNECTION_PARAM_REQ, &conn, &tx, req_B);
4263 lt_rx_q_is_empty(&conn);
4264
4265 /* Done */
4266 event_done(&conn);
4267
4268 /* (A) There should be one host notification */
4269 ut_rx_node(NODE_CONN_UPDATE, &ntf, &cu);
4270 ut_rx_q_is_empty();
4271
4272 /* Release Ntf */
4273 release_ntf(ntf);
4274
4275 /* Prepare */
4276 event_prepare(&conn);
4277
4278 /* (B) Tx Queue should NOT have a LL Control PDU */
4279 lt_rx_q_is_empty(&conn);
4280
4281 /* (B) Rx */
4282 cu_ind_B->instant = instant = event_counter(&conn) + 6;
4283 lt_tx(LL_CONNECTION_UPDATE_IND, &conn, cu_ind_B);
4284
4285 /* Done */
4286 event_done(&conn);
4287
4288 /* */
4289 while (!is_instant_reached(&conn, instant)) {
4290 /* Prepare */
4291 event_prepare(&conn);
4292
4293 /* (B) Tx Queue should NOT have a LL Control PDU */
4294 lt_rx_q_is_empty(&conn);
4295
4296 /* Done */
4297 event_done(&conn);
4298
4299 /* (B) There should NOT be a host notification */
4300 ut_rx_q_is_empty();
4301 }
4302
4303 /* Prepare */
4304 event_prepare(&conn);
4305
4306 /* (B) Tx Queue should NOT have a LL Control PDU */
4307 lt_rx_q_is_empty(&conn);
4308
4309 /* Done */
4310 event_done(&conn);
4311
4312 /* (B) There should be one host notification */
4313 ut_rx_node(NODE_CONN_UPDATE, &ntf, &cu);
4314 ut_rx_q_is_empty();
4315
4316 /* Release Ntf */
4317 release_ntf(ntf);
4318 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
4319 "Free CTX buffers %d", llcp_ctx_buffers_free());
4320 }
4321
4322 /*
4323 * (A)
4324 * Central-initiated Connection Parameters Request procedure.
4325 * Central requests change in LE connection parameters, peripheral’s Host accepts.
4326 *
4327 * and
4328 *
4329 * (B)
4330 * Peripheral-initiated Connection Parameters Request procedure.
4331 * Peripheral requests change in LE connection parameters, central’s Host accepts.
4332 *
4333 * NOTE:
4334 * Peripheral-initiated Connection Parameters Request procedure is paused.
4335 * Central-initiated Connection Parameters Request procedure is finished.
4336 * Peripheral-initiated Connection Parameters Request procedure is resumed.
4337 *
4338 * +-----+ +-------+ +-----+
4339 * | UT | | LL_P | | LT |
4340 * +-----+ +-------+ +-----+
4341 * | | |
4342 * | LE Connection Update | |
4343 * |-------------------------->| | (B)
4344 * | | LL_CONNECTION_PARAM_REQ |
4345 * | |<--------------------------| (A)
4346 * | | LL_CONNECTION_PARAM_REQ |
4347 * | |-------------------------->| (B)
4348 * | | |
4349 * | | |
4350 * | | |
4351 * | LE Remote Connection | |
4352 * | Parameter Request | |
4353 * |<--------------------------| | (A)
4354 * | LE Remote Connection | |
4355 * | Parameter Request | |
4356 * | Reply | |
4357 * |-------------------------->| | (A)
4358 * | | LL_REJECT_EXT_IND |
4359 * | |<--------------------------| (B)
4360 * | | |
4361 * | LE Connection Update | |
4362 * | Complete (collision) | |
4363 * |<--------------------------| | (B)
4364 * | | LL_CONNECTION_PARAM_RSP |
4365 * | |-------------------------->| (A)
4366 * | | |
4367 * | LE Connection Update | |
4368 * |-------------------------->| | (B)
4369 * | | |
4370 * | <------------------------> |
4371 * | < LOCAL PROCEDURE PAUSED > |
4372 * | <------------------------> |
4373 * | | |
4374 * | | LL_CONNECTION_UPDATE_IND |
4375 * | |<--------------------------| (A)
4376 * | | |
4377 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4378 * | | |
4379 * | LE Connection Update | |
4380 * | Complete | |
4381 * |<--------------------------| | (A)
4382 * | | |
4383 * | <-------------------------> |
4384 * | < LOCAL PROCEDURE RESUMED > |
4385 * | <-------------------------> |
4386 * | | |
4387 * | | LL_CONNECTION_PARAM_REQ |
4388 * | |-------------------------->| (B)
4389 * | | |
4390 * | | LL_CONNECTION_UPDATE_IND |
4391 * | |<--------------------------| (B)
4392 * | | |
4393 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4394 * | | |
4395 * | LE Connection Update | |
4396 * | Complete | |
4397 * |<--------------------------| | (B)
4398 * | | |
4399 */
ZTEST(periph_rem,test_conn_update_periph_rem_late_collision)4400 ZTEST(periph_rem, test_conn_update_periph_rem_late_collision)
4401 {
4402 uint8_t err;
4403 struct node_tx *tx;
4404 struct node_rx_pdu *ntf;
4405 uint16_t instant;
4406 struct pdu_data_llctrl_reject_ext_ind reject_ext_ind = {
4407 .reject_opcode = PDU_DATA_LLCTRL_TYPE_CONN_PARAM_REQ,
4408 .error_code = BT_HCI_ERR_LL_PROC_COLLISION
4409 };
4410 struct node_rx_pu cu1 = { .status = BT_HCI_ERR_LL_PROC_COLLISION };
4411 struct node_rx_pu cu = { .status = BT_HCI_ERR_SUCCESS };
4412
4413 /* Role */
4414 test_set_role(&conn, BT_HCI_ROLE_PERIPHERAL);
4415
4416 /* Connect */
4417 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
4418
4419 /*******************/
4420
4421 /* (B) Initiate a Connection Parameter Request Procedure */
4422 err = ull_cp_conn_update(&conn, req_B->interval_min, req_B->interval_max, req_B->latency,
4423 req_B->timeout, NULL);
4424 zassert_equal(err, BT_HCI_ERR_SUCCESS);
4425
4426 /* Prepare */
4427 event_prepare(&conn);
4428
4429 /*******************/
4430
4431 /* (A) Rx */
4432 lt_tx(LL_CONNECTION_PARAM_REQ, &conn, &conn_param_req);
4433
4434 /* Done */
4435 event_done(&conn);
4436
4437 /*******************/
4438
4439 /* Prepare */
4440 event_prepare(&conn);
4441
4442 /* (B) Tx Queue should have one LL Control PDU */
4443 req_B->reference_conn_event_count = event_counter(&conn) - 1;
4444 lt_rx(LL_CONNECTION_PARAM_REQ, &conn, &tx, req_B);
4445 lt_rx_q_is_empty(&conn);
4446
4447 /* Done */
4448 event_done(&conn);
4449
4450 /*******************/
4451 /* (A) There should be one host notification */
4452 ut_rx_pdu(LL_CONNECTION_PARAM_REQ, &ntf, &conn_param_req);
4453 ut_rx_q_is_empty();
4454
4455 /* Release Ntf */
4456 release_ntf(ntf);
4457
4458 /*******************/
4459 /* Rx */
4460 lt_tx(LL_REJECT_EXT_IND, &conn, &reject_ext_ind);
4461
4462 /* (A) */
4463 ull_cp_conn_param_req_reply(&conn);
4464
4465 /*******************/
4466
4467 /* Prepare */
4468 event_prepare(&conn);
4469 conn_param_rsp.reference_conn_event_count = conn_param_req.reference_conn_event_count;
4470
4471 /* (A) Tx Queue should have one LL Control PDU */
4472 lt_rx(LL_CONNECTION_PARAM_RSP, &conn, &tx, &conn_param_rsp);
4473 lt_rx_q_is_empty(&conn);
4474
4475 /* Done */
4476 event_done(&conn);
4477
4478 /* (A) There should be one host notification */
4479 ut_rx_node(NODE_CONN_UPDATE, &ntf, &cu1);
4480 ut_rx_q_is_empty();
4481
4482 /* Release Ntf */
4483 release_ntf(ntf);
4484
4485 /* (B) Initiate a Connection Parameter Request Procedure */
4486 err = ull_cp_conn_update(&conn, req_B->interval_min, req_B->interval_max, req_B->latency,
4487 req_B->timeout, NULL);
4488
4489 /* Prepare */
4490 event_prepare(&conn);
4491 /* Done */
4492 event_done(&conn);
4493
4494
4495 /* (A) Rx */
4496 conn_update_ind.instant = event_counter(&conn) + 6U;
4497 instant = conn_update_ind.instant;
4498 lt_tx(LL_CONNECTION_UPDATE_IND, &conn, &conn_update_ind);
4499 /* Prepare */
4500 event_prepare(&conn);
4501
4502 /* Done */
4503 event_done(&conn);
4504
4505 /* Release Tx */
4506 ull_cp_release_tx(&conn, tx);
4507
4508 /* */
4509 while (!is_instant_reached(&conn, instant)) {
4510 /* Prepare */
4511 event_prepare(&conn);
4512
4513 /* (A) Tx Queue should NOT have a LL Control PDU */
4514 lt_rx_q_is_empty(&conn);
4515
4516 /* Done */
4517 event_done(&conn);
4518
4519 /* (A) There should NOT be a host notification */
4520 ut_rx_q_is_empty();
4521 }
4522
4523 /* Prepare */
4524 event_prepare(&conn);
4525
4526 /* (B) Tx Queue should have one LL Control PDU */
4527 req_B->reference_conn_event_count = event_counter(&conn) - 1;
4528 lt_rx(LL_CONNECTION_PARAM_REQ, &conn, &tx, req_B);
4529 lt_rx_q_is_empty(&conn);
4530
4531 /* Done */
4532 event_done(&conn);
4533
4534 /* (A) There should be one host notification */
4535 ut_rx_node(NODE_CONN_UPDATE, &ntf, &cu);
4536 ut_rx_q_is_empty();
4537
4538 /* Release Ntf */
4539 release_ntf(ntf);
4540
4541 /* Prepare */
4542 event_prepare(&conn);
4543
4544 /* (B) Tx Queue should NOT have a LL Control PDU */
4545 lt_rx_q_is_empty(&conn);
4546
4547 /* (B) Rx */
4548 cu_ind_B->instant = instant = event_counter(&conn) + 6;
4549 lt_tx(LL_CONNECTION_UPDATE_IND, &conn, cu_ind_B);
4550
4551 /* Done */
4552 event_done(&conn);
4553
4554 /* */
4555 while (!is_instant_reached(&conn, instant)) {
4556 /* Prepare */
4557 event_prepare(&conn);
4558
4559 /* (B) Tx Queue should NOT have a LL Control PDU */
4560 lt_rx_q_is_empty(&conn);
4561
4562 /* Done */
4563 event_done(&conn);
4564
4565 /* (B) There should NOT be a host notification */
4566 ut_rx_q_is_empty();
4567 }
4568
4569 /* Prepare */
4570 event_prepare(&conn);
4571
4572 /* (B) Tx Queue should NOT have a LL Control PDU */
4573 lt_rx_q_is_empty(&conn);
4574
4575 /* Done */
4576 event_done(&conn);
4577
4578 /* (B) There should be one host notification */
4579 ut_rx_node(NODE_CONN_UPDATE, &ntf, &cu);
4580 ut_rx_q_is_empty();
4581
4582 /* Release Ntf */
4583 release_ntf(ntf);
4584 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
4585 "Free CTX buffers %d", llcp_ctx_buffers_free());
4586 }
4587 #else /* CONFIG_BT_CTLR_CONN_PARAM_REQ */
4588
4589 /*
4590 * Parameter Request Procedure not supported.
4591 * Central-initiated Connection Update procedure.
4592 * Central requests update of LE connection.
4593 *
4594 * +-----+ +-------+ +-----+
4595 * | UT | | LL_C | | LT |
4596 * +-----+ +-------+ +-----+
4597 * | | |
4598 * | LE Connection Update | |
4599 * |-------------------------->| |
4600 * | | LL_CONNECTION_UPDATE_IND |
4601 * | |-------------------------->|
4602 * | | |
4603 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4604 * | | |
4605 * | LE Connection Update | |
4606 * | Complete | |
4607 * |<--------------------------| |
4608 * | | |
4609 * | (If conn. parameters are | |
4610 * | unchanged, host should | |
4611 * | not receive a ntf.) | |
4612 * | | |
4613 */
ZTEST(central_loc_no_param_req,test_conn_update_central_loc_accept_no_param_req)4614 ZTEST(central_loc_no_param_req, test_conn_update_central_loc_accept_no_param_req)
4615 {
4616 uint8_t err;
4617 struct node_tx *tx;
4618 struct node_rx_pdu *ntf;
4619 struct pdu_data *pdu;
4620 uint16_t instant;
4621
4622 /* Test with and without parameter change */
4623 uint8_t parameters_changed = 1U;
4624
4625 struct node_rx_pu cu = { .status = BT_HCI_ERR_SUCCESS };
4626
4627 /* Role */
4628 test_set_role(&conn, BT_HCI_ROLE_CENTRAL);
4629
4630 /* Connect */
4631 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
4632
4633 do {
4634 /* Initiate a Connection Update Procedure */
4635 err = ull_cp_conn_update(&conn, INTVL_MIN, INTVL_MAX, LATENCY, TIMEOUT, NULL);
4636 zassert_equal(err, BT_HCI_ERR_SUCCESS);
4637
4638 /* Prepare */
4639 event_prepare(&conn);
4640
4641 /* Tx Queue should have one LL Control PDU */
4642 conn_update_ind.instant = event_counter(&conn) + 6U;
4643 lt_rx(LL_CONNECTION_UPDATE_IND, &conn, &tx, &conn_update_ind);
4644 lt_rx_q_is_empty(&conn);
4645
4646 /* Done */
4647 event_done(&conn);
4648
4649 /* Release Tx */
4650 ull_cp_release_tx(&conn, tx);
4651
4652 /* Save Instant */
4653 pdu = (struct pdu_data *)tx->pdu;
4654 instant = sys_le16_to_cpu(pdu->llctrl.conn_update_ind.instant);
4655
4656 /* */
4657 while (!is_instant_reached(&conn, instant)) {
4658 /* Prepare */
4659 event_prepare(&conn);
4660
4661 /* Tx Queue should NOT have a LL Control PDU */
4662 lt_rx_q_is_empty(&conn);
4663
4664 /* Done */
4665 event_done(&conn);
4666
4667 /* There should NOT be a host notification */
4668 ut_rx_q_is_empty();
4669 }
4670
4671 /* Prepare */
4672 event_prepare(&conn);
4673
4674 /* Tx Queue should NOT have a LL Control PDU */
4675 lt_rx_q_is_empty(&conn);
4676
4677 /* Done */
4678 event_done(&conn);
4679
4680 if (parameters_changed == 0U) {
4681 /* There should NOT be a host notification */
4682 ut_rx_q_is_empty();
4683 } else {
4684 /* There should be one host notification */
4685 ut_rx_node(NODE_CONN_UPDATE, &ntf, &cu);
4686 ut_rx_q_is_empty();
4687
4688 /* Release Ntf */
4689 release_ntf(ntf);
4690 }
4691 } while (parameters_changed-- > 0U);
4692
4693 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
4694 "Free CTX buffers %d", llcp_ctx_buffers_free());
4695 }
4696
4697 /*
4698 * Parameter Request Procedure not supported.
4699 * Peripheral-initiated Connection Update/Connection Parameter Request procedure
4700 * Central receives Connection Update parameters.
4701 *
4702 * +-----+ +-------+ +-----+
4703 * | UT | | LL_C | | LT |
4704 * +-----+ +-------+ +-----+
4705 * | | |
4706 * | | LL_CONNECTION_UPDATE_IND |
4707 * | |<--------------------------|
4708 * | | |
4709 * | | LL_UNKNOWN_RSP |
4710 * | |-------------------------->|
4711 * | | |
4712 * | | |
4713 * | | LL_CONNECTION_PARAM_REQ |
4714 * | |<--------------------------|
4715 * | | |
4716 * | | LL_UNKNOWN_RSP |
4717 * | |-------------------------->|
4718 * | | |
4719 * | | |
4720 */
ZTEST(central_rem_no_param_req,test_conn_update_central_rem_unknown_no_param_req)4721 ZTEST(central_rem_no_param_req, test_conn_update_central_rem_unknown_no_param_req)
4722 {
4723 struct node_tx *tx;
4724
4725 struct pdu_data_llctrl_unknown_rsp unknown_rsp = {
4726 .type = PDU_DATA_LLCTRL_TYPE_CONN_UPDATE_IND
4727 };
4728
4729 /* Role */
4730 test_set_role(&conn, BT_HCI_ROLE_CENTRAL);
4731
4732 /* Connect */
4733 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
4734
4735 /* Prepare */
4736 event_prepare(&conn);
4737
4738 /* Rx */
4739 lt_tx(LL_CONNECTION_UPDATE_IND, &conn, &conn_update_ind);
4740
4741 /* Done */
4742 event_done(&conn);
4743
4744 /* Prepare */
4745 event_prepare(&conn);
4746
4747 /* Tx Queue should have one LL Control PDU */
4748 lt_rx(LL_UNKNOWN_RSP, &conn, &tx, &unknown_rsp);
4749 lt_rx_q_is_empty(&conn);
4750
4751 /* Done */
4752 event_done(&conn);
4753
4754 /* There should NOT be a host notification */
4755 ut_rx_q_is_empty();
4756
4757 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
4758 "Free CTX buffers %d", llcp_ctx_buffers_free());
4759
4760 /* Check UNKNOWN_RSP on Connection Parameter Request */
4761 unknown_rsp.type = PDU_DATA_LLCTRL_TYPE_CONN_PARAM_REQ;
4762 /* Prepare */
4763 event_prepare(&conn);
4764
4765 /* Rx */
4766 lt_tx(LL_CONNECTION_PARAM_REQ, &conn, &conn_param_req);
4767
4768 /* Done */
4769 event_done(&conn);
4770
4771 /* Prepare */
4772 event_prepare(&conn);
4773
4774 /* Tx Queue should have one LL Control PDU */
4775 lt_rx(LL_UNKNOWN_RSP, &conn, &tx, &unknown_rsp);
4776 lt_rx_q_is_empty(&conn);
4777
4778 /* Done */
4779 event_done(&conn);
4780
4781 /* There should NOT be a host notification */
4782 ut_rx_q_is_empty();
4783
4784 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
4785 "Free CTX buffers %d", llcp_ctx_buffers_free());
4786
4787 }
4788
4789 /*
4790 * Parameter Request Procedure not supported.
4791 * Peripheral-initiated Connection Update/Connection Parameter Request procedure
4792 * Central receives Connection Update parameters.
4793 *
4794 * +-----+ +-------+ +-----+
4795 * | UT | | LL_M | | LT |
4796 * +-----+ +-------+ +-----+
4797 * | | |
4798 * | | |
4799 * | | LL_CONNECTION_PARAM_REQ |
4800 * | |<--------------------------|
4801 * | | |
4802 * | | LL_UNKNOWN_RSP |
4803 * | |-------------------------->|
4804 * | | |
4805 * | | |
4806 */
ZTEST(periph_rem_no_param_req,test_conn_update_periph_rem_unknown_no_param_req)4807 ZTEST(periph_rem_no_param_req, test_conn_update_periph_rem_unknown_no_param_req)
4808 {
4809 struct node_tx *tx;
4810
4811 struct pdu_data_llctrl_unknown_rsp unknown_rsp = {
4812 .type = PDU_DATA_LLCTRL_TYPE_CONN_PARAM_REQ
4813 };
4814
4815 /* Role */
4816 test_set_role(&conn, BT_HCI_ROLE_PERIPHERAL);
4817
4818 /* Connect */
4819 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
4820
4821 /* Prepare */
4822 event_prepare(&conn);
4823
4824 /* Rx */
4825 lt_tx(LL_CONNECTION_PARAM_REQ, &conn, &conn_param_req);
4826
4827 /* Done */
4828 event_done(&conn);
4829
4830 /* Prepare */
4831 event_prepare(&conn);
4832
4833 /* Tx Queue should have one LL Control PDU */
4834 lt_rx(LL_UNKNOWN_RSP, &conn, &tx, &unknown_rsp);
4835 lt_rx_q_is_empty(&conn);
4836
4837 /* Done */
4838 event_done(&conn);
4839
4840 /* There should NOT be a host notification */
4841 ut_rx_q_is_empty();
4842
4843 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
4844 "Free CTX buffers %d", llcp_ctx_buffers_free());
4845
4846 }
4847
4848 /*
4849 * Parameter Request Procedure not supported.
4850 * Central-initiated Connection Update procedure.
4851 * Peripheral receives Connection Update parameters.
4852 *
4853 * +-----+ +-------+ +-----+
4854 * | UT | | LL_P | | LT |
4855 * +-----+ +-------+ +-----+
4856 * | | |
4857 * | | LL_CONNECTION_UPDATE_IND |
4858 * | |<--------------------------|
4859 * | | |
4860 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4861 * | | |
4862 * | LE Connection Update | |
4863 * | Complete | |
4864 * |<--------------------------| |
4865 * | | |
4866 * | (If conn. parameters are | |
4867 * | unchanged, host should | |
4868 * | not receive a ntf.) | |
4869 * | | |
4870 */
ZTEST(periph_rem_no_param_req,test_conn_update_periph_rem_accept_no_param_req)4871 ZTEST(periph_rem_no_param_req, test_conn_update_periph_rem_accept_no_param_req)
4872 {
4873 struct node_rx_pdu *ntf;
4874 uint16_t instant;
4875
4876 /* Test with and without parameter change */
4877 uint8_t parameters_changed = 1U;
4878
4879 struct node_rx_pu cu = { .status = BT_HCI_ERR_SUCCESS };
4880
4881 /* Role */
4882 test_set_role(&conn, BT_HCI_ROLE_PERIPHERAL);
4883
4884 /* Connect */
4885 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
4886
4887 do {
4888 /* Prepare */
4889 event_prepare(&conn);
4890
4891 /* Rx */
4892 conn_update_ind.instant = event_counter(&conn) + 6U;
4893 instant = conn_update_ind.instant;
4894 lt_tx(LL_CONNECTION_UPDATE_IND, &conn, &conn_update_ind);
4895
4896 /* Done */
4897 event_done(&conn);
4898
4899 /* */
4900 while (!is_instant_reached(&conn, instant)) {
4901 /* Prepare */
4902 event_prepare(&conn);
4903
4904 /* Tx Queue should NOT have a LL Control PDU */
4905 lt_rx_q_is_empty(&conn);
4906
4907 /* Done */
4908 event_done(&conn);
4909
4910 /* There should NOT be a host notification */
4911 ut_rx_q_is_empty();
4912 }
4913
4914 /* Prepare */
4915 event_prepare(&conn);
4916
4917 /* Tx Queue should NOT have a LL Control PDU */
4918 lt_rx_q_is_empty(&conn);
4919
4920 /* Done */
4921 event_done(&conn);
4922
4923 if (parameters_changed == 0U) {
4924 /* There should NOT be a host notification */
4925 ut_rx_q_is_empty();
4926 } else {
4927 /* There should be one host notification */
4928 ut_rx_node(NODE_CONN_UPDATE, &ntf, &cu);
4929 ut_rx_q_is_empty();
4930
4931 /* Release Ntf */
4932 release_ntf(ntf);
4933 }
4934 } while (parameters_changed-- > 0U);
4935
4936 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
4937 "Free CTX buffers %d", llcp_ctx_buffers_free());
4938 }
4939
4940 /*
4941 * Parameter Request Procedure not supported.
4942 * Peripheral-initiated Connection Update procedure (not allowed).
4943 *
4944 * +-----+ +-------+ +-----+
4945 * | UT | | LL_P | | LT |
4946 * +-----+ +-------+ +-----+
4947 * | | |
4948 * | LE Connection Update | |
4949 * |-------------------------->| |
4950 * | | |
4951 * | ERR CMD Disallowed | |
4952 * |<--------------------------| |
4953 * | | |
4954 */
ZTEST(periph_loc_no_param_req,test_conn_update_periph_loc_disallowed_no_param_req)4955 ZTEST(periph_loc_no_param_req, test_conn_update_periph_loc_disallowed_no_param_req)
4956 {
4957 uint8_t err;
4958
4959 /* Role */
4960 test_set_role(&conn, BT_HCI_ROLE_PERIPHERAL);
4961
4962 /* Connect */
4963 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
4964
4965 /* Initiate a Connection Update Procedure */
4966 err = ull_cp_conn_update(&conn, INTVL_MIN, INTVL_MAX, LATENCY, TIMEOUT, NULL);
4967 zassert_equal(err, BT_HCI_ERR_CMD_DISALLOWED);
4968
4969 /* Prepare */
4970 event_prepare(&conn);
4971
4972 /* Tx Queue should have no LL Control PDU */
4973 lt_rx_q_is_empty(&conn);
4974
4975 /* Done */
4976 event_done(&conn);
4977
4978 /* There should be no host notification */
4979 ut_rx_q_is_empty();
4980
4981 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
4982 "Free CTX buffers %d", llcp_ctx_buffers_free());
4983 }
4984 #endif
4985
4986 /*
4987 * Central-initiated Connection Update procedure.
4988 * Peripheral receives invalid Connection Update parameters.
4989 *
4990 * +-----+ +-------+ +-----+
4991 * | UT | | LL_P | | LT |
4992 * +-----+ +-------+ +-----+
4993 * | | |
4994 * | | LL_CONNECTION_UPDATE_IND |
4995 * | |<--------------------------|
4996 * | | |
4997 * ~~~~~~~~~~~~~~~~~~ TERMINATE CONNECTION ~~~~~~~~~~~~~~~~~
4998 * | | |
4999 */
ZTEST(periph_rem_invalid,test_conn_update_periph_rem_invalid_param)5000 ZTEST(periph_rem_invalid, test_conn_update_periph_rem_invalid_param)
5001 {
5002 uint16_t interval;
5003
5004 /* Role */
5005 test_set_role(&conn, BT_HCI_ROLE_PERIPHERAL);
5006
5007 /* Connect */
5008 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
5009
5010 /* Prepare */
5011 event_prepare(&conn);
5012
5013 /* Rx */
5014 interval = conn_update_ind.interval;
5015 conn_update_ind.interval = 0U;
5016 conn_update_ind.instant = event_counter(&conn) + 6U;
5017 lt_tx(LL_CONNECTION_UPDATE_IND, &conn, &conn_update_ind);
5018
5019 /* Done */
5020 event_done(&conn);
5021
5022 /* Termination 'triggered' */
5023 zassert_equal(conn.llcp_terminate.reason_final, BT_HCI_ERR_INVALID_LL_PARAM,
5024 "Terminate reason %d", conn.llcp_terminate.reason_final);
5025
5026 /* Clear termination flag for subsequent test cycle */
5027 conn.llcp_terminate.reason_final = 0;
5028
5029 /* Restore interval for other tests */
5030 conn_update_ind.interval = interval;
5031 }
5032
5033 #if defined(CONFIG_BT_CTLR_CONN_PARAM_REQ)
5034 /*
5035 * Peripheral-initiated Connection Parameters Request procedure.
5036 * Peripheral requests change in LE connection parameters, central’s Host accepts.
5037 * Peripheral receives invalid Connection Update parameters.
5038 *
5039 * +-----+ +-------+ +-----+
5040 * | UT | | LL_P | | LT |
5041 * +-----+ +-------+ +-----+
5042 * | | |
5043 * | LE Connection Update | |
5044 * |-------------------------->| |
5045 * | | LL_CONNECTION_PARAM_REQ |
5046 * | |-------------------------->|
5047 * | | |
5048 * | | LL_CONNECTION_UPDATE_IND |
5049 * | |<--------------------------|
5050 * | | |
5051 * ~~~~~~~~~~~~~~~~~~ TERMINATE CONNECTION ~~~~~~~~~~~~~~~~~
5052 * | | |
5053 */
ZTEST(periph_rem_invalid,test_conn_param_req_periph_rem_invalid_param)5054 ZTEST(periph_rem_invalid, test_conn_param_req_periph_rem_invalid_param)
5055 {
5056 struct node_tx *tx;
5057 uint16_t interval;
5058 uint8_t err;
5059
5060 /* Role */
5061 test_set_role(&conn, BT_HCI_ROLE_PERIPHERAL);
5062
5063 /* Connect */
5064 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
5065
5066 /* Initiate a Connection Parameter Request Procedure */
5067 err = ull_cp_conn_update(&conn, INTVL_MIN, INTVL_MAX, LATENCY, TIMEOUT, NULL);
5068 zassert_equal(err, BT_HCI_ERR_SUCCESS);
5069
5070 /* Prepare */
5071 event_prepare(&conn);
5072 conn_param_req.reference_conn_event_count = event_counter(&conn);
5073
5074 /* Tx Queue should have one LL Control PDU */
5075 lt_rx(LL_CONNECTION_PARAM_REQ, &conn, &tx, &conn_param_req);
5076 lt_rx_q_is_empty(&conn);
5077
5078 /* Done */
5079 event_done(&conn);
5080
5081 /* Release Tx */
5082 ull_cp_release_tx(&conn, tx);
5083
5084 /* Prepare */
5085 event_prepare(&conn);
5086
5087 /* Rx */
5088 interval = conn_update_ind.interval;
5089 conn_update_ind.interval = 0U;
5090 conn_update_ind.instant = event_counter(&conn) + 6U;
5091 lt_tx(LL_CONNECTION_UPDATE_IND, &conn, &conn_update_ind);
5092
5093 /* Done */
5094 event_done(&conn);
5095
5096 /* Termination 'triggered' */
5097 zassert_equal(conn.llcp_terminate.reason_final, BT_HCI_ERR_INVALID_LL_PARAM,
5098 "Terminate reason %d", conn.llcp_terminate.reason_final);
5099
5100 /* Clear termination flag for subsequent test cycle */
5101 conn.llcp_terminate.reason_final = 0;
5102
5103 /* Restore interval for other tests */
5104 conn_update_ind.interval = interval;
5105 }
5106 #endif /* CONFIG_BT_CTLR_CONN_PARAM_REQ */
5107
5108 #if defined(CONFIG_BT_CTLR_CONN_PARAM_REQ)
5109 ZTEST_SUITE(central_loc, NULL, NULL, conn_update_setup, NULL, NULL);
5110 ZTEST_SUITE(central_rem, NULL, NULL, conn_update_setup, NULL, NULL);
5111 ZTEST_SUITE(periph_loc, NULL, NULL, conn_update_setup, NULL, NULL);
5112 ZTEST_SUITE(periph_rem, NULL, NULL, conn_update_setup, NULL, NULL);
5113 #else
5114 ZTEST_SUITE(central_loc_no_param_req, NULL, NULL, conn_update_setup, NULL, NULL);
5115 ZTEST_SUITE(central_rem_no_param_req, NULL, NULL, conn_update_setup, NULL, NULL);
5116 ZTEST_SUITE(periph_loc_no_param_req, NULL, NULL, conn_update_setup, NULL, NULL);
5117 ZTEST_SUITE(periph_rem_no_param_req, NULL, NULL, conn_update_setup, NULL, NULL);
5118 #endif /* CONFIG_BT_CTLR_CONN_PARAM_REQ */
5119
5120 ZTEST_SUITE(periph_rem_invalid, NULL, NULL, conn_update_setup, NULL, NULL);
5121