Mistake on this page?
Report an issue in GitHub or email us
lctr_int_iso.h
Go to the documentation of this file.
1 /*************************************************************************************************/
2 /*!
3  * \file
4  *
5  * \brief Internal link layer controller connection interface file.
6  *
7  * Copyright (c) 2013-2018 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_ISO_H
26 #define LCTR_INT_ISO_H
27 
28 #include "lctr_api_iso.h"
29 #include "lctr_int.h"
30 #include "lctr_int_conn.h"
31 #include "lctr_pdu_iso.h"
32 #include "lmgr_api_iso.h"
33 #include "ll_defs.h"
34 #include "wsf_cs.h"
35 #include "pal_codec.h"
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 /**************************************************************************************************
42  Macros
43 **************************************************************************************************/
44 
45 #define LCTR_ISO_DATA_PDU_FC_OFFSET 0 /*!< Flow control fields data PDU offset. */
46 #define LCTR_ISO_DATA_PDU_LEN_OFFSET 1 /*!< Length field CIS or BIS Data PDU offset. */
47 
48 /*! \brief First CIS handle (follows ACL handles). */
49 #define LCTR_FIRST_CIS_HANDLE (pLctrRtCfg->maxConn)
50 
51 /*! \brief First BIS handle (follows CIS handles). */
52 #define LCTR_FIRST_BIS_HANDLE (pLctrRtCfg->maxConn + pLctrRtCfg->maxCis)
53 
54 /*! \brief Fragment header maximum length. */
55 #define LCTR_ISO_FRAG_HDR_MAX_LEN (LL_ISO_DATA_HDR_LEN + LL_ISO_SEG_HDR_LEN + LL_ISO_SEG_TO_LEN)
56 
57 /*! \brief Fragment trailer maximum length. */
58 #define LCTR_ISO_FRAG_TRL_MAX_LEN LL_DATA_MIC_LEN
59 
60 /*! \brief SDU offset to start of the SDU data buffer. */
61 #define LCTR_ISO_SDU_DATA_START_OFFSET HCI_ISO_HDR_LEN + HCI_ISO_DL_MAX_LEN
62 
63 /**************************************************************************************************
64  Type Definitions
65 **************************************************************************************************/
66 
67 /*! \brief Transmit buffer descriptor. */
68 typedef struct
69 {
70  uint8_t *pIsoSdu; /*!< ISO buffer. */
71  uint8_t *pPduBuf; /*!< PDU data buffer. */
72  uint16_t isoLen; /*!< ISO SDU length. */
73  uint8_t fragLen; /*!< Fragmentation length. */
74  uint8_t fragCnt; /*!< Current fragmentation Tx count. */
75  struct
76  {
77  uint8_t hdrLen; /*!< Data PDU header length. */
78  uint8_t trlLen; /*!< Data PDU trailer length. */
79  uint8_t hdr[LCTR_ISO_FRAG_HDR_MAX_LEN]; /*!< Data PDU header. */
80  uint8_t trl[LCTR_ISO_FRAG_TRL_MAX_LEN]; /*!< Data PDU trailer (i.e., MIC). */
81  } frag[]; /*!< Fragmented Data PDU packet data. */
83 
84 /*! \brief Start stream call signature. */
85 typedef bool_t (*lctrCodecStartStream)(uint16_t id, PalCodecSreamParam_t *pParam);
86 
87 /*! \brief Stop stream call signature. */
88 typedef void (*lctrCodecStopStream)(uint16_t id);
89 
90 /*! \brief Stream in data call signature. */
91 typedef uint16_t (*lctrCodecStreamIn)(uint16_t id, uint8_t *pBuf, uint16_t len, uint32_t *pPktCtr);
92 
93 /*! \brief Stream out data call signature. */
94 typedef void (*lctrCodecStreamOut)(uint16_t id, const uint8_t *pBuf, uint16_t len, uint32_t pktCtr);
95 
96 /*! \brief Codec event handlers. */
97 typedef struct
98 {
99  lctrCodecStartStream start; /*!< Start stream. */
100  lctrCodecStopStream stop; /*!< Stop stream. */
101  lctrCodecStreamIn in; /*!< Stream data input. */
102  lctrCodecStreamOut out; /*!< Stream data output. */
104 
105 /*! \brief Codec event handlers. */
107 
108 /*! \brief Transmit ISOAL Context. */
109 typedef struct
110 {
111  wsfQueue_t pendingSduQ; /*!< ISO pending SDU queue. */
112  uint8_t pendQueueSize; /*!< Pending queue size. */
113  uint16_t sduOffset; /*!< Offset of incomplete SDU. */
114  uint8_t compSdu; /*!< Number of completed SDUs for current ISO event. */
116 
117 /*! \brief Receive ISOAL Context. */
118 typedef struct
119 {
120  uint8_t *pPendSduBuf; /*!< Pointer to incomplete SDU buffer. */
121  uint16_t rxSduOffset; /*!< Offset of SDU currently being assembled. */
122  bool_t pduFlushed; /*!< Most recent PDU was flushed due to failed RXs. */
123  uint8_t rxState; /*!< RX state. */
124  uint16_t packetSequence; /*!< Packet sequence number. */
125 
126  union
127  {
128  struct
129  {
130  uint32_t timeOffset; /*!< Time offset of an SDU. */
131  } framed; /*!< Framed specific data. */
132 
133  struct
134  {
135  wsfQueue_t pendSduQ; /*!< Pending PDU fragments. */
136  uint16_t curLen; /*!< Current length of SDU being received. */
137  uint8_t ps; /*!< Packet status. */
138  } unframed; /*!< Unframed specific data. */
139  } data; /*!< Framing-specific data. */
141 
142 /*! \brief Input datapath context. */
143 typedef struct
144 {
145  LlIsoDataPath_t id; /*!< Input data path ID. */
146 } lctrInDataPathCtx_t; /*!< Input datapath configuration. */
147 
148 /*! \brief Output datapath context. */
149 typedef struct
150 {
151  LlIsoDataPath_t id; /*!< Output data path ID. */
152 
153  union
154  {
155  struct
156  {
157  wsfQueue_t rxDataQ; /*!< Receive data pending queue. */
158  uint8_t numRxPend; /*!< Number of messages pending in the RX queue. */
159  } hci; /*!< HCI data path configuration. */
160  } cfg; /*!< Datapath-specific configuration parameters. */
161 } lctrOutDataPathCtx_t; /*!< Output datapath configuration. */
162 
163 /*! \brief Datapath context. */
164 typedef union
165 {
166  lctrInDataPathCtx_t in; /*!< Input context. */
167  lctrOutDataPathCtx_t out; /*!< Output context. */
168 } lctrDataPathCtx_t; /*!< Datapath context collection. */
169 
170 /**************************************************************************************************
171  Function Declarations
172 **************************************************************************************************/
173 
174 /* Task event handler */
175 void lctrIsoTxCompletedHandler(void);
176 void lctrCisRxPendingHandler(void);
177 void lctrNotifyHostIsoEventComplete(uint8_t handle, uint32_t evtCtr);
178 
179 /* ISO data path */
180 lctrIsoTxBufDesc_t *lctrAllocIsoTxBufDesc(void);
181 void lctrFreeIsoTxBufDesc(lctrIsoTxBufDesc_t *pDesc);
182 uint8_t lctrSetupIsoDataPath( LlIsoSetupDataPath_t *pSetupDataPath, lctrDataPathCtx_t *pDataPathCtx);
183 void lctrIsoSendCodecSdu(uint16_t id);
184 bool_t lctrIsoRxConnEnq(lctrOutDataPathCtx_t *pOutDataPathCtx, uint16_t handle, uint8_t *pBuf);
185 void lctrIsoOutDataPathClear(lctrOutDataPathCtx_t *pOutCtx);
186 void lctrIsoalRxDataPathClear(lctrIsoalRxCtx_t *pRxCtx, uint8_t framing);
187 void lctrIsoOutDataPathSetup(lctrOutDataPathCtx_t *pOutCtx);
188 uint8_t *lctrIsoRxConnDeq(lctrOutDataPathCtx_t *pOutCtx);
189 bool_t lctrIsoUnframedRxSduPendQueue(lctrIsoalRxCtx_t *pRxCtx, uint8_t *pSdu, uint16_t handle,
190  uint16_t dataLen, uint8_t llid);
191 
192 /* ISO Test mode. */
193 uint8_t *lctrGenerateIsoTestData(uint16_t handle, LlIsoPldType_t pldType, uint16_t maxSdu, uint32_t pktCtr);
194 void lctrValidateIsoTestData(uint8_t *pPld, uint8_t actLen, LlIsoTestCtrs_t *pRxStats, uint8_t pldType, uint16_t expMaxSdu, uint32_t expPldCtr);
195 /* ISOAL Utility. */
196 uint8_t lctrAssembleTxFramedPdu(lctrIsoalTxCtx_t *pIsoalTxCtx, uint8_t *pPduBuf, uint16_t maxPduLen);
197 uint8_t lctrAssembleRxFramedSdu(lctrIsoalRxCtx_t *pIsoalRxCtx, wsfQueue_t *pRxQueue,
198  uint16_t handle, uint8_t *pIsoBuf, uint8_t len);
199 uint8_t *lctrTxIsoDataPduAlloc(void);
200 
201 /*************************************************************************************************/
202 /*!
203  * \brief Increment available Tx data buffers.
204  */
205 /*************************************************************************************************/
206 static inline void lctrIsoSduTxIncAvailBuf(void)
207 {
208  WSF_CS_INIT();
209 
210  WSF_CS_ENTER();
211  lmgrIsoCb.availTxBuf++;
212  WSF_CS_EXIT();
213 }
214 
215 /*************************************************************************************************/
216 /*!
217  * \brief Decrement available Tx data buffers.
218  */
219 /*************************************************************************************************/
220 static inline void lctrIsoSduTxDecAvailBuf(void)
221 {
222  WSF_CS_INIT();
223 
224  WSF_CS_ENTER();
225  lmgrIsoCb.availTxBuf--;
226  WSF_CS_EXIT();
227 }
228 
229 /*************************************************************************************************/
230 /*!
231  * \brief Increment available Rx data buffers.
232  *
233  * \param numBufs Number of additional buffers available.
234  */
235 /*************************************************************************************************/
236 static inline void lctrIsoDataRxIncAvailBuf(uint8_t numBufs)
237 {
238  WSF_CS_INIT();
239 
240  WSF_CS_ENTER();
241  lmgrIsoCb.availRxBuf += numBufs;
242  WSF_CS_EXIT();
243 }
244 
245 /*************************************************************************************************/
246 /*!
247  * \brief Decrement available Rx data buffers.
248  */
249 /*************************************************************************************************/
250 static inline void lctrIsoDataRxDecAvailBuf(void)
251 {
252  WSF_CS_INIT();
253 
254  WSF_CS_ENTER();
255  lmgrIsoCb.availRxBuf--;
256  WSF_CS_EXIT();
257 }
258 
259 #ifdef __cplusplus
260 };
261 #endif
262 
263 #endif /* LCTR_INT_ISO_H */
uint8_t * pPendSduBuf
Definition: lctr_int_iso.h:120
ISO test counter data.
Definition: ll_api.h:887
Transmit buffer descriptor.
Definition: lctr_int_iso.h:68
wsfQueue_t pendingSduQ
Definition: lctr_int_iso.h:111
uint16_t rxSduOffset
Definition: lctr_int_iso.h:121
uint8_t availTxBuf
Definition: lmgr_api_iso.h:46
lctrOutDataPathCtx_t out
Definition: lctr_int_iso.h:167
static void lctrIsoSduTxDecAvailBuf(void)
Decrement available Tx data buffers.
Definition: lctr_int_iso.h:220
Codec event handlers.
Definition: lctr_int_iso.h:97
Output datapath context.
Definition: lctr_int_iso.h:149
void(* lctrCodecStopStream)(uint16_t id)
Stop stream call signature.
Definition: lctr_int_iso.h:88
static void lctrIsoDataRxIncAvailBuf(uint8_t numBufs)
Increment available Rx data buffers.
Definition: lctr_int_iso.h:236
lctrCodecStreamOut out
Definition: lctr_int_iso.h:102
LlIsoDataPath_t id
Definition: lctr_int_iso.h:151
bool_t(* lctrCodecStartStream)(uint16_t id, PalCodecSreamParam_t *pParam)
Start stream call signature.
Definition: lctr_int_iso.h:85
uint8_t availRxBuf
Definition: lmgr_api_iso.h:47
Link layer controller common ISO interface file.
Critical section macros.
static void lctrIsoSduTxIncAvailBuf(void)
Increment available Tx data buffers.
Definition: lctr_int_iso.h:206
lctrCodecStartStream start
Definition: lctr_int_iso.h:99
#define LCTR_ISO_FRAG_TRL_MAX_LEN
Fragment trailer maximum length.
Definition: lctr_int_iso.h:58
#define WSF_CS_EXIT(cs)
Exit a critical section.
Definition: wsf_cs.h:74
LlIsoDataPath_t id
Definition: lctr_int_iso.h:145
Input datapath context.
Definition: lctr_int_iso.h:143
lctrInDataPathCtx_t in
Definition: lctr_int_iso.h:166
Transmit ISOAL Context.
Definition: lctr_int_iso.h:109
Receive ISOAL Context.
Definition: lctr_int_iso.h:118
Queue structure.
Definition: wsf_queue.h:46
uint16_t sduOffset
Definition: lctr_int_iso.h:113
LlIsoDataPath_t
ISO data path.
Definition: ll_api.h:733
uint16_t packetSequence
Definition: lctr_int_iso.h:124
static void lctrIsoDataRxDecAvailBuf(void)
Decrement available Rx data buffers.
Definition: lctr_int_iso.h:250
LE setup ISO Data Path command.
Definition: ll_api.h:751
Link layer constant definitions.
Internal link layer controller connection interface file.
Hardware audio codec interface file.
#define LCTR_ISO_FRAG_HDR_MAX_LEN
Fragment header maximum length.
Definition: lctr_int_iso.h:55
lctrCodecStopStream stop
Definition: lctr_int_iso.h:100
Link layer controller data channel packet interface file.
uint32_t timeOffset
Definition: lctr_int_iso.h:130
wsfQueue_t pendSduQ
Definition: lctr_int_iso.h:135
Link layer manager connection interface file.
uint16_t(* lctrCodecStreamIn)(uint16_t id, uint8_t *pBuf, uint16_t len, uint32_t *pPktCtr)
Stream in data call signature.
Definition: lctr_int_iso.h:91
lctrCodecHandlers_t lctrCodecHdlr
Codec event handlers.
void(* lctrCodecStreamOut)(uint16_t id, const uint8_t *pBuf, uint16_t len, uint32_t pktCtr)
Stream out data call signature.
Definition: lctr_int_iso.h:94
Internal link layer controller interface file.
#define WSF_CS_INIT(cs)
Initialize critical section. This macro may define a variable.
Definition: wsf_cs.h:52
Datapath context.
Definition: lctr_int_iso.h:164
LlIsoPldType_t
ISO test packet payload type.
Definition: ll_api.h:879
#define WSF_CS_ENTER(cs)
Enter a critical section.
Definition: wsf_cs.h:63
uint8_t pendQueueSize
Definition: lctr_int_iso.h:112
lctrCodecStreamIn in
Definition: lctr_int_iso.h:101
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.