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 #define INTVL_MIN 6U /* multiple of 1.25 ms (min 6, max 3200) */
48 #define INTVL_MAX 6U /* multiple of 1.25 ms (min 6, max 3200) */
49 #define LATENCY 1U
50 #define TIMEOUT 10U /* multiple of 10 ms (min 10, max 3200) */
51
52 #define PREFER_S8_CODING 1
53 #define PREFER_S2_CODING 0
54
55 static struct ll_conn conn;
56
57 struct pdu_data_llctrl_conn_update_ind conn_update_ind = { .win_size = 1U,
58 .win_offset = 0U,
59 .interval = INTVL_MAX,
60 .latency = LATENCY,
61 .timeout = TIMEOUT,
62 .instant = 6U };
63
64 struct pdu_data_llctrl_conn_param_req conn_param_req_B = {
65 .interval_min = INTVL_MIN,
66 .interval_max = INTVL_MAX,
67 .latency = LATENCY + 1U, /* differentiate parameter */
68 .timeout = TIMEOUT + 1U, /* differentiate parameter */
69 .preferred_periodicity = 0U,
70 .reference_conn_event_count = 0u,
71 .offset0 = 0x0000U,
72 .offset1 = 0xffffU,
73 .offset2 = 0xffffU,
74 .offset3 = 0xffffU,
75 .offset4 = 0xffffU,
76 .offset5 = 0xffffU
77 };
78
79 struct pdu_data_llctrl_conn_param_rsp conn_param_rsp = { .interval_min = INTVL_MIN,
80 .interval_max = INTVL_MAX,
81 .latency = LATENCY,
82 .timeout = TIMEOUT,
83 .preferred_periodicity = 0U,
84 .reference_conn_event_count = 0u,
85 .offset0 = 0x0000U,
86 .offset1 = 0xffffU,
87 .offset2 = 0xffffU,
88 .offset3 = 0xffffU,
89 .offset4 = 0xffffU,
90 .offset5 = 0xffffU };
91
92 struct pdu_data_llctrl_conn_param_req *req_B = &conn_param_req_B;
93
collision_setup(void * data)94 static void collision_setup(void *data)
95 {
96 test_setup(&conn);
97
98 /* Emulate initial conn state */
99 conn.phy_pref_rx = PHY_1M | PHY_2M | PHY_CODED;
100 conn.phy_pref_tx = PHY_1M | PHY_2M | PHY_CODED;
101 conn.lll.phy_flags = PREFER_S2_CODING;
102 conn.lll.phy_tx_time = PHY_1M;
103 conn.lll.phy_rx = PHY_1M;
104 conn.lll.phy_tx = PHY_1M;
105
106 /* Init DLE data */
107 ull_conn_default_tx_octets_set(251);
108 ull_conn_default_tx_time_set(2120);
109 ull_dle_init(&conn, PHY_1M);
110 /* Emulate different remote numbers to trigger update of eff */
111 conn.lll.dle.remote.max_tx_octets = PDU_DC_PAYLOAD_SIZE_MIN * 3;
112 conn.lll.dle.remote.max_rx_octets = PDU_DC_PAYLOAD_SIZE_MIN * 3;
113 conn.lll.dle.remote.max_tx_time = PDU_DC_MAX_US(conn.lll.dle.remote.max_tx_octets,
114 PHY_1M);
115 conn.lll.dle.remote.max_rx_time = PDU_DC_MAX_US(conn.lll.dle.remote.max_rx_octets,
116 PHY_1M);
117 ull_dle_update_eff(&conn);
118 }
119
120 #define CHECK_PREF_PHY_STATE(_conn, _tx, _rx) \
121 do { \
122 zassert_equal(_conn.phy_pref_rx, _rx, \
123 "Preferred RX PHY mismatch %u (actual) != %u (expected)", \
124 _conn.phy_pref_rx, ((unsigned int)(_rx))); \
125 zassert_equal(_conn.phy_pref_tx, _tx, \
126 "Preferred TX PHY mismatch %u (actual) != %u (expected)", \
127 _conn.phy_pref_tx, ((unsigned int)(_tx))); \
128 } while (0)
129
130 #define CHECK_CURRENT_PHY_STATE(_conn, _tx, _flags, _rx) \
131 do { \
132 zassert_equal(_conn.lll.phy_rx, _rx, \
133 "Current RX PHY mismatch %u (actual) != %u (expected)", \
134 _conn.lll.phy_rx, ((unsigned int)(_rx))); \
135 zassert_equal(_conn.lll.phy_tx, _tx, \
136 "Current TX PHY mismatch %u (actual) != %u (expected)", \
137 _conn.lll.phy_tx, ((unsigned int)(_tx))); \
138 zassert_equal(_conn.lll.phy_rx, _rx, \
139 "Current Flags mismatch %u (actual) != %u (expected)", \
140 _conn.lll.phy_flags, ((unsigned int)(_flags))); \
141 } while (0)
142
is_instant_reached(struct ll_conn * llconn,uint16_t instant)143 static bool is_instant_reached(struct ll_conn *llconn, uint16_t instant)
144 {
145 return ((event_counter(llconn) - instant) & 0xFFFF) <= 0x7FFF;
146 }
147
ZTEST(collision,test_phy_update_central_loc_collision)148 ZTEST(collision, test_phy_update_central_loc_collision)
149 {
150 uint8_t err;
151 struct node_tx *tx;
152 struct node_rx_pdu *ntf;
153 struct pdu_data *pdu;
154 struct pdu_data_llctrl_phy_req req = { .rx_phys = PHY_2M, .tx_phys = PHY_2M };
155 struct pdu_data_llctrl_phy_req rsp = { .rx_phys = PHY_1M | PHY_2M,
156 .tx_phys = PHY_1M | PHY_2M };
157 struct pdu_data_llctrl_phy_upd_ind ind = { .instant = 9,
158 .c_to_p_phy = PHY_2M,
159 .p_to_c_phy = PHY_2M };
160 uint16_t instant;
161
162 struct pdu_data_llctrl_reject_ext_ind reject_ext_ind = {
163 .reject_opcode = PDU_DATA_LLCTRL_TYPE_PHY_REQ,
164 .error_code = BT_HCI_ERR_LL_PROC_COLLISION
165 };
166
167 struct node_rx_pu pu = { .status = BT_HCI_ERR_SUCCESS };
168
169 /* Role */
170 test_set_role(&conn, BT_HCI_ROLE_CENTRAL);
171
172 /* Emulate valid feature exchange */
173 conn.llcp.fex.valid = 1;
174
175 /* Connect */
176 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
177
178 /* Initiate an PHY Update Procedure */
179 err = ull_cp_phy_update(&conn, PHY_2M, PREFER_S8_CODING, PHY_2M, 1);
180 zassert_equal(err, BT_HCI_ERR_SUCCESS);
181
182 /*** ***/
183
184 /* Prepare */
185 event_prepare(&conn);
186
187 /* Tx Queue should have one LL Control PDU */
188 lt_rx(LL_PHY_REQ, &conn, &tx, &req);
189 lt_rx_q_is_empty(&conn);
190
191 /* Rx - emulate colliding PHY_REQ from peer */
192 lt_tx(LL_PHY_REQ, &conn, &req);
193
194 /* Check that data tx is paused */
195 zassert_equal(conn.tx_q.pause_data, 1U, "Data tx is not paused");
196
197 /* TX Ack */
198 event_tx_ack(&conn, tx);
199
200 /* Check that data tx is paused */
201 zassert_equal(conn.tx_q.pause_data, 1U, "Data tx is paused");
202
203 /* Done */
204 event_done(&conn);
205
206 /* Check that data tx is not paused */
207 zassert_equal(conn.tx_q.pause_data, 1U, "Data tx is not paused");
208
209 /* Release Tx */
210 ull_cp_release_tx(&conn, tx);
211
212 /*** ***/
213
214 /* Prepare */
215 event_prepare(&conn);
216 test_print_conn(&conn);
217 /* Tx Queue should have one LL Control PDU */
218 printf("Tx REJECT\n");
219 lt_rx(LL_REJECT_EXT_IND, &conn, &tx, &reject_ext_ind);
220 lt_rx_q_is_empty(&conn);
221
222 /* TX Ack */
223 event_tx_ack(&conn, tx);
224
225 /* Done */
226 printf("Done again\n");
227 event_done(&conn);
228
229 /* Release Tx */
230 ull_cp_release_tx(&conn, tx);
231
232 /*** ***/
233
234 /* Prepare */
235 event_prepare(&conn);
236
237 /* Tx Queue should NOT have a LL Control PDU */
238 printf("Empty\n");
239 lt_rx_q_is_empty(&conn);
240
241 /* Rx */
242 printf("Tx again\n");
243 lt_tx(LL_PHY_RSP, &conn, &rsp);
244
245 /* TX Ack */
246 event_tx_ack(&conn, tx);
247
248 /* Done */
249 event_done(&conn);
250
251 /* Check that data tx is paused */
252 zassert_equal(conn.tx_q.pause_data, 1U, "Data tx is not paused");
253
254 /*** ***/
255
256 /* Prepare */
257 event_prepare(&conn);
258
259 /* Tx Queue should have one LL Control PDU */
260 printf("And again\n");
261 lt_rx(LL_PHY_UPDATE_IND, &conn, &tx, &ind);
262 lt_rx_q_is_empty(&conn);
263
264 /* TX Ack */
265 event_tx_ack(&conn, tx);
266
267 /* Done */
268 event_done(&conn);
269
270 /* Check that data tx is not paused */
271 zassert_equal(conn.tx_q.pause_data, 0U, "Data tx is paused");
272
273 /* Save Instant */
274 pdu = (struct pdu_data *)tx->pdu;
275 instant = sys_le16_to_cpu(pdu->llctrl.phy_upd_ind.instant);
276
277 /* Release Tx */
278 ull_cp_release_tx(&conn, tx);
279
280 /* */
281 while (!is_instant_reached(&conn, instant)) {
282 /* Prepare */
283 event_prepare(&conn);
284
285 /* Tx Queue should NOT have a LL Control PDU */
286 lt_rx_q_is_empty(&conn);
287
288 /* Done */
289 event_done(&conn);
290
291 /* There should NOT be a host notification */
292 ut_rx_q_is_empty();
293 }
294
295 /*** ***/
296
297 /* Prepare */
298 event_prepare(&conn);
299
300 /* Tx Queue should NOT have a LL Control PDU */
301 lt_rx_q_is_empty(&conn);
302
303 /* Done */
304 event_done(&conn);
305
306 /* There should be one host notification */
307 ut_rx_node(NODE_PHY_UPDATE, &ntf, &pu);
308 ut_rx_q_is_empty();
309
310 /* Release Ntf */
311 release_ntf(ntf);
312
313 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
314 "Free CTX buffers %d", llcp_ctx_buffers_free());
315 }
316
ZTEST(collision,test_phy_update_central_rem_collision)317 ZTEST(collision, test_phy_update_central_rem_collision)
318 {
319 uint8_t err;
320 struct node_tx *tx;
321 struct node_rx_pdu *ntf;
322 struct pdu_data *pdu;
323 struct pdu_data_llctrl_phy_req req_peripheral = { .rx_phys = PHY_1M, .tx_phys = PHY_2M };
324 struct pdu_data_llctrl_phy_req req_central = { .rx_phys = PHY_2M, .tx_phys = PHY_2M };
325 struct pdu_data_llctrl_phy_req rsp = { .rx_phys = PHY_1M | PHY_2M,
326 .tx_phys = PHY_1M | PHY_2M };
327 struct pdu_data_llctrl_phy_upd_ind ind_1 = { .instant = 7,
328 .c_to_p_phy = 0,
329 .p_to_c_phy = PHY_2M };
330 struct pdu_data_llctrl_phy_upd_ind ind_2 = { .instant = 15,
331 .c_to_p_phy = PHY_2M,
332 .p_to_c_phy = 0 };
333 uint16_t instant;
334
335 struct node_rx_pu pu = { .status = BT_HCI_ERR_SUCCESS };
336
337 /* Role */
338 test_set_role(&conn, BT_HCI_ROLE_CENTRAL);
339
340 /* Connect */
341 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
342
343 /*** ***/
344
345 /* Prepare */
346 event_prepare(&conn);
347
348 /* Rx */
349 lt_tx(LL_PHY_REQ, &conn, &req_peripheral);
350
351 /* Done */
352 event_done(&conn);
353
354 /*** ***/
355
356 /* Initiate an PHY Update Procedure */
357 err = ull_cp_phy_update(&conn, PHY_2M, PREFER_S8_CODING, PHY_2M, 1);
358 zassert_equal(err, BT_HCI_ERR_SUCCESS);
359
360 /*** ***/
361
362 /* Prepare */
363 event_prepare(&conn);
364
365 /* Tx Queue should have one LL Control PDU */
366 lt_rx(LL_PHY_UPDATE_IND, &conn, &tx, &ind_1);
367 lt_rx_q_is_empty(&conn);
368
369 /* TX Ack */
370 event_tx_ack(&conn, tx);
371
372 /* Done */
373 event_done(&conn);
374
375 /* Save Instant */
376 pdu = (struct pdu_data *)tx->pdu;
377 instant = sys_le16_to_cpu(pdu->llctrl.phy_upd_ind.instant);
378
379 /* Release Tx */
380 ull_cp_release_tx(&conn, tx);
381
382 /* */
383 while (!is_instant_reached(&conn, instant)) {
384 /* Prepare */
385 event_prepare(&conn);
386
387 /* Tx Queue should NOT have a LL Control PDU */
388 lt_rx_q_is_empty(&conn);
389
390 /* Done */
391 event_done(&conn);
392
393 /* There should NOT be a host notification */
394 ut_rx_q_is_empty();
395 }
396
397 /*** ***/
398
399 /* Prepare */
400 event_prepare(&conn);
401
402 /* Tx Queue should NOT have a LL Control PDU */
403 lt_rx_q_is_empty(&conn);
404
405 /* Done */
406 event_done(&conn);
407
408 /* Prepare */
409 event_prepare(&conn);
410
411 /* Tx Queue should have one LL Control PDU */
412 lt_rx(LL_PHY_REQ, &conn, &tx, &req_central);
413 lt_rx_q_is_empty(&conn);
414
415 /* Rx */
416 lt_tx(LL_PHY_RSP, &conn, &rsp);
417
418 /* TX Ack */
419 event_tx_ack(&conn, tx);
420
421 /* Done */
422 event_done(&conn);
423
424 /* Release Tx */
425 ull_cp_release_tx(&conn, tx);
426
427 /* There should be one host notification */
428 ut_rx_node(NODE_PHY_UPDATE, &ntf, &pu);
429 ut_rx_q_is_empty();
430
431 /* Release Ntf */
432 release_ntf(ntf);
433
434 /* Prepare */
435 event_prepare(&conn);
436
437 /* Tx Queue should have one LL Control PDU */
438 lt_rx(LL_PHY_UPDATE_IND, &conn, &tx, &ind_2);
439 lt_rx_q_is_empty(&conn);
440
441 /* TX Ack */
442 event_tx_ack(&conn, tx);
443
444 /* Done */
445 event_done(&conn);
446
447 /* Save Instant */
448 pdu = (struct pdu_data *)tx->pdu;
449 instant = sys_le16_to_cpu(pdu->llctrl.phy_upd_ind.instant);
450
451 /* Release Tx */
452 ull_cp_release_tx(&conn, tx);
453
454 /* */
455 while (!is_instant_reached(&conn, instant)) {
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 /* There should NOT be a host notification */
466 ut_rx_q_is_empty();
467 }
468
469 /* Prepare */
470 event_prepare(&conn);
471
472 /* Tx Queue should NOT have a LL Control PDU */
473 lt_rx_q_is_empty(&conn);
474
475 /* Done */
476 event_done(&conn);
477
478 /* There should be one host notification */
479 ut_rx_node(NODE_PHY_UPDATE, &ntf, &pu);
480 ut_rx_q_is_empty();
481
482 /* Release Ntf */
483 release_ntf(ntf);
484
485 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
486 "Free CTX buffers %d", llcp_ctx_buffers_free());
487 }
488
ZTEST(collision,test_phy_update_periph_loc_collision)489 ZTEST(collision, test_phy_update_periph_loc_collision)
490 {
491 uint8_t err;
492 struct node_tx *tx;
493 struct node_rx_pdu *ntf;
494 struct pdu_data_llctrl_phy_req req_central = { .rx_phys = PHY_1M, .tx_phys = PHY_2M };
495 struct pdu_data_llctrl_phy_req req_peripheral = { .rx_phys = PHY_2M, .tx_phys = PHY_2M };
496 struct pdu_data_llctrl_phy_req rsp = { .rx_phys = PHY_2M, .tx_phys = PHY_2M };
497 struct pdu_data_llctrl_phy_upd_ind ind = { .instant = 7,
498 .c_to_p_phy = PHY_2M,
499 .p_to_c_phy = PHY_1M };
500 uint16_t instant;
501
502 struct pdu_data_llctrl_reject_ext_ind reject_ext_ind = {
503 .reject_opcode = PDU_DATA_LLCTRL_TYPE_PHY_REQ,
504 .error_code = BT_HCI_ERR_LL_PROC_COLLISION
505 };
506
507 struct node_rx_pu pu = { 0 };
508
509 /* Role */
510 test_set_role(&conn, BT_HCI_ROLE_PERIPHERAL);
511
512 /* Connect */
513 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
514
515 /*** ***/
516
517 /* Initiate an PHY Update Procedure */
518 err = ull_cp_phy_update(&conn, PHY_2M, PREFER_S8_CODING, PHY_2M, 1);
519 zassert_equal(err, BT_HCI_ERR_SUCCESS);
520
521 /* Prepare */
522 event_prepare(&conn);
523
524 /* Tx Queue should have one LL Control PDU */
525 lt_rx(LL_PHY_REQ, &conn, &tx, &req_peripheral);
526 lt_rx_q_is_empty(&conn);
527
528 /* Rx */
529 lt_tx(LL_PHY_REQ, &conn, &req_central);
530
531 /* TX Ack */
532 event_tx_ack(&conn, tx);
533
534 /* Done */
535 event_done(&conn);
536
537 /* Release Tx */
538 ull_cp_release_tx(&conn, tx);
539
540 /* Prepare */
541 event_prepare(&conn);
542
543 /* Tx Queue should have one LL Control PDU */
544 lt_rx(LL_PHY_RSP, &conn, &tx, &rsp);
545 lt_rx_q_is_empty(&conn);
546
547 /* Rx */
548 lt_tx(LL_REJECT_EXT_IND, &conn, &reject_ext_ind);
549
550 /* Done */
551 event_done(&conn);
552
553 /* Prepare */
554 event_prepare(&conn);
555
556 /* Done */
557 event_done(&conn);
558
559 /* There should be one host notification */
560 pu.status = BT_HCI_ERR_LL_PROC_COLLISION;
561 ut_rx_node(NODE_PHY_UPDATE, &ntf, &pu);
562 ut_rx_q_is_empty();
563
564 /* Release Ntf */
565 release_ntf(ntf);
566
567 /* Prepare */
568 event_prepare(&conn);
569
570 /* Rx */
571 ind.instant = instant = event_counter(&conn) + 6;
572 lt_tx(LL_PHY_UPDATE_IND, &conn, &ind);
573
574 /* TX Ack */
575 event_tx_ack(&conn, tx);
576
577 /* Done */
578 event_done(&conn);
579
580 /* Release Tx */
581 ull_cp_release_tx(&conn, tx);
582
583 /* */
584 while (!is_instant_reached(&conn, instant)) {
585 /* Prepare */
586 event_prepare(&conn);
587
588 /* Tx Queue should NOT have a LL Control PDU */
589 lt_rx_q_is_empty(&conn);
590
591 /* Done */
592 event_done(&conn);
593
594 /* There should NOT be a host notification */
595 ut_rx_q_is_empty();
596 }
597
598 /* Prepare */
599 event_prepare(&conn);
600
601 /* Tx Queue should NOT have a LL Control PDU */
602 lt_rx_q_is_empty(&conn);
603
604 /* Done */
605 event_done(&conn);
606
607 /* There should be one host notification */
608 pu.status = BT_HCI_ERR_SUCCESS;
609 ut_rx_node(NODE_PHY_UPDATE, &ntf, &pu);
610 ut_rx_q_is_empty();
611
612 /* Release Ntf */
613 release_ntf(ntf);
614
615 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
616 "Free CTX buffers %d", llcp_ctx_buffers_free());
617 }
618
ZTEST(collision,test_phy_conn_update_central_loc_collision)619 ZTEST(collision, test_phy_conn_update_central_loc_collision)
620 {
621 uint8_t err;
622 struct node_tx *tx;
623 struct node_rx_pdu *ntf;
624 struct pdu_data *pdu;
625 uint16_t instant;
626
627 struct pdu_data_llctrl_reject_ext_ind reject_ext_ind = {
628 .reject_opcode = PDU_DATA_LLCTRL_TYPE_CONN_PARAM_REQ,
629 .error_code = BT_HCI_ERR_DIFF_TRANS_COLLISION
630 };
631 struct pdu_data_llctrl_phy_req req = { .rx_phys = PHY_2M, .tx_phys = PHY_2M };
632 struct pdu_data_llctrl_phy_req rsp = { .rx_phys = PHY_1M | PHY_2M,
633 .tx_phys = PHY_1M | PHY_2M };
634 struct pdu_data_llctrl_phy_upd_ind ind = { .instant = 9,
635 .c_to_p_phy = PHY_2M,
636 .p_to_c_phy = PHY_2M };
637
638 struct node_rx_pu pu = { .status = BT_HCI_ERR_SUCCESS };
639
640 /* Role */
641 test_set_role(&conn, BT_HCI_ROLE_CENTRAL);
642
643 /* Emulate valid feature exchange */
644 conn.llcp.fex.valid = 1;
645
646 /* Connect */
647 ull_cp_state_set(&conn, ULL_CP_CONNECTED);
648
649 /* (A) Initiate a PHY update procedure */
650
651 err = ull_cp_phy_update(&conn, PHY_2M, PREFER_S8_CODING, PHY_2M, 1);
652 zassert_equal(err, BT_HCI_ERR_SUCCESS);
653
654 /* Prepare */
655 event_prepare(&conn);
656
657 /* (A) Tx Queue should have one LL Control PDU */
658 lt_rx(LL_PHY_REQ, &conn, &tx, &req);
659 lt_rx_q_is_empty(&conn);
660
661 /* (B) Rx */
662 lt_tx(LL_CONNECTION_PARAM_REQ, &conn, req_B);
663
664 event_tx_ack(&conn, tx);
665
666 /* Done */
667 event_done(&conn);
668
669 /* Release Tx */
670 ull_cp_release_tx(&conn, tx);
671
672 /* Prepare */
673 event_prepare(&conn);
674
675 /* (B) Rx Queue should have a REJECT_EXT_IND PDU */
676 lt_rx(LL_REJECT_EXT_IND, &conn, &tx, &reject_ext_ind);
677 lt_rx_q_is_empty(&conn);
678
679 event_tx_ack(&conn, tx);
680
681 /* Done */
682 event_done(&conn);
683
684 /* Release Tx */
685 ull_cp_release_tx(&conn, tx);
686
687 /**/
688
689 /* Prepare */
690 event_prepare(&conn);
691
692 /* (B) Tx Queue should NOT have a LL Control PDU */
693 lt_rx_q_is_empty(&conn);
694
695 /* (A) Rx */
696 lt_tx(LL_PHY_RSP, &conn, &rsp);
697
698 /* Done */
699 event_done(&conn);
700
701 zassert_equal(conn.tx_q.pause_data, 1U, "Data tx is not paused");
702
703
704 /* Prepare */
705 event_prepare(&conn);
706
707 /* (A) Tx Queue should have one LL Control PDU */
708 lt_rx(LL_PHY_UPDATE_IND, &conn, &tx, &ind);
709 lt_rx_q_is_empty(&conn);
710 event_tx_ack(&conn, tx);
711
712 /* Done */
713 event_done(&conn);
714
715 /* Save Instant */
716 pdu = (struct pdu_data *)tx->pdu;
717 instant = sys_le16_to_cpu(pdu->llctrl.phy_upd_ind.instant);
718
719 /* Release Tx */
720 ull_cp_release_tx(&conn, tx);
721
722 /* */
723 while (!is_instant_reached(&conn, instant)) {
724 /* Prepare */
725 event_prepare(&conn);
726
727 /* (A) Tx Queue should NOT have a LL Control PDU */
728 lt_rx_q_is_empty(&conn);
729
730 /* Done */
731 event_done(&conn);
732
733 /* (A) There should NOT be a host notification */
734 ut_rx_q_is_empty();
735 }
736
737 /* Prepare */
738 event_prepare(&conn);
739
740 /* (A) Tx Queue should NOT have a LL Control PDU */
741 lt_rx_q_is_empty(&conn);
742
743 /* Done */
744 event_done(&conn);
745
746 /* (A) There should be one host notification */
747 ut_rx_node(NODE_PHY_UPDATE, &ntf, &pu);
748
749 ut_rx_q_is_empty();
750
751 /* Release Ntf */
752 release_ntf(ntf);
753 zassert_equal(llcp_ctx_buffers_free(), test_ctx_buffers_cnt(),
754 "Free CTX buffers %d", llcp_ctx_buffers_free());
755 }
756
757 ZTEST_SUITE(collision, NULL, NULL, collision_setup, NULL, NULL);
758