Mistake on this page?
Report an issue in GitHub or email us
dm_cis.h
Go to the documentation of this file.
1 /*************************************************************************************************/
2 /*!
3  * \file
4  *
5  * \brief DM Connected Isochronous Stream (CIS) management module.
6  *
7  * Copyright (c) 2019-2020 Packetcraft, Inc.
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21 /*************************************************************************************************/
22 #ifndef DM_CIS_H
23 #define DM_CIS_H
24 
25 #include "dm_api.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 /**************************************************************************************************
32  Macros
33 **************************************************************************************************/
34 
35 /* Uninitialized HCI handle */
36 #define DM_CIS_HCI_HANDLE_NONE 0xFFFF
37 
38 /* Action set initializer */
39 #define DM_CIS_ACT_SET_INIT(n) ((n) << 4)
40 
41 /* Get action set ID from action */
42 #define DM_CIS_ACT_SET_ID(action) ((action) >> 4)
43 
44 /* Get action ID from action */
45 #define DM_CIS_ACT_ID(action) ((action) & 0x0F)
46 
47 /* Restore old state */
48 #define DM_CIS_SM_RESTORE_OLD_STATE 0xFF
49 
50 /**************************************************************************************************
51  Data Types
52 **************************************************************************************************/
53 
54 /*! DM CIS event handler messages for state machine */
55 enum
56 {
57  /* messages from API */
58  DM_CIS_MSG_API_OPEN = DM_MSG_START(DM_ID_CIS), /*!< Open CIS Connection */
59  DM_CIS_MSG_API_CLOSE, /*!< Close CIS Connection */
60  DM_CIS_MSG_API_ACCEPT, /*!< Accept CIS Connection */
61  DM_CIS_MSG_API_REJECT, /*!< Reject CIS Connection */
62 
63  /* messages from HCI */
64  DM_CIS_MSG_HCI_LE_CIS_EST_FAIL, /*!< HCI LE CIS Establish Failure Event */
65  DM_CIS_MSG_HCI_LE_CIS_EST, /*!< HCI LE CIS Established Event */
66  DM_CIS_MSG_HCI_DISCONNECT_CMPL, /*!< HCI Disconnection Complete Event */
67  DM_CIS_MSG_HCI_LE_CIS_REQ /*!< HCI LE CIS Request Event */
68 };
69 
70 /* Number of CIS messages */
71 #define DM_CIS_NUM_MSGS (DM_CIS_MSG_HCI_LE_CIS_REQ - DM_CIS_MSG_API_OPEN + 1)
72 
73 /* CIS state machine action function sets */
74 enum
75 {
76  DM_CIS_ACT_SET_MAIN, /*!< Main action functions */
77  DM_CIS_ACT_SET_MASTER, /*!< Master action functions */
78  DM_CIS_ACT_SET_SLAVE, /*!< Slave action functions */
79 
80  DM_CIS_NUM_ACT_SETS
81 };
82 
83 /*! CIS state machine actions */
84 enum
85 {
86  DM_CIS_SM_ACT_NONE = DM_CIS_ACT_SET_INIT(DM_CIS_ACT_SET_MAIN), /*!< No Action */
87  DM_CIS_SM_ACT_CLOSE, /*!< Process Close */
88  DM_CIS_SM_ACT_CIS_EST, /*!< Procoss CIS Established */
89  DM_CIS_SM_ACT_CIS_EST_FAILED, /*!< Process CIS Establish Failed */
90  DM_CIS_SM_ACT_CIS_CLOSED, /*!< Process CIS Closed */
91 
92  DM_CIS_SM_ACT_OPEN = DM_CIS_ACT_SET_INIT(DM_CIS_ACT_SET_MASTER), /*!< Process Master Open */
93  DM_CIS_SM_ACT_CANCEL_OPEN, /*!< Process Master Cancel Open */
94 
95  DM_CIS_SM_ACT_REQUEST = DM_CIS_ACT_SET_INIT(DM_CIS_ACT_SET_SLAVE),/*!< Process Slave Request */
96  DM_CIS_SM_ACT_ACCEPT, /*!< Process Slave Accept */
97  DM_CIS_SM_ACT_REJECT, /*!< Process Slave Reject */
98 };
99 
100 /*! CIS state machine states */
101 enum
102 {
103  DM_CIS_SM_ST_IDLE, /*!< Idle State */
104  DM_CIS_SM_ST_CONNECTING, /*!< Connecting State */
105  DM_CIS_SM_ST_REQUESTING, /*!< Requesting State */
106  DM_CIS_SM_ST_ACCEPTING, /*!< Accepting State */
107  DM_CIS_SM_ST_CONNECTED, /*!< Connected State */
108  DM_CIS_SM_ST_DISCONNECTING, /*!< Disconnecting State */
109 
110  DM_CIS_SM_NUM_STATES
111 };
112 
113 /*! DM CIS CIG event handler messages for state machine */
114 enum
115 {
116  /* messages from API */
117  DM_CIS_CIG_MSG_API_CONFIG = DM_MSG_START(DM_ID_CIS_CIG), /*!< Configure CIG */
118  DM_CIS_CIG_MSG_API_REMOVE, /*!< Remove CIG */
119 
120  /* messages from HCI */
121  DM_CIS_MSG_HCI_LE_SET_CIG_PARAMS_CMD_CMPL_FAIL, /*!< HCI LE Set CIG Parameters Command Complete Failure Event */
122  DM_CIS_MSG_HCI_LE_SET_CIG_PARAMS_CMD_CMPL, /*!< HCI LE Set CIG Parameters Command Complete Event */
123  DM_CIS_MSG_HCI_LE_REMOVE_CIG_CMD_CMPL_FAIL, /*!< HCI LE Remove CIG Command Complete Failure Event */
124  DM_CIS_MSG_HCI_LE_REMOVE_CIG_CMD_CMPL /*!< HCI LE Remove CIG Command Complete Event */
125 };
126 
127 /* Number of CIS CIG messages */
128 #define DM_CIS_CIG_NUM_MSGS (DM_CIS_MSG_HCI_LE_REMOVE_CIG_CMD_CMPL - DM_CIS_CIG_MSG_API_CONFIG + 1)
129 
130 /*! CIS CIG state machine actions */
131 enum
132 {
133  DM_CIS_CIG_SM_ACT_NONE, /*!< No Action */
134  DM_CIS_CIG_SM_ACT_CONFIG, /*!< Process Configure */
135  DM_CIS_CIG_SM_ACT_CONFIGED, /*!< Process Configured */
136  DM_CIS_CIG_SM_ACT_CONFIG_FAILED, /*!< Process Configure Failed */
137  DM_CIS_CIG_SM_ACT_REMOVE, /*!< Process Remove */
138  DM_CIS_CIG_SM_ACT_REMOVED, /*!< Process Removed */
139  DM_CIS_CIG_SM_ACT_REMOVE_FAILED, /*!< Process Remove Failed */
140 };
141 
142 /*! CIS CIG state machine states */
143 enum
144 {
145  DM_CIS_CIG_SM_ST_IDLE, /*!< Idle State */
146  DM_CIS_CIG_SM_ST_CONFIGING, /*!< Configuring State */
147  DM_CIS_CIG_SM_ST_CONFIGED, /*!< Configured State */
148  DM_CIS_CIG_SM_ST_REMOVING, /*!< Removing State */
149 
150  DM_CIS_CIG_SM_NUM_STATES
151 };
152 
153 /* Data structure for DM_CIS_CIG_MSG_API_CONFIG */
154 typedef struct
155 {
156  wsfMsgHdr_t hdr; /*!< Message Header */
157  uint8_t numCis; /*!< Number of CIS to be configured */
158  HciCisCisParams_t *pCisParam; /*!< CIS parameters */
160 
161 /* Data structure for DM_CIS_MSG_API_OPEN */
162 typedef struct
163 {
164  wsfMsgHdr_t hdr; /*!< Message Header */
165  uint8_t numCis; /*!< Total number of CISes to be created */
166  uint16_t *pCisHandle; /*!< List of connection handles of CISes */
167  uint16_t *pAclHandle; /*!< List of connection handles of ACLs */
169 
170 /*! Data structure for DM_CIS_MSG_API_CLOSE */
171 typedef struct
172 {
173  wsfMsgHdr_t hdr; /*!< Message Header */
174  uint8_t reason; /*!< Reason connection is being closed */
176 
177 /*! Data structure for DM_CIS_MSG_API_REJECT */
178 typedef struct
179 {
180  wsfMsgHdr_t hdr; /*!< Message Header */
181  uint8_t reason; /*!< Reason CIS request was rejected */
183 
184 /*! Union of all DM CIS state machine messages */
185 typedef union
186 {
187  wsfMsgHdr_t hdr; /*!< Message Header */
188 
189  /* API messages */
190  dmCisCigApiConfig_t apiConfig; /*!< Configure CIG */
191  dmCisApiOpen_t apiOpen; /*!< Open CIS Connection */
192  dmCisApiClose_t apiClose; /*!< Close CIS Connection */
193  dmCisApiReject_t apiReject; /*!< Reject CIS Connection */
194 
195  /* HCI LE events */
196  HciLeCisEstEvt_t hciLeCisEst; /*!< CIS Established */
197  HciLeCisReqEvt_t hciLeCisReq; /*!< CIS Request */
198  hciLeSetCigParamsCmdCmplEvt_t hciLeSetCigParamsCmdCmpl; /*!< Set CIS Parameters Command Complete */
199  hciLeRemoveCigCmdCmplEvt_t hciLeRemoveCigCmdCmpl; /*!< Remove CIG Command Complete */
200 } dmCisMsg_t;
201 
202 /*! CIS connection control block */
203 typedef struct
204 {
205  uint8_t cigId; /*!< Used to identify the connected isochronous group. */
206  uint8_t cisId; /*!< Used to identify a connected isochronous stream. */
207  uint16_t aclHandle; /*!< ACL handle. */
208  uint16_t cisHandle; /*!< CIS handle. */
209  dmConnId_t connId; /*!< DM connection ID */
210  uint8_t role; /*!< Role. */
211  uint8_t state; /*!< Main state. */
212  uint8_t inUse; /*!< TRUE if entry in use. */
213 } dmCisCcb_t;
214 
215 /*! CIS CIG control block */
216 typedef struct
217 {
218  uint8_t cigId; /*!< Used to identify the connected isochronous group. */
219  uint32_t sduIntervalMToS; /*!< Time interval between the start of consecutive SDUs from the master Host (in usec). */
220  uint32_t sduIntervalSToM; /*!< Time interval between the start of consecutive SDUs from the slave Host (in usec). */
221  uint8_t sca; /*!< Sleep clock accuracy. */
222  uint8_t packing; /*!< Packing scheme. */
223  uint8_t framing; /*!< Indicates the format of CIS Data PDUs. */
224  uint16_t transLatMToS; /*!< Maximum time for an SDU to be transported from the master Controller to slave Controller (in msec). */
225  uint16_t transLatSToM; /*!< Maximum time for an SDU to be transported from the slave Controller to master Controller (in msec). */
226  uint8_t numCis; /*!< Total number of CISes in the CIG being added or modified. */
227  uint8_t cisId[DM_CIS_MAX]; /*!< List of CIS IDs being added or modified. */
228  uint8_t state; /*!< Main state. */
229  uint8_t inUse; /*!< TRUE if entry in use. */
230 } dmCisCigCb_t;
231 
232 /*! Action functions */
233 typedef void (*dmCisAct_t)(dmCisCcb_t *pCcb, dmCisMsg_t *pMsg);
234 typedef void (*dmCisCigAct_t)(dmCisCigCb_t *pCigCb, dmCisMsg_t *pMsg);
235 
236 /*! Control block of the DM CIS module */
237 typedef struct
238 {
239  dmCisCcb_t cisCcb[DM_CIS_MAX]; /*!< CIS connection control block. */
240  dmCisCigCb_t cisCigCb[DM_CIG_MAX]; /*!< CIS CIG control block. */
241 } dmCisCb_t;
242 
243 /**************************************************************************************************
244  Global Variables
245 **************************************************************************************************/
246 
247 /*! State machine action sets */
248 extern dmCisAct_t *dmCisActSet[DM_CIS_NUM_ACT_SETS];
249 
250 /*! Action function table for CIG master module */
251 extern const dmCisCigAct_t dmCisCigAct[];
252 
253 /*! Control block */
254 extern dmCisCb_t dmCisCb;
255 
256 /**************************************************************************************************
257  Function Declarations
258 **************************************************************************************************/
259 
260 /* utility functions */
261 dmCisCigCb_t *dmCisCigCbAlloc(uint8_t cigId);
262 void dmCisCigCbDealloc(dmCisCigCb_t *pCigCb);
263 dmCisCcb_t *dmCisCcbAlloc(uint8_t cigId, uint8_t cisId, uint8_t role);
264 void dmCisCcbDealloc(dmCisCcb_t *pCcb);
265 void dmCisCcbDeallocByCigId(uint8_t cigId);
266 dmCisCcb_t *dmCisCcbByHandle(uint16_t handle);
267 dmCisCcb_t *dmCisCcbById(uint8_t cigId, uint8_t cisId);
268 dmCisCigCb_t *dmCisCigCbById(uint8_t cigId);
269 
270 /* CIS main action functions */
271 void dmCisSmActClose(dmCisCcb_t *pCcb, dmCisMsg_t *pMsg);
272 void dmCisSmActCisEst(dmCisCcb_t *pCcb, dmCisMsg_t *pMsg);
273 void dmCisSmActCisEstFailed(dmCisCcb_t *pCcb, dmCisMsg_t *pMsg);
274 void dmCisSmActCisClosed(dmCisCcb_t *pCcb, dmCisMsg_t *pMsg);
275 
276 /* CIG main action functions */
277 void dmCisCigReset(void);
278 void dmCisCigMsgHandler(wsfMsgHdr_t *pMsg);
279 void dmCisCigHciHandler(hciEvt_t *pEvent);
280 
281 /* state machine */
282 void dmCisSmExecute(dmCisCcb_t *pCcb, dmCisMsg_t *pMsg);
283 void dmCisCigSmExecute(dmCisCigCb_t *pCcb, dmCisMsg_t *pMsg);
284 
285 /* main action functions */
286 void dmCisSmActNone(dmCisCcb_t *pCcb, dmCisMsg_t *pMsg);
287 
288 #ifdef __cplusplus
289 };
290 #endif
291 
292 #endif /* DM_CIS_H */
LE CIS established event.
Definition: hci_api.h:701
uint8_t framing
Definition: dm_cis.h:223
const dmCisCigAct_t dmCisCigAct[]
uint8_t packing
Definition: dm_cis.h:222
uint8_t cisId
Definition: dm_cis.h:206
uint8_t dmConnId_t
Connection identifier.
Definition: dm_api.h:588
CIS parameters.
Definition: hci_api.h:1086
uint8_t numCis
Definition: dm_cis.h:226
uint32_t sduIntervalSToM
Definition: dm_cis.h:220
uint16_t transLatMToS
Definition: dm_cis.h:224
uint32_t sduIntervalMToS
Definition: dm_cis.h:219
uint16_t * pAclHandle
Definition: dm_cis.h:167
LE CIS request event.
Definition: hci_api.h:723
dmCisCb_t dmCisCb
uint8_t cigId
Definition: dm_cis.h:218
wsfMsgHdr_t hdr
Definition: dm_cis.h:156
HciLeCisReqEvt_t hciLeCisReq
Definition: dm_cis.h:197
uint16_t aclHandle
Definition: dm_cis.h:207
uint8_t state
Definition: dm_cis.h:228
dmCisApiClose_t apiClose
Definition: dm_cis.h:192
dmCisCigApiConfig_t apiConfig
Definition: dm_cis.h:190
HciCisCisParams_t * pCisParam
Definition: dm_cis.h:158
dmCisApiOpen_t apiOpen
Definition: dm_cis.h:191
uint16_t * pCisHandle
Definition: dm_cis.h:166
wsfMsgHdr_t hdr
Definition: dm_cis.h:180
void(* dmCisAct_t)(dmCisCcb_t *pCcb, dmCisMsg_t *pMsg)
Definition: dm_cis.h:233
dmCisApiReject_t apiReject
Definition: dm_cis.h:193
LE set CIG parameters command complete event.
Definition: hci_api.h:742
dmConnId_t connId
Definition: dm_cis.h:209
#define DM_CIG_MAX
Maximum number of connected isochronous groups.
Definition: cfg_stack.h:102
uint8_t inUse
Definition: dm_cis.h:229
HciLeCisEstEvt_t hciLeCisEst
Definition: dm_cis.h:196
uint16_t transLatSToM
Definition: dm_cis.h:225
hciLeRemoveCigCmdCmplEvt_t hciLeRemoveCigCmdCmpl
Definition: dm_cis.h:199
uint8_t numCis
Definition: dm_cis.h:165
uint8_t numCis
Definition: dm_cis.h:157
wsfMsgHdr_t hdr
Definition: dm_cis.h:164
uint8_t sca
Definition: dm_cis.h:221
Union of all event types.
Definition: hci_api.h:931
hciLeSetCigParamsCmdCmplEvt_t hciLeSetCigParamsCmdCmpl
Definition: dm_cis.h:198
Device Manager subsystem API.
wsfMsgHdr_t hdr
Definition: dm_cis.h:173
uint8_t inUse
Definition: dm_cis.h:212
uint16_t cisHandle
Definition: dm_cis.h:208
uint8_t reason
Definition: dm_cis.h:181
dmCisAct_t * dmCisActSet[DM_CIS_NUM_ACT_SETS]
uint8_t role
Definition: dm_cis.h:210
uint8_t state
Definition: dm_cis.h:211
wsfMsgHdr_t hdr
Definition: dm_cis.h:187
LE remove CIG command complete event.
Definition: hci_api.h:752
uint8_t cigId
Definition: dm_cis.h:205
Common message structure passed to event handler.
Definition: wsf_os.h:106
#define DM_CIS_MAX
Maximum number of connected isochronous streams, it is shared by CIGs.
Definition: cfg_stack.h:107
uint8_t reason
Definition: dm_cis.h:174
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.