xref: /OK3568_Linux_fs/app/forlinx/quectelCM/MPQCTL.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*===========================================================================
2 
3                             M P Q C T L. H
4 DESCRIPTION:
5 
6     This module contains QMI QCTL module.
7 
8 INITIALIZATION AND SEQUENCING REQUIREMENTS:
9 
10 Copyright (C) 2011 by Qualcomm Technologies, Incorporated.  All Rights Reserved.
11 ===========================================================================*/
12 
13 #ifndef MPQCTL_H
14 #define MPQCTL_H
15 
16 #include "MPQMI.h"
17 
18 #pragma pack(push, 1)
19 
20 // ================= QMICTL ==================
21 
22 // QMICTL Control Flags
23 #define QMICTL_CTL_FLAG_CMD     0x00
24 #define QMICTL_CTL_FLAG_RSP     0x01
25 #define QMICTL_CTL_FLAG_IND     0x02
26 
27 #if 0
28 typedef struct _QMICTL_TRANSACTION_ITEM
29 {
30    LIST_ENTRY  List;
31    UCHAR       TransactionId;  // QMICTL transaction id
32    PVOID       Context;        // Adapter or IocDev
33    PIRP        Irp;
34 } QMICTL_TRANSACTION_ITEM, *PQMICTL_TRANSACTION_ITEM;
35 #endif
36 
37 typedef struct _QCQMICTL_MSG_HDR
38 {
39    UCHAR  CtlFlags;  // 00-cmd, 01-rsp, 10-ind
40    UCHAR  TransactionId;
41    USHORT QMICTLType;
42    USHORT Length;
43 } __attribute__ ((packed)) QCQMICTL_MSG_HDR, *PQCQMICTL_MSG_HDR;
44 
45 #define QCQMICTL_MSG_HDR_SIZE sizeof(QCQMICTL_MSG_HDR)
46 
47 typedef struct _QCQMICTL_MSG_HDR_RESP
48 {
49    UCHAR  CtlFlags;  // 00-cmd, 01-rsp, 10-ind
50    UCHAR  TransactionId;
51    USHORT QMICTLType;
52    USHORT Length;
53    UCHAR  TLVType;          // 0x02 - result code
54    USHORT TLVLength;        // 4
55    USHORT QMUXResult;       // QMI_RESULT_SUCCESS
56                             // QMI_RESULT_FAILURE
57    USHORT QMUXError;        // QMI_ERR_INVALID_ARG
58                             // QMI_ERR_NO_MEMORY
59                             // QMI_ERR_INTERNAL
60                             // QMI_ERR_FAULT
61 } __attribute__ ((packed)) QCQMICTL_MSG_HDR_RESP, *PQCQMICTL_MSG_HDR_RESP;
62 
63 typedef struct _QCQMICTL_MSG
64 {
65    UCHAR  CtlFlags;  // 00-cmd, 01-rsp, 10-ind
66    UCHAR  TransactionId;
67    USHORT QMICTLType;
68    USHORT Length;
69    UCHAR  Payload;
70 } __attribute__ ((packed)) QCQMICTL_MSG, *PQCQMICTL_MSG;
71 
72 // TLV Header
73 typedef struct _QCQMICTL_TLV_HDR
74 {
75    UCHAR  TLVType;
76    USHORT TLVLength;
77 } __attribute__ ((packed)) QCQMICTL_TLV_HDR, *PQCQMICTL_TLV_HDR;
78 
79 #define QCQMICTL_TLV_HDR_SIZE sizeof(QCQMICTL_TLV_HDR)
80 
81 // QMICTL Type
82 #define QMICTL_SET_INSTANCE_ID_REQ    0x0020
83 #define QMICTL_SET_INSTANCE_ID_RESP   0x0020
84 #define QMICTL_GET_VERSION_REQ        0x0021
85 #define QMICTL_GET_VERSION_RESP       0x0021
86 #define QMICTL_GET_CLIENT_ID_REQ      0x0022
87 #define QMICTL_GET_CLIENT_ID_RESP     0x0022
88 #define QMICTL_RELEASE_CLIENT_ID_REQ  0x0023
89 #define QMICTL_RELEASE_CLIENT_ID_RESP 0x0023
90 #define QMICTL_REVOKE_CLIENT_ID_IND   0x0024
91 #define QMICTL_INVALID_CLIENT_ID_IND  0x0025
92 #define QMICTL_SET_DATA_FORMAT_REQ    0x0026
93 #define QMICTL_SET_DATA_FORMAT_RESP   0x0026
94 #define QMICTL_SYNC_REQ               0x0027
95 #define QMICTL_SYNC_RESP              0x0027
96 #define QMICTL_SYNC_IND               0x0027
97 #define QMI_MESSAGE_CTL_INTERNAL_PROXY_OPEN 0xFF00
98 
99 #define QMICTL_FLAG_REQUEST    0x00
100 #define QMICTL_FLAG_RESPONSE   0x01
101 #define QMICTL_FLAG_INDICATION 0x02
102 
103 // QMICTL Message Definitions
104 
105 typedef struct _QMICTL_SET_INSTANCE_ID_REQ_MSG
106 {
107    UCHAR  CtlFlags;        // QMICTL_FLAG_REQUEST
108    UCHAR  TransactionId;
109    USHORT QMICTLType;      // QMICTL_SET_INSTANCE_ID_REQ
110    USHORT Length;          // 4
111    UCHAR  TLVType;         // QCTLV_TYPE_REQUIRED_PARAMETER
112    USHORT TLVLength;       // 1
113    UCHAR  Value;           // Host-unique QMI instance for this device driver
114 } __attribute__ ((packed)) QMICTL_SET_INSTANCE_ID_REQ_MSG, *PQMICTL_SET_INSTANCE_ID_REQ_MSG;
115 
116 typedef struct _QMICTL_SET_INSTANCE_ID_RESP_MSG
117 {
118    UCHAR  CtlFlags;        // QMICTL_FLAG_RESPONSE
119    UCHAR  TransactionId;
120    USHORT QMICTLType;      // QMICTL_SET_INSTANCE_ID_RESP
121    USHORT Length;
122    UCHAR  TLVType;         // QCTLV_TYPE_RESULT_CODE
123    USHORT TLVLength;       // 0x0004
124    USHORT QMIResult;
125    USHORT QMIError;
126    UCHAR  TLV2Type;        // QCTLV_TYPE_REQUIRED_PARAMETER
127    USHORT TLV2Length;      // 0x0002
128    USHORT QMI_ID;          // Upper byte is assigned by MSM,
129                            // lower assigned by host
130 } __attribute__ ((packed)) QMICTL_SET_INSTANCE_ID_RESP_MSG, *PQMICTL_SET_INSTANCE_ID_RESP_MSG;
131 
132 typedef struct _QMICTL_GET_VERSION_REQ_MSG
133 {
134    UCHAR  CtlFlags;        // QMICTL_FLAG_REQUEST
135    UCHAR  TransactionId;
136    USHORT QMICTLType;      // QMICTL_GET_VERSION_REQ
137    USHORT Length;          // 0
138    UCHAR  TLVType;         // QCTLV_TYPE_REQUIRED_PARAMETER
139    USHORT TLVLength;       // var
140    UCHAR  QMUXTypes;       // List of one byte QMUX_TYPE values
141                            // 0xFF returns a list of versions for all
142                            // QMUX_TYPEs implemented on the device
143 } __attribute__ ((packed)) QMICTL_GET_VERSION_REQ_MSG, *PQMICTL_GET_VERSION_REQ_MSG;
144 
145 typedef struct _QMUX_TYPE_VERSION_STRUCT
146 {
147    UCHAR  QMUXType;
148    USHORT MajorVersion;
149    USHORT MinorVersion;
150 } __attribute__ ((packed)) QMUX_TYPE_VERSION_STRUCT, *PQMUX_TYPE_VERSION_STRUCT;
151 
152 typedef struct _ADDENDUM_VERSION_PREAMBLE
153 {
154    UCHAR LabelLength;
155    UCHAR Label;
156 } __attribute__ ((packed)) ADDENDUM_VERSION_PREAMBLE, *PADDENDUM_VERSION_PREAMBLE;
157 
158 #define QMICTL_GET_VERSION_RSP_TLV_TYPE_VERSION     0x01
159 #define QMICTL_GET_VERSION_RSP_TLV_TYPE_ADD_VERSION 0x10
160 
161 typedef struct _QMICTL_GET_VERSION_RESP_MSG
162 {
163    UCHAR  CtlFlags;        // QMICTL_FLAG_RESPONSE
164    UCHAR  TransactionId;
165    USHORT QMICTLType;      // QMICTL_GET_VERSION_RESP
166    USHORT Length;
167    UCHAR  TLVType;         // QCTLV_TYPE_RESULT_CODE
168    USHORT TLVLength;       // 0x0004
169    USHORT QMIResult;
170    USHORT QMIError;
171    UCHAR  TLV2Type;        // QCTLV_TYPE_REQUIRED_PARAMETER
172    USHORT TLV2Length;      // var
173    UCHAR  NumElements;     // Num of QMUX_TYPE_VERSION_STRUCT
174    QMUX_TYPE_VERSION_STRUCT TypeVersion[0];
175 } __attribute__ ((packed)) QMICTL_GET_VERSION_RESP_MSG, *PQMICTL_GET_VERSION_RESP_MSG;
176 
177 typedef struct _QMICTL_GET_CLIENT_ID_REQ_MSG
178 {
179    UCHAR  CtlFlags;        // QMICTL_FLAG_REQUEST
180    UCHAR  TransactionId;
181    USHORT QMICTLType;      // QMICTL_GET_CLIENT_ID_REQ
182    USHORT Length;
183    UCHAR  TLVType;         // QCTLV_TYPE_REQUIRED_PARAMETER
184    USHORT TLVLength;       // 1
185    UCHAR  QMIType;         // QMUX type
186 } __attribute__ ((packed)) QMICTL_GET_CLIENT_ID_REQ_MSG, *PQMICTL_GET_CLIENT_ID_REQ_MSG;
187 
188 typedef struct _QMICTL_GET_CLIENT_ID_RESP_MSG
189 {
190    UCHAR  CtlFlags;        // QMICTL_FLAG_RESPONSE
191    UCHAR  TransactionId;
192    USHORT QMICTLType;      // QMICTL_GET_CLIENT_ID_RESP
193    USHORT Length;
194    UCHAR  TLVType;         // QCTLV_TYPE_RESULT_CODE
195    USHORT TLVLength;       // 0x0004
196    USHORT QMIResult;       // result code
197    USHORT QMIError;        // error code
198    UCHAR  TLV2Type;        // QCTLV_TYPE_REQUIRED_PARAMETER
199    USHORT TLV2Length;      // 2
200    UCHAR  QMIType;
201    UCHAR  ClientId;
202 } __attribute__ ((packed)) QMICTL_GET_CLIENT_ID_RESP_MSG, *PQMICTL_GET_CLIENT_ID_RESP_MSG;
203 
204 typedef struct _QMICTL_RELEASE_CLIENT_ID_REQ_MSG
205 {
206    UCHAR  CtlFlags;        // QMICTL_FLAG_REQUEST
207    UCHAR  TransactionId;
208    USHORT QMICTLType;      // QMICTL_RELEASE_CLIENT_ID_REQ
209    USHORT Length;
210    UCHAR  TLVType;         // QCTLV_TYPE_REQUIRED_PARAMETER
211    USHORT TLVLength;       // 0x0002
212    UCHAR  QMIType;
213    UCHAR  ClientId;
214 } __attribute__ ((packed)) QMICTL_RELEASE_CLIENT_ID_REQ_MSG, *PQMICTL_RELEASE_CLIENT_ID_REQ_MSG;
215 
216 typedef struct _QMICTL_RELEASE_CLIENT_ID_RESP_MSG
217 {
218    UCHAR  CtlFlags;        // QMICTL_FLAG_RESPONSE
219    UCHAR  TransactionId;
220    USHORT QMICTLType;      // QMICTL_RELEASE_CLIENT_ID_RESP
221    USHORT Length;
222    UCHAR  TLVType;         // QCTLV_TYPE_RESULT_CODE
223    USHORT TLVLength;       // 0x0004
224    USHORT QMIResult;       // result code
225    USHORT QMIError;        // error code
226    UCHAR  TLV2Type;        // QCTLV_TYPE_REQUIRED_PARAMETER
227    USHORT TLV2Length;      // 2
228    UCHAR  QMIType;
229    UCHAR  ClientId;
230 } __attribute__ ((packed)) QMICTL_RELEASE_CLIENT_ID_RESP_MSG, *PQMICTL_RELEASE_CLIENT_ID_RESP_MSG;
231 
232 typedef struct _QMICTL_REVOKE_CLIENT_ID_IND_MSG
233 {
234    UCHAR  CtlFlags;        // QMICTL_FLAG_INDICATION
235    UCHAR  TransactionId;
236    USHORT QMICTLType;      // QMICTL_REVOKE_CLIENT_ID_IND
237    USHORT Length;
238    UCHAR  TLVType;         // QCTLV_TYPE_REQUIRED_PARAMETER
239    USHORT TLVLength;       // 0x0002
240    UCHAR  QMIType;
241    UCHAR  ClientId;
242 } __attribute__ ((packed)) QMICTL_REVOKE_CLIENT_ID_IND_MSG, *PQMICTL_REVOKE_CLIENT_ID_IND_MSG;
243 
244 typedef struct _QMICTL_INVALID_CLIENT_ID_IND_MSG
245 {
246    UCHAR  CtlFlags;        // QMICTL_FLAG_INDICATION
247    UCHAR  TransactionId;
248    USHORT QMICTLType;      // QMICTL_REVOKE_CLIENT_ID_IND
249    USHORT Length;
250    UCHAR  TLVType;         // QCTLV_TYPE_REQUIRED_PARAMETER
251    USHORT TLVLength;       // 0x0002
252    UCHAR  QMIType;
253    UCHAR  ClientId;
254 } __attribute__ ((packed)) QMICTL_INVALID_CLIENT_ID_IND_MSG, *PQMICTL_INVALID_CLIENT_ID_IND_MSG;
255 
256 typedef struct _QMICTL_SET_DATA_FORMAT_REQ_MSG
257 {
258    UCHAR  CtlFlags;        // QMICTL_FLAG_REQUEST
259    UCHAR  TransactionId;
260    USHORT QMICTLType;      // QMICTL_SET_DATA_FORMAT_REQ
261    USHORT Length;
262    UCHAR  TLVType;         // QCTLV_TYPE_REQUIRED_PARAMETER
263    USHORT TLVLength;       // 1
264    UCHAR  DataFormat;      // 0-default; 1-QoS hdr present
265 } __attribute__ ((packed)) QMICTL_SET_DATA_FORMAT_REQ_MSG, *PQMICTL_SET_DATA_FORMAT_REQ_MSG;
266 
267 #ifdef QC_IP_MODE
268 #define SET_DATA_FORMAT_TLV_TYPE_LINK_PROTO 0x10
269 #define SET_DATA_FORMAT_LINK_PROTO_ETH      0x0001
270 #define SET_DATA_FORMAT_LINK_PROTO_IP       0x0002
271 typedef struct _QMICTL_SET_DATA_FORMAT_TLV_LINK_PROT
272 {
273    UCHAR  TLVType;         // Link-Layer Protocol
274    USHORT TLVLength;       // 2
275    USHORT LinkProt;        // 0x1: ETH; 0x2: IP
276 } QMICTL_SET_DATA_FORMAT_TLV_LINK_PROT, *PQMICTL_SET_DATA_FORMAT_TLV_LINK_PROT;
277 
278 #ifdef QCMP_UL_TLP
279 #define SET_DATA_FORMAT_TLV_TYPE_UL_TLP 0x11
280 typedef struct _QMICTL_SET_DATA_FORMAT_TLV_UL_TLP
281 {
282    UCHAR  TLVType;         // 0x11, Uplink TLP Setting
283    USHORT TLVLength;       // 1
284    UCHAR  UlTlpSetting;    // 0x0: Disable; 0x01: Enable
285 } QMICTL_SET_DATA_FORMAT_TLV_UL_TLP, *PQMICTL_SET_DATA_FORMAT_TLV_UL_TLP;
286 #endif // QCMP_UL_TLP
287 
288 #ifdef QCMP_DL_TLP
289 #define SET_DATA_FORMAT_TLV_TYPE_DL_TLP 0x13
290 typedef struct _QMICTL_SET_DATA_FORMAT_TLV_DL_TLP
291 {
292    UCHAR  TLVType;         // 0x11, Uplink TLP Setting
293    USHORT TLVLength;       // 1
294    UCHAR  DlTlpSetting;    // 0x0: Disable; 0x01: Enable
295 } QMICTL_SET_DATA_FORMAT_TLV_DL_TLP, *PQMICTL_SET_DATA_FORMAT_TLV_DL_TLP;
296 #endif // QCMP_DL_TLP
297 
298 #endif // QC_IP_MODE
299 
300 #ifdef MP_QCQOS_ENABLED
301 #define SET_DATA_FORMAT_TLV_TYPE_QOS_SETTING 0x12
302 typedef struct _QMICTL_SET_DATA_FORMAT_TLV_QOS_SETTING
303 {
304    UCHAR  TLVType;       // 0x12, QoS setting
305    USHORT TLVLength;     // 1
306    UCHAR  QosSetting;    // 0x0: Disable; 0x01: Enable
307 } QMICTL_SET_DATA_FORMAT_TLV_QOS_SETTING, *PQMICTL_SET_DATA_FORMAT_TLV_QOS_SETTING;
308 #endif // MP_QCQOS_ENABLED
309 
310 typedef struct _QMICTL_SET_DATA_FORMAT_RESP_MSG
311 {
312    UCHAR  CtlFlags;        // QMICTL_FLAG_RESPONSE
313    UCHAR  TransactionId;
314    USHORT QMICTLType;      // QMICTL_SET_DATA_FORMAT_RESP
315    USHORT Length;
316    UCHAR  TLVType;         // QCTLV_TYPE_RESULT_CODE
317    USHORT TLVLength;       // 0x0004
318    USHORT QMIResult;       // result code
319    USHORT QMIError;        // error code
320 } __attribute__ ((packed)) QMICTL_SET_DATA_FORMAT_RESP_MSG, *PQMICTL_SET_DATA_FORMAT_RESP_MSG;
321 
322 typedef struct _QMICTL_SYNC_REQ_MSG
323 {
324    UCHAR  CtlFlags;        // QMICTL_FLAG_REQUEST
325    UCHAR  TransactionId;
326    USHORT QMICTLType;      // QMICTL_CTL_SYNC_REQ
327    USHORT Length;          // 0
328 } __attribute__ ((packed)) QMICTL_SYNC_REQ_MSG, *PQMICTL_SYNC_REQ_MSG;
329 
330 typedef struct _QMICTL_SYNC_RESP_MSG
331 {
332    UCHAR  CtlFlags;        // QMICTL_FLAG_RESPONSE
333    UCHAR  TransactionId;
334    USHORT QMICTLType;      // QMICTL_CTL_SYNC_RESP
335    USHORT Length;
336    UCHAR  TLVType;         // QCTLV_TYPE_RESULT_CODE
337    USHORT TLVLength;       // 0x0004
338    USHORT QMIResult;
339    USHORT QMIError;
340 } __attribute__ ((packed)) QMICTL_SYNC_RESP_MSG, *PQMICTL_SYNC_RESP_MSG;
341 
342 typedef struct _QMICTL_SYNC_IND_MSG
343 {
344    UCHAR  CtlFlags;        // QMICTL_FLAG_INDICATION
345    UCHAR  TransactionId;
346    USHORT QMICTLType;      // QMICTL_REVOKE_CLIENT_ID_IND
347    USHORT Length;
348 } __attribute__ ((packed)) QMICTL_SYNC_IND_MSG, *PQMICTL_SYNC_IND_MSG;
349 
350 typedef struct _QMICTL_LIBQMI_PROXY_OPEN_MSG
351 {
352    UCHAR  CtlFlags;        // QMICTL_FLAG_RESPONSE
353    UCHAR  TransactionId;
354    USHORT QMICTLType;      // QMICTL_SET_DATA_FORMAT_RESP
355    USHORT Length;
356    UCHAR  TLVType;         // QCTLV_TYPE_RESULT_CODE
357    USHORT TLVLength;       // 0x0004
358    char device_path[0];       // result code
359 } __attribute__ ((packed)) QMICTL_LIBQMI_PROXY_OPEN_MSG, *PQMICTL_LIBQMI_PROXY_OPEN_MSG;
360 
361 typedef struct _QMICTL_MSG
362 {
363    union
364    {
365       // Message Header
366       QCQMICTL_MSG_HDR                             QMICTLMsgHdr;
367       QCQMICTL_MSG_HDR_RESP                             QMICTLMsgHdrRsp;
368 
369       // QMICTL Message
370       QMICTL_SET_INSTANCE_ID_REQ_MSG               SetInstanceIdReq;
371       QMICTL_SET_INSTANCE_ID_RESP_MSG              SetInstanceIdRsp;
372       QMICTL_GET_VERSION_REQ_MSG                   GetVersionReq;
373       QMICTL_GET_VERSION_RESP_MSG                  GetVersionRsp;
374       QMICTL_GET_CLIENT_ID_REQ_MSG                 GetClientIdReq;
375       QMICTL_GET_CLIENT_ID_RESP_MSG                GetClientIdRsp;
376       QMICTL_RELEASE_CLIENT_ID_REQ_MSG             ReleaseClientIdReq;
377       QMICTL_RELEASE_CLIENT_ID_RESP_MSG            ReleaseClientIdRsp;
378       QMICTL_REVOKE_CLIENT_ID_IND_MSG              RevokeClientIdInd;
379       QMICTL_INVALID_CLIENT_ID_IND_MSG             InvalidClientIdInd;
380       QMICTL_SET_DATA_FORMAT_REQ_MSG               SetDataFormatReq;
381       QMICTL_SET_DATA_FORMAT_RESP_MSG              SetDataFormatRsp;
382       QMICTL_SYNC_REQ_MSG                          SyncReq;
383       QMICTL_SYNC_RESP_MSG                         SyncRsp;
384       QMICTL_SYNC_IND_MSG                          SyncInd;
385       QMICTL_LIBQMI_PROXY_OPEN_MSG          LibQmiProxyOpenReq;
386    };
387 } __attribute__ ((packed)) QMICTL_MSG, *PQMICTL_MSG;
388 #pragma pack(pop)
389 
390 #endif // MPQCTL_H
391