1 /*
2  * Copyright (c) 2020-2021 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 struct lll_sync_iso_stream {
8 	uint8_t big_handle;
9 	uint8_t bis_index;
10 	struct ll_iso_rx_test_mode *test_mode;
11 	struct ll_iso_datapath *dp;
12 };
13 
14 struct lll_sync_iso {
15 	struct lll_hdr hdr;
16 
17 	uint8_t seed_access_addr[4];
18 	uint8_t base_crc_init[2];
19 
20 	uint16_t iso_interval;
21 
22 	uint16_t latency_prepare;
23 	uint16_t latency_event;
24 	uint16_t data_chan_prn_s;
25 	uint16_t data_chan_remap_idx;
26 
27 	uint64_t payload_count:39;
28 	uint64_t framing:1;
29 	uint64_t enc:1;
30 	uint64_t ctrl:1;
31 	uint64_t cssn_curr:3;
32 	uint64_t cssn_next:3;
33 
34 	uint8_t data_chan_map[PDU_CHANNEL_MAP_SIZE];
35 	uint8_t data_chan_count:6;
36 	uint8_t num_bis:5;
37 	uint8_t bn:3;
38 	uint8_t nse:5;
39 	uint8_t phy:3;
40 
41 	uint32_t sub_interval:20;
42 	uint32_t max_pdu:8;
43 	uint32_t pto:4;
44 
45 	uint32_t bis_spacing:20;
46 	uint32_t max_sdu:8;
47 	uint32_t irc:4;
48 
49 	uint32_t sdu_interval:20;
50 	uint32_t irc_curr:4;
51 	uint32_t ptc_curr:4;
52 	uint32_t ptc:4;
53 
54 	uint8_t bn_curr:3;
55 	uint8_t bis_curr:5;
56 
57 	uint8_t stream_curr:5;
58 
59 	uint8_t establish_events:3;
60 
61 	uint8_t next_chan_use;
62 
63 	/* Encryption */
64 	uint8_t giv[8];
65 	struct ccm ccm_rx;
66 
67 	uint8_t chm_chan_map[PDU_CHANNEL_MAP_SIZE];
68 	uint8_t chm_chan_count:6;
69 
70 	uint8_t term_reason;
71 
72 	uint16_t ctrl_instant;
73 
74 	uint8_t stream_count;
75 	uint16_t stream_handle[BT_CTLR_SYNC_ISO_STREAM_MAX];
76 
77 	struct node_rx_pdu *payload[BT_CTLR_SYNC_ISO_STREAM_MAX]
78 				   [PDU_BIG_PAYLOAD_COUNT_MAX];
79 	uint8_t payload_count_max;
80 	uint8_t payload_tail;
81 
82 	uint32_t window_widening_periodic_us;
83 	uint32_t window_widening_max_us;
84 	uint32_t window_widening_prepare_us;
85 	uint32_t window_widening_event_us;
86 	uint32_t window_size_event_us;
87 };
88 
89 int lll_sync_iso_init(void);
90 int lll_sync_iso_reset(void);
91 void lll_sync_iso_create_prepare(void *param);
92 void lll_sync_iso_prepare(void *param);
93 
94 extern uint8_t ull_sync_iso_lll_index_get(struct lll_sync_iso *lll);
95 extern struct lll_sync_iso_stream *ull_sync_iso_lll_stream_get(uint16_t handle);
96 extern void ll_iso_rx_put(memq_link_t *link, void *rx);
97 extern void ll_rx_sched(void);
98