Mistake on this page?
Report an issue in GitHub or email us
lctr_int_bis.h
Go to the documentation of this file.
1 /*************************************************************************************************/
2 /*!
3  * \file
4  *
5  * \brief Internal link layer controller connected isochronous interface file.
6  *
7  * Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
8  *
9  * Copyright (c) 2019-2020 Packetcraft, Inc.
10  *
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  * http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  */
23 /*************************************************************************************************/
24 
25 #ifndef LCTR_INT_BIS_H
26 #define LCTR_INT_BIS_H
27 
28 #include "lctr_int_adv_slave_ae.h"
29 #include "lctr_int_adv_master_ae.h"
30 #include "lctr_int.h"
31 #include "lctr_int_iso.h"
32 #include "lctr_pdu_iso.h"
33 #include "bb_ble_api.h"
34 #include "pal_codec.h"
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 /**************************************************************************************************
41  Macros
42 **************************************************************************************************/
43 
44 /*! \brief Get encryption ID from BIG context. */
45 #define LCTR_BIG_CTRL_ENC_ID(pBigCtx) (LL_MAX_CONN + LL_MAX_CIG + LL_MAX_BIG + (pBigCtx - &pLctrBigTbl[0]))
46 
47 /*! \brief ISO Data PDU start offset in a buffer. */
48 #define LCTR_ISO_SDU_START_OFFSET (HCI_ISO_HDR_LEN + HCI_ISO_DL_MAX_LEN - LL_ISO_DATA_HDR_LEN)
49 
50 /**************************************************************************************************
51  Data Types
52 **************************************************************************************************/
53 
54 struct lctrBigCtx_tag;
55 
56 /*! \brief Broadcast Isochronous Stream (BIS) context. */
57 typedef struct
58 {
59  bool_t enabled; /*!< Enable flag. */
60  uint8_t bisNum; /*!< BIS positional sequence number. */
61  uint16_t handle; /*!< BIS handle. */
62  struct lctrBigCtx_tag *pBigCtx; /*!< BIG context. */
63 
64  union
65  {
66  struct
67  {
68  /* Data */
69  wsfQueue_t txDataQ; /*!< Transmit ISO queue. */
70  uint8_t numTxSduComp; /*!< Number of Tx completed SDUs. */
71  lctrIsoalTxCtx_t isoalTxCtx; /*!< ISOAL transmit context. */
72  } slv; /*!< BIS slave specific data. */
73 
74  struct
75  {
76  /* Data */
77  wsfQueue_t rxDataQ; /*!< Receive ISO Data PDU pending queue. */
78  wsfQueue_t rxIsoSduQ; /*!< Receive ISO SDU PDU pending queue. */
79  lctrIsoalRxCtx_t isoalRxCtx; /*!< ISOAL Receive context. */
80 
81  /* ISO test */
82  LlIsoTestCtrs_t stats; /*!< Rx statistics. */
83  } mst; /*!< BIS master specific data. */
84  } roleData; /*!< Role specific data. */
85 
86  /* ISO test */
87  struct
88  {
89  bool_t enabled; /*!< TRUE ISO test enabled, FALSE otherwise. */
90  bool_t term; /*!< Flag for ISO test termination. */
91  bool_t pendInit; /*!< Receive pending init. */
92  union
93  {
94  struct
95  {
96  uint32_t payloadCtr; /*!< Payload counter for framed transmissions. */
97  } framed; /*!< Framed context. */
98  struct
99  {
100  uint8_t payloadOffset; /*!< Payload offset for unframed transmissions. */
101  } unframed; /*!< Unframed context. */
102  } util; /*!< Role-based utility variables. */
103  LlIsoPldType_t pldType:8; /*!< Test payload type. */
104  } test; /*!< ISO Test data. */
105 
106  /* BB */
107  lmgrChanParam_t chSelInfo; /*!< Channel selection state. */
108  PalBbBleChan_t chan; /*!< Channelization parameters. */
109 
110  /* Data */
111  LlIsoDataPath_t path:8; /*!< Input audio data path. */
112  LlIsoLlid_t lastLlid:8; /*!< Last LLID. */
113 } lctrBisCtx_t;
114 
115 /*! \brief Broadcast Isochronous Group (BIG) context. */
116 typedef struct lctrBigCtx_tag
117 {
118  bool_t enabled; /*!< Context enabled. */
119  uint8_t state; /*!< Current state. */
120  uint8_t handle; /*!< BIG handle. */
121  LlRole_t role:8; /*!< Role. */
122 
123  /* Data */
124  uint16_t maxPdu; /*!< Maximum size of BIS Data PDU. */
125  uint16_t maxSdu; /*!< Maximum size of ISO SDU. */
126 
127  /* Host */
128  uint32_t sduInterUsec; /*!< SDU interval in microseconds. */
129  uint32_t bisSpaceUsec; /*!< BIS space in microseconds. */
130  uint32_t isoInterUsec; /*!< Isochronous PDU interval in microseconds. */
131  uint8_t bn; /*!< Burst number. */
132  uint8_t nse; /*!< Maximum number of subevent in each interval on BIS. */
133  uint8_t pto; /*!< Pre-transmission offset. */
134  uint8_t irc; /*!< Immediate repetition count. */
135  LlFraming_t framing:8; /*!< BIS Data PDU format. */
136  LlPacking_t packing:8; /*!< Packing sequence scheme. */
137 
138  /* ISO Event */
139  uint64_t eventCounter; /*!< Event counter. */
140  uint32_t syncDelayUsec; /*!< Synchronization delay in microseconds. */
141  uint32_t transLatUsec; /*!< The maximum transmission latency, in microseconds. */
142  uint32_t subInterUsec; /*!< Subevent interval in microseconds. */
143 
144  /* BIS */
145  uint8_t numBis; /*!< Number of BISs. */
146  lctrBisCtx_t *pBisCtx[LL_MAX_BIS]; /*!< BIS contexts. */
147 
148  union
149  {
150  struct
151  {
152  lctrAdvSet_t *pAdvSet; /*!< Advertising Set parent. */
153  wsfQueue_t txCtrlQ; /*!< Transmit BIG control queue. */
154  bool_t notifyHostEst; /*!< Notify host event sent flag. */
155  } slv; /*!< BIG slave specific data. */
156 
157  struct
158  {
159  /* BIG Create Sync */
160  lctrPerScanCtx_t *pPerScanCtx; /*!< Periodic Scan parent. */
161  bool_t syncLostReason; /*!< BIG synchronization lost. */
162  uint8_t mse; /*!< Maximum number of subevents. */
163  uint8_t numBisIdx; /*!< Total number of BISes in the BIG. */
164  uint8_t bisIdx[LL_MAX_BIS]; /*!< List of indices of BISes. */
165 
166  /* Sync timeout */
167  uint32_t bigSyncTimeoutMs; /*!< Synchronization timeout in microseconds. */
168  wsfTimer_t bigSyncTmr; /*!< Synchronization timeout timer. */
169 
170  /* Event state */
171  uint16_t totalAcc; /*!< Total clock accuracy. */
172  uint16_t extraWwUsec; /*!< Extra window widening time in microseconds. */
173  uint32_t rxSyncTime; /*!< Last received BIG anchor point. */
174  uint32_t anchorPoint; /*!< BIG anchor point. */
175 
176  /* Encryption */
177  uint8_t bcstCode[LL_BC_LEN]; /*!< Broadcast Code. */
178  } mst; /*!< BIG master specific data. */
179  } roleData; /*!< Role-specific data. */
180 
181  /* Control */
182  struct
183  {
184  uint8_t actMsk; /*!< Active control procedure bitmask. */
185  uint8_t pendMsk; /*!< Pending control procedure bitmask. */
186  uint8_t cssn; /*!< Control Subevent Sequence Number */
187  struct
188  {
189  uint16_t inst; /*!< Instant. */
190  uint64_t chanMap; /*!< Channel map. */
191  } chanMapUpd; /*!< Channel Map Update data. */
192  struct
193  {
194  uint16_t inst; /*!< Instant. */
195  uint8_t reason; /*!< Termination reason. */
196  } term; /*!< Terminate data. */
197  } bcp; /*!< BIG Control Procedure data. */
198 
199  /* BB */
200  PalBbPhy_t phy:8; /*!< PHY used for the BIG. */
201  BbOpDesc_t bod; /*!< BIG BOD. */
202  BbBleData_t bleData; /*!< BLE BB operation data. */
203  uint32_t seedAccAddr; /*!< Seed access address. */
204  uint16_t baseCrcInit; /*!< Base CRC Init. */
205  lmgrChanParam_t ctrChSelInfo; /*!< Control channel selection state. */
206  PalBbBleChan_t ctrChan; /*!< BIG Control channelization parameters. */
207 
208  /* Encryption */
209  /* Note: located at end of structure for non-encryption optimization */
210  bool_t encrypt; /*!< Encryption enable for BIS. */
211  uint8_t giv[LL_GIV_LEN]; /*!< GIV. */
212  uint8_t gskd[LL_GSKD_LEN]; /*!< GSKD. */
213 
214  /* Reception status. */
215  bool_t lastPduMissed; /*!< Rx failure on last PDU. */
216 } lctrBigCtx_t;
217 
218 /*! \brief ISR subevent context. */
219 typedef struct
220 {
221  uint8_t bisEvtIdx; /*!< BIS event index within an event. */
222  uint8_t burstIdx; /*!< Burst index within a subevent. */
223  uint8_t repIdx; /*!< Repeat index within a subevent. */
224  uint8_t ptIdx; /*!< Pre-transmission index within a subevent. */
225 } lctrSeCtx_t;
226 
227 /**************************************************************************************************
228  Globals
229 **************************************************************************************************/
230 
231 extern lctrBisCtx_t *pLctrBisTbl;
232 extern lctrBigCtx_t *pLctrBigTbl;
233 
234 /**************************************************************************************************
235  Function Declarations
236 **************************************************************************************************/
237 
238 /* BIG Context */
239 lctrBigCtx_t *lctrAllocBigCtx(uint8_t bigHandle);
240 void lctrFreeBigCtx(lctrBigCtx_t *pBigCtx);
241 uint8_t lctrBigIsPerAdvUsed(uint8_t handle);
242 lctrBigCtx_t *lctrFindBigByHandle(uint8_t bigHandle);
243 lctrBigCtx_t *lctrFindBigBySyncHandle(uint16_t syncHandle);
244 bool_t lctrIsBigSynchronizing(void);
245 
246 /* BIS Context */
247 lctrBisCtx_t *lctrAllocBisCtx(lctrBigCtx_t *pBigCtx);
248 void lctrCleanupBisCtx(lctrBisCtx_t *pBisCtx);
249 void lctrFreeBisCtx(lctrBisCtx_t *pBisCtx);
250 lctrBisCtx_t *lctrFindBisByHandle(uint16_t bisHandle);
251 uint8_t lctrGetNumAvailBisCtx(void);
252 uint32_t lctrComputeBisAccessAddr(uint32_t seedAccAddr, uint8_t bisNum);
253 void lctrSetupBisContext(lctrBisCtx_t *pBisCtx, uint32_t seedAccAddr, uint16_t baseCrcInit, uint64_t chMap, LlPhy_t phy);
254 void lctrSelectBigChannels(lctrBigCtx_t *pBigCtx);
255 void lctrRemapBigChannels(lctrBigCtx_t *pBigCtx, uint64_t chanMap);
256 
257 /* BIS Tx Data Path */
258 void lctrBisTxIsoPduQueue(lctrBisCtx_t *pBisCtx, lctrIsoHdr_t *pIsoHdr, uint8_t *pIsoSdu);
259 uint8_t lctrBisTxQueuePeek(lctrBisCtx_t *pBisCtx, uint8_t burstIdx, PalBbBleTxBufDesc_t *descs);
260 void lctrBisTxQueuePopCleanup(lctrBisCtx_t *pBisCtx, uint8_t numFrag);
261 uint8_t *lctrBigTxCtrlAlloc(uint8_t pduLen);
262 void lctrBigTxCtrlQueue(lctrBigCtx_t *pBigCtx, uint8_t *pBuf, uint8_t numReTx);
263 uint8_t *lctrBigTxCtrlQueuePeek(lctrBigCtx_t *pBigCtx);
264 void lctrBigTxCtrlQueuePop(lctrBigCtx_t *pBigCtx);
265 void lctrBigTxCtrlQueuePopCleanup(lctrBigCtx_t *pBigCtx);
266 
267 /* BIS Rx Data Path */
268 uint8_t *lctrBisRxIsoSduDeq(lctrBisCtx_t *pBisCtx);
269 void lctrBisRxIsoSduEnq(lctrBisCtx_t *pBisCtx, uint8_t *pBuf);
270 uint8_t *lctrBisRxIsoDataPduAlloc(void);
271 void lctrBisRxIsoDataPduFree(uint8_t *pPdu);
272 void lctrBisEnqueueRxDataPdu(lctrBisCtx_t *pBisCtx, uint8_t *pRxBuf, uint64_t evtCtr);
273 uint8_t *lctrBisDequeueRxDataPdu(lctrBisCtx_t *pBisCtx, uint8_t *pEvtCtrLsb);
274 
275 /* ISO Test mode */
276 uint8_t lctrBisTxTest(lctrBisCtx_t *pBisCtx, uint8_t pldType);
277 uint8_t lctrBisRxTest(lctrBisCtx_t *pBisCtx, uint8_t pldType);
278 uint8_t LctrBisReadTestCounters(lctrBisCtx_t *pBisCtx, LlIsoTestCtrs_t *pStats);
279 
280 /* BIS helper functions */
281 void lctrBisDefaults(void);
282 void lctrNotifyIsoTxComplete(lctrBigCtx_t *pBigCtx);
283 void lctrBisCalcGroupSessionKey(const uint8_t *pGSKD, const uint8_t *pBC, uint8_t *pGSK);
284 uint8_t lctrBisSetDataPath(lctrBisCtx_t *pBisCtx, LlIsoDataPathDir_t dpDir, LlIsoDataPath_t dpId);
285 bool_t lctrSlvBisCalcNextIdxSequential(lctrBigCtx_t *pBigCtx, lctrSeCtx_t *pSeCtx, uint8_t numSePkts);
286 bool_t lctrSlvBisCalcNextIdxInterleaved(lctrBigCtx_t *pBigCtx, lctrSeCtx_t *pSeCtx, uint8_t numSePkts);
287 
288 #ifdef __cplusplus
289 };
290 #endif
291 
292 #endif /* LCTR_INT_BIS_H */
uint32_t anchorPoint
Definition: lctr_int_bis.h:174
Broadcast Isochronous Stream (BIS) context.
Definition: lctr_int_bis.h:57
uint16_t maxPdu
Definition: lctr_int_bis.h:124
wsfQueue_t rxDataQ
Definition: lctr_int_bis.h:77
struct lctrBigCtx_tag::@254::@257 mst
bool_t syncLostReason
Definition: lctr_int_bis.h:161
lctrBisCtx_t * pBisCtx[LL_MAX_BIS]
Definition: lctr_int_bis.h:146
ISO test counter data.
Definition: ll_api.h:887
lctrPerScanCtx_t * pPerScanCtx
Definition: lctr_int_bis.h:160
bool_t pendInit
Definition: lctr_int_bis.h:91
union lctrBigCtx_tag::@254 roleData
BLE baseband interface file.
LlFraming_t
ISO PDU type.
Definition: ll_defs.h:432
uint32_t subInterUsec
Definition: lctr_int_bis.h:142
uint32_t bisSpaceUsec
Definition: lctr_int_bis.h:129
ISO header.
Definition: lctr_pdu_iso.h:72
Internal link layer controller slave extended advertising interface file.
PalBbBleChan_t ctrChan
Definition: lctr_int_bis.h:206
uint32_t rxSyncTime
Definition: lctr_int_bis.h:173
LlRole_t
This parameter identifies the device role.
Definition: ll_api.h:267
uint8_t numTxSduComp
Definition: lctr_int_bis.h:70
uint32_t seedAccAddr
Definition: lctr_int_bis.h:203
uint8_t repIdx
Definition: lctr_int_bis.h:223
bool_t enabled
Definition: lctr_int_bis.h:59
bool_t notifyHostEst
Definition: lctr_int_bis.h:154
uint8_t bisEvtIdx
Definition: lctr_int_bis.h:221
uint64_t chanMap
Definition: lctr_int_bis.h:190
PalBbPhy_t phy
Definition: lctr_int_bis.h:200
uint8_t giv[LL_GIV_LEN]
Definition: lctr_int_bis.h:211
Periodic scanning context.
uint8_t ptIdx
Definition: lctr_int_bis.h:224
#define LL_GSKD_LEN
Definition: ll_defs.h:315
LlIsoTestCtrs_t stats
Definition: lctr_int_bis.h:82
LlPhy_t
PHY types.
Definition: ll_api.h:553
uint8_t bisNum
Definition: lctr_int_bis.h:60
#define LL_MAX_BIS
Definition: cfg_mac_ble.h:87
struct lctrBigCtx_tag::@255::@259 term
LlFraming_t framing
Definition: lctr_int_bis.h:135
uint16_t totalAcc
Definition: lctr_int_bis.h:171
Bluetooth Low Energy protocol specific operation parameters.
Channel parameters.
Definition: lmgr_api.h:137
lctrIsoalTxCtx_t isoalTxCtx
Definition: lctr_int_bis.h:71
uint32_t syncDelayUsec
Definition: lctr_int_bis.h:140
uint8_t gskd[LL_GSKD_LEN]
Definition: lctr_int_bis.h:212
lmgrChanParam_t ctrChSelInfo
Definition: lctr_int_bis.h:205
struct lctrBigCtx_tag lctrBigCtx_t
Broadcast Isochronous Group (BIG) context.
uint32_t bigSyncTimeoutMs
Definition: lctr_int_bis.h:167
uint16_t handle
Definition: lctr_int_bis.h:61
Transmit ISOAL Context.
Definition: lctr_int_iso.h:109
struct lctrBigCtx_tag::@255::@258 chanMapUpd
Receive ISOAL Context.
Definition: lctr_int_iso.h:118
PalBbBleChan_t chan
Definition: lctr_int_bis.h:108
uint64_t eventCounter
Definition: lctr_int_bis.h:139
Queue structure.
Definition: wsf_queue.h:46
Internal link layer controller extended scanning master interface file.
Broadcast Isochronous Group (BIG) context.
Definition: lctr_int_bis.h:116
uint8_t burstIdx
Definition: lctr_int_bis.h:222
wsfQueue_t rxIsoSduQ
Definition: lctr_int_bis.h:78
bool_t lastPduMissed
Definition: lctr_int_bis.h:215
LlIsoDataPath_t
ISO data path.
Definition: ll_api.h:733
uint8_t numBisIdx
Definition: lctr_int_bis.h:163
LlIsoLlid_t
ISO PDU LLID types.
Definition: ll_defs.h:419
wsfQueue_t txCtrlQ
Definition: lctr_int_bis.h:153
struct lctrBigCtx_tag::@254::@256 slv
BLE channelization parameters.
Definition: pal_bb_ble.h:67
uint8_t payloadOffset
Definition: lctr_int_bis.h:100
uint32_t payloadCtr
Definition: lctr_int_bis.h:96
BbBleData_t bleData
Definition: lctr_int_bis.h:202
wsfQueue_t txDataQ
Definition: lctr_int_bis.h:69
Internal link layer controller connection interface file.
#define LL_GIV_LEN
Definition: ll_defs.h:314
Hardware audio codec interface file.
Timer structure.
Definition: wsf_timer.h:53
uint16_t maxSdu
Definition: lctr_int_bis.h:125
uint32_t transLatUsec
Definition: lctr_int_bis.h:141
ISR subevent context.
Definition: lctr_int_bis.h:219
Link layer controller data channel packet interface file.
PalBbPhy_t
PHY types.
Definition: pal_bb.h:65
Baseband operation descriptor (BOD).
Definition: bb_api.h:149
uint32_t sduInterUsec
Definition: lctr_int_bis.h:128
lctrIsoalRxCtx_t isoalRxCtx
Definition: lctr_int_bis.h:79
LlPacking_t
Packing scheme.
Definition: ll_api.h:654
LlIsoDataPathDir_t
ISO data path direction.
Definition: ll_api.h:726
Internal link layer controller interface file.
Advertising set.
struct lctrBigCtx_tag * pBigCtx
Definition: lctr_int_bis.h:62
wsfTimer_t bigSyncTmr
Definition: lctr_int_bis.h:168
Transmit buffer descriptor.
Definition: pal_bb_ble.h:131
lmgrChanParam_t chSelInfo
Definition: lctr_int_bis.h:107
#define LL_BC_LEN
Definition: ll_defs.h:313
uint32_t isoInterUsec
Definition: lctr_int_bis.h:130
uint8_t bcstCode[LL_BC_LEN]
Definition: lctr_int_bis.h:177
LlPacking_t packing
Definition: lctr_int_bis.h:136
LlIsoPldType_t
ISO test packet payload type.
Definition: ll_api.h:879
struct lctrBigCtx_tag::@255 bcp
BbOpDesc_t bod
Definition: lctr_int_bis.h:201
lctrAdvSet_t * pAdvSet
Definition: lctr_int_bis.h:152
uint8_t bisIdx[LL_MAX_BIS]
Definition: lctr_int_bis.h:164
uint16_t extraWwUsec
Definition: lctr_int_bis.h:172
uint16_t baseCrcInit
Definition: lctr_int_bis.h:204
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.