Mistake on this page?
Report an issue in GitHub or email us
lctr_int_cis.h
Go to the documentation of this file.
1 /*************************************************************************************************/
2 /*!
3  * \file
4  *
5  * \brief Internal link layer controller connected isochronous stream 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_CIS_H
26 #define LCTR_INT_CIS_H
27 
28 #include "lmgr_api_iso.h"
29 #include "lctr_int.h"
30 #include "lctr_int_iso.h"
31 #include "lctr_int_conn.h"
32 #include "lctr_api_cis.h"
33 #include "lctr_pdu_conn.h"
34 #include "bb_ble_api.h"
35 #include "bb_ble_api_op.h"
36 #include "lctr_pdu_iso.h"
37 #include "wsf_timer.h"
38 #include "pal_codec.h"
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 /**************************************************************************************************
45  Macros
46 **************************************************************************************************/
47 
48 /*! \brief Maximum number of burst number. */
49 #define LCTR_MAX_BN 0x0F
50 
51 /*! \brief Get reservation manager handle for CIG from the context pointer. */
52 #define LCTR_GET_CIG_RM_HANDLE(pCigCtx) (LL_MAX_CONN + LL_MAX_ADV_SETS + (pCigCtx - &pLctrCigTbl[0]))
53 
54 /*! \brief Get topology manager handle for CIG from the context pointer. */
55 #define LCTR_GET_CIG_TM_HANDLE(pCigCtx) (LL_MAX_CONN + LL_MAX_PER_SCAN + (pCigCtx - &pLctrCigTbl[0]))
56 
57 /*! \brief Resolve CIG context pointer from the reservation manager handle. */
58 #define LCTR_GET_CIG_RM_CTX(rmHandle) &(pLctrCigTbl[rmHandle - (LL_MAX_CONN + LL_MAX_ADV_SETS)])
59 
60 /*! \brief Resolve CIG context pointer from the topology manager handle. */
61 #define LCTR_GET_CIG_TM_CTX(rmHandle) &(pLctrCigTbl[rmHandle - (LL_MAX_CONN + LL_MAX_PER_SCAN)])
62 
63 /*! \brief ISO Data PDU start offset in a buffer. */
64 #define LCTR_CIS_DATA_PDU_START_OFFSET 3
65 
66 /*! \brief Data PDU start offset in a buffer. */
67 #define LCTR_CIS_DATA_TX_PDU_START_OFFSET 0
68 
69 /**************************************************************************************************
70  Constants
71 **************************************************************************************************/
72 
73 /*! \brief CIS main states. */
74 enum
75 {
76  LCTR_CIS_STATE_IDLE, /*!< CIS idle state. */
77  LCTR_CIS_STATE_EST, /*!< CIS established state. */
78  LCTR_CIS_STATE_SHUTDOWN, /*!< CIS terminating state. */
79  LCTR_CIS_STATE_TOTAL /*!< Total number of CIS slave states. */
80 };
81 
82 /*! \brief CIS termination states. */
83 enum
84 {
85  LCTR_CIS_TERM_STATE_IDLE, /*!< Idle state. */
86  LCTR_CIS_TERM_STATE_TERMINATING, /*!< Wait for LL_CIS_RSP state. */
87  LCTR_CIS_TERM_STATE_TOTAL /*!< Total CIS states. */
88 };
89 
90 /*! \brief CIS termination procedure events. */
91 enum
92 {
93  LCTR_CIS_TERM_EVENT_HOST_DISC, /*!< Received host disconnect CIS. */
94  LCTR_CIS_TERM_EVENT_PEER_DISC, /*!< Received peer disconnect CIS. */
95  LCTR_CIS_TERM_EVENT_INT_START_DISC, /*!< Start pending host disconnect CIS procedure. */
96  LCTR_CIS_TERM_EVENT_INT_START_PEER_DISC, /*!< Start pending peer disconnect CIS procedure. */
97  LCTR_CIS_TERM_EVENT_CIS_TERM, /*!< Received CIS terminated event. */
98  LCTR_CIS_TERM_EVENT_TOTAL, /*!< Total CIS events. */
99  LCTR_CIS_TERM_EVENT_INVALID = 0xFF /*!< Invalid event. */
100 };
101 
102 /*! \brief CIS PDU type. */
103 enum
104 {
105  LCTR_CIS_PDU_DEFAULT, /*!< Default PDU. */
106  LCTR_CIS_PDU_NULL, /*!< NULL PDU. */
107  LCTR_CIS_PDU_EMPTY, /*!< Empty PDU. */
108  LCTR_CIS_PDU_NON_EMPTY /*!< Non-empty PDU. */
109 };
110 
111 /**************************************************************************************************
112  Data Types
113 **************************************************************************************************/
114 
115 /*! \brief Parameters related to Tx flush timeout. */
116 typedef struct
117 {
118  bool_t pduAcked; /*!< TRUE if current PDU is acked, for Tx only. */
119  bool_t pduRcved; /*!< TRUE if current PDU is received, for Rx only. */
120  uint8_t bn; /*!< Burst number for the flush timeout. */
121  uint8_t pduCounter; /*!< Current PDU counter in term of BN. */
122  uint8_t subEvtCounter; /*!< Current subevent counter before flush timeout. */
123  uint8_t intervalTotal; /*!< Total number interval before flush timeout. */
124  uint8_t intervalCounter; /*!< Current interval counter. */
125 
126  uint8_t lastSubEvtFt[LCTR_MAX_BN]; /*!< Last subevent the PDU could be transmitted before flush timeout for each PDU(in the last interval). */
127  uint8_t pduType[LCTR_MAX_BN]; /*!< PDU type, whether NULL, empty or non-empty. */
128  bool_t isPduDone[LCTR_MAX_BN]; /*!< TRUE if the PDU is either acked or flushed. */
129 } lctrFtParam_t;
130 
131 /*! \brief Flush timeout parameter node. */
132 typedef struct ftNode
133 {
134  lctrFtParam_t ftParam; /*!< Flush time parameter. */
135  struct ftNode *pNext; /*!< Pointer to the next node. */
137 
138 /*! \brief Flush timeout parameter list. */
139 typedef struct ftList
140 {
141  lctrFtParamNode_t *pHead; /*!< Pointer to the head of the CIS linked list. */
142  lctrFtParamNode_t *pTail; /*!< Pointer to the tail of the CIS linked list. */
143  uint8_t numNodes; /*!< Number of nodes in the CIS linked list. */
145 
146 /*! \brief Connected isochronous stream context. */
147 typedef struct
148 {
149  bool_t enabled; /*!< Enable flag. */
150  uint8_t state; /*!< main state. */
151  uint8_t estState; /*!< Establishment procedure state. */
152  uint8_t termState; /*!< Termination procedure state. */
153  uint16_t aclHandle; /*!< ACL handle. */
154  uint16_t cisHandle; /*!< CIS handle. */
155  uint8_t role; /*!< Role. */
156  uint8_t cigId; /*!< Used to identify the connected isochronous group. */
157  uint8_t cisId; /*!< Used to identify a connected isochronous stream. */
158  uint16_t cisEvtCounter; /*!< Event counter. */
159  uint32_t cisSyncDelayUsec; /*!< CIS synchronous delay in microsecond. */
160  uint32_t cigSyncDelayUsec; /*!< CIG synchronous delay in microsecond. */
161  bool_t cisDone; /*!< CIS transfer is done, no more subevent for the CIS. Used for interleaved CIS only. */
162  bool_t isClosing; /*!< TRUE if the context is closing. */
163 
164  uint8_t subEvtCounter; /*!< Sub event counter. */
165  bool_t isTxDone; /*!< TRUE if all the Tx are done, start sending NULL packet. */
166  bool_t pduFlushed; /*!< TRUE if the PDU is flushed, for Tx only. */
167 
168  uint8_t reason; /*!< Disconnect reason. */
169  lctrCisTermInd_t cisTerm; /*!< Peer CIS Disconnect reason. */
170 
171  uint64_t txPktCounter; /*!< Transmit packet counter. */
172  uint64_t rxPktCounter; /*!< Receive packet counter. */
173 
174  /* Buffers */
175  uint8_t dataHdrBuf[LL_DATA_HDR_LEN]; /*!< Data header buffer */
176  uint8_t dataBuf[10]; /*!< Data header buffer */
177  uint16_t dataCounter; /*!< Data counter. */
178 
179  /* LLCP */
180  bool_t isCisReqPend; /*!< True if CIS_REQ is sent and response is not received yet. */
181  uint16_t ceRef; /*!< ACL connection event where the offset referenced. */
182  uint16_t cisCeRef; /*!< Number of CIS event before CIS is started. */
183  uint32_t offsetUsec; /*!< Time in microsecond between the start of the referenced CE to the start of first CIS event. */
184  wsfTimer_t tmrProcRsp; /*!< Procedure response timer. */
185 
186  union
187  {
188  struct
189  {
190  uint32_t anchorOffsetUsec; /*!< Offset to the stream anchor point. */
191  lctrCisReq_t cisReq; /*!< CIS request parameters. */
192  bool_t syncWithMaster; /*!< Flag indicating synchronize packet received from master. */
193  bool_t rxFromMaster; /*!< At least one successful packet received from master. */
194  bool_t firstRxFromMaster; /*!< TRUE if the first Rx from master. */
195  uint32_t offsetUsec; /*!< Offset to the next Rx. */
196  uint32_t firstRxStartTsUsec; /*!< Timestamp of the first received frame regardless of CRC error in microseconds. */
197  uint8_t consCrcFailed; /*!< Number of consecutive CRC failures. */
198  uint8_t rxStatus; /*!< Rx status. */
199  } slv; /*!< Slave connection specific data. */
200 
201  struct
202  {
203  bool_t txPduIsAcked; /*!< TRUE if the PDU is acked. */
204  bool_t rxFromSlave; /*!< At least one packet received from slave. */
205  } mst; /*!< CIS master specific data. */
206  } data; /*!< role-specific data. */
207 
208  /* Channel parameters */
209  lmgrChanParam_t chanParam; /*!< Channel parameter. */
210  uint8_t chIdx; /*!< LL channel index. */
211  uint8_t nextSubEvtChanIdx; /*!< Next subevent channel index. */
212  uint32_t accessAddr; /*!< Access address. */
213  uint32_t crcInit; /*!< CRC initialization value. */
214 
215  /* Flow control */
216  lctrCisDataPduHdr_t txHdr; /*!< Transmit data PDU header. */
217  lctrCisDataPduHdr_t rxHdr; /*!< Receive data PDU header. */
218  wsfQueue_t txIsoQ; /*!< Transmit ISO queue. */
219  wsfQueue_t txArqQ; /*!< Transmit ARQ queue. */
220  uint8_t numTxComp; /*!< Number of completed Tx buffers. */
221  uint32_t delayUsec; /*!< Time between the start of subevent to the start of next subevent in microsecond.
222  Same as subEvtInter for sequential scheme, different for interleaved scheme. */
223  uint8_t *pRxBuf; /*!< Pointer to the RX buffer later to be cleaned. */
224  bool_t validRx; /*!< TRUE if the RX buffer is valid and shall be processed. */
225  bool_t txPduIsAcked; /*!< TRUE if the TX PDU is acked. */
226  bool_t txBufPendAck; /*!< A transmit buffer is pending acknowledgement. */
227 
228  /* Flush timeout Tx/Rx list */
229  lctrFtParamList_t txFtParamList; /*!< Tx flush timeout parameters list. */
230  lctrFtParamList_t rxFtParamList; /*!< Rx flush timeout parameters list. */
231 
232  /* Data length */
233  lctrDataLen_t localDataPdu; /*!< Local Data PDU parameters. */
234 
235  /* BB data */
236  BbBleData_t bleData; /*!< BLE BB operation data. */
237 
238  /* Supervision */
239  uint16_t supTimeoutMs; /*!< Supervision timeout in milliseconds. */
240  wsfTimer_t tmrSupTimeout; /*!< Supervision timer. */
241  bool_t connEst; /*!< Connection established. */
242  bool_t powerIndReq; /*!< Power control indication required when established conn. */
243 
244  /* Encryption */
245  uint8_t iv[LL_IV_LEN]; /*!< Initialization vector. */
246 
247  /* PHY */
248  uint8_t phyMToS; /*!< Master to slave PHY. */
249  uint8_t phySToM; /*!< Slave to master PHY. */
250 
251  /* Data */
252  uint8_t sca; /*!< Sleep clock accuracy. */
253  uint8_t packing; /*!< Packing scheme. */
254  uint8_t framing; /*!< Indicates the format of CIS Data PDUs. */
255  uint16_t sduSizeMToS; /*!< Maximum SDU size from the master Host. */
256  uint16_t sduSizeSToM; /*!< Maximum SDU size from the slave Host. */
257  uint32_t sduIntervalMToS; /*!< Time interval between the start of consecutive SDUs from the master Host in microseconds */
258  uint32_t sduIntervalSToM; /*!< Time interval between the start of consecutive SDUs from the master Host in microseconds */
259  uint16_t isoInterval; /*!< Isochronous PDU interval in 1.25ms unit. */
260  uint8_t ftMToS; /*!< Master to slave flush time. */
261  uint8_t ftSToM; /*!< Slave to master flush time. */
262  uint8_t nse; /*!< Maximum number of subevent in each interval on CIS. */
263  uint32_t subIntervUsec; /*!< Subevent duration in microsecond. */
264  uint8_t bnMToS; /*!< Master to slave burst number. */
265  uint8_t bnSToM; /*!< Slave to master burst number. */
266  uint32_t transLatUsec; /*!< The maximum time, in microseconds, for transmission of SDUs of all CISes. */
267  uint32_t nextCisOffsetUsec; /*!< For slave sequential packing only, from the start of this CIS to the start of the next CIS. */
268 
269  /* BB/ISR context */
270  bool_t firstFromPeer; /*!< TRUE if received once from peer, used for fast supervision timeout. */
271  uint8_t txDataCounter; /*!< Tx data counter in each ISO interval, used to determine whether continue operation for the BOD or not. */
272  uint8_t rxDataCounter; /*!< Rx data counter in each ISO interval, used to determine whether continue operation for the BOD or not. */
273 
274  /* Datapath configuration */
275  lctrInDataPathCtx_t dataPathInCtx; /*!< Input data path config. */
276  lctrOutDataPathCtx_t dataPathOutCtx; /*!< Output data path context. */
277 
278  /* ISO test */
279  bool_t txTestEnabled; /*!< TRUE ISO test enabled, FALSE otherwise. */
280  bool_t rxTestEnabled; /*!< TRUE if ISO RX test enabled, FALSE otherwise. */
281  uint32_t testSduTs; /*!< Timestamp of last tx sdu. */
282  LlIsoPldType_t testPldType:8; /*!< Test payload type. */
283 
284  uint32_t expectedPkt; /*!< Next expected packet for Rx test. */
285  uint32_t testTxPktCtr; /*!< Packet counter for TX test. */
286  uint32_t numRxSuccess; /*!< ISO Rx received payload counter. */
287  uint32_t numRxMissed; /*!< ISO Rx missed payload counter. */
288  uint32_t numRxFailed; /*!< ISO Rx failed payload counter. */
289  uint8_t isoRxPldType; /*!< ISO RX payload length type. */
290  bool_t rxPendInit; /*!< ISO test pending initialization flag. */
291 
292  LlIsoLinkQual_t isoLinkQualStats; /*!< ISO Link quality statistics. */
293 
294  lctrIsoalTxCtx_t isoalTxCtx; /*!< ISOAL transmit context. */
295  lctrIsoalRxCtx_t isoalRxCtx; /*!< Partial receive context. */
296 } lctrCisCtx_t;
297 
298 /*! \brief Connected isochronous stream node. */
299 typedef struct node
300 {
301  lctrCisCtx_t *pCisCtx; /*!< CIS context. */
302  struct node *pNext; /*!< Next node. */
303 } lctrCisNode_t;
304 
305 /*! \brief Connected isochronous stream linked list. */
306 typedef struct list
307 {
308  lctrCisNode_t *pHead; /*!< Pointer to the head of the CIS linked list. */
309  lctrCisNode_t *pTail; /*!< Pointer to the tail of the CIS linked list. */
310  uint8_t numNodes; /*!< Number of nodes in the CIS linked list. */
311 } lctrCisList_t;
312 
313 /*! \brief Connected isochronous group context. */
314 typedef struct
315 {
316  bool_t enabled; /*!< Context enabled. */
317  uint8_t packing; /*!< Packing scheme. */
318  bool_t isBodBuilt; /*!< TRUE if BOD is built. */
319  bool_t isBodStarted; /*!< TRUE if BOD is started. */
320  bool_t isRmAdded; /*!< TRUE if reservation is added. */
321  uint8_t cigId; /*!< Used to identify the connected isochronous group. */
322  uint16_t cigHandle; /*!< CIG handle. */
323  uint32_t cigSyncDelayUsec; /*!< CIG synchronous delay in microsecond. */
324  uint16_t isoInterval; /*!< Isochronous PDU interval in 1.25ms unit. */
325  bool_t isValid; /*!< TRUE if CIS parameters are valid and is able to be scheduled. */
326  uint8_t numCisEsted; /*!< Number of CISs that are established. */
327  bool_t isLoopBack; /*!< TRUE if all the CIS streams have been traversed once. */
328  bool_t headCisRmved; /*!< TRUE if the head CIS in the CIG is removed. */
329  uint32_t offsetUsec; /*!< Only valid when headCisRmved is TRUE, duration between the old anchor point and new anchor point. */
330  uint32_t firstRxStartTsUsec; /*!< Only valid when headCisRmved is TRUE, timestamp of the first received frame regardless of CRC error. */
331 
332  /* BB data */
333  BbOpDesc_t cigBod; /*!< CIG BOD. */
334 
335  /* Linked list of CIS context. */
336  lctrCisCtx_t *pCisCtx; /*!< Pointer to the current CIS context. */
337  lctrCisList_t list; /*!< CIS linked list. */
338 
339  /* BOD data. */
340  union
341  {
342  struct
343  {
344  uint16_t cigEvtCounter; /*!< Event counter. */
345  uint32_t anchorPointUsec; /*!< Anchor point in microseconds. */
346  uint16_t lastActiveEvent; /*!< Last active event counter. */
347  uint16_t totalAcc; /*!< Combined sleep clock inaccuracy. */
348  } slv; /*!< Slave BOD data. */
349 
350  struct
351  {
352  uint8_t numCis; /*!< Number of CIS. */
353  } mst; /*!< Master BOD data. */
354  } roleData; /*!< Role-specific BOD Data. */
355 
356  PalBbBleTxBufDesc_t dataPdu[3]; /*!< Data PDU descriptor. */
357 } lctrCigCtx_t;
358 
359 /**************************************************************************************************
360  Globals
361 **************************************************************************************************/
362 
363 extern lctrCisCtx_t *pLctrCisTbl;
364 extern lctrCigCtx_t *pLctrCigTbl;
365 extern lctrCisMsg_t *pLctrCisMsg;
366 
367 /**************************************************************************************************
368  Function Declarations
369 **************************************************************************************************/
370 /* State machine */
371 void lctrCisExecuteSm(lctrCisCtx_t *pCisCtx, uint8_t event);
372 bool_t lctrLlcpExecuteCisTermSm(lctrConnCtx_t *pCtx, uint8_t event);
373 void lctrCisDisp(lctrCisMsg_t *pMsg);
374 
375 /* Action routines for main state machine */
376 void lctrCisActCisEst(lctrCisCtx_t *pCtx);
377 void lctrCisActCisEstFail(lctrCisCtx_t *pCtx);
378 void lctrCisActDisc(lctrCisCtx_t *pCtx);
379 void lctrCisActClosed(lctrCisCtx_t *pCisCtx);
380 void lctrCisActFail(lctrCisCtx_t *pCisCtx);
381 
382 /* Action routines for LLCP termination state machine */
383 void lctrCisLlcpActHostDisc(lctrConnCtx_t *pCtx, lctrCisCtx_t *pCisCtx);
384 void lctrCisLlcpActPeerDisc(lctrConnCtx_t *pCtx, lctrCisCtx_t *pCisCtx);
385 void lctrCisLlcpActCisTerm(lctrConnCtx_t *pCtx, lctrCisCtx_t *pCisCtx);
386 void lctrCisLlcpActIntHostDisc(lctrConnCtx_t *pCtx, lctrCisCtx_t *pCisCtx);
387 void lctrCisLlcpActIntPeerDisc(lctrConnCtx_t *pCtx, lctrCisCtx_t *pCisCtx);
388 
389 /* CIS Context */
390 lctrCisCtx_t *lctrAllocCisCtx(lctrCigCtx_t *pCigCtx);
391 void lctrCleanupCtx(lctrCisCtx_t *pCisCtx);
392 void lctrFreeCisCtx(lctrCisCtx_t *pCisCtx);
393 lctrCisCtx_t *lctrFindCisByHandle(uint16_t cisHandle);
394 lctrCisCtx_t *lctrFindCisById(uint8_t cigId, uint8_t cisId);
395 uint8_t lctrGetNumAvailCisCtx();
396 uint8_t lctrGetNumEnabledCisCtx(LlCisCigParams_t *pSetCigParam);
397 uint8_t lctrGetNumEnabledCisCtxTest(LlCisCigParamsTest_t *pSetCigParam);
398 uint8_t lctrGetNumEstCisCtx(LlCisCigParams_t *pSetCigParam);
399 uint8_t lctrGetNumEstCisCtxTest(LlCisCigParamsTest_t *pSetCigParam);
400 uint8_t lctrGetNumEstCisCtxByCigCtx(lctrCigCtx_t *pCigCtx);
401 
402 /* CIS list utility functions */
403 bool_t lctrCisInsertHead(lctrCisList_t *pList, lctrCisCtx_t *pCisCtx);
404 bool_t lctrCisInsertTail(lctrCisList_t *pList, lctrCisCtx_t *pCisCtx);
405 bool_t lctrCisRemoveHead(lctrCisList_t *pList);
406 bool_t lctrCisRemoveTail(lctrCisList_t *pList);
407 bool_t lctrCisRemoveMiddle(lctrCisList_t *pList, lctrCisCtx_t *pCisCtx);
408 bool_t lctrCisRemove(lctrCisList_t *pList, lctrCisCtx_t *pCisCtx);
409 bool_t lctrCisIsListEmpty(lctrCisList_t *pList);
410 uint8_t lctrCisGetListCount(lctrCisList_t *pList);
411 lctrCisCtx_t * lctrCisGetHeadCis(lctrCisList_t *pList);
412 bool_t lctrCisIsHeadCis(lctrCisList_t *pList, lctrCisCtx_t *pCisCtx);
413 lctrCisCtx_t * lctrCisGetNextCis(lctrCisList_t *pList, lctrCisCtx_t *pCurCis);
414 lctrCisCtx_t * lctrCisGetPreCis(lctrCisList_t *pList, lctrCisCtx_t *pCurCis);
415 bool_t lctrCisAreCisCtxDone(lctrCisList_t *pList);
416 void lctrCisClearCisDone(lctrCisList_t *pList);
417 void lctrCisSetCisDone(lctrCisList_t *pList, lctrCisCtx_t *pCurCisCtx);
418 
419 /* CIS flush timeout list utility functions */
420 lctrFtParamNode_t * lctrCisFtCreateFtParamNode(lctrFtParam_t *pFtParam);
421 bool_t lctrCisFtInsertHead(lctrFtParamList_t *pList, lctrFtParam_t *pFtParam);
422 bool_t lctrCisFtInsertTail(lctrFtParamList_t *pList, lctrFtParam_t *pFtParam);
423 bool_t lctrCisFtRemoveHead(lctrFtParamList_t *pList);
424 bool_t lctrCisFtRemoveTail(lctrFtParamList_t *pList);
425 bool_t lctrCisFtIsListEmpty(lctrFtParamList_t *pList);
426 void lctrCisFtListClear(lctrFtParamList_t *pList);
427 
428 /* CIG Context */
429 lctrCigCtx_t *lctrAllocCigCtx(uint8_t cigId);
430 void lctrFreeCigCtx(lctrCigCtx_t *pCigCtx);
431 lctrCigCtx_t *lctrFindCigById(uint8_t cigId);
432 uint8_t lctrGetNumAvailCigCtx();
433 
434 /* Helper */
435 void lctrCisDefaults(void);
436 bool_t lctrIsCisEst(lctrCisCtx_t *pCtx);
437 void lctrCisSetupChanParam(lctrCisCtx_t *pCisCtx, uint64_t chanMask);
438 void lctrCisSetupEncrypt(lctrCisCtx_t *pCisCtx);
439 void lctrCisStoreTerminateReason(lctrCisCtx_t *pCisCtx);
440 void lctrCisStoreDisconnectReason(lctrCisCtx_t *pCisCtx);
441 void lctrCisStoreConnFailEstablishTerminateReason(lctrCisCtx_t *pCisCtx);
442 void lctrCisStoreLlcpTimeoutTerminateReason(lctrCisCtx_t *pCisCtx);
443 void lctrCisStoreLocalLowResourceTerminateReason(lctrCisCtx_t *pCisCtx);
444 void lctrCisStoreMicFailedTerminateReason(lctrCisCtx_t *pCisCtx);
445 void lctrCisStoreConnTimeoutTerminateReason(lctrCisCtx_t *pCisCtx);
446 void lctrCisStoreLlcpPeerRejTerminateReason(lctrCisCtx_t *pCisCtx);
447 void lctrCisStartLlcpTimer(lctrConnCtx_t *pCtx, lctrCisCtx_t *pCisCtx);
448 void lctrCisStopLlcpTimer(lctrConnCtx_t *pCtx, lctrCisCtx_t *pCisCtx);
449 void lctrCisInitFtParam(lctrFtParam_t *pTxFtParam, uint8_t bn, uint8_t ft, uint8_t nse);
450 uint32_t lctrCisCalcSubEvtDurationUsecSeq(uint8_t phyMToS, uint8_t phySToM, uint8_t plMToS, uint8_t plSToM);
451 uint32_t lctrCisCalcSubEvtDurationUsecInter(LlCisCigParams_t *pSetCigParam);
452 void LctrCisUpdateChanMap(uint16_t aclHandle);
453 void lctrCleanupCigCtx();
454 
455 /* Function used by connection context */
456 bool_t lctrCheckForCisLinkTerm(uint16_t aclHandle);
457 bool_t lctrCheckIsCisEstAcl(uint16_t aclHandle);
458 bool_t lctrCheckIsCisEstCis(uint16_t cisHandle);
459 
460 /* CIS Tx data path */
461 uint16_t lctrIsoTxInitMem(uint8_t *pFreeMem, uint32_t freeMemSize);
462 void lctrCisTxDataPduQueue(lctrCisCtx_t *pCtx, lctrIsoHdr_t *pIsoHdr, uint8_t *pIsoBuf);
463 uint8_t lctrCisTxQueuePeek(lctrCisCtx_t *pCisCtx, PalBbBleTxBufDesc_t *bbDescs);
464 bool_t lctrCisTxQueuePop(lctrCisCtx_t *pCisCtx);
465 void lctrCisTxQueuePopCleanup(lctrCisCtx_t *pCisCtx);
466 uint8_t lctrCisTxQueueClear(lctrCisCtx_t *pCisCtx);
467 
468 /* CIS Rx data path */
469 uint8_t *lctrCisRxPduAlloc(uint16_t maxRxLen);
470 void lctrCisRxPduFree(uint8_t *pBuf);
471 void lctrCisRxEnq(uint8_t *pBuf, uint16_t eventCounter, uint16_t cisHandle);
472 uint8_t *lctrCisRxDeq(uint16_t *pConnHandle);
473 
474 /* Message */
475 void lctrSendCisMsg(lctrCisCtx_t *pCisCtx, uint8_t event);
476 void lctrSendCisLlcpMsg(lctrCisCtx_t *pCisCtx, uint8_t event);
477 
478 /* Notification */
479 void lctrNotifyHostCisEst(lctrCisCtx_t *pCisCtx, uint8_t status, uint32_t cigSyncDelayUsec);
480 void lctrNotifyHostCisTerm(lctrCisCtx_t *pCisCtx);
481 
482 /* ISR */
483 uint16_t lctrCisSetupForTx(lctrCigCtx_t *pCigCtx, uint8_t rxStatus, bool_t reqTx);
484 bool_t lctrCisProcessRxAck(lctrCisCtx_t *pCisCtx);
485 bool_t lctrCisProcessTxAck(lctrCisCtx_t *pCisCtx);
486 void lctrCisTxPduAck(lctrCisCtx_t *pCisCtx);
487 void lctrCisProcessTxAckCleanup(lctrCisCtx_t *pCisCtx);
488 void lctrCisRxPostProcessing(lctrCisCtx_t *pCisCtx, uint8_t *pRxBuf);
489 void lctrCisTxTestPayloadHandler(lctrCisCtx_t * pCisCtx);
490 void lctrCisPowerMonitorCheckRssi(int8_t rssi, uint8_t status, uint8_t phy, lctrConnCtx_t *pConnCtx);
491 
492 /* Scheduler */
493 BbOpDesc_t *lctrCisResolveConflict(BbOpDesc_t *pNewOp, BbOpDesc_t *pExistOp);
494 
495 /*************************************************************************************************/
496 /*!
497  * \brief Increment the Tx/encrypt packet counter.
498  *
499  * \param pCisCtx Connection context.
500  */
501 /*************************************************************************************************/
502 static inline void lctrCisIncPacketCounterTx(lctrCisCtx_t *pCisCtx)
503 {
504  pCisCtx->txPktCounter++;
505 
506  /* Set the new packet counter for inline encryption. */
507  if (lctrSetEncryptPktCountHdlr)
508  {
509  lctrSetEncryptPktCountHdlr(&pCisCtx->bleData.chan.enc, pCisCtx->txPktCounter);
510  }
511 }
512 
513 /*************************************************************************************************/
514 /*!
515  * \brief Increment the Rx/decrypt packet counter.
516  *
517  * \param pCisCtx Connection context.
518  */
519 /*************************************************************************************************/
520 static inline void lctrCisIncPacketCounterRx(lctrCisCtx_t *pCisCtx)
521 {
522  pCisCtx->rxPktCounter++;
523 
524  /* Set the new packet counter for inline encryption. */
525  if (lctrSetDecryptPktCountHdlr)
526  {
527  /* lctrSetDecryptPktCountHdlr(&pCisCtx->bleData.chan.enc, pCisCtx->rxPktCounter); */ /* Not necessary. */
528  }
529 }
530 
531 #ifdef __cplusplus
532 };
533 #endif
534 
535 #endif /* LCTR_INT_CIS_H */
wsfQueue_t txArqQ
Definition: lctr_int_cis.h:219
uint32_t cigSyncDelayUsec
Definition: lctr_int_cis.h:323
static void lctrCisIncPacketCounterTx(lctrCisCtx_t *pCisCtx)
Increment the Tx/encrypt packet counter.
Definition: lctr_int_cis.h:502
BbBleData_t bleData
Definition: lctr_int_cis.h:236
bool_t validRx
Definition: lctr_int_cis.h:224
Data length request or response PDU.
bool_t isCisReqPend
Definition: lctr_int_cis.h:180
Connected isochronous stream node.
Definition: lctr_int_cis.h:299
Link layer controller CIS slave interface file.
uint32_t anchorOffsetUsec
Definition: lctr_int_cis.h:190
bool_t isValid
Definition: lctr_int_cis.h:325
Connection context.
lctrInDataPathCtx_t dataPathInCtx
Definition: lctr_int_cis.h:275
uint8_t phySToM
Definition: lctr_int_cis.h:249
uint8_t rxDataCounter
Definition: lctr_int_cis.h:272
uint8_t cigId
Definition: lctr_int_cis.h:156
BLE baseband interface file.
CIG test CIG parameters.
Definition: ll_api.h:703
lctrCisReq_t cisReq
Definition: lctr_int_cis.h:191
uint8_t consCrcFailed
Definition: lctr_int_cis.h:197
bool_t connEst
Definition: lctr_int_cis.h:241
uint16_t isoInterval
Definition: lctr_int_cis.h:259
uint16_t isoInterval
Definition: lctr_int_cis.h:324
struct node lctrCisNode_t
Connected isochronous stream node.
Output datapath context.
Definition: lctr_int_iso.h:149
lctrCisDataPduHdr_t txHdr
Definition: lctr_int_cis.h:216
bool_t cisDone
Definition: lctr_int_cis.h:161
uint32_t delayUsec
Definition: lctr_int_cis.h:221
lctrFtParamNode_t * pTail
Definition: lctr_int_cis.h:142
uint8_t rxStatus
Definition: lctr_int_cis.h:198
bool_t rxPendInit
Definition: lctr_int_cis.h:290
uint8_t bnSToM
Definition: lctr_int_cis.h:265
ISO header.
Definition: lctr_pdu_iso.h:72
bool_t powerIndReq
Definition: lctr_int_cis.h:242
struct node * pNext
Definition: lctr_int_cis.h:302
bool_t pduFlushed
Definition: lctr_int_cis.h:166
uint64_t rxPktCounter
Definition: lctr_int_cis.h:172
static void lctrCisIncPacketCounterRx(lctrCisCtx_t *pCisCtx)
Increment the Rx/decrypt packet counter.
Definition: lctr_int_cis.h:520
bool_t isClosing
Definition: lctr_int_cis.h:162
lctrFtParamNode_t * pHead
Definition: lctr_int_cis.h:141
uint16_t cisEvtCounter
Definition: lctr_int_cis.h:158
bool_t txTestEnabled
Definition: lctr_int_cis.h:279
bool_t isLoopBack
Definition: lctr_int_cis.h:327
uint8_t chIdx
Definition: lctr_int_cis.h:210
wsfQueue_t txIsoQ
Definition: lctr_int_cis.h:218
uint8_t intervalTotal
Definition: lctr_int_cis.h:123
uint16_t totalAcc
Definition: lctr_int_cis.h:347
uint16_t supTimeoutMs
Definition: lctr_int_cis.h:239
struct ftNode lctrFtParamNode_t
Flush timeout parameter node.
uint64_t txPktCounter
Definition: lctr_int_cis.h:171
uint32_t numRxSuccess
Definition: lctr_int_cis.h:286
uint8_t subEvtCounter
Definition: lctr_int_cis.h:164
uint8_t pduCounter
Definition: lctr_int_cis.h:121
Connected isochronous stream context.
Definition: lctr_int_cis.h:147
uint8_t packing
Definition: lctr_int_cis.h:317
bool_t txBufPendAck
Definition: lctr_int_cis.h:226
lctrCisTermInd_t cisTerm
Definition: lctr_int_cis.h:169
uint8_t bnMToS
Definition: lctr_int_cis.h:264
LlIsoLinkQual_t isoLinkQualStats
Definition: lctr_int_cis.h:292
bool_t isBodStarted
Definition: lctr_int_cis.h:319
wsfTimer_t tmrSupTimeout
Definition: lctr_int_cis.h:240
bool_t isTxDone
Definition: lctr_int_cis.h:165
uint8_t numNodes
Definition: lctr_int_cis.h:143
struct ftList lctrFtParamList_t
Flush timeout parameter list.
struct ftNode * pNext
Definition: lctr_int_cis.h:135
uint32_t offsetUsec
Definition: lctr_int_cis.h:329
Link layer controller data channel packet interface file.
lctrFtParamList_t txFtParamList
Definition: lctr_int_cis.h:229
bool_t rxFromMaster
Definition: lctr_int_cis.h:193
uint8_t * pRxBuf
Definition: lctr_int_cis.h:223
lctrCisNode_t * pTail
Definition: lctr_int_cis.h:309
Bluetooth Low Energy protocol specific operation parameters.
lctrCisCtx_t * pCisCtx
Definition: lctr_int_cis.h:336
Input datapath context.
Definition: lctr_int_iso.h:143
uint32_t sduIntervalMToS
Definition: lctr_int_cis.h:257
Channel parameters.
Definition: lmgr_api.h:137
bool_t txPduIsAcked
Definition: lctr_int_cis.h:203
uint32_t offsetUsec
Definition: lctr_int_cis.h:183
wsfTimer_t tmrProcRsp
Definition: lctr_int_cis.h:184
CIG parameters.
Definition: ll_api.h:673
lctrFtParamList_t rxFtParamList
Definition: lctr_int_cis.h:230
uint8_t txDataCounter
Definition: lctr_int_cis.h:271
uint32_t accessAddr
Definition: lctr_int_cis.h:212
lctrIsoalTxCtx_t isoalTxCtx
Definition: lctr_int_cis.h:294
lctrCisList_t list
Definition: lctr_int_cis.h:337
bool_t syncWithMaster
Definition: lctr_int_cis.h:192
uint32_t crcInit
Definition: lctr_int_cis.h:213
uint8_t isoRxPldType
Definition: lctr_int_cis.h:289
uint32_t firstRxStartTsUsec
Definition: lctr_int_cis.h:196
uint8_t ftMToS
Definition: lctr_int_cis.h:260
lctrFtParam_t ftParam
Definition: lctr_int_cis.h:134
uint8_t numNodes
Definition: lctr_int_cis.h:310
uint16_t sduSizeSToM
Definition: lctr_int_cis.h:256
CIS terminate PDU.
bool_t enabled
Definition: lctr_int_cis.h:316
uint8_t termState
Definition: lctr_int_cis.h:152
uint32_t anchorPointUsec
Definition: lctr_int_cis.h:345
uint32_t transLatUsec
Definition: lctr_int_cis.h:266
uint32_t testSduTs
Definition: lctr_int_cis.h:281
Transmit ISOAL Context.
Definition: lctr_int_iso.h:109
uint8_t reason
Definition: lctr_int_cis.h:168
bool_t isRmAdded
Definition: lctr_int_cis.h:320
Receive ISOAL Context.
Definition: lctr_int_iso.h:118
uint8_t numTxComp
Definition: lctr_int_cis.h:220
Queue structure.
Definition: wsf_queue.h:46
struct list lctrCisList_t
Connected isochronous stream linked list.
BbOpDesc_t cigBod
Definition: lctr_int_cis.h:333
PalCryptoEnc_t enc
Definition: pal_bb_ble.h:80
lctrCisCtx_t * pCisCtx
Definition: lctr_int_cis.h:301
uint8_t framing
Definition: lctr_int_cis.h:254
uint16_t cisCeRef
Definition: lctr_int_cis.h:182
CIS request PDU.
#define LL_DATA_HDR_LEN
Definition: ll_defs.h:282
lctrDataLen_t localDataPdu
Definition: lctr_int_cis.h:233
uint8_t role
Definition: lctr_int_cis.h:155
#define LL_IV_LEN
Definition: ll_defs.h:312
lctrIsoalRxCtx_t isoalRxCtx
Definition: lctr_int_cis.h:295
bool_t headCisRmved
Definition: lctr_int_cis.h:328
lctrCisNode_t * pHead
Definition: lctr_int_cis.h:308
uint8_t cisId
Definition: lctr_int_cis.h:157
bool_t firstRxFromMaster
Definition: lctr_int_cis.h:194
PalBbBleChan_t chan
Internal link layer controller connection interface file.
uint8_t state
Definition: lctr_int_cis.h:150
Internal link layer controller connection interface file.
uint16_t lastActiveEvent
Definition: lctr_int_cis.h:346
Hardware audio codec interface file.
uint8_t numCis
Definition: lctr_int_cis.h:352
Flush timeout parameter list.
Definition: lctr_int_cis.h:139
Timer structure.
Definition: wsf_timer.h:53
Connected isochronous stream linked list.
Definition: lctr_int_cis.h:306
bool_t rxTestEnabled
Definition: lctr_int_cis.h:280
#define LCTR_MAX_BN
Maximum number of burst number.
Definition: lctr_int_cis.h:49
uint8_t cigId
Definition: lctr_int_cis.h:321
uint32_t sduIntervalSToM
Definition: lctr_int_cis.h:258
Link layer controller data channel packet interface file.
bool_t firstFromPeer
Definition: lctr_int_cis.h:270
Baseband operation descriptor (BOD).
Definition: bb_api.h:149
lmgrChanParam_t chanParam
Definition: lctr_int_cis.h:209
bool_t isBodBuilt
Definition: lctr_int_cis.h:318
Parameters related to Tx flush timeout.
Definition: lctr_int_cis.h:116
bool_t enabled
Definition: lctr_int_cis.h:149
lctrOutDataPathCtx_t dataPathOutCtx
Definition: lctr_int_cis.h:276
Connected isochronous group context.
Definition: lctr_int_cis.h:314
uint16_t aclHandle
Definition: lctr_int_cis.h:153
Flush timeout parameter node.
Definition: lctr_int_cis.h:132
uint32_t cigSyncDelayUsec
Definition: lctr_int_cis.h:160
uint8_t phyMToS
Definition: lctr_int_cis.h:248
Link layer manager connection interface file.
uint32_t firstRxStartTsUsec
Definition: lctr_int_cis.h:330
uint8_t estState
Definition: lctr_int_cis.h:151
Timer service.
uint8_t packing
Definition: lctr_int_cis.h:253
BLE baseband interface file.
Link layer controller message data.
Definition: lctr_api_cis.h:81
uint32_t numRxMissed
Definition: lctr_int_cis.h:287
uint32_t nextCisOffsetUsec
Definition: lctr_int_cis.h:267
uint16_t ceRef
Definition: lctr_int_cis.h:181
uint16_t cigEvtCounter
Definition: lctr_int_cis.h:344
uint8_t numCisEsted
Definition: lctr_int_cis.h:326
Internal link layer controller interface file.
uint8_t intervalCounter
Definition: lctr_int_cis.h:124
uint32_t subIntervUsec
Definition: lctr_int_cis.h:263
bool_t rxFromSlave
Definition: lctr_int_cis.h:204
uint32_t cisSyncDelayUsec
Definition: lctr_int_cis.h:159
uint32_t testTxPktCtr
Definition: lctr_int_cis.h:285
uint16_t sduSizeMToS
Definition: lctr_int_cis.h:255
Transmit buffer descriptor.
Definition: pal_bb_ble.h:131
uint32_t expectedPkt
Definition: lctr_int_cis.h:284
uint16_t cisHandle
Definition: lctr_int_cis.h:154
uint8_t subEvtCounter
Definition: lctr_int_cis.h:122
uint32_t numRxFailed
Definition: lctr_int_cis.h:288
uint8_t ftSToM
Definition: lctr_int_cis.h:261
LlIsoPldType_t
ISO test packet payload type.
Definition: ll_api.h:879
uint16_t cigHandle
Definition: lctr_int_cis.h:322
uint8_t nextSubEvtChanIdx
Definition: lctr_int_cis.h:211
lctrCisDataPduHdr_t rxHdr
Definition: lctr_int_cis.h:217
uint16_t dataCounter
Definition: lctr_int_cis.h:177
ISO CIS PDU header.
Definition: lctr_pdu_iso.h:97
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.